laymur 0.2.15 → 0.2.16
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/index.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.min.js","sources":["../src/miscellaneous/UIExpression.ts","../node_modules/eventail/dist/index.min.js","../src/miscellaneous/UIMode.ts","../src/miscellaneous/UIOrientation.ts","../node_modules/@lume/kiwi/dist/maptype.js","../node_modules/@lume/kiwi/dist/variable.js","../node_modules/@lume/kiwi/dist/expression.js","../node_modules/@lume/kiwi/dist/strength.js","../node_modules/@lume/kiwi/dist/constraint.js","../node_modules/@lume/kiwi/dist/solver.js","../src/miscellaneous/UIPriority.ts","../src/miscellaneous/UIAnchorMode.ts","../src/wrappers/UISceneWrapper.ts","../src/miscellaneous/UIRelation.ts","../src/layers/UILayer.ts","../src/wrappers/UISolverWrapper.ts","../src/constraints/UIConstraint.ts","../src/constraints/UISingleParameterConstraint.ts","../src/constraints/UIHeightConstraint.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/builders/UICoverConstraintBuilder.ts","../src/builders/UIFitConstraintBuilder.ts","../src/constraints/UICustomConstraint.ts","../src/elements/UIAnchor.ts","../src/elements/UIDummy.ts","../src/miscellaneous/UIMicro.ts","../src/elements/UIElement.ts","../src/materials/UIMaterial.ts","../src/miscellaneous/threeInstances.ts","../src/elements/UIImage.ts","../src/materials/UINineSliceMaterial.ts","../src/miscellaneous/UINineSliceBorder.ts","../src/elements/UINineSline.ts","../src/materials/UIProgressMaterial.ts","../src/elements/UIProgress.ts","../src/elements/UIScene.ts","../src/miscellaneous/UITextStyle.ts","../src/miscellaneous/textTools.ts","../src/miscellaneous/UITextPadding.ts","../src/elements/UIText.ts","../src/layers/UIFullscreenLayer.ts","../src/miscellaneous/UITextSpan.ts"],"sourcesContent":["/**\n * Mathematical expression builder for constraint equations in the UI layout system.\n *\n * UIExpression represents linear mathematical expressions of the form:\n * constant + coefficient₁ × variable₁ + coefficient₂ × variable₂ + ... + coefficientₙ × variableₙ\n *\n * These expressions are used to build constraint equations for the Kiwi solver,\n * enabling complex mathematical relationships between UI element properties.\n * Variables are referenced by their numeric descriptors from the solver system.\n *\n * @see {@link UIConstraint} - Constraints that use expressions\n * @see {@link UISolverWrapper} - Solver integration that creates variables\n */\nexport class UIExpression {\n /** The constant term of the expression. */\n public constant: number;\n /** Map of variable descriptors to their coefficients in the expression. */\n private readonly terms: Map<number, number>;\n\n /**\n * Creates a new UIExpression instance.\n *\n * @param constant - The constant term of the expression (defaults to 0)\n * @param terms - Optional array of [variableDescriptor, coefficient] pairs\n */\n constructor(constant = 0, terms?: [number, number][]) {\n this.constant = constant;\n this.terms = terms ? new Map(terms) : new Map();\n }\n\n /**\n * Creates a new expression that represents the sum of two expressions.\n *\n * Performs mathematical addition: (a.constant + a.terms) + (b.constant + b.terms)\n * Coefficients for the same variables are combined.\n *\n * @param a - The first expression\n * @param b - The second expression\n * @returns A new expression representing a + b\n */\n public static plus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant + b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.plus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Creates a new expression that represents the difference of two expressions.\n *\n * Performs mathematical subtraction: (a.constant + a.terms) - (b.constant + b.terms)\n * Coefficients for the same variables are combined with subtraction.\n *\n * @param a - The first expression (minuend)\n * @param b - The second expression (subtrahend)\n * @returns A new expression representing a - b\n */\n public static minus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant - b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.minus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Adds a variable term to this expression (mutating operation).\n *\n * If the variable already exists in the expression, its coefficient is\n * increased by the specified amount. Otherwise, a new term is added.\n *\n * @param variableIndex - The variable descriptor from the solver\n * @param coefficient - The coefficient to add for this variable\n * @returns This expression instance for method chaining\n */\n public plus(variableIndex: number, coefficient: number): this {\n this.terms.set(\n variableIndex,\n (this.terms.get(variableIndex) ?? 0) + coefficient,\n );\n return this;\n }\n\n /**\n * Subtracts a variable term from this expression (mutating operation).\n *\n * If the variable already exists in the expression, its coefficient is\n * decreased by the specified amount. Otherwise, a new term with negative\n * coefficient is added.\n *\n * @param variableIndex - The variable descriptor from the solver\n * @param coefficient - The coefficient to subtract for this variable\n * @returns This expression instance for method chaining\n */\n public minus(variableIndex: number, coefficient: number): this {\n return this.plus(variableIndex, -coefficient);\n }\n\n /**\n * Multiplies all terms in this expression by a scalar value (mutating operation).\n *\n * Both the constant term and all variable coefficients are multiplied\n * by the specified value.\n *\n * @param value - The scalar value to multiply by\n * @returns This expression instance for method chaining\n */\n public multiply(value: number): this {\n this.constant *= value;\n for (const [variableIndex, coefficient] of this.terms) {\n this.terms.set(variableIndex, coefficient * value);\n }\n return this;\n }\n\n /**\n * Divides all terms in this expression by a scalar value (mutating operation).\n *\n * Both the constant term and all variable coefficients are divided\n * by the specified value.\n *\n * @param value - The scalar value to divide by (must not be zero)\n * @returns This expression instance for method chaining\n */\n public divide(value: number): this {\n return this.multiply(1 / value);\n }\n\n /**\n * Checks if the expression contains a term for the specified variable.\n *\n * @param variableIndex - The variable descriptor to check for\n * @returns True if the expression has a term for this variable, false otherwise\n */\n public hasTerm(variableIndex: number): boolean {\n return this.terms.has(variableIndex);\n }\n\n /**\n * Copies the content of another expression into this expression (mutating operation).\n *\n * Replaces all terms and the constant of this expression with those\n * from the source expression.\n *\n * @param expression - The source expression to copy from\n * @returns This expression instance for method chaining\n */\n public copy(expression: UIExpression): this {\n this.constant = expression.constant;\n this.terms.clear();\n for (const [variableIndex, coefficient] of expression.terms) {\n this.terms.set(variableIndex, coefficient);\n }\n return this;\n }\n\n /**\n * Creates a deep copy of this expression.\n *\n * The returned expression is completely independent and can be modified\n * without affecting the original.\n *\n * @returns A new UIExpression instance with the same content\n */\n public clone(): UIExpression {\n return new UIExpression(this.constant, Array.from(this.terms.entries()));\n }\n\n /**\n * Prepares the variable terms for internal solver operations.\n *\n * Converts the internal terms map to an array format suitable for\n * integration with the constraint solver system.\n *\n * @returns Array of [variableDescriptor, coefficient] pairs\n * @internal\n */\n protected [\"prepareTermsInternal\"](): [number, number][] {\n return Array.from(this.terms.entries());\n }\n}\n","class t{constructor(t,i,r=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,r):this.t.set(i,new Map([[t,r]])))}insert(t,i,r=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,r)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,r]])):s.has(t)||s.set(t,r)}remove(t,i){if(void 0===i)return void this.i.delete(t);const r=this.t.get(i);void 0!==r&&(r.delete(t),0===r.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const r=this.t.get(i);return void 0!==r&&r.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const r=this.t.get(i);return void 0!==r?r.get(t):void 0}}class i{constructor(){this.o=new Map}on(t,i,r,s=0){return this.h(t,!1,s,i,r),this}once(t,i,r,s=0){return this.h(t,!0,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=!1,s.v=s.v.slice());const o=s.v;if(0===o.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;t<o.length;t++){const i=o[t];s.l.remove(i._,i.p)}return this}{const e=o.length;if(o[0]._===i&&o[0].p===r)return 1===e?this.o.delete(t):o.shift(),this;const n=e-1;if(o[n]._===i&&o[n].p===r)return o.pop(),this;if(e<10||o[0].M===o[n].M)for(let t=1;t<n;t++){const s=o[t];if(s._===i&&s.p===r)return o.splice(t,1),this}else{const t=s.l.getPriority(i,r);if(void 0===t)return this;let e=0,n=o.length-1;for(;e<=n;){const i=e+n>>>1;o[i].M<t?e=i+1:n=i-1}const c=e;for(n=o.length-1;e<=n;){const i=e+n>>>1;o[i].M<=t?e=i+1:n=i-1}const h=n;for(let t=c;t<=h;t++)if(o[t]._===i&&o[t].p===r)return o.splice(t,1),this}}return this}emit(t,...i){const r=this.o.get(t);if(void 0===r)return!1;if(0===r.v.length)return!1;r.u?r.v=r.v.slice():r.u=!0;const s=r.v;let o=!1;for(let t=0;t<s.length;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=!0,r.m=!0)}const e=this.o.get(t);if(void 0===e)return!0;e.v===s&&(e.u=!1);const n=e.v;if(o){let i=0;for(let t=0;t<n.length;t++){const r=n[t];r.m?e.l.remove(r._,r.p):n[i++]=r}0===i?this.o.delete(t):n.length=i}return!0}h(i,r,s,o,e){let n=this.o.get(i);if(void 0===n)return void this.o.set(i,{v:[{_:o,p:e,M:s,k:r,m:!1}],u:!1,l:new t(o,e,s)});if(n.l.has(o,e))throw Error(\"Event listener already exists\");n.l.insert(o,e,s);const c={_:o,p:e,M:s,k:r,m:!1};n.u&&(n.u=!1,n.v=n.v.slice());{const t=n.v,i=c.M;if(0===t.length||t[t.length-1].M<=i)return void t.push(c);if(t[0].M>=i)return void t.unshift(c);{let r=0,s=t.length;for(;r<s;){const o=r+s>>>1;t[o].M<i?r=o+1:s=o}t.splice(r,0,c)}}}}export{i as Eventail};\n//# sourceMappingURL=index.min.js.map\n","/**\n * Defines the visibility and interactivity state of UI elements.\n *\n * UI elements can be in one of three states:\n * - Hidden: Element is not visible and does not receive input\n * - Visible: Element is visible but does not receive input\n * - Interactive: Element is visible and can receive input events\n */\nexport enum UIMode {\n /**\n * Element is not rendered and does not receive input events.\n * Equivalent to setting `display: none` in CSS.\n */\n HIDDEN = 0,\n\n /**\n * Element is rendered but does not receive input events.\n * Equivalent to setting `pointer-events: none` in CSS.\n */\n VISIBLE = 1,\n\n /**\n * Element is rendered and can receive input events.\n * This is the fully active state for UI elements.\n */\n INTERACTIVE = 2,\n}\n","/**\n * Defines the screen orientation states for UI constraints.\n *\n * This enum is used to specify when certain UI constraints should be active\n * based on the current device/screen orientation.\n */\nexport enum UIOrientation {\n /**\n * Indicates a landscape orientation (width > height).\n * Constraints using this value will only be active in landscape mode.\n */\n HORIZONTAL = 0,\n\n /**\n * Indicates a portrait orientation (height > width).\n * Constraints using this value will only be active in portrait mode.\n */\n VERTICAL = 1,\n\n /**\n * Indicates that the constraint should always be active,\n * regardless of screen orientation.\n */\n ALWAYS = 2,\n}\n\n/**\n * Resolves an optional orientation to a definite value.\n *\n * @param orientation - The orientation to resolve, or undefined\n * @returns The provided orientation, or ALWAYS if none was provided\n */\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","export function createMap() {\n return new IndexedMap();\n}\nclass IndexedMap {\n index = {};\n array = [];\n /**\n * Returns the number of items in the array.\n */\n size() {\n return this.array.length;\n }\n /**\n * Returns true if the array is empty.\n */\n empty() {\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 itemAt(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 contains(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 find(key) {\n const 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 setDefault(key, factory) {\n const i = this.index[key.id()];\n if (i === undefined) {\n const 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 insert(key, value) {\n const pair = new Pair(key, value);\n const 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 erase(key) {\n const i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n const pair = this.array[i];\n const 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 copy() {\n const copy = new IndexedMap();\n for (let i = 0; i < this.array.length; i++) {\n const pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n }\n}\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nclass Pair {\n first;\n second;\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 constructor(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n copy() {\n return new Pair(this.first, this.second);\n }\n}\n","import { Expression } from './expression.js';\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nexport class Variable {\n constructor(name = '') {\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n id() {\n return this._id;\n }\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n name() {\n return this._name;\n }\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n setName(name) {\n this._name = name;\n }\n /**\n * Returns the user context object of the variable.\n * @private\n */\n context() {\n return this._context;\n }\n /**\n * Set the user context object of the variable.\n * @private\n */\n setContext(context) {\n this._context = context;\n }\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n value() {\n return this._value;\n }\n /**\n * Set the value of the variable.\n * @private\n */\n setValue(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 plus(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 minus(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 multiply(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 divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n toJSON() {\n return {\n name: this._name,\n value: this._value,\n };\n }\n toString() {\n return this._context + '[' + this._name + ':' + this._value + ']';\n }\n _name;\n _value = 0.0;\n _context = null;\n _id = VarId++;\n}\n/**\n * The internal variable id counter.\n * @private\n */\nlet VarId = 0;\n","import { createMap } from './maptype.js';\nimport { Variable } from './variable.js';\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 */\nexport class Expression {\n constructor() {\n let 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 terms() {\n return this._terms;\n }\n /**\n * Returns the constant of the expression.\n * @private\n */\n constant() {\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 value() {\n let result = this._constant;\n for (let i = 0, n = this._terms.size(); i < n; i++) {\n let 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 plus(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 minus(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 multiply(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 divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n isConstant() {\n return this._terms.size() == 0;\n }\n toString() {\n let result = this._terms.array\n .map(function (pair) {\n return pair.second + '*' + pair.first.toString();\n })\n .join(' + ');\n if (!this.isConstant() && this._constant !== 0) {\n result += ' + ';\n }\n result += this._constant;\n return result;\n }\n _terms;\n _constant;\n}\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n let constant = 0.0;\n let factory = () => 0.0;\n let terms = createMap();\n for (let i = 0, n = args.length; i < n; ++i) {\n let 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 let terms2 = item.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let 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 let value = item[0];\n let 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 let terms2 = value2.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let 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, constant };\n}\n","/**\n * @class Strength\n */\nexport class Strength {\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 static create(a, b, c, w = 1.0) {\n let 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 * The 'required' symbolic strength.\n */\n static required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n static strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n static medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n static weak = Strength.create(0.0, 0.0, 1.0);\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n static clip(value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n }\n}\n","import { Expression } from './expression.js';\nimport { Strength } from './strength.js';\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 */\nexport class Constraint {\n constructor(expression, operator, rhs, strength = Strength.required) {\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 id() {\n return this._id;\n }\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n expression() {\n return this._expression;\n }\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n op() {\n return this._operator;\n }\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n strength() {\n return this._strength;\n }\n toString() {\n return (this._expression.toString() + ' ' + ['<=', '>=', '='][this._operator] + ' 0 (' + this._strength.toString() + ')');\n }\n _expression;\n _operator;\n _strength;\n _id = CnId++;\n}\n/**\n * The internal constraint id counter.\n * @private\n */\nlet CnId = 0;\n","import { Constraint, Operator } from './constraint.js';\nimport { Expression } from './expression.js';\nimport { createMap } from './maptype.js';\nimport { Strength } from './strength.js';\n/**\n * The constraint solver class.\n *\n * @class\n */\nexport class Solver {\n /**\n * @type {number} - The max number of solver iterations before an error\n * is thrown, in order to prevent infinite iteration. Default: `10,000`.\n */\n maxIterations = 1000;\n /**\n * Construct a new Solver.\n */\n constructor() { }\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 createConstraint(lhs, operator, rhs, strength = Strength.required) {\n let 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 addConstraint(constraint) {\n let 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 let data = this._createRow(constraint);\n let row = data.row;\n let tag = data.tag;\n let 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 removeConstraint(constraint) {\n let 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 let marker = cnPair.second.marker;\n let rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n let 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 hasConstraint(constraint) {\n return this._cnMap.contains(constraint);\n }\n /**\n * Get an array of the current constraints.\n *\n * @return {Constraint[]}\n */\n getConstraints() {\n return this._cnMap.array.map(({ first }) => first);\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 addEditVariable(variable, strength) {\n let 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 let expr = new Expression(variable);\n let cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n let tag = this._cnMap.find(cn).second;\n let info = { 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 removeEditVariable(variable) {\n let 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 hasEditVariable(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 suggestValue(variable, value) {\n let editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error('unknown edit variable');\n }\n let rows = this._rowMap;\n let info = editPair.second;\n let delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n let marker = info.tag.marker;\n let 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 let 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 (let i = 0, n = rows.size(); i < n; ++i) {\n let rowPair = rows.itemAt(i);\n let row = rowPair.second;\n let coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 && rowPair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair.first);\n }\n }\n this._dualOptimize();\n }\n /**\n * Update the values of the variables.\n */\n updateVariables() {\n let vars = this._varMap;\n let rows = this._rowMap;\n for (let i = 0, n = vars.size(); i < n; ++i) {\n let pair = vars.itemAt(i);\n let 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 _getVarSymbol(variable) {\n let factory = () => 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 _createRow(constraint) {\n let expr = constraint.expression();\n let row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n let terms = expr.terms();\n for (let i = 0, n = terms.size(); i < n; ++i) {\n let termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n let symbol = this._getVarSymbol(termPair.first);\n let 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 let objective = this._objective;\n let strength = constraint.strength();\n let tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge: {\n let coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n let slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n let 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 if (strength < Strength.required) {\n let errplus = this._makeSymbol(SymbolType.Error);\n let 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 let 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, 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 _chooseSubject(row, tag) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n let 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 _addWithArtificialVariable(row) {\n // Create and add the artificial variable to the tableau.\n let 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 let 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 let pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n let basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n let 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 let rows = this._rowMap;\n for (let 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 _substitute(symbol, row) {\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 && 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 _optimize(objective) {\n let iterations = 0;\n while (iterations < this.maxIterations) {\n let entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n let 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 let row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n iterations++;\n }\n throw new Error('solver iterations exceeded');\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 _dualOptimize() {\n let rows = this._rowMap;\n let infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n let leaving = infeasible.pop();\n let pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n let 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 let 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 _getEnteringSymbol(objective) {\n let cells = objective.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let 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 _getDualEnteringSymbol(row) {\n let ratio = Number.MAX_VALUE;\n let entering = INVALID_SYMBOL;\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let symbol = pair.first;\n let c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n let coeff = this._objective.coefficientFor(symbol);\n let 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 _getLeavingSymbol(entering) {\n let ratio = Number.MAX_VALUE;\n let found = INVALID_SYMBOL;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n let row = pair.second;\n let temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n let 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 _getMarkerLeavingSymbol(marker) {\n let dmax = Number.MAX_VALUE;\n let r1 = dmax;\n let r2 = dmax;\n let invalid = INVALID_SYMBOL;\n let first = invalid;\n let second = invalid;\n let third = invalid;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let row = pair.second;\n let c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n let symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n let r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n let 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 _removeConstraintEffects(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 _removeMarkerEffects(marker, strength) {\n let 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 _anyPivotableSymbol(row) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let 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 _makeSymbol(type) {\n return new Symbol(type, this._idTick++);\n }\n _cnMap = createCnMap();\n _rowMap = createRowMap();\n _varMap = createVarMap();\n _editMap = createEditMap();\n _infeasibleRows = [];\n _objective = new Row();\n _artificial = null;\n _idTick = 0;\n}\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n let 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 */\nclass Symbol {\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 constructor(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n id() {\n return this._id;\n }\n /**\n * Returns the type of the symbol.\n */\n type() {\n return this._type;\n }\n _id;\n _type;\n}\n/**\n * A static invalid symbol\n * @private\n */\nlet INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nclass Row {\n /**\n * Construct a new Row.\n */\n constructor(constant = 0.0) {\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n cells() {\n return this._cellMap;\n }\n /**\n * Returns the constant for the row.\n */\n constant() {\n return this._constant;\n }\n /**\n * Returns true if the row is a constant value.\n */\n isConstant() {\n return this._cellMap.empty();\n }\n /**\n * Returns true if the Row has all dummy symbols.\n */\n allDummies() {\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let 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 copy() {\n let 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 add(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 insertSymbol(symbol, coefficient = 1.0) {\n let pair = this._cellMap.setDefault(symbol, () => 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 insertRow(other, coefficient = 1.0) {\n this._constant += other._constant * coefficient;\n let cells = other._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n }\n /**\n * Remove a symbol from the row.\n */\n removeSymbol(symbol) {\n this._cellMap.erase(symbol);\n }\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n reverseSign() {\n this._constant = -this._constant;\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let 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 solveFor(symbol) {\n let cells = this._cellMap;\n let pair = cells.erase(symbol);\n let coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (let 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 solveForEx(lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n }\n /**\n * Returns the coefficient for the given symbol.\n */\n coefficientFor(symbol) {\n let 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 substitute(symbol, row) {\n let pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n }\n _cellMap = createMap();\n _constant;\n}\n","import { Strength } from \"@lume/kiwi\";\n\n/** High priority value for constraint solver strength calculations. */\nconst HIGH_PRIORITY = 1000;\n/** Medium priority value for constraint solver strength calculations. */\nconst MEDIUM_PRIORITY = 100;\n/** Low priority value for constraint solver strength calculations. */\nconst LOW_PRIORITY = 10;\n\n/**\n * Priority levels for UI layout constraints and variables.\n *\n * UIPriority defines a hierarchical system of priority levels used by the\n * constraint solver to determine which constraints should take precedence\n * when conflicts arise. Lower numeric values represent higher priority,\n * with P0 being the highest priority and P7 being the lowest.\n *\n * The priority system maps to Kiwi solver strength values with different\n * strength components (required, strong, medium, weak) to create a nuanced\n * priority hierarchy for layout solving.\n *\n * @see {@link convertPriority} - Converts to Kiwi solver strength values\n */\nexport enum UIPriority {\n /** Highest priority - required constraints that must be satisfied. */\n P0 = 0,\n /** High priority - strong constraints with medium strength. */\n P1 = 1,\n /** Medium-high priority - strong constraints with low strength. */\n P2 = 2,\n /** Medium priority - medium strength constraints. */\n P3 = 3,\n /** Medium-low priority - medium strength constraints with low weight. */\n P4 = 4,\n /** Low priority - weak strength constraints with medium weight. */\n P5 = 5,\n /** Very low priority - weak strength constraints with low weight. */\n P6 = 6,\n /** Lowest priority - weak strength constraints with minimal weight. */\n P7 = 7,\n}\n\n/**\n * Converts UIPriority enum values to Kiwi solver strength values.\n *\n * This function maps the UI priority levels to the three-component strength\n * system used by the Kiwi constraint solver (required, strong, medium, weak).\n * Higher priority levels get stronger constraint strength values.\n *\n * @param priority - The UI priority level to convert\n * @returns The corresponding Kiwi solver strength value\n * @throws Will throw an error if an invalid priority is provided\n * @see {@link UIPriority} - Priority level definitions\n */\nexport function convertPriority(priority: UIPriority): number {\n switch (priority) {\n case UIPriority.P0:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIPriority.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIPriority.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIPriority.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIPriority.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIPriority.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIPriority.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIPriority.P7:\n return Strength.create(0, 0, 1);\n default:\n throw new Error(`Invalid priority: ${priority}`);\n }\n}\n\n/**\n * Resolves an optional priority value to a concrete UIPriority.\n *\n * If no priority is provided, returns the default highest priority (P0).\n * This function is commonly used in constraint creation where priority\n * is an optional parameter.\n *\n * @param priority - The optional priority value to resolve\n * @returns The resolved priority, defaulting to P0 if undefined\n */\nexport function resolvePriority(priority?: UIPriority): UIPriority {\n return priority ?? UIPriority.P0;\n}\n","/**\n * Defines the anchor mode for UIMicro, determining which transformations are applied around the anchor point.\n */\nexport enum UIAnchorMode {\n /** Rotation and scaling are applied around the anchor point */\n ROTATION_SCALE = 0,\n /** Position, rotation, and scaling transformations are all applied around the anchor point */\n POSITION_ROTATION_SCALE = 1,\n}\n","import type { Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIElement } from \"../elements/UIElement\";\nimport { UIAnchorMode } from \"../miscellaneous/UIAnchorMode\";\n\nlet originalClearColor: Color = new Color();\nlet originalClearAlpha = 0;\nlet originalAutoClear = false;\nlet originalAutoClearColor = false;\nlet originalAutoClearDepth = false;\nlet originalAutoClearStencil = false;\n\nexport class UISceneWrapper {\n private readonly scene = new Scene();\n private readonly camera: OrthographicCamera;\n private readonly elements = new Map<UIElement, Object3D>();\n\n constructor(w: number, h: number) {\n this.camera = new OrthographicCamera(0, w, h, 0, -1, 1);\n }\n\n public insertObject(element: UIElement, object: Object3D): void {\n if (this.elements.has(element)) {\n throw new Error(\"Element already exists\");\n }\n this.elements.set(element, object);\n this.scene.add(object);\n }\n\n public replaceObject(element: UIElement, object: Object3D): void {\n const oldObject = this.elements.get(element);\n if (oldObject === undefined) {\n throw new Error(\"Element not found\");\n }\n\n this.scene.remove(oldObject);\n this.scene.add(object);\n this.elements.set(element, object);\n }\n\n public removeObject(element: UIElement): void {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n this.scene.remove(object);\n this.elements.delete(element);\n }\n\n public resize(w: number, h: number): void {\n this.camera.right = w;\n this.camera.top = h;\n this.camera.updateProjectionMatrix();\n }\n\n public getVisibility(element: UIElement): boolean {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n return object.visible;\n }\n\n public getZIndex(element: UIElement): number {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n return object.renderOrder;\n }\n\n public setZIndex(element: UIElement, zIndex: number): void {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n object.renderOrder = zIndex;\n }\n\n public setVisibility(element: UIElement, visible: boolean): void {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n object.visible = visible;\n }\n\n public getSortedVisibleElements(): UIElement[] {\n return Array.from(this.elements.keys()).sort(\n (a, b) => this.getZIndex(a) - this.getZIndex(b),\n );\n }\n\n public prepareRender(renderer: WebGLRenderer): void {\n originalClearColor = renderer.getClearColor(originalClearColor);\n originalClearAlpha = renderer.getClearAlpha();\n originalAutoClear = renderer.autoClear;\n originalAutoClearColor = renderer.autoClearColor;\n originalAutoClearDepth = renderer.autoClearDepth;\n originalAutoClearStencil = renderer.autoClearStencil;\n\n renderer.autoClear = false;\n renderer.autoClearColor = false;\n renderer.autoClearDepth = false;\n renderer.autoClearStencil = false;\n renderer.setClearColor(0x000000, 1);\n\n for (const [element, object] of this.elements) {\n const micro = element.micro;\n\n const width = element.width * micro.scaleX;\n const height = element.height * micro.scaleY;\n\n const anchorOffsetX = micro.anchorX * width;\n const anchorOffsetY = micro.anchorY * height;\n\n const cos = Math.cos(micro.rotation);\n const sin = Math.sin(micro.rotation);\n\n const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;\n const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;\n\n if (micro.anchorMode === UIAnchorMode.POSITION_ROTATION_SCALE) {\n object.position.x = element.x + micro.x - rotatedAnchorX;\n object.position.y = element.y + micro.y - rotatedAnchorY;\n } else {\n const rawAnchorOffsetX = micro.anchorX * element.width;\n const rawAnchorOffsetY = micro.anchorY * element.height;\n object.position.x =\n element.x + rawAnchorOffsetX - rotatedAnchorX + micro.x;\n object.position.y =\n element.y + rawAnchorOffsetY - rotatedAnchorY + micro.y;\n }\n\n object.scale.x = width;\n object.scale.y = height;\n object.rotation.z = micro.rotation;\n }\n }\n\n public render(renderer: WebGLRenderer): void {\n renderer.clear(false, true, true);\n renderer.render(this.scene, this.camera);\n\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.autoClear = originalAutoClear;\n renderer.autoClearColor = originalAutoClearColor;\n renderer.autoClearDepth = originalAutoClearDepth;\n renderer.autoClearStencil = originalAutoClearStencil;\n }\n}\n","import { Operator } from \"@lume/kiwi\";\n\n/**\n * Relational operators for UI layout constraints.\n *\n * UIRelation defines the mathematical relationship between the left-hand\n * and right-hand sides of constraint equations. These relations are used\n * by the constraint solver to determine how expressions should be compared\n * when solving layout constraints.\n *\n * @see {@link convertRelation} - Converts to Kiwi solver operators\n */\nexport enum UIRelation {\n /** Equality relation: left-hand side equals right-hand side. */\n EQUAL = 0,\n /** Less than or equal relation: left-hand side ≤ right-hand side. */\n LESS_THAN = 1,\n /** Greater than or equal relation: left-hand side ≥ right-hand side. */\n GREATER_THAN = 2,\n}\n\n/**\n * Converts UIRelation enum values to Kiwi solver operator values.\n *\n * This function maps the UI relation types to the corresponding operators\n * used by the Kiwi constraint solver for mathematical comparisons in\n * constraint equations.\n *\n * @param relation - The UI relation type to convert\n * @returns The corresponding Kiwi solver operator\n * @throws Will throw an error if an invalid relation is provided\n * @see {@link UIRelation} - Relation type definitions\n */\nexport function convertRelation(relation: UIRelation): Operator {\n switch (relation) {\n case UIRelation.EQUAL:\n return Operator.Eq;\n case UIRelation.LESS_THAN:\n return Operator.Le;\n case UIRelation.GREATER_THAN:\n return Operator.Ge;\n default:\n throw new Error(`Invalid relation: ${relation}`);\n }\n}\n\n/**\n * Resolves an optional relation value to a concrete UIRelation.\n *\n * If no relation is provided, returns the default equality relation.\n * This function is commonly used in constraint creation where relation\n * is an optional parameter.\n *\n * @param relation - The optional relation value to resolve\n * @returns The resolved relation, defaulting to EQUAL if undefined\n */\nexport function resolveRelation(relation?: UIRelation): UIRelation {\n return relation ?? UIRelation.EQUAL;\n}\n","import { Eventail } from \"eventail\";\nimport { type WebGLRenderer } from \"three\";\nimport { UIMode } from \"../miscellaneous/UIMode\";\nimport { UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UISceneWrapper } from \"../wrappers/UISceneWrapper\";\nimport { UISolverWrapper } from \"../wrappers/UISolverWrapper\";\n\n/**\n * Events that can be emitted by UI layers.\n */\nexport enum UILayerEvent {\n /** Emitted when the layer's orientation changes between horizontal and vertical. */\n ORIENTATION_CHANGE = \"orientation_change\",\n /** Emitted when the layer's visibility/interaction mode changes. */\n MODE_CHANGE = \"mode_change\",\n /** Emitted before the layer is rendered. */\n WILL_RENDER = \"will_render\",\n}\n\n/**\n * Abstract base class for UI layout containers with constraint solving and rendering.\n *\n * UILayer serves as the fundamental container for UI elements, providing constraint-based\n * layout solving, 3D scene management, and event handling. It manages the layer's\n * dimensions through solver variables, handles orientation changes, and coordinates\n * rendering and interaction for all contained elements.\n *\n * Each layer maintains its own constraint solver and scene graph, allowing for\n * independent layout calculation and rendering optimization.\n *\n * @see {@link UIElement} - Elements contained within layers\n * @see {@link UISolverWrapper} - Constraint solving system\n * @see {@link UISceneWrapper} - 3D scene management\n * @see {@link UIOrientation} - Layer orientation states\n */\nexport abstract class UILayer extends Eventail {\n /** Optional name identifier for the layer. */\n public name = \"\";\n\n /**\n * Solver variable descriptor for the x-coordinate position.\n * This variable is managed by the constraint solver system.\n */\n public readonly xVariable: number;\n\n /**\n * Solver variable descriptor for the y-coordinate position.\n * This variable is managed by the constraint solver system.\n */\n public readonly yVariable: number;\n\n /**\n * Solver variable descriptor for the width dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly wVariable: number;\n\n /**\n * Solver variable descriptor for the height dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly hVariable: number;\n\n /**\n * Constraint solver wrapper for managing layout calculations.\n * @see {@link UISolverWrapper}\n */\n protected readonly solverWrapper = new UISolverWrapper();\n\n /**\n * 3D scene wrapper for managing rendering and element hierarchy.\n * @see {@link UISceneWrapper}\n */\n protected readonly sceneWrapper: UISceneWrapper;\n\n /** Internal storage for the current visibility/interaction mode. */\n protected modeInternal: UIMode = UIMode.VISIBLE;\n\n /** Internal storage for the current orientation state. */\n protected orientationInternal: UIOrientation;\n\n /**\n * Creates a new UILayer instance with specified dimensions.\n *\n * Initializes the constraint solver with position and dimension variables,\n * sets up the 3D scene wrapper, and determines the initial orientation\n * based on the width-to-height ratio.\n *\n * @param w - Initial width of the layer\n * @param h - Initial height of the layer\n */\n constructor(w: number, h: number) {\n super();\n this.sceneWrapper = new UISceneWrapper(w, h);\n this.xVariable = this.solverWrapper.createVariable(0, UIPriority.P0);\n this.yVariable = this.solverWrapper.createVariable(0, UIPriority.P0);\n this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P0);\n this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P0);\n this.orientationInternal =\n w > h ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n }\n\n /**\n * Gets the current width value from the constraint solver.\n * @returns The current layer width in pixels\n */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /**\n * Gets the current height value from the constraint solver.\n * @returns The current layer height in pixels\n */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /**\n * Gets the current visibility and interaction mode.\n * @returns The current UIMode setting\n * @see {@link UIMode}\n */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /**\n * Gets the current orientation state.\n * @returns The current orientation (horizontal or vertical)\n * @see {@link UIOrientation}\n */\n public get orientation(): UIOrientation {\n return this.orientationInternal;\n }\n\n /**\n * Sets the visibility and interaction mode and emits change event.\n * @param value - The new UIMode setting\n * @see {@link UIMode}\n */\n public set mode(value: UIMode) {\n if (value !== this.modeInternal) {\n this.modeInternal = value;\n this.emit(UILayerEvent.MODE_CHANGE, this.modeInternal, this);\n }\n }\n\n /**\n * Internal method for resizing the layer and updating orientation.\n *\n * Updates the solver variables for width and height, resizes the scene wrapper,\n * and determines if the orientation has changed based on the new dimensions.\n * Emits an orientation change event if the orientation has changed.\n *\n * @param width - The new layer width\n * @param height - The new layer height\n * @protected\n */\n protected resizeInternal(width: number, height: number): void {\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n this.sceneWrapper.resize(width, height);\n\n const orientation =\n width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n\n if (orientation !== this.orientationInternal) {\n this.orientationInternal = orientation;\n this.emit(\n UILayerEvent.ORIENTATION_CHANGE,\n this.orientationInternal,\n this,\n );\n }\n }\n\n /**\n * Internal method for rendering the layer and its elements.\n *\n * Delegates rendering to the scene wrapper if the layer is not hidden.\n * This method is called during the rendering loop to update and draw\n * all elements contained within the layer.\n *\n * @param renderer - The WebGL renderer instance\n * @param deltaTime - Time elapsed since the last frame in seconds\n * @protected\n */\n protected renderInternal(renderer: WebGLRenderer, deltaTime: number): void {\n if (this.mode !== UIMode.HIDDEN) {\n this.sceneWrapper.prepareRender(renderer);\n this.emit(UILayerEvent.WILL_RENDER, renderer, deltaTime, this);\n this.sceneWrapper.render(renderer);\n }\n }\n\n /**\n * Internal method for handling click events on the layer.\n *\n * Processes click events by testing elements in reverse z-order (top to bottom)\n * until one handles the click. Only processes clicks when the layer is in\n * interactive mode.\n *\n * @param x - The x-coordinate of the click\n * @param y - The y-coordinate of the click\n * @protected\n */\n protected clickInternal(x: number, y: number): void {\n if (this.mode === UIMode.INTERACTIVE) {\n for (const element of this.sceneWrapper.getSortedVisibleElements()) {\n if (element[\"onClickInternal\"](x, y)) {\n return;\n }\n }\n }\n }\n\n /**\n * Internal method for accessing the constraint solver wrapper.\n *\n * Provides access to the layer's constraint solver for elements and\n * constraints that need to create variables or constraints.\n *\n * @returns The constraint solver wrapper instance\n */\n protected [\"getSolverWrapperInternal\"](): UISolverWrapper {\n return this.solverWrapper;\n }\n\n /**\n * Internal method for accessing the 3D scene wrapper.\n *\n * Provides access to the layer's scene management system for elements\n * that need to be added to or removed from the 3D scene.\n *\n * @returns The scene wrapper instance\n */\n protected [\"getSceneWrapperInternal\"](): UISceneWrapper {\n return this.sceneWrapper;\n }\n}\n","import { Constraint, Expression, Solver, Variable } from \"@lume/kiwi\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport { convertPriority, UIPriority } from \"../miscellaneous/UIPriority\";\nimport { convertRelation, UIRelation } from \"../miscellaneous/UIRelation\";\n\ninterface VariableDescription {\n variable: Variable;\n priority: UIPriority;\n value: number;\n constraint?: Constraint;\n}\n\ninterface ConstraintDescription {\n constraint: Constraint;\n lhs: UIExpression;\n rhs: UIExpression;\n priority: UIPriority;\n relation: UIRelation;\n enabled: boolean;\n}\n\nexport class UISolverWrapper {\n private solver? = new Solver();\n private recalculationRequired = false;\n\n private readonly variables = new Map<number, VariableDescription>();\n private lastVariableIndex = 0;\n\n private readonly constraints = new Map<number, ConstraintDescription>();\n private lastConstraintIndex = 0;\n\n public createVariable(value: number, priority: UIPriority): number {\n const index = this.lastVariableIndex++;\n const variable = new Variable();\n\n if (priority === UIPriority.P0) {\n const description: VariableDescription = { variable, priority, value };\n this.variables.set(index, description);\n\n description.constraint = this.buildConstraint(\n new UIExpression(0, [[index, 1]]),\n new UIExpression(value),\n UIRelation.EQUAL,\n priority,\n );\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n this.variables.set(index, { variable, priority, value });\n\n try {\n this.solver?.addEditVariable(variable, convertPriority(priority));\n this.solver?.suggestValue(variable, value);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.recalculationRequired = true;\n return index;\n }\n\n public removeVariable(index: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n throw new Error(`Variable ${index} is used in constraint`);\n }\n }\n\n try {\n description.constraint\n ? this.solver?.removeConstraint(description.constraint)\n : this.solver?.removeEditVariable(description.variable);\n } catch {\n this.solver = undefined;\n }\n\n this.variables.delete(index);\n this.recalculationRequired = true;\n }\n\n public suggestVariableValue(index: number, value: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n if (description.value !== value) {\n description.value = value;\n\n if (description.constraint) {\n description.constraint = this.rebuildConstraint(\n description.constraint,\n new UIExpression().plus(index, 1),\n new UIExpression(description.value),\n UIRelation.EQUAL,\n description.priority,\n );\n } else {\n this.solver?.suggestValue(description.variable, value);\n }\n\n this.recalculationRequired = true;\n }\n }\n\n public setVariablePriority(index: number, priority: UIPriority): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n if (priority !== description.priority) {\n description.priority = priority;\n\n if (description.priority === UIPriority.P0) {\n const lhs = new UIExpression().plus(index, 1);\n const rhs = new UIExpression(description.value);\n\n description.constraint = this.buildConstraint(\n lhs,\n rhs,\n UIRelation.EQUAL,\n description.priority,\n );\n\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n if (description.constraint) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n description.constraint = undefined;\n this.rebuildVariable(index, description);\n }\n\n this.recalculationRequired = true;\n }\n }\n\n public readVariableValue(index: number): number {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n if (this.solver === undefined) {\n this.rebuildSolver();\n }\n\n if (this.recalculationRequired) {\n this.solver?.updateVariables();\n this.recalculationRequired = false;\n }\n\n return description.variable.value();\n }\n\n public createConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n enabled: boolean,\n ): number {\n const index = this.lastConstraintIndex++;\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n this.constraints.set(index, {\n constraint,\n lhs: lhs.clone(),\n rhs: rhs.clone(),\n priority,\n relation,\n enabled,\n });\n if (enabled) {\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n }\n return index;\n }\n\n public removeConstraint(index: number): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n if (description.enabled) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.constraints.delete(index);\n this.recalculationRequired = true;\n }\n\n public setConstraintLHS(index: number, lhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.lhs.copy(lhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintRHS(index: number, rhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.rhs.copy(rhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintRelation(index: number, relation: UIRelation): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.relation = relation;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintPriority(index: number, priority: UIPriority): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.priority = priority;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintEnabled(index: number, enabled: boolean): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n if (enabled !== description.enabled) {\n description.enabled = enabled;\n try {\n description.enabled\n ? this.solver?.addConstraint(description.constraint)\n : this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n }\n }\n\n private rebuildVariable(\n index: number,\n description: VariableDescription,\n ): void {\n const dependConstraints: ConstraintDescription[] = [];\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n try {\n this.solver?.removeConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n }\n dependConstraints.push(cDescription);\n }\n }\n\n this.solver?.removeEditVariable(description.variable);\n this.solver?.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n\n for (const cDescription of dependConstraints) {\n cDescription.constraint = this.buildConstraint(\n cDescription.lhs,\n cDescription.rhs,\n cDescription.relation,\n cDescription.priority,\n );\n }\n\n for (const cDescription of dependConstraints) {\n try {\n this.solver?.addConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n break;\n }\n }\n }\n\n private rebuildConstraintByDescription(\n description: ConstraintDescription,\n ): void {\n description.constraint = description.enabled\n ? this.rebuildConstraint(\n description.constraint,\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n )\n : this.buildConstraint(\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n );\n }\n\n private rebuildConstraint(\n oldConstraint: Constraint,\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n try {\n this.solver?.removeConstraint(oldConstraint);\n } catch {\n this.solver = undefined;\n }\n\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n\n return constraint;\n }\n\n private buildConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n return new Constraint(\n this.convertExpression(lhs),\n convertRelation(relation),\n this.convertExpression(rhs),\n convertPriority(priority),\n );\n }\n\n private convertExpression(expression: UIExpression): Expression {\n return new Expression(\n ...expression[\"prepareTermsInternal\"]().map(\n ([variableIndex, coefficient]): [number, Variable] => {\n const description = this.variables.get(variableIndex);\n if (description === undefined) {\n throw new Error(`Variable ${variableIndex} does not exist`);\n }\n return [coefficient, description.variable];\n },\n ),\n expression.constant,\n );\n }\n\n private rebuildSolver(): void {\n if (this.solver) {\n throw new Error(\"Solver already exists\");\n }\n\n this.solver = new Solver();\n\n for (const description of this.variables.values()) {\n if (description.constraint) {\n this.solver.addConstraint(description.constraint);\n } else {\n this.solver.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n this.solver.suggestValue(description.variable, description.value);\n }\n }\n\n for (const description of this.constraints.values()) {\n if (description.enabled) {\n this.solver.addConstraint(description.constraint);\n }\n }\n\n this.recalculationRequired = true;\n }\n}\n","import { type UILayer } from \"../layers/UILayer\";\n\nimport type { UISolverWrapper } from \"../wrappers/UISolverWrapper\";\n\n/**\n * Abstract base class for all UI layout constraints.\n *\n * UIConstraint serves as the fundamental building block for the constraint-based\n * layout system. It provides access to the solver wrapper for creating and\n * managing constraint relationships between UI elements. All concrete constraint\n * implementations must extend this class to participate in the layout solving process.\n *\n * @see {@link UILayer} - Container layer for constraints\n * @see {@link UISolverWrapper} - Constraint solver integration\n */\nexport abstract class UIConstraint {\n /** Optional name identifier for the constraint. */\n public name = \"\";\n\n /**\n * Reference to the constraint solver wrapper for managing solver operations.\n * @see {@link UISolverWrapper}\n */\n protected readonly solverWrapper: UISolverWrapper;\n\n /**\n * Creates a new UIConstraint instance.\n *\n * @param layer - The UI layer that contains this constraint\n */\n constructor(public readonly layer: UILayer) {\n this.solverWrapper = this.layer[\"getSolverWrapperInternal\"]();\n }\n}\n","import type { UILayer } from \"../layers/UILayer\";\nimport { UILayerEvent } from \"../layers/UILayer\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../miscellaneous/UIOrientation\";\nimport { resolvePriority, type UIPriority } from \"../miscellaneous/UIPriority\";\nimport { resolveRelation, type UIRelation } from \"../miscellaneous/UIRelation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\n/**\n * Configuration options for UISingleParameterConstraint creation.\n */\nexport interface UISingleParameterConstraintOptions {\n /** Priority level for the constraint in the solver hierarchy. */\n priority: UIPriority;\n /** Mathematical relation type for the constraint equation. */\n relation: UIRelation;\n /** Orientation context for when the constraint should be active. */\n orientation: UIOrientation;\n}\n\n/**\n * Abstract base class for constraints that operate with configurable parameters.\n *\n * UISingleParameterConstraint extends UIConstraint with common functionality\n * for constraints that need priority, relation, and orientation configuration.\n * It provides automatic orientation-based enabling/disabling of constraints\n * and manages the lifecycle of solver constraint descriptors.\n *\n * @see {@link UIConstraint} - Base constraint class\n * @see {@link UIPriority} - Priority level configuration\n * @see {@link UIRelation} - Mathematical relation types\n * @see {@link UIOrientation} - Orientation-based activation\n */\nexport abstract class UISingleParameterConstraint extends UIConstraint {\n /** Internal storage for the constraint priority level. */\n protected priorityInternal: UIPriority;\n /** Internal storage for the constraint relation type. */\n protected relationInternal: UIRelation;\n /** Internal storage for the constraint orientation setting. */\n protected orientationInternal: UIOrientation;\n\n /** The constraint descriptor managed by the solver system. */\n protected abstract readonly constraint: number;\n\n /**\n * Creates a new UISingleParameterConstraint instance.\n *\n * Initializes the constraint with resolved default values and sets up\n * orientation change event handling for dynamic constraint activation.\n *\n * @param layer - The UI layer that contains this constraint\n * @param priority - Optional priority level (defaults to P0)\n * @param relation - Optional relation type (defaults to EQUAL)\n * @param orientation - Optional orientation setting (defaults to ALWAYS)\n */\n constructor(\n layer: UILayer,\n priority?: UIPriority,\n relation?: UIRelation,\n orientation?: UIOrientation,\n ) {\n super(layer);\n this.priorityInternal = resolvePriority(priority);\n this.relationInternal = resolveRelation(relation);\n this.orientationInternal = resolveOrientation(orientation);\n this.layer.on(UILayerEvent.ORIENTATION_CHANGE, this.onOrientationChange);\n }\n\n /**\n * Gets the current priority level of the constraint.\n * @returns The constraint priority level\n */\n public get priority(): UIPriority {\n return this.priorityInternal;\n }\n\n /**\n * Gets the current mathematical relation type of the constraint.\n * @returns The constraint relation type\n */\n public get relation(): UIRelation {\n return this.relationInternal;\n }\n\n /**\n * Gets the current orientation setting of the constraint.\n * @returns The constraint orientation setting\n */\n public get orientation(): UIOrientation {\n return this.orientationInternal;\n }\n\n /**\n * Sets a new priority level for the constraint.\n * @param value - The new priority level\n */\n public set priority(value: UIPriority) {\n if (value !== this.priorityInternal) {\n this.priorityInternal = value;\n this.solverWrapper.setConstraintPriority(\n this.constraint,\n this.priorityInternal,\n );\n }\n }\n\n /**\n * Sets a new mathematical relation type for the constraint.\n * @param value - The new relation type\n */\n public set relation(value: UIRelation) {\n if (value !== this.relationInternal) {\n this.relationInternal = value;\n this.solverWrapper.setConstraintRelation(\n this.constraint,\n this.relationInternal,\n );\n }\n }\n\n /**\n * Sets a new orientation setting for the constraint.\n * @param value - The new orientation setting\n */\n public set orientation(value: UIOrientation) {\n if (value !== this.orientationInternal) {\n this.orientationInternal = value;\n this.onOrientationChange();\n }\n }\n\n /**\n * Destroys the constraint by cleaning up event listeners and solver resources.\n *\n * This method removes the orientation change event listener and removes\n * the constraint from the solver system. After calling this method,\n * the constraint should not be used anymore.\n */\n public destroy(): void {\n this.layer.off(UILayerEvent.ORIENTATION_CHANGE, this.onOrientationChange);\n this.solverWrapper.removeConstraint(this.constraint);\n }\n\n /**\n * Determines if the constraint should be enabled based on orientation.\n *\n * The constraint is enabled if its orientation is set to ALWAYS or if\n * it matches the current layer orientation.\n *\n * @returns True if the constraint should be enabled, false otherwise\n * @protected\n */\n protected isConstraintEnabled(): boolean {\n return (\n this.orientationInternal === UIOrientation.ALWAYS ||\n this.orientationInternal === this.layer.orientation\n );\n }\n\n /**\n * Event handler for layer orientation changes.\n *\n * Updates the constraint's enabled state in the solver based on the\n * current orientation and the constraint's orientation setting.\n *\n * @private\n */\n private readonly onOrientationChange = (): void => {\n this.solverWrapper.setConstraintEnabled(\n this.constraint,\n this.isConstraintEnabled(),\n );\n };\n}\n","import type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIHeightConstraint creation.\n */\nexport interface UIHeightConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The desired height value for the element. */\n height: number;\n}\n\n/**\n * Constraint that enforces a specific height value for UI elements.\n *\n * UIHeightConstraint creates a mathematical relationship that fixes an element's\n * height to a constant value. The constraint equation is: element.height = height.\n * This is useful for ensuring elements maintain a specific height regardless of\n * other layout changes or for setting fixed dimensions in responsive layouts.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Elements that can have height constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIHeightConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for the current height value. */\n private heightInternal: number;\n\n /**\n * Creates a new UIHeightConstraint instance.\n *\n * If no height is specified in options, the constraint will use the\n * element's current height as the target height value.\n *\n * @param element - The UI element to apply the height constraint to\n * @param options - Configuration options for the constraint\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIHeightConstraintOptions> = {},\n ) {\n super(\n element.layer,\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.heightInternal = options.height ?? element.height;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.hVariable, 1]]),\n new UIExpression(this.heightInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current height value being enforced.\n * @returns The height value in pixels\n */\n public get height(): number {\n return this.heightInternal;\n }\n\n /**\n * Sets a new height value and updates the constraint equation.\n * @param value - The new height value in pixels\n */\n public set height(value: number) {\n if (this.heightInternal !== value) {\n this.heightInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import { UILayer } from \"../layers/UILayer\";\n\n/** Small epsilon value for floating-point comparisons and minimum positive number validation. */\nexport const EPSILON = 1e-6;\n\n/**\n * Interface for objects that belong to a UI layer.\n *\n * Elements implementing this interface are associated with a specific layer\n * for constraint solving and rendering management.\n */\nexport interface UILayerElement {\n /** The UI layer that contains this element. */\n layer: UILayer;\n}\n\n/**\n * Interface for UI elements that have a position in 2D space.\n *\n * Point elements are characterized by x and y coordinates represented\n * as solver variable descriptors for constraint-based positioning.\n */\nexport interface UIPointElement {\n /** Solver variable descriptor for the x-coordinate. */\n xVariable: number;\n /** Solver variable descriptor for the y-coordinate. */\n yVariable: number;\n\n /** The x-coordinate of the element. */\n x: number;\n /** The y-coordinate of the element. */\n y: number;\n}\n\n/**\n * Interface for UI elements that have both position and dimensions in 2D space.\n *\n * Plane elements extend point elements with width and height properties,\n * enabling rectangular area constraints and positioning.\n */\nexport interface UIPlaneElement extends UIPointElement {\n /** Solver variable descriptor for the width dimension. */\n wVariable: number;\n /** Solver variable descriptor for the height dimension. */\n hVariable: number;\n\n /** The width of the element. */\n width: number;\n /** The height of the element. */\n height: number;\n}\n\n/**\n * Type guard to check if an object implements the UILayerElement interface.\n *\n * @param obj - The object to check\n * @returns True if the object has a valid layer property, false otherwise\n */\nexport function isUILayerElement(obj: unknown): obj is UILayerElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"layer\" in obj &&\n obj.layer instanceof UILayer\n );\n}\n\n/**\n * Type guard to check if an object implements the UIPointElement interface.\n *\n * @param obj - The object to check\n * @returns True if the object has valid xVariable and yVariable properties, false otherwise\n */\nexport function isUIPointElement(obj: unknown): obj is UIPointElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"xVariable\" in obj &&\n typeof obj.xVariable === \"number\" &&\n \"yVariable\" in obj &&\n typeof obj.yVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\n/**\n * Type guard to check if an object implements the UIPlaneElement interface.\n *\n * Note: This function only checks for width and height variables. Objects\n * should also satisfy UIPointElement requirements for complete validation.\n *\n * @param obj - The object to check\n * @returns True if the object has valid wVariable and hVariable properties, false otherwise\n */\nexport function isUIPlaneElement(obj: unknown): obj is UIPlaneElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"wVariable\" in obj &&\n typeof obj.wVariable === \"number\" &&\n \"hVariable\" in obj &&\n typeof obj.hVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\n/**\n * Validates that two objects are valid constraint subjects from the same layer.\n *\n * Ensures that both objects are either UILayer instances or UILayerElement instances,\n * that they are not both layers (which cannot be constrained to each other),\n * and that they belong to the same layer for constraint solving.\n *\n * @param a - The first constraint subject\n * @param b - The second constraint subject\n * @param subject - The name of the constraint for error messages\n * @returns The common layer that both subjects belong to\n * @throws Will throw an error if subjects are invalid or from different layers\n */\nexport function assertValidConstraintSubjects(\n a: unknown,\n b: unknown,\n subject: string,\n): UILayer {\n if (a instanceof UILayer && b instanceof UILayer) {\n throw new Error(`${subject}: layer cannot be snapped to another layer`);\n }\n\n let layerA: UILayer;\n let layerB: UILayer;\n\n if (a instanceof UILayer || isUILayerElement(a)) {\n layerA = a instanceof UILayer ? a : a.layer;\n } else {\n throw new Error(`${subject}: A must be a UILayer or a UIPointElement`);\n }\n\n if (b instanceof UILayer || isUILayerElement(b)) {\n layerB = b instanceof UILayer ? b : b.layer;\n } else {\n throw new Error(`${subject}: B must be a UILayer or a UIPointElement`);\n }\n\n if (layerA !== layerB) {\n throw new Error(`${subject}: elements must be on the same layer`);\n }\n\n return layerA;\n}\n\n/**\n * Validates that a value is a finite number within safe integer range.\n *\n * Checks that the value is finite (not NaN, Infinity, or -Infinity) and\n * within the safe integer range for reliable mathematical operations.\n *\n * @param value - The number to validate\n * @param subject - The name of the value for error messages\n * @throws Will throw an error if the value is not finite or exceeds safe range\n */\nexport function assertValidNumber(value: number, subject: string): void {\n if (!Number.isFinite(value)) {\n throw new Error(`${subject}: value must be a finite number`);\n }\n\n if (Math.abs(value) > Number.MAX_SAFE_INTEGER) {\n throw new Error(`${subject}: value exceeds maximum safe integer range`);\n }\n}\n\n/**\n * Validates that a value is a positive number above the epsilon threshold.\n *\n * First validates that the value is a finite number, then ensures it is\n * greater than or equal to EPSILON to avoid numerical precision issues\n * with very small positive values.\n *\n * @param value - The number to validate\n * @param subject - The name of the value for error messages\n * @throws Will throw an error if the value is invalid or not sufficiently positive\n * @see {@link assertValidNumber}\n */\nexport function assertValidPositiveNumber(\n value: number,\n subject: string,\n): void {\n assertValidNumber(value, subject);\n\n if (value < EPSILON) {\n throw new Error(\n `${subject}: value must be greater than or equal to ${EPSILON}`,\n );\n }\n}\n\n/**\n * Validates that a value is a non-negative number (including zero).\n *\n * First validates that the value is a finite number, then ensures it is\n * greater than or equal to zero. Unlike assertValidPositiveNumber, this\n * function allows zero as a valid value.\n *\n * @param value - The number to validate\n * @param subject - The name of the value for error messages\n * @throws Will throw an error if the value is invalid or negative\n * @see {@link assertValidNumber}\n */\nexport function assertValidNonNegativeNumber(\n value: number,\n subject: string,\n): void {\n assertValidNumber(value, subject);\n if (value < 0) {\n throw new Error(`${subject}: value must be greater than or equal to 0`);\n }\n}\n","import type { UIPlaneElement, UIPointElement } from \"../miscellaneous/asserts\";\nimport {\n assertValidConstraintSubjects,\n isUIPlaneElement,\n isUIPointElement,\n} from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/** Default anchor point (0.5 = center) for elements when not specified. */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for UIHorizontalDistanceConstraint creation.\n */\nexport interface UIHorizontalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor point for element A (0.0 = left edge, 0.5 = center, 1.0 = right edge). */\n anchorA: number;\n /** Anchor point for element B (0.0 = left edge, 0.5 = center, 1.0 = right edge). */\n anchorB: number;\n /** The desired horizontal distance between the elements. */\n distance: number;\n}\n\n/**\n * Constraint that enforces horizontal distance between two UI elements.\n *\n * UIHorizontalDistanceConstraint creates a mathematical relationship that maintains\n * a specific horizontal distance between two elements using configurable anchor points.\n * For plane elements, anchors determine the reference point (0.0 = left, 0.5 = center, 1.0 = right).\n * For point elements, the anchor is always the element's position. The constraint equation is:\n * (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA) = distance\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPointElement} - Point elements that can be constrained\n * @see {@link UIPlaneElement} - Plane elements that can be constrained\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for element A's anchor point. */\n private anchorAInternal: number;\n /** Internal storage for element B's anchor point. */\n private anchorBInternal: number;\n /** Internal storage for the horizontal distance value. */\n private distanceInternal: number;\n\n /**\n * Creates a new UIHorizontalDistanceConstraint instance.\n *\n * The constraint will use default anchor points (0.5 = center) and zero distance\n * if not specified in options. Both elements must be from the same layer.\n *\n * @param a - The first UI element (point or plane element)\n * @param b - The second UI element (point or plane element)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIHorizontalDistanceConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIHorizontalDistanceConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current horizontal distance being enforced.\n * @returns The horizontal distance in pixels\n */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /**\n * Gets the anchor point for element A.\n * @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /**\n * Gets the anchor point for element B.\n * @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /**\n * Sets a new horizontal distance and updates the constraint equation.\n * @param value - The new horizontal distance in pixels\n */\n public set distance(value: number) {\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /**\n * Sets a new anchor point for element A and updates the constraint equation.\n * @param value - The new anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public set anchorA(value: number) {\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Sets a new anchor point for element B and updates the constraint equation.\n * @param value - The new anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public set anchorB(value: number) {\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Builds the left-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA)\n * For point elements, only the x position is used since they have no width.\n * For plane elements, the anchor determines the reference point within the element's width.\n *\n * @returns The UIExpression representing the horizontal distance calculation\n * @private\n */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.xVariable, 1],\n [this.a.wVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.xVariable, 1);\n } else {\n throw new Error(\"A is not a valid element type\");\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.xVariable, 1],\n [this.b.wVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.xVariable, 1);\n } else {\n throw new Error(\"B is not a valid element type\");\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { assertValidConstraintSubjects } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIHorizontalProportionConstraint creation.\n */\nexport interface UIHorizontalProportionConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The proportional relationship between element widths (elementA.width = elementB.width * proportion). */\n proportion: number;\n}\n\n/**\n * Constraint that enforces proportional width relationships between two UI elements.\n *\n * UIHorizontalProportionConstraint creates a mathematical relationship that maintains\n * a proportional ratio between the widths of two plane elements. The constraint equation is:\n * elementA.width * proportion = elementB.width, which can be rearranged as:\n * elementA.width * proportion - elementB.width = 0\n *\n * This is useful for creating responsive layouts where elements need to maintain\n * specific width ratios, such as sidebar-to-content ratios or grid column proportions.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIHorizontalProportionConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n /** Internal storage for the current proportion value. */\n private proportionInternal: number;\n\n /**\n * Creates a new UIHorizontalProportionConstraint instance.\n *\n * The constraint will enforce the relationship: elementA.width * proportion = elementB.width.\n * If no proportion is specified, it defaults to 1.0 (equal widths).\n * Both elements must be from the same layer.\n *\n * @param a - The first UI plane element (whose width will be multiplied by proportion)\n * @param b - The second UI plane element (target width for the proportion)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIHorizontalProportionConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIHorizontalProportionConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current proportion value being enforced.\n * @returns The proportion ratio (elementA.width = elementB.width * proportion)\n */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /**\n * Sets a new proportion value and updates the constraint equation.\n * @param value - The new proportion ratio\n */\n public set proportion(value: number) {\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /**\n * Builds the right-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementA.width * proportion) - elementB.width = 0\n * This enforces the relationship: elementA.width * proportion = elementB.width\n *\n * @returns The UIExpression representing the proportional width relationship\n * @private\n */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.wVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.wVariable, 1]]),\n );\n }\n}\n","import type { UIPlaneElement, UIPointElement } from \"../miscellaneous/asserts\";\nimport {\n assertValidConstraintSubjects,\n isUIPlaneElement,\n isUIPointElement,\n} from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/** Default anchor point (0.5 = center) for elements when not specified. */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for UIVerticalDistanceConstraint creation.\n */\nexport interface UIVerticalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor point for element A (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */\n anchorA: number;\n /** Anchor point for element B (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */\n anchorB: number;\n /** The desired vertical distance between the elements. */\n distance: number;\n}\n\n/**\n * Constraint that enforces vertical distance between two UI elements.\n *\n * UIVerticalDistanceConstraint creates a mathematical relationship that maintains\n * a specific vertical distance between two elements using configurable anchor points.\n * For plane elements, anchors determine the reference point (0.0 = top, 0.5 = center, 1.0 = bottom).\n * For point elements, the anchor is always the element's position. The constraint equation is:\n * (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA) = distance\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPointElement} - Point elements that can be constrained\n * @see {@link UIPlaneElement} - Plane elements that can be constrained\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIVerticalDistanceConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for element A's anchor point. */\n private anchorAInternal: number;\n /** Internal storage for element B's anchor point. */\n private anchorBInternal: number;\n /** Internal storage for the vertical distance value. */\n private distanceInternal: number;\n\n /**\n * Creates a new UIVerticalDistanceConstraint instance.\n *\n * The constraint will use default anchor points (0.5 = center) and zero distance\n * if not specified in options. Both elements must be from the same layer.\n *\n * @param a - The first UI element (point or plane element)\n * @param b - The second UI element (point or plane element)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIVerticalDistanceConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIVerticalDistanceConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current vertical distance being enforced.\n * @returns The vertical distance in pixels\n */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /**\n * Gets the anchor point for element A.\n * @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /**\n * Gets the anchor point for element B.\n * @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /**\n * Sets a new vertical distance and updates the constraint equation.\n * @param value - The new vertical distance in pixels\n */\n public set distance(value: number) {\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /**\n * Sets a new anchor point for element A and updates the constraint equation.\n * @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public set anchorA(value: number) {\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Sets a new anchor point for element B and updates the constraint equation.\n * @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public set anchorB(value: number) {\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Builds the left-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA)\n * For point elements, only the y position is used since they have no height.\n * For plane elements, the anchor determines the reference point within the element's height.\n *\n * @returns The UIExpression representing the vertical distance calculation\n * @private\n */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.yVariable, 1],\n [this.a.hVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.yVariable, 1);\n } else {\n throw new Error(\"A is not a valid element type\");\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.yVariable, 1],\n [this.b.hVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.yVariable, 1);\n } else {\n throw new Error(\"B is not a valid element type\");\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { assertValidConstraintSubjects } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIVerticalProportionConstraint creation.\n */\nexport interface UIVerticalProportionConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The proportional relationship between element heights (elementA.height = elementB.height * proportion). */\n proportion: number;\n}\n\n/**\n * Constraint that enforces proportional height relationships between two UI elements.\n *\n * UIVerticalProportionConstraint creates a mathematical relationship that maintains\n * a proportional ratio between the heights of two plane elements. The constraint equation is:\n * elementA.height * proportion = elementB.height, which can be rearranged as:\n * elementA.height * proportion - elementB.height = 0\n *\n * This is useful for creating responsive layouts where elements need to maintain\n * specific height ratios, such as header-to-content ratios or row height proportions.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIVerticalProportionConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n /** Internal storage for the current proportion value. */\n private proportionInternal: number;\n\n /**\n * Creates a new UIVerticalProportionConstraint instance.\n *\n * The constraint will enforce the relationship: elementA.height * proportion = elementB.height.\n * If no proportion is specified, it defaults to 1.0 (equal heights).\n * Both elements must be from the same layer.\n *\n * @param a - The first UI plane element (whose height will be multiplied by proportion)\n * @param b - The second UI plane element (target height for the proportion)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIVerticalProportionConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIVerticalProportionConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current proportion value being enforced.\n * @returns The proportion ratio (elementA.height = elementB.height * proportion)\n */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /**\n * Sets a new proportion value and updates the constraint equation.\n * @param value - The new proportion ratio\n */\n public set proportion(value: number) {\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /**\n * Builds the right-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementA.height * proportion) - elementB.height = 0\n * This enforces the relationship: elementA.height * proportion = elementB.height\n *\n * @returns The UIExpression representing the proportional height relationship\n * @private\n */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.hVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.hVariable, 1]]),\n );\n }\n}\n","import type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIWidthConstraint creation.\n */\nexport interface UIWidthConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The desired width value for the element. */\n width: number;\n}\n\n/**\n * Constraint that enforces a specific width value for UI elements.\n *\n * UIWidthConstraint creates a mathematical relationship that fixes an element's\n * width to a constant value. The constraint equation is: element.width = width.\n * This is useful for ensuring elements maintain a specific width regardless of\n * other layout changes or for setting fixed dimensions in responsive layouts.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Elements that can have width constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIWidthConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for the current width value. */\n private widthInternal: number;\n\n /**\n * Creates a new UIWidthConstraint instance.\n *\n * If no width is specified in options, the constraint will use the\n * element's current width as the target width value.\n *\n * @param element - The UI element to apply the width constraint to\n * @param options - Configuration options for the constraint\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIWidthConstraintOptions> = {},\n ) {\n super(\n element.layer,\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.widthInternal = options.width ?? element.width;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.wVariable, 1]]),\n new UIExpression(this.widthInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current width value being enforced.\n * @returns The width value in pixels\n */\n public get width(): number {\n return this.widthInternal;\n }\n\n /**\n * Sets a new width value and updates the constraint equation.\n * @param value - The new width value in pixels\n */\n public set width(value: number) {\n if (this.widthInternal !== value) {\n this.widthInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import { UIHeightConstraint } from \"../constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../constraints/UIWidthConstraint\";\nimport type { UIElement } from \"../elements/UIElement\";\nimport type { UIPlaneElement, UIPointElement } from \"../miscellaneous/asserts\";\nimport type { UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport type { UIPriority } from \"../miscellaneous/UIPriority\";\nimport type { UIRelation } from \"../miscellaneous/UIRelation\";\n\n/**\n * Generic 2D type for specifying horizontal and vertical values.\n *\n * This interface allows configuration of properties that can have\n * different values for horizontal and vertical directions.\n *\n * @template T - The type of values for horizontal and vertical properties\n */\nexport interface UIType2D<T> {\n /** Horizontal (x-axis) value. */\n h?: T;\n /** Vertical (y-axis) value. */\n v?: T;\n}\n\n/**\n * Base options for 2D constraint configuration.\n */\ninterface UIConstraint2DOptions {\n /** Priority levels for horizontal and vertical constraints. */\n priority: UIType2D<UIPriority>;\n /** Mathematical relations for horizontal and vertical constraints. */\n relation: UIType2D<UIRelation>;\n /** Orientation settings for horizontal and vertical constraints. */\n orientation: UIType2D<UIOrientation>;\n}\n\n/**\n * Configuration options for 2D size constraints.\n */\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n /** Size values for horizontal (width) and vertical (height) dimensions. */\n size: UIType2D<number>;\n}\n\n/**\n * Configuration options for 2D distance constraints.\n */\nexport interface UIConstraintDistance2DOptions extends UIConstraint2DOptions {\n /** Anchor points for element A in horizontal and vertical directions. */\n anchorA: UIType2D<number>;\n /** Anchor points for element B in horizontal and vertical directions. */\n anchorB: UIType2D<number>;\n /** Distance values for horizontal and vertical spacing. */\n distance: UIType2D<number>;\n}\n\n/**\n * Configuration options for 2D proportion constraints.\n */\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n /** Proportion ratios for horizontal and vertical relationships. */\n proportion: UIType2D<number>;\n}\n\n/**\n * Result object containing horizontal and vertical constraint instances.\n *\n * @template TH - The type of the horizontal constraint\n * @template TV - The type of the vertical constraint\n */\nexport interface UIConstraint2DResult<TH, TV> {\n /** The horizontal constraint instance. */\n h: TH;\n /** The vertical constraint instance. */\n v: TV;\n}\n\n/**\n * Builder utility for creating paired horizontal and vertical constraints.\n *\n * UIConstraint2DBuilder simplifies the creation of constraint pairs that work\n * together to define 2D relationships between UI elements. Instead of manually\n * creating separate horizontal and vertical constraints, this builder allows\n * you to specify both dimensions at once with a unified interface.\n *\n * This is particularly useful for creating consistent spacing, sizing, and\n * proportional relationships across both axes simultaneously.\n *\n * @see {@link UIWidthConstraint} - Horizontal size constraints\n * @see {@link UIHeightConstraint} - Vertical size constraints\n * @see {@link UIHorizontalDistanceConstraint} - Horizontal spacing constraints\n * @see {@link UIVerticalDistanceConstraint} - Vertical spacing constraints\n */\nexport class UIConstraint2DBuilder {\n /**\n * Creates paired width and height constraints for an element.\n *\n * This method generates both horizontal (width) and vertical (height)\n * size constraints simultaneously, allowing you to set fixed dimensions\n * for both axes with a single call.\n *\n * @param element - The UI element to apply size constraints to\n * @param options - Configuration options for both width and height constraints\n * @returns Object containing the created width and height constraint instances\n */\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions> = {},\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n return {\n h: new UIWidthConstraint(element, {\n width: options.size?.h,\n priority: options.priority?.h,\n relation: options.relation?.h,\n orientation: options.orientation?.h,\n }),\n v: new UIHeightConstraint(element, {\n height: options.size?.v,\n priority: options.priority?.v,\n relation: options.relation?.v,\n orientation: options.orientation?.v,\n }),\n };\n }\n\n /**\n * Creates paired horizontal and vertical distance constraints between two elements.\n *\n * This method generates both horizontal and vertical spacing constraints\n * simultaneously, allowing you to define 2D spacing relationships with\n * configurable anchor points for both axes.\n *\n * @param a - The first UI element (point or plane element)\n * @param b - The second UI element (point or plane element)\n * @param options - Configuration options for both horizontal and vertical distance constraints\n * @returns Object containing the created horizontal and vertical distance constraint instances\n */\n public static distance(\n a: UIPointElement | UIPlaneElement,\n b: UIPointElement | UIPlaneElement,\n options: Partial<UIConstraintDistance2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n return {\n h: new UIHorizontalDistanceConstraint(a, b, {\n anchorA: options.anchorA?.h,\n anchorB: options.anchorB?.h,\n distance: options.distance?.h,\n priority: options.priority?.h,\n relation: options.relation?.h,\n orientation: options.orientation?.h,\n }),\n v: new UIVerticalDistanceConstraint(a, b, {\n anchorA: options.anchorA?.v,\n anchorB: options.anchorB?.v,\n distance: options.distance?.v,\n priority: options.priority?.v,\n relation: options.relation?.v,\n orientation: options.orientation?.v,\n }),\n };\n }\n\n /**\n * Creates paired horizontal and vertical proportion constraints between two elements.\n *\n * This method generates both horizontal (width) and vertical (height)\n * proportion constraints simultaneously, allowing you to define proportional\n * relationships for both dimensions with a single call.\n *\n * @param a - The first UI plane element (whose dimensions will be multiplied by proportion)\n * @param b - The second UI plane element (target dimensions for the proportion)\n * @param options - Configuration options for both horizontal and vertical proportion constraints\n * @returns Object containing the created horizontal and vertical proportion constraint instances\n */\n public static proportion(\n a: UIPlaneElement,\n b: UIPlaneElement,\n options: Partial<UIConstraintProportion2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n return {\n h: new UIHorizontalProportionConstraint(a, b, {\n proportion: options.proportion?.h,\n priority: options.priority?.h,\n relation: options.relation?.h,\n orientation: options.orientation?.h,\n }),\n v: new UIVerticalProportionConstraint(a, b, {\n proportion: options.proportion?.v,\n priority: options.priority?.v,\n relation: options.relation?.v,\n orientation: options.orientation?.v,\n }),\n };\n }\n}\n","import type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIAspectConstraint creation.\n */\nexport interface UIAspectConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The desired aspect ratio (width/height) for the element. */\n aspect: number;\n}\n\n/**\n * Constraint that maintains a specific aspect ratio for UI elements.\n *\n * UIAspectConstraint enforces a mathematical relationship between an element's\n * width and height to maintain a constant aspect ratio. The constraint equation\n * is: width = height * aspect. This is useful for ensuring elements maintain\n * their proportions during layout changes or for enforcing specific aspect\n * ratios like 16:9 for video content.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Elements that can have aspect constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIAspectConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for the current aspect ratio value. */\n private aspectInternal: number;\n\n /**\n * Creates a new UIAspectConstraint instance.\n *\n * If no aspect ratio is specified in options, the constraint will use the\n * element's current width-to-height ratio as the target aspect ratio.\n *\n * @param element - The UI element to apply the aspect constraint to\n * @param options - Configuration options for the constraint\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIAspectConstraintOptions> = {},\n ) {\n super(\n element.layer,\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.aspectInternal = options.aspect ?? element.width / element.height;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current aspect ratio being enforced.\n * @returns The aspect ratio (width/height)\n */\n public get aspect(): number {\n return this.aspectInternal;\n }\n\n /**\n * Sets a new aspect ratio and updates the constraint equation.\n * @param value - The new aspect ratio (width/height)\n */\n public set aspect(value: number) {\n if (this.aspectInternal !== value) {\n this.aspectInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Builds the left-hand side expression for the constraint equation.\n *\n * Creates the expression: width - (height * aspect) = 0\n * This enforces the relationship: width = height * aspect\n *\n * @returns The UIExpression representing the constraint equation\n * @private\n */\n private buildLHS(): UIExpression {\n return new UIExpression(0, [\n [this.element.wVariable, 1],\n [this.element.hVariable, -this.aspectInternal],\n ]);\n }\n}\n","import { UIAspectConstraint } from \"../constraints/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../constraints/UIVerticalProportionConstraint\";\nimport type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { type UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../miscellaneous/UIRelation\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for the UICoverConstraintBuilder.\n */\nexport interface UICoverConstraintBuilderOptions {\n /** Whether to maintain the aspect ratio of the active (content) element */\n keepActiveAspect: boolean;\n /** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */\n anchorH: number;\n /** Vertical anchor point (0.0 = bottom, 0.5 = center, 1.0 = top) */\n anchorV: number;\n /** Orientation context for constraint calculations */\n orientation: UIOrientation;\n}\n\n/**\n * Builder for creating \"cover\" layout constraints that make an element cover its container.\n *\n * Cover layout ensures the active element is large enough to completely cover the passive\n * element while maintaining proportions. This is similar to CSS `background-size: cover`\n * or `object-fit: cover` behavior.\n *\n * The active element will be:\n * - Positioned at the specified anchor point within the passive element\n * - Sized to be at least as large as the passive element in both dimensions\n * - Scaled proportionally to maintain aspect ratio (if enabled)\n */\nexport class UICoverConstraintBuilder {\n /**\n * Creates a set of constraints for cover layout behavior.\n *\n * @param passive - The container element (what gets covered)\n * @param active - The content element (what does the covering)\n * @param options - Configuration options for the cover layout\n * @returns Object containing all created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UICoverConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint for the active element (if keepActiveAspect is true) */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal positioning constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical positioning constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width proportion constraint (ensures coverage) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height proportion constraint (ensures coverage) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.GREATER_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import { UIAspectConstraint } from \"../constraints/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../constraints/UIVerticalProportionConstraint\";\nimport type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { type UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../miscellaneous/UIRelation\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for the UIFitConstraintBuilder.\n */\nexport interface UIFitConstraintBuilderOptions {\n /** Whether to maintain the aspect ratio of the active (content) element */\n keepActiveAspect: boolean;\n /** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */\n anchorH: number;\n /** Vertical anchor point (0.0 = bottom, 0.5 = center, 1.0 = top) */\n anchorV: number;\n /** Orientation context for constraint calculations */\n orientation: UIOrientation;\n}\n\n/**\n * Builder for creating \"fit\" layout constraints that make an element fit within its container.\n *\n * Fit layout ensures the active element is sized to completely fit within the passive\n * element while maintaining proportions. This is similar to CSS `background-size: contain`\n * or `object-fit: contain` behavior.\n *\n * The active element will be:\n * - Positioned at the specified anchor point within the passive element\n * - Sized to fit entirely within the passive element in both dimensions\n * - Scaled proportionally to maintain aspect ratio (if enabled)\n */\nexport class UIFitConstraintBuilder {\n /**\n * Creates a set of constraints for fit layout behavior.\n *\n * @param passive - The container element (what contains the content)\n * @param active - The content element (what gets fitted within the container)\n * @param options - Configuration options for the fit layout\n * @returns Object containing all created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UIFitConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint for the active element (if keepActiveAspect is true) */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal positioning constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical positioning constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width proportion constraint (ensures fitting) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height proportion constraint (ensures fitting) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.LESS_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import type { UILayer } from \"../layers/UILayer\";\nimport type { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Constraint that allows custom mathematical relationships between UI elements.\n *\n * UICustomConstraint provides maximum flexibility by allowing direct specification\n * of the left-hand side (LHS) and right-hand side (RHS) expressions for constraint\n * equations. This enables creation of complex mathematical relationships that may\n * not be covered by the specialized constraint types. The constraint equation is:\n * LHS relation RHS (e.g., LHS = RHS, LHS ≤ RHS, or LHS ≥ RHS)\n *\n * This is useful for implementing custom layout logic, complex mathematical\n * relationships between multiple elements, or prototype new constraint types.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n * @see {@link UILayer} - Container layer for constraints\n */\nexport class UICustomConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n /** Internal storage for the left-hand side expression. */\n private lhsInternal: UIExpression;\n /** Internal storage for the right-hand side expression. */\n private rhsInternal: UIExpression;\n\n /**\n * Creates a new UICustomConstraint instance with custom expressions.\n *\n * The constraint will enforce the relationship: LHS relation RHS, where\n * the relation is determined by the options (defaults to equality).\n *\n * @param layer - The UI layer that contains this constraint\n * @param lhs - The left-hand side expression of the constraint equation\n * @param rhs - The right-hand side expression of the constraint equation\n * @param options - Configuration options for the constraint\n */\n constructor(\n layer: UILayer,\n lhs: UIExpression,\n rhs: UIExpression,\n options: Partial<UISingleParameterConstraintOptions> = {},\n ) {\n super(layer, options.priority, options.relation, options.orientation);\n\n this.lhsInternal = lhs;\n this.rhsInternal = rhs;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.lhsInternal,\n this.rhsInternal,\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current left-hand side expression.\n * @returns The LHS expression of the constraint equation\n */\n public get lhs(): UIExpression {\n return this.lhsInternal;\n }\n\n /**\n * Gets the current right-hand side expression.\n * @returns The RHS expression of the constraint equation\n */\n public get rhs(): UIExpression {\n return this.rhsInternal;\n }\n\n /**\n * Sets a new left-hand side expression and updates the constraint.\n * @param value - The new LHS expression for the constraint equation\n */\n public setLHS(value: UIExpression): void {\n this.lhsInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.lhsInternal);\n }\n\n /**\n * Sets a new right-hand side expression and updates the constraint.\n * @param value - The new RHS expression for the constraint equation\n */\n public setRHS(value: UIExpression): void {\n this.rhsInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.rhsInternal);\n }\n}\n","import { Eventail } from \"eventail\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport type { UIPointElement } from \"../miscellaneous/asserts\";\nimport { assertValidNumber } from \"../miscellaneous/asserts\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport type { UISolverWrapper } from \"../wrappers/UISolverWrapper\";\n\n/**\n * Abstract base class representing a minimal UI element as a point in 2D space.\n *\n * A UIAnchor serves as the fundamental building block for UI layout systems,\n * representing a single point with x and y coordinates. It provides constraint-based\n * positioning through solver variables and serves as an anchor point for more\n * complex UI elements.\n *\n * @see {@link UIPointElement} - Interface defining point element behavior\n * @see {@link UILayer} - Container layer for UI elements\n * @see {@link UISolverWrapper} - Constraint solver integration\n */\nexport abstract class UIAnchor extends Eventail implements UIPointElement {\n /** Optional name identifier for the anchor. */\n public name = \"\";\n\n /**\n * Solver variable descriptor for the x-coordinate.\n * This variable is managed by the constraint solver system.\n */\n public readonly xVariable: number;\n\n /**\n * Solver variable descriptor for the y-coordinate.\n * This variable is managed by the constraint solver system.\n */\n public readonly yVariable: number;\n\n /**\n * Reference to the constraint solver wrapper for variable management.\n * @see {@link UISolverWrapper}\n */\n protected readonly solverWrapper: UISolverWrapper;\n\n /**\n * Creates a new UIAnchor instance.\n *\n * @param layer - The UI layer that contains this anchor\n * @param x - Initial x-coordinate position\n * @param y - Initial y-coordinate position\n * @throws Will throw an error if x or y are not valid numbers\n * @see {@link assertValidNumber}\n */\n constructor(\n public readonly layer: UILayer,\n x: number,\n y: number,\n ) {\n assertValidNumber(x, \"UIAnchor x\");\n assertValidNumber(y, \"UIAnchor y\");\n\n super();\n this.solverWrapper = this.layer[\"getSolverWrapperInternal\"]();\n this.xVariable = this.solverWrapper.createVariable(x, UIPriority.P7);\n this.yVariable = this.solverWrapper.createVariable(y, UIPriority.P7);\n }\n\n /**\n * Gets the current x-coordinate value from the solver.\n * @returns The current x-coordinate position\n */\n public get x(): number {\n return this.solverWrapper.readVariableValue(this.xVariable);\n }\n\n /**\n * Gets the current y-coordinate value from the solver.\n * @returns The current y-coordinate position\n */\n public get y(): number {\n return this.solverWrapper.readVariableValue(this.yVariable);\n }\n\n /**\n * Sets the x-coordinate value through the solver system.\n * @param value - The new x-coordinate value\n * @throws Will throw an error if value is not a valid number\n * @see {@link assertValidNumber}\n */\n public set x(value: number) {\n assertValidNumber(value, \"UIAnchor x\");\n this.solverWrapper.suggestVariableValue(this.xVariable, value);\n }\n\n /**\n * Sets the y-coordinate value through the solver system.\n * @param value - The new y-coordinate value\n * @throws Will throw an error if value is not a valid number\n * @see {@link assertValidNumber}\n */\n public set y(value: number) {\n assertValidNumber(value, \"UIAnchor y\");\n this.solverWrapper.suggestVariableValue(this.yVariable, value);\n }\n\n /**\n * Destroys the anchor by removing its solver variables.\n *\n * This method cleans up the solver variables associated with this anchor,\n * effectively removing it from the constraint solving system. After calling\n * this method, the anchor should not be used anymore.\n */\n public destroy(): void {\n this.solverWrapper.removeVariable(this.yVariable);\n this.solverWrapper.removeVariable(this.xVariable);\n }\n}\n","import type { UILayer } from \"../layers/UILayer\";\nimport {\n assertValidPositiveNumber,\n type UIPlaneElement,\n} from \"../miscellaneous/asserts\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UIAnchor } from \"./UIAnchor\";\n\n/** Default width and height value for UIDummy elements. */\nconst DEFAULT_SIZE = 100;\n\n/**\n * Abstract UI element that extends UIAnchor with dimensions but without rendering.\n *\n * UIDummy represents a rectangular area in the UI layout system that has position\n * and dimensions (width and height) but does not perform any visual rendering.\n * It serves as a placeholder or spacer element in constraint-based layouts,\n * useful for defining layout structure without visual content.\n *\n * @see {@link UIAnchor} - Base class providing position functionality\n * @see {@link UIPlaneElement} - Interface defining dimensional element behavior\n * @see {@link UILayer} - Container layer for UI elements\n */\nexport abstract class UIDummy extends UIAnchor implements UIPlaneElement {\n /**\n * Solver variable descriptor for the width dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly wVariable: number;\n\n /**\n * Solver variable descriptor for the height dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly hVariable: number;\n\n /**\n * Creates a new UIDummy instance with position and dimensions.\n *\n * @param layer - The UI layer that contains this dummy element\n * @param x - Initial x-coordinate position\n * @param y - Initial y-coordinate position\n * @param width - Initial width dimension (defaults to 100)\n * @param height - Initial height dimension (defaults to 100)\n * @throws Will throw an error if width or height are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n constructor(\n layer: UILayer,\n x: number,\n y: number,\n width: number = DEFAULT_SIZE,\n height: number = DEFAULT_SIZE,\n ) {\n assertValidPositiveNumber(width, \"UIDummy width\");\n assertValidPositiveNumber(height, \"UIDummy height\");\n\n super(layer, x, y);\n this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);\n this.hVariable = this.solverWrapper.createVariable(height, UIPriority.P6);\n }\n\n /**\n * Gets the current width value from the solver.\n * @returns The current width dimension\n */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /**\n * Gets the current height value from the solver.\n * @returns The current height dimension\n */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /**\n * Sets the width value through the solver system.\n * @param value - The new width dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIDummy width\");\n this.solverWrapper.suggestVariableValue(this.wVariable, value);\n }\n\n /**\n * Sets the height value through the solver system.\n * @param value - The new height dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIDummy height\");\n this.solverWrapper.suggestVariableValue(this.hVariable, value);\n }\n\n /**\n * Destroys the dummy element by removing its solver variables.\n *\n * This method cleans up the dimension solver variables (width and height)\n * associated with this dummy element, then calls the parent destroy method\n * to clean up position variables. After calling this method, the dummy\n * element should not be used anymore.\n */\n public override destroy(): void {\n this.solverWrapper.removeVariable(this.hVariable);\n this.solverWrapper.removeVariable(this.wVariable);\n super.destroy();\n }\n}\n","import { MathUtils } from \"three\";\nimport { UIAnchorMode } from \"./UIAnchorMode\";\n\n/** Default position value for x and y coordinates. */\nconst DEFAULT_POSITION = 0;\n/** Default anchor point value for anchorX and anchorY. */\nconst DEFAULT_ANCHOR = 0.5;\n/** Default scale value for scaleX and scaleY. */\nconst DEFAULT_SCALE = 1;\n/** Default rotation value in radians. */\nconst DEFAULT_ROTATION = 0;\n\n/**\n * Micro-transformation system for non-constraint based UI element adjustments.\n *\n * UIMicro provides a lightweight transformation system that operates independently\n * of the constraint solver. It manages position offsets, anchor points, scaling,\n * and rotation transformations that can be applied to UI elements for animations,\n * visual effects, or fine-tuned positioning without affecting the constraint-based\n * layout system.\n *\n * All transformations are tracked with change detection to optimize rendering\n * performance by only recalculating when properties have actually changed.\n *\n * @see {@link UIElement} - Elements that use micro transformations\n */\nexport class UIMicro {\n /** Internal storage for x-coordinate offset. */\n private xInternal: number = DEFAULT_POSITION;\n /** Internal storage for y-coordinate offset. */\n private yInternal: number = DEFAULT_POSITION;\n /** Internal storage for x-axis anchor point. */\n private anchorXInternal: number = DEFAULT_ANCHOR;\n /** Internal storage for y-axis anchor point. */\n private anchorYInternal: number = DEFAULT_ANCHOR;\n /** Internal storage for x-axis scale factor. */\n private scaleXInternal: number = DEFAULT_SCALE;\n /** Internal storage for y-axis scale factor. */\n private scaleYInternal: number = DEFAULT_SCALE;\n /** Internal storage for rotation in radians. */\n private rotationInternal: number = DEFAULT_ROTATION;\n /** Internal storage for anchor mode determining which transformations are applied around the anchor point. */\n private anchorModeInternal: UIAnchorMode = UIAnchorMode.ROTATION_SCALE;\n /** Flag indicating if any transformation properties have changed. */\n private recalculationRequired = false;\n\n /**\n * Gets the x-coordinate offset for micro positioning.\n * @returns The x-offset value\n */\n public get x(): number {\n return this.xInternal;\n }\n\n /**\n * Gets the y-coordinate offset for micro positioning.\n * @returns The y-offset value\n */\n public get y(): number {\n return this.yInternal;\n }\n\n /**\n * Gets the x-axis anchor point for transformations.\n * @returns The anchor point (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public get anchorX(): number {\n return this.anchorXInternal;\n }\n\n /**\n * Gets the y-axis anchor point for transformations.\n * @returns The anchor point (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public get anchorY(): number {\n return this.anchorYInternal;\n }\n\n /**\n * Gets the x-axis scale factor.\n * @returns The scale factor (1.0 = normal size)\n */\n public get scaleX(): number {\n return this.scaleXInternal;\n }\n\n /**\n * Gets the y-axis scale factor.\n * @returns The scale factor (1.0 = normal size)\n */\n public get scaleY(): number {\n return this.scaleYInternal;\n }\n\n /**\n * Gets the uniform scale factor (maximum of scaleX and scaleY).\n * @returns The larger of the two scale factors\n */\n public get size(): number {\n return Math.max(this.scaleXInternal, this.scaleYInternal);\n }\n\n /**\n * Gets the rotation angle in degrees.\n * @returns The rotation angle in degrees\n */\n public get angle(): number {\n return MathUtils.radToDeg(this.rotationInternal);\n }\n\n /**\n * Gets the current anchor mode determining which transformations are applied around the anchor point.\n * @returns The anchor mode (ROTATION_SCALE or POSITION_ROTATION_SCALE)\n */\n public get anchorMode(): UIAnchorMode {\n return this.anchorModeInternal;\n }\n\n /**\n * Gets the rotation angle in radians.\n * @returns The rotation angle in radians\n */\n public get rotation(): number {\n return this.rotationInternal;\n }\n\n /**\n * Sets the x-coordinate offset for micro positioning.\n * @param value - The new x-offset value\n */\n public set x(value: number) {\n if (value !== this.xInternal) {\n this.xInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the y-coordinate offset for micro positioning.\n * @param value - The new y-offset value\n */\n public set y(value: number) {\n if (value !== this.yInternal) {\n this.yInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the x-axis anchor point for transformations.\n * @param value - The anchor point (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public set anchorX(value: number) {\n if (value !== this.anchorXInternal) {\n this.anchorXInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the y-axis anchor point for transformations.\n * @param value - The anchor point (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public set anchorY(value: number) {\n if (value !== this.anchorYInternal) {\n this.anchorYInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the x-axis scale factor.\n * @param value - The scale factor (1.0 = normal size)\n */\n public set scaleX(value: number) {\n if (value !== this.scaleXInternal) {\n this.scaleXInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the y-axis scale factor.\n * @param value - The scale factor (1.0 = normal size)\n */\n public set scaleY(value: number) {\n if (value !== this.scaleYInternal) {\n this.scaleYInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets both scale factors to the same value for uniform scaling.\n * @param value - The uniform scale factor (1.0 = normal size)\n */\n public set size(value: number) {\n if (value !== this.scaleXInternal || value !== this.scaleYInternal) {\n this.scaleXInternal = value;\n this.scaleYInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the rotation angle in degrees.\n * @param value - The rotation angle in degrees\n */\n public set angle(value: number) {\n const rotation = MathUtils.degToRad(value);\n if (rotation !== this.rotationInternal) {\n this.rotationInternal = rotation;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the rotation angle in radians.\n * @param value - The rotation angle in radians\n */\n public set rotation(value: number) {\n if (value !== this.rotationInternal) {\n this.rotationInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the anchor mode determining which transformations are applied around the anchor point.\n * @param value - The anchor mode (ROTATION_SCALE or POSITION_ROTATION_SCALE)\n */\n public set anchorMode(value: UIAnchorMode) {\n if (value !== this.anchorModeInternal) {\n this.anchorModeInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Resets all transformation properties to their default values.\n *\n * This method restores position (0,0), anchor (0,0), scale (1,1),\n * and rotation (0) to their initial states. Only triggers recalculation\n * if any values actually change.\n */\n public reset(): void {\n if (\n this.xInternal !== DEFAULT_POSITION ||\n this.yInternal !== 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 ) {\n this.xInternal = DEFAULT_POSITION;\n this.yInternal = 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.recalculationRequired = true;\n }\n }\n\n /**\n * Gets whether any transformation properties have changed since last reset.\n *\n * This method is used internally by the rendering system to determine\n * if transformation matrices need to be recalculated.\n *\n * @returns True if recalculation is required, false otherwise\n * @internal\n */\n protected [\"getRecalculationRequiredInternal\"](): boolean {\n return this.recalculationRequired;\n }\n\n /**\n * Resets the recalculation flag after transformations have been applied.\n *\n * This method is called internally by the rendering system after\n * transformation matrices have been updated.\n *\n * @internal\n */\n protected [\"resetRecalculationRequiredInternal\"](): void {\n this.recalculationRequired = false;\n }\n}\n","import { type Object3D } from \"three\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../miscellaneous/asserts\";\nimport { UIMicro } from \"../miscellaneous/UIMicro\";\nimport { UIMode } from \"../miscellaneous/UIMode\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport type { UISceneWrapper } from \"../wrappers/UISceneWrapper\";\nimport { UIAnchor } from \"./UIAnchor\";\n\n/**\n * Events that can be emitted by UI elements.\n */\nexport enum UIElementEvent {\n /** Emitted when the element is clicked. */\n CLICK = \"click\",\n}\n\n/**\n * Abstract base class for all renderable UI elements with dimensions.\n *\n * UIElement serves as the fundamental building block for all other UI elements\n * that need to be visually rendered. It extends UIAnchor with dimensional properties\n * and integrates with the Three.js rendering system through Object3D. This class\n * provides essential functionality for positioning, sizing, rendering, visibility,\n * z-index management, and user interaction.\n *\n * @template T - The type of Three.js Object3D used for rendering\n * @see {@link UIAnchor} - Base class providing position functionality\n * @see {@link UIPlaneElement} - Interface defining dimensional element behavior\n * @see {@link UISceneWrapper} - Scene management for rendering\n * @see {@link UIMicro} - Micro-optimization utilities\n */\nexport abstract class UIElement<T extends Object3D = Object3D>\n extends UIAnchor\n implements UIPlaneElement, UILayerElement\n{\n /** Micro-transformation system for non-constraint based positioning, scaling, and rotation adjustments. */\n public readonly micro = new UIMicro();\n\n /**\n * Solver variable descriptor for the width dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly wVariable: number;\n\n /**\n * Solver variable descriptor for the height dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly hVariable: number;\n\n /**\n * Reference to the scene wrapper for rendering management.\n * @see {@link UISceneWrapper}\n */\n protected readonly sceneWrapper: UISceneWrapper;\n\n /** Internal storage for the current visibility/interaction mode. */\n protected modeInternal: UIMode = UIMode.VISIBLE;\n\n /**\n * Creates a new UIElement instance with rendering capabilities.\n *\n * @param layer - The UI layer that contains this element\n * @param x - Initial x-coordinate position\n * @param y - Initial y-coordinate position\n * @param width - Initial width dimension (must be positive)\n * @param height - Initial height dimension (must be positive)\n * @param object - The Three.js Object3D used for rendering this element\n * @throws Will throw an error if width or height are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n constructor(\n layer: UILayer,\n x: number,\n y: number,\n width: number,\n height: number,\n protected readonly object: T,\n ) {\n assertValidPositiveNumber(width, \"UIElement width\");\n assertValidPositiveNumber(height, \"UIElement height\");\n\n super(layer, x, y);\n this.sceneWrapper = this.layer[\"getSceneWrapperInternal\"]();\n this.sceneWrapper.insertObject(this, this.object);\n this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);\n this.hVariable = this.solverWrapper.createVariable(height, UIPriority.P6);\n }\n\n /**\n * Gets the current width value from the solver.\n * @returns The current width dimension\n */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /**\n * Gets the current height value from the solver.\n * @returns The current height dimension\n */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /**\n * Gets the current z-index (depth) value from the scene.\n * @returns The current z-index for rendering order\n */\n public get zIndex(): number {\n return this.sceneWrapper.getZIndex(this);\n }\n\n /**\n * Gets the current visibility and interaction mode.\n * @returns The current UIMode setting\n * @see {@link UIMode}\n */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /**\n * Sets the width value through the solver system.\n * @param value - The new width dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIElement width\");\n this.solverWrapper.suggestVariableValue(this.wVariable, value);\n }\n\n /**\n * Sets the height value through the solver system.\n * @param value - The new height dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIElement height\");\n this.solverWrapper.suggestVariableValue(this.hVariable, value);\n }\n\n /**\n * Sets the z-index (depth) value for rendering order.\n * @param value - The new z-index value\n * @throws Will throw an error if value is not a valid number\n * @see {@link assertValidNumber}\n */\n public set zIndex(value: number) {\n assertValidNumber(value, \"UIElement zIndex\");\n this.sceneWrapper.setZIndex(this, value);\n }\n\n /**\n * Sets the visibility and interaction mode.\n * @param value - The new UIMode setting\n * @see {@link UIMode}\n */\n public set mode(value: UIMode) {\n if (value !== this.modeInternal) {\n this.modeInternal = value;\n this.sceneWrapper.setVisibility(this, value !== UIMode.HIDDEN);\n }\n }\n\n /**\n * Destroys the UI element by cleaning up all associated resources.\n *\n * This method removes the element from the rendering scene, cleans up\n * dimension solver variables, and calls the parent destroy method to\n * clean up position variables. After calling this method, the element\n * should not be used anymore.\n */\n public override destroy(): void {\n this.solverWrapper.removeVariable(this.hVariable);\n this.solverWrapper.removeVariable(this.wVariable);\n this.sceneWrapper.removeObject(this);\n super.destroy();\n }\n\n /**\n * Internal method for handling click events.\n *\n * Determines if the click coordinates intersect with this element's bounds\n * and emits a CLICK event if the element is in interactive mode.\n *\n * @param x - The x-coordinate of the click\n * @param y - The y-coordinate of the click\n * @returns True if the click was handled by this element\n */\n protected [\"onClickInternal\"](x: number, y: number): boolean {\n const isClicked =\n this.modeInternal === UIMode.INTERACTIVE &&\n x > this.x &&\n x < this.x + this.width &&\n y > this.y &&\n y < this.y + this.height;\n if (isClicked) {\n this.emit(UIElementEvent.CLICK, x, y, this);\n }\n return isClicked;\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial } from \"three\";\nimport fragmentShader from \"../shaders/UIMaterial.fs\";\nimport vertexShader from \"../shaders/UIMaterial.vs\";\n\nconst DEFAULT_ALPHA_TEST = 0.25;\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 alphaTest: { value: DEFAULT_ALPHA_TEST },\n },\n vertexShader,\n fragmentShader,\n transparent: false,\n alphaTest: DEFAULT_ALPHA_TEST,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: false,\n });\n }\n\n public getTexture(): Texture {\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 getTransparency(): boolean {\n return this.transparent;\n }\n\n public setTexture(value: Texture): this {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setColor(value: number): this {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setOpacity(value: number): this {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setTransparency(value: boolean): this {\n if (this.transparent !== value) {\n this.transparent = value;\n this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;\n this.needsUpdate = true;\n this.uniformsNeedUpdate = true;\n }\n return this;\n }\n}\n","import { PlaneGeometry } from \"three\";\n\nconst GEOMETRY_SIZE = 1;\nconst GEOMETRY_OFFSET = GEOMETRY_SIZE / 2;\n\nexport const geometry = new PlaneGeometry(\n GEOMETRY_SIZE,\n GEOMETRY_SIZE,\n).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);\n","import type { Texture } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport { UIMaterial } from \"../materials/UIMaterial\";\nimport { assertValidPositiveNumber } from \"../miscellaneous/asserts\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * UI element for displaying textured images.\n *\n * UIImage is a concrete implementation of UIElement that renders a textured\n * image using Three.js Mesh and UIMaterial. It automatically sizes itself\n * to match the texture dimensions and provides control over visual properties\n * such as color tinting, opacity, and transparency.\n *\n * @see {@link UIElement} - Base class providing UI element functionality\n * @see {@link UIMaterial} - Material system for rendering\n * @see {@link Texture} - Three.js texture for image data\n */\nexport class UIImage extends UIElement<Mesh> {\n /** The material used for rendering the image. */\n private readonly material: UIMaterial;\n\n /** Internal storage for the current texture. */\n private readonly textureInternal: Texture;\n\n /**\n * Creates a new UIImage instance.\n *\n * The image will automatically size itself to match the texture's dimensions.\n * The position defaults to (0, 0) if not specified.\n *\n * @param layer - The UI layer that contains this image\n * @param texture - The Three.js texture to display\n * @param x - Initial x-coordinate position (defaults to 0)\n * @param y - Initial y-coordinate position (defaults to 0)\n */\n constructor(layer: UILayer, texture: Texture, x = 0, y = 0) {\n const width = texture.image.width;\n const height = texture.image.height;\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, x, y, width, height, object);\n this.material = material;\n this.textureInternal = texture;\n }\n\n /**\n * Gets the current texture being displayed.\n * @returns The current Three.js texture\n */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /**\n * Gets the current color tint applied to the image.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the image.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the image.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Sets a new texture for the image.\n *\n * When setting a new texture, the image will automatically resize to match\n * the new texture's dimensions.\n *\n * @param value - The new Three.js texture to display\n * @throws Will throw an error if the texture dimensions are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n public set texture(value: Texture) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UIImage texture width\");\n assertValidPositiveNumber(height, \"UIImage texture height\");\n\n this.material.setTexture(value);\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n }\n\n /**\n * Sets the color tint applied to the image.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the image.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the image.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Destroys the image by cleaning up all associated resources.\n *\n * This method disposes of the material resources and calls the parent\n * destroy method to clean up the underlying UI element. After calling\n * this method, the image should not be used anymore.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, Vector2, Vector4 } from \"three\";\nimport fragmentShader from \"../shaders/UINineSliceMaterial.fs\";\nimport vertexShader from \"../shaders/UINineSliceMaterial.vs\";\n\nconst DEFAULT_ALPHA_TEST = 0.025;\n\nexport class UINineSliceMaterial extends ShaderMaterial {\n constructor(texture: Texture) {\n super({\n uniforms: {\n map: { value: texture },\n color: { value: new Color(0xffffff) },\n opacity: { value: 1.0 },\n alphaTest: { value: DEFAULT_ALPHA_TEST },\n sliceBorders: {\n value: new Vector4(0, 0, 0, 0),\n }, // left, right, top, bottom (in UV)\n quadSize: { value: new Vector2(1, 1) }, // width, height (in World)\n textureSize: {\n value: new Vector2(texture.image.width, texture.image.height),\n },\n },\n vertexShader,\n fragmentShader,\n transparent: false,\n alphaTest: DEFAULT_ALPHA_TEST,\n lights: false,\n fog: false,\n depthWrite: true,\n depthTest: true,\n });\n }\n\n public getSliceBorderLeft(): number {\n return this.uniforms.sliceBorders.value.x;\n }\n\n public getSliceBorderRight(): number {\n return this.uniforms.sliceBorders.value.y;\n }\n\n public getSliceBorderTop(): number {\n return this.uniforms.sliceBorders.value.z;\n }\n\n public getSliceBorderBottom(): number {\n return this.uniforms.sliceBorders.value.w;\n }\n\n public getQuadSize(): { w: number; h: number } {\n const quadSize = this.uniforms.quadSize.value;\n return { w: quadSize.x, h: quadSize.y };\n }\n\n public getTexture(): Texture {\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 getTransparency(): boolean {\n return this.transparent;\n }\n\n public setSliceBorderLeft(l: number): this {\n this.uniforms.sliceBorders.value.x = l;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorderRight(r: number): this {\n this.uniforms.sliceBorders.value.y = r;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorderTop(t: number): this {\n this.uniforms.sliceBorders.value.z = t;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorderBottom(b: number): this {\n this.uniforms.sliceBorders.value.w = b;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorder(l: number, r: number, t: number, b: number): this {\n this.uniforms.sliceBorders.value.set(l, r, t, b);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setQuadSize(w: number, h: number): this {\n this.uniforms.quadSize.value.set(w, h);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setTexture(value: Texture): this {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setColor(color: number): this {\n (this.uniforms.color.value as Color).setHex(color);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setOpacity(opacity: number): this {\n this.uniforms.opacity.value = opacity;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setTransparency(value: boolean): this {\n if (this.transparent !== value) {\n this.transparent = value;\n this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;\n this.needsUpdate = true;\n this.uniformsNeedUpdate = true;\n }\n return this;\n }\n}\n","const DEFAULT_SLICE_BORDER = 0.25;\n\nexport type UINineSliceBorder =\n | { left: number; right: number; top: number; bottom: number }\n | { horizontal: number; vertical: number }\n | number;\n\n/**\n * Resolves various nine-slice border inputs into a normalized border object.\n *\n * @param value - The border value to resolve (can be number, partial object, or full object)\n * @returns Normalized border object with left, right, top, bottom properties\n */\nexport function resolveNineSliceBorder(value: unknown): {\n left: number;\n right: number;\n top: number;\n bottom: number;\n} {\n // Handle null/undefined\n if (value === null || value === undefined) {\n return {\n left: DEFAULT_SLICE_BORDER,\n right: DEFAULT_SLICE_BORDER,\n top: DEFAULT_SLICE_BORDER,\n bottom: DEFAULT_SLICE_BORDER,\n };\n }\n\n // Handle number\n if (typeof value === \"number\") {\n return {\n left: value,\n right: value,\n top: value,\n bottom: value,\n };\n }\n\n // Handle object\n if (typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n\n // Handle { horizontal, vertical } format\n if (\"horizontal\" in obj && \"vertical\" in obj) {\n const horizontal =\n typeof obj.horizontal === \"number\"\n ? obj.horizontal\n : DEFAULT_SLICE_BORDER;\n const vertical =\n typeof obj.vertical === \"number\" ? obj.vertical : DEFAULT_SLICE_BORDER;\n\n return {\n left: horizontal,\n right: horizontal,\n top: vertical,\n bottom: vertical,\n };\n }\n\n // Handle { left, right, top, bottom } format\n const left = typeof obj.left === \"number\" ? obj.left : DEFAULT_SLICE_BORDER;\n const right =\n typeof obj.right === \"number\" ? obj.right : DEFAULT_SLICE_BORDER;\n const top = typeof obj.top === \"number\" ? obj.top : DEFAULT_SLICE_BORDER;\n const bottom =\n typeof obj.bottom === \"number\" ? obj.bottom : DEFAULT_SLICE_BORDER;\n\n return { left, right, top, bottom };\n }\n\n // Fallback to default\n return {\n left: DEFAULT_SLICE_BORDER,\n right: DEFAULT_SLICE_BORDER,\n top: DEFAULT_SLICE_BORDER,\n bottom: DEFAULT_SLICE_BORDER,\n };\n}\n","import type { Texture } from \"three\";\nimport { Mesh } from \"three\";\nimport { UILayerEvent, type UILayer } from \"../layers/UILayer\";\nimport { UINineSliceMaterial } from \"../materials/UINineSliceMaterial\";\nimport { assertValidPositiveNumber } from \"../miscellaneous/asserts\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport {\n resolveNineSliceBorder,\n type UINineSliceBorder,\n} from \"../miscellaneous/UINineSliceBorder\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Configuration options for creating a UINineSlice element.\n */\nexport interface UINineSliceOptions {\n /** Nine-slice border configuration (can be number, object with horizontal/vertical, or full border object) */\n sliceBorder: UINineSliceBorder;\n /** X position of the element */\n x: number;\n /** Y position of the element */\n y: number;\n}\n\n/**\n * Nine-slice UI element for scalable images with preserved border regions.\n *\n * Nine-slice scaling divides an image into 9 regions: 4 corners, 4 edges, and 1 center.\n * The corners maintain their original size, edges scale in one dimension, and the center\n * scales in both dimensions. This technique is commonly used for creating scalable UI\n * panels, buttons, and borders that maintain visual quality at any size.\n */\nexport class UINineSlice extends UIElement<Mesh> {\n private readonly material: UINineSliceMaterial;\n private readonly textureInternal: Texture;\n\n /**\n * Creates a new nine-slice UI element.\n *\n * @param layer - The UI layer to add this element to\n * @param texture - The texture to use for nine-slice rendering\n * @param options - Configuration options for the nine-slice element\n */\n constructor(\n layer: UILayer,\n texture: Texture,\n options: Partial<UINineSliceOptions> = {},\n ) {\n const w = texture.image.width;\n const h = texture.image.height;\n\n const material = new UINineSliceMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, options.x ?? 0, options.y ?? 0, w, h, object);\n this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n\n this.material = material;\n this.textureInternal = texture;\n\n const sliceBorder = resolveNineSliceBorder(options.sliceBorder);\n this.material.setSliceBorder(\n sliceBorder.left,\n sliceBorder.right,\n sliceBorder.top,\n sliceBorder.bottom,\n );\n }\n\n /**\n * Gets the left border size for nine-slice scaling.\n * @returns The left border size in texture UV coordinates\n */\n public get sliceBorderLeft(): number {\n return this.material.getSliceBorderLeft();\n }\n\n /**\n * Gets the right border size for nine-slice scaling.\n * @returns The right border size in texture UV coordinates\n */\n public get sliceBorderRight(): number {\n return this.material.getSliceBorderRight();\n }\n\n /**\n * Gets the top border size for nine-slice scaling.\n * @returns The top border size in texture UV coordinates\n */\n public get sliceBorderTop(): number {\n return this.material.getSliceBorderTop();\n }\n\n /**\n * Gets the bottom border size for nine-slice scaling.\n * @returns The bottom border size in texture UV coordinates\n */\n public get sliceBorderBottom(): number {\n return this.material.getSliceBorderBottom();\n }\n\n /**\n * Gets the current texture being displayed.\n * @returns The current Three.js texture\n */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /**\n * Gets the current color tint applied to the image.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the image.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the image.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Sets the left border size for nine-slice scaling.\n * @param value - The left border size in texture UV coordinates\n */\n public set sliceBorderLeft(value: number) {\n this.material.setSliceBorderLeft(value);\n }\n\n /**\n * Sets the right border size for nine-slice scaling.\n * @param value - The right border size in texture UV coordinates\n */\n public set sliceBorderRight(value: number) {\n this.material.setSliceBorderRight(value);\n }\n\n /**\n * Sets the top border size for nine-slice scaling.\n * @param value - The top border size in texture UV coordinates\n */\n public set sliceBorderTop(value: number) {\n this.material.setSliceBorderTop(value);\n }\n\n /**\n * Sets the bottom border size for nine-slice scaling.\n * @param value - The bottom border size in texture UV coordinates\n */\n public set sliceBorderBottom(value: number) {\n this.material.setSliceBorderBottom(value);\n }\n\n /**\n * Sets a new texture for the image.\n *\n * When setting a new texture, the image will automatically resize to match\n * the new texture's dimensions.\n *\n * @param value - The new Three.js texture to display\n * @throws Will throw an error if the texture dimensions are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n public set texture(value: Texture) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UINineSlice texture width\");\n assertValidPositiveNumber(height, \"UINineSlice texture height\");\n\n this.material.setTexture(value);\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n }\n\n /**\n * Sets the color tint applied to the image.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the image.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the image.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets all four border sizes for nine-slice scaling at once.\n *\n * @param left - The left border size in texture UV coordinates\n * @param right - The right border size in texture UV coordinates\n * @param top - The top border size in texture UV coordinates\n * @param bottom - The bottom border size in texture UV coordinates\n */\n public setSliceBorders(\n left: number,\n right: number,\n top: number,\n bottom: number,\n ): void {\n this.material.setSliceBorder(left, right, top, bottom);\n }\n\n /**\n * Destroys the nine-slice element and cleans up resources.\n *\n * This method removes event listeners, disposes of the material,\n * and calls the parent destroy method.\n */\n public override destroy(): void {\n this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n this.material.dispose();\n super.destroy();\n }\n\n /**\n * Internal render callback that updates the material's quad size.\n * This ensures the nine-slice scaling works correctly with micro transformations.\n */\n private readonly onWillRenderInternal = (): void => {\n this.material.setQuadSize(\n this.width * this.micro.scaleX,\n this.height * this.micro.scaleY,\n );\n };\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, UniformsUtils } from \"three\";\nimport fragmentShader from \"../shaders/UIProgressMaterial.fs\";\nimport vertexShader from \"../shaders/UIProgressMaterial.vs\";\n\nconst DEFAULT_ALPHA_TEST = 0.025;\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 backgroundOpacity: { value: 1 },\n foregroundOpacity: { value: 1 },\n alphaTest: { value: DEFAULT_ALPHA_TEST },\n angle: { value: 0 },\n direction: { value: 1 },\n },\n ]),\n vertexShader,\n fragmentShader,\n transparent: true,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: 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.backgroundColor.value as Color).getHex();\n }\n\n public getForegroundColor(): number {\n return (this.uniforms.foregroundColor.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 getTransparency(): boolean {\n return this.transparent;\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.backgroundColor.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundColor(value: number): void {\n (this.uniforms.foregroundColor.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 setTransparency(value: boolean): this {\n if (this.transparent !== value) {\n this.transparent = value;\n this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;\n this.needsUpdate = true;\n this.uniformsNeedUpdate = true;\n }\n return this;\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 } from \"three\";\nimport { MathUtils, Mesh } from \"three\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport { UIProgressMaterial } from \"../materials/UIProgressMaterial\";\nimport { assertValidPositiveNumber } from \"../miscellaneous/asserts\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Configuration options for creating a UIProgress element.\n */\nexport interface UIProgressOptions {\n /** X position of the element */\n x: number;\n /** Y position of the element */\n y: number;\n /** Optional background texture (if not provided, only foreground is shown) */\n textureBackground: Texture;\n /** Progress value between 0.0 (empty) and 1.0 (full) */\n progress: number;\n /** Direction of progress fill (true = forward, false = reverse) */\n isForwardDirection: boolean;\n /** Angle of progress fill in degrees (0 = horizontal, 90 = vertical) */\n angle: number;\n /** Background color tint as hex number (e.g., 0xFFFFFF) */\n backgroundColor: number;\n /** Foreground color tint as hex number (e.g., 0xFFFFFF) */\n foregroundColor: number;\n /** Background opacity between 0.0 (transparent) and 1.0 (opaque) */\n backgroundOpacity: number;\n /** Foreground opacity between 0.0 (transparent) and 1.0 (opaque) */\n foregroundOpacity: number;\n}\n\n/**\n * Progress bar UI element with customizable fill direction and appearance.\n *\n * UIProgress displays a progress bar that can be filled in various directions\n * (horizontal, vertical, or at custom angles). It supports separate background\n * and foreground textures with independent color tinting and opacity control.\n *\n * The progress value ranges from 0.0 (empty) to 1.0 (completely filled).\n * The fill direction can be controlled both by angle and forward/reverse direction.\n */\nexport class UIProgress extends UIElement<Mesh> {\n private readonly material: UIProgressMaterial;\n\n /**\n * Creates a new progress bar UI element.\n *\n * @param layer - The UI layer to add this element to\n * @param textureForeground - The texture used for the progress fill\n * @param options - Configuration options for the progress bar\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 assertValidPositiveNumber(\n foregroundWidth,\n \"UIProgress foreground texture width\",\n );\n assertValidPositiveNumber(\n foregroundHeight,\n \"UIProgress foreground texture height\",\n );\n\n const backgroundWidth = options.textureBackground?.image?.width;\n const backgroundHeight = options.textureBackground?.image?.height;\n\n if (options.textureBackground) {\n assertValidPositiveNumber(\n backgroundWidth,\n \"UIProgress background texture width\",\n );\n assertValidPositiveNumber(\n backgroundHeight,\n \"UIProgress background texture height\",\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 !== undefined) {\n material.setProgress(options.progress);\n }\n\n if (options.isForwardDirection !== undefined) {\n material.setIsForwardDirection(options.isForwardDirection);\n }\n\n if (options.angle !== undefined) {\n material.setAngle(MathUtils.degToRad(options.angle));\n }\n\n if (options.backgroundColor !== undefined) {\n material.setBackgroundColor(options.backgroundColor);\n }\n\n if (options.foregroundColor !== undefined) {\n material.setForegroundColor(options.foregroundColor);\n }\n\n if (options.backgroundOpacity !== undefined) {\n material.setBackgroundOpacity(options.backgroundOpacity);\n }\n\n if (options.foregroundOpacity !== undefined) {\n material.setForegroundOpacity(options.foregroundOpacity);\n }\n\n const imageWidth = backgroundWidth ?? foregroundWidth;\n const imageHeight = foregroundHeight ?? backgroundHeight;\n\n super(\n layer,\n options.x ?? 0,\n options.y ?? 0,\n imageWidth,\n imageHeight,\n object,\n );\n\n this.material = material;\n }\n\n /**\n * Gets the current progress value.\n * @returns Progress value between 0.0 (empty) and 1.0 (full)\n */\n public get progress(): number {\n return this.material.getProgress();\n }\n\n /**\n * Gets the background texture.\n * @returns The background texture, or undefined if none is set\n */\n public get backgroundTexture(): Texture | undefined {\n return this.material.getBackgroundTexture();\n }\n\n /**\n * Gets the foreground (fill) texture.\n * @returns The foreground texture\n */\n public get foregroundTexture(): Texture {\n return this.material.getForegroundTexture();\n }\n\n /**\n * Gets the background color tint.\n * @returns The background color as a hex number (e.g., 0xFFFFFF)\n */\n public get backgroundColor(): number {\n return this.material.getBackgroundColor();\n }\n\n /**\n * Gets the foreground color tint.\n * @returns The foreground color as a hex number (e.g., 0xFFFFFF)\n */\n public get foregroundColor(): number {\n return this.material.getForegroundColor();\n }\n\n /**\n * Gets the background opacity.\n * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get backgroundOpacity(): number {\n return this.material.getBackgroundOpacity();\n }\n\n /**\n * Gets the foreground opacity.\n * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get foregroundOpacity(): number {\n return this.material.getForegroundOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the image.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Gets the progress fill angle in degrees.\n * @returns Angle in degrees (0 = horizontal, 90 = vertical)\n */\n public get angle(): number {\n return MathUtils.radToDeg(this.material.getAngle());\n }\n\n /**\n * Gets whether the progress fills in forward direction.\n * @returns True if filling forward, false if filling in reverse\n */\n public get isForwardDirection(): boolean {\n return this.material.getIsForwardDirection();\n }\n\n /**\n * Sets the progress value.\n * @param value - Progress value between 0.0 (empty) and 1.0 (full)\n */\n public set progress(value: number) {\n this.material.setProgress(value);\n }\n\n /**\n * Sets the background texture.\n * @param value - The background texture, or undefined to remove background\n */\n public set backgroundTexture(value: Texture | undefined) {\n if (value) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UIProgress background texture width\");\n assertValidPositiveNumber(height, \"UIProgress background texture height\");\n }\n\n this.material.setBackgroundTexture(value);\n }\n\n /**\n * Sets the foreground (fill) texture.\n *\n * When setting a new texture, the progress bar will automatically resize\n * to match the new texture's dimensions.\n *\n * @param value - The new foreground texture\n * @throws Will throw an error if the texture dimensions are not valid positive numbers\n */\n public set foregroundTexture(value: Texture) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UIProgress foreground texture width\");\n assertValidPositiveNumber(height, \"UIProgress foreground texture height\");\n\n this.material.setForegroundTexture(value);\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n }\n\n /**\n * Sets the background color tint.\n * @param value - The background color as a hex number (e.g., 0xFFFFFF)\n */\n public set backgroundColor(value: number) {\n this.material.setBackgroundColor(value);\n }\n\n /**\n * Sets the foreground color tint.\n * @param value - The foreground color as a hex number (e.g., 0xFFFFFF)\n */\n public set foregroundColor(value: number) {\n this.material.setForegroundColor(value);\n }\n\n /**\n * Sets the background opacity.\n * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set backgroundOpacity(value: number) {\n this.material.setBackgroundOpacity(value);\n }\n\n /**\n * Sets the foreground opacity.\n * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set foregroundOpacity(value: number) {\n this.material.setForegroundOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the image.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets the progress fill angle.\n * @param value - Angle in degrees (0 = horizontal, 90 = vertical)\n */\n public set angle(value: number) {\n this.material.setAngle(MathUtils.degToRad(value));\n }\n\n /**\n * Sets the progress fill direction.\n * @param value - True for forward direction, false for reverse\n */\n public set isForwardDirection(value: boolean) {\n this.material.setIsForwardDirection(value);\n }\n\n /**\n * Destroys the progress bar element and cleans up resources.\n *\n * This method disposes of the material and calls the parent destroy method.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\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 { UILayerEvent, type UILayer } from \"../layers/UILayer\";\nimport { UIMaterial } from \"../materials/UIMaterial\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Update modes for controlling when the 3D scene should be re-rendered.\n */\nexport enum UISceneUpdateMode {\n /** Re-render the scene every frame. */\n EACH_FRAME = 1,\n /** Re-render the scene every second frame for performance. */\n EACH_SECOND_FRAME = 2,\n /** Re-render the scene only when properties change. */\n PROPERTY_CHANGED = 3,\n /** Re-render the scene only when manually requested. */\n MANUAL = 4,\n}\n\n/** Default resolution factor for render target sizing. */\nconst DEFAULT_RESOLUTION_FACTOR = 0.5;\n/** Minimum allowed resolution factor to prevent performance issues. */\nconst MIN_RESOLUTION_FACTOR = 0.1;\n/** Maximum allowed resolution factor to prevent memory issues. */\nconst MAX_RESOLUTION_FACTOR = 2;\n/** Default width for the scene render target in pixels. */\nconst DEFAULT_WIDTH = 512;\n/** Default height for the scene render target in pixels. */\nconst DEFAULT_HEIGHT = 512;\n/** Default field of view for the perspective camera in degrees. */\nconst DEFAULT_CAMERA_FOV = 75;\n/** Default near clipping plane distance for the camera. */\nconst DEFAULT_CAMERA_NEAR = 0.1;\n/** Default far clipping plane distance for the camera. */\nconst DEFAULT_CAMERA_FAR = 100;\n/** Default update mode for scene rendering. */\nconst DEFAULT_UPDATE_MODE = UISceneUpdateMode.PROPERTY_CHANGED;\n/** Default clear color for the render target. */\nconst DEFAULT_CLEAR_COLOR = 0x000000;\n/** Default clear alpha for the render target. */\nconst DEFAULT_CLEAR_ALPHA = 0;\n/** Default depth buffer usage setting. */\nconst DEFAULT_USE_DEPTH = true;\n\n/**\n * Configuration options for UIScene element creation.\n */\nexport interface UISceneOptions {\n /** Initial x-coordinate position. */\n x: number;\n /** Initial y-coordinate position. */\n y: number;\n /** Width of the scene render target in pixels. */\n width: number;\n /** Height of the scene render target in pixels. */\n height: number;\n\n /** Three.js scene to render. */\n scene: Scene;\n /** Camera to use for rendering the scene. */\n camera: Camera;\n /** Update mode controlling when the scene is re-rendered. */\n updateMode: UISceneUpdateMode;\n /** Resolution factor for render target sizing (0.1 to 2.0). */\n resolutionFactor: number;\n /** Clear color for the render target background. */\n clearColor: number;\n /** Clear alpha for the render target background. */\n clearAlpha: number;\n /** Whether to enable depth buffer for the render target. */\n enableDepthBuffer: boolean;\n}\n\n/**\n * UI element for rendering 3D scenes to texture within the UI system.\n *\n * UIScene is a concrete implementation of UIElement that renders a Three.js\n * scene to a WebGL render target and displays it as a texture. It provides\n * control over rendering frequency, resolution, and visual properties. This\n * allows embedding complex 3D content within the 2D UI layout system with\n * performance optimizations through configurable update modes.\n *\n * @see {@link UIElement} - Base class providing UI element functionality\n * @see {@link UISceneUpdateMode} - Update mode configuration\n * @see {@link Scene} - Three.js scene for 3D content\n * @see {@link Camera} - Three.js camera for scene rendering\n */\nexport class UIScene extends UIElement<Mesh> {\n /** The material used for rendering the scene texture. */\n private readonly material: UIMaterial;\n\n /** The WebGL render target for off-screen scene rendering. */\n private readonly renderTarget: WebGLRenderTarget;\n\n /** Internal storage for the current Three.js scene. */\n private sceneInternal: Scene;\n /** Internal storage for the current camera. */\n private cameraInternal: Camera;\n /** Internal storage for the current update mode. */\n private updateModeInternal: UISceneUpdateMode;\n /** Internal storage for the current resolution factor. */\n private resolutionFactorInternal: number;\n /** Internal storage for the current clear color. */\n private clearColorInternal: number;\n /** Internal storage for the current clear alpha. */\n private clearAlphaInternal: number;\n\n /** Frame alternation boolean for EACH_SECOND_FRAME update mode. */\n private frameBoolean = true;\n /** Flag indicating if properties have changed requiring a re-render. */\n private propertyChanged = false;\n /** Flag indicating if a manual render has been requested. */\n private renderRequired = false;\n\n /**\n * Creates a new UIScene instance with 3D scene rendering capabilities.\n *\n * The scene element creates a WebGL render target for off-screen rendering\n * and displays the result as a texture. A default perspective camera is\n * created if none is provided.\n *\n * @param layer - The UI layer that contains this scene element\n * @param options - Configuration options for scene rendering\n * @throws Will throw an error if resolution factor is outside valid range (0.1-2.0)\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 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.enableDepthBuffer ?? 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, 0, 0, width, height, object);\n this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n\n this.material = material;\n this.renderTarget = renderTarget;\n\n this.sceneInternal = options.scene ?? new Scene();\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n DEFAULT_CAMERA_FOV,\n width / height,\n DEFAULT_CAMERA_NEAR,\n DEFAULT_CAMERA_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n this.updateModeInternal = options.updateMode ?? DEFAULT_UPDATE_MODE;\n\n this.clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;\n this.clearAlphaInternal = options.clearAlpha ?? DEFAULT_CLEAR_ALPHA;\n\n if (options.updateMode === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.renderRequired = true;\n }\n }\n\n /**\n * Gets the current color tint applied to the scene texture.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the scene texture.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the scene texture.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Gets the Three.js scene being rendered.\n * @returns The current Three.js scene\n */\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n /**\n * Gets the camera used for rendering the scene.\n * @returns The current Three.js camera\n */\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n /**\n * Gets the current update mode controlling render frequency.\n * @returns The current update mode\n */\n public get updateMode(): UISceneUpdateMode {\n return this.updateModeInternal;\n }\n\n /**\n * Gets the resolution factor for render target sizing.\n * @returns The resolution factor between 0.1 and 2.0\n */\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n /**\n * Gets the clear color used for the render target background.\n * @returns The clear color as a number\n */\n public get clearColor(): number {\n return this.clearColorInternal;\n }\n\n /**\n * Gets the clear alpha used for the render target background.\n * @returns The clear alpha value between 0.0 and 1.0\n */\n public get clearAlpha(): number {\n return this.clearAlphaInternal;\n }\n\n /**\n * Sets the color tint applied to the scene texture.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the scene texture.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the scene texture.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets a new Three.js scene to render and marks for re-render.\n * @param value - The new Three.js scene\n */\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets a new camera for rendering and marks for re-render.\n * @param value - The new Three.js camera\n */\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the update mode controlling render frequency and marks for re-render.\n * @param value - The new update mode\n */\n public set updateMode(value: UISceneUpdateMode) {\n if (this.updateModeInternal !== value) {\n this.updateModeInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the resolution factor and resizes the render target accordingly.\n * @param value - The new resolution factor between 0.1 and 2.0\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 this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the clear color for the render target background and marks for re-render.\n * @param value - The new clear color as a number\n */\n public set clearColor(value: number) {\n if (this.clearColorInternal !== value) {\n this.clearColorInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the clear alpha for the render target background and marks for re-render.\n * @param value - The new clear alpha value between 0.0 and 1.0\n */\n public set clearAlpha(value: number) {\n if (this.clearAlphaInternal !== value) {\n this.clearAlphaInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Destroys the scene element by cleaning up all associated resources.\n *\n * This method disposes of the material and render target resources,\n * and calls the parent destroy method to clean up the underlying UI element.\n * After calling this method, the scene element should not be used anymore.\n */\n public override destroy(): void {\n this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n this.material.dispose();\n this.renderTarget.dispose();\n super.destroy();\n }\n\n /**\n * Manually requests a re-render of the scene.\n *\n * This method is useful when the update mode is set to MANUAL and you\n * want to trigger a scene re-render without changing any properties.\n */\n public requestRender(): void {\n this.renderRequired = true;\n }\n\n private readonly onWillRenderInternal = (renderer: WebGLRenderer): void => {\n if (\n this.updateModeInternal === UISceneUpdateMode.EACH_FRAME ||\n (this.updateModeInternal === UISceneUpdateMode.EACH_SECOND_FRAME &&\n this.frameBoolean) ||\n (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED &&\n this.propertyChanged) ||\n (this.updateModeInternal === UISceneUpdateMode.MANUAL &&\n this.renderRequired)\n ) {\n this.renderRequired = false;\n this.propertyChanged = false;\n this.frameBoolean = !this.frameBoolean;\n\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}\n","import {\n assertValidNonNegativeNumber,\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"./asserts\";\n\nexport 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 function isUITextStyle(obj: unknown): obj is UITextStyle {\n if (typeof obj !== \"object\" || obj === null) {\n return false;\n }\n\n const candidate = obj as Record<string, unknown>;\n\n return (\n typeof candidate.color === \"string\" &&\n typeof candidate.fontFamily === \"string\" &&\n typeof candidate.fontSize === \"number\" &&\n (candidate.fontStyle === \"normal\" ||\n candidate.fontStyle === \"italic\" ||\n candidate.fontStyle === \"oblique\") &&\n (candidate.fontWeight === \"normal\" ||\n candidate.fontWeight === \"bold\" ||\n candidate.fontWeight === \"bolder\" ||\n candidate.fontWeight === \"lighter\" ||\n typeof candidate.fontWeight === \"number\") &&\n typeof candidate.lineHeight === \"number\" &&\n typeof candidate.enableShadow === \"boolean\" &&\n typeof candidate.shadowOffsetX === \"number\" &&\n typeof candidate.shadowOffsetY === \"number\" &&\n typeof candidate.shadowBlur === \"number\" &&\n typeof candidate.shadowColor === \"string\" &&\n typeof candidate.enableStroke === \"boolean\" &&\n typeof candidate.strokeColor === \"string\" &&\n typeof candidate.strokeWidth === \"number\"\n );\n}\n\nconst DEFAULT_TEXT_STYLE: UITextStyle = {\n color: \"#000000\",\n\n fontFamily: \"Arial\",\n fontSize: 16,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n lineHeight: 1.2,\n\n enableShadow: false,\n shadowOffsetX: 0,\n shadowOffsetY: 0,\n shadowBlur: 0,\n shadowColor: \"transparent\",\n\n enableStroke: false,\n strokeColor: \"#000000\",\n strokeWidth: 0,\n};\n\nexport function resolveTextStyle(\n style?: Partial<UITextStyle>,\n commonStyle?: Partial<UITextStyle>,\n): UITextStyle {\n const fontSize =\n style?.fontSize ?? commonStyle?.fontSize ?? DEFAULT_TEXT_STYLE.fontSize;\n assertValidPositiveNumber(fontSize, \"Font size\");\n\n const fontWeight = style?.fontWeight ?? commonStyle?.fontWeight ?? \"normal\";\n if (typeof fontWeight === \"number\") {\n assertValidPositiveNumber(fontWeight, \"Font weight\");\n }\n\n const lineHeight =\n style?.lineHeight ??\n commonStyle?.lineHeight ??\n fontSize * DEFAULT_TEXT_STYLE.lineHeight;\n assertValidNumber(lineHeight, \"Line height\");\n\n const shadowOffsetX =\n style?.shadowOffsetX ??\n commonStyle?.shadowOffsetX ??\n DEFAULT_TEXT_STYLE.shadowOffsetX;\n assertValidNonNegativeNumber(shadowOffsetX, \"Shadow offset X\");\n\n const shadowOffsetY =\n style?.shadowOffsetY ??\n commonStyle?.shadowOffsetY ??\n DEFAULT_TEXT_STYLE.shadowOffsetY;\n assertValidNonNegativeNumber(shadowOffsetY, \"Shadow offset Y\");\n\n const shadowBlur =\n style?.shadowBlur ??\n commonStyle?.shadowBlur ??\n DEFAULT_TEXT_STYLE.shadowBlur;\n assertValidNonNegativeNumber(shadowBlur, \"Shadow blur\");\n\n const strokeWidth =\n style?.strokeWidth ??\n commonStyle?.strokeWidth ??\n DEFAULT_TEXT_STYLE.strokeWidth;\n assertValidNonNegativeNumber(strokeWidth, \"Stroke width\");\n\n return {\n color: style?.color ?? commonStyle?.color ?? DEFAULT_TEXT_STYLE.color,\n\n fontFamily:\n style?.fontFamily ??\n commonStyle?.fontFamily ??\n DEFAULT_TEXT_STYLE.fontFamily,\n fontSize,\n fontStyle:\n style?.fontStyle ??\n commonStyle?.fontStyle ??\n DEFAULT_TEXT_STYLE.fontStyle,\n fontWeight,\n lineHeight,\n\n enableShadow:\n style?.enableShadow ??\n commonStyle?.enableShadow ??\n DEFAULT_TEXT_STYLE.enableShadow,\n shadowOffsetX,\n shadowOffsetY,\n shadowBlur,\n shadowColor:\n style?.shadowColor ??\n commonStyle?.shadowColor ??\n DEFAULT_TEXT_STYLE.shadowColor,\n\n enableStroke:\n style?.enableStroke ??\n commonStyle?.enableStroke ??\n DEFAULT_TEXT_STYLE.enableStroke,\n strokeColor:\n style?.strokeColor ??\n commonStyle?.strokeColor ??\n DEFAULT_TEXT_STYLE.strokeColor,\n strokeWidth,\n };\n}\n","import type {\n UIChunkMetrics,\n UITextChunk,\n UITextContent,\n UITextLine,\n UITextSize,\n} from \"./textInterfaces\";\nimport { resolveTextStyle, type UITextStyle } from \"./UITextStyle\";\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 = Math.ceil(metrics.width);\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width,\n height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: style.lineHeight,\n };\n}\n\nexport function buildLines(\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 calculateTextSize(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 totalHeight += i === 0 ? line.height : line.lineHeight;\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\nexport function calculateTextContentParameters(\n context: CanvasRenderingContext2D,\n content: UITextContent,\n maxLineWidth: number,\n commonStyle?: Partial<UITextStyle>,\n): { lines: UITextLine[]; size: UITextSize } {\n const chunks: UITextChunk[] = [];\n\n for (const span of Array.isArray(content) ? content : [content]) {\n const isSpanString = typeof span === \"string\";\n const spanString = isSpanString ? span : span.text;\n const style = resolveTextStyle(\n isSpanString ? undefined : span.style,\n commonStyle,\n );\n\n for (const text of splitText(spanString)) {\n const metrics = measureTextChunk(context, text, style);\n chunks.push({ text, style, metrics });\n }\n }\n\n const lines = buildLines(maxLineWidth, chunks);\n const textSize = calculateTextSize(lines);\n\n return { lines, size: textSize };\n}\n","import { assertValidNonNegativeNumber } from \"./asserts\";\n\nexport interface UITextPadding {\n left: number;\n right: number;\n top: number;\n bottom: number;\n}\n\nexport function resolvePadding(value: unknown): UITextPadding {\n if (typeof value === \"number\") {\n return { left: value, right: value, top: value, bottom: value };\n }\n\n if (typeof value === \"object\" && value !== null) {\n const left =\n \"left\" in value && typeof value.left === \"number\" ? value.left : 0;\n const right =\n \"right\" in value && typeof value.right === \"number\" ? value.right : 0;\n const top = \"top\" in value && typeof value.top === \"number\" ? value.top : 0;\n const bottom =\n \"bottom\" in value && typeof value.bottom === \"number\" ? value.bottom : 0;\n\n assertValidNonNegativeNumber(left, \"Padding left\");\n assertValidNonNegativeNumber(right, \"Padding right\");\n assertValidNonNegativeNumber(top, \"Padding top\");\n assertValidNonNegativeNumber(bottom, \"Padding bottom\");\n\n return { left, right, top, bottom };\n }\n\n return { left: 0, right: 0, top: 0, bottom: 0 };\n}\n","import { CanvasTexture, Mesh } from \"three\";\nimport { UILayerEvent, type UILayer } from \"../layers/UILayer\";\nimport { UIMaterial } from \"../materials/UIMaterial\";\nimport type { UITextContent } from \"../miscellaneous/textInterfaces\";\nimport {\n calculateTextContentParameters,\n renderTextLines,\n} from \"../miscellaneous/textTools\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport {\n resolvePadding,\n type UITextPadding,\n} from \"../miscellaneous/UITextPadding\";\nimport { type UITextStyle } from \"../miscellaneous/UITextStyle\";\nimport { UIElement } from \"./UIElement\";\n\n/** Default maximum width for text elements in pixels. */\nconst DEFAULT_MAX_WIDTH = 1024;\n\n/**\n * Configuration options for UIText element creation.\n */\nexport interface UITextOptions {\n /** Maximum width in pixels before text wrapping occurs. */\n maxWidth: number;\n /** Padding configuration for text content. */\n padding: Partial<UITextPadding>;\n /** Common style properties applied to all text content. */\n commonStyle: Partial<UITextStyle>;\n /** X-coordinate of the text element. */\n x: number;\n /** Y-coordinate of the text element. */\n y: number;\n}\n\n/**\n * UI element for rendering dynamic text with canvas-based rendering.\n *\n * UIText is a concrete implementation of UIElement that renders text content\n * using HTML5 Canvas and displays it as a texture. It supports rich text\n * formatting, automatic text wrapping, padding, and dynamic resizing based\n * on content. The text is rendered to a canvas texture which is then applied\n * to a Three.js mesh for display in the 3D scene.\n *\n * @see {@link UIElement} - Base class providing UI element functionality\n * @see {@link UITextContent} - Text content structure\n * @see {@link UITextStyle} - Text styling options\n * @see {@link UITextPadding} - Padding configuration\n */\nexport class UIText extends UIElement<Mesh> {\n /** The material used for rendering the text texture. */\n private readonly material: UIMaterial;\n\n /** The canvas texture containing the rendered text. */\n private readonly texture: CanvasTexture;\n\n /** The HTML canvas element used for text rendering. */\n private readonly canvas: HTMLCanvasElement;\n\n /** The 2D rendering context for drawing text on the canvas. */\n private readonly context: CanvasRenderingContext2D;\n\n /** Internal storage for the current text content. */\n private contentInternal: UITextContent;\n\n /** Internal storage for the maximum width before text wrapping. */\n private maxWidthInternal: number;\n\n /** Internal storage for the current padding configuration. */\n private paddingInternal: UITextPadding;\n\n /** Internal storage for the common text style properties. */\n private commonStyleInternal: Partial<UITextStyle>;\n\n /** Target aspect ratio for the text element based on content. */\n private targetAspectRatio = 1;\n\n /** Last calculated aspect ratio for comparison during rendering. */\n private lastAspectRatio = 1;\n\n /**\n * Creates a new UIText instance with dynamic text rendering.\n *\n * The text element will automatically size itself based on the content\n * and specified options. A canvas is created for rendering the text,\n * which is then used as a texture for the 3D mesh.\n *\n * @param layer - The UI layer that contains this text element\n * @param content - The text content to display\n * @param options - Configuration options for text rendering\n * @param x - Initial x-coordinate position (defaults to 0)\n * @param y - Initial y-coordinate position (defaults to 0)\n * @throws Will throw an error if canvas context creation fails\n */\n constructor(\n layer: UILayer,\n content: UITextContent,\n options: 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 texture = new CanvasTexture(canvas);\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, options.x ?? 0, options.y ?? 0, 2, 2, object);\n this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n\n this.material = material;\n this.texture = texture;\n\n this.canvas = canvas;\n this.context = context;\n\n this.contentInternal = content;\n this.maxWidthInternal = options.maxWidth ?? DEFAULT_MAX_WIDTH;\n this.paddingInternal = resolvePadding(options.padding);\n this.commonStyleInternal = options.commonStyle ?? {};\n\n this.rebuildText();\n }\n\n /**\n * Gets the current color tint applied to the text.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the text.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the text.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Gets the current text content being displayed.\n * @returns The current text content structure\n */\n public get content(): UITextContent {\n return this.contentInternal;\n }\n\n /**\n * Gets the maximum width before text wrapping occurs.\n * @returns The maximum width in pixels\n */\n public get maxWidth(): number {\n return this.maxWidthInternal;\n }\n\n /**\n * Gets the current padding configuration.\n * @returns The padding configuration for all sides\n */\n public get padding(): UITextPadding {\n return this.paddingInternal;\n }\n\n /**\n * Gets the common style properties applied to the text.\n * @returns The partial text style configuration\n */\n public get commonStyle(): Partial<UITextStyle> {\n return this.commonStyleInternal;\n }\n\n /**\n * Sets the color tint applied to the text.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the text.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the text.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets new text content and triggers a rebuild.\n * @param value - The new text content structure\n */\n public set content(value: UITextContent) {\n this.contentInternal = value;\n this.rebuildText();\n }\n\n /**\n * Sets the maximum width before text wrapping and triggers a rebuild.\n * @param value - The new maximum width in pixels\n */\n public set maxWidth(value: number) {\n this.maxWidthInternal = value;\n this.rebuildText();\n }\n\n /**\n * Sets new padding configuration and triggers a rebuild.\n * @param value - The new padding configuration\n */\n public set padding(value: UITextPadding) {\n this.paddingInternal = value;\n this.rebuildText();\n }\n\n /**\n * Sets new common style properties and triggers a rebuild.\n * @param value - The new partial text style configuration\n */\n public set commonStyle(value: Partial<UITextStyle>) {\n this.commonStyleInternal = value;\n this.rebuildText();\n }\n\n /**\n * Destroys the text element by cleaning up all associated resources.\n *\n * This method disposes of the material and texture resources, removes\n * the canvas element from the DOM, and calls the parent destroy method\n * to clean up the underlying UI element. After calling this method,\n * the text element should not be used anymore.\n */\n public override destroy(): void {\n this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n this.material.dispose();\n this.texture.dispose();\n this.canvas.remove();\n super.destroy();\n }\n\n private readonly onWillRenderInternal = (): void => {\n if (this.lastAspectRatio !== this.width / this.height) {\n this.lastAspectRatio = this.targetAspectRatio;\n this.height = this.width / this.targetAspectRatio;\n }\n };\n\n /**\n * Rebuilds the text canvas and texture based on current content and settings.\n *\n * This method calculates the text layout, resizes the canvas to fit the content\n * with padding, renders the text lines to the canvas, and updates the texture.\n * It also calculates and sets the target aspect ratio for proper display.\n *\n * @private\n */\n private rebuildText(): void {\n const { lines, size } = calculateTextContentParameters(\n this.context,\n this.content,\n this.maxWidthInternal,\n this.commonStyleInternal,\n );\n\n this.canvas.width =\n size.width + this.paddingInternal.left + this.paddingInternal.right;\n this.canvas.height =\n size.height + this.paddingInternal.top + this.paddingInternal.bottom;\n\n this.width = this.canvas.width;\n this.height = this.canvas.height;\n\n this.targetAspectRatio =\n (size.width + this.paddingInternal.left + this.paddingInternal.right) /\n (size.height + this.paddingInternal.top + this.paddingInternal.bottom);\n\n renderTextLines(\n this.paddingInternal.top,\n this.paddingInternal.left,\n lines,\n this.context,\n );\n this.texture.needsUpdate = true;\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../miscellaneous/asserts\";\nimport { UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UILayer } from \"./UILayer\";\n\n/**\n * UI layer that manages fullscreen interfaces with optional fixed dimensions and automatic scaling.\n *\n * UIFullscreenLayer extends UILayer to provide automatic browser window integration,\n * handling window resize events and pointer interactions. It supports optional fixed\n * width or height constraints that enable responsive scaling while maintaining\n * design proportions across different screen sizes.\n *\n * The layer automatically calculates scaling factors based on the orientation and\n * fixed dimension constraints, ensuring consistent layout appearance regardless\n * of the actual browser window size.\n *\n * @see {@link UILayer} - Base layer functionality\n * @see {@link UIOrientation} - Orientation-based scaling behavior\n */\nexport class UIFullscreenLayer extends UILayer {\n /** Internal storage for the optional fixed width constraint. */\n private fixedWidthInternal?: number;\n /** Internal storage for the optional fixed height constraint. */\n private fixedHeightInternal?: number;\n\n /**\n * Creates a new UIFullscreenLayer instance with optional fixed dimensions.\n *\n * The layer will automatically resize to match the browser window and set up\n * event listeners for window resize and pointer events. Fixed dimensions\n * enable proportional scaling while maintaining design aspect ratios.\n *\n * @param fixedWidth - Optional fixed width for proportional scaling\n * @param fixedHeight - Optional fixed height for proportional scaling\n * @throws Will throw an error if fixed dimensions are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n constructor(fixedWidth: number | undefined, fixedHeight: number | undefined) {\n if (fixedWidth !== undefined) {\n assertValidPositiveNumber(fixedWidth, \"UIFullscreenLayer.fixedWidth\");\n }\n if (fixedHeight !== undefined) {\n assertValidPositiveNumber(fixedHeight, \"UIFullscreenLayer.fixedHeight\");\n }\n\n super(1, 1);\n this.fixedWidthInternal = fixedWidth;\n this.fixedHeightInternal = fixedHeight;\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"pointerdown\", this.onClick);\n this.onResize();\n }\n\n /**\n * Gets the current fixed width constraint.\n * @returns The fixed width in pixels, or undefined if not set\n */\n public get fixedWidth(): number | undefined {\n return this.fixedWidthInternal;\n }\n\n /**\n * Gets the current fixed height constraint.\n * @returns The fixed height in pixels, or undefined if not set\n */\n public get fixedHeight(): number | undefined {\n return this.fixedHeightInternal;\n }\n\n /**\n * Sets a new fixed width constraint and triggers resize recalculation.\n * @param value - The new fixed width in pixels, or undefined to remove constraint\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set fixedWidth(value: number | undefined) {\n if (value !== undefined) {\n assertValidPositiveNumber(value, \"UIFullscreenLayer.fixedWidth\");\n }\n\n if (value !== this.fixedWidthInternal) {\n this.fixedWidthInternal = value;\n this.onResize();\n }\n }\n\n /**\n * Sets a new fixed height constraint and triggers resize recalculation.\n * @param value - The new fixed height in pixels, or undefined to remove constraint\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set fixedHeight(value: number | undefined) {\n if (value !== undefined) {\n assertValidPositiveNumber(value, \"UIFullscreenLayer.fixedHeight\");\n }\n\n if (value !== this.fixedHeightInternal) {\n this.fixedHeightInternal = value;\n this.onResize();\n }\n }\n\n /**\n * Destroys the fullscreen layer by removing all event listeners.\n *\n * This method cleans up window event listeners for resize and pointer events.\n * After calling this method, the layer will no longer respond to window\n * changes and should not be used anymore.\n */\n public destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"pointerdown\", this.onClick);\n }\n\n /**\n * Renders the fullscreen layer and all its contained elements.\n *\n * Clears the depth and stencil buffers and delegates rendering to the\n * parent layer's render method. This ensures proper rendering order\n * and buffer management for fullscreen interfaces.\n *\n * @param renderer - The WebGL renderer instance\n * @param deltaTime - Time elapsed since the last frame in seconds\n * @throws Will throw an error if deltaTime is not a valid number\n * @see {@link assertValidNumber}\n */\n public render(renderer: WebGLRenderer, deltaTime: number): void {\n assertValidNumber(deltaTime, \"UIFullscreenLayer.deltaTime\");\n super.renderInternal(renderer, deltaTime);\n }\n\n /**\n * Calculates the scaling factor based on orientation and fixed dimensions.\n *\n * The scaling factor is determined by the current orientation and which\n * fixed dimension constraint is active. In horizontal orientation, fixed\n * width takes precedence; in vertical orientation, fixed height takes precedence.\n *\n * @returns The scaling factor to apply to window dimensions\n * @private\n */\n private calculateScale(): number {\n if (this.orientation === UIOrientation.HORIZONTAL) {\n if (this.fixedWidth !== undefined) {\n return this.fixedWidth / window.innerWidth;\n } else if (this.fixedHeight !== undefined) {\n return this.fixedHeight / window.innerHeight;\n } else {\n return 1;\n }\n } else {\n if (this.fixedHeight !== undefined) {\n return this.fixedHeight / window.innerHeight;\n } else if (this.fixedWidth !== undefined) {\n return this.fixedWidth / window.innerWidth;\n } else {\n return 1;\n }\n }\n }\n\n /**\n * Event handler for window resize events.\n *\n * Recalculates the scaling factor and updates the layer dimensions\n * based on the new window size and fixed dimension constraints.\n *\n * @private\n */\n private readonly onResize = (): void => {\n const scale = this.calculateScale();\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n /**\n * Event handler for pointer down events.\n *\n * Converts browser pointer coordinates to layer coordinates by accounting\n * for element positioning and applying the appropriate scaling factor.\n * The y-coordinate is flipped to match the UI coordinate system.\n *\n * @param event - The pointer event from the browser\n * @private\n */\n private readonly onClick = (event: PointerEvent): void => {\n const r =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\n const x = r ? event.clientX - r.left : event.clientX;\n const y = r ? r.bottom - event.clientY : window.innerHeight - event.clientY;\n\n const scale = this.calculateScale();\n this.clickInternal(x * scale, y * scale);\n };\n}\n","import { isUITextStyle, type UITextStyle } from \"./UITextStyle\";\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 (!(\"style\" in obj) || isUITextStyle(obj.style))\n );\n}\n"],"names":["UIExpression","constructor","constant","terms","this","Map","plus","a","b","result","Array","from","entries","variableIndex","coefficient","_private_terms","minus","set","get","multiply","value","divide","hasTerm","has","copy","expression","clear","clone","t","i","r","WeakMap","insert","s","remove","delete","size","getPriority","o","on","h","once","off","u","v","slice","length","l","_","p","e","shift","n","pop","M","splice","c","emit","apply","k","m","Error","push","unshift","UIMode","UIOrientation","resolveOrientation","orientation","ALWAYS","createMap","IndexedMap","index","array","empty","itemAt","contains","key","undefined","id","find","setDefault","factory","pair","Pair","erase","last","first","second","Variable","name","_name","_id","setName","context","_context","setContext","_value","setValue","Expression","toJSON","toString","VarId","parsed","args","item","terms2","j","termPair","value2","parseArgs","arguments","_terms","_constant","isConstant","map","join","Strength","create","w","Math","max","min","static","clip","required","Operator","Constraint","operator","rhs","strength","_operator","_strength","_expression","op","CnId","Solver","maxIterations","createConstraint","lhs","cn","addConstraint","constraint","_cnMap","data","_createRow","row","tag","subject","_chooseSubject","type","SymbolType","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_rowMap","_optimize","_objective","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","getConstraints","addEditVariable","variable","_editMap","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_infeasibleRows","_dualOptimize","other","coeff","coefficientFor","External","updateVariables","vars","_varMap","_getVarSymbol","_makeSymbol","Row","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","_artificial","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","iterations","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_idTick","createCnMap","createRowMap","createVarMap","createEditMap","_type","_cellMap","theCopy","HIGH_PRIORITY","UIPriority","UIAnchorMode","convertPriority","priority","P0","P1","P2","P3","P4","P5","P6","P7","resolvePriority","originalClearColor","Color","originalClearAlpha","originalAutoClear","originalAutoClearColor","originalAutoClearDepth","originalAutoClearStencil","UISceneWrapper","Scene","OrthographicCamera","insertObject","element","object","_private_elements","_private_scene","replaceObject","oldObject","removeObject","resize","_private_camera","right","top","updateProjectionMatrix","getVisibility","visible","getZIndex","renderOrder","setZIndex","zIndex","setVisibility","getSortedVisibleElements","keys","sort","prepareRender","renderer","getClearColor","getClearAlpha","autoClear","autoClearColor","autoClearDepth","autoClearStencil","setClearColor","micro","width","scaleX","height","scaleY","anchorOffsetX","anchorX","anchorOffsetY","anchorY","cos","rotation","sin","rotatedAnchorX","rotatedAnchorY","anchorMode","POSITION_ROTATION_SCALE","position","x","y","rawAnchorOffsetY","scale","z","render","setClearAlpha","UIRelation","UILayerEvent","convertRelation","relation","EQUAL","LESS_THAN","GREATER_THAN","resolveRelation","UISolverWrapper","_private_recalculationRequired","_private_lastVariableIndex","_private_lastConstraintIndex","createVariable","description","_private_buildConstraint","_private_solver","_private_variables","removeVariable","cDescription","values","suggestVariableValue","_private_rebuildConstraint","setVariablePriority","_private_rebuildVariable","readVariableValue","enabled","_private_constraints","setConstraintLHS","_private_rebuildConstraintByDescription","setConstraintRHS","setConstraintRelation","setConstraintPriority","setConstraintEnabled","dependConstraints","oldConstraint","_private_convertExpression","_private_rebuildSolver","UILayer","Eventail","super","solverWrapper","modeInternal","VISIBLE","sceneWrapper","xVariable","yVariable","wVariable","hVariable","orientationInternal","HORIZONTAL","VERTICAL","mode","MODE_CHANGE","resizeInternal","ORIENTATION_CHANGE","renderInternal","deltaTime","HIDDEN","WILL_RENDER","clickInternal","INTERACTIVE","UIConstraint","layer","UISingleParameterConstraint","_private_onOrientationChange","isConstraintEnabled","priorityInternal","relationInternal","destroy","UIHeightConstraint","_private_element","options","_private_heightInternal","isUILayerElement","obj","isUIPointElement","isUIPlaneElement","assertValidConstraintSubjects","layerA","layerB","assertValidNumber","isFinite","abs","MAX_SAFE_INTEGER","assertValidPositiveNumber","assertValidNonNegativeNumber","UIHorizontalDistanceConstraint","_private_a","_private_b","anchorA","anchorB","distance","_private_buildLHS","_private_distanceInternal","_private_anchorAInternal","_private_anchorBInternal","aExpression","bExpression","UIHorizontalProportionConstraint","proportion","_private_buildRHS","_private_proportionInternal","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","_private_widthInternal","UIConstraint2DBuilder","UIAspectConstraint","_private_aspectInternal","aspect","DEFAULT_ANCHOR","UICoverConstraintBuilder","build","passive","active","activeAspectConstraint","keepActiveAspect","xConstraint","anchorH","yConstraint","anchorV","widthConstraint","heightConstraint","UIFitConstraintBuilder","UICustomConstraint","_private_lhsInternal","_private_rhsInternal","setLHS","setRHS","UIAnchor","UIDummy","UIMicro","_private_xInternal","_private_yInternal","_private_anchorXInternal","_private_anchorYInternal","_private_scaleXInternal","_private_scaleYInternal","_private_rotationInternal","ROTATION_SCALE","angle","MathUtils","radToDeg","_private_anchorModeInternal","degToRad","reset","UIElementEvent","UIElement","isClicked","CLICK","DEFAULT_ALPHA_TEST","UIMaterial","ShaderMaterial","uniforms","opacity","color","alphaTest","transparent","lights","fog","depthWrite","depthTest","getTexture","getColor","getHex","getOpacity","getTransparency","setTexture","uniformsNeedUpdate","setColor","setHex","setOpacity","setTransparency","needsUpdate","geometry","PlaneGeometry","translate","GEOMETRY_SIZE","UIImage","texture","image","material","Mesh","_private_material","_private_textureInternal","transparency","dispose","UINineSliceMaterial","sliceBorders","Vector4","quadSize","Vector2","textureSize","getSliceBorderLeft","getSliceBorderRight","getSliceBorderTop","getSliceBorderBottom","getQuadSize","setSliceBorderLeft","setSliceBorderRight","setSliceBorderTop","setSliceBorderBottom","setSliceBorder","setQuadSize","DEFAULT_SLICE_BORDER","UINineSlice","_private_onWillRenderInternal","sliceBorder","left","bottom","horizontal","vertical","resolveNineSliceBorder","sliceBorderLeft","sliceBorderRight","sliceBorderTop","sliceBorderBottom","setSliceBorders","UIProgressMaterial","foregroundTexture","backgroundTexture","UniformsUtils","merge","background","foreground","progress","backgroundColor","foregroundColor","backgroundOpacity","foregroundOpacity","direction","vertexShader","fragmentShader","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","isForwardDirection","UISceneUpdateMode","DEFAULT_UPDATE_MODE","PROPERTY_CHANGED","UIScene","resolutionFactor","renderTarget","WebGLRenderTarget","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","enableDepthBuffer","stencilBuffer","_private_frameBoolean","_private_propertyChanged","_private_renderRequired","_private_updateModeInternal","EACH_FRAME","EACH_SECOND_FRAME","MANUAL","setSize","_private_resolutionFactorInternal","clearAlpha","setRenderTarget","_private_sceneInternal","_private_renderTarget","scene","_private_cameraInternal","camera","PerspectiveCamera","updateMode","clearColor","_private_clearColorInternal","_private_clearAlphaInternal","requestRender","isUITextStyle","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","enableShadow","shadowOffsetX","shadowOffsetY","shadowBlur","shadowColor","enableStroke","strokeColor","strokeWidth","resolveTextStyle","style","commonStyle","splitText","text","match","measureTextChunk","chunk","font","baseline","metrics","measureText","ceil","actualBoundingBoxAscent","actualBoundingBoxDescent","renderText","strokeStyle","lineWidth","strokeText","fillStyle","fillText","resolvePadding","UIText","content","canvas","document","createElement","getContext","CanvasTexture","_private_targetAspectRatio","_private_lastAspectRatio","_private_texture","_private_canvas","_private_context","_private_contentInternal","maxWidth","padding","_private_maxWidthInternal","_private_paddingInternal","_private_commonStyleInternal","_private_rebuildText","lines","maxLineWidth","chunks","span","isArray","isSpanString","spanString","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","buildLines","textSize","line","totalHeight","calculateTextSize","calculateTextContentParameters","paddingTop","paddingLeft","currentY","currentX","renderTextLines","UIFullscreenLayer","fixedWidth","fixedHeight","_private_onResize","_private_calculateScale","window","innerWidth","innerHeight","event","target","HTMLElement","getBoundingClientRect","clientX","clientY","_private_fixedWidthInternal","_private_fixedHeightInternal","addEventListener","removeEventListener","isUITextSpan"],"mappings":"6SAaaA,EAYX,WAAAC,CAAYC,EAAW,EAAGC,GACxBC,KAAKF,SAAWA,EAChBE,OAAaD,EAAQ,IAAIE,IAAIF,GAAS,IAAIE,GAC5C,CAYO,WAAOC,CAAKC,EAAiBC,GAClC,MAAMC,EAAS,IAAIT,EACjBO,EAAEL,SAAWM,EAAEN,SACfQ,MAAMC,KAAKJ,IAAQK,YAErB,IAAK,MAAOC,EAAeC,KAAgBN,EAACO,EAC1CN,EAAOH,KAAKO,EAAeC,GAE7B,OAAOL,CACT,CAYO,YAAOO,CAAMT,EAAiBC,GACnC,MAAMC,EAAS,IAAIT,EACjBO,EAAEL,SAAWM,EAAEN,SACfQ,MAAMC,KAAKJ,IAAQK,YAErB,IAAK,MAAOC,EAAeC,KAAgBN,EAACO,EAC1CN,EAAOO,MAAMH,EAAeC,GAE9B,OAAOL,CACT,CAYO,IAAAH,CAAKO,EAAuBC,GAKjC,OAJAV,OAAWa,IACTJ,GACCT,KAAIW,EAAOG,IAAIL,IAAkB,GAAKC,GAElCV,IACT,CAaO,KAAAY,CAAMH,EAAuBC,GAClC,OAAOV,KAAKE,KAAKO,GAAgBC,EACnC,CAWO,QAAAK,CAASC,GACdhB,KAAKF,UAAYkB,EACjB,IAAK,MAAOP,EAAeC,KAAgBV,KAAIW,EAC7CX,KAAIW,EAAOE,IAAIJ,EAAeC,EAAcM,GAE9C,OAAOhB,IACT,CAWO,MAAAiB,CAAOD,GACZ,OAAOhB,KAAKe,SAAS,EAAIC,EAC3B,CAQO,OAAAE,CAAQT,GACb,OAAOT,KAAIW,EAAOQ,IAAIV,EACxB,CAWO,IAAAW,CAAKC,GACVrB,KAAKF,SAAWuB,E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KAAK0rB,WAAaI,OAAOC,gBACFtnB,IAArBzE,KAAK2rB,YACP3rB,KAAK2rB,YAAcG,OAAOE,YAE1B,OAGgBvnB,IAArBzE,KAAK2rB,YACA3rB,KAAK2rB,YAAcG,OAAOE,iBACJvnB,IAApBzE,KAAK0rB,WACP1rB,KAAK0rB,WAAaI,OAAOC,WAEzB,CAGb,EC7JI,SAAUY,GAAa/T,GAC3B,OACU,OAARA,GACe,iBAARA,GACP,SAAUA,GACU,iBAAbA,EAAIiP,SACR,UAAWjP,IAAQ+N,GAAc/N,EAAI8O,OAE5C","x_google_ignoreList":[1,4,5,6,7,8,9]}
|
|
1
|
+
{"version":3,"file":"index.min.js","sources":["../src/miscellaneous/UIExpression.ts","../node_modules/eventail/dist/index.min.js","../src/miscellaneous/UIMode.ts","../src/miscellaneous/UIOrientation.ts","../node_modules/@lume/kiwi/dist/maptype.js","../node_modules/@lume/kiwi/dist/variable.js","../node_modules/@lume/kiwi/dist/expression.js","../node_modules/@lume/kiwi/dist/strength.js","../node_modules/@lume/kiwi/dist/constraint.js","../node_modules/@lume/kiwi/dist/solver.js","../src/miscellaneous/UIPriority.ts","../src/miscellaneous/UIAnchorMode.ts","../src/wrappers/UISceneWrapper.ts","../src/miscellaneous/UIRelation.ts","../src/layers/UILayer.ts","../src/wrappers/UISolverWrapper.ts","../src/constraints/UIConstraint.ts","../src/constraints/UISingleParameterConstraint.ts","../src/constraints/UIHeightConstraint.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/builders/UICoverConstraintBuilder.ts","../src/builders/UIFitConstraintBuilder.ts","../src/constraints/UICustomConstraint.ts","../src/elements/UIAnchor.ts","../src/elements/UIDummy.ts","../src/miscellaneous/UIMicro.ts","../src/elements/UIElement.ts","../src/materials/UIMaterial.ts","../src/miscellaneous/threeInstances.ts","../src/elements/UIImage.ts","../src/materials/UINineSliceMaterial.ts","../src/miscellaneous/UINineSliceBorder.ts","../src/elements/UINineSline.ts","../src/materials/UIProgressMaterial.ts","../src/elements/UIProgress.ts","../src/elements/UIScene.ts","../src/miscellaneous/UITextStyle.ts","../src/miscellaneous/textTools.ts","../src/miscellaneous/UITextPadding.ts","../src/elements/UIText.ts","../src/layers/UIFullscreenLayer.ts","../src/miscellaneous/UITextSpan.ts"],"sourcesContent":["/**\n * Mathematical expression builder for constraint equations in the UI layout system.\n *\n * UIExpression represents linear mathematical expressions of the form:\n * constant + coefficient₁ × variable₁ + coefficient₂ × variable₂ + ... + coefficientₙ × variableₙ\n *\n * These expressions are used to build constraint equations for the Kiwi solver,\n * enabling complex mathematical relationships between UI element properties.\n * Variables are referenced by their numeric descriptors from the solver system.\n *\n * @see {@link UIConstraint} - Constraints that use expressions\n * @see {@link UISolverWrapper} - Solver integration that creates variables\n */\nexport class UIExpression {\n /** The constant term of the expression. */\n public constant: number;\n /** Map of variable descriptors to their coefficients in the expression. */\n private readonly terms: Map<number, number>;\n\n /**\n * Creates a new UIExpression instance.\n *\n * @param constant - The constant term of the expression (defaults to 0)\n * @param terms - Optional array of [variableDescriptor, coefficient] pairs\n */\n constructor(constant = 0, terms?: [number, number][]) {\n this.constant = constant;\n this.terms = terms ? new Map(terms) : new Map();\n }\n\n /**\n * Creates a new expression that represents the sum of two expressions.\n *\n * Performs mathematical addition: (a.constant + a.terms) + (b.constant + b.terms)\n * Coefficients for the same variables are combined.\n *\n * @param a - The first expression\n * @param b - The second expression\n * @returns A new expression representing a + b\n */\n public static plus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant + b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.plus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Creates a new expression that represents the difference of two expressions.\n *\n * Performs mathematical subtraction: (a.constant + a.terms) - (b.constant + b.terms)\n * Coefficients for the same variables are combined with subtraction.\n *\n * @param a - The first expression (minuend)\n * @param b - The second expression (subtrahend)\n * @returns A new expression representing a - b\n */\n public static minus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant - b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.minus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Adds a variable term to this expression (mutating operation).\n *\n * If the variable already exists in the expression, its coefficient is\n * increased by the specified amount. Otherwise, a new term is added.\n *\n * @param variableIndex - The variable descriptor from the solver\n * @param coefficient - The coefficient to add for this variable\n * @returns This expression instance for method chaining\n */\n public plus(variableIndex: number, coefficient: number): this {\n this.terms.set(\n variableIndex,\n (this.terms.get(variableIndex) ?? 0) + coefficient,\n );\n return this;\n }\n\n /**\n * Subtracts a variable term from this expression (mutating operation).\n *\n * If the variable already exists in the expression, its coefficient is\n * decreased by the specified amount. Otherwise, a new term with negative\n * coefficient is added.\n *\n * @param variableIndex - The variable descriptor from the solver\n * @param coefficient - The coefficient to subtract for this variable\n * @returns This expression instance for method chaining\n */\n public minus(variableIndex: number, coefficient: number): this {\n return this.plus(variableIndex, -coefficient);\n }\n\n /**\n * Multiplies all terms in this expression by a scalar value (mutating operation).\n *\n * Both the constant term and all variable coefficients are multiplied\n * by the specified value.\n *\n * @param value - The scalar value to multiply by\n * @returns This expression instance for method chaining\n */\n public multiply(value: number): this {\n this.constant *= value;\n for (const [variableIndex, coefficient] of this.terms) {\n this.terms.set(variableIndex, coefficient * value);\n }\n return this;\n }\n\n /**\n * Divides all terms in this expression by a scalar value (mutating operation).\n *\n * Both the constant term and all variable coefficients are divided\n * by the specified value.\n *\n * @param value - The scalar value to divide by (must not be zero)\n * @returns This expression instance for method chaining\n */\n public divide(value: number): this {\n return this.multiply(1 / value);\n }\n\n /**\n * Checks if the expression contains a term for the specified variable.\n *\n * @param variableIndex - The variable descriptor to check for\n * @returns True if the expression has a term for this variable, false otherwise\n */\n public hasTerm(variableIndex: number): boolean {\n return this.terms.has(variableIndex);\n }\n\n /**\n * Copies the content of another expression into this expression (mutating operation).\n *\n * Replaces all terms and the constant of this expression with those\n * from the source expression.\n *\n * @param expression - The source expression to copy from\n * @returns This expression instance for method chaining\n */\n public copy(expression: UIExpression): this {\n this.constant = expression.constant;\n this.terms.clear();\n for (const [variableIndex, coefficient] of expression.terms) {\n this.terms.set(variableIndex, coefficient);\n }\n return this;\n }\n\n /**\n * Creates a deep copy of this expression.\n *\n * The returned expression is completely independent and can be modified\n * without affecting the original.\n *\n * @returns A new UIExpression instance with the same content\n */\n public clone(): UIExpression {\n return new UIExpression(this.constant, Array.from(this.terms.entries()));\n }\n\n /**\n * Prepares the variable terms for internal solver operations.\n *\n * Converts the internal terms map to an array format suitable for\n * integration with the constraint solver system.\n *\n * @returns Array of [variableDescriptor, coefficient] pairs\n * @internal\n */\n protected [\"prepareTermsInternal\"](): [number, number][] {\n return Array.from(this.terms.entries());\n }\n}\n","class t{constructor(t,i,r=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,r):this.t.set(i,new Map([[t,r]])))}insert(t,i,r=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,r)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,r]])):s.has(t)||s.set(t,r)}remove(t,i){if(void 0===i)return void this.i.delete(t);const r=this.t.get(i);void 0!==r&&(r.delete(t),0===r.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const r=this.t.get(i);return void 0!==r&&r.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const r=this.t.get(i);return void 0!==r?r.get(t):void 0}}class i{constructor(){this.o=new Map}on(t,i,r,s=0){return this.h(t,!1,s,i,r),this}once(t,i,r,s=0){return this.h(t,!0,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=!1,s.v=s.v.slice());const o=s.v;if(0===o.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;t<o.length;t++){const i=o[t];s.l.remove(i._,i.p)}return this}{const e=o.length;if(o[0]._===i&&o[0].p===r)return 1===e?this.o.delete(t):o.shift(),this;const n=e-1;if(o[n]._===i&&o[n].p===r)return o.pop(),this;if(e<10||o[0].M===o[n].M)for(let t=1;t<n;t++){const s=o[t];if(s._===i&&s.p===r)return o.splice(t,1),this}else{const t=s.l.getPriority(i,r);if(void 0===t)return this;let e=0,n=o.length-1;for(;e<=n;){const i=e+n>>>1;o[i].M<t?e=i+1:n=i-1}const c=e;for(n=o.length-1;e<=n;){const i=e+n>>>1;o[i].M<=t?e=i+1:n=i-1}const h=n;for(let t=c;t<=h;t++)if(o[t]._===i&&o[t].p===r)return o.splice(t,1),this}}return this}emit(t,...i){const r=this.o.get(t);if(void 0===r)return!1;if(0===r.v.length)return!1;r.u?r.v=r.v.slice():r.u=!0;const s=r.v;let o=!1;for(let t=0;t<s.length;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=!0,r.m=!0)}const e=this.o.get(t);if(void 0===e)return!0;e.v===s&&(e.u=!1);const n=e.v;if(o){let i=0;for(let t=0;t<n.length;t++){const r=n[t];r.m?e.l.remove(r._,r.p):n[i++]=r}0===i?this.o.delete(t):n.length=i}return!0}h(i,r,s,o,e){let n=this.o.get(i);if(void 0===n)return void this.o.set(i,{v:[{_:o,p:e,M:s,k:r,m:!1}],u:!1,l:new t(o,e,s)});if(n.l.has(o,e))throw Error(\"Event listener already exists\");n.l.insert(o,e,s);const c={_:o,p:e,M:s,k:r,m:!1};n.u&&(n.u=!1,n.v=n.v.slice());{const t=n.v,i=c.M;if(0===t.length||t[t.length-1].M<=i)return void t.push(c);if(t[0].M>=i)return void t.unshift(c);{let r=0,s=t.length;for(;r<s;){const o=r+s>>>1;t[o].M<i?r=o+1:s=o}t.splice(r,0,c)}}}}export{i as Eventail};\n//# sourceMappingURL=index.min.js.map\n","/**\n * Defines the visibility and interactivity state of UI elements.\n *\n * UI elements can be in one of three states:\n * - Hidden: Element is not visible and does not receive input\n * - Visible: Element is visible but does not receive input\n * - Interactive: Element is visible and can receive input events\n */\nexport enum UIMode {\n /**\n * Element is not rendered and does not receive input events.\n * Equivalent to setting `display: none` in CSS.\n */\n HIDDEN = 0,\n\n /**\n * Element is rendered but does not receive input events.\n * Equivalent to setting `pointer-events: none` in CSS.\n */\n VISIBLE = 1,\n\n /**\n * Element is rendered and can receive input events.\n * This is the fully active state for UI elements.\n */\n INTERACTIVE = 2,\n}\n","/**\n * Defines the screen orientation states for UI constraints.\n *\n * This enum is used to specify when certain UI constraints should be active\n * based on the current device/screen orientation.\n */\nexport enum UIOrientation {\n /**\n * Indicates a landscape orientation (width > height).\n * Constraints using this value will only be active in landscape mode.\n */\n HORIZONTAL = 0,\n\n /**\n * Indicates a portrait orientation (height > width).\n * Constraints using this value will only be active in portrait mode.\n */\n VERTICAL = 1,\n\n /**\n * Indicates that the constraint should always be active,\n * regardless of screen orientation.\n */\n ALWAYS = 2,\n}\n\n/**\n * Resolves an optional orientation to a definite value.\n *\n * @param orientation - The orientation to resolve, or undefined\n * @returns The provided orientation, or ALWAYS if none was provided\n */\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","export function createMap() {\n return new IndexedMap();\n}\nclass IndexedMap {\n index = {};\n array = [];\n /**\n * Returns the number of items in the array.\n */\n size() {\n return this.array.length;\n }\n /**\n * Returns true if the array is empty.\n */\n empty() {\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 itemAt(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 contains(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 find(key) {\n const 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 setDefault(key, factory) {\n const i = this.index[key.id()];\n if (i === undefined) {\n const 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 insert(key, value) {\n const pair = new Pair(key, value);\n const 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 erase(key) {\n const i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n const pair = this.array[i];\n const 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 copy() {\n const copy = new IndexedMap();\n for (let i = 0; i < this.array.length; i++) {\n const pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n }\n}\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nclass Pair {\n first;\n second;\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 constructor(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n copy() {\n return new Pair(this.first, this.second);\n }\n}\n","import { Expression } from './expression.js';\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nexport class Variable {\n constructor(name = '') {\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n id() {\n return this._id;\n }\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n name() {\n return this._name;\n }\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n setName(name) {\n this._name = name;\n }\n /**\n * Returns the user context object of the variable.\n * @private\n */\n context() {\n return this._context;\n }\n /**\n * Set the user context object of the variable.\n * @private\n */\n setContext(context) {\n this._context = context;\n }\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n value() {\n return this._value;\n }\n /**\n * Set the value of the variable.\n * @private\n */\n setValue(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 plus(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 minus(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 multiply(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 divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n toJSON() {\n return {\n name: this._name,\n value: this._value,\n };\n }\n toString() {\n return this._context + '[' + this._name + ':' + this._value + ']';\n }\n _name;\n _value = 0.0;\n _context = null;\n _id = VarId++;\n}\n/**\n * The internal variable id counter.\n * @private\n */\nlet VarId = 0;\n","import { createMap } from './maptype.js';\nimport { Variable } from './variable.js';\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 */\nexport class Expression {\n constructor() {\n let 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 terms() {\n return this._terms;\n }\n /**\n * Returns the constant of the expression.\n * @private\n */\n constant() {\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 value() {\n let result = this._constant;\n for (let i = 0, n = this._terms.size(); i < n; i++) {\n let 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 plus(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 minus(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 multiply(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 divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n isConstant() {\n return this._terms.size() == 0;\n }\n toString() {\n let result = this._terms.array\n .map(function (pair) {\n return pair.second + '*' + pair.first.toString();\n })\n .join(' + ');\n if (!this.isConstant() && this._constant !== 0) {\n result += ' + ';\n }\n result += this._constant;\n return result;\n }\n _terms;\n _constant;\n}\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n let constant = 0.0;\n let factory = () => 0.0;\n let terms = createMap();\n for (let i = 0, n = args.length; i < n; ++i) {\n let 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 let terms2 = item.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let 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 let value = item[0];\n let 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 let terms2 = value2.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let 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, constant };\n}\n","/**\n * @class Strength\n */\nexport class Strength {\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 static create(a, b, c, w = 1.0) {\n let 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 * The 'required' symbolic strength.\n */\n static required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n static strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n static medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n static weak = Strength.create(0.0, 0.0, 1.0);\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n static clip(value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n }\n}\n","import { Expression } from './expression.js';\nimport { Strength } from './strength.js';\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 */\nexport class Constraint {\n constructor(expression, operator, rhs, strength = Strength.required) {\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 id() {\n return this._id;\n }\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n expression() {\n return this._expression;\n }\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n op() {\n return this._operator;\n }\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n strength() {\n return this._strength;\n }\n toString() {\n return (this._expression.toString() + ' ' + ['<=', '>=', '='][this._operator] + ' 0 (' + this._strength.toString() + ')');\n }\n _expression;\n _operator;\n _strength;\n _id = CnId++;\n}\n/**\n * The internal constraint id counter.\n * @private\n */\nlet CnId = 0;\n","import { Constraint, Operator } from './constraint.js';\nimport { Expression } from './expression.js';\nimport { createMap } from './maptype.js';\nimport { Strength } from './strength.js';\n/**\n * The constraint solver class.\n *\n * @class\n */\nexport class Solver {\n /**\n * @type {number} - The max number of solver iterations before an error\n * is thrown, in order to prevent infinite iteration. Default: `10,000`.\n */\n maxIterations = 1000;\n /**\n * Construct a new Solver.\n */\n constructor() { }\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 createConstraint(lhs, operator, rhs, strength = Strength.required) {\n let 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 addConstraint(constraint) {\n let 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 let data = this._createRow(constraint);\n let row = data.row;\n let tag = data.tag;\n let 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 removeConstraint(constraint) {\n let 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 let marker = cnPair.second.marker;\n let rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n let 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 hasConstraint(constraint) {\n return this._cnMap.contains(constraint);\n }\n /**\n * Get an array of the current constraints.\n *\n * @return {Constraint[]}\n */\n getConstraints() {\n return this._cnMap.array.map(({ first }) => first);\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 addEditVariable(variable, strength) {\n let 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 let expr = new Expression(variable);\n let cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n let tag = this._cnMap.find(cn).second;\n let info = { 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 removeEditVariable(variable) {\n let 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 hasEditVariable(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 suggestValue(variable, value) {\n let editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error('unknown edit variable');\n }\n let rows = this._rowMap;\n let info = editPair.second;\n let delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n let marker = info.tag.marker;\n let 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 let 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 (let i = 0, n = rows.size(); i < n; ++i) {\n let rowPair = rows.itemAt(i);\n let row = rowPair.second;\n let coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 && rowPair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair.first);\n }\n }\n this._dualOptimize();\n }\n /**\n * Update the values of the variables.\n */\n updateVariables() {\n let vars = this._varMap;\n let rows = this._rowMap;\n for (let i = 0, n = vars.size(); i < n; ++i) {\n let pair = vars.itemAt(i);\n let 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 _getVarSymbol(variable) {\n let factory = () => 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 _createRow(constraint) {\n let expr = constraint.expression();\n let row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n let terms = expr.terms();\n for (let i = 0, n = terms.size(); i < n; ++i) {\n let termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n let symbol = this._getVarSymbol(termPair.first);\n let 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 let objective = this._objective;\n let strength = constraint.strength();\n let tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge: {\n let coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n let slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n let 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 if (strength < Strength.required) {\n let errplus = this._makeSymbol(SymbolType.Error);\n let 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 let 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, 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 _chooseSubject(row, tag) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n let 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 _addWithArtificialVariable(row) {\n // Create and add the artificial variable to the tableau.\n let 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 let 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 let pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n let basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n let 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 let rows = this._rowMap;\n for (let 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 _substitute(symbol, row) {\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 && 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 _optimize(objective) {\n let iterations = 0;\n while (iterations < this.maxIterations) {\n let entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n let 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 let row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n iterations++;\n }\n throw new Error('solver iterations exceeded');\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 _dualOptimize() {\n let rows = this._rowMap;\n let infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n let leaving = infeasible.pop();\n let pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n let 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 let 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 _getEnteringSymbol(objective) {\n let cells = objective.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let 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 _getDualEnteringSymbol(row) {\n let ratio = Number.MAX_VALUE;\n let entering = INVALID_SYMBOL;\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let symbol = pair.first;\n let c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n let coeff = this._objective.coefficientFor(symbol);\n let 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 _getLeavingSymbol(entering) {\n let ratio = Number.MAX_VALUE;\n let found = INVALID_SYMBOL;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n let row = pair.second;\n let temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n let 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 _getMarkerLeavingSymbol(marker) {\n let dmax = Number.MAX_VALUE;\n let r1 = dmax;\n let r2 = dmax;\n let invalid = INVALID_SYMBOL;\n let first = invalid;\n let second = invalid;\n let third = invalid;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let row = pair.second;\n let c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n let symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n let r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n let 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 _removeConstraintEffects(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 _removeMarkerEffects(marker, strength) {\n let 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 _anyPivotableSymbol(row) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let 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 _makeSymbol(type) {\n return new Symbol(type, this._idTick++);\n }\n _cnMap = createCnMap();\n _rowMap = createRowMap();\n _varMap = createVarMap();\n _editMap = createEditMap();\n _infeasibleRows = [];\n _objective = new Row();\n _artificial = null;\n _idTick = 0;\n}\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n let 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 */\nclass Symbol {\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 constructor(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n id() {\n return this._id;\n }\n /**\n * Returns the type of the symbol.\n */\n type() {\n return this._type;\n }\n _id;\n _type;\n}\n/**\n * A static invalid symbol\n * @private\n */\nlet INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nclass Row {\n /**\n * Construct a new Row.\n */\n constructor(constant = 0.0) {\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n cells() {\n return this._cellMap;\n }\n /**\n * Returns the constant for the row.\n */\n constant() {\n return this._constant;\n }\n /**\n * Returns true if the row is a constant value.\n */\n isConstant() {\n return this._cellMap.empty();\n }\n /**\n * Returns true if the Row has all dummy symbols.\n */\n allDummies() {\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let 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 copy() {\n let 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 add(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 insertSymbol(symbol, coefficient = 1.0) {\n let pair = this._cellMap.setDefault(symbol, () => 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 insertRow(other, coefficient = 1.0) {\n this._constant += other._constant * coefficient;\n let cells = other._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n }\n /**\n * Remove a symbol from the row.\n */\n removeSymbol(symbol) {\n this._cellMap.erase(symbol);\n }\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n reverseSign() {\n this._constant = -this._constant;\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let 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 solveFor(symbol) {\n let cells = this._cellMap;\n let pair = cells.erase(symbol);\n let coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (let 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 solveForEx(lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n }\n /**\n * Returns the coefficient for the given symbol.\n */\n coefficientFor(symbol) {\n let 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 substitute(symbol, row) {\n let pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n }\n _cellMap = createMap();\n _constant;\n}\n","import { Strength } from \"@lume/kiwi\";\n\n/** High priority value for constraint solver strength calculations. */\nconst HIGH_PRIORITY = 1000;\n/** Medium priority value for constraint solver strength calculations. */\nconst MEDIUM_PRIORITY = 100;\n/** Low priority value for constraint solver strength calculations. */\nconst LOW_PRIORITY = 10;\n\n/**\n * Priority levels for UI layout constraints and variables.\n *\n * UIPriority defines a hierarchical system of priority levels used by the\n * constraint solver to determine which constraints should take precedence\n * when conflicts arise. Lower numeric values represent higher priority,\n * with P0 being the highest priority and P7 being the lowest.\n *\n * The priority system maps to Kiwi solver strength values with different\n * strength components (required, strong, medium, weak) to create a nuanced\n * priority hierarchy for layout solving.\n *\n * @see {@link convertPriority} - Converts to Kiwi solver strength values\n */\nexport enum UIPriority {\n /** Highest priority - required constraints that must be satisfied. */\n P0 = 0,\n /** High priority - strong constraints with medium strength. */\n P1 = 1,\n /** Medium-high priority - strong constraints with low strength. */\n P2 = 2,\n /** Medium priority - medium strength constraints. */\n P3 = 3,\n /** Medium-low priority - medium strength constraints with low weight. */\n P4 = 4,\n /** Low priority - weak strength constraints with medium weight. */\n P5 = 5,\n /** Very low priority - weak strength constraints with low weight. */\n P6 = 6,\n /** Lowest priority - weak strength constraints with minimal weight. */\n P7 = 7,\n}\n\n/**\n * Converts UIPriority enum values to Kiwi solver strength values.\n *\n * This function maps the UI priority levels to the three-component strength\n * system used by the Kiwi constraint solver (required, strong, medium, weak).\n * Higher priority levels get stronger constraint strength values.\n *\n * @param priority - The UI priority level to convert\n * @returns The corresponding Kiwi solver strength value\n * @throws Will throw an error if an invalid priority is provided\n * @see {@link UIPriority} - Priority level definitions\n */\nexport function convertPriority(priority: UIPriority): number {\n switch (priority) {\n case UIPriority.P0:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIPriority.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIPriority.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIPriority.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIPriority.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIPriority.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIPriority.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIPriority.P7:\n return Strength.create(0, 0, 1);\n default:\n throw new Error(`Invalid priority: ${priority}`);\n }\n}\n\n/**\n * Resolves an optional priority value to a concrete UIPriority.\n *\n * If no priority is provided, returns the default highest priority (P0).\n * This function is commonly used in constraint creation where priority\n * is an optional parameter.\n *\n * @param priority - The optional priority value to resolve\n * @returns The resolved priority, defaulting to P0 if undefined\n */\nexport function resolvePriority(priority?: UIPriority): UIPriority {\n return priority ?? UIPriority.P0;\n}\n","/**\n * Defines the anchor mode for UIMicro, determining which transformations are applied around the anchor point.\n */\nexport enum UIAnchorMode {\n /** Rotation and scaling are applied around the anchor point */\n ROTATION_SCALE = 0,\n /** Position, rotation, and scaling transformations are all applied around the anchor point */\n POSITION_ROTATION_SCALE = 1,\n}\n","import type { Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIElement } from \"../elements/UIElement\";\nimport { UIAnchorMode } from \"../miscellaneous/UIAnchorMode\";\n\nlet originalClearColor: Color = new Color();\nlet originalClearAlpha = 0;\nlet originalAutoClear = false;\nlet originalAutoClearColor = false;\nlet originalAutoClearDepth = false;\nlet originalAutoClearStencil = false;\n\nexport class UISceneWrapper {\n private readonly scene = new Scene();\n private readonly camera: OrthographicCamera;\n private readonly elements = new Map<UIElement, Object3D>();\n\n constructor(w: number, h: number) {\n this.camera = new OrthographicCamera(0, w, h, 0, -1, 1);\n }\n\n public insertObject(element: UIElement, object: Object3D): void {\n if (this.elements.has(element)) {\n throw new Error(\"Element already exists\");\n }\n this.elements.set(element, object);\n this.scene.add(object);\n }\n\n public replaceObject(element: UIElement, object: Object3D): void {\n const oldObject = this.elements.get(element);\n if (oldObject === undefined) {\n throw new Error(\"Element not found\");\n }\n\n this.scene.remove(oldObject);\n this.scene.add(object);\n this.elements.set(element, object);\n }\n\n public removeObject(element: UIElement): void {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n this.scene.remove(object);\n this.elements.delete(element);\n }\n\n public resize(w: number, h: number): void {\n this.camera.right = w;\n this.camera.top = h;\n this.camera.updateProjectionMatrix();\n }\n\n public getVisibility(element: UIElement): boolean {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n return object.visible;\n }\n\n public getZIndex(element: UIElement): number {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n return object.renderOrder;\n }\n\n public setZIndex(element: UIElement, zIndex: number): void {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n object.renderOrder = zIndex;\n }\n\n public setVisibility(element: UIElement, visible: boolean): void {\n const object = this.elements.get(element);\n if (object === undefined) {\n throw new Error(\"Element not found\");\n }\n\n object.visible = visible;\n }\n\n public getSortedVisibleElements(): UIElement[] {\n return Array.from(this.elements.keys()).sort(\n (a, b) => this.getZIndex(a) - this.getZIndex(b),\n );\n }\n\n public prepareRender(renderer: WebGLRenderer): void {\n originalClearColor = renderer.getClearColor(originalClearColor);\n originalClearAlpha = renderer.getClearAlpha();\n originalAutoClear = renderer.autoClear;\n originalAutoClearColor = renderer.autoClearColor;\n originalAutoClearDepth = renderer.autoClearDepth;\n originalAutoClearStencil = renderer.autoClearStencil;\n\n renderer.autoClear = false;\n renderer.autoClearColor = false;\n renderer.autoClearDepth = false;\n renderer.autoClearStencil = false;\n renderer.setClearColor(0x000000, 1);\n\n for (const [element, object] of this.elements) {\n const micro = element.micro;\n\n const width = element.width * micro.scaleX;\n const height = element.height * micro.scaleY;\n\n const anchorOffsetX = micro.anchorX * width;\n const anchorOffsetY = micro.anchorY * height;\n\n const cos = Math.cos(micro.rotation);\n const sin = Math.sin(micro.rotation);\n\n const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;\n const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;\n\n if (micro.anchorMode === UIAnchorMode.POSITION_ROTATION_SCALE) {\n object.position.x = element.x + micro.x - rotatedAnchorX;\n object.position.y = element.y + micro.y - rotatedAnchorY;\n } else {\n const rawAnchorOffsetX = micro.anchorX * element.width;\n const rawAnchorOffsetY = micro.anchorY * element.height;\n object.position.x =\n element.x + rawAnchorOffsetX - rotatedAnchorX + micro.x;\n object.position.y =\n element.y + rawAnchorOffsetY - rotatedAnchorY + micro.y;\n }\n\n object.scale.x = width;\n object.scale.y = height;\n object.rotation.z = micro.rotation;\n }\n }\n\n public render(renderer: WebGLRenderer): void {\n renderer.clear(false, true, true);\n renderer.render(this.scene, this.camera);\n\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.autoClear = originalAutoClear;\n renderer.autoClearColor = originalAutoClearColor;\n renderer.autoClearDepth = originalAutoClearDepth;\n renderer.autoClearStencil = originalAutoClearStencil;\n }\n}\n","import { Operator } from \"@lume/kiwi\";\n\n/**\n * Relational operators for UI layout constraints.\n *\n * UIRelation defines the mathematical relationship between the left-hand\n * and right-hand sides of constraint equations. These relations are used\n * by the constraint solver to determine how expressions should be compared\n * when solving layout constraints.\n *\n * @see {@link convertRelation} - Converts to Kiwi solver operators\n */\nexport enum UIRelation {\n /** Equality relation: left-hand side equals right-hand side. */\n EQUAL = 0,\n /** Less than or equal relation: left-hand side ≤ right-hand side. */\n LESS_THAN = 1,\n /** Greater than or equal relation: left-hand side ≥ right-hand side. */\n GREATER_THAN = 2,\n}\n\n/**\n * Converts UIRelation enum values to Kiwi solver operator values.\n *\n * This function maps the UI relation types to the corresponding operators\n * used by the Kiwi constraint solver for mathematical comparisons in\n * constraint equations.\n *\n * @param relation - The UI relation type to convert\n * @returns The corresponding Kiwi solver operator\n * @throws Will throw an error if an invalid relation is provided\n * @see {@link UIRelation} - Relation type definitions\n */\nexport function convertRelation(relation: UIRelation): Operator {\n switch (relation) {\n case UIRelation.EQUAL:\n return Operator.Eq;\n case UIRelation.LESS_THAN:\n return Operator.Le;\n case UIRelation.GREATER_THAN:\n return Operator.Ge;\n default:\n throw new Error(`Invalid relation: ${relation}`);\n }\n}\n\n/**\n * Resolves an optional relation value to a concrete UIRelation.\n *\n * If no relation is provided, returns the default equality relation.\n * This function is commonly used in constraint creation where relation\n * is an optional parameter.\n *\n * @param relation - The optional relation value to resolve\n * @returns The resolved relation, defaulting to EQUAL if undefined\n */\nexport function resolveRelation(relation?: UIRelation): UIRelation {\n return relation ?? UIRelation.EQUAL;\n}\n","import { Eventail } from \"eventail\";\nimport { type WebGLRenderer } from \"three\";\nimport { UIMode } from \"../miscellaneous/UIMode\";\nimport { UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UISceneWrapper } from \"../wrappers/UISceneWrapper\";\nimport { UISolverWrapper } from \"../wrappers/UISolverWrapper\";\n\n/**\n * Events that can be emitted by UI layers.\n */\nexport enum UILayerEvent {\n /** Emitted when the layer's orientation changes between horizontal and vertical. */\n ORIENTATION_CHANGE = \"orientation_change\",\n /** Emitted when the layer's visibility/interaction mode changes. */\n MODE_CHANGE = \"mode_change\",\n /** Emitted before the layer is rendered. */\n WILL_RENDER = \"will_render\",\n}\n\n/**\n * Abstract base class for UI layout containers with constraint solving and rendering.\n *\n * UILayer serves as the fundamental container for UI elements, providing constraint-based\n * layout solving, 3D scene management, and event handling. It manages the layer's\n * dimensions through solver variables, handles orientation changes, and coordinates\n * rendering and interaction for all contained elements.\n *\n * Each layer maintains its own constraint solver and scene graph, allowing for\n * independent layout calculation and rendering optimization.\n *\n * @see {@link UIElement} - Elements contained within layers\n * @see {@link UISolverWrapper} - Constraint solving system\n * @see {@link UISceneWrapper} - 3D scene management\n * @see {@link UIOrientation} - Layer orientation states\n */\nexport abstract class UILayer extends Eventail {\n /** Optional name identifier for the layer. */\n public name = \"\";\n\n /**\n * Solver variable descriptor for the x-coordinate position.\n * This variable is managed by the constraint solver system.\n */\n public readonly xVariable: number;\n\n /**\n * Solver variable descriptor for the y-coordinate position.\n * This variable is managed by the constraint solver system.\n */\n public readonly yVariable: number;\n\n /**\n * Solver variable descriptor for the width dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly wVariable: number;\n\n /**\n * Solver variable descriptor for the height dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly hVariable: number;\n\n /**\n * Constraint solver wrapper for managing layout calculations.\n * @see {@link UISolverWrapper}\n */\n protected readonly solverWrapper = new UISolverWrapper();\n\n /**\n * 3D scene wrapper for managing rendering and element hierarchy.\n * @see {@link UISceneWrapper}\n */\n protected readonly sceneWrapper: UISceneWrapper;\n\n /** Internal storage for the current visibility/interaction mode. */\n protected modeInternal: UIMode = UIMode.VISIBLE;\n\n /** Internal storage for the current orientation state. */\n protected orientationInternal: UIOrientation;\n\n /**\n * Creates a new UILayer instance with specified dimensions.\n *\n * Initializes the constraint solver with position and dimension variables,\n * sets up the 3D scene wrapper, and determines the initial orientation\n * based on the width-to-height ratio.\n *\n * @param w - Initial width of the layer\n * @param h - Initial height of the layer\n */\n constructor(w: number, h: number) {\n super();\n this.sceneWrapper = new UISceneWrapper(w, h);\n this.xVariable = this.solverWrapper.createVariable(0, UIPriority.P0);\n this.yVariable = this.solverWrapper.createVariable(0, UIPriority.P0);\n this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P0);\n this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P0);\n this.orientationInternal =\n w > h ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n }\n\n /**\n * Gets the current width value from the constraint solver.\n * @returns The current layer width in pixels\n */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /**\n * Gets the current height value from the constraint solver.\n * @returns The current layer height in pixels\n */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /**\n * Gets the current visibility and interaction mode.\n * @returns The current UIMode setting\n * @see {@link UIMode}\n */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /**\n * Gets the current orientation state.\n * @returns The current orientation (horizontal or vertical)\n * @see {@link UIOrientation}\n */\n public get orientation(): UIOrientation {\n return this.orientationInternal;\n }\n\n /**\n * Sets the visibility and interaction mode and emits change event.\n * @param value - The new UIMode setting\n * @see {@link UIMode}\n */\n public set mode(value: UIMode) {\n if (value !== this.modeInternal) {\n this.modeInternal = value;\n this.emit(UILayerEvent.MODE_CHANGE, this.modeInternal, this);\n }\n }\n\n /**\n * Internal method for resizing the layer and updating orientation.\n *\n * Updates the solver variables for width and height, resizes the scene wrapper,\n * and determines if the orientation has changed based on the new dimensions.\n * Emits an orientation change event if the orientation has changed.\n *\n * @param width - The new layer width\n * @param height - The new layer height\n * @protected\n */\n protected resizeInternal(width: number, height: number): void {\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n this.sceneWrapper.resize(width, height);\n\n const orientation =\n width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n\n if (orientation !== this.orientationInternal) {\n this.orientationInternal = orientation;\n this.emit(\n UILayerEvent.ORIENTATION_CHANGE,\n this.orientationInternal,\n this,\n );\n }\n }\n\n /**\n * Internal method for rendering the layer and its elements.\n *\n * Delegates rendering to the scene wrapper if the layer is not hidden.\n * This method is called during the rendering loop to update and draw\n * all elements contained within the layer.\n *\n * @param renderer - The WebGL renderer instance\n * @param deltaTime - Time elapsed since the last frame in seconds\n * @protected\n */\n protected renderInternal(renderer: WebGLRenderer, deltaTime: number): void {\n if (this.mode !== UIMode.HIDDEN) {\n this.sceneWrapper.prepareRender(renderer);\n this.emit(UILayerEvent.WILL_RENDER, renderer, deltaTime, this);\n this.sceneWrapper.render(renderer);\n }\n }\n\n /**\n * Internal method for handling click events on the layer.\n *\n * Processes click events by testing elements in reverse z-order (top to bottom)\n * until one handles the click. Only processes clicks when the layer is in\n * interactive mode.\n *\n * @param x - The x-coordinate of the click\n * @param y - The y-coordinate of the click\n * @protected\n */\n protected clickInternal(x: number, y: number): void {\n if (this.mode === UIMode.INTERACTIVE) {\n for (const element of this.sceneWrapper.getSortedVisibleElements()) {\n if (element[\"onClickInternal\"](x, y)) {\n return;\n }\n }\n }\n }\n\n /**\n * Internal method for accessing the constraint solver wrapper.\n *\n * Provides access to the layer's constraint solver for elements and\n * constraints that need to create variables or constraints.\n *\n * @returns The constraint solver wrapper instance\n */\n protected [\"getSolverWrapperInternal\"](): UISolverWrapper {\n return this.solverWrapper;\n }\n\n /**\n * Internal method for accessing the 3D scene wrapper.\n *\n * Provides access to the layer's scene management system for elements\n * that need to be added to or removed from the 3D scene.\n *\n * @returns The scene wrapper instance\n */\n protected [\"getSceneWrapperInternal\"](): UISceneWrapper {\n return this.sceneWrapper;\n }\n}\n","import { Constraint, Expression, Solver, Variable } from \"@lume/kiwi\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport { convertPriority, UIPriority } from \"../miscellaneous/UIPriority\";\nimport { convertRelation, UIRelation } from \"../miscellaneous/UIRelation\";\n\ninterface VariableDescription {\n variable: Variable;\n priority: UIPriority;\n value: number;\n constraint?: Constraint;\n}\n\ninterface ConstraintDescription {\n constraint: Constraint;\n lhs: UIExpression;\n rhs: UIExpression;\n priority: UIPriority;\n relation: UIRelation;\n enabled: boolean;\n}\n\nexport class UISolverWrapper {\n private solver? = new Solver();\n private recalculationRequired = false;\n\n private readonly variables = new Map<number, VariableDescription>();\n private lastVariableIndex = 0;\n\n private readonly constraints = new Map<number, ConstraintDescription>();\n private lastConstraintIndex = 0;\n\n public createVariable(value: number, priority: UIPriority): number {\n const index = this.lastVariableIndex++;\n const variable = new Variable();\n\n if (priority === UIPriority.P0) {\n const description: VariableDescription = { variable, priority, value };\n this.variables.set(index, description);\n\n description.constraint = this.buildConstraint(\n new UIExpression(0, [[index, 1]]),\n new UIExpression(value),\n UIRelation.EQUAL,\n priority,\n );\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n this.variables.set(index, { variable, priority, value });\n\n try {\n this.solver?.addEditVariable(variable, convertPriority(priority));\n this.solver?.suggestValue(variable, value);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.recalculationRequired = true;\n return index;\n }\n\n public removeVariable(index: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n throw new Error(`Variable ${index} is used in constraint`);\n }\n }\n\n try {\n description.constraint\n ? this.solver?.removeConstraint(description.constraint)\n : this.solver?.removeEditVariable(description.variable);\n } catch {\n this.solver = undefined;\n }\n\n this.variables.delete(index);\n this.recalculationRequired = true;\n }\n\n public suggestVariableValue(index: number, value: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n if (description.value !== value) {\n description.value = value;\n\n if (description.constraint) {\n description.constraint = this.rebuildConstraint(\n description.constraint,\n new UIExpression().plus(index, 1),\n new UIExpression(description.value),\n UIRelation.EQUAL,\n description.priority,\n );\n } else {\n this.solver?.suggestValue(description.variable, value);\n }\n\n this.recalculationRequired = true;\n }\n }\n\n public setVariablePriority(index: number, priority: UIPriority): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n if (priority !== description.priority) {\n description.priority = priority;\n\n if (description.priority === UIPriority.P0) {\n const lhs = new UIExpression().plus(index, 1);\n const rhs = new UIExpression(description.value);\n\n description.constraint = this.buildConstraint(\n lhs,\n rhs,\n UIRelation.EQUAL,\n description.priority,\n );\n\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n if (description.constraint) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n description.constraint = undefined;\n this.rebuildVariable(index, description);\n }\n\n this.recalculationRequired = true;\n }\n }\n\n public readVariableValue(index: number): number {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(`Variable ${index} does not exist`);\n }\n\n if (this.solver === undefined) {\n this.rebuildSolver();\n }\n\n if (this.recalculationRequired) {\n this.solver?.updateVariables();\n this.recalculationRequired = false;\n }\n\n return description.variable.value();\n }\n\n public createConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n enabled: boolean,\n ): number {\n const index = this.lastConstraintIndex++;\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n this.constraints.set(index, {\n constraint,\n lhs: lhs.clone(),\n rhs: rhs.clone(),\n priority,\n relation,\n enabled,\n });\n if (enabled) {\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n }\n return index;\n }\n\n public removeConstraint(index: number): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n if (description.enabled) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.constraints.delete(index);\n this.recalculationRequired = true;\n }\n\n public setConstraintLHS(index: number, lhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.lhs.copy(lhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintRHS(index: number, rhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.rhs.copy(rhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintRelation(index: number, relation: UIRelation): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.relation = relation;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintPriority(index: number, priority: UIPriority): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n description.priority = priority;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n }\n\n public setConstraintEnabled(index: number, enabled: boolean): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(`Constraint ${index} does not exist`);\n }\n\n if (enabled !== description.enabled) {\n description.enabled = enabled;\n try {\n description.enabled\n ? this.solver?.addConstraint(description.constraint)\n : this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n }\n }\n\n private rebuildVariable(\n index: number,\n description: VariableDescription,\n ): void {\n const dependConstraints: ConstraintDescription[] = [];\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n try {\n this.solver?.removeConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n }\n dependConstraints.push(cDescription);\n }\n }\n\n this.solver?.removeEditVariable(description.variable);\n this.solver?.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n\n for (const cDescription of dependConstraints) {\n cDescription.constraint = this.buildConstraint(\n cDescription.lhs,\n cDescription.rhs,\n cDescription.relation,\n cDescription.priority,\n );\n }\n\n for (const cDescription of dependConstraints) {\n try {\n this.solver?.addConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n break;\n }\n }\n }\n\n private rebuildConstraintByDescription(\n description: ConstraintDescription,\n ): void {\n description.constraint = description.enabled\n ? this.rebuildConstraint(\n description.constraint,\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n )\n : this.buildConstraint(\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n );\n }\n\n private rebuildConstraint(\n oldConstraint: Constraint,\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n try {\n this.solver?.removeConstraint(oldConstraint);\n } catch {\n this.solver = undefined;\n }\n\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n\n return constraint;\n }\n\n private buildConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n return new Constraint(\n this.convertExpression(lhs),\n convertRelation(relation),\n this.convertExpression(rhs),\n convertPriority(priority),\n );\n }\n\n private convertExpression(expression: UIExpression): Expression {\n return new Expression(\n ...expression[\"prepareTermsInternal\"]().map(\n ([variableIndex, coefficient]): [number, Variable] => {\n const description = this.variables.get(variableIndex);\n if (description === undefined) {\n throw new Error(`Variable ${variableIndex} does not exist`);\n }\n return [coefficient, description.variable];\n },\n ),\n expression.constant,\n );\n }\n\n private rebuildSolver(): void {\n if (this.solver) {\n throw new Error(\"Solver already exists\");\n }\n\n this.solver = new Solver();\n\n for (const description of this.variables.values()) {\n if (description.constraint) {\n this.solver.addConstraint(description.constraint);\n } else {\n this.solver.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n this.solver.suggestValue(description.variable, description.value);\n }\n }\n\n for (const description of this.constraints.values()) {\n if (description.enabled) {\n this.solver.addConstraint(description.constraint);\n }\n }\n\n this.recalculationRequired = true;\n }\n}\n","import { type UILayer } from \"../layers/UILayer\";\n\nimport type { UISolverWrapper } from \"../wrappers/UISolverWrapper\";\n\n/**\n * Abstract base class for all UI layout constraints.\n *\n * UIConstraint serves as the fundamental building block for the constraint-based\n * layout system. It provides access to the solver wrapper for creating and\n * managing constraint relationships between UI elements. All concrete constraint\n * implementations must extend this class to participate in the layout solving process.\n *\n * @see {@link UILayer} - Container layer for constraints\n * @see {@link UISolverWrapper} - Constraint solver integration\n */\nexport abstract class UIConstraint {\n /** Optional name identifier for the constraint. */\n public name = \"\";\n\n /**\n * Reference to the constraint solver wrapper for managing solver operations.\n * @see {@link UISolverWrapper}\n */\n protected readonly solverWrapper: UISolverWrapper;\n\n /**\n * Creates a new UIConstraint instance.\n *\n * @param layer - The UI layer that contains this constraint\n */\n constructor(public readonly layer: UILayer) {\n this.solverWrapper = this.layer[\"getSolverWrapperInternal\"]();\n }\n}\n","import type { UILayer } from \"../layers/UILayer\";\nimport { UILayerEvent } from \"../layers/UILayer\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../miscellaneous/UIOrientation\";\nimport { resolvePriority, type UIPriority } from \"../miscellaneous/UIPriority\";\nimport { resolveRelation, type UIRelation } from \"../miscellaneous/UIRelation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\n/**\n * Configuration options for UISingleParameterConstraint creation.\n */\nexport interface UISingleParameterConstraintOptions {\n /** Priority level for the constraint in the solver hierarchy. */\n priority: UIPriority;\n /** Mathematical relation type for the constraint equation. */\n relation: UIRelation;\n /** Orientation context for when the constraint should be active. */\n orientation: UIOrientation;\n}\n\n/**\n * Abstract base class for constraints that operate with configurable parameters.\n *\n * UISingleParameterConstraint extends UIConstraint with common functionality\n * for constraints that need priority, relation, and orientation configuration.\n * It provides automatic orientation-based enabling/disabling of constraints\n * and manages the lifecycle of solver constraint descriptors.\n *\n * @see {@link UIConstraint} - Base constraint class\n * @see {@link UIPriority} - Priority level configuration\n * @see {@link UIRelation} - Mathematical relation types\n * @see {@link UIOrientation} - Orientation-based activation\n */\nexport abstract class UISingleParameterConstraint extends UIConstraint {\n /** Internal storage for the constraint priority level. */\n protected priorityInternal: UIPriority;\n /** Internal storage for the constraint relation type. */\n protected relationInternal: UIRelation;\n /** Internal storage for the constraint orientation setting. */\n protected orientationInternal: UIOrientation;\n\n /** The constraint descriptor managed by the solver system. */\n protected abstract readonly constraint: number;\n\n /**\n * Creates a new UISingleParameterConstraint instance.\n *\n * Initializes the constraint with resolved default values and sets up\n * orientation change event handling for dynamic constraint activation.\n *\n * @param layer - The UI layer that contains this constraint\n * @param priority - Optional priority level (defaults to P0)\n * @param relation - Optional relation type (defaults to EQUAL)\n * @param orientation - Optional orientation setting (defaults to ALWAYS)\n */\n constructor(\n layer: UILayer,\n priority?: UIPriority,\n relation?: UIRelation,\n orientation?: UIOrientation,\n ) {\n super(layer);\n this.priorityInternal = resolvePriority(priority);\n this.relationInternal = resolveRelation(relation);\n this.orientationInternal = resolveOrientation(orientation);\n this.layer.on(UILayerEvent.ORIENTATION_CHANGE, this.onOrientationChange);\n }\n\n /**\n * Gets the current priority level of the constraint.\n * @returns The constraint priority level\n */\n public get priority(): UIPriority {\n return this.priorityInternal;\n }\n\n /**\n * Gets the current mathematical relation type of the constraint.\n * @returns The constraint relation type\n */\n public get relation(): UIRelation {\n return this.relationInternal;\n }\n\n /**\n * Gets the current orientation setting of the constraint.\n * @returns The constraint orientation setting\n */\n public get orientation(): UIOrientation {\n return this.orientationInternal;\n }\n\n /**\n * Sets a new priority level for the constraint.\n * @param value - The new priority level\n */\n public set priority(value: UIPriority) {\n if (value !== this.priorityInternal) {\n this.priorityInternal = value;\n this.solverWrapper.setConstraintPriority(\n this.constraint,\n this.priorityInternal,\n );\n }\n }\n\n /**\n * Sets a new mathematical relation type for the constraint.\n * @param value - The new relation type\n */\n public set relation(value: UIRelation) {\n if (value !== this.relationInternal) {\n this.relationInternal = value;\n this.solverWrapper.setConstraintRelation(\n this.constraint,\n this.relationInternal,\n );\n }\n }\n\n /**\n * Sets a new orientation setting for the constraint.\n * @param value - The new orientation setting\n */\n public set orientation(value: UIOrientation) {\n if (value !== this.orientationInternal) {\n this.orientationInternal = value;\n this.onOrientationChange();\n }\n }\n\n /**\n * Destroys the constraint by cleaning up event listeners and solver resources.\n *\n * This method removes the orientation change event listener and removes\n * the constraint from the solver system. After calling this method,\n * the constraint should not be used anymore.\n */\n public destroy(): void {\n this.layer.off(UILayerEvent.ORIENTATION_CHANGE, this.onOrientationChange);\n this.solverWrapper.removeConstraint(this.constraint);\n }\n\n /**\n * Determines if the constraint should be enabled based on orientation.\n *\n * The constraint is enabled if its orientation is set to ALWAYS or if\n * it matches the current layer orientation.\n *\n * @returns True if the constraint should be enabled, false otherwise\n * @protected\n */\n protected isConstraintEnabled(): boolean {\n return (\n this.orientationInternal === UIOrientation.ALWAYS ||\n this.orientationInternal === this.layer.orientation\n );\n }\n\n /**\n * Event handler for layer orientation changes.\n *\n * Updates the constraint's enabled state in the solver based on the\n * current orientation and the constraint's orientation setting.\n *\n * @private\n */\n private readonly onOrientationChange = (): void => {\n this.solverWrapper.setConstraintEnabled(\n this.constraint,\n this.isConstraintEnabled(),\n );\n };\n}\n","import type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIHeightConstraint creation.\n */\nexport interface UIHeightConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The desired height value for the element. */\n height: number;\n}\n\n/**\n * Constraint that enforces a specific height value for UI elements.\n *\n * UIHeightConstraint creates a mathematical relationship that fixes an element's\n * height to a constant value. The constraint equation is: element.height = height.\n * This is useful for ensuring elements maintain a specific height regardless of\n * other layout changes or for setting fixed dimensions in responsive layouts.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Elements that can have height constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIHeightConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for the current height value. */\n private heightInternal: number;\n\n /**\n * Creates a new UIHeightConstraint instance.\n *\n * If no height is specified in options, the constraint will use the\n * element's current height as the target height value.\n *\n * @param element - The UI element to apply the height constraint to\n * @param options - Configuration options for the constraint\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIHeightConstraintOptions> = {},\n ) {\n super(\n element.layer,\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.heightInternal = options.height ?? element.height;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.hVariable, 1]]),\n new UIExpression(this.heightInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current height value being enforced.\n * @returns The height value in pixels\n */\n public get height(): number {\n return this.heightInternal;\n }\n\n /**\n * Sets a new height value and updates the constraint equation.\n * @param value - The new height value in pixels\n */\n public set height(value: number) {\n if (this.heightInternal !== value) {\n this.heightInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import { UILayer } from \"../layers/UILayer\";\n\n/** Small epsilon value for floating-point comparisons and minimum positive number validation. */\nexport const EPSILON = 1e-6;\n\n/**\n * Interface for objects that belong to a UI layer.\n *\n * Elements implementing this interface are associated with a specific layer\n * for constraint solving and rendering management.\n */\nexport interface UILayerElement {\n /** The UI layer that contains this element. */\n layer: UILayer;\n}\n\n/**\n * Interface for UI elements that have a position in 2D space.\n *\n * Point elements are characterized by x and y coordinates represented\n * as solver variable descriptors for constraint-based positioning.\n */\nexport interface UIPointElement {\n /** Solver variable descriptor for the x-coordinate. */\n xVariable: number;\n /** Solver variable descriptor for the y-coordinate. */\n yVariable: number;\n\n /** The x-coordinate of the element. */\n x: number;\n /** The y-coordinate of the element. */\n y: number;\n}\n\n/**\n * Interface for UI elements that have both position and dimensions in 2D space.\n *\n * Plane elements extend point elements with width and height properties,\n * enabling rectangular area constraints and positioning.\n */\nexport interface UIPlaneElement extends UIPointElement {\n /** Solver variable descriptor for the width dimension. */\n wVariable: number;\n /** Solver variable descriptor for the height dimension. */\n hVariable: number;\n\n /** The width of the element. */\n width: number;\n /** The height of the element. */\n height: number;\n}\n\n/**\n * Type guard to check if an object implements the UILayerElement interface.\n *\n * @param obj - The object to check\n * @returns True if the object has a valid layer property, false otherwise\n */\nexport function isUILayerElement(obj: unknown): obj is UILayerElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"layer\" in obj &&\n obj.layer instanceof UILayer\n );\n}\n\n/**\n * Type guard to check if an object implements the UIPointElement interface.\n *\n * @param obj - The object to check\n * @returns True if the object has valid xVariable and yVariable properties, false otherwise\n */\nexport function isUIPointElement(obj: unknown): obj is UIPointElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"xVariable\" in obj &&\n typeof obj.xVariable === \"number\" &&\n \"yVariable\" in obj &&\n typeof obj.yVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\n/**\n * Type guard to check if an object implements the UIPlaneElement interface.\n *\n * Note: This function only checks for width and height variables. Objects\n * should also satisfy UIPointElement requirements for complete validation.\n *\n * @param obj - The object to check\n * @returns True if the object has valid wVariable and hVariable properties, false otherwise\n */\nexport function isUIPlaneElement(obj: unknown): obj is UIPlaneElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"wVariable\" in obj &&\n typeof obj.wVariable === \"number\" &&\n \"hVariable\" in obj &&\n typeof obj.hVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\n/**\n * Validates that two objects are valid constraint subjects from the same layer.\n *\n * Ensures that both objects are either UILayer instances or UILayerElement instances,\n * that they are not both layers (which cannot be constrained to each other),\n * and that they belong to the same layer for constraint solving.\n *\n * @param a - The first constraint subject\n * @param b - The second constraint subject\n * @param subject - The name of the constraint for error messages\n * @returns The common layer that both subjects belong to\n * @throws Will throw an error if subjects are invalid or from different layers\n */\nexport function assertValidConstraintSubjects(\n a: unknown,\n b: unknown,\n subject: string,\n): UILayer {\n if (a instanceof UILayer && b instanceof UILayer) {\n throw new Error(`${subject}: layer cannot be snapped to another layer`);\n }\n\n let layerA: UILayer;\n let layerB: UILayer;\n\n if (a instanceof UILayer || isUILayerElement(a)) {\n layerA = a instanceof UILayer ? a : a.layer;\n } else {\n throw new Error(`${subject}: A must be a UILayer or a UIPointElement`);\n }\n\n if (b instanceof UILayer || isUILayerElement(b)) {\n layerB = b instanceof UILayer ? b : b.layer;\n } else {\n throw new Error(`${subject}: B must be a UILayer or a UIPointElement`);\n }\n\n if (layerA !== layerB) {\n throw new Error(`${subject}: elements must be on the same layer`);\n }\n\n return layerA;\n}\n\n/**\n * Validates that a value is a finite number within safe integer range.\n *\n * Checks that the value is finite (not NaN, Infinity, or -Infinity) and\n * within the safe integer range for reliable mathematical operations.\n *\n * @param value - The number to validate\n * @param subject - The name of the value for error messages\n * @throws Will throw an error if the value is not finite or exceeds safe range\n */\nexport function assertValidNumber(value: number, subject: string): void {\n if (!Number.isFinite(value)) {\n throw new Error(`${subject}: value must be a finite number`);\n }\n\n if (Math.abs(value) > Number.MAX_SAFE_INTEGER) {\n throw new Error(`${subject}: value exceeds maximum safe integer range`);\n }\n}\n\n/**\n * Validates that a value is a positive number above the epsilon threshold.\n *\n * First validates that the value is a finite number, then ensures it is\n * greater than or equal to EPSILON to avoid numerical precision issues\n * with very small positive values.\n *\n * @param value - The number to validate\n * @param subject - The name of the value for error messages\n * @throws Will throw an error if the value is invalid or not sufficiently positive\n * @see {@link assertValidNumber}\n */\nexport function assertValidPositiveNumber(\n value: number,\n subject: string,\n): void {\n assertValidNumber(value, subject);\n\n if (value < EPSILON) {\n throw new Error(\n `${subject}: value must be greater than or equal to ${EPSILON}`,\n );\n }\n}\n\n/**\n * Validates that a value is a non-negative number (including zero).\n *\n * First validates that the value is a finite number, then ensures it is\n * greater than or equal to zero. Unlike assertValidPositiveNumber, this\n * function allows zero as a valid value.\n *\n * @param value - The number to validate\n * @param subject - The name of the value for error messages\n * @throws Will throw an error if the value is invalid or negative\n * @see {@link assertValidNumber}\n */\nexport function assertValidNonNegativeNumber(\n value: number,\n subject: string,\n): void {\n assertValidNumber(value, subject);\n if (value < 0) {\n throw new Error(`${subject}: value must be greater than or equal to 0`);\n }\n}\n","import type { UIPlaneElement, UIPointElement } from \"../miscellaneous/asserts\";\nimport {\n assertValidConstraintSubjects,\n isUIPlaneElement,\n isUIPointElement,\n} from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/** Default anchor point (0.5 = center) for elements when not specified. */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for UIHorizontalDistanceConstraint creation.\n */\nexport interface UIHorizontalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor point for element A (0.0 = left edge, 0.5 = center, 1.0 = right edge). */\n anchorA: number;\n /** Anchor point for element B (0.0 = left edge, 0.5 = center, 1.0 = right edge). */\n anchorB: number;\n /** The desired horizontal distance between the elements. */\n distance: number;\n}\n\n/**\n * Constraint that enforces horizontal distance between two UI elements.\n *\n * UIHorizontalDistanceConstraint creates a mathematical relationship that maintains\n * a specific horizontal distance between two elements using configurable anchor points.\n * For plane elements, anchors determine the reference point (0.0 = left, 0.5 = center, 1.0 = right).\n * For point elements, the anchor is always the element's position. The constraint equation is:\n * (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA) = distance\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPointElement} - Point elements that can be constrained\n * @see {@link UIPlaneElement} - Plane elements that can be constrained\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for element A's anchor point. */\n private anchorAInternal: number;\n /** Internal storage for element B's anchor point. */\n private anchorBInternal: number;\n /** Internal storage for the horizontal distance value. */\n private distanceInternal: number;\n\n /**\n * Creates a new UIHorizontalDistanceConstraint instance.\n *\n * The constraint will use default anchor points (0.5 = center) and zero distance\n * if not specified in options. Both elements must be from the same layer.\n *\n * @param a - The first UI element (point or plane element)\n * @param b - The second UI element (point or plane element)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIHorizontalDistanceConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIHorizontalDistanceConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current horizontal distance being enforced.\n * @returns The horizontal distance in pixels\n */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /**\n * Gets the anchor point for element A.\n * @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /**\n * Gets the anchor point for element B.\n * @returns The anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /**\n * Sets a new horizontal distance and updates the constraint equation.\n * @param value - The new horizontal distance in pixels\n */\n public set distance(value: number) {\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /**\n * Sets a new anchor point for element A and updates the constraint equation.\n * @param value - The new anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public set anchorA(value: number) {\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Sets a new anchor point for element B and updates the constraint equation.\n * @param value - The new anchor value (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public set anchorB(value: number) {\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Builds the left-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementB.x + elementB.width * anchorB) - (elementA.x + elementA.width * anchorA)\n * For point elements, only the x position is used since they have no width.\n * For plane elements, the anchor determines the reference point within the element's width.\n *\n * @returns The UIExpression representing the horizontal distance calculation\n * @private\n */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.xVariable, 1],\n [this.a.wVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.xVariable, 1);\n } else {\n throw new Error(\"A is not a valid element type\");\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.xVariable, 1],\n [this.b.wVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.xVariable, 1);\n } else {\n throw new Error(\"B is not a valid element type\");\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { assertValidConstraintSubjects } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIHorizontalProportionConstraint creation.\n */\nexport interface UIHorizontalProportionConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The proportional relationship between element widths (elementA.width = elementB.width * proportion). */\n proportion: number;\n}\n\n/**\n * Constraint that enforces proportional width relationships between two UI elements.\n *\n * UIHorizontalProportionConstraint creates a mathematical relationship that maintains\n * a proportional ratio between the widths of two plane elements. The constraint equation is:\n * elementA.width * proportion = elementB.width, which can be rearranged as:\n * elementA.width * proportion - elementB.width = 0\n *\n * This is useful for creating responsive layouts where elements need to maintain\n * specific width ratios, such as sidebar-to-content ratios or grid column proportions.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIHorizontalProportionConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n /** Internal storage for the current proportion value. */\n private proportionInternal: number;\n\n /**\n * Creates a new UIHorizontalProportionConstraint instance.\n *\n * The constraint will enforce the relationship: elementA.width * proportion = elementB.width.\n * If no proportion is specified, it defaults to 1.0 (equal widths).\n * Both elements must be from the same layer.\n *\n * @param a - The first UI plane element (whose width will be multiplied by proportion)\n * @param b - The second UI plane element (target width for the proportion)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIHorizontalProportionConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIHorizontalProportionConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current proportion value being enforced.\n * @returns The proportion ratio (elementA.width = elementB.width * proportion)\n */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /**\n * Sets a new proportion value and updates the constraint equation.\n * @param value - The new proportion ratio\n */\n public set proportion(value: number) {\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /**\n * Builds the right-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementA.width * proportion) - elementB.width = 0\n * This enforces the relationship: elementA.width * proportion = elementB.width\n *\n * @returns The UIExpression representing the proportional width relationship\n * @private\n */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.wVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.wVariable, 1]]),\n );\n }\n}\n","import type { UIPlaneElement, UIPointElement } from \"../miscellaneous/asserts\";\nimport {\n assertValidConstraintSubjects,\n isUIPlaneElement,\n isUIPointElement,\n} from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/** Default anchor point (0.5 = center) for elements when not specified. */\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for UIVerticalDistanceConstraint creation.\n */\nexport interface UIVerticalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor point for element A (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */\n anchorA: number;\n /** Anchor point for element B (0.0 = top edge, 0.5 = center, 1.0 = bottom edge). */\n anchorB: number;\n /** The desired vertical distance between the elements. */\n distance: number;\n}\n\n/**\n * Constraint that enforces vertical distance between two UI elements.\n *\n * UIVerticalDistanceConstraint creates a mathematical relationship that maintains\n * a specific vertical distance between two elements using configurable anchor points.\n * For plane elements, anchors determine the reference point (0.0 = top, 0.5 = center, 1.0 = bottom).\n * For point elements, the anchor is always the element's position. The constraint equation is:\n * (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA) = distance\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPointElement} - Point elements that can be constrained\n * @see {@link UIPlaneElement} - Plane elements that can be constrained\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIVerticalDistanceConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for element A's anchor point. */\n private anchorAInternal: number;\n /** Internal storage for element B's anchor point. */\n private anchorBInternal: number;\n /** Internal storage for the vertical distance value. */\n private distanceInternal: number;\n\n /**\n * Creates a new UIVerticalDistanceConstraint instance.\n *\n * The constraint will use default anchor points (0.5 = center) and zero distance\n * if not specified in options. Both elements must be from the same layer.\n *\n * @param a - The first UI element (point or plane element)\n * @param b - The second UI element (point or plane element)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIVerticalDistanceConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIVerticalDistanceConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current vertical distance being enforced.\n * @returns The vertical distance in pixels\n */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /**\n * Gets the anchor point for element A.\n * @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /**\n * Gets the anchor point for element B.\n * @returns The anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /**\n * Sets a new vertical distance and updates the constraint equation.\n * @param value - The new vertical distance in pixels\n */\n public set distance(value: number) {\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /**\n * Sets a new anchor point for element A and updates the constraint equation.\n * @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public set anchorA(value: number) {\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Sets a new anchor point for element B and updates the constraint equation.\n * @param value - The new anchor value (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public set anchorB(value: number) {\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Builds the left-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementB.y + elementB.height * anchorB) - (elementA.y + elementA.height * anchorA)\n * For point elements, only the y position is used since they have no height.\n * For plane elements, the anchor determines the reference point within the element's height.\n *\n * @returns The UIExpression representing the vertical distance calculation\n * @private\n */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.yVariable, 1],\n [this.a.hVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.yVariable, 1);\n } else {\n throw new Error(\"A is not a valid element type\");\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.yVariable, 1],\n [this.b.hVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.yVariable, 1);\n } else {\n throw new Error(\"B is not a valid element type\");\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { assertValidConstraintSubjects } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIVerticalProportionConstraint creation.\n */\nexport interface UIVerticalProportionConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The proportional relationship between element heights (elementA.height = elementB.height * proportion). */\n proportion: number;\n}\n\n/**\n * Constraint that enforces proportional height relationships between two UI elements.\n *\n * UIVerticalProportionConstraint creates a mathematical relationship that maintains\n * a proportional ratio between the heights of two plane elements. The constraint equation is:\n * elementA.height * proportion = elementB.height, which can be rearranged as:\n * elementA.height * proportion - elementB.height = 0\n *\n * This is useful for creating responsive layouts where elements need to maintain\n * specific height ratios, such as header-to-content ratios or row height proportions.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Plane elements that can have proportional constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIVerticalProportionConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n /** Internal storage for the current proportion value. */\n private proportionInternal: number;\n\n /**\n * Creates a new UIVerticalProportionConstraint instance.\n *\n * The constraint will enforce the relationship: elementA.height * proportion = elementB.height.\n * If no proportion is specified, it defaults to 1.0 (equal heights).\n * Both elements must be from the same layer.\n *\n * @param a - The first UI plane element (whose height will be multiplied by proportion)\n * @param b - The second UI plane element (target height for the proportion)\n * @param options - Configuration options for the constraint\n * @throws Will throw an error if elements are not from the same layer\n * @see {@link assertValidConstraintSubjects}\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIVerticalProportionConstraintOptions> = {},\n ) {\n super(\n assertValidConstraintSubjects(a, b, \"UIVerticalProportionConstraint\"),\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relationInternal,\n this.priorityInternal,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current proportion value being enforced.\n * @returns The proportion ratio (elementA.height = elementB.height * proportion)\n */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /**\n * Sets a new proportion value and updates the constraint equation.\n * @param value - The new proportion ratio\n */\n public set proportion(value: number) {\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /**\n * Builds the right-hand side expression for the constraint equation.\n *\n * Creates the expression: (elementA.height * proportion) - elementB.height = 0\n * This enforces the relationship: elementA.height * proportion = elementB.height\n *\n * @returns The UIExpression representing the proportional height relationship\n * @private\n */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.hVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.hVariable, 1]]),\n );\n }\n}\n","import type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIWidthConstraint creation.\n */\nexport interface UIWidthConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The desired width value for the element. */\n width: number;\n}\n\n/**\n * Constraint that enforces a specific width value for UI elements.\n *\n * UIWidthConstraint creates a mathematical relationship that fixes an element's\n * width to a constant value. The constraint equation is: element.width = width.\n * This is useful for ensuring elements maintain a specific width regardless of\n * other layout changes or for setting fixed dimensions in responsive layouts.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Elements that can have width constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIWidthConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for the current width value. */\n private widthInternal: number;\n\n /**\n * Creates a new UIWidthConstraint instance.\n *\n * If no width is specified in options, the constraint will use the\n * element's current width as the target width value.\n *\n * @param element - The UI element to apply the width constraint to\n * @param options - Configuration options for the constraint\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIWidthConstraintOptions> = {},\n ) {\n super(\n element.layer,\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.widthInternal = options.width ?? element.width;\n\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.wVariable, 1]]),\n new UIExpression(this.widthInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current width value being enforced.\n * @returns The width value in pixels\n */\n public get width(): number {\n return this.widthInternal;\n }\n\n /**\n * Sets a new width value and updates the constraint equation.\n * @param value - The new width value in pixels\n */\n public set width(value: number) {\n if (this.widthInternal !== value) {\n this.widthInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import { UIHeightConstraint } from \"../constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../constraints/UIWidthConstraint\";\nimport type { UIElement } from \"../elements/UIElement\";\nimport type { UIPlaneElement, UIPointElement } from \"../miscellaneous/asserts\";\nimport type { UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport type { UIPriority } from \"../miscellaneous/UIPriority\";\nimport type { UIRelation } from \"../miscellaneous/UIRelation\";\n\n/**\n * Generic 2D type for specifying horizontal and vertical values.\n *\n * This interface allows configuration of properties that can have\n * different values for horizontal and vertical directions.\n *\n * @template T - The type of values for horizontal and vertical properties\n */\nexport interface UIType2D<T> {\n /** Horizontal (x-axis) value. */\n h?: T;\n /** Vertical (y-axis) value. */\n v?: T;\n}\n\n/**\n * Base options for 2D constraint configuration.\n */\ninterface UIConstraint2DOptions {\n /** Priority levels for horizontal and vertical constraints. */\n priority: UIType2D<UIPriority>;\n /** Mathematical relations for horizontal and vertical constraints. */\n relation: UIType2D<UIRelation>;\n /** Orientation settings for horizontal and vertical constraints. */\n orientation: UIType2D<UIOrientation>;\n}\n\n/**\n * Configuration options for 2D size constraints.\n */\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n /** Size values for horizontal (width) and vertical (height) dimensions. */\n size: UIType2D<number>;\n}\n\n/**\n * Configuration options for 2D distance constraints.\n */\nexport interface UIConstraintDistance2DOptions extends UIConstraint2DOptions {\n /** Anchor points for element A in horizontal and vertical directions. */\n anchorA: UIType2D<number>;\n /** Anchor points for element B in horizontal and vertical directions. */\n anchorB: UIType2D<number>;\n /** Distance values for horizontal and vertical spacing. */\n distance: UIType2D<number>;\n}\n\n/**\n * Configuration options for 2D proportion constraints.\n */\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n /** Proportion ratios for horizontal and vertical relationships. */\n proportion: UIType2D<number>;\n}\n\n/**\n * Result object containing horizontal and vertical constraint instances.\n *\n * @template TH - The type of the horizontal constraint\n * @template TV - The type of the vertical constraint\n */\nexport interface UIConstraint2DResult<TH, TV> {\n /** The horizontal constraint instance. */\n h: TH;\n /** The vertical constraint instance. */\n v: TV;\n}\n\n/**\n * Builder utility for creating paired horizontal and vertical constraints.\n *\n * UIConstraint2DBuilder simplifies the creation of constraint pairs that work\n * together to define 2D relationships between UI elements. Instead of manually\n * creating separate horizontal and vertical constraints, this builder allows\n * you to specify both dimensions at once with a unified interface.\n *\n * This is particularly useful for creating consistent spacing, sizing, and\n * proportional relationships across both axes simultaneously.\n *\n * @see {@link UIWidthConstraint} - Horizontal size constraints\n * @see {@link UIHeightConstraint} - Vertical size constraints\n * @see {@link UIHorizontalDistanceConstraint} - Horizontal spacing constraints\n * @see {@link UIVerticalDistanceConstraint} - Vertical spacing constraints\n */\nexport class UIConstraint2DBuilder {\n /**\n * Creates paired width and height constraints for an element.\n *\n * This method generates both horizontal (width) and vertical (height)\n * size constraints simultaneously, allowing you to set fixed dimensions\n * for both axes with a single call.\n *\n * @param element - The UI element to apply size constraints to\n * @param options - Configuration options for both width and height constraints\n * @returns Object containing the created width and height constraint instances\n */\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions> = {},\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n return {\n h: new UIWidthConstraint(element, {\n width: options.size?.h,\n priority: options.priority?.h,\n relation: options.relation?.h,\n orientation: options.orientation?.h,\n }),\n v: new UIHeightConstraint(element, {\n height: options.size?.v,\n priority: options.priority?.v,\n relation: options.relation?.v,\n orientation: options.orientation?.v,\n }),\n };\n }\n\n /**\n * Creates paired horizontal and vertical distance constraints between two elements.\n *\n * This method generates both horizontal and vertical spacing constraints\n * simultaneously, allowing you to define 2D spacing relationships with\n * configurable anchor points for both axes.\n *\n * @param a - The first UI element (point or plane element)\n * @param b - The second UI element (point or plane element)\n * @param options - Configuration options for both horizontal and vertical distance constraints\n * @returns Object containing the created horizontal and vertical distance constraint instances\n */\n public static distance(\n a: UIPointElement | UIPlaneElement,\n b: UIPointElement | UIPlaneElement,\n options: Partial<UIConstraintDistance2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n return {\n h: new UIHorizontalDistanceConstraint(a, b, {\n anchorA: options.anchorA?.h,\n anchorB: options.anchorB?.h,\n distance: options.distance?.h,\n priority: options.priority?.h,\n relation: options.relation?.h,\n orientation: options.orientation?.h,\n }),\n v: new UIVerticalDistanceConstraint(a, b, {\n anchorA: options.anchorA?.v,\n anchorB: options.anchorB?.v,\n distance: options.distance?.v,\n priority: options.priority?.v,\n relation: options.relation?.v,\n orientation: options.orientation?.v,\n }),\n };\n }\n\n /**\n * Creates paired horizontal and vertical proportion constraints between two elements.\n *\n * This method generates both horizontal (width) and vertical (height)\n * proportion constraints simultaneously, allowing you to define proportional\n * relationships for both dimensions with a single call.\n *\n * @param a - The first UI plane element (whose dimensions will be multiplied by proportion)\n * @param b - The second UI plane element (target dimensions for the proportion)\n * @param options - Configuration options for both horizontal and vertical proportion constraints\n * @returns Object containing the created horizontal and vertical proportion constraint instances\n */\n public static proportion(\n a: UIPlaneElement,\n b: UIPlaneElement,\n options: Partial<UIConstraintProportion2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n return {\n h: new UIHorizontalProportionConstraint(a, b, {\n proportion: options.proportion?.h,\n priority: options.priority?.h,\n relation: options.relation?.h,\n orientation: options.orientation?.h,\n }),\n v: new UIVerticalProportionConstraint(a, b, {\n proportion: options.proportion?.v,\n priority: options.priority?.v,\n relation: options.relation?.v,\n orientation: options.orientation?.v,\n }),\n };\n }\n}\n","import type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Configuration options for UIAspectConstraint creation.\n */\nexport interface UIAspectConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** The desired aspect ratio (width/height) for the element. */\n aspect: number;\n}\n\n/**\n * Constraint that maintains a specific aspect ratio for UI elements.\n *\n * UIAspectConstraint enforces a mathematical relationship between an element's\n * width and height to maintain a constant aspect ratio. The constraint equation\n * is: width = height * aspect. This is useful for ensuring elements maintain\n * their proportions during layout changes or for enforcing specific aspect\n * ratios like 16:9 for video content.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIPlaneElement} - Elements that can have aspect constraints applied\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n */\nexport class UIAspectConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n\n /** Internal storage for the current aspect ratio value. */\n private aspectInternal: number;\n\n /**\n * Creates a new UIAspectConstraint instance.\n *\n * If no aspect ratio is specified in options, the constraint will use the\n * element's current width-to-height ratio as the target aspect ratio.\n *\n * @param element - The UI element to apply the aspect constraint to\n * @param options - Configuration options for the constraint\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIAspectConstraintOptions> = {},\n ) {\n super(\n element.layer,\n options.priority,\n options.relation,\n options.orientation,\n );\n\n this.aspectInternal = options.aspect ?? element.width / element.height;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current aspect ratio being enforced.\n * @returns The aspect ratio (width/height)\n */\n public get aspect(): number {\n return this.aspectInternal;\n }\n\n /**\n * Sets a new aspect ratio and updates the constraint equation.\n * @param value - The new aspect ratio (width/height)\n */\n public set aspect(value: number) {\n if (this.aspectInternal !== value) {\n this.aspectInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /**\n * Builds the left-hand side expression for the constraint equation.\n *\n * Creates the expression: width - (height * aspect) = 0\n * This enforces the relationship: width = height * aspect\n *\n * @returns The UIExpression representing the constraint equation\n * @private\n */\n private buildLHS(): UIExpression {\n return new UIExpression(0, [\n [this.element.wVariable, 1],\n [this.element.hVariable, -this.aspectInternal],\n ]);\n }\n}\n","import { UIAspectConstraint } from \"../constraints/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../constraints/UIVerticalProportionConstraint\";\nimport type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { type UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../miscellaneous/UIRelation\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for the UICoverConstraintBuilder.\n */\nexport interface UICoverConstraintBuilderOptions {\n /** Whether to maintain the aspect ratio of the active (content) element */\n keepActiveAspect: boolean;\n /** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */\n anchorH: number;\n /** Vertical anchor point (0.0 = bottom, 0.5 = center, 1.0 = top) */\n anchorV: number;\n /** Orientation context for constraint calculations */\n orientation: UIOrientation;\n}\n\n/**\n * Builder for creating \"cover\" layout constraints that make an element cover its container.\n *\n * Cover layout ensures the active element is large enough to completely cover the passive\n * element while maintaining proportions. This is similar to CSS `background-size: cover`\n * or `object-fit: cover` behavior.\n *\n * The active element will be:\n * - Positioned at the specified anchor point within the passive element\n * - Sized to be at least as large as the passive element in both dimensions\n * - Scaled proportionally to maintain aspect ratio (if enabled)\n */\nexport class UICoverConstraintBuilder {\n /**\n * Creates a set of constraints for cover layout behavior.\n *\n * @param passive - The container element (what gets covered)\n * @param active - The content element (what does the covering)\n * @param options - Configuration options for the cover layout\n * @returns Object containing all created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UICoverConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint for the active element (if keepActiveAspect is true) */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal positioning constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical positioning constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width proportion constraint (ensures coverage) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height proportion constraint (ensures coverage) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.GREATER_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import { UIAspectConstraint } from \"../constraints/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../constraints/UIVerticalProportionConstraint\";\nimport type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport { type UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../miscellaneous/UIRelation\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\n/**\n * Configuration options for the UIFitConstraintBuilder.\n */\nexport interface UIFitConstraintBuilderOptions {\n /** Whether to maintain the aspect ratio of the active (content) element */\n keepActiveAspect: boolean;\n /** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */\n anchorH: number;\n /** Vertical anchor point (0.0 = bottom, 0.5 = center, 1.0 = top) */\n anchorV: number;\n /** Orientation context for constraint calculations */\n orientation: UIOrientation;\n}\n\n/**\n * Builder for creating \"fit\" layout constraints that make an element fit within its container.\n *\n * Fit layout ensures the active element is sized to completely fit within the passive\n * element while maintaining proportions. This is similar to CSS `background-size: contain`\n * or `object-fit: contain` behavior.\n *\n * The active element will be:\n * - Positioned at the specified anchor point within the passive element\n * - Sized to fit entirely within the passive element in both dimensions\n * - Scaled proportionally to maintain aspect ratio (if enabled)\n */\nexport class UIFitConstraintBuilder {\n /**\n * Creates a set of constraints for fit layout behavior.\n *\n * @param passive - The container element (what contains the content)\n * @param active - The content element (what gets fitted within the container)\n * @param options - Configuration options for the fit layout\n * @returns Object containing all created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UIFitConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint for the active element (if keepActiveAspect is true) */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal positioning constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical positioning constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width proportion constraint (ensures fitting) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height proportion constraint (ensures fitting) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.LESS_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import type { UILayer } from \"../layers/UILayer\";\nimport type { UIExpression } from \"../miscellaneous/UIExpression\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint\";\n\n/**\n * Constraint that allows custom mathematical relationships between UI elements.\n *\n * UICustomConstraint provides maximum flexibility by allowing direct specification\n * of the left-hand side (LHS) and right-hand side (RHS) expressions for constraint\n * equations. This enables creation of complex mathematical relationships that may\n * not be covered by the specialized constraint types. The constraint equation is:\n * LHS relation RHS (e.g., LHS = RHS, LHS ≤ RHS, or LHS ≥ RHS)\n *\n * This is useful for implementing custom layout logic, complex mathematical\n * relationships between multiple elements, or prototype new constraint types.\n *\n * @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints\n * @see {@link UIExpression} - Mathematical expressions for constraint equations\n * @see {@link UILayer} - Container layer for constraints\n */\nexport class UICustomConstraint extends UISingleParameterConstraint {\n /** The constraint descriptor managed by the solver system. */\n protected override readonly constraint: number;\n /** Internal storage for the left-hand side expression. */\n private lhsInternal: UIExpression;\n /** Internal storage for the right-hand side expression. */\n private rhsInternal: UIExpression;\n\n /**\n * Creates a new UICustomConstraint instance with custom expressions.\n *\n * The constraint will enforce the relationship: LHS relation RHS, where\n * the relation is determined by the options (defaults to equality).\n *\n * @param layer - The UI layer that contains this constraint\n * @param lhs - The left-hand side expression of the constraint equation\n * @param rhs - The right-hand side expression of the constraint equation\n * @param options - Configuration options for the constraint\n */\n constructor(\n layer: UILayer,\n lhs: UIExpression,\n rhs: UIExpression,\n options: Partial<UISingleParameterConstraintOptions> = {},\n ) {\n super(layer, options.priority, options.relation, options.orientation);\n\n this.lhsInternal = lhs;\n this.rhsInternal = rhs;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.lhsInternal,\n this.rhsInternal,\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /**\n * Gets the current left-hand side expression.\n * @returns The LHS expression of the constraint equation\n */\n public get lhs(): UIExpression {\n return this.lhsInternal;\n }\n\n /**\n * Gets the current right-hand side expression.\n * @returns The RHS expression of the constraint equation\n */\n public get rhs(): UIExpression {\n return this.rhsInternal;\n }\n\n /**\n * Sets a new left-hand side expression and updates the constraint.\n * @param value - The new LHS expression for the constraint equation\n */\n public setLHS(value: UIExpression): void {\n this.lhsInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.lhsInternal);\n }\n\n /**\n * Sets a new right-hand side expression and updates the constraint.\n * @param value - The new RHS expression for the constraint equation\n */\n public setRHS(value: UIExpression): void {\n this.rhsInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.rhsInternal);\n }\n}\n","import { Eventail } from \"eventail\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport type { UIPointElement } from \"../miscellaneous/asserts\";\nimport { assertValidNumber } from \"../miscellaneous/asserts\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport type { UISolverWrapper } from \"../wrappers/UISolverWrapper\";\n\n/**\n * Abstract base class representing a minimal UI element as a point in 2D space.\n *\n * A UIAnchor serves as the fundamental building block for UI layout systems,\n * representing a single point with x and y coordinates. It provides constraint-based\n * positioning through solver variables and serves as an anchor point for more\n * complex UI elements.\n *\n * @see {@link UIPointElement} - Interface defining point element behavior\n * @see {@link UILayer} - Container layer for UI elements\n * @see {@link UISolverWrapper} - Constraint solver integration\n */\nexport abstract class UIAnchor extends Eventail implements UIPointElement {\n /** Optional name identifier for the anchor. */\n public name = \"\";\n\n /**\n * Solver variable descriptor for the x-coordinate.\n * This variable is managed by the constraint solver system.\n */\n public readonly xVariable: number;\n\n /**\n * Solver variable descriptor for the y-coordinate.\n * This variable is managed by the constraint solver system.\n */\n public readonly yVariable: number;\n\n /**\n * Reference to the constraint solver wrapper for variable management.\n * @see {@link UISolverWrapper}\n */\n protected readonly solverWrapper: UISolverWrapper;\n\n /**\n * Creates a new UIAnchor instance.\n *\n * @param layer - The UI layer that contains this anchor\n * @param x - Initial x-coordinate position\n * @param y - Initial y-coordinate position\n * @throws Will throw an error if x or y are not valid numbers\n * @see {@link assertValidNumber}\n */\n constructor(\n public readonly layer: UILayer,\n x: number,\n y: number,\n ) {\n assertValidNumber(x, \"UIAnchor x\");\n assertValidNumber(y, \"UIAnchor y\");\n\n super();\n this.solverWrapper = this.layer[\"getSolverWrapperInternal\"]();\n this.xVariable = this.solverWrapper.createVariable(x, UIPriority.P7);\n this.yVariable = this.solverWrapper.createVariable(y, UIPriority.P7);\n }\n\n /**\n * Gets the current x-coordinate value from the solver.\n * @returns The current x-coordinate position\n */\n public get x(): number {\n return this.solverWrapper.readVariableValue(this.xVariable);\n }\n\n /**\n * Gets the current y-coordinate value from the solver.\n * @returns The current y-coordinate position\n */\n public get y(): number {\n return this.solverWrapper.readVariableValue(this.yVariable);\n }\n\n /**\n * Sets the x-coordinate value through the solver system.\n * @param value - The new x-coordinate value\n * @throws Will throw an error if value is not a valid number\n * @see {@link assertValidNumber}\n */\n public set x(value: number) {\n assertValidNumber(value, \"UIAnchor x\");\n this.solverWrapper.suggestVariableValue(this.xVariable, value);\n }\n\n /**\n * Sets the y-coordinate value through the solver system.\n * @param value - The new y-coordinate value\n * @throws Will throw an error if value is not a valid number\n * @see {@link assertValidNumber}\n */\n public set y(value: number) {\n assertValidNumber(value, \"UIAnchor y\");\n this.solverWrapper.suggestVariableValue(this.yVariable, value);\n }\n\n /**\n * Destroys the anchor by removing its solver variables.\n *\n * This method cleans up the solver variables associated with this anchor,\n * effectively removing it from the constraint solving system. After calling\n * this method, the anchor should not be used anymore.\n */\n public destroy(): void {\n this.solverWrapper.removeVariable(this.yVariable);\n this.solverWrapper.removeVariable(this.xVariable);\n }\n}\n","import type { UILayer } from \"../layers/UILayer\";\nimport {\n assertValidPositiveNumber,\n type UIPlaneElement,\n} from \"../miscellaneous/asserts\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport { UIAnchor } from \"./UIAnchor\";\n\n/** Default width and height value for UIDummy elements. */\nconst DEFAULT_SIZE = 100;\n\n/**\n * Abstract UI element that extends UIAnchor with dimensions but without rendering.\n *\n * UIDummy represents a rectangular area in the UI layout system that has position\n * and dimensions (width and height) but does not perform any visual rendering.\n * It serves as a placeholder or spacer element in constraint-based layouts,\n * useful for defining layout structure without visual content.\n *\n * @see {@link UIAnchor} - Base class providing position functionality\n * @see {@link UIPlaneElement} - Interface defining dimensional element behavior\n * @see {@link UILayer} - Container layer for UI elements\n */\nexport abstract class UIDummy extends UIAnchor implements UIPlaneElement {\n /**\n * Solver variable descriptor for the width dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly wVariable: number;\n\n /**\n * Solver variable descriptor for the height dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly hVariable: number;\n\n /**\n * Creates a new UIDummy instance with position and dimensions.\n *\n * @param layer - The UI layer that contains this dummy element\n * @param x - Initial x-coordinate position\n * @param y - Initial y-coordinate position\n * @param width - Initial width dimension (defaults to 100)\n * @param height - Initial height dimension (defaults to 100)\n * @throws Will throw an error if width or height are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n constructor(\n layer: UILayer,\n x: number,\n y: number,\n width: number = DEFAULT_SIZE,\n height: number = DEFAULT_SIZE,\n ) {\n assertValidPositiveNumber(width, \"UIDummy width\");\n assertValidPositiveNumber(height, \"UIDummy height\");\n\n super(layer, x, y);\n this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);\n this.hVariable = this.solverWrapper.createVariable(height, UIPriority.P6);\n }\n\n /**\n * Gets the current width value from the solver.\n * @returns The current width dimension\n */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /**\n * Gets the current height value from the solver.\n * @returns The current height dimension\n */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /**\n * Sets the width value through the solver system.\n * @param value - The new width dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIDummy width\");\n this.solverWrapper.suggestVariableValue(this.wVariable, value);\n }\n\n /**\n * Sets the height value through the solver system.\n * @param value - The new height dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIDummy height\");\n this.solverWrapper.suggestVariableValue(this.hVariable, value);\n }\n\n /**\n * Destroys the dummy element by removing its solver variables.\n *\n * This method cleans up the dimension solver variables (width and height)\n * associated with this dummy element, then calls the parent destroy method\n * to clean up position variables. After calling this method, the dummy\n * element should not be used anymore.\n */\n public override destroy(): void {\n this.solverWrapper.removeVariable(this.hVariable);\n this.solverWrapper.removeVariable(this.wVariable);\n super.destroy();\n }\n}\n","import { MathUtils } from \"three\";\nimport { UIAnchorMode } from \"./UIAnchorMode\";\n\n/** Default position value for x and y coordinates. */\nconst DEFAULT_POSITION = 0;\n/** Default anchor point value for anchorX and anchorY. */\nconst DEFAULT_ANCHOR = 0.5;\n/** Default scale value for scaleX and scaleY. */\nconst DEFAULT_SCALE = 1;\n/** Default rotation value in radians. */\nconst DEFAULT_ROTATION = 0;\n\n/**\n * Micro-transformation system for non-constraint based UI element adjustments.\n *\n * UIMicro provides a lightweight transformation system that operates independently\n * of the constraint solver. It manages position offsets, anchor points, scaling,\n * and rotation transformations that can be applied to UI elements for animations,\n * visual effects, or fine-tuned positioning without affecting the constraint-based\n * layout system.\n *\n * All transformations are tracked with change detection to optimize rendering\n * performance by only recalculating when properties have actually changed.\n *\n * @see {@link UIElement} - Elements that use micro transformations\n */\nexport class UIMicro {\n /** Internal storage for x-coordinate offset. */\n private xInternal: number = DEFAULT_POSITION;\n /** Internal storage for y-coordinate offset. */\n private yInternal: number = DEFAULT_POSITION;\n /** Internal storage for x-axis anchor point. */\n private anchorXInternal: number = DEFAULT_ANCHOR;\n /** Internal storage for y-axis anchor point. */\n private anchorYInternal: number = DEFAULT_ANCHOR;\n /** Internal storage for x-axis scale factor. */\n private scaleXInternal: number = DEFAULT_SCALE;\n /** Internal storage for y-axis scale factor. */\n private scaleYInternal: number = DEFAULT_SCALE;\n /** Internal storage for rotation in radians. */\n private rotationInternal: number = DEFAULT_ROTATION;\n /** Internal storage for anchor mode determining which transformations are applied around the anchor point. */\n private anchorModeInternal: UIAnchorMode = UIAnchorMode.ROTATION_SCALE;\n /** Flag indicating if any transformation properties have changed. */\n private recalculationRequired = false;\n\n /**\n * Gets the x-coordinate offset for micro positioning.\n * @returns The x-offset value\n */\n public get x(): number {\n return this.xInternal;\n }\n\n /**\n * Gets the y-coordinate offset for micro positioning.\n * @returns The y-offset value\n */\n public get y(): number {\n return this.yInternal;\n }\n\n /**\n * Gets the x-axis anchor point for transformations.\n * @returns The anchor point (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public get anchorX(): number {\n return this.anchorXInternal;\n }\n\n /**\n * Gets the y-axis anchor point for transformations.\n * @returns The anchor point (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public get anchorY(): number {\n return this.anchorYInternal;\n }\n\n /**\n * Gets the x-axis scale factor.\n * @returns The scale factor (1.0 = normal size)\n */\n public get scaleX(): number {\n return this.scaleXInternal;\n }\n\n /**\n * Gets the y-axis scale factor.\n * @returns The scale factor (1.0 = normal size)\n */\n public get scaleY(): number {\n return this.scaleYInternal;\n }\n\n /**\n * Gets the uniform scale factor (maximum of scaleX and scaleY).\n * @returns The larger of the two scale factors\n */\n public get size(): number {\n return Math.max(this.scaleXInternal, this.scaleYInternal);\n }\n\n /**\n * Gets the rotation angle in degrees.\n * @returns The rotation angle in degrees\n */\n public get angle(): number {\n return MathUtils.radToDeg(this.rotationInternal);\n }\n\n /**\n * Gets the current anchor mode determining which transformations are applied around the anchor point.\n * @returns The anchor mode (ROTATION_SCALE or POSITION_ROTATION_SCALE)\n */\n public get anchorMode(): UIAnchorMode {\n return this.anchorModeInternal;\n }\n\n /**\n * Gets the rotation angle in radians.\n * @returns The rotation angle in radians\n */\n public get rotation(): number {\n return this.rotationInternal;\n }\n\n /**\n * Sets the x-coordinate offset for micro positioning.\n * @param value - The new x-offset value\n */\n public set x(value: number) {\n if (value !== this.xInternal) {\n this.xInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the y-coordinate offset for micro positioning.\n * @param value - The new y-offset value\n */\n public set y(value: number) {\n if (value !== this.yInternal) {\n this.yInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the x-axis anchor point for transformations.\n * @param value - The anchor point (0.0 = left, 0.5 = center, 1.0 = right)\n */\n public set anchorX(value: number) {\n if (value !== this.anchorXInternal) {\n this.anchorXInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the y-axis anchor point for transformations.\n * @param value - The anchor point (0.0 = top, 0.5 = center, 1.0 = bottom)\n */\n public set anchorY(value: number) {\n if (value !== this.anchorYInternal) {\n this.anchorYInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the x-axis scale factor.\n * @param value - The scale factor (1.0 = normal size)\n */\n public set scaleX(value: number) {\n if (value !== this.scaleXInternal) {\n this.scaleXInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the y-axis scale factor.\n * @param value - The scale factor (1.0 = normal size)\n */\n public set scaleY(value: number) {\n if (value !== this.scaleYInternal) {\n this.scaleYInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets both scale factors to the same value for uniform scaling.\n * @param value - The uniform scale factor (1.0 = normal size)\n */\n public set size(value: number) {\n if (value !== this.scaleXInternal || value !== this.scaleYInternal) {\n this.scaleXInternal = value;\n this.scaleYInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the rotation angle in degrees.\n * @param value - The rotation angle in degrees\n */\n public set angle(value: number) {\n const rotation = MathUtils.degToRad(value);\n if (rotation !== this.rotationInternal) {\n this.rotationInternal = rotation;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the rotation angle in radians.\n * @param value - The rotation angle in radians\n */\n public set rotation(value: number) {\n if (value !== this.rotationInternal) {\n this.rotationInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Sets the anchor mode determining which transformations are applied around the anchor point.\n * @param value - The anchor mode (ROTATION_SCALE or POSITION_ROTATION_SCALE)\n */\n public set anchorMode(value: UIAnchorMode) {\n if (value !== this.anchorModeInternal) {\n this.anchorModeInternal = value;\n this.recalculationRequired = true;\n }\n }\n\n /**\n * Resets all transformation properties to their default values.\n *\n * This method restores position (0,0), anchor (0,0), scale (1,1),\n * and rotation (0) to their initial states. Only triggers recalculation\n * if any values actually change.\n */\n public reset(): void {\n if (\n this.xInternal !== DEFAULT_POSITION ||\n this.yInternal !== 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 ) {\n this.xInternal = DEFAULT_POSITION;\n this.yInternal = 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.recalculationRequired = true;\n }\n }\n\n /**\n * Gets whether any transformation properties have changed since last reset.\n *\n * This method is used internally by the rendering system to determine\n * if transformation matrices need to be recalculated.\n *\n * @returns True if recalculation is required, false otherwise\n * @internal\n */\n protected [\"getRecalculationRequiredInternal\"](): boolean {\n return this.recalculationRequired;\n }\n\n /**\n * Resets the recalculation flag after transformations have been applied.\n *\n * This method is called internally by the rendering system after\n * transformation matrices have been updated.\n *\n * @internal\n */\n protected [\"resetRecalculationRequiredInternal\"](): void {\n this.recalculationRequired = false;\n }\n}\n","import { type Object3D } from \"three\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport type { UILayerElement, UIPlaneElement } from \"../miscellaneous/asserts\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../miscellaneous/asserts\";\nimport { UIMicro } from \"../miscellaneous/UIMicro\";\nimport { UIMode } from \"../miscellaneous/UIMode\";\nimport { UIPriority } from \"../miscellaneous/UIPriority\";\nimport type { UISceneWrapper } from \"../wrappers/UISceneWrapper\";\nimport { UIAnchor } from \"./UIAnchor\";\n\n/**\n * Events that can be emitted by UI elements.\n */\nexport enum UIElementEvent {\n /** Emitted when the element is clicked. */\n CLICK = \"click\",\n}\n\n/**\n * Abstract base class for all renderable UI elements with dimensions.\n *\n * UIElement serves as the fundamental building block for all other UI elements\n * that need to be visually rendered. It extends UIAnchor with dimensional properties\n * and integrates with the Three.js rendering system through Object3D. This class\n * provides essential functionality for positioning, sizing, rendering, visibility,\n * z-index management, and user interaction.\n *\n * @template T - The type of Three.js Object3D used for rendering\n * @see {@link UIAnchor} - Base class providing position functionality\n * @see {@link UIPlaneElement} - Interface defining dimensional element behavior\n * @see {@link UISceneWrapper} - Scene management for rendering\n * @see {@link UIMicro} - Micro-optimization utilities\n */\nexport abstract class UIElement<T extends Object3D = Object3D>\n extends UIAnchor\n implements UIPlaneElement, UILayerElement\n{\n /** Micro-transformation system for non-constraint based positioning, scaling, and rotation adjustments. */\n public readonly micro = new UIMicro();\n\n /**\n * Solver variable descriptor for the width dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly wVariable: number;\n\n /**\n * Solver variable descriptor for the height dimension.\n * This variable is managed by the constraint solver system.\n */\n public readonly hVariable: number;\n\n /**\n * Reference to the scene wrapper for rendering management.\n * @see {@link UISceneWrapper}\n */\n protected readonly sceneWrapper: UISceneWrapper;\n\n /** Internal storage for the current visibility/interaction mode. */\n protected modeInternal: UIMode = UIMode.VISIBLE;\n\n /**\n * Creates a new UIElement instance with rendering capabilities.\n *\n * @param layer - The UI layer that contains this element\n * @param x - Initial x-coordinate position\n * @param y - Initial y-coordinate position\n * @param width - Initial width dimension (must be positive)\n * @param height - Initial height dimension (must be positive)\n * @param object - The Three.js Object3D used for rendering this element\n * @throws Will throw an error if width or height are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n constructor(\n layer: UILayer,\n x: number,\n y: number,\n width: number,\n height: number,\n protected readonly object: T,\n ) {\n assertValidPositiveNumber(width, \"UIElement width\");\n assertValidPositiveNumber(height, \"UIElement height\");\n\n super(layer, x, y);\n this.sceneWrapper = this.layer[\"getSceneWrapperInternal\"]();\n this.sceneWrapper.insertObject(this, this.object);\n this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);\n this.hVariable = this.solverWrapper.createVariable(height, UIPriority.P6);\n }\n\n /**\n * Gets the current width value from the solver.\n * @returns The current width dimension\n */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /**\n * Gets the current height value from the solver.\n * @returns The current height dimension\n */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /**\n * Gets the current z-index (depth) value from the scene.\n * @returns The current z-index for rendering order\n */\n public get zIndex(): number {\n return this.sceneWrapper.getZIndex(this);\n }\n\n /**\n * Gets the current visibility and interaction mode.\n * @returns The current UIMode setting\n * @see {@link UIMode}\n */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /**\n * Sets the width value through the solver system.\n * @param value - The new width dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIElement width\");\n this.solverWrapper.suggestVariableValue(this.wVariable, value);\n }\n\n /**\n * Sets the height value through the solver system.\n * @param value - The new height dimension (must be positive)\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIElement height\");\n this.solverWrapper.suggestVariableValue(this.hVariable, value);\n }\n\n /**\n * Sets the z-index (depth) value for rendering order.\n * @param value - The new z-index value\n * @throws Will throw an error if value is not a valid number\n * @see {@link assertValidNumber}\n */\n public set zIndex(value: number) {\n assertValidNumber(value, \"UIElement zIndex\");\n this.sceneWrapper.setZIndex(this, value);\n }\n\n /**\n * Sets the visibility and interaction mode.\n * @param value - The new UIMode setting\n * @see {@link UIMode}\n */\n public set mode(value: UIMode) {\n if (value !== this.modeInternal) {\n this.modeInternal = value;\n this.sceneWrapper.setVisibility(this, value !== UIMode.HIDDEN);\n }\n }\n\n /**\n * Destroys the UI element by cleaning up all associated resources.\n *\n * This method removes the element from the rendering scene, cleans up\n * dimension solver variables, and calls the parent destroy method to\n * clean up position variables. After calling this method, the element\n * should not be used anymore.\n */\n public override destroy(): void {\n this.solverWrapper.removeVariable(this.hVariable);\n this.solverWrapper.removeVariable(this.wVariable);\n this.sceneWrapper.removeObject(this);\n super.destroy();\n }\n\n /**\n * Internal method for handling click events.\n *\n * Determines if the click coordinates intersect with this element's bounds\n * and emits a CLICK event if the element is in interactive mode.\n *\n * @param x - The x-coordinate of the click\n * @param y - The y-coordinate of the click\n * @returns True if the click was handled by this element\n */\n protected [\"onClickInternal\"](x: number, y: number): boolean {\n const isClicked =\n this.modeInternal === UIMode.INTERACTIVE &&\n x > this.x &&\n x < this.x + this.width &&\n y > this.y &&\n y < this.y + this.height;\n if (isClicked) {\n this.emit(UIElementEvent.CLICK, x, y, this);\n }\n return isClicked;\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial } from \"three\";\nimport fragmentShader from \"../shaders/UIMaterial.fs\";\nimport vertexShader from \"../shaders/UIMaterial.vs\";\n\nconst DEFAULT_ALPHA_TEST = 0.25;\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 alphaTest: { value: DEFAULT_ALPHA_TEST },\n },\n vertexShader,\n fragmentShader,\n transparent: false,\n alphaTest: DEFAULT_ALPHA_TEST,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: false,\n });\n }\n\n public getTexture(): Texture {\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 getTransparency(): boolean {\n return this.transparent;\n }\n\n public setTexture(value: Texture): this {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setColor(value: number): this {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setOpacity(value: number): this {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setTransparency(value: boolean): this {\n if (this.transparent !== value) {\n this.transparent = value;\n this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;\n this.needsUpdate = true;\n this.uniformsNeedUpdate = true;\n }\n return this;\n }\n}\n","import { PlaneGeometry } from \"three\";\n\nconst GEOMETRY_SIZE = 1;\nconst GEOMETRY_OFFSET = GEOMETRY_SIZE / 2;\n\nexport const geometry = new PlaneGeometry(\n GEOMETRY_SIZE,\n GEOMETRY_SIZE,\n).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);\n","import type { Texture } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport { UIMaterial } from \"../materials/UIMaterial\";\nimport { assertValidPositiveNumber } from \"../miscellaneous/asserts\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * UI element for displaying textured images.\n *\n * UIImage is a concrete implementation of UIElement that renders a textured\n * image using Three.js Mesh and UIMaterial. It automatically sizes itself\n * to match the texture dimensions and provides control over visual properties\n * such as color tinting, opacity, and transparency.\n *\n * @see {@link UIElement} - Base class providing UI element functionality\n * @see {@link UIMaterial} - Material system for rendering\n * @see {@link Texture} - Three.js texture for image data\n */\nexport class UIImage extends UIElement<Mesh> {\n /** The material used for rendering the image. */\n private readonly material: UIMaterial;\n\n /** Internal storage for the current texture. */\n private readonly textureInternal: Texture;\n\n /**\n * Creates a new UIImage instance.\n *\n * The image will automatically size itself to match the texture's dimensions.\n * The position defaults to (0, 0) if not specified.\n *\n * @param layer - The UI layer that contains this image\n * @param texture - The Three.js texture to display\n * @param x - Initial x-coordinate position (defaults to 0)\n * @param y - Initial y-coordinate position (defaults to 0)\n */\n constructor(layer: UILayer, texture: Texture, x = 0, y = 0) {\n const width = texture.image.width;\n const height = texture.image.height;\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, x, y, width, height, object);\n this.material = material;\n this.textureInternal = texture;\n }\n\n /**\n * Gets the current texture being displayed.\n * @returns The current Three.js texture\n */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /**\n * Gets the current color tint applied to the image.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the image.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the image.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Sets a new texture for the image.\n *\n * When setting a new texture, the image will automatically resize to match\n * the new texture's dimensions.\n *\n * @param value - The new Three.js texture to display\n * @throws Will throw an error if the texture dimensions are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n public set texture(value: Texture) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UIImage texture width\");\n assertValidPositiveNumber(height, \"UIImage texture height\");\n\n this.material.setTexture(value);\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n }\n\n /**\n * Sets the color tint applied to the image.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the image.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the image.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Destroys the image by cleaning up all associated resources.\n *\n * This method disposes of the material resources and calls the parent\n * destroy method to clean up the underlying UI element. After calling\n * this method, the image should not be used anymore.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, Vector2, Vector4 } from \"three\";\nimport fragmentShader from \"../shaders/UINineSliceMaterial.fs\";\nimport vertexShader from \"../shaders/UINineSliceMaterial.vs\";\n\nconst DEFAULT_ALPHA_TEST = 0.25;\n\nexport class UINineSliceMaterial extends ShaderMaterial {\n constructor(texture: Texture) {\n super({\n uniforms: {\n map: { value: texture },\n color: { value: new Color(0xffffff) },\n opacity: { value: 1.0 },\n alphaTest: { value: DEFAULT_ALPHA_TEST },\n sliceBorders: {\n value: new Vector4(0, 0, 0, 0),\n }, // left, right, top, bottom (in UV)\n quadSize: { value: new Vector2(1, 1) }, // width, height (in World)\n textureSize: {\n value: new Vector2(texture.image.width, texture.image.height),\n },\n },\n vertexShader,\n fragmentShader,\n transparent: false,\n alphaTest: DEFAULT_ALPHA_TEST,\n lights: false,\n fog: false,\n depthWrite: true,\n depthTest: true,\n });\n }\n\n public getSliceBorderLeft(): number {\n return this.uniforms.sliceBorders.value.x;\n }\n\n public getSliceBorderRight(): number {\n return this.uniforms.sliceBorders.value.y;\n }\n\n public getSliceBorderTop(): number {\n return this.uniforms.sliceBorders.value.z;\n }\n\n public getSliceBorderBottom(): number {\n return this.uniforms.sliceBorders.value.w;\n }\n\n public getQuadSize(): { w: number; h: number } {\n const quadSize = this.uniforms.quadSize.value;\n return { w: quadSize.x, h: quadSize.y };\n }\n\n public getTexture(): Texture {\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 getTransparency(): boolean {\n return this.transparent;\n }\n\n public setSliceBorderLeft(l: number): this {\n this.uniforms.sliceBorders.value.x = l;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorderRight(r: number): this {\n this.uniforms.sliceBorders.value.y = r;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorderTop(t: number): this {\n this.uniforms.sliceBorders.value.z = t;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorderBottom(b: number): this {\n this.uniforms.sliceBorders.value.w = b;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setSliceBorder(l: number, r: number, t: number, b: number): this {\n this.uniforms.sliceBorders.value.set(l, r, t, b);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setQuadSize(w: number, h: number): this {\n this.uniforms.quadSize.value.set(w, h);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setTexture(value: Texture): this {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setColor(color: number): this {\n (this.uniforms.color.value as Color).setHex(color);\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setOpacity(opacity: number): this {\n this.uniforms.opacity.value = opacity;\n this.uniformsNeedUpdate = true;\n return this;\n }\n\n public setTransparency(value: boolean): this {\n if (this.transparent !== value) {\n this.transparent = value;\n this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;\n this.needsUpdate = true;\n this.uniformsNeedUpdate = true;\n }\n return this;\n }\n}\n","const DEFAULT_SLICE_BORDER = 0.25;\n\nexport type UINineSliceBorder =\n | { left: number; right: number; top: number; bottom: number }\n | { horizontal: number; vertical: number }\n | number;\n\n/**\n * Resolves various nine-slice border inputs into a normalized border object.\n *\n * @param value - The border value to resolve (can be number, partial object, or full object)\n * @returns Normalized border object with left, right, top, bottom properties\n */\nexport function resolveNineSliceBorder(value: unknown): {\n left: number;\n right: number;\n top: number;\n bottom: number;\n} {\n // Handle null/undefined\n if (value === null || value === undefined) {\n return {\n left: DEFAULT_SLICE_BORDER,\n right: DEFAULT_SLICE_BORDER,\n top: DEFAULT_SLICE_BORDER,\n bottom: DEFAULT_SLICE_BORDER,\n };\n }\n\n // Handle number\n if (typeof value === \"number\") {\n return {\n left: value,\n right: value,\n top: value,\n bottom: value,\n };\n }\n\n // Handle object\n if (typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n\n // Handle { horizontal, vertical } format\n if (\"horizontal\" in obj && \"vertical\" in obj) {\n const horizontal =\n typeof obj.horizontal === \"number\"\n ? obj.horizontal\n : DEFAULT_SLICE_BORDER;\n const vertical =\n typeof obj.vertical === \"number\" ? obj.vertical : DEFAULT_SLICE_BORDER;\n\n return {\n left: horizontal,\n right: horizontal,\n top: vertical,\n bottom: vertical,\n };\n }\n\n // Handle { left, right, top, bottom } format\n const left = typeof obj.left === \"number\" ? obj.left : DEFAULT_SLICE_BORDER;\n const right =\n typeof obj.right === \"number\" ? obj.right : DEFAULT_SLICE_BORDER;\n const top = typeof obj.top === \"number\" ? obj.top : DEFAULT_SLICE_BORDER;\n const bottom =\n typeof obj.bottom === \"number\" ? obj.bottom : DEFAULT_SLICE_BORDER;\n\n return { left, right, top, bottom };\n }\n\n // Fallback to default\n return {\n left: DEFAULT_SLICE_BORDER,\n right: DEFAULT_SLICE_BORDER,\n top: DEFAULT_SLICE_BORDER,\n bottom: DEFAULT_SLICE_BORDER,\n };\n}\n","import type { Texture } from \"three\";\nimport { Mesh } from \"three\";\nimport { UILayerEvent, type UILayer } from \"../layers/UILayer\";\nimport { UINineSliceMaterial } from \"../materials/UINineSliceMaterial\";\nimport { assertValidPositiveNumber } from \"../miscellaneous/asserts\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport {\n resolveNineSliceBorder,\n type UINineSliceBorder,\n} from \"../miscellaneous/UINineSliceBorder\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Configuration options for creating a UINineSlice element.\n */\nexport interface UINineSliceOptions {\n /** Nine-slice border configuration (can be number, object with horizontal/vertical, or full border object) */\n sliceBorder: UINineSliceBorder;\n /** X position of the element */\n x: number;\n /** Y position of the element */\n y: number;\n}\n\n/**\n * Nine-slice UI element for scalable images with preserved border regions.\n *\n * Nine-slice scaling divides an image into 9 regions: 4 corners, 4 edges, and 1 center.\n * The corners maintain their original size, edges scale in one dimension, and the center\n * scales in both dimensions. This technique is commonly used for creating scalable UI\n * panels, buttons, and borders that maintain visual quality at any size.\n */\nexport class UINineSlice extends UIElement<Mesh> {\n private readonly material: UINineSliceMaterial;\n private readonly textureInternal: Texture;\n\n /**\n * Creates a new nine-slice UI element.\n *\n * @param layer - The UI layer to add this element to\n * @param texture - The texture to use for nine-slice rendering\n * @param options - Configuration options for the nine-slice element\n */\n constructor(\n layer: UILayer,\n texture: Texture,\n options: Partial<UINineSliceOptions> = {},\n ) {\n const w = texture.image.width;\n const h = texture.image.height;\n\n const material = new UINineSliceMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, options.x ?? 0, options.y ?? 0, w, h, object);\n this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n\n this.material = material;\n this.textureInternal = texture;\n\n const sliceBorder = resolveNineSliceBorder(options.sliceBorder);\n this.material.setSliceBorder(\n sliceBorder.left,\n sliceBorder.right,\n sliceBorder.top,\n sliceBorder.bottom,\n );\n }\n\n /**\n * Gets the left border size for nine-slice scaling.\n * @returns The left border size in texture UV coordinates\n */\n public get sliceBorderLeft(): number {\n return this.material.getSliceBorderLeft();\n }\n\n /**\n * Gets the right border size for nine-slice scaling.\n * @returns The right border size in texture UV coordinates\n */\n public get sliceBorderRight(): number {\n return this.material.getSliceBorderRight();\n }\n\n /**\n * Gets the top border size for nine-slice scaling.\n * @returns The top border size in texture UV coordinates\n */\n public get sliceBorderTop(): number {\n return this.material.getSliceBorderTop();\n }\n\n /**\n * Gets the bottom border size for nine-slice scaling.\n * @returns The bottom border size in texture UV coordinates\n */\n public get sliceBorderBottom(): number {\n return this.material.getSliceBorderBottom();\n }\n\n /**\n * Gets the current texture being displayed.\n * @returns The current Three.js texture\n */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /**\n * Gets the current color tint applied to the image.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the image.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the image.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Sets the left border size for nine-slice scaling.\n * @param value - The left border size in texture UV coordinates\n */\n public set sliceBorderLeft(value: number) {\n this.material.setSliceBorderLeft(value);\n }\n\n /**\n * Sets the right border size for nine-slice scaling.\n * @param value - The right border size in texture UV coordinates\n */\n public set sliceBorderRight(value: number) {\n this.material.setSliceBorderRight(value);\n }\n\n /**\n * Sets the top border size for nine-slice scaling.\n * @param value - The top border size in texture UV coordinates\n */\n public set sliceBorderTop(value: number) {\n this.material.setSliceBorderTop(value);\n }\n\n /**\n * Sets the bottom border size for nine-slice scaling.\n * @param value - The bottom border size in texture UV coordinates\n */\n public set sliceBorderBottom(value: number) {\n this.material.setSliceBorderBottom(value);\n }\n\n /**\n * Sets a new texture for the image.\n *\n * When setting a new texture, the image will automatically resize to match\n * the new texture's dimensions.\n *\n * @param value - The new Three.js texture to display\n * @throws Will throw an error if the texture dimensions are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n public set texture(value: Texture) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UINineSlice texture width\");\n assertValidPositiveNumber(height, \"UINineSlice texture height\");\n\n this.material.setTexture(value);\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n }\n\n /**\n * Sets the color tint applied to the image.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the image.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the image.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets all four border sizes for nine-slice scaling at once.\n *\n * @param left - The left border size in texture UV coordinates\n * @param right - The right border size in texture UV coordinates\n * @param top - The top border size in texture UV coordinates\n * @param bottom - The bottom border size in texture UV coordinates\n */\n public setSliceBorders(\n left: number,\n right: number,\n top: number,\n bottom: number,\n ): void {\n this.material.setSliceBorder(left, right, top, bottom);\n }\n\n /**\n * Destroys the nine-slice element and cleans up resources.\n *\n * This method removes event listeners, disposes of the material,\n * and calls the parent destroy method.\n */\n public override destroy(): void {\n this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n this.material.dispose();\n super.destroy();\n }\n\n /**\n * Internal render callback that updates the material's quad size.\n * This ensures the nine-slice scaling works correctly with micro transformations.\n */\n private readonly onWillRenderInternal = (): void => {\n this.material.setQuadSize(\n this.width * this.micro.scaleX,\n this.height * this.micro.scaleY,\n );\n };\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, UniformsUtils } from \"three\";\nimport fragmentShader from \"../shaders/UIProgressMaterial.fs\";\nimport vertexShader from \"../shaders/UIProgressMaterial.vs\";\n\nconst DEFAULT_ALPHA_TEST = 0.25;\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 color: { value: new Color(1, 1, 1) },\n backgroundColor: { value: new Color(1, 1, 1) },\n foregroundColor: { value: new Color(1, 1, 1) },\n opacity: { value: 1 },\n backgroundOpacity: { value: 1 },\n foregroundOpacity: { value: 1 },\n alphaTest: { value: DEFAULT_ALPHA_TEST },\n angle: { value: 0 },\n direction: { value: 1 },\n },\n ]),\n vertexShader,\n fragmentShader,\n transparent: true,\n lights: false,\n fog: false,\n depthWrite: false,\n depthTest: 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 getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getBackgroundColor(): number {\n return (this.uniforms.backgroundColor.value as Color).getHex();\n }\n\n public getForegroundColor(): number {\n return (this.uniforms.foregroundColor.value as Color).getHex();\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\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 getTransparency(): boolean {\n return this.transparent;\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 setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundColor(value: number): void {\n (this.uniforms.backgroundColor.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundColor(value: number): void {\n (this.uniforms.foregroundColor.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 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 setTransparency(value: boolean): this {\n if (this.transparent !== value) {\n this.transparent = value;\n this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;\n this.needsUpdate = true;\n this.uniformsNeedUpdate = true;\n }\n return this;\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 } from \"three\";\nimport { MathUtils, Mesh } from \"three\";\nimport type { UILayer } from \"../layers/UILayer\";\nimport { UIProgressMaterial } from \"../materials/UIProgressMaterial\";\nimport { assertValidPositiveNumber } from \"../miscellaneous/asserts\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Configuration options for creating a UIProgress element.\n */\nexport interface UIProgressOptions {\n /** X position of the element */\n x: number;\n /** Y position of the element */\n y: number;\n /** Optional background texture (if not provided, only foreground is shown) */\n textureBackground: Texture;\n /** Progress value between 0.0 (empty) and 1.0 (full) */\n progress: number;\n /** Direction of progress fill (true = forward, false = reverse) */\n isForwardDirection: boolean;\n /** Angle of progress fill in degrees (0 = horizontal, 90 = vertical) */\n angle: number;\n /** Background color tint as hex number (e.g., 0xFFFFFF) */\n backgroundColor: number;\n /** Foreground color tint as hex number (e.g., 0xFFFFFF) */\n foregroundColor: number;\n /** Background opacity between 0.0 (transparent) and 1.0 (opaque) */\n backgroundOpacity: number;\n /** Foreground opacity between 0.0 (transparent) and 1.0 (opaque) */\n foregroundOpacity: number;\n}\n\n/**\n * Progress bar UI element with customizable fill direction and appearance.\n *\n * UIProgress displays a progress bar that can be filled in various directions\n * (horizontal, vertical, or at custom angles). It supports separate background\n * and foreground textures with independent color tinting and opacity control.\n *\n * The progress value ranges from 0.0 (empty) to 1.0 (completely filled).\n * The fill direction can be controlled both by angle and forward/reverse direction.\n */\nexport class UIProgress extends UIElement<Mesh> {\n private readonly material: UIProgressMaterial;\n\n /**\n * Creates a new progress bar UI element.\n *\n * @param layer - The UI layer to add this element to\n * @param textureForeground - The texture used for the progress fill\n * @param options - Configuration options for the progress bar\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 assertValidPositiveNumber(\n foregroundWidth,\n \"UIProgress foreground texture width\",\n );\n assertValidPositiveNumber(\n foregroundHeight,\n \"UIProgress foreground texture height\",\n );\n\n const backgroundWidth = options.textureBackground?.image?.width;\n const backgroundHeight = options.textureBackground?.image?.height;\n\n if (options.textureBackground) {\n assertValidPositiveNumber(\n backgroundWidth,\n \"UIProgress background texture width\",\n );\n assertValidPositiveNumber(\n backgroundHeight,\n \"UIProgress background texture height\",\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 !== undefined) {\n material.setProgress(options.progress);\n }\n\n if (options.isForwardDirection !== undefined) {\n material.setIsForwardDirection(options.isForwardDirection);\n }\n\n if (options.angle !== undefined) {\n material.setAngle(MathUtils.degToRad(options.angle));\n }\n\n if (options.backgroundColor !== undefined) {\n material.setBackgroundColor(options.backgroundColor);\n }\n\n if (options.foregroundColor !== undefined) {\n material.setForegroundColor(options.foregroundColor);\n }\n\n if (options.backgroundOpacity !== undefined) {\n material.setBackgroundOpacity(options.backgroundOpacity);\n }\n\n if (options.foregroundOpacity !== undefined) {\n material.setForegroundOpacity(options.foregroundOpacity);\n }\n\n const imageWidth = backgroundWidth ?? foregroundWidth;\n const imageHeight = foregroundHeight ?? backgroundHeight;\n\n super(\n layer,\n options.x ?? 0,\n options.y ?? 0,\n imageWidth,\n imageHeight,\n object,\n );\n\n this.material = material;\n }\n\n /**\n * Gets the current progress value.\n * @returns Progress value between 0.0 (empty) and 1.0 (full)\n */\n public get progress(): number {\n return this.material.getProgress();\n }\n\n /**\n * Gets the background texture.\n * @returns The background texture, or undefined if none is set\n */\n public get backgroundTexture(): Texture | undefined {\n return this.material.getBackgroundTexture();\n }\n\n /**\n * Gets the foreground (fill) texture.\n * @returns The foreground texture\n */\n public get foregroundTexture(): Texture {\n return this.material.getForegroundTexture();\n }\n\n /**\n * Gets the color tint.\n * @returns The color as a hex number (e.g., 0xFFFFFF)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the background color tint.\n * @returns The background color as a hex number (e.g., 0xFFFFFF)\n */\n public get backgroundColor(): number {\n return this.material.getBackgroundColor();\n }\n\n /**\n * Gets the foreground color tint.\n * @returns The foreground color as a hex number (e.g., 0xFFFFFF)\n */\n public get foregroundColor(): number {\n return this.material.getForegroundColor();\n }\n\n /**\n * Gets the opacity.\n * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets the background opacity.\n * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get backgroundOpacity(): number {\n return this.material.getBackgroundOpacity();\n }\n\n /**\n * Gets the foreground opacity.\n * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get foregroundOpacity(): number {\n return this.material.getForegroundOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the image.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Gets the progress fill angle in degrees.\n * @returns Angle in degrees (0 = horizontal, 90 = vertical)\n */\n public get angle(): number {\n return MathUtils.radToDeg(this.material.getAngle());\n }\n\n /**\n * Gets whether the progress fills in forward direction.\n * @returns True if filling forward, false if filling in reverse\n */\n public get isForwardDirection(): boolean {\n return this.material.getIsForwardDirection();\n }\n\n /**\n * Sets the progress value.\n * @param value - Progress value between 0.0 (empty) and 1.0 (full)\n */\n public set progress(value: number) {\n this.material.setProgress(value);\n }\n\n /**\n * Sets the background texture.\n * @param value - The background texture, or undefined to remove background\n */\n public set backgroundTexture(value: Texture | undefined) {\n if (value) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UIProgress background texture width\");\n assertValidPositiveNumber(height, \"UIProgress background texture height\");\n }\n\n this.material.setBackgroundTexture(value);\n }\n\n /**\n * Sets the foreground (fill) texture.\n *\n * When setting a new texture, the progress bar will automatically resize\n * to match the new texture's dimensions.\n *\n * @param value - The new foreground texture\n * @throws Will throw an error if the texture dimensions are not valid positive numbers\n */\n public set foregroundTexture(value: Texture) {\n const width = value.image.width;\n const height = value.image.height;\n\n assertValidPositiveNumber(width, \"UIProgress foreground texture width\");\n assertValidPositiveNumber(height, \"UIProgress foreground texture height\");\n\n this.material.setForegroundTexture(value);\n this.solverWrapper.suggestVariableValue(this.wVariable, width);\n this.solverWrapper.suggestVariableValue(this.hVariable, height);\n }\n\n /**\n * Sets the color tint.\n * @param value - The color as a hex number (e.g., 0xFFFFFF)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the background color tint.\n * @param value - The background color as a hex number (e.g., 0xFFFFFF)\n */\n public set backgroundColor(value: number) {\n this.material.setBackgroundColor(value);\n }\n\n /**\n * Sets the foreground color tint.\n * @param value - The foreground color as a hex number (e.g., 0xFFFFFF)\n */\n public set foregroundColor(value: number) {\n this.material.setForegroundColor(value);\n }\n\n /**\n * Sets the opacity.\n * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets the background opacity.\n * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set backgroundOpacity(value: number) {\n this.material.setBackgroundOpacity(value);\n }\n\n /**\n * Sets the foreground opacity.\n * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set foregroundOpacity(value: number) {\n this.material.setForegroundOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the image.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets the progress fill angle.\n * @param value - Angle in degrees (0 = horizontal, 90 = vertical)\n */\n public set angle(value: number) {\n this.material.setAngle(MathUtils.degToRad(value));\n }\n\n /**\n * Sets the progress fill direction.\n * @param value - True for forward direction, false for reverse\n */\n public set isForwardDirection(value: boolean) {\n this.material.setIsForwardDirection(value);\n }\n\n /**\n * Destroys the progress bar element and cleans up resources.\n *\n * This method disposes of the material and calls the parent destroy method.\n */\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\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 { UILayerEvent, type UILayer } from \"../layers/UILayer\";\nimport { UIMaterial } from \"../materials/UIMaterial\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\n/**\n * Update modes for controlling when the 3D scene should be re-rendered.\n */\nexport enum UISceneUpdateMode {\n /** Re-render the scene every frame. */\n EACH_FRAME = 1,\n /** Re-render the scene every second frame for performance. */\n EACH_SECOND_FRAME = 2,\n /** Re-render the scene only when properties change. */\n PROPERTY_CHANGED = 3,\n /** Re-render the scene only when manually requested. */\n MANUAL = 4,\n}\n\n/** Default resolution factor for render target sizing. */\nconst DEFAULT_RESOLUTION_FACTOR = 0.5;\n/** Minimum allowed resolution factor to prevent performance issues. */\nconst MIN_RESOLUTION_FACTOR = 0.1;\n/** Maximum allowed resolution factor to prevent memory issues. */\nconst MAX_RESOLUTION_FACTOR = 2;\n/** Default width for the scene render target in pixels. */\nconst DEFAULT_WIDTH = 512;\n/** Default height for the scene render target in pixels. */\nconst DEFAULT_HEIGHT = 512;\n/** Default field of view for the perspective camera in degrees. */\nconst DEFAULT_CAMERA_FOV = 75;\n/** Default near clipping plane distance for the camera. */\nconst DEFAULT_CAMERA_NEAR = 0.1;\n/** Default far clipping plane distance for the camera. */\nconst DEFAULT_CAMERA_FAR = 100;\n/** Default update mode for scene rendering. */\nconst DEFAULT_UPDATE_MODE = UISceneUpdateMode.PROPERTY_CHANGED;\n/** Default clear color for the render target. */\nconst DEFAULT_CLEAR_COLOR = 0x000000;\n/** Default clear alpha for the render target. */\nconst DEFAULT_CLEAR_ALPHA = 0;\n/** Default depth buffer usage setting. */\nconst DEFAULT_USE_DEPTH = true;\n\n/**\n * Configuration options for UIScene element creation.\n */\nexport interface UISceneOptions {\n /** Initial x-coordinate position. */\n x: number;\n /** Initial y-coordinate position. */\n y: number;\n /** Width of the scene render target in pixels. */\n width: number;\n /** Height of the scene render target in pixels. */\n height: number;\n\n /** Three.js scene to render. */\n scene: Scene;\n /** Camera to use for rendering the scene. */\n camera: Camera;\n /** Update mode controlling when the scene is re-rendered. */\n updateMode: UISceneUpdateMode;\n /** Resolution factor for render target sizing (0.1 to 2.0). */\n resolutionFactor: number;\n /** Clear color for the render target background. */\n clearColor: number;\n /** Clear alpha for the render target background. */\n clearAlpha: number;\n /** Whether to enable depth buffer for the render target. */\n enableDepthBuffer: boolean;\n}\n\n/**\n * UI element for rendering 3D scenes to texture within the UI system.\n *\n * UIScene is a concrete implementation of UIElement that renders a Three.js\n * scene to a WebGL render target and displays it as a texture. It provides\n * control over rendering frequency, resolution, and visual properties. This\n * allows embedding complex 3D content within the 2D UI layout system with\n * performance optimizations through configurable update modes.\n *\n * @see {@link UIElement} - Base class providing UI element functionality\n * @see {@link UISceneUpdateMode} - Update mode configuration\n * @see {@link Scene} - Three.js scene for 3D content\n * @see {@link Camera} - Three.js camera for scene rendering\n */\nexport class UIScene extends UIElement<Mesh> {\n /** The material used for rendering the scene texture. */\n private readonly material: UIMaterial;\n\n /** The WebGL render target for off-screen scene rendering. */\n private readonly renderTarget: WebGLRenderTarget;\n\n /** Internal storage for the current Three.js scene. */\n private sceneInternal: Scene;\n /** Internal storage for the current camera. */\n private cameraInternal: Camera;\n /** Internal storage for the current update mode. */\n private updateModeInternal: UISceneUpdateMode;\n /** Internal storage for the current resolution factor. */\n private resolutionFactorInternal: number;\n /** Internal storage for the current clear color. */\n private clearColorInternal: number;\n /** Internal storage for the current clear alpha. */\n private clearAlphaInternal: number;\n\n /** Frame alternation boolean for EACH_SECOND_FRAME update mode. */\n private frameBoolean = true;\n /** Flag indicating if properties have changed requiring a re-render. */\n private propertyChanged = false;\n /** Flag indicating if a manual render has been requested. */\n private renderRequired = false;\n\n /**\n * Creates a new UIScene instance with 3D scene rendering capabilities.\n *\n * The scene element creates a WebGL render target for off-screen rendering\n * and displays the result as a texture. A default perspective camera is\n * created if none is provided.\n *\n * @param layer - The UI layer that contains this scene element\n * @param options - Configuration options for scene rendering\n * @throws Will throw an error if resolution factor is outside valid range (0.1-2.0)\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 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.enableDepthBuffer ?? 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, 0, 0, width, height, object);\n this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n\n this.material = material;\n this.renderTarget = renderTarget;\n\n this.sceneInternal = options.scene ?? new Scene();\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n DEFAULT_CAMERA_FOV,\n width / height,\n DEFAULT_CAMERA_NEAR,\n DEFAULT_CAMERA_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n this.updateModeInternal = options.updateMode ?? DEFAULT_UPDATE_MODE;\n\n this.clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;\n this.clearAlphaInternal = options.clearAlpha ?? DEFAULT_CLEAR_ALPHA;\n\n if (options.updateMode === UISceneUpdateMode.PROPERTY_CHANGED) {\n this.renderRequired = true;\n }\n }\n\n /**\n * Gets the current color tint applied to the scene texture.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the scene texture.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the scene texture.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Gets the Three.js scene being rendered.\n * @returns The current Three.js scene\n */\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n /**\n * Gets the camera used for rendering the scene.\n * @returns The current Three.js camera\n */\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n /**\n * Gets the current update mode controlling render frequency.\n * @returns The current update mode\n */\n public get updateMode(): UISceneUpdateMode {\n return this.updateModeInternal;\n }\n\n /**\n * Gets the resolution factor for render target sizing.\n * @returns The resolution factor between 0.1 and 2.0\n */\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n /**\n * Gets the clear color used for the render target background.\n * @returns The clear color as a number\n */\n public get clearColor(): number {\n return this.clearColorInternal;\n }\n\n /**\n * Gets the clear alpha used for the render target background.\n * @returns The clear alpha value between 0.0 and 1.0\n */\n public get clearAlpha(): number {\n return this.clearAlphaInternal;\n }\n\n /**\n * Sets the color tint applied to the scene texture.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the scene texture.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the scene texture.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets a new Three.js scene to render and marks for re-render.\n * @param value - The new Three.js scene\n */\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets a new camera for rendering and marks for re-render.\n * @param value - The new Three.js camera\n */\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the update mode controlling render frequency and marks for re-render.\n * @param value - The new update mode\n */\n public set updateMode(value: UISceneUpdateMode) {\n if (this.updateModeInternal !== value) {\n this.updateModeInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the resolution factor and resizes the render target accordingly.\n * @param value - The new resolution factor between 0.1 and 2.0\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 this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the clear color for the render target background and marks for re-render.\n * @param value - The new clear color as a number\n */\n public set clearColor(value: number) {\n if (this.clearColorInternal !== value) {\n this.clearColorInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Sets the clear alpha for the render target background and marks for re-render.\n * @param value - The new clear alpha value between 0.0 and 1.0\n */\n public set clearAlpha(value: number) {\n if (this.clearAlphaInternal !== value) {\n this.clearAlphaInternal = value;\n this.propertyChanged = true;\n }\n }\n\n /**\n * Destroys the scene element by cleaning up all associated resources.\n *\n * This method disposes of the material and render target resources,\n * and calls the parent destroy method to clean up the underlying UI element.\n * After calling this method, the scene element should not be used anymore.\n */\n public override destroy(): void {\n this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n this.material.dispose();\n this.renderTarget.dispose();\n super.destroy();\n }\n\n /**\n * Manually requests a re-render of the scene.\n *\n * This method is useful when the update mode is set to MANUAL and you\n * want to trigger a scene re-render without changing any properties.\n */\n public requestRender(): void {\n this.renderRequired = true;\n }\n\n private readonly onWillRenderInternal = (renderer: WebGLRenderer): void => {\n if (\n this.updateModeInternal === UISceneUpdateMode.EACH_FRAME ||\n (this.updateModeInternal === UISceneUpdateMode.EACH_SECOND_FRAME &&\n this.frameBoolean) ||\n (this.updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED &&\n this.propertyChanged) ||\n (this.updateModeInternal === UISceneUpdateMode.MANUAL &&\n this.renderRequired)\n ) {\n this.renderRequired = false;\n this.propertyChanged = false;\n this.frameBoolean = !this.frameBoolean;\n\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}\n","import {\n assertValidNonNegativeNumber,\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"./asserts\";\n\nexport 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 function isUITextStyle(obj: unknown): obj is UITextStyle {\n if (typeof obj !== \"object\" || obj === null) {\n return false;\n }\n\n const candidate = obj as Record<string, unknown>;\n\n return (\n typeof candidate.color === \"string\" &&\n typeof candidate.fontFamily === \"string\" &&\n typeof candidate.fontSize === \"number\" &&\n (candidate.fontStyle === \"normal\" ||\n candidate.fontStyle === \"italic\" ||\n candidate.fontStyle === \"oblique\") &&\n (candidate.fontWeight === \"normal\" ||\n candidate.fontWeight === \"bold\" ||\n candidate.fontWeight === \"bolder\" ||\n candidate.fontWeight === \"lighter\" ||\n typeof candidate.fontWeight === \"number\") &&\n typeof candidate.lineHeight === \"number\" &&\n typeof candidate.enableShadow === \"boolean\" &&\n typeof candidate.shadowOffsetX === \"number\" &&\n typeof candidate.shadowOffsetY === \"number\" &&\n typeof candidate.shadowBlur === \"number\" &&\n typeof candidate.shadowColor === \"string\" &&\n typeof candidate.enableStroke === \"boolean\" &&\n typeof candidate.strokeColor === \"string\" &&\n typeof candidate.strokeWidth === \"number\"\n );\n}\n\nconst DEFAULT_TEXT_STYLE: UITextStyle = {\n color: \"#000000\",\n\n fontFamily: \"Arial\",\n fontSize: 16,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n lineHeight: 1.2,\n\n enableShadow: false,\n shadowOffsetX: 0,\n shadowOffsetY: 0,\n shadowBlur: 0,\n shadowColor: \"transparent\",\n\n enableStroke: false,\n strokeColor: \"#000000\",\n strokeWidth: 0,\n};\n\nexport function resolveTextStyle(\n style?: Partial<UITextStyle>,\n commonStyle?: Partial<UITextStyle>,\n): UITextStyle {\n const fontSize =\n style?.fontSize ?? commonStyle?.fontSize ?? DEFAULT_TEXT_STYLE.fontSize;\n assertValidPositiveNumber(fontSize, \"Font size\");\n\n const fontWeight = style?.fontWeight ?? commonStyle?.fontWeight ?? \"normal\";\n if (typeof fontWeight === \"number\") {\n assertValidPositiveNumber(fontWeight, \"Font weight\");\n }\n\n const lineHeight =\n style?.lineHeight ??\n commonStyle?.lineHeight ??\n fontSize * DEFAULT_TEXT_STYLE.lineHeight;\n assertValidNumber(lineHeight, \"Line height\");\n\n const shadowOffsetX =\n style?.shadowOffsetX ??\n commonStyle?.shadowOffsetX ??\n DEFAULT_TEXT_STYLE.shadowOffsetX;\n assertValidNonNegativeNumber(shadowOffsetX, \"Shadow offset X\");\n\n const shadowOffsetY =\n style?.shadowOffsetY ??\n commonStyle?.shadowOffsetY ??\n DEFAULT_TEXT_STYLE.shadowOffsetY;\n assertValidNonNegativeNumber(shadowOffsetY, \"Shadow offset Y\");\n\n const shadowBlur =\n style?.shadowBlur ??\n commonStyle?.shadowBlur ??\n DEFAULT_TEXT_STYLE.shadowBlur;\n assertValidNonNegativeNumber(shadowBlur, \"Shadow blur\");\n\n const strokeWidth =\n style?.strokeWidth ??\n commonStyle?.strokeWidth ??\n DEFAULT_TEXT_STYLE.strokeWidth;\n assertValidNonNegativeNumber(strokeWidth, \"Stroke width\");\n\n return {\n color: style?.color ?? commonStyle?.color ?? DEFAULT_TEXT_STYLE.color,\n\n fontFamily:\n style?.fontFamily ??\n commonStyle?.fontFamily ??\n DEFAULT_TEXT_STYLE.fontFamily,\n fontSize,\n fontStyle:\n style?.fontStyle ??\n commonStyle?.fontStyle ??\n DEFAULT_TEXT_STYLE.fontStyle,\n fontWeight,\n lineHeight,\n\n enableShadow:\n style?.enableShadow ??\n commonStyle?.enableShadow ??\n DEFAULT_TEXT_STYLE.enableShadow,\n shadowOffsetX,\n shadowOffsetY,\n shadowBlur,\n shadowColor:\n style?.shadowColor ??\n commonStyle?.shadowColor ??\n DEFAULT_TEXT_STYLE.shadowColor,\n\n enableStroke:\n style?.enableStroke ??\n commonStyle?.enableStroke ??\n DEFAULT_TEXT_STYLE.enableStroke,\n strokeColor:\n style?.strokeColor ??\n commonStyle?.strokeColor ??\n DEFAULT_TEXT_STYLE.strokeColor,\n strokeWidth,\n };\n}\n","import type {\n UIChunkMetrics,\n UITextChunk,\n UITextContent,\n UITextLine,\n UITextSize,\n} from \"./textInterfaces\";\nimport { resolveTextStyle, type UITextStyle } from \"./UITextStyle\";\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 = Math.ceil(metrics.width);\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width,\n height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: style.lineHeight,\n };\n}\n\nexport function buildLines(\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 calculateTextSize(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 totalHeight += i === 0 ? line.height : line.lineHeight;\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\nexport function calculateTextContentParameters(\n context: CanvasRenderingContext2D,\n content: UITextContent,\n maxLineWidth: number,\n commonStyle?: Partial<UITextStyle>,\n): { lines: UITextLine[]; size: UITextSize } {\n const chunks: UITextChunk[] = [];\n\n for (const span of Array.isArray(content) ? content : [content]) {\n const isSpanString = typeof span === \"string\";\n const spanString = isSpanString ? span : span.text;\n const style = resolveTextStyle(\n isSpanString ? undefined : span.style,\n commonStyle,\n );\n\n for (const text of splitText(spanString)) {\n const metrics = measureTextChunk(context, text, style);\n chunks.push({ text, style, metrics });\n }\n }\n\n const lines = buildLines(maxLineWidth, chunks);\n const textSize = calculateTextSize(lines);\n\n return { lines, size: textSize };\n}\n","import { assertValidNonNegativeNumber } from \"./asserts\";\n\nexport interface UITextPadding {\n left: number;\n right: number;\n top: number;\n bottom: number;\n}\n\nexport function resolvePadding(value: unknown): UITextPadding {\n if (typeof value === \"number\") {\n return { left: value, right: value, top: value, bottom: value };\n }\n\n if (typeof value === \"object\" && value !== null) {\n const left =\n \"left\" in value && typeof value.left === \"number\" ? value.left : 0;\n const right =\n \"right\" in value && typeof value.right === \"number\" ? value.right : 0;\n const top = \"top\" in value && typeof value.top === \"number\" ? value.top : 0;\n const bottom =\n \"bottom\" in value && typeof value.bottom === \"number\" ? value.bottom : 0;\n\n assertValidNonNegativeNumber(left, \"Padding left\");\n assertValidNonNegativeNumber(right, \"Padding right\");\n assertValidNonNegativeNumber(top, \"Padding top\");\n assertValidNonNegativeNumber(bottom, \"Padding bottom\");\n\n return { left, right, top, bottom };\n }\n\n return { left: 0, right: 0, top: 0, bottom: 0 };\n}\n","import { CanvasTexture, Mesh } from \"three\";\nimport { UILayerEvent, type UILayer } from \"../layers/UILayer\";\nimport { UIMaterial } from \"../materials/UIMaterial\";\nimport type { UITextContent } from \"../miscellaneous/textInterfaces\";\nimport {\n calculateTextContentParameters,\n renderTextLines,\n} from \"../miscellaneous/textTools\";\nimport { geometry } from \"../miscellaneous/threeInstances\";\nimport {\n resolvePadding,\n type UITextPadding,\n} from \"../miscellaneous/UITextPadding\";\nimport { type UITextStyle } from \"../miscellaneous/UITextStyle\";\nimport { UIElement } from \"./UIElement\";\n\n/** Default maximum width for text elements in pixels. */\nconst DEFAULT_MAX_WIDTH = 1024;\n\n/**\n * Configuration options for UIText element creation.\n */\nexport interface UITextOptions {\n /** Maximum width in pixels before text wrapping occurs. */\n maxWidth: number;\n /** Padding configuration for text content. */\n padding: Partial<UITextPadding>;\n /** Common style properties applied to all text content. */\n commonStyle: Partial<UITextStyle>;\n /** X-coordinate of the text element. */\n x: number;\n /** Y-coordinate of the text element. */\n y: number;\n}\n\n/**\n * UI element for rendering dynamic text with canvas-based rendering.\n *\n * UIText is a concrete implementation of UIElement that renders text content\n * using HTML5 Canvas and displays it as a texture. It supports rich text\n * formatting, automatic text wrapping, padding, and dynamic resizing based\n * on content. The text is rendered to a canvas texture which is then applied\n * to a Three.js mesh for display in the 3D scene.\n *\n * @see {@link UIElement} - Base class providing UI element functionality\n * @see {@link UITextContent} - Text content structure\n * @see {@link UITextStyle} - Text styling options\n * @see {@link UITextPadding} - Padding configuration\n */\nexport class UIText extends UIElement<Mesh> {\n /** The material used for rendering the text texture. */\n private readonly material: UIMaterial;\n\n /** The canvas texture containing the rendered text. */\n private readonly texture: CanvasTexture;\n\n /** The HTML canvas element used for text rendering. */\n private readonly canvas: HTMLCanvasElement;\n\n /** The 2D rendering context for drawing text on the canvas. */\n private readonly context: CanvasRenderingContext2D;\n\n /** Internal storage for the current text content. */\n private contentInternal: UITextContent;\n\n /** Internal storage for the maximum width before text wrapping. */\n private maxWidthInternal: number;\n\n /** Internal storage for the current padding configuration. */\n private paddingInternal: UITextPadding;\n\n /** Internal storage for the common text style properties. */\n private commonStyleInternal: Partial<UITextStyle>;\n\n /** Target aspect ratio for the text element based on content. */\n private targetAspectRatio = 1;\n\n /** Last calculated aspect ratio for comparison during rendering. */\n private lastAspectRatio = 1;\n\n /**\n * Creates a new UIText instance with dynamic text rendering.\n *\n * The text element will automatically size itself based on the content\n * and specified options. A canvas is created for rendering the text,\n * which is then used as a texture for the 3D mesh.\n *\n * @param layer - The UI layer that contains this text element\n * @param content - The text content to display\n * @param options - Configuration options for text rendering\n * @param x - Initial x-coordinate position (defaults to 0)\n * @param y - Initial y-coordinate position (defaults to 0)\n * @throws Will throw an error if canvas context creation fails\n */\n constructor(\n layer: UILayer,\n content: UITextContent,\n options: 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 texture = new CanvasTexture(canvas);\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, options.x ?? 0, options.y ?? 0, 2, 2, object);\n this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n\n this.material = material;\n this.texture = texture;\n\n this.canvas = canvas;\n this.context = context;\n\n this.contentInternal = content;\n this.maxWidthInternal = options.maxWidth ?? DEFAULT_MAX_WIDTH;\n this.paddingInternal = resolvePadding(options.padding);\n this.commonStyleInternal = options.commonStyle ?? {};\n\n this.rebuildText();\n }\n\n /**\n * Gets the current color tint applied to the text.\n * @returns The color value as a number (e.g., 0xFFFFFF for white)\n */\n public get color(): number {\n return this.material.getColor();\n }\n\n /**\n * Gets the current opacity level of the text.\n * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n /**\n * Gets whether transparency is enabled for the text.\n * @returns True if transparency is enabled, false otherwise\n */\n public get transparency(): boolean {\n return this.material.getTransparency();\n }\n\n /**\n * Gets the current text content being displayed.\n * @returns The current text content structure\n */\n public get content(): UITextContent {\n return this.contentInternal;\n }\n\n /**\n * Gets the maximum width before text wrapping occurs.\n * @returns The maximum width in pixels\n */\n public get maxWidth(): number {\n return this.maxWidthInternal;\n }\n\n /**\n * Gets the current padding configuration.\n * @returns The padding configuration for all sides\n */\n public get padding(): UITextPadding {\n return this.paddingInternal;\n }\n\n /**\n * Gets the common style properties applied to the text.\n * @returns The partial text style configuration\n */\n public get commonStyle(): Partial<UITextStyle> {\n return this.commonStyleInternal;\n }\n\n /**\n * Sets the color tint applied to the text.\n * @param value - The color value as a number (e.g., 0xFFFFFF for white)\n */\n public set color(value: number) {\n this.material.setColor(value);\n }\n\n /**\n * Sets the opacity level of the text.\n * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)\n */\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n /**\n * Sets whether transparency is enabled for the text.\n * @param value - True to enable transparency, false to disable\n */\n public set transparency(value: boolean) {\n this.material.setTransparency(value);\n }\n\n /**\n * Sets new text content and triggers a rebuild.\n * @param value - The new text content structure\n */\n public set content(value: UITextContent) {\n this.contentInternal = value;\n this.rebuildText();\n }\n\n /**\n * Sets the maximum width before text wrapping and triggers a rebuild.\n * @param value - The new maximum width in pixels\n */\n public set maxWidth(value: number) {\n this.maxWidthInternal = value;\n this.rebuildText();\n }\n\n /**\n * Sets new padding configuration and triggers a rebuild.\n * @param value - The new padding configuration\n */\n public set padding(value: UITextPadding) {\n this.paddingInternal = value;\n this.rebuildText();\n }\n\n /**\n * Sets new common style properties and triggers a rebuild.\n * @param value - The new partial text style configuration\n */\n public set commonStyle(value: Partial<UITextStyle>) {\n this.commonStyleInternal = value;\n this.rebuildText();\n }\n\n /**\n * Destroys the text element by cleaning up all associated resources.\n *\n * This method disposes of the material and texture resources, removes\n * the canvas element from the DOM, and calls the parent destroy method\n * to clean up the underlying UI element. After calling this method,\n * the text element should not be used anymore.\n */\n public override destroy(): void {\n this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRenderInternal);\n this.material.dispose();\n this.texture.dispose();\n this.canvas.remove();\n super.destroy();\n }\n\n private readonly onWillRenderInternal = (): void => {\n if (this.lastAspectRatio !== this.width / this.height) {\n this.lastAspectRatio = this.targetAspectRatio;\n this.height = this.width / this.targetAspectRatio;\n }\n };\n\n /**\n * Rebuilds the text canvas and texture based on current content and settings.\n *\n * This method calculates the text layout, resizes the canvas to fit the content\n * with padding, renders the text lines to the canvas, and updates the texture.\n * It also calculates and sets the target aspect ratio for proper display.\n *\n * @private\n */\n private rebuildText(): void {\n const { lines, size } = calculateTextContentParameters(\n this.context,\n this.content,\n this.maxWidthInternal,\n this.commonStyleInternal,\n );\n\n this.canvas.width =\n size.width + this.paddingInternal.left + this.paddingInternal.right;\n this.canvas.height =\n size.height + this.paddingInternal.top + this.paddingInternal.bottom;\n\n this.width = this.canvas.width;\n this.height = this.canvas.height;\n\n this.targetAspectRatio =\n (size.width + this.paddingInternal.left + this.paddingInternal.right) /\n (size.height + this.paddingInternal.top + this.paddingInternal.bottom);\n\n renderTextLines(\n this.paddingInternal.top,\n this.paddingInternal.left,\n lines,\n this.context,\n );\n this.texture.needsUpdate = true;\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../miscellaneous/asserts\";\nimport { UIOrientation } from \"../miscellaneous/UIOrientation\";\nimport { UILayer } from \"./UILayer\";\n\n/**\n * UI layer that manages fullscreen interfaces with optional fixed dimensions and automatic scaling.\n *\n * UIFullscreenLayer extends UILayer to provide automatic browser window integration,\n * handling window resize events and pointer interactions. It supports optional fixed\n * width or height constraints that enable responsive scaling while maintaining\n * design proportions across different screen sizes.\n *\n * The layer automatically calculates scaling factors based on the orientation and\n * fixed dimension constraints, ensuring consistent layout appearance regardless\n * of the actual browser window size.\n *\n * @see {@link UILayer} - Base layer functionality\n * @see {@link UIOrientation} - Orientation-based scaling behavior\n */\nexport class UIFullscreenLayer extends UILayer {\n /** Internal storage for the optional fixed width constraint. */\n private fixedWidthInternal?: number;\n /** Internal storage for the optional fixed height constraint. */\n private fixedHeightInternal?: number;\n\n /**\n * Creates a new UIFullscreenLayer instance with optional fixed dimensions.\n *\n * The layer will automatically resize to match the browser window and set up\n * event listeners for window resize and pointer events. Fixed dimensions\n * enable proportional scaling while maintaining design aspect ratios.\n *\n * @param fixedWidth - Optional fixed width for proportional scaling\n * @param fixedHeight - Optional fixed height for proportional scaling\n * @throws Will throw an error if fixed dimensions are not valid positive numbers\n * @see {@link assertValidPositiveNumber}\n */\n constructor(fixedWidth: number | undefined, fixedHeight: number | undefined) {\n if (fixedWidth !== undefined) {\n assertValidPositiveNumber(fixedWidth, \"UIFullscreenLayer.fixedWidth\");\n }\n if (fixedHeight !== undefined) {\n assertValidPositiveNumber(fixedHeight, \"UIFullscreenLayer.fixedHeight\");\n }\n\n super(1, 1);\n this.fixedWidthInternal = fixedWidth;\n this.fixedHeightInternal = fixedHeight;\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"pointerdown\", this.onClick);\n this.onResize();\n }\n\n /**\n * Gets the current fixed width constraint.\n * @returns The fixed width in pixels, or undefined if not set\n */\n public get fixedWidth(): number | undefined {\n return this.fixedWidthInternal;\n }\n\n /**\n * Gets the current fixed height constraint.\n * @returns The fixed height in pixels, or undefined if not set\n */\n public get fixedHeight(): number | undefined {\n return this.fixedHeightInternal;\n }\n\n /**\n * Sets a new fixed width constraint and triggers resize recalculation.\n * @param value - The new fixed width in pixels, or undefined to remove constraint\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set fixedWidth(value: number | undefined) {\n if (value !== undefined) {\n assertValidPositiveNumber(value, \"UIFullscreenLayer.fixedWidth\");\n }\n\n if (value !== this.fixedWidthInternal) {\n this.fixedWidthInternal = value;\n this.onResize();\n }\n }\n\n /**\n * Sets a new fixed height constraint and triggers resize recalculation.\n * @param value - The new fixed height in pixels, or undefined to remove constraint\n * @throws Will throw an error if value is not a valid positive number\n * @see {@link assertValidPositiveNumber}\n */\n public set fixedHeight(value: number | undefined) {\n if (value !== undefined) {\n assertValidPositiveNumber(value, \"UIFullscreenLayer.fixedHeight\");\n }\n\n if (value !== this.fixedHeightInternal) {\n this.fixedHeightInternal = value;\n this.onResize();\n }\n }\n\n /**\n * Destroys the fullscreen layer by removing all event listeners.\n *\n * This method cleans up window event listeners for resize and pointer events.\n * After calling this method, the layer will no longer respond to window\n * changes and should not be used anymore.\n */\n public destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"pointerdown\", this.onClick);\n }\n\n /**\n * Renders the fullscreen layer and all its contained elements.\n *\n * Clears the depth and stencil buffers and delegates rendering to the\n * parent layer's render method. This ensures proper rendering order\n * and buffer management for fullscreen interfaces.\n *\n * @param renderer - The WebGL renderer instance\n * @param deltaTime - Time elapsed since the last frame in seconds\n * @throws Will throw an error if deltaTime is not a valid number\n * @see {@link assertValidNumber}\n */\n public render(renderer: WebGLRenderer, deltaTime: number): void {\n assertValidNumber(deltaTime, \"UIFullscreenLayer.deltaTime\");\n super.renderInternal(renderer, deltaTime);\n }\n\n /**\n * Calculates the scaling factor based on orientation and fixed dimensions.\n *\n * The scaling factor is determined by the current orientation and which\n * fixed dimension constraint is active. In horizontal orientation, fixed\n * width takes precedence; in vertical orientation, fixed height takes precedence.\n *\n * @returns The scaling factor to apply to window dimensions\n * @private\n */\n private calculateScale(): number {\n if (this.orientation === UIOrientation.HORIZONTAL) {\n if (this.fixedWidth !== undefined) {\n return this.fixedWidth / window.innerWidth;\n } else if (this.fixedHeight !== undefined) {\n return this.fixedHeight / window.innerHeight;\n } else {\n return 1;\n }\n } else {\n if (this.fixedHeight !== undefined) {\n return this.fixedHeight / window.innerHeight;\n } else if (this.fixedWidth !== undefined) {\n return this.fixedWidth / window.innerWidth;\n } else {\n return 1;\n }\n }\n }\n\n /**\n * Event handler for window resize events.\n *\n * Recalculates the scaling factor and updates the layer dimensions\n * based on the new window size and fixed dimension constraints.\n *\n * @private\n */\n private readonly onResize = (): void => {\n const scale = this.calculateScale();\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n /**\n * Event handler for pointer down events.\n *\n * Converts browser pointer coordinates to layer coordinates by accounting\n * for element positioning and applying the appropriate scaling factor.\n * The y-coordinate is flipped to match the UI coordinate system.\n *\n * @param event - The pointer event from the browser\n * @private\n */\n private readonly onClick = (event: PointerEvent): void => {\n const r =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\n const x = r ? event.clientX - r.left : event.clientX;\n const y = r ? r.bottom - event.clientY : window.innerHeight - event.clientY;\n\n const scale = this.calculateScale();\n this.clickInternal(x * scale, y * scale);\n };\n}\n","import { isUITextStyle, type UITextStyle } from \"./UITextStyle\";\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 (!(\"style\" in obj) || isUITextStyle(obj.style))\n );\n}\n"],"names":["UIExpression","constructor","constant","terms","this","Map","plus","a","b","result","Array","from","entries","variableIndex","coefficient","_private_terms","minus","set","get","multiply","value","divide","hasTerm","has","copy","expression","clear","clone","t","i","r","WeakMap","insert","s","remove","delete","size","getPriority","o","on","h","once","off","u","v","slice","length","l","_","p","e","shift","n","pop","M","splice","c","emit","apply","k","m","Error","push","unshift","UIMode","UIOrientation","resolveOrientation","orientation","ALWAYS","createMap","IndexedMap","index","array","empty","itemAt","contains","key","undefined","id","find","setDefault","factory","pair","Pair","erase","last","first","second","Variable","name","_name","_id","setName","context","_context","setContext","_value","setValue","Expression","toJSON","toString","VarId","parsed","args","item","terms2","j","termPair","value2","parseArgs","arguments","_terms","_constant","isConstant","map","join","Strength","create","w","Math","max","min","static","clip","required","Operator","Constraint","operator","rhs","strength","_operator","_strength","_expression","op","CnId","Solver","maxIterations","createConstraint","lhs","cn","addConstraint","constraint","_cnMap","data","_createRow","row","tag","subject","_chooseSubject","type","SymbolType","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_rowMap","_optimize","_objective","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","getConstraints","addEditVariable","variable","_editMap","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_infeasibleRows","_dualOptimize","other","coeff","coefficientFor","External","updateVariables","vars","_varMap","_getVarSymbol","_makeSymbol","Row","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","_artificial","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","iterations","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_idTick","createCnMap","createRowMap","createVarMap","createEditMap","_type","_cellMap","theCopy","HIGH_PRIORITY","UIPriority","UIAnchorMode","convertPriority","priority","P0","P1","P2","P3","P4","P5","P6","P7","resolvePriority","originalClearColor","Color","originalClearAlpha","originalAutoClear","originalAutoClearColor","originalAutoClearDepth","originalAutoClearStencil","UISceneWrapper","Scene","OrthographicCamera","insertObject","element","object","_private_elements","_private_scene","replaceObject","oldObject","removeObject","resize","_private_camera","right","top","updateProjectionMatrix","getVisibility","visible","getZIndex","renderOrder","setZIndex","zIndex","setVisibility","getSortedVisibleElements","keys","sort","prepareRender","renderer","getClearColor","getClearAlpha","autoClear","autoClearColor","autoClearDepth","autoClearStencil","setClearColor","micro","width","scaleX","height","scaleY","anchorOffsetX","anchorX","anchorOffsetY","anchorY","cos","rotation","sin","rotatedAnchorX","rotatedAnchorY","anchorMode","POSITION_ROTATION_SCALE","position","x","y","rawAnchorOffsetY","scale","z","render","setClearAlpha","UIRelation","UILayerEvent","convertRelation","relation","EQUAL","LESS_THAN","GREATER_THAN","resolveRelation","UISolverWrapper","_private_recalculationRequired","_private_lastVariableIndex","_private_lastConstraintIndex","createVariable","description","_private_buildConstraint","_private_solver","_private_variables","removeVariable","cDescription","values","suggestVariableValue","_private_rebuildConstraint","setVariablePriority","_private_rebuildVariable","readVariableValue","enabled","_private_constraints","setConstraintLHS","_private_rebuildConstraintByDescription","setConstraintRHS","setConstraintRelation","setConstraintPriority","setConstraintEnabled","dependConstraints","oldConstraint","_private_convertExpression","_private_rebuildSolver","UILayer","Eventail","super","solverWrapper","modeInternal","VISIBLE","sceneWrapper","xVariable","yVariable","wVariable","hVariable","orientationInternal","HORIZONTAL","VERTICAL","mode","MODE_CHANGE","resizeInternal","ORIENTATION_CHANGE","renderInternal","deltaTime","HIDDEN","WILL_RENDER","clickInternal","INTERACTIVE","UIConstraint","layer","UISingleParameterConstraint","_private_onOrientationChange","isConstraintEnabled","priorityInternal","relationInternal","destroy","UIHeightConstraint","_private_element","options","_private_heightInternal","isUILayerElement","obj","isUIPointElement","isUIPlaneElement","assertValidConstraintSubjects","layerA","layerB","assertValidNumber","isFinite","abs","MAX_SAFE_INTEGER","assertValidPositiveNumber","assertValidNonNegativeNumber","UIHorizontalDistanceConstraint","_private_a","_private_b","anchorA","anchorB","distance","_private_buildLHS","_private_distanceInternal","_private_anchorAInternal","_private_anchorBInternal","aExpression","bExpression","UIHorizontalProportionConstraint","proportion","_private_buildRHS","_private_proportionInternal","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","_private_widthInternal","UIConstraint2DBuilder","UIAspectConstraint","_private_aspectInternal","aspect","DEFAULT_ANCHOR","UICoverConstraintBuilder","build","passive","active","activeAspectConstraint","keepActiveAspect","xConstraint","anchorH","yConstraint","anchorV","widthConstraint","heightConstraint","UIFitConstraintBuilder","UICustomConstraint","_private_lhsInternal","_private_rhsInternal","setLHS","setRHS","UIAnchor","UIDummy","UIMicro","_private_xInternal","_private_yInternal","_private_anchorXInternal","_private_anchorYInternal","_private_scaleXInternal","_private_scaleYInternal","_private_rotationInternal","ROTATION_SCALE","angle","MathUtils","radToDeg","_private_anchorModeInternal","degToRad","reset","UIElementEvent","UIElement","isClicked","CLICK","DEFAULT_ALPHA_TEST","UIMaterial","ShaderMaterial","uniforms","opacity","color","alphaTest","transparent","lights","fog","depthWrite","depthTest","getTexture","getColor","getHex","getOpacity","getTransparency","setTexture","uniformsNeedUpdate","setColor","setHex","setOpacity","setTransparency","needsUpdate","geometry","PlaneGeometry","translate","GEOMETRY_SIZE","UIImage","texture","image","material","Mesh","_private_material","_private_textureInternal","transparency","dispose","UINineSliceMaterial","sliceBorders","Vector4","quadSize","Vector2","textureSize","getSliceBorderLeft","getSliceBorderRight","getSliceBorderTop","getSliceBorderBottom","getQuadSize","setSliceBorderLeft","setSliceBorderRight","setSliceBorderTop","setSliceBorderBottom","setSliceBorder","setQuadSize","DEFAULT_SLICE_BORDER","UINineSlice","_private_onWillRenderInternal","sliceBorder","left","bottom","horizontal","vertical","resolveNineSliceBorder","sliceBorderLeft","sliceBorderRight","sliceBorderTop","sliceBorderBottom","setSliceBorders","UIProgressMaterial","foregroundTexture","backgroundTexture","UniformsUtils","merge","background","foreground","progress","backgroundColor","foregroundColor","backgroundOpacity","foregroundOpacity","direction","vertexShader","fragmentShader","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","isForwardDirection","UISceneUpdateMode","DEFAULT_UPDATE_MODE","PROPERTY_CHANGED","UIScene","resolutionFactor","renderTarget","WebGLRenderTarget","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","enableDepthBuffer","stencilBuffer","_private_frameBoolean","_private_propertyChanged","_private_renderRequired","_private_updateModeInternal","EACH_FRAME","EACH_SECOND_FRAME","MANUAL","setSize","_private_resolutionFactorInternal","clearAlpha","setRenderTarget","_private_sceneInternal","_private_renderTarget","scene","_private_cameraInternal","camera","PerspectiveCamera","updateMode","clearColor","_private_clearColorInternal","_private_clearAlphaInternal","requestRender","isUITextStyle","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","enableShadow","shadowOffsetX","shadowOffsetY","shadowBlur","shadowColor","enableStroke","strokeColor","strokeWidth","resolveTextStyle","style","commonStyle","splitText","text","match","measureTextChunk","chunk","font","baseline","metrics","measureText","ceil","actualBoundingBoxAscent","actualBoundingBoxDescent","renderText","strokeStyle","lineWidth","strokeText","fillStyle","fillText","resolvePadding","UIText","content","canvas","document","createElement","getContext","CanvasTexture","_private_targetAspectRatio","_private_lastAspectRatio","_private_texture","_private_canvas","_private_context","_private_contentInternal","maxWidth","padding","_private_maxWidthInternal","_private_paddingInternal","_private_commonStyleInternal","_private_rebuildText","lines","maxLineWidth","chunks","span","isArray","isSpanString","spanString","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","buildLines","textSize","line","totalHeight","calculateTextSize","calculateTextContentParameters","paddingTop","paddingLeft","currentY","currentX","renderTextLines","UIFullscreenLayer","fixedWidth","fixedHeight","_private_onResize","_private_calculateScale","window","innerWidth","innerHeight","event","target","HTMLElement","getBoundingClientRect","clientX","clientY","_private_fixedWidthInternal","_private_fixedHeightInternal","addEventListener","removeEventListener","isUITextSpan"],"mappings":"6SAaaA,EAYX,WAAAC,CAAYC,EAAW,EAAGC,GACxBC,KAAKF,SAAWA,EAChBE,OAAaD,EAAQ,IAAIE,IAAIF,GAAS,IAAIE,GAC5C,CAYO,WAAOC,CAAKC,EAAiBC,GACl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