From c16cef09586601d8338c99e925db9d065bcda497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Rebelo?= Date: Mon, 24 Jul 2023 15:34:17 +0200 Subject: [PATCH 1/9] feat: Grid Size Appropriateness metric #46 --- src/@evoposter/evaluator/package-lock.json | 3443 ++++++++++++++++- src/@evoposter/evaluator/package.json | 5 +- .../src/constraints/GridAppropriateSize.mjs | 18 - src/@evoposter/evaluator/src/index.mjs | 4 +- .../src/metrics/GridAppropriateSize.mjs | 61 + .../{constraints => metrics}/Legibility.mjs | 4 +- .../evaluator/test/unit/gridSize.test.js | 25 + .../evaluator/test/unit/legibility.test.js | 0 src/client/controllers/Population.js | 1 - src/client/controllers/Poster.js | 13 +- src/public/app.js | 4 +- 11 files changed, 3550 insertions(+), 28 deletions(-) delete mode 100644 src/@evoposter/evaluator/src/constraints/GridAppropriateSize.mjs create mode 100644 src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs rename src/@evoposter/evaluator/src/{constraints => metrics}/Legibility.mjs (96%) create mode 100644 src/@evoposter/evaluator/test/unit/gridSize.test.js create mode 100644 src/@evoposter/evaluator/test/unit/legibility.test.js diff --git a/src/@evoposter/evaluator/package-lock.json b/src/@evoposter/evaluator/package-lock.json index c7f8747..ed0cb06 100644 --- a/src/@evoposter/evaluator/package-lock.json +++ b/src/@evoposter/evaluator/package-lock.json @@ -7,7 +7,3448 @@ "": { "name": "@evoposter/evaluator", "version": "0.0.1", - "license": "ISC" + "license": "ISC", + "devDependencies": { + "jest": "^29.6.1" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", + "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", + "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.9.tgz", + "integrity": "sha512-G2EgeufBcYw27U4hhoIwFcgc1XU7TlXJ3mv04oOv1WCuo900U/anZSPzEqNjwdjgffkk2Gs0AN0dW1CKVLcG7w==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.9", + "@babel/helper-compilation-targets": "^7.22.9", + "@babel/helper-module-transforms": "^7.22.9", + "@babel/helpers": "^7.22.6", + "@babel/parser": "^7.22.7", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.8", + "@babel/types": "^7.22.5", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.2", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/@babel/generator": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.9.tgz", + "integrity": "sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.9.tgz", + "integrity": "sha512-7qYrNM6HjpnPHJbopxmb8hSPoZ0gsX8IvUS32JGVoy+pU9e5N0nLr1VjJoR6kA4d9dmGLxNYOjeB8sUDal2WMw==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.22.9", + "@babel/helper-validator-option": "^7.22.5", + "browserslist": "^4.21.9", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", + "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz", + "integrity": "sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==", + "dev": true, + "dependencies": { + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/helper-validator-identifier": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", + "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.6.tgz", + "integrity": "sha512-YjDs6y/fVOYFV8hAf1rxd1QvR9wJe1pDBZ2AREKq/SDayfPzgk0PBnVuTCE5X1acEpMMNOVUqoe+OwiZGJ+OaA==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.6", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", + "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.22.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.7.tgz", + "integrity": "sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.22.5.tgz", + "integrity": "sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", + "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.22.8", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.8.tgz", + "integrity": "sha512-y6LPR+wpM2I3qJrsheCTwhIinzkETbplIgPBbwvqPKc+uljeA5gP+3nP8irdYt1mjQaDnlIcG+dw8OjAco4GXw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.5", + "@babel/generator": "^7.22.7", + "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-function-name": "^7.22.5", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.22.7", + "@babel/types": "^7.22.5", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", + "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.6.1.tgz", + "integrity": "sha512-Aj772AYgwTSr5w8qnyoJ0eDYvN6bMsH3ORH1ivMotrInHLKdUz6BDlaEXHdM6kODaBIkNIyQGzsMvRdOv7VG7Q==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.6.1", + "jest-util": "^29.6.1", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.6.1.tgz", + "integrity": "sha512-CcowHypRSm5oYQ1obz1wfvkjZZ2qoQlrKKvlfPwh5jUXVU12TWr2qMeH8chLMuTFzHh5a1g2yaqlqDICbr+ukQ==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.1", + "@jest/reporters": "^29.6.1", + "@jest/test-result": "^29.6.1", + "@jest/transform": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.5.0", + "jest-config": "^29.6.1", + "jest-haste-map": "^29.6.1", + "jest-message-util": "^29.6.1", + "jest-regex-util": "^29.4.3", + "jest-resolve": "^29.6.1", + "jest-resolve-dependencies": "^29.6.1", + "jest-runner": "^29.6.1", + "jest-runtime": "^29.6.1", + "jest-snapshot": "^29.6.1", + "jest-util": "^29.6.1", + "jest-validate": "^29.6.1", + "jest-watcher": "^29.6.1", + "micromatch": "^4.0.4", + "pretty-format": "^29.6.1", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.6.1.tgz", + "integrity": "sha512-RMMXx4ws+Gbvw3DfLSuo2cfQlK7IwGbpuEWXCqyYDcqYTI+9Ju3a5hDnXaxjNsa6uKh9PQF2v+qg+RLe63tz5A==", + "dev": true, + "dependencies": { + "@jest/fake-timers": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "jest-mock": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.6.1.tgz", + "integrity": "sha512-N5xlPrAYaRNyFgVf2s9Uyyvr795jnB6rObuPx4QFvNJz8aAjpZUDfO4bh5G/xuplMID8PrnuF1+SfSyDxhsgYg==", + "dev": true, + "dependencies": { + "expect": "^29.6.1", + "jest-snapshot": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.6.1.tgz", + "integrity": "sha512-o319vIf5pEMx0LmzSxxkYYxo4wrRLKHq9dP1yJU7FoPTB0LfAKSz8SWD6D/6U3v/O52t9cF5t+MeJiRsfk7zMw==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.4.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.6.1.tgz", + "integrity": "sha512-RdgHgbXyosCDMVYmj7lLpUwXA4c69vcNzhrt69dJJdf8azUrpRh3ckFCaTPNjsEeRi27Cig0oKDGxy5j7hOgHg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.6.1", + "jest-mock": "^29.6.1", + "jest-util": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.6.1.tgz", + "integrity": "sha512-2VjpaGy78JY9n9370H8zGRCFbYVWwjY6RdDMhoJHa1sYfwe6XM/azGN0SjY8kk7BOZApIejQ1BFPyH7FPG0w3A==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.1", + "@jest/expect": "^29.6.1", + "@jest/types": "^29.6.1", + "jest-mock": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.6.1.tgz", + "integrity": "sha512-9zuaI9QKr9JnoZtFQlw4GREQbxgmNYXU6QuWtmuODvk5nvPUeBYapVR/VYMyi2WSx3jXTLJTJji8rN6+Cm4+FA==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.6.1", + "@jest/test-result": "^29.6.1", + "@jest/transform": "^29.6.1", + "@jest/types": "^29.6.1", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^5.1.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.6.1", + "jest-util": "^29.6.1", + "jest-worker": "^29.6.1", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.0", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.0.tgz", + "integrity": "sha512-rxLjXyJBTL4LQeJW3aKo0M/+GkCOXsO+8i9Iu7eDb6KwtP65ayoDsitrdPBtujxQ88k4wI2FNYfa6TOGwSn6cQ==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.0", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.0.tgz", + "integrity": "sha512-oA+I2SHHQGxDCZpbrsCQSoMLb3Bz547JnM+jUr9qEbuw0vQlWZfpPS7CO9J7XiwKicEz9OFn/IYoLkkiUD7bzA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.6.1.tgz", + "integrity": "sha512-Ynr13ZRcpX6INak0TPUukU8GWRfm/vAytE3JbJNGAvINySWYdfE7dGZMbk36oVuK4CigpbhMn8eg1dixZ7ZJOw==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.6.1.tgz", + "integrity": "sha512-oBkC36PCDf/wb6dWeQIhaviU0l5u6VCsXa119yqdUosYAt7/FbQU2M2UoziO3igj/HBDEgp57ONQ3fm0v9uyyg==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.6.1", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.1", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.6.1.tgz", + "integrity": "sha512-URnTneIU3ZjRSaf906cvf6Hpox3hIeJXRnz3VDSw5/X93gR8ycdfSIEy19FlVx8NFmpN7fe3Gb1xF+NjXaQLWg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.1", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.1", + "jest-regex-util": "^29.4.3", + "jest-util": "^29.6.1", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.1.tgz", + "integrity": "sha512-tPKQNMPuXgvdOn2/Lg9HNfUvjYVGolt04Hp03f5hAk878uwOLikN+JzeLY0HcVgKgFl9Hs3EIqpu3WX27XNhnw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, + "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@types/babel__core": { + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.1.tgz", + "integrity": "sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", + "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", + "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.1.tgz", + "integrity": "sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", + "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", + "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/node": { + "version": "20.4.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.4.tgz", + "integrity": "sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew==", + "dev": true + }, + "node_modules/@types/prettier": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", + "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==", + "dev": true + }, + "node_modules/@types/stack-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", + "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.24", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", + "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/babel-jest": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.6.1.tgz", + "integrity": "sha512-qu+3bdPEQC6KZSPz+4Fyjbga5OODNcp49j6GKzG1EKbkfyJBxEYGVUmVGpwCSeGouG52R4EgYMLb6p9YeEEQ4A==", + "dev": true, + "dependencies": { + "@jest/transform": "^29.6.1", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.5.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.5.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.5.0.tgz", + "integrity": "sha512-zSuuuAlTMT4mzLj2nPnUm6fsE6270vdOfnpbJ+RmruU75UhLFvL0N2NgI7xpeS7NaB6hGqmd5pVpGTDYvi4Q3w==", + "dev": true, + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.5.0", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.5.0.tgz", + "integrity": "sha512-JOMloxOqdiBSxMAzjRaH023/vvcaSaec49zvg+2LmNsktC7ei39LTJGw02J+9uUtTZUq6xbLyJ4dxe9sSmIuAg==", + "dev": true, + "dependencies": { + "babel-plugin-jest-hoist": "^29.5.0", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.21.9", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", + "integrity": "sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001503", + "electron-to-chromium": "^1.4.431", + "node-releases": "^2.0.12", + "update-browserslist-db": "^1.0.11" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001517", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz", + "integrity": "sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ci-info": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", + "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", + "dev": true + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", + "dev": true + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diff-sequences": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", + "integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.468", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.468.tgz", + "integrity": "sha512-6M1qyhaJOt7rQtNti1lBA0GwclPH+oKCmsra/hkcWs5INLxfXXD/dtdnaKUYQu/pjOBP/8Osoe4mAcNvvzoFag==", + "dev": true + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.6.1.tgz", + "integrity": "sha512-XEdDLonERCU1n9uR56/Stx9OqojaLAQtZf9PrCHH9Hl8YXiEIka3H4NXJ3NOIBmQJTg7+j7buh34PMHfJujc8g==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.6.1", + "@types/node": "*", + "jest-get-type": "^29.4.3", + "jest-matcher-utils": "^29.6.1", + "jest-message-util": "^29.6.1", + "jest-util": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/is-core-module": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", + "integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.6.1.tgz", + "integrity": "sha512-Nirw5B4nn69rVUZtemCQhwxOBhm0nsp3hmtF4rzCeWD7BkjAXRIji7xWQfnTNbz9g0aVsBX6aZK3n+23LM6uDw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.6.1", + "@jest/types": "^29.6.1", + "import-local": "^3.0.2", + "jest-cli": "^29.6.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.5.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.5.0.tgz", + "integrity": "sha512-IFG34IUMUaNBIxjQXF/iu7g6EcdMrGRRxaUSw92I/2g2YC6vCdTltl4nHvt7Ci5nSJwXIkCu8Ka1DKF+X7Z1Ag==", + "dev": true, + "dependencies": { + "execa": "^5.0.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.6.1.tgz", + "integrity": "sha512-tPbYLEiBU4MYAL2XoZme/bgfUeotpDBd81lgHLCbDZZFaGmECk0b+/xejPFtmiBP87GgP/y4jplcRpbH+fgCzQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.1", + "@jest/expect": "^29.6.1", + "@jest/test-result": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^0.7.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.6.1", + "jest-matcher-utils": "^29.6.1", + "jest-message-util": "^29.6.1", + "jest-runtime": "^29.6.1", + "jest-snapshot": "^29.6.1", + "jest-util": "^29.6.1", + "p-limit": "^3.1.0", + "pretty-format": "^29.6.1", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.6.1.tgz", + "integrity": "sha512-607dSgTA4ODIN6go9w6xY3EYkyPFGicx51a69H7yfvt7lN53xNswEVLovq+E77VsTRi5fWprLH0yl4DJgE8Ing==", + "dev": true, + "dependencies": { + "@jest/core": "^29.6.1", + "@jest/test-result": "^29.6.1", + "@jest/types": "^29.6.1", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "import-local": "^3.0.2", + "jest-config": "^29.6.1", + "jest-util": "^29.6.1", + "jest-validate": "^29.6.1", + "prompts": "^2.0.1", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.6.1.tgz", + "integrity": "sha512-XdjYV2fy2xYixUiV2Wc54t3Z4oxYPAELUzWnV6+mcbq0rh742X2p52pii5A3oeRzYjLnQxCsZmp0qpI6klE2cQ==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.6.1", + "@jest/types": "^29.6.1", + "babel-jest": "^29.6.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.6.1", + "jest-environment-node": "^29.6.1", + "jest-get-type": "^29.4.3", + "jest-regex-util": "^29.4.3", + "jest-resolve": "^29.6.1", + "jest-runner": "^29.6.1", + "jest-util": "^29.6.1", + "jest-validate": "^29.6.1", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.6.1", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.6.1.tgz", + "integrity": "sha512-FsNCvinvl8oVxpNLttNQX7FAq7vR+gMDGj90tiP7siWw1UdakWUGqrylpsYrpvj908IYckm5Y0Q7azNAozU1Kg==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.4.3", + "jest-get-type": "^29.4.3", + "pretty-format": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.4.3.tgz", + "integrity": "sha512-fzdTftThczeSD9nZ3fzA/4KkHtnmllawWrXO69vtI+L9WjEIuXWs4AmyME7lN5hU7dB0sHhuPfcKofRsUb/2Fg==", + "dev": true, + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.6.1.tgz", + "integrity": "sha512-n5eoj5eiTHpKQCAVcNTT7DRqeUmJ01hsAL0Q1SMiBHcBcvTKDELixQOGMCpqhbIuTcfC4kMfSnpmDqRgRJcLNQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "chalk": "^4.0.0", + "jest-get-type": "^29.4.3", + "jest-util": "^29.6.1", + "pretty-format": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.6.1.tgz", + "integrity": "sha512-ZNIfAiE+foBog24W+2caIldl4Irh8Lx1PUhg/GZ0odM1d/h2qORAsejiFc7zb+SEmYPn1yDZzEDSU5PmDkmVLQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.1", + "@jest/fake-timers": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "jest-mock": "^29.6.1", + "jest-util": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz", + "integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.6.1.tgz", + "integrity": "sha512-0m7f9PZXxOCk1gRACiVgX85knUKPKLPg4oRCjLoqIm9brTHXaorMA0JpmtmVkQiT8nmXyIVoZd/nnH1cfC33ig==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.4.3", + "jest-util": "^29.6.1", + "jest-worker": "^29.6.1", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.6.1.tgz", + "integrity": "sha512-OrxMNyZirpOEwkF3UHnIkAiZbtkBWiye+hhBweCHkVbCgyEy71Mwbb5zgeTNYWJBi1qgDVfPC1IwO9dVEeTLwQ==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.4.3", + "pretty-format": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.6.1.tgz", + "integrity": "sha512-SLaztw9d2mfQQKHmJXKM0HCbl2PPVld/t9Xa6P9sgiExijviSp7TnZZpw2Fpt+OI3nwUO/slJbOfzfUMKKC5QA==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.6.1", + "jest-get-type": "^29.4.3", + "pretty-format": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.6.1.tgz", + "integrity": "sha512-KoAW2zAmNSd3Gk88uJ56qXUWbFk787QKmjjJVOjtGFmmGSZgDBrlIL4AfQw1xyMYPNVD7dNInfIbur9B2rd/wQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.1", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.6.1", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.6.1.tgz", + "integrity": "sha512-brovyV9HBkjXAEdRooaTQK42n8usKoSRR3gihzUpYeV/vwqgSoNfrksO7UfSACnPmxasO/8TmHM3w9Hp3G1dgw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "@types/node": "*", + "jest-util": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.4.3.tgz", + "integrity": "sha512-O4FglZaMmWXbGHSQInfXewIsd1LMn9p3ZXB/6r4FOkyhX2/iP/soMG98jGvk/A3HAN78+5VWcBGO0BJAPRh4kg==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.6.1.tgz", + "integrity": "sha512-AeRkyS8g37UyJiP9w3mmI/VXU/q8l/IH52vj/cDAyScDcemRbSBhfX/NMYIGilQgSVwsjxrCHf3XJu4f+lxCMg==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.1", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.6.1", + "jest-validate": "^29.6.1", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.6.1.tgz", + "integrity": "sha512-BbFvxLXtcldaFOhNMXmHRWx1nXQO5LoXiKSGQcA1LxxirYceZT6ch8KTE1bK3X31TNG/JbkI7OkS/ABexVahiw==", + "dev": true, + "dependencies": { + "jest-regex-util": "^29.4.3", + "jest-snapshot": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.6.1.tgz", + "integrity": "sha512-tw0wb2Q9yhjAQ2w8rHRDxteryyIck7gIzQE4Reu3JuOBpGp96xWgF0nY8MDdejzrLCZKDcp8JlZrBN/EtkQvPQ==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.1", + "@jest/environment": "^29.6.1", + "@jest/test-result": "^29.6.1", + "@jest/transform": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.4.3", + "jest-environment-node": "^29.6.1", + "jest-haste-map": "^29.6.1", + "jest-leak-detector": "^29.6.1", + "jest-message-util": "^29.6.1", + "jest-resolve": "^29.6.1", + "jest-runtime": "^29.6.1", + "jest-util": "^29.6.1", + "jest-watcher": "^29.6.1", + "jest-worker": "^29.6.1", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.6.1.tgz", + "integrity": "sha512-D6/AYOA+Lhs5e5il8+5pSLemjtJezUr+8zx+Sn8xlmOux3XOqx4d8l/2udBea8CRPqqrzhsKUsN/gBDE/IcaPQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.1", + "@jest/fake-timers": "^29.6.1", + "@jest/globals": "^29.6.1", + "@jest/source-map": "^29.6.0", + "@jest/test-result": "^29.6.1", + "@jest/transform": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.1", + "jest-message-util": "^29.6.1", + "jest-mock": "^29.6.1", + "jest-regex-util": "^29.4.3", + "jest-resolve": "^29.6.1", + "jest-snapshot": "^29.6.1", + "jest-util": "^29.6.1", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.6.1.tgz", + "integrity": "sha512-G4UQE1QQ6OaCgfY+A0uR1W2AY0tGXUPQpoUClhWHq1Xdnx1H6JOrC2nH5lqnOEqaDgbHFgIwZ7bNq24HpB180A==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.6.1", + "@jest/transform": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/prettier": "^2.1.5", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.6.1", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.6.1", + "jest-get-type": "^29.4.3", + "jest-matcher-utils": "^29.6.1", + "jest-message-util": "^29.6.1", + "jest-util": "^29.6.1", + "natural-compare": "^1.4.0", + "pretty-format": "^29.6.1", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-snapshot/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/jest-util": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.1.tgz", + "integrity": "sha512-NRFCcjc+/uO3ijUVyNOQJluf8PtGCe/W6cix36+M3cTFgiYqFOOW5MgN4JOOcvbUhcKTYVd1CvHz/LWi8d16Mg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.6.1.tgz", + "integrity": "sha512-r3Ds69/0KCN4vx4sYAbGL1EVpZ7MSS0vLmd3gV78O+NAx3PDQQukRU5hNHPXlyqCgFY8XUk7EuTMLugh0KzahA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.1", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.4.3", + "leven": "^3.1.0", + "pretty-format": "^29.6.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.6.1.tgz", + "integrity": "sha512-d4wpjWTS7HEZPaaj8m36QiaP856JthRZkrgcIY/7ISoUWPIillrXM23WPboZVLbiwZBt4/qn2Jke84Sla6JhFA==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.6.1", + "@jest/types": "^29.6.1", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.6.1", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.1.tgz", + "integrity": "sha512-U+Wrbca7S8ZAxAe9L6nb6g8kPdia5hj32Puu5iOqBCMTMWFHXuK6dOV2IFrpedbTV8fjMFLdWNttQTBL6u2MRA==", + "dev": true, + "dependencies": { + "@types/node": "*", + "jest-util": "^29.6.1", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format": { + "version": "29.6.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.1.tgz", + "integrity": "sha512-7jRj+yXO0W7e4/tSJKoR7HRIHLPPjtNaUGG2xxKQnGvPNRkgWcQ0AZX6P4KBRJN4FcTBWb3sa7DVUJmocYuoog==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.0", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pure-rand": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.2.tgz", + "integrity": "sha512-6Yg0ekpKICSjPswYOuC5sku/TSWaRYlA0qsXqJgM/d/4pLPHPuTxK7Nbf7jFKzAeedUhR8C7K9Uv63FBsSo8xQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ] + }, + "node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", + "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "dev": true, + "dependencies": { + "is-core-module": "^2.11.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", + "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/src/@evoposter/evaluator/package.json b/src/@evoposter/evaluator/package.json index 4946d2c..2ecec8e 100644 --- a/src/@evoposter/evaluator/package.json +++ b/src/@evoposter/evaluator/package.json @@ -12,5 +12,8 @@ "url": "git+https://github.com/sergiomrebelo/evo-poster.git" }, "author": "Sérgio M. Rebelo (https://sergiorebelo.work/)", - "license": "ISC" + "license": "ISC", + "devDependencies": { + "jest": "^29.6.1" + } } diff --git a/src/@evoposter/evaluator/src/constraints/GridAppropriateSize.mjs b/src/@evoposter/evaluator/src/constraints/GridAppropriateSize.mjs deleted file mode 100644 index 45c7208..0000000 --- a/src/@evoposter/evaluator/src/constraints/GridAppropriateSize.mjs +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Measure the appropriate of the used grid to the size of container - * it is related to if the width and height of the grid is - * in accordance with poster size - * - * Sérgio M. Rebelo - * CDV lab. (CMS, CISUC, Portugal) - * srebelo[at]dei.uc.pt - * - * v1.0.0 November 2023 - */ - -export const compute = (containerSize, grid) => { - console.log("colSize=", grid); - return 1; -} - -export { compute as default }; \ No newline at end of file diff --git a/src/@evoposter/evaluator/src/index.mjs b/src/@evoposter/evaluator/src/index.mjs index 4e0d14a..3b31ffa 100644 --- a/src/@evoposter/evaluator/src/index.mjs +++ b/src/@evoposter/evaluator/src/index.mjs @@ -7,8 +7,8 @@ * v0.0.1 July 2023 */ -import * as Legibility from "./constraints/Legibility.mjs"; -import * as GridAppropriateSize from "./constraints/GridAppropriateSize.mjs"; +import * as Legibility from "./metrics/Legibility.mjs"; +import * as GridAppropriateSize from "./metrics/GridAppropriateSize.mjs"; export const info = () => { console.log ("Evaluator working"); diff --git a/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs b/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs new file mode 100644 index 0000000..b0b6fa3 --- /dev/null +++ b/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs @@ -0,0 +1,61 @@ +/** + * Grid Size Appropriateness + * + * Measure the appropriate of the used grid to the size of container + * it is related to if the width and height of the grid is + * in accordance with poster size + * + * Sérgio M. Rebelo + * CDV lab. (CMS, CISUC, Portugal) + * srebelo[at]dei.uc.pt + * + * v1.0.0 November 2023 + */ + +const DEBUG = true; + +export const compute = ( + containerWidth, containerHeight, + rows = [], columns = [], + margins = {left:0, top:0, right:0, bottom:0} +) => { + console.log ("EXAMPLE=", containerWidth, containerHeight, rows, columns, margins); + + + let invalid = false; + // debug + let msg = ""; + + // height calculation + let height = margins.top+margins.bottom; + for (let r of rows) { + height = height + parseFloat(r); + } + // width calculation + let width = margins.left+margins.right; + for (let r of columns) { + width = width + parseFloat(r); + } + + if (height > containerHeight) { + invalid = true; + msg += `Grid height is bigger than container (grid:${height}, container:${containerHeight}). `; + } else if (height < containerHeight) { + msg += `Grid and container height are not the same (grid:${height}, container:${containerHeight}). `; + } + + if (width > containerWidth) { + invalid = true; + msg += `Grid width is bigger than container (grid:${width}, container:${containerWidth}). `; + } else if (width < containerWidth) { + msg += `Grid and container width are not the same (grid:${width}, container:${containerWidth}). `; + } + + if (msg !== "" && DEBUG) { + console.warn(msg); + } + + return invalid ? 1 : 0; +} + +export { compute as default }; \ No newline at end of file diff --git a/src/@evoposter/evaluator/src/constraints/Legibility.mjs b/src/@evoposter/evaluator/src/metrics/Legibility.mjs similarity index 96% rename from src/@evoposter/evaluator/src/constraints/Legibility.mjs rename to src/@evoposter/evaluator/src/metrics/Legibility.mjs index 6f33a8c..f8f1752 100644 --- a/src/@evoposter/evaluator/src/constraints/Legibility.mjs +++ b/src/@evoposter/evaluator/src/metrics/Legibility.mjs @@ -3,6 +3,8 @@ * it is related to the legibility of the sentence * and not the typeface shapes * + * Expected return a value between 0 (good) and (1) bad + * * Sérgio M. Rebelo * CDV lab. (CMS, CISUC, Portugal) * srebelo[at]dei.uc.pt @@ -15,7 +17,7 @@ import {arrMean, map} from "../utils.js"; -const MAX_CONSTRAINT = 0.5; +const MAX_CONSTRAINT = 1; const WHITE_SPACE_FACTOR = 3; const MODES = [`OVERSET`, `JUSTIFY`,`ATTEMPT_JUSTIFY`]; diff --git a/src/@evoposter/evaluator/test/unit/gridSize.test.js b/src/@evoposter/evaluator/test/unit/gridSize.test.js new file mode 100644 index 0000000..259948d --- /dev/null +++ b/src/@evoposter/evaluator/test/unit/gridSize.test.js @@ -0,0 +1,25 @@ +const params = [ + { + width: 300, + height: 423, + rows: [379.95], + columns: [135, 135], + margins: {left: 15, top: 21.900000000000002, right: 15, bottom: 21.150000000000002}, + invalid: false, + }, + { + width: 300, + height: 423, + rows: [377.84999999999997], + columns: [135, 135], + margins: {left: 15, top: 21.150000000000002, right: 15, bottom: 24.000000000000025}, + invalid: true + } +]; + + +describe(`Test the Grid Size Appropriateness metric`, () => { + // Grid Size Appropriateness metric +}); + +// (5) [72.85000000000001, 69.85, 71.95, 70.89999999999999, 70.89999999999999] (2) [135, 135] {left: 15, top: 33.27500000000001, right: 15, bottom: 33.27500000000001} \ No newline at end of file diff --git a/src/@evoposter/evaluator/test/unit/legibility.test.js b/src/@evoposter/evaluator/test/unit/legibility.test.js new file mode 100644 index 0000000..e69de29 diff --git a/src/client/controllers/Population.js b/src/client/controllers/Population.js index 5e1597f..41cc645 100644 --- a/src/client/controllers/Population.js +++ b/src/client/controllers/Population.js @@ -68,7 +68,6 @@ export class Population { // crossover for (let i = eliteSize; i < this.params["evo"]["popSize"]; i++) { if (Math.random() <= this.params["evo"]["crossoverProb"]) { - const parentA = this.tournament(TOURNAMENT_SIZE); const parentB = this.tournament(TOURNAMENT_SIZE); // crossover method diff --git a/src/client/controllers/Poster.js b/src/client/controllers/Poster.js index 1b56c62..6698864 100644 --- a/src/client/controllers/Poster.js +++ b/src/client/controllers/Poster.js @@ -223,7 +223,12 @@ class Poster { // constraints const legibility = evaluator.legibility(this.sentencesLenght, this.genotype["grid"].getAvailableWidth(), `JUSTIFY`); - // const gridAppropriateness = evaluator.gridAppropriateSize(this.genotype["size"], this.genotype["grid"]); + const gridAppropriateness = evaluator.gridAppropriateSize( + this.genotype["size"].width, this.genotype["size"].height, + this.genotype["grid"].rows.l, this.genotype["grid"].columns.l, this.genotype["grid"].marginsPos + ); + + console.log (`gridAppropriateness=${gridAppropriateness}`) // returns a number between 0 and 0.5 // subtracted to fitness @@ -477,7 +482,11 @@ export class Grid { this.columns.y.bottom = (this.size.height / 2) - (this.marginsPos.bottom); const inc = (this.size.width - (this.marginsPos.left + this.marginsPos.right)) / this.v; - this.columns.l = inc; + let horizontalSpace = []; + for (let i=0; i`:U}
- `}createRenderRoot(){return this}}customElements.define("header-section",je);var Se={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Ee=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Me=(e,t)=>Ee(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,.5,0),Te=(e,t)=>(e=Math.abs(e),Ee(e=e>t?t:e,t,0,.5,0)),Ce=(e,t)=>Te(e=e>=0?e/3:e,t),Ae=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=.5;switch(r){case"JUSTIFY":i=Te(e,n);break;case"ATTEMPT_JUSTIFY":i=Ce(e,n);break;default:i=Me(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i};function ke(e,t,r){return Math.max(t,Math.min(e,r))}function Oe(e){return(e%360+360)%360}function Pe(e){var t,r;return Oe(function(e,t){var r;return e*(null!==(r={rad:180/Math.PI,grad:.9,turn:360}[t.toLowerCase()])&&void 0!==r?r:1)}(parseFloat(e),null!==(r=null===(t=e.match(/deg|rad|grad|turn/i))||void 0===t?void 0:t[0])&&void 0!==r?r:"deg"))}function Le(e){return new RegExp(`^${e.source}$`,e.flags)}function Re(e){return e.slice(1).filter((e=>void 0!==e))}const Ie=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,De=/(?=[,\s])\s*(?:,\s*)?/,Fe=/\s*[,\/]\s*/,Ne=Ie.source,Ue=De.source,Be=new RegExp(`hsla?\\(\\s*(${Ne}(?:deg|rad|grad|turn)?)${Ue}(${Ne})%${Ue}(${Ne})%(?:${Fe.source}(${Ne}%?))?\\s*\\)`,"i");const Ge={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const ze=/[0-9a-fA-F]/.source,Ve=new RegExp(`#(${ze}{2})(${ze}{2})(${ze}{2})(${ze}{2})?`),$e=new RegExp(`#(${ze})(${ze})(${ze})(${ze})?`);const He=Ie.source,qe=De.source,We=new RegExp(`rgba?\\(\\s*(${He}%?)${qe}(${He}%?)${qe}(${He}%?)(?:${Fe.source}(${He}%?))?\\s*\\)`,"i");function Xe(e){return{r:ke(e.r,0,255),g:ke(e.g,0,255),b:ke(e.b,0,255),a:ke(e.a,0,1)}}function Ye(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=Ge[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Le(Ve).exec(e))&&void 0!==t?t:Le($e).exec(e);return r?Re(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Le(We).exec(e);return t?Re(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Xe({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Ze(e){return{h:Oe(e.h),s:ke(e.s,0,100),l:ke(e.l,0,100),a:ke(e.a,0,1)}}function Je(e){const t=Ye(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Xe(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Ze({h:Pe(e[0]),s:o[1],l:o[2],a:s})}(t):null}function Ke(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function et(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Ze(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Xe(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):Ke(t)}var tt=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=Qe(e))&&void 0!==t?t:Je(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return et(Object.assign(Object.assign({},r),{h:o}))};var rt=(e,t)=>"number"!=typeof t||0===t?e:tt(e,30*t);var ot=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return tt(e,r)};const st=()=>{const e=it();return nt(e)},nt=e=>{const t=ot(e,1);return{baseColour:e,colorA:t,colorB:rt(t,Math.round(4*Math.random()-2))}},it=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class at{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ct(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new at(this.n,this.generation,null,i)};#p=e=>{const t=st(),r=new ct({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Se)[this.genotype.background.style-1];return(0,Se[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Ae(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"JUSTIFY");this.fitness-=e};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${lt(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${lt(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const lt=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ct{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ct(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;this.columns.l=e;let t=-this.size.width/2+this.marginsPos.left;for(let r=0;r0&&r{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class ut{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ct(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();this.population=this.population.sort(((e,t)=>t.fitness-e.fitness))};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#j=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null;key.toUpperCase()};class dt extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#S();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new je,this.initPopForm=new xe(this.config,this.#E,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#S=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#M(),this.#E()};#E=(e=!1)=>{e&&this.#M(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new ut(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#M=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#T=()=>F` + `}createRenderRoot(){return this}}customElements.define("header-section",je);var Se={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Ee=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Me=(e,t)=>Ee(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Te=(e,t)=>(e=Math.abs(e),Ee(e=e>t?t:e,t,0,1,0)),Ce=(e,t)=>Te(e=e>=0?e/3:e,t),Ae=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Te(e,n);break;case"ATTEMPT_JUSTIFY":i=Ce(e,n);break;default:i=Me(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},ke=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{console.log("EXAMPLE=",e,t,r,o,s);let n=!1,i="",a=s.top+s.bottom;for(let e of r)a+=parseFloat(e);let l=s.left+s.right;for(let e of o)l+=parseFloat(e);return a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const De=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Fe=/(?=[,\s])\s*(?:,\s*)?/,Ne=/\s*[,\/]\s*/,Ue=De.source,Be=Fe.source,Ge=new RegExp(`hsla?\\(\\s*(${Ue}(?:deg|rad|grad|turn)?)${Be}(${Ue})%${Be}(${Ue})%(?:${Ne.source}(${Ue}%?))?\\s*\\)`,"i");const ze={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const Ve=/[0-9a-fA-F]/.source,$e=new RegExp(`#(${Ve}{2})(${Ve}{2})(${Ve}{2})(${Ve}{2})?`),He=new RegExp(`#(${Ve})(${Ve})(${Ve})(${Ve})?`);const qe=De.source,We=Fe.source,Xe=new RegExp(`rgba?\\(\\s*(${qe}%?)${We}(${qe}%?)${We}(${qe}%?)(?:${Ne.source}(${qe}%?))?\\s*\\)`,"i");function Ye(e){return{r:Oe(e.r,0,255),g:Oe(e.g,0,255),b:Oe(e.b,0,255),a:Oe(e.a,0,1)}}function Ze(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=ze[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Re($e).exec(e))&&void 0!==t?t:Re(He).exec(e);return r?Ie(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Re(Xe).exec(e);return t?Ie(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Ye({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Je(e){return{h:Pe(e.h),s:Oe(e.s,0,100),l:Oe(e.l,0,100),a:Oe(e.a,0,1)}}function Qe(e){const t=Ze(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Ye(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Je({h:Le(e[0]),s:o[1],l:o[2],a:s})}(t):null}function et(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function tt(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Je(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Ye(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):et(t)}var rt=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=Ke(e))&&void 0!==t?t:Qe(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return tt(Object.assign(Object.assign({},r),{h:o}))};var ot=(e,t)=>"number"!=typeof t||0===t?e:rt(e,30*t);var st=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return rt(e,r)};const nt=()=>{const e=at();return it(e)},it=e=>{const t=st(e,1);return{baseColour:e,colorA:t,colorB:ot(t,Math.round(4*Math.random()-2))}},at=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class lt{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ut(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new lt(this.n,this.generation,null,i)};#p=e=>{const t=nt(),r=new ut({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Se)[this.genotype.background.style-1];return(0,Se[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Ae(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"JUSTIFY"),t=ke(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);console.log(`gridAppropriateness=${t}`),this.fitness-=e};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const ct=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ut{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ut(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class dt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ut(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();this.population=this.population.sort(((e,t)=>t.fitness-e.fitness))};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#j=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ht extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#S();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new je,this.initPopForm=new xe(this.config,this.#E,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#S=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#M(),this.#E()};#E=(e=!1)=>{e&&this.#M(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new dt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#M=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#T=()=>F`
`:U} - `}createRenderRoot(){return this}}customElements.define("app-evo",dt);export{dt as App}; + `}createRenderRoot(){return this}}customElements.define("app-evo",ht);export{ht as App}; From 2ce2c6e57805035c8c1fb011bf3b37c66be79a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Rebelo?= Date: Mon, 24 Jul 2023 15:58:18 +0200 Subject: [PATCH 2/9] test: append gridAppropriateSize metric test #46 --- src/@evoposter/evaluator/package.json | 2 +- .../src/metrics/GridAppropriateSize.mjs | 7 +- .../test/unit/GridAppropriateSize.test.js | 74 +++++++++++++++++++ .../evaluator/test/unit/gridSize.test.js | 25 ------- .../evaluator/test/unit/legibility.test.js | 0 src/public/app.js | 2 +- 6 files changed, 81 insertions(+), 29 deletions(-) create mode 100644 src/@evoposter/evaluator/test/unit/GridAppropriateSize.test.js delete mode 100644 src/@evoposter/evaluator/test/unit/gridSize.test.js delete mode 100644 src/@evoposter/evaluator/test/unit/legibility.test.js diff --git a/src/@evoposter/evaluator/package.json b/src/@evoposter/evaluator/package.json index 2ecec8e..771271c 100644 --- a/src/@evoposter/evaluator/package.json +++ b/src/@evoposter/evaluator/package.json @@ -4,7 +4,7 @@ "description": "set of metric for evaluation of poster designs", "main": "src/index.mjs", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest" }, "type": "module", "repository": { diff --git a/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs b/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs index b0b6fa3..9a4e858 100644 --- a/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs +++ b/src/@evoposter/evaluator/src/metrics/GridAppropriateSize.mjs @@ -27,16 +27,19 @@ export const compute = ( let msg = ""; // height calculation - let height = margins.top+margins.bottom; + let height = Math.abs(margins.top)+Math.abs(margins.bottom); for (let r of rows) { height = height + parseFloat(r); } // width calculation - let width = margins.left+margins.right; + let width = Math.abs(margins.left)+Math.abs(margins.right); for (let r of columns) { width = width + parseFloat(r); } + width = Math.round(width); + height = Math.round(height); + if (height > containerHeight) { invalid = true; msg += `Grid height is bigger than container (grid:${height}, container:${containerHeight}). `; diff --git a/src/@evoposter/evaluator/test/unit/GridAppropriateSize.test.js b/src/@evoposter/evaluator/test/unit/GridAppropriateSize.test.js new file mode 100644 index 0000000..2219128 --- /dev/null +++ b/src/@evoposter/evaluator/test/unit/GridAppropriateSize.test.js @@ -0,0 +1,74 @@ +import {gridAppropriateSize} from '../../src/index.mjs' + +const TESTING_PARAMS = [ + { + width: 300, + height: 423, + rows: [379.95], + columns: [135, 135], + margins: {left: 15, top: 21.900000000000002, right: 15, bottom: 21.150000000000002}, + invalid: false, + }, + { + width: 300, + height: 423, + rows: [377.84999999999997], + columns: [135, 135], + margins: {left: 15, top: 21.150000000000002, right: 15, bottom: 24.000000000000025}, + invalid: false + }, + { + width: 300, + height: 423, + rows: [72.85000000000001, 69.85, 71.95, 70.89999999999999, 70.89999999999999], + columns: [135, 135], + margins: {left: 15, top: 33.27500000000001, right: 15, bottom: 33.27500000000001}, + invalid: false + }, + { + width: 300, + height: 423, + rows: [76, 74.95, 74.95, 73.9, 72.85000000000001], + columns: [135, 135], + margins: {left: 15, top: 21.150000000000002, right: 15, bottom: 29.199999999999985}, + invalid: false + }, + { + width: 300, + height: 423, + rows: [22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05, 22.05], + columns: [135, 135], + margins: {left: 15, top: -171.45000000000002, right: 15, bottom: 21.150000000000002}, + invalid: true + }, + { + width: 300, + height: 423, + rows: [76, 74.95, 74.95, 73.9, 72.85000000000001], + columns: [135, 160], + margins: {left: 15, top: 21.150000000000002, right: 20, bottom: 29.199999999999985}, + invalid: true + }, + { + width: 300, + height: 423, + rows: [76, 150, 74.95, 200, 72.85000000000001], + columns: [135, 160], + margins: {left: 1000, top: 21.150000000000002, right: 20, bottom: 29.199999999999985}, + invalid: true + } +]; + +describe(`Test the Grid Size Appropriateness metric`, () => { + for (let i in TESTING_PARAMS) { + let params = TESTING_PARAMS[i]; + test(`Test ${i}`, async () => { + const invalid = gridAppropriateSize( + params.width, params.height, + params.rows, params.columns, params.margins + ); + const expectResult = params.invalid ? 1 : 0; + expect(invalid).toBe(expectResult); + }); + } +}); \ No newline at end of file diff --git a/src/@evoposter/evaluator/test/unit/gridSize.test.js b/src/@evoposter/evaluator/test/unit/gridSize.test.js deleted file mode 100644 index 259948d..0000000 --- a/src/@evoposter/evaluator/test/unit/gridSize.test.js +++ /dev/null @@ -1,25 +0,0 @@ -const params = [ - { - width: 300, - height: 423, - rows: [379.95], - columns: [135, 135], - margins: {left: 15, top: 21.900000000000002, right: 15, bottom: 21.150000000000002}, - invalid: false, - }, - { - width: 300, - height: 423, - rows: [377.84999999999997], - columns: [135, 135], - margins: {left: 15, top: 21.150000000000002, right: 15, bottom: 24.000000000000025}, - invalid: true - } -]; - - -describe(`Test the Grid Size Appropriateness metric`, () => { - // Grid Size Appropriateness metric -}); - -// (5) [72.85000000000001, 69.85, 71.95, 70.89999999999999, 70.89999999999999] (2) [135, 135] {left: 15, top: 33.27500000000001, right: 15, bottom: 33.27500000000001} \ No newline at end of file diff --git a/src/@evoposter/evaluator/test/unit/legibility.test.js b/src/@evoposter/evaluator/test/unit/legibility.test.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/public/app.js b/src/public/app.js index 42d1799..9bb5d0c 100644 --- a/src/public/app.js +++ b/src/public/app.js @@ -339,7 +339,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r) `:U}
- `}createRenderRoot(){return this}}customElements.define("header-section",je);var Se={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Ee=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Me=(e,t)=>Ee(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Te=(e,t)=>(e=Math.abs(e),Ee(e=e>t?t:e,t,0,1,0)),Ce=(e,t)=>Te(e=e>=0?e/3:e,t),Ae=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Te(e,n);break;case"ATTEMPT_JUSTIFY":i=Ce(e,n);break;default:i=Me(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},ke=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{console.log("EXAMPLE=",e,t,r,o,s);let n=!1,i="",a=s.top+s.bottom;for(let e of r)a+=parseFloat(e);let l=s.left+s.right;for(let e of o)l+=parseFloat(e);return a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const De=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Fe=/(?=[,\s])\s*(?:,\s*)?/,Ne=/\s*[,\/]\s*/,Ue=De.source,Be=Fe.source,Ge=new RegExp(`hsla?\\(\\s*(${Ue}(?:deg|rad|grad|turn)?)${Be}(${Ue})%${Be}(${Ue})%(?:${Ne.source}(${Ue}%?))?\\s*\\)`,"i");const ze={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const Ve=/[0-9a-fA-F]/.source,$e=new RegExp(`#(${Ve}{2})(${Ve}{2})(${Ve}{2})(${Ve}{2})?`),He=new RegExp(`#(${Ve})(${Ve})(${Ve})(${Ve})?`);const qe=De.source,We=Fe.source,Xe=new RegExp(`rgba?\\(\\s*(${qe}%?)${We}(${qe}%?)${We}(${qe}%?)(?:${Ne.source}(${qe}%?))?\\s*\\)`,"i");function Ye(e){return{r:Oe(e.r,0,255),g:Oe(e.g,0,255),b:Oe(e.b,0,255),a:Oe(e.a,0,1)}}function Ze(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=ze[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Re($e).exec(e))&&void 0!==t?t:Re(He).exec(e);return r?Ie(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Re(Xe).exec(e);return t?Ie(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Ye({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Je(e){return{h:Pe(e.h),s:Oe(e.s,0,100),l:Oe(e.l,0,100),a:Oe(e.a,0,1)}}function Qe(e){const t=Ze(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Ye(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Je({h:Le(e[0]),s:o[1],l:o[2],a:s})}(t):null}function et(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function tt(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Je(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Ye(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):et(t)}var rt=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=Ke(e))&&void 0!==t?t:Qe(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return tt(Object.assign(Object.assign({},r),{h:o}))};var ot=(e,t)=>"number"!=typeof t||0===t?e:rt(e,30*t);var st=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return rt(e,r)};const nt=()=>{const e=at();return it(e)},it=e=>{const t=st(e,1);return{baseColour:e,colorA:t,colorB:ot(t,Math.round(4*Math.random()-2))}},at=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class lt{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ut(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new lt(this.n,this.generation,null,i)};#p=e=>{const t=nt(),r=new ut({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Se)[this.genotype.background.style-1];return(0,Se[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Ae(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"JUSTIFY"),t=ke(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);console.log(`gridAppropriateness=${t}`),this.fitness-=e};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const ct=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ut{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ut(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class dt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ut(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();this.population=this.population.sort(((e,t)=>t.fitness-e.fitness))};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#j=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ht extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#S();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new je,this.initPopForm=new xe(this.config,this.#E,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#S=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#M(),this.#E()};#E=(e=!1)=>{e&&this.#M(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new dt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#M=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#T=()=>F` + `}createRenderRoot(){return this}}customElements.define("header-section",je);var Se={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Ee=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Me=(e,t)=>Ee(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Te=(e,t)=>(e=Math.abs(e),Ee(e=e>t?t:e,t,0,1,0)),Ce=(e,t)=>Te(e=e>=0?e/3:e,t),Ae=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Te(e,n);break;case"ATTEMPT_JUSTIFY":i=Ce(e,n);break;default:i=Me(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},ke=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{console.log("EXAMPLE=",e,t,r,o,s);let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const De=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Fe=/(?=[,\s])\s*(?:,\s*)?/,Ne=/\s*[,\/]\s*/,Ue=De.source,Be=Fe.source,Ge=new RegExp(`hsla?\\(\\s*(${Ue}(?:deg|rad|grad|turn)?)${Be}(${Ue})%${Be}(${Ue})%(?:${Ne.source}(${Ue}%?))?\\s*\\)`,"i");const ze={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const Ve=/[0-9a-fA-F]/.source,$e=new RegExp(`#(${Ve}{2})(${Ve}{2})(${Ve}{2})(${Ve}{2})?`),He=new RegExp(`#(${Ve})(${Ve})(${Ve})(${Ve})?`);const qe=De.source,We=Fe.source,Xe=new RegExp(`rgba?\\(\\s*(${qe}%?)${We}(${qe}%?)${We}(${qe}%?)(?:${Ne.source}(${qe}%?))?\\s*\\)`,"i");function Ye(e){return{r:Oe(e.r,0,255),g:Oe(e.g,0,255),b:Oe(e.b,0,255),a:Oe(e.a,0,1)}}function Ze(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=ze[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Re($e).exec(e))&&void 0!==t?t:Re(He).exec(e);return r?Ie(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Re(Xe).exec(e);return t?Ie(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Ye({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Je(e){return{h:Pe(e.h),s:Oe(e.s,0,100),l:Oe(e.l,0,100),a:Oe(e.a,0,1)}}function Qe(e){const t=Ze(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Ye(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Je({h:Le(e[0]),s:o[1],l:o[2],a:s})}(t):null}function et(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function tt(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Je(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Ye(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):et(t)}var rt=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=Ke(e))&&void 0!==t?t:Qe(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return tt(Object.assign(Object.assign({},r),{h:o}))};var ot=(e,t)=>"number"!=typeof t||0===t?e:rt(e,30*t);var st=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return rt(e,r)};const nt=()=>{const e=at();return it(e)},it=e=>{const t=st(e,1);return{baseColour:e,colorA:t,colorB:ot(t,Math.round(4*Math.random()-2))}},at=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class lt{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ut(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new lt(this.n,this.generation,null,i)};#p=e=>{const t=nt(),r=new ut({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Se)[this.genotype.background.style-1];return(0,Se[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Ae(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"JUSTIFY"),t=ke(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);console.log(`gridAppropriateness=${t}`),this.fitness-=e};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const ct=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ut{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ut(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class dt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ut(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();this.population=this.population.sort(((e,t)=>t.fitness-e.fitness))};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#j=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ht extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#S();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new je,this.initPopForm=new xe(this.config,this.#E,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#S=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#M(),this.#E()};#E=(e=!1)=>{e&&this.#M(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new dt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#M=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#T=()=>F`
`:U}
- `}createRenderRoot(){return this}}customElements.define("header-section",je);var Se={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Ee=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Me=(e,t)=>Ee(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Te=(e,t)=>(e=Math.abs(e),Ee(e=e>t?t:e,t,0,1,0)),Ce=(e,t)=>Te(e=e>=0?e/3:e,t),Ae=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Te(e,n);break;case"ATTEMPT_JUSTIFY":i=Ce(e,n);break;default:i=Me(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},ke=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{console.log("EXAMPLE=",e,t,r,o,s);let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const De=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Fe=/(?=[,\s])\s*(?:,\s*)?/,Ne=/\s*[,\/]\s*/,Ue=De.source,Be=Fe.source,Ge=new RegExp(`hsla?\\(\\s*(${Ue}(?:deg|rad|grad|turn)?)${Be}(${Ue})%${Be}(${Ue})%(?:${Ne.source}(${Ue}%?))?\\s*\\)`,"i");const ze={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const Ve=/[0-9a-fA-F]/.source,$e=new RegExp(`#(${Ve}{2})(${Ve}{2})(${Ve}{2})(${Ve}{2})?`),He=new RegExp(`#(${Ve})(${Ve})(${Ve})(${Ve})?`);const qe=De.source,We=Fe.source,Xe=new RegExp(`rgba?\\(\\s*(${qe}%?)${We}(${qe}%?)${We}(${qe}%?)(?:${Ne.source}(${qe}%?))?\\s*\\)`,"i");function Ye(e){return{r:Oe(e.r,0,255),g:Oe(e.g,0,255),b:Oe(e.b,0,255),a:Oe(e.a,0,1)}}function Ze(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=ze[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Re($e).exec(e))&&void 0!==t?t:Re(He).exec(e);return r?Ie(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Re(Xe).exec(e);return t?Ie(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Ye({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Je(e){return{h:Pe(e.h),s:Oe(e.s,0,100),l:Oe(e.l,0,100),a:Oe(e.a,0,1)}}function Qe(e){const t=Ze(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Ye(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Je({h:Le(e[0]),s:o[1],l:o[2],a:s})}(t):null}function et(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function tt(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Je(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Ye(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):et(t)}var rt=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=Ke(e))&&void 0!==t?t:Qe(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return tt(Object.assign(Object.assign({},r),{h:o}))};var ot=(e,t)=>"number"!=typeof t||0===t?e:rt(e,30*t);var st=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return rt(e,r)};const nt=()=>{const e=at();return it(e)},it=e=>{const t=st(e,1);return{baseColour:e,colorA:t,colorB:ot(t,Math.round(4*Math.random()-2))}},at=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class lt{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ut(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new lt(this.n,this.generation,null,i)};#p=e=>{const t=nt(),r=new ut({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Se)[this.genotype.background.style-1];return(0,Se[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Ae(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"JUSTIFY"),t=ke(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);console.log(`gridAppropriateness=${t}`),this.fitness-=e};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const ct=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ut{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ut(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class dt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ut(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();this.population=this.population.sort(((e,t)=>t.fitness-e.fitness))};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#j=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ht extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#S();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new je,this.initPopForm=new xe(this.config,this.#E,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#S=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#M(),this.#E()};#E=(e=!1)=>{e&&this.#M(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new dt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#M=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#T=()=>F` + `}createRenderRoot(){return this}}customElements.define("header-section",je);var Se={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Ee=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Me=(e,t)=>Ee(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Te=(e,t)=>(e=Math.abs(e),Ee(e=e>t?t:e,t,0,1,0)),Ce=(e,t)=>Te(e=e>=0?e/3:e,t),Ae=(e=[],t,r="OVERSET",o=3)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Te(e,n);break;case"ATTEMPT_JUSTIFY":i=Ce(e,n);break;default:i=Me(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return console.log("EXAMPLE=",e,t,r,o,"——————— mean=",i),i},ke=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const De=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Fe=/(?=[,\s])\s*(?:,\s*)?/,Ne=/\s*[,\/]\s*/,Ue=De.source,Be=Fe.source,Ge=new RegExp(`hsla?\\(\\s*(${Ue}(?:deg|rad|grad|turn)?)${Be}(${Ue})%${Be}(${Ue})%(?:${Ne.source}(${Ue}%?))?\\s*\\)`,"i");const ze={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const Ve=/[0-9a-fA-F]/.source,$e=new RegExp(`#(${Ve}{2})(${Ve}{2})(${Ve}{2})(${Ve}{2})?`),He=new RegExp(`#(${Ve})(${Ve})(${Ve})(${Ve})?`);const qe=De.source,We=Fe.source,Xe=new RegExp(`rgba?\\(\\s*(${qe}%?)${We}(${qe}%?)${We}(${qe}%?)(?:${Ne.source}(${qe}%?))?\\s*\\)`,"i");function Ye(e){return{r:Oe(e.r,0,255),g:Oe(e.g,0,255),b:Oe(e.b,0,255),a:Oe(e.a,0,1)}}function Ze(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=ze[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Re($e).exec(e))&&void 0!==t?t:Re(He).exec(e);return r?Ie(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Re(Xe).exec(e);return t?Ie(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Ye({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Je(e){return{h:Pe(e.h),s:Oe(e.s,0,100),l:Oe(e.l,0,100),a:Oe(e.a,0,1)}}function Qe(e){const t=Ze(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Ye(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Je({h:Le(e[0]),s:o[1],l:o[2],a:s})}(t):null}function et(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function tt(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Je(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Ye(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):et(t)}var rt=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=Ke(e))&&void 0!==t?t:Qe(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return tt(Object.assign(Object.assign({},r),{h:o}))};var ot=(e,t)=>"number"!=typeof t||0===t?e:rt(e,30*t);var st=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return rt(e,r)};const nt=()=>{const e=at();return it(e)},it=e=>{const t=st(e,1);return{baseColour:e,colorA:t,colorB:ot(t,Math.round(4*Math.random()-2))}},at=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class lt{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ut(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new lt(this.n,this.generation,null,i)};#p=e=>{const t=nt(),r=new ut({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Se)[this.genotype.background.style-1];return(0,Se[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Ae(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"ATTEMPT_JUSTIFY");ke(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos),console.log(`legibility=${e}`),this.fitness-=e};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${ct(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const ct=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ut{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ut(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class dt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ut(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();this.population=this.population.sort(((e,t)=>t.fitness-e.fitness))};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#j=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ht extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#S();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new je,this.initPopForm=new xe(this.config,this.#E,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#S=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#M(),this.#E()};#E=(e=!1)=>{e&&this.#M(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new dt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#M=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#T=()=>F`
`}createRenderRoot(){return this}}customElements.define("text-input",pe);const fe=(e,t=1)=>(e=parseFloat(e.replace(",",".")),isNaN(e)||null==e?t:e);class me extends re{static properties={generations:0};constructor(e,t,r,o){super(),this.params=e,this.restart=t,this.errorMessage=r,this.fields={populationSize:new pe("Population size",e.evo?e.evo.popSize:0,"pop-size",(t=>{e.evo&&(e.evo.popSize=this.#e(t.target.value,this.params.evo.popSize,2),t.target.value=e.evo.popSize,this.restart())}),["col-12","evolution-locked"]),numberOfGenerations:new pe("No. generations",e.evo?e.evo.noGen:0,"no-gen",(t=>{e.evo&&(e.evo.noGen=this.#e(t.target.value,this.params.evo.noGen,2),t.target.value=e.evo.popSize)}),["col-12","my-2"]),eliteSize:new pe("Elite size",e.evo?e.evo.eliteSize:0,"elite-size",(t=>{if(e.evo){let r=Math.round(parseInt(e.evo.popSize)/2);e.evo.eliteSize=this.#e(t.target.value,this.params.evo.eliteSize,0,r),parseInt(t.target.value)>r&&this.errorMessage.set({message:"elite size must be in the maximum half of the full population"}),t.target.value=e.evo.eliteSize}}),["col-12","my-2"]),crossoverProbability:new pe("Crossover probability",e.evo?e.evo.crossoverProb:1,"crossover-probability",(t=>{e.evo&&(e.evo.crossoverProb=this.#e(t.target.value,e.evo.crossoverProb,0,1),t.target.value=e.evo.crossoverProb)}),["col-12","my-2"]),mutationProbability:new pe("Mutation probability",e.evo?e.evo.mutationProb:0,"mutation-probability",(t=>{e.evo&&(e.evo.mutationProb=this.#e(t.target.value,e.evo.mutationProb,0,1),t.target.value=e.evo.mutationProb)}),["col-12","my-2"])}}#e=(e,t,r,o=null)=>(t!==fe(e,t)&&(null!==o&&(e=Math.min(o,e)),t=Math.max(r,e)),t);render(){return F` + `}createRenderRoot(){return this}}customElements.define("text-input",pe);const fe=(e,t=1)=>(e=parseFloat(e.replace(",",".")),isNaN(e)||null==e?t:e),me=(e,t,r)=>{const o=e[r];return e[r]=e[t],e[t]=o,e};class ye extends re{static properties={generations:0};constructor(e,t,r,o){super(),this.params=e,this.restart=t,this.errorMessage=r,this.fields={populationSize:new pe("Population size",e.evo?e.evo.popSize:0,"pop-size",(t=>{e.evo&&(e.evo.popSize=this.#e(t.target.value,this.params.evo.popSize,2),t.target.value=e.evo.popSize,this.restart())}),["col-12","evolution-locked"]),numberOfGenerations:new pe("No. generations",e.evo?e.evo.noGen:0,"no-gen",(t=>{e.evo&&(e.evo.noGen=this.#e(t.target.value,this.params.evo.noGen,2),t.target.value=e.evo.popSize)}),["col-12","my-2"]),eliteSize:new pe("Elite size",e.evo?e.evo.eliteSize:0,"elite-size",(t=>{if(e.evo){let r=Math.round(parseInt(e.evo.popSize)/2);e.evo.eliteSize=this.#e(t.target.value,this.params.evo.eliteSize,0,r),parseInt(t.target.value)>r&&this.errorMessage.set({message:"elite size must be in the maximum half of the full population"}),t.target.value=e.evo.eliteSize}}),["col-12","my-2"]),crossoverProbability:new pe("Crossover probability",e.evo?e.evo.crossoverProb:1,"crossover-probability",(t=>{e.evo&&(e.evo.crossoverProb=this.#e(t.target.value,e.evo.crossoverProb,0,1),t.target.value=e.evo.crossoverProb)}),["col-12","my-2"]),mutationProbability:new pe("Mutation probability",e.evo?e.evo.mutationProb:0,"mutation-probability",(t=>{e.evo&&(e.evo.mutationProb=this.#e(t.target.value,e.evo.mutationProb,0,1),t.target.value=e.evo.mutationProb)}),["col-12","my-2"])}}#e=(e,t,r,o=null)=>(t!==fe(e,t)&&(null!==o&&(e=Math.min(o,e)),t=Math.max(r,e)),t);render(){return F`
@@ -160,7 +160,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r) ${this.fields.mutationProbability}

-
`}createRenderRoot(){return this}}customElements.define("evo-panel",me);class ye extends re{static properties={label:"label",showLabel:!0,colorA:"#fff",colorB:"#000",onChange:()=>{}};constructor(e,t,r=null,o,s=(()=>{}),n=[]){super(),this.classList.add(...n),this.colorA=t,this.colorB=r,this.id=o,this.disable=!0,this.showLabel=null!==e,this.label=this.showLabel?e:null,this.onChange=s}render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("evo-panel",ye);class ge extends re{static properties={label:"label",showLabel:!0,colorA:"#fff",colorB:"#000",onChange:()=>{}};constructor(e,t,r=null,o,s=(()=>{}),n=[]){super(),this.classList.add(...n),this.colorA=t,this.colorB=r,this.id=o,this.disable=!0,this.showLabel=null!==e,this.label=this.showLabel?e:null,this.onChange=s}render(){return F`
${this.showLabel?F`${this.label}`:U} `:U}
-
`}createRenderRoot(){return this}}customElements.define("color-input",ye);class ge extends re{static properties={label:"label",showLabel:!0,checked:!0,onChange:()=>{}};constructor(e,t=!0,r,o=(()=>{}),s=[]){super(),this.id=r,this.label=e,this.checked=t,this.classList.add(...s),this.onChange=o}render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("color-input",ge);class ve extends re{static properties={label:"label",showLabel:!0,checked:!0,onChange:()=>{}};constructor(e,t=!0,r,o=(()=>{}),s=[]){super(),this.id=r,this.label=e,this.checked=t,this.classList.add(...s),this.onChange=o}render(){return F`
-
`}createRenderRoot(){return this}}customElements.define("checkbox-input",ge);class ve extends re{static properties={label:"label",min:0,max:100,step:1,value:50,onChange:()=>{}};constructor(e,t,r,o,s,n,i=(()=>{}),a=[]){super(),this.label=e,this.min=r,this.max=o,this.step=s,this.id=n,this.value=t,this.classList.add(...a),this.onChange=e=>{this.#t(e),i(e)},this.textField=new pe(this.label,this.value,`${this.id}-text`,(e=>{this.#t(e),i(e)}),[],`${this.id}-slider`)}#t=e=>{const t=document.getElementById(e.target.getAttribute("data-mirror"));t&&(t.value=parseInt(e.target.value))};render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("checkbox-input",ve);class be extends re{static properties={label:"label",min:0,max:100,step:1,value:50,onChange:()=>{}};constructor(e,t,r,o,s,n,i=(()=>{}),a=[]){super(),this.label=e,this.min=r,this.max=o,this.step=s,this.id=n,this.value=t,this.classList.add(...a),this.onChange=e=>{this.#t(e),i(e)},this.textField=new pe(this.label,this.value,`${this.id}-text`,(e=>{this.#t(e),i(e)}),[],`${this.id}-slider`)}#t=e=>{const t=document.getElementById(e.target.getAttribute("data-mirror"));t&&(t.value=parseInt(e.target.value))};render(){return F`
${this.textField}
-
`}createRenderRoot(){return this}}customElements.define("slider-input",ve);class be extends re{static properties={label:"label"};constructor(e=null,t=[["default",0]],r=0,o,s=(()=>{}),n=[]){super(),this.label=e,this.id=o,this.options=t,this.init=r,this.onChange=s,this.classList.add(...n)}render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("slider-input",be);class _e extends re{static properties={label:"label"};constructor(e=null,t=[["default",0]],r=0,o,s=(()=>{}),n=[]){super(),this.label=e,this.id=o,this.options=t,this.init=r,this.onChange=s,this.classList.add(...n)}render(){return F`
${this.label}
-
`}createRenderRoot(){return this}}customElements.define("dropdown-input",be);class _e extends re{static properties={label:"label",content:[],onChange:()=>{}};constructor(e,t=[],r,o=(()=>{}),s=[]){super(),this.id=r,this.content=t,null===this.content&&(this.content=[]),this.label=e,this.classList.add(...s),this.onChange=o}set=e=>{this.content=e};render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("dropdown-input",_e);class we extends re{static properties={label:"label",content:[],onChange:()=>{}};constructor(e,t=[],r,o=(()=>{}),s=[]){super(),this.id=r,this.content=t,null===this.content&&(this.content=[]),this.label=e,this.classList.add(...s),this.onChange=o}set=e=>{this.content=e};render(){return F`
${ue(this.label)}
-
`}createRenderRoot(){return this}}customElements.define("textarea-input",_e);class we extends re{static properties={params:{},changesInTypefaces:0};constructor(e,t,r,o="poster-features"){super(),this.id=o,this.params=e,this.restart=t,this.changesInTypefaces=0,this.errorMessage=r;const s=this.params?this.params.sentences:[];this.fields={content:new _e("Content The text lines are defined by pilcrows (¶)",s,"text-area-content",(e=>{const t=e.target.value.split("¶");this.params.sentences&&(this.params.sentences=t.map((e=>e.trim()))),this.restart()})),size:{width:new pe("Width",1,"size-x",this.#r,["col-8","mb-2"]),height:new pe("Height",Math.round(this.params.size.height/this.params.size.width*100)/100,"size-y",this.#r,["col-8","mb-2"]),margins:{left:new pe("Margins (ltrb)",this.params.size.margin[0],"size-mg-l",this.#r,["col-8","my-2"]),top:new pe(null,this.params.size.margin[1],"size-mg-t",this.#r,["col-4","my-2"]),right:new pe(null,this.params.size.margin[2],"size-mg-r",this.#r,["col-4"]),bottom:new pe(null,this.params.size.margin[3],"size-mg-b",this.#r,["col-4"])}},typography:{color:new ye("Main Colour",this.params.typography.color.value,null,"typography",(e=>{this.params.typography.color.value!==e.target.value&&(this.params.typography.color.value=e.target.value,this.restart())}),["col-8","my-2"]),random:new ge("Random",!0,"random-colour-typo",(async e=>{const t=document.getElementById("typography-colour-picker-1");this.params.typography.color.random=e.target.checked,t.disabled=e.target.checked,this.params.typography.lock[1]=!e.target.checked,this.restart()}),["col-4"]),weight:{min:new ve("Min",this.params.typography.weight.min,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-min",(e=>{this.params.typography.weight.min=parseInt(e.target.value),this.params.typography.weight.min>this.params.typography.weight.max&&(this.params.typography.weight.min=this.params.typography.weight.max,e.target.value=this.params.typography.weight.max),this.restart()}),["my-2"]),max:new ve("Max",this.params.typography.weight.max,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-max",(e=>{this.params.typography.weight.max=parseInt(e.target.value),this.params.typography.weight.max{this.params.typography.stretch.min=parseInt(e.target.value),this.params.typography.stretch.min>this.params.typography.stretch.max&&(this.params.typography.stretch.min=this.params.typography.stretch.max,e.target.value=this.params.typography.stretch.max),this.restart()}),["my-2"]),max:new ve("Max",this.params.typography.stretch.max,this.params.typography.stretch.min,this.params.typography.stretch.max,1,"typeface-stretch-max",(e=>{this.params.typography.stretch.max=parseInt(e.target.value),this.params.typography.stretch.max{this.params.typography.verticalAlignment=parseInt(e.target.value),this.restart()}),["mb-2"]),typefaces:new pe("Add Typeface","","typefaces-add",(e=>{const t=e.target.value,r=this.params.typography.typefaces.map((e=>e.family));if(se.availableTypefaces.includes(t)&&!r.includes(t)){for(let e of Array.from(document.fonts))if(console.log(e,e.family),e.family===t){let t=e.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e))),r=e.weight.split(" ").map((e=>parseInt(e)));const o={family:e.family,weight:r,stretch:t};this.params.typography.typefaces.push(o);break}this.restart(),this.changesInTypefaces++}else this.errorMessage.set({message:`Typeface ${t} is not available
available typefaces: ${se.availableTypefaces}`}),this.numberOfTypeface+=1}),["mb-2"])},textboxes:{align:new be("Texbox alignment",se.textAlignmentTbOptions,0,"texbox-align",(e=>{this.params.typography.textAlignment=parseInt(e.target.value),this.params.typography.lock[7]=0!==e.target.value,this.restart()}),["mb-2"]),uppercase:new ge("Uppercase",this.params.typography.uppercase,"case",(e=>{this.params.typography.uppercase=e.target.checked,this.restart()}))},background:{style:new be("Background Style",se.background.availableStyles,0,"background-style",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=document.getElementById("bk-color-check").checked;if(this.params.background.color.random=r,this.params.background.style=parseInt(e.target.value),this.params.background.lock[0]=0!==this.params.background.style,!r){const r=se.background.availableStyles[parseInt(e.target.value)][1];t.forEach(((e,t)=>{e.disabled=!(t{const t=e.target.getAttribute("data-param");this.params.background.color[t]!==e.target.value&&(this.params.background.color[t]=e.target.value),this.restart()})),random:new ge("Random",!0,"bk-color",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=e.target.checked;if(this.params.background.color.random=r,this.params.background.lock[1]=!r,r)t.forEach((e=>e.disabled=!0));else{const e=document.getElementById("background-style-list").value,r=se.background.availableStyles[parseInt(e)][1];t.forEach(((e,t)=>{t{let e=fe(document.getElementById("size-x-input").value),t=fe(document.getElementById("size-y-input").value),r=fe(document.getElementById("size-mg-l-input").value,this.params.size.margin[0]),o=fe(document.getElementById("size-mg-t-input").value,this.params.size.margin[1]),s=fe(document.getElementById("size-mg-r-input").value,this.params.size.margin[2]),n=fe(document.getElementById("size-mg-b-input").value,this.params.size.margin[3]);1!==e&&(t=Math.round(100*parseFloat(t/e))/100,e=1),this.params.size.width=se.visualisationGrid.width*e,this.params.size.height=se.visualisationGrid.width*t,this.params.size.margin=[r,o,s,n],document.getElementById("size-x-input").value=e,document.getElementById("size-y-input").value=t,document.getElementById("size-mg-l-input").value=r,document.getElementById("size-mg-t-input").value=o,document.getElementById("size-mg-r-input").value=s,document.getElementById("size-mg-b-input").value=n,this.restart(!0)};#o=(e="",t)=>F``}createRenderRoot(){return this}}customElements.define("textarea-input",we);class xe extends re{static properties={params:{},changesInTypefaces:0};constructor(e,t,r,o="poster-features"){super(),this.id=o,this.params=e,this.restart=t,this.changesInTypefaces=0,this.errorMessage=r;const s=this.params?this.params.sentences:[];this.fields={content:new we("Content The text lines are defined by pilcrows (¶)",s,"text-area-content",(e=>{const t=e.target.value.split("¶");this.params.sentences&&(this.params.sentences=t.map((e=>e.trim()))),this.restart()})),size:{width:new pe("Width",1,"size-x",this.#r,["col-8","mb-2"]),height:new pe("Height",Math.round(this.params.size.height/this.params.size.width*100)/100,"size-y",this.#r,["col-8","mb-2"]),margins:{left:new pe("Margins (ltrb)",this.params.size.margin[0],"size-mg-l",this.#r,["col-8","my-2"]),top:new pe(null,this.params.size.margin[1],"size-mg-t",this.#r,["col-4","my-2"]),right:new pe(null,this.params.size.margin[2],"size-mg-r",this.#r,["col-4"]),bottom:new pe(null,this.params.size.margin[3],"size-mg-b",this.#r,["col-4"])}},typography:{color:new ge("Main Colour",this.params.typography.color.value,null,"typography",(e=>{this.params.typography.color.value!==e.target.value&&(this.params.typography.color.value=e.target.value,this.restart())}),["col-8","my-2"]),random:new ve("Random",!0,"random-colour-typo",(async e=>{const t=document.getElementById("typography-colour-picker-1");this.params.typography.color.random=e.target.checked,t.disabled=e.target.checked,this.params.typography.lock[1]=!e.target.checked,this.restart()}),["col-4"]),weight:{min:new be("Min",this.params.typography.weight.min,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-min",(e=>{this.params.typography.weight.min=parseInt(e.target.value),this.params.typography.weight.min>this.params.typography.weight.max&&(this.params.typography.weight.min=this.params.typography.weight.max,e.target.value=this.params.typography.weight.max),this.restart()}),["my-2"]),max:new be("Max",this.params.typography.weight.max,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-max",(e=>{this.params.typography.weight.max=parseInt(e.target.value),this.params.typography.weight.max{this.params.typography.stretch.min=parseInt(e.target.value),this.params.typography.stretch.min>this.params.typography.stretch.max&&(this.params.typography.stretch.min=this.params.typography.stretch.max,e.target.value=this.params.typography.stretch.max),this.restart()}),["my-2"]),max:new be("Max",this.params.typography.stretch.max,this.params.typography.stretch.min,this.params.typography.stretch.max,1,"typeface-stretch-max",(e=>{this.params.typography.stretch.max=parseInt(e.target.value),this.params.typography.stretch.max{this.params.typography.verticalAlignment=parseInt(e.target.value),this.restart()}),["mb-2"]),typefaces:new pe("Add Typeface","","typefaces-add",(e=>{const t=e.target.value,r=this.params.typography.typefaces.map((e=>e.family));if(se.availableTypefaces.includes(t)&&!r.includes(t)){for(let e of Array.from(document.fonts))if(console.log(e,e.family),e.family===t){let t=e.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e))),r=e.weight.split(" ").map((e=>parseInt(e)));const o={family:e.family,weight:r,stretch:t};this.params.typography.typefaces.push(o);break}this.restart(),this.changesInTypefaces++}else this.errorMessage.set({message:`Typeface ${t} is not available
available typefaces: ${se.availableTypefaces}`}),this.numberOfTypeface+=1}),["mb-2"])},textboxes:{align:new _e("Texbox alignment",se.textAlignmentTbOptions,0,"texbox-align",(e=>{this.params.typography.textAlignment=parseInt(e.target.value),this.params.typography.lock[7]=0!==e.target.value,this.restart()}),["mb-2"]),uppercase:new ve("Uppercase",this.params.typography.uppercase,"case",(e=>{this.params.typography.uppercase=e.target.checked,this.restart()}))},background:{style:new _e("Background Style",se.background.availableStyles,0,"background-style",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=document.getElementById("bk-color-check").checked;if(this.params.background.color.random=r,this.params.background.style=parseInt(e.target.value),this.params.background.lock[0]=0!==this.params.background.style,!r){const r=se.background.availableStyles[parseInt(e.target.value)][1];t.forEach(((e,t)=>{e.disabled=!(t{const t=e.target.getAttribute("data-param");this.params.background.color[t]!==e.target.value&&(this.params.background.color[t]=e.target.value),this.restart()})),random:new ve("Random",!0,"bk-color",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=e.target.checked;if(this.params.background.color.random=r,this.params.background.lock[1]=!r,r)t.forEach((e=>e.disabled=!0));else{const e=document.getElementById("background-style-list").value,r=se.background.availableStyles[parseInt(e)][1];t.forEach(((e,t)=>{t{let e=fe(document.getElementById("size-x-input").value),t=fe(document.getElementById("size-y-input").value),r=fe(document.getElementById("size-mg-l-input").value,this.params.size.margin[0]),o=fe(document.getElementById("size-mg-t-input").value,this.params.size.margin[1]),s=fe(document.getElementById("size-mg-r-input").value,this.params.size.margin[2]),n=fe(document.getElementById("size-mg-b-input").value,this.params.size.margin[3]);1!==e&&(t=Math.round(100*parseFloat(t/e))/100,e=1),this.params.size.width=se.visualisationGrid.width*e,this.params.size.height=se.visualisationGrid.width*t,this.params.size.margin=[r,o,s,n],document.getElementById("size-x-input").value=e,document.getElementById("size-y-input").value=t,document.getElementById("size-mg-l-input").value=r,document.getElementById("size-mg-t-input").value=o,document.getElementById("size-mg-r-input").value=s,document.getElementById("size-mg-b-input").value=n,this.restart(!0)};#o=(e="",t)=>F`${e} × `;#s=()=>{let e=[];if(void 0!==this.params)for(let t=0;tF` @@ -282,7 +282,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r) ${ne.get()} ${this.#c()} -
`}createRenderRoot(){return this}}customElements.define("generation-panel",we);class xe extends re{static properties={evolving:!1};constructor(e,t,r,o,s){super(),this.params=e,this.restart=t,this.pop=r,this.errorMessage=o,this.initEvolution=s,this.evolving=!1,this.generationPanelID="poster-tab",this.evolutionPanelID="evolution-tab",this.refinePanelID="refine-tab",this.tabGeneration=this.#u("General",this.generationPanelID,!0),this.tabEvolution=this.#u("Evolution",this.evolutionPanelID,!1),this.tabRefine=this.#u("Refine",this.refinePanelID,!1),this.generationPanel=new we(this.params,this.restart,this.errorMessage),this.evolutionPanel=new me(this.params,this.restart,this.errorMessage,this.pop)}#u=(e,t,r=!1)=>F``;render(){return F`
@@ -308,7 +308,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r)
- ${new ge("Show grid",this.params.display.grid,"grid-display",(e=>{this.params.display.grid=e.target.checked,this.pop.toggleGrid(this.params.display.grid)}))} + ${new ve("Show grid",this.params.display.grid,"grid-display",(e=>{this.params.display.grid=e.target.checked,this.pop.toggleGrid(this.params.display.grid)}))}
${ne.get()}
@@ -322,7 +322,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r)
-
`}createRenderRoot(){return this}}customElements.define("init-form",xe);class je extends re{static properties={evolutionaryInterface:!1};constructor(e=!1){super(),this.evolutionaryInterface=e}showControls=()=>{this.evolutionaryInterface=!0};render(){return F``}createRenderRoot(){return this}}customElements.define("header-section",Se);var Ee={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Me=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Te=(e,t)=>Me(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Ce=(e,t)=>(e=Math.abs(e),Me(e=e>t?t:e,t,0,1,0)),Ae=(e,t)=>Ce(e=e>=0?e/3:e,t),ke=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Ce(e,n);break;case"ATTEMPT_JUSTIFY":i=Ae(e,n);break;default:i=Te(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},Oe=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const Fe=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Ne=/(?=[,\s])\s*(?:,\s*)?/,Ue=/\s*[,\/]\s*/,Be=Fe.source,Ge=Ne.source,ze=new RegExp(`hsla?\\(\\s*(${Be}(?:deg|rad|grad|turn)?)${Ge}(${Be})%${Ge}(${Be})%(?:${Ue.source}(${Be}%?))?\\s*\\)`,"i");const Ve={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const $e=/[0-9a-fA-F]/.source,He=new RegExp(`#(${$e}{2})(${$e}{2})(${$e}{2})(${$e}{2})?`),qe=new RegExp(`#(${$e})(${$e})(${$e})(${$e})?`);const We=Fe.source,Xe=Ne.source,Ye=new RegExp(`rgba?\\(\\s*(${We}%?)${Xe}(${We}%?)${Xe}(${We}%?)(?:${Ue.source}(${We}%?))?\\s*\\)`,"i");function Ze(e){return{r:Pe(e.r,0,255),g:Pe(e.g,0,255),b:Pe(e.b,0,255),a:Pe(e.a,0,1)}}function Je(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=Ve[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=Ie(He).exec(e))&&void 0!==t?t:Ie(qe).exec(e);return r?De(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=Ie(Ye).exec(e);return t?De(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Ze({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Qe(e){return{h:Le(e.h),s:Pe(e.s,0,100),l:Pe(e.l,0,100),a:Pe(e.a,0,1)}}function Ke(e){const t=Je(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Ze(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Qe({h:Re(e[0]),s:o[1],l:o[2],a:s})}(t):null}function tt(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function rt(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Qe(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Ze(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):tt(t)}var ot=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=et(e))&&void 0!==t?t:Ke(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return rt(Object.assign(Object.assign({},r),{h:o}))};var st=(e,t)=>"number"!=typeof t||0===t?e:ot(e,30*t);var nt=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return ot(e,r)};const it=()=>{const e=lt();return at(e)},at=e=>{const t=nt(e,1);return{baseColour:e,colorA:t,colorB:st(t,Math.round(4*Math.random()-2))}},lt=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class ct{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.constraint=0,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new dt(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new ct(this.n,this.generation,null,i)};#p=e=>{const t=it(),r=new dt({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Ee)[this.genotype.background.style-1];return(0,Ee[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=ke(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"OVERSET"),t=Oe(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);return this.constraint=e+t,{fitness:this.fitness,constraints:this.constraint}};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${ut(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${ut(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const ut=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class dt{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new dt(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class ht{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new dt(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();let e=this.population.map((e=>e.fitness)),t=this.population.map((e=>e.constraint));const r=await this.#j(e,t),o=[];for(let e=0;e{let o=this.population.length,s=Array.from(Array(o).keys());for(let n=0;ne[s[i+1]]||t[s[i]]>t[s[i+1]])&&(me(s,i,i+1),n=!1)}if(n)break;n=!0}return s};#j=async()=>{};copy=e=>JSON.parse(JSON.stringify(e));tournament=(e=2)=>{let t=[];for(let r=0;rr.fitness&&(r=t[e]);return r};#E=()=>{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class pt extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#M();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new Se,this.initPopForm=new je(this.config,this.#T,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#M=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#C(),this.#T()};#T=(e=!1)=>{e&&this.#C(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new ht(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#C=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#A=()=>F`
- `}createRenderRoot(){return this}}customElements.define("text-input",pe);const fe=(e,t=1)=>(e=parseFloat(e.replace(",",".")),isNaN(e)||null==e?t:e),me=(e,t,r)=>{const o=e[r];return e[r]=e[t],e[t]=o,e};class ye extends re{static properties={generations:0};constructor(e,t,r,o){super(),this.params=e,this.restart=t,this.errorMessage=r,this.fields={populationSize:new pe("Population size",e.evo?e.evo.popSize:0,"pop-size",(t=>{e.evo&&(e.evo.popSize=this.#e(t.target.value,this.params.evo.popSize,2),t.target.value=e.evo.popSize,this.restart())}),["col-12","evolution-locked"]),numberOfGenerations:new pe("No. generations",e.evo?e.evo.noGen:0,"no-gen",(t=>{e.evo&&(e.evo.noGen=this.#e(t.target.value,this.params.evo.noGen,2),t.target.value=e.evo.popSize)}),["col-12","my-2"]),eliteSize:new pe("Elite size",e.evo?e.evo.eliteSize:0,"elite-size",(t=>{if(e.evo){let r=Math.round(parseInt(e.evo.popSize)/2);e.evo.eliteSize=this.#e(t.target.value,this.params.evo.eliteSize,0,r),parseInt(t.target.value)>r&&this.errorMessage.set({message:"elite size must be in the maximum half of the full population"}),t.target.value=e.evo.eliteSize}}),["col-12","my-2"]),crossoverProbability:new pe("Crossover probability",e.evo?e.evo.crossoverProb:1,"crossover-probability",(t=>{e.evo&&(e.evo.crossoverProb=this.#e(t.target.value,e.evo.crossoverProb,0,1),t.target.value=e.evo.crossoverProb)}),["col-12","my-2"]),mutationProbability:new pe("Mutation probability",e.evo?e.evo.mutationProb:0,"mutation-probability",(t=>{e.evo&&(e.evo.mutationProb=this.#e(t.target.value,e.evo.mutationProb,0,1),t.target.value=e.evo.mutationProb)}),["col-12","my-2"])}}#e=(e,t,r,o=null)=>(t!==fe(e,t)&&(null!==o&&(e=Math.min(o,e)),t=Math.max(r,e)),t);render(){return F` + `}createRenderRoot(){return this}}customElements.define("text-input",pe);const fe=(e,t=1)=>(e=parseFloat(e.replace(",",".")),isNaN(e)||null==e?t:e),me=(e,t,r)=>{const o=e[r];return e[r]=e[t],e[t]=o,e},ye=(e,t=1)=>{const r=Math.random()*t;let o=0;for(let t in e)if(o+=e[t],r{e.evo&&(e.evo.popSize=this.#e(t.target.value,this.params.evo.popSize,2),t.target.value=e.evo.popSize,this.restart())}),["col-12","evolution-locked"]),numberOfGenerations:new pe("No. generations",e.evo?e.evo.noGen:0,"no-gen",(t=>{e.evo&&(e.evo.noGen=this.#e(t.target.value,this.params.evo.noGen,2),t.target.value=e.evo.popSize)}),["col-12","my-2"]),eliteSize:new pe("Elite size",e.evo?e.evo.eliteSize:0,"elite-size",(t=>{if(e.evo){let r=Math.round(parseInt(e.evo.popSize)/2);e.evo.eliteSize=this.#e(t.target.value,this.params.evo.eliteSize,0,r),parseInt(t.target.value)>r&&this.errorMessage.set({message:"elite size must be in the maximum half of the full population"}),t.target.value=e.evo.eliteSize}}),["col-12","my-2"]),crossoverProbability:new pe("Crossover probability",e.evo?e.evo.crossoverProb:1,"crossover-probability",(t=>{e.evo&&(e.evo.crossoverProb=this.#e(t.target.value,e.evo.crossoverProb,0,1),t.target.value=e.evo.crossoverProb)}),["col-12","my-2"]),mutationProbability:new pe("Mutation probability",e.evo?e.evo.mutationProb:0,"mutation-probability",(t=>{e.evo&&(e.evo.mutationProb=this.#e(t.target.value,e.evo.mutationProb,0,1),t.target.value=e.evo.mutationProb)}),["col-12","my-2"])}}#e=(e,t,r,o=null)=>(t!==fe(e,t)&&(null!==o&&(e=Math.min(o,e)),t=Math.max(r,e)),t);render(){return F`
@@ -160,7 +160,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r) ${this.fields.mutationProbability}

-
`}createRenderRoot(){return this}}customElements.define("evo-panel",ye);class ge extends re{static properties={label:"label",showLabel:!0,colorA:"#fff",colorB:"#000",onChange:()=>{}};constructor(e,t,r=null,o,s=(()=>{}),n=[]){super(),this.classList.add(...n),this.colorA=t,this.colorB=r,this.id=o,this.disable=!0,this.showLabel=null!==e,this.label=this.showLabel?e:null,this.onChange=s}render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("evo-panel",ge);class ve extends re{static properties={label:"label",showLabel:!0,colorA:"#fff",colorB:"#000",onChange:()=>{}};constructor(e,t,r=null,o,s=(()=>{}),n=[]){super(),this.classList.add(...n),this.colorA=t,this.colorB=r,this.id=o,this.disable=!0,this.showLabel=null!==e,this.label=this.showLabel?e:null,this.onChange=s}render(){return F`
${this.showLabel?F`${this.label}`:U} `:U}
-
`}createRenderRoot(){return this}}customElements.define("color-input",ge);class ve extends re{static properties={label:"label",showLabel:!0,checked:!0,onChange:()=>{}};constructor(e,t=!0,r,o=(()=>{}),s=[]){super(),this.id=r,this.label=e,this.checked=t,this.classList.add(...s),this.onChange=o}render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("color-input",ve);class be extends re{static properties={label:"label",showLabel:!0,checked:!0,onChange:()=>{}};constructor(e,t=!0,r,o=(()=>{}),s=[]){super(),this.id=r,this.label=e,this.checked=t,this.classList.add(...s),this.onChange=o}render(){return F`
-
`}createRenderRoot(){return this}}customElements.define("checkbox-input",ve);class be extends re{static properties={label:"label",min:0,max:100,step:1,value:50,onChange:()=>{}};constructor(e,t,r,o,s,n,i=(()=>{}),a=[]){super(),this.label=e,this.min=r,this.max=o,this.step=s,this.id=n,this.value=t,this.classList.add(...a),this.onChange=e=>{this.#t(e),i(e)},this.textField=new pe(this.label,this.value,`${this.id}-text`,(e=>{this.#t(e),i(e)}),[],`${this.id}-slider`)}#t=e=>{const t=document.getElementById(e.target.getAttribute("data-mirror"));t&&(t.value=parseInt(e.target.value))};render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("checkbox-input",be);class _e extends re{static properties={label:"label",min:0,max:100,step:1,value:50,onChange:()=>{}};constructor(e,t,r,o,s,n,i=(()=>{}),a=[]){super(),this.label=e,this.min=r,this.max=o,this.step=s,this.id=n,this.value=t,this.classList.add(...a),this.onChange=e=>{this.#t(e),i(e)},this.textField=new pe(this.label,this.value,`${this.id}-text`,(e=>{this.#t(e),i(e)}),[],`${this.id}-slider`)}#t=e=>{const t=document.getElementById(e.target.getAttribute("data-mirror"));t&&(t.value=parseInt(e.target.value))};render(){return F`
${this.textField}
-
`}createRenderRoot(){return this}}customElements.define("slider-input",be);class _e extends re{static properties={label:"label"};constructor(e=null,t=[["default",0]],r=0,o,s=(()=>{}),n=[]){super(),this.label=e,this.id=o,this.options=t,this.init=r,this.onChange=s,this.classList.add(...n)}render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("slider-input",_e);class we extends re{static properties={label:"label"};constructor(e=null,t=[["default",0]],r=0,o,s=(()=>{}),n=[]){super(),this.label=e,this.id=o,this.options=t,this.init=r,this.onChange=s,this.classList.add(...n)}render(){return F`
${this.label}
-
`}createRenderRoot(){return this}}customElements.define("dropdown-input",_e);class we extends re{static properties={label:"label",content:[],onChange:()=>{}};constructor(e,t=[],r,o=(()=>{}),s=[]){super(),this.id=r,this.content=t,null===this.content&&(this.content=[]),this.label=e,this.classList.add(...s),this.onChange=o}set=e=>{this.content=e};render(){return F`
+
`}createRenderRoot(){return this}}customElements.define("dropdown-input",we);class xe extends re{static properties={label:"label",content:[],onChange:()=>{}};constructor(e,t=[],r,o=(()=>{}),s=[]){super(),this.id=r,this.content=t,null===this.content&&(this.content=[]),this.label=e,this.classList.add(...s),this.onChange=o}set=e=>{this.content=e};render(){return F`
${ue(this.label)}
-
`}createRenderRoot(){return this}}customElements.define("textarea-input",we);class xe extends re{static properties={params:{},changesInTypefaces:0};constructor(e,t,r,o="poster-features"){super(),this.id=o,this.params=e,this.restart=t,this.changesInTypefaces=0,this.errorMessage=r;const s=this.params?this.params.sentences:[];this.fields={content:new we("Content The text lines are defined by pilcrows (¶)",s,"text-area-content",(e=>{const t=e.target.value.split("¶");this.params.sentences&&(this.params.sentences=t.map((e=>e.trim()))),this.restart()})),size:{width:new pe("Width",1,"size-x",this.#r,["col-8","mb-2"]),height:new pe("Height",Math.round(this.params.size.height/this.params.size.width*100)/100,"size-y",this.#r,["col-8","mb-2"]),margins:{left:new pe("Margins (ltrb)",this.params.size.margin[0],"size-mg-l",this.#r,["col-8","my-2"]),top:new pe(null,this.params.size.margin[1],"size-mg-t",this.#r,["col-4","my-2"]),right:new pe(null,this.params.size.margin[2],"size-mg-r",this.#r,["col-4"]),bottom:new pe(null,this.params.size.margin[3],"size-mg-b",this.#r,["col-4"])}},typography:{color:new ge("Main Colour",this.params.typography.color.value,null,"typography",(e=>{this.params.typography.color.value!==e.target.value&&(this.params.typography.color.value=e.target.value,this.restart())}),["col-8","my-2"]),random:new ve("Random",!0,"random-colour-typo",(async e=>{const t=document.getElementById("typography-colour-picker-1");this.params.typography.color.random=e.target.checked,t.disabled=e.target.checked,this.params.typography.lock[1]=!e.target.checked,this.restart()}),["col-4"]),weight:{min:new be("Min",this.params.typography.weight.min,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-min",(e=>{this.params.typography.weight.min=parseInt(e.target.value),this.params.typography.weight.min>this.params.typography.weight.max&&(this.params.typography.weight.min=this.params.typography.weight.max,e.target.value=this.params.typography.weight.max),this.restart()}),["my-2"]),max:new be("Max",this.params.typography.weight.max,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-max",(e=>{this.params.typography.weight.max=parseInt(e.target.value),this.params.typography.weight.max{this.params.typography.stretch.min=parseInt(e.target.value),this.params.typography.stretch.min>this.params.typography.stretch.max&&(this.params.typography.stretch.min=this.params.typography.stretch.max,e.target.value=this.params.typography.stretch.max),this.restart()}),["my-2"]),max:new be("Max",this.params.typography.stretch.max,this.params.typography.stretch.min,this.params.typography.stretch.max,1,"typeface-stretch-max",(e=>{this.params.typography.stretch.max=parseInt(e.target.value),this.params.typography.stretch.max{this.params.typography.verticalAlignment=parseInt(e.target.value),this.restart()}),["mb-2"]),typefaces:new pe("Add Typeface","","typefaces-add",(e=>{const t=e.target.value,r=this.params.typography.typefaces.map((e=>e.family));if(se.availableTypefaces.includes(t)&&!r.includes(t)){for(let e of Array.from(document.fonts))if(console.log(e,e.family),e.family===t){let t=e.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e))),r=e.weight.split(" ").map((e=>parseInt(e)));const o={family:e.family,weight:r,stretch:t};this.params.typography.typefaces.push(o);break}this.restart(),this.changesInTypefaces++}else this.errorMessage.set({message:`Typeface ${t} is not available
available typefaces: ${se.availableTypefaces}`}),this.numberOfTypeface+=1}),["mb-2"])},textboxes:{align:new _e("Texbox alignment",se.textAlignmentTbOptions,0,"texbox-align",(e=>{this.params.typography.textAlignment=parseInt(e.target.value),this.params.typography.lock[7]=0!==e.target.value,this.restart()}),["mb-2"]),uppercase:new ve("Uppercase",this.params.typography.uppercase,"case",(e=>{this.params.typography.uppercase=e.target.checked,this.restart()}))},background:{style:new _e("Background Style",se.background.availableStyles,0,"background-style",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=document.getElementById("bk-color-check").checked;if(this.params.background.color.random=r,this.params.background.style=parseInt(e.target.value),this.params.background.lock[0]=0!==this.params.background.style,!r){const r=se.background.availableStyles[parseInt(e.target.value)][1];t.forEach(((e,t)=>{e.disabled=!(t{const t=e.target.getAttribute("data-param");this.params.background.color[t]!==e.target.value&&(this.params.background.color[t]=e.target.value),this.restart()})),random:new ve("Random",!0,"bk-color",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=e.target.checked;if(this.params.background.color.random=r,this.params.background.lock[1]=!r,r)t.forEach((e=>e.disabled=!0));else{const e=document.getElementById("background-style-list").value,r=se.background.availableStyles[parseInt(e)][1];t.forEach(((e,t)=>{t{let e=fe(document.getElementById("size-x-input").value),t=fe(document.getElementById("size-y-input").value),r=fe(document.getElementById("size-mg-l-input").value,this.params.size.margin[0]),o=fe(document.getElementById("size-mg-t-input").value,this.params.size.margin[1]),s=fe(document.getElementById("size-mg-r-input").value,this.params.size.margin[2]),n=fe(document.getElementById("size-mg-b-input").value,this.params.size.margin[3]);1!==e&&(t=Math.round(100*parseFloat(t/e))/100,e=1),this.params.size.width=se.visualisationGrid.width*e,this.params.size.height=se.visualisationGrid.width*t,this.params.size.margin=[r,o,s,n],document.getElementById("size-x-input").value=e,document.getElementById("size-y-input").value=t,document.getElementById("size-mg-l-input").value=r,document.getElementById("size-mg-t-input").value=o,document.getElementById("size-mg-r-input").value=s,document.getElementById("size-mg-b-input").value=n,this.restart(!0)};#o=(e="",t)=>F``}createRenderRoot(){return this}}customElements.define("textarea-input",xe);class je extends re{static properties={params:{},changesInTypefaces:0};constructor(e,t,r,o="poster-features"){super(),this.id=o,this.params=e,this.restart=t,this.changesInTypefaces=0,this.errorMessage=r;const s=this.params?this.params.sentences:[];this.fields={content:new xe("Content The text lines are defined by pilcrows (¶)",s,"text-area-content",(e=>{const t=e.target.value.split("¶");this.params.sentences&&(this.params.sentences=t.map((e=>e.trim()))),this.restart()})),size:{width:new pe("Width",1,"size-x",this.#r,["col-8","mb-2"]),height:new pe("Height",Math.round(this.params.size.height/this.params.size.width*100)/100,"size-y",this.#r,["col-8","mb-2"]),margins:{left:new pe("Margins (ltrb)",this.params.size.margin[0],"size-mg-l",this.#r,["col-8","my-2"]),top:new pe(null,this.params.size.margin[1],"size-mg-t",this.#r,["col-4","my-2"]),right:new pe(null,this.params.size.margin[2],"size-mg-r",this.#r,["col-4"]),bottom:new pe(null,this.params.size.margin[3],"size-mg-b",this.#r,["col-4"])}},typography:{color:new ve("Main Colour",this.params.typography.color.value,null,"typography",(e=>{this.params.typography.color.value!==e.target.value&&(this.params.typography.color.value=e.target.value,this.restart())}),["col-8","my-2"]),random:new be("Random",!0,"random-colour-typo",(async e=>{const t=document.getElementById("typography-colour-picker-1");this.params.typography.color.random=e.target.checked,t.disabled=e.target.checked,this.params.typography.lock[1]=!e.target.checked,this.restart()}),["col-4"]),weight:{min:new _e("Min",this.params.typography.weight.min,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-min",(e=>{this.params.typography.weight.min=parseInt(e.target.value),this.params.typography.weight.min>this.params.typography.weight.max&&(this.params.typography.weight.min=this.params.typography.weight.max,e.target.value=this.params.typography.weight.max),this.restart()}),["my-2"]),max:new _e("Max",this.params.typography.weight.max,this.params.typography.weight.min,this.params.typography.weight.max,1,"typeface-weight-max",(e=>{this.params.typography.weight.max=parseInt(e.target.value),this.params.typography.weight.max{this.params.typography.stretch.min=parseInt(e.target.value),this.params.typography.stretch.min>this.params.typography.stretch.max&&(this.params.typography.stretch.min=this.params.typography.stretch.max,e.target.value=this.params.typography.stretch.max),this.restart()}),["my-2"]),max:new _e("Max",this.params.typography.stretch.max,this.params.typography.stretch.min,this.params.typography.stretch.max,1,"typeface-stretch-max",(e=>{this.params.typography.stretch.max=parseInt(e.target.value),this.params.typography.stretch.max{this.params.typography.verticalAlignment=parseInt(e.target.value),this.restart()}),["mb-2"]),typefaces:new pe("Add Typeface","","typefaces-add",(e=>{const t=e.target.value,r=this.params.typography.typefaces.map((e=>e.family));if(se.availableTypefaces.includes(t)&&!r.includes(t)){for(let e of Array.from(document.fonts))if(console.log(e,e.family),e.family===t){let t=e.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e))),r=e.weight.split(" ").map((e=>parseInt(e)));const o={family:e.family,weight:r,stretch:t};this.params.typography.typefaces.push(o);break}this.restart(),this.changesInTypefaces++}else this.errorMessage.set({message:`Typeface ${t} is not available
available typefaces: ${se.availableTypefaces}`}),this.numberOfTypeface+=1}),["mb-2"])},textboxes:{align:new we("Texbox alignment",se.textAlignmentTbOptions,0,"texbox-align",(e=>{this.params.typography.textAlignment=parseInt(e.target.value),this.params.typography.lock[7]=0!==e.target.value,this.restart()}),["mb-2"]),uppercase:new be("Uppercase",this.params.typography.uppercase,"case",(e=>{this.params.typography.uppercase=e.target.checked,this.restart()}))},background:{style:new we("Background Style",se.background.availableStyles,0,"background-style",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=document.getElementById("bk-color-check").checked;if(this.params.background.color.random=r,this.params.background.style=parseInt(e.target.value),this.params.background.lock[0]=0!==this.params.background.style,!r){const r=se.background.availableStyles[parseInt(e.target.value)][1];t.forEach(((e,t)=>{e.disabled=!(t{const t=e.target.getAttribute("data-param");this.params.background.color[t]!==e.target.value&&(this.params.background.color[t]=e.target.value),this.restart()})),random:new be("Random",!0,"bk-color",(e=>{const t=document.querySelectorAll(".background-colour-picker"),r=e.target.checked;if(this.params.background.color.random=r,this.params.background.lock[1]=!r,r)t.forEach((e=>e.disabled=!0));else{const e=document.getElementById("background-style-list").value,r=se.background.availableStyles[parseInt(e)][1];t.forEach(((e,t)=>{t{let e=fe(document.getElementById("size-x-input").value),t=fe(document.getElementById("size-y-input").value),r=fe(document.getElementById("size-mg-l-input").value,this.params.size.margin[0]),o=fe(document.getElementById("size-mg-t-input").value,this.params.size.margin[1]),s=fe(document.getElementById("size-mg-r-input").value,this.params.size.margin[2]),n=fe(document.getElementById("size-mg-b-input").value,this.params.size.margin[3]);1!==e&&(t=Math.round(100*parseFloat(t/e))/100,e=1),this.params.size.width=se.visualisationGrid.width*e,this.params.size.height=se.visualisationGrid.width*t,this.params.size.margin=[r,o,s,n],document.getElementById("size-x-input").value=e,document.getElementById("size-y-input").value=t,document.getElementById("size-mg-l-input").value=r,document.getElementById("size-mg-t-input").value=o,document.getElementById("size-mg-r-input").value=s,document.getElementById("size-mg-b-input").value=n,this.restart(!0)};#o=(e="",t)=>F`${e} × `;#s=()=>{let e=[];if(void 0!==this.params)for(let t=0;tF` @@ -282,7 +282,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r) ${ne.get()} ${this.#c()} -
`}createRenderRoot(){return this}}customElements.define("generation-panel",xe);class je extends re{static properties={evolving:!1};constructor(e,t,r,o,s){super(),this.params=e,this.restart=t,this.pop=r,this.errorMessage=o,this.initEvolution=s,this.evolving=!1,this.generationPanelID="poster-tab",this.evolutionPanelID="evolution-tab",this.refinePanelID="refine-tab",this.tabGeneration=this.#u("General",this.generationPanelID,!0),this.tabEvolution=this.#u("Evolution",this.evolutionPanelID,!1),this.tabRefine=this.#u("Refine",this.refinePanelID,!1),this.generationPanel=new xe(this.params,this.restart,this.errorMessage),this.evolutionPanel=new ye(this.params,this.restart,this.errorMessage,this.pop)}#u=(e,t,r=!1)=>F``;render(){return F`
@@ -308,7 +308,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r)
- ${new ve("Show grid",this.params.display.grid,"grid-display",(e=>{this.params.display.grid=e.target.checked,this.pop.toggleGrid(this.params.display.grid)}))} + ${new be("Show grid",this.params.display.grid,"grid-display",(e=>{this.params.display.grid=e.target.checked,this.pop.toggleGrid(this.params.display.grid)}))}
${ne.get()}
@@ -322,7 +322,7 @@ const ae=2;class le{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,r)
-
`}createRenderRoot(){return this}}customElements.define("init-form",je);class Se extends re{static properties={evolutionaryInterface:!1};constructor(e=!1){super(),this.evolutionaryInterface=e}showControls=()=>{this.evolutionaryInterface=!0};render(){return F`
`}createRenderRoot(){return this}}customElements.define("header-section",Ee);var Me={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Te=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Ce=(e,t)=>Te(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Ae=(e,t)=>(e=Math.abs(e),Te(e=e>t?t:e,t,0,1,0)),ke=(e,t)=>Ae(e=e>=0?e/3:e,t),Oe=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Ae(e,n);break;case"ATTEMPT_JUSTIFY":i=ke(e,n);break;default:i=Ce(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},Pe=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const Ne=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Ue=/(?=[,\s])\s*(?:,\s*)?/,Be=/\s*[,\/]\s*/,Ge=Ne.source,ze=Ue.source,Ve=new RegExp(`hsla?\\(\\s*(${Ge}(?:deg|rad|grad|turn)?)${ze}(${Ge})%${ze}(${Ge})%(?:${Be.source}(${Ge}%?))?\\s*\\)`,"i");const $e={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const He=/[0-9a-fA-F]/.source,qe=new RegExp(`#(${He}{2})(${He}{2})(${He}{2})(${He}{2})?`),We=new RegExp(`#(${He})(${He})(${He})(${He})?`);const Xe=Ne.source,Ye=Ue.source,Ze=new RegExp(`rgba?\\(\\s*(${Xe}%?)${Ye}(${Xe}%?)${Ye}(${Xe}%?)(?:${Be.source}(${Xe}%?))?\\s*\\)`,"i");function Je(e){return{r:Le(e.r,0,255),g:Le(e.g,0,255),b:Le(e.b,0,255),a:Le(e.a,0,1)}}function Qe(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=$e[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=De(qe).exec(e))&&void 0!==t?t:De(We).exec(e);return r?Fe(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=De(Ze).exec(e);return t?Fe(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Je({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Ke(e){return{h:Re(e.h),s:Le(e.s,0,100),l:Le(e.l,0,100),a:Le(e.a,0,1)}}function et(e){const t=Qe(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Je(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Ke({h:Ie(e[0]),s:o[1],l:o[2],a:s})}(t):null}function rt(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function ot(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Ke(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Je(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):rt(t)}var st=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=tt(e))&&void 0!==t?t:et(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return ot(Object.assign(Object.assign({},r),{h:o}))};var nt=(e,t)=>"number"!=typeof t||0===t?e:st(e,30*t);var it=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return st(e,r)};const at=()=>{const e=ct();return lt(e)},lt=e=>{const t=it(e,1);return{baseColour:e,colorA:t,colorB:nt(t,Math.round(4*Math.random()-2))}},ct=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class ut{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.constraint=0,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ht(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new ut(this.n,this.generation,null,i)};#p=e=>{const t=at(),r=new ht({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Me)[this.genotype.background.style-1];return(0,Me[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Oe(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"OVERSET"),t=Pe(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);return this.constraint=e+t,{fitness:this.fitness,constraints:this.constraint}};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const dt=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ht{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ht(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class pt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;re.fitness)),o=this.population.map((e=>e.constraint));const s=await this.#j(r,o);for(let r=t;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ht(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate()};#j=async(e,t,r=.45)=>{let o=this.population.length,s=Array.from(Array(o).keys());for(let n=0;ne[s[i+1]]||t[s[i]]>t[s[i+1]])&&(me(s,i,i+1),n=!1)}if(n)break;n=!0}return s};#E=async()=>{};copy=e=>JSON.parse(JSON.stringify(e));#S=(e,t=5,r=2,o=2)=>{t=te-t));let i=n.map((e=>o-2*e*(o-1)/(this.population.length-1)));const a=i.reduce(((e,t)=>e+t),0);i=i.map((e=>e/a)),i=(e=>{for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e})(i);for(let e=0;e{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ft extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#T();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new Ee,this.initPopForm=new Se(this.config,this.#C,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#T=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#A(),this.#C()};#C=(e=!1)=>{e&&this.#A(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new pt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#A=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#k=()=>F`
`:U}
- `}createRenderRoot(){return this}}customElements.define("header-section",Ee);var Me={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Te=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Ce=(e,t)=>Te(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Ae=(e,t)=>(e=Math.abs(e),Te(e=e>t?t:e,t,0,1,0)),ke=(e,t)=>Ae(e=e>=0?e/3:e,t),Oe=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Ae(e,n);break;case"ATTEMPT_JUSTIFY":i=ke(e,n);break;default:i=Ce(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},Pe=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const Ne=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Ue=/(?=[,\s])\s*(?:,\s*)?/,Be=/\s*[,\/]\s*/,Ge=Ne.source,ze=Ue.source,Ve=new RegExp(`hsla?\\(\\s*(${Ge}(?:deg|rad|grad|turn)?)${ze}(${Ge})%${ze}(${Ge})%(?:${Be.source}(${Ge}%?))?\\s*\\)`,"i");const $e={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const He=/[0-9a-fA-F]/.source,qe=new RegExp(`#(${He}{2})(${He}{2})(${He}{2})(${He}{2})?`),We=new RegExp(`#(${He})(${He})(${He})(${He})?`);const Xe=Ne.source,Ye=Ue.source,Ze=new RegExp(`rgba?\\(\\s*(${Xe}%?)${Ye}(${Xe}%?)${Ye}(${Xe}%?)(?:${Be.source}(${Xe}%?))?\\s*\\)`,"i");function Je(e){return{r:Le(e.r,0,255),g:Le(e.g,0,255),b:Le(e.b,0,255),a:Le(e.a,0,1)}}function Qe(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=$e[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=De(qe).exec(e))&&void 0!==t?t:De(We).exec(e);return r?Fe(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=De(Ze).exec(e);return t?Fe(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Je({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Ke(e){return{h:Re(e.h),s:Le(e.s,0,100),l:Le(e.l,0,100),a:Le(e.a,0,1)}}function et(e){const t=Qe(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Je(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Ke({h:Ie(e[0]),s:o[1],l:o[2],a:s})}(t):null}function rt(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function ot(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Ke(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Je(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):rt(t)}var st=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=tt(e))&&void 0!==t?t:et(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return ot(Object.assign(Object.assign({},r),{h:o}))};var nt=(e,t)=>"number"!=typeof t||0===t?e:st(e,30*t);var it=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return st(e,r)};const at=()=>{const e=ct();return lt(e)},lt=e=>{const t=it(e,1);return{baseColour:e,colorA:t,colorB:nt(t,Math.round(4*Math.random()-2))}},ct=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class ut{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.constraint=0,this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ht(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new ut(this.n,this.generation,null,i)};#p=e=>{const t=at(),r=new ht({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Me)[this.genotype.background.style-1];return(0,Me[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Oe(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"OVERSET"),t=Pe(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);return this.constraint=e+t,{fitness:this.fitness,constraints:this.constraint}};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const dt=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ht{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ht(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class pt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;re.fitness)),o=this.population.map((e=>e.constraint));const s=await this.#j(r,o);for(let r=t;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ht(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate()};#j=async(e,t,r=.45)=>{let o=this.population.length,s=Array.from(Array(o).keys());for(let n=0;ne[s[i+1]]||t[s[i]]>t[s[i+1]])&&(me(s,i,i+1),n=!1)}if(n)break;n=!0}return s};#E=async()=>{};copy=e=>JSON.parse(JSON.stringify(e));#S=(e,t=5,r=2,o=2)=>{t=te-t));let i=n.map((e=>o-2*e*(o-1)/(this.population.length-1)));const a=i.reduce(((e,t)=>e+t),0);i=i.map((e=>e/a)),i=(e=>{for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e})(i);for(let e=0;e{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ft extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#T();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new Ee,this.initPopForm=new Se(this.config,this.#C,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#T=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#A(),this.#C()};#C=(e=!1)=>{e&&this.#A(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new pt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#A=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#k=()=>F` + `}createRenderRoot(){return this}}customElements.define("header-section",Ee);var Me={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Te=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Ce=(e,t)=>Te(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Ae=(e,t)=>(e=Math.abs(e),Te(e=e>t?t:e,t,0,1,0)),ke=(e,t)=>Ae(e=e>=0?e/3:e,t),Oe=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Ae(e,n);break;case"ATTEMPT_JUSTIFY":i=ke(e,n);break;default:i=Ce(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},Pe=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const Ne=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Ue=/(?=[,\s])\s*(?:,\s*)?/,Be=/\s*[,\/]\s*/,Ge=Ne.source,ze=Ue.source,Ve=new RegExp(`hsla?\\(\\s*(${Ge}(?:deg|rad|grad|turn)?)${ze}(${Ge})%${ze}(${Ge})%(?:${Be.source}(${Ge}%?))?\\s*\\)`,"i");const $e={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const He=/[0-9a-fA-F]/.source,qe=new RegExp(`#(${He}{2})(${He}{2})(${He}{2})(${He}{2})?`),We=new RegExp(`#(${He})(${He})(${He})(${He})?`);const Xe=Ne.source,Ye=Ue.source,Ze=new RegExp(`rgba?\\(\\s*(${Xe}%?)${Ye}(${Xe}%?)${Ye}(${Xe}%?)(?:${Be.source}(${Xe}%?))?\\s*\\)`,"i");function Je(e){return{r:Le(e.r,0,255),g:Le(e.g,0,255),b:Le(e.b,0,255),a:Le(e.a,0,1)}}function Qe(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=$e[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=De(qe).exec(e))&&void 0!==t?t:De(We).exec(e);return r?Fe(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=De(Ze).exec(e);return t?Fe(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Je({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Ke(e){return{h:Re(e.h),s:Le(e.s,0,100),l:Le(e.l,0,100),a:Le(e.a,0,1)}}function et(e){const t=Qe(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Je(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Ke({h:Ie(e[0]),s:o[1],l:o[2],a:s})}(t):null}function rt(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function ot(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Ke(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Je(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):rt(t)}var st=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=tt(e))&&void 0!==t?t:et(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return ot(Object.assign(Object.assign({},r),{h:o}))};var nt=(e,t)=>"number"!=typeof t||0===t?e:st(e,30*t);var it=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return st(e,r)};const at=()=>{const e=ct();return lt(e)},lt=e=>{const t=it(e,1);return{baseColour:e,colorA:t,colorB:nt(t,Math.round(4*Math.random()-2))}},ct=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class ut{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.constraint=0,this.metrics={legibility:1,gridAppropriateness:1},this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ht(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new ut(this.n,this.generation,null,i)};#p=e=>{const t=at(),r=new ht({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Me)[this.genotype.background.style-1];return(0,Me[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Oe(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"OVERSET"),t=Pe(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);return this.constraint=e+t,this.metrics.legibility=e,this.metrics.gridAppropriateness=t,{fitness:this.fitness,constraints:this.constraint}};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const dt=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ht{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ht(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class pt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;re.fitness)),o=this.population.map((e=>e.constraint));const s=await this.#j(r,o);for(let r=t;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ht(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();await this.#E()};#j=async(e,t,r=.45)=>{let o=this.population.length,s=Array.from(Array(o).keys());for(let n=0;ne[s[i+1]]||t[s[i]]>t[s[i+1]])&&(me(s,i,i+1),n=!1)}if(n)break;n=!0}return s};#E=async()=>{this.population=this.population.sort(((e,t)=>t.fitness-t.constraint-(e.fitness-e.constraint)))};copy=e=>JSON.parse(JSON.stringify(e));#S=(e,t=5,r=2,o=2)=>{t=te-t));let i=n.map((e=>o-2*e*(o-1)/(this.population.length-1)));const a=i.reduce(((e,t)=>e+t),0);i=i.map((e=>e/a)),i=(e=>{for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e})(i);for(let e=0;e{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ft extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#T();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new Ee,this.initPopForm=new Se(this.config,this.#C,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#T=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#A(),this.#C()};#C=(e=!1)=>{e&&this.#A(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new pt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#A=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#k=()=>F`
`:U}
- `}createRenderRoot(){return this}}customElements.define("header-section",Ee);var Me={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Te=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Ce=(e,t)=>Te(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Ae=(e,t)=>(e=Math.abs(e),Te(e=e>t?t:e,t,0,1,0)),ke=(e,t)=>Ae(e=e>=0?e/3:e,t),Oe=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Ae(e,n);break;case"ATTEMPT_JUSTIFY":i=ke(e,n);break;default:i=Ce(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},Pe=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const Ne=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Ue=/(?=[,\s])\s*(?:,\s*)?/,Be=/\s*[,\/]\s*/,Ge=Ne.source,ze=Ue.source,Ve=new RegExp(`hsla?\\(\\s*(${Ge}(?:deg|rad|grad|turn)?)${ze}(${Ge})%${ze}(${Ge})%(?:${Be.source}(${Ge}%?))?\\s*\\)`,"i");const $e={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const He=/[0-9a-fA-F]/.source,qe=new RegExp(`#(${He}{2})(${He}{2})(${He}{2})(${He}{2})?`),We=new RegExp(`#(${He})(${He})(${He})(${He})?`);const Xe=Ne.source,Ye=Ue.source,Ze=new RegExp(`rgba?\\(\\s*(${Xe}%?)${Ye}(${Xe}%?)${Ye}(${Xe}%?)(?:${Be.source}(${Xe}%?))?\\s*\\)`,"i");function Je(e){return{r:Le(e.r,0,255),g:Le(e.g,0,255),b:Le(e.b,0,255),a:Le(e.a,0,1)}}function Qe(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=$e[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=De(qe).exec(e))&&void 0!==t?t:De(We).exec(e);return r?Fe(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=De(Ze).exec(e);return t?Fe(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Je({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Ke(e){return{h:Re(e.h),s:Le(e.s,0,100),l:Le(e.l,0,100),a:Le(e.a,0,1)}}function et(e){const t=Qe(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Je(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Ke({h:Ie(e[0]),s:o[1],l:o[2],a:s})}(t):null}function rt(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function ot(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Ke(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Je(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):rt(t)}var st=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=tt(e))&&void 0!==t?t:et(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return ot(Object.assign(Object.assign({},r),{h:o}))};var nt=(e,t)=>"number"!=typeof t||0===t?e:st(e,30*t);var it=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return st(e,r)};const at=()=>{const e=ct();return lt(e)},lt=e=>{const t=it(e,1);return{baseColour:e,colorA:t,colorB:nt(t,Math.round(4*Math.random()-2))}},ct=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class ut{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.constraint=0,this.metrics={legibility:1,gridAppropriateness:1},this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ht(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new ut(this.n,this.generation,null,i)};#p=e=>{const t=at(),r=new ht({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Me)[this.genotype.background.style-1];return(0,Me[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Oe(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"OVERSET"),t=Pe(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);return this.constraint=e+t,this.metrics.legibility=e,this.metrics.gridAppropriateness=t,{fitness:this.fitness,constraints:this.constraint}};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const dt=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ht{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ht(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class pt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;re.fitness)),o=this.population.map((e=>e.constraint));const s=await this.#j(r,o);for(let r=t;r{this.evolve()}),100):(console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ht(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();await this.#E()};#j=async(e,t,r=.45)=>{let o=this.population.length,s=Array.from(Array(o).keys());for(let n=0;ne[s[i+1]]||t[s[i]]>t[s[i+1]])&&(me(s,i,i+1),n=!1)}if(n)break;n=!0}return s};#E=async()=>{this.population=this.population.sort(((e,t)=>t.fitness-t.constraint-(e.fitness-e.constraint)))};copy=e=>JSON.parse(JSON.stringify(e));#S=(e,t=5,r=2,o=2)=>{t=te-t));let i=n.map((e=>o-2*e*(o-1)/(this.population.length-1)));const a=i.reduce(((e,t)=>e+t),0);i=i.map((e=>e/a)),i=(e=>{for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e})(i);for(let e=0;e{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ft extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#T();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new Ee,this.initPopForm=new Se(this.config,this.#C,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#T=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#A(),this.#C()};#C=(e=!1)=>{e&&this.#A(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new pt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#A=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#k=()=>F` + `}createRenderRoot(){return this}}customElements.define("header-section",Ee);var Me={solid:(e,t)=>{e.background(t)},gradient:(e,t,r)=>{push();const o=e.drawingContext;e.background(t);let s=e.height;const n=o.createLinearGradient(0,0,0,s);n.addColorStop(0,t),n.addColorStop(.25,t),n.addColorStop(.75,r),n.addColorStop(1,r),o.fillStyle=n,o.fillRect(0,0,e.width,s),pop()},triangle:(e,t,r)=>{push(),e.background(t),e.noStroke(),e.fill(r),e.triangle(0,0,0,e.height,e.width,e.height),pop()}};const Te=(e,t,r,o,s)=>o+(e-t)/(r-t)*(s-o),Ce=(e,t)=>Te(e=(e=e>=0?0:e)<=-t?-t:e,-t,0,1,0),Ae=(e,t)=>(e=Math.abs(e),Te(e=e>t?t:e,t,0,1,0)),ke=(e,t)=>Ae(e=e>=0?e/3:e,t),Oe=(e=[],t,r="OVERSET",o=1)=>{let s=[],n=t*o;for(let o of e){let e=t-o,i=1;switch(r){case"JUSTIFY":i=Ae(e,n);break;case"ATTEMPT_JUSTIFY":i=ke(e,n);break;default:i=Ce(e,n)}s.push(i)}const i=(e=>{const t=e.reduce(((e,t)=>e+t),0);return t/e.length||0})([...s]);return i},Pe=(e,t,r=[],o=[],s={left:0,top:0,right:0,bottom:0})=>{let n=!1,i="",a=Math.abs(s.top)+Math.abs(s.bottom);for(let e of r)a+=parseFloat(e);let l=Math.abs(s.left)+Math.abs(s.right);for(let e of o)l+=parseFloat(e);return l=Math.round(l),a=Math.round(a),a>t?(n=!0,i+=`Grid height is bigger than container (grid:${a}, container:${t}). `):ae?(n=!0,i+=`Grid width is bigger than container (grid:${l}, container:${e}). `):lvoid 0!==e))}const Ne=/[+-]?(?=\.\d|\d)\d*(?:\.\d+)?(?:[eE][+-]?\d+)?/,Ue=/(?=[,\s])\s*(?:,\s*)?/,Be=/\s*[,\/]\s*/,Ge=Ne.source,ze=Ue.source,Ve=new RegExp(`hsla?\\(\\s*(${Ge}(?:deg|rad|grad|turn)?)${ze}(${Ge})%${ze}(${Ge})%(?:${Be.source}(${Ge}%?))?\\s*\\)`,"i");const $e={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#00FFFF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000000",blanchedalmond:"#FFEBCD",blue:"#0000FF",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#00FFFF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgreen:"#006400",darkgrey:"#A9A9A9",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#FF00FF",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",goldenrod:"#DAA520",gold:"#FFD700",gray:"#808080",green:"#008000",greenyellow:"#ADFF2F",grey:"#808080",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavenderblush:"#FFF0F5",lavender:"#E6E6FA",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgreen:"#90EE90",lightgrey:"#D3D3D3",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#00FF00",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#FF00FF",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#663399",red:"#FF0000",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFFFFF",whitesmoke:"#F5F5F5",yellow:"#FFFF00",yellowgreen:"#9ACD32"};const He=/[0-9a-fA-F]/.source,qe=new RegExp(`#(${He}{2})(${He}{2})(${He}{2})(${He}{2})?`),We=new RegExp(`#(${He})(${He})(${He})(${He})?`);const Xe=Ne.source,Ye=Ue.source,Ze=new RegExp(`rgba?\\(\\s*(${Xe}%?)${Ye}(${Xe}%?)${Ye}(${Xe}%?)(?:${Be.source}(${Xe}%?))?\\s*\\)`,"i");function Je(e){return{r:Le(e.r,0,255),g:Le(e.g,0,255),b:Le(e.b,0,255),a:Le(e.a,0,1)}}function Qe(e){if("transparent"===(e=e.trim()).toLowerCase())return{r:0,g:0,b:0,a:0};const t=$e[e.toLowerCase()];let r;return t&&(e=t),null!==(r=function(e){var t;const r=null!==(t=De(qe).exec(e))&&void 0!==t?t:De(We).exec(e);return r?Fe(r):null}(e))?function(e){var t;const r=e.map((e=>(1===e.length&&(e=`${e}${e}`),parseInt(e,16)))),o=(null!==(t=r[3])&&void 0!==t?t:255)/255;return{r:r[0],g:r[1],b:r[2],a:o}}(r):null!==(r=function(e){const t=De(Ze).exec(e);return t?Fe(t):null}(e))?function(e){var t;const r=e.map(((e,t)=>{let r=parseFloat(e);return e.indexOf("%")>-1&&(r*=.01,t<3&&(r*=255)),r}));return Je({r:r[0],g:r[1],b:r[2],a:null!==(t=r[3])&&void 0!==t?t:1})}(r):null}function Ke(e){return{h:Re(e.h),s:Le(e.s,0,100),l:Le(e.l,0,100),a:Le(e.a,0,1)}}function et(e){const t=Qe(e);return t?function(e){const{r:t,g:r,b:o,a:s}=Je(e),n=t/255,i=r/255,a=o/255,l=Math.max(n,i,a),c=Math.min(n,i,a),u=l-c,d=(c+l)/2;let h=NaN,p=0;if(0!==u){switch(p=(l-d)/Math.min(d,1-d),l){case n:h=(i-a)/u+(iparseFloat(e)));let s=null!==(t=o[3])&&void 0!==t?t:1;return(null===(r=e[3])||void 0===r?void 0:r.indexOf("%"))>-1&&(s*=.01),Ke({h:Ie(e[0]),s:o[1],l:o[2],a:s})}(t):null}function rt(e){return`rgba(${(e=function(e){return{r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b),a:e.a}}(e)).r}, ${e.g}, ${e.b}, ${e.a})`}function ot(e){const t=function(e){return"number"==typeof e.h&&"number"==typeof e.s&&"number"==typeof e.l&&"number"==typeof e.a}(e)?function(e){const{h:t,s:r,l:o,a:s}=Ke(e),n=t||0,i=r/100,a=o/100;function l(e){const t=(e+n/30)%12,r=i*Math.min(a,1-a);return a-r*Math.max(-1,Math.min(t-3,9-t,1))}return{r:255*l(0),g:255*l(8),b:255*l(4),a:s}}(e):Je(e);return 1===t.a?function(e){const t=(((255&Math.round(e.r))<<16)+((255&Math.round(e.g))<<8)+(255&Math.round(e.b))).toString(16).toUpperCase();return`#${"000000".substring(t.length)}${t}`}(t):rt(t)}var st=(e,t)=>{if("number"!=typeof t||0===t)return e;const r=function(e){var t;const r=null!==(t=tt(e))&&void 0!==t?t:et(e);if(null===r)throw new Error("Invalid color string");return r}(e),o=(r.h+t)%360;return ot(Object.assign(Object.assign({},r),{h:o}))};var nt=(e,t)=>"number"!=typeof t||0===t?e:st(e,30*t);var it=(e,t)=>{if("number"!=typeof t||0===t)return e;let r=0,o=t<0?-1:1,s=0;for(;s!==t;)s+=o,r+=s%2!=0?180*o:30*o;return st(e,r)};const at=()=>{const e=ct();return lt(e)},lt=e=>{const t=it(e,1);return{baseColour:e,colorA:t,colorB:nt(t,Math.round(4*Math.random()-2))}},ct=()=>{const e=[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random())].map((e=>e.toString(16).padStart(2,"0")));return`#${e.join("")}`};class ut{#d=!1;#h=!1;constructor(e,t,r=null,o=null){this.id=`${t}-${e}`,this.n=e,this.generation=t,this.ready=!1,r=JSON.parse(JSON.stringify(r)),this.fitness=1,this.constraint=0,this.metrics={legibility:1,gridAppropriateness:1},this.sentencesLenght=[];const s=null===o?r.size.height:o.size.height;this.maxFontSize=se.typography.maxSize*s,this.minFontSize=se.typography.minSize*s,this.genotype=null===o?this.#p(r):o,this.#d=null===r||r.display.grid,this.phenotype=null,this.evaluate()}copy=()=>{const e=this.genotype.grid,t=new ht(JSON.parse(JSON.stringify(e.size)),JSON.parse(JSON.stringify(e.v)),JSON.parse(JSON.stringify(e.h)),JSON.parse(JSON.stringify(e.defaultMargins)),JSON.parse(JSON.stringify(e.gwper)),JSON.parse(JSON.stringify(e.ghper))),r=JSON.parse(JSON.stringify(this.genotype.size)),o=JSON.parse(JSON.stringify(this.genotype.textboxes));for(let e in o)o[e].color=color(this.genotype.textboxes[e].color);const s=JSON.parse(JSON.stringify(this.genotype.background));s.colors[0]=color(this.genotype.background.colors[0]),s.colors[1]=color(this.genotype.background.colors[1]);let n=[];for(let e of this.genotype.images){const t={scale:e.scale,src:e.src,x:e.x,y:e.y};n.push(t)}const i={grid:t,textboxes:o,size:r,background:s,typography:JSON.parse(JSON.stringify(this.genotype.typography)),images:n};return new ut(this.n,this.generation,null,i)};#p=e=>{const t=at(),r=new ht({width:e.size.width,height:e.size.height,margin:e.size.margin},2,e.sentences.length,JSON.parse(JSON.stringify(e.size.margin))),o=[],s=0===e.typography.verticalAlignment?Math.round(Math.random()*(se.textAlignmentOptions.length-2)+1):e.typography.verticalAlignment;for(let n in e.sentences){const i=e.sentences[n],a=Math.round(Math.random()*(e.typography.typefaces.length-1));let l=e.typography.typefaces[a].stretch;l.map((e=>isNaN(e)?100:parseInt(e))),l.length<2&&l.push(100);let c=e.typography.typefaces[a].weight,u=Math.round(Math.random()*(e.typography.weight.max-e.typography.weight.min)+e.typography.weight.min);u=Math.max(c[0],Math.min(u,c[1]));let d=Math.round(Math.random()*(e.typography.stretch.max-e.typography.stretch.min)+e.typography.stretch.min);d=Math.max(l[0],Math.min(d,l[1]));const h=se.availableTypefacesInfo[se.availableTypefaces[a]].leading;let p=Math.round(r.rows.l[0])/h;p+=Math.round(-p*se.typography.range+Math.random()*(p*se.typography.range)),p=Math.max(Math.round(e.size.height*se.typography.minSize),Math.min(Math.round(e.size.height*se.typography.maxSize),p)),r.defineRow(n,p*h,s);const f=0===e.typography.textAlignment?Math.round(Math.random()*(se.textAlignmentTbOptions.length-2)+1):e.typography.textAlignment;o.push({content:i,weight:u,"font-stretch":d,alignment:f,size:p,typeface:e.typography.typefaces[a].family,color:e.typography.color.random?t.baseColour:color(e.typography.color.value),uppercase:e.typography.uppercase})}const n=[];for(let t of e.images){const r=t.src,o=loadImage(r,(async t=>{await t.resize(0,e.size.height),t.ready=!0}));n.push({x:Math.random(),y:Math.random(),scale:Math.random(),src:o})}return{grid:r,textboxes:o,size:{width:e.size.width,height:e.size.height,margin:e.size.margin},background:{style:0===e.background.style?Math.round(1+Math.random()*(se.background.availableStyles.length-2)):e.background.style,colors:[e.background.color.random?t.colorA:color(e.background.color.valueA),e.background.color.random?t.colorB:color(e.background.color.valueB)]},typography:{verticalAlignment:s},images:n}};draw=async()=>{this.ready=!0,this.phenotype=createGraphics(this.genotype.size.width,this.genotype.size.height),this.phenotype.id=this.n;const e=Object.keys(Me)[this.genotype.background.style-1];return(0,Me[e])(this.phenotype,this.genotype.background.colors[0],this.genotype.background.colors[1]),this.ready=await this.#f(this.phenotype),await this.typeset(this.phenotype),this.#h&&(pg.textSize(10),pg.fill(0),pg.text(`${this.id}+${this.genotype.typography.verticalAlignment}+style=${this.genotype.background.style}\nfitness=${this.fitness}`,20,20)),(this.#d||this.#h)&&this.genotype.grid.display(this.phenotype),this.phenotype};evaluate=async()=>{this.phenotype=await this.draw(),this.fitness=1;const e=Oe(this.sentencesLenght,this.genotype.grid.getAvailableWidth(),"OVERSET"),t=Pe(this.genotype.size.width,this.genotype.size.height,this.genotype.grid.rows.l,this.genotype.grid.columns.l,this.genotype.grid.marginsPos);return this.constraint=e+t,this.metrics.legibility=e,this.metrics.gridAppropriateness=t,{fitness:this.fitness,constraints:this.constraint}};typeset=async e=>{this.sentencesLenght=[],e.push(),e.translate(e.width/2,e.height/2);const t=e.drawingContext;for(let r in this.genotype.textboxes){const o=this.genotype.textboxes[r];let s=o.alignment,n=LEFT;2===s?n=CENTER:3===s&&(n=RIGHT),e.textAlign(n,BASELINE);let i=this.genotype.grid.col(s-1,!1),a=this.genotype.grid.row(parseInt(r)+1,!1);e.fill(o.color),t.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`,drawingContext.font=`${o.weight} ${dt(o["font-stretch"])} ${o.size}px ${o.typeface}`;let l=!0===o.uppercase?o.content.toUpperCase():o.content;e.text(l,i,a);const c=t.measureText(l).width;this.sentencesLenght.push(c)}e.pop()};#f=async e=>{let t=!0;for(let r of this.genotype.images)if(void 0!==r.src&&r.src.hasOwnProperty("ready")){if(r.src.ready){let t=e.width*r.x,o=e.height*r.y;e.imageMode(CENTER),e.image(r.src,t,o,r.src.width*r.scale,r.src.height*r.scale)}}else t=!1;return t};toggleGrid=(e=null)=>{null===e&&(e=!this.#d),this.#d=e,this.draw()}}const dt=e=>e>-10&&e<=50?"ultra-condensed":e>50&&e<=62.5?"extra-condensed":e>62.5&&e<=75?"condensed":e>75&&e<=87.5?"semi-condensed":e>87.5&&e<=100?"normal":e>100&&e<=112.5?"semi-expanded":e>112.5&&e<=125?"expanded":e>125&&e<=150?"extra-expanded":"ultra-expanded";class ht{constructor(e,t=12,r=24,o,s=.03,n=null){null===n&&(n=s),this.pos=createVector(e.width/2,e.height/2),this.size=JSON.parse(JSON.stringify(e)),this.defaultMargins=o,this.v=t,this.h=r,this.gwper=s,this.ghper=n,this.gapw=this.size.width*this.gwper,this.gaph=this.size.height*this.ghper,this.regular=!0,this.verticalSpace=[],this.marginsPos={},this.columns={},this.columns.y={},this.columns.center={},this.columns.gap={},this.rows={},this.rows.x={},this.rows.center={},this.rows.gap={},this.def()}export=()=>({pos:[this.pos.x,this.pos.y,this.pos.z],size:this.size,defaultMargins:this.defaultMargins,v:this.v,h:this.h,gapw:this.gapw,gaph:this.gaph,marginsPos:this.marginsPos,columns:this.columns,rows:this.rows});copy=()=>new ht(JSON.parse(JSON.stringify(this.size)),JSON.parse(JSON.stringify(this.v)),JSON.parse(JSON.stringify(this.h)),JSON.parse(JSON.stringify(this.defaultMargins)),JSON.parse(JSON.stringify(this.gwper)),JSON.parse(JSON.stringify(this.ghper)));updateMarginsBasedOnSize=(e=0,t=1,r,o=this.size.height)=>{const s=t*r;let n=this.size.height-s;0===e&&(n/=2),(0===e||1===e)&&this.size.margin[1]{0===e&&(t/=2),(0===e||1===e)&&this.size.margin[1]{this.size.margin=this.defaultMargins,this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height,this.def()};def=()=>{this.#m(),this.#y(),this.#g()};update=(e=null,t=null)=>{null!==e&&e!==this.v&&console.log(`grid updated from ${this.v} to ${e}`)};defineRow=(e,t,r)=>{this.regular=!1;const o=this.rows.l[e];this.rows.l[e]=t;let s=this.rows.l[e]-o;s=2===r?s/2:s,this.marginsPos.bottom,this.size.height,r<=2&&(this.size.margin[3]=(this.marginsPos.bottom-s)/this.size.height),r>=2&&(this.size.margin[1]=(this.marginsPos.top-s)/this.size.height),this.def()};#m=()=>{this.marginsPos.left=this.size.margin[0]*this.size.width,this.marginsPos.top=this.size.margin[1]*this.size.height,this.marginsPos.right=this.size.margin[2]*this.size.width,this.marginsPos.bottom=this.size.margin[3]*this.size.height};getSpace=()=>{const e=this.rows.l.reduce(((e,t)=>e+t),0)/this.rows.l.length;return{centre:{col:this.columns.l,row:e},gap:{col:this.columns.l-this.gapw/2,row:e-this.gaph/2}}};#y=()=>{this.columns.y.top=-this.size.height/2+this.marginsPos.top,this.columns.y.bottom=this.size.height/2-this.marginsPos.bottom;const e=(this.size.width-(this.marginsPos.left+this.marginsPos.right))/this.v;let t=[];for(let r=0;r0&&t{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const t=e;this.rows.l=t;let r=-this.size.height/2+this.marginsPos.top;for(let e=0;e0&&e{this.rows.x.left=-this.size.width/2+this.marginsPos.left,this.rows.x.right=this.size.width/2-this.marginsPos.right;const e=(this.size.height-(this.marginsPos.top+this.marginsPos.bottom))/this.h;if(null===this.verticalSpace||this.verticalSpace.length!==this.h||this.regular){this.verticalSpace=[];for(let t=0;tthis.h?r+=parseInt(this.rows.l[e-1]):r+=parseInt(this.rows.l[e]),this.rows.gap[e]={},e>0&&ee=0?t?this.columns.center[e]:this.columns.gap[e].right:(console.error(`this col dod not exists in grid. requested number ${e}`),0);row=(e,t=!1)=>e=0?t?this.rows.center[e]:this.rows.gap[e].top:(console.error(`this row do not exists in grid. requested number ${e}`),0);getAvailableWidth=(e=!0)=>{if(e){return this.size.width-this.size.width*this.size.margin[0]-this.size.width*this.size.margin[2]}return this.size.width};width=(e,t=!1,r=!1)=>e0?t||e===this.v?this.columns.l*e:r?this.columns.l*e-this.gapw/2:this.columns.l*e-this.gapw:(console.error(`side bigger than grid. requested side ${e}`),0);height=(e,t=!1,r=!1)=>e0?t||e===this.h?this.rows.l*e:r?this.rows.l*e-this.gaph/2:this.rows.l*e-this.gaph:(console.error(`side bigger than row grid. requested side ${e}`),0);display=(e,t=!0,r=!0,o=!0)=>{e.push(),e.translate(this.size.width/2,this.size.height/2),r&&this.#v(e),o&&this.#b(e),t&&this.#_(e),e.pop()};#_=(e,t="#0000ff")=>{e.push(),e.stroke(t),e.rectMode(CORNER),e.noFill(),e.rect(this.rows.x.left,this.columns.y.top,this.size.width-(this.marginsPos.left+this.marginsPos.right),this.size.height-(this.marginsPos.top+this.marginsPos.bottom)),e.pop()};#v=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.columns.center)){const r=this.columns.center[t];e.line(r,this.columns.y.top,r,this.columns.y.bottom)}e.stroke(r);for(let t of Object.keys(this.columns.gap)){const r=this.columns.gap[t];"0"!==t&&t!==""+this.v&&(e.line(r.left,this.columns.y.top,r.left,this.columns.y.bottom),e.line(r.right,this.columns.y.top,r.right,this.columns.y.bottom))}e.pop()};#b=(e,t="#ff00ff",r="#009800")=>{e.push(),e.stroke(t);for(let t of Object.keys(this.rows.center)){const r=this.rows.center[t];e.line(this.rows.x.left,r,this.rows.x.right,r)}e.stroke(r);for(let t of Object.keys(this.rows.gap)){t=parseInt(t);const r=this.rows.gap[t];0!==t&&t!==this.h&&(e.text(t,this.rows.x.left+this.rows.x.right/2,r.top),e.line(this.rows.x.left,r.top,this.rows.x.right,r.top),e.line(this.rows.x.left,r.bottom,this.rows.x.right,r.bottom))}e.pop()}}class pt{#w;constructor(e){this.size=e.evo.popSize,this.params=e,this.population=[],this.generations=0,this.ready=!1,this.evolving=!1,this.pause=!1,this.#w=[],this.updated=!0,this.log={config:this.params,generations:[]}}initialisation=async()=>{this.updated=!0,this.generations=0,this.#x();for(let e=0;ee.typeface));for(const e of r)-1===this.#w.indexOf(e)&&this.#w.push(e)}this.evaluate(),this.updated=!0};evolve=async()=>{await this.#x(),document.getElementById("generation-number").textContent=this.generations;const e=[],t=parseInt(this.params.evo.eliteSize);for(let r=0;re.fitness)),o=this.population.map((e=>e.constraint));const s=await this.#j(r,o);for(let r=t;r{this.evolve()}),100):(this.evolving=!1,console.group("stats"),console.log(this.log),console.groupEnd())};uniformCrossover=(e,t)=>{const r=e.copy();t=t.copy(),Math.random()>.5&&(r.genotype.typography.verticalAlignment=t.genotype.typography.verticalAlignment);for(const e in r.genotype.textboxes)Math.random()>.5&&(r.genotype.textboxes[e]=t.genotype.textboxes[e]);r.genotype.grid=new ht(this.params.size,2,this.params.sentences.length,this.params.size.margin);for(const e in r.genotype.textboxes){const t=r.genotype.textboxes[e],o=se.availableTypefacesInfo[t.typeface].leading;r.genotype.grid.defineRow(e,t.size*o,r.genotype.typography.verticalAlignment)}if(Math.random()>.5&&(r.genotype.background.style=t.genotype.background.style),Math.random()>.5){r.genotype.background.colors[0]=t.genotype.background.colors[0],r.genotype.background.colors[1]=t.genotype.background.colors[1];for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=t.genotype.textboxes[e].color}else{let t=e.genotype.textboxes[0].color,o=t.levels?color(t.levels[0],t.levels[1],t.levels[2]):color(t);for(const e in r.genotype.textboxes)r.genotype.textboxes[e].color=o}for(const e in r.genotype.images)Math.random()>.5&&(r.genotype.images[e]=t.genotype.images[e]);return r};mutate=e=>{let t=this.params.evo.mutationProb;if(Math.random()1){const e=Math.round(Math.random()*(this.params.typography.typefaces.length-1));n=e,s.typeface=this.params.typography.typefaces[e].family}if(Math.random()<2*t){let t=Math.round(s.size+-5+5*Math.random());t=Math.min(Math.max(t,e.minFontSize),e.maxFontSize),s.size=t,r=!0}if(Math.random(){for(let t of this.population)t.toggleGrid(e);this.updated=!0};evaluate=async()=>{for(let e of this.population)await e.evaluate();await this.#E()};#j=async(e,t,r=.45)=>{let o=this.population.length,s=Array.from(Array(o).keys());for(let n=0;ne[s[i+1]]||t[s[i]]>t[s[i+1]])&&(me(s,i,i+1),n=!1)}if(n)break;n=!0}return s};#E=async()=>{this.population=this.population.sort(((e,t)=>t.fitness-t.constraint-(e.fitness-e.constraint)))};copy=e=>JSON.parse(JSON.stringify(e));#S=(e,t=5,r=2,o=2)=>{t=te-t));let i=n.map((e=>o-2*e*(o-1)/(this.population.length-1)));const a=i.reduce(((e,t)=>e+t),0);i=i.map((e=>e/a)),i=(e=>{for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e})(i);for(let e=0;e{for(let e of this.#w){if(!document.fonts.check(`12px ${e}`))return!1}return!0};#x=()=>{document.querySelectorAll("canvas:not(#defaultCanvas0)").forEach((e=>{e.remove()}))};draw=async()=>{this.updated=!1;const e=this.population.length{for(let e in this.population){const t=this.population[e];save(t.phenotype,`${Date.now()}-${this.generations}-${e}`)}}}window.preload=()=>{},window.setup=()=>{window.app=document.createElement("app-evo"),document.querySelector("main").appendChild(app),noCanvas(),noLoop(),frameRate(25)},window.draw=()=>{if(window.app.screen<3)return null;window.app.population.updated&&(push(),background(window.app.backgroundColor),window.app.population.draw(),pop())},window.windowResized=()=>{if(window.app.screen<2)return null},window.keyPressed=()=>{if(window.app.screen<2)return null};class ft extends re{static properties={screen:0,results:{},evolving:!1};constructor(){super(),this.results=null,this.screen=0,this.evolving=!1;const e=this.#T();this.config={evo:{popSize:se.evolution.popSize,noGen:se.evolution.noGen,crossoverProb:se.evolution.crossoverProb,mutationProb:se.evolution.mutationProb,eliteSize:se.evolution.eliteSize},size:{width:se.visualisationGrid.width,height:se.visualisationGrid.height,margin:se.visualisationGrid.posterMargins},images:[],sentences:null,background:{style:0,color:{random:!0,valueA:se.background.defaultColors[0],valueB:se.background.defaultColors[1]},lock:[!1,!1]},typography:{verticalAlignment:0,color:{random:!0,value:se.typography.defaultColor},textAlignment:0,typefaces:e.typefaces,weight:e.weight,stretch:e.stretch,uppercase:!1,texboxAlignment:0,lock:[!1,!1,!1,!1,!1,!1,!1,!1]},display:{grid:!0}},this.population=null,this.errorMessage=new he,this.resultsContainer=new de,this.inputForm=new ie(this.analyse,this.resultsContainer,this.errorMessage),this.header=new Ee,this.initPopForm=new Se(this.config,this.#C,this.population,this.errorMessage),document.getElementById("defaultCanvas0").style.visibility="visible",this.backgroundColor=getComputedStyle(document.documentElement).getPropertyValue("--main-bg-color")}#T=()=>{const e={typefaces:[],weight:{min:Number.MAX_VALUE,max:Number.MIN_VALUE},stretch:{min:Number.MAX_VALUE,max:Number.MIN_VALUE}};for(let t of Array.from(document.fonts))if(se.availableTypefaces.includes(t.family)){let r=t.stretch.replaceAll("%","").split(" ").map((e=>parseInt(e)));e.stretch.min>r[0]&&(e.stretch.min=r[0]),e.stretch.maxparseInt(e)));e.weight.min>o[0]&&(e.weight.min=o[0]),e.weight.max{const e=this.inputForm.data();let t=`/${e.shouldDivide?"text":`lines/${e.delimiter}`}/${e.lang}/${e.textContent}`;fetch(t).then((e=>e.json())).then((e=>{this.results=e,!1===e.success&&this.errorMessage.set(e),this.resultsContainer.set(this.results),this.inputForm.dis(),this.screen=1})).catch((e=>{this.errorMessage.set(e)}))};setupEvolution=e=>{e.preventDefault(),this.screen=2,this.config.images=Array.from(document.querySelectorAll("#input-images img")),this.#A(),this.#C()};#C=(e=!1)=>{e&&this.#A(),background(this.backgroundColor),null!==this.results?(null==this.config.sentences&&(this.config.sentences=this.results.sentences),this.population=new pt(this.config),this.population.initialisation(),this.initPopForm.pop=this.population,this.screen=3,this.header.showControls()):this.errorMessage.set({msg:"text input not defined. Not possible to init population"})};#A=()=>{let e=se.visiblePosters,t=Math.ceil(e/Math.floor(windowWidth/this.config.size.width));t*=this.config.size.height+2*se.visualisationGrid.marginY,createCanvas(windowWidth,t),loop()};#k=()=>F`