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ApB9H,EAAU8H,EAE1B,CAEO,SAASsM,GAAqBtM,GACjC,MAAMzqC,EAAM2iC,EAAU8H,GAEtB,MAD4B,iBAAV,GAA8B,OAARzqC,CAE5C,CAEO,SAASg3C,GAAwBvM,GAEpC,YADgCniD,IAApBq6C,EAAU8H,EAE1B,CAEO,SAASwM,KAEZ,OAAOxU,EADKJ,EAAKY,OAErB,CAEO,SAASiU,GAAsBzM,EAAM+J,GACxC,MAAM78B,EAAMgrB,EAAU6R,GAChBvQ,EAAsB,iBAAV,EAAqBtsB,OAAMrvB,EAC7Cm7C,IAAqB0T,WAAW1M,EAAO,EAAO9E,EAAW1B,GAAO,EAAIA,GAAK,GACzER,IAAqB4R,SAAS5K,EAAO,GAAQ9E,EAAW1B,IAAM,EAClE,CAEO,SAASmT,GAAsB3M,GAElC,OAAOhI,EADKgI,EAEhB,CAEO,SAAS4M,GAA4B5M,GAExC,OAAOhI,EADKE,EAAU8H,GAE1B,CAEO,SAAS6M,GAA2B7M,GACvCzG,EAAWyG,EACf,CAEO,SAAS8M,GAAsB9M,EAAM+J,GACxC,MAAM78B,EAAMgrB,EAAU6R,GAChBvQ,EAAsB,iBAAV,EAAqBtsB,OAAMrvB,EAC7C,IAAI2+C,EAAOtB,EAAW1B,GAAO,EAAIqB,EAAkBrB,EAAK5B,EAAKgF,kBAAmBhF,EAAK8F,oBACjFjB,EAAO/D,EACXM,IAAqB4R,SAAS5K,EAAO,EAAOvD,GAAM,GAClDzD,IAAqB4R,SAAS5K,EAAO,EAAOxD,GAAM,EACtD,CAEO,SAASuQ,GAAsB/M,EAAM+J,GAExC,OAAO/R,EADKuD,EAAmByE,EAAM+J,GAEzC,CAEO,SAASiD,GAAiBhN,EAAM+J,GACnC,MAAM,IAAItlC,MAAM82B,EAAmByE,EAAM+J,GAC7C,C","sources":["webpack://ch.enlightware.gamecreator/./src/apps/common/browser-check-ui.ts","webpack://ch.enlightware.gamecreator/./src/apps/common/browser-check.ts","webpack://ch.enlightware.gamecreator/./src/apps/common/workspace.ts","webpack://ch.enlightware.gamecreator/./src/blocks/common/variable/variable-render.ts","webpack://ch.enlightware.gamecreator/./src/blocks/conditions/comparison/comparison-block.ts","webpack://ch.enlightware.gamecreator/./src/blocks/conditions/input/input-block.ts","webpack://ch.enlightware.gamecreator/./src/blocks/generic/binary-arithmetic/binary-arithmetic-block.ts","webpack://ch.enlightware.gamecreator/./src/game/game-core.ts","webpack://ch.enlightware.gamecreator/./src/math/convex-poly.ts","webpack://ch.enlightware.gamecreator/./src/math/helpers.ts","webpack://ch.enlightware.gamecreator/./src/math/linalg.ts","webpack://ch.enlightware.gamecreator/./src/network/api-uuid.ts","webpack://ch.enlightware.gamecreator/./src/runtime/runtime-core.ts","webpack://ch.enlightware.gamecreator/./src/storage/rust-db-storage.ts","webpack://ch.enlightware.gamecreator/./src/utils/array-types.ts","webpack://ch.enlightware.gamecreator/./src/utils/flags.ts","webpack://ch.enlightware.gamecreator/./src/utils/image.ts","webpack://ch.enlightware.gamecreator/./src/utils/render.ts","webpack://ch.enlightware.gamecreator/./src/app-core-web/pkg/index.js","webpack://ch.enlightware.gamecreator/./src/app-core-web/pkg/index_bg.js"],"sourcesContent":["/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { getPropByNameOrNull } from 'utils/types';\nimport { reportLog, Analytics } from './analytics';\nimport { fatalBox } from 'mdcext/message-box/message-box';\nimport { qsT, qsTr } from 'translator/translator';\nimport { checkUserAgent, SupportedBrowsers } from './browser-check';\nimport { openDB } from 'idb';\n\nasync function isIndexDBAvailable() {\n\ttry {\n\t\tawait openDB('inPrivate');\n\t\treturn true;\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n\nexport async function checkBrowserAndWarnUser(requiresIndexDB: boolean, allowOnlySafariOnIOS = true) {\n\tconst { ok, isSupported, browserName, browserVersion, requiredVersion, downloadLink, osName } = checkUserAgent();\n\tconst isIDB = !requiresIndexDB || await isIndexDBAvailable();\n\tif (!(ok && isIDB)) {\n\t\treportLog('unsupportedBrowser', [\n\t\t\tAnalytics.appInfo,\n\t\t\twindow.location.href,\n\t\t\tisIDB ? 'browser or version': 'indexDB not available'\n\t\t]);\n\t} else {\n\t\treturn;\n\t}\n\n\tconst browserSupported = isSupported;\n\tconst title = !isIDB ?\n\t\tqsT('IndexDB not available') :\n\t\t(!browserSupported ? qsT('Your browser version is not supported') : qsT('Your browser is not supported'))\n\t;\n\n\tlet text: string;\n\tif (!isIDB) {\n\t\ttext = '<p>' + qsT('Your browser does not support IndexDB, maybe you are using Firefox in private mode. If so, restart in normal mode.') + '</p>';\n\t} else if (osName === 'iOS' && browserName !== 'Safari' && allowOnlySafariOnIOS) {\n\t\ttext = '<p>' + qsTr('You are running %1 version %2, but only Safari is supported on iOS. Please use Safari.').args(browserName, browserVersion) + '</p>';\n\t} else {\n\t\tconst textRunning = qsTr('You are running %1 version %2').args(browserName, browserVersion);\n\t\tconst textUpgrade1 = qsTr(' but only %1 versions %2 are supported.').args(browserName, requiredVersion);\n\t\tconst textUpgrade2 = qsTr('You can download a recent %1 from %2here%3.').args(browserName, `<a href=\"${downloadLink}\">`, '</a>');\n\t\tconst textNew1 = qsT('.');\n\t\tconst textNew2 = qsT('You can download one of the recent and supported browsers here:');\n\t\tif (browserSupported) {\n\t\t\ttext = '<p>' + textRunning + textUpgrade1 + '</p><p>' + textUpgrade2 + '</p>';\n\t\t} else {\n\t\t\ttext = '<p>' + textRunning + textNew1 + '</p><p>' + textNew2 + '<ul><li>'\n\t\t\t\t+ (['Chrome', 'Firefox'].map((b) => `<a href=\"${getPropByNameOrNull(SupportedBrowsers, b.toLowerCase())}\">${b}</a>`).join('</li><li>'))\n\t\t\t\t+ '</li></ul></p>';\n\t\t}\n\t}\n\tconst image = '<img src=\"/error/404-295w.jpg\" style=\"width:min(20vw, 30vh);transform:scaleX(-1);float:right;margin-left:8px;margin-bottom:8px;\"/>';\n\ttext = `${image}<h4 style=\"margin-top: 0px\">${title}</h4>${text}`;\n\tawait fatalBox(text);\n\treportLog('checkBrowserIgnored');\n}\n\n","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { getPropByNameOrNull, isRunningInJest } from 'utils/types';\nimport Bowser from 'bowser';\n\n// See this page for the format of the following requirement list: https://www.npmjs.com/package/bowser#filtering-browsers\n// See this page for the browser (short) names: https://github.com/lancedikson/bowser/blob/HEAD/src/constants.js\nconst SupportedBrowsersVersions = {\n\tchrome: '>=96',\n\tedge: '>=96',\n\tfirefox: '>=105',\n\tsafari: '>=15',\n\t// eslint-disable-next-line camelcase\n\tsamsung_internet: '>=17'\n};\n\nexport const SupportedBrowsers = {\n\tchrome: 'https://www.google.com/chrome/',\n\tfirefox: 'https://www.mozilla.org/firefox/new/',\n\tsafari: 'https://support.apple.com/downloads/safari',\n\tedge: 'https://www.microsoft.com/edge',\n\t// eslint-disable-next-line camelcase\n\tsamsung_internet: 'https://play.google.com/store/apps/details?id=com.sec.android.app.sbrowser'\n};\n\nlet browserOk: boolean | null = false;\nlet appleDevice: boolean | null = null;\nlet browserNameLowercase: string | null = null;\n\nexport function checkUserAgent(userAgent?: string) {\n\tuserAgent = userAgent || window.navigator.userAgent;\n\tconst browser = Bowser.getParser(userAgent);\n\tconst browserName = browser.getBrowserName();\n\tconst browserVersion = browser.getBrowserVersion();\n\tconst osName = browser.getOSName();\n\tconsole.debug(`Identified browser as: \"${browserName} ${browserVersion}\" running on \"${osName} ${browser.getOSVersion()}\", ${browser.getPlatformType()}`);\n\tconst browserLower = browserName.toLowerCase();\n\tconst versionBounds = getPropByNameOrNull(SupportedBrowsersVersions, browserLower);\n\tconst downloadLink = getPropByNameOrNull(SupportedBrowsers, browserLower);\n\tconst ok = browser.satisfies(SupportedBrowsersVersions) === true;\n\t// work around what seems to be a bug in Bowser\n\t// see: https://github.com/lancedikson/bowser/issues/434\n\tconst isIOSNotSafari = osName === 'iOS' && browserName !== 'Safari';\n\tbrowserOk = ok && !isIOSNotSafari;\n\tappleDevice = osName === 'iOS' || osName === 'macOS';\n\tbrowserNameLowercase = browserLower;\n\treturn {\n\t\tok: browserOk,\n\t\tbrowserVersion,\n\t\tbrowserName,\n\t\tdownloadLink,\n\t\tisSupported: downloadLink !== null,\n\t\trequiredVersion: versionBounds,\n\t\tosName\n\t};\n}\n\nexport function isBrowserOk() {\n\treturn browserOk;\n}\n\nexport function isAppleDevice() {\n\treturn appleDevice;\n}\n\nexport function getBrowserNameLowercase() {\n\treturn browserNameLowercase;\n}\n\nasync function checkWebPFeature(feature: 'lossy' | 'lossless' | 'alpha' | 'animation') {\n\tif (isRunningInJest()) {\n\t\treturn true;\n\t}\n\tconst testImages = {\n\t\tlossy: 'UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA',\n\t\tlossless: 'UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==',\n\t\talpha: 'UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==',\n\t\tanimation: 'UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA'\n\t};\n\tconst img = new Image();\n\treturn new Promise<boolean>((resolve) => {\n\t\timg.onload = function () {\n\t\t\tconst result = (img.width > 0) && (img.height > 0);\n\t\t\tresolve(result);\n\t\t};\n\t\timg.onerror = function () {\n\t\t\tresolve(false);\n\t\t};\n\t\timg.src = 'data:image/webp;base64,' + testImages[feature];\n\t});\n}\n\nlet webPSupported: undefined | Promise<boolean>;\nexport async function isWebPSupported() {\n\tif (webPSupported === undefined) {\n\t\twebPSupported = Promise.all([\n\t\t\tcheckWebPFeature('lossless'),\n\t\t\tcheckWebPFeature('lossy'),\n\t\t\tcheckWebPFeature('alpha')\n\t\t]).then(([lossless, lossy, alpha]) => { return lossless && lossy && alpha; })\n\t}\n\treturn await webPSupported;\n}\n","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport * as UuidGenerator from 'utils/uuid-generator';\nimport { Parameters, getLoggedInUserInfo } from './parameters';\n\nconst DeprecatedWorkspaceKeys = ['gc-current-workspace-id', 'gc-primary-workspace-id'];\nconst DeviceWorkspaceIdKey = 'gc-device-workspace-id';\n\nconst FirstUseKey = 'gc-first-use';\nconst FirstUseTimestamp = localStorage.getItem(FirstUseKey);\nif (!FirstUseTimestamp) {\n\tlocalStorage.setItem(FirstUseKey, new Date().toISOString());\n}\nexport const isFirstUse = FirstUseTimestamp === null && localStorage.getItem(DeviceWorkspaceIdKey) === null;\n\n// Generate UUID namespaces.\nconst WorkspaceNamespace = UuidGenerator.createCurrentLocationBasedNamespace('_workspace');\n// Primary workspace id\n\nexport function getDeviceWorkspaceId() {\n\tlet ws = localStorage.getItem(DeviceWorkspaceIdKey);\n\tif (!ws) { // try deprecated keys and migrate to the new key\n\t\tfor (const deprecatedWorkspaceIdKey of DeprecatedWorkspaceKeys) {\n\t\t\tws = localStorage.getItem(deprecatedWorkspaceIdKey);\n\t\t\tif (ws) {\n\t\t\t\tlocalStorage.removeItem(deprecatedWorkspaceIdKey);\n\t\t\t}\n\t\t}\n\t\tif (ws) {\n\t\t\tlocalStorage.setItem(DeviceWorkspaceIdKey, ws);\n\t\t}\n\t}\n\treturn ws;\n}\n\nexport function createNewWorkspace() {\n\treturn UuidGenerator.createCurrentHostBasedUuid(WorkspaceNamespace).toString();\n}\n\nexport function getWorkspaceId() {\n\tconst overriddenPrimaryWorkspace = Parameters.primaryWorkspaceIdFromUrl;\n\tif (overriddenPrimaryWorkspace) {\n\t\treturn overriddenPrimaryWorkspace;\n\t}\n\tconst loggedInUserInfo = getLoggedInUserInfo();\n\tif (loggedInUserInfo?.primaryWs) {\n\t\treturn loggedInUserInfo.primaryWs;\n\t}\n\tconst deviceWorkspaceId = getDeviceWorkspaceId();\n\tif (deviceWorkspaceId) {\n\t\treturn deviceWorkspaceId;\n\t} else {\n\t\t// generate a new one\n\t\treturn setDeviceWorkspaceIdInLocalStorage(createNewWorkspace());\n\t}\n}\nexport function removeDeviceWorkspaceIdFromLocalStorage() {\n\tlocalStorage.removeItem(DeviceWorkspaceIdKey);\n}\n\nexport function setDeviceWorkspaceIdInLocalStorage(newWorkspaceId: string) {\n\tlocalStorage.setItem(DeviceWorkspaceIdKey, newWorkspaceId);\n\treturn newWorkspaceId;\n}\n","/**\n * @module block-common\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { CanvasWithKey } from 'game/game';\nimport { CoreGame, VariableName } from 'game/game-core';\nimport { CanvasFont } from 'imgui/canvas-renderer';\nimport { AnyCanvasRenderingContext2D } from 'imgui/imgui-types';\nimport { layoutText } from 'imgui/text-layout';\nimport { Vector2 } from 'math/linalg';\nimport { VariableScope, scopeAsVisualIndex, variableScopeAndIndex } from 'runtime/variable';\nimport { createOffscreenCanvasAnd2DContextHiDPI } from 'utils/canvas';\nimport { Drawable, drawCanvasInBox } from 'utils/render';\nimport { defined, definedOr } from 'utils/types';\nimport { canvasTextFont } from 'vpl/vpl-typography';\n\n// TODO: pass more information above pos and use these in drawVariableFromAddress\nexport function drawScoreIcon(ctx: AnyCanvasRenderingContext2D, xC: number, yC: number, d = 32) {\n\tctx.save();\n\tctx.translate(xC, yC);\n\tctx.scale(d / 32, d / 32);\n\tctx.translate(-12, -12);\n\tctx.fill(new Path2D('m 12,22 h 5 V 20 C 14,17 14,17 14,13 14,9 21,8 21,2 H 3 c 0,6 7,7 7,11 0,4 0,4 -3,7 v 2 z'));\n\tctx.restore();\n}\n\nexport function hexagonLengths(d: number) {\n\t// hexagon formula from http://blog.inkofpark.com/?p=1109\n\tconst dD2 = d * 0.5;\n\tconst c = d * Math.sqrt(3) / 2;\n\tconst cD2 = c * 0.5;\n\tconst s = c / Math.sqrt(3);\n\tconst sD2 = s * 0.5;\n\treturn [dD2, cD2, sD2] as const; // [d/2, c/2, s/2]\n}\n\nexport function drawValueArrowHorizontal(ctx: AnyCanvasRenderingContext2D, xC: number, yC: number, scale = 1) {\n\tconst [dD2, cD2, sD2] = hexagonLengths(20);\n\tconst dx = 0;\n\tctx.beginPath();\n\tctx.moveTo(xC + scale * (sD2 + dx), yC - cD2);\n\tctx.lineTo(xC + scale * (dD2 + dx), yC);\n\tctx.lineTo(xC + scale * (sD2 + dx), yC + cD2);\n\tctx.fill();\n}\n\nexport function drawValueArrowVertical(ctx: AnyCanvasRenderingContext2D, xC: number, yC: number, scale = 1) {\n\tconst [dD2, cD2, sD2] = hexagonLengths(20);\n\tconst dx = 0;\n\tctx.beginPath();\n\tctx.moveTo(xC + cD2, yC + scale * (sD2 + dx));\n\tctx.lineTo(xC, yC + scale * (dD2 + dx));\n\tctx.lineTo(xC - cD2, yC + scale * (sD2 + dx));\n\tctx.fill();\n}\n\nexport function drawVariableHex(ctx: AnyCanvasRenderingContext2D, image: Drawable, xC: number, yC: number, d: number) {\n\tctx.save();\n\t// clip\n\tconst [dD2, cD2, sD2] = hexagonLengths(d);\n\tctx.beginPath();\n\tctx.moveTo(xC - sD2, yC - cD2);\n\tctx.lineTo(xC + sD2, yC - cD2);\n\tctx.lineTo(xC + dD2, yC);\n\tctx.lineTo(xC + sD2, yC + cD2);\n\tctx.lineTo(xC - sD2, yC + cD2);\n\tctx.lineTo(xC - dD2, yC);\n\tctx.closePath();\n\tctx.clip();\n\t// draw\n\tdrawCanvasInBox(ctx, image, d, new Vector2(xC - dD2, yC - dD2));\n\tctx.restore();\n}\n\nfunction drawVariableScope(ctx: AnyCanvasRenderingContext2D, scope: VariableScope, xC: number, yC: number, d: number) {\n\tconst white = 'white';\n\tconst gray = 'rgba(255, 255, 255, 0.35)';\n\tconst Colors = [\n\t\t[ gray, gray ],\n\t\t[ gray, white ],\n\t\t[ white, gray ]\n\t] as const;\n\tconst colors = Colors[scopeAsVisualIndex(scope)];\n\t// using hexagon formula above\n\tconst [dD2, cD2, sD2] = hexagonLengths(d);\n\tctx.save();\n\tctx.rect(xC - 32, yC - d * 0.3, 64, d * 0.6);\n\tctx.clip();\n\tctx.lineWidth = 3;\n\tfor (const i of [0, 1] as const) {\n\t\tctx.strokeStyle = colors[i];\n\t\tconst dx = i * 6 + 1.5;\n\t\tfor (const flip of [-1, 1] as const) {\n\t\t\tctx.beginPath();\n\t\t\tctx.moveTo(xC + flip * (sD2 + dx), yC - cD2);\n\t\t\tctx.lineTo(xC + flip * (dD2 + dx), yC);\n\t\t\tctx.lineTo(xC + flip * (sD2 + dx), yC + cD2);\n\t\t\tctx.stroke();\n\t\t}\n\t}\n\tctx.restore();\n}\n\nexport function drawVariableFromAddress(ctx: AnyCanvasRenderingContext2D, game: CoreGame, address: number, xC: number, yC: number, d: number) {\n\tconst [scope, index] = variableScopeAndIndex(address);\n\tif (index === 0) {\n\t\tdrawScoreIcon(ctx, xC, yC, d);\n\t} else {\n\t\tconst imageIndex = index - 1;\n\t\tconst variableName = definedOr(game.variables[imageIndex], () => `Attempted to draw variable index ${imageIndex} that does not exist.`).name;\n\t\tdrawVariableHex(ctx, getVariableMiniature(variableName, true), xC, yC, d);\n\t\tdrawVariableScope(ctx, scope, xC, yC, d);\n\t}\n}\n\nlet literalIconCanvasCache = null as CanvasWithKey | null;\n\nexport function createLiteralIconCanvas() {\n\tif (literalIconCanvasCache !== null) {\n\t\treturn literalIconCanvasCache;\n\t}\n\tliteralIconCanvasCache = createCenteredTextCanvas('1…');\n\treturn literalIconCanvasCache;\n}\n\nlet scoreCanvasCache = null as CanvasWithKey | null;\n\nexport function createScoreCanvas() {\n\tif (scoreCanvasCache !== null) {\n\t\treturn scoreCanvasCache;\n\t}\n\tconst { canvas, ctx } = createOffscreenCanvasAnd2DContextHiDPI(64, 64);\n\tdrawScoreIcon(ctx, 32, 32);\n\tscoreCanvasCache = new CanvasWithKey(canvas);\n\treturn scoreCanvasCache;\n}\n\nlet valueInputCanvasCache = null as CanvasWithKey | null;\n\nexport function createValueInputCanvas() {\n\tif (valueInputCanvasCache !== null) {\n\t\treturn valueInputCanvasCache;\n\t}\n\tconst { canvas, ctx } = createOffscreenCanvasAnd2DContextHiDPI(64, 64);\n\t// somehow the color theme is not ready at this point\n\tctx.fillStyle = '#00bb8c';\n\tctx.beginPath();\n\tctx.ellipse(32, 32, 12, 12, 0, 0, Math.PI * 2);\n\tctx.fill();\n\tvalueInputCanvasCache = new CanvasWithKey(canvas);\n\treturn valueInputCanvasCache;\n}\n\nexport function createCenteredTextCanvas(text: string, color = 'black') {\n\tconst { canvas, ctx } = createOffscreenCanvasAnd2DContextHiDPI(64, 64);\n\tconst usabeWidth = color === 'black' ? 64 : 56;\n\tconst blackRanges = [64, 56, 48, 36, 24, 16];\n\tconst whiteRanges = [64, 56, 48, 36, 24];\n\tconst ranges = color === 'black' ? blackRanges : whiteRanges;\n\tlet textWidth = 0;\n\tlet selectedSize = 16;\n\tfor (const size of ranges) {\n\t\tselectedSize = size;\n\t\tctx.font = canvasTextFont(size);\n\t\ttextWidth = ctx.measureText(text).width;\n\t\tif (textWidth < usabeWidth) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tconst metrics = ctx.measureText(text);\n\tconst h = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;\n\tctx.fillStyle = color;\n\tif (color === 'black' && selectedSize === 16) {\n\t\t// multi-line text\n\t\tconst font = new CanvasFont(ctx, ctx.font);\n\t\tconst lines = layoutText(text, font, usabeWidth, '_');\n\t\tconst rows = Math.min(lines.length, 4);\n\t\tlines.forEach(([line, _], i) => {\n\t\t\tif (i >= rows) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst y = (64 - h * rows) / 2 + (i + 0) * h + metrics.actualBoundingBoxAscent;\n\t\t\tctx.fillText(line, 0, y);\n\t\t});\n\t} else {\n\t\t// single line text\n\t\tconst x = textWidth < usabeWidth ? 32 - textWidth / 2 : (64 - usabeWidth) / 2;\n\t\tconst y = (64 - h) / 2 + metrics.actualBoundingBoxAscent;\n\t\tctx.fillText(text, x, y);\n\t}\n\treturn new CanvasWithKey(canvas);\n}\n\nconst miniatureCache = new Map<string, [CanvasWithKey, CanvasWithKey]>();\n\nexport function getVariableMiniature(textOrName: string | VariableName, white: boolean): Drawable {\n\tif (textOrName instanceof VariableName) {\n\t\tconst variableName = textOrName;\n\t\treturn variableName.image ?? getVariableMiniature(variableName.name ?? '', white);;\n\t}\n\tconst text = textOrName;\n\tlet miniatures = miniatureCache.get(text);\n\tif (miniatures === undefined) {\n\t\tminiatures = [\n\t\t\tcreateCenteredTextCanvas(text, 'black'),\n\t\t\tcreateCenteredTextCanvas(text, 'white')\n\t\t];\n\t\tminiatureCache.set(text, miniatures);\n\t}\n\treturn white ? miniatures[1] : miniatures[0];\n}\n\nexport function clearVariableMiniatureCache() {\n\tminiatureCache.clear();\n}","/**\n * condition: compare the value of the variable\n * @module block-compare-variable\n * @preferred\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { CandliBlock } from 'game/game-block-definition';\nimport * as flatbuffers from 'flatbuffers';\nimport * as CandliFB from 'flatbuffers/all';\nimport { assertInteger, assertIntegerRange } from 'utils/assert';\nimport { qsT } from 'translator/translator';\nimport { validateAddress, variableAddress, variableIndex, variableScope, VariableScope } from 'runtime/variable';\n\nexport import ComparisonOperation = CandliFB.ComparisonOperation;\nexport import ComparisonInputSide  = CandliFB.InputToBinarySide;\nimport { varLongNameNom, varShortName } from 'blocks/common/variable/variable-block';\nimport { BlockKind, ValuePortPresence } from 'vpl/block';\nimport { EditedObjectContext } from 'level/behaviour-editor-interface';\n\nexport const ValueAbbreviatedText = qsT('val.');\nexport const ValueText = qsT('value');\nexport const TheValueText = qsT('the value');\nexport const ComparisonText = qsT('Comparison');\n\nexport function operationToText(operation: ComparisonOperation) {\n\tswitch (operation) {\n\t\tcase ComparisonOperation.EQUAL: return '=';\n\t\tcase ComparisonOperation.GREATER_THAN: return '>';\n\t\tcase ComparisonOperation.LESS_THAN: return '<';\n\t\tcase ComparisonOperation.NOT_EQUAL: return '≠';\n\t\tcase ComparisonOperation.LESS_THAN_OR_EQUAL_TO: return '≤';\n\t\tcase ComparisonOperation.GREATER_THAN_OR_EQUAL_TO: return '≥';\n\t}\n}\n\nexport function flipOperation(operation: ComparisonOperation) {\n\tswitch (operation) {\n\t\tcase ComparisonOperation.EQUAL: return ComparisonOperation.EQUAL;\n\t\tcase ComparisonOperation.GREATER_THAN: return ComparisonOperation.LESS_THAN;\n\t\tcase ComparisonOperation.LESS_THAN: return ComparisonOperation.GREATER_THAN;\n\t\tcase ComparisonOperation.NOT_EQUAL: return ComparisonOperation.NOT_EQUAL;\n\t\tcase ComparisonOperation.LESS_THAN_OR_EQUAL_TO: return ComparisonOperation.GREATER_THAN_OR_EQUAL_TO;\n\t\tcase ComparisonOperation.GREATER_THAN_OR_EQUAL_TO: return ComparisonOperation.LESS_THAN_OR_EQUAL_TO;\n\t}\n}\n\nexport class ComparisonBlock extends CandliBlock {\n\tpublic address: number;\n\tpublic value: number;\n\tpublic operation: ComparisonOperation;\n\tpublic inputSide: ComparisonInputSide;\n\n\tconstructor(address: number, value: number, operation?: ComparisonOperation, inputSide?: ComparisonInputSide, lockState?: CandliBlock);\n\tconstructor(fbVariable: CandliFB.Comparison, fromVersion: number);\n\tconstructor(\n\t\taddressOrFbVariable: number | CandliFB.Comparison,\n\t\tvalueOrFromVersion: number,\n\t\toperation: ComparisonOperation = ComparisonOperation.EQUAL,\n\t\tinputSide: ComparisonInputSide = ComparisonInputSide.LEFT,\n\t\tlockState?: CandliBlock\n\t) {\n\t\tsuper('Comparison', lockState);\n\t\tif (addressOrFbVariable instanceof CandliFB.Comparison) {\n\t\t\tthis.address = addressOrFbVariable.address();\n\t\t\tthis.value = addressOrFbVariable.value();\n\t\t\tthis.operation = addressOrFbVariable.operation();\n\t\t\tthis.inputSide = addressOrFbVariable.inputSide();\n\t\t\tif (valueOrFromVersion < 3) { // see version history in game-core.ts\n\t\t\t\tconst scope = variableScope(this.address);\n\t\t\t\tlet index = variableIndex(this.address);\n\t\t\t\tif (scope !== VariableScope.Game) {\n\t\t\t\t\t// We have to fix index, because old format did not reserve index 0\n\t\t\t\t\t// for score when not in game scope.\n\t\t\t\t\tindex += 1;\n\t\t\t\t}\n\t\t\t\tthis.address = variableAddress(scope, index);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.address = addressOrFbVariable;\n\t\t\tthis.value = valueOrFromVersion;\n\t\t\tthis.operation = operation;\n\t\t\tthis.inputSide = inputSide;\n\t\t}\n\t\tthis.validate();\n\t}\n\n\tclone(): ComparisonBlock {\n\t\treturn new ComparisonBlock(this.address, this.value, this.operation, this.inputSide, this);\n\t}\n\n\tget name() {\n\t\treturn ComparisonText;\n\t}\n\n\tget inputValuePortPresence() {\n\t\treturn ValuePortPresence.Optional;\n\t}\n\n\tsummaryText(_userContext: EditedObjectContext | null, valueIn: boolean) {\n\t\tif (valueIn) {\n\t\t\tif (this.inputSide === ComparisonInputSide.LEFT) {\n\t\t\t\treturn `${ValueText} ${operationToText(this.operation)} ${this.value}`;\n\t\t\t} else {\n\t\t\t\tconst operationText = operationToText(flipOperation(this.operation));\n\t\t\t\treturn `${ValueText} ${operationText} ${varShortName(this.address)}`;\n\t\t\t}\n\t\t} else {\n\t\t\treturn `${varShortName(this.address)} ${operationToText(this.operation)} ${this.value}`;\n\t\t}\n\t}\n\n\tdetailedTextIfConfigured(userContext: EditedObjectContext | null, valueIn: boolean) {\n\t\tif (valueIn) {\n\t\t\tif (this.inputSide === ComparisonInputSide.LEFT) {\n\t\t\t\treturn `${TheValueText} ${operationToText(this.operation)} ${this.value}`;\n\t\t\t} else {\n\t\t\t\tconst operationText = operationToText(flipOperation(this.operation));\n\t\t\t\treturn `${TheValueText} ${operationText} ${varLongNameNom(this.address, userContext?.game)}`;\n\t\t\t}\n\t\t} else {\n\t\t\treturn `${varLongNameNom(this.address, userContext?.game)} ${operationToText(this.operation)} ${this.value}`;\n\t\t}\n\t}\n\n\tserialise(builder: flatbuffers.Builder) {\n\t\treturn CandliFB.Comparison.createComparison(builder,\n\t\t\tthis.address,\n\t\t\tthis.value,\n\t\t\tthis.operation,\n\t\t\tthis.inputSide\n\t\t);\n\t}\n\n\tget fbConditionType() {\n\t\treturn CandliFB.AnyCondition.Comparison;\n\t}\n\n\tget kind(): BlockKind {\n\t\treturn BlockKind.Condition;\n\t}\n\n\tvalidate() {\n\t\tsuper.validate();\n\t\tvalidateAddress(this.address);\n\t\tassertInteger(this.value, 'value');\n\t\tassertIntegerRange(this.operation, 0, 5, 'operation');\n\t}\n\n\tgetMiniatureKey(_userContext: unknown, valueIn: boolean) {\n\t\tlet rhs;\n\t\tif (valueIn) {\n\t\t\tif (this.inputSide === CandliFB.InputToBinarySide.LEFT) {\n\t\t\t\trhs = `L ${this.value}`;\n\t\t\t} else {\n\t\t\t\trhs = `R ${this.address}`;\n\t\t\t}\n\t\t} else {\n\t\t\trhs = `${this.address} ${this.value}`;\n\t\t}\n\t\treturn `comp ${valueIn} ${this.operation} ${rhs}`;\n\t}\n}\n","/**\n * condition: user input\n * @module block-input\n * @preferred\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { CandliBlock } from 'game/game-block-definition';\nimport * as flatbuffers from 'flatbuffers';\nimport * as CandliFB from 'flatbuffers/all';\nimport { assertIntegerRange } from 'utils/assert';\nimport { EditedObjectContext } from 'level/behaviour-editor-interface';\nimport { qsT, qsTr } from 'translator/translator';\nimport { toIndex, Nat, genIndex } from 'utils/array-types';\nimport { BlockKind } from 'vpl/block';\nimport { DirectionContext, downText, leftText, rightText, upText } from 'translator/common-texts';\n\nexport const enum Button {\n\tUp = 0,\n\tDown,\n\tLeft,\n\tRight,\n\tA,\n\tB,\n\tX,\n\tY\n}\nexport const ButtonCount = 8;\nexport type ButtonCount = typeof ButtonCount;\nexport type ButtonIndex = Nat<ButtonCount>;\nconst ButtonNames = [\n\tupText(DirectionContext.Key),\n\tdownText(DirectionContext.Key),\n\tleftText(DirectionContext.Key),\n\trightText(DirectionContext.Key),\n\t'A',\n\t'B',\n\t'X',\n\t'Y'\n] as const;\n\nexport class InputBlock extends CandliBlock {\n\tpublic button: Button;\n\tpublic player: 0 | 1;\n\n\tconstructor(button: Button, player?: number, lockState?: CandliBlock);\n\tconstructor(fbButton: CandliFB.InputButton);\n\tconstructor(\n\t\tbuttonOrFbButton: Button | CandliFB.InputButton,\n\t\tplayer: 0 | 1 = 0,\n\t\tlockState?: CandliBlock\n\t) {\n\t\tsuper('InputButton', lockState);\n\t\tif (buttonOrFbButton instanceof CandliFB.InputButton) {\n\t\t\tthis.button = buttonOrFbButton.number();\n\t\t\tthis.player = toIndex(2, buttonOrFbButton.player());\n\t\t} else {\n\t\t\tthis.button = buttonOrFbButton;\n\t\t\tthis.player = player;\n\t\t}\n\t\tthis.validate();\n\t}\n\n\tclone(): InputBlock {\n\t\treturn new InputBlock(this.button, this.player, this);\n\t}\n\n\tget name() {\n\t\treturn qsT('The player presses a button');\n\t}\n\n\tsummaryText() {\n\t\treturn qsT('pressed');\n\t}\n\n\tdetailedTextIfConfigured() {\n\t\treturn qsTr('the player presses the %1 button').args(ButtonNames[this.button]);\n\t}\n\n\tserialise(builder: flatbuffers.Builder) {\n\t\treturn CandliFB.InputButton.createInputButton(builder, this.button, this.player);\n\t}\n\n\tget fbConditionType() {\n\t\treturn CandliFB.AnyCondition.InputButton;\n\t}\n\n\tget kind(): BlockKind {\n\t\treturn BlockKind.Condition;\n\t}\n\n\tvalidate() {\n\t\tsuper.validate();\n\t\tassertIntegerRange(this.button, Button.Up, Button.Y, 'button');\n\t\tassertIntegerRange(this.player, 0, 1, 'player');\n\t}\n\n\tgetMiniatureKey(userContext: EditedObjectContext) {\n\t\tconst twoPlayers = userContext.game.twoPlayers;\n\t\tif (twoPlayers) {\n\t\t\treturn `input ${this.button} ${this.player}`;\n\t\t} else {\n\t\t\treturn `input ${this.button}`;\n\t\t}\n\t}\n}\n\n// keycodes for event.which, to be replaced later by key and code\nconst keyboardCodes = [38, 40, 37, 39, [65, 32], [66, 17], 88, 89] as const;\n\nexport function keyCodeToInputNumber(which: number): ButtonIndex | null {\n\tfor (const index of genIndex(keyboardCodes.length)) {\n\t\tconst keyCode = keyboardCodes[index];\n\t\tconst codes = keyCode instanceof Array ? keyCode : [keyCode];\n\t\tfor (const code of codes) {\n\t\t\tif (code === which) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t};\n\treturn null;\n}\n\n// keycodes for event.which, to be replaced later by key and code\nconst numpadCodes = ['Numpad8', 'Numpad2', 'Numpad4', 'Numpad6', 'NumpadDecimal', 'NumpadEnter', 'Numpad0', 'Numpad3'] as const;\n\nexport function numpadCodeToInputNumber(code: string): ButtonIndex | null {\n\tfor (const index of genIndex(numpadCodes.length)) {\n\t\tconst keyCode = numpadCodes[index];\n\t\tif (keyCode === code) {\n\t\t\treturn index;\n\t\t}\n\t};\n\treturn null;\n}","/**\n * generic: binary arithmetic operation\n * @module block-binary-arithmetic\n * @preferred\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { CandliBlock } from 'game/game-block-definition';\nimport * as flatbuffers from 'flatbuffers';\nimport * as CandliFB from 'flatbuffers/all';\nimport { BlockKind, ValuePortPresence } from 'vpl/block';\nimport { qsT, qsTr } from 'translator/translator';\nimport { varLongNameAcc, varShortName } from 'blocks/common/variable/variable-block';\nimport { BinaryArithmeticInput, BinaryArithmeticOperation } from 'flatbuffers/all';\nimport { TheValueText, ValueAbbreviatedText } from 'blocks/conditions/comparison/comparison-block';\nimport { assert } from 'utils/assert';\nimport { euclideanQuotient, euclideanRemainder } from 'math/euclidean-division';\nimport { CoreGame } from 'game/game-core';\nimport { EditedObjectContext } from 'level/behaviour-editor-interface';\n\nexport function isBinaryOperationValid(op: BinaryArithmeticOperation, lhs: number, rhs: number) {\n\tif (!Number.isFinite(lhs) || !Number.isFinite(rhs)) {\n\t\treturn false;\n\t}\n\tif (op === BinaryArithmeticOperation.DIV ||\n\t\top === BinaryArithmeticOperation.IDIV ||\n\t\top === BinaryArithmeticOperation.REM\n\t) {\n\t\treturn rhs !== 0;\n\t}\n\tif (op === BinaryArithmeticOperation.POW) {\n\t\tif (lhs < 0) {\n\t\t\treturn Number.isInteger(rhs);\n\t\t}\n\t}\n\tif (op === BinaryArithmeticOperation.LOG) {\n\t\treturn lhs > 0 && rhs > 0 && rhs !== 1;\n\t}\n\treturn true;\n}\n\nexport function executeBinaryOperation(op: BinaryArithmeticOperation, lhs: number, rhs: number) {\n\tswitch (op) {\n\t\tcase BinaryArithmeticOperation.ADD: return lhs + rhs;\n\t\tcase BinaryArithmeticOperation.SUB: return lhs - rhs;\n\t\tcase BinaryArithmeticOperation.MUL: return lhs * rhs;\n\t\tcase BinaryArithmeticOperation.DIV: {\n\t\t\tassert(rhs !== 0);\n\t\t\treturn lhs / rhs;\n\t\t}\n\t\tcase BinaryArithmeticOperation.IDIV: {\n\t\t\tassert(rhs !== 0);\n\t\t\treturn euclideanQuotient(lhs, rhs);\n\t\t}\n\t\tcase BinaryArithmeticOperation.REM: {\n\t\t\tassert(rhs !== 0);\n\t\t\treturn euclideanRemainder(lhs, rhs);\n\t\t}\n\t\tcase BinaryArithmeticOperation.POW: {\n\t\t\tif (lhs < 0) {\n\t\t\t\tassert(Number.isInteger(rhs));\n\t\t\t}\n\t\t\treturn Math.pow(lhs, rhs);\n\t\t}\n\t\tcase BinaryArithmeticOperation.LOG: {\n\t\t\tassert(lhs > 0);\n\t\t\tassert(rhs > 0);\n\t\t\tassert(rhs !== 1);\n\t\t\treturn Math.log(lhs) / Math.log(rhs);\n\t\t}\n\t\tcase BinaryArithmeticOperation.MIN: return Math.min(lhs, rhs);\n\t\tcase BinaryArithmeticOperation.MAX: return Math.max(lhs, rhs);\n\t}\n}\n\nexport function operationToSymbol(operation: BinaryArithmeticOperation) {\n\tswitch (operation) {\n\t\tcase BinaryArithmeticOperation.ADD: return '+';\n\t\tcase BinaryArithmeticOperation.SUB: return '−';\n\t\tcase BinaryArithmeticOperation.MUL: return '×';\n\t\tcase BinaryArithmeticOperation.DIV: return '/';\n\t\tcase BinaryArithmeticOperation.IDIV: return 'quot';\n\t\tcase BinaryArithmeticOperation.REM: return 'mod';\n\t\tcase BinaryArithmeticOperation.POW: return 'pow';\n\t\tcase BinaryArithmeticOperation.LOG: return 'log';\n\t\tcase BinaryArithmeticOperation.MIN: return 'min';\n\t\tcase BinaryArithmeticOperation.MAX: return 'max';\n\t}\n}\n\nexport function operationToText(operation: BinaryArithmeticOperation) {\n\tswitch (operation) {\n\t\tcase BinaryArithmeticOperation.ADD: return qsT('Addition');\n\t\tcase BinaryArithmeticOperation.SUB: return qsT('Subtraction');\n\t\tcase BinaryArithmeticOperation.MUL: return qsT('Multiplication');\n\t\tcase BinaryArithmeticOperation.DIV: return qsT('Division');\n\t\tcase BinaryArithmeticOperation.IDIV: return qsT('Euclidean division');\n\t\tcase BinaryArithmeticOperation.REM: return qsT('Remainder');\n\t\tcase BinaryArithmeticOperation.POW: return qsT('Exponentiation');\n\t\tcase BinaryArithmeticOperation.LOG: return qsT('Logarithm');\n\t\tcase BinaryArithmeticOperation.MIN: return qsT('Minimum');\n\t\tcase BinaryArithmeticOperation.MAX: return qsT('Maximum');\n\t}\n}\n\nfunction formatInput(input: BinaryArithmeticInput, addressOrValue: number) {\n\tswitch (input) {\n\t\tcase BinaryArithmeticInput.INPUT: return ValueAbbreviatedText;\n\t\tcase BinaryArithmeticInput.VARIABLE: return varShortName(addressOrValue);\n\t\tcase BinaryArithmeticInput.LITERAL: return addressOrValue.toString();\n\t}\n}\n\nfunction formatInputLong(input: BinaryArithmeticInput, addressOrValue: number, game?: CoreGame) {\n\tswitch (input) {\n\t\tcase BinaryArithmeticInput.INPUT: return TheValueText;\n\t\tcase BinaryArithmeticInput.VARIABLE: return varLongNameAcc(addressOrValue, game);\n\t\tcase BinaryArithmeticInput.LITERAL: return addressOrValue.toString();\n\t}\n}\n\nexport class BinaryArithmeticBlock extends CandliBlock {\n\tpublic op: BinaryArithmeticOperation;\n\tpublic lInput: BinaryArithmeticInput;\n\tpublic lAddressOrValue: number;\n\tpublic rInput: BinaryArithmeticInput;\n\tpublic rAddressOrValue: number;\n\n\tconstructor(\n\t\top: BinaryArithmeticOperation,\n\t\tlInput: BinaryArithmeticInput,\n\t\tlAddressOrValue: number,\n\t\trInput: BinaryArithmeticInput,\n\t\trAddressOrValue: number,\n\t\tlockState?: CandliBlock,\n\t);\n\tconstructor(fbBinaryArithmetic: CandliFB.BinaryArithmetic);\n\tconstructor(\n\t\topOrFbBinaryArithmetic: BinaryArithmeticOperation | CandliFB.BinaryArithmetic,\n\t\tlInput?: BinaryArithmeticInput,\n\t\tlAddressOrValue?: number,\n\t\trInput?: BinaryArithmeticInput,\n\t\trAddressOrValue?: number,\n\t\tlockState?: CandliBlock\n\t) {\n\t\tsuper('BinaryArithmetic', lockState);\n\t\tif (opOrFbBinaryArithmetic instanceof CandliFB.BinaryArithmetic) {\n\t\t\tconst fbBinaryArithmetic = opOrFbBinaryArithmetic;\n\t\t\tthis.op = fbBinaryArithmetic.operation();\n\t\t\tthis.lInput = fbBinaryArithmetic.lInput();\n\t\t\tswitch (this.lInput) {\n\t\t\t\tcase BinaryArithmeticInput.VARIABLE:\n\t\t\t\t\tthis.lAddressOrValue = fbBinaryArithmetic.lAddress();\n\t\t\t\t\tbreak;\n\t\t\t\tcase BinaryArithmeticInput.LITERAL:\n\t\t\t\t\tthis.lAddressOrValue = fbBinaryArithmetic.lValue();\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthis.lAddressOrValue = 0;\n\t\t\t}\n\t\t\tthis.rInput = fbBinaryArithmetic.rInput();\n\t\t\tswitch (this.rInput) {\n\t\t\t\tcase BinaryArithmeticInput.VARIABLE:\n\t\t\t\t\tthis.rAddressOrValue = fbBinaryArithmetic.rAddress();\n\t\t\t\t\tbreak;\n\t\t\t\tcase BinaryArithmeticInput.LITERAL:\n\t\t\t\t\tthis.rAddressOrValue = fbBinaryArithmetic.rValue();\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthis.rAddressOrValue = 0;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.op = opOrFbBinaryArithmetic;\n\t\t\tthis.lInput = lInput!;\n\t\t\tthis.lAddressOrValue = lAddressOrValue!;\n\t\t\tthis.rInput = rInput!;\n\t\t\tthis.rAddressOrValue = rAddressOrValue!;\n\t\t}\n\t}\n\n\tclone(): BinaryArithmeticBlock {\n\t\treturn new BinaryArithmeticBlock(this.op, this.lInput, this.lAddressOrValue, this.rInput, this.rAddressOrValue, this);\n\t}\n\n\tget name() {\n\t\treturn qsT('Binary operation');\n\t}\n\n\tget inputValuePortPresence() {\n\t\tconst hasInput = this.lInput === BinaryArithmeticInput.INPUT || this.rInput === BinaryArithmeticInput.INPUT;\n\t\treturn hasInput ? ValuePortPresence.Mandatory : ValuePortPresence.None;\n\t}\n\n\tget outputValuePortPresence() {\n\t\treturn ValuePortPresence.Mandatory;\n\t}\n\n\tsummaryText() {\n\t\tif (\n\t\t\tthis.op === BinaryArithmeticOperation.MIN ||\n\t\t\tthis.op === BinaryArithmeticOperation.MAX ||\n\t\t\tthis.op === BinaryArithmeticOperation.POW ||\n\t\t\tthis.op === BinaryArithmeticOperation.LOG\n\t\t) {\n\t\t\treturn `${operationToSymbol(this.op)}(${formatInput(this.lInput, this.lAddressOrValue)}, ${formatInput(this.rInput, this.rAddressOrValue)})`;\n\t\t} else {\n\t\t\treturn `${formatInput(this.lInput, this.lAddressOrValue)} ${operationToSymbol(this.op)} ${formatInput(this.rInput, this.rAddressOrValue)}`;\n\t\t}\n\t}\n\n\tdetailedTextIfConfigured(userContext: EditedObjectContext | null) {\n\t\tconst lhs = formatInputLong(this.lInput, this.lAddressOrValue, userContext?.game);\n\t\tconst rhs = formatInputLong(this.rInput, this.rAddressOrValue, userContext?.game);\n\t\tswitch (this.op) {\n\t\t\tcase BinaryArithmeticOperation.ADD:\n\t\t\t\treturn qsTr('add %1 to %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.SUB:\n\t\t\t\treturn qsTr('subtract %1 from %2').args(rhs, lhs);\n\t\t\tcase BinaryArithmeticOperation.MUL:\n\t\t\t\treturn qsTr('multiply %1 by %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.DIV:\n\t\t\t\treturn qsTr('divide %1 by %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.IDIV:\n\t\t\t\treturn qsTr('take the Euclidean quotient of %1 divided by %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.REM:\n\t\t\t\treturn qsTr('take the remainder of %1 divided by %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.POW:\n\t\t\t\treturn qsTr('raise %1 to the power of %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.LOG:\n\t\t\t\treturn qsTr('take the logarithm of %1 to the base %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.MIN:\n\t\t\t\treturn qsTr('take the minimum of %1 and %2').args(lhs, rhs);\n\t\t\tcase BinaryArithmeticOperation.MAX:\n\t\t\t\treturn qsTr('take the maximum of %1 and %2').args(lhs, rhs);\n\t\t}\n\t}\n\n\tserialise(builder: flatbuffers.Builder) {\n\t\tconst lAddress = this.lInput === BinaryArithmeticInput.VARIABLE ? this.lAddressOrValue : 0;\n\t\tconst lValue = this.lInput === BinaryArithmeticInput.LITERAL ? this.lAddressOrValue : 0;\n\t\tconst rAddress = this.rInput === BinaryArithmeticInput.VARIABLE ? this.rAddressOrValue : 0;\n\t\tconst rValue = this.rInput === BinaryArithmeticInput.LITERAL ? this.rAddressOrValue : 0;\n\t\treturn CandliFB.BinaryArithmetic.createBinaryArithmetic(builder,\n\t\t\tthis.op,\n\t\t\tthis.lInput,\n\t\t\tlAddress,\n\t\t\tlValue,\n\t\t\tthis.rInput,\n\t\t\trAddress,\n\t\t\trValue\n\t\t);\n\t}\n\n\tget fbGenericType() {\n\t\treturn CandliFB.AnyGenericBlock.BinaryArithmetic;\n\t}\n\n\tget kind(): BlockKind {\n\t\treturn BlockKind.Generic;\n\t}\n\n\tget premium() {\n\t\treturn true;\n\t}\n\n\tneedsConfiguration() {\n\t\t// division by zero\n\t\tif (\n\t\t\t(\n\t\t\t\tthis.op === BinaryArithmeticOperation.DIV ||\n\t\t\t\tthis.op === BinaryArithmeticOperation.IDIV ||\n\t\t\t\tthis.op === BinaryArithmeticOperation.REM\n\t\t\t) &&\n\t\t\tthis.rInput === BinaryArithmeticInput.LITERAL &&\n\t\t\tthis.rAddressOrValue === 0\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\t// pow of negative number with non-integer exponent\n\t\t// not necessary available as non-integer cannot be selected\n\t\t// if (\n\t\t// \tthis.op === BinaryArithmeticOperation.POW &&\n\t\t// \tthis.lInput === BinaryArithmeticInput.LITERAL &&\n\t\t// \tthis.lAddressOrValue < 0 &&\n\t\t// \tthis.rInput === BinaryArithmeticInput.LITERAL &&\n\t\t// \t!Number.isInteger(this.rAddressOrValue)\n\t\t// ) {\n\t\t// \treturn true;\n\t\t// }\n\t\tif (this.op === BinaryArithmeticOperation.LOG) {\n\t\t\tif (this.lInput === BinaryArithmeticInput.LITERAL && this.lAddressOrValue <= 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (this.rInput === BinaryArithmeticInput.LITERAL) {\n\t\t\t\tif (this.rAddressOrValue <= 0 || this.rAddressOrValue === 1) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tneedsConfigurationFix() {\n\t\tif (this.op === BinaryArithmeticOperation.DIV || this.op === BinaryArithmeticOperation.IDIV) {\n\t\t\treturn qsT('choose a non-zero value, as division by zero is not defined');\n\t\t}\n\t\tif (this.op === BinaryArithmeticOperation.REM) {\n\t\t\treturn qsT('choose a non-zero value, as taking the remainder of a number divided by zero is not defined');\n\t\t}\n\t\tif (this.op === BinaryArithmeticOperation.LOG) {\n\t\t\tif (this.lInput === BinaryArithmeticInput.LITERAL && this.lAddressOrValue <= 0) {\n\t\t\t\treturn qsT('choose a positive value, as the logarithm of a non-positive number is not defined');\n\t\t\t}\n\t\t\tif (this.rInput === BinaryArithmeticInput.LITERAL) {\n\t\t\t\tif (this.rAddressOrValue <= 0) {\n\t\t\t\t\treturn qsT('choose a positive value, as the base of the logarithm must be positive');\n\t\t\t\t}\n\t\t\t\tif (this.rAddressOrValue === 1) {\n\t\t\t\t\treturn qsT('choose a value different from 1, as the base of the logarithm must not be 1');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn '';\n\t}\n\n\tgetMiniatureKey() {\n\t\treturn `binaryArithmetic ${this.op} ${this.lInput} ${this.lAddressOrValue} ${this.rInput} ${this.rAddressOrValue}`;\n\t}\n}","/**\n * The in-memory structure of a Game.\n * @module game\n * @preferred\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { CandliBlock, ObjectTypeIdMap } from './game-block-definition';\nimport { Condition, Row } from '../vpl/row';\nimport { Vector2, SimilarityTransform, assertVector2, assertSimilarityTransform, transformVectors2 } from 'math/linalg';\nimport { Color, assertColor } from 'color/color';\nimport { dynamicCast, nonnull, downcast, Constructor, defined, cast, toStr } from 'utils/types';\nimport { EditorDefaultScale, CameraDefaultExtent, LevelDefaultGravity, LevelDefaultAirFriction, WorldWindowMarginConstant, WorldWindowMarginProportional, ObjectTypeDefaultBounciness, ObjectTypeDefaultStickiness, CameraDefaultBackgroundColor, ObjectTypeDefaultDensity } from './constants';\nimport { Rect } from 'math/geometry';\nimport { SpeedBlock, SpeedBlockMode } from 'blocks/actions/speed/speed-block';\nimport { InputBlock } from 'blocks/conditions/input/input-block';\nimport { assert, assertInteger, assertType, assertPositiveNumber, assertNumberRange, assertBoolean, assertNumber, assertFalse, assertMemberEqual, assertMemberNumberEqual, assertMemberTypeEqual, assertNull, assertNumberEqual, assertStrictlyPositiveNumber, assertValidType, assertValidArrayType, assertMemberArrayEqualM, assertMemberEqualM, assertNonNegativeInteger, assertStringOrNull, assertMemberArrayEqual, assertMemberSetEqual, assertValidSetPrimitive, assertMemberEqualF, assertL, assertMemberMapEqual, assertValidArrayString, assertString, assertNonNull, assertValidMapPrimitive } from 'utils/assert';\nimport { BrakeBlock } from 'blocks/actions/speed/brake-block';\nimport { StopBlock } from 'blocks/actions/speed/stop-block';\nimport { MusicBlock } from 'blocks/actions/music/music-block';\nimport { Drawable } from 'utils/render';\nimport * as flatbuffers from 'flatbuffers';\nimport * as CandliFB from 'flatbuffers/all';\nimport { fromFbObjectTypeRef, fromFbSimilarityTransform2, fromFbScalingTranslation2, fromFbVector2, fromFbArray, fromFbColorPacked32, fromFbScalingRotation2, fromFbPolygon2, fromFbArrayWithFactory, toFbScalingRotation2, toFbSimilarityTransform2, toFbObjectTypeRef, toFbScalingTranslation2, toFbVector2, toFbColorPacked32, toFbAnyShape, fromFbAnyShape, fromFbArrayIdentity, FbAnyShape } from 'flatbuffers/flatbuffers-cast';\nimport { decodeFbCondition, decodeFbAction } from './game-blocks';\nimport { assertMemberVector2Equal, assertMemberColorEqual, assertMemberSimilarityTransformEqual, assertVector2Array, assertObjectTypeOptEqual, assertShapeEqual, assertSimilarityTransformEqual } from 'utils/assert-specific';\nimport { AngularSpeedBlock, AngularSpeedBlockMode } from 'blocks/actions/speed/angular-speed-block';\nimport { ShowDialogBlock } from 'blocks/actions/dialog/dialog-block';\nimport { ComparisonBlock } from 'blocks/conditions/comparison/comparison-block';\nimport { variableAddress, VariableScope, variableScopeAndIndex } from 'runtime/variable';\nimport { ChangeVariableBlock } from 'blocks/actions/variable/change-variable-block';\nimport { AtmosphereIndex } from 'blocks/actions/music/music-interface';\nimport { clone, cloneDeepWith } from 'lodash-es';\nimport { CandliAction, CandliBlockI, CandliCondition, CandliRow, EditedObjectContext } from 'level/behaviour-editor-interface';\nimport { Sound } from 'blocks/actions/sound/sound-interface';\nimport { SoundBlock } from 'blocks/actions/sound/sound-block';\nimport { qsT, qsTr } from 'translator/translator';\nimport { PlayAnimationBlock } from 'blocks/actions/animation/animation-block';\nimport { moveRange } from 'utils/range';\nimport { CopyOf, Quoting, WithNumberSign } from 'translator/common-texts';\nimport { AnimationIdleText } from 'blocks/common/animation/animation-common';\nimport { AnimationIsBlock } from 'blocks/conditions/animation/animation-is-block';\nimport { ReadVariableBlock } from 'blocks/generic/read-variable/read-variable-block';\nimport { BinaryArithmeticBlock } from 'blocks/generic/binary-arithmetic/binary-arithmetic-block';\nimport { ScriptAbstractBlock } from 'blocks/common/script/script-block';\nimport { OptScriptVariable, ScriptCtx, ScriptCtxBuilder, ScriptVariableType } from 'app-core-web/pkg';\nimport { ScriptPackageLocator } from 'network/api';\nimport { clearCanvas, drawText, setTextColor, setFontSize, drawEllipse, drawLine, drawRect, fillEllipse, fillRect, setFillColor, setStrokeColor, setCandliVariable, getCandliVariable, checkPoint, getPilaCompetency, setPilaCompetency, setTextAlignment, attachCamera, getScriptVariable, setScriptVariable, openURL, log, textInputActive, getTextInput, startTextInput, stopTextInput, spawnObject, gameSessionId, logGameEvent } from 'runtime/runtime-script';\nimport { getSpeechRecognitionError, getSpeechRecognitionResult, hasSpeechRecognitionError, hasSpeechRecognitionResult, isSpeechRecognitionSupported, startSpeechRecognition, stopSpeechRecognition } from 'runtime/runtime-speech';\nimport { askLlm, getLlmResponse, hasLlmResponse, newLlmConversation } from 'runtime/runtime-llm';\nimport { toLimitName } from 'limits/limits';\nimport { randIntInclusiveRange } from 'utils/random-core';\n\n\nexport type ImageIndices = Map<Drawable, number>;\n\nexport type ImageDecoder = (index: number) => Drawable;\n\nexport type SoundDecoder = (index: number) => Sound;\n\n/**\n * Data version. History:\n * - 1: first version, if zero is used, no version was saved before, changes:\n * \t\t- Store real vector value in SpeedBlock, removed hack in runtime, moved factor to speed block editor\n * - 2: Flatbuffers serialisation, changes:\n * \t\t- Added Flatbuffers serialisation\n * \t\t- Sprite embeds a Drawable instead of inheriting from CanvasWithKey, allowing to move it to core\n *      - Added density parameter to ObjectType\n * - 3: Variable blocks reserve index 0 for score, and all user-defined names start at 1.\n * - 4: Let relative speed and spawn speed be proportional to the object/parent's size.\n */\nexport const CurrentDataVersion = 4;\n\n/** If a game's data version is below that, loading that game will throw an error */\nexport const OldestLoadableDataVersion = 2;\n\n\n/** Decode a row from Flatbuffers, used as a factory to avoid injecting dependencies of Candli into VPL */\nexport function decodeFbRow(fbRule: CandliFB.Rule, game: CoreGame, fromVersion: number) {\n\treturn new Row(\n\t\tfromFbArrayWithFactory(fbRule, 'conditions', decodeFbCondition, game, fromVersion),\n\t\tfromFbArrayWithFactory(fbRule, 'actions', decodeFbAction, game, fromVersion),\n\t\tfbRule.movementLocked(),\n\t\tfbRule.conditionsExtendLocked(),\n\t\tfbRule.actionsExtendLocked()\n\t);\n}\n\nexport function conditionsToFb(builder: flatbuffers.Builder, conditions: CandliCondition[], objectTypes: ObjectTypeIdMap, keepLocking: boolean) {\n\treturn conditions.map((condition) => {\n\t\tconst block = downcast(CandliBlock, condition.block);\n\t\tlet conditionType: CandliFB.AnyCondition;\n\t\tlet serialized;\n\t\tconst genericType = block.fbGenericType;\n\t\tif (genericType !== null) {\n\t\t\tconditionType = CandliFB.AnyCondition.GenericBlock_GenericBlockContainer;\n\t\t\tserialized = CandliFB.GenericBlockContainer.createGenericBlockContainer(\n\t\t\t\tbuilder,\n\t\t\t\tgenericType,\n\t\t\t\tblock.serialise(builder, objectTypes)\n\t\t\t);\n\t\t} else {\n\t\t\tconditionType = nonnull(block.fbConditionType);\n\t\t\tserialized = block.serialise(builder, objectTypes);\n\t\t}\n\t\treturn CandliFB.Condition.createCondition(\n\t\t\tbuilder,\n\t\t\tconditionType,\n\t\t\tserialized,\n\t\t\tcondition.inverted,\n\t\t\tkeepLocking ? block.movementLocked : false,\n\t\t\tkeepLocking ? block.parametersLocked : false\n\t\t);\n\t})\n}\n\nexport function actionsToFb(builder: flatbuffers.Builder, actions: CandliAction[], objectTypes: ObjectTypeIdMap, keepLocking: boolean) {\n\treturn actions.map((action) => {\n\t\tconst block = downcast(CandliBlock, action.block);\n\t\tlet actionType: CandliFB.AnyAction;\n\t\tlet serialized;\n\t\tconst genericType = block.fbGenericType;\n\t\tif (genericType !== null) {\n\t\t\tactionType = CandliFB.AnyAction.GenericBlock_GenericBlockContainer;\n\t\t\tserialized = CandliFB.GenericBlockContainer.createGenericBlockContainer(\n\t\t\t\tbuilder,\n\t\t\t\tgenericType,\n\t\t\t\tblock.serialise(builder, objectTypes)\n\t\t\t);\n\t\t} else {\n\t\t\tactionType = nonnull(block.fbActionType);\n\t\t\tserialized = block.serialise(builder, objectTypes);\n\t\t}\n\t\treturn CandliFB.Action.createAction(\n\t\t\tbuilder,\n\t\t\tactionType,\n\t\t\tserialized,\n\t\t\tkeepLocking ? block.movementLocked : false,\n\t\t\tkeepLocking ? block.parametersLocked : false\n\t\t);\n\t})\n}\n\nexport class AnimationFrame {\n\tsprite: Drawable;\n\tpartFromPixelTransform: SimilarityTransform;\n\n\tconstructor(sprite: Drawable, partFromPixelTransform: SimilarityTransform)\n\tconstructor(fbAnimationFrame: CandliFB.AnimationFrame, imageDecoder: ImageDecoder);\n\tconstructor(\n\t\tspriteOrFbAnimationFrame: Drawable | CandliFB.AnimationFrame,\n\t\tpartFromPixelTransformOrImageDecoder: SimilarityTransform | ImageDecoder\n\t) {\n\t\tif (spriteOrFbAnimationFrame instanceof CandliFB.AnimationFrame) {\n\t\t\tconst fbAnimationFrame = spriteOrFbAnimationFrame;\n\t\t\tconst imageDecoder = partFromPixelTransformOrImageDecoder as ImageDecoder;\n\t\t\tthis.sprite = imageDecoder(fbAnimationFrame.textureImageIndex());\n\t\t\tthis.partFromPixelTransform = fromFbSimilarityTransform2(fbAnimationFrame.partFromPixelTransform());\n\t\t} else {\n\t\t\tthis.sprite = spriteOrFbAnimationFrame;\n\t\t\tthis.partFromPixelTransform = partFromPixelTransformOrImageDecoder as SimilarityTransform;\n\t\t}\n\t}\n\n\tget resolution() {\n\t\treturn 1 / this.partFromPixelTransform.scaleFactor\n\t}\n\n\tget spriteSize() {\n\t\treturn this.sprite.size;\n\t}\n\n\tget size() {\n\t\treturn this.sprite.size.multScalar(this.partFromPixelTransform.scaleFactor);\n\t}\n\n\tget maxExtent() {\n\t\tconst spriteRect = new Rect(0, 0, this.sprite.size.x, this.sprite.size.y);\n\t\treturn spriteRect.transformAsAABB(this.partFromPixelTransform).maxAbsCoord;\n\t}\n\n\tclone() {\n\t\treturn new AnimationFrame(this.sprite, this.partFromPixelTransform.clone());\n\t}\n\n\tserialise(builder: flatbuffers.Builder, imageIndices: ImageIndices) {\n\t\tconst textureImageIndex = defined(imageIndices.get(this.sprite))\n\t\tCandliFB.AnimationFrame.startAnimationFrame(builder);\n\t\tCandliFB.AnimationFrame.addTextureImageIndex(builder, textureImageIndex);\n\t\tCandliFB.AnimationFrame.addPartFromPixelTransform(builder, toFbSimilarityTransform2(builder, this.partFromPixelTransform));\n\t\treturn CandliFB.AnimationFrame.endAnimationFrame(builder);\n\t}\n\n\tvalidate() {\n\t\tdefined(this.sprite);\n\t\tthis.sprite.validate();\n\t}\n\n\tstatic newCenteredWithResolution(sprite: Drawable, resolution: number) {\n\t\tconst scaling = 1 / resolution;\n\t\tconst translation = new Vector2(-sprite.size.x * scaling * 0.5, -sprite.size.y * scaling * 0.5);\n\t\treturn new AnimationFrame(sprite, SimilarityTransform.scalingTranslation(scaling, translation));\n\t}\n\n\tstatic newWithCenterAndResolution(sprite: Drawable, center: Vector2, resolution: number) {\n\t\tconst scaling = 1 / resolution;\n\t\tconst translation = center.multScalar(-scaling);\n\t\treturn new AnimationFrame(sprite, SimilarityTransform.scalingTranslation(scaling, translation));\n\t}\n\n\tassertEqual(that: AnimationFrame, ctx: string) {\n\t\tassertMemberEqual(this, that, 'sprite', ctx);\n\t\tassertMemberSimilarityTransformEqual(this, that, 'partFromPixelTransform', ctx);\n\t}\n}\n\nexport class Animation {\n\tpublic frames: AnimationFrame[];\n\tpublic name: string | null;\n\tpublic fps: number;\n\n\tconstructor(frames: AnimationFrame[], name?: string, fps?: number);\n\tconstructor(fbAnimation: CandliFB.Animation, imageDecoder: ImageDecoder);\n\tconstructor(\n\t\tframesOrFbAnimation: AnimationFrame[] | CandliFB.Animation,\n\t\tnameOrImageDecoder: string | undefined | ImageDecoder = undefined,\n\t\tfps = 8\n\t) {\n\t\tif (framesOrFbAnimation instanceof CandliFB.Animation) {\n\t\t\tconst fbAnimation = framesOrFbAnimation;\n\t\t\tconst imageDecoder = nameOrImageDecoder as ImageDecoder;\n\t\t\tthis.frames = fromFbArray(fbAnimation, 'frames', AnimationFrame, imageDecoder);\n\t\t\tthis.name = fbAnimation.name();\n\t\t\tthis.fps = fbAnimation.fps();\n\t\t} else {\n\t\t\tthis.frames = framesOrFbAnimation;\n\t\t\tthis.name = (nameOrImageDecoder as string | undefined) ?? null;\n\t\t\tthis.fps = fps;\n\t\t}\n\t}\n\n\tget frameCount() {\n\t\treturn this.frames.length;\n\t}\n\n\tget duration() {\n\t\treturn this.frameCount / this.fps;\n\t}\n\n\tclone() {\n\t\treturn new Animation(this.frames.map((frame) => frame.clone()), this.name ?? undefined, this.fps);\n\t}\n\n\tisVirgin() {\n\t\treturn this.frameCount === 0 && this.name === null;\n\t}\n\n\tserialise(builder: flatbuffers.Builder, imageIndices: ImageIndices) {\n\t\tconst framesOffset = CandliFB.Animation.createFramesVector(builder,\n\t\t\tthis.frames.map((frame) => frame.serialise(builder, imageIndices))\n\t\t);\n\t\tconst nameOffset = this.name !== null ? builder.createString(this.name) : null;\n\t\tCandliFB.Animation.startAnimation(builder);\n\t\tCandliFB.Animation.addFrames(builder, framesOffset);\n\t\tif (nameOffset !== null) {\n\t\t\tCandliFB.Animation.addName(builder, nameOffset);\n\t\t}\n\t\tCandliFB.Animation.addFps(builder, this.fps);\n\t\treturn CandliFB.Animation.endAnimation(builder);\n\t}\n\n\tvalidate() {\n\t\tassertStrictlyPositiveNumber(this.fps, 'fps');\n\t\tassertValidArrayType(AnimationFrame, this.frames, 'frames');\n\t}\n\n\tassertEqual(that: Animation, ctx: string) {\n\t\tassertMemberArrayEqualM(this, that, 'frames', ctx);\n\t\tassertMemberEqual(this, that, 'name', ctx);\n\t\tassertMemberEqual(this, that, 'fps', ctx);\n\t}\n}\n\nexport type Shape = Vector2[] | Vector2 | number;\n\nexport function radiusOfShape(shape: Shape) {\n\tif (shape instanceof Array) {\n\t\treturn Math.sqrt(shape.reduce((maxRadius2, p) => Math.max(maxRadius2, p.norm2()), 0));\n\t} else if (shape instanceof Vector2) {\n\t\treturn shape.norm() * 0.5;\n\t} else {\n\t\treturn shape;\n\t}\n}\n\nexport function boundingRectOfShape(shape: Shape) {\n\tif (shape instanceof Array) {\n\t\treturn Rect.fromPoints(shape);\n\t} else if (shape instanceof Vector2) {\n\t\treturn Rect.fromCenterAndSize(new Vector2(), shape);\n\t} else {\n\t\treturn new Rect(-shape, -shape, 2 * shape, 2 * shape);\n\t}\n}\n\nexport function shapeToPolygon(shape: Shape) {\n\tif (shape instanceof Array) {\n\t\treturn shape;\n\t} else if (shape instanceof Vector2) {\n\t\tconst shapeHalfSize = shape.multScalar(0.5);\n\t\treturn [\n\t\t\tnew Vector2( shapeHalfSize.x, -shapeHalfSize.y),\n\t\t\tnew Vector2( shapeHalfSize.x,  shapeHalfSize.y),\n\t\t\tnew Vector2(-shapeHalfSize.x,  shapeHalfSize.y),\n\t\t\tnew Vector2(-shapeHalfSize.x, -shapeHalfSize.y)\n\t\t];\n\t} else {\n\t\tconst points: Vector2[] = [];\n\t\tconst radius = shape;\n\t\tfor (let i = 0; i < 64; ++i) {\n\t\t\tconst angle = i * Math.PI / 32;\n\t\t\tpoints.push(new Vector2(Math.cos(angle) * radius, Math.sin(angle) * radius));\n\t\t}\n\t\treturn points;\n\t}\n}\n\nexport function serializeRow(rule: CandliRow, builder: flatbuffers.Builder, objectTypes: ObjectTypeIdMap, keepLocking: boolean) {\n\treturn CandliFB.Rule.createRule(builder,\n\t\tCandliFB.Rule.createConditionsVector(builder,\n\t\t\tconditionsToFb(builder, rule.conditions, objectTypes, keepLocking)\n\t\t),\n\t\tCandliFB.Rule.createActionsVector(builder,\n\t\t\tactionsToFb(builder, rule.actions, objectTypes, keepLocking)\n\t\t),\n\t\tkeepLocking ? rule.movementLocked : false,\n\t\tkeepLocking ? rule.conditionsExtendLocked: false,\n\t\tkeepLocking ? rule.actionsExtendLocked: false\n\t);\n}\n\n/**\n * A type of game object.\n */\nexport class ObjectType {\n\t/** counter to create unique identifiers */\n\tprivate static _maxId = 0;\n\n\t/** unique identifier for this type within an execution, but NOT its index in [[Game.objects]] */\n\tpublic readonly id: number;\n\n\t// general\n\tpublic name: string | null = null;\n\tpublic roles: Set<string>;\n\n\t// for runtime\n\t/** the rules controlling the behaviour of the object instances */\n\tpublic behaviour: CandliRow[] = [ new Row() ];\n\t/** the type of physics and display order */\n\tprivate _kind: ObjectType.Kind;\n\t/** the object's contribution to the effective friction during collision or with the world, in range [0..1], default 0.1 */\n\tpublic stickiness: number;\n\t/** how much of the object's original energy is kept during collision, in range [0..1], default 0 */\n\tpublic bounciness: number;\n\t/** how dense is the object, default 1 */\n\tpublic density: number;\n\t/** whether the object is allowed to rotate */\n\tprivate _canRotate = false;\n\n\t/** the object collider */\n\tprivate _shape: Shape;\n\t/** the transparency of the sprite */\n\tpublic alpha = 1.0;\n\t/** the animations of this object */\n\tpublic animations: Animation[];\n\n\t// for editor\n\t/** scale factor used last time an instance was edited */\n\tpublic lastScale: number;\n\t/** rotation angle used last time an instance was edited */\n\tpublic lastRotation: number;\n\t/** whether the object type is locked for editing in VPL */\n\tpublic editLocked: boolean;\n\t/** whether the object type is locked for deletion in level editor / VPL */\n\tpublic deleteLocked: boolean;\n\t/** whether the object type is locked for instantiating in level editor */\n\tpublic instantiationLocked: boolean;\n\n\t// pre-computed for performance reasons based on profiling\n\t/** the distance of the furthest point from the object center */\n\tprivate _boundingRadius!: number;\n\n\t/**\n\t * Constructor.\n\t */\n\tconstructor(kind: ObjectType.Kind, firstFrameOrAnims: AnimationFrame | Animation[], shape: Shape, stickiness?: number, bounciness?: number);\n\tconstructor(fbObjectType: CandliFB.ObjectType, imageDecoder: ImageDecoder, roleNames: string[]);\n\tconstructor(kindOrFbObjectType: ObjectType.Kind | CandliFB.ObjectType, firstFrameOrAnimsOrImageDecoder: AnimationFrame | Animation[] | ImageDecoder, shapeOrRoleNames: Shape | string[], stickiness?: number, bounciness?: number) {\n\t\tthis.id = ObjectType.newId();\n\t\tif (kindOrFbObjectType instanceof CandliFB.ObjectType) {\n\t\t\t// deserialiser\n\t\t\tconst fbObjectType = kindOrFbObjectType;\n\t\t\tconst imageDecoder = firstFrameOrAnimsOrImageDecoder as ImageDecoder;\n\t\t\t// general\n\t\t\tthis.name = fbObjectType.name();\n\t\t\tconst roles: number[] = fromFbArrayIdentity(fbObjectType, 'roles');\n\t\t\tconst roleNames = shapeOrRoleNames as string[];\n\t\t\tthis.roles = new Set(roles.map((roleIndex) => defined(roleNames[roleIndex])));\n\t\t\t// basic physics\n\t\t\tthis._kind = fbObjectType.kind().valueOf();\n\t\t\tthis.stickiness = fbObjectType.stickiness();\n\t\t\tthis.bounciness = fbObjectType.bounciness();\n\t\t\tthis.density = fbObjectType.density();\n\t\t\tif (isNaN(this.density)) { // some objects have NaN density, fixing\n\t\t\t\tthis.density = 1;\n\t\t\t}\n\t\t\tthis._canRotate = fbObjectType.canRotate();\n\t\t\tconst partsType = fbObjectType.partsType();\n\t\t\tassert(partsType === CandliFB.AnyBody.SinglePartBody, `A object type has invalid parts type ${partsType}`);\n\t\t\t// body parts (and display)\n\t\t\tconst singlePartBody = nonnull(fbObjectType.parts(new CandliFB.SinglePartBody())) as CandliFB.SinglePartBody;\n\t\t\tthis._shape = fromFbAnyShape(singlePartBody);\n\t\t\tthis.alpha = singlePartBody.alpha() / 255.0;\n\t\t\tif (singlePartBody.animationsLength() === 0) {\n\t\t\t\t// no animations, old format, use the single sprite\n\t\t\t\tconst pixelToBodyTransform = fromFbSimilarityTransform2(singlePartBody.pixelToBodyTransform());\n\t\t\t\tconst sprite = new AnimationFrame(imageDecoder(singlePartBody.textureImageIndex()), pixelToBodyTransform);\n\t\t\t\tthis.animations = [new Animation([sprite])];\n\t\t\t} else {\n\t\t\t\t// animations are present, use them\n\t\t\t\tthis.animations = fromFbArray(singlePartBody, 'animations', Animation, imageDecoder);\n\t\t\t}\n\t\t\t// behaviour: done later, as other object types might need to be resolved, see deserialiseBehaviours() below\n\t\t\t// editor stuff\n\t\t\t[this.lastScale, this.lastRotation] = fromFbScalingRotation2(fbObjectType.editorLastTransform());\n\t\t\tthis.editLocked = fbObjectType.editionLocked();\n\t\t\tthis.deleteLocked = fbObjectType.deletionLocked();\n\t\t\tthis.instantiationLocked = fbObjectType.instantiationLocked();\n\t\t} else {\n\t\t\t// normal constructor\n\t\t\tthis.roles = new Set();\n\t\t\tthis._kind = kindOrFbObjectType;\n\t\t\tthis.stickiness = stickiness !== undefined ? stickiness : ObjectTypeDefaultStickiness;\n\t\t\tthis.bounciness = bounciness !== undefined ? bounciness : ObjectTypeDefaultBounciness;\n\t\t\tthis.density = ObjectTypeDefaultDensity;\n\t\t\tif (firstFrameOrAnimsOrImageDecoder instanceof AnimationFrame) {\n\t\t\t\tthis.animations = [new Animation([firstFrameOrAnimsOrImageDecoder])];\n\t\t\t} else {\n\t\t\t\tthis.animations = firstFrameOrAnimsOrImageDecoder as Animation[];\n\t\t\t}\n\t\t\tthis._shape = shapeOrRoleNames as Shape;\n\t\t\tthis.lastScale = 1.0;\n\t\t\tthis.lastRotation = 0.0;\n\t\t\tthis.editLocked = false;\n\t\t\tthis.deleteLocked = false;\n\t\t\tthis.instantiationLocked = false;\n\t\t}\n\t\t// pre-compute values for performance reasons\n\t\tthis.recomputedCachedValues();\n\t}\n\n\t/// Recompute boundingRadius, spriteWorldSize and spriteCenterRatio, based on the current values of shape, sprite and spriteScale\n\tprivate recomputedCachedValues() {\n\t\tthis._boundingRadius = radiusOfShape(this.shape);\n\t}\n\n\tget boundingRadius() {\n\t\treturn this._boundingRadius;\n\t}\n\n\tget shape() {\n\t\treturn this._shape;\n\t}\n\tset shape(shape: Shape) {\n\t\tthis._shape = shape;\n\t\tthis.recomputedCachedValues();\n\t}\n\n\tprotected get firstAnimation() {\n\t\treturn defined(this.animations[0]);\n\t}\n\n\tget firstFrame() {\n\t\tconst quickFirst = this.animations[0]?.frames[0];\n\t\tif (quickFirst) {\n\t\t\treturn quickFirst;\n\t\t}\n\t\tfor (const animation of this.animations) {\n\t\t\tfor (const frame of animation.frames) {\n\t\t\t\treturn frame;\n\t\t\t}\n\t\t}\n\t\tassertFalse('object type has no frames');\n\t}\n\tset firstFrame(newFrame: AnimationFrame) {\n\t\tfor (const animation of this.animations) {\n\t\t\tfor (const frame of animation.frames) {\n\t\t\t\tframe.sprite = newFrame.sprite;\n\t\t\t\tframe.partFromPixelTransform = newFrame.partFromPixelTransform;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tconst firstAnimation = this.animations[0];\n\t\tif (firstAnimation !== undefined) {\n\t\t\tfirstAnimation.frames.push(newFrame);\n\t\t} else {\n\t\t\tthis.animations = [new Animation([newFrame])];\n\t\t}\n\t}\n\n\t*allFrames() {\n\t\tfor (const animation of this.animations) {\n\t\t\tfor (const frame of animation.frames) {\n\t\t\t\tyield frame;\n\t\t\t}\n\t\t}\n\t}\n\n\t*firstFrames() {\n\t\tfor (const animation of this.animations) {\n\t\t\tconst frame = animation.frames[0];\n\t\t\tif (frame) {\n\t\t\t\tyield frame;\n\t\t\t}\n\t\t}\n\t}\n\n\tnamedAnimations() {\n\t\treturn this.animations.flatMap(\n\t\t\t(animation) => animation.name !== null ? [animation.name] : []\n\t\t);\n\t}\n\n\tget sprite() {\n\t\treturn this.firstFrame.sprite;\n\t}\n\n\tget nonNullName() {\n\t\treturn this.name ?? '';\n\t}\n\tset nonNullName(name: string) {\n\t\tthis.name = name.length > 0 ? name : null;\n\t}\n\n\tget idSafeName() {\n\t\treturn this.name?.replace(/ /g, '_');\n\t}\n\n\tnameOrIndex(game: CoreGame) {\n\t\tconst objectIndex = () => game.objects.indexOf(this);\n\t\treturn this.name ? Quoting.args(qsT(this.name)) : WithNumberSign.args(objectIndex());\n\t}\n\n\tobjectOfType(game: CoreGame) {\n\t\treturn qsTr('object of type %1').args(this.nameOrIndex(game));\n\t}\n\n\tanObjectOfType(game: CoreGame) {\n\t\treturn qsTr('an object of type %1').args(this.nameOrIndex(game));\n\t}\n\n\tanimName(index: number) {\n\t\tconst animation = this.animations[index];\n\t\treturn animation?.name ?? (index === 0 ? AnimationIdleText : null);\n\t}\n\n\tnameOrRoles() {\n\t\treturn this.name !== null ?\n\t\t\tqsT(this.name) :\n\t\t\t[...this.roles].map((role) => qsT(role)).join(', ');\n\t}\n\n\tprivate static newId() {\n\t\t// eslint-disable-next-line no-underscore-dangle\n\t\tconst id = ObjectType._maxId;\n\t\t// eslint-disable-next-line no-underscore-dangle\n\t\tObjectType._maxId += 1;\n\t\treturn id;\n\t}\n\n\t/**\n\t * Second pass deserialisation\n\t * @param objectTypes already loaded object types (without their behaviours)\n\t */\n\tdeserialiseBehaviours(fbObjectType: CandliFB.ObjectType, game: CoreGame, fromVersion: number) {\n\t\tthis.behaviour = fromFbArrayWithFactory(fbObjectType, 'behaviour', decodeFbRow, game, fromVersion);\n\t}\n\n\tserialise(builder: flatbuffers.Builder, objectTypes: ObjectTypeIdMap, imageIndices: ImageIndices, roleNames: string[], keepLocking: boolean) {\n\t\t// single part body\n\t\tconst animationsOffset = CandliFB.SinglePartBody.createAnimationsVector(builder,\n\t\t\tthis.animations.map((animation) => animation.serialise(builder, imageIndices))\n\t\t);\n\t\tconst [shapeType, shapeOffset] = toFbAnyShape(builder, this.shape);\n\t\tconst textureImageIndex = defined(imageIndices.get(this.sprite))\n\t\tCandliFB.SinglePartBody.startSinglePartBody(builder);\n\t\tCandliFB.SinglePartBody.addShapeType(builder, shapeType);\n\t\tCandliFB.SinglePartBody.addShape(builder, shapeOffset);\n\t\tCandliFB.SinglePartBody.addAlpha(builder, this.alpha * 255);\n\t\tCandliFB.SinglePartBody.addAnimations(builder, animationsOffset);\n\t\tCandliFB.SinglePartBody.addPixelToBodyTransform(builder, toFbSimilarityTransform2(builder, this.firstFrame.partFromPixelTransform)); // for compatibility with old versions\n\t\tCandliFB.SinglePartBody.addTextureImageIndex(builder, textureImageIndex); // for compatibility with old versions\n\t\tconst singlePartBodyOffset = CandliFB.SinglePartBody.endSinglePartBody(builder);\n\t\t// behaviour\n\t\tconst behaviourOffset = CandliFB.ObjectType.createBehaviourVector(builder,\n\t\t\tthis.behaviour.map((rule) => serializeRow(rule, builder, objectTypes, keepLocking))\n\t\t);\n\t\t// name and roles\n\t\tconst nameOffset = this.name !== null ? builder.createString(this.name) : null;\n\t\tconst rolesIndices = [...this.roles].map((role, i) => {\n\t\t\tconst index = roleNames.indexOf(role);\n\t\t\tassertNonNegativeInteger(index, `role[${i}]`);\n\t\t\treturn index;\n\t\t})\n\t\tconst rolesOffset = CandliFB.ObjectType.createRolesVector(builder, rolesIndices);\n\t\t// object type itself, write in an order that optimises alignment\n\t\tCandliFB.ObjectType.startObjectType(builder);\n\t\tCandliFB.ObjectType.addStickiness(builder, this.stickiness);\n\t\tCandliFB.ObjectType.addBounciness(builder, this.bounciness);\n\t\tCandliFB.ObjectType.addDensity(builder, this.density);\n\t\tCandliFB.ObjectType.addRoles(builder, rolesOffset);\n\t\tif (nameOffset !== null) {\n\t\t\tCandliFB.ObjectType.addName(builder, nameOffset);\n\t\t}\n\t\tCandliFB.ObjectType.addCanRotate(builder, this._canRotate);\n\t\tCandliFB.ObjectType.addEditorLastTransform(builder,\n\t\t\ttoFbScalingRotation2(builder, this.lastScale, this.lastRotation)\n\t\t);\n\t\tCandliFB.ObjectType.addBehaviour(builder, behaviourOffset);\n\t\tCandliFB.ObjectType.addPartsType(builder, CandliFB.AnyBody.SinglePartBody);\n\t\tCandliFB.ObjectType.addParts(builder, singlePartBodyOffset);\n\t\tCandliFB.ObjectType.addKind(builder, this._kind as number);\n\t\tCandliFB.ObjectType.addEditionLocked(builder, keepLocking ? this.editLocked : false);\n\t\tCandliFB.ObjectType.addDeletionLocked(builder, keepLocking ? this.deleteLocked : false);\n\t\tCandliFB.ObjectType.addInstantiationLocked(builder, keepLocking ? this.instantiationLocked : false);\n\t\treturn CandliFB.ObjectType.endObjectType(builder);\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate() {\n\t\tassertInteger(this.id, 'id');\n\t\tassertStringOrNull(this.name, 'name');\n\t\tassertValidSetPrimitive('string', this.roles, 'roles');\n\t\tassertValidArrayType(Row, this.behaviour, 'behaviour');\n\t\tassertNumberRange(this._kind, ObjectType.Kind.Background, ObjectType.Kind.Foreground, '_kind');\n\t\tassertPositiveNumber(this.stickiness, 'stickiness');\n\t\tassertPositiveNumber(this.bounciness, 'bounciness');\n\t\tassertPositiveNumber(this.density, 'density');\n\t\tif (this.shape instanceof Array) {\n\t\t\tassertVector2Array(this.shape, 'shape');\n\t\t} else if (this.shape instanceof Vector2) {\n\t\t\tassertVector2(this.shape, 'shape');\n\t\t} else {\n\t\t\tassertStrictlyPositiveNumber(this.shape, 'shape');\n\t\t}\n\t\tassertPositiveNumber(this.boundingRadius, 'boundingRadius');\n\t\tassertNumberRange(this.alpha, 0, 1, 'alpha');\n\t\tassertValidArrayType(Animation, this.animations, 'animations');\n\t\tassertPositiveNumber(this.lastScale, 'lastScale');\n\t\tassertNumber(this.lastRotation, 'lastRotation');\n\t\tassertBoolean(this.editLocked, 'editLocked');\n\t\tassertBoolean(this.deleteLocked, 'deleteLocked');\n\t\tassertBoolean(this.instantiationLocked, 'instantiationLocked');\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: ObjectType, ctx: string) {\n\t\tassertMemberEqual(this, that, 'id', ctx);\n\t\tassertMemberEqual(this, that, 'name', ctx);\n\t\tassertMemberSetEqual(this, that, 'roles', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'behaviour', ctx);\n\t\tassertMemberEqual(this, that, 'kind', ctx);\n\t\tassertMemberNumberEqual(this, that, 'stickiness', ctx);\n\t\tassertMemberNumberEqual(this, that, 'bounciness', ctx);\n\t\tassertMemberNumberEqual(this, that, 'density', ctx);\n\t\tassertMemberEqual(this, that, 'canRotate', ctx);\n\t\tassertMemberEqualF(this, that, 'shape', assertShapeEqual, ctx);\n\t\tassertMemberNumberEqual(this, that, 'alpha', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'animations', ctx);\n\t\tassertMemberNumberEqual(this, that, 'lastScale', ctx);\n\t\tassertMemberNumberEqual(this, that, 'lastRotation', ctx);\n\t\tassertMemberEqual(this, that, 'editLocked', ctx);\n\t\tassertMemberEqual(this, that, 'deleteLocked', ctx);\n\t\tassertMemberEqual(this, that, 'instantiationLocked', ctx);\n\t\tassertMemberNumberEqual(this, that, 'boundingRadius', ctx);\n\t}\n\n\t/** Clone this object type. */\n\tclone() {\n\t\treturn cloneDeepWith(this, (val, key) => {\n\t\t\tif (key === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (key === 'id') {\n\t\t\t\treturn ObjectType.newId();\n\t\t\t}\n\t\t\tif (val instanceof Array) {\n\t\t\t\tif (key === 'behaviour') {\n\t\t\t\t\treturn val.map((rule) => cast(Row, rule).clone());\n\t\t\t\t}\n\t\t\t\tif (key === '_shape') {\n\t\t\t\t\treturn val.map((point) => cast(Vector2, point).clone());\n\t\t\t\t}\n\t\t\t\tif (key === 'animations') {\n\t\t\t\t\treturn val.map((animation) => cast(Animation, animation).clone());\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (val instanceof Vector2) {\n\t\t\t\treturn val.clone();\n\t\t\t}\n\t\t\tif (val instanceof SimilarityTransform) {\n\t\t\t\treturn val.clone();\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn clone<any>(val);\n\t\t}) as ObjectType;\n\t}\n\n\t/** Clone this object type but detach from the rest of the game (i.e. remove code) */\n\tcloneDetached() {\n\t\treturn cloneDeepWith(this, (val, key) => {\n\t\t\tif (key === undefined) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (key === 'id') {\n\t\t\t\treturn ObjectType.newId();\n\t\t\t}\n\t\t\tif (key === 'behaviour') {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tif (key === '_shape' && val instanceof Array) {\n\t\t\t\treturn val.map((point) => cast(Vector2, point).clone());\n\t\t\t}\n\t\t\tif (val instanceof AnimationFrame) {\n\t\t\t\treturn new AnimationFrame(val.sprite, val.partFromPixelTransform.clone());\n\t\t\t}\n\t\t\tif (val instanceof Vector2) {\n\t\t\t\treturn val.clone();\n\t\t\t}\n\t\t\tif (val instanceof SimilarityTransform) {\n\t\t\t\treturn val.clone();\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn clone<any>(val);\n\t\t}) as ObjectType;\n\t}\n\n\t/** return a polygon version of the shape */\n\tget polygonShape() {\n\t\t// FIXME: we now regenerate a circle for snapping, but ideally we should support snapping with a circle\n\t\treturn shapeToPolygon(this.shape);\n\t}\n\n\tget polygonShapeOrRadius() {\n\t\tif (typeof this.shape === 'number') {\n\t\t\treturn this.shape;\n\t\t} else {\n\t\t\treturn this.polygonShape;\n\t\t}\n\t}\n\n\t/** the type of physics and display order */\n\tget kind() {\n\t\treturn this._kind;\n\t}\n\tset kind(kind: ObjectType.Kind) {\n\t\tif (kind === this._kind) {\n\t\t\treturn;\n\t\t}\n\t\tthis._kind = kind;\n\t\t// make sure we only have compatible blocks with new physics\n\t\tif (this.isDynamic) {\n\t\t\treturn;\n\t\t}\n\t\t// if kinematic, replace all force and brake actions\n\t\tfor (const rule of this.behaviour) {\n\t\t\tfor (const [index, action] of rule.actions.entries()) {\n\t\t\t\tconst block = action.block;\n\t\t\t\tconst brakeAction = dynamicCast(BrakeBlock, block);\n\t\t\t\tconst speedAction = dynamicCast(SpeedBlock, block);\n\t\t\t\tconst angularSpeedAction = dynamicCast(AngularSpeedBlock, block);\n\t\t\t\tif (brakeAction) {\n\t\t\t\t\tdefined(rule.actions[index]).block = new StopBlock();\n\t\t\t\t} else if (speedAction) {\n\t\t\t\t\tspeedAction.mode = SpeedBlockMode.Velocity;\n\t\t\t\t} else if (angularSpeedAction) {\n\t\t\t\t\tangularSpeedAction.mode = AngularSpeedBlockMode.AngularVelocity;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/** whether the object is allowed to rotate */\n\tget canRotate() {\n\t\treturn this._canRotate;\n\t}\n\tset canRotate(canRotate: boolean) {\n\t\tif (canRotate === this._canRotate) {\n\t\t\treturn;\n\t\t}\n\t\tthis._canRotate = canRotate;\n\t\t// make sure we only have compatible blocks with new rotation option\n\t\tif (canRotate) {\n\t\t\treturn;\n\t\t}\n\t\t// if cannot rotate, remove rotation-related blocks\n\t\tfor (const rule of this.behaviour) {\n\t\t\tconst keptActions = [];\n\t\t\tfor (const action of rule.actions) {\n\t\t\t\tif (!(action instanceof AngularSpeedBlock)) {\n\t\t\t\t\tkeptActions.push(action);\n\t\t\t\t}\n\t\t\t}\n\t\t\trule.actions = keptActions;\n\t\t}\n\t}\n\n\t/** whether this object has dynamic physics (i.e. object or floating object) */\n\tget isDynamic() {\n\t\treturn this.kind === ObjectType.Kind.Dynamic;\n\t}\n\n\t/** whether this object takes part in physical collisions (i.e. not background or foreground) */\n\tget isCollidable() {\n\t\tconst isNotBackground = this.kind !== ObjectType.Kind.Background;\n\t\tconst isNotForeground = this.kind !== ObjectType.Kind.Foreground;\n\t\treturn isNotBackground && isNotForeground;\n\t}\n\n\t/** whether this object has animations */\n\tget hasAnimations() {\n\t\treturn this.animations.length > 1 || this.firstAnimation.frameCount > 1;\n\t}\n\n\t/** number of events in the behaviours */\n\tget conditionsCount() {\n\t\treturn this.behaviour.reduce((sum, rule) => sum + rule.conditions.length, 0);\n\t}\n\n\t/** number of actions in the behaviours */\n\tget actionsCount() {\n\t\treturn this.behaviour.reduce((sum, rule) => sum + rule.actions.length, 0);\n\t}\n\n\t/** whether this object is edit, delete and instantiation locked */\n\tget fullyLocked() {\n\t\treturn this.editLocked && this.instantiationLocked && this.deleteLocked;\n\t}\n\n\t/** Iterate over all blocks of a certain category in [[behaviour]] */\n\tprivate *blocksIterator(category: 'conditions' | 'actions'): IterableIterator<CandliBlockI> {\n\t\tfor (const rule of this.behaviour) {\n\t\t\tfor (const element of rule[category]) {\n\t\t\t\tyield element.block;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Iterate over all conditions of [[behaviour]] */\n\tconditionsIterator(): IterableIterator<CandliBlockI> {\n\t\treturn this.blocksIterator('conditions');\n\t}\n\n\t/** Iterate over all actions of [[behaviour]] */\n\tactionsIterator(): IterableIterator<CandliBlockI> {\n\t\treturn this.blocksIterator('actions');\n\t}\n\n\t/** Iterate over all blocks of a certain type in a certain category in [[behaviour]] */\n\tprivate *blocksIteratorByType<T extends CandliBlockI>(category: 'conditions' | 'actions', type: Constructor<T>): IterableIterator<T> {\n\t\tfor (const rule of this.behaviour) {\n\t\t\tfor (const element of rule[category]) {\n\t\t\t\tconst block = element instanceof Condition ? element.block : element.block;\n\t\t\t\tconst blockT = dynamicCast(type, block);\n\t\t\t\tif (blockT !== null) {\n\t\t\t\t\tyield blockT;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Iterate over all conditions of [[behaviour]] of a certain type */\n\tconditionsIteratorByType<T extends CandliBlockI>(type: Constructor<T>): IterableIterator<T> {\n\t\treturn this.blocksIteratorByType('conditions', type);\n\t}\n\n\t/** Iterate over all actions of [[behaviour]] of a certain type  */\n\tactionsIteratorByType<T extends CandliBlockI>(type: Constructor<T>): IterableIterator<T> {\n\t\treturn this.blocksIteratorByType('actions', type);\n\t}\n\n\t/** Return the number of [condition, action] blocks */\n\tblocksCount() {\n\t\tconst count: [number, number] = [0, 0];\n\t\tfor (const rule of this.behaviour) {\n\t\t\tcount[0] += rule.conditions.length;\n\t\t\tcount[1] += rule.actions.length;\n\t\t}\n\t\treturn count;\n\t}\n\n\t/** Return the number of conditions needing configuration */\n\tconditionsNeedingConfiguration() {\n\t\tlet count = 0;\n\t\tfor (const block of this.conditionsIterator()) {\n\t\t\tif (block.needsConfiguration(this)) {\n\t\t\t\tcount += 1;\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n\n\t/** Return the number of actions needing configuration */\n\tactionsNeedingConfiguration() {\n\t\tlet count = 0;\n\t\tfor (const block of this.actionsIterator()) {\n\t\t\tif (block.needsConfiguration(this)) {\n\t\t\t\tcount += 1;\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n\n\t/** Return the number of rows with conditions but no actions */\n\temptyConditionsCount() {\n\t\treturn this.behaviour.reduce(\n\t\t\t(sum, rule) => sum + (rule.conditions.length > 0 && rule.actions.length === 0 ? 1 : 0), 0\n\t\t);\n\t}\n\n\t/** Return the number of blocks that have been suppressed */\n\tsuppressedCount() {\n\t\treturn this.behaviour.reduce(\n\t\t\t(sum, rule) => sum + rule.effectSuppressedActions(this).length, 0\n\t\t);\n\t}\n\n\t/** Return the number of blocks needing configuration */\n\twarningsCount() {\n\t\treturn this.conditionsNeedingConfiguration() +\n\t\t\tthis.actionsNeedingConfiguration() +\n\t\t\tthis.emptyConditionsCount() +\n\t\t\tthis.suppressedCount();\n\t}\n\n\n\t/** the music atmospheres referenced in the behaviours */\n\tcollectMusicAtmospheres(atmospheres: Set<AtmosphereIndex>) {\n\t\tfor (const block of this.blocksIterator('actions')) {\n\t\t\tconst musicBlock = dynamicCast(MusicBlock, block);\n\t\t\tif (musicBlock !== null) {\n\t\t\t\tconst atmosphere = musicBlock.atmosphere;\n\t\t\t\tif (atmosphere !== null) {\n\t\t\t\t\tatmospheres.add(atmosphere);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Move an animation in all blocks */\n\tmoveAnimation(from: number, to: number) {\n\t\tif (from === to) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const animation of this.blocksIteratorByType('conditions', AnimationIsBlock)) {\n\t\t\tconst animations = [...animation.animations];\n\t\t\tfor (let i = 0; i < animations.length; i++) {\n\t\t\t\tmoveRange(from, to, defined(animations[i]), (index: number) => animations[i] = index);\n\t\t\t}\n\t\t\tanimation.animations = new Set(animations);\n\t\t}\n\t\tfor (const animation of this.blocksIteratorByType('actions', PlayAnimationBlock)) {\n\t\t\tif (animation.index === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmoveRange(from, to, animation.index, (index: number) => animation.index = index);\n\t\t}\n\t}\n\n\tdeleteAnimation(delIndex: number) {\n\t\tfor (const animation of this.blocksIteratorByType('conditions', AnimationIsBlock)) {\n\t\t\tconst set = new Set<number>();\n\t\t\tfor (const index of animation.animations) {\n\t\t\t\tif (index > delIndex) {\n\t\t\t\t\tset.add(index - 1);\n\t\t\t\t} else if (index < delIndex) {\n\t\t\t\t\tset.add(index);\n\t\t\t\t}\n\t\t\t\t// else: index === delIndex, do not add it, as it is the index to be deleted\n\t\t\t}\n\t\t\tanimation.animations = set;\n\t\t}\n\t\tfor (const animation of this.blocksIteratorByType('actions', PlayAnimationBlock)) {\n\t\t\tif (animation.index === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (animation.index === delIndex) {\n\t\t\t\tanimation.index = null;\n\t\t\t} else if (animation.index > delIndex) {\n\t\t\t\tanimation.index -= 1;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Count for each animation how many blocks refer to it */\n\tcountAnimationBlocks() {\n\t\tconst counts: Map<number, number> = new Map();\n\t\tconst inc = (index: number) => {\n\t\t\tlet count = counts.get(index) ?? 0;\n\t\t\tcount += 1;\n\t\t\tcounts.set(index, count);\n\t\t};\n\t\tfor (const animation of this.blocksIteratorByType('conditions', AnimationIsBlock)) {\n\t\t\tfor (const index of animation.animations) {\n\t\t\t\tinc(index);\n\t\t\t}\n\t\t}\n\t\tfor (const animation of this.blocksIteratorByType('actions', PlayAnimationBlock)) {\n\t\t\tif (animation.index === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tinc(animation.index);\n\t\t}\n\t\treturn counts;\n\t}\n\n\t/** Reset maxId, to only use from test code */\n\tstatic resetMaxId() {\n\t\t// eslint-disable-next-line no-underscore-dangle\n\t\tObjectType._maxId = 0;\n\t}\n\n\t/** Disable or enable some features of this object. */\n\tsetAvailability(disabled: boolean, path: string[]) {\n\t\tconst element = path[0];\n\t\tswitch (element) {\n\t\t\tcase 'editable': this.editLocked = disabled; break;\n\t\t\tcase 'deletable': this.deleteLocked = disabled; break;\n\t\t\tcase 'instantiable': this.instantiationLocked = disabled; break;\n\t\t\tcase 'interactable':\n\t\t\t\tthis.editLocked = disabled;\n\t\t\t\tthis.deleteLocked = disabled;\n\t\t\t\tthis.instantiationLocked = disabled;\n\t\t\t\tbreak;\n\t\t\tcase 'code': this.setCodeAvailability(disabled, path.slice(1)); break;\n\t\t\tdefault: console.warn(`Unknown object type feature \"${element}\" to set availability for.`);\n\t\t}\n\t}\n\n\t/** Disable or enable some features of the code. */\n\tsetCodeAvailability(disabled: boolean, path: string[]) {\n\t\tconst row = path[0];\n\t\tif (row === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tif (row === '*') {\n\t\t\tfor (let i = 0; i < this.behaviour.length; i++) {\n\t\t\t\tthis.setCodeRowAvailability(i, disabled, path.slice(1));\n\t\t\t}\n\t\t} else {\n\t\t\tconst setAvailability = (rowIndex: number) => {\n\t\t\t\tif (rowIndex < 0 || rowIndex >= this.behaviour.length) {\n\t\t\t\t\tconsole.warn(`Invalid row ${rowIndex} to set availability for.`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.setCodeRowAvailability(rowIndex, disabled, path.slice(1));\n\t\t\t}\n\t\t\tconst indexes = indexOrInterval(row);\n\t\t\tif (Array.isArray(indexes)) {\n\t\t\t\tfor (let i = indexes[0]; i <= indexes[1]; i++) {\n\t\t\t\t\tsetAvailability(i);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsetAvailability(indexes);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Disable or enable some features of a row in the code. */\n\tsetCodeRowAvailability(index: number, disabled: boolean, path: string[]) {\n\t\tconst row = defined(this.behaviour[index]);\n\t\tif (path.length === 1) {\n\t\t\t// row-level property\n\t\t\tconst property = path[0];\n\t\t\tif (property === 'movable') {\n\t\t\t\trow.movementLocked = disabled;\n\t\t\t} else if (property === 'extendableConditions') {\n\t\t\t\trow.conditionsExtendLocked = disabled;\n\t\t\t} else if (property === 'extendableActions') {\n\t\t\t\trow.actionsExtendLocked = disabled;\n\t\t\t} else if (property === 'editable') {\n\t\t\t\trow.movementLocked = disabled;\n\t\t\t\trow.conditionsExtendLocked = disabled;\n\t\t\t\trow.actionsExtendLocked = disabled;\n\t\t\t\tthis.setCodeBlocksAvailability(row.conditions, disabled, ['*', 'editable'], 'condition', index);\n\t\t\t\tthis.setCodeBlocksAvailability(row.actions, disabled, ['*', 'editable'], 'action', index);\n\t\t\t} else {\n\t\t\t\tconsole.warn(`Unknown row-level property \"${property}\" to set availability for.`);\n\t\t\t}\n\t\t} else {\n\t\t\t// block-level property\n\t\t\tconst category = path[0];\n\t\t\tlet unset = true;\n\t\t\tif (category === '*' || category === 'condition') {\n\t\t\t\tthis.setCodeBlocksAvailability(row.conditions, disabled, path.slice(1), 'condition', index);\n\t\t\t\tunset = false;\n\t\t\t}\n\t\t\tif (category === '*' || category === 'action') {\n\t\t\t\tthis.setCodeBlocksAvailability(row.actions, disabled, path.slice(1), 'action', index);\n\t\t\t\tunset = false;\n\t\t\t}\n\t\t\tif (unset) {\n\t\t\t\tconsole.warn(`Unknown block type \"${category}\" to set availability for.`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Disable or enable some features of a conditions or actions in the code. */\n\tsetCodeBlocksAvailability(blocks: CandliCondition[] | CandliAction[], disabled: boolean, path: string[], category: string, rowIndex: number) {\n\t\tconst name = path[0];\n\t\tlet selectedBlocks;\n\t\tif (name === '*') {\n\t\t\tselectedBlocks = blocks.map((element) => element.block);\n\t\t} else {\n\t\t\tselectedBlocks = [];\n\t\t\tconst blockIndex = Number(name);\n\t\t\tif (Number.isInteger(blockIndex)) {\n\t\t\t\tif (blockIndex < 0 || blockIndex >= blocks.length) {\n\t\t\t\t\tconsole.warn(`Invalid block index ${blockIndex} for ${category} of row ${rowIndex} to set availability for.`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tselectedBlocks.push(defined(blocks[blockIndex]?.block));\n\t\t\t} else {\n\t\t\t\tfor (const element of blocks) {\n\t\t\t\t\tconst block = element.block;\n\t\t\t\t\tif (block.type === name) {\n\t\t\t\t\t\tselectedBlocks.push(block);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst property = path[1];\n\t\tfor (const block of selectedBlocks) {\n\t\t\tif (property === 'editable') {\n\t\t\t\tblock.editLocked = disabled;\n\t\t\t} else if (property === 'movable') {\n\t\t\t\tblock.movementLocked = disabled;\n\t\t\t} else if (property === 'parametrisable') {\n\t\t\t\tblock.parametersLocked = disabled;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`Unknown block-level property \"${property}\" to set availability for.`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Reset to default the availability of all features of this object. */\n\tresetAvailability() {\n\t\tthis.editLocked = false;\n\t\tthis.deleteLocked = false;\n\t\tthis.instantiationLocked = false;\n\t\tfor (const rule of this.behaviour) {\n\t\t\trule.movementLocked = false;\n\t\t\trule.conditionsExtendLocked = false;\n\t\t\trule.actionsExtendLocked = false;\n\t\t\tfor (const condition of rule.conditions) {\n\t\t\t\tcondition.block.movementLocked = false;\n\t\t\t\tcondition.block.parametersLocked = false;\n\t\t\t}\n\t\t\tfor (const action of rule.actions) {\n\t\t\t\taction.block.movementLocked = false;\n\t\t\t\taction.block.parametersLocked = false;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport namespace ObjectType {\n\t/** Type of physics and display order game objects follow. */\n\texport const enum Kind {\n\t\t/** touch detection with all, physics interaction with none, controlled in speed */\n\t\tBackground,\n\t\t/** touch detection with all but other [[Kind.Kinematic], physics interaction with [[Kind.Dynamic]], controlled in speed */\n\t\tKinematic,\n\t\t/** touch detection with all, physics interaction with all but [[Kind.Background]], controlled in force, subject to gravity */\n\t\tDynamic,\n\t\t/** touch detection with all, physics interaction with none, controlled in speed */\n\t\tForeground\n\t}\n\t/** All valid object kind strings */\n\texport const KindStrings = ['background', 'kinematic', 'dynamic', 'foreground'] as const;\n\t/** A string representation of an object kind */\n\texport type KindString = typeof KindStrings[number];\n\t/** Get a kind from a string */\n\texport function kindFromString(s: KindString) {\n\t\tswitch (s) {\n\t\t\tcase 'background': return Kind.Background;\n\t\t\tcase 'kinematic': return Kind.Kinematic;\n\t\t\tcase 'dynamic': return Kind.Dynamic;\n\t\t\tcase 'foreground': return Kind.Foreground;\n\t\t}\n\t}\n}\n\nexport type ObjectInstanceIdMap = Map<ObjectInstance, number>;\n\n/**\n * The runtime camera.\n */\nexport class Camera {\n\t/** the size in world unit of the smallest side of the camera's viewport */\n\textent: Vector2;\n\t/** the object being tracked, or the world position of the camera's center */\n\ttrackedObjectOrPosition: ObjectInstance | Vector2;\n\t/** the background color of the world */\n\t_backgroundColor!: Color;\n\t/** the RGB string of the background color */\n\t_backgroundColorRgbHexString!: string;\n\t/** the free motion box's fractions */\n\tfreeMotionBoxFractions: Vector2;\n\t/** the displacement of the center */\n\tcenterDisplacement: Vector2;\n\n\tconstructor()\n\tconstructor(fbCamera: CandliFB.Camera, objectInstances: ObjectInstance[]);\n\tconstructor(fbCamera?: CandliFB.Camera, objectInstances?: ObjectInstance[]) {\n\t\tif (fbCamera === undefined) {\n\t\t\tthis.extent = Vector2.fromScalar(CameraDefaultExtent);\n\t\t\tthis.trackedObjectOrPosition = new Vector2();\n\t\t\tthis.backgroundColor = new Color(CameraDefaultBackgroundColor);\n\t\t\tthis.freeMotionBoxFractions = new Vector2();\n\t\t\tthis.centerDisplacement = new Vector2();\n\t\t} else {\n\t\t\tconst extentX = fbCamera.extentX();\n\t\t\tconst extentY = fbCamera.extentY() !== 0 ? fbCamera.extentY() : extentX;\n\t\t\tthis.extent = new Vector2(extentX, extentY);\n\t\t\tconst type = fbCamera.trackedObjectOrPositionType();\n\t\t\tif (type === CandliFB.CameraTrackedObjectOrPosition.CameraTrackedObject) {\n\t\t\t\tconst cameraTrackedObject = nonnull(fbCamera.trackedObjectOrPosition(new CandliFB.CameraTrackedObject()));\n\t\t\t\tthis.trackedObjectOrPosition = defined(objectInstances![cameraTrackedObject.instance()]);\n\t\t\t} else if (type === CandliFB.CameraTrackedObjectOrPosition.CameraPosition) {\n\t\t\t\tconst cameraPosition = nonnull(fbCamera.trackedObjectOrPosition(new CandliFB.CameraPosition())) as CandliFB.CameraPosition;\n\t\t\t\tthis.trackedObjectOrPosition = fromFbVector2(cameraPosition.position());\n\t\t\t} else {\n\t\t\t\tassertFalse(`Unknown CameraTrackedObjectOrPosition type ${type}`);\n\t\t\t}\n\t\t\tconst backgroundColor = fbCamera.backgroundColor();\n\t\t\tthis.backgroundColor = backgroundColor !== null ?\n\t\t\t\tColor.fromRgbNumber(backgroundColor.bgra()) :\n\t\t\t\tnew Color(CameraDefaultBackgroundColor)\n\t\t\t;\n\t\t\tthis.freeMotionBoxFractions = fromFbVector2(fbCamera.freeMotionBoxFractions());\n\t\t\tthis.centerDisplacement = fromFbVector2(fbCamera.centerDisplacement());\n\t\t}\n\t}\n\n\tget backgroundColor() {\n\t\treturn this._backgroundColor;\n\t}\n\tset backgroundColor(color: Color) {\n\t\tthis._backgroundColor = color;\n\t\tthis._backgroundColorRgbHexString = color.rgbHexString;\n\t}\n\tget backgroundColorRgbHexString() {\n\t\treturn this._backgroundColorRgbHexString;\n\t}\n\n\t/** the position of the camera (if detached), or of the object's center (if attached) */\n\tget position() {\n\t\tif (this.trackedObjectOrPosition instanceof Vector2) {\n\t\t\treturn this.trackedObjectOrPosition;\n\t\t} else {\n\t\t\treturn this.trackedObjectOrPosition.pose.translation;\n\t\t}\n\t}\n\n\t/** the tracked object (if attached), or null (if detached) */\n\tget trackedObject() {\n\t\tif (this.trackedObjectOrPosition instanceof ObjectInstance) {\n\t\t\treturn this.trackedObjectOrPosition;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** whether the camera is attached to an object */\n\tget isAttached() {\n\t\treturn this.trackedObject !== null;\n\t}\n\n\tget extentAspectRatio() {\n\t\treturn this.extent.x / this.extent.y;\n\t}\n\n\tserialise(builder: flatbuffers.Builder, objectInstances: ObjectInstanceIdMap) {\n\t\tconst trackedObjectOrPositionType =\n\t\t\tthis.trackedObjectOrPosition instanceof ObjectInstance ?\n\t\t\t\tCandliFB.CameraTrackedObjectOrPosition.CameraTrackedObject :\n\t\t\t\tCandliFB.CameraTrackedObjectOrPosition.CameraPosition\n\t\t;\n\t\tconst trackedObjectOrPositionOffset =\n\t\t\tthis.trackedObjectOrPosition instanceof ObjectInstance ?\n\t\t\t\tCandliFB.CameraTrackedObject.createCameraTrackedObject(builder,\n\t\t\t\t\tdefined(objectInstances.get(this.trackedObjectOrPosition))\n\t\t\t\t) :\n\t\t\t\tCandliFB.CameraPosition.createCameraPosition(builder,\n\t\t\t\t\ttoFbVector2(builder, this.trackedObjectOrPosition)\n\t\t\t\t)\n\t\t;\n\t\tCandliFB.Camera.startCamera(builder);\n\t\tCandliFB.Camera.addExtentX(builder, this.extent.x);\n\t\tCandliFB.Camera.addExtentY(builder, this.extent.y);\n\t\tCandliFB.Camera.addTrackedObjectOrPositionType(builder, trackedObjectOrPositionType);\n\t\tCandliFB.Camera.addTrackedObjectOrPosition(builder, trackedObjectOrPositionOffset);\n\t\tCandliFB.Camera.addBackgroundColor(builder,\n\t\t\ttoFbColorPacked32(builder, this.backgroundColor)\n\t\t);\n\t\tCandliFB.Camera.addFreeMotionBoxFractions(builder, toFbVector2(builder, this.freeMotionBoxFractions));\n\t\tCandliFB.Camera.addCenterDisplacement(builder, toFbVector2(builder, this.centerDisplacement));\n\t\treturn CandliFB.Camera.endCamera(builder);\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate() {\n\t\tassertPositiveNumber(this.extent.x, 'extentX');\n\t\tassertPositiveNumber(this.extent.y, 'extentY');\n\t\tif (this.trackedObjectOrPosition instanceof Vector2) {\n\t\t\tassertVector2(this.trackedObjectOrPosition, 'trackedObjectOrPosition');\n\t\t} else {\n\t\t\tassertType(ObjectInstance, this.trackedObjectOrPosition, 'trackedObjectOrPosition');\n\t\t}\n\t\tassertColor(this.backgroundColor, 'backgroundColor');\n\t\tassertVector2(this.freeMotionBoxFractions, 'freeMotionBoxFractions');\n\t\tassertVector2(this.centerDisplacement, 'centerDisplacement');\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: Camera, ctx: string) {\n\t\tassertMemberVector2Equal(this, that, 'extent', ctx);\n\t\tassertMemberVector2Equal(this, that, 'position', ctx);\n\t\tassertMemberEqualM(this, that, 'trackedObject', ctx);\n\t\tassertMemberColorEqual(this, that, 'backgroundColor', ctx);\n\t\tassertMemberVector2Equal(this, that, 'freeMotionBoxFractions', ctx);\n\t\tassertMemberVector2Equal(this, that, 'centerDisplacement', ctx);\n\t}\n}\n\n/**\n * An instance of game object.\n */\nexport class ObjectInstance {\n\t// FIXME: after switch to Flatbuffers, rename pose into poseAndScale\n\t/** the pose in the level */\n\tpublic pose: SimilarityTransform;\n\t/** whether the pose of can be modified in the editor */\n\tpublic movementLocked: boolean;\n\t/** whether the object can be deleted in the editor */\n\tpublic deleteLocked: boolean;\n\t/** whether the object can be copied in the editor */\n\tpublic copyLocked: boolean;\n\t/** whether the object can be selected in the editor */\n\tpublic selectionLocked: boolean;\n\t/** the initial values of the object variables */\n\tpublic variables: Map<number, number>;\n\t/** the type of this instance */\n\tpublic type: ObjectType;\n\n\t/**\n\t * Constructor.\n\t */\n\tconstructor(type: ObjectType, pose: SimilarityTransform);\n\tconstructor(fbObjectInstance: CandliFB.ObjectInstance, objectTypes: ObjectType[]);\n\tconstructor(\n\t\ttypeOrFbObjectInstance: ObjectType | CandliFB.ObjectInstance,\n\t\tposeOrObjectTypes: SimilarityTransform | ObjectType[]\n\t) {\n\t\tif (typeOrFbObjectInstance instanceof ObjectType) {\n\t\t\t// normal constructor\n\t\t\tthis.pose = (poseOrObjectTypes as SimilarityTransform).clone();\n\t\t\tthis.movementLocked = false;\n\t\t\tthis.deleteLocked = false;\n\t\t\tthis.copyLocked = false;\n\t\t\tthis.selectionLocked = false;\n\t\t\tthis.variables = new Map();\n\t\t\tthis.type = typeOrFbObjectInstance;\n\t\t} else {\n\t\t\t// deserialiser\n\t\t\tthis.pose = fromFbSimilarityTransform2(typeOrFbObjectInstance.poseAndScale());\n\t\t\tif (typeOrFbObjectInstance.editionLocked()) {\n\t\t\t\tthis.movementLocked = true;\n\t\t\t\tthis.deleteLocked = true;\n\t\t\t\tthis.copyLocked = true;\n\t\t\t\tthis.selectionLocked = true;\n\t\t\t} else {\n\t\t\t\tthis.movementLocked = typeOrFbObjectInstance.movementLocked();\n\t\t\t\tthis.deleteLocked = typeOrFbObjectInstance.deletionLocked();\n\t\t\t\tthis.copyLocked = typeOrFbObjectInstance.copyLocked();\n\t\t\t\tthis.selectionLocked = typeOrFbObjectInstance.selectionLocked();\n\t\t\t}\n\t\t\tconst variableArray = fromFbArrayWithFactory(typeOrFbObjectInstance, 'variables',\n\t\t\t\t(fbVariable: CandliFB.VariableIndexAndValue) => [fbVariable.index(), fbVariable.value()] as const\n\t\t\t);\n\t\t\tthis.variables = new Map(variableArray);\n\t\t\tconst objectTypes = poseOrObjectTypes as ObjectType[];\n\t\t\tthis.type = nonnull(fromFbObjectTypeRef(typeOrFbObjectInstance.type(), objectTypes));\n\t\t}\n\t}\n\n\t/** this instance is not locked in any way */\n\tget fullyEditable() {\n\t\treturn !this.movementLocked && !this.deleteLocked && !this.copyLocked;\n\t}\n\t/** this instance is fully editable and selectable */\n\tget fullyEditableAndSelectable() {\n\t\treturn this.fullyEditable && !this.selectionLocked;\n\t}\n\t/** make this instance fully editable  */\n\tsetFullyEditableAndSelectable() {\n\t\tthis.movementLocked = false;\n\t\tthis.deleteLocked = false;\n\t\tthis.copyLocked = false;\n\t\tthis.selectionLocked = false;\n\t}\n\t/** make this instance not editable in any way */\n\tsetFullyEditAndSelectionLocked() {\n\t\tthis.movementLocked = true;\n\t\tthis.deleteLocked = true;\n\t\tthis.copyLocked = true;\n\t\tthis.selectionLocked = true;\n\t}\n\n\t/** the sprite of this instance */\n\tget firstFrame(): AnimationFrame {\n\t\treturn this.type.firstFrame;\n\t}\n\n\t/** the distance of the furthest point from the object center */\n\tget boundingRadius(): number {\n\t\treturn this.type.boundingRadius * this.pose.scaleFactor;\n\t}\n\n\t/**\tthe shape of the object, in world coordinates by applying the pose to the type's shape */\n\tget polygonShape() {\n\t\treturn transformVectors2(this.type.polygonShape, this.pose);\n\t}\n\n\t/** the axis-aligned bounding box of the object */\n\taabb() {\n\t\treturn Rect.fromPoints(this.polygonShape);\n\t}\n\n\tserialise(builder: flatbuffers.Builder, objectTypes: ObjectTypeIdMap, keepLocking: boolean) {\n\t\t// first add the list of variables\n\t\tCandliFB.ObjectInstance.startVariablesVector(builder, this.variables.size);\n\t\t// we create structs in reverse because Flatbuffers builds vectors back to front\n\t\tfor (const [index, value] of Array.from(this.variables).reverse()) {\n\t\t\tCandliFB.VariableIndexAndValue.createVariableIndexAndValue(builder, index, value);\n\t\t}\n\t\tconst variables = builder.endVector();\n\t\t// write in an order that optimises alignment\n\t\tCandliFB.ObjectInstance.startObjectInstance(builder);\n\t\tCandliFB.ObjectInstance.addPoseAndScale(builder,\n\t\t\ttoFbSimilarityTransform2(builder, this.pose)\n\t\t);\n\t\tCandliFB.ObjectInstance.addType(builder,\n\t\t\ttoFbObjectTypeRef(this.type, objectTypes)\n\t\t);\n\t\tCandliFB.ObjectInstance.addMovementLocked(builder, keepLocking ? this.movementLocked : false);\n\t\tCandliFB.ObjectInstance.addDeletionLocked(builder, keepLocking ? this.deleteLocked : false);\n\t\tCandliFB.ObjectInstance.addCopyLocked(builder, keepLocking ? this.copyLocked : false);\n\t\tCandliFB.ObjectInstance.addSelectionLocked(builder, keepLocking ? this.selectionLocked : false);\n\t\tCandliFB.ObjectInstance.addVariables(builder, variables);\n\t\treturn CandliFB.ObjectInstance.endObjectInstance(builder);\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate() {\n\t\tassertType(ObjectType, this.type, 'type');\n\t\tassertSimilarityTransform(this.pose, 'pose');\n\t\tassertBoolean(this.movementLocked, 'movementLocked');\n\t\tassertBoolean(this.deleteLocked, 'deleteLocked');\n\t\tassertBoolean(this.copyLocked, 'copyLocked');\n\t\tassertBoolean(this.selectionLocked, 'selectionLocked');\n\t\tassertValidMapPrimitive('number', 'number', this.variables, 'variables');\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: ObjectInstance, ctx: string) {\n\t\tassertMemberEqualM(this, that, 'type', ctx);\n\t\tassertMemberSimilarityTransformEqual(this, that, 'pose', ctx);\n\t\tassertMemberEqual(this, that, 'movementLocked', ctx);\n\t\tassertMemberEqual(this, that, 'deleteLocked', ctx);\n\t\tassertMemberEqual(this, that, 'copyLocked', ctx);\n\t\tassertMemberEqual(this, that, 'selectionLocked', ctx);\n\t\tassertMemberMapEqual(this, that, 'variables', ctx);\n\t}\n\n\t/**\n\t * Duplicate this object instance, and remove locking.\n\t * @returns a deep copy of this object instance, except for the object type\n\t */\n\tduplicate() {\n\t\tconst newObject = new ObjectInstance(this.type, this.pose);\n\t\t// newObject.movementLocked = this.movementLocked;\n\t\t// newObject.deleteLocked = this.deleteLocked;\n\t\t// newObject.copyLocked = this.copyLocked;\n\t\t// newObject.selectionLocked = this.selectionLocked;\n\t\tnewObject.variables = new Map(this.variables);\n\t\treturn newObject;\n\t}\n\n\t/** Disable or enable some features of this object. */\n\tsetAvailability(disabled: boolean, feature: string) {\n\t\tswitch (feature) {\n\t\t\tcase 'movable': this.movementLocked = disabled; break;\n\t\t\tcase 'deletable': this.deleteLocked = disabled; break;\n\t\t\tcase 'copyable': this.copyLocked = disabled; break;\n\t\t\tcase 'selectable': this.selectionLocked = disabled; break;\n\t\t\tcase 'editable':\n\t\t\t\tthis.movementLocked = disabled;\n\t\t\t\tthis.deleteLocked = disabled;\n\t\t\t\tthis.copyLocked = disabled;\n\t\t\t\tthis.selectionLocked = disabled;\n\t\t\t\tbreak;\n\t\t\tdefault: console.warn(`Unknown object instance feature \"${feature}\" to set availability for.`);\n\t\t}\n\t}\n\n\t/** Reset to default the availability of all features of this object. */\n\tresetAvailability() {\n\t\tthis.movementLocked = false;\n\t\tthis.deleteLocked = false;\n\t\tthis.copyLocked = false;\n\t\tthis.selectionLocked = false;\n\t}\n}\n\nfunction areInstanceSameKindAndDoTheyOverlap(instance0: ObjectInstance, instance1: ObjectInstance) {\n\tif (instance0.type.kind !== instance1.type.kind) {\n\t\treturn false;\n\t}\n\tconst dist = instance0.pose.translation.dist(instance1.pose.translation);\n\treturn dist < instance0.boundingRadius + instance1.boundingRadius;\n}\n\n/**\n * A game level.\n */\nexport class Level {\n\t/** The scale of this level in the editor */\n\tpublic editorScale: number;\n\t/** The position of this level in the editor */\n\tpublic editorPosition: Vector2;\n\t/** The camera for this level */\n\tpublic camera: Camera;\n\t/** The gravity for this level */\n\tpublic gravity: number;\n\t/**  global \"air\" friction for world damping */\n\tpublic airFriction: number;\n\t/** All object instances for this level */\n\tpublic objects: ObjectInstance[];\n\n\tconstructor();\n\tconstructor(fbLevel: CandliFB.Level, objectTypes: ObjectType[]);\n\tconstructor(fbLevel?: CandliFB.Level, objectTypes?: ObjectType[]) {\n\t\tif (fbLevel === undefined) {\n\t\t\t// empty constructor\n\t\t\tthis.editorScale = EditorDefaultScale;\n\t\t\tthis.editorPosition = new Vector2();\n\t\t\tthis.camera = new Camera();\n\t\t\tthis.gravity = LevelDefaultGravity;\n\t\t\tthis.airFriction = LevelDefaultAirFriction;\n\t\t\tthis.objects = [];\n\t\t} else {\n\t\t\t// deserialiser\n\t\t\tconst editorToWorld = fbLevel.editorToWorld();\n\t\t\tif (editorToWorld !== null) {\n\t\t\t\tconst [invScale, position] = fromFbScalingTranslation2(editorToWorld);\n\t\t\t\tthis.editorScale = 1 / invScale;\n\t\t\t\tthis.editorPosition = position;\n\t\t\t} else {\n\t\t\t\tthis.editorScale = EditorDefaultScale;\n\t\t\t\tthis.editorPosition = new Vector2();\n\t\t\t}\n\t\t\tthis.gravity = fbLevel.gravity();\n\t\t\tthis.airFriction = fbLevel.airFriction();\n\t\t\tthis.objects = fromFbArray(fbLevel, 'objectInstances', ObjectInstance, objectTypes!);\n\t\t\tthis.camera = new Camera(nonnull(fbLevel.camera()), this.objects);\n\t\t}\n\t}\n\n\t/** inverse of [[editorScale]] */\n\tget editorInvScale(): number {\n\t\treturn 1 / this.editorScale;\n\t}\n\tset editorInvScale(invScale: number) {\n\t\tthis.editorScale = 1 / invScale;\n\t}\n\n\t/** transform for taking an object from the editor frame to the world frame */\n\tget editorToWorld() {\n\t\treturn SimilarityTransform.scalingTranslation(this.editorInvScale, this.editorPosition);\n\t}\n\n\tserialise(builder: flatbuffers.Builder, objectTypes: ObjectTypeIdMap, keepLocking: boolean) {\n\t\tconst objectInstancesOffset = CandliFB.Level.createObjectInstancesVector(builder,\n\t\t\tthis.objects.map((object) => object.serialise(builder, objectTypes, keepLocking))\n\t\t);\n\t\tconst cameraOffset = this.camera.serialise(builder, this.buildObjectInstanceIdMap());\n\t\tCandliFB.Level.startLevel(builder);\n\t\tCandliFB.Level.addObjectInstances(builder, objectInstancesOffset);\n\t\tCandliFB.Level.addCamera(builder, cameraOffset);\n\t\tCandliFB.Level.addGravity(builder, this.gravity);\n\t\tCandliFB.Level.addAirFriction(builder, this.airFriction);\n\t\tCandliFB.Level.addEditorToWorld(builder,\n\t\t\ttoFbScalingTranslation2(builder, this.editorInvScale, this.editorPosition)\n\t\t);\n\t\treturn CandliFB.Level.endLevel(builder);\n\t}\n\n\tprivate buildObjectInstanceIdMap() {\n\t\treturn new Map(this.objects.map((object, i) => [object, i]));\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate() {\n\t\tassertPositiveNumber(this.editorScale, 'editorScale');\n\t\tassertVector2(this.editorPosition, 'editorPosition');\n\t\tassertValidType(Camera, this.camera, 'camera');\n\t\tassertNumber(this.gravity, 'gravity');\n\t\tassertPositiveNumber(this.airFriction, 'airFriction');\n\t\tassertValidArrayType(ObjectInstance, this.objects, 'objects');\n\t}\n\n\t/**\n\t * Clone this level, with a deep clone of instances set to editLocked, and a deep clone of editor pose,\n\t * but a shallow clone otherwise.\n\t */\n\tfrozenInstanceClone() {\n\t\tconst level = clone(this);\n\t\tlevel.editorPosition = level.editorPosition.clone();\n\t\tconst newInstances = level.objects.map((instance) => {\n\t\t\tconst newInstance = clone(instance);\n\t\t\tnewInstance.setFullyEditAndSelectionLocked();\n\t\t\treturn newInstance;\n\t\t});\n\t\tlevel.objects = newInstances;\n\t\treturn level;\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: Level, ctx: string) {\n\t\tassertMemberNumberEqual(this, that, 'editorScale', ctx);\n\t\tassertMemberVector2Equal(this, that, 'editorPosition', ctx);\n\t\tassertMemberEqualM(this, that, 'camera', ctx);\n\t\tassertMemberNumberEqual(this, that, 'gravity', ctx);\n\t\tassertMemberNumberEqual(this, that, 'airFriction', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'objects', ctx);\n\t}\n\n\t/**\n\t * Delete an object instance\n\t * @param indexOrObjectInstance\tthe instance of an object in [[objects]] or its index\n\t * @returns the object instance just deleted from the level\n\t */\n\tdeleteObjectInstance(indexOrObjectInstance: number | ObjectInstance) {\n\t\t// find the object instance index\n\t\tlet index: number;\n\t\tif (indexOrObjectInstance instanceof ObjectInstance) {\n\t\t\tindex = this.objects.indexOf(indexOrObjectInstance);\n\t\t} else {\n\t\t\tindex = indexOrObjectInstance;\n\t\t}\n\t\tassertNonNegativeInteger(index, 'instance index');\n\t\t// delete the object instance\n\t\tconst object = defined(this.objects.splice(index, 1)[0]);\n\t\t// if attached to camera, detach it\n\t\tif (this.camera.trackedObject === object) {\n\t\t\tthis.camera.trackedObjectOrPosition = object.pose.translation;\n\t\t}\n\t\treturn object;\n\t}\n\n\t/**\n\t * Compute the bounding rectangle of all objects, excluding margins.\n\t * @returns the bounding rectangle, excluding margins\n\t */\n\tcomputeSceneBounds(): Rect {\n\t\tif (this.objects.length === 0) {\n\t\t\treturn new Rect(0, 0, 0, 0);\n\t\t}\n\t\tlet bounds = null;\n\t\tfor (const object of this.objects) {\n\t\t\tconst extent = object.boundingRadius;\n\t\t\tconst size = new Vector2(extent * 2, extent * 2);\n\t\t\tconst objectBound = Rect.fromCenterAndSize(object.pose.translation, size);\n\t\t\tif (bounds === null) {\n\t\t\t\tbounds = objectBound;\n\t\t\t} else {\n\t\t\t\tbounds = bounds.union(objectBound);\n\t\t\t}\n\t\t}\n\t\treturn nonnull(bounds);\n\t}\n\n\t/**\n\t * Compute the bounds of the world, including margins.\n\t * @returns the bounding rectangle, including margins\n\t */\n\tcomputeWorldBounds(): Rect {\n\t\tif (this.objects.length === 0) {\n\t\t\tconst extent = WorldWindowMarginConstant;\n\t\t\treturn new Rect(-extent, -extent, 2 * extent, 2 * extent);\n\t\t}\n\t\tlet bounds = null;\n\t\tfor (const object of this.objects) {\n\t\t\tconst extent = WorldWindowMarginConstant + object.boundingRadius * WorldWindowMarginProportional;\n\t\t\tconst size = new Vector2(extent * 2, extent * 2);\n\t\t\tconst objectBound = Rect.fromCenterAndSize(object.pose.translation, size);\n\t\t\tif (bounds === null) {\n\t\t\t\tbounds = objectBound;\n\t\t\t} else {\n\t\t\t\tbounds = bounds.union(objectBound);\n\t\t\t}\n\t\t}\n\t\treturn nonnull(bounds);\n\t}\n\n\t/**\n\t * Iterate object instances, considering layers\n\t * @param frontToBack whether to iterate front to back (default: false, back to front)\n\t * @param type if not null, return only instances of that type\n\t * @param layers an array that tells, for each layer, whether it is editable or not\n\t * @returns all objects, per layer\n\t */\n\t*iterateObjectInstances(frontToBack = false, type: ObjectType | null = null, layers: [boolean, boolean, boolean, boolean] | null = null): Generator<[ObjectInstance, number], void, any> {\n\t\tif (frontToBack) {\n\t\t\tfor (let layer = 3; layer >= 0; --layer) {\n\t\t\t\tif (layers !== null && !layers[layer]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (let i = this.objects.length - 1; i >= 0; --i) {\n\t\t\t\t\tconst object = this.objects[i]!;\n\t\t\t\t\tif (object.type.kind as number !== layer) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (type === null || object.type === type) {\n\t\t\t\t\t\tyield [object, i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (let layer = 0; layer < 4; ++layer) {\n\t\t\t\tif (layers !== null && !layers[layer]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (let i = 0; i < this.objects.length; ++i) {\n\t\t\t\t\tconst object = this.objects[i]!;\n\t\t\t\t\tif (object.type.kind as number !== layer) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (type === null || object.type === type) {\n\t\t\t\t\t\tyield [object, i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Iterator all object instances, apply [[action]] to the ones that match [[[filter]].\n\t * @param filter whether action should be applied\n\t * @param action modifier to apply to object instance.\n\t */\n\tmodifyObjectInstances(filter: (object: ObjectInstance) => boolean, action: (object: ObjectInstance) => void) {\n\t\tfor (const [object, _] of this.iterateObjectInstances()) {\n\t\t\tif (filter(object)) {\n\t\t\t\taction(object);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Count the number of instances of a given type in the level\n\t * @param type if not null, count only instances of that type\n\t */\n\tcountInstancesOfType(type: ObjectType | null = null) {\n\t\tlet count = 0;\n\t\tfor (const object of this.objects) {\n\t\t\tif (type === null || object.type === type) {\n\t\t\t\tcount += 1;\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * Return the closest instance of a given type to a position, null if none.\n\t */\n\tgetClosestInstanceOfType(type: ObjectType, position: Vector2) {\n\t\tlet bestInstance = null;\n\t\tlet bestDist2 = Number.MAX_VALUE;\n\t\tfor (const o of this.objects) {\n\t\t\tif (o.type === type) {\n\t\t\t\tconst dist2 = o.pose.translation.dist2(position);\n\t\t\t\tif (dist2 < bestDist2) {\n\t\t\t\t\tbestInstance = o;\n\t\t\t\t\tbestDist2 = dist2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn bestInstance;\n\t}\n\n\t/**\n\t * Move object instance up once on the z-order, do nothing if not in level or already at the top\n\t * @param instance instance to move up\n\t */\n\tmoveInstanceZUp(instance: ObjectInstance) {\n\t\tlet index = this.objects.indexOf(instance);\n\t\tif (index < 0) {\n\t\t\treturn;\n\t\t}\n\t\t// put the object after the next object of the same kind\n\t\tthis.objects.splice(index, 1);\n\t\twhile (index < this.objects.length) {\n\t\t\tif (areInstanceSameKindAndDoTheyOverlap(defined(this.objects[index]), instance)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tindex += 1;\n\t\t}\n\t\tthis.objects.splice(index + 1, 0, instance);\n\t}\n\n\t/**\n\t * Move object instance down once on the z-order, do nothing if not in level or already at the bottom\n\t * @param instance instance to move down\n\t */\n\tmoveInstanceZDown(instance: ObjectInstance) {\n\t\tlet index = this.objects.indexOf(instance);\n\t\tif (index < 0) {\n\t\t\treturn;\n\t\t}\n\t\t// put the object before the previous object of the same kind\n\t\tthis.objects.splice(index, 1);\n\t\twhile (index > 0) {\n\t\t\tindex -= 1;\n\t\t\tif (areInstanceSameKindAndDoTheyOverlap(defined(this.objects[index]), instance)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tthis.objects.splice(index, 0, instance);\n\t}\n\n\t/** Disable or enable some features of object instances in this level. */\n\tsetAvailability(disabled: boolean, feature: string, target: ObjectType[] | number | null) {\n\t\tif (target === null) {\n\t\t\tthis.modifyObjectInstances(_ => true, oi => oi.setAvailability(disabled, feature));\n\t\t} else if (target instanceof Array) {\n\t\t\tconst targetSet = new Set([...target]);\n\t\t\tthis.modifyObjectInstances(\n\t\t\t\toi => targetSet.has(oi.type),\n\t\t\t\toi => oi.setAvailability(disabled, feature)\n\t\t\t);\n\t\t} else {\n\t\t\tthis.objects[target]?.setAvailability(disabled, feature);\n\t\t}\n\t}\n\n\t/** Reset to default the availability of all features of all object instances of this level. */\n\tresetAvailability() {\n\t\tfor (const oi of this.objects) {\n\t\t\toi.resetAvailability();\n\t\t}\n\t}\n}\n\n/** An ancillary object during iteration in [[Level.blockWithContextIterator]] */\nexport interface BlockWithContext {\n\tobjectType: ObjectType;\n\tobjectTypeIndex: number;\n\trule: CandliRow;\n\truleIndex: number;\n\tcategory: 'conditions' | 'actions';\n\tblock: CandliBlock;\n\tblockIndex: number;\n}\n\n/** An dialog or end game screen */\nexport class Dialog {\n\t/** the main square image of the screen */\n\tpublic image: Drawable;\n\t/** the background color around that image */\n\tpublic backgroundColor: Color;\n\t/** the scaling factor for this end screen */\n\tpublic scaleFactor: number;\n\n\t/**\n\t * Constructor\n\t */\n\tconstructor(image: Drawable, backgroundColor: Color, scaleFactor: number);\n\tconstructor(fbDialog: CandliFB.Dialog, imageDecoder: ImageDecoder);\n\tconstructor(\n\t\timageOrFbDialog: Drawable | CandliFB.Dialog,\n\t\tbackgroundColorOrImageDecoder: Color | ImageDecoder,\n\t\tscaleFactor?: number\n\t) {\n\t\tif (imageOrFbDialog instanceof CandliFB.Dialog) {\n\t\t\t// deserialiser\n\t\t\tconst imageDecoder = backgroundColorOrImageDecoder as ImageDecoder;\n\t\t\tthis.image = imageDecoder(imageOrFbDialog.imageIndex());\n\t\t\tthis.backgroundColor = fromFbColorPacked32(imageOrFbDialog.backgroundColor());\n\t\t\tthis.scaleFactor = imageOrFbDialog.scaleFactor();\n\t\t} else {\n\t\t\t// normal constructor\n\t\t\tthis.image = imageOrFbDialog;\n\t\t\tthis.backgroundColor = backgroundColorOrImageDecoder as Color;\n\t\t\tthis.scaleFactor = scaleFactor ?? 1;\n\t\t}\n\t}\n\n\tserialise(builder: flatbuffers.Builder, imageIndices: ImageIndices) {\n\t\treturn CandliFB.Dialog.createDialog(builder,\n\t\t\ttoFbColorPacked32(builder, this.backgroundColor),\n\t\t\tdefined(imageIndices.get(this.image)),\n\t\t\tthis.scaleFactor\n\t\t);\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: Dialog, ctx: string) {\n\t\t// use reference equality\n\t\tassertMemberEqual(this, that, 'image', ctx);\n\t\tassertMemberColorEqual(this, that, 'backgroundColor', ctx);\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate() {\n\t\tdefined(this.image);\n\t\tthis.image.validate();\n\t\tassertType(Color, this.backgroundColor, 'backgroundColor');\n\t}\n}\n\n/** A variable name */\nexport class VariableName {\n\t/** the image representing the variable */\n\tpublic image: Drawable | null;\n\tpublic name: string | null;\n\tpublic type: ScriptVariableType | null;\n\n\t/**\n\t * Constructor\n\t */\n\tconstructor(imageOrName: Drawable | string);\n\tconstructor(fbVariableName: number | CandliFB.VariableName, imageDecoder: ImageDecoder);\n\tconstructor(imageOrNameOrIndexOrFb: Drawable | string | CandliFB.VariableName | number, imageDecoder?: ImageDecoder) {\n\t\tif (imageOrNameOrIndexOrFb instanceof CandliFB.VariableName) {\n\t\t\t// deserialiser\n\t\t\tthis.name = imageOrNameOrIndexOrFb.name();\n\t\t\tconst imageIndex = imageOrNameOrIndexOrFb.imageIndex();\n\t\t\tif (imageIndex !== 0xffff) {\n\t\t\t\tthis.image = imageDecoder!(imageIndex);\n\t\t\t} else {\n\t\t\t\tthis.image = null;\n\t\t\t}\n\t\t\tconst typeName = imageOrNameOrIndexOrFb.type();\n\t\t\tthis.type = typeName !== null ? new ScriptVariableType(typeName) : null;\n\t\t\tthis.validate();\n\t\t} else if (typeof imageOrNameOrIndexOrFb === 'string') {\n\t\t\t// normal constructor, string\n\t\t\tthis.image = null;\n\t\t\tthis.name = imageOrNameOrIndexOrFb;\n\t\t\tthis.type = null;\n\t\t} else if (typeof imageOrNameOrIndexOrFb === 'number') {\n\t\t\t// compatibility constructor, index\n\t\t\tthis.image = imageDecoder!(imageOrNameOrIndexOrFb);\n\t\t\tthis.name = null;\n\t\t\tthis.type = null;\n\t\t} else {\n\t\t\t// normal constructor, image\n\t\t\tthis.image = imageOrNameOrIndexOrFb;\n\t\t\tthis.name = null;\n\t\t\tthis.type = null;\n\t\t}\n\t}\n\n\tserialise(builder: flatbuffers.Builder, imageIndices: ImageIndices, scriptCtx: ScriptCtx) {\n\t\tconst nameOffset = this.name !== null ? builder.createString(this.name) : null;\n\t\tconst typeName: string | null = this.type !== null ? scriptCtx.type_name(this.type) : null;\n\t\tconst typeOffset = typeName !== null ? builder.createString(typeName) : null;\n\t\tCandliFB.VariableName.startVariableName(builder);\n\t\tif (this.image !== null) {\n\t\t\tCandliFB.VariableName.addImageIndex(builder, defined(imageIndices.get(this.image)));\n\t\t}\n\t\tif (nameOffset !== null) {\n\t\t\tCandliFB.VariableName.addName(builder, nameOffset);\n\t\t}\n\t\tif (typeOffset !== null) {\n\t\t\tCandliFB.VariableName.addType(builder, typeOffset);\n\t\t}\n\t\treturn CandliFB.VariableName.endVariableName(builder);\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: VariableName, ctx: string) {\n\t\t// use reference equality\n\t\tassertMemberEqual(this, that, 'image', ctx);\n\t\tassertMemberEqual(this, that, 'name', ctx);\n\t\tassertMemberEqualF(this, that, 'type', assertScriptVariableTypeEqual, ctx);\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate() {\n\t\tassert(this.image !== undefined || this.name !== undefined, 'VariableName must have at least one of image or name');\n\t\tthis.image?.validate();\n\t}\n}\n\nfunction assertScriptVariableTypeEqual(lhs: ScriptVariableType, rhs: ScriptVariableType, ctx: string) {\n\tassert(lhs.is_equal(rhs), `ScriptVariableType ${toStr(lhs)} is not equal to ${toStr(rhs)} in ${ctx}`);\n}\n\n/** A variable in the global scope */\nexport class Variable {\n\tconstructor(\n\t\tpublic name: VariableName,\n\t\tpublic visible: boolean\n\t) {}\n\n\tassertEqual(that: Variable, ctx: string) {\n\t\t// use reference equality\n\t\tassertMemberEqualM(this, that, 'name', ctx);\n\t\tassertMemberEqual(this, that, 'visible', ctx);\n\t}\n\n\tvalidate() {\n\t\tthis.name.validate();\n\t}\n}\n\nexport interface GameCoreSerialisedOffsets {\n\tobjectTypes: number;\n\tdialogs: number;\n\tlevels: number;\n\tvariableNames: number;\n\tvariableVisibility: number;\n\troleNames: number;\n\tscriptDependencies: number;\n\tscriptModules: number;\n\tlimitOverrides: number;\n}\n\n/** A basic script module name and code */\nexport class ScriptModule {\n\t/** the name of the module, used as the top-level module of this script */\n\tpublic name: string;\n\t/** the source code of the script */\n\tpublic code: string;\n\n\tconstructor(name: string, code: string);\n\tconstructor(fbScriptModule: CandliFB.ScriptModule);\n\tconstructor(fbScriptModuleOrName: CandliFB.ScriptModule | string, code?: string) {\n\t\tif (fbScriptModuleOrName instanceof CandliFB.ScriptModule) {\n\t\t\tthis.name = fbScriptModuleOrName.name() ?? '';\n\t\t\tthis.code = fbScriptModuleOrName.code() ?? '';\n\t\t} else {\n\t\t\tthis.name = fbScriptModuleOrName;\n\t\t\tthis.code = code ?? '';\n\t\t}\n\t}\n\n\tserialise(builder: flatbuffers.Builder) {\n\t\tconst nameOffset = builder.createString(this.name);\n\t\tconst codeOffset = builder.createString(this.code);\n\t\tCandliFB.ScriptModule.startScriptModule(builder);\n\t\tCandliFB.ScriptModule.addName(builder, nameOffset);\n\t\tCandliFB.ScriptModule.addCode(builder, codeOffset);\n\t\treturn CandliFB.ScriptModule.endScriptModule(builder);\n\t}\n\n\tassertEqual(that: ScriptModule, ctx: string) {\n\t\tassertMemberEqual(this, that, 'name', ctx);\n\t\tassertMemberEqual(this, that, 'code', ctx);\n\t}\n\n\tvalidate() {\n\t\tassertString(this.name, 'name');\n\t\tassertString(this.code, 'code');\n\t}\n}\n\n/** A loaded (but not compiled) script package, that is, a module and a path for its origin */\nexport class ScriptPackage extends ScriptModule {\n\tconstructor(\n\t\t/** the dependency path to the script, if external */\n\t\tpublic path: string,\n\t\t/** the name of the package, used as the top-level module of this script */\n\t\tname: string,\n\t\t/** the source code of the script */\n\t\tcode: string\n\t) {\n\t\tsuper(name, code);\n\t}\n\n\tassertEqual(that: ScriptPackage, ctx: string) {\n\t\tsuper.assertEqual(that, ctx);\n\t\tassertMemberEqual(this, that, 'path', ctx);\n\t}\n\n\tvalidate() {\n\t\tsuper.validate();\n\t\tassertString(this.path, 'path');\n\t\tconst locator = ScriptPackageLocator.parseDependencyPath(this.path);\n\t\tassertString(locator.owner, 'locator.owner');\n\t\tassertString(locator.packageName, 'locator.packageName');\n\t\tassertString(locator.version, 'locator.version');\n\t}\n}\n\n/**\n * A game that can be run in a headless runtime.\n */\nexport class CoreGame {\n\tpublic dataVersion: number;\n\tpublic objects: ObjectType[];\n\tpublic dialogs: Dialog[];\n\tpublic level: Level;\n\tpublic twoPlayers: boolean;\n\tpublic variables: Variable[]; // index here is index from address - 1\n\tpublic sounds: Sound[];\n\tpublic scriptPackages: ScriptPackage[];\n\tpublic scriptModules: ScriptModule[];\n\tpublic scriptCtx: ScriptCtx;\n\tpublic limitOverrides: Map<string, number>;\n\tpublic limitOverridesDuplicationCounter: number;\n\n\tconstructor();\n\tconstructor(fbGame: CandliFB.Game, imageDecoder: ImageDecoder, sounds: Sound[], scripts: ScriptPackage[]);\n\tconstructor(fbGame?: CandliFB.Game, imageDecoder?: ImageDecoder, sounds?: Sound[], scripts?: ScriptPackage[]) {\n\t\tif (fbGame === undefined) {\n\t\t\t// empty constructor\n\t\t\tthis.dataVersion = CurrentDataVersion;\n\t\t\tthis.objects = [];\n\t\t\tthis.dialogs = [];\n\t\t\tthis.level = new Level();\n\t\t\tthis.twoPlayers = false;\n\t\t\tthis.variables = [];\n\t\t\tthis.sounds = [];\n\t\t\tthis.scriptPackages = [];\n\t\t\tthis.scriptModules = [];\n\t\t\tthis.scriptCtx = this.recompileGameScripts();\n\t\t\tthis.limitOverrides = new Map();\n\t\t\tthis.limitOverridesDuplicationCounter = 0;\n\t\t} else {\n\t\t\t// deserialiser\n\t\t\tconst imgDecoder = imageDecoder!;\n\t\t\tthis.sounds = sounds!;\n\t\t\tthis.scriptPackages = scripts!;\n\n\t\t\t// check version, allow limited backward but not forward compatibility\n\t\t\tconst dataVersion = fbGame.dataVersion();\n\t\t\tif (dataVersion > CurrentDataVersion) {\n\t\t\t\tthrow Error(`Game data version (${dataVersion}) is more recent than mine (${CurrentDataVersion})`);\n\t\t\t} else if (dataVersion < OldestLoadableDataVersion) {\n\t\t\t\tthrow Error(`Game data version (${dataVersion}) is older than oldest supported (${OldestLoadableDataVersion})`);\n\t\t\t}\n\t\t\tthis.dataVersion = CurrentDataVersion;\n\n\t\t\t// load settings\n\t\t\tthis.twoPlayers = fbGame.twoPlayers();\n\n\t\t\t// load variable names\n\t\t\tconst variableVisibility = fromFbArrayWithFactory(fbGame, 'variableVisibility', (x: boolean | null) => x ?? true);\n\t\t\tconst oldVarNameLength = fbGame.oldVariableNamesLength();\n\t\t\tconst newVarNameLength = fbGame.variableNamesLength();\n\t\t\tlet variableNames: VariableName[] = [];\n\t\t\tif (newVarNameLength > 0) {\n\t\t\t\t// new variables, load\n\t\t\t\tvariableNames = fromFbArray(fbGame, 'variableNames', VariableName, imgDecoder);\n\t\t\t} else if (oldVarNameLength > 0) {\n\t\t\t\t// old variables, migrate\n\t\t\t\t// Note: due to limitations in Typescript, all generic parameters must be specified\n\t\t\t\tvariableNames = fromFbArray<VariableName, number, CandliFB.Game, 'oldVariableNames', [ImageDecoder]>(fbGame, 'oldVariableNames', VariableName, imgDecoder);\n\t\t\t} else {\n\t\t\t\tthis.variables = [];\n\t\t\t}\n\t\t\tthis.variables = variableNames.map((name, i) => new Variable(name, variableVisibility[i] ?? true));\n\n\t\t\t// load internal scripts and compile game-wide scripts\n\t\t\tthis.scriptModules = fromFbArray(fbGame, 'scriptModules', ScriptModule);\n\t\t\tthis.scriptCtx = this.recompileGameScripts();\n\n\t\t\t// first pass: load object types core data\n\t\t\tconst roleNames: string[] = fromFbArrayIdentity(fbGame, 'roleNames');\n\t\t\tthis.objects = fromFbArray(fbGame, 'objectTypes', ObjectType, imgDecoder, roleNames);\n\n\t\t\t// second pass: load behaviours so that blocks can resolve dependencies\n\t\t\tthis.objects.forEach((object, i) => {\n\t\t\t\tobject.deserialiseBehaviours(nonnull(fbGame.objectTypes(i)), this, dataVersion);\n\t\t\t});\n\n\t\t\t// load dialogs\n\t\t\tthis.dialogs = fromFbArray(fbGame, 'dialogs', Dialog, imgDecoder);\n\n\t\t\t// load levels\n\t\t\tconst levelsCount = fbGame.levelsLength();\n\t\t\tassert(levelsCount === 1, `Need 1 level, found ${levelsCount}`);\n\t\t\tthis.level = new Level(nonnull(fbGame.levels(0)), this.objects);\n\n\t\t\t// load limit overrides\n\t\t\tconst limitOverrides = fromFbArrayWithFactory(fbGame, 'limitOverrides',\n\t\t\t\t(fbLimit: CandliFB.LimitOverride) => [fbLimit.name(), fbLimit.value()] as const\n\t\t\t);\n\t\t\tconst limitLimitOverrides = limitOverrides.flatMap(\n\t\t\t\t([name, value]) => {\n\t\t\t\t\tif (name === null) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\tconst validLimit = toLimitName(name);\n\t\t\t\t\tif (validLimit === undefined) {\n\t\t\t\t\t\treturn [];\n\t\t\t\t\t}\n\t\t\t\t\treturn [[validLimit, value]] as const;\n\t\t\t\t}\n\t\t\t);\n\t\t\tthis.limitOverrides = new Map(limitLimitOverrides);\n\t\t\tthis.limitOverridesDuplicationCounter = fbGame.limitOverrideDuplicationCounter();\n\t\t}\n\t}\n\n\t/**\n\t * Compile all game-wide (but not block-level) scripts, including external ones.\n\t * @param resetSharedEnv whether to reset the shared module environment before compiling\n\t */\n\trecompileGameScripts() {\n\t\tconst builder = new ScriptCtxBuilder();\n\n\t\t// set variable names\n\t\tbuilder.set_game_variables([\n\t\t\tnew OptScriptVariable('score', undefined),\n\t\t\t...this.variables.map(\n\t\t\t\t(variable) => new OptScriptVariable(\n\t\t\t\t\tvariable.name.name ?? undefined,\n\t\t\t\t\tvariable.name?.type?.clone() ?? undefined\n\t\t\t\t)\n\t\t\t)\n\t\t]);\n\n\t\t// compile external scripts\n\t\tfor (const script of this.scriptPackages) {\n\t\t\ttry {\n\t\t\t\tbuilder.stage_module(script.name, script.code);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(`Failed to load script package ${script.name} from ${script.path}: ${e}`);\n\t\t\t}\n\t\t}\n\t\tbuilder.commit_staged_modules();\n\t\tbuilder.fix_game_env();\n\n\t\t// compile internal scripts\n\t\tfor (const script of this.scriptModules) {\n\t\t\ttry {\n\t\t\t\tbuilder.stage_module(script.name, script.code);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(`Failed to load script module ${script.name}: ${e}`);\n\t\t\t}\n\t\t}\n\t\tbuilder.commit_staged_modules();\n\n\t\t// return the context with all Candli modules loaded\n\t\treturn builder.to_ctx({\n\t\t\tgetCandliVariable,\n\t\t\tgetScriptVariable,\n\t\t\trandInt: randIntInclusiveRange,\n\t\t}, {\n\t\t\tlog,\n\t\t\tsetCandliVariable,\n\t\t\tsetScriptVariable,\n\t\t\tcheckPoint,\n\t\t\topenURL,\n\t\t\tclearCanvas,\n\t\t\tdrawText,\n\t\t\tdrawLine,\n\t\t\tdrawRect,\n\t\t\tfillRect,\n\t\t\tdrawEllipse,\n\t\t\tfillEllipse,\n\t\t\tsetFontSize,\n\t\t\tsetTextAlignment,\n\t\t\tsetTextColor,\n\t\t\tsetStrokeColor,\n\t\t\tsetFillColor,\n\t\t\tattachCamera,\n\t\t}, {\n\t\t\tspawn: spawnObject,\n\t\t}, {\n\t\t\tsessionId: gameSessionId,\n\t\t}, {\n\t\t\tlog: logGameEvent,\n\t\t}, {\n\t\t\tactive: textInputActive,\n\t\t\ttext: getTextInput,\n\t\t}, {\n\t\t\tstart: startTextInput,\n\t\t\tstop: stopTextInput,\n\t\t}, {\n\t\t\tisSupported: isSpeechRecognitionSupported,\n\t\t\thasResult: hasSpeechRecognitionResult,\n\t\t\thasError: hasSpeechRecognitionError,\n\t\t}, {\n\t\t\tstart: startSpeechRecognition,\n\t\t\tstop: stopSpeechRecognition,\n\t\t\tgetResult: getSpeechRecognitionResult,\n\t\t\tgetError: getSpeechRecognitionError,\n\t\t}, {\n\t\t\thasResponse: hasLlmResponse,\n\t\t}, {\n\t\t\tnewConversation: newLlmConversation,\n\t\t\task: askLlm,\n\t\t\tgetResponse: getLlmResponse,\n\t\t}, {\n\t\t\tgetPilaCompetency,\n\t\t}, {\n\t\t\tsetPilaCompetency,\n\t\t});\n\t}\n\n\t/**\n\t * Replace content of [[this]] with the one of [[that]].\n\t * Content is not removed from [[that]].\n\t * @param that the game whose content have to be put to [[this]]\n\t */\n\treplaceWith(that: CoreGame) {\n\t\tthis.dataVersion = that.dataVersion;\n\t\tthis.objects = that.objects;\n\t\tthis.dialogs = that.dialogs;\n\t\tthis.level = that.level;\n\t\tthis.twoPlayers = that.twoPlayers;\n\t\tthis.variables = that.variables;\n\t\tthis.sounds = that.sounds;\n\t\tthis.scriptPackages = that.scriptPackages;\n\t\tthis.scriptModules = that.scriptModules;\n\t\tthis.scriptCtx = that.scriptCtx;\n\t\tthis.limitOverrides = that.limitOverrides;\n\t\tthis.limitOverridesDuplicationCounter = that.limitOverridesDuplicationCounter;\n\t}\n\n\t/** Serialise all children and return their indices */\n\tserialiseChildren(builder: flatbuffers.Builder, imageIndices: ImageIndices, keepLocking: boolean): GameCoreSerialisedOffsets {\n\t\t// build object types map and list of roles\n\t\tconst objectTypeIdMap = this.buildObjectTypeIdMap();\n\t\tconst roleNames = this.collectRoleNames();\n\t\t// serialise children\n\t\treturn {\n\t\t\tobjectTypes: CandliFB.Game.createObjectTypesVector(builder,\n\t\t\t\tthis.objects.map((object) => object.serialise(builder, objectTypeIdMap, imageIndices, roleNames, keepLocking))\n\t\t\t),\n\t\t\tlevels: CandliFB.Game.createLevelsVector(builder,\n\t\t\t\t[this.level.serialise(builder, objectTypeIdMap, keepLocking)]\n\t\t\t),\n\t\t\tdialogs: CandliFB.Game.createDialogsVector(builder,\n\t\t\t\tthis.dialogs.map((dialog) => dialog.serialise(builder, imageIndices))\n\t\t\t),\n\t\t\tvariableNames: CandliFB.Game.createVariableNamesVector(builder,\n\t\t\t\tthis.variables.map((variable) => variable.name.serialise(builder, imageIndices, this.scriptCtx))\n\t\t\t),\n\t\t\tvariableVisibility: CandliFB.Game.createVariableVisibilityVector(builder,\n\t\t\t\tthis.variables.map((variable) => variable.visible)\n\t\t\t),\n\t\t\troleNames: CandliFB.Game.createRoleNamesVector(builder,\n\t\t\t\troleNames.map((roleName) => builder.createString(roleName))\n\t\t\t),\n\t\t\tscriptDependencies: CandliFB.Game.createScriptDependenciesVector(builder,\n\t\t\t\tthis.scriptPackages.map((dependency) => builder.createString(dependency.path))\n\t\t\t),\n\t\t\tscriptModules: CandliFB.Game.createScriptModulesVector(builder,\n\t\t\t\tthis.scriptModules.map((module) => module.serialise(builder))\n\t\t\t),\n\t\t\tlimitOverrides: CandliFB.Game.createLimitOverridesVector(builder,\n\t\t\t\tArray.from(this.limitOverrides.entries()).map(([name, value]) => {\n\t\t\t\t\tconst nameOffset = builder.createString(name);\n\t\t\t\t\treturn CandliFB.LimitOverride.createLimitOverride(builder, nameOffset, value);\n\t\t\t\t})\n\t\t\t),\n\t\t};\n\t}\n\n\t/** Serialise indices of core game elements */\n\tserialiseSelf(builder: flatbuffers.Builder, offsets: GameCoreSerialisedOffsets) {\n\t\tCandliFB.Game.addDataVersion(builder, this.dataVersion);\n\t\tCandliFB.Game.addObjectTypes(builder, offsets.objectTypes);\n\t\tCandliFB.Game.addLevels(builder, offsets.levels);\n\t\tCandliFB.Game.addDialogs(builder, offsets.dialogs);\n\t\tCandliFB.Game.addTwoPlayers(builder, this.twoPlayers);\n\t\tCandliFB.Game.addVariableNames(builder, offsets.variableNames);\n\t\tCandliFB.Game.addVariableVisibility(builder, offsets.variableVisibility);\n\t\tCandliFB.Game.addRoleNames(builder, offsets.roleNames);\n\t\tCandliFB.Game.addScriptDependencies(builder, offsets.scriptDependencies);\n\t\tCandliFB.Game.addScriptModules(builder, offsets.scriptModules);\n\t\tCandliFB.Game.addLimitOverrides(builder, offsets.limitOverrides);\n\t\tCandliFB.Game.addLimitOverrideDuplicationCounter(builder, this.limitOverridesDuplicationCounter);\n\t}\n\n\t/** Get a map of drawables to a unique index */\n\tprotected collectImageIndices(): ImageIndices {\n\t\tconst imageIndices: ImageIndices = new Map();\n\t\tconst insert = (drawable: Drawable) => {\n\t\t\tif (!imageIndices.has(drawable)) {\n\t\t\t\timageIndices.set(drawable, imageIndices.size);\n\t\t\t}\n\t\t};\n\t\tfor (const object of this.objects) {\n\t\t\tfor (const animation of object.animations) {\n\t\t\t\tfor (const frame of animation.frames) {\n\t\t\t\t\tinsert(frame.sprite);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const endScreen of this.dialogs) {\n\t\t\tinsert(endScreen.image);\n\t\t}\n\t\tfor (const variable of this.variables) {\n\t\t\tif (variable.name.image !== null) {\n\t\t\t\tinsert(variable.name.image);\n\t\t\t}\n\t\t}\n\t\treturn imageIndices;\n\t}\n\n\t/** Return a vector of all used roles with each one being unique */\n\tcollectRoleNames() {\n\t\tconst roleNamesWithDup = (this.objects.map((object) => [...object.roles]));\n\t\treturn [...new Set(roleNamesWithDup.flat())];\n\t}\n\n\t/** If there is still duplication with limit override available, decrement counter,\n\t * otherwise, clear limits.\n\t */\n\tconsumeOneLimitOverrideDuplication() {\n\t\tif (this.limitOverridesDuplicationCounter > 0) {\n\t\t\tthis.limitOverridesDuplicationCounter -= 1;\n\t\t} else {\n\t\t\tthis.limitOverrides.clear();\n\t\t}\n\t}\n\n\t/** Return the object type of a given name, or null if none find. */\n\tobjectTypeByName(name: string) {\n\t\tfor (const object of this.objects) {\n\t\t\tif (object.name === name) {\n\t\t\t\treturn object;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/** Return a vector of object types matching the name or the role */\n\tobjectTypesFromNameOrRole(nameOrRole: string) {\n\t\tif (nameOrRole === '*') {\n\t\t\treturn this.objects;\n\t\t}\n\t\tconst objects = [];\n\t\tfor (const object of this.objects) {\n\t\t\tif (object.idSafeName === nameOrRole) {\n\t\t\t\treturn [object];\n\t\t\t} else if (object.roles.has(nameOrRole)) {\n\t\t\t\tobjects.push(object);\n\t\t\t}\n\t\t}\n\t\treturn objects;\n\t}\n\n\tbuildObjectTypeIdMap() {\n\t\treturn new Map(this.objects.map((object, i) => [object, i]));\n\t}\n\n\t/** Iterate over all conditions of a certain type */\n\t*conditionsIteratorByType<T extends CandliBlockI>(type: Constructor<T>): IterableIterator<T> {\n\t\tfor (const object of this.objects) {\n\t\t\tfor (const block of object.conditionsIteratorByType(type)) {\n\t\t\t\tyield block;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Iterate over all actions of a certain type */\n\t*actionsIteratorByType<T extends CandliBlockI>(type: Constructor<T>): IterableIterator<T> {\n\t\tfor (const object of this.objects) {\n\t\t\tfor (const block of object.actionsIteratorByType(type)) {\n\t\t\t\tyield block;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Ensure data integrity by checking that they are of the right type and valid.\n\t */\n\tvalidate(acceptLocking = false) {\n\t\tassertNonNegativeInteger(this.dataVersion, 'dataVersion');\n\t\tassertValidArrayType(ObjectType, this.objects, 'objects');\n\t\tassertValidArrayType(Dialog, this.dialogs, 'dialogs');\n\t\tassertValidType(Level, this.level, 'level');\n\t\tassertBoolean(this.twoPlayers, 'twoPlayers');\n\t\tassertValidArrayType(Variable, this.variables, 'variables');\n\t\tassertValidArrayType(ScriptPackage, this.scriptPackages, 'scriptPackages');\n\t\tassertValidArrayType(ScriptModule, this.scriptModules, 'scriptModules');\n\t\tassertValidMapPrimitive('string', 'number', this.limitOverrides, 'limitOverrides');\n\t\tassertNonNegativeInteger(this.limitOverridesDuplicationCounter, 'limitOverridesDuplicationCounter');\n\n\t\tif (!acceptLocking) {\n\t\t\tfor (const [i, object] of this.objects.entries()) {\n\t\t\t\tassertL(!object.editLocked, () => `Object type ${i} is edit-locked`);\n\t\t\t\tassertL(!object.instantiationLocked, () => `Object type ${i} is instantiation-locked`);\n\t\t\t\tfor (const [j, rule] of object.behaviour.entries()) {\n\t\t\t\t\tassertL(!rule.movementLocked, () => `Object type ${i} rule ${j} is movement-locked`);\n\t\t\t\t\tassertL(!rule.conditionsExtendLocked, () => `Object type ${i} rule ${j} is conditions-extend-locked`);\n\t\t\t\t\tassertL(!rule.actionsExtendLocked, () => `Object type ${i} rule ${j} is actions-extend-locked`);\n\t\t\t\t\tfor (const [k, condition] of rule.conditions.entries()) {\n\t\t\t\t\t\tassertL(!condition.block.movementLocked, () => `Object type ${i} rule ${j} condition ${k} is movement-locked`);\n\t\t\t\t\t\tassertL(!condition.block.parametersLocked, () => `Object type ${i} rule ${j} condition ${k} is parameters-locked`);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const [k, action] of rule.actions.entries()) {\n\t\t\t\t\t\tassertL(!action.block.movementLocked, () => `Object type ${i} rule ${j} action ${k} is movement-locked`);\n\t\t\t\t\t\tassertL(!action.block.parametersLocked, () => `Object type ${i} rule ${j} action ${k} is parameters-locked`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [i, object] of this.level.objects.entries()) {\n\t\t\t\tassertL(!object.movementLocked, () => `Object instance ${i} is movement-locked`);\n\t\t\t\tassertL(!object.deleteLocked, () => `Object instance ${i} is delete-locked`);\n\t\t\t\tassertL(!object.copyLocked, () => `Object instance ${i} is copy-locked`);\n\t\t\t\tassertL(!object.selectionLocked, () => `Object instance ${i} is selection-locked`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Compare this to that, and aborts if they are different\n\t * @param that other to compare to\n\t * @param ctx debug context\n\t */\n\tassertEqual(that: CoreGame, ctx: string) {\n\t\tassertMemberEqual(this, that, 'dataVersion', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'objects', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'dialogs', ctx);\n\t\tassertMemberEqualM(this, that, 'level', ctx);\n\t\tassertMemberEqual(this, that, 'twoPlayers', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'variables', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'scriptPackages', ctx);\n\t\tassertMemberArrayEqualM(this, that, 'scriptModules', ctx);\n\t\tassertMemberMapEqual(this, that, 'limitOverrides', ctx);\n\t\tassertMemberEqual(this, that, 'limitOverridesDuplicationCounter', ctx);\n\t}\n\n\t/**\n\t * Iterate over all blocks of all object types, return them with context.\n\t */\n\t*blockWithContextIterator(categories: ('conditions' | 'actions')[] = ['conditions', 'actions']): IterableIterator<BlockWithContext> {\n\t\tfor (const [objectTypeIndex, objectType] of this.objects.entries()) {\n\t\t\tfor (const [ruleIndex, rule] of objectType.behaviour.entries()) {\n\t\t\t\tfor (const category of categories) {\n\t\t\t\t\tfor (const [blockIndex, block] of rule[category].entries()) {\n\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\tobjectType,\n\t\t\t\t\t\t\tobjectTypeIndex,\n\t\t\t\t\t\t\trule,\n\t\t\t\t\t\t\truleIndex,\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t\tblock: downcast(CandliBlock, block.block),\n\t\t\t\t\t\t\tblockIndex\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Iterate over all blocks of all object types.\n\t */\n\t*blockIterator(categories: ('conditions' | 'actions')[] = ['conditions', 'actions']): IterableIterator<CandliBlock> {\n\t\tfor (const contextualisedBlock of this.blockWithContextIterator(categories)) {\n\t\t\tyield contextualisedBlock.block;\n\t\t}\n\t}\n\n\t/**\n\t * Iterate over all block of a given type\n\t * @param type block type to fetch\n\t */\n\t*blockOfTypeIterator<T extends CandliBlock>(type: Constructor<T>): Generator<T, void, unknown> {\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tconst blockT = dynamicCast(type, block);\n\t\t\tif (blockT !== null) {\n\t\t\t\tyield blockT;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Return whether the game contains at least one block of a given type\n\t * @param type the type of block to check for presence, this allows to pass abstract classes using [[Constructor]] type.\n\t */\n\thasAnyBlockOfType<T extends CandliBlock>(type: Constructor<T>) {\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tif (dynamicCast(type, block) !== null) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Return which input buttons are used\n\t * @return a bit mask of the buttons used\n\t */\n\tgetActiveInputButtons(): number {\n\t\tlet bitMask = 0;\n\t\tfor (const eventBlock of this.blockIterator(['conditions'])) {\n\t\t\tconst inputBlock = dynamicCast(InputBlock, eventBlock);\n\t\t\tif (inputBlock !== null) {\n\t\t\t\tbitMask |= 1 << inputBlock.button;\n\t\t\t}\n\t\t}\n\t\treturn bitMask;\n\t}\n\n\t/**\n\t * Return the object type with a given name\n\t * @param name the name of the object type to find\n\t * @returns the object type or null if not found\n\t */\n\tfindObjectTypeByName(name: string) {\n\t\tfor (const objectType of this.objects) {\n\t\t\tif (objectType.name === name) {\n\t\t\t\treturn objectType;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Count how many times an object type is referred in blocks\n\t * @param type the object type to count references for\n\t */\n\tcountReferenceToTypeInBlocks(type: ObjectType) {\n\t\tlet count = 0;\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tcount += block.hasReferencesToObjectType(type) ? 1 : 0;\n\t\t}\n\t\treturn count;\n\t}\n\n\n\t/**\n\t * Duplicate an object type.\n\t * @param indexOrObjectType the type of an object in [[objects]] or its index\n\t */\n\tduplicateObjectType(indexOrObjectType: number | ObjectType) {\n\t\t// find the object type index\n\t\tlet index: number;\n\t\tif (indexOrObjectType instanceof ObjectType) {\n\t\t\tindex = this.objects.indexOf(indexOrObjectType);\n\t\t} else {\n\t\t\tindex = indexOrObjectType;\n\t\t}\n\t\tassertNonNegativeInteger(index, 'index');\n\t\t// clone the object\n\t\tconst object = defined(this.objects[index]).clone();\n\t\tif (object.name !== null) {\n\t\t\tobject.name = CopyOf.args(object.name);\n\t\t}\n\t\tthis.objects.push(object);\n\t}\n\n\t/**\n\t * Delete an object type.\n\t * @param indexOrObjectType the type of an object in [[objects]] or its index\n\t */\n\tdeleteObjectType(indexOrObjectType: number | ObjectType) {\n\t\t// find the object type index\n\t\tlet index: number;\n\t\tif (indexOrObjectType instanceof ObjectType) {\n\t\t\tindex = this.objects.indexOf(indexOrObjectType);\n\t\t} else {\n\t\t\tindex = indexOrObjectType;\n\t\t}\n\t\tassertNonNegativeInteger(index, 'index');\n\t\t// delete the object type\n\t\tconst object = defined(this.objects.splice(index, 1)[0]);\n\t\t// delete all instances with that type\n\t\tconst newLevelObjects = [];\n\t\tfor (const objectInstance of this.level.objects) {\n\t\t\tif (objectInstance.type !== object) {\n\t\t\t\t// different type, keep\n\t\t\t\tnewLevelObjects.push(objectInstance);\n\t\t\t} else {\n\t\t\t\t// same type, if attached to camera, detach it\n\t\t\t\tif (this.level.camera.trackedObject === objectInstance) {\n\t\t\t\t\tthis.level.camera.trackedObjectOrPosition = objectInstance.pose.translation;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.level.objects = newLevelObjects;\n\t\t// make sure that this object is not referenced by any other object\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tblock.releaseReferencesToObjectType(object);\n\t\t}\n\t}\n\n\t/** all images of end screens */\n\tget endScreenImages() {\n\t\treturn this.dialogs.map((endScreen) => endScreen.image);\n\t}\n\n\tdeleteDialog(index: number) {\n\t\tthis.dialogs.splice(index, 1);\n\t\t// update all end screen blocks and update their index\n\t\tfor (const block of this.blockOfTypeIterator(ShowDialogBlock)) {\n\t\t\tif (block.screen === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.screen === index) {\n\t\t\t\tblock.screen = null;\n\t\t\t} else if (block.screen > index) {\n\t\t\t\tblock.screen -= 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tdeleteSound(index: number) {\n\t\tthis.sounds.splice(index, 1);\n\t\t// update all sound blocks and update their index\n\t\tfor (const block of this.blockOfTypeIterator(SoundBlock)) {\n\t\t\tif (block.index === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (block.index === index) {\n\t\t\t\tblock.index = null;\n\t\t\t} else if (block.index > index) {\n\t\t\t\tblock.index -= 1;\n\t\t\t}\n\t\t}\n\t}\n\n\t/** index of a given variable name, in the game data structure, so one must do +1 to use it in the address */\n\tvariableNameIndex(name: string) {\n\t\tfor (const [i, v] of this.variables.entries()) {\n\t\t\tif (v.name.name === name) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/** all images of variable names */\n\tvariableNameImages(fallback: (_: string) => Drawable) {\n\t\treturn this.variables.map(\n\t\t\t(variable) => variable.name.image ?? fallback(variable.name.name ?? '')\n\t\t);\n\t}\n\n\t/** all named variables present in this game */\n\tallNamedVariables() {\n\t\treturn [\n\t\t\t//'score', // we comment the score out as it is not a valid input to variableNameIndex\n\t\t\t...this.variables\n\t\t\t\t.map((variable) => variable.name.name)\n\t\t\t\t.filter(name => name !== undefined)\n\t\t];\n\t}\n\n\t/** delete a variable name of a given index */\n\tdeleteVariableName(index: number) {\n\t\tassertNonNegativeInteger(index,  'index');\n\t\tthis.variables.splice(index, 1);\n\n\t\t// address rewriting logic\n\t\tconst rewriteAddress = <K extends string>(obj: Record<K, number>, propName: K) => {\n\t\t\tconst [scope, varIndex] = variableScopeAndIndex(obj[propName]);\n\t\t\tconst varNameIndex = varIndex - 1;\n\t\t\tif (varNameIndex === index) {\n\t\t\t\tobj[propName] = variableAddress(VariableScope.Game, 0);\n\t\t\t} else if (varNameIndex > index) {\n\t\t\t\tobj[propName] = variableAddress(scope, varIndex - 1);\n\t\t\t}\n\t\t};\n\n\t\t// process all blocks containing addresses\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tconst compareVariableBlock = dynamicCast(ComparisonBlock, block);\n\t\t\tif (compareVariableBlock !== null) {\n\t\t\t\trewriteAddress(compareVariableBlock, 'address');\n\t\t\t}\n\t\t\tconst changeVariableBlock = dynamicCast(ChangeVariableBlock, block);\n\t\t\tif (changeVariableBlock !== null) {\n\t\t\t\trewriteAddress(changeVariableBlock, 'address');\n\t\t\t}\n\t\t\tconst readVariableBlock = dynamicCast(ReadVariableBlock, block);\n\t\t\tif (readVariableBlock !== null) {\n\t\t\t\trewriteAddress(readVariableBlock, 'address');\n\t\t\t}\n\t\t\tconst binaryArithmeticBlock = dynamicCast(BinaryArithmeticBlock, block);\n\t\t\tif (binaryArithmeticBlock !== null) {\n\t\t\t\tif (binaryArithmeticBlock.lInput === CandliFB.BinaryArithmeticInput.VARIABLE) {\n\t\t\t\t\trewriteAddress(binaryArithmeticBlock, 'lAddressOrValue');\n\t\t\t\t}\n\t\t\t\tif (binaryArithmeticBlock.rInput === CandliFB.BinaryArithmeticInput.VARIABLE) {\n\t\t\t\t\trewriteAddress(binaryArithmeticBlock, 'rAddressOrValue');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// update script blocks accordingly\n\t\tthis.recompileAllScripts();\n\t}\n\n\t/** rename all instance of oldName into newNames in script blocks */\n\trenameCandliVariableInScriptBlocks(oldName: string, newName: string) {\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tconst scriptBlock = dynamicCast(ScriptAbstractBlock, block);\n\t\t\tif (scriptBlock !== null) {\n\t\t\t\tscriptBlock.renameVariable(oldName, newName);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** recompile game and block scripts */\n\trecompileAllScripts() {\n\t\tthis.scriptCtx = this.recompileGameScripts();\n\t\tfor (const block of this.blockIterator()) {\n\t\t\tconst scriptBlock = dynamicCast(ScriptAbstractBlock, block);\n\t\t\tif (scriptBlock !== null) {\n\t\t\t\tscriptBlock.scriptCtx = this.scriptCtx;\n\t\t\t\tscriptBlock.setupCompiler();\n\t\t\t\tscriptBlock.compile();\n\t\t\t}\n\t\t}\n\t}\n\n\t/** the music atmospheres referenced in the objects of this game */\n\tcollectMusicAtmospheres() {\n\t\tconst atmospheres: Set<AtmosphereIndex> = new Set();\n\t\tfor (const object of this.objects) {\n\t\t\tobject.collectMusicAtmospheres(atmospheres);\n\t\t}\n\t\treturn atmospheres;\n\t}\n\n\t/** Enable or disable some elements */\n\tsetAvailability(disabled: boolean, path: string[]) {\n\t\tconst element = path[0];\n\t\tconst otsFromNameOrRole = (nameOrRole: string) => {\n\t\t\tconst index = Number(nameOrRole);\n\t\t\tif (Number.isInteger(index)) {\n\t\t\t\tif (index >= 0 && index < this.objects.length) {\n\t\t\t\t\treturn [defined(this.objects[index])];\n\t\t\t\t} else {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn this.objectTypesFromNameOrRole(nameOrRole);\n\t\t\t}\n\t\t};\n\t\tswitch (element) {\n\t\t\tcase 'types': {\n\t\t\t\tconst otName = defined(path[1]);\n\t\t\t\tconst restOfPath = path.slice(2);\n\t\t\t\tfor (const object of otsFromNameOrRole(otName)) {\n\t\t\t\t\tobject.setAvailability(disabled, restOfPath);\n\t\t\t\t}\n\t\t\t} break;\n\t\t\tcase 'instances': {\n\t\t\t\tlet target: ObjectType[] | number | null | undefined;\n\t\t\t\tlet feature: string;\n\t\t\t\tif (path[1] === '*') {\n\t\t\t\t\ttarget = null;\n\t\t\t\t\tfeature = defined(path[2]);\n\t\t\t\t} else if (path[1] === 'of') {\n\t\t\t\t\tconst otName = defined(path[2]);\n\t\t\t\t\ttarget = otsFromNameOrRole(otName);\n\t\t\t\t\tfeature = defined(path[3]);\n\t\t\t\t} else {\n\t\t\t\t\tconst indexes = indexOrInterval(defined(path[1]));\n\t\t\t\t\tfeature = defined(path[2]);\n\t\t\t\t\tif (Array.isArray(indexes)) {\n\t\t\t\t\t\tfor (let i = indexes[0]; i <= indexes[1]; i++) {\n\t\t\t\t\t\t\tthis.level.setAvailability(disabled, feature, i);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttarget = indexes;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (target !== undefined) {\n\t\t\t\t\tthis.level.setAvailability(disabled, feature, target);\n\t\t\t\t}\n\t\t\t} break;\n\t\t\tdefault: console.warn(`Unknown game element \"${element}\" to set availability for.`);\n\t\t}\n\t}\n\n\t/** Return index of a given object type, -1 if not found. */\n\tobjectTypeIndex(objectType: ObjectType) {\n\t\treturn this.objects.indexOf(objectType);\n\t}\n\n\t/** Return index of the object type corresponding to a given id, null if not found. */\n\tobjectTypeIndexFromId(id: number) {\n\t\tlet index: number | null = null;\n\t\tthis.objects.forEach((ot, i) => {\n\t\t\tif (ot.id === id) {\n\t\t\t\tindex = i;\n\t\t\t}\n\t\t});\n\t\treturn index;\n\t}\n\n\t/** Reset availability to default: Remove any locking state */\n\tresetAvailability() {\n\t\tfor (const objectType of this.objects) {\n\t\t\tobjectType.resetAvailability()\n\t\t}\n\t\tthis.level.resetAvailability();\n\t}\n}\n\nfunction indexOrInterval(text: string) {\n\tconst interval = text.match(/\\[(\\d+),(\\d+)\\]/);\n\tif (interval !== null) {\n\t\tconst first = parseInt(defined(interval[1]), 10);\n\t\tconst last = parseInt(defined(interval[2]), 10);\n\t\treturn [first, last] as [number, number];\n\t} else {\n\t\treturn parseInt(text, 10);\n\t}\n}\n","/**\n * @module math\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { calcLineIntersectionPoint } from 'level/snapping';\nimport { applyToArrayIfLargeEnough } from 'utils/array-types';\nimport { assert, assertValueEqual } from 'utils/assert';\nimport { projectOntoArrowRightHalfSpace } from './geometry';\nimport { areVector2Collinear, Vector2 } from './linalg';\nimport { defined } from 'utils/types';\n\nexport function getMostRightPointIndex(startI: number, endI: number, points: Array<Vector2>): number | null {\n\tassert(startI >= 0);\n\tassert(startI < points.length);\n\tassert(startI <= endI);\n\tassert(endI < points.length);\n\tconst startPoint = points[startI]!;\n\tconst deltaVector = points[endI]!.sub(startPoint);\n\t// cSpell:ignore Jdelta\n\tconst JdeltaVector = new Vector2(deltaVector.y, -deltaVector.x);\n\n\tlet mostRightI = -1;\n\tlet dMost = -Infinity;\n\tfor (let i = startI + 1; i < endI; i++) {\n\t\tconst p = points[i]!;\n\t\tconst d = JdeltaVector.dot(p.sub(startPoint));\n\t\tif (d > 0 && dMost < d) {\n\t\t\tdMost = d;\n\t\t\tmostRightI = i;\n\t\t}\n\t}\n\treturn mostRightI === -1 ? null : mostRightI;\n}\n\nfunction addExtraInnerPoints(startI: number, endI: number, source: Array<Vector2>, dest: Array<Vector2>) {\n\tassert(startI >= 0);\n\tassert(startI < source.length);\n\tassert(endI >= startI);\n\tassert(endI < source.length);\n\tconst i = getMostRightPointIndex(startI, endI, source);\n\tif (i !== null) {\n\t\taddExtraInnerPoints(startI, i, source, dest);\n\t\tdest.push(source[i]!);\n\t\taddExtraInnerPoints(i, endI, source, dest);\n\t}\n}\n\nclass AngularBin {\n\tconstructor(public index: number = -1, public d2: number = 0) {\n\t}\n}\n\nexport function approximateConvexHull(center: Vector2, boundaryPoints: Array<Vector2>): Array<Vector2> {\n//\tconsole.log(\"Input \" + center + \", \" + boundaryPoints);\n\n\tconst binnedPoints = new Array<Vector2>();\n\tlet eastI = -1, westI = -1;\n\t{ // create bins\n\t\tconst numAngularBins = 256;\n\t\tconst angularBins = new Array<AngularBin | undefined>(numAngularBins);\n\n\t\tlet i = 0;\n\t\tfor (const p of boundaryPoints) {\n\t\t\tconst delta = p.sub(center);\n\t\t\tconst d2 = delta.norm2();\n\t\t\tconst binIndex = Math.round((delta.angle / (2 * Math.PI) + 1.0) * numAngularBins) % numAngularBins;\n\t\t\t// console.log(\"delta.angle\", delta.angle, \"p\", p.toString(), \"binIndex\", binIndex);\n\t\t\tassert(0 <= binIndex);\n\t\t\tassert(binIndex < numAngularBins);\n\t\t\tlet bin = angularBins[binIndex];\n\t\t\tif (bin === undefined) {\n\t\t\t\tbin = new AngularBin(i, d2);\n\t\t\t\tangularBins[binIndex] = bin;\n\t\t\t} else {\n\t\t\t\tif (d2 > bin.d2) {\n\t\t\t\t\tbin.d2 = d2;\n\t\t\t\t\tbin.index = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t\tlet minX = Infinity, maxX = -Infinity;\n\t\tfor (const bin of angularBins) {\n\t\t\tif (bin !== undefined) {\n\t\t\t\tconst p = boundaryPoints[bin.index]!;\n\t\t\t\tif (p.x < minX) {\n\t\t\t\t\tminX = p.x;\n\t\t\t\t\twestI = binnedPoints.length;\n\t\t\t\t}\n\t\t\t\tif (p.x > maxX) {\n\t\t\t\t\tmaxX = p.x;\n\t\t\t\t\teastI = binnedPoints.length;\n\t\t\t\t}\n\t\t\t\tbinnedPoints.push(p);\n\t\t\t}\n\t\t}\n\t\t// console.log(minX, maxX, westI, eastI, binnedPoints.toString());\n\t}\n\n\tif (westI === -1 || westI === eastI) {\n\t\treturn binnedPoints;\n\t}\n\n\tif (westI > eastI) {\n\t\t[ eastI, westI ] = [ westI, eastI ];\n\t}\n\n\t// console.log(westI, eastI, binnedPoints.toString());\n\n\tconst pointsBeforeWest = binnedPoints.slice(0, westI);\n\tbinnedPoints.splice(0, westI);\n\tbinnedPoints.push(... pointsBeforeWest);\n\n\teastI -= westI;\n\twestI = 0;\n\n\t// console.log(westI, eastI, binnedPoints.toString());\n\n\tconst aCH = new Array<Vector2>();\n\taCH.push(binnedPoints[westI]!);\n\taddExtraInnerPoints(westI, eastI, binnedPoints, aCH);\n\taCH.push(binnedPoints[eastI]!);\n\tbinnedPoints.push(binnedPoints[westI]!);\n\taddExtraInnerPoints(eastI, binnedPoints.length - 1, binnedPoints, aCH);\n\treturn aCH;\n}\n\n// cSpell:ignore cheapo\n// el-cheapo's polygon simplification\nexport function simplify(polygon: Vector2[], maxVertices: number) {\n\tpolygon = polygon.map((v) => v.clone());\n\t// special optimisation of wrap-around case\n\tconst align = (p0: Vector2, p1: Vector2, p2: Vector2) => {\n\t\tconst d0 = p1.sub(p0);\n\t\tconst d1 = p2.sub(p1);\n\t\treturn areVector2Collinear(d0, d1);\n\t}\n\twhile (polygon.length > 2 && align(polygon[polygon.length - 1]!, polygon[0]!, polygon[1]!)) {\n\t\tpolygon.splice(0, 1);\n\t}\n\twhile (polygon.length > maxVertices) {\n\t\t// find the index of the vertices with the smallest triangle area between\n\t\t// itself and its left and right neighbours.\n\t\tconst { index } = polygon.reduce((acc, cur, index, array) => {\n\t\t\tconst pPrev = array[(index + array.length - 1) % array.length]!;\n\t\t\tconst pCur = array[index]!;\n\t\t\tconst pNext = array[(index + 1) % array.length]!;\n\t\t\tconst area = Math.abs(\n\t\t\t\tpPrev.x * (pCur.y - pNext.y) +\n\t\t\t\tpCur.x * (pNext.y - pPrev.y) +\n\t\t\t\tpNext.x * (pPrev.y - pCur.y)\n\t\t\t) / 2;\n\t\t\tif (area < acc.error) {\n\t\t\t\treturn { index, error: area };\n\t\t\t} else {\n\t\t\t\treturn acc;\n\t\t\t}\n\t\t}, { index: 0, error: Infinity });\n\t\t// remove this vertex from the array\n\t\tpolygon.splice(index, 1);\n\t}\n\treturn polygon;\n}\n\n/** Return whether the point lies in this polygon or circle */\nexport function isPointInShape(shape: Vector2[] | Vector2 | number, point: Vector2) {\n\tif (shape instanceof Array) {\n\t\tconst polygon = shape;\n\t\tfor (let i = 0; i < polygon.length; ++i) {\n\t\t\tconst pointB = polygon[(i + 1) % polygon.length]!;\n\t\t\tconst pointA = polygon[i]!;\n\t\t\tconst segmentAB = pointB.sub(pointA);\n\t\t\tconst segmentPerpAB = segmentAB.perp;\n\t\t\tconst segmentAP = point.sub(pointA);\n\t\t\tif (segmentPerpAB.dot(segmentAP) < 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t} else if (shape instanceof Vector2) {\n\t\tconst ax = Math.abs(point.x);\n\t\tconst ay = Math.abs(point.y);\n\t\treturn ax <= shape.x * 0.5 && ay <= shape.y * 0.5;\n\t} else {\n\t\treturn point.norm2() <= shape * shape;\n\t}\n\n}\n\n/*\n// This is incorrect because boundaryPoints are not continuous\nexport function approximateCircle(center: Vector2, boundaryPoints: Array<Vector2>): [number, number] {\n\tlet sum = 0;\n\tfor (const p of boundaryPoints) {\n\t\tconst dist = p.sub(center).norm();\n\t\tsum += dist;\n\t}\n\tconst count = boundaryPoints.length;\n\tconst mean = sum / count;\n\tlet squareDiffSum = 0;\n\tfor (const p of boundaryPoints) {\n\t\tconst delta = p.sub(center).norm() - mean;\n\t\tsquareDiffSum += delta * delta;\n\t}\n\tconst sd = Math.sqrt(squareDiffSum / count);\n\treturn [mean, sd];\n}\n*/\n\nexport function approximateCircleFromConvexHull(center: Vector2, convexHull: Vector2[]): [number, number] {\n\tfunction* hullIterator() {\n\t\tfor (let i = 0; i < convexHull.length; ++i) {\n\t\t\tconst p1 = convexHull[i]!;\n\t\t\tconst p2 = convexHull[(i + 1) % convexHull.length]!;\n\t\t\tconst v = p2.sub(p1);\n\t\t\tconst u = v.unit();\n\t\t\tfor (let j = 0; j < v.norm(); ++j) {\n\t\t\t\tyield p1.add(u.multScalar(j));\n\t\t\t}\n\t\t}\n\t}\n\tlet sum = 0;\n\tlet count = 0;\n\tfor (const p of hullIterator()) {\n\t\tconst dist = p.sub(center).norm();\n\t\tsum += dist;\n\t\tcount += 1;\n\t}\n\tconst mean = sum / count;\n\tlet squareDiffSum = 0;\n\tfor (const p of hullIterator()) {\n\t\tconst delta = p.sub(center).norm() - mean;\n\t\tsquareDiffSum += delta * delta;\n\t}\n\tconst sd = Math.sqrt(squareDiffSum / count);\n\treturn [mean, sd];\n}\n\nexport function isTrivialRectangle(convexHull: Vector2[]) {\n\treturn convexHull.length === 4 && applyToArrayIfLargeEnough(convexHull, 4, (convexHull) => {\n\t\tconst bottomRight = convexHull[0];\n\t\tconst bottomLeft = convexHull[1];\n\t\tconst topLeft = convexHull[2];\n\t\tconst topRight = convexHull[3];\n\t\treturn (\n\t\t\tbottomRight.x === topRight.x &&\n\t\t\tbottomRight.y === bottomLeft.y &&\n\t\t\tbottomLeft.x === topLeft.x &&\n\t\t\ttopLeft.y === topRight.y\n\t\t);\n\t}) && false;\n}\n\nexport function snapToConvexPolyConstraint(vertex: Vector2, getNeighbor: (relIndex: number) => Vector2, minDistance: number) {\n\tconst llNeighbor = getNeighbor(2);\n\tconst lNeighbor = getNeighbor(1);\n\tconst rNeighbor = getNeighbor(-1);\n\tconst rrNeighbor = getNeighbor(-2);\n\treturn fixTooCloseNeighborProximity(\n\t\tminimallyCorrectToSatisfyConvexPolygonConstraint(vertex, llNeighbor, lNeighbor, rNeighbor, rrNeighbor),\n\t\tllNeighbor, lNeighbor, rNeighbor, rrNeighbor, vertex, minDistance);\n}\n\n\nfunction byDistanceTo(tieBreakerTarget: Vector2) {\n\treturn (a: Vector2, b: Vector2) => a.dist(tieBreakerTarget) - b.dist(tieBreakerTarget);\n}\nexport function minimallyCorrectToSatisfyConvexPolygonConstraint(vertex: Vector2, llNeighbor: Vector2, lNeighbor: Vector2, rNeighbor: Vector2, rrNeighbor: Vector2) {\n\tconst directedBoundaryLineTriple = [\n\t\t[rNeighbor, lNeighbor],\n\t\t[llNeighbor, lNeighbor],\n\t\t[rNeighbor, rrNeighbor]\n\t] as const;\n\n\tconst nonTrivialProjections = directedBoundaryLineTriple\n\t\t.map(([a, b], i) => [i, projectOntoArrowRightHalfSpace(vertex, a, b)] as const)\n\t\t.filter(([_, p]) => p !== vertex);\n\n\tif (nonTrivialProjections.length) { // some half space constraints made a non-trivial projection necessary -> we must correct the position.\n\t\tconst secondaryProjectors = nonTrivialProjections.map(([i, p]) =>\n\t\t\t[\n\t\t\t\ti, p,\n\t\t\t\t[i + 1, i + 2].filter(i => {\n\t\t\t\t\tconst [a, b] = directedBoundaryLineTriple[i % directedBoundaryLineTriple.length]!;\n\t\t\t\t\treturn p !== projectOntoArrowRightHalfSpace(p, a, b);\n\t\t\t\t})\n\t\t\t] as const\n\t\t)\n\t\tconst withEmptySecondaryProjectors = secondaryProjectors.filter(([_i, _p, sps]) => sps.length === 0);\n\t\tif (withEmptySecondaryProjectors.length) {\n\t\t\tassertValueEqual(withEmptySecondaryProjectors.length, 1, 'Every non trivial projection with no non-trivial secondary projections is a solution and the entire problem has exactly one solution.');\n\t\t\treturn withEmptySecondaryProjectors[0]![1];\n\t\t} else {\n\t\t\t// all non-trivial projections would be at least once non-trivially projected further\n\t\t\t// -> it is a vertex of the(half open) triangle.\n\t\t\t// -> we take the one that is closest.\n\t\t\treturn ( llNeighbor.dist2(rrNeighbor) <= lNeighbor.dist2(rNeighbor) ?\n\t\t\t\t[ // open \"triangle\"\n\t\t\t\t\tlNeighbor, rNeighbor\n\t\t\t\t] : [ // closed triangle -> we must compute the vertex pointing away from the convex polygon.\n\t\t\t\t\tlNeighbor, rNeighbor,\n\t\t\t\t\tcalcLineIntersectionPoint(llNeighbor, llNeighbor.sub(lNeighbor).normalized(), rrNeighbor, rrNeighbor.sub(rNeighbor).normalized())\n\t\t\t\t]\n\t\t\t).sort(byDistanceTo(vertex))[0]!;\n\t\t}\n\t}\n\treturn vertex; // no correction necessary -> return original\n}\n\nexport function fixTooCloseNeighborProximity(vertex: Vector2, llNeighbor: Vector2, lNeighbor: Vector2, rNeighbor: Vector2, rrNeighbor: Vector2, tieBreakerTarget: Vector2, minDistance: number) {\n\tfor (const a of [lNeighbor, rNeighbor]) {\n\t\tconst displacementAToTarget = vertex.sub(a);\n\t\tconst distance = displacementAToTarget.norm();\n\t\tif (distance < minDistance) {\n\t\t\t// We are too close to neighbor `a` (and thus only to this neighbor by choice of minDistance)\n\t\t\t// -> we move to the closes point on the circular keep out zone.\n\t\t\t// But that is only well defined if we are have meaningful distance ot the center of\n\t\t\t// the circle.\n\t\t\tconst candidate = (distance > 1e-5) ? // TODO what is a good threshold?!\n\t\t\t\ta.add(displacementAToTarget.multScalar(minDistance / distance))\n\t\t\t\t:\n\t\t\t\t// We are so close to the center that the arrow center-us has unstable direction.\n\t\t\t\t// Therefore we go to the closest of the intersection points of the circle and\n\t\t\t\t// the two triangle segments meeting in this center.\n\t\t\t\t(a === lNeighbor ? // which corner are we in?\n\t\t\t\t\t[\n\t\t\t\t\t\trNeighbor.sub(lNeighbor), lNeighbor.sub(llNeighbor)\n\t\t\t\t\t] : [\n\t\t\t\t\t\tlNeighbor.sub(rNeighbor), rNeighbor.sub(rrNeighbor)\n\t\t\t\t\t]\n\t\t\t\t).map(b =>\n\t\t\t\t\ta.add(b.multScalar(minDistance / b.norm()))\n\t\t\t\t).sort(byDistanceTo(tieBreakerTarget))[0]!;\n\t\t\t;\n\t\t\t// This candidate may now be beyond the opposing segment.\n\t\t\tconst opposingSegment = a === lNeighbor ?\n\t\t\t\t[ rNeighbor, rrNeighbor ] as const : [ llNeighbor, lNeighbor ] as const\n\t\t\tif (candidate === projectOntoArrowRightHalfSpace(candidate, ...opposingSegment)) {\n\t\t\t\t// It is not.\n\t\t\t\treturn candidate;\n\t\t\t} else {\n\t\t\t\t// It is. That means we must go back to the vertex we went past.\n\t\t\t\t// But that can't be the other direct neighbor (by construction of minDistance).\n\t\t\t\t// Thus it is the outwards pointing vertex that we must compute first.\n\t\t\t\treturn calcLineIntersectionPoint(\n\t\t\t\t\tllNeighbor, llNeighbor.sub(lNeighbor).normalized(),\n\t\t\t\t\trrNeighbor, rrNeighbor.sub(rNeighbor).normalized()\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn vertex; // no correction necessary -> return original\n}\n\n/// Compute the convex hull using the Monotone Chain algorithm.\nexport function convexHull(points: Vector2[]): Vector2[] {\n\tconst cross = (o: Vector2, a: Vector2, b: Vector2) =>\n\t\t(a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)\n\t;\n\n\tassert(points.length >= 3, 'convexHull computation needs at least 3 points');\n\tpoints.sort((a, b) => a.x === b.x ? a.y - b.y : a.x - b.x);\n\n\tconst lower: Vector2[] = [];\n\tfor (const point of points) {\n\t\twhile (lower.length >= 2 && cross(defined(lower[lower.length - 2]), defined(lower[lower.length - 1]), point) <= 0) {\n\t\t\tlower.pop();\n\t\t}\n\t\tlower.push(point);\n\t}\n\n\tconst upper: Vector2[] = [];\n\tfor (let i = points.length - 1; i >= 0; i--) {\n\t\tconst point = defined(points[i]);\n\t\twhile (upper.length >= 2 && cross(defined(upper[upper.length - 2]), defined(upper[upper.length - 1]), point) <= 0) {\n\t\t\tupper.pop();\n\t\t}\n\t\tupper.push(point);\n\t}\n\n\tupper.pop();\n\tlower.pop();\n\treturn lower.concat(upper);\n}\n\n/// Compute the union of two convex hulls.\nexport function unionConvexHulls(a: Array<Vector2>, b: Array<Vector2>): Array<Vector2> {\n\tconst points = [...a, ...b];\n\treturn convexHull(points);\n}\n\n/// Project a point onto the convex hull, assuming the point is inside or on the convex hull.\nexport function projectPointOntoConvexHull(point: Vector2, hull: Vector2[]): Vector2 {\n\tlet minDistance = Infinity;\n\tlet projection = point;\n\n\tfor (let i = 0; i < hull.length; i++) {\n\t\tconst a = hull[i]!;\n\t\tconst b = hull[(i + 1) % hull.length]!;\n\t\tconst v1 = b.sub(a);\n\t\tconst v2 = point.sub(a);\n\t\tlet t = v2.dot(v1) / v1.dot(v1);\n\t\tt = Math.max(0, Math.min(1, t)); // Clamp to line segment\n\t\tconst projectedPoint = a.add(v1.multScalar(t));\n\t\tconst distance = projectedPoint.dist(point);\n\t\tif (distance < minDistance) {\n\t\t\tminDistance = distance;\n\t\t\tprojection = projectedPoint;\n\t\t}\n\t}\n\n\treturn projection;\n}\n\n/// Return the edges of a convex polygon.\nexport function edges(points: Vector2[]) {\n\tconst edges = new Array<[Vector2, Vector2]>();\n\tfor (let i = 0; i < points.length; i++) {\n\t\tconst a = points[i]!.clone();\n\t\tconst b = points[(i + 1) % points.length]!;\n\t\tedges.push([a, b]);\n\t}\n\treturn edges;\n}","/**\n * @module math\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nconst TwoPI = Math.PI * 2;\n\n/** Normalise angle within the [0..2 * PI[ interval */\nexport function normalizeAngle(angle: number): number {\n\tangle %= TwoPI;\n\tif (angle < 0) {\n\t\tangle += TwoPI;\n\t}\n\treturn angle;\n}\n\n/** Normalise angle within the [-PI..PI[ interval */\nexport function normalizeAngleAround0(angle: number): number {\n\tlet nAngle = normalizeAngle(angle);\n\tif (nAngle >= Math.PI) {\n\t\tnAngle -= TwoPI;\n\t}\n\treturn nAngle;\n}\n\n/** Normalise angle within the ]-180..180] interval */\nexport function normalizeDegreesAround0(angle: number): number {\n\twhile (angle > 180) {\n\t\tangle -= 360;\n\t}\n\twhile (angle <= -180) {\n\t\tangle += 360;\n\t}\n\treturn angle;\n}\n\nexport function dist2(x1: number, y1: number, x2: number, y2: number): number {\n\tconst dx = x1 - x2;\n\tconst dy = y1 - y2;\n\treturn dx * dx + dy * dy;\n}\n\nexport function clamp(v: number, min: number, max: number) {\n\tif (v < min) {\n\t\treturn min;\n\t} else if (v > max) {\n\t\treturn max;\n\t} else {\n\t\treturn v;\n\t}\n}\n\n/**\n * Return whether [[a]] and [[b]] have same numeric value, up to [[tolerance]]\n * @param a first number\n * @param b second number\n * @param relTolerance optional numeric relative tolerance for equality comparison, default: 1e-6\n * @param absTolerance optional numeric absolute tolerance for equality comparison, default: 1e-10\n */\nexport function approximateEqual(a: number, b: number, relTolerance = 1e-6, absTolerance = 1e-10) {\n\t// Inspired by https://floating-point-gui.de/errors/comparison/\n\tconst absDiff = Math.abs(a - b);\n\treturn (\n\t\ta === b // shortcut, handles infinities\n\t)\n\t|| (\n\t\tabsDiff < absTolerance\n\t)\n\t|| (\n\t\tabsDiff / Math.min(Math.abs(a) + Math.abs(b), Number.MAX_VALUE) < relTolerance\n\t);\n}\n","/**\n * A linear algebra and 2D geometry library.\n * @module math\n * @preferred\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport { normalizeAngle } from './helpers';\nimport { assertType, assert, assertNumber } from 'utils/assert';\nimport { createFixedSizeFloat32Array, FixedSizeFloat32Array } from 'utils/array-types';\n\nexport class Matrix {\n\t/** Matrix entries (row major layout) */\n\tprotected data: Float32Array;\n\n\t// constructors\n\n\tconstructor(rows: number, readonly cols: number, data?: ArrayLike<number> | Float32Array) {\n\t\tif (data !== undefined) {\n\t\t\tif (rows * cols !== data.length) {\n\t\t\t\tthrow new Error('wrong array size');\n\t\t\t}\n\t\t\tif (data instanceof Float32Array) {\n\t\t\t\tthis.data = data;\n\t\t\t} else {\n\t\t\t\tthis.data = Float32Array.from(data);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.data = new Float32Array(rows * cols);\n\t\t}\n\t}\n\n\tstatic identity(dimOrResult: number | Matrix): Matrix {\n\t\tconst result = typeof dimOrResult === 'number' ? new Matrix(dimOrResult, dimOrResult) : dimOrResult;\n\t\tfor (let i = 0; i < result.rows; ++i) {\n\t\t\tresult.set(i, i, 1);\n\t\t}\n\t\treturn result;\n\t}\n\n\t// getters\n\n\tget rows(): number {\n\t\treturn this.data.length / this.cols;\n\t}\n\n\tget dim(): number {\n\t\treturn this.rows * this.cols;\n\t}\n\n\tget dataRowMajor() {\n\t\treturn this.data;\n\t}\n\n\t// member access\n\n\tat(row: number, col: number): number {\n\t\tthis.checkBoundary(row, col);\n\t\treturn this.atUnchecked(row, col)!;\n\t}\n\tprotected atUnchecked(row: number, col: number) {\n\t\treturn this.data[this.indexAtUnchecked(row, col)];\n\t}\n\tset(row: number, col: number, val: number): void {\n\t\tthis.checkBoundary(row, col);\n\t\tthis.setUnchecked(row, col, val);\n\t}\n\tprotected setUnchecked(row: number, col: number, val: number): void {\n\t\tthis.data[this.indexAtUnchecked(row, col)] = val;\n\t}\n\n\tprotected indexAtUnchecked(row: number, col: number): number {\n\t\treturn this.cols * row + col;\n\t}\n\n\t// access checkers and functional helpers\n\n\tprotected checkBoundary(row: number, col: number) {\n\t\tif (row < 0.0 || row > this.rows - 1.0) {\n\t\t\tthrow new Error('row index out of bounds');\n\t\t}\n\t\tif (col < 0.0 || col > this.cols - 1.0) {\n\t\t\tthrow new Error('col index out of bounds');\n\t\t}\n\t}\n\tprotected checkMatchingSize(o: Matrix) {\n\t\tif (o.rows !== this.rows || o.cols !== this.cols) {\n\t\t\tthrow new Error('incompatible dimensions');\n\t\t}\n\t}\n\tprotected fold(functor: (acc: number, value: number) => number, initial: number) {\n\t\tlet acc = initial;\n\t\tfor (const value of this.data) {\n\t\t\tacc = functor(acc, value);\n\t\t}\n\t\treturn acc;\n\t}\n\tprotected fold2Unchecked(functor: (acc: number, value1: number, value2: number) => number, o: Matrix, initial: number) {\n\t\tlet acc = initial;\n\t\tfor (let i = 0; i < this.data.length; ++i) {\n\t\t\tacc = functor(acc, this.data[i]!, o.data[i]!);\n\t\t}\n\t\treturn acc;\n\t}\n\tprotected unaryElementsUnchecked(functor: (value: number) => number, result: Matrix): Matrix {\n\t\tfor (let i = 0; i < this.data.length; ++i) {\n\t\t\tresult.data[i] = functor(this.data[i]!);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected binaryElementsUnchecked(functor: (thisValue: number, oValue: number) => number, o: Matrix | number, result: Matrix | null = null): Matrix {\n\t\tresult = result || new Matrix(this.rows, this.cols);\n\t\tfor (let i = 0; i < this.data.length; ++i) {\n\t\t\tif (typeof o === 'number') {\n\t\t\t\tresult.data[i] = functor(this.data[i]!, o);\n\t\t\t} else {\n\t\t\t\tresult.data[i] = functor(this.data[i]!, o.data[i]!);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected createEmptyOfSameSize(): this {\n\t\treturn new Matrix(this.rows, this.cols) as this;\n\t}\n\n\tprivate unaryOperation(functor: (result: Matrix) => Matrix): this {\n\t\tconst result = this.createEmptyOfSameSize();\n\t\tfunctor.bind(this)(result);\n\t\treturn result;\n\t}\n\n\t// operations\n\n\tclone(): this {\n\t\treturn this.unaryOperation(this.cloneUnchecked);\n\t}\n\tprotected cloneUnchecked(result: Matrix): Matrix {\n\t\treturn this.unaryElementsUnchecked((value) => value, result);\n\t}\n\n\tabs(): this {\n\t\treturn this.unaryOperation(this.absUnchecked);\n\t}\n\tprotected absUnchecked(result: Matrix): Matrix {\n\t\treturn this.unaryElementsUnchecked(Math.abs, result);\n\t}\n\n\tminimum(): number {\n\t\treturn this.fold(Math.min, Infinity);\n\t}\n\n\tmaximum(): number {\n\t\treturn this.fold(Math.max, -Infinity);\n\t}\n\n\tmin(o: Matrix): Matrix {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.minUnchecked(o);\n\t}\n\tprotected minUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked(Math.min, o, result);\n\t}\n\n\tmax(o: Matrix): Matrix {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.maxUnchecked(o);\n\t}\n\tprotected maxUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked(Math.max, o, result);\n\t}\n\n\tadd(o: Matrix): Matrix {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.addUnchecked(o);\n\t}\n\tprotected addUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked((a, b) => a + b, o, result);\n\t}\n\n\tsub(o: Matrix): Matrix {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.subUnchecked(o);\n\t}\n\tprotected subUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked((a, b) => a - b, o, result);\n\t}\n\n\tdivElements(o: Matrix): Matrix {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.divElementsUnchecked(o);\n\t}\n\tprotected divElementsUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked((a, b) => a / b, o, result);\n\t}\n\n\tmultElements(o: Matrix): Matrix {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.multElementsUnchecked(o);\n\t}\n\tprotected multElementsUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked((a, b) => a * b, o, result);\n\t}\n\n\tmult(o: Matrix): Matrix {\n\t\tif (this.cols !== o.rows ) {\n\t\t\tthrow new Error('incompatible dimensions');\n\t\t}\n\t\treturn this.multUnchecked(o);\n\t}\n\tprotected multUnchecked(o: Matrix, result: Matrix | null = null): Matrix {\n\t\tresult = result || new Matrix(this.rows, o.cols);\n\t\tfor (let i = 0; i < this.rows; ++i) {\n\t\t\tfor (let j = 0; j < o.cols; ++j) {\n\t\t\t\tlet v = 0;\n\t\t\t\tfor (let k = 0; k < this.cols; ++k) {\n\t\t\t\t\tv += this.atUnchecked(i, k)! * o.atUnchecked(k, j)!;\n\t\t\t\t}\n\t\t\t\tresult.setUnchecked(i, j, v);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tmultScalar(s: number): Matrix {\n\t\treturn this.multScalarUnchecked(s);\n\t}\n\tprotected multScalarUnchecked(s: number, result: Matrix | null = null): Matrix {\n\t\treturn this.binaryElementsUnchecked((a, b) => a * b, s, result);\n\t}\n\n\ttranspose(): Matrix {\n\t\treturn this.transposeUnchecked(null);\n\t}\n\tprotected transposeUnchecked(result: Matrix | null) {\n\t\tresult = result || new Matrix(this.cols, this.rows);\n\t\tfor (let i = 0; i < this.rows; ++i) {\n\t\t\tfor (let j = 0; j < this.cols; ++j) {\n\t\t\t\tresult.setUnchecked(j, i, this.atUnchecked(i, j)!);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tround(): this {\n\t\treturn this.unaryOperation(this.roundUnchecked);\n\t}\n\tprotected roundUnchecked(result: Matrix) {\n\t\treturn this.unaryElementsUnchecked(Math.round, result);\n\t}\n\n\tfloor(): this {\n\t\treturn this.unaryOperation(this.floorUnchecked);\n\t}\n\tprotected floorUnchecked(result: Matrix) {\n\t\treturn this.unaryElementsUnchecked(Math.floor, result);\n\t}\n\n\tceil(): this {\n\t\treturn this.unaryOperation(this.ceilUnchecked);\n\t}\n\tprotected ceilUnchecked(result: Matrix) {\n\t\treturn this.unaryElementsUnchecked(Math.ceil, result);\n\t}\n\n\tisEqual(o: Matrix) {\n\t\tthis.checkMatchingSize(o);\n\t\tfor (let i = 0; i < this.data.length; ++i) {\n\t\t\tif (this.data[i] !== o.data[i]) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tisApproxEqual(o: Matrix, delta: number): boolean {\n\t\tthis.checkMatchingSize(o);\n\t\treturn this.sub(o).abs().maximum() < delta;\n\t}\n\n\tisZero() {\n\t\tfor (const value of this.data) {\n\t\t\tif (value !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tisFinite() {\n\t\tfor (const value of this.data) {\n\t\t\tif (!Number.isFinite(value)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\ttoString(): string {\n\t\tif (this.cols === 1) {\n\t\t\treturn '[' + this.data.toString() + ']ᵀ';\n\t\t} else {\n\t\t\tconst rowStrings: string[] = [];\n\t\t\tfor (let i = 0; i < this.rows; ++i) {\n\t\t\t\tconst start = i * this.cols;\n\t\t\t\trowStrings.push('[' + this.data.slice(start, start + this.cols).toString() + ']');\n\t\t\t}\n\t\t\treturn '[' + rowStrings.toString() + ']';\n\t\t}\n\t}\n}\n\nexport class Vector extends Matrix {\n\tconstructor(dim: number, data?: ArrayLike<number> | Float32Array) {\n\t\tsuper(dim, 1, data);\n\t}\n\n\tprotected checkLength(o: Vector) {\n\t\tif (o.dim !== this.dim) {\n\t\t\tthrow new Error('incompatible dimensions');\n\t\t}\n\t}\n\n\tprotected createEmptyOfSameSize(): this {\n\t\treturn new Vector(this.dim) as this;\n\t}\n\n\tprivate unaryVectorOperation(functor: (result: Vector) => Vector): this {\n\t\tconst result = this.createEmptyOfSameSize();\n\t\tfunctor.bind(this)(result);\n\t\treturn result;\n\t}\n\n\tdot(o: Vector): number {\n\t\tthis.checkLength(o);\n\t\treturn this.dotUnchecked(o);\n\t}\n\tprotected dotUnchecked(o: Vector): number {\n\t\treturn this.fold2Unchecked((acc: number, value1: number, value2: number) => acc + value1 * value2, o, 0);\n\t}\n\n\tnorm2(): number {\n\t\treturn this.dotUnchecked(this);\n\t}\n\n\tnorm(): number {\n\t\treturn Math.sqrt(this.norm2());\n\t}\n\n\treverse(): this {\n\t\treturn this.unaryVectorOperation(this.reverseUnchecked);\n\t}\n\tprotected reverseUnchecked(result: Vector): Vector {\n\t\tfor (let i = 0; i < this.data.length; ++i) {\n\t\t\tresult.data[this.data.length - i - 1] = this.data[i]!;\n\t\t}\n\t\treturn result;\n\t}\n\n\tunit(): this {\n\t\treturn this.unaryVectorOperation(this.unitUnchecked);\n\t}\n\tprotected unitUnchecked(result: Vector): Vector {\n\t\tconst norm = this.norm();\n\t\tfor (let i = 0; i < this.data.length; ++i) {\n\t\t\tresult.data[i] = this.data[i]! / norm;\n\t\t}\n\t\treturn result;\n\t}\n}\n\n// Note: this version is manually optimised instead of inheriting Matrix & Vector\n// because complex class structure is too slow and Vector2 is on the hot path.\nexport class Vector2 {\n\tx: number;\n\ty: number;\n\n\t// constructors\n\n\tconstructor(xOrArray: number | [number, number] = 0, y = 0) {\n\t\tif (xOrArray === undefined) {\n\t\t\tthis.x = 0;\n\t\t\tthis.y = 0;\n\t\t} else if (xOrArray instanceof Array) {\n\t\t\tthis.x = xOrArray[0];\n\t\t\tthis.y = xOrArray[1];\n\t\t} else {\n\t\t\tthis.x = xOrArray;\n\t\t\tthis.y = y;\n\t\t}\n\t}\n\n\t// getters and setters\n\n\tstatic unitX(): Vector2 {\n\t\treturn new Vector2(1, 0);\n\t}\n\n\tstatic unitY(): Vector2 {\n\t\treturn new Vector2(0, 1);\n\t}\n\n\tstatic zeros(): Vector2 {\n\t\treturn new Vector2(0, 0);\n\t}\n\n\tstatic ones(): Vector2 {\n\t\treturn new Vector2(1, 1);\n\t}\n\n\tstatic fromRotation(angle: number): Vector2 {\n\t\treturn new Vector2(Math.cos(angle), Math.sin(angle));\n\t}\n\n\tstatic fromAngleAndLength(angle: number, length: number): Vector2 {\n\t\treturn new Vector2(Math.cos(angle) * length, Math.sin(angle) * length);\n\t}\n\n\tstatic fromScalar(value: number) {\n\t\treturn new Vector2(value, value);\n\t}\n\n\tget xx(): Vector2 {\n\t\treturn new Vector2(this.x, this.x);\n\t}\n\tget yy(): Vector2 {\n\t\treturn new Vector2(this.y, this.y);\n\t}\n\tget yx(): Vector2 {\n\t\treturn new Vector2(this.y, this.x);\n\t}\n\n\tget negateX(): Vector2 {\n\t\treturn new Vector2(-this.x, this.y);\n\t}\n\tget negateY(): Vector2 {\n\t\treturn new Vector2(this.x, -this.y);\n\t}\n\n\tget angle(): number {\n\t\treturn Math.atan2(this.y, this.x);\n\t}\n\n\tget perp(): Vector2 {\n\t\treturn new Vector2(-this.y, this.x);\n\t}\n\n\tget aspectRatio(): number {\n\t\treturn this.x / this.y;\n\t}\n\n\tget dataRowMajor() {\n\t\treturn [this.x, this.y];\n\t}\n\n\t// operations\n\n\tclone() {\n\t\treturn new Vector2(this.x, this.y);\n\t}\n\n\tabs() {\n\t\treturn new Vector2(Math.abs(this.x), Math.abs(this.y));\n\t}\n\n\tsign(): Vector2 {\n\t\treturn new Vector2(Math.sign(this.x), Math.sign(this.y));\n\t}\n\n\tminimum(): number {\n\t\treturn Math.min(this.x, this.y);\n\t}\n\n\tmaximum(): number {\n\t\treturn Math.max(this.x, this.y);\n\t}\n\n\tmin(v: Vector2): Vector2 {\n\t\treturn new Vector2(\n\t\t\tMath.min(this.x, v.x),\n\t\t\tMath.min(this.y, v.y)\n\t\t);\n\t}\n\n\tminXY(x: number, y: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tMath.min(this.x, x),\n\t\t\tMath.min(this.y, y)\n\t\t);\n\t}\n\n\tmax(v: Vector2): Vector2 {\n\t\treturn new Vector2(\n\t\t\tMath.max(this.x, v.x),\n\t\t\tMath.max(this.y, v.y)\n\t\t);\n\t}\n\n\tmaxXY(x: number, y: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tMath.max(this.x, x),\n\t\t\tMath.max(this.y, y)\n\t\t);\n\t}\n\n\tadd(v: Vector2): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x + v.x,\n\t\t\tthis.y + v.y\n\t\t);\n\t}\n\n\taddXY(x: number, y: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x + x,\n\t\t\tthis.y + y\n\t\t);\n\t}\n\n\tsub(v: Vector2): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x - v.x,\n\t\t\tthis.y - v.y\n\t\t);\n\t}\n\n\tsubXY(x: number, y: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x - x,\n\t\t\tthis.y - y\n\t\t);\n\t}\n\n\tdivElements(v: Vector2): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x / v.x,\n\t\t\tthis.y / v.y\n\t\t);\n\t}\n\n\tdivXY(x: number, y: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x / x,\n\t\t\tthis.y / y\n\t\t);\n\t}\n\n\tmultElements(v: Vector2): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x * v.x,\n\t\t\tthis.y * v.y\n\t\t);\n\t}\n\n\tmultXY(x: number, y: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x * x,\n\t\t\tthis.y * y\n\t\t);\n\t}\n\n\tmultScalar(s: number): Vector2 {\n\t\treturn new Vector2(\n\t\t\tthis.x * s,\n\t\t\tthis.y * s\n\t\t);\n\t}\n\n\tround() {\n\t\treturn new Vector2(Math.round(this.x), Math.round(this.y));\n\t}\n\n\tfloor() {\n\t\treturn new Vector2(Math.floor(this.x), Math.floor(this.y));\n\t}\n\n\tceil() {\n\t\treturn new Vector2(Math.ceil(this.x), Math.ceil(this.y));\n\t}\n\n\tisEqual(o: Vector2) {\n\t\treturn this.x === o.x && this.y === o.y;\n\t}\n\n\tisApproxEqual(o: Vector2, delta: number): boolean {\n\t\treturn Math.abs(this.x - o.x) < delta && Math.abs(this.y - o.y) < delta;\n\t}\n\n\tisZero() {\n\t\treturn this.x === 0 && this.y === 0;\n\t}\n\n\tisFinite() {\n\t\treturn Number.isFinite(this.x) && Number.isFinite(this.y);\n\t}\n\n\ttoString() {\n\t\treturn `[${this.x}, ${this.y}]`;\n\t}\n\n\tdot(o: Vector2): number {\n\t\treturn this.x * o.x + this.y * o.y;\n\t}\n\n\tcross(o: Vector2): number {\n\t\treturn this.x * o.y - this.y * o.x;\n\t}\n\n\trotate(angle: number): Vector2 {\n\t\tconst cos = Math.cos(angle);\n\t\tconst sin = Math.sin(angle);\n\t\tconst x = this.x;\n\t\tconst y = this.y;\n\t\treturn new Vector2(\n\t\t\tx * cos - y * sin,\n\t\t\tx * sin + y * cos\n\t\t);\n\t}\n\n\trotate90deg(): Vector2 {\n\t\treturn new Vector2(-this.y, this.x);\n\t}\n\n\tnorm2() {\n\t\treturn this.x * this.x + this.y * this.y;\n\t}\n\tnorm() {\n\t\treturn Math.sqrt(this.norm2());\n\t}\n\tnormalized() {\n\t\treturn this.multScalar(1 / this.norm());\n\t}\n\n\tdist2(o: Vector2) {\n\t\treturn o.sub(this).norm2();\n\t}\n\tdist(o: Vector2) {\n\t\treturn Math.sqrt(this.dist2(o));\n\t}\n\n\tunit() {\n\t\tconst norm = this.norm();\n\t\treturn new Vector2(this.x / norm, this.y / norm);\n\t}\n\n\tperpUnit() {\n\t\tconst norm = this.norm();\n\t\treturn new Vector2(-this.y / norm, this.x / norm);\n\t}\n\n\t// This normal points outwards if this is an arrow of a counter clockwise boundary polygon\n\tnormal() {\n\t\tconst norm = this.norm();\n\t\treturn new Vector2(this.y / norm, -this.x / norm);\n\t}\n\n\tisInRect(rx: number, ry: number, rWidth: number, rHeight: number): boolean;\n\tisInRect(pos: Vector2, size: Vector2): boolean;\n\tisInRect(rxOrPos: number | Vector2, ryOrSize: number|Vector2, rWidth?: number, rHeight?: number) {\n\t\tif (rxOrPos instanceof Vector2 && ryOrSize instanceof Vector2) {\n\t\t\treturn isInRect(this.x, this.y, rxOrPos.x, rxOrPos.y, ryOrSize.x, ryOrSize.y);\n\t\t} else {\n\t\t\treturn isInRect(this.x, this.y, rxOrPos as number, ryOrSize as number, rWidth!, rHeight!);\n\t\t}\n\t}\n}\n\nexport function assertVector2(value: Vector2, name: string) {\n\tassertType(Vector2, value, name);\n\tassert(value.isFinite(), `${name} (${value.toString()}) is not a finite Vector2`);\n}\n\nexport function isInRect(px: number, py: number, x: number, y: number, w: number, h: number): boolean {\n\treturn px >= x && px < x + w && py >= y && py < y + h;\n}\n\n/**\n * Compute vector closest to v within the origin centered axis-symmetric rectangle defined by topRightCorner.\n */\nexport function projectIntoRect(v: Vector2, topRightCorner: Vector2) {\n\treturn v.abs().min(topRightCorner).multElements(v.sign());\n}\n\n/**\n * Compute length of the intersection of a ray starting in the center of a rectangle with that rectangle.\n */\nexport function rectangleCenterRayIntersectionLength(rayDirection: Vector2, topRightCorner: Vector2) {\n\tassert(!rayDirection.isZero(), 'Ray direction must not be zero!');\n\n\trayDirection = rayDirection.abs().normalized(); // length will be the same for the abs ray, because the rectangle is assumed axis aligned and centered (-> axis mirroring leaves it invariant)\n\n\tlet intersectionPoint;\n\tif (topRightCorner.normalized().x < rayDirection.x) { // ray intersects the right wall of the rectangle\n\t\tintersectionPoint = new Vector2(topRightCorner.x, topRightCorner.x / rayDirection.aspectRatio);\n\t} else { // ray intersects top wall\n\t\tintersectionPoint = new Vector2(topRightCorner.y * rayDirection.aspectRatio, topRightCorner.y);\n\t}\n\treturn intersectionPoint.norm();\n}\n\nexport class Matrix2 extends Matrix {\n\n\t// constructors\n\n\tconstructor();\n\t// eslint-disable-next-line @typescript-eslint/unified-signatures\n\tconstructor(data: [[number, number], [number, number]]);\n\t// eslint-disable-next-line @typescript-eslint/unified-signatures\n\tconstructor(data: [number, number, number, number]);\n\tconstructor(a11: number, a12: number, a21: number, a22: number);\n\tconstructor(a11OrData?: any, a12?: number, a21?: number, a22?: number) {\n\t\tif (a11OrData === undefined) {\n\t\t\tsuper(2, 2);\n\t\t} else if (a11OrData instanceof Array) {\n\t\t\tif (a11OrData[0] instanceof Array) {\n\t\t\t\tsuper(2, 2, [a11OrData[0][0], a11OrData[0][1], a11OrData[1][0], a11OrData[1][1]]);\n\t\t\t} else {\n\t\t\t\tsuper(2, 2, [a11OrData[0], a11OrData[1], a11OrData[2], a11OrData[3]]);\n\t\t\t}\n\t\t} else {\n\t\t\tsuper(2, 2, [a11OrData, a12!, a21!, a22!]);\n\t\t}\n\t}\n\n\t// getters and setters\n\n\tstatic zeros(): Matrix2 {\n\t\treturn new Matrix2(0, 0, 0, 0);\n\t}\n\n\tstatic ones(): Matrix2 {\n\t\treturn new Matrix2(1, 1, 1, 1);\n\t}\n\n\tstatic identity() {\n\t\tconst result = new Matrix2();\n\t\tsuper.identity(result);\n\t\treturn result;\n\t}\n\n\tstatic fromRotation(angle: number): Matrix2 {\n\t\tconst cAngle = Math.cos(angle);\n\t\tconst sAngle = Math.sin(angle);\n\t\treturn new Matrix2(cAngle, -sAngle, sAngle, cAngle);\n\t}\n\n\t// helpers\n\n\tprotected createEmptyOfSameSize(): this {\n\t\treturn new Matrix2() as this;\n\t}\n\n\tprivate unaryOperationMatrix2(functor: (result: Matrix) => Matrix): Matrix2 {\n\t\tconst result = new Matrix2();\n\t\tfunctor.bind(this)(result);\n\t\treturn result;\n\t}\n\n\tprivate binaryOperation(functor: (o: Matrix, result: Matrix) => Matrix, o: Matrix2): Matrix2;\n\tprivate binaryOperation(functor: (s: number, result: Matrix) => Matrix, s: number): Matrix2;\n\tprivate binaryOperation(functor: ((o: Matrix, result: Matrix) => Matrix) | ((s: number, result: Matrix) => Matrix), o: Matrix2 | number): Matrix2 {\n\t\tconst result = new Matrix2();\n\t\t(functor as ((s: number | Matrix, result: Matrix) => Matrix)).bind(this)(o, result);\n\t\treturn result;\n\t}\n\n\t// operations\n\n\tmin(v: Matrix2): Matrix2 {\n\t\treturn this.binaryOperation(super.minUnchecked, v);\n\t}\n\n\tmax(v: Matrix2): Matrix2 {\n\t\treturn this.binaryOperation(super.maxUnchecked, v);\n\t}\n\n\tadd(v: Matrix2): Matrix2 {\n\t\treturn this.binaryOperation(super.addUnchecked, v);\n\t}\n\n\tsub(v: Matrix2): Matrix2 {\n\t\treturn this.binaryOperation(super.subUnchecked, v);\n\t}\n\n\tdivElements(v: Matrix2): Matrix2 {\n\t\treturn this.binaryOperation(super.divElementsUnchecked, v);\n\t}\n\n\tmultElements(v: Matrix2): Matrix2 {\n\t\treturn this.binaryOperation(super.multElementsUnchecked, v);\n\t}\n\n\tmult(v: Vector2): Vector2;\n\tmult(v: Matrix2): Matrix2;\n\tmult<R extends Vector2 | Matrix2>(v: R): R {\n\t\tif (v instanceof Vector2) {\n\t\t\treturn new Vector2(\n\t\t\t\tthis.data[0]! * v.x + this.data[1]! * v.y,\n\t\t\t\tthis.data[2]! * v.x + this.data[3]! * v.y\n\t\t\t) as R;\n\t\t} else {\n\t\t\tconst result = new Matrix2();\n\t\t\tsuper.multUnchecked(v, result);\n\t\t\treturn result as R;\n\t\t}\n\t}\n\n\tmultScalar(s: number): Matrix2 {\n\t\treturn this.binaryOperation(super.multScalarUnchecked, s);\n\t}\n\n\ttranspose(): Matrix2 {\n\t\treturn this.unaryOperationMatrix2(super.transposeUnchecked);\n\t}\n}\n\n\nexport class ScalingTranslation {\n\tconstructor(public scaleFactor: number, public translation: Vector2) {\n\t}\n\ttoSimilarityTransform() {\n\t\treturn new SimilarityTransform(this.translation, 0, this.scaleFactor);\n\t}\n}\n\nexport class ScalingRotation {\n\tconstructor(public scaleFactor: number = 1, public rotationAngle: number = 0) {\n\t}\n\ttoSimilarityTransform() {\n\t\treturn new SimilarityTransform(new Vector2(), this.rotationAngle, this.scaleFactor);\n\t}\n}\n\nexport class ProperIsometry {\n\tconstructor(public rotationAngle: number, public translation: Vector2) {\n\t}\n\ttoSimilarityTransform() {\n\t\treturn new SimilarityTransform(this.translation, this.rotationAngle, 1.0);\n\t}\n}\n\n/**\n * This class represents a 2d similarity transformation.\n * The transformation is represented by translation after rotation and scaling\n */\nexport class SimilarityTransform {\n\tdata: FixedSizeFloat32Array<4>;\n\n\tconstructor(translation: Vector2 = new Vector2(), rotationAngle = 0, scaleFactor = 1) {\n\t\tthis.data = createFixedSizeFloat32Array(4);\n\t\tthis.data[0] = translation.x;\n\t\tthis.data[1] = translation.y;\n\t\tthis.data[2] = normalizeAngle(rotationAngle);\n\t\tthis.data[3] = scaleFactor;\n\t}\n\n\tget translationX() { return this.data[0]; }\n\tset translationX(value: number) { this.data[0] = value; }\n\tget translationY() { return this.data[1]; }\n\tset translationY(value: number) { this.data[1] = value; }\n\tget translation() { return new Vector2(this.data[0], this.data[1]); }\n\tset translation(value: Vector2) { this.data[0] = value.x; this.data[1] = value.y; }\n\tget rotationAngle() { return this.data[2]; }\n\tset rotationAngle(value: number) { this.data[2] = value; }\n\tget rotationDegrees() { return this.data[2] * 180 / Math.PI; }\n\tset rotationDegrees(value: number) { this.data[2] = value * Math.PI / 180; }\n\tget scaleFactor() { return this.data[3]; }\n\tset scaleFactor(value: number) { this.data[3] = value; }\n\n\tapply(point: Vector2): Vector2 {\n\t\t// Hand-optimised because on the performance hot path\n\t\tconst s = this.scaleFactor;\n\t\tconst sx = point.x * s;\n\t\tconst sy = point.y * s;\n\t\tconst angle = this.rotationAngle;\n\t\tconst cos = Math.cos(angle);\n\t\tconst sin = Math.sin(angle);\n\t\tconst rx = sx * cos - sy * sin;\n\t\tconst ry = sx * sin + sy * cos;\n\t\treturn new Vector2(this.translationX + rx, this.translationY + ry);\n\t\t// return this.translation.add(point.multScalar(this.scaleFactor).rotate(this.rotationAngle));\n\t}\n\n\tapplyInverted(point: Vector2): Vector2 {\n\t\t// Same as apply, but reversed\n\t\tconst s = 1 / this.scaleFactor;\n\t\tconst sx = (point.x - this.translation.x) * s;\n\t\tconst sy = (point.y - this.translation.y) * s;\n\t\tconst angle = -this.rotationAngle;\n\t\tconst cos = Math.cos(angle);\n\t\tconst sin = Math.sin(angle);\n\t\tconst rx = sx * cos - sy * sin;\n\t\tconst ry = sx * sin + sy * cos;\n\t\treturn new Vector2(rx, ry);\n\t}\n\n\tinverse(): SimilarityTransform {\n\t\tconst invScale = 1 / this.scaleFactor;\n\t\tconst invRotation = -this.rotationAngle;\n\t\treturn new SimilarityTransform(this.translation.multScalar(-invScale).rotate(invRotation), invRotation, invScale);\n\t}\n\n\t/**\n\t * Creates a new transformation equivalent to first applying other, than this.\n\t */\n\tafter(other: SimilarityTransform): SimilarityTransform {\n\t\treturn new SimilarityTransform(\n\t\t\tthis.apply(other.translation),\n\t\t\tnormalizeAngle(other.rotationAngle + this.rotationAngle),\n\t\t\tother.scaleFactor * this.scaleFactor\n\t\t);\n\t}\n\n\tisEqual(that: SimilarityTransform) {\n\t\treturn this.translation.isEqual(that.translation) &&\n\t\t\tthis.rotationAngle === that.rotationAngle &&\n\t\t\tthis.scaleFactor === that.scaleFactor\n\t\t;\n\t}\n\n\tisApproxEqual(that: SimilarityTransform, eps: number) {\n\t\tconst angleD = Math.abs(this.rotationAngle - that.rotationAngle) % (Math.PI * 2);\n\t\treturn this.translation.isApproxEqual(that.translation, eps)\n\t\t\t&& Math.abs(angleD > Math.PI ? Math.PI * 2 - angleD : angleD) < eps\n\t\t\t&& Math.abs(this.scaleFactor - that.scaleFactor) < eps\n\t\t;\n\t}\n\n\ttoString(): string {\n\t\tconst deg = this.rotationAngle * 180 / Math.PI;\n\t\treturn `ST(trans: ${this.translation}, rot: ${deg} deg, scale: ${this.scaleFactor})`;\n\t}\n\n\tclone(): SimilarityTransform {\n\t\treturn new SimilarityTransform(this.translation.clone(), this.rotationAngle, this.scaleFactor);\n\t}\n\n\ttoGLMat3() {\n\t\tconst mat3 = createFixedSizeFloat32Array(9);\n\t\tmat3[0] = Math.cos(this.rotationAngle) * this.scaleFactor;\n\t\tmat3[1] = Math.sin(this.rotationAngle) * this.scaleFactor;\n\t\tmat3[3] = -mat3[1];\n\t\tmat3[4] = mat3[0];\n\t\tmat3[6] = this.translationX;\n\t\tmat3[7] = this.translationY;\n\t\tmat3[8] = 1;\n\t\treturn mat3;\n\t}\n\n\ttoHomMatrix() {\n\t\treturn new Matrix(3, 3, this.toGLMat3());\n\t}\n\n\tstatic translation(translation: Vector2) {\n\t\treturn new SimilarityTransform(translation);\n\t}\n\n\tstatic scalingTranslation(scaleFactor: number, translation: Vector2) {\n\t\treturn new SimilarityTransform(translation, 0, scaleFactor);\n\t}\n\n\tstatic rotation(rotationAngle: number) {\n\t\treturn new SimilarityTransform(new Vector2(), rotationAngle);\n\t}\n\n\tstatic scalingRotation(scaleFactor: number, rotationAngle: number) {\n\t\treturn new SimilarityTransform(new Vector2(), rotationAngle, scaleFactor);\n\t}\n\n\tstatic se2(translation: Vector2, rotationAngle: number) {\n\t\treturn new SimilarityTransform(translation, rotationAngle);\n\t}\n\n\tstatic scaling(scaleFactor: number) {\n\t\treturn new SimilarityTransform(new Vector2(), 0, scaleFactor);\n\t}\n}\n\nexport function assertSimilarityTransform(value: SimilarityTransform, name: string) {\n\tassertType(SimilarityTransform, value, name);\n\tassertVector2(value.translation, 'translation');\n\tassertNumber(value.rotationAngle, 'rotationAngle');\n\tassertNumber(value.scaleFactor, 'scaleFactor');\n}\n\nexport function clonePolygon(polygon: Vector2[]): Vector2[] {\n\treturn polygon.map((p) => p.clone());\n}\n\nexport function scaleVectors2OrScalar<T extends Vector2[] | Vector2 | number>(polygon: T, factor: number): T {\n\tif (polygon instanceof Vector2) {\n\t\treturn polygon.multScalar(factor) as T;\n\t} else if (polygon instanceof Array) {\n\t\treturn polygon.map((p) => p.multScalar(factor)) as T;\n\t} else {\n\t\t// Note: we have to disable the linter here because it pretends the\n\t\t// annotation is not needed but the compiler is not able to deduce the type.\n\t\t// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n\t\treturn (polygon as number) * factor as T;\n\t}\n}\n\nexport function translateVectors2<T extends Vector2[] | null>(polygon: T, shift: Vector2): T {\n\tif (polygon === null) {\n\t\treturn polygon;\n\t} else {\n\t\treturn polygon.map((p) => p.add(shift)) as T;\n\t}\n}\n\nexport function transformVectors2<T extends Vector2[] | null>(polygon: T, transform: SimilarityTransform): T {\n\tif (polygon === null) {\n\t\treturn polygon;\n\t} else {\n\t\treturn polygon.map((p) => transform.apply(p)) as T;\n\t}\n}\n\nexport function areVector2Collinear(v0: Vector2, v1: Vector2, error = 1e-3) {\n\tconst u0 = v0.unit();\n\tconst u1 = v1.unit();\n\treturn u0.isApproxEqual(u1, error);\n}\n\n\nexport const IdentityTransformation = new SimilarityTransform();\nexport const IdentityScalingRotation = new ScalingRotation();\n","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { v5 as uuidv5 } from 'uuid';\nimport * as UuidGenerator from 'utils/uuid-generator';\nimport { bufferToHex } from 'utils/buffers';\n\n// Generate a namespace for game uu./game-core\nexport const GameNamespace = uuidv5(window.location.search + '_games', uuidv5.DNS);\nexport const AssetNamespace = uuidv5(window.location.search + '_assets', uuidv5.DNS);\nexport const CamNamespace = uuidv5(window.location.search + '_cam', uuidv5.DNS);\nexport const GameSessionNamespace = uuidv5(window.location.search + '_game_sessions', uuidv5.DNS);\n\nexport function createUUID(namespace: string) {\n\treturn UuidGenerator.createCurrentHostBasedUuidBuffer(namespace);\n}\n\nexport function createUUIDString(namespace: string) {\n\treturn bufferToHex(createUUID(namespace));\n}","/**\n * Game runtime based on planck.js for simulation and HTML Canvas for display.\n * @module runtime\n * @preferred\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { dynamicCast, cast, defined, nonnull, toStr } from '../utils/types';\nimport { World, Vec2, Body, BodyDef, FixtureDef, Box, Polygon, Circle, Contact, Manifold, WorldManifold, internal as PlanckInternal, Settings as PlanckSettings, Fixture, AABB, Shape, Transform } from 'planck-js';\nimport { ObjectType, CoreGame, Animation } from '../game/game-core';\nimport { Vector2, SimilarityTransform, ScalingRotation, projectIntoRect, rectangleCenterRayIntersectionLength } from 'math/linalg';\nimport { Rect } from 'math/geometry';\nimport { InputBlock } from 'blocks/conditions/input/input-block';\nimport { SpeedBlock, SpeedBlockMode } from 'blocks/actions/speed/speed-block';\nimport { AngularSpeedBlock, AngularSpeedBlockMode } from 'blocks/actions/speed/angular-speed-block';\nimport { StopBlock } from 'blocks/actions/speed/stop-block';\nimport { BrakeBlock } from 'blocks/actions/speed/brake-block';\nimport { CollisionBlock } from 'blocks/conditions/collision/collision-block';\nimport { DeleteBlock } from 'blocks/actions/delete/delete-block';\nimport { ChangeVariableOperation, ChangeVariableBlock } from 'blocks/actions/variable/change-variable-block';\nimport { ComparisonBlock, ComparisonInputSide, ComparisonOperation } from 'blocks/conditions/comparison/comparison-block';\nimport { SpawnBlock } from 'blocks/actions/spawn/spawn-block';\nimport { InitBlock } from 'blocks/conditions/init/init-block';\nimport { FlipBlock } from 'blocks/actions/flip/flip-block';\nimport { ShowDialogBlock } from 'blocks/actions/dialog/dialog-block';\nimport { TeleportBlock } from 'blocks/actions/teleport/teleport-block';\nimport { VibrateBlock } from 'blocks/actions/vibrate/vibrate-block';\nimport { MusicBlock } from 'blocks/actions/music/music-block';\nimport { TimerBlock } from 'blocks/conditions/timer/timer-block';\nimport { RestartTimerBlock } from 'blocks/actions/timer/restart-timer-block';\nimport { assert, assertNonNull, assertRecoverable } from 'utils/assert';\nimport { getMusic } from 'blocks/actions/music/music';\nimport { TouchBlock } from 'blocks/conditions/touch/touch-block';\nimport { normalizeAngle, normalizeAngleAround0 } from 'math/helpers';\nimport { collisionDistance } from 'math/collision-distance';\nimport { isBitSet } from 'utils/flags';\nimport { variableIndex, VariableScope, variableScope } from './variable';\nimport { BlockKind } from 'vpl/block';\nimport { ReadVariableBlock } from 'blocks/generic/read-variable/read-variable-block';\nimport { CandliRow } from 'level/behaviour-editor-interface';\nimport { SoundBlock } from 'blocks/actions/sound/sound-block';\nimport { getSoundSystem } from 'blocks/actions/sound/sound';\nimport { EndAnimationMode, PlayAnimationBlock } from 'blocks/actions/animation/animation-block';\nimport { AnimationIsBlock } from 'blocks/conditions/animation/animation-is-block';\nimport { BinaryArithmeticBlock, executeBinaryOperation, isBinaryOperationValid } from 'blocks/generic/binary-arithmetic/binary-arithmetic-block';\nimport { BinaryArithmeticInput } from 'flatbuffers/all';\nimport { RandomValueBlock } from 'blocks/generic/random-value/random-value-block';\nimport { randIntInclusiveRange } from 'utils/random-core';\nimport { ScriptGenericBlock } from 'blocks/generic/script-generic/script-generic-block';\nimport { ScriptActionBlock } from 'blocks/actions/script/script-action-block';\nimport { setScriptRuntimeData } from './runtime-script';\nimport { ScriptConditionBlock } from 'blocks/conditions/script/script-condition-block';\nimport { CanvasAttributes, CanvasOverlay, CanvasRenderAction } from './runtime-canvas';\nimport { uniqueId } from 'utils/debug';\nimport { ScriptValue } from 'app-core-web/pkg';\nimport { isPointInShape, unionConvexHulls } from 'math/convex-poly';\nimport { createUUIDString, GameSessionNamespace } from 'network/api-uuid';\n\nexport { Body };\n\n// damping is used to simulate world friction\n// TODO: put it in world settings\nconst LinearDampingFactor = 1.0;\nconst AngularDampingFactor = 1.0;\n\nexport const MaxSpawnedInstanceCount = 1000;\n\nexport function toVec2(vec: Vector2) {\n\treturn new Vec2(vec.x, vec.y);\n}\n\nexport function toVector2(vec: Vec2) {\n\treturn new Vector2(vec.x, vec.y);\n}\n\nfunction toVec2Array(vecs: Vector2[], scale: Vector2) {\n\tconst result: Vec2[] = [];\n\tfor (const vec of vecs) {\n\t\tresult.push(toVec2(vec.multElements(scale)));\n\t}\n\treturn result;\n}\n\nfunction getShapeCenter(shape: Shape, xf: Transform) {\n\tconst aabb = new AABB();\n\tshape.computeAABB(aabb, xf);\n\treturn aabb.getCenter();\n}\n\n/// Assuming point is outside shape, project it to the shape boundary\nfunction projectPointToShape(point: Vec2, shape: Shape, xf: Transform) {\n\tconst c = getShapeCenter(shape, xf);\n\tconst input = {\n\t\tp1: point,\n\t\tp2: c,\n\t\tmaxFraction: 1,\n\t};\n\tconst output = {\n\t\tfraction: 0,\n\t\tnormal: Vec2(0, 0),\n\t};\n\tshape.rayCast(output, input, xf);\n\tpoint.x += (c.x - point.x) * (output.fraction);\n\tpoint.y += (c.y - point.y) * (output.fraction);\n}\n\n// function bodyTypeName(body: Body) {\n// \tconst bodyData = cast(BodyData, body.getUserData());\n// \treturn bodyData.typeName;\n// }\n\nfunction contactToWorldManifold(contact: Contact) {\n\tlet worldManifold: WorldManifold | undefined = contact.getWorldManifold(null);\n\tif (worldManifold === undefined) {\n\t\tconst fixtureA = contact.getFixtureA();\n\t\tconst fixtureB = contact.getFixtureB();\n\t\tconst shapeA = fixtureA.getShape();\n\t\tconst shapeB = fixtureB.getShape();\n\t\tconst bodyA = fixtureA.getBody();\n\t\tconst bodyB = fixtureB.getBody();\n\t\tconst xfA = bodyA.getTransform();\n\t\tconst xfB = bodyB.getTransform();\n\t\tconst manifold = new PlanckInternal.Manifold();\n\t\tcontact.evaluate(manifold, xfA, xfB);\n\t\tworldManifold = manifold.getWorldManifold(undefined, xfA, shapeA.getRadius(), xfB, shapeB.getRadius());\n\t\tif (worldManifold === undefined) {\n\t\t\treturn null;\n\t\t}\n\t\tfor (const point of worldManifold.points) {\n\t\t\tconst insideA = shapeA.testPoint(xfA, point);\n\t\t\tconst insideB = shapeB.testPoint(xfB, point);\n\t\t\t// console.log('inside', bodyTypeName(bodyA), insideA, bodyTypeName(bodyB), insideB);\n\t\t\tif (insideA && !insideB) {\n\t\t\t\tprojectPointToShape(point, shapeB, xfB);\n\t\t\t}\n\t\t\tif (insideB && !insideA) {\n\t\t\t\tprojectPointToShape(point, shapeA, xfA);\n\t\t\t}\n\t\t}\n\t}\n\treturn worldManifold;\n}\n\nexport function getContactPoints(contact: Contact) {\n\tconst worldManifold = contactToWorldManifold(contact);\n\tif (worldManifold === null) {\n\t\treturn [];\n\t}\n\treturn worldManifold.points.map(toVector2);\n}\n\nexport function getContactPoint(contact: Contact) {\n\tconst worldManifold = contactToWorldManifold(contact);\n\tif (worldManifold === null) {\n\t\treturn null;\n\t}\n\treturn toVector2(worldManifold.points.reduce(\n\t\t(accP: Vec2, curP: Vec2) => accP.add(curP),\n\t\tnew Vec2()\n\t).mul(1 / worldManifold.points.length));\n}\n\nfunction createFixtureDef(objectType: ObjectType, scale: number, flippedX: boolean, flippedY: boolean, hasCollisionWithSomeone: boolean): FixtureDef {\n\tconst neverCollide = !objectType.isCollidable && !hasCollisionWithSomeone;\n\treturn {\n\t\tshape:\n\t\t\tobjectType.shape instanceof Vector2 ?\n\t\t\t\tBox(objectType.shape.x * scale * 0.5, objectType.shape.y * scale * 0.5) :\n\t\t\t\t(objectType.shape instanceof Array ?\n\t\t\t\t\tPolygon(toVec2Array(\n\t\t\t\t\t\tobjectType.shape,\n\t\t\t\t\t\tnew Vector2(flippedX ? -scale : scale, flippedY ? -scale : scale)\n\t\t\t\t\t)) :\n\t\t\t\t\tCircle(objectType.shape * scale)\n\t\t\t\t)\n\t\t,\n\t\tuserData: scale,\n\t\tdensity: objectType.density,\n\t\tfriction: objectType.isCollidable ? objectType.stickiness : 0,\n\t\trestitution: objectType.isDynamic ? objectType.bounciness : 0,\n\t\tisSensor: !objectType.isCollidable,\n\t\tfilterMaskBits: neverCollide ? 0 : undefined\n\t};\n}\n\nfunction getBodyTransform(body: Body) {\n\tconst fixture = nonnull(body.getFixtureList());\n\tconst scale = fixture.getUserData() as number;\n\treturn new SimilarityTransform(\n\t\ttoVector2(body.getPosition()),\n\t\tbody.getAngle(),\n\t\tscale\n\t)\n}\n\nexport type VariableValue = number | ScriptValue;\n\nexport class AnimationData {\n\tpublic startTime: number;\n\tpublic frameIndex: number;\n\tpublic index: number;\n\tpublic backward: boolean;\n\tpublic bounce: boolean;\n\tpublic endMode: EndAnimationMode;\n\n\tconstructor(currentTime: number, block?: PlayAnimationBlock, backward = false, bounce = false) {\n\t\tthis.startTime = currentTime;\n\t\tthis.frameIndex = 0;\n\t\tif (block !== undefined) {\n\t\t\tthis.index = block.index ?? 0;\n\t\t\tthis.endMode = block.endMode;\n\t\t} else {\n\t\t\tthis.index = 0;\n\t\t\tthis.endMode = EndAnimationMode.Loop;\n\t\t}\n\t\tthis.backward = backward;\n\t\tthis.bounce = bounce;\n\t}\n\n\tanimate(currentTime: number, animations: Animation[]) {\n\t\t// animation from object type\n\t\tconst otAnimation = defined(animations[this.index]);\n\t\tconst fps = otAnimation.fps;\n\t\tconst inFrameCount = otAnimation.frames.length;\n\n\t\t// specific animation ongoing\n\t\tconst duration = (currentTime - this.startTime);\n\t\tconst frame = Math.floor(duration * fps); // time-based frame\n\n\t\t// depending on animation mode, build frame computation function\n\t\tlet frameCount: number;\n\t\tlet frameProjF: (_: number) => number;\n\t\tif (this.bounce) {\n\t\t\tconst loop = this.endMode === EndAnimationMode.Loop && inFrameCount > 1;\n\t\t\tframeCount = loop ? 2 * inFrameCount - 2 : 2 * inFrameCount - 1;\n\t\t\tif (this.backward) {\n\t\t\t\tframeProjF = (x: number) => {\n\t\t\t\t\treturn x >= inFrameCount ? x - inFrameCount + 1 : inFrameCount - 1 - x;\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tframeProjF = (x: number) => x >= inFrameCount ? 2 * inFrameCount - 2 - x : x;\n\t\t\t}\n\t\t} else {\n\t\t\tframeCount = inFrameCount;\n\t\t\tif (this.backward) {\n\t\t\t\tframeProjF = (x: number) => frameCount - 1 - x;\n\t\t\t} else {\n\t\t\t\tframeProjF = (x: number) => x;\n\t\t\t}\n\t\t}\n\n\t\tassert(frameCount > 0);\n\n\t\tif (frame < frameCount) {\n\t\t\t// animation is ongoing, update frame\n\t\t\tthis.frameIndex = frameProjF(frame);\n\t\t} else {\n\t\t\t// animation is finished\n\t\t\tswitch (this.endMode) {\n\t\t\t\tcase EndAnimationMode.ReturnToIdle:\n\t\t\t\t\t// replace by default idle animation\n\t\t\t\t\tthis.startTime = currentTime;\n\t\t\t\t\tthis.frameIndex = 0;\n\t\t\t\t\tthis.index = 0;\n\t\t\t\t\tthis.backward = false;\n\t\t\t\t\tthis.bounce = false;\n\t\t\t\t\tthis.endMode = EndAnimationMode.Loop;\n\t\t\t\t\tbreak;\n\t\t\t\tcase EndAnimationMode.Loop:\n\t\t\t\t\tthis.frameIndex = frameProjF(frame % frameCount);\n\t\t\t\t\tbreak;\n\t\t\t\tcase EndAnimationMode.Stay:\n\t\t\t\t\tthis.frameIndex = frameProjF(frameCount - 1);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class BodyData {\n\tprivate _rulesCheckedAtLeastOnce = false;\n\tprivate _stepRunAtLeastOnce = false;\n\trulesActiveAtLastStep: Set<CandliRow> = new Set();\n\t// a cached of checked conditions, in case it was checked in pre-step\n\tcachedConditionResults: Map<CandliRow, boolean> = new Map();\n\tflippingFactors = new Vector2(1, 1);\n\tanimation: AnimationData | null = null;\n\tvariables: Map<number, VariableValue> = new Map();\n\ttouchedAsNew: number[] = [];\n\tcanvasOverlay: CanvasOverlay | null = null;\n\tcanvasAttributes = new CanvasAttributes();\n\n\tconstructor(\n\t\tpublic readonly objectType: ObjectType,\n\t\tpublic readonly typeName: string,\n\t\tpublic startTime: number,\n\t\tpublic readonly zOrder: number,\n\t\tflipX = false,\n\t\tflipY = false\n\t) {\n\t\tthis.flipX = flipX;\n\t\tthis.flipY = flipY;\n\t}\n\n\tget wereRulesCheckedAtLeastOnce() {\n\t\treturn this._rulesCheckedAtLeastOnce;\n\t}\n\tmarkRulesCheckedAtLeastOnce() {\n\t\tthis._rulesCheckedAtLeastOnce = true;\n\t}\n\n\tget wasStepRunAtLeastOnce() {\n\t\treturn this._stepRunAtLeastOnce;\n\t}\n\tmarkStepRunAtLeastOnce() {\n\t\tthis._stepRunAtLeastOnce = true;\n\t}\n\n\tget flipX() {\n\t\treturn this.flippingFactors.x < 0;\n\t}\n\tset flipX(flip: boolean) {\n\t\tthis.flippingFactors.x = flip ? -1 : 1;\n\t}\n\n\tget flipY() {\n\t\treturn this.flippingFactors.y < 0;\n\t}\n\tset flipY(flip: boolean) {\n\t\tthis.flippingFactors.y = flip ? -1 : 1;\n\t}\n\n\tanimate(currentTime: number) {\n\t\tnonnull(this.animation).animate(currentTime, this.objectType.animations);\n\t}\n\n\tcurrentAnimation() {\n\t\treturn defined(this.objectType.animations[this.animation?.index ?? 0]);\n\t}\n}\n\ntype ContactPointsGenerator = (body: Body, others: Set<ObjectType>) => Iterable<ContactPoint>;\n\nclass ObjectTypeProperties {\n\tpublic readonly hasSpeedBlocks: boolean;\n\tpublic readonly hasDeleteBlocks: boolean;\n\tpublic readonly collideWithNonObject: boolean;\n\tpublic readonly hasCollisionWithSomeone: boolean;\n\tpublic readonly hasTouchBlocks: boolean;\n\tpublic readonly displayBoxHalfSize: Vector2 | null;\n\tpublic levelInstanceCount = 0;\n\tpublic instanceCount = 0;\n\tpublic variables: Map<number, VariableValue> = new Map();\n\n\tconstructor(objectType: ObjectType, game: CoreGame) {\n\t\t// does its image extend beyond its collider?\n\t\tlet imageHull = null;\n\t\tfor (const animation of objectType.animations) {\n\t\t\tfor (const frame of animation.frames) {\n\t\t\t\tconst imageRect = new Rect(0, 0, frame.size.x, frame.size.y);\n\t\t\t\tconst frameHull = imageRect.transform(frame.partFromPixelTransform);\n\t\t\t\tif (imageHull === null) {\n\t\t\t\t\timageHull = frameHull;\n\t\t\t\t} else {\n\t\t\t\t\timageHull = unionConvexHulls(imageHull, frameHull);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tassertNonNull(imageHull, 'object type has no image');\n\t\tlet fullyContained = true;\n\t\tfor (const point of imageHull) {\n\t\t\tif (!isPointInShape(objectType.shape, point)) {\n\t\t\t\tfullyContained = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (fullyContained) {\n\t\t\tthis.displayBoxHalfSize = null;\n\t\t\t// console.log('DBG: Object type ' + objectType.nameOrIndex(game) + ' has fully contained image');\n\t\t} else {\n\t\t\tlet hx = 0;\n\t\t\tlet hy = 0;\n\t\t\tfor (const point of imageHull) {\n\t\t\t\thx = Math.max(hx, Math.abs(point.x));\n\t\t\t\thy = Math.max(hy, Math.abs(point.y));\n\t\t\t}\n\t\t\tthis.displayBoxHalfSize = new Vector2(hx, hy);\n\t\t\t// console.log('DBG: Object type ' + objectType.nameOrIndex(game) + ' has fully uncontained image with ', hx, hy, imageHull.length);\n\t\t}\n\t\t// does this object type has blocks of a given type?\n\t\tthis.hasSpeedBlocks = [...objectType.actionsIterator()].some(\n\t\t\t(block) => block instanceof SpeedBlock || block instanceof AngularSpeedBlock\n\t\t);\n\t\tthis.hasDeleteBlocks = [...objectType.actionsIterator()].some(\n\t\t\t(block) => block instanceof DeleteBlock\n\t\t);\n\t\tthis.hasTouchBlocks = [...objectType.conditionsIterator()].some(\n\t\t\t(block) => block instanceof TouchBlock\n\t\t);\n\t\t// does it collide with non-objects?\n\t\tthis.collideWithNonObject = false;\n\t\tthis.hasCollisionWithSomeone = false;\n\t\tfor (const collisionBlock of objectType.conditionsIteratorByType(CollisionBlock)) {\n\t\t\tthis.hasCollisionWithSomeone = true;\n\t\t\tfor (const other of collisionBlock.others) {\n\t\t\t\tif (!other.isCollidable ||\n\t\t\t\t\tother.kind === ObjectType.Kind.Kinematic\n\t\t\t\t) {\n\t\t\t\t\tthis.collideWithNonObject = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// do non-objects collide with it?\n\t\tfor (const block of game.blockWithContextIterator(['conditions'])) {\n\t\t\t// TODO: cleanup, using a game block iterator by type as in objectType\n\t\t\tconst collisionBlock = dynamicCast(CollisionBlock, block.block);\n\t\t\tif (collisionBlock === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (collisionBlock.others.has(objectType)) {\n\t\t\t\tthis.hasCollisionWithSomeone = true;\n\t\t\t\tif (block.objectType.kind !== ObjectType.Kind.Dynamic) {\n\t\t\t\t\tthis.collideWithNonObject = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport type RuntimeContactCallback = (contact: Contact) => void;\n\nexport type TouchingPoint = [Vector2, number, boolean];\n\nexport type DialogCallback = (endGame: boolean, screen: number | null) => void;\n\nexport interface TextInput {\n\tactive: boolean;\n\ttext: string;\n\tinitiator: Body | null;\n}\n\n/// A contact point with cached computation.\nexport class ContactPoint {\n\t/// Cached world coordinate point\n\t_point: Vector2 | null | undefined = undefined;\n\n\tconstructor(private readonly contact: Contact) {}\n\n\tget point() {\n\t\tif (this._point === undefined) {\n\t\t\tthis._point = getContactPoint(this.contact);\n\t\t}\n\t\treturn this._point;\n\t}\n\n\tgetOtherBody(body: Body) {\n\t\treturn this.contact.getFixtureA().getBody() === body ?\n\t\t\tthis.contact.getFixtureB().getBody() :\n\t\t\tthis.contact.getFixtureA().getBody();\n\t}\n}\n\nexport class Runtime {\n\tpublic world: World;\n\tpublic worldBounds = new Rect(0, 0, 0, 0);\n\tpublic lastStepTime: number | null = null;\n\tpublic scriptedBodies: Set<Body> = new Set();\n\tpublic animatedBodies: Set<Body> = new Set();\n\tpublic contactMaps = new Map<Body, Map<Body, ContactPoint>>();\n\tpublic objectTypesProperties = new Map<ObjectType, ObjectTypeProperties>();\n\tprivate currentDeltaT = 0;\n\tprivate currentTime = 0;\n\tprivate sessionId = createUUIDString(GameSessionNamespace);\n\tpublic targetCamera: Vector2 | Body = new Vector2();\n\tpublic targetCameraPos: Vector2 | null = null; // null to detect first pass of updateCameraPosition (needed for free motion box algo.)\n\tpublic currentCamera = new Vector2();\n\tpublic cameraExtent = Vector2.ones();\n\tpublic cameraVelocityOld = new Vector2();\n\tpublic maxZ = 0;\n\tpublic buttonState: [number, number] = [0, 0]; // bit masks\n\tpublic touchingPoints: TouchingPoint[] = [];\n\tprivate perfStatWindow = new Float32Array(64);\n\tprivate perfStateIndex = 0;\n\n\tpublic gameVariables: Map<number, VariableValue> = new Map([[0, 0]]);\n\tpublic gameVariablesChanged = true;\n\tpublic checkPoints: Set<string> = new Set();\n\n\tpublic contactCallback: RuntimeContactCallback | null = null;\n\n\tpublic canvasRenderActions: Map<BodyData, CanvasRenderAction[]> = new Map();\n\n\tprivate worldContacts: ContactPointsGenerator;\n\n\tprivate unknownActionExceptionFired = false;\n\tprivate unknownConditionExceptionFired = false;\n\tprivate unknownScopeExceptionFired = false;\n\tprivate unknownVarOpExceptionFired = false;\n\tprivate invalidVarWriteExceptionFired = false;\n\tinvalidVarReadExceptionFired = false;\n\n\tconstructor(\n\t\tpublic game: CoreGame,\n\t\tpublic gameId: string,\n\t\tprivate dialogCallback: DialogCallback,\n\t\tprivate textInput: TextInput\n\t) {\n\t\tthis.world = new World(new Vec2(0, game.level.gravity));\n\t\tthis.worldContacts = this.listWorldContacts.bind(this);\n\t\t// eslint-disable-next-line no-loss-of-precision\n\t\tthis.perfStatWindow.fill(1/60.);\n\t}\n\n\tget worldTime() {\n\t\treturn this.currentTime;\n\t}\n\n\tget gameSessionId() {\n\t\treturn this.sessionId;\n\t}\n\n\tget perfStats(): [number, number] {\n\t\tconst totalTime = this.perfStatWindow.reduce((acc, cur) => acc + cur, 0);\n\t\tif (totalTime === 0) {\n\t\t\treturn [1, 0];\n\t\t} else {\n\t\t\treturn [totalTime, this.perfStatWindow.length];\n\t\t}\n\t}\n\n\tget score() {\n\t\treturn this.gameVariables.get(0) ?? 0;\n\t}\n\n\tget displacedCurrentCamera() {\n\t\tconst centerDisplacement = this.targetCamera instanceof Vector2 ?\n\t\t\tVector2.zeros() :\n\t\t\tthis.game.level.camera.centerDisplacement;\n\t\tconst extent = this.game.level.camera.extent;\n\t\treturn this.currentCamera.add(centerDisplacement.multElements(extent).multScalar(1 / 2));\n\t}\n\n\tpublic eatGameVariablesChanged() {\n\t\tthis.gameVariablesChanged = false;\n\t}\n\n\tpublic step(timestamp: number, buttonState: [number, number], touchingPoints: TouchingPoint[], miniStepCb: () => void) {\n\t\t// if this is first render, just save timestamp\n\t\tif (this.lastStepTime !== null) {\n\t\t\t// define a mini-step\n\t\t\tconst miniStep = (deltaT: number) => {\n\t\t\t\t// step the world\n\t\t\t\tthis.currentDeltaT = deltaT;\n\t\t\t\tthis.world.step(deltaT);\n\t\t\t\tthis.updateContactMap();\n\t\t\t\t// process all inputs and execute rules for the engine\n\t\t\t\tthis.executeRules(deltaT);\n\t\t\t\t// update camera\n\t\t\t\tthis.updateCameraPosition(deltaT);\n\t\t\t\t// increment world time\n\t\t\t\tthis.currentTime += deltaT;\n\t\t\t\t// update animations\n\t\t\t\tthis.updateAnimations();\n\t\t\t\t// notify the parent that the mini step is done\n\t\t\t\tminiStepCb();\n\t\t\t};\n\n\t\t\t// store inputs state\n\t\t\tthis.buttonState = buttonState;\n\t\t\tthis.touchingPoints = touchingPoints;\n\n\t\t\t// if we dropped frame, perform several mini steps, but do not exceed 100ms\n\t\t\tconst idealDeltaT = (timestamp - this.lastStepTime) * 0.001;\n\t\t\tconst deltaT = Math.max(Math.min(idealDeltaT, 0.1), 0.001);\n\t\t\tconst MaxStepDuration = 0.020; // s\n\t\t\tconst miniStepCount = Math.ceil(deltaT / MaxStepDuration);\n\t\t\tconst miniStepDeltaT = deltaT / miniStepCount;\n\t\t\tfor (let i = 0; i < miniStepCount; ++i) {\n\t\t\t\tminiStep(miniStepDeltaT);\n\t\t\t}\n\n\t\t\t// store performance statistics\n\t\t\tthis.perfStatWindow[this.perfStateIndex] = deltaT;\n\t\t\tthis.perfStateIndex = (this.perfStateIndex + 1) % this.perfStatWindow.length;\n\t\t}\n\t\t// mark all objects as having run a step at least once\n\t\tfor (const body of this.scriptedBodies) {\n\t\t\tconst bodyData = cast(BodyData, body.getUserData());\n\t\t\tbodyData.markStepRunAtLeastOnce();\n\t\t}\n\t\tthis.lastStepTime = timestamp;\n\t}\n\n\tprivate executeRules(deltaT: number) {\n\t\t// process each scripted body\n\t\tconst toDeleteBodies: Set<Body> = new Set();\n\t\tconst toExecute = new Map<Body, [CandliRow, number, boolean][]>();\n\n\t\t// check all conditions\n\t\tthis.scriptedBodies.forEach((body) => {\n\t\t\tconst bodyData = cast(BodyData, body.getUserData());\n\t\t\tconst objectType = bodyData.objectType;\n\t\t\tconst objectTypeProperties = defined(this.objectTypesProperties.get(objectType));\n\t\t\t// update touch data for this body if it has touch blocks\n\t\t\tif (objectTypeProperties.hasTouchBlocks) {\n\t\t\t\tthis.updateTouches(body, bodyData);\n\t\t\t}\n\t\t\t// prepare local variable\n\t\t\tconst rulesActiveAtThisStep: Set<CandliRow> = new Set();\n\t\t\tconst wereRulesCheckedBefore = bodyData.wereRulesCheckedAtLeastOnce;\n\t\t\t// for each row...\n\t\t\tobjectType.behaviour.forEach((row, rowIndex) => {\n\t\t\t\t// ignore empty rows\n\t\t\t\tif (row.isEmpty()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// check each condition of the row...\n\t\t\t\tconst active = this.checkConditions(row, rowIndex, body, this.worldContacts);\n\t\t\t\t// ...if active, execute corresponding actions\n\t\t\t\tif (active) {\n\t\t\t\t\tlet rows = toExecute.get(body);\n\t\t\t\t\tif (rows === undefined) {\n\t\t\t\t\t\trows = [];\n\t\t\t\t\t\ttoExecute.set(body, rows);\n\t\t\t\t\t}\n\t\t\t\t\tconst isFirstExecution = !bodyData.rulesActiveAtLastStep.has(row);\n\t\t\t\t\trows.push([row, rowIndex, isFirstExecution]);\n\t\t\t\t\trulesActiveAtThisStep.add(row);\n\t\t\t\t}\n\t\t\t});\n\t\t\t// keep track of what is active\n\t\t\tbodyData.rulesActiveAtLastStep = rulesActiveAtThisStep;\n\t\t\tif (!wereRulesCheckedBefore) {\n\t\t\t\tbodyData.markRulesCheckedAtLeastOnce();\n\t\t\t}\n\t\t\t// clear cached conditions results\n\t\t\tbodyData.cachedConditionResults.clear();\n\t\t});\n\n\t\t// execute all actions for active rules\n\t\ttoExecute.forEach((rows, body) => {\n\t\t\trows.forEach(([row, rowIndex, isFirstExecution]) => {\n\t\t\t\tthis.executeActions(row, rowIndex, body, deltaT, toDeleteBodies, isFirstExecution);\n\t\t\t});\n\t\t});\n\n\t\t// TODO: optimize with a contact listener on a non-colliding fixture\n\t\t// check if any object is out of bounds\n\t\tlet bodyIterator = this.world.getBodyList();\n\t\tconst worldBoundTopLeft = this.worldBounds.topLeft;\n\t\tconst worldBoundSize = this.worldBounds.size;\n\t\tconst minX = worldBoundTopLeft.x;\n\t\tconst minY = worldBoundTopLeft.y;\n\t\tconst maxX = minX + worldBoundSize.x;\n\t\tconst maxY = minY + worldBoundSize.y;\n\t\twhile (bodyIterator !== null) {\n\t\t\t// hand-optimised to avoid conversion of position to vec2 because this is a hotspot\n\t\t\tconst pos = bodyIterator.getPosition();\n\t\t\tif (pos.x < minX || pos.x > maxX || pos.y < minY || pos.y > maxY) {\n\t\t\t\t// to be deleted, add to list\n\t\t\t\ttoDeleteBodies.add(bodyIterator);\n\t\t\t}\n\t\t\tbodyIterator = bodyIterator.getNext();\n\t\t}\n\n\t\t// garbage collect bodies to delete,\n\t\t// planck will call endContact() for each respective body\n\t\tfor (const body of toDeleteBodies) {\n\t\t\tthis.destroyObject(body);\n\t\t}\n\t}\n\n\tprivate updateTouches(body: Body, bodyData: BodyData) {\n\t\tconst newTouchedAsNew: number[] = [];\n\t\tfor (const [point, id, isNew] of this.touchingPoints) {\n\t\t\tif (\n\t\t\t\tbodyData.wasStepRunAtLeastOnce &&\n\t\t\t\t(isNew || bodyData.touchedAsNew.indexOf(id) >= 0) &&\n\t\t\t\tnonnull(body.getFixtureList()).testPoint(toVec2(point))\n\t\t\t) {\n\t\t\t\tnewTouchedAsNew.push(id);\n\t\t\t}\n\t\t}\n\t\tbodyData.touchedAsNew = newTouchedAsNew;\n\t}\n\n\tprivate checkConditions(row: CandliRow, rowIndex: number, body: Body, contacts: ContactPointsGenerator) {\n\t\tconst bodyData = cast(BodyData, body.getUserData());\n\t\t// If we were evaluated to true once, we are still true.\n\t\t// This is important as a second preSolve evaluation of the same contact might lead\n\t\t// to false due to contact being disabled by the first preSolve evaluation.\n\t\t// If we were evaluated to false once, we need to re-evaluate, as the pre-solve evaluation\n\t\t// does not receive the full contact list.\n\t\tconst cachedEvaluation = bodyData.cachedConditionResults.get(row);\n\t\tif (cachedEvaluation === true) {\n\t\t\treturn true;\n\t\t}\n\t\tconst wereRulesCheckedBefore = bodyData.wereRulesCheckedAtLeastOnce;\n\t\t// check each condition of the row\n\t\tlet active = true;\n\t\tlet value: number | undefined;\n\t\tlet conditionIndex = 0;\n\t\tfor (const condition of row.conditions) {\n\t\t\tconst block = condition.block;\n\t\t\tconst initCondition = dynamicCast(InitBlock, block);\n\t\t\tconst inputCondition = dynamicCast(InputBlock, block);\n\t\t\tconst touchCondition = dynamicCast(TouchBlock, block);\n\t\t\tconst collisionCondition = dynamicCast(CollisionBlock, block);\n\t\t\tconst timerCondition = dynamicCast(TimerBlock, block);\n\t\t\tconst comparisonCondition = dynamicCast(ComparisonBlock, block);\n\t\t\tconst animationIsCondition = dynamicCast(AnimationIsBlock, block);\n\t\t\tconst readVariableBlock = dynamicCast(ReadVariableBlock, block);\n\t\t\tconst binaryArithmeticBlock = dynamicCast(BinaryArithmeticBlock, block);\n\t\t\tconst randomValueBlock = dynamicCast(RandomValueBlock, block);\n\t\t\tconst scriptGenericBlock = dynamicCast(ScriptGenericBlock, block);\n\t\t\tconst scriptConditionBlock = dynamicCast(ScriptConditionBlock, block);\n\t\t\tconst lastValue = value;\n\t\t\tvalue = undefined;\n\n\t\t\tlet thisTest: boolean;\n\t\t\tif (inputCondition !== null) {\n\t\t\t\t// we have an active button\n\t\t\t\tconst player = this.game.twoPlayers ? inputCondition.player : 0;\n\t\t\t\tthisTest = isBitSet(this.buttonState[player], inputCondition.button);\n\t\t\t} else if (touchCondition !== null) {\n\t\t\t\t// we have a touch\n\t\t\t\tthisTest = bodyData.touchedAsNew.length !== 0;\n\t\t\t} else if (collisionCondition !== null) {\n\t\t\t\t// we have an active collision\n\t\t\t\t// FIXME: improve this by putting object in active collision state when a contact match\n\t\t\t\tthisTest = false;\n\t\t\t\tfor (const contact of contacts(body, collisionCondition.others)) {\n\t\t\t\t\tconst cp = contact.point;\n\t\t\t\t\tif (cp !== null) {\n\t\t\t\t\t\tconst colVector = cp.sub(toVector2(body.getPosition()));\n\t\t\t\t\t\tconst localColVector = colVector.rotate(-body.getAngle()).multElements(bodyData.flippingFactors);\n\t\t\t\t\t\t//const localColBin = (Math.round(localColVector.angle * 16 / Math.PI) + 32) % 32;\n\t\t\t\t\t\t//if ((collisionEvent.angularGrid & (1 << localColBin)) !== 0) {\n\t\t\t\t\t\tif (collisionCondition.collidesAtAngle(localColVector.angle)) {\n\t\t\t\t\t\t\tif (collisionCondition.animation !== null) {\n\t\t\t\t\t\t\t\tconst otherBody = contact.getOtherBody(body);\n\t\t\t\t\t\t\t\tconst otherBodyData = cast(BodyData, otherBody.getUserData());\n\t\t\t\t\t\t\t\tconst otherAnim = otherBodyData.currentAnimation();\n\t\t\t\t\t\t\t\tif (otherAnim.name === collisionCondition.animation) {\n\t\t\t\t\t\t\t\t\tthisTest = true;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthisTest = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (initCondition !== null) {\n\t\t\t\t// we have an init\n\t\t\t\tthisTest = !wereRulesCheckedBefore;\n\t\t\t} else if (timerCondition !== null) {\n\t\t\t\tconst time = this.currentTime - bodyData.startTime;\n\t\t\t\tconst timeAtEnd = time + this.currentDeltaT;\n\t\t\t\t// see whether we are active\n\t\t\t\tconst elapsed = timeAtEnd >= timerCondition.period;\n\t\t\t\tif (timerCondition.repeat) {\n\t\t\t\t\t// repeating timer, true if timer elapses within this time step\n\t\t\t\t\tconst repeating = timeAtEnd % timerCondition.period <= this.currentDeltaT;\n\t\t\t\t\tthisTest = elapsed && repeating;\n\t\t\t\t} else {\n\t\t\t\t\t// single-shot timer, true if period is elapsed\n\t\t\t\t\tthisTest = elapsed;\n\t\t\t\t}\n\t\t\t} else if (comparisonCondition !== null) {\n\t\t\t\tconst leftInput = comparisonCondition.inputSide === ComparisonInputSide.LEFT;\n\t\t\t\tconst leftLastValue = leftInput ? lastValue : undefined;\n\t\t\t\tconst rightLastValue = !leftInput ? lastValue : undefined;\n\t\t\t\tconst lhs = leftLastValue ?? this.getVariableAsNumber(comparisonCondition.address, bodyData);\n\t\t\t\tconst op = comparisonCondition.operation;\n\t\t\t\tconst rhs = rightLastValue ?? comparisonCondition.value;\n\t\t\t\tswitch (op) {\n\t\t\t\t\tcase ComparisonOperation.EQUAL:\n\t\t\t\t\t\tthisTest = lhs === rhs;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ComparisonOperation.GREATER_THAN:\n\t\t\t\t\t\tthisTest = lhs > rhs;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ComparisonOperation.LESS_THAN:\n\t\t\t\t\t\tthisTest = lhs < rhs;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ComparisonOperation.NOT_EQUAL:\n\t\t\t\t\t\tthisTest = lhs !== rhs;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ComparisonOperation.LESS_THAN_OR_EQUAL_TO:\n\t\t\t\t\t\tthisTest = lhs <= rhs;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ComparisonOperation.GREATER_THAN_OR_EQUAL_TO:\n\t\t\t\t\t\tthisTest = lhs >= rhs;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (!this.unknownVarOpExceptionFired) {\n\t\t\t\t\t\t\tassertRecoverable(false, `Unknown compare variable operation ${op}`);\n\t\t\t\t\t\t\tthis.unknownVarOpExceptionFired = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthisTest = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (animationIsCondition !== null) {\n\t\t\t\tconst currentAnimation = bodyData.animation?.index ?? 0;\n\t\t\t\tthisTest = animationIsCondition.animations.has(currentAnimation);\n\t\t\t} else if (readVariableBlock !== null) {\n\t\t\t\tvalue = this.getVariableAsNumber(readVariableBlock.address, bodyData);\n\t\t\t\tthisTest = true;\n\t\t\t} else if (binaryArithmeticBlock !== null) {\n\t\t\t\t// detect div and mod by 0, later notify user\n\t\t\t\tif (!this.isBinaryOperationValid(binaryArithmeticBlock, lastValue, bodyData)) {\n\t\t\t\t\t// unconditionally fail the condition, regardless of its inversion status\n\t\t\t\t\tthisTest = false;\n\t\t\t\t\tactive = false;\n\t\t\t\t} else {\n\t\t\t\t\tvalue = this.executeBinaryOperation(binaryArithmeticBlock, lastValue, bodyData);\n\t\t\t\t\tif (Number.isFinite(value)) {\n\t\t\t\t\t\tthisTest = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// unconditionally fail the condition, regardless of its inversion status\n\t\t\t\t\t\tthisTest = false;\n\t\t\t\t\t\tactive = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (randomValueBlock !== null) {\n\t\t\t\tvalue = this.getRandomValue(randomValueBlock, lastValue);\n\t\t\t\tthisTest = true;\n\t\t\t} else if (scriptGenericBlock !== null) {\n\t\t\t\tconst logCtx = `${bodyData.typeName}/${rowIndex}/condition/${conditionIndex}: `;\n\t\t\t\tsetScriptRuntimeData(this, body, bodyData, logCtx);\n\t\t\t\tconst output = scriptGenericBlock.run(lastValue, logCtx);\n\t\t\t\tvalue = output[0];\n\t\t\t\tthisTest = output[1];\n\t\t\t} else if (scriptConditionBlock !== null) {\n\t\t\t\tconst logCtx = `${bodyData.typeName}/${rowIndex}/condition/${conditionIndex}: `;\n\t\t\t\tsetScriptRuntimeData(this, body, bodyData, logCtx);\n\t\t\t\tconst output = scriptConditionBlock.run(lastValue, logCtx);\n\t\t\t\tvalue = output[0];\n\t\t\t\tthisTest = output[1];\n\t\t\t} else {\n\t\t\t\tif (!this.unknownConditionExceptionFired) {\n\t\t\t\t\tassertRecoverable(false, `Unknown condition ${toStr(condition)}`);\n\t\t\t\t\tthis.unknownConditionExceptionFired = true;\n\t\t\t\t}\n\t\t\t\tthisTest = false;\n\t\t\t}\n\t\t\t// chain with possibly inversion\n\t\t\tactive = active && (thisTest !== condition.inverted);\n\t\t\t// optimisation: stop testing as soon as we are not active\n\t\t\tif (!active) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconditionIndex++;\n\t\t}\n\t\tbodyData.cachedConditionResults.set(row, active);\n\t\treturn active;\n\t}\n\n\tprivate executeActions(row: CandliRow, rowIndex: number, body: Body, deltaT: number, toDeleteBodies: Set<Body>, isFirstExecution: boolean) {\n\t\tconst bodyData = cast(BodyData, body.getUserData());\n\t\tconst objectType = bodyData.objectType;\n\t\tlet value: number | undefined;\n\t\tlet actionIndex = 0;\n\t\tfor (const action of row.actions) {\n\t\t\tconst block = action.block;\n\t\t\tconst instant = block.kind === BlockKind.InstantaneousAction;\n\t\t\tif (instant && !isFirstExecution) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst speedAction = dynamicCast(SpeedBlock, block);\n\t\t\tconst angularSpeedAction = dynamicCast(AngularSpeedBlock, block);\n\t\t\tconst stopAction = dynamicCast(StopBlock, block);\n\t\t\tconst brakeAction = dynamicCast(BrakeBlock, block);\n\t\t\tconst deleteAction = dynamicCast(DeleteBlock, block);\n\t\t\tconst changeVariableAction = dynamicCast(ChangeVariableBlock, block);\n\t\t\tconst spawnAction = dynamicCast(SpawnBlock, block);\n\t\t\tconst flipAction = dynamicCast(FlipBlock, block);\n\t\t\tconst teleportAction = dynamicCast(TeleportBlock, block);\n\t\t\tconst showDialogAction = dynamicCast(ShowDialogBlock, block);\n\t\t\tconst vibrateAction = dynamicCast(VibrateBlock, block);\n\t\t\tconst musicAction = dynamicCast(MusicBlock, block);\n\t\t\tconst restartTimerAction = dynamicCast(RestartTimerBlock, block);\n\t\t\tconst soundAction = dynamicCast(SoundBlock, block);\n\t\t\tconst animationAction = dynamicCast(PlayAnimationBlock, block);\n\t\t\tconst scriptActionBlock = dynamicCast(ScriptActionBlock, block);\n\t\t\tconst readVariableBlock = dynamicCast(ReadVariableBlock, block);\n\t\t\tconst binaryArithmeticBlock = dynamicCast(BinaryArithmeticBlock, block);\n\t\t\tconst randomValueBlock = dynamicCast(RandomValueBlock, block);\n\t\t\tconst scriptGenericBlock = dynamicCast(ScriptGenericBlock, block);\n\t\t\tconst lastValue = value;\n\t\t\tvalue = undefined;\n\n\t\t\tif (speedAction !== null) {\n\t\t\t\tconst factor = lastValue ?? 1.0;\n\t\t\t\tlet rotatedVec = speedAction.vector.negateY.multScalar(factor);\n\t\t\t\tif (speedAction.relative) {\n\t\t\t\t\trotatedVec = rotatedVec.multElements(bodyData.flippingFactors);\n\t\t\t\t\trotatedVec = rotatedVec.rotate(body.getAngle());\n\t\t\t\t\tif (!speedAction.compatFixedMagnitude) {\n\t\t\t\t\t\tconst scaleFactor = nonnull(body.getFixtureList()).getUserData() as number;\n\t\t\t\t\t\trotatedVec = rotatedVec.multScalar(scaleFactor);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst vec = toVec2(rotatedVec);\n\t\t\t\t// Note: application of once or continuously is solved by the kind getter above.\n\t\t\t\tif (body.getType() === 'dynamic' && objectType.isCollidable) {\n\t\t\t\t\tif (speedAction.mode === SpeedBlockMode.Velocity) {\n\t\t\t\t\t\tbody.applyLinearImpulse(vec.mul(body.getMass()), body.getWorldCenter(), true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody.applyForce(vec.mul(body.getMass()), body.getWorldCenter(), true);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (speedAction.mode === SpeedBlockMode.Velocity) {\n\t\t\t\t\t\tbody.setLinearVelocity(vec.add(body.getLinearVelocity()));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody.setLinearVelocity(vec.mul(deltaT).add(body.getLinearVelocity()));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (angularSpeedAction !== null) {\n\t\t\t\tconst factor = lastValue ?? 1.0;\n\t\t\t\tconst v = angularSpeedAction.amount * factor;\n\t\t\t\t// Note: application of once or continuously is solved by the kind getter above.\n\t\t\t\tif (body.getType() === 'dynamic' && objectType.isCollidable) {\n\t\t\t\t\tif (angularSpeedAction.mode === AngularSpeedBlockMode.AngularVelocity) {\n\t\t\t\t\t\tbody.applyAngularImpulse(v * body.getInertia(), true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody.applyTorque(v * body.getInertia(), true);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (angularSpeedAction.mode === AngularSpeedBlockMode.AngularVelocity) {\n\t\t\t\t\t\tbody.setAngularVelocity(body.getAngularVelocity() + v);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody.setAngularVelocity(body.getAngularVelocity() + v * deltaT);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (stopAction !== null) {\n\t\t\t\tbody.setLinearVelocity(Vec2.zero());\n\t\t\t\tbody.setAngularVelocity(0);\n\t\t\t} else if (brakeAction !== null) {\n\t\t\t\tconst brakeFactor = -brakeAction.intensity;\n\t\t\t\tif (body.getType() === 'dynamic' && objectType.isCollidable) {\n\t\t\t\t\tbody.applyForce(body.getLinearVelocity().clone().mul(brakeFactor * body.getMass()), body.getWorldCenter(), true);\n\t\t\t\t\tif (objectType.canRotate) {\n\t\t\t\t\t\tbody.applyTorque(body.getAngularVelocity() * brakeFactor * body.getInertia(), true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// TODO: Think how we can do braking equivalent for non-physical objects.\n\t\t\t} else \tif (deleteAction !== null) {\n\t\t\t\ttoDeleteBodies.add(body);\n\t\t\t} else if (changeVariableAction !== null) {\n\t\t\t\tconst op = changeVariableAction.operation;\n\t\t\t\tconst v = lastValue ?? changeVariableAction.value;\n\t\t\t\tconst address = changeVariableAction.address;\n\t\t\t\tswitch (op) {\n\t\t\t\t\tcase ChangeVariableOperation.SET:\n\t\t\t\t\t\tthis.setVariable(address, v, bodyData);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChangeVariableOperation.ADD:\n\t\t\t\t\t\tthis.setVariable(address, this.getVariableAsNumber(address, bodyData) + v, bodyData);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (!this.unknownVarOpExceptionFired) {\n\t\t\t\t\t\t\tassertRecoverable(false, `Unknown change variable operation ${op}`);\n\t\t\t\t\t\t\tthis.unknownVarOpExceptionFired = true;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (spawnAction !== null) {\n\t\t\t\tconst thatObjectType = spawnAction.objectType;\n\t\t\t\tif (thatObjectType !== null) {\n\t\t\t\t\tconst scaleFactor = nonnull(body.getFixtureList()).getUserData() as number;\n\t\t\t\t\tconst thisAngle = body.getAngle();\n\t\t\t\t\tlet pos = toVector2(body.getPosition());\n\t\t\t\t\tlet velocity = toVector2(body.getLinearVelocity());\n\t\t\t\t\tif (spawnAction.angle !== null) {\n\t\t\t\t\t\t// we need to add this because Planck keeps polygons apart at a distance of 2 skinRadius\n\t\t\t\t\t\tconst skinRadius = PlanckSettings.polygonRadius;\n\t\t\t\t\t\tconst spawnDist = collisionDistance(\n\t\t\t\t\t\t\tobjectType.polygonShape, thatObjectType.polygonShape,\n\t\t\t\t\t\t\tspawnAction.angle, scaleFactor,\n\t\t\t\t\t\t\tnew ScalingRotation(spawnAction.scale, spawnAction.orientation)\n\t\t\t\t\t\t) + 3 * skinRadius;\n\t\t\t\t\t\tconst spawnDir = Vector2.fromAngleAndLength(spawnAction.angle, spawnDist);\n\t\t\t\t\t\tconst spawnVector = spawnDir.multElements(bodyData.flippingFactors).rotate(thisAngle);\n\t\t\t\t\t\tconst velocityFactor = spawnAction.compatFixedChildVelocity ? 1 : scaleFactor;\n\t\t\t\t\t\tconst spawnedVelocity = Vector2.fromAngleAndLength(spawnVector.angle, spawnAction.speed * velocityFactor);\n\t\t\t\t\t\tpos = pos.add(spawnVector);\n\t\t\t\t\t\tvelocity = velocity.add(spawnedVelocity);\n\t\t\t\t\t\tconst rotVelocity = spawnVector.perp.multScalar(body.getAngularVelocity());\n\t\t\t\t\t\tvelocity = velocity.add(rotVelocity);\n\t\t\t\t\t}\n\t\t\t\t\tconst childOrientationFlip = bodyData.flippingFactors.x * bodyData.flippingFactors.y;\n\t\t\t\t\tconst childOrientation = normalizeAngle(thisAngle + spawnAction.orientation * childOrientationFlip);\n\t\t\t\t\tconst childScale = scaleFactor * spawnAction.scale;\n\t\t\t\t\tconst pose = new SimilarityTransform(pos, childOrientation, childScale);\n\t\t\t\t\tthis.createObject(thatObjectType, pose, undefined, velocity, bodyData.flipX, bodyData.flipY);\n\t\t\t\t}\n\t\t\t} else if (flipAction !== null) {\n\t\t\t\t// get absolute flip values\n\t\t\t\tconst [flipX, flipY] = flipAction.getAbsoluteFlip(bodyData.flipX, bodyData.flipY);\n\t\t\t\t// if there is a change,\n\t\t\t\tif (flipX !== bodyData.flipX || flipY !== bodyData.flipY) {\n\t\t\t\t\t// first destroy old fixture...\n\t\t\t\t\tconst fixture = nonnull(body.getFixtureList());\n\t\t\t\t\tconst scale = fixture.getUserData() as number;\n\t\t\t\t\tthis.destroyFixtures(body, fixture);\n\t\t\t\t\t// ...and then create new fixture and save new flip values\n\t\t\t\t\tthis.addFixtures(body, objectType, scale, flipX, flipY);\n\t\t\t\t\tbody.setAwake(true);\n\t\t\t\t\tbodyData.flipX = flipX;\n\t\t\t\t\tbodyData.flipY = flipY;\n\t\t\t\t}\n\t\t\t} else if (teleportAction !== null) {\n\t\t\t\tlet beacon: Body | null = null;\n\t\t\t\tconst useBeacon = teleportAction.beacon !== null;\n\t\t\t\tif (useBeacon) {\n\t\t\t\t\t// we have a beacon wrt teleport\n\t\t\t\t\tif (teleportAction.beacon === objectType) {\n\t\t\t\t\t\t// the beacon is ourself\n\t\t\t\t\t\tbeacon = body;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// the beacon is another type, search for it, if not found, do nothing\n\t\t\t\t\t\tlet closestDist2 = Number.MAX_VALUE;\n\t\t\t\t\t\tfor (let that = this.world.getBodyList(); that; that = that.getNext()) {\n\t\t\t\t\t\t\tconst thatData = cast(BodyData, that.getUserData());\n\t\t\t\t\t\t\tif (thatData.objectType === teleportAction.beacon) {\n\t\t\t\t\t\t\t\t// correct, type, look at distance\n\t\t\t\t\t\t\t\tconst dist2 = that.getPosition().clone().sub(body.getPosition()).lengthSquared();\n\t\t\t\t\t\t\t\tif (beacon === null || dist2 < closestDist2) {\n\t\t\t\t\t\t\t\t\tbeacon = that;\n\t\t\t\t\t\t\t\t\tclosestDist2 = dist2;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If we have to use beacon but it is not found, do nothing.\n\t\t\t\tif (!useBeacon || beacon !== null) {\n\t\t\t\t\tlet transform = teleportAction.transform.clone();\n\t\t\t\t\tif (lastValue !== undefined) {\n\t\t\t\t\t\t// change the \"magnitude\" of the transform by the input value\n\t\t\t\t\t\ttransform.translationX *= lastValue;\n\t\t\t\t\t\ttransform.translationY *= lastValue;\n\t\t\t\t\t\ttransform.rotationAngle = normalizeAngleAround0(transform.rotationAngle) * lastValue;\n\t\t\t\t\t\ttransform.scaleFactor *= lastValue;\n\t\t\t\t\t}\n\t\t\t\t\tif (beacon !== null) {\n\t\t\t\t\t\ttransform = getBodyTransform(beacon).after(transform);\n\t\t\t\t\t}\n\t\t\t\t\tif (teleportAction.moveCamera) {\n\t\t\t\t\t\tif (teleportAction.doTranslation) {\n\t\t\t\t\t\t\tthis.teleportCameraTo(transform.translation);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (teleportAction.doScaling) {\n\t\t\t\t\t\t\tconst extentRatio = this.cameraExtent.aspectRatio;\n\t\t\t\t\t\t\tthis.cameraExtent = new Vector2(transform.scaleFactor, transform.scaleFactor / extentRatio);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (teleportAction.doTranslation) {\n\t\t\t\t\t\t\tif (this.targetCamera === body) {\n\t\t\t\t\t\t\t\tconst deltaPos = transform.translation.clone().sub(toVector2(body.getPosition()));\n\t\t\t\t\t\t\t\tthis.currentCamera = this.currentCamera.add(deltaPos);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbody.setPosition(toVec2(transform.translation));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (teleportAction.doRotation) {\n\t\t\t\t\t\t\tbody.setAngle(transform.rotationAngle);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (teleportAction.doScaling) {\n\t\t\t\t\t\t\t// did scale change?\n\t\t\t\t\t\t\tconst fixture = nonnull(body.getFixtureList());\n\t\t\t\t\t\t\tconst scale = fixture.getUserData() as number;\n\t\t\t\t\t\t\tif (transform.scaleFactor !== scale) {\n\t\t\t\t\t\t\t\t// new scale, first destroy old fixtures...\n\t\t\t\t\t\t\t\tthis.destroyFixtures(body, fixture);\n\t\t\t\t\t\t\t\t// ...and then create new fixtures\n\t\t\t\t\t\t\t\tthis.addFixtures(body, objectType, transform.scaleFactor, bodyData.flipX, bodyData.flipY);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbody.setAwake(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (showDialogAction !== null) {\n\t\t\t\tthis.dialogCallback(showDialogAction.endGame, showDialogAction.screen);\n\t\t\t} else if (vibrateAction !== null) {\n\t\t\t\tif (navigator.vibrate) {\n\t\t\t\t\tnavigator.vibrate(400);\n\t\t\t\t}\n\t\t\t} else if (musicAction !== null) {\n\t\t\t\tgetMusic().setAtmosphere(musicAction.atmosphere, musicAction.timeConstant, musicAction.gains);\n\t\t\t} else if (restartTimerAction !== null) {\n\t\t\t\tbodyData.startTime = this.currentTime;\n\t\t\t} else if (soundAction !== null) {\n\t\t\t\tif (soundAction.index !== null) {\n\t\t\t\t\tconst relativePos = toVector2(body.getPosition())\n\t\t\t\t\t\t.sub(this.trackedCameraPos())\n\t\t\t\t\t\t.multScalar(2 / this.cameraExtent.x);\n\t\t\t\t\tconst fadingFactors = Vector2.ones().sub(\n\t\t\t\t\t\trelativePos\n\t\t\t\t\t\t\t.abs()\n\t\t\t\t\t\t\t.addXY(-1, -0.75) // we assume that most likely the game will be played in landscape mode\n\t\t\t\t\t\t\t.max(Vector2.zeros())\n\t\t\t\t\t\t\t.multScalar(0.5)\n\t\t\t\t\t).max(Vector2.zeros());\n\t\t\t\t\tif (fadingFactors.x > 0 && fadingFactors.y > 0) {\n\t\t\t\t\t\tconst sound = defined(this.game.sounds[soundAction.index]);\n\t\t\t\t\t\tconst gain = soundAction.gain * fadingFactors.x * fadingFactors.y;\n\t\t\t\t\t\tconst pan = relativePos.x * 0.5;\n\t\t\t\t\t\tgetSoundSystem().playSound(sound, gain, pan);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (animationAction !== null) {\n\t\t\t\tif (animationAction.index !== null &&\n\t\t\t\t\t(objectType.animations[animationAction.index]?.frames?.length ?? 0 > 0)\n\t\t\t\t) {\n\t\t\t\t\tbodyData.animation = new AnimationData(this.currentTime, animationAction);\n\t\t\t\t}\n\t\t\t} else if (scriptActionBlock !== null) {\n\t\t\t\tconst logCtx = `${bodyData.typeName}/${rowIndex}/action/${actionIndex}: `;\n\t\t\t\tsetScriptRuntimeData(this, body, bodyData, logCtx);\n\t\t\t\tconst output = scriptActionBlock.run(lastValue, logCtx);\n\t\t\t\t// stop execution of actions for this row if execution failed\n\t\t\t\tif (!output[1]) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvalue = output[0];\n\t\t\t} else if (readVariableBlock !== null) {\n\t\t\t\tvalue = this.getVariableAsNumber(readVariableBlock.address, bodyData);\n\t\t\t} else if (binaryArithmeticBlock !== null) {\n\t\t\t\t// detect div and mod by 0, later notify user\n\t\t\t\tif (!this.isBinaryOperationValid(binaryArithmeticBlock, lastValue, bodyData)) {\n\t\t\t\t\t// stop execution of actions for this row\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tvalue = this.executeBinaryOperation(binaryArithmeticBlock, lastValue, bodyData);\n\t\t\t\t\t// stop execution of actions for this row\n\t\t\t\t\tif (!Number.isFinite(value)) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (randomValueBlock !== null) {\n\t\t\t\tvalue = this.getRandomValue(randomValueBlock, lastValue);\n\t\t\t} else if (scriptGenericBlock !== null) {\n\t\t\t\tconst logCtx = `${bodyData.typeName}/${rowIndex}/action/${actionIndex}: `;\n\t\t\t\tsetScriptRuntimeData(this, body, bodyData, logCtx)\n\t\t\t\tconst output = scriptGenericBlock.run(lastValue, logCtx);\n\t\t\t\t// stop execution of actions for this row if execution failed\n\t\t\t\tif (!output[1]) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvalue = output[0];\n\t\t\t} else {\n\t\t\t\tif (!this.unknownActionExceptionFired) {\n\t\t\t\t\tassertRecoverable(false, `Unknown action ${toStr(action)}`);\n\t\t\t\t\tthis.unknownActionExceptionFired = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tactionIndex++;\n\t\t}\n\t}\n\n\tprivate teleportCameraTo(target: Vector2 | Body) {\n\t\tconst curTrackedCameraPos = this.trackedCameraPos();\n\t\tthis.targetCamera = target;\n\t\tconst targetPosition = target instanceof Vector2 ? target : toVector2(target.getPosition());\n\t\tconst deltaTrackedCameraPos = targetPosition.sub(curTrackedCameraPos);\n\t\tthis.currentCamera = this.currentCamera.add(deltaTrackedCameraPos);\n\t}\n\n\tprivate variableNameToIndex(name: string) {\n\t\tif (name === 'score') {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tconst nameIndex = this.game.variableNameIndex(name);\n\t\t\tif (nameIndex === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn nameIndex + 1;\n\t\t}\n\t}\n\n\tprivate getGameVariableByIndex(index: number) {\n\t\treturn this.gameVariables.get(index) ?? null;\n\t}\n\n\tgetGameVariableByName(name: string) {\n\t\tconst index = this.variableNameToIndex(name);\n\t\tif (index === null) {\n\t\t\tconsole.warn(`Trying to get unknown game variable ${name}.`);\n\t\t\treturn 0;\n\t\t}\n\t\treturn this.getGameVariableByIndex(index);\n\t}\n\n\tprivate getObjectTypeVariableByIndex(bodyData: BodyData, index: number) {\n\t\tconst objectTypeProperties = defined(this.objectTypesProperties.get(bodyData.objectType));\n\t\treturn objectTypeProperties.variables.get(index) ?? null;\n\t}\n\n\tgetObjectTypeVariableByName(name: string, bodyData: BodyData) {\n\t\tconst index = this.variableNameToIndex(name);\n\t\tif (index === null) {\n\t\t\tconst nameOrIndex = bodyData.typeName;\n\t\t\tconsole.warn(`Trying to get unknown variable ${name} in object type ${nameOrIndex}.`);\n\t\t\treturn 0;\n\t\t}\n\t\treturn this.getObjectTypeVariableByIndex(bodyData, index);\n\t}\n\n\tprivate getObjectInstanceVariableByIndex(bodyData: BodyData, index: number) {\n\t\treturn bodyData.variables.get(index) ?? null;\n\t}\n\n\tgetObjectInstanceVariableByName(name: string, bodyData: BodyData) {\n\t\tconst index = this.variableNameToIndex(name);\n\t\tif (index === null) {\n\t\t\tconst nameOrIndex = bodyData.typeName;\n\t\t\tconst instanceId = uniqueId(bodyData);\n\t\t\tconsole.warn(`Trying to get unknown variable ${name} in instance ${instanceId} of object type ${nameOrIndex}.`);\n\t\t\treturn 0;\n\t\t}\n\t\treturn this.getObjectInstanceVariableByIndex(bodyData, index);\n\t}\n\n\tgetVariableByScopeAndIndex(scope: VariableScope, index: number, bodyData: BodyData) {\n\t\tswitch (scope) {\n\t\t\tcase VariableScope.Game:\n\t\t\t\treturn this.getGameVariableByIndex(index);\n\t\t\tcase VariableScope.ObjectType:\n\t\t\t\treturn this.getObjectTypeVariableByIndex(bodyData, index);\n\t\t\tcase VariableScope.ObjectInstance:\n\t\t\t\treturn this.getObjectInstanceVariableByIndex(bodyData, index);\n\t\t\tdefault:\n\t\t\t\tif (!this.unknownScopeExceptionFired) {\n\t\t\t\t\tassertRecoverable(false, `Unknown variable scope ${scope}`);\n\t\t\t\t\tthis.unknownScopeExceptionFired = true;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate getVariable(address: number, bodyData: BodyData) {\n\t\tconst scope = variableScope(address);\n\t\tconst index = variableIndex(address);\n\t\treturn this.getVariableByScopeAndIndex(scope, index, bodyData);\n\t}\n\n\tprivate getVariableAsNumber(address: number, bodyData: BodyData) {\n\t\tconst value = this.getVariable(address, bodyData);\n\t\tif (value === null) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (typeof value !== 'number') {\n\t\t\tconsole.warn(`Trying to use script variable at ${address} as a number.`);\n\t\t\treturn 0;\n\t\t}\n\t\treturn value;\n\t}\n\n\tprivate checkVariableValidityForIndex(index: number, value: VariableValue) {\n\t\tconst type = this.game.variables[index - 1]?.name.type ?? null;\n\t\tif (type === null) {\n\t\t\tif (typeof value  === 'number') {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!this.invalidVarWriteExceptionFired) {\n\t\t\t\tassertRecoverable(false, `Trying to write script value to game variable ${index} that is number.`);\n\t\t\t\tthis.invalidVarWriteExceptionFired = true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (value instanceof ScriptValue) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!this.invalidVarWriteExceptionFired) {\n\t\t\t\tconst typeName = this.game.scriptCtx.type_name(type);\n\t\t\t\tassertRecoverable(false, `Trying to write number to script game variable ${index} that has type ${typeName}.`);\n\t\t\t\tthis.invalidVarWriteExceptionFired = true;\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\tprivate setGameVariableByIndex(index: number, value: VariableValue) {\n\t\tthis.gameVariablesChanged = true;\n\t\tthis.gameVariables.set(index, value);\n\t}\n\n\tprivate setObjectTypeVariableByIndex(bodyData: BodyData, index: number, value: VariableValue) {\n\t\tconst objectTypeProperties = defined(this.objectTypesProperties.get(bodyData.objectType));\n\t\tobjectTypeProperties.variables.set(index, value);\n\t}\n\n\tprivate setObjectInstanceVariableByIndex(bodyData: BodyData, index: number, value: VariableValue) {\n\t\tbodyData.variables.set(index, value);\n\t}\n\n\tsetVariableByScopeAndIndex(scope: VariableScope, index: number, value: VariableValue, bodyData: BodyData) {\n\t\tif (!this.checkVariableValidityForIndex(index, value)) {\n\t\t\treturn;\n\t\t}\n\t\tswitch (scope) {\n\t\t\tcase VariableScope.Game:\n\t\t\t\tthis.setGameVariableByIndex(index, value);\n\t\t\t\tbreak;\n\t\t\tcase VariableScope.ObjectType:\n\t\t\t\tthis.setObjectTypeVariableByIndex(bodyData, index, value);\n\t\t\t\tbreak;\n\t\t\tcase VariableScope.ObjectInstance:\n\t\t\t\tthis.setObjectInstanceVariableByIndex(bodyData, index, value);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (!this.unknownScopeExceptionFired) {\n\t\t\t\t\tassertRecoverable(false, `Unknown variable scope ${scope}`);\n\t\t\t\t\tthis.unknownScopeExceptionFired = true;\n\t\t\t\t}\n\t\t}\n\t}\n\n\tprivate setVariable(address: number, value: number, bodyData: BodyData) {\n\t\tconst scope = variableScope(address);\n\t\tconst index = variableIndex(address);\n\t\tthis.setVariableByScopeAndIndex(scope, index, value, bodyData);\n\t}\n\n\taddCanvasRenderAction(bodyData: BodyData, action: CanvasRenderAction) {\n\t\tconst actions = this.canvasRenderActions.get(bodyData) ?? [];\n\t\tactions.push(action);\n\t\tthis.canvasRenderActions.set(bodyData, actions);\n\t}\n\n\tattachCamera(body: Body) {\n\t\tthis.teleportCameraTo(body);\n\t}\n\n\tstartTextInput(initial: string, initiator: Body) {\n\t\tthis.textInput.text = initial;\n\t\tthis.textInput.initiator = initiator;\n\t\tthis.textInput.active = true;\n\t}\n\n\tstopTextInput() {\n\t\tthis.textInput.active = false;\n\t\tthis.textInput.initiator = null;\n\t}\n\n\ttextInputActive() {\n\t\treturn this.textInput.active;\n\t}\n\n\ttextInputContent() {\n\t\treturn this.textInput.text;\n\t}\n\n\ttextInputInitiator() {\n\t\tconst initiator = this.textInput.initiator;\n\t\tif (initiator === null) {\n\t\t\treturn null;\n\t\t}\n\t\tconst bodyData = cast(BodyData, initiator.getUserData());\n\t\treturn {\n\t\t\tpos: toVector2(initiator.getPosition()),\n\t\t\tangle: initiator.getAngle(),\n\t\t\tscale: nonnull(initiator.getFixtureList()).getUserData() as number,\n\t\t\tbodyData,\n\t\t} as const;\n\t}\n\n\tprivate getBinaryInputValue(input: BinaryArithmeticInput, addressOrValue: number, value: number | undefined, bodyData: BodyData) {\n\t\tswitch (input) {\n\t\t\tcase BinaryArithmeticInput.INPUT: return value ?? 0;\n\t\t\tcase BinaryArithmeticInput.VARIABLE: return this.getVariableAsNumber(addressOrValue, bodyData);\n\t\t\tcase BinaryArithmeticInput.LITERAL: return addressOrValue;\n\t\t}\n\t}\n\n\tprivate isBinaryOperationValid(block: BinaryArithmeticBlock, value: number | undefined, bodyData: BodyData) {\n\t\tconst lhs = this.getBinaryInputValue(block.lInput, block.lAddressOrValue, value, bodyData);\n\t\tconst rhs = this.getBinaryInputValue(block.rInput, block.rAddressOrValue, value, bodyData);\n\t\treturn isBinaryOperationValid(block.op, lhs, rhs);\n\t}\n\n\tprivate executeBinaryOperation(block: BinaryArithmeticBlock, value: number | undefined, bodyData: BodyData) {\n\t\tconst lhs = this.getBinaryInputValue(block.lInput, block.lAddressOrValue, value, bodyData);\n\t\tconst rhs = this.getBinaryInputValue(block.rInput, block.rAddressOrValue, value, bodyData);\n\t\treturn executeBinaryOperation(block.op, lhs, rhs);\n\t}\n\n\tprivate getRandomValue(block: RandomValueBlock, prevValue: number | undefined) {\n\t\tif (prevValue !== undefined) {\n\t\t\tif (block.inputToMin) {\n\t\t\t\tconst min = Math.min(block.max, prevValue);\n\t\t\t\treturn randIntInclusiveRange(min, block.max);\n\t\t\t} else {\n\t\t\t\tconst max = Math.max(block.min, prevValue);\n\t\t\t\treturn randIntInclusiveRange(block.min, max);\n\t\t\t}\n\t\t} else {\n\t\t\treturn randIntInclusiveRange(block.min, block.max);\n\t\t}\n\t}\n\n\tprivate addFixtures(body: Body, objectType: ObjectType, scaleFactor: number, flippedX: boolean, flippedY: boolean, otProperties?: ObjectTypeProperties) {\n\t\tconst objectTypeProperties = otProperties ?? defined(this.objectTypesProperties.get(objectType));\n\t\tif (objectTypeProperties.displayBoxHalfSize !== null) {\n\t\t\t// display-only fixture to detect when to show the object\n\t\t\tconst displayFixtureDef = {\n\t\t\t\tshape: Box(objectTypeProperties.displayBoxHalfSize.x * scaleFactor, objectTypeProperties.displayBoxHalfSize.y * scaleFactor),\n\t\t\t\tisSensor: true,\n\t\t\t\tfilterMaskBits: 0,\n\t\t\t}\n\t\t\tbody.createFixture(displayFixtureDef);\n\t\t}\n\t\tbody.createFixture(createFixtureDef(objectType, scaleFactor, flippedX, flippedY, objectTypeProperties.hasCollisionWithSomeone));\n\t}\n\n\tprivate destroyFixtures(body: Body, fixture: Fixture | null) {\n\t\twhile (fixture) {\n\t\t\tbody.destroyFixture(fixture);\n\t\t\tfixture = fixture.getNext();\n\t\t}\n\t}\n\n\tprivate *listWorldContacts(body: Body, others: Set<ObjectType>) {\n\t\tconst thatSet = this.contactMaps.get(body);\n\t\tif (thatSet !== undefined) {\n\t\t\tfor (const [thatBody, contact] of thatSet) {\n\t\t\t\tconst thatBodyData = cast(BodyData, thatBody.getUserData());\n\t\t\t\tif (others.has(thatBodyData.objectType)) {\n\t\t\t\t\tyield contact;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate *listSingleContact(thatObjectType: ObjectType, contact: Contact, _body: Body, others: Set<ObjectType>) {\n\t\tif (others.has(thatObjectType)) {\n\t\t\tyield new ContactPoint(contact);\n\t\t}\n\t}\n\n\tprivate isCameraBodyCentered(targetCamera: Vector2 | Body) : targetCamera is Body {\n\t\treturn targetCamera instanceof Body;\n\t}\n\n\tprivate trackedCameraPos() {\n\t\treturn this.isCameraBodyCentered(this.targetCamera) ? toVector2(this.targetCamera.getPosition()) : this.targetCamera;\n\t}\n\n\tprivate updateCameraPosition(deltaT: number) {\n\t\t// parameters\n\t\tconst lookAheadTime = 0.3; // duration to consider for computing look ahead position\n\t\tconst lookAheadMaxExtentRatio = 0.35; // maximum distance lookahead position can be wrt extent\n\t\tconst corrPropFactor = 10; // 3.5; // ratio of error that would be applied as a correction of 1 second\n\t\tconst maxErrorExtentRatio = 0.4; // maximum error between the actual camera pos and what it should be\n\t\tconst cameraAccBound = 3; // maximum acceleration of the camera (in unit/s²)\n\t\t// compute look ahead and clamp it\n\t\tconst extent = this.cameraExtent;\n\t\tconst extentDist = extent.norm();\n\t\tconst freeMotionBoxFractions = this.game.level.camera.freeMotionBoxFractions;\n\t\tconst lookAheadDir = this.targetCamera instanceof Body ? toVector2(this.targetCamera.getLinearVelocity()) : new Vector2();\n\t\tconst lookAheadDelta = lookAheadDir.multScalar(lookAheadTime);\n\t\tconst lookAheadDist = lookAheadDelta.norm();\n\t\tconst lookAheadMaxDist = extentDist * lookAheadMaxExtentRatio;\n\t\tconst lookAheadClamped = lookAheadDist > lookAheadMaxDist ? lookAheadDelta.multScalar(lookAheadMaxDist / lookAheadDist) : lookAheadDelta;\n\t\t// compute target position and correction\n\t\tconst trackedPos = this.trackedCameraPos();\n\t\tconst trackedPoseWithLookAhead = trackedPos.add(lookAheadClamped);\n\t\t// consider free motion box\n\t\tconst freeMotionBoxTopRightCorner = freeMotionBoxFractions.multElements(extent).multScalar(1 / 2);\n\t\tconst useFreeMotionBox = this.isCameraBodyCentered(this.targetCamera) && this.targetCameraPos !== null;\n\t\tif (useFreeMotionBox && this.targetCameraPos !== null) { // duplicate !== null condition for the compiler\n\t\t\tconst relativeTrackedPoseWithLookAhead = trackedPoseWithLookAhead.sub(this.targetCameraPos);\n\t\t\tconst requiredCameraShift = relativeTrackedPoseWithLookAhead.sub(projectIntoRect(relativeTrackedPoseWithLookAhead, freeMotionBoxTopRightCorner));\n\t\t\tthis.targetCameraPos = this.targetCameraPos.add(requiredCameraShift);\n\t\t} else {\n\t\t\tthis.targetCameraPos = trackedPoseWithLookAhead;\n\t\t}\n\t\t// is target reached?\n\t\tconst diff = this.targetCameraPos.sub(this.currentCamera);\n\t\tconst dist = diff.norm2();\n\t\tif (dist < this.cameraExtent.x / 4320) {\n\t\t\t// less then a pixel error in 8k, we already reached destination\n\t\t\treturn;\n\t\t}\n\t\tif (deltaT === 0) {\n\t\t\t// initialization, position at target position with velocity corresponding to the object's one\n\t\t\tthis.currentCamera = this.targetCameraPos.clone();\n\t\t\tthis.cameraVelocityOld = lookAheadDir;\n\t\t\treturn;\n\t\t}\n\t\t// make sure that we do not overshoot destination\n\t\tconst corrDist = Math.min(corrPropFactor * deltaT, 1.0) * dist;\n\t\tconst cameraDelta = diff.multScalar(corrDist / dist);\n\t\t// compute velocity and clamp its acceleration\n\t\tconst cameraVelocity = cameraDelta.multScalar(1 / deltaT);\n\t\tconst cameraAcc = cameraVelocity.sub(this.cameraVelocityOld);\n\t\tconst cameraAccClamped = cameraAcc.max(new Vector2(-cameraAccBound, -cameraAccBound)).min(new Vector2(cameraAccBound, cameraAccBound));\n\t\tconst cameraVelocityClamped = this.cameraVelocityOld.add(cameraAccClamped);\n\t\tthis.currentCamera = this.currentCamera.add(cameraVelocityClamped.multScalar(deltaT));\n\t\t// if distance is too large to object, hard bound it\n\t\tconst cameraToObject = trackedPos.sub(this.currentCamera);\n\t\tconst cameraToObjectDist = cameraToObject.norm();\n\t\tif (cameraToObjectDist > 0) {\n\t\t\tconst cameraToObjectMaxDist = extentDist * maxErrorExtentRatio +\n\t\t\t\t(useFreeMotionBox ? rectangleCenterRayIntersectionLength(cameraToObject, freeMotionBoxTopRightCorner): 0);\n\t\t\tif (cameraToObjectDist > cameraToObjectMaxDist) {\n\t\t\t\tconst distRatio = cameraToObjectMaxDist / cameraToObjectDist;\n\t\t\t\tthis.currentCamera = trackedPos.sub(cameraToObject.multScalar(distRatio));\n\t\t\t}\n\t\t}\n\n\t\tthis.cameraVelocityOld = cameraVelocityClamped;\n\t}\n\n\tprivate updateAnimations() {\n\t\tfor (const body of this.animatedBodies) {\n\t\t\tconst bodyData = cast(BodyData, body.getUserData());\n\t\t\tbodyData.animate(this.currentTime);\n\t\t}\n\t}\n\n\tcreateObject(objectType: ObjectType, pose: SimilarityTransform, initialVariables?: Map<number, number>, initialVelocity: Vector2 = Vector2.zeros(), flipX = false, flipY = false) {\n\t\t// do we have too much instances of this type?\n\t\tconst objectTypeProperties = defined(this.objectTypesProperties.get(objectType));\n\t\tif (objectTypeProperties.instanceCount >= objectTypeProperties.levelInstanceCount + MaxSpawnedInstanceCount) {\n\t\t\t//console.warn('Maximum number of instances reached for object type', objectType.id);\n\t\t\t// TODO: in debug bug, show error\n\t\t\treturn null;\n\t\t}\n\t\t// helper constants and lambdas\n\t\tconst hasInitialVelocity = initialVelocity.x !== 0 || initialVelocity.y !== 0;\n\t\tconst hasMovement = () => {\n\t\t\tif (hasInitialVelocity) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn objectTypeProperties.hasSpeedBlocks;\n\t\t\t}\n\t\t};\n\t\tconst physicsType = (() => {\n\t\t\tswitch (objectType.kind) {\n\t\t\t\tcase ObjectType.Kind.Background:\n\t\t\t\tcase ObjectType.Kind.Foreground:\n\t\t\t\t\treturn objectTypeProperties.collideWithNonObject ?\n\t\t\t\t\t\t('dynamic') :\n\t\t\t\t\t\t(hasMovement() ? 'kinematic' : 'static')\n\t\t\t\t\t;\n\t\t\t\tcase ObjectType.Kind.Kinematic:\n\t\t\t\t\treturn hasMovement() ? 'kinematic' : 'static';\n\t\t\t\tcase ObjectType.Kind.Dynamic:\n\t\t\t\t\treturn 'dynamic';\n\t\t\t}\n\t\t})();\n\t\tconst gravityScale = (() => {\n\t\t\tif (!objectType.isCollidable && physicsType === 'dynamic') {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn 1;\n\t\t})();\n\t\t//console.log('Creating object of physics type', objectType.physics, physicsType, hasMovement(), collideWithNonObject(), objectType.id);\n\t\t// build a definition of the body given the editor type\n\t\tconst worldDamping = this.game.level.airFriction;\n\t\tconst typeName = objectType.name ?? this.game.objects.indexOf(objectType).toString();\n\t\tconst bodyData = new BodyData(objectType, typeName, this.currentTime, this.maxZ++, flipX, flipY);\n\t\tif (initialVariables !== undefined) {\n\t\t\tbodyData.variables = new Map(initialVariables);\n\t\t}\n\t\tconst bodyDef: BodyDef = {\n\t\t\tposition: toVec2(pose.translation),\n\t\t\tangle: pose.rotationAngle,\n\t\t\ttype: physicsType,\n\t\t\tfixedRotation: !objectType.canRotate,\n\t\t\tallowSleep: true,\n\t\t\tawake: true,\n\t\t\tgravityScale,\n\t\t\tlinearDamping: objectType.isDynamic ? worldDamping * LinearDampingFactor : 0,\n\t\t\tangularDamping: objectType.isDynamic ? worldDamping * AngularDampingFactor : 0,\n\t\t\tlinearVelocity: toVec2(initialVelocity),\n\t\t\tbullet: false,\n\t\t\tuserData: bodyData\n\t\t};\n\n\t\t// create the body and add its fixture\n\t\tconst body = this.world.createBody(bodyDef);\n\t\tthis.addFixtures(body, objectType, pose.scaleFactor, flipX, flipY, objectTypeProperties);\n\n\t\t// we have one more body of this type\n\t\tobjectTypeProperties.instanceCount += 1;\n\n\t\t// if the object is controllable, register as rows that can trigger control\n\t\tobjectType.behaviour.some((row) => {\n\t\t\tif (!row.isEmpty()) {\n\t\t\t\tthis.scriptedBodies.add(body);\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\n\t\t// if the object has animations, register it\n\t\tif (objectType.hasAnimations) {\n\t\t\tbodyData.animation = new AnimationData(this.currentTime);\n\t\t\tthis.animatedBodies.add(body);\n\t\t}\n\n\t\treturn body;\n\t}\n\n\tprivate destroyObject(body: Body) {\n\t\t// disable text input if the object is the initiator\n\t\tif (this.textInput.initiator === body) {\n\t\t\tthis.stopTextInput();\n\t\t}\n\n\t\t// detach camera\n\t\tif (this.targetCamera === body) {\n\t\t\tthis.targetCamera = toVector2(body.getPosition());\n\t\t\tthis.dialogCallback(true, null);\n\t\t}\n\n\t\t// if the object is controllable, de-register rows that can trigger control\n\t\tconst objectType = cast(BodyData, body.getUserData()).objectType;\n\t\tobjectType.behaviour.some((row) => {\n\t\t\tif (!row.isEmpty()) {\n\t\t\t\tthis.scriptedBodies.delete(body);\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\n\t\t// remove from animated bodies\n\t\tif (objectType.hasAnimations) {\n\t\t\tthis.animatedBodies.delete(body);\n\t\t}\n\n\t\t// remove from physics engine\n\t\tthis.world.destroyBody(body);\n\n\t\t// we have one less body of this type\n\t\tconst objectTypeProperty = defined(this.objectTypesProperties.get(objectType));\n\t\tobjectTypeProperty.instanceCount -= 1;\n\t\tassert(objectTypeProperty.instanceCount >= 0, 'counted negative number of instance of a given type in the world');\n\t}\n\n\tprivate gameHasChangeScoreBlocks() {\n\t\tfor (const block of this.game.blockOfTypeIterator(ChangeVariableBlock)) {\n\t\t\tif (block.address === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic initWorld(forceFakeMusic = false) {\n\t\t// reset internal state\n\t\tthis.lastStepTime = null;\n\t\tthis.scriptedBodies.clear();\n\t\tthis.animatedBodies.clear();\n\t\tthis.contactMaps.clear();\n\t\tthis.targetCamera = new Vector2();\n\t\tthis.currentCamera = new Vector2();\n\t\tthis.targetCameraPos = null;\n\t\tthis.cameraVelocityOld = new Vector2();\n\t\tthis.gameVariables = new Map();\n\t\tif (this.gameHasChangeScoreBlocks()) {\n\t\t\tthis.gameVariables.set(0, 0);\n\t\t}\n\t\tthis.gameVariablesChanged = true;\n\t\tthis.currentTime = 0;\n\t\tthis.sessionId = createUUIDString(GameSessionNamespace);\n\t\tthis.textInput.text = '';\n\n\t\t// create a new world and setup listeners\n\t\tthis.world = new World(new Vec2(0, this.game.level.gravity));\n\t\tthis.world.on('pre-solve', this.preSolveContact.bind(this));\n\n\t\t// compute object type properties\n\t\tthis.objectTypesProperties.clear();\n\t\tfor (const objectType of this.game.objects) {\n\t\t\tthis.objectTypesProperties.set(objectType, new ObjectTypeProperties(objectType, this.game));\n\t\t}\n\n\t\t// get world bounds\n\t\tthis.worldBounds = this.game.level.computeWorldBounds();\n\n\t\t// fill the world with objects from the level\n\t\tthis.maxZ = 0;\n\t\tfor (const editorObject of this.game.level.objects) {\n\t\t\tconst objectTypeProperties = defined(this.objectTypesProperties.get(editorObject.type));\n\t\t\tobjectTypeProperties.levelInstanceCount += 1;\n\n\t\t\t// create object\n\t\t\tconst body = this.createObject(editorObject.type, editorObject.pose, editorObject.variables);\n\n\t\t\t// if the object is tracked by camera, set that up\n\t\t\tif (body && this.game.level.camera.trackedObject === editorObject) {\n\t\t\t\tthis.targetCamera = body;\n\t\t\t\tthis.currentCamera = toVector2(body.getPosition());\n\t\t\t}\n\t\t}\n\n\t\t// if no object is tracked by camera, save its position\n\t\tif (!this.game.level.camera.isAttached) {\n\t\t\tthis.targetCamera = this.game.level.camera.position.clone();\n\t\t\tthis.currentCamera = this.targetCamera.clone();\n\t\t}\n\t\tthis.cameraExtent = this.game.level.camera.extent.clone();\n\n\t\t// create music object, if it does not exist yet\n\t\tgetMusic(forceFakeMusic);\n\t}\n\n\tpublic stopWorld() {\n\t\tgetMusic().stop();\n\t}\n\n\tprivate updateContactMap() {\n\t\tthis.contactMaps.clear();\n\t\tfor (let contact = this.world.getContactList(); contact; contact = contact.getNext()) {\n\t\t\tconst bodyA = contact.getFixtureA().getBody();\n\t\t\tconst bodyB = contact.getFixtureB().getBody();\n\t\t\tconst contactPoint = new ContactPoint(contact);\n\t\t\tfor (const [thisBody, thatBody] of [[bodyA, bodyB], [bodyB, bodyA]] as const) {\n\t\t\t\tconst contactSet = this.contactMaps.get(thisBody);\n\t\t\t\tif (contactSet !== undefined) {\n\t\t\t\t\tcontactSet.set(thatBody, contactPoint);\n\t\t\t\t} else {\n\t\t\t\t\tthis.contactMaps.set(thisBody, new Map([[thatBody, contactPoint]]));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.contactCallback) {\n\t\t\t\tthis.contactCallback(contact);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate preSolveContact(contact: Contact, _oldManifold: Manifold) {\n\t\tconst bodyA = contact.getFixtureA().getBody();\n\t\tconst bodyB = contact.getFixtureB().getBody();\n\t\t// is there an active rule that will lead to deletion of one of the body?\n\t\tconst toTest = [[bodyA, bodyB], [bodyB, bodyA]] as const;\n\t\tfor (const [body, thatBody] of toTest) {\n\t\t\tconst bodyData = cast(BodyData, body.getUserData());\n\t\t\tconst objectType = bodyData.objectType;\n\t\t\tif (!defined(this.objectTypesProperties.get(objectType)).hasDeleteBlocks) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst thatBodyData = cast(BodyData, thatBody.getUserData());\n\t\t\tconst thatObjectType = thatBodyData.objectType;\n\t\t\tconst contacts = this.listSingleContact.bind(this, thatObjectType, contact);\n\t\t\tobjectType.behaviour.forEach((row, rowIndex) => {\n\t\t\t\tif (this.checkConditions(row, rowIndex, body, contacts)) {\n\t\t\t\t\tif (row.actions.some(\n\t\t\t\t\t\t(action) => dynamicCast(DeleteBlock, action.block) !== null\n\t\t\t\t\t)) {\n\t\t\t\t\t\tcontact.setEnabled(false);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n","/**\n * @module storage\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { KeyValueMap } from 'storage/db';\nimport { ContentTypes } from 'network/api-types';\nimport { RustServerDb } from 'storage/rust-db';\nimport { GameSaveResult, Storage } from 'storage/storage';\nimport { gamesBacklog, gameNamesBacklog, miniaturesBacklog } from 'storage/backlog';\nimport { GameMetaDataCanvas, saveGameWithStorer, saveNewBinaryGameWithStorer } from 'game/game-saver';\nimport { AssetManager } from './asset-manager';\nimport { Game, CanvasWithKey, SoundWithKey } from 'game/game';\nimport { getAttributeRustServerOrLocal, setAttributeRustServerOrLocal } from 'network/api';\nimport { AssetSerializer } from './asset-serializer';\nimport { AssetLoaderAndSaver } from './asset-saver';\nimport { storeWithBacklog } from 'apps/full/backlog-executor';\nimport { imageDataToURIString } from 'utils/serialization';\nimport { encodePng } from 'utils/image';\nimport { canvasToImageData } from 'utils/conversion';\nimport { AssetLoader } from './asset-loader';\nimport { assertFalse } from 'utils/assert';\n\n\nexport abstract class RustDbFbsReadStorage implements Storage {\n\tgameDb: KeyValueMap<ArrayBuffer>;\n\tgameNamesDb: KeyValueMap<null | string>;\n\n\tconstructor(protected db: RustServerDb, protected assetSerializer: AssetSerializer) {\n\t\tthis.gameDb = db.getBinaryMap('games', ContentTypes.Game);\n\t\tthis.gameNamesDb = db.getMap('gameNames');\n\t}\n\n\tgetAttribute(name: string) {\n\t\treturn getAttributeRustServerOrLocal(name);\n\t}\n\n\tabstract setAttribute(name: string, value: string): Promise<void>;\n\n\tgetWorkspace(name: string, insecure: boolean) {\n\t\treturn this.db.getWorkspace(name, insecure);\n\t}\n\n\tgetCounter(name: string) {\n\t\treturn this.db.getCounter(name);\n\t}\n\n\tasync loadGameBinary(gameKey: string) {\n\t\treturn new Uint8Array(await this.gameDb.get(gameKey));\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tasync miniatureReadURI(gameKey: string) {\n\t\treturn this.db.getMiniatureReadURI(gameKey);\n\t}\n\n\tasync getGameName(gameKey: string) {\n\t\treturn await this.gameNamesDb.get(gameKey);\n\t}\n\n\tabstract saveGame(game: Game): GameSaveResult;\n\n\tabstract saveNewBinaryGame(binaryGame: Uint8Array): GameSaveResult;\n\n\tabstract setGameName(gameKey: string, gameName: string | null): Promise<void>;\n\n\tget imageAssets(): AssetManager<CanvasWithKey> {\n\t\treturn this.assetSerializer.imageManager;\n\t}\n\n\tget soundAssets(): AssetManager<SoundWithKey> {\n\t\treturn this.assetSerializer.soundManager;\n\t}\n\n\tasync storePendingAssetsAndReturnSuccess() {\n\t\treturn this.assetSerializer.storePendingAssetsAndReturnSuccess();\n\t}\n\n\tlistAssets() {\n\t\tthis.assetSerializer.listAssets();\n\t}\n}\n\nexport class RustDbFbsReadOnlyStorage extends RustDbFbsReadStorage {\n\tconstructor(protected db: RustServerDb) {\n\t\tsuper(db, new AssetSerializer(\n\t\t\tdb.getBinaryWithContentTypeMap('assets'),\n\t\t\tAssetLoader,\n\t\t\tAssetLoader\n\t\t));\n\t}\n\n\tsetAttribute(_name: string, _value: string): Promise<void> {\n\t\tassertFalse('Not available in read-only storage.');\n\t}\n\n\tsaveGame(_game: Game): GameSaveResult {\n\t\tassertFalse('Not available in read-only storage.');\n\t}\n\n\tsaveNewBinaryGame(_binaryGame: Uint8Array): GameSaveResult {\n\t\tassertFalse('Not available in read-only storage.');\n\t}\n\n\tsetGameName(_gameKey: string, _gameName: string | null): Promise<void> {\n\t\tassertFalse('Not available in read-only storage.');\n\t}\n}\n\nexport class RustDbFbsStorage extends RustDbFbsReadStorage {\n\tgameMiniaturesDB: KeyValueMap<ArrayBuffer>;\n\n\tpublic gameSavedCb: (metaData: GameMetaDataCanvas) => void = (_) => {};\n\n\tconstructor(protected db: RustServerDb) {\n\t\tsuper(db, new AssetSerializer(\n\t\t\tdb.getBinaryWithContentTypeMap('assets'),\n\t\t\tAssetLoaderAndSaver,\n\t\t\tAssetLoaderAndSaver\n\t\t));\n\t\tthis.gameMiniaturesDB = db.getBinaryMap('miniatures', ContentTypes.ImagePng);\n\t}\n\n\tasync setAttribute(name: string, value: string) {\n\t\treturn setAttributeRustServerOrLocal(name, value);\n\t}\n\n\tasync miniatureReadURI(gameKey: string) {\n\t\tconst backlogGameMiniature = await miniaturesBacklog.get(gameKey);\n\t\tif (backlogGameMiniature !== undefined) {\n\t\t\tconsole.debug(`Fetching game miniature for ${gameKey} from backlog`);\n\t\t\t// in backlog, encode as image URI\n\t\t\treturn imageDataToURIString(backlogGameMiniature);\n\t\t} else {\n\t\t\t// fetch from server\n\t\t\treturn super.miniatureReadURI(gameKey);\n\t\t}\n\t}\n\n\tasync loadGameBinary(gameKey: string) {\n\t\treturn new Uint8Array(\n\t\t\tawait gamesBacklog.get(gameKey) ||\n\t\t\tawait this.gameDb.get(gameKey)\n\t\t);\n\t}\n\n\tasync getGameName(gameKey: string): Promise<string | null> {\n\t\treturn (\n\t\t\tawait gameNamesBacklog.get(gameKey) ||\n\t\t\tawait this.gameNamesDb.get(gameKey)\n\t\t);\n\t}\n\n\tsaveGame(game: Game): GameSaveResult {\n\t\treturn saveGameWithStorer(\n\t\t\tgame,\n\t\t\tthis,\n\t\t\tthis.gameStorer.bind(this)\n\t\t);\n\t}\n\n\tsaveNewBinaryGame(binaryGame: Uint8Array): GameSaveResult {\n\t\treturn saveNewBinaryGameWithStorer(\n\t\t\tbinaryGame,\n\t\t\tthis.gameStorer.bind(this)\n\t\t);\n\t}\n\n\tprivate gameStorer(serialisedGame: Uint8Array, gameMetaData: GameMetaDataCanvas) {\n\t\t// Call our callback\n\t\tthis.gameSavedCb(gameMetaData);\n\n\t\t// Create the promise\n\t\tconst gameKey = gameMetaData.id;\n\t\tconst gameSavePromise = Promise.all([\n\t\t\tthis.gameDataStore(gameKey, serialisedGame),\n\t\t\tthis.miniatureStore(gameKey, canvasToImageData(gameMetaData.miniature))\n\t\t]).then(() => {});\n\n\t\t// Start the async part of the saving and return a promise for its result\n\t\treturn { serialisedGame, gameSavePromise };\n\t}\n\n\tprivate async gameDataStore(gameKey: string, binaryGame: ArrayBuffer) {\n\t\tconst isAnyAssetInBacklog = !await this.assetSerializer.storePendingAssetsAndReturnSuccess();\n\t\tconsole.debug('isAnyAssetInBacklog', isAnyAssetInBacklog);\n\t\tawait storeWithBacklog(\n\t\t\tgameKey,\n\t\t\tbinaryGame,\n\t\t\t(key, data) => this.gameDb.set(key, data),\n\t\t\tgamesBacklog,\n\t\t\tisAnyAssetInBacklog\n\t\t);\n\t};\n\n\tprivate async miniatureStore(gameKey: string, miniature: ImageData) {\n\t\t// TODO: add miniature store 2 where we store the PNGs\n\t\tconsole.debug(`Saving game miniature for ${gameKey}`);\n\t\treturn storeWithBacklog(\n\t\t\tgameKey,\n\t\t\tminiature,\n\t\t\t(key, data) => this.gameMiniaturesDB.set(key, encodePng(data)),\n\t\t\tminiaturesBacklog\n\t\t);\n\t}\n\n\tsetGameName(gameKey: string, gameName: string | null): Promise<void> {\n\t\tif (gameName !== null && gameName.length > 64) {\n\t\t\tgameName = gameName.substring(0, 64);\n\t\t}\n\t\tconsole.debug(`Setting game name for ${gameKey} to ${gameName}`);\n\t\treturn storeWithBacklog(\n\t\t\tgameKey,\n\t\t\tgameName,\n\t\t\t(key, name) => this.gameNamesDb.set(key, name),\n\t\t\tgameNamesBacklog\n\t\t);\n\t}\n\n\tget assetDb() {\n\t\treturn this.assetSerializer.assetDb;\n\t}\n}","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { assertIntegerRange, assert } from './assert';\nimport { toStr } from './types';\n\n/** Get an union of valid indices of a tuple */\nexport type IndexOf<T extends {length: number}> = Exclude<Partial<T>['length'], T['length']>;\n\n/** Get the length of a tuple */\nexport type TupleLength<T extends {length: number}> = T['length'];\n\n/** Fixed-size array of a given type */\nexport type FixedSizeArray<T, N extends number> = N extends N ? number extends N ? T[] : _FixedSizeArray<T, N, []> : never;\ntype _FixedSizeArray<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : _FixedSizeArray<T, N, [T, ...R]>;\n\n/** Minimum-size array of a given type, MinSizeArray<T, N> accepts FixedSizeArray<T, M> for any M >= N */\nexport type MinSizeArray<T, N extends number> = N extends N ? number extends N ? T[] : _MinSizeArray<T, N, []> : never;\ntype _MinSizeArray<T, N extends number, R extends unknown[]> = R['length'] extends N ? [...R, ...T[]] : _MinSizeArray<T, N, [T, ...R]>;\n\n// Helper to exclude index keys of a type\ntype RemoveIndex<T> = {\n\t[ K in keyof T as string extends K ? never : number extends K ? never : K ] : T[K]\n};\n// A non-indexable Float32Array\ntype Float32ArrayWithoutIndex = RemoveIndex<Float32Array>;\n\n/** A fixed-size Float32 array */\nexport type FixedSizeFloat32Array<N extends number> = FixedSizeArray<number, N> & Float32ArrayWithoutIndex;\n\n/** Create a fixed-size Float32 array */\nexport function createFixedSizeFloat32Array<N extends number>(n: N) {\n\treturn new Float32Array(n) as unknown as FixedSizeFloat32Array<N>;\n}\n\n/** Build a Float32 array of size n by calling f(index) for all its indices */\nexport function buildFixedSizeFloat32Array<N extends number>(n: N, f: (index: Nat<N>) => number) {\n\tconst a = createFixedSizeFloat32Array(n);\n\tfor (let i = 0; i < n; ++i) {\n\t\ta[i] = f(i as Nat<N>)\n\t}\n\treturn a;\n}\n\n/** An index for a type with a fixed size of N (tuple or array) */\nexport type Nat<N extends number> = IndexOf<FixedSizeArray<any, N>>;\n\n/** Build an array of size n by calling f(index) for all its indices */\nexport function buildRangeArray<T, N extends number>(n: N, f: (index: Nat<N>) => T) {\n\tconst a: T[] = new Array(n);\n\tfor (let i = 0; i < n; ++i) {\n\t\ta[i] = f(i as Nat<N>)\n\t}\n\treturn a as FixedSizeArray<T, N>;\n}\n\n/** Return a as a fixed-size array of length n, asserts if its length is actually not n */\nexport function asFixedSizeArray<T, N extends number>(a: T[], n: N, message = '') {\n\tassert(a.length === n, `Length of ${toStr(a)} is ${a.length} != n=${n}. ${message ? ' ' + message : ''}`);\n\treturn a as FixedSizeArray<T, N>;\n}\n\n/** Convert number to index type, assert it to be in range */\nexport function toIndex<N extends number>(n: N, index: number) {\n\tassertIntegerRange(index, 0, n - 1, 'index');\n\treturn index as Nat<N>;\n}\n\n/** Index of maximum value in a fixed-size array */\nexport function indexOfMax<N extends Exclude<number, 0>>(a: { length: N } & Readonly<number[]>) {\n\tlet max: number = a[0]!;\n\tlet maxIndex = 0 as Nat<N>;\n\titerConstFixedSizeArray(a, (value, i) => {\n\t\tif (value > max) {\n\t\t\tmaxIndex = i;\n\t\t\tmax = value;\n\t\t}\n\t});\n\treturn maxIndex;\n}\n\n// Loops with index type\n\n// a small bunch of unsigned, to constrain N below\ntype Index16 = Nat<17>;\n\n/** For each element of the const N-sized array, call f() with the element and its index, typed 0 | ... | N-1 (type-safe forEach) */\nexport function iterConstFixedSizeArray<T, N extends number>(a: { length: N } & Readonly<T[]>, f: (value: T, i: Nat<N>) => void) {\n\tfor (let i = 0; i < a.length; ++i) {\n\t\tf(a[i]!, i as Nat<N>);\n\t}\n}\n\n/** For each element of the N-sized array, call f() with the element and its index, typed 0 | ... | N-1 (type-safe forEach) */\nexport function iterFixedSizeArray<T, N extends number>(a: { length: N } & T[], f: (value: T, i: Nat<N>) => void) {\n\tfor (let i = 0; i < a.length; ++i) {\n\t\tf(a[i]!, i as Nat<N>);\n\t}\n}\n\n/** Generate indices from 0 to n-1, typed 0 | ... | n-1, and call f() for each of them (faster than genIndex) */\nexport function iterIndex<N extends Index16>(n: N, f: (i: Nat<N>) => void) {\n\tfor (let i = 0; i < n; ++i) {\n\t\tf(i as Nat<N>);\n\t}\n}\n\n/** Generate indices from 0 to n-1, typed 0 | ... | n-1 (slower than iterIndex) */\nexport function *genIndex<N extends Index16>(n: N) {\n\tfor (let i = 0; i < n; ++i) {\n\t\tyield (i as Nat<N>);\n\t}\n}\n\n// Map\n\n/** A map over fixed-sized array that retain the size */\nexport function map<T, U, N extends number>(a: { length: N } & readonly T[], f: (value: T, i: Nat<N>) => U) {\n\treturn a.map(f as (value: T, i: number) => U) as FixedSizeArray<U, N>;\n}\n\n// Safe array access if enough size\n\n/** If index is valid in array, call f with array[index] as argument, and return result; otherwise return undefined. */\nexport function applyToElementIfExists<T, N extends Index16, R>(array: T[], index: N, f: (value: T) => R) {\n\tif (index < array.length) {\n\t\treturn f(array[index] as T);\n\t}\n}\n\n/** If array has length >= size, then call f with array as argument, but with type MinSizeArray<T, size>, and return result; other return undefined. */\nexport function applyToArrayIfLargeEnough<T, N extends Index16, R>(array: T[], size: N, f: (array: MinSizeArray<T, N>) => R) {\n\tif (size <= array.length) {\n\t\treturn f(array as MinSizeArray<T, N>);\n\t}\n}\n\n/** If const array has length >= size, then call f with array as argument, but with type ConstMinSizeArray<T, size>, and return result; other return undefined. */\nexport function applyToConstArrayIfLargeEnough<T, N extends Index16, R>(array: Readonly<T[]>, size: N, f: (array: Readonly<MinSizeArray<T, N>>) => R) {\n\tif (size <= array.length) {\n\t\treturn f(array as unknown as Readonly<MinSizeArray<T, N>>);\n\t}\n}\n","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nexport function isBitMaskSet(bitSet: number, mask: number): boolean {\n\treturn (bitSet & mask) === mask;\n}\n\nexport function isBitSet(bitSet: number, bit: number): boolean {\n\treturn (bitSet & (1 << bit)) !== 0;\n}\n\nexport function setBitValue(bitSet: number, bit: number, value: boolean) {\n\tif (value) {\n\t\tbitSet |= 1 << bit;\n\t} else {\n\t\tbitSet &= ~(1 << bit);\n\t}\n\treturn bitSet;\n}\n\nexport class BitString {\n\tconstructor(public bits = '') {}\n\n\tisBitSet(bit: number): boolean {\n\t\tconst charNumber = bit >> 2;\n\t\tif (charNumber >= this.bits.length) {\n\t\t\treturn false;\n\t\t}\n\t\tconst l = this.bits.length;\n\t\tconst charIndex = l - charNumber - 1;\n\t\tconst char = this.bits[charIndex]!;\n\t\tconst value = parseInt(char, 16) || 0;\n\t\tconst bitIndex = bit & 0x3;\n\t\treturn isBitSet(value, bitIndex);\n\t}\n\n\tsetBitValue(bit: number, value: boolean) {\n\t\tconst charNumber = bit >> 2;\n\t\tif (charNumber >= this.bits.length) {\n\t\t\tconst toAddCount = charNumber - this.bits.length + 1;\n\t\t\tthis.bits = '0'.repeat(toAddCount) + this.bits;\n\t\t}\n\t\tconst l = this.bits.length;\n\t\tconst charIndex = l - charNumber - 1;\n\t\tconst char = this.bits[charIndex]!;\n\t\tconst bitSet = parseInt(char, 16) || 0;\n\t\tconst bitIndex = bit & 0x3;\n\t\tconst newBitSet = setBitValue(bitSet, bitIndex, value);\n\t\tthis.bits =\n\t\t\tthis.bits.substring(0, charIndex) +\n\t\t\tnewBitSet.toString(16) +\n\t\t\tthis.bits.substring(charIndex + 1)\n\t\t;\n\t}\n}\n","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { cast } from 'utils/types';\nimport { cloneImageData } from './clone';\n\n// cSpell:ignore camelcase\n// eslint-disable-next-line camelcase\nimport { decode_png_callback, decode_png_base64_callback, premultiply_alpha } from 'app-core-web/pkg';\nimport { createOffscreenCanvasAnd2DContext } from './canvas';\n// eslint-disable-next-line camelcase\nexport { encode_png as encodePng, encode_png_base64, encode_base64, decode_base64 } from 'app-core-web/pkg';\n\nexport function decodePng(encoded: Uint8Array): ImageData {\n\tlet decodedImageData: ImageData | null = null;\n\tdecode_png_callback(encoded, (image: ImageData) => {\n\t\tdecodedImageData = cloneImageData(cast(ImageData, image));\n\t});\n\tif (decodedImageData !== null) {\n\t\treturn decodedImageData;\n\t} else {\n\t\tthrow Error('Never got called back from decode_png_callback!');\n\t}\n}\n\nexport function decodePngBase64(encoded: string): ImageData {\n\tlet decodedImageData: ImageData | null = null;\n\tdecode_png_base64_callback(encoded, (image: ImageData) => {\n\t\tdecodedImageData = cloneImageData(cast(ImageData, image));\n\t});\n\tif (decodedImageData !== null) {\n\t\treturn decodedImageData;\n\t} else {\n\t\tthrow Error('Never got called back from decode_png_base64_callback!');\n\t}\n}\n\nexport const ImageContentTypes = ['image/png', 'image/jpeg', 'image/webp'] as const;\n\nexport async function decodeImageBrowser(encodedOrURL: Uint8Array | string, type: typeof ImageContentTypes[number]) {\n\tconst image = new Image();\n\tif (typeof encodedOrURL === 'string') {\n\t\timage.src = encodedOrURL;\n\t} else {\n\t\tconst blob = new Blob( [ encodedOrURL ], { type } );\n\t\timage.src = URL.createObjectURL(blob);\n\t}\n\tawait image.decode();\n\tconst { ctx } = createOffscreenCanvasAnd2DContext(image.width, image.height);\n\tctx.drawImage(image, 0, 0);\n\treturn ctx.getImageData(0, 0, image.width, image.height);\n}\n\nexport async function decodePngBrowser(encodedOrURL: Uint8Array | string) {\n\treturn decodeImageBrowser(encodedOrURL, 'image/png');\n}\n\nexport function preMultiplyAlpha(imageData: ImageData) {\n\tconst preMultData = new Uint8ClampedArray(premultiply_alpha(new Uint8Array(imageData.data)));\n\treturn new ImageData(preMultData, imageData.width, imageData.height);\n}","/**\n * @module utils\n */\n/** comment to work-around limitation of typedoc module plugin */\n\n// Copyright 2018-2024 Enlightware GmbH, Switzerland\n\nimport { Vector2, SimilarityTransform } from 'math/linalg';\nimport { Rect } from 'math/geometry';\nimport { AnyCanvas, AnyCanvasRenderingContext2D } from 'imgui/imgui-types';\nimport { createOffscreenCanvasAnd2DContext } from './canvas';\n\nexport function renderClosedPolygon(ctx: AnyCanvasRenderingContext2D, polygon: Vector2[]) {\n\tlet i = 0;\n\tfor (const p of polygon) {\n\t\tif (i++ === 0) {\n\t\t\tctx.moveTo(p.x, p.y);\n\t\t} else {\n\t\t\tctx.lineTo(p.x, p.y);\n\t\t}\n\t}\n\tctx.closePath();\n}\n\nexport function applyTransform(ctx: AnyCanvasRenderingContext2D, transform: SimilarityTransform) {\n\tctx.translate(transform.translation.x, transform.translation.y);\n\tctx.rotate(transform.rotationAngle);\n\tctx.scale(transform.scaleFactor, transform.scaleFactor);\n}\n\nexport interface Drawable {\n\tdraw(ctx: AnyCanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;\n\tvalidate(): void;\n\tcanvas: AnyCanvas;\n\treadonly size: Vector2;\n\tclone(): Drawable;\n}\n\n// Return transform source pixels from destination pixels\nexport function drawCanvasInBox(ctx: AnyCanvasRenderingContext2D, src: Drawable, size: number | Vector2, topLeft = new Vector2()) {\n\tconst sourceAspectRatio = src.size.aspectRatio;\n\tconst box = size instanceof Vector2 ? size : new Vector2(size, size);\n\tif (sourceAspectRatio >= box.aspectRatio) {\n\t\tconst h = box.x / sourceAspectRatio;\n\t\tconst y = (box.y - h) / 2;\n\t\tsrc.draw(ctx, topLeft.x, topLeft.y + y, box.x, h);\n\t\tconst scaling = src.size.x / box.x;\n\t\treturn SimilarityTransform.scalingTranslation(scaling, new Vector2(0, -y));\n\t} else {\n\t\tconst w = box.y * sourceAspectRatio;\n\t\tconst x = (box.x - w) / 2;\n\t\tsrc.draw(ctx, topLeft.x + x, topLeft.y, w, box.y);\n\t\tconst scaling = src.size.y / box.y;\n\t\treturn SimilarityTransform.scalingTranslation(scaling, new Vector2(-x, 0));\n\t}\n}\n\n// Return transfrom source pixels from destination pixels\nexport function drawCanvasRotatedInBox(ctx: AnyCanvasRenderingContext2D, src: Drawable, angle:number, size: number | Vector2, topLeft = new Vector2()) {\n\tif (angle === 0) {\n\t\treturn drawCanvasInBox(ctx, src, size, topLeft);\n\t}\n\tconst maxSrcSize = src.size.maximum();\n\tconst box = size instanceof Vector2 ? size : new Vector2(size, size);\n\tconst minDestSize = box.minimum();\n\tconst ratio = minDestSize / maxSrcSize;\n\tctx.translate(topLeft.x + box.x / 2, topLeft.y + box.y / 2);\n\tctx.rotate(angle);\n\tconst w = src.size.x * ratio;\n\tconst h = src.size.y * ratio;\n\tsrc.draw(ctx, -w / 2, -h / 2, w, h);\n\tctx.rotate(-angle);\n\tctx.translate(-topLeft.x - box.x / 2, -topLeft.y - box.y / 2);\n\treturn new SimilarityTransform(new Vector2(), -angle, ratio);\n}\n\nexport function roundRectPath(ctx: AnyCanvasRenderingContext2D, rect: Rect | [number, number, number, number], radius: number) {\n\tconst [ x, y, width, height ] = rect instanceof Rect ? [ rect.x, rect.y, rect.width, rect.height ] : rect;\n\t// inspired by https://stackoverflow.com/questions/1255512/how-to-draw-a-rounded-rectangle-on-html-canvas\n\tctx.beginPath();\n\tctx.moveTo(x + radius, y);\n\tctx.lineTo(x + width - radius, y);\n\tctx.quadraticCurveTo(x + width, y, x + width, y + radius);\n\tctx.lineTo(x + width, y + height - radius);\n\tctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);\n\tctx.lineTo(x + radius, y + height);\n\tctx.quadraticCurveTo(x, y + height, x, y + height - radius);\n\tctx.lineTo(x, y + radius);\n\tctx.quadraticCurveTo(x, y, x + radius, y);\n\tctx.closePath();\n}\n\nexport function createFallbackCanvas(key: string) {\n\tconst { canvas, ctx } = createOffscreenCanvasAnd2DContext(64, 64);\n\tctx.fillStyle = 'white';\n\tctx.strokeStyle = 'red';\n\tctx.lineWidth = 2;\n\tctx.beginPath();\n\tctx.rect(1, 1, canvas.width - 2, canvas.height - 2);\n\tctx.stroke();\n\tctx.fill();\n\tctx.font = 'bold 16px \"Roboto\"';\n\tctx.fillStyle = 'red';\n\tctx.fillText('broken', 6, 20);\n\tctx.fillText('asset', 12, 40);\n\tctx.font = '12px \"Roboto\"';\n\tctx.fillStyle = 'black';\n\tctx.fillText(key.substring(0, 8), 6, 58);\n\treturn canvas;\n}","import * as wasm from \"./index_bg.wasm\";\nexport * from \"./index_bg.js\";\nimport { __wbg_set_wasm } from \"./index_bg.js\";\n__wbg_set_wasm(wasm);\nwasm.__wbindgen_start();\n","let wasm;\nexport function __wbg_set_wasm(val) {\n    wasm = val;\n}\n\n\nconst heap = new Array(128).fill(undefined);\n\nheap.push(undefined, null, true, false);\n\nlet heap_next = heap.length;\n\nfunction addHeapObject(obj) {\n    if (heap_next === heap.length) heap.push(heap.length + 1);\n    const idx = heap_next;\n    heap_next = heap[idx];\n\n    heap[idx] = obj;\n    return idx;\n}\n\nfunction getObject(idx) { return heap[idx]; }\n\nfunction handleError(f, args) {\n    try {\n        return f.apply(this, args);\n    } catch (e) {\n        wasm.__wbindgen_exn_store(addHeapObject(e));\n    }\n}\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n    if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n        cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n    }\n    return cachedUint8ArrayMemory0;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nfunction passArray8ToWasm0(arg, malloc) {\n    const ptr = malloc(arg.length * 1, 1) >>> 0;\n    getUint8ArrayMemory0().set(arg, ptr / 1);\n    WASM_VECTOR_LEN = arg.length;\n    return ptr;\n}\n\nlet cachedDataViewMemory0 = null;\n\nfunction getDataViewMemory0() {\n    if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n        cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n    }\n    return cachedDataViewMemory0;\n}\n\nlet cachedUint8ClampedArrayMemory0 = null;\n\nfunction getUint8ClampedArrayMemory0() {\n    if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {\n        cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);\n    }\n    return cachedUint8ClampedArrayMemory0;\n}\n\nfunction getClampedArrayU8FromWasm0(ptr, len) {\n    ptr = ptr >>> 0;\n    return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction dropObject(idx) {\n    if (idx < 132) return;\n    heap[idx] = heap_next;\n    heap_next = idx;\n}\n\nfunction takeObject(idx) {\n    const ret = getObject(idx);\n    dropObject(idx);\n    return ret;\n}\n\nfunction debugString(val) {\n    // primitive types\n    const type = typeof val;\n    if (type == 'number' || type == 'boolean' || val == null) {\n        return  `${val}`;\n    }\n    if (type == 'string') {\n        return `\"${val}\"`;\n    }\n    if (type == 'symbol') {\n        const description = val.description;\n        if (description == null) {\n            return 'Symbol';\n        } else {\n            return `Symbol(${description})`;\n        }\n    }\n    if (type == 'function') {\n        const name = val.name;\n        if (typeof name == 'string' && name.length > 0) {\n            return `Function(${name})`;\n        } else {\n            return 'Function';\n        }\n    }\n    // objects\n    if (Array.isArray(val)) {\n        const length = val.length;\n        let debug = '[';\n        if (length > 0) {\n            debug += debugString(val[0]);\n        }\n        for(let i = 1; i < length; i++) {\n            debug += ', ' + debugString(val[i]);\n        }\n        debug += ']';\n        return debug;\n    }\n    // Test for built-in\n    const builtInMatches = /\\[object ([^\\]]+)\\]/.exec(toString.call(val));\n    let className;\n    if (builtInMatches && builtInMatches.length > 1) {\n        className = builtInMatches[1];\n    } else {\n        // Failed to match the standard '[object ClassName]'\n        return toString.call(val);\n    }\n    if (className == 'Object') {\n        // we're a user defined class or Object\n        // JSON.stringify avoids problems with cycles, and is generally much\n        // easier than looping through ownProperties of `val`.\n        try {\n            return 'Object(' + JSON.stringify(val) + ')';\n        } catch (_) {\n            return 'Object';\n        }\n    }\n    // errors\n    if (val instanceof Error) {\n        return `${val.name}: ${val.message}\\n${val.stack}`;\n    }\n    // TODO we could test for more things here, like `Set`s and `Map`s.\n    return className;\n}\n\nconst lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;\n\nlet cachedTextEncoder = new lTextEncoder('utf-8');\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n    ? function (arg, view) {\n    return cachedTextEncoder.encodeInto(arg, view);\n}\n    : function (arg, view) {\n    const buf = cachedTextEncoder.encode(arg);\n    view.set(buf);\n    return {\n        read: arg.length,\n        written: buf.length\n    };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n    if (realloc === undefined) {\n        const buf = cachedTextEncoder.encode(arg);\n        const ptr = malloc(buf.length, 1) >>> 0;\n        getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n        WASM_VECTOR_LEN = buf.length;\n        return ptr;\n    }\n\n    let len = arg.length;\n    let ptr = malloc(len, 1) >>> 0;\n\n    const mem = getUint8ArrayMemory0();\n\n    let offset = 0;\n\n    for (; offset < len; offset++) {\n        const code = arg.charCodeAt(offset);\n        if (code > 0x7F) break;\n        mem[ptr + offset] = code;\n    }\n\n    if (offset !== len) {\n        if (offset !== 0) {\n            arg = arg.slice(offset);\n        }\n        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n        const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n        const ret = encodeString(arg, view);\n\n        offset += ret.written;\n        ptr = realloc(ptr, len, offset, 1) >>> 0;\n    }\n\n    WASM_VECTOR_LEN = offset;\n    return ptr;\n}\n\nfunction isLikeNone(x) {\n    return x === undefined || x === null;\n}\n\nconst lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;\n\nlet cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n\ncachedTextDecoder.decode();\n\nfunction getStringFromWasm0(ptr, len) {\n    ptr = ptr >>> 0;\n    return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nlet stack_pointer = 128;\n\nfunction addBorrowedObject(obj) {\n    if (stack_pointer == 1) throw new Error('out of js stack');\n    heap[--stack_pointer] = obj;\n    return stack_pointer;\n}\n/**\n * @param {string} markdown\n * @param {string} valid_pages\n * @returns {string}\n */\nexport function candlipedia_page_to_html(markdown, valid_pages) {\n    let deferred3_0;\n    let deferred3_1;\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        const ptr1 = passStringToWasm0(valid_pages, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len1 = WASM_VECTOR_LEN;\n        wasm.candlipedia_page_to_html(retptr, ptr0, len0, ptr1, len1);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        deferred3_0 = r0;\n        deferred3_1 = r1;\n        return getStringFromWasm0(r0, r1);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n    }\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n    ptr = ptr >>> 0;\n    return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n/**\n * @param {Uint8Array} data\n * @returns {Uint8Array}\n */\nexport function compress(data) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.compress(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var v2 = getArrayU8FromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 1, 1);\n        return v2;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Uint8Array} data\n * @returns {Uint8Array}\n */\nexport function decompress(data) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.decompress(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        if (r3) {\n            throw takeObject(r2);\n        }\n        var v2 = getArrayU8FromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 1, 1);\n        return v2;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function rules_bin2json(data) {\n    let deferred3_0;\n    let deferred3_1;\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.rules_bin2json(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        var ptr2 = r0;\n        var len2 = r1;\n        if (r3) {\n            ptr2 = 0; len2 = 0;\n            throw takeObject(r2);\n        }\n        deferred3_0 = ptr2;\n        deferred3_1 = len2;\n        return getStringFromWasm0(ptr2, len2);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n    }\n}\n\n/**\n * @param {string} json\n * @returns {Uint8Array}\n */\nexport function rules_json2bin(json) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.rules_json2bin(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return takeObject(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {string} json\n * @returns {Uint8Array}\n */\nexport function game_json2bin(json) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.game_json2bin(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return takeObject(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Uint8Array} data\n * @returns {string}\n */\nexport function game_bin2json(data) {\n    let deferred3_0;\n    let deferred3_1;\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.game_bin2json(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        var ptr2 = r0;\n        var len2 = r1;\n        if (r3) {\n            ptr2 = 0; len2 = 0;\n            throw takeObject(r2);\n        }\n        deferred3_0 = ptr2;\n        deferred3_1 = len2;\n        return getStringFromWasm0(ptr2, len2);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n    }\n}\n\n/**\n * @param {ImageData} image_data\n * @returns {Uint8Array}\n */\nexport function encode_png(image_data) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        wasm.encode_png(retptr, addHeapObject(image_data));\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        if (r3) {\n            throw takeObject(r2);\n        }\n        var v1 = getArrayU8FromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 1, 1);\n        return v1;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {ImageData} image_data\n * @returns {string}\n */\nexport function encode_png_base64(image_data) {\n    let deferred2_0;\n    let deferred2_1;\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        wasm.encode_png_base64(retptr, addHeapObject(image_data));\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        var ptr1 = r0;\n        var len1 = r1;\n        if (r3) {\n            ptr1 = 0; len1 = 0;\n            throw takeObject(r2);\n        }\n        deferred2_0 = ptr1;\n        deferred2_1 = len1;\n        return getStringFromWasm0(ptr1, len1);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n        wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n    }\n}\n\n/**\n * @param {Uint8Array} compressed\n * @param {Function} callback\n */\nexport function decode_png_callback(compressed, callback) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(compressed, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.decode_png_callback(retptr, ptr0, len0, addHeapObject(callback));\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        if (r1) {\n            throw takeObject(r0);\n        }\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {string} compressed_base64\n * @param {Function} callback\n */\nexport function decode_png_base64_callback(compressed_base64, callback) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passStringToWasm0(compressed_base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.decode_png_base64_callback(retptr, ptr0, len0, addHeapObject(callback));\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        if (r1) {\n            throw takeObject(r0);\n        }\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Uint8Array} image_data\n * @returns {Uint8Array}\n */\nexport function premultiply_alpha(image_data) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.premultiply_alpha(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var v2 = getArrayU8FromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 1, 1);\n        return v2;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\nfunction _assertClass(instance, klass) {\n    if (!(instance instanceof klass)) {\n        throw new Error(`expected instance of ${klass.name}`);\n    }\n}\n\nlet cachedUint16ArrayMemory0 = null;\n\nfunction getUint16ArrayMemory0() {\n    if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {\n        cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);\n    }\n    return cachedUint16ArrayMemory0;\n}\n\nfunction getArrayU16FromWasm0(ptr, len) {\n    ptr = ptr >>> 0;\n    return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);\n}\n/**\n * @param {number} grid\n * @returns {Uint16Array}\n */\nexport function arcs_array_from_uint32grid(grid) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        wasm.arcs_array_from_uint32grid(retptr, grid);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var v1 = getArrayU16FromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 2, 2);\n        return v1;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\nfunction passArray16ToWasm0(arg, malloc) {\n    const ptr = malloc(arg.length * 2, 2) >>> 0;\n    getUint16ArrayMemory0().set(arg, ptr / 2);\n    WASM_VECTOR_LEN = arg.length;\n    return ptr;\n}\n/**\n * @param {number} angle\n * @param {Uint16Array} arcs\n * @returns {boolean}\n */\nexport function is_angle_in_arcs(angle, arcs) {\n    const ptr0 = passArray16ToWasm0(arcs, wasm.__wbindgen_malloc);\n    const len0 = WASM_VECTOR_LEN;\n    const ret = wasm.is_angle_in_arcs(angle, ptr0, len0);\n    return ret !== 0;\n}\n\n/**\n * @param {Uint8Array} input\n * @returns {string}\n */\nexport function encode_base64(input) {\n    let deferred3_0;\n    let deferred3_1;\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.encode_base64(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        var ptr2 = r0;\n        var len2 = r1;\n        if (r3) {\n            ptr2 = 0; len2 = 0;\n            throw takeObject(r2);\n        }\n        deferred3_0 = ptr2;\n        deferred3_1 = len2;\n        return getStringFromWasm0(ptr2, len2);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n        wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n    }\n}\n\n/**\n * @param {string} encoded\n * @returns {Uint8Array}\n */\nexport function decode_base64(encoded) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passStringToWasm0(encoded, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.decode_base64(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);\n        if (r3) {\n            throw takeObject(r2);\n        }\n        var v2 = getArrayU8FromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 1, 1);\n        return v2;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Uint8Array} game\n * @returns {any}\n */\nexport function build_ot_interaction_overview(game) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        const ptr0 = passArray8ToWasm0(game, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.build_ot_interaction_overview(retptr, ptr0, len0);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return takeObject(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {string} ctx\n */\nexport function set_log_ctx(ctx) {\n    const ptr0 = passStringToWasm0(ctx, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n    const len0 = WASM_VECTOR_LEN;\n    wasm.set_log_ctx(ptr0, len0);\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} _input\n * @returns {ExecOutput}\n */\nexport function exec_fn_unit_bool(compiler, name, _input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_unit_bool(retptr, compiler.__wbg_ptr, ptr0, len0, _input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} input\n * @returns {ExecOutput}\n */\nexport function exec_fn_int_bool(compiler, name, input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_int_bool(retptr, compiler.__wbg_ptr, ptr0, len0, input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} _input\n * @returns {ExecOutput}\n */\nexport function exec_fn_unit_tuple(compiler, name, _input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_unit_tuple(retptr, compiler.__wbg_ptr, ptr0, len0, _input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} input\n * @returns {ExecOutput}\n */\nexport function exec_fn_int_tuple(compiler, name, input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_int_tuple(retptr, compiler.__wbg_ptr, ptr0, len0, input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} _input\n * @returns {ExecOutput}\n */\nexport function exec_fn_unit_unit(compiler, name, _input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_unit_unit(retptr, compiler.__wbg_ptr, ptr0, len0, _input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} input\n * @returns {ExecOutput}\n */\nexport function exec_fn_int_unit(compiler, name, input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_int_unit(retptr, compiler.__wbg_ptr, ptr0, len0, input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} _input\n * @returns {ExecOutput}\n */\nexport function exec_fn_unit_int(compiler, name, _input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_unit_int(retptr, compiler.__wbg_ptr, ptr0, len0, _input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\n/**\n * @param {Compiler} compiler\n * @param {string} name\n * @param {number} input\n * @returns {ExecOutput}\n */\nexport function exec_fn_int_int(compiler, name, input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        _assertClass(compiler, Compiler);\n        const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.exec_fn_int_int(retptr, compiler.__wbg_ptr, ptr0, len0, input);\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n        if (r2) {\n            throw takeObject(r1);\n        }\n        return ExecOutput.__wrap(r0);\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\nfunction passArrayJsValueToWasm0(array, malloc) {\n    const ptr = malloc(array.length * 4, 4) >>> 0;\n    const mem = getDataViewMemory0();\n    for (let i = 0; i < array.length; i++) {\n        mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);\n    }\n    WASM_VECTOR_LEN = array.length;\n    return ptr;\n}\n/**\n * @param {string} s\n * @returns {boolean}\n */\nexport function is_valid_identifier(s) {\n    const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n    const len0 = WASM_VECTOR_LEN;\n    const ret = wasm.is_valid_identifier(ptr0, len0);\n    return ret !== 0;\n}\n\nfunction getArrayJsValueFromWasm0(ptr, len) {\n    ptr = ptr >>> 0;\n    const mem = getDataViewMemory0();\n    const result = [];\n    for (let i = ptr; i < ptr + 4 * len; i += 4) {\n        result.push(takeObject(mem.getUint32(i, true)));\n    }\n    return result;\n}\n/**\n * @param {ImageData} input\n * @returns {SpriteRow[]}\n */\nexport function processSpriteSheet(input) {\n    try {\n        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n        wasm.processSpriteSheet(retptr, addHeapObject(input));\n        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n        var v1 = getArrayJsValueFromWasm0(r0, r1).slice();\n        wasm.__wbindgen_free(r0, r1 * 4, 4);\n        return v1;\n    } finally {\n        wasm.__wbindgen_add_to_stack_pointer(16);\n    }\n}\n\nexport function main_js() {\n    wasm.main_js();\n}\n\n/**\n * Chroma subsampling format\n * @enum {0 | 1 | 2 | 3}\n */\nexport const ChromaSampling = Object.freeze({\n    /**\n     * Both vertically and horizontally subsampled.\n     */\n    Cs420: 0, \"0\": \"Cs420\",\n    /**\n     * Horizontally subsampled.\n     */\n    Cs422: 1, \"1\": \"Cs422\",\n    /**\n     * Not subsampled.\n     */\n    Cs444: 2, \"2\": \"Cs444\",\n    /**\n     * Monochrome.\n     */\n    Cs400: 3, \"3\": \"Cs400\",\n});\n\nconst ActivityFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_activity_free(ptr >>> 0, 1));\n\nexport class Activity {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(Activity.prototype);\n        obj.__wbg_ptr = ptr;\n        ActivityFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ActivityFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_activity_free(ptr, 0);\n    }\n    /**\n     * @param {string} source\n     * @returns {Activity}\n     */\n    static new(source) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len0 = WASM_VECTOR_LEN;\n            wasm.activity_new(retptr, ptr0, len0);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n            if (r2) {\n                throw takeObject(r1);\n            }\n            return Activity.__wrap(r0);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @returns {string}\n     */\n    description() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.activity_description(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n    /**\n     * @param {Uint8Array} game\n     * @returns {any}\n     */\n    validate_game(game) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passArray8ToWasm0(game, wasm.__wbindgen_malloc);\n            const len0 = WASM_VECTOR_LEN;\n            wasm.activity_validate_game(retptr, this.__wbg_ptr, ptr0, len0);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n            if (r2) {\n                throw takeObject(r1);\n            }\n            return takeObject(r0);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @param {Uint8Array} game\n     * @param {Uint8Array} vpl_palettes\n     * @param {number} step\n     * @param {number} item\n     * @param {number} last_step_reached\n     * @returns {any}\n     */\n    get_hint(game, vpl_palettes, step, item, last_step_reached) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passArray8ToWasm0(game, wasm.__wbindgen_malloc);\n            const len0 = WASM_VECTOR_LEN;\n            const ptr1 = passArray8ToWasm0(vpl_palettes, wasm.__wbindgen_malloc);\n            const len1 = WASM_VECTOR_LEN;\n            wasm.activity_get_hint(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, step, item, last_step_reached);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n            if (r2) {\n                throw takeObject(r1);\n            }\n            return takeObject(r0);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n}\n\nconst AnnotationDataFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_annotationdata_free(ptr >>> 0, 1));\n/**\n * An annotation data struct to be used in IDEs\n */\nexport class AnnotationData {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(AnnotationData.prototype);\n        obj.__wbg_ptr = ptr;\n        AnnotationDataFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        AnnotationDataFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_annotationdata_free(ptr, 0);\n    }\n    /**\n     * @returns {number}\n     */\n    get pos() {\n        const ret = wasm.__wbg_get_annotationdata_pos(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set pos(arg0) {\n        wasm.__wbg_set_annotationdata_pos(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {string}\n     */\n    get hint() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.__wbg_get_annotationdata_hint(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n    /**\n     * @param {string} arg0\n     */\n    set hint(arg0) {\n        const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.__wbg_set_annotationdata_hint(this.__wbg_ptr, ptr0, len0);\n    }\n    /**\n     * @param {number} pos\n     * @param {string} hint\n     */\n    constructor(pos, hint) {\n        const ptr0 = passStringToWasm0(hint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        const ret = wasm.annotationdata_new(pos, ptr0, len0);\n        this.__wbg_ptr = ret >>> 0;\n        AnnotationDataFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n}\n\nconst CompilerFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_compiler_free(ptr >>> 0, 1));\n\nexport class Compiler {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(Compiler.prototype);\n        obj.__wbg_ptr = ptr;\n        CompilerFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        CompilerFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_compiler_free(ptr, 0);\n    }\n    constructor() {\n        const ret = wasm.compiler_new();\n        this.__wbg_ptr = ret >>> 0;\n        CompilerFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n    /**\n     * @param {string} src\n     * @returns {ErrorData[] | undefined}\n     */\n    compile(src) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len0 = WASM_VECTOR_LEN;\n            wasm.compiler_compile(retptr, this.__wbg_ptr, ptr0, len0);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            let v2;\n            if (r0 !== 0) {\n                v2 = getArrayJsValueFromWasm0(r0, r1).slice();\n                wasm.__wbindgen_free(r0, r1 * 4, 4);\n            }\n            return v2;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @param {string} name\n     * @returns {string | undefined}\n     */\n    fn_signature(name) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len0 = WASM_VECTOR_LEN;\n            wasm.compiler_fn_signature(retptr, this.__wbg_ptr, ptr0, len0);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            let v2;\n            if (r0 !== 0) {\n                v2 = getStringFromWasm0(r0, r1).slice();\n                wasm.__wbindgen_free(r0, r1 * 1, 1);\n            }\n            return v2;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @param {string} name\n     * @returns {string | undefined}\n     */\n    fn_signature_without_effects(name) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len0 = WASM_VECTOR_LEN;\n            wasm.compiler_fn_signature_without_effects(retptr, this.__wbg_ptr, ptr0, len0);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            let v2;\n            if (r0 !== 0) {\n                v2 = getStringFromWasm0(r0, r1).slice();\n                wasm.__wbindgen_free(r0, r1 * 1, 1);\n            }\n            return v2;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @returns {string}\n     */\n    run_expr_to_html() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.compiler_run_expr_to_html(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n    /**\n     * @returns {AnnotationData[]}\n     */\n    get_annotations() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.compiler_get_annotations(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var v1 = getArrayJsValueFromWasm0(r0, r1).slice();\n            wasm.__wbindgen_free(r0, r1 * 4, 4);\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @returns {string[]}\n     */\n    list_module_fn_names() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.compiler_list_module_fn_names(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var v1 = getArrayJsValueFromWasm0(r0, r1).slice();\n            wasm.__wbindgen_free(r0, r1 * 4, 4);\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @returns {FunctionSignature[]}\n     */\n    list_module_fns() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.compiler_list_module_fns(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var v1 = getArrayJsValueFromWasm0(r0, r1).slice();\n            wasm.__wbindgen_free(r0, r1 * 4, 4);\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @returns {string[]}\n     */\n    list_module_props() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.compiler_list_module_props(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var v1 = getArrayJsValueFromWasm0(r0, r1).slice();\n            wasm.__wbindgen_free(r0, r1 * 4, 4);\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n}\n\nconst ErrorDataFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_errordata_free(ptr >>> 0, 1));\n/**\n * An error-data structure to be used in IDEs\n */\nexport class ErrorData {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(ErrorData.prototype);\n        obj.__wbg_ptr = ptr;\n        ErrorDataFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ErrorDataFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_errordata_free(ptr, 0);\n    }\n    /**\n     * @returns {number}\n     */\n    get from() {\n        const ret = wasm.__wbg_get_annotationdata_pos(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set from(arg0) {\n        wasm.__wbg_set_annotationdata_pos(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    get to() {\n        const ret = wasm.__wbg_get_errordata_to(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set to(arg0) {\n        wasm.__wbg_set_errordata_to(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {string}\n     */\n    get text() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.__wbg_get_annotationdata_hint(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n    /**\n     * @param {string} arg0\n     */\n    set text(arg0) {\n        const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.__wbg_set_annotationdata_hint(this.__wbg_ptr, ptr0, len0);\n    }\n    /**\n     * @param {number} from\n     * @param {number} to\n     * @param {string} text\n     */\n    constructor(from, to, text) {\n        const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        const ret = wasm.errordata_new(from, to, ptr0, len0);\n        this.__wbg_ptr = ret >>> 0;\n        ErrorDataFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n}\n\nconst ExecOutputFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_execoutput_free(ptr >>> 0, 1));\n\nexport class ExecOutput {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(ExecOutput.prototype);\n        obj.__wbg_ptr = ptr;\n        ExecOutputFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ExecOutputFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_execoutput_free(ptr, 0);\n    }\n    /**\n     * @returns {boolean}\n     */\n    get cont() {\n        const ret = wasm.__wbg_get_execoutput_cont(this.__wbg_ptr);\n        return ret !== 0;\n    }\n    /**\n     * @param {boolean} arg0\n     */\n    set cont(arg0) {\n        wasm.__wbg_set_execoutput_cont(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number | undefined}\n     */\n    get value() {\n        const ret = wasm.__wbg_get_execoutput_value(this.__wbg_ptr);\n        return ret === 0x100000001 ? undefined : ret;\n    }\n    /**\n     * @param {number | null} [arg0]\n     */\n    set value(arg0) {\n        wasm.__wbg_set_execoutput_value(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : (arg0) >> 0);\n    }\n    /**\n     * @param {boolean} cont\n     * @param {number | null} [value]\n     */\n    constructor(cont, value) {\n        const ret = wasm.execoutput_new(cont, isLikeNone(value) ? 0x100000001 : (value) >> 0);\n        this.__wbg_ptr = ret >>> 0;\n        ExecOutputFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n}\n\nconst FunctionSignatureFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_functionsignature_free(ptr >>> 0, 1));\n/**\n * A function signature data struct to be used in IDEs\n */\nexport class FunctionSignature {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(FunctionSignature.prototype);\n        obj.__wbg_ptr = ptr;\n        FunctionSignatureFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        FunctionSignatureFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_functionsignature_free(ptr, 0);\n    }\n    /**\n     * @returns {string}\n     */\n    get name() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.__wbg_get_annotationdata_hint(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n    /**\n     * @param {string} arg0\n     */\n    set name(arg0) {\n        const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.__wbg_set_annotationdata_hint(this.__wbg_ptr, ptr0, len0);\n    }\n    /**\n     * @returns {string[]}\n     */\n    get args() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.__wbg_get_functionsignature_args(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var v1 = getArrayJsValueFromWasm0(r0, r1).slice();\n            wasm.__wbindgen_free(r0, r1 * 4, 4);\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @param {string[]} arg0\n     */\n    set args(arg0) {\n        const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.__wbg_set_functionsignature_args(this.__wbg_ptr, ptr0, len0);\n    }\n    /**\n     * @returns {string | undefined}\n     */\n    get doc() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.__wbg_get_functionsignature_doc(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            let v1;\n            if (r0 !== 0) {\n                v1 = getStringFromWasm0(r0, r1).slice();\n                wasm.__wbindgen_free(r0, r1 * 1, 1);\n            }\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @param {string | null} [arg0]\n     */\n    set doc(arg0) {\n        var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        var len0 = WASM_VECTOR_LEN;\n        wasm.__wbg_set_functionsignature_doc(this.__wbg_ptr, ptr0, len0);\n    }\n}\n\nconst OptScriptVariableFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_optscriptvariable_free(ptr >>> 0, 1));\n\nexport class OptScriptVariable {\n\n    static __unwrap(jsValue) {\n        if (!(jsValue instanceof OptScriptVariable)) {\n            return 0;\n        }\n        return jsValue.__destroy_into_raw();\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        OptScriptVariableFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_optscriptvariable_free(ptr, 0);\n    }\n    /**\n     * @returns {string | undefined}\n     */\n    get name() {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.__wbg_get_optscriptvariable_name(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            let v1;\n            if (r0 !== 0) {\n                v1 = getStringFromWasm0(r0, r1).slice();\n                wasm.__wbindgen_free(r0, r1 * 1, 1);\n            }\n            return v1;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @param {string | null} [arg0]\n     */\n    set name(arg0) {\n        var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        var len0 = WASM_VECTOR_LEN;\n        wasm.__wbg_set_optscriptvariable_name(this.__wbg_ptr, ptr0, len0);\n    }\n    /**\n     * @returns {ScriptVariableType | undefined}\n     */\n    get type() {\n        const ret = wasm.__wbg_get_optscriptvariable_type(this.__wbg_ptr);\n        return ret === 0 ? undefined : ScriptVariableType.__wrap(ret);\n    }\n    /**\n     * @param {ScriptVariableType | null} [arg0]\n     */\n    set type(arg0) {\n        let ptr0 = 0;\n        if (!isLikeNone(arg0)) {\n            _assertClass(arg0, ScriptVariableType);\n            ptr0 = arg0.__destroy_into_raw();\n        }\n        wasm.__wbg_set_optscriptvariable_type(this.__wbg_ptr, ptr0);\n    }\n    /**\n     * @param {string | null} [name]\n     * @param {ScriptVariableType | null} [ty]\n     */\n    constructor(name, ty) {\n        var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n        var len0 = WASM_VECTOR_LEN;\n        let ptr1 = 0;\n        if (!isLikeNone(ty)) {\n            _assertClass(ty, ScriptVariableType);\n            ptr1 = ty.__destroy_into_raw();\n        }\n        const ret = wasm.optscriptvariable_new(ptr0, len0, ptr1);\n        this.__wbg_ptr = ret >>> 0;\n        OptScriptVariableFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n}\n\nconst ScriptCtxFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_scriptctx_free(ptr >>> 0, 1));\n/**\n * The Candli game-related context for compiling and running scripts.\n */\nexport class ScriptCtx {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(ScriptCtx.prototype);\n        obj.__wbg_ptr = ptr;\n        ScriptCtxFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ScriptCtxFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_scriptctx_free(ptr, 0);\n    }\n    /**\n     * Empty constructor to be used for block documentation\n     */\n    constructor() {\n        const ret = wasm.scriptctx_new();\n        this.__wbg_ptr = ret >>> 0;\n        ScriptCtxFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n    /**\n     * Get the game compiler.\n     * @returns {Compiler}\n     */\n    game_script_compiler() {\n        const ret = wasm.scriptctx_game_script_compiler(this.__wbg_ptr);\n        return Compiler.__wrap(ret);\n    }\n    /**\n     * Get the condition block compiler.\n     * @returns {Compiler}\n     */\n    condition_block_script_compiler() {\n        const ret = wasm.scriptctx_condition_block_script_compiler(this.__wbg_ptr);\n        return Compiler.__wrap(ret);\n    }\n    /**\n     * Get the action block compiler.\n     * @returns {Compiler}\n     */\n    action_block_script_compiler() {\n        const ret = wasm.scriptctx_action_block_script_compiler(this.__wbg_ptr);\n        return Compiler.__wrap(ret);\n    }\n    /**\n     * Get the name of the type, given the current game environment.\n     * @param {ScriptVariableType} ty\n     * @returns {string}\n     */\n    type_name(ty) {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            _assertClass(ty, ScriptVariableType);\n            wasm.scriptctx_type_name(retptr, this.__wbg_ptr, ty.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n}\n\nconst ScriptCtxBuilderFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_scriptctxbuilder_free(ptr >>> 0, 1));\n/**\n * A builder to create the script contexts for read and write operations.\n */\nexport class ScriptCtxBuilder {\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ScriptCtxBuilderFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_scriptctxbuilder_free(ptr, 0);\n    }\n    /**\n     * Create an empty context.\n     */\n    constructor() {\n        const ret = wasm.scriptctxbuilder_new();\n        this.__wbg_ptr = ret >>> 0;\n        ScriptCtxBuilderFinalization.register(this, this.__wbg_ptr, this);\n        return this;\n    }\n    /**\n     * Set the variable names for the Candli variables.\n     * Pass empty an string to skip a variable.\n     * @param {OptScriptVariable[]} vars\n     */\n    set_game_variables(vars) {\n        const ptr0 = passArrayJsValueToWasm0(vars, wasm.__wbindgen_malloc);\n        const len0 = WASM_VECTOR_LEN;\n        wasm.scriptctxbuilder_set_game_variables(this.__wbg_ptr, ptr0, len0);\n    }\n    /**\n     * Set the code for a module, attempt to compile it, and if successful\n     * stage it for later addition to the shared module environment.\n     * @param {string} name\n     * @param {string} code\n     */\n    stage_module(name, code) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len0 = WASM_VECTOR_LEN;\n            const ptr1 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len1 = WASM_VECTOR_LEN;\n            wasm.scriptctxbuilder_stage_module(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            if (r1) {\n                throw takeObject(r0);\n            }\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * Commit the staged modules to the shared module environment.\n     */\n    commit_staged_modules() {\n        wasm.scriptctxbuilder_commit_staged_modules(this.__wbg_ptr);\n    }\n    /**\n     * Use the current shared module environment as the game environment.\n     */\n    fix_game_env() {\n        wasm.scriptctxbuilder_fix_game_env(this.__wbg_ptr);\n    }\n    debug_log_content() {\n        wasm.scriptctxbuilder_debug_log_content(this.__wbg_ptr);\n    }\n    /**\n     * Add Candli-related modules to the shared module environment\n     * and return a CandliScriptCtx.\n     * @param {ScriptReadCtx} read_ctx\n     * @param {ScriptWriteCtx} write_ctx\n     * @param {ScriptWorldWriteCtx} world_write_ctx\n     * @param {ScriptAnalyticsReadCtx} analytics_read_ctx\n     * @param {ScriptAnalyticsWriteCtx} analytics_write_ctx\n     * @param {ScriptTextInputReadCtx} text_input_read_ctx\n     * @param {ScriptTextInputWriteCtx} text_input_write_ctx\n     * @param {ScriptSpeechRecognitionReadCtx} speech_read_ctx\n     * @param {ScriptSpeechRecognitionWriteCtx} speech_write_ctx\n     * @param {ScriptLlmReadCtx} llm_read_ctx\n     * @param {ScriptLlmWriteCtx} llm_write_ctx\n     * @param {ScriptPilaReadCtx} pila_read_ctx\n     * @param {ScriptPilaWriteCtx} pila_write_ctx\n     * @returns {ScriptCtx}\n     */\n    to_ctx(read_ctx, write_ctx, world_write_ctx, analytics_read_ctx, analytics_write_ctx, text_input_read_ctx, text_input_write_ctx, speech_read_ctx, speech_write_ctx, llm_read_ctx, llm_write_ctx, pila_read_ctx, pila_write_ctx) {\n        const ptr = this.__destroy_into_raw();\n        const ret = wasm.scriptctxbuilder_to_ctx(ptr, addHeapObject(read_ctx), addHeapObject(write_ctx), addHeapObject(world_write_ctx), addHeapObject(analytics_read_ctx), addHeapObject(analytics_write_ctx), addHeapObject(text_input_read_ctx), addHeapObject(text_input_write_ctx), addHeapObject(speech_read_ctx), addHeapObject(speech_write_ctx), addHeapObject(llm_read_ctx), addHeapObject(llm_write_ctx), addHeapObject(pila_read_ctx), addHeapObject(pila_write_ctx));\n        return ScriptCtx.__wrap(ret);\n    }\n}\n\nconst ScriptValueFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_scriptvalue_free(ptr >>> 0, 1));\n/**\n * A value that can be passed between scripts.\n */\nexport class ScriptValue {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(ScriptValue.prototype);\n        obj.__wbg_ptr = ptr;\n        ScriptValueFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ScriptValueFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_scriptvalue_free(ptr, 0);\n    }\n    /**\n     * @returns {string}\n     */\n    __getClassname() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.scriptvalue___getClassname(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n    /**\n     * @returns {string}\n     */\n    toString() {\n        let deferred1_0;\n        let deferred1_1;\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.scriptvalue_toString(retptr, this.__wbg_ptr);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            deferred1_0 = r0;\n            deferred1_1 = r1;\n            return getStringFromWasm0(r0, r1);\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n        }\n    }\n}\n\nconst ScriptVariableTypeFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_scriptvariabletype_free(ptr >>> 0, 1));\n\nexport class ScriptVariableType {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(ScriptVariableType.prototype);\n        obj.__wbg_ptr = ptr;\n        ScriptVariableTypeFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        ScriptVariableTypeFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_scriptvariabletype_free(ptr, 0);\n    }\n    /**\n     * @param {string} ty_name\n     */\n    constructor(ty_name) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            const ptr0 = passStringToWasm0(ty_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n            const len0 = WASM_VECTOR_LEN;\n            wasm.scriptvariabletype_new(retptr, ptr0, len0);\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);\n            if (r2) {\n                throw takeObject(r1);\n            }\n            this.__wbg_ptr = r0 >>> 0;\n            ScriptVariableTypeFinalization.register(this, this.__wbg_ptr, this);\n            return this;\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n        }\n    }\n    /**\n     * @returns {ScriptValue}\n     */\n    default_value() {\n        const ret = wasm.scriptvariabletype_default_value(this.__wbg_ptr);\n        return ScriptValue.__wrap(ret);\n    }\n    /**\n     * @returns {ScriptVariableType}\n     */\n    clone() {\n        const ret = wasm.scriptvariabletype_clone(this.__wbg_ptr);\n        return ScriptVariableType.__wrap(ret);\n    }\n    /**\n     * @param {ScriptVariableType} other\n     * @returns {boolean}\n     */\n    is_equal(other) {\n        _assertClass(other, ScriptVariableType);\n        const ret = wasm.scriptvariabletype_is_equal(this.__wbg_ptr, other.__wbg_ptr);\n        return ret !== 0;\n    }\n}\n\nconst SpriteFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_sprite_free(ptr >>> 0, 1));\n/**\n * A sprite on a sprite sheet\n */\nexport class Sprite {\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        SpriteFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_sprite_free(ptr, 0);\n    }\n}\n\nconst SpriteLocationFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_spritelocation_free(ptr >>> 0, 1));\n/**\n * Location of a sprite on a sprite sheet\n */\nexport class SpriteLocation {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(SpriteLocation.prototype);\n        obj.__wbg_ptr = ptr;\n        SpriteLocationFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        SpriteLocationFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_spritelocation_free(ptr, 0);\n    }\n    /**\n     * @returns {number}\n     */\n    get index() {\n        const ret = wasm.__wbg_get_spritelocation_index(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set index(arg0) {\n        wasm.__wbg_set_spritelocation_index(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    get x_min() {\n        const ret = wasm.__wbg_get_spritelocation_x_min(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set x_min(arg0) {\n        wasm.__wbg_set_spritelocation_x_min(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    get y_min() {\n        const ret = wasm.__wbg_get_spritelocation_y_min(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set y_min(arg0) {\n        wasm.__wbg_set_spritelocation_y_min(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    get x_max() {\n        const ret = wasm.__wbg_get_spritelocation_x_max(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set x_max(arg0) {\n        wasm.__wbg_set_spritelocation_x_max(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    get y_max() {\n        const ret = wasm.__wbg_get_spritelocation_y_max(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set y_max(arg0) {\n        wasm.__wbg_set_spritelocation_y_max(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    get count() {\n        const ret = wasm.__wbg_get_spritelocation_count(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} arg0\n     */\n    set count(arg0) {\n        wasm.__wbg_set_spritelocation_count(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {bigint}\n     */\n    get x_sum() {\n        const ret = wasm.__wbg_get_spritelocation_x_sum(this.__wbg_ptr);\n        return BigInt.asUintN(64, ret);\n    }\n    /**\n     * @param {bigint} arg0\n     */\n    set x_sum(arg0) {\n        wasm.__wbg_set_spritelocation_x_sum(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {bigint}\n     */\n    get y_sum() {\n        const ret = wasm.__wbg_get_spritelocation_y_sum(this.__wbg_ptr);\n        return BigInt.asUintN(64, ret);\n    }\n    /**\n     * @param {bigint} arg0\n     */\n    set y_sum(arg0) {\n        wasm.__wbg_set_spritelocation_y_sum(this.__wbg_ptr, arg0);\n    }\n    /**\n     * @returns {number}\n     */\n    width() {\n        const ret = wasm.spritelocation_width(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @returns {number}\n     */\n    height() {\n        const ret = wasm.spritelocation_height(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @returns {number}\n     */\n    radiusOfShape() {\n        const ret = wasm.spritelocation_radiusOfShape(this.__wbg_ptr);\n        return ret;\n    }\n    /**\n     * @returns {number}\n     */\n    localCx() {\n        const ret = wasm.spritelocation_localCx(this.__wbg_ptr);\n        return ret;\n    }\n    /**\n     * @returns {number}\n     */\n    localCy() {\n        const ret = wasm.spritelocation_localCy(this.__wbg_ptr);\n        return ret;\n    }\n}\n\nconst SpriteRowFinalization = (typeof FinalizationRegistry === 'undefined')\n    ? { register: () => {}, unregister: () => {} }\n    : new FinalizationRegistry(ptr => wasm.__wbg_spriterow_free(ptr >>> 0, 1));\n\nexport class SpriteRow {\n\n    static __wrap(ptr) {\n        ptr = ptr >>> 0;\n        const obj = Object.create(SpriteRow.prototype);\n        obj.__wbg_ptr = ptr;\n        SpriteRowFinalization.register(obj, obj.__wbg_ptr, obj);\n        return obj;\n    }\n\n    __destroy_into_raw() {\n        const ptr = this.__wbg_ptr;\n        this.__wbg_ptr = 0;\n        SpriteRowFinalization.unregister(this);\n        return ptr;\n    }\n\n    free() {\n        const ptr = this.__destroy_into_raw();\n        wasm.__wbg_spriterow_free(ptr, 0);\n    }\n    /**\n     * @returns {number}\n     */\n    get y() {\n        const ret = wasm.spriterow_y_f32(this.__wbg_ptr);\n        return ret;\n    }\n    /**\n     * @returns {number}\n     */\n    get spriteCount() {\n        const ret = wasm.spriterow_sprite_count(this.__wbg_ptr);\n        return ret >>> 0;\n    }\n    /**\n     * @param {number} index\n     * @returns {SpriteLocation}\n     */\n    spriteLocation(index) {\n        const ret = wasm.spriterow_spriteLocation(this.__wbg_ptr, index);\n        return SpriteLocation.__wrap(ret);\n    }\n    /**\n     * @param {number} index\n     * @param {any} ctx\n     */\n    copySprite(index, ctx) {\n        try {\n            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n            wasm.spriterow_copySprite(retptr, this.__wbg_ptr, index, addBorrowedObject(ctx));\n            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n            if (r1) {\n                throw takeObject(r0);\n            }\n        } finally {\n            wasm.__wbindgen_add_to_stack_pointer(16);\n            heap[stack_pointer++] = undefined;\n        }\n    }\n}\n\nexport function __wbg_annotationdata_new(arg0) {\n    const ret = AnnotationData.__wrap(arg0);\n    return addHeapObject(ret);\n};\n\nexport function __wbg_apply_36be6a55257c99bf() { return handleError(function (arg0, arg1, arg2) {\n    const ret = getObject(arg0).apply(getObject(arg1), getObject(arg2));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_apply_eb9e9b97497f91e4() { return handleError(function (arg0, arg1, arg2) {\n    const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_buffer_609cc3eee51ed158(arg0) {\n    const ret = getObject(arg0).buffer;\n    return addHeapObject(ret);\n};\n\nexport function __wbg_call_672a4d21634d4a24() { return handleError(function (arg0, arg1) {\n    const ret = getObject(arg0).call(getObject(arg1));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_call_7cccdd69e0791ae2() { return handleError(function (arg0, arg1, arg2) {\n    const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_call_833bed5770ea2041() { return handleError(function (arg0, arg1, arg2, arg3) {\n    const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_call_b8adc8b1d0a0d8eb() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {\n    const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_data_d1ed736c1e42b10e(arg0, arg1) {\n    const ret = getObject(arg1).data;\n    const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);\n    const len1 = WASM_VECTOR_LEN;\n    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n};\n\nexport function __wbg_errordata_new(arg0) {\n    const ret = ErrorData.__wrap(arg0);\n    return addHeapObject(ret);\n};\n\nexport function __wbg_from_2a5d3e218e67aa85(arg0) {\n    const ret = Array.from(getObject(arg0));\n    return addHeapObject(ret);\n};\n\nexport function __wbg_functionsignature_new(arg0) {\n    const ret = FunctionSignature.__wrap(arg0);\n    return addHeapObject(ret);\n};\n\nexport function __wbg_get_67b2ba62fc30de12() { return handleError(function (arg0, arg1) {\n    const ret = Reflect.get(getObject(arg0), getObject(arg1));\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_get_b9b93047fe3cf45b(arg0, arg1) {\n    const ret = getObject(arg0)[arg1 >>> 0];\n    return addHeapObject(ret);\n};\n\nexport function __wbg_height_1d93eb7f5e355d97(arg0) {\n    const ret = getObject(arg0).height;\n    return ret;\n};\n\nexport function __wbg_log_c222819a41e063d3(arg0) {\n    console.log(getObject(arg0));\n};\n\nexport function __wbg_new_405e22f390576ce2() {\n    const ret = new Object();\n    return addHeapObject(ret);\n};\n\nexport function __wbg_new_78feb108b6472713() {\n    const ret = new Array();\n    return addHeapObject(ret);\n};\n\nexport function __wbg_new_a12002a7f91c75be(arg0) {\n    const ret = new Uint8Array(getObject(arg0));\n    return addHeapObject(ret);\n};\n\nexport function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a(arg0, arg1, arg2) {\n    const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);\n    return addHeapObject(ret);\n};\n\nexport function __wbg_newwithu8clampedarrayandsh_7ea6ee082a25bc85() { return handleError(function (arg0, arg1, arg2, arg3) {\n    const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);\n    return addHeapObject(ret);\n}, arguments) };\n\nexport function __wbg_optscriptvariable_unwrap(arg0) {\n    const ret = OptScriptVariable.__unwrap(takeObject(arg0));\n    return ret;\n};\n\nexport function __wbg_push_737cfc8c1432c2c6(arg0, arg1) {\n    const ret = getObject(arg0).push(getObject(arg1));\n    return ret;\n};\n\nexport function __wbg_putImageData_4c5aa10f3b3e4924() { return handleError(function (arg0, arg1, arg2, arg3) {\n    getObject(arg0).putImageData(getObject(arg1), arg2, arg3);\n}, arguments) };\n\nexport function __wbg_scriptvalue_new(arg0) {\n    const ret = ScriptValue.__wrap(arg0);\n    return addHeapObject(ret);\n};\n\nexport function __wbg_set_37837023f3d740e8(arg0, arg1, arg2) {\n    getObject(arg0)[arg1 >>> 0] = takeObject(arg2);\n};\n\nexport function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {\n    getObject(arg0)[takeObject(arg1)] = takeObject(arg2);\n};\n\nexport function __wbg_spriterow_new(arg0) {\n    const ret = SpriteRow.__wrap(arg0);\n    return addHeapObject(ret);\n};\n\nexport function __wbg_width_b0c1d9f437a95799(arg0) {\n    const ret = getObject(arg0).width;\n    return ret;\n};\n\nexport function __wbindgen_boolean_get(arg0) {\n    const v = getObject(arg0);\n    const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;\n    return ret;\n};\n\nexport function __wbindgen_debug_string(arg0, arg1) {\n    const ret = debugString(getObject(arg1));\n    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n    const len1 = WASM_VECTOR_LEN;\n    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n};\n\nexport function __wbindgen_is_function(arg0) {\n    const ret = typeof(getObject(arg0)) === 'function';\n    return ret;\n};\n\nexport function __wbindgen_is_null(arg0) {\n    const ret = getObject(arg0) === null;\n    return ret;\n};\n\nexport function __wbindgen_is_object(arg0) {\n    const val = getObject(arg0);\n    const ret = typeof(val) === 'object' && val !== null;\n    return ret;\n};\n\nexport function __wbindgen_is_undefined(arg0) {\n    const ret = getObject(arg0) === undefined;\n    return ret;\n};\n\nexport function __wbindgen_memory() {\n    const ret = wasm.memory;\n    return addHeapObject(ret);\n};\n\nexport function __wbindgen_number_get(arg0, arg1) {\n    const obj = getObject(arg1);\n    const ret = typeof(obj) === 'number' ? obj : undefined;\n    getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);\n    getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);\n};\n\nexport function __wbindgen_number_new(arg0) {\n    const ret = arg0;\n    return addHeapObject(ret);\n};\n\nexport function __wbindgen_object_clone_ref(arg0) {\n    const ret = getObject(arg0);\n    return addHeapObject(ret);\n};\n\nexport function __wbindgen_object_drop_ref(arg0) {\n    takeObject(arg0);\n};\n\nexport function __wbindgen_string_get(arg0, arg1) {\n    const obj = getObject(arg1);\n    const ret = typeof(obj) === 'string' ? obj : undefined;\n    var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n    var len1 = WASM_VECTOR_LEN;\n    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n};\n\nexport function __wbindgen_string_new(arg0, arg1) {\n    const ret = getStringFromWasm0(arg0, arg1);\n    return addHeapObject(ret);\n};\n\nexport function __wbindgen_throw(arg0, arg1) {\n    throw new Error(getStringFromWasm0(arg0, arg1));\n};\n\n"],"names":["async","checkBrowserAndWarnUser","requiresIndexDB","allowOnlySafariOnIOS","ok","isSupported","browserName","browserVersion","requiredVersion","downloadLink","osName","isIDB","e","isIndexDBAvailable","appInfo","window","location","href","browserSupported","title","text","args","textRunning","textUpgrade1","textUpgrade2","textNew1","textNew2","map","b","toLowerCase","join","SupportedBrowsersVersions","chrome","edge","firefox","safari","samsung_internet","SupportedBrowsers","webPSupported","browserOk","appleDevice","browserNameLowercase","checkUserAgent","userAgent","navigator","browser","getBrowserName","getBrowserVersion","getOSName","console","debug","getOSVersion","getPlatformType","browserLower","versionBounds","satisfies","isBrowserOk","getBrowserNameLowercase","checkWebPFeature","feature","testImages","lossy","lossless","alpha","animation","img","Image","Promise","resolve","onload","result","width","height","onerror","src","isWebPSupported","undefined","all","then","DeprecatedWorkspaceKeys","DeviceWorkspaceIdKey","FirstUseKey","FirstUseTimestamp","localStorage","getItem","setItem","Date","toISOString","isFirstUse","WorkspaceNamespace","getDeviceWorkspaceId","ws","deprecatedWorkspaceIdKey","removeItem","getWorkspaceId","overriddenPrimaryWorkspace","primaryWorkspaceIdFromUrl","loggedInUserInfo","primaryWs","deviceWorkspaceId","newWorkspaceId","toString","drawScoreIcon","ctx","xC","yC","d","save","translate","scale","fill","Path2D","restore","createCenteredTextCanvas","color","canvas","usabeWidth","ranges","textWidth","selectedSize","size","font","measureText","metrics","h","actualBoundingBoxAscent","actualBoundingBoxDescent","fillStyle","lines","rows","Math","min","length","forEach","line","_","i","y","fillText","x","miniatureCache","Map","getVariableMiniature","textOrName","white","variableName","image","name","miniatures","get","set","ComparisonOperation","ComparisonInputSide","ValueAbbreviatedText","ValueText","TheValueText","ComparisonText","operationToText","operation","EQUAL","GREATER_THAN","LESS_THAN","NOT_EQUAL","LESS_THAN_OR_EQUAL_TO","GREATER_THAN_OR_EQUAL_TO","flipOperation","ComparisonBlock","address","value","inputSide","constructor","addressOrFbVariable","valueOrFromVersion","LEFT","lockState","super","this","scope","index","validate","clone","inputValuePortPresence","summaryText","_userContext","valueIn","operationText","detailedTextIfConfigured","userContext","game","serialise","builder","createComparison","fbConditionType","Comparison","kind","getMiniatureKey","rhs","ButtonNames","InputBlock","button","player","buttonOrFbButton","number","createInputButton","InputButton","twoPlayers","keyboardCodes","keyCodeToInputNumber","which","keyCode","codes","Array","code","numpadCodes","numpadCodeToInputNumber","isBinaryOperationValid","op","lhs","Number","isFinite","DIV","IDIV","REM","POW","isInteger","LOG","executeBinaryOperation","ADD","SUB","MUL","pow","log","MIN","MAX","max","operationToSymbol","formatInput","input","addressOrValue","INPUT","VARIABLE","LITERAL","formatInputLong","BinaryArithmeticBlock","lInput","lAddressOrValue","rInput","rAddressOrValue","opOrFbBinaryArithmetic","fbBinaryArithmetic","lAddress","lValue","rAddress","rValue","outputValuePortPresence","createBinaryArithmetic","fbGenericType","BinaryArithmetic","premium","needsConfiguration","needsConfigurationFix","CurrentDataVersion","OldestLoadableDataVersion","decodeFbRow","fbRule","fromVersion","movementLocked","conditionsExtendLocked","actionsExtendLocked","conditionsToFb","conditions","objectTypes","keepLocking","condition","block","conditionType","serialized","genericType","GenericBlock_GenericBlockContainer","createGenericBlockContainer","createCondition","inverted","parametersLocked","actionsToFb","actions","action","actionType","fbActionType","createAction","AnimationFrame","sprite","partFromPixelTransform","spriteOrFbAnimationFrame","partFromPixelTransformOrImageDecoder","fbAnimationFrame","imageDecoder","textureImageIndex","resolution","scaleFactor","spriteSize","multScalar","maxExtent","transformAsAABB","maxAbsCoord","imageIndices","startAnimationFrame","addTextureImageIndex","addPartFromPixelTransform","endAnimationFrame","newCenteredWithResolution","scaling","translation","scalingTranslation","newWithCenterAndResolution","center","assertEqual","that","Animation","frames","fps","framesOrFbAnimation","nameOrImageDecoder","fbAnimation","frameCount","duration","frame","isVirgin","framesOffset","createFramesVector","nameOffset","createString","startAnimation","addFrames","addName","addFps","endAnimation","boundingRectOfShape","shape","fromPoints","fromCenterAndSize","shapeToPolygon","shapeHalfSize","points","radius","angle","PI","push","cos","sin","serializeRow","rule","createRule","createConditionsVector","createActionsVector","ObjectType","static","id","roles","behaviour","_kind","stickiness","bounciness","density","_canRotate","_shape","animations","lastScale","lastRotation","editLocked","deleteLocked","instantiationLocked","_boundingRadius","kindOrFbObjectType","firstFrameOrAnimsOrImageDecoder","shapeOrRoleNames","newId","fbObjectType","roleNames","Set","roleIndex","valueOf","isNaN","canRotate","partsType","SinglePartBody","singlePartBody","parts","animationsLength","pixelToBodyTransform","editorLastTransform","editionLocked","deletionLocked","recomputedCachedValues","sqrt","reduce","maxRadius2","p","norm2","norm","boundingRadius","firstAnimation","firstFrame","quickFirst","newFrame","allFrames","firstFrames","namedAnimations","flatMap","nonNullName","idSafeName","replace","nameOrIndex","objects","indexOf","objectIndex","objectOfType","anObjectOfType","animName","nameOrRoles","role","_maxId","deserialiseBehaviours","animationsOffset","createAnimationsVector","shapeType","shapeOffset","startSinglePartBody","addShapeType","addShape","addAlpha","addAnimations","addPixelToBodyTransform","singlePartBodyOffset","endSinglePartBody","behaviourOffset","createBehaviourVector","rolesIndices","rolesOffset","createRolesVector","startObjectType","addStickiness","addBounciness","addDensity","addRoles","addCanRotate","addEditorLastTransform","addBehaviour","addPartsType","addParts","addKind","addEditionLocked","addDeletionLocked","addInstantiationLocked","endObjectType","val","key","point","cloneDetached","polygonShape","polygonShapeOrRadius","isDynamic","entries","brakeAction","speedAction","angularSpeedAction","mode","keptActions","isCollidable","isNotBackground","isNotForeground","hasAnimations","conditionsCount","sum","actionsCount","fullyLocked","blocksIterator","category","element","conditionsIterator","actionsIterator","blocksIteratorByType","type","blockT","conditionsIteratorByType","actionsIteratorByType","blocksCount","count","conditionsNeedingConfiguration","actionsNeedingConfiguration","emptyConditionsCount","suppressedCount","effectSuppressedActions","warningsCount","collectMusicAtmospheres","atmospheres","musicBlock","atmosphere","add","moveAnimation","from","to","deleteAnimation","delIndex","countAnimationBlocks","counts","inc","resetMaxId","setAvailability","disabled","path","setCodeAvailability","slice","warn","row","setCodeRowAvailability","rowIndex","indexes","indexOrInterval","isArray","property","setCodeBlocksAvailability","unset","blocks","selectedBlocks","blockIndex","resetAvailability","KindStrings","kindFromString","s","Camera","extent","trackedObjectOrPosition","_backgroundColor","_backgroundColorRgbHexString","freeMotionBoxFractions","centerDisplacement","fbCamera","objectInstances","fromScalar","backgroundColor","extentX","extentY","trackedObjectOrPositionType","CameraTrackedObject","cameraTrackedObject","instance","CameraPosition","cameraPosition","position","fromRgbNumber","bgra","rgbHexString","backgroundColorRgbHexString","pose","trackedObject","ObjectInstance","isAttached","extentAspectRatio","trackedObjectOrPositionOffset","createCameraTrackedObject","createCameraPosition","startCamera","addExtentX","addExtentY","addTrackedObjectOrPositionType","addTrackedObjectOrPosition","addBackgroundColor","addFreeMotionBoxFractions","addCenterDisplacement","endCamera","copyLocked","selectionLocked","variables","typeOrFbObjectInstance","poseOrObjectTypes","poseAndScale","variableArray","fbVariable","fullyEditable","fullyEditableAndSelectable","setFullyEditableAndSelectable","setFullyEditAndSelectionLocked","aabb","startVariablesVector","reverse","createVariableIndexAndValue","endVector","startObjectInstance","addPoseAndScale","addType","addMovementLocked","addCopyLocked","addSelectionLocked","addVariables","endObjectInstance","duplicate","newObject","areInstanceSameKindAndDoTheyOverlap","instance0","instance1","dist","Level","editorScale","editorPosition","camera","gravity","airFriction","fbLevel","editorToWorld","invScale","editorInvScale","objectInstancesOffset","createObjectInstancesVector","object","cameraOffset","buildObjectInstanceIdMap","startLevel","addObjectInstances","addCamera","addGravity","addAirFriction","addEditorToWorld","endLevel","frozenInstanceClone","level","newInstances","newInstance","deleteObjectInstance","indexOrObjectInstance","splice","computeSceneBounds","bounds","objectBound","union","computeWorldBounds","iterateObjectInstances","frontToBack","layers","layer","modifyObjectInstances","filter","countInstancesOfType","getClosestInstanceOfType","bestInstance","bestDist2","MAX_VALUE","o","dist2","moveInstanceZUp","moveInstanceZDown","target","oi","targetSet","has","Dialog","imageOrFbDialog","backgroundColorOrImageDecoder","imageIndex","createDialog","VariableName","imageOrNameOrIndexOrFb","typeName","scriptCtx","type_name","typeOffset","startVariableName","addImageIndex","endVariableName","assertScriptVariableTypeEqual","is_equal","Variable","visible","ScriptModule","fbScriptModuleOrName","codeOffset","startScriptModule","addCode","endScriptModule","ScriptPackage","locator","parseDependencyPath","owner","packageName","version","CoreGame","dataVersion","dialogs","sounds","scriptPackages","scriptModules","limitOverrides","limitOverridesDuplicationCounter","fbGame","scripts","recompileGameScripts","imgDecoder","Error","variableVisibility","oldVarNameLength","oldVariableNamesLength","variableNames","variableNamesLength","levelsCount","levelsLength","levels","limitLimitOverrides","fbLimit","validLimit","limitOverrideDuplicationCounter","set_game_variables","variable","script","stage_module","error","commit_staged_modules","fix_game_env","to_ctx","getCandliVariable","getScriptVariable","randInt","setCandliVariable","setScriptVariable","checkPoint","openURL","clearCanvas","drawText","drawLine","drawRect","fillRect","drawEllipse","fillEllipse","setFontSize","setTextAlignment","setTextColor","setStrokeColor","setFillColor","attachCamera","spawn","sessionId","active","start","stop","hasResult","hasError","getResult","getError","hasResponse","newConversation","ask","getResponse","getPilaCompetency","setPilaCompetency","replaceWith","serialiseChildren","objectTypeIdMap","buildObjectTypeIdMap","collectRoleNames","createObjectTypesVector","createLevelsVector","createDialogsVector","dialog","createVariableNamesVector","createVariableVisibilityVector","createRoleNamesVector","roleName","scriptDependencies","createScriptDependenciesVector","dependency","createScriptModulesVector","module","createLimitOverridesVector","createLimitOverride","serialiseSelf","offsets","addDataVersion","addObjectTypes","addLevels","addDialogs","addTwoPlayers","addVariableNames","addVariableVisibility","addRoleNames","addScriptDependencies","addScriptModules","addLimitOverrides","addLimitOverrideDuplicationCounter","collectImageIndices","insert","drawable","endScreen","roleNamesWithDup","flat","consumeOneLimitOverrideDuplication","clear","objectTypeByName","objectTypesFromNameOrRole","nameOrRole","acceptLocking","j","k","blockWithContextIterator","categories","objectTypeIndex","objectType","ruleIndex","blockIterator","contextualisedBlock","blockOfTypeIterator","hasAnyBlockOfType","getActiveInputButtons","bitMask","eventBlock","inputBlock","findObjectTypeByName","countReferenceToTypeInBlocks","hasReferencesToObjectType","duplicateObjectType","indexOrObjectType","deleteObjectType","newLevelObjects","objectInstance","releaseReferencesToObjectType","endScreenImages","deleteDialog","screen","deleteSound","variableNameIndex","v","variableNameImages","fallback","allNamedVariables","deleteVariableName","rewriteAddress","obj","propName","varIndex","varNameIndex","compareVariableBlock","changeVariableBlock","readVariableBlock","binaryArithmeticBlock","recompileAllScripts","renameCandliVariableInScriptBlocks","oldName","newName","scriptBlock","renameVariable","setupCompiler","compile","otsFromNameOrRole","otName","restOfPath","objectTypeIndexFromId","ot","interval","match","parseInt","isPointInShape","polygon","pointB","pointA","segmentPerpAB","sub","perp","segmentAP","dot","ax","abs","ay","unionConvexHulls","a","cross","sort","lower","pop","upper","concat","convexHull","TwoPI","normalizeAngle","normalizeAngleAround0","nAngle","normalizeDegreesAround0","clamp","approximateEqual","relTolerance","absTolerance","absDiff","Matrix","cols","data","Float32Array","identity","dimOrResult","dim","dataRowMajor","at","col","checkBoundary","atUnchecked","indexAtUnchecked","setUnchecked","checkMatchingSize","fold","functor","initial","acc","fold2Unchecked","unaryElementsUnchecked","binaryElementsUnchecked","createEmptyOfSameSize","unaryOperation","bind","cloneUnchecked","absUnchecked","minimum","Infinity","maximum","minUnchecked","maxUnchecked","addUnchecked","subUnchecked","divElements","divElementsUnchecked","multElements","multElementsUnchecked","mult","multUnchecked","multScalarUnchecked","transpose","transposeUnchecked","round","roundUnchecked","floor","floorUnchecked","ceil","ceilUnchecked","isEqual","isApproxEqual","delta","isZero","rowStrings","Vector2","xOrArray","unitX","unitY","zeros","ones","fromRotation","fromAngleAndLength","xx","yy","yx","negateX","negateY","atan2","aspectRatio","sign","minXY","maxXY","addXY","subXY","divXY","multXY","rotate","rotate90deg","normalized","unit","perpUnit","normal","isInRect","rxOrPos","ryOrSize","rWidth","rHeight","assertVector2","px","py","w","projectIntoRect","topRightCorner","rectangleCenterRayIntersectionLength","rayDirection","intersectionPoint","ScalingRotation","rotationAngle","toSimilarityTransform","SimilarityTransform","translationX","translationY","rotationDegrees","apply","sx","sy","rx","ry","applyInverted","inverse","invRotation","after","other","eps","angleD","deg","toGLMat3","mat3","toHomMatrix","rotation","scalingRotation","se2","assertSimilarityTransform","transformVectors2","transform","GameNamespace","search","DNS","AssetNamespace","GameSessionNamespace","createUUID","namespace","createUUIDString","LinearDampingFactor","AngularDampingFactor","MaxSpawnedInstanceCount","toVec2","vec","Vec2","toVector2","toVec2Array","vecs","getShapeCenter","xf","AABB","computeAABB","getCenter","projectPointToShape","c","p1","p2","maxFraction","output","fraction","rayCast","contactToWorldManifold","contact","worldManifold","getWorldManifold","fixtureA","getFixtureA","fixtureB","getFixtureB","shapeA","getShape","shapeB","bodyA","getBody","bodyB","xfA","getTransform","xfB","manifold","Manifold","evaluate","getRadius","insideA","testPoint","insideB","getContactPoints","getContactPoint","accP","curP","mul","createFixtureDef","flippedX","flippedY","hasCollisionWithSomeone","neverCollide","Box","Polygon","Circle","userData","friction","restitution","isSensor","filterMaskBits","getBodyTransform","body","getFixtureList","getUserData","getPosition","getAngle","AnimationData","startTime","frameIndex","backward","bounce","endMode","currentTime","Loop","animate","otAnimation","inFrameCount","frameProjF","loop","ReturnToIdle","Stay","BodyData","zOrder","_rulesCheckedAtLeastOnce","_stepRunAtLeastOnce","rulesActiveAtLastStep","cachedConditionResults","flippingFactors","touchedAsNew","canvasOverlay","canvasAttributes","flipX","flipY","wereRulesCheckedAtLeastOnce","markRulesCheckedAtLeastOnce","wasStepRunAtLeastOnce","markStepRunAtLeastOnce","flip","currentAnimation","ObjectTypeProperties","hasSpeedBlocks","hasDeleteBlocks","collideWithNonObject","hasTouchBlocks","displayBoxHalfSize","levelInstanceCount","instanceCount","imageHull","frameHull","fullyContained","hx","hy","some","collisionBlock","C","others","ContactPoint","_point","getOtherBody","Runtime","gameId","dialogCallback","textInput","world","worldBounds","lastStepTime","scriptedBodies","animatedBodies","contactMaps","objectTypesProperties","currentDeltaT","targetCamera","targetCameraPos","currentCamera","cameraExtent","cameraVelocityOld","maxZ","buttonState","touchingPoints","perfStatWindow","perfStateIndex","gameVariables","gameVariablesChanged","checkPoints","contactCallback","canvasRenderActions","worldContacts","unknownActionExceptionFired","unknownConditionExceptionFired","unknownScopeExceptionFired","unknownVarOpExceptionFired","invalidVarWriteExceptionFired","invalidVarReadExceptionFired","World","listWorldContacts","worldTime","gameSessionId","perfStats","totalTime","cur","score","displacedCurrentCamera","eatGameVariablesChanged","step","timestamp","miniStepCb","miniStep","deltaT","updateContactMap","executeRules","updateCameraPosition","updateAnimations","idealDeltaT","MaxStepDuration","miniStepCount","miniStepDeltaT","toDeleteBodies","toExecute","bodyData","updateTouches","rulesActiveAtThisStep","wereRulesCheckedBefore","isEmpty","checkConditions","isFirstExecution","executeActions","bodyIterator","getBodyList","worldBoundTopLeft","topLeft","worldBoundSize","minX","minY","maxX","maxY","pos","getNext","destroyObject","newTouchedAsNew","isNew","contacts","conditionIndex","initCondition","inputCondition","touchCondition","collisionCondition","timerCondition","comparisonCondition","animationIsCondition","randomValueBlock","scriptGenericBlock","scriptConditionBlock","lastValue","thisTest","cp","localColVector","collidesAtAngle","otherBody","timeAtEnd","elapsed","period","repeat","repeating","leftInput","rightLastValue","getVariableAsNumber","getRandomValue","logCtx","run","actionIndex","stopAction","deleteAction","changeVariableAction","spawnAction","flipAction","teleportAction","showDialogAction","vibrateAction","musicAction","restartTimerAction","soundAction","animationAction","scriptActionBlock","factor","rotatedVec","vector","relative","compatFixedMagnitude","getType","applyLinearImpulse","getMass","getWorldCenter","applyForce","setLinearVelocity","getLinearVelocity","amount","applyAngularImpulse","getInertia","applyTorque","setAngularVelocity","getAngularVelocity","brakeFactor","intensity","SET","setVariable","thatObjectType","thisAngle","velocity","skinRadius","spawnDist","orientation","spawnVector","velocityFactor","compatFixedChildVelocity","spawnedVelocity","speed","rotVelocity","childOrientationFlip","childOrientation","childScale","createObject","getAbsoluteFlip","fixture","destroyFixtures","addFixtures","setAwake","beacon","useBeacon","closestDist2","lengthSquared","moveCamera","doTranslation","teleportCameraTo","doScaling","extentRatio","deltaPos","setPosition","doRotation","setAngle","endGame","vibrate","g","setAtmosphere","timeConstant","gains","relativePos","trackedCameraPos","fadingFactors","sound","gain","pan","playSound","curTrackedCameraPos","deltaTrackedCameraPos","variableNameToIndex","nameIndex","getGameVariableByIndex","getGameVariableByName","getObjectTypeVariableByIndex","getObjectTypeVariableByName","getObjectInstanceVariableByIndex","getObjectInstanceVariableByName","instanceId","getVariableByScopeAndIndex","getVariable","checkVariableValidityForIndex","setGameVariableByIndex","setObjectTypeVariableByIndex","setObjectInstanceVariableByIndex","setVariableByScopeAndIndex","addCanvasRenderAction","startTextInput","initiator","stopTextInput","textInputActive","textInputContent","textInputInitiator","getBinaryInputValue","prevValue","inputToMin","otProperties","objectTypeProperties","displayFixtureDef","createFixture","destroyFixture","thatSet","thatBody","thatBodyData","listSingleContact","_body","isCameraBodyCentered","Body","extentDist","lookAheadDir","lookAheadDelta","lookAheadDist","lookAheadMaxDist","lookAheadClamped","trackedPos","trackedPoseWithLookAhead","freeMotionBoxTopRightCorner","useFreeMotionBox","relativeTrackedPoseWithLookAhead","requiredCameraShift","diff","corrDist","cameraAccClamped","cameraVelocityClamped","cameraToObject","cameraToObjectDist","cameraToObjectMaxDist","distRatio","initialVariables","initialVelocity","hasInitialVelocity","hasMovement","physicsType","gravityScale","worldDamping","bodyDef","fixedRotation","allowSleep","awake","linearDamping","angularDamping","linearVelocity","bullet","createBody","delete","destroyBody","objectTypeProperty","gameHasChangeScoreBlocks","initWorld","forceFakeMusic","on","preSolveContact","editorObject","stopWorld","getContactList","contactPoint","thisBody","contactSet","_oldManifold","toTest","setEnabled","RustDbFbsReadStorage","db","assetSerializer","gameDb","gameNamesDb","getBinaryMap","Game","getMap","getAttribute","getWorkspace","insecure","getCounter","loadGameBinary","gameKey","Uint8Array","miniatureReadURI","getMiniatureReadURI","getGameName","imageAssets","imageManager","soundAssets","soundManager","storePendingAssetsAndReturnSuccess","listAssets","RustDbFbsReadOnlyStorage","getBinaryWithContentTypeMap","setAttribute","_name","_value","saveGame","_game","saveNewBinaryGame","_binaryGame","setGameName","_gameKey","_gameName","createFixedSizeFloat32Array","n","buildFixedSizeFloat32Array","f","buildRangeArray","asFixedSizeArray","message","toIndex","iterConstFixedSizeArray","iterIndex","genIndex","applyToConstArrayIfLargeEnough","array","isBitMaskSet","bitSet","mask","isBitSet","bit","setBitValue","ImageContentTypes","decodeImageBrowser","encodedOrURL","blob","Blob","URL","createObjectURL","decode","drawImage","getImageData","preMultiplyAlpha","imageData","preMultData","Uint8ClampedArray","ImageData","applyTransform","drawCanvasInBox","sourceAspectRatio","box","draw","drawCanvasRotatedInBox","maxSrcSize","ratio","createFallbackCanvas","strokeStyle","lineWidth","beginPath","rect","stroke","substring","wasm","__wbg_set_wasm","heap","heap_next","addHeapObject","idx","getObject","handleError","__wbindgen_exn_store","cachedUint8ArrayMemory0","getUint8ArrayMemory0","byteLength","memory","buffer","WASM_VECTOR_LEN","passArray8ToWasm0","arg","malloc","ptr","cachedDataViewMemory0","getDataViewMemory0","detached","DataView","cachedUint8ClampedArrayMemory0","getClampedArrayU8FromWasm0","len","subarray","takeObject","ret","dropObject","debugString","description","builtInMatches","exec","call","className","JSON","stringify","stack","cachedTextEncoder","TextEncoder","require","encodeString","encodeInto","view","buf","encode","read","written","passStringToWasm0","realloc","mem","offset","charCodeAt","isLikeNone","cachedTextDecoder","TextDecoder","ignoreBOM","fatal","getStringFromWasm0","stack_pointer","getArrayU8FromWasm0","encode_png","image_data","retptr","__wbindgen_add_to_stack_pointer","r0","getInt32","r1","r2","v1","__wbindgen_free","encode_png_base64","deferred2_0","deferred2_1","r3","ptr1","len1","premultiply_alpha","ptr0","__wbindgen_malloc","len0","v2","_assertClass","klass","cachedUint16ArrayMemory0","getUint16ArrayMemory0","Uint16Array","arcs_array_from_uint32grid","grid","is_angle_in_arcs","arcs","passArray16ToWasm0","set_log_ctx","__wbindgen_realloc","exec_fn_unit_bool","compiler","_input","Compiler","__wbg_ptr","ExecOutput","__wrap","exec_fn_int_bool","exec_fn_unit_tuple","exec_fn_int_tuple","exec_fn_unit_unit","exec_fn_int_unit","exec_fn_unit_int","exec_fn_int_int","passArrayJsValueToWasm0","setUint32","is_valid_identifier","getArrayJsValueFromWasm0","getUint32","Object","freeze","Cs420","Cs422","Cs444","Cs400","FinalizationRegistry","__wbg_activity_free","AnnotationDataFinalization","register","unregister","__wbg_annotationdata_free","AnnotationData","create","prototype","__destroy_into_raw","free","__wbg_get_annotationdata_pos","arg0","__wbg_set_annotationdata_pos","hint","deferred1_0","deferred1_1","__wbg_get_annotationdata_hint","__wbg_set_annotationdata_hint","annotationdata_new","CompilerFinalization","__wbg_compiler_free","compiler_new","compiler_compile","fn_signature","compiler_fn_signature","fn_signature_without_effects","compiler_fn_signature_without_effects","run_expr_to_html","compiler_run_expr_to_html","get_annotations","compiler_get_annotations","list_module_fn_names","compiler_list_module_fn_names","list_module_fns","compiler_list_module_fns","list_module_props","compiler_list_module_props","ErrorDataFinalization","__wbg_errordata_free","ErrorData","__wbg_get_errordata_to","__wbg_set_errordata_to","errordata_new","ExecOutputFinalization","__wbg_execoutput_free","cont","__wbg_get_execoutput_cont","__wbg_set_execoutput_cont","__wbg_get_execoutput_value","__wbg_set_execoutput_value","execoutput_new","FunctionSignatureFinalization","__wbg_functionsignature_free","FunctionSignature","__wbg_get_functionsignature_args","__wbg_set_functionsignature_args","doc","__wbg_get_functionsignature_doc","__wbg_set_functionsignature_doc","OptScriptVariableFinalization","__wbg_optscriptvariable_free","OptScriptVariable","__unwrap","jsValue","__wbg_get_optscriptvariable_name","__wbg_set_optscriptvariable_name","__wbg_get_optscriptvariable_type","ScriptVariableType","__wbg_set_optscriptvariable_type","ty","optscriptvariable_new","ScriptCtxFinalization","__wbg_scriptctx_free","ScriptCtx","scriptctx_new","game_script_compiler","scriptctx_game_script_compiler","condition_block_script_compiler","scriptctx_condition_block_script_compiler","action_block_script_compiler","scriptctx_action_block_script_compiler","scriptctx_type_name","ScriptCtxBuilderFinalization","__wbg_scriptctxbuilder_free","ScriptCtxBuilder","scriptctxbuilder_new","vars","scriptctxbuilder_set_game_variables","scriptctxbuilder_stage_module","scriptctxbuilder_commit_staged_modules","scriptctxbuilder_fix_game_env","debug_log_content","scriptctxbuilder_debug_log_content","read_ctx","write_ctx","world_write_ctx","analytics_read_ctx","analytics_write_ctx","text_input_read_ctx","text_input_write_ctx","speech_read_ctx","speech_write_ctx","llm_read_ctx","llm_write_ctx","pila_read_ctx","pila_write_ctx","scriptctxbuilder_to_ctx","ScriptValueFinalization","__wbg_scriptvalue_free","ScriptValue","__getClassname","scriptvalue___getClassname","scriptvalue_toString","ScriptVariableTypeFinalization","__wbg_scriptvariabletype_free","ty_name","scriptvariabletype_new","default_value","scriptvariabletype_default_value","scriptvariabletype_clone","scriptvariabletype_is_equal","__wbg_sprite_free","SpriteLocationFinalization","__wbg_spritelocation_free","SpriteLocation","__wbg_get_spritelocation_index","__wbg_set_spritelocation_index","x_min","__wbg_get_spritelocation_x_min","__wbg_set_spritelocation_x_min","y_min","__wbg_get_spritelocation_y_min","__wbg_set_spritelocation_y_min","x_max","__wbg_get_spritelocation_x_max","__wbg_set_spritelocation_x_max","y_max","__wbg_get_spritelocation_y_max","__wbg_set_spritelocation_y_max","__wbg_get_spritelocation_count","__wbg_set_spritelocation_count","x_sum","__wbg_get_spritelocation_x_sum","BigInt","asUintN","__wbg_set_spritelocation_x_sum","y_sum","__wbg_get_spritelocation_y_sum","__wbg_set_spritelocation_y_sum","spritelocation_width","spritelocation_height","radiusOfShape","spritelocation_radiusOfShape","localCx","spritelocation_localCx","localCy","spritelocation_localCy","SpriteRowFinalization","__wbg_spriterow_free","SpriteRow","spriterow_y_f32","spriteCount","spriterow_sprite_count","spriteLocation","spriterow_spriteLocation","copySprite","spriterow_copySprite","addBorrowedObject","__wbg_annotationdata_new","__wbg_apply_36be6a55257c99bf","arg1","arg2","arguments","__wbg_apply_eb9e9b97497f91e4","Reflect","__wbg_buffer_609cc3eee51ed158","__wbg_call_672a4d21634d4a24","__wbg_call_7cccdd69e0791ae2","__wbg_call_833bed5770ea2041","arg3","__wbg_call_b8adc8b1d0a0d8eb","arg4","__wbg_data_d1ed736c1e42b10e","setInt32","__wbg_errordata_new","__wbg_from_2a5d3e218e67aa85","__wbg_functionsignature_new","__wbg_get_67b2ba62fc30de12","__wbg_get_b9b93047fe3cf45b","__wbg_height_1d93eb7f5e355d97","__wbg_log_c222819a41e063d3","__wbg_new_405e22f390576ce2","__wbg_new_78feb108b6472713","__wbg_new_a12002a7f91c75be","__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a","__wbg_newwithu8clampedarrayandsh_7ea6ee082a25bc85","__wbg_optscriptvariable_unwrap","__wbg_push_737cfc8c1432c2c6","__wbg_putImageData_4c5aa10f3b3e4924","putImageData","__wbg_scriptvalue_new","__wbg_set_37837023f3d740e8","__wbg_set_3f1d0b984ed272ed","__wbg_spriterow_new","__wbg_width_b0c1d9f437a95799","__wbindgen_boolean_get","__wbindgen_debug_string","__wbindgen_is_function","__wbindgen_is_null","__wbindgen_is_object","__wbindgen_is_undefined","__wbindgen_memory","__wbindgen_number_get","setFloat64","__wbindgen_number_new","__wbindgen_object_clone_ref","__wbindgen_object_drop_ref","__wbindgen_string_get","__wbindgen_string_new","__wbindgen_throw"],"sourceRoot":""}