@react-shimeji/core 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/dom.ts","../src/loader.ts","../src/behavior.ts","../src/physics.ts","../src/action.ts","../src/mascot.ts","../src/platform.ts","../src/sprite.ts","../src/engine.ts"],"sourcesContent":["/** Framework-agnostic Shimeji engine. */\nexport { ShimejiEngine } from \"./engine\";\n/** Character loading and legacy XML parsing utilities. */\nexport { loadCharacter, normalizeCharacterSpec, parseActionsXml, parseBehaviorsXml } from \"./loader\";\n/** Behavior selection and safe expression utilities. */\nexport { BehaviorController, conditionsMatch, evaluateExpression, selectWeighted } from \"./behavior\";\n/** Low-level action-tree executor. */\nexport { ActionExecutor } from \"./action\";\n/** Geometry and physics helpers. */\nexport { applyGravity, clamp, isOnBorder, isOnBottom, isOnLeft, isOnRight, isOnTop, moveToward } from \"./physics\";\n/** DOM platform geometry utilities. */\nexport { readPlatformRectangles, resolvePlatformElements } from \"./platform\";\nexport type { PlatformRectangle } from \"./platform\";\n/** Sprite resource manager. */\nexport { SpriteManager, isIndividualSprite } from \"./sprite\";\nexport type * from \"./types\";\nexport type { ActionExecutorCallbacks, ActionExecutorOptions } from \"./action\";\nexport type { MascotCallbacks } from \"./mascot\";\nexport type { MascotDomHandle } from \"./dom\";\nexport type { ResolvedSprite, SpriteLease } from \"./sprite\";\n","import { SpriteManager, type SpriteLease } from \"./sprite\";\nimport type { CharacterSpec, MascotState, Rectangle } from \"./types\";\n\n/** DOM nodes and resources owned by one mascot. */\nexport interface MascotDomHandle {\n /** Absolutely positioned, pointer-transparent mascot wrapper. */\n element: HTMLDivElement;\n /** Pointer-interactive child element on which sprite images are painted. */\n spriteElement: HTMLDivElement;\n /** Per-mascot spritesheet URL lease. */\n spriteLease: SpriteLease;\n}\n\n/** Creates and updates all DOM owned by an engine instance. */\nexport class DomManager {\n private readonly handles = new Set<MascotDomHandle>();\n private readonly restoreContainerStyles: Array<() => void> = [];\n\n /** Uses the supplied element as the containing block and clipping boundary. */\n public constructor(\n private readonly container: HTMLElement,\n private readonly sprites: SpriteManager,\n ) {\n const view = container.ownerDocument.defaultView;\n const computedStyle = view?.getComputedStyle(container);\n if (!computedStyle?.position || computedStyle.position === \"static\") this.applyContainerStyle(\"position\", \"relative\");\n if (computedStyle?.overflowX === \"visible\" || !computedStyle?.overflowX) {\n this.applyContainerStyle(\"overflowX\", \"clip\");\n }\n }\n\n /** Reattaches mascot elements if application code temporarily removed them. */\n public ensureMounted(): void {\n for (const handle of this.handles) {\n if (handle.element.parentElement !== this.container) this.container.appendChild(handle.element);\n }\n }\n\n /** Returns bounds in the container-local coordinate system. */\n public getBounds(): Rectangle {\n return { x: 0, y: 0, width: this.container.clientWidth, height: this.container.clientHeight };\n }\n\n /** Converts a viewport client coordinate into container-local coordinates. */\n public toLocalPoint(clientX: number, clientY: number): { x: number; y: number } {\n const rectangle = this.container.getBoundingClientRect();\n return { x: clientX - rectangle.left, y: clientY - rectangle.top };\n }\n\n /** Creates a mascot node and acquires its spritesheet resource. */\n public createMascot(spec: CharacterSpec, mascotId: string, mascotClassName?: string): MascotDomHandle {\n const spriteLease = this.sprites.acquire(spec.spritesheet);\n const element = this.container.ownerDocument.createElement(\"div\");\n element.dataset.shimejiId = mascotId;\n element.setAttribute(\"aria-hidden\", \"true\");\n if (mascotClassName) element.className = mascotClassName;\n Object.assign(element.style, { position: \"absolute\", left: \"0\", top: \"0\", width: \"0\", height: \"0\", pointerEvents: \"none\", zIndex: \"9999\", userSelect: \"none\", willChange: \"transform\" });\n const spriteElement = this.container.ownerDocument.createElement(\"div\");\n Object.assign(spriteElement.style, { position: \"absolute\", left: \"0\", top: \"0\", backgroundRepeat: \"no-repeat\", transformOrigin: \"center center\", pointerEvents: \"auto\", touchAction: \"none\", userSelect: \"none\" });\n element.appendChild(spriteElement);\n const handle = { element, spriteElement, spriteLease };\n this.handles.add(handle);\n this.container.appendChild(element);\n return handle;\n }\n\n /** Paints one mascot state into its existing DOM nodes. */\n public render(handle: MascotDomHandle, spec: CharacterSpec, state: MascotState): void {\n const sprite = this.sprites.resolve(spec, handle.spriteLease, state.sprite);\n handle.spriteElement.style.left = \"0\";\n handle.spriteElement.style.top = \"0\";\n handle.spriteElement.style.transform = `scaleX(${state.lookRight ? -1 : 1})`;\n if (!sprite) {\n handle.element.style.transform = `translate3d(${state.x - state.anchorX}px, ${state.y - state.anchorY}px, 0)`;\n return;\n }\n let width = 128;\n let height = 128;\n handle.spriteElement.style.backgroundImage = `url(\"${sprite.url.replaceAll('\"', '\\\\\"')}\")`;\n if (sprite.rectangle) {\n width = sprite.rectangle.width;\n height = sprite.rectangle.height;\n handle.spriteElement.style.backgroundPosition = `${-sprite.rectangle.x}px ${-sprite.rectangle.y}px`;\n handle.spriteElement.style.backgroundSize = \"auto\";\n } else {\n handle.spriteElement.style.backgroundPosition = \"0 0\";\n handle.spriteElement.style.backgroundSize = \"contain\";\n const definition = Object.values(spec.sprites).find((candidate) => typeof candidate === \"object\" && \"url\" in candidate && candidate.url === sprite.url);\n if (typeof definition === \"object\" && \"width\" in definition && definition.width !== undefined) width = definition.width;\n if (typeof definition === \"object\" && \"height\" in definition && definition.height !== undefined) height = definition.height;\n }\n handle.spriteElement.style.width = `${width}px`;\n handle.spriteElement.style.height = `${height}px`;\n handle.element.style.width = `${width}px`;\n handle.element.style.height = `${height}px`;\n const anchorX = state.lookRight ? width - state.anchorX : state.anchorX;\n handle.element.style.transform = `translate3d(${state.x - anchorX}px, ${state.y - state.anchorY}px, 0)`;\n }\n\n /** Removes one mascot node and releases its temporary image URL. */\n public removeMascot(handle: MascotDomHandle): void {\n if (!this.handles.delete(handle)) return;\n handle.element.remove();\n handle.spriteLease.release();\n }\n\n /** Returns whether an element belongs to one of this manager's mascots. */\n public owns(element: HTMLElement): boolean {\n for (const handle of this.handles) if (handle.element === element || handle.element.contains(element)) return true;\n return false;\n }\n\n /** Removes every mascot element and releases its temporary image URL. */\n public destroy(): void {\n for (const handle of [...this.handles]) this.removeMascot(handle);\n for (const restore of this.restoreContainerStyles.splice(0).reverse()) restore();\n }\n\n private applyContainerStyle(property: \"position\" | \"overflow\" | \"overflowX\", value: string): void {\n const previous = this.container.style[property];\n this.container.style[property] = value;\n this.restoreContainerStyles.push(() => {\n if (this.container.style[property] === value) this.container.style[property] = previous;\n });\n }\n}\n","import type {\n ActionDefinition,\n ActionType,\n AnimationDefinition,\n BehaviorDefinition,\n BorderType,\n CharacterSource,\n CharacterSpec,\n LegacyCharacterPack,\n Point,\n Pose,\n SpriteMap,\n} from \"./types\";\n\nconst actionTypeNames: Record<string, ActionType> = {\n Sequence: \"Sequence\", Select: \"Select\", Reference: \"Reference\", Stay: \"Stay\", Animate: \"Animate\", Move: \"Move\", Embedded: \"Embedded\",\n Composite: \"Sequence\", Fixed: \"Animate\", Pause: \"Stay\",\n 複合: \"Sequence\", 選択: \"Select\", 参照: \"Reference\", 静止: \"Stay\", 固定: \"Animate\", 移動: \"Move\", 組み込み: \"Embedded\",\n};\nconst borderTypeNames: Record<string, BorderType> = { Floor: \"Floor\", Wall: \"Wall\", Ceiling: \"Ceiling\", 地面: \"Floor\", 壁: \"Wall\", 天井: \"Ceiling\" };\n\nfunction parseJson<T>(value: T | string, label: string): T {\n if (typeof value !== \"string\") return value;\n try { return JSON.parse(value) as T; } catch (error) { throw new TypeError(`Invalid ${label}: ${error instanceof Error ? error.message : String(error)}`); }\n}\n\nfunction attribute(element: Element, ...names: string[]): string | undefined {\n for (const name of names) { const value = element.getAttribute(name); if (value !== null) return value; }\n return undefined;\n}\n\nfunction directChildren(element: Element, ...names: string[]): Element[] {\n const accepted = new Set(names);\n return Array.from(element.children).filter((child) => accepted.has(child.localName) || accepted.has(child.tagName));\n}\n\nfunction parsePoint(value: string | undefined, fallback: Point = { x: 0, y: 0 }): Point {\n if (!value) return fallback;\n const [x = fallback.x, y = fallback.y] = value.split(\",\").map(Number);\n return { x: Number.isFinite(x) ? x : fallback.x, y: Number.isFinite(y) ? y : fallback.y };\n}\n\nfunction requireDomParser(): DOMParser {\n if (typeof DOMParser === \"undefined\") throw new Error(\"XML character packs require the browser DOMParser API; use pre-parsed JSON in non-browser environments\");\n return new DOMParser();\n}\n\nfunction parseDocument(xml: string, label: string): Document {\n const document = requireDomParser().parseFromString(xml.replace(/^\\uFEFF/, \"\"), \"application/xml\");\n const error = document.querySelector(\"parsererror\");\n if (error) throw new TypeError(`Invalid ${label}: ${error.textContent?.trim() ?? \"XML parse error\"}`);\n return document;\n}\n\nfunction actionProperty(element: Element, ...names: string[]): string | undefined { return attribute(element, ...names); }\n\nfunction parseAnimation(element: Element): AnimationDefinition {\n const poses = directChildren(element, \"Pose\", \"ポーズ\").map((pose): Pose => ({\n sprite: attribute(pose, \"Image\", \"画像\") ?? \"/shime1.png\",\n anchor: parsePoint(attribute(pose, \"ImageAnchor\", \"Anchor\", \"基準座標\"), { x: 64, y: 128 }),\n velocity: parsePoint(attribute(pose, \"Velocity\", \"移動速度\")),\n duration: Number(attribute(pose, \"Duration\", \"長さ\") ?? 1),\n }));\n const condition = attribute(element, \"Condition\", \"条件\");\n const turn = (attribute(element, \"IsTurn\", \"Turn\") ?? \"false\").toLowerCase() === \"true\";\n return { poses, ...(condition !== undefined && { condition }), ...(turn && { turn }) };\n}\n\nfunction parseActionElement(element: Element): ActionDefinition {\n const isReference = element.localName === \"ActionReference\" || element.localName === \"動作参照\";\n const rawType = isReference ? \"Reference\" : attribute(element, \"Type\", \"種類\") ?? (directChildren(element, \"Action\", \"動作\", \"ActionReference\", \"動作参照\").length ? \"Sequence\" : \"Animate\");\n const className = attribute(element, \"Class\", \"クラス\");\n const embedType = className?.split(\".\").at(-1);\n const type = actionTypeNames[rawType] ?? (embedType ? \"Embedded\" : \"Animate\");\n const name = attribute(element, \"Name\", \"名前\");\n const condition = actionProperty(element, \"Condition\", \"条件\");\n const borderRaw = actionProperty(element, \"BorderType\", \"Border\", \"枠\");\n const actions = directChildren(element, \"Action\", \"動作\", \"ActionReference\", \"動作参照\").map(parseActionElement);\n const animations = directChildren(element, \"Animation\", \"アニメーション\").map(parseAnimation);\n const result: ActionDefinition = {\n type,\n ...(name !== undefined && { name }),\n ...(embedType !== undefined && { embedType }),\n ...(condition !== undefined && { condition }),\n ...(borderRaw !== undefined && borderTypeNames[borderRaw] !== undefined && { borderType: borderTypeNames[borderRaw] }),\n ...(actions.length > 0 && { actions }),\n ...(animations.length > 0 && { animations }),\n };\n const properties: Array<[keyof ActionDefinition, string | undefined]> = [\n [\"duration\", actionProperty(element, \"Duration\", \"長さ\")], [\"gap\", actionProperty(element, \"Gap\", \"間隔\", \"ずれ\")], [\"targetX\", actionProperty(element, \"TargetX\", \"目的地X\")],\n [\"targetY\", actionProperty(element, \"TargetY\", \"目的地Y\")], [\"velocity\", actionProperty(element, \"VelocityParam\", \"Velocity\", \"速度\")],\n [\"x\", actionProperty(element, \"X\", \"変位X\")], [\"y\", actionProperty(element, \"Y\", \"変位Y\")],\n [\"offsetX\", actionProperty(element, \"OffsetX\", \"端X\")], [\"offsetY\", actionProperty(element, \"OffsetY\", \"端Y\")],\n [\"offsetType\", actionProperty(element, \"OffsetType\")],\n [\"initialVx\", actionProperty(element, \"InitialVX\", \"InitialVx\", \"初速X\")], [\"initialVy\", actionProperty(element, \"InitialVY\", \"InitialVy\", \"初速Y\")],\n [\"resistanceX\", actionProperty(element, \"RegistanceX\", \"ResistanceX\", \"空気抵抗X\")], [\"resistanceY\", actionProperty(element, \"RegistanceY\", \"ResistanceY\", \"空気抵抗Y\")],\n [\"gravity\", actionProperty(element, \"Gravity\", \"重力\")], [\"bornX\", actionProperty(element, \"BornX\", \"誕生X\", \"生まれる場所X\")],\n [\"bornY\", actionProperty(element, \"BornY\", \"誕生Y\", \"生まれる場所Y\")], [\"bornBehavior\", actionProperty(element, \"BornBehavior\", \"BornBehaviour\", \"誕生時の行動\", \"生まれた時の行動\")],\n [\"bornMascot\", actionProperty(element, \"BornMascot\")], [\"bornCount\", actionProperty(element, \"BornCount\")],\n [\"bornInterval\", actionProperty(element, \"BornInterval\")],\n [\"ieOffsetX\", actionProperty(element, \"IEOffsetX\", \"IEの端X\")], [\"ieOffsetY\", actionProperty(element, \"IEOffsetY\", \"IEの端Y\")],\n [\"lookRight\", actionProperty(element, \"LookRight\", \"右向き\")],\n ];\n for (const [key, value] of properties) if (value !== undefined) (result as unknown as Record<string, unknown>)[key] = value;\n const loop = actionProperty(element, \"Loop\", \"繰り返し\");\n if (loop !== undefined) result.loop = loop.toLowerCase() === \"true\";\n return result;\n}\n\n/** Parses a legacy `actions.xml` document into normalized action definitions. */\nexport function parseActionsXml(xml: string): ActionDefinition[] {\n const document = parseDocument(xml, \"actions.xml\");\n const lists = Array.from(document.getElementsByTagNameNS(\"*\", \"ActionList\")).concat(Array.from(document.getElementsByTagNameNS(\"*\", \"動作リスト\")));\n const roots = lists.length ? lists : [document.documentElement];\n return roots.flatMap((list) => directChildren(list, \"Action\", \"動作\").map(parseActionElement));\n}\n\nfunction parseNextBehaviors(element: Element, inheritedConditions: readonly string[]): BehaviorDefinition[] {\n const behaviors: BehaviorDefinition[] = [];\n for (const child of Array.from(element.children)) {\n if (child.localName === \"Condition\" || child.localName === \"条件\") {\n const condition = attribute(child, \"Condition\", \"条件\");\n behaviors.push(...parseNextBehaviors(child, [...inheritedConditions, ...(condition ? [condition] : [])]));\n } else if ([\"Behavior\", \"行動\", \"BehaviorReference\", \"BehaviorReferance\", \"行動参照\"].includes(child.localName)) {\n behaviors.push(parseBehaviorElement(child, inheritedConditions, 0));\n }\n }\n return behaviors;\n}\n\nfunction parseBehaviorElement(element: Element, inheritedConditions: readonly string[], groupIndex: number): BehaviorDefinition {\n const condition = attribute(element, \"Condition\", \"条件\");\n const conditions = [...inheritedConditions, ...(condition ? [condition] : [])];\n const nextList = directChildren(element, \"NextBehaviorList\", \"NextBehavior\", \"次の行動リスト\")[0];\n const nextBehaviors = nextList ? parseNextBehaviors(nextList, []) : [];\n const reference = element.localName === \"BehaviorReference\" || element.localName === \"BehaviorReferance\" || element.localName === \"行動参照\";\n const actionName = attribute(element, \"Action\", \"動作\");\n return {\n type: reference ? \"Reference\" : \"Behavior\",\n name: attribute(element, \"Name\", \"名前\") ?? \"\",\n frequency: Number(attribute(element, \"Frequency\", \"頻度\") ?? 0),\n conditions,\n nextBehaviors,\n ...(nextList && { nextAdditive: (attribute(nextList, \"Add\", \"追加\") ?? \"true\").toLowerCase() === \"true\" }),\n ...(actionName !== undefined && { actionName }),\n groupIndex,\n hidden: (attribute(element, \"Hidden\", \"非表示\") ?? \"false\").toLowerCase() === \"true\",\n };\n}\n\n/** Parses a legacy `behaviors.xml` document into normalized behavior definitions. */\nexport function parseBehaviorsXml(xml: string): BehaviorDefinition[] {\n const document = parseDocument(xml, \"behaviors.xml\");\n const lists = Array.from(document.getElementsByTagNameNS(\"*\", \"BehaviorList\")).concat(Array.from(document.getElementsByTagNameNS(\"*\", \"行動リスト\")));\n const root = lists[0] ?? document.documentElement;\n const behaviors: BehaviorDefinition[] = [];\n let groupIndex = 0;\n for (const child of Array.from(root.children)) {\n if (child.localName === \"Condition\" || child.localName === \"条件\") {\n groupIndex += 1;\n const condition = attribute(child, \"Condition\", \"条件\");\n const inherited = condition ? [condition] : [];\n behaviors.push(...directChildren(child, \"Behavior\", \"行動\", \"BehaviorReference\", \"BehaviorReferance\", \"行動参照\").map((element) => parseBehaviorElement(element, inherited, groupIndex)));\n } else if ([\"Behavior\", \"行動\", \"BehaviorReference\", \"BehaviorReferance\", \"行動参照\"].includes(child.localName)) {\n behaviors.push(parseBehaviorElement(child, [], 0));\n }\n }\n return behaviors;\n}\n\nfunction isCharacterSpec(value: unknown): value is CharacterSpec {\n if (!value || typeof value !== \"object\") return false;\n const candidate = value as Partial<CharacterSpec>;\n return typeof candidate.id === \"string\" && Array.isArray(candidate.actions) && Array.isArray(candidate.behaviors) && typeof candidate.sprites === \"object\" && candidate.sprites !== null && (typeof candidate.spritesheet === \"string\" || (typeof Blob !== \"undefined\" && candidate.spritesheet instanceof Blob));\n}\n\n/** Converts a pre-parsed definition or raw XML/JSON legacy bundle to a character specification. */\nexport function normalizeCharacterSpec(input: CharacterSpec | LegacyCharacterPack | unknown): CharacterSpec {\n let candidate: unknown = input;\n if (typeof candidate === \"string\") candidate = parseJson<unknown>(candidate, \"character JSON\");\n if (!candidate || typeof candidate !== \"object\") throw new TypeError(\"Character data must be an object\");\n const record = candidate as Record<string, unknown>;\n if (record.configuration) {\n const configuration = typeof record.configuration === \"string\"\n ? parseJson<Record<string, unknown>>(record.configuration, \"configuration\")\n : record.configuration;\n if (typeof configuration === \"object\") candidate = { ...(configuration as object), ...record };\n }\n const pack = candidate as Partial<LegacyCharacterPack> & Record<string, unknown>;\n const id = typeof pack.id === \"string\" ? pack.id : typeof pack.metadata?.shimeji === \"string\" ? pack.metadata.shimeji : undefined;\n if (!id) throw new TypeError(\"Character specification requires an id\");\n if (pack.actions === undefined || pack.behaviors === undefined || pack.sprites === undefined || pack.spritesheet === undefined) throw new TypeError(`Character '${id}' is missing actions, behaviors, sprites, or spritesheet`);\n const actions = typeof pack.actions === \"string\" && pack.actions.trimStart().startsWith(\"<\") ? parseActionsXml(pack.actions) : parseJson<ActionDefinition[]>(pack.actions, \"actions\");\n const behaviors = typeof pack.behaviors === \"string\" && pack.behaviors.trimStart().startsWith(\"<\") ? parseBehaviorsXml(pack.behaviors) : parseJson<BehaviorDefinition[]>(pack.behaviors, \"behaviors\");\n const sprites = parseJson<SpriteMap>(pack.sprites, \"sprites\");\n const spec: CharacterSpec = {\n id,\n spritesheet: pack.spritesheet,\n sprites,\n actions,\n behaviors,\n ...(typeof pack.name === \"string\" && { name: pack.name }),\n ...(pack.metadata !== undefined && { metadata: pack.metadata }),\n };\n if (!isCharacterSpec(spec)) throw new TypeError(`Character '${id}' could not be normalized`);\n return spec;\n}\n\n/** Loads character JSON from a URL or normalizes an already available character bundle. */\nexport async function loadCharacter(source: CharacterSource): Promise<CharacterSpec> {\n if (typeof source !== \"string\" && !(source instanceof URL)) return normalizeCharacterSpec(source);\n const url = source instanceof URL ? source : new URL(source, typeof document === \"undefined\" ? \"http://localhost/\" : document.baseURI);\n const response = await fetch(url);\n if (!response.ok) throw new Error(`Unable to load character '${url}': ${response.status} ${response.statusText}`);\n const spec = normalizeCharacterSpec(await response.json() as unknown);\n if (typeof spec.spritesheet === \"string\" && !/^(?:data:|blob:)/.test(spec.spritesheet)) {\n spec.spritesheet = new URL(spec.spritesheet, url).toString();\n }\n return spec;\n}\n","import type { BehaviorDefinition, CharacterSpec, MascotEnvironment } from \"./types\";\n\ntype TokenKind = \"number\" | \"identifier\" | \"operator\" | \"punctuation\" | \"eof\";\ninterface Token { kind: TokenKind; value: string }\ntype AstNode =\n | { kind: \"literal\"; value: number | boolean }\n | { kind: \"identifier\"; name: string }\n | { kind: \"member\"; object: AstNode; property: string }\n | { kind: \"call\"; callee: AstNode; args: AstNode[] }\n | { kind: \"unary\"; operator: string; argument: AstNode }\n | { kind: \"binary\"; operator: string; left: AstNode; right: AstNode }\n | { kind: \"conditional\"; test: AstNode; consequent: AstNode; alternate: AstNode };\n\nconst forbiddenProperties = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\nconst functions: Record<string, (...args: number[]) => number> = {\n abs: Math.abs, acos: Math.acos, acosh: Math.acosh, asin: Math.asin, asinh: Math.asinh,\n atan: Math.atan, atan2: Math.atan2, atanh: Math.atanh, cbrt: Math.cbrt, ceil: Math.ceil,\n cos: Math.cos, cosh: Math.cosh, exp: Math.exp, expm1: Math.expm1, floor: Math.floor,\n hypot: Math.hypot, log: Math.log, log1p: Math.log1p, log2: Math.log2, log10: Math.log10,\n max: Math.max, min: Math.min, pow: Math.pow, random: (maximum = 1) => Math.random() * maximum,\n round: Math.round, sign: Math.sign, sin: Math.sin, sinh: Math.sinh, sqrt: Math.sqrt,\n tan: Math.tan, tanh: Math.tanh, trunc: Math.trunc,\n};\nconst constants: Record<string, number> = { E: Math.E, PI: Math.PI };\n\nfunction normalizeExpression(source: string): string {\n return source\n .trim()\n .replace(/^(?:#|\\$)\\{/, \"\")\n .replace(/\\}$/, \"\")\n .replace(/Math\\.(random|min|max|abs|floor|ceil|round|sqrt|pow|sin|cos|tan|asin|acos|atan|sinh|cosh|tanh|asinh|acosh|atanh|cbrt|log|log2|log10|exp|expm1|log1p|trunc|sign|hypot|atan2)/g, \"$1\")\n .replace(/Math\\.(PI|E)\\b/g, \"$1\")\n .replace(/Mascot\\./gi, \"mascot.\")\n .replace(/TargetX|目的地X/gi, \"targetX\")\n .replace(/TargetY|目的地Y/gi, \"targetY\")\n .replace(/FootX|足X/gi, \"footX\")\n .replace(/FootY|足Y/gi, \"footY\")\n .replace(/VelocityX|速度X/gi, \"velocityX\")\n .replace(/VelocityY|速度Y/gi, \"velocityY\")\n .replace(/MaxCount/gi, \"maxCount\")\n .replace(/Gap|ずれ/gi, \"gap\")\n .replace(/\\band\\b/gi, \"&&\")\n .replace(/\\bor\\b/gi, \"||\")\n .replace(/\\bnot\\b/gi, \"!\");\n}\n\nfunction tokenize(source: string): Token[] {\n const tokens: Token[] = [];\n let index = 0;\n while (index < source.length) {\n const rest = source.slice(index);\n const whitespace = /^\\s+/.exec(rest);\n if (whitespace) { index += whitespace[0].length; continue; }\n const number = /^(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?/i.exec(rest);\n if (number) { tokens.push({ kind: \"number\", value: number[0] }); index += number[0].length; continue; }\n const identifier = /^[A-Za-z_$\\u0080-\\uFFFF][\\w$\\u0080-\\uFFFF]*/u.exec(rest);\n if (identifier) { tokens.push({ kind: \"identifier\", value: identifier[0] }); index += identifier[0].length; continue; }\n const operator = /^(?:===|!==|==|!=|<=|>=|&&|\\|\\||[+\\-*/%^<>!?:.,()])/.exec(rest);\n if (!operator) throw new SyntaxError(`Unexpected token at ${index}`);\n const value = operator[0];\n tokens.push({ kind: value === \"(\" || value === \")\" || value === \",\" || value === \".\" ? \"punctuation\" : \"operator\", value });\n index += value.length;\n }\n tokens.push({ kind: \"eof\", value: \"\" });\n return tokens;\n}\n\nclass Parser {\n private index = 0;\n public constructor(private readonly tokens: Token[]) {}\n public parse(): AstNode {\n const node = this.parseConditional();\n if (this.peek().kind !== \"eof\") throw new SyntaxError(`Unexpected '${this.peek().value}'`);\n return node;\n }\n private peek(): Token { return this.tokens[this.index] ?? { kind: \"eof\", value: \"\" }; }\n private take(value?: string): Token {\n const token = this.peek();\n if (value !== undefined && token.value !== value) throw new SyntaxError(`Expected '${value}'`);\n this.index += 1;\n return token;\n }\n private match(...values: string[]): boolean {\n if (!values.includes(this.peek().value)) return false;\n this.index += 1;\n return true;\n }\n private parseConditional(): AstNode {\n const test = this.parseOr();\n if (!this.match(\"?\")) return test;\n const consequent = this.parseConditional();\n this.take(\":\");\n return { kind: \"conditional\", test, consequent, alternate: this.parseConditional() };\n }\n private parseOr(): AstNode { return this.binary(() => this.parseAnd(), [\"||\"]); }\n private parseAnd(): AstNode { return this.binary(() => this.parseEquality(), [\"&&\"]); }\n private parseEquality(): AstNode { return this.binary(() => this.parseComparison(), [\"==\", \"===\", \"!=\", \"!==\"]); }\n private parseComparison(): AstNode { return this.binary(() => this.parseAdditive(), [\"<\", \"<=\", \">\", \">=\"]); }\n private parseAdditive(): AstNode { return this.binary(() => this.parseMultiplicative(), [\"+\", \"-\"]); }\n private parseMultiplicative(): AstNode { return this.binary(() => this.parsePower(), [\"*\", \"/\", \"%\"]); }\n private parsePower(): AstNode { return this.binary(() => this.parseUnary(), [\"^\"]); }\n private binary(next: () => AstNode, operators: string[]): AstNode {\n let left = next();\n while (operators.includes(this.peek().value)) {\n const operator = this.take().value;\n left = { kind: \"binary\", operator, left, right: next() };\n }\n return left;\n }\n private parseUnary(): AstNode {\n if ([\"!\", \"+\", \"-\"].includes(this.peek().value)) {\n return { kind: \"unary\", operator: this.take().value, argument: this.parseUnary() };\n }\n return this.parsePostfix();\n }\n private parsePostfix(): AstNode {\n let node = this.parsePrimary();\n for (;;) {\n if (this.match(\".\")) {\n const property = this.take();\n if (property.kind !== \"identifier\" || forbiddenProperties.has(property.value)) throw new SyntaxError(\"Unsafe member access\");\n node = { kind: \"member\", object: node, property: property.value };\n } else if (this.match(\"(\")) {\n const args: AstNode[] = [];\n if (!this.match(\")\")) {\n do { args.push(this.parseConditional()); } while (this.match(\",\"));\n this.take(\")\");\n }\n node = { kind: \"call\", callee: node, args };\n } else return node;\n }\n }\n private parsePrimary(): AstNode {\n const token = this.take();\n if (token.kind === \"number\") return { kind: \"literal\", value: Number(token.value) };\n if (token.kind === \"identifier\") {\n if (token.value === \"true\" || token.value === \"false\") return { kind: \"literal\", value: token.value === \"true\" };\n return { kind: \"identifier\", name: token.value };\n }\n if (token.value === \"(\") {\n const node = this.parseConditional();\n this.take(\")\");\n return node;\n }\n throw new SyntaxError(`Unexpected '${token.value}'`);\n }\n}\n\nfunction resolveMember(node: Extract<AstNode, { kind: \"member\" }>, scope: Record<string, unknown>): { owner: unknown; value: unknown } {\n const owner = evaluateNode(node.object, scope);\n if ((typeof owner !== \"object\" && typeof owner !== \"function\") || owner === null) return { owner, value: undefined };\n if (forbiddenProperties.has(node.property)) return { owner, value: undefined };\n return { owner, value: (owner as Record<string, unknown>)[node.property] };\n}\n\nfunction evaluateNode(node: AstNode, scope: Record<string, unknown>): unknown {\n switch (node.kind) {\n case \"literal\": return node.value;\n case \"identifier\": return Object.hasOwn(scope, node.name) ? scope[node.name] : functions[node.name] ?? constants[node.name];\n case \"member\": return resolveMember(node, scope).value;\n case \"call\": {\n const member = node.callee.kind === \"member\" ? resolveMember(node.callee, scope) : undefined;\n const callable = member?.value ?? evaluateNode(node.callee, scope);\n if (typeof callable !== \"function\") throw new TypeError(\"Expression value is not callable\");\n return callable.apply(member?.owner, node.args.map((argument) => evaluateNode(argument, scope)));\n }\n case \"unary\": {\n const value = evaluateNode(node.argument, scope);\n if (node.operator === \"!\") return !value;\n if (node.operator === \"+\") return Number(value);\n return -Number(value);\n }\n case \"conditional\": return evaluateNode(node.test, scope) ? evaluateNode(node.consequent, scope) : evaluateNode(node.alternate, scope);\n case \"binary\": {\n if (node.operator === \"&&\") return Boolean(evaluateNode(node.left, scope)) && Boolean(evaluateNode(node.right, scope));\n if (node.operator === \"||\") return Boolean(evaluateNode(node.left, scope)) || Boolean(evaluateNode(node.right, scope));\n const left = evaluateNode(node.left, scope);\n const right = evaluateNode(node.right, scope);\n switch (node.operator) {\n case \"+\": return Number(left) + Number(right);\n case \"-\": return Number(left) - Number(right);\n case \"*\": return Number(left) * Number(right);\n case \"/\": return Number(left) / Number(right);\n case \"%\": return Number(left) % Number(right);\n case \"^\": return Math.pow(Number(left), Number(right));\n case \"==\": case \"===\": return left === right;\n case \"!=\": case \"!==\": return left !== right;\n case \"<\": return Number(left) < Number(right);\n case \"<=\": return Number(left) <= Number(right);\n case \">\": return Number(left) > Number(right);\n case \">=\": return Number(left) >= Number(right);\n default: return false;\n }\n }\n }\n}\n\nconst expressionCache = new Map<string, AstNode>();\n\n/** Safely evaluates a legacy Shimeji expression without using `eval` or `Function`. */\nexport function evaluateExpression(expression: string | number | boolean | undefined, environment: MascotEnvironment, fallback: number, random?: () => number): number;\n/** Safely evaluates a legacy Shimeji expression without using `eval` or `Function`. */\nexport function evaluateExpression(expression: string | number | boolean | undefined, environment: MascotEnvironment, fallback: boolean, random?: () => number): boolean;\n/** Safely evaluates a legacy Shimeji expression without using `eval` or `Function`. */\nexport function evaluateExpression(expression: string | number | boolean | undefined, environment: MascotEnvironment, fallback: number | boolean, random: () => number = Math.random): number | boolean {\n if (expression === undefined) return fallback;\n if (typeof expression !== \"string\") return expression;\n try {\n const normalized = normalizeExpression(expression);\n let ast = expressionCache.get(normalized);\n if (!ast) { ast = new Parser(tokenize(normalized)).parse(); expressionCache.set(normalized, ast); }\n const result = evaluateNode(ast, { ...environment, random: (maximum = 1) => random() * Number(maximum) } as unknown as Record<string, unknown>);\n if (typeof fallback === \"boolean\") return Boolean(result);\n const numericResult = Number(result);\n return Number.isNaN(numericResult) ? fallback : numericResult;\n } catch { return fallback; }\n}\n\n/** Returns true when every condition in a behavior or action is satisfied. */\nexport function conditionsMatch(conditions: readonly string[], environment: MascotEnvironment, random: () => number = Math.random): boolean {\n return conditions.every((condition) => evaluateExpression(condition, environment, false, random));\n}\n\n/** Chooses one item with probability proportional to its non-negative weight. */\nexport function selectWeighted<T>(items: readonly T[], weight: (item: T) => number, random: () => number = Math.random): T | undefined {\n const weighted = items.map((item) => ({ item, weight: Math.max(0, weight(item)) }));\n const total = weighted.reduce((sum, entry) => sum + entry.weight, 0);\n if (total <= 0) return undefined;\n let cursor = random() * total;\n for (const entry of weighted) { cursor -= entry.weight; if (cursor < 0) return entry.item; }\n return weighted.at(-1)?.item;\n}\n\n/** Selects applicable behaviors and resolves legacy behavior references. */\nexport class BehaviorController {\n private previous: BehaviorDefinition | undefined;\n private fallbackSelected = false;\n\n /** Creates a behavior selector for a normalized character specification. */\n public constructor(private readonly spec: CharacterSpec, private readonly random: () => number = Math.random) {}\n\n /** Selects an initial behavior, honoring an explicit requested name when possible. */\n public selectInitial(environment: MascotEnvironment, requestedName?: string): BehaviorDefinition | undefined {\n this.fallbackSelected = false;\n if (requestedName) {\n const requested = this.spec.behaviors.find((behavior) => behavior.name === requestedName);\n if (requested) return (this.previous = this.resolve(requested));\n }\n return (this.previous = this.choose(this.spec.behaviors, environment));\n }\n\n /** Selects the weighted transition following the current behavior. */\n public selectNext(environment: MascotEnvironment): BehaviorDefinition | undefined {\n const selected = this.choose(this.nextPool(), environment);\n this.fallbackSelected = selected === undefined;\n return (this.previous = selected ?? this.findFallBehavior());\n }\n\n /** Tries a weighted transition from a subset without changing history when none applies. */\n public trySelectNext(environment: MascotEnvironment, predicate: (behavior: BehaviorDefinition) => boolean): BehaviorDefinition | undefined {\n const selected = this.choose(this.nextPool().filter(predicate), environment);\n if (!selected) return undefined;\n this.fallbackSelected = false;\n return (this.previous = selected);\n }\n\n /** Whether the most recent transition had no effective weighted candidate. */\n public usedFallback(): boolean { return this.fallbackSelected; }\n\n /** Replaces selection history so an external interaction can force a behavior. */\n public force(name: string): BehaviorDefinition | undefined {\n this.fallbackSelected = false;\n const behavior = this.spec.behaviors.find((candidate) => candidate.name === name);\n return (this.previous = behavior ? this.resolve(behavior) : undefined);\n }\n\n private choose(pool: readonly BehaviorDefinition[], environment: MascotEnvironment): BehaviorDefinition | undefined {\n const applicable = pool.filter((behavior) => conditionsMatch(behavior.conditions, environment, this.random));\n const chosen = selectWeighted(applicable, (behavior) => behavior.frequency, this.random);\n return chosen ? this.resolve(chosen) : undefined;\n }\n\n private nextPool(): readonly BehaviorDefinition[] {\n const next = this.previous?.nextBehaviors ?? [];\n return this.previous && this.previous.nextAdditive === false ? next : [...this.spec.behaviors, ...next];\n }\n\n private resolve(behavior: BehaviorDefinition): BehaviorDefinition {\n if (behavior.type !== \"Reference\") return behavior;\n const target = this.spec.behaviors.find((candidate) => candidate.type === \"Behavior\" && candidate.name === behavior.name);\n return target ? {\n ...target,\n ...behavior,\n type: \"Behavior\",\n nextBehaviors: target.nextBehaviors,\n ...(behavior.actionName !== undefined\n ? { actionName: behavior.actionName }\n : target.actionName !== undefined ? { actionName: target.actionName } : {}),\n ...(target.nextAdditive !== undefined && { nextAdditive: target.nextAdditive }),\n } : { ...behavior, type: \"Behavior\" };\n }\n\n private findFallBehavior(): BehaviorDefinition | undefined {\n return this.spec.behaviors.find((behavior) => behavior.name === \"Fall\" || behavior.name === \"落下する\");\n }\n\n}\n","import type { MascotState, Point, Rectangle } from \"./types\";\n\n// Mascot anchors and evaluated action targets use truncated legacy pixels,\n// while DOMRect edges may lie anywhere between CSS pixels. Any distance below\n// one pixel is therefore the same legacy coordinate; an exact adjacent pixel\n// remains distinct.\nconst BORDER_TOLERANCE = 1 - Number.EPSILON / 2;\n\nfunction isWithinSpan(value: number, minimum: number, maximum: number, tolerance: number): boolean {\n const distance = value < minimum ? minimum - value : value > maximum ? value - maximum : 0;\n return distance <= tolerance;\n}\n\n/** Clamps a number to an inclusive range. */\nexport function clamp(value: number, minimum: number, maximum: number): number {\n return Math.min(Math.max(value, minimum), maximum);\n}\n\n/** Returns whether a point lies on the top edge of a rectangle. */\nexport function isOnTop(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.x, rectangle.x, rectangle.x + rectangle.width, tolerance) && Math.abs(point.y - rectangle.y) <= tolerance;\n}\n\n/** Returns whether a point lies on the bottom edge of a rectangle. */\nexport function isOnBottom(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.x, rectangle.x, rectangle.x + rectangle.width, tolerance) && Math.abs(point.y - rectangle.y - rectangle.height) <= tolerance;\n}\n\n/** Returns whether a point lies on the left edge of a rectangle. */\nexport function isOnLeft(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.y, rectangle.y, rectangle.y + rectangle.height, tolerance) && Math.abs(point.x - rectangle.x) <= tolerance;\n}\n\n/** Returns whether a point lies on the right edge of a rectangle. */\nexport function isOnRight(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.y, rectangle.y, rectangle.y + rectangle.height, tolerance) && Math.abs(point.x - rectangle.x - rectangle.width) <= tolerance;\n}\n\n/** Returns whether an anchor satisfies an action's boundary requirement. */\nexport function isOnBorder(\n state: MascotState,\n bounds: Rectangle,\n border: \"Floor\" | \"Wall\" | \"Ceiling\" | undefined,\n platform?: Rectangle,\n): boolean {\n if (!border) return true;\n if (border === \"Floor\") return isOnBottom(state, bounds) || (platform !== undefined && isOnTop(state, platform));\n if (border === \"Ceiling\") return isOnTop(state, bounds) || (platform !== undefined && isOnBottom(state, platform));\n return isOnLeft(state, bounds)\n || isOnRight(state, bounds)\n || (platform !== undefined && (isOnLeft(state, platform) || isOnRight(state, platform)));\n}\n\n/** Returns whether a point is on a floor (platform top or work-area bottom). */\nexport function isOnFloor(point: Point, bounds: Rectangle, platforms: readonly Rectangle[] = []): boolean {\n return platforms.some((platform) => isOnTop(point, platform)) || isOnBottom(point, bounds);\n}\n\n/** Returns whether a point is on the wall it is moving/facing toward. */\nexport function isOnWall(point: Point, bounds: Rectangle, lookRight: boolean, platforms: readonly Rectangle[] = []): boolean {\n return lookRight\n ? platforms.some((platform) => isOnLeft(point, platform)) || isOnRight(point, bounds)\n : platforms.some((platform) => isOnRight(point, platform)) || isOnLeft(point, bounds);\n}\n\n/**\n * Advances one legacy Fall tick. Velocity is damped and accelerated before\n * movement, then the path is sampled one pixel at a time just like Shimeji-ee.\n */\nexport function applyGravity(\n state: MascotState,\n bounds: Rectangle,\n frameScale: number,\n gravity: number,\n resistanceX = 0.05,\n resistanceY = 0.1,\n platform?: Rectangle,\n): boolean {\n const platforms = platform ? [platform] : [];\n const steps = Math.max(1, Math.round(frameScale));\n let stopped = false;\n for (let frame = 0; frame < steps && !stopped; frame += 1) {\n state.vx -= state.vx * resistanceX;\n state.vy = state.vy - state.vy * resistanceY + gravity;\n const dx = Math.trunc(state.vx);\n const dy = Math.trunc(state.vy);\n const divisions = Math.max(1, Math.abs(dx), Math.abs(dy));\n const start = { x: state.x, y: state.y };\n for (let index = 0; index <= divisions; index += 1) {\n const x = start.x + Math.trunc((dx * index) / divisions);\n const y = start.y + Math.trunc((dy * index) / divisions);\n state.x = x;\n state.y = y;\n if (dy > 0) {\n for (let offset = -80; offset <= 0; offset += 1) {\n state.y = y + offset;\n if (isOnFloor(state, bounds, platforms)) { stopped = true; break; }\n }\n if (stopped) break;\n state.y = y;\n }\n if (isOnWall(state, bounds, state.lookRight, platforms)) { stopped = true; break; }\n }\n }\n return stopped;\n}\n\n/** Moves a mascot toward a target without overshooting it. */\nexport function moveToward(state: MascotState, target: Point, speed: number, frameScale: number): boolean {\n const dx = target.x - state.x;\n const dy = target.y - state.y;\n const distance = Math.hypot(dx, dy);\n if (distance <= Math.max(0.001, speed * frameScale)) {\n state.x = target.x;\n state.y = target.y;\n return true;\n }\n state.x += (dx / distance) * speed * frameScale;\n state.y += (dy / distance) * speed * frameScale;\n return false;\n}\n","import { evaluateExpression } from \"./behavior\";\nimport { isOnBottom, isOnFloor, isOnLeft, isOnRight, isOnTop, isOnWall } from \"./physics\";\nimport type { PlatformRectangle } from \"./platform\";\nimport type {\n ActionDefinition,\n AnimationDefinition,\n BorderType,\n CharacterSpec,\n MascotEnvironment,\n MascotState,\n Point,\n Pose,\n Rectangle,\n} from \"./types\";\n\n/** Callbacks through which embedded actions request engine-level operations. */\nexport interface ActionExecutorCallbacks {\n /** Spawns another mascot, optionally from another registered character. */\n spawn(position: { x: number; y: number; behaviorName?: string; lookRight?: boolean }, characterId?: string): void;\n /** Removes the mascot owning this executor. */\n remove(): void;\n /** Moves a DOM platform for the legacy IE-carrying actions. */\n movePlatform?(element: HTMLElement, point: Point): void;\n}\n\n/** Settings used while interpreting actions. */\nexport interface ActionExecutorOptions {\n /** Duration of one legacy animation unit in milliseconds. */\n frameDuration: number;\n /** Gravity used when a Fall action does not define one. */\n gravity: number;\n /** Optional deterministic random-number source. */\n random?: (() => number) | undefined;\n}\n\nexport type ActionTickResult = \"running\" | \"complete\" | \"lost-ground\";\n\ninterface RuntimeContext {\n environment: MascotEnvironment;\n bounds: Rectangle;\n platforms: readonly PlatformRectangle[];\n}\n\ninterface Runtime {\n init(context: RuntimeContext): void;\n hasNext(context: RuntimeContext): boolean;\n step(context: RuntimeContext): \"running\" | \"lost-ground\";\n}\n\nfunction expressionIsPerFrame(value: unknown): boolean {\n return typeof value === \"string\" && value.trimStart().startsWith(\"#{\");\n}\n\nclass ActionValues {\n private readonly actionCache = new Map<string, number | boolean>();\n private readonly frameCache = new Map<string, number | boolean>();\n\n public constructor(private readonly random: () => number) {}\n\n public init(): void {\n this.actionCache.clear();\n this.frameCache.clear();\n }\n\n public initFrame(): void { this.frameCache.clear(); }\n\n public number(key: string, value: string | number | undefined, environment: MascotEnvironment, fallback: number): number {\n if (value === undefined) return fallback;\n if (typeof value === \"number\") return value;\n const cache = expressionIsPerFrame(value) ? this.frameCache : this.actionCache;\n const cached = cache.get(key);\n if (typeof cached === \"number\") return cached;\n const result = evaluateExpression(value, environment, fallback, this.random);\n cache.set(key, result);\n return result;\n }\n\n public boolean(key: string, value: string | boolean | undefined, environment: MascotEnvironment, fallback: boolean): boolean {\n if (value === undefined) return fallback;\n if (typeof value === \"boolean\") return value;\n const cache = expressionIsPerFrame(value) ? this.frameCache : this.actionCache;\n const cached = cache.get(key);\n if (typeof cached === \"boolean\") return cached;\n const result = evaluateExpression(value, environment, fallback, this.random);\n cache.set(key, result);\n return result;\n }\n}\n\nabstract class RuntimeBase implements Runtime {\n protected time = 0;\n protected readonly values: ActionValues;\n\n protected constructor(protected readonly definition: ActionDefinition, random: () => number) {\n this.values = new ActionValues(random);\n }\n\n public init(context: RuntimeContext): void {\n this.time = 0;\n this.values.init();\n this.onInit(context);\n }\n\n public hasNext(context: RuntimeContext): boolean {\n return this.baseHasNext(context) && this.hasMore(context);\n }\n\n public step(context: RuntimeContext): \"running\" | \"lost-ground\" {\n this.values.initFrame();\n const result = this.tick(context);\n this.time += 1;\n return result;\n }\n\n protected onInit(_context: RuntimeContext): void {}\n protected hasMore(_context: RuntimeContext): boolean { return true; }\n protected baseHasNext(context: RuntimeContext): boolean {\n const condition = this.values.boolean(\"condition\", this.definition.condition, context.environment, true);\n const duration = Math.trunc(this.values.number(\"duration\", this.definition.duration, context.environment, Number.POSITIVE_INFINITY));\n return condition && this.time < duration;\n }\n protected abstract tick(context: RuntimeContext): \"running\" | \"lost-ground\";\n}\n\ntype BorderSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nclass TrackedBorder {\n private previous: Rectangle | undefined;\n\n public constructor(\n private readonly side: BorderSide,\n private readonly source: \"work-area\" | HTMLElement | undefined,\n context: RuntimeContext,\n ) { this.previous = this.rectangle(context); }\n\n public move(point: Point, context: RuntimeContext): Point {\n const current = this.rectangle(context);\n const previous = this.previous;\n this.previous = current;\n if (!current || !previous) return point;\n if (this.side === \"left\" || this.side === \"right\") {\n if (previous.height === 0) return point;\n const next = {\n x: point.x + this.coordinate(current) - this.coordinate(previous),\n y: Math.trunc(((point.y - previous.y) * current.height) / previous.height + current.y),\n };\n return Math.abs(next.x - point.x) >= 80 || Math.abs(next.y - point.y) >= 80 ? point : next;\n }\n if (previous.width === 0) return point;\n const next = {\n // FloorCeiling.java performs integer division before applying the\n // mascot's relative offset along a resized border.\n x: (point.x - previous.x) * Math.trunc(current.width / previous.width) + current.x,\n y: point.y + this.coordinate(current) - this.coordinate(previous),\n };\n return Math.abs(next.x - point.x) >= 80 || next.y - point.y > 20 || next.y - point.y < -80 ? point : next;\n }\n\n public isOn(point: Point, context: RuntimeContext): boolean {\n const rectangle = this.rectangle(context);\n if (!rectangle) return false;\n switch (this.side) {\n case \"top\": return isOnTop(point, rectangle);\n case \"bottom\": return isOnBottom(point, rectangle);\n case \"left\": return isOnLeft(point, rectangle);\n case \"right\": return isOnRight(point, rectangle);\n }\n }\n\n private coordinate(rectangle: Rectangle): number {\n switch (this.side) {\n case \"top\": return rectangle.y;\n case \"bottom\": return rectangle.y + rectangle.height;\n case \"left\": return rectangle.x;\n case \"right\": return rectangle.x + rectangle.width;\n }\n }\n\n private rectangle(context: RuntimeContext): Rectangle | undefined {\n if (this.source === \"work-area\") return context.bounds;\n if (!this.source) return undefined;\n return context.platforms.find((platform) => platform.element === this.source);\n }\n}\n\nfunction selectBorder(type: BorderType, state: MascotState, context: RuntimeContext): TrackedBorder {\n if (type === \"Floor\") {\n const platform = context.platforms.find((candidate) => isOnTop(state, candidate));\n if (platform) return new TrackedBorder(\"top\", platform.element, context);\n if (isOnBottom(state, context.bounds)) return new TrackedBorder(\"bottom\", \"work-area\", context);\n return new TrackedBorder(\"bottom\", undefined, context);\n }\n if (type === \"Ceiling\") {\n const platform = context.platforms.find((candidate) => isOnBottom(state, candidate));\n if (platform) return new TrackedBorder(\"bottom\", platform.element, context);\n if (isOnTop(state, context.bounds)) return new TrackedBorder(\"top\", \"work-area\", context);\n return new TrackedBorder(\"top\", undefined, context);\n }\n if (state.lookRight) {\n const platform = context.platforms.find((candidate) => isOnLeft(state, candidate));\n if (platform) return new TrackedBorder(\"left\", platform.element, context);\n if (isOnRight(state, context.bounds)) return new TrackedBorder(\"right\", \"work-area\", context);\n return new TrackedBorder(\"right\", undefined, context);\n }\n const platform = context.platforms.find((candidate) => isOnRight(state, candidate));\n if (platform) return new TrackedBorder(\"right\", platform.element, context);\n if (isOnLeft(state, context.bounds)) return new TrackedBorder(\"left\", \"work-area\", context);\n return new TrackedBorder(\"left\", undefined, context);\n}\n\nabstract class AnimatedRuntime extends RuntimeBase {\n protected border: TrackedBorder | undefined;\n\n public constructor(definition: ActionDefinition, protected readonly state: MascotState, random: () => number) {\n super(definition, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n this.border = this.definition.borderType ? selectBorder(this.definition.borderType, this.state, context) : undefined;\n }\n\n protected animation(context: RuntimeContext, turn?: boolean): AnimationDefinition | undefined {\n const scoped = this.scopedEnvironment(context.environment);\n return this.definition.animations?.find((animation, index) =>\n (turn === undefined || Boolean(animation.turn) === turn)\n && this.values.boolean(`animation-${index}`, animation.condition, scoped, true));\n }\n\n protected animationDuration(context: RuntimeContext, turn?: boolean): number {\n return this.animation(context, turn)?.poses.reduce((sum, pose) => sum + Math.max(0, pose.duration), 0) ?? 0;\n }\n\n protected applyBorder(context: RuntimeContext): \"running\" | \"lost-ground\" {\n if (!this.border) return \"running\";\n const moved = this.border.move(this.state, context);\n this.state.x = moved.x;\n this.state.y = moved.y;\n return this.border.isOn(this.state, context) ? \"running\" : \"lost-ground\";\n }\n\n protected applyAnimation(context: RuntimeContext, turn?: boolean): void {\n const animation = this.animation(context, turn);\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n }\n\n protected scopedEnvironment(environment: MascotEnvironment): MascotEnvironment {\n const gap = this.values.number(\"gap\", this.definition.gap, environment, 0);\n const withGap = { ...environment, gap };\n const targetX = this.definition.targetX === undefined ? undefined : this.values.number(\"targetX\", this.definition.targetX, withGap, 0);\n const targetY = this.definition.targetY === undefined ? undefined : this.values.number(\"targetY\", this.definition.targetY, withGap, 0);\n return { ...withGap, ...(targetX !== undefined && { targetX }), ...(targetY !== undefined && { targetY }) };\n }\n}\n\nfunction poseAt(animation: AnimationDefinition, time: number): Pose | undefined {\n const duration = animation.poses.reduce((sum, pose) => sum + Math.max(0, pose.duration), 0);\n if (duration <= 0) return undefined;\n let cursor = time % duration;\n for (const pose of animation.poses) {\n cursor -= Math.max(0, pose.duration);\n if (cursor < 0) return pose;\n }\n return animation.poses.at(-1);\n}\n\nfunction applyPose(state: MascotState, pose: Pose): void {\n state.sprite = pose.sprite;\n state.anchorX = pose.anchor.x;\n state.anchorY = pose.anchor.y;\n state.x += (state.lookRight ? -1 : 1) * pose.velocity.x;\n state.y += pose.velocity.y;\n}\n\nclass StayRuntime extends AnimatedRuntime {\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const border = this.applyBorder(context);\n if (border === \"lost-ground\") return border;\n this.applyAnimation(context);\n return \"running\";\n }\n}\n\nclass AnimateRuntime extends StayRuntime {\n protected override hasMore(context: RuntimeContext): boolean { return this.time < this.animationDuration(context); }\n}\n\nclass MoveRuntime extends AnimatedRuntime {\n protected turning = false;\n protected hasTurningAnimation = false;\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.turning = false;\n this.hasTurningAnimation = this.definition.animations?.some((animation) => animation.turn) ?? false;\n }\n\n protected override hasMore(context: RuntimeContext): boolean {\n const scoped = this.scopedEnvironment(context.environment);\n const targetX = this.targetX(scoped);\n const targetY = this.targetY(scoped);\n const reached = (targetX !== undefined && this.state.x === targetX) || (targetY !== undefined && this.state.y === targetY);\n return !reached || this.turning;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const border = this.applyBorder(context);\n if (border === \"lost-ground\") return border;\n const scoped = this.scopedEnvironment(context.environment);\n const targetX = this.targetX(scoped);\n const targetY = this.targetY(scoped);\n let down = false;\n if (targetX !== undefined && this.state.x !== targetX) {\n const nextLookRight = this.state.x < targetX;\n this.turning = this.hasTurningAnimation && (this.turning || nextLookRight !== this.state.lookRight);\n this.state.lookRight = nextLookRight;\n }\n if (targetY !== undefined) down = this.state.y < targetY;\n if (this.turning && this.time >= this.animationDuration(context, true)) this.turning = false;\n this.applyAnimation(context, this.turning);\n if (targetX !== undefined && ((this.state.lookRight && this.state.x >= targetX) || (!this.state.lookRight && this.state.x <= targetX))) this.state.x = targetX;\n if (targetY !== undefined && ((down && this.state.y >= targetY) || (!down && this.state.y <= targetY))) this.state.y = targetY;\n return \"running\";\n }\n\n protected targetX(environment: MascotEnvironment): number | undefined {\n return this.definition.targetX === undefined ? undefined : Math.trunc(this.values.number(\"targetX\", this.definition.targetX, environment, 0));\n }\n\n protected targetY(environment: MascotEnvironment): number | undefined {\n return this.definition.targetY === undefined ? undefined : Math.trunc(this.values.number(\"targetY\", this.definition.targetY, environment, 0));\n }\n}\n\nclass MoveWithTurnRuntime extends MoveRuntime {\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.hasTurningAnimation = (this.definition.animations?.length ?? 0) >= 2;\n }\n\n protected override animation(context: RuntimeContext, turn?: boolean): AnimationDefinition | undefined {\n const animations = this.definition.animations ?? [];\n if (turn) return animations.at(-1);\n const scoped = this.scopedEnvironment(context.environment);\n return animations.slice(0, -1).find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, scoped, true));\n }\n}\n\nclass TurnRuntime extends AnimatedRuntime {\n private turning = false;\n\n protected override hasMore(context: RuntimeContext): boolean {\n const desired = this.values.boolean(\"lookRight\", this.definition.lookRight, context.environment, !this.state.lookRight);\n this.turning ||= desired !== this.state.lookRight;\n return this.turning && this.time < this.animationDuration(context);\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n this.state.lookRight = this.values.boolean(\"lookRight\", this.definition.lookRight, context.environment, !this.state.lookRight);\n const border = this.applyBorder(context);\n if (border === \"lost-ground\") return border;\n this.applyAnimation(context);\n return \"running\";\n }\n}\n\nclass InstantRuntime extends RuntimeBase {\n public constructor(definition: ActionDefinition, private readonly state: MascotState, random: () => number, private readonly operation: \"look\" | \"offset\" | \"noop\") {\n super(definition, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n if (!this.baseHasNext(context)) return;\n if (this.operation === \"look\") {\n this.state.lookRight = this.values.boolean(\"lookRight\", this.definition.lookRight, context.environment, !this.state.lookRight);\n } else if (this.operation === \"offset\") {\n this.state.x += Math.trunc(this.values.number(\"x\", this.definition.x, context.environment, 0));\n this.state.y += Math.trunc(this.values.number(\"y\", this.definition.y, context.environment, 0));\n }\n }\n\n protected override hasMore(): boolean { return false; }\n protected override tick(): \"running\" { return \"running\"; }\n}\n\nclass JumpRuntime extends RuntimeBase {\n public constructor(definition: ActionDefinition, private readonly state: MascotState, random: () => number) { super(definition, random); }\n\n protected override hasMore(context: RuntimeContext): boolean { return this.distance(context).distance !== 0; }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const { targetX, targetY, distanceX, distanceY, distance } = this.distance(context);\n this.state.lookRight = this.state.x < targetX;\n const velocity = this.values.number(\"velocity\", this.definition.velocity, context.environment, 20);\n if (distance !== 0) {\n this.state.vx = velocity * distanceX / distance;\n this.state.vy = velocity * distanceY / distance;\n this.state.x += Math.trunc(this.state.vx);\n this.state.y += Math.trunc(this.state.vy);\n const environment = { ...context.environment, targetX, targetY };\n const animation = this.definition.animations?.find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, environment, true));\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n }\n if (distance <= velocity) { this.state.x = targetX; this.state.y = targetY; }\n return \"running\";\n }\n\n private distance(context: RuntimeContext): { targetX: number; targetY: number; distanceX: number; distanceY: number; distance: number } {\n const targetX = Math.trunc(this.values.number(\"targetX\", this.definition.targetX, context.environment, 0));\n const targetY = Math.trunc(this.values.number(\"targetY\", this.definition.targetY, context.environment, 0));\n const distanceX = targetX - this.state.x;\n const distanceY = targetY - this.state.y - Math.abs(distanceX) / 2;\n return { targetX, targetY, distanceX, distanceY, distance: Math.hypot(distanceX, distanceY) };\n }\n}\n\nclass FallRuntime extends RuntimeBase {\n private modX = 0;\n private modY = 0;\n\n public constructor(definition: ActionDefinition, protected readonly state: MascotState, random: () => number, private readonly defaultGravity: number) {\n super(definition, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n this.modX = 0;\n this.modY = 0;\n this.state.vx = Math.trunc(this.values.number(\"initialVx\", this.definition.initialVx, context.environment, 0));\n this.state.vy = Math.trunc(this.values.number(\"initialVy\", this.definition.initialVy, context.environment, 0));\n }\n\n protected override hasMore(context: RuntimeContext): boolean {\n return !isOnFloor(this.state, context.bounds, context.platforms) && !isOnWall(this.state, context.bounds, this.state.lookRight, context.platforms);\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n if (this.state.vx !== 0) this.state.lookRight = this.state.vx > 0;\n const resistanceX = this.values.number(\"resistanceX\", this.definition.resistanceX, context.environment, 0.05);\n const resistanceY = this.values.number(\"resistanceY\", this.definition.resistanceY, context.environment, 0.1);\n const gravity = this.values.number(\"gravity\", this.definition.gravity, context.environment, this.defaultGravity);\n this.state.vx -= this.state.vx * resistanceX;\n this.state.vy = this.state.vy - this.state.vy * resistanceY + gravity;\n this.modX += this.state.vx % 1;\n this.modY += this.state.vy % 1;\n const dx = Math.trunc(this.state.vx) + Math.trunc(this.modX);\n const dy = Math.trunc(this.state.vy) + Math.trunc(this.modY);\n this.modX %= 1;\n this.modY %= 1;\n const divisions = Math.max(1, Math.abs(dx), Math.abs(dy));\n const start = { x: this.state.x, y: this.state.y };\n let stopped = false;\n for (let index = 0; index <= divisions; index += 1) {\n const x = start.x + Math.trunc((dx * index) / divisions);\n const y = start.y + Math.trunc((dy * index) / divisions);\n this.state.x = x;\n this.state.y = y;\n if (dy > 0) {\n for (let offset = -80; offset <= 0; offset += 1) {\n this.state.y = y + offset;\n if (isOnFloor(this.state, context.bounds, context.platforms)) { stopped = true; break; }\n }\n if (stopped) break;\n this.state.y = y;\n }\n if (isOnWall(this.state, context.bounds, this.state.lookRight, context.platforms)) break;\n }\n const fallEnvironment = { ...context.environment, velocityX: this.state.vx, velocityY: this.state.vy };\n const animation = this.definition.animations?.find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, fallEnvironment, true));\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n return \"running\";\n }\n}\n\nfunction matchingActivePlatform(context: RuntimeContext): PlatformRectangle | undefined {\n const active = context.environment.mascot.environment.activeIE;\n if (!active.visible) return undefined;\n return context.platforms.find((platform) =>\n Math.abs(platform.x - active.x) < 0.001\n && Math.abs(platform.y - active.y) < 0.001\n && Math.abs(platform.width - active.width) < 0.001\n && Math.abs(platform.height - active.height) < 0.001);\n}\n\nfunction carryRelation(state: MascotState, platform: Rectangle, offsetX: number, offsetY: number): boolean {\n const grip = {\n x: state.x + (state.lookRight ? -offsetX : offsetX),\n y: state.y + offsetY,\n };\n return isOnBottom(grip, platform)\n && (state.lookRight ? isOnLeft(grip, platform) : isOnRight(grip, platform));\n}\n\nfunction carriedPlatformPosition(state: MascotState, platform: Rectangle, offsetX: number, offsetY: number): Point {\n return state.lookRight\n ? { x: state.x - offsetX, y: state.y + offsetY - platform.height }\n : { x: state.x + offsetX - platform.width, y: state.y + offsetY - platform.height };\n}\n\nclass CarryFallRuntime extends FallRuntime {\n private element: HTMLElement | undefined;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, gravity: number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random, gravity);\n }\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.element = matchingActivePlatform(context)?.element;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const platform = context.platforms.find((candidate) => candidate.element === this.element);\n const offsetX = Math.trunc(this.values.number(\"ieOffsetX\", this.definition.ieOffsetX, context.environment, 0));\n const offsetY = Math.trunc(this.values.number(\"ieOffsetY\", this.definition.ieOffsetY, context.environment, 0));\n if (!platform || !carryRelation(this.state, platform, offsetX, offsetY)) return \"lost-ground\";\n const result = super.tick(context);\n this.callbacks.movePlatform?.(platform.element, carriedPlatformPosition(this.state, platform, offsetX, offsetY));\n return result;\n }\n}\n\nclass CarryMoveRuntime extends MoveRuntime {\n private element: HTMLElement | undefined;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.element = matchingActivePlatform(context)?.element;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const platform = context.platforms.find((candidate) => candidate.element === this.element);\n const offsetX = Math.trunc(this.values.number(\"ieOffsetX\", this.definition.ieOffsetX, context.environment, 0));\n const offsetY = Math.trunc(this.values.number(\"ieOffsetY\", this.definition.ieOffsetY, context.environment, 0));\n if (!platform || !carryRelation(this.state, platform, offsetX, offsetY)) return \"lost-ground\";\n const result = super.tick(context);\n this.callbacks.movePlatform?.(platform.element, carriedPlatformPosition(this.state, platform, offsetX, offsetY));\n return result;\n }\n}\n\nclass ThrowPlatformRuntime extends AnimateRuntime {\n private element: HTMLElement | undefined;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.element = matchingActivePlatform(context)?.element;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n const platform = context.platforms.find((candidate) => candidate.element === this.element);\n if (platform) {\n const vx = Math.trunc(this.values.number(\"initialVx\", this.definition.initialVx, context.environment, 32));\n const vy = Math.trunc(this.values.number(\"initialVy\", this.definition.initialVy, context.environment, -10));\n const gravity = this.values.number(\"gravity\", this.definition.gravity, context.environment, 0.5);\n this.callbacks.movePlatform?.(platform.element, {\n x: platform.x + (this.state.lookRight ? vx : -vx),\n y: platform.y + vy + Math.trunc(this.time * gravity),\n });\n }\n return result;\n }\n}\n\nfunction breed(\n definition: ActionDefinition,\n state: MascotState,\n values: ActionValues,\n context: RuntimeContext,\n callbacks: ActionExecutorCallbacks,\n): void {\n const bornX = Math.trunc(values.number(\"bornX\", definition.bornX, context.environment, 0));\n const bornY = Math.trunc(values.number(\"bornY\", definition.bornY, context.environment, 0));\n const count = Math.trunc(values.number(\"bornCount\", definition.bornCount, context.environment, 1));\n if (count < 1) throw new RangeError(\"BornCount must be positive\");\n for (let index = 0; index < count; index += 1) {\n callbacks.spawn({\n x: state.x + (state.lookRight ? -bornX : bornX),\n y: state.y + bornY,\n lookRight: state.lookRight,\n ...(definition.bornBehavior && { behaviorName: definition.bornBehavior }),\n }, definition.bornMascot);\n }\n}\n\nclass BreedRuntime extends AnimateRuntime {\n private spawned = false;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random);\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n if (result === \"lost-ground\") return result;\n const duration = this.animationDuration(context);\n if (!this.spawned && this.time === duration - 1) {\n this.spawned = true;\n breed(this.definition, this.state, this.values, context, this.callbacks);\n }\n return result;\n }\n}\n\nclass BreedMoveRuntime extends MoveRuntime {\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) { super(definition, state, random); }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n if (result === \"lost-ground\") return result;\n const interval = Math.trunc(this.values.number(\"bornInterval\", this.definition.bornInterval, context.environment, 1));\n if (interval < 1) throw new RangeError(\"BornInterval must be positive\");\n if (this.time % interval === 0 && !this.turning) breed(this.definition, this.state, this.values, context, this.callbacks);\n return result;\n }\n}\n\nclass BreedJumpRuntime extends JumpRuntime {\n public constructor(definition: ActionDefinition, private readonly breedState: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) { super(definition, breedState, random); }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n const interval = Math.trunc(this.values.number(\"bornInterval\", this.definition.bornInterval, context.environment, 1));\n if (interval < 1) throw new RangeError(\"BornInterval must be positive\");\n if (this.time % interval === 0) breed(this.definition, this.breedState, this.values, context, this.callbacks);\n return result;\n }\n}\n\nclass DraggedRuntime extends RuntimeBase {\n private footX = 0;\n private footDx = 0;\n private timeToRegist = 250;\n\n public constructor(definition: ActionDefinition, private readonly state: MascotState, random: () => number, private readonly spec: CharacterSpec) { super(definition, random); }\n\n protected override onInit(context: RuntimeContext): void {\n this.footDx = 0;\n this.timeToRegist = 250;\n this.footX = context.environment.mascot.environment.cursor.x + this.offsetX(context);\n }\n\n protected override hasMore(): boolean { return this.time < this.timeToRegist; }\n\n protected override tick(context: RuntimeContext): \"running\" {\n this.state.lookRight = false;\n this.state.dragging = true;\n const cursor = context.environment.mascot.environment.cursor;\n const offsetX = this.offsetX(context);\n const offsetY = this.offsetY(context);\n if (Math.abs(cursor.x - this.state.x + offsetX) >= 5) this.time = 0;\n this.footDx = (this.footDx + (cursor.x - this.footX) * 0.1) * 0.8;\n this.footX += this.footDx;\n const environment = { ...context.environment, footX: this.footX };\n const animation = this.definition.animations?.find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, environment, true));\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n this.state.x = cursor.x + offsetX;\n this.state.y = cursor.y + offsetY;\n if (this.time === this.timeToRegist - 1 && this.values.number(`regist-${this.time}`, \"#{Math.random()}\", environment, 0) >= 0.1) this.timeToRegist += 1;\n return \"running\";\n }\n\n private offsetX(context: RuntimeContext): number {\n const offset = Math.trunc(this.values.number(\"offsetX\", this.definition.offsetX, context.environment, 0));\n return this.definition.offsetType === \"Origin\" ? -offset + this.spriteCenter().x : offset;\n }\n\n private offsetY(context: RuntimeContext): number {\n const offset = Math.trunc(this.values.number(\"offsetY\", this.definition.offsetY, context.environment, 120));\n return this.definition.offsetType === \"Origin\" ? -offset + this.spriteCenter().y : offset;\n }\n\n private spriteCenter(): Point {\n const sprite = this.spec.sprites[this.state.sprite];\n const width = typeof sprite === \"object\" ? (sprite.width ?? 128) : 128;\n return { x: this.state.lookRight ? width - this.state.anchorX : this.state.anchorX, y: this.state.anchorY };\n }\n}\n\nclass RegistRuntime extends AnimatedRuntime {\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly spec: CharacterSpec) { super(definition, state, random); }\n\n protected override hasMore(context: RuntimeContext): boolean {\n const cursor = context.environment.mascot.environment.cursor;\n const rawOffset = Math.trunc(this.values.number(\"offsetX\", this.definition.offsetX, context.environment, 0));\n const sprite = this.spec.sprites[this.state.sprite];\n const width = typeof sprite === \"object\" ? (sprite.width ?? 128) : 128;\n const centerX = this.state.lookRight ? width - this.state.anchorX : this.state.anchorX;\n const offsetX = this.definition.offsetType === \"Origin\" ? -rawOffset + centerX : rawOffset;\n return Math.abs(cursor.x - this.state.x + offsetX) < 5;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n this.state.dragging = true;\n this.applyAnimation(context);\n if (this.time + 1 >= this.animationDuration(context)) {\n this.state.lookRight = this.values.number(`look-${this.time}`, \"#{Math.random()}\", context.environment, 0) < 0.5;\n return \"lost-ground\";\n }\n return \"running\";\n }\n}\n\nclass SelfDestructRuntime extends AnimateRuntime {\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) { super(definition, state, random); }\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n if (this.time === this.animationDuration(context) - 1) this.callbacks.remove();\n return result;\n }\n}\n\nclass ComplexRuntime extends RuntimeBase {\n private index = 0;\n private child: Runtime | undefined;\n private selectionMade = false;\n\n public constructor(\n definition: ActionDefinition,\n random: () => number,\n private readonly factory: (definition: ActionDefinition, context: RuntimeContext) => Runtime,\n private readonly selectOnly: boolean,\n ) { super(definition, random); }\n\n protected override onInit(context: RuntimeContext): void {\n this.index = 0;\n this.child = undefined;\n this.selectionMade = false;\n if (this.baseHasNext(context)) this.seek(context);\n }\n\n protected override hasMore(context: RuntimeContext): boolean {\n if (!this.selectOnly) this.seek(context);\n return this.child?.hasNext(context) ?? false;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n return this.child?.hasNext(context) ? this.child.step(context) : \"running\";\n }\n\n private seek(context: RuntimeContext): void {\n const definitions = this.definition.actions ?? [];\n if (definitions.length === 0) return;\n for (let guard = 0; guard <= definitions.length; guard += 1) {\n if (this.child?.hasNext(context)) { this.selectionMade = true; return; }\n if (this.selectOnly && this.selectionMade) { this.child = undefined; return; }\n if (this.index >= definitions.length) {\n if (this.definition.loop !== true) { this.child = undefined; return; }\n this.index = 0;\n }\n const definition = definitions[this.index++];\n if (!definition) { this.child = undefined; return; }\n this.child = this.factory(definition, context);\n this.child.init(context);\n }\n this.child = undefined;\n }\n}\n\n/** Executes normalized action trees using Shimeji-ee's discrete action lifecycle. */\nexport class ActionExecutor {\n private runtime: Runtime | undefined;\n private accumulator = 0;\n private readonly random: () => number;\n\n public constructor(\n private readonly spec: CharacterSpec,\n private readonly state: MascotState,\n private readonly options: ActionExecutorOptions,\n private readonly callbacks: ActionExecutorCallbacks,\n ) { this.random = options.random ?? Math.random; }\n\n /** Starts the action whose name matches a selected behavior. */\n public start(\n actionName: string,\n environment: MascotEnvironment,\n _preserveLookRight = false,\n bounds: Rectangle = environment.mascot.environment.workArea,\n platforms: readonly PlatformRectangle[] = [],\n ): boolean {\n const definition = this.spec.actions.find((action) => action.name === actionName);\n this.accumulator = 0;\n if (!definition) { this.runtime = undefined; return false; }\n const context = { environment, bounds, platforms };\n this.runtime = this.createRuntime(definition, context, new Set());\n this.runtime.init(context);\n return true;\n }\n\n /** Advances by elapsed milliseconds and reports completion. */\n public tick(deltaMs: number, environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[] = []): boolean {\n this.accumulator += Math.max(0, deltaMs);\n let result: ActionTickResult = this.runtime?.hasNext({ environment, bounds, platforms }) ? \"running\" : \"complete\";\n while (this.accumulator >= this.options.frameDuration && result === \"running\") {\n this.accumulator -= this.options.frameDuration;\n result = this.step(environment, bounds, platforms);\n }\n return result !== \"running\";\n }\n\n /** Advances exactly one legacy frame. */\n public step(environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[] = []): ActionTickResult {\n const context = { environment, bounds, platforms };\n if (!this.runtime?.hasNext(context)) return \"complete\";\n const result = this.runtime.step(context);\n if (result === \"lost-ground\") return result;\n return this.runtime.hasNext(context) ? \"running\" : \"complete\";\n }\n\n /** Returns whether the current action can execute another legacy frame. */\n public hasNext(environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[] = []): boolean {\n return this.runtime?.hasNext({ environment, bounds, platforms }) ?? false;\n }\n\n /** Retained for source compatibility with the previous collision API. */\n public consumeViewportWallCollision(): boolean { return false; }\n\n /** Cancels the current action tree. */\n public cancel(): void { this.runtime = undefined; this.accumulator = 0; }\n\n private createRuntime(definition: ActionDefinition, context: RuntimeContext, references: Set<string>): Runtime {\n if (definition.type === \"Reference\") {\n if (!definition.name || references.has(definition.name)) return new InstantRuntime(definition, this.state, this.random, \"noop\");\n const referenced = this.spec.actions.find((action) => action.name === definition.name);\n if (!referenced) return new InstantRuntime(definition, this.state, this.random, \"noop\");\n return this.createRuntime({ ...referenced, ...definition, type: referenced.type, name: definition.name }, context, new Set(references).add(definition.name));\n }\n if (definition.type === \"Sequence\" || definition.type === \"Select\") {\n return new ComplexRuntime(definition, this.random, (child, nextContext) => this.createRuntime(child, nextContext, new Set(references)), definition.type === \"Select\");\n }\n if (definition.type === \"Stay\") return new StayRuntime(definition, this.state, this.random);\n if (definition.type === \"Animate\") return new AnimateRuntime(definition, this.state, this.random);\n if (definition.type === \"Move\") return new MoveRuntime(definition, this.state, this.random);\n switch (definition.embedType) {\n case \"Fall\": return new FallRuntime(definition, this.state, this.random, this.options.gravity);\n case \"FallWithIE\": return new CarryFallRuntime(definition, this.state, this.random, this.options.gravity, this.callbacks);\n case \"Jump\": case \"ComplexJump\": case \"ScanJump\": case \"BroadcastJump\": return new JumpRuntime(definition, this.state, this.random);\n case \"WalkWithIE\": return new CarryMoveRuntime(definition, this.state, this.random, this.callbacks);\n case \"MoveWithTurn\": return new MoveWithTurnRuntime(definition, this.state, this.random);\n case \"ComplexMove\": case \"ScanMove\": case \"BroadcastMove\": return new MoveRuntime(definition, this.state, this.random);\n case \"Turn\": return new TurnRuntime(definition, this.state, this.random);\n case \"Look\": return new InstantRuntime(definition, this.state, this.random, \"look\");\n case \"Offset\": return new InstantRuntime(definition, this.state, this.random, \"offset\");\n case \"Mute\": case \"Reboot\": return new InstantRuntime(definition, this.state, this.random, \"noop\");\n case \"Breed\": return new BreedRuntime(definition, this.state, this.random, this.callbacks);\n case \"BreedMove\": return new BreedMoveRuntime(definition, this.state, this.random, this.callbacks);\n case \"BreedJump\": return new BreedJumpRuntime(definition, this.state, this.random, this.callbacks);\n case \"ThrowIE\": return new ThrowPlatformRuntime(definition, this.state, this.random, this.callbacks);\n case \"SelfDestruct\": case \"Exit\": return new SelfDestructRuntime(definition, this.state, this.random, this.callbacks);\n case \"Dragged\": return new DraggedRuntime(definition, this.state, this.random, this.spec);\n case \"Regist\": return new RegistRuntime(definition, this.state, this.random, this.spec);\n case \"Broadcast\": case \"Interact\": case \"ScanInteract\": case \"Transform\": return new AnimateRuntime(definition, this.state, this.random);\n case \"BroadcastStay\": return new StayRuntime(definition, this.state, this.random);\n default: return new StayRuntime(definition, this.state, this.random);\n }\n }\n}\n","import { ActionExecutor } from \"./action\";\nimport { BehaviorController } from \"./behavior\";\nimport type { DomManager, MascotDomHandle } from \"./dom\";\nimport { isOnBottom, isOnFloor, isOnLeft, isOnRight, isOnTop } from \"./physics\";\nimport type { PlatformRectangle } from \"./platform\";\nimport type { BehaviorDefinition, CharacterSpec, EnvironmentEdge, EnvironmentRectangle, MascotEnvironment, MascotState, Point, Rectangle, ShimejiEngineOptions, SpawnOptions } from \"./types\";\n\n/** Callbacks through which a mascot communicates with its owning engine. */\nexport interface MascotCallbacks {\n /** Returns the latest pointer position and velocity in work-area coordinates. */\n pointer(): Point & { dx: number; dy: number };\n /** Returns the current number of live mascots. */\n count(): number;\n /** Requests a sibling mascot. */\n spawn(characterId: string, options: SpawnOptions): void;\n /** Requests removal of this mascot. */\n remove(id: string): void;\n /** Moves a registered platform for legacy IE interaction actions. */\n movePlatform?(element: HTMLElement, point: Point): void;\n /** Reports a click without a drag gesture. */\n click(state: MascotState): void;\n /** Reports a recoverable runtime failure. */\n error(error: Error): void;\n}\n\nfunction edge(predicate: (point: Point) => boolean): EnvironmentEdge { return { isOn: predicate }; }\n\nfunction environmentRectangle(bounds: Rectangle): EnvironmentRectangle {\n const left = bounds.x;\n const right = bounds.x + bounds.width;\n const top = bounds.y;\n const bottom = bounds.y + bounds.height;\n return {\n x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height,\n left, right, top, bottom,\n topBorder: edge((point) => isOnTop(point, bounds)),\n leftBorder: edge((point) => isOnLeft(point, bounds)),\n rightBorder: edge((point) => isOnRight(point, bounds)),\n bottomBorder: edge((point) => isOnBottom(point, bounds)),\n };\n}\n\nconst PLATFORM_NEARBY_DISTANCE = 400;\nconst PLATFORM_EDGE_TOLERANCE = 2;\nconst MASCOT_HITBOX_MAX_WIDTH = 32;\nconst MASCOT_HITBOX_MAX_HEIGHT = 64;\nconst MASCOT_COLLISION_LOOKAHEAD = 4;\nconst IE_BEHAVIOR_NAME_PATTERN = /wall|climb|crawl|壁|登|よじ/i;\n\n/** Lightweight geometry shared between mascots for behavioral collision avoidance. */\nexport interface MascotCollisionBox extends Rectangle {\n id: string;\n}\n\nfunction isIEBehavior(behavior: BehaviorDefinition): boolean {\n return behavior.conditions.some((condition) => /activeIE/i.test(condition))\n || behavior.name.includes(\"IE\")\n || behavior.name.includes(\"IE\")\n || IE_BEHAVIOR_NAME_PATTERN.test(behavior.name)\n || (behavior.actionName !== undefined && (\n behavior.actionName.includes(\"IE\")\n || behavior.actionName.includes(\"IE\")\n || IE_BEHAVIOR_NAME_PATTERN.test(behavior.actionName)\n ));\n}\n\nfunction distanceToRectangle(point: Point, rectangle: Rectangle): number {\n const dx = Math.max(rectangle.x - point.x, 0, point.x - rectangle.x - rectangle.width);\n const dy = Math.max(rectangle.y - point.y, 0, point.y - rectangle.y - rectangle.height);\n return Math.hypot(dx, dy);\n}\n\n/** Owns one mascot's state machine, interaction listeners, and DOM resource. */\nexport class Mascot {\n /** Mutable internal state; callers should consume snapshots from the engine. */\n public readonly state: MascotState;\n private readonly domHandle: MascotDomHandle;\n private readonly behavior: BehaviorController;\n private readonly actions: ActionExecutor;\n private readonly disposers: Array<() => void> = [];\n private currentBehavior: BehaviorDefinition | undefined;\n private destroyed = false;\n private dragOffset: Point = { x: 0, y: 0 };\n private pointerId: number | undefined;\n private pointerDown: Point | undefined;\n private lastPointer: Point | undefined;\n private activePlatformElement: HTMLElement | undefined;\n private platforms: readonly PlatformRectangle[] = [];\n private accumulatedMs = 0;\n private readonly frameDuration: number;\n private readonly random: () => number;\n private readonly forceInitialFall: boolean;\n\n /** Creates a mascot and immediately installs its pointer handlers. */\n public constructor(\n public readonly id: string,\n public readonly spec: CharacterSpec,\n private readonly dom: DomManager,\n options: Required<Pick<ShimejiEngineOptions, \"frameDuration\" | \"gravity\" | \"mascotClassName\">> & { random: (() => number) | undefined },\n spawnOptions: SpawnOptions,\n private readonly callbacks: MascotCallbacks,\n ) {\n const initialPose = spec.actions.flatMap((action) => action.animations ?? []).flatMap((animation) => animation.poses)[0];\n this.state = {\n id,\n characterId: spec.id,\n x: spawnOptions.x ?? 0,\n y: spawnOptions.y ?? 0,\n vx: spawnOptions.vx ?? 0,\n vy: spawnOptions.vy ?? 0,\n sprite: initialPose?.sprite ?? Object.keys(spec.sprites)[0] ?? \"\",\n anchorX: initialPose?.anchor.x ?? 64,\n anchorY: initialPose?.anchor.y ?? 128,\n lookRight: spawnOptions.lookRight ?? false,\n behaviorName: spawnOptions.behaviorName ?? \"Fall\",\n dragging: false,\n };\n this.domHandle = dom.createMascot(spec, id, options.mascotClassName || undefined);\n this.frameDuration = options.frameDuration;\n this.random = options.random ?? Math.random;\n this.forceInitialFall = spawnOptions.behaviorName === undefined;\n this.behavior = new BehaviorController(spec, options.random);\n this.actions = new ActionExecutor(spec, this.state, options, {\n spawn: (position, characterId) => this.callbacks.spawn(characterId ?? this.spec.id, position),\n remove: () => this.callbacks.remove(this.id),\n ...(this.callbacks.movePlatform && { movePlatform: this.callbacks.movePlatform }),\n });\n this.installPointerHandlers();\n }\n\n /** Advances behavior, animation, physics, and rendering by one clock tick. */\n public tick(\n deltaMs: number,\n bounds: Rectangle,\n platforms: readonly PlatformRectangle[] = [],\n siblings: readonly MascotCollisionBox[] = [],\n ): void {\n if (this.destroyed) return;\n this.platforms = platforms;\n try {\n this.ensureBehavior(bounds, platforms, true);\n this.accumulatedMs += Math.max(0, deltaMs);\n while (this.accumulatedMs >= this.frameDuration && !this.destroyed) {\n this.accumulatedMs -= this.frameDuration;\n this.legacyTick(bounds, platforms, siblings);\n }\n } catch (error) {\n this.callbacks.error(error instanceof Error ? error : new Error(String(error)));\n this.currentBehavior = undefined;\n this.actions.cancel();\n }\n this.dom.render(this.domHandle, this.spec, this.state);\n }\n\n /** Returns a detached snapshot safe for application code to retain. */\n public snapshot(): MascotState { return { ...this.state }; }\n\n /** Returns the mascot's compact, feet-aligned behavioral collision box. */\n public collisionBox(): MascotCollisionBox {\n const sprite = this.spec.sprites[this.state.sprite];\n const spriteWidth = typeof sprite === \"object\" && sprite.width !== undefined ? sprite.width : 128;\n const spriteHeight = typeof sprite === \"object\" && sprite.height !== undefined ? sprite.height : 128;\n const width = Math.min(spriteWidth, MASCOT_HITBOX_MAX_WIDTH);\n const height = Math.min(spriteHeight, MASCOT_HITBOX_MAX_HEIGHT);\n const anchorX = this.state.lookRight ? spriteWidth - this.state.anchorX : this.state.anchorX;\n const visualLeft = this.state.x - anchorX;\n const visualTop = this.state.y - this.state.anchorY;\n return {\n id: this.id,\n x: visualLeft + (spriteWidth - width) / 2,\n y: visualTop + spriteHeight - height,\n width,\n height,\n };\n }\n\n /** Removes listeners, DOM nodes, and object URLs owned by this mascot. */\n public destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.actions.cancel();\n for (const dispose of this.disposers.splice(0)) dispose();\n this.dom.removeMascot(this.domHandle);\n }\n\n private startBehavior(environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[]): boolean {\n if (!this.currentBehavior) return false;\n this.state.behaviorName = this.currentBehavior.name;\n return this.actions.start(this.currentBehavior.actionName ?? this.currentBehavior.name, environment, false, bounds, platforms);\n }\n\n private ensureBehavior(bounds: Rectangle, platforms: readonly PlatformRectangle[], initial: boolean): void {\n for (let guard = 0; guard < 32 && !this.destroyed; guard += 1) {\n const environment = this.createEnvironment(bounds, platforms);\n if (!this.currentBehavior) {\n this.currentBehavior = initial\n ? this.forceInitialFall\n ? this.findFallBehavior() ?? this.behavior.selectInitial(environment)\n : this.behavior.selectInitial(environment, this.state.behaviorName)\n : this.selectNextBehavior(environment, bounds);\n initial = false;\n if (!this.currentBehavior) this.currentBehavior = this.findFallBehavior();\n if (!this.currentBehavior || !this.startBehavior(environment, bounds, platforms)) return;\n }\n if (this.actions.hasNext(environment, bounds, platforms)) return;\n this.currentBehavior = this.selectNextBehavior(environment, bounds) ?? this.findFallBehavior();\n if (!this.currentBehavior) return;\n if (!this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms)) return;\n }\n }\n\n private legacyTick(\n bounds: Rectangle,\n platforms: readonly PlatformRectangle[],\n siblings: readonly MascotCollisionBox[],\n ): void {\n this.ensureBehavior(bounds, platforms, false);\n if (!this.currentBehavior) return;\n const previous = { x: this.state.x, y: this.state.y };\n const result = this.actions.step(this.createEnvironment(bounds, platforms), bounds, platforms);\n if (this.destroyed) return;\n this.avoidSiblingCollision(previous, bounds, platforms, siblings);\n if (result === \"lost-ground\") {\n this.state.dragging = false;\n this.actions.cancel();\n this.currentBehavior = this.selectEdgeBehavior(bounds, platforms);\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms);\n } else if (result === \"complete\") {\n this.currentBehavior = this.selectNextBehavior(this.createEnvironment(bounds, platforms), bounds);\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms);\n this.ensureBehavior(bounds, platforms, false);\n } else if (this.isOutsideVisibleBounds(bounds)) {\n this.state.x = Math.trunc(bounds.x + this.random() * bounds.width);\n this.state.y = bounds.y - 256;\n this.actions.cancel();\n this.currentBehavior = this.findFallBehavior();\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms);\n }\n }\n\n private avoidSiblingCollision(\n previous: Point,\n bounds: Rectangle,\n platforms: readonly PlatformRectangle[],\n siblings: readonly MascotCollisionBox[],\n ): void {\n const dx = this.state.x - previous.x;\n if (this.state.dragging || dx === 0 || this.state.y !== previous.y) return;\n const onHorizontalSurface = isOnFloor(previous, bounds, platforms)\n || isOnTop(previous, bounds)\n || platforms.some((platform) => isOnBottom(previous, platform));\n if (!onHorizontalSurface) return;\n\n const currentBox = this.collisionBox();\n const offsetX = currentBox.x - this.state.x;\n const previousBox = { ...currentBox, x: previous.x + offsetX };\n const movingRight = dx > 0;\n const sweptLeft = Math.min(previousBox.x, currentBox.x) - (movingRight ? 0 : MASCOT_COLLISION_LOOKAHEAD);\n const sweptRight = Math.max(previousBox.x + previousBox.width, currentBox.x + currentBox.width)\n + (movingRight ? MASCOT_COLLISION_LOOKAHEAD : 0);\n const previousCenterX = previousBox.x + previousBox.width / 2;\n\n const collision = siblings.some((sibling) => {\n if (sibling.id === this.id) return false;\n const siblingCenterX = sibling.x + sibling.width / 2;\n const isAhead = movingRight ? siblingCenterX >= previousCenterX : siblingCenterX <= previousCenterX;\n const overlapsVertically = currentBox.y < sibling.y + sibling.height\n && sibling.y < currentBox.y + currentBox.height;\n const crossesHorizontally = sweptLeft <= sibling.x + sibling.width && sibling.x <= sweptRight;\n // Skip collision when already overlapping — avoid infinite flip-flop on spawn\n const wasAlreadyOverlapping = overlapsVertically\n && previousBox.x < sibling.x + sibling.width && sibling.x < previousBox.x + previousBox.width;\n return isAhead && overlapsVertically && crossesHorizontally && !wasAlreadyOverlapping;\n });\n if (!collision) return;\n\n this.state.x = previous.x;\n this.state.vx = 0;\n this.state.lookRight = !this.state.lookRight;\n }\n\n private isOutsideVisibleBounds(bounds: Rectangle): boolean {\n const sprite = this.spec.sprites[this.state.sprite];\n const width = typeof sprite === \"object\" && \"width\" in sprite && sprite.width !== undefined ? sprite.width : 128;\n const height = typeof sprite === \"object\" && \"height\" in sprite && sprite.height !== undefined ? sprite.height : 128;\n const anchorX = this.state.lookRight ? width - this.state.anchorX : this.state.anchorX;\n const left = this.state.x - anchorX;\n const top = this.state.y - this.state.anchorY;\n return left + width <= bounds.x || bounds.x + bounds.width <= left || bounds.y + bounds.height <= top;\n }\n\n private findFallBehavior(): BehaviorDefinition | undefined {\n return this.behavior.force(\"Fall\") ?? this.behavior.force(\"落下する\");\n }\n\n private selectNextBehavior(environment: MascotEnvironment, bounds: Rectangle, relocateOnFallback = true): BehaviorDefinition | undefined {\n const selected = this.behavior.selectNext(environment);\n if (relocateOnFallback && this.behavior.usedFallback()) {\n this.state.x = Math.trunc(bounds.x + this.random() * bounds.width);\n this.state.y = bounds.y - 256;\n }\n return selected;\n }\n\n private selectEdgeBehavior(bounds: Rectangle, platforms: readonly PlatformRectangle[]): BehaviorDefinition | undefined {\n const original = { x: this.state.x, y: this.state.y };\n const platform = platforms.find((candidate) => candidate.element === this.activePlatformElement);\n if (platform) {\n const left = platform.x;\n const right = platform.x + platform.width;\n const top = platform.y;\n const bottom = platform.y + platform.height;\n if (Math.abs(this.state.y - top) <= PLATFORM_EDGE_TOLERANCE || Math.abs(this.state.y - bottom) <= PLATFORM_EDGE_TOLERANCE) {\n if (this.state.x < left) this.state.x = left;\n else if (this.state.x > right) this.state.x = right;\n } else if (Math.abs(this.state.x - left) <= PLATFORM_EDGE_TOLERANCE || Math.abs(this.state.x - right) <= PLATFORM_EDGE_TOLERANCE) {\n if (this.state.y < top) this.state.y = top;\n else if (this.state.y > bottom) this.state.y = bottom;\n }\n }\n\n const environment = this.createEnvironment(bounds, platforms);\n const interruptedBehavior = this.currentBehavior;\n const selected = this.behavior.trySelectNext(environment, (candidate) => (\n candidate.name !== interruptedBehavior?.name && isIEBehavior(candidate)\n ))\n ?? this.selectNextBehavior(environment, bounds, false);\n if (this.behavior.usedFallback() || selected?.name === \"Fall\" || selected?.name === \"落下する\") {\n this.state.x = original.x;\n this.state.y = original.y;\n }\n return selected ?? this.findFallBehavior();\n }\n\n private createEnvironment(bounds: Rectangle, platforms: readonly PlatformRectangle[] = this.platforms): MascotEnvironment {\n const workArea = environmentRectangle(bounds);\n const inactive = environmentRectangle({ x: -100, y: -100, width: 0, height: 0 });\n const platform = this.selectActivePlatform(platforms);\n const activeIE = platform\n ? { ...environmentRectangle(platform), visible: true }\n : { ...inactive, visible: false };\n return {\n gap: 0,\n maxCount: 999,\n mascot: {\n totalCount: this.callbacks.count(),\n anchor: { x: this.state.x, y: this.state.y },\n lookRight: this.state.lookRight,\n environment: {\n cursor: this.callbacks.pointer(),\n screen: workArea,\n workArea,\n floor: edge((point) => isOnFloor(point, bounds, platforms)),\n ceiling: edge((point) => isOnTop(point, bounds) || platforms.some((candidate) => isOnBottom(point, candidate))),\n activeIE,\n },\n },\n };\n }\n\n private selectActivePlatform(platforms: readonly PlatformRectangle[]): PlatformRectangle | undefined {\n if (platforms.length === 0) {\n this.activePlatformElement = undefined;\n return undefined;\n }\n const anchor = this.state;\n const current = platforms.find((platform) => platform.element === this.activePlatformElement);\n if (current && (\n isOnTop(anchor, current, PLATFORM_EDGE_TOLERANCE)\n || isOnBottom(anchor, current, PLATFORM_EDGE_TOLERANCE)\n || isOnLeft(anchor, current, PLATFORM_EDGE_TOLERANCE)\n || isOnRight(anchor, current, PLATFORM_EDGE_TOLERANCE)\n )) return current;\n\n if (this.state.vy >= 0) {\n const landingPlatform = platforms\n .filter((platform) => anchor.x >= platform.x && anchor.x <= platform.x + platform.width && platform.y >= anchor.y - 1)\n .sort((left, right) => left.y - right.y)[0];\n if (landingPlatform) {\n this.activePlatformElement = landingPlatform.element;\n return landingPlatform;\n }\n }\n\n const nearby = [...platforms]\n .map((platform) => ({ platform, distance: distanceToRectangle(anchor, platform) }))\n .filter(({ distance }) => distance <= PLATFORM_NEARBY_DISTANCE)\n .sort((left, right) => left.distance - right.distance)[0]?.platform;\n this.activePlatformElement = nearby?.element;\n return nearby;\n }\n\n private installPointerHandlers(): void {\n const element = this.domHandle.spriteElement;\n const document = element.ownerDocument;\n const listen = <K extends keyof HTMLElementEventMap>(target: EventTarget, type: K, listener: (event: HTMLElementEventMap[K]) => void): void => {\n target.addEventListener(type, listener as EventListener);\n this.disposers.push(() => target.removeEventListener(type, listener as EventListener));\n };\n listen(element, \"pointerdown\", (event) => {\n const pointerEvent = event as PointerEvent;\n if (pointerEvent.button !== 0) return;\n event.preventDefault();\n const point = this.dom.toLocalPoint(pointerEvent.clientX, pointerEvent.clientY);\n this.pointerId = pointerEvent.pointerId;\n this.pointerDown = point;\n this.lastPointer = point;\n this.dragOffset = { x: this.state.x - point.x, y: this.state.y - point.y };\n this.state.dragging = true;\n this.currentBehavior = this.behavior.force(\"Dragged\") ?? this.behavior.force(\"ドラッグされる\");\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(this.dom.getBounds()), this.dom.getBounds(), this.platforms);\n element.setPointerCapture?.(pointerEvent.pointerId);\n });\n listen(document, \"pointermove\", (event) => {\n const pointerEvent = event as PointerEvent;\n if (!this.state.dragging || pointerEvent.pointerId !== this.pointerId) return;\n const point = this.dom.toLocalPoint(pointerEvent.clientX, pointerEvent.clientY);\n const previous = this.lastPointer ?? point;\n const bounds = this.dom.getBounds();\n this.state.vx = (point.x - previous.x) * 0.8;\n this.state.vy = (point.y - previous.y) * 0.8;\n this.state.x = point.x + this.dragOffset.x;\n this.state.y = point.y + this.dragOffset.y;\n this.lastPointer = point;\n });\n listen(document, \"pointerup\", (event) => {\n const pointerEvent = event as PointerEvent;\n if (!this.state.dragging || pointerEvent.pointerId !== this.pointerId) return;\n this.state.dragging = false;\n const moved = this.pointerDown ? Math.hypot(this.lastPointer!.x - this.pointerDown.x, this.lastPointer!.y - this.pointerDown.y) : 0;\n this.pointerId = undefined;\n this.currentBehavior = this.behavior.force(\"Thrown\") ?? this.behavior.force(\"投げられる\") ?? this.findFallBehavior();\n if (this.currentBehavior) {\n const bounds = this.dom.getBounds();\n this.startBehavior(this.createEnvironment(bounds), bounds, this.platforms);\n }\n if (moved < 4) this.callbacks.click(this.snapshot());\n });\n }\n}\n","import type { Rectangle } from \"./types\";\n\n/** A platform rectangle paired with the DOM element that produced it. */\nexport interface PlatformRectangle extends Rectangle {\n element: HTMLElement;\n}\n\n/** Resolves a platform option into connected DOM elements contained by the supplied root. */\nexport function resolvePlatformElements(\n source: string | readonly HTMLElement[],\n root: Document | HTMLElement,\n excludedRoot?: HTMLElement,\n): HTMLElement[] {\n let elements: readonly Element[];\n if (typeof source === \"string\") {\n try {\n elements = [...root.querySelectorAll(source)];\n } catch {\n return [];\n }\n } else {\n elements = source;\n }\n const document = root.nodeType === 9 ? root as Document : root.ownerDocument;\n if (!document) return [];\n const HTMLElementConstructor = document.defaultView?.HTMLElement;\n if (!HTMLElementConstructor) return [];\n return [...new Set(elements)].filter((element): element is HTMLElement =>\n element instanceof HTMLElementConstructor\n && element.isConnected\n && root.contains(element)\n && (!excludedRoot || !excludedRoot.contains(element)),\n );\n}\n\n/** Reads platform bounds once and converts viewport coordinates to the supplied origin. */\nexport function readPlatformRectangles(\n elements: readonly HTMLElement[],\n workAreaRectangle: Pick<DOMRect, \"left\" | \"top\">,\n): PlatformRectangle[] {\n const rectangles: PlatformRectangle[] = [];\n for (const element of elements) {\n const rectangle = element.getBoundingClientRect();\n if (rectangle.width <= 0 || rectangle.height <= 0) continue;\n rectangles.push({\n element,\n x: rectangle.left - workAreaRectangle.left,\n y: rectangle.top - workAreaRectangle.top,\n width: rectangle.width,\n height: rectangle.height,\n });\n }\n return rectangles;\n}\n","import type { CharacterSpec, IndividualSprite, SpriteRectangle } from \"./types\";\n\n/** A resolved image and optional atlas crop for one sprite frame. */\nexport interface ResolvedSprite {\n /** Browser-loadable image URL. */\n url: string;\n /** Optional atlas crop. */\n rectangle?: SpriteRectangle;\n}\n\n/** A per-mascot spritesheet resource whose temporary URL can be released. */\nexport interface SpriteLease {\n /** URL used to render atlas-backed frames. */\n url: string;\n /** Releases any object URL owned by this lease. */\n release(): void;\n}\n\nfunction dataUriToBlob(source: string): Blob {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/s.exec(source);\n if (!match) throw new TypeError(\"Invalid image data URI\");\n const mimeType = match[1] ?? \"application/octet-stream\";\n const encoded = match[3] ?? \"\";\n const binary = match[2] ? atob(encoded) : decodeURIComponent(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);\n return new Blob([bytes], { type: mimeType });\n}\n\n/** Owns temporary sprite URLs and resolves atlas or individual image frames. */\nexport class SpriteManager {\n private readonly leases = new Set<SpriteLease>();\n\n /** Creates a separately releasable spritesheet lease for a mascot. */\n public acquire(source: string | Blob): SpriteLease {\n let url = typeof source === \"string\" ? source : \"\";\n let owned = false;\n if (typeof URL.createObjectURL === \"function\" && (typeof source !== \"string\" || source.startsWith(\"data:image\"))) {\n try {\n url = URL.createObjectURL(typeof source === \"string\" ? dataUriToBlob(source) : source);\n owned = true;\n } catch {\n if (typeof source !== \"string\") throw new Error(\"The current environment cannot create a URL for the spritesheet Blob\");\n }\n }\n let released = false;\n const lease: SpriteLease = {\n url,\n release: () => {\n if (released) return;\n released = true;\n this.leases.delete(lease);\n if (owned) URL.revokeObjectURL(url);\n },\n };\n this.leases.add(lease);\n return lease;\n }\n\n /** Resolves a sprite key using a lease and the character's sprite map. */\n public resolve(spec: CharacterSpec, lease: SpriteLease, spriteName: string): ResolvedSprite | undefined {\n const key = Object.keys(spec.sprites).find((candidate) => candidate.toLowerCase() === spriteName.toLowerCase());\n const sprite = key ? spec.sprites[key] : undefined;\n if (typeof sprite === \"string\") return { url: sprite };\n if (sprite && \"url\" in sprite && typeof sprite.url === \"string\" && !(\"x\" in sprite)) return { url: sprite.url };\n if (sprite && \"x\" in sprite) return { url: sprite.url ?? lease.url, rectangle: sprite };\n if (/^(?:data:|blob:|https?:|\\/)/.test(spriteName)) return { url: spriteName };\n return undefined;\n }\n\n /** Revokes every object URL that has not already been released. */\n public destroy(): void {\n for (const lease of [...this.leases]) lease.release();\n }\n}\n\n/** Returns whether a sprite definition is a standalone image object. */\nexport function isIndividualSprite(sprite: SpriteRectangle | IndividualSprite | string): sprite is IndividualSprite {\n return typeof sprite === \"object\" && \"url\" in sprite && !(\"x\" in sprite);\n}\n","import { DomManager } from \"./dom\";\nimport { normalizeCharacterSpec } from \"./loader\";\nimport { Mascot, type MascotCollisionBox } from \"./mascot\";\nimport { readPlatformRectangles, resolvePlatformElements, type PlatformRectangle } from \"./platform\";\nimport { SpriteManager } from \"./sprite\";\nimport type { CharacterSpec, MascotState, ShimejiEngineEventMap, ShimejiEngineOptions, ShimejiEventListener, SpawnOptions } from \"./types\";\n\nclass EventEmitter<Events extends object> {\n private readonly listeners = new Map<keyof Events, Set<(payload: never) => void>>();\n public on<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): () => void {\n const listeners = this.listeners.get(event) ?? new Set();\n listeners.add(listener as (payload: never) => void);\n this.listeners.set(event, listeners);\n return () => { listeners.delete(listener as (payload: never) => void); };\n }\n public emit<K extends keyof Events>(event: K, payload: Events[K]): void {\n for (const listener of [...(this.listeners.get(event) ?? [])]) listener(payload as never);\n }\n public clear(): void { this.listeners.clear(); }\n}\n\nconst defaults = {\n frameDuration: 40,\n gravity: 2,\n maxDeltaTime: 100,\n workAreaClassName: \"\",\n mascotClassName: \"\",\n platforms: [] as readonly HTMLElement[],\n} as const;\n\ntype ResolvedEngineOptions = Required<Omit<ShimejiEngineOptions, \"random\">> & { random: (() => number) | undefined };\n\n/** Framework-agnostic manager for character registration and live Shimeji mascots. */\nexport class ShimejiEngine {\n private readonly specs = new Map<string, CharacterSpec>();\n private readonly mascots = new Map<string, Mascot>();\n private readonly sprites = new SpriteManager();\n private readonly dom: DomManager;\n private readonly events = new EventEmitter<ShimejiEngineEventMap>();\n private readonly disposers: Array<() => void> = [];\n private readonly intervals = new Set<number>();\n private readonly options: ResolvedEngineOptions;\n private pointer = { x: 0, y: 0, dx: 0, dy: 0 };\n private animationFrame: number | undefined;\n private lastFrameTime: number | undefined;\n private nextMascotId = 1;\n private destroyed = false;\n private initialized = false;\n private platformSource: string | readonly HTMLElement[];\n private additionalPlatformElements: readonly HTMLElement[] = [];\n private readonly movedPlatforms = new Map<HTMLElement, { originalTransform: string; x: number; y: number }>();\n private readonly platformRectangles = new Map<HTMLElement, PlatformRectangle>();\n\n /** Creates and initializes an engine inside a host DOM element. */\n public constructor(private readonly container: HTMLElement, options: ShimejiEngineOptions = {}) {\n if (!container) throw new TypeError(\"ShimejiEngine requires a container element\");\n this.options = { ...defaults, ...options, random: options.random };\n this.platformSource = this.options.platforms;\n this.dom = new DomManager(container, this.sprites);\n this.initialize();\n }\n\n /** Starts the clock and container-aware listeners. Calling this method more than once is harmless. */\n public initialize(): void {\n this.assertAlive();\n if (this.initialized) return;\n this.initialized = true;\n const document = this.container.ownerDocument;\n const view = document.defaultView;\n if (!view) throw new Error(\"ShimejiEngine requires a container connected to a window\");\n this.listen(document, \"pointermove\", (event) => {\n const pointerEvent = event as PointerEvent;\n const { x, y } = this.dom.toLocalPoint(pointerEvent.clientX, pointerEvent.clientY);\n this.pointer = { x, y, dx: x - this.pointer.x, dy: y - this.pointer.y };\n });\n this.listen(view, \"resize\", () => this.renderAll());\n const maintenance = view.setInterval(() => this.dom.ensureMounted(), 2_000);\n this.intervals.add(maintenance);\n this.animationFrame = view.requestAnimationFrame(this.onAnimationFrame);\n }\n\n /** Registers or replaces a parsed or legacy character specification. */\n public registerCharacter(spec: CharacterSpec | unknown): string {\n this.assertAlive();\n const normalized = normalizeCharacterSpec(spec);\n this.specs.set(normalized.id, normalized);\n return normalized.id;\n }\n\n /** Unregisters a character and optionally removes all of its live mascots. */\n public unregisterCharacter(characterId: string, removeMascots = true): boolean {\n this.assertAlive();\n if (removeMascots) {\n for (const state of this.getState()) if (state.characterId === characterId) this.remove(state.id);\n }\n return this.specs.delete(characterId);\n }\n\n /** Returns identifiers for all currently registered characters. */\n public getCharacterIds(): string[] { return [...this.specs.keys()]; }\n\n /** Creates a mascot from a registered character and returns its instance id. */\n public spawn(characterId: string, position: SpawnOptions = {}): string {\n this.assertAlive();\n const spec = this.specs.get(characterId);\n if (!spec) throw new Error(`Character '${characterId}' is not registered`);\n const { bounds, platforms } = this.readFrameGeometry();\n const random = this.options.random ?? Math.random;\n const randomX = Math.trunc(bounds.x + random() * bounds.width);\n const spawnInset = Math.min(2, bounds.width / 2);\n const spawnOptions: SpawnOptions = {\n ...position,\n // Fall treats the wall in the facing direction as ground. Keep implicit\n // spawns clear of both side-wall tolerances so even random() === 0 falls.\n x: position.x ?? Math.min(Math.max(randomX, bounds.x + spawnInset), bounds.x + bounds.width - spawnInset),\n y: position.y ?? bounds.y + 2,\n };\n const id = `shimeji-${this.nextMascotId++}`;\n const mascot = new Mascot(id, spec, this.dom, this.options, spawnOptions, {\n pointer: () => ({ ...this.pointer }),\n count: () => this.mascots.size,\n spawn: (nextCharacterId, nextPosition) => { if (!this.destroyed) this.spawn(nextCharacterId, nextPosition); },\n remove: (mascotId) => { if (!this.destroyed) this.remove(mascotId); },\n movePlatform: (element, point) => this.movePlatform(element, point),\n click: (state) => this.events.emit(\"click\", state),\n error: (error) => this.events.emit(\"error\", error),\n });\n this.mascots.set(id, mascot);\n mascot.tick(0, bounds, platforms);\n const state = mascot.snapshot();\n this.events.emit(\"spawn\", state);\n this.emitState();\n return id;\n }\n\n /** Removes one mascot and all resources associated with it. */\n public remove(mascotId: string): boolean {\n this.assertAlive();\n const mascot = this.mascots.get(mascotId);\n if (!mascot) return false;\n const state = mascot.snapshot();\n this.mascots.delete(mascotId);\n mascot.destroy();\n this.events.emit(\"remove\", state);\n this.emitState();\n return true;\n }\n\n /** Removes every live mascot while leaving registered character specs available. */\n public removeAll(): void {\n this.assertAlive();\n for (const id of [...this.mascots.keys()]) this.remove(id);\n }\n\n /** Returns detached snapshots of every live mascot. */\n public getState(): MascotState[] { return [...this.mascots.values()].map((mascot) => mascot.snapshot()); }\n\n /** Subscribes to a typed engine event and returns an unsubscribe function. */\n public on<K extends keyof ShimejiEngineEventMap>(event: K, listener: ShimejiEventListener<K>): () => void {\n this.assertAlive();\n return this.events.on(event, listener);\n }\n\n /** Replaces the primary platform source and any additional registered elements. */\n public setPlatforms(platforms: string | readonly HTMLElement[], additionalPlatforms: readonly HTMLElement[] = []): void {\n this.assertAlive();\n this.platformSource = platforms;\n this.additionalPlatformElements = additionalPlatforms;\n }\n\n /** Stops animation and timers, removes listeners and DOM, and revokes all object URLs. */\n public destroy(): void {\n if (this.destroyed) return;\n for (const mascot of this.mascots.values()) mascot.destroy();\n this.mascots.clear();\n const view = this.container.ownerDocument.defaultView;\n if (this.animationFrame !== undefined) view?.cancelAnimationFrame(this.animationFrame);\n this.animationFrame = undefined;\n for (const interval of this.intervals) view?.clearInterval(interval);\n this.intervals.clear();\n for (const dispose of this.disposers.splice(0)) dispose();\n this.dom.destroy();\n for (const [element, movement] of this.movedPlatforms) element.style.transform = movement.originalTransform;\n this.movedPlatforms.clear();\n this.platformRectangles.clear();\n this.sprites.destroy();\n this.specs.clear();\n this.events.clear();\n this.destroyed = true;\n this.initialized = false;\n }\n\n /** Returns whether this engine has completed permanent teardown. */\n public isDestroyed(): boolean { return this.destroyed; }\n\n private readonly onAnimationFrame = (timestamp: number): void => {\n if (this.destroyed) return;\n const rawDelta = this.lastFrameTime === undefined ? this.options.frameDuration : timestamp - this.lastFrameTime;\n this.lastFrameTime = timestamp;\n const delta = Math.max(0, Math.min(rawDelta, this.options.maxDeltaTime));\n const { bounds, platforms } = this.readFrameGeometry();\n const mascots = [...this.mascots.values()];\n const collisionBoxes: MascotCollisionBox[] = mascots.map((mascot) => mascot.collisionBox());\n for (const mascot of mascots) mascot.tick(delta, bounds, platforms, collisionBoxes);\n this.emitState();\n this.animationFrame = this.container.ownerDocument.defaultView?.requestAnimationFrame(this.onAnimationFrame);\n };\n\n private renderAll(): void {\n const { bounds, platforms } = this.readFrameGeometry();\n for (const mascot of this.mascots.values()) mascot.tick(0, bounds, platforms);\n }\n\n private readFrameGeometry(): { bounds: ReturnType<DomManager[\"getBounds\"]>; platforms: PlatformRectangle[] } {\n const bounds = this.dom.getBounds();\n const elements = [...new Set([\n ...resolvePlatformElements(this.platformSource, this.container),\n ...resolvePlatformElements(this.additionalPlatformElements, this.container),\n ])].filter((element) => !this.dom.owns(element));\n const platforms = readPlatformRectangles(elements, this.container.getBoundingClientRect());\n this.platformRectangles.clear();\n for (const platform of platforms) this.platformRectangles.set(platform.element, platform);\n return { bounds, platforms };\n }\n\n private movePlatform(element: HTMLElement, point: { x: number; y: number }): void {\n const rectangle = this.platformRectangles.get(element);\n if (!rectangle) return;\n const movement = this.movedPlatforms.get(element) ?? { originalTransform: element.style.transform, x: 0, y: 0 };\n movement.x += point.x - rectangle.x;\n movement.y += point.y - rectangle.y;\n const translate = `translate(${movement.x}px, ${movement.y}px)`;\n element.style.transform = movement.originalTransform ? `${movement.originalTransform} ${translate}` : translate;\n rectangle.x = point.x;\n rectangle.y = point.y;\n this.movedPlatforms.set(element, movement);\n }\n\n private emitState(): void { this.events.emit(\"statechange\", this.getState()); }\n\n private listen(target: EventTarget, type: string, listener: EventListener): void {\n target.addEventListener(type, listener);\n this.disposers.push(() => target.removeEventListener(type, listener));\n }\n\n private assertAlive(): void {\n if (this.destroyed) throw new Error(\"ShimejiEngine has been destroyed\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,aAAN,MAAiB;AAAA;AAAA,EAKf,YACY,WACA,SACjB;AAFiB;AACA;AAEjB,UAAM,OAAO,UAAU,cAAc;AACrC,UAAM,gBAAgB,MAAM,iBAAiB,SAAS;AACtD,QAAI,CAAC,eAAe,YAAY,cAAc,aAAa,SAAU,MAAK,oBAAoB,YAAY,UAAU;AACpH,QAAI,eAAe,cAAc,aAAa,CAAC,eAAe,WAAW;AACvE,WAAK,oBAAoB,aAAa,MAAM;AAAA,IAC9C;AAAA,EACF;AAAA,EATmB;AAAA,EACA;AAAA,EANF,UAAU,oBAAI,IAAqB;AAAA,EACnC,yBAA4C,CAAC;AAAA;AAAA,EAgBvD,gBAAsB;AAC3B,eAAW,UAAU,KAAK,SAAS;AACjC,UAAI,OAAO,QAAQ,kBAAkB,KAAK,UAAW,MAAK,UAAU,YAAY,OAAO,OAAO;AAAA,IAChG;AAAA,EACF;AAAA;AAAA,EAGO,YAAuB;AAC5B,WAAO,EAAE,GAAG,GAAG,GAAG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AAK,OAAO,KAAK,eAAe,KAAK,SAAS,CAAC;AAAA,EAAG;AAAA,EAEtE,OAAO,QAAqB,MAAc,UAA+B;AAC/E,WAAO,iBAAiB,MAAM,QAAQ;AACtC,SAAK,UAAU,KAAK,MAAM,OAAO,oBAAoB,MAAM,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEQ,cAAoB;AAC1B,QAAI,KAAK,UAAW,OAAM,IAAI,MAAM,kCAAkC;AAAA,EACxE;AACF;","names":["document","next","platform","document","document","document","state"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/dom.ts","../src/loader.ts","../src/behavior.ts","../src/physics.ts","../src/action.ts","../src/mascot.ts","../src/platform.ts","../src/sprite.ts","../src/engine.ts"],"sourcesContent":["/** Framework-agnostic Shimeji engine. */\nexport { ShimejiEngine } from \"./engine\";\n/** Character loading and legacy XML parsing utilities. */\nexport { loadCharacter, normalizeCharacterSpec, parseActionsXml, parseBehaviorsXml } from \"./loader\";\n/** Behavior selection and safe expression utilities. */\nexport { BehaviorController, conditionsMatch, evaluateExpression, selectWeighted } from \"./behavior\";\n/** Low-level action-tree executor. */\nexport { ActionExecutor } from \"./action\";\n/** Geometry and physics helpers. */\nexport { applyGravity, clamp, isOnBorder, isOnBottom, isOnLeft, isOnRight, isOnTop, moveToward } from \"./physics\";\n/** DOM platform geometry utilities. */\nexport { readPlatformRectangles, resolvePlatformElements } from \"./platform\";\nexport type { PlatformRectangle } from \"./platform\";\n/** Sprite resource manager. */\nexport { SpriteManager, isIndividualSprite } from \"./sprite\";\nexport type * from \"./types\";\nexport type { ActionExecutorCallbacks, ActionExecutorOptions } from \"./action\";\nexport type { MascotCallbacks } from \"./mascot\";\nexport type { MascotDomHandle } from \"./dom\";\nexport type { ResolvedSprite, SpriteLease } from \"./sprite\";\n","import { SpriteManager, type SpriteLease } from \"./sprite\";\nimport type { CharacterSpec, MascotState, Rectangle } from \"./types\";\n\n/** DOM nodes and resources owned by one mascot. */\nexport interface MascotDomHandle {\n /** Absolutely positioned, pointer-transparent mascot wrapper. */\n element: HTMLDivElement;\n /** Pointer-interactive child element on which sprite images are painted. */\n spriteElement: HTMLDivElement;\n /** Per-mascot spritesheet URL lease. */\n spriteLease: SpriteLease;\n}\n\n/** Creates and updates all DOM owned by an engine instance. */\nexport class DomManager {\n private readonly handles = new Set<MascotDomHandle>();\n private readonly restoreContainerStyles: Array<() => void> = [];\n\n /** Uses the supplied element as the containing block and clipping boundary. */\n public constructor(\n private readonly container: HTMLElement,\n private readonly sprites: SpriteManager,\n ) {\n const view = container.ownerDocument.defaultView;\n const computedStyle = view?.getComputedStyle(container);\n if (!computedStyle?.position || computedStyle.position === \"static\") this.applyContainerStyle(\"position\", \"relative\");\n if (computedStyle?.overflowX === \"visible\" || !computedStyle?.overflowX) {\n this.applyContainerStyle(\"overflowX\", \"clip\");\n }\n }\n\n /** Reattaches mascot elements if application code temporarily removed them. */\n public ensureMounted(): void {\n for (const handle of this.handles) {\n if (handle.element.parentElement !== this.container) this.container.appendChild(handle.element);\n }\n }\n\n /** Returns bounds in the container-local coordinate system. */\n public getBounds(): Rectangle {\n return { x: 0, y: 0, width: this.container.clientWidth, height: this.container.clientHeight };\n }\n\n /** Converts a viewport client coordinate into container-local coordinates. */\n public toLocalPoint(clientX: number, clientY: number): { x: number; y: number } {\n const rectangle = this.container.getBoundingClientRect();\n return { x: clientX - rectangle.left, y: clientY - rectangle.top };\n }\n\n /** Creates a mascot node and acquires its spritesheet resource. */\n public createMascot(spec: CharacterSpec, mascotId: string, mascotClassName?: string): MascotDomHandle {\n const spriteLease = this.sprites.acquire(spec.spritesheet);\n const element = this.container.ownerDocument.createElement(\"div\");\n element.dataset.shimejiId = mascotId;\n element.setAttribute(\"aria-hidden\", \"true\");\n if (mascotClassName) element.className = mascotClassName;\n Object.assign(element.style, { position: \"absolute\", left: \"0\", top: \"0\", width: \"0\", height: \"0\", pointerEvents: \"none\", zIndex: \"9999\", userSelect: \"none\", willChange: \"transform\" });\n const spriteElement = this.container.ownerDocument.createElement(\"div\");\n Object.assign(spriteElement.style, { position: \"absolute\", left: \"0\", top: \"0\", backgroundRepeat: \"no-repeat\", transformOrigin: \"center center\", pointerEvents: \"auto\", touchAction: \"none\", userSelect: \"none\" });\n element.appendChild(spriteElement);\n const handle = { element, spriteElement, spriteLease };\n this.handles.add(handle);\n this.container.appendChild(element);\n return handle;\n }\n\n /** Paints one mascot state into its existing DOM nodes. */\n public render(handle: MascotDomHandle, spec: CharacterSpec, state: MascotState): void {\n const sprite = this.sprites.resolve(spec, handle.spriteLease, state.sprite);\n handle.spriteElement.style.left = \"0\";\n handle.spriteElement.style.top = \"0\";\n handle.spriteElement.style.transform = `scaleX(${state.lookRight ? -1 : 1})`;\n if (!sprite) {\n handle.element.style.transform = `translate3d(${state.x - state.anchorX}px, ${state.y - state.anchorY}px, 0)`;\n return;\n }\n let width = 128;\n let height = 128;\n handle.spriteElement.style.backgroundImage = `url(\"${sprite.url.replaceAll('\"', '\\\\\"')}\")`;\n if (sprite.rectangle) {\n width = sprite.rectangle.width;\n height = sprite.rectangle.height;\n handle.spriteElement.style.backgroundPosition = `${-sprite.rectangle.x}px ${-sprite.rectangle.y}px`;\n handle.spriteElement.style.backgroundSize = \"auto\";\n } else {\n handle.spriteElement.style.backgroundPosition = \"0 0\";\n handle.spriteElement.style.backgroundSize = \"contain\";\n const definition = Object.values(spec.sprites).find((candidate) => typeof candidate === \"object\" && \"url\" in candidate && candidate.url === sprite.url);\n if (typeof definition === \"object\" && \"width\" in definition && definition.width !== undefined) width = definition.width;\n if (typeof definition === \"object\" && \"height\" in definition && definition.height !== undefined) height = definition.height;\n }\n handle.spriteElement.style.width = `${width}px`;\n handle.spriteElement.style.height = `${height}px`;\n handle.element.style.width = `${width}px`;\n handle.element.style.height = `${height}px`;\n const anchorX = state.lookRight ? width - state.anchorX : state.anchorX;\n handle.element.style.transform = `translate3d(${state.x - anchorX}px, ${state.y - state.anchorY}px, 0)`;\n }\n\n /** Removes one mascot node and releases its temporary image URL. */\n public removeMascot(handle: MascotDomHandle): void {\n if (!this.handles.delete(handle)) return;\n handle.element.remove();\n handle.spriteLease.release();\n }\n\n /** Returns whether an element belongs to one of this manager's mascots. */\n public owns(element: HTMLElement): boolean {\n for (const handle of this.handles) if (handle.element === element || handle.element.contains(element)) return true;\n return false;\n }\n\n /** Removes every mascot element and releases its temporary image URL. */\n public destroy(): void {\n for (const handle of [...this.handles]) this.removeMascot(handle);\n for (const restore of this.restoreContainerStyles.splice(0).reverse()) restore();\n }\n\n private applyContainerStyle(property: \"position\" | \"overflow\" | \"overflowX\", value: string): void {\n const previous = this.container.style[property];\n this.container.style[property] = value;\n this.restoreContainerStyles.push(() => {\n if (this.container.style[property] === value) this.container.style[property] = previous;\n });\n }\n}\n","import type {\n ActionDefinition,\n ActionType,\n AnimationDefinition,\n BehaviorDefinition,\n BorderType,\n CharacterSource,\n CharacterSpec,\n LegacyCharacterPack,\n Point,\n Pose,\n SpriteMap,\n} from \"./types\";\n\nconst actionTypeNames: Record<string, ActionType> = {\n Sequence: \"Sequence\", Select: \"Select\", Reference: \"Reference\", Stay: \"Stay\", Animate: \"Animate\", Move: \"Move\", Embedded: \"Embedded\",\n Composite: \"Sequence\", Fixed: \"Animate\", Pause: \"Stay\",\n 複合: \"Sequence\", 選択: \"Select\", 参照: \"Reference\", 静止: \"Stay\", 固定: \"Animate\", 移動: \"Move\", 組み込み: \"Embedded\",\n};\nconst borderTypeNames: Record<string, BorderType> = { Floor: \"Floor\", Wall: \"Wall\", Ceiling: \"Ceiling\", 地面: \"Floor\", 壁: \"Wall\", 天井: \"Ceiling\" };\n\nfunction parseJson<T>(value: T | string, label: string): T {\n if (typeof value !== \"string\") return value;\n try { return JSON.parse(value) as T; } catch (error) { throw new TypeError(`Invalid ${label}: ${error instanceof Error ? error.message : String(error)}`); }\n}\n\nfunction attribute(element: Element, ...names: string[]): string | undefined {\n for (const name of names) { const value = element.getAttribute(name); if (value !== null) return value; }\n return undefined;\n}\n\nfunction directChildren(element: Element, ...names: string[]): Element[] {\n const accepted = new Set(names);\n return Array.from(element.children).filter((child) => accepted.has(child.localName) || accepted.has(child.tagName));\n}\n\nfunction parsePoint(value: string | undefined, fallback: Point = { x: 0, y: 0 }): Point {\n if (!value) return fallback;\n const [x = fallback.x, y = fallback.y] = value.split(\",\").map(Number);\n return { x: Number.isFinite(x) ? x : fallback.x, y: Number.isFinite(y) ? y : fallback.y };\n}\n\nfunction requireDomParser(): DOMParser {\n if (typeof DOMParser === \"undefined\") throw new Error(\"XML character packs require the browser DOMParser API; use pre-parsed JSON in non-browser environments\");\n return new DOMParser();\n}\n\nfunction parseDocument(xml: string, label: string): Document {\n const document = requireDomParser().parseFromString(xml.replace(/^\\uFEFF/, \"\"), \"application/xml\");\n const error = document.querySelector(\"parsererror\");\n if (error) throw new TypeError(`Invalid ${label}: ${error.textContent?.trim() ?? \"XML parse error\"}`);\n return document;\n}\n\nfunction actionProperty(element: Element, ...names: string[]): string | undefined { return attribute(element, ...names); }\n\nfunction parseAnimation(element: Element): AnimationDefinition {\n const poses = directChildren(element, \"Pose\", \"ポーズ\").map((pose): Pose => ({\n sprite: attribute(pose, \"Image\", \"画像\") ?? \"/shime1.png\",\n anchor: parsePoint(attribute(pose, \"ImageAnchor\", \"Anchor\", \"基準座標\"), { x: 64, y: 128 }),\n velocity: parsePoint(attribute(pose, \"Velocity\", \"移動速度\")),\n duration: Number(attribute(pose, \"Duration\", \"長さ\") ?? 1),\n }));\n const condition = attribute(element, \"Condition\", \"条件\");\n const turn = (attribute(element, \"IsTurn\", \"Turn\") ?? \"false\").toLowerCase() === \"true\";\n return { poses, ...(condition !== undefined && { condition }), ...(turn && { turn }) };\n}\n\nfunction parseActionElement(element: Element): ActionDefinition {\n const isReference = element.localName === \"ActionReference\" || element.localName === \"動作参照\";\n const rawType = isReference ? \"Reference\" : attribute(element, \"Type\", \"種類\") ?? (directChildren(element, \"Action\", \"動作\", \"ActionReference\", \"動作参照\").length ? \"Sequence\" : \"Animate\");\n const className = attribute(element, \"Class\", \"クラス\");\n const embedType = className?.split(\".\").at(-1);\n const type = actionTypeNames[rawType] ?? (embedType ? \"Embedded\" : \"Animate\");\n const name = attribute(element, \"Name\", \"名前\");\n const condition = actionProperty(element, \"Condition\", \"条件\");\n const borderRaw = actionProperty(element, \"BorderType\", \"Border\", \"枠\");\n const actions = directChildren(element, \"Action\", \"動作\", \"ActionReference\", \"動作参照\").map(parseActionElement);\n const animations = directChildren(element, \"Animation\", \"アニメーション\").map(parseAnimation);\n const result: ActionDefinition = {\n type,\n ...(name !== undefined && { name }),\n ...(embedType !== undefined && { embedType }),\n ...(condition !== undefined && { condition }),\n ...(borderRaw !== undefined && borderTypeNames[borderRaw] !== undefined && { borderType: borderTypeNames[borderRaw] }),\n ...(actions.length > 0 && { actions }),\n ...(animations.length > 0 && { animations }),\n };\n const properties: Array<[keyof ActionDefinition, string | undefined]> = [\n [\"duration\", actionProperty(element, \"Duration\", \"長さ\")], [\"gap\", actionProperty(element, \"Gap\", \"間隔\", \"ずれ\")], [\"targetX\", actionProperty(element, \"TargetX\", \"目的地X\")],\n [\"targetY\", actionProperty(element, \"TargetY\", \"目的地Y\")], [\"velocity\", actionProperty(element, \"VelocityParam\", \"Velocity\", \"速度\")],\n [\"x\", actionProperty(element, \"X\", \"変位X\")], [\"y\", actionProperty(element, \"Y\", \"変位Y\")],\n [\"offsetX\", actionProperty(element, \"OffsetX\", \"端X\")], [\"offsetY\", actionProperty(element, \"OffsetY\", \"端Y\")],\n [\"offsetType\", actionProperty(element, \"OffsetType\")],\n [\"initialVx\", actionProperty(element, \"InitialVX\", \"InitialVx\", \"初速X\")], [\"initialVy\", actionProperty(element, \"InitialVY\", \"InitialVy\", \"初速Y\")],\n [\"resistanceX\", actionProperty(element, \"RegistanceX\", \"ResistanceX\", \"空気抵抗X\")], [\"resistanceY\", actionProperty(element, \"RegistanceY\", \"ResistanceY\", \"空気抵抗Y\")],\n [\"gravity\", actionProperty(element, \"Gravity\", \"重力\")], [\"bornX\", actionProperty(element, \"BornX\", \"誕生X\", \"生まれる場所X\")],\n [\"bornY\", actionProperty(element, \"BornY\", \"誕生Y\", \"生まれる場所Y\")], [\"bornBehavior\", actionProperty(element, \"BornBehavior\", \"BornBehaviour\", \"誕生時の行動\", \"生まれた時の行動\")],\n [\"bornMascot\", actionProperty(element, \"BornMascot\")], [\"bornCount\", actionProperty(element, \"BornCount\")],\n [\"bornInterval\", actionProperty(element, \"BornInterval\")],\n [\"ieOffsetX\", actionProperty(element, \"IEOffsetX\", \"IEの端X\")], [\"ieOffsetY\", actionProperty(element, \"IEOffsetY\", \"IEの端Y\")],\n [\"lookRight\", actionProperty(element, \"LookRight\", \"右向き\")],\n ];\n for (const [key, value] of properties) if (value !== undefined) (result as unknown as Record<string, unknown>)[key] = value;\n const loop = actionProperty(element, \"Loop\", \"繰り返し\");\n if (loop !== undefined) result.loop = loop.toLowerCase() === \"true\";\n return result;\n}\n\n/** Parses a legacy `actions.xml` document into normalized action definitions. */\nexport function parseActionsXml(xml: string): ActionDefinition[] {\n const document = parseDocument(xml, \"actions.xml\");\n const lists = Array.from(document.getElementsByTagNameNS(\"*\", \"ActionList\")).concat(Array.from(document.getElementsByTagNameNS(\"*\", \"動作リスト\")));\n const roots = lists.length ? lists : [document.documentElement];\n return roots.flatMap((list) => directChildren(list, \"Action\", \"動作\").map(parseActionElement));\n}\n\nfunction parseNextBehaviors(element: Element, inheritedConditions: readonly string[]): BehaviorDefinition[] {\n const behaviors: BehaviorDefinition[] = [];\n for (const child of Array.from(element.children)) {\n if (child.localName === \"Condition\" || child.localName === \"条件\") {\n const condition = attribute(child, \"Condition\", \"条件\");\n behaviors.push(...parseNextBehaviors(child, [...inheritedConditions, ...(condition ? [condition] : [])]));\n } else if ([\"Behavior\", \"行動\", \"BehaviorReference\", \"BehaviorReferance\", \"行動参照\"].includes(child.localName)) {\n behaviors.push(parseBehaviorElement(child, inheritedConditions, 0));\n }\n }\n return behaviors;\n}\n\nfunction parseBehaviorElement(element: Element, inheritedConditions: readonly string[], groupIndex: number): BehaviorDefinition {\n const condition = attribute(element, \"Condition\", \"条件\");\n const conditions = [...inheritedConditions, ...(condition ? [condition] : [])];\n const nextList = directChildren(element, \"NextBehaviorList\", \"NextBehavior\", \"次の行動リスト\")[0];\n const nextBehaviors = nextList ? parseNextBehaviors(nextList, []) : [];\n const reference = element.localName === \"BehaviorReference\" || element.localName === \"BehaviorReferance\" || element.localName === \"行動参照\";\n const actionName = attribute(element, \"Action\", \"動作\");\n return {\n type: reference ? \"Reference\" : \"Behavior\",\n name: attribute(element, \"Name\", \"名前\") ?? \"\",\n frequency: Number(attribute(element, \"Frequency\", \"頻度\") ?? 0),\n conditions,\n nextBehaviors,\n ...(nextList && { nextAdditive: (attribute(nextList, \"Add\", \"追加\") ?? \"true\").toLowerCase() === \"true\" }),\n ...(actionName !== undefined && { actionName }),\n groupIndex,\n hidden: (attribute(element, \"Hidden\", \"非表示\") ?? \"false\").toLowerCase() === \"true\",\n };\n}\n\n/** Parses a legacy `behaviors.xml` document into normalized behavior definitions. */\nexport function parseBehaviorsXml(xml: string): BehaviorDefinition[] {\n const document = parseDocument(xml, \"behaviors.xml\");\n const lists = Array.from(document.getElementsByTagNameNS(\"*\", \"BehaviorList\")).concat(Array.from(document.getElementsByTagNameNS(\"*\", \"行動リスト\")));\n const root = lists[0] ?? document.documentElement;\n const behaviors: BehaviorDefinition[] = [];\n let groupIndex = 0;\n for (const child of Array.from(root.children)) {\n if (child.localName === \"Condition\" || child.localName === \"条件\") {\n groupIndex += 1;\n const condition = attribute(child, \"Condition\", \"条件\");\n const inherited = condition ? [condition] : [];\n behaviors.push(...directChildren(child, \"Behavior\", \"行動\", \"BehaviorReference\", \"BehaviorReferance\", \"行動参照\").map((element) => parseBehaviorElement(element, inherited, groupIndex)));\n } else if ([\"Behavior\", \"行動\", \"BehaviorReference\", \"BehaviorReferance\", \"行動参照\"].includes(child.localName)) {\n behaviors.push(parseBehaviorElement(child, [], 0));\n }\n }\n return behaviors;\n}\n\nfunction isCharacterSpec(value: unknown): value is CharacterSpec {\n if (!value || typeof value !== \"object\") return false;\n const candidate = value as Partial<CharacterSpec>;\n return typeof candidate.id === \"string\" && Array.isArray(candidate.actions) && Array.isArray(candidate.behaviors) && typeof candidate.sprites === \"object\" && candidate.sprites !== null && (typeof candidate.spritesheet === \"string\" || (typeof Blob !== \"undefined\" && candidate.spritesheet instanceof Blob));\n}\n\n/** Converts a pre-parsed definition or raw XML/JSON legacy bundle to a character specification. */\nexport function normalizeCharacterSpec(input: CharacterSpec | LegacyCharacterPack | unknown): CharacterSpec {\n let candidate: unknown = input;\n if (typeof candidate === \"string\") candidate = parseJson<unknown>(candidate, \"character JSON\");\n if (!candidate || typeof candidate !== \"object\") throw new TypeError(\"Character data must be an object\");\n const record = candidate as Record<string, unknown>;\n if (record.configuration) {\n const configuration = typeof record.configuration === \"string\"\n ? parseJson<Record<string, unknown>>(record.configuration, \"configuration\")\n : record.configuration;\n if (typeof configuration === \"object\") candidate = { ...(configuration as object), ...record };\n }\n const pack = candidate as Partial<LegacyCharacterPack> & Record<string, unknown>;\n const id = typeof pack.id === \"string\" ? pack.id : typeof pack.metadata?.shimeji === \"string\" ? pack.metadata.shimeji : undefined;\n if (!id) throw new TypeError(\"Character specification requires an id\");\n if (pack.actions === undefined || pack.behaviors === undefined || pack.sprites === undefined || pack.spritesheet === undefined) throw new TypeError(`Character '${id}' is missing actions, behaviors, sprites, or spritesheet`);\n const actions = typeof pack.actions === \"string\" && pack.actions.trimStart().startsWith(\"<\") ? parseActionsXml(pack.actions) : parseJson<ActionDefinition[]>(pack.actions, \"actions\");\n const behaviors = typeof pack.behaviors === \"string\" && pack.behaviors.trimStart().startsWith(\"<\") ? parseBehaviorsXml(pack.behaviors) : parseJson<BehaviorDefinition[]>(pack.behaviors, \"behaviors\");\n const sprites = parseJson<SpriteMap>(pack.sprites, \"sprites\");\n const spec: CharacterSpec = {\n id,\n spritesheet: pack.spritesheet,\n sprites,\n actions,\n behaviors,\n ...(typeof pack.name === \"string\" && { name: pack.name }),\n ...(pack.metadata !== undefined && { metadata: pack.metadata }),\n };\n if (!isCharacterSpec(spec)) throw new TypeError(`Character '${id}' could not be normalized`);\n return spec;\n}\n\n/** Loads character JSON from a URL or normalizes an already available character bundle. */\nexport async function loadCharacter(source: CharacterSource): Promise<CharacterSpec> {\n if (typeof source !== \"string\" && !(source instanceof URL)) return normalizeCharacterSpec(source);\n const url = source instanceof URL ? source : new URL(source, typeof document === \"undefined\" ? \"http://localhost/\" : document.baseURI);\n const response = await fetch(url);\n if (!response.ok) throw new Error(`Unable to load character '${url}': ${response.status} ${response.statusText}`);\n const spec = normalizeCharacterSpec(await response.json() as unknown);\n if (typeof spec.spritesheet === \"string\" && !/^(?:data:|blob:)/.test(spec.spritesheet)) {\n spec.spritesheet = new URL(spec.spritesheet, url).toString();\n }\n return spec;\n}\n","import type { BehaviorDefinition, CharacterSpec, MascotEnvironment } from \"./types\";\n\ntype TokenKind = \"number\" | \"identifier\" | \"operator\" | \"punctuation\" | \"eof\";\ninterface Token { kind: TokenKind; value: string }\ntype AstNode =\n | { kind: \"literal\"; value: number | boolean }\n | { kind: \"identifier\"; name: string }\n | { kind: \"member\"; object: AstNode; property: string }\n | { kind: \"call\"; callee: AstNode; args: AstNode[] }\n | { kind: \"unary\"; operator: string; argument: AstNode }\n | { kind: \"binary\"; operator: string; left: AstNode; right: AstNode }\n | { kind: \"conditional\"; test: AstNode; consequent: AstNode; alternate: AstNode };\n\nconst forbiddenProperties = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\nconst functions: Record<string, (...args: number[]) => number> = {\n abs: Math.abs, acos: Math.acos, acosh: Math.acosh, asin: Math.asin, asinh: Math.asinh,\n atan: Math.atan, atan2: Math.atan2, atanh: Math.atanh, cbrt: Math.cbrt, ceil: Math.ceil,\n cos: Math.cos, cosh: Math.cosh, exp: Math.exp, expm1: Math.expm1, floor: Math.floor,\n hypot: Math.hypot, log: Math.log, log1p: Math.log1p, log2: Math.log2, log10: Math.log10,\n max: Math.max, min: Math.min, pow: Math.pow, random: (maximum = 1) => Math.random() * maximum,\n round: Math.round, sign: Math.sign, sin: Math.sin, sinh: Math.sinh, sqrt: Math.sqrt,\n tan: Math.tan, tanh: Math.tanh, trunc: Math.trunc,\n};\nconst constants: Record<string, number> = { E: Math.E, PI: Math.PI };\n\nfunction normalizeExpression(source: string): string {\n return source\n .trim()\n .replace(/^(?:#|\\$)\\{/, \"\")\n .replace(/\\}$/, \"\")\n .replace(/Math\\.(random|min|max|abs|floor|ceil|round|sqrt|pow|sin|cos|tan|asin|acos|atan|sinh|cosh|tanh|asinh|acosh|atanh|cbrt|log|log2|log10|exp|expm1|log1p|trunc|sign|hypot|atan2)/g, \"$1\")\n .replace(/Math\\.(PI|E)\\b/g, \"$1\")\n .replace(/Mascot\\./gi, \"mascot.\")\n .replace(/TargetX|目的地X/gi, \"targetX\")\n .replace(/TargetY|目的地Y/gi, \"targetY\")\n .replace(/FootX|足X/gi, \"footX\")\n .replace(/FootY|足Y/gi, \"footY\")\n .replace(/VelocityX|速度X/gi, \"velocityX\")\n .replace(/VelocityY|速度Y/gi, \"velocityY\")\n .replace(/MaxCount/gi, \"maxCount\")\n .replace(/Gap|ずれ/gi, \"gap\")\n .replace(/\\band\\b/gi, \"&&\")\n .replace(/\\bor\\b/gi, \"||\")\n .replace(/\\bnot\\b/gi, \"!\");\n}\n\nfunction tokenize(source: string): Token[] {\n const tokens: Token[] = [];\n let index = 0;\n while (index < source.length) {\n const rest = source.slice(index);\n const whitespace = /^\\s+/.exec(rest);\n if (whitespace) { index += whitespace[0].length; continue; }\n const number = /^(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?/i.exec(rest);\n if (number) { tokens.push({ kind: \"number\", value: number[0] }); index += number[0].length; continue; }\n const identifier = /^[A-Za-z_$\\u0080-\\uFFFF][\\w$\\u0080-\\uFFFF]*/u.exec(rest);\n if (identifier) { tokens.push({ kind: \"identifier\", value: identifier[0] }); index += identifier[0].length; continue; }\n const operator = /^(?:===|!==|==|!=|<=|>=|&&|\\|\\||[+\\-*/%^<>!?:.,()])/.exec(rest);\n if (!operator) throw new SyntaxError(`Unexpected token at ${index}`);\n const value = operator[0];\n tokens.push({ kind: value === \"(\" || value === \")\" || value === \",\" || value === \".\" ? \"punctuation\" : \"operator\", value });\n index += value.length;\n }\n tokens.push({ kind: \"eof\", value: \"\" });\n return tokens;\n}\n\nclass Parser {\n private index = 0;\n public constructor(private readonly tokens: Token[]) {}\n public parse(): AstNode {\n const node = this.parseConditional();\n if (this.peek().kind !== \"eof\") throw new SyntaxError(`Unexpected '${this.peek().value}'`);\n return node;\n }\n private peek(): Token { return this.tokens[this.index] ?? { kind: \"eof\", value: \"\" }; }\n private take(value?: string): Token {\n const token = this.peek();\n if (value !== undefined && token.value !== value) throw new SyntaxError(`Expected '${value}'`);\n this.index += 1;\n return token;\n }\n private match(...values: string[]): boolean {\n if (!values.includes(this.peek().value)) return false;\n this.index += 1;\n return true;\n }\n private parseConditional(): AstNode {\n const test = this.parseOr();\n if (!this.match(\"?\")) return test;\n const consequent = this.parseConditional();\n this.take(\":\");\n return { kind: \"conditional\", test, consequent, alternate: this.parseConditional() };\n }\n private parseOr(): AstNode { return this.binary(() => this.parseAnd(), [\"||\"]); }\n private parseAnd(): AstNode { return this.binary(() => this.parseEquality(), [\"&&\"]); }\n private parseEquality(): AstNode { return this.binary(() => this.parseComparison(), [\"==\", \"===\", \"!=\", \"!==\"]); }\n private parseComparison(): AstNode { return this.binary(() => this.parseAdditive(), [\"<\", \"<=\", \">\", \">=\"]); }\n private parseAdditive(): AstNode { return this.binary(() => this.parseMultiplicative(), [\"+\", \"-\"]); }\n private parseMultiplicative(): AstNode { return this.binary(() => this.parsePower(), [\"*\", \"/\", \"%\"]); }\n private parsePower(): AstNode { return this.binary(() => this.parseUnary(), [\"^\"]); }\n private binary(next: () => AstNode, operators: string[]): AstNode {\n let left = next();\n while (operators.includes(this.peek().value)) {\n const operator = this.take().value;\n left = { kind: \"binary\", operator, left, right: next() };\n }\n return left;\n }\n private parseUnary(): AstNode {\n if ([\"!\", \"+\", \"-\"].includes(this.peek().value)) {\n return { kind: \"unary\", operator: this.take().value, argument: this.parseUnary() };\n }\n return this.parsePostfix();\n }\n private parsePostfix(): AstNode {\n let node = this.parsePrimary();\n for (;;) {\n if (this.match(\".\")) {\n const property = this.take();\n if (property.kind !== \"identifier\" || forbiddenProperties.has(property.value)) throw new SyntaxError(\"Unsafe member access\");\n node = { kind: \"member\", object: node, property: property.value };\n } else if (this.match(\"(\")) {\n const args: AstNode[] = [];\n if (!this.match(\")\")) {\n do { args.push(this.parseConditional()); } while (this.match(\",\"));\n this.take(\")\");\n }\n node = { kind: \"call\", callee: node, args };\n } else return node;\n }\n }\n private parsePrimary(): AstNode {\n const token = this.take();\n if (token.kind === \"number\") return { kind: \"literal\", value: Number(token.value) };\n if (token.kind === \"identifier\") {\n if (token.value === \"true\" || token.value === \"false\") return { kind: \"literal\", value: token.value === \"true\" };\n return { kind: \"identifier\", name: token.value };\n }\n if (token.value === \"(\") {\n const node = this.parseConditional();\n this.take(\")\");\n return node;\n }\n throw new SyntaxError(`Unexpected '${token.value}'`);\n }\n}\n\nfunction resolveMember(node: Extract<AstNode, { kind: \"member\" }>, scope: Record<string, unknown>): { owner: unknown; value: unknown } {\n const owner = evaluateNode(node.object, scope);\n if ((typeof owner !== \"object\" && typeof owner !== \"function\") || owner === null) return { owner, value: undefined };\n if (forbiddenProperties.has(node.property)) return { owner, value: undefined };\n return { owner, value: (owner as Record<string, unknown>)[node.property] };\n}\n\nfunction evaluateNode(node: AstNode, scope: Record<string, unknown>): unknown {\n switch (node.kind) {\n case \"literal\": return node.value;\n case \"identifier\": return Object.hasOwn(scope, node.name) ? scope[node.name] : functions[node.name] ?? constants[node.name];\n case \"member\": return resolveMember(node, scope).value;\n case \"call\": {\n const member = node.callee.kind === \"member\" ? resolveMember(node.callee, scope) : undefined;\n const callable = member?.value ?? evaluateNode(node.callee, scope);\n if (typeof callable !== \"function\") throw new TypeError(\"Expression value is not callable\");\n return callable.apply(member?.owner, node.args.map((argument) => evaluateNode(argument, scope)));\n }\n case \"unary\": {\n const value = evaluateNode(node.argument, scope);\n if (node.operator === \"!\") return !value;\n if (node.operator === \"+\") return Number(value);\n return -Number(value);\n }\n case \"conditional\": return evaluateNode(node.test, scope) ? evaluateNode(node.consequent, scope) : evaluateNode(node.alternate, scope);\n case \"binary\": {\n if (node.operator === \"&&\") return Boolean(evaluateNode(node.left, scope)) && Boolean(evaluateNode(node.right, scope));\n if (node.operator === \"||\") return Boolean(evaluateNode(node.left, scope)) || Boolean(evaluateNode(node.right, scope));\n const left = evaluateNode(node.left, scope);\n const right = evaluateNode(node.right, scope);\n switch (node.operator) {\n case \"+\": return Number(left) + Number(right);\n case \"-\": return Number(left) - Number(right);\n case \"*\": return Number(left) * Number(right);\n case \"/\": return Number(left) / Number(right);\n case \"%\": return Number(left) % Number(right);\n case \"^\": return Math.pow(Number(left), Number(right));\n case \"==\": case \"===\": return left === right;\n case \"!=\": case \"!==\": return left !== right;\n case \"<\": return Number(left) < Number(right);\n case \"<=\": return Number(left) <= Number(right);\n case \">\": return Number(left) > Number(right);\n case \">=\": return Number(left) >= Number(right);\n default: return false;\n }\n }\n }\n}\n\nconst expressionCache = new Map<string, AstNode>();\n\n/** Safely evaluates a legacy Shimeji expression without using `eval` or `Function`. */\nexport function evaluateExpression(expression: string | number | boolean | undefined, environment: MascotEnvironment, fallback: number, random?: () => number): number;\n/** Safely evaluates a legacy Shimeji expression without using `eval` or `Function`. */\nexport function evaluateExpression(expression: string | number | boolean | undefined, environment: MascotEnvironment, fallback: boolean, random?: () => number): boolean;\n/** Safely evaluates a legacy Shimeji expression without using `eval` or `Function`. */\nexport function evaluateExpression(expression: string | number | boolean | undefined, environment: MascotEnvironment, fallback: number | boolean, random: () => number = Math.random): number | boolean {\n if (expression === undefined) return fallback;\n if (typeof expression !== \"string\") return expression;\n try {\n const normalized = normalizeExpression(expression);\n let ast = expressionCache.get(normalized);\n if (!ast) { ast = new Parser(tokenize(normalized)).parse(); expressionCache.set(normalized, ast); }\n const result = evaluateNode(ast, { ...environment, random: (maximum = 1) => random() * Number(maximum) } as unknown as Record<string, unknown>);\n if (typeof fallback === \"boolean\") return Boolean(result);\n const numericResult = Number(result);\n return Number.isNaN(numericResult) ? fallback : numericResult;\n } catch { return fallback; }\n}\n\n/** Returns true when every condition in a behavior or action is satisfied. */\nexport function conditionsMatch(conditions: readonly string[], environment: MascotEnvironment, random: () => number = Math.random): boolean {\n return conditions.every((condition) => evaluateExpression(condition, environment, false, random));\n}\n\n/** Chooses one item with probability proportional to its non-negative weight. */\nexport function selectWeighted<T>(items: readonly T[], weight: (item: T) => number, random: () => number = Math.random): T | undefined {\n const weighted = items.map((item) => ({ item, weight: Math.max(0, weight(item)) }));\n const total = weighted.reduce((sum, entry) => sum + entry.weight, 0);\n if (total <= 0) return undefined;\n let cursor = random() * total;\n for (const entry of weighted) { cursor -= entry.weight; if (cursor < 0) return entry.item; }\n return weighted.at(-1)?.item;\n}\n\n/** Selects applicable behaviors and resolves legacy behavior references. */\nexport class BehaviorController {\n private previous: BehaviorDefinition | undefined;\n private fallbackSelected = false;\n\n /** Creates a behavior selector for a normalized character specification. */\n public constructor(private readonly spec: CharacterSpec, private readonly random: () => number = Math.random) {}\n\n /** Selects an initial behavior, honoring an explicit requested name when possible. */\n public selectInitial(environment: MascotEnvironment, requestedName?: string): BehaviorDefinition | undefined {\n this.fallbackSelected = false;\n if (requestedName) {\n const requested = this.spec.behaviors.find((behavior) => behavior.name === requestedName);\n if (requested) return (this.previous = this.resolve(requested));\n }\n return (this.previous = this.choose(this.spec.behaviors, environment));\n }\n\n /** Selects the weighted transition following the current behavior. */\n public selectNext(environment: MascotEnvironment): BehaviorDefinition | undefined {\n const selected = this.choose(this.nextPool(), environment);\n this.fallbackSelected = selected === undefined;\n return (this.previous = selected ?? this.findFallBehavior());\n }\n\n /** Tries a weighted transition from a subset without changing history when none applies. */\n public trySelectNext(environment: MascotEnvironment, predicate: (behavior: BehaviorDefinition) => boolean): BehaviorDefinition | undefined {\n const selected = this.choose(this.nextPool().filter(predicate), environment);\n if (!selected) return undefined;\n this.fallbackSelected = false;\n return (this.previous = selected);\n }\n\n /** Whether the most recent transition had no effective weighted candidate. */\n public usedFallback(): boolean { return this.fallbackSelected; }\n\n /** Replaces selection history so an external interaction can force a behavior. */\n public force(name: string): BehaviorDefinition | undefined {\n this.fallbackSelected = false;\n const behavior = this.spec.behaviors.find((candidate) => candidate.name === name);\n return (this.previous = behavior ? this.resolve(behavior) : undefined);\n }\n\n private choose(pool: readonly BehaviorDefinition[], environment: MascotEnvironment): BehaviorDefinition | undefined {\n const applicable = pool.filter((behavior) => conditionsMatch(behavior.conditions, environment, this.random));\n const chosen = selectWeighted(applicable, (behavior) => behavior.frequency, this.random);\n return chosen ? this.resolve(chosen) : undefined;\n }\n\n private nextPool(): readonly BehaviorDefinition[] {\n const next = this.previous?.nextBehaviors ?? [];\n return this.previous && this.previous.nextAdditive === false ? next : [...this.spec.behaviors, ...next];\n }\n\n private resolve(behavior: BehaviorDefinition): BehaviorDefinition {\n if (behavior.type !== \"Reference\") return behavior;\n const target = this.spec.behaviors.find((candidate) => candidate.type === \"Behavior\" && candidate.name === behavior.name);\n return target ? {\n ...target,\n ...behavior,\n type: \"Behavior\",\n nextBehaviors: target.nextBehaviors,\n ...(behavior.actionName !== undefined\n ? { actionName: behavior.actionName }\n : target.actionName !== undefined ? { actionName: target.actionName } : {}),\n ...(target.nextAdditive !== undefined && { nextAdditive: target.nextAdditive }),\n } : { ...behavior, type: \"Behavior\" };\n }\n\n private findFallBehavior(): BehaviorDefinition | undefined {\n return this.spec.behaviors.find((behavior) => behavior.name === \"Fall\" || behavior.name === \"落下する\");\n }\n\n}\n","import type { MascotState, Point, Rectangle } from \"./types\";\n\n// Mascot anchors and evaluated action targets use truncated legacy pixels,\n// while DOMRect edges may lie anywhere between CSS pixels. Any distance below\n// one pixel is therefore the same legacy coordinate; an exact adjacent pixel\n// remains distinct.\nconst BORDER_TOLERANCE = 1 - Number.EPSILON / 2;\n\nfunction isWithinSpan(value: number, minimum: number, maximum: number, tolerance: number): boolean {\n const distance = value < minimum ? minimum - value : value > maximum ? value - maximum : 0;\n return distance <= tolerance;\n}\n\n/** Clamps a number to an inclusive range. */\nexport function clamp(value: number, minimum: number, maximum: number): number {\n return Math.min(Math.max(value, minimum), maximum);\n}\n\n/** Returns whether a point lies on the top edge of a rectangle. */\nexport function isOnTop(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.x, rectangle.x, rectangle.x + rectangle.width, tolerance) && Math.abs(point.y - rectangle.y) <= tolerance;\n}\n\n/** Returns whether a point lies on the bottom edge of a rectangle. */\nexport function isOnBottom(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.x, rectangle.x, rectangle.x + rectangle.width, tolerance) && Math.abs(point.y - rectangle.y - rectangle.height) <= tolerance;\n}\n\n/** Returns whether a point lies on the left edge of a rectangle. */\nexport function isOnLeft(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.y, rectangle.y, rectangle.y + rectangle.height, tolerance) && Math.abs(point.x - rectangle.x) <= tolerance;\n}\n\n/** Returns whether a point lies on the right edge of a rectangle. */\nexport function isOnRight(point: Point, rectangle: Rectangle, tolerance = BORDER_TOLERANCE): boolean {\n return isWithinSpan(point.y, rectangle.y, rectangle.y + rectangle.height, tolerance) && Math.abs(point.x - rectangle.x - rectangle.width) <= tolerance;\n}\n\n/** Returns whether an anchor satisfies an action's boundary requirement. */\nexport function isOnBorder(\n state: MascotState,\n bounds: Rectangle,\n border: \"Floor\" | \"Wall\" | \"Ceiling\" | undefined,\n platform?: Rectangle,\n): boolean {\n if (!border) return true;\n if (border === \"Floor\") return isOnBottom(state, bounds) || (platform !== undefined && isOnTop(state, platform));\n if (border === \"Ceiling\") return isOnTop(state, bounds) || (platform !== undefined && isOnBottom(state, platform));\n return isOnLeft(state, bounds)\n || isOnRight(state, bounds)\n || (platform !== undefined && (isOnLeft(state, platform) || isOnRight(state, platform)));\n}\n\n/** Returns whether a point is on a floor (platform top or work-area bottom). */\nexport function isOnFloor(point: Point, bounds: Rectangle, platforms: readonly Rectangle[] = []): boolean {\n return platforms.some((platform) => isOnTop(point, platform)) || isOnBottom(point, bounds);\n}\n\n/** Returns whether a point is on the wall it is moving/facing toward. */\nexport function isOnWall(point: Point, bounds: Rectangle, lookRight: boolean, platforms: readonly Rectangle[] = []): boolean {\n return lookRight\n ? platforms.some((platform) => isOnLeft(point, platform)) || isOnRight(point, bounds)\n : platforms.some((platform) => isOnRight(point, platform)) || isOnLeft(point, bounds);\n}\n\n/**\n * Advances one legacy Fall tick. Velocity is damped and accelerated before\n * movement, then the path is sampled one pixel at a time just like Shimeji-ee.\n */\nexport function applyGravity(\n state: MascotState,\n bounds: Rectangle,\n frameScale: number,\n gravity: number,\n resistanceX = 0.05,\n resistanceY = 0.1,\n platform?: Rectangle,\n): boolean {\n const platforms = platform ? [platform] : [];\n const steps = Math.max(1, Math.round(frameScale));\n let stopped = false;\n for (let frame = 0; frame < steps && !stopped; frame += 1) {\n state.vx -= state.vx * resistanceX;\n state.vy = state.vy - state.vy * resistanceY + gravity;\n const dx = Math.trunc(state.vx);\n const dy = Math.trunc(state.vy);\n const divisions = Math.max(1, Math.abs(dx), Math.abs(dy));\n const start = { x: state.x, y: state.y };\n for (let index = 0; index <= divisions; index += 1) {\n const x = start.x + Math.trunc((dx * index) / divisions);\n const y = start.y + Math.trunc((dy * index) / divisions);\n state.x = x;\n state.y = y;\n if (dy > 0) {\n for (let offset = -80; offset <= 0; offset += 1) {\n state.y = y + offset;\n if (isOnFloor(state, bounds, platforms)) { stopped = true; break; }\n }\n if (stopped) break;\n state.y = y;\n }\n if (isOnWall(state, bounds, state.lookRight, platforms)) { stopped = true; break; }\n }\n }\n return stopped;\n}\n\n/** Moves a mascot toward a target without overshooting it. */\nexport function moveToward(state: MascotState, target: Point, speed: number, frameScale: number): boolean {\n const dx = target.x - state.x;\n const dy = target.y - state.y;\n const distance = Math.hypot(dx, dy);\n if (distance <= Math.max(0.001, speed * frameScale)) {\n state.x = target.x;\n state.y = target.y;\n return true;\n }\n state.x += (dx / distance) * speed * frameScale;\n state.y += (dy / distance) * speed * frameScale;\n return false;\n}\n","import { evaluateExpression } from \"./behavior\";\nimport { isOnBottom, isOnFloor, isOnLeft, isOnRight, isOnTop, isOnWall } from \"./physics\";\nimport type { PlatformRectangle } from \"./platform\";\nimport type {\n ActionDefinition,\n AnimationDefinition,\n BorderType,\n CharacterSpec,\n MascotEnvironment,\n MascotState,\n Point,\n Pose,\n Rectangle,\n} from \"./types\";\n\n/** Callbacks through which embedded actions request engine-level operations. */\nexport interface ActionExecutorCallbacks {\n /** Spawns another mascot, optionally from another registered character. */\n spawn(position: { x: number; y: number; behaviorName?: string; lookRight?: boolean }, characterId?: string): void;\n /** Removes the mascot owning this executor. */\n remove(): void;\n /** Moves a DOM platform for the legacy IE-carrying actions. */\n movePlatform?(element: HTMLElement, point: Point): void;\n}\n\n/** Settings used while interpreting actions. */\nexport interface ActionExecutorOptions {\n /** Duration of one legacy animation unit in milliseconds. */\n frameDuration: number;\n /** Gravity used when a Fall action does not define one. */\n gravity: number;\n /** Optional deterministic random-number source. */\n random?: (() => number) | undefined;\n}\n\nexport type ActionTickResult = \"running\" | \"complete\" | \"lost-ground\";\n\ninterface RuntimeContext {\n environment: MascotEnvironment;\n bounds: Rectangle;\n platforms: readonly PlatformRectangle[];\n}\n\ninterface Runtime {\n init(context: RuntimeContext): void;\n hasNext(context: RuntimeContext): boolean;\n step(context: RuntimeContext): \"running\" | \"lost-ground\";\n}\n\nfunction expressionIsPerFrame(value: unknown): boolean {\n return typeof value === \"string\" && value.trimStart().startsWith(\"#{\");\n}\n\nclass ActionValues {\n private readonly actionCache = new Map<string, number | boolean>();\n private readonly frameCache = new Map<string, number | boolean>();\n\n public constructor(private readonly random: () => number) {}\n\n public init(): void {\n this.actionCache.clear();\n this.frameCache.clear();\n }\n\n public initFrame(): void { this.frameCache.clear(); }\n\n public number(key: string, value: string | number | undefined, environment: MascotEnvironment, fallback: number): number {\n if (value === undefined) return fallback;\n if (typeof value === \"number\") return value;\n const cache = expressionIsPerFrame(value) ? this.frameCache : this.actionCache;\n const cached = cache.get(key);\n if (typeof cached === \"number\") return cached;\n const result = evaluateExpression(value, environment, fallback, this.random);\n cache.set(key, result);\n return result;\n }\n\n public boolean(key: string, value: string | boolean | undefined, environment: MascotEnvironment, fallback: boolean): boolean {\n if (value === undefined) return fallback;\n if (typeof value === \"boolean\") return value;\n const cache = expressionIsPerFrame(value) ? this.frameCache : this.actionCache;\n const cached = cache.get(key);\n if (typeof cached === \"boolean\") return cached;\n const result = evaluateExpression(value, environment, fallback, this.random);\n cache.set(key, result);\n return result;\n }\n}\n\nabstract class RuntimeBase implements Runtime {\n protected time = 0;\n protected readonly values: ActionValues;\n\n protected constructor(protected readonly definition: ActionDefinition, random: () => number) {\n this.values = new ActionValues(random);\n }\n\n public init(context: RuntimeContext): void {\n this.time = 0;\n this.values.init();\n this.onInit(context);\n }\n\n public hasNext(context: RuntimeContext): boolean {\n return this.baseHasNext(context) && this.hasMore(context);\n }\n\n public step(context: RuntimeContext): \"running\" | \"lost-ground\" {\n this.values.initFrame();\n const result = this.tick(context);\n this.time += 1;\n return result;\n }\n\n protected onInit(_context: RuntimeContext): void {}\n protected hasMore(_context: RuntimeContext): boolean { return true; }\n protected baseHasNext(context: RuntimeContext): boolean {\n const condition = this.values.boolean(\"condition\", this.definition.condition, context.environment, true);\n const duration = Math.trunc(this.values.number(\"duration\", this.definition.duration, context.environment, Number.POSITIVE_INFINITY));\n return condition && this.time < duration;\n }\n protected abstract tick(context: RuntimeContext): \"running\" | \"lost-ground\";\n}\n\ntype BorderSide = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nclass TrackedBorder {\n private previous: Rectangle | undefined;\n\n public constructor(\n private readonly side: BorderSide,\n private readonly source: \"work-area\" | HTMLElement | undefined,\n context: RuntimeContext,\n ) { this.previous = this.rectangle(context); }\n\n public move(point: Point, context: RuntimeContext): Point {\n const current = this.rectangle(context);\n const previous = this.previous;\n this.previous = current;\n if (!current || !previous) return point;\n if (this.side === \"left\" || this.side === \"right\") {\n if (previous.height === 0) return point;\n const next = {\n x: point.x + this.coordinate(current) - this.coordinate(previous),\n y: Math.trunc(((point.y - previous.y) * current.height) / previous.height + current.y),\n };\n return Math.abs(next.x - point.x) >= 80 || Math.abs(next.y - point.y) >= 80 ? point : next;\n }\n if (previous.width === 0) return point;\n const next = {\n // FloorCeiling.java performs integer division before applying the\n // mascot's relative offset along a resized border.\n x: (point.x - previous.x) * Math.trunc(current.width / previous.width) + current.x,\n y: point.y + this.coordinate(current) - this.coordinate(previous),\n };\n return Math.abs(next.x - point.x) >= 80 || next.y - point.y > 20 || next.y - point.y < -80 ? point : next;\n }\n\n public isOn(point: Point, context: RuntimeContext): boolean {\n const rectangle = this.rectangle(context);\n if (!rectangle) return false;\n switch (this.side) {\n case \"top\": return isOnTop(point, rectangle);\n case \"bottom\": return isOnBottom(point, rectangle);\n case \"left\": return isOnLeft(point, rectangle);\n case \"right\": return isOnRight(point, rectangle);\n }\n }\n\n private coordinate(rectangle: Rectangle): number {\n switch (this.side) {\n case \"top\": return rectangle.y;\n case \"bottom\": return rectangle.y + rectangle.height;\n case \"left\": return rectangle.x;\n case \"right\": return rectangle.x + rectangle.width;\n }\n }\n\n private rectangle(context: RuntimeContext): Rectangle | undefined {\n if (this.source === \"work-area\") return context.bounds;\n if (!this.source) return undefined;\n return context.platforms.find((platform) => platform.element === this.source);\n }\n}\n\nfunction selectBorder(type: BorderType, state: MascotState, context: RuntimeContext): TrackedBorder {\n if (type === \"Floor\") {\n const platform = context.platforms.find((candidate) => isOnTop(state, candidate));\n if (platform) return new TrackedBorder(\"top\", platform.element, context);\n if (isOnBottom(state, context.bounds)) return new TrackedBorder(\"bottom\", \"work-area\", context);\n return new TrackedBorder(\"bottom\", undefined, context);\n }\n if (type === \"Ceiling\") {\n const platform = context.platforms.find((candidate) => isOnBottom(state, candidate));\n if (platform) return new TrackedBorder(\"bottom\", platform.element, context);\n if (isOnTop(state, context.bounds)) return new TrackedBorder(\"top\", \"work-area\", context);\n return new TrackedBorder(\"top\", undefined, context);\n }\n if (state.lookRight) {\n const platform = context.platforms.find((candidate) => isOnLeft(state, candidate));\n if (platform) return new TrackedBorder(\"left\", platform.element, context);\n if (isOnRight(state, context.bounds)) return new TrackedBorder(\"right\", \"work-area\", context);\n return new TrackedBorder(\"right\", undefined, context);\n }\n const platform = context.platforms.find((candidate) => isOnRight(state, candidate));\n if (platform) return new TrackedBorder(\"right\", platform.element, context);\n if (isOnLeft(state, context.bounds)) return new TrackedBorder(\"left\", \"work-area\", context);\n return new TrackedBorder(\"left\", undefined, context);\n}\n\nabstract class AnimatedRuntime extends RuntimeBase {\n protected border: TrackedBorder | undefined;\n\n public constructor(definition: ActionDefinition, protected readonly state: MascotState, random: () => number) {\n super(definition, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n this.border = this.definition.borderType ? selectBorder(this.definition.borderType, this.state, context) : undefined;\n }\n\n protected animation(context: RuntimeContext, turn?: boolean): AnimationDefinition | undefined {\n const scoped = this.scopedEnvironment(context.environment);\n return this.definition.animations?.find((animation, index) =>\n (turn === undefined || Boolean(animation.turn) === turn)\n && this.values.boolean(`animation-${index}`, animation.condition, scoped, true));\n }\n\n protected animationDuration(context: RuntimeContext, turn?: boolean): number {\n return this.animation(context, turn)?.poses.reduce((sum, pose) => sum + Math.max(0, pose.duration), 0) ?? 0;\n }\n\n protected applyBorder(context: RuntimeContext): \"running\" | \"lost-ground\" {\n if (!this.border) return \"running\";\n const moved = this.border.move(this.state, context);\n this.state.x = moved.x;\n this.state.y = moved.y;\n return this.border.isOn(this.state, context) ? \"running\" : \"lost-ground\";\n }\n\n protected applyAnimation(context: RuntimeContext, turn?: boolean): void {\n const animation = this.animation(context, turn);\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n }\n\n protected scopedEnvironment(environment: MascotEnvironment): MascotEnvironment {\n const gap = this.values.number(\"gap\", this.definition.gap, environment, 0);\n const withGap = { ...environment, gap };\n const targetX = this.definition.targetX === undefined ? undefined : this.values.number(\"targetX\", this.definition.targetX, withGap, 0);\n const targetY = this.definition.targetY === undefined ? undefined : this.values.number(\"targetY\", this.definition.targetY, withGap, 0);\n return { ...withGap, ...(targetX !== undefined && { targetX }), ...(targetY !== undefined && { targetY }) };\n }\n}\n\nfunction poseAt(animation: AnimationDefinition, time: number): Pose | undefined {\n const duration = animation.poses.reduce((sum, pose) => sum + Math.max(0, pose.duration), 0);\n if (duration <= 0) return undefined;\n let cursor = time % duration;\n for (const pose of animation.poses) {\n cursor -= Math.max(0, pose.duration);\n if (cursor < 0) return pose;\n }\n return animation.poses.at(-1);\n}\n\nfunction applyPose(state: MascotState, pose: Pose): void {\n state.sprite = pose.sprite;\n state.anchorX = pose.anchor.x;\n state.anchorY = pose.anchor.y;\n state.x += (state.lookRight ? -1 : 1) * pose.velocity.x;\n state.y += pose.velocity.y;\n}\n\nclass StayRuntime extends AnimatedRuntime {\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const border = this.applyBorder(context);\n if (border === \"lost-ground\") return border;\n this.applyAnimation(context);\n return \"running\";\n }\n}\n\nclass AnimateRuntime extends StayRuntime {\n protected override hasMore(context: RuntimeContext): boolean { return this.time < this.animationDuration(context); }\n}\n\nclass MoveRuntime extends AnimatedRuntime {\n protected turning = false;\n protected hasTurningAnimation = false;\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.turning = false;\n this.hasTurningAnimation = this.definition.animations?.some((animation) => animation.turn) ?? false;\n }\n\n protected override hasMore(context: RuntimeContext): boolean {\n const scoped = this.scopedEnvironment(context.environment);\n const targetX = this.targetX(scoped);\n const targetY = this.targetY(scoped);\n const reached = (targetX !== undefined && this.state.x === targetX) || (targetY !== undefined && this.state.y === targetY);\n return !reached || this.turning;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const border = this.applyBorder(context);\n if (border === \"lost-ground\") return border;\n const scoped = this.scopedEnvironment(context.environment);\n const targetX = this.targetX(scoped);\n const targetY = this.targetY(scoped);\n let down = false;\n if (targetX !== undefined && this.state.x !== targetX) {\n const nextLookRight = this.state.x < targetX;\n this.turning = this.hasTurningAnimation && (this.turning || nextLookRight !== this.state.lookRight);\n this.state.lookRight = nextLookRight;\n }\n if (targetY !== undefined) down = this.state.y < targetY;\n if (this.turning && this.time >= this.animationDuration(context, true)) this.turning = false;\n this.applyAnimation(context, this.turning);\n if (targetX !== undefined && ((this.state.lookRight && this.state.x >= targetX) || (!this.state.lookRight && this.state.x <= targetX))) this.state.x = targetX;\n if (targetY !== undefined && ((down && this.state.y >= targetY) || (!down && this.state.y <= targetY))) this.state.y = targetY;\n return \"running\";\n }\n\n protected targetX(environment: MascotEnvironment): number | undefined {\n return this.definition.targetX === undefined ? undefined : Math.trunc(this.values.number(\"targetX\", this.definition.targetX, environment, 0));\n }\n\n protected targetY(environment: MascotEnvironment): number | undefined {\n return this.definition.targetY === undefined ? undefined : Math.trunc(this.values.number(\"targetY\", this.definition.targetY, environment, 0));\n }\n}\n\nclass MoveWithTurnRuntime extends MoveRuntime {\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.hasTurningAnimation = (this.definition.animations?.length ?? 0) >= 2;\n }\n\n protected override animation(context: RuntimeContext, turn?: boolean): AnimationDefinition | undefined {\n const animations = this.definition.animations ?? [];\n if (turn) return animations.at(-1);\n const scoped = this.scopedEnvironment(context.environment);\n return animations.slice(0, -1).find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, scoped, true));\n }\n}\n\nclass TurnRuntime extends AnimatedRuntime {\n private turning = false;\n\n protected override hasMore(context: RuntimeContext): boolean {\n const desired = this.values.boolean(\"lookRight\", this.definition.lookRight, context.environment, !this.state.lookRight);\n this.turning ||= desired !== this.state.lookRight;\n return this.turning && this.time < this.animationDuration(context);\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n this.state.lookRight = this.values.boolean(\"lookRight\", this.definition.lookRight, context.environment, !this.state.lookRight);\n const border = this.applyBorder(context);\n if (border === \"lost-ground\") return border;\n this.applyAnimation(context);\n return \"running\";\n }\n}\n\nclass InstantRuntime extends RuntimeBase {\n public constructor(definition: ActionDefinition, private readonly state: MascotState, random: () => number, private readonly operation: \"look\" | \"offset\" | \"noop\") {\n super(definition, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n if (!this.baseHasNext(context)) return;\n if (this.operation === \"look\") {\n this.state.lookRight = this.values.boolean(\"lookRight\", this.definition.lookRight, context.environment, !this.state.lookRight);\n } else if (this.operation === \"offset\") {\n this.state.x += Math.trunc(this.values.number(\"x\", this.definition.x, context.environment, 0));\n this.state.y += Math.trunc(this.values.number(\"y\", this.definition.y, context.environment, 0));\n }\n }\n\n protected override hasMore(): boolean { return false; }\n protected override tick(): \"running\" { return \"running\"; }\n}\n\nclass JumpRuntime extends RuntimeBase {\n public constructor(definition: ActionDefinition, private readonly state: MascotState, random: () => number) { super(definition, random); }\n\n protected override hasMore(context: RuntimeContext): boolean { return this.distance(context).distance !== 0; }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const { targetX, targetY, distanceX, distanceY, distance } = this.distance(context);\n this.state.lookRight = this.state.x < targetX;\n const velocity = this.values.number(\"velocity\", this.definition.velocity, context.environment, 20);\n if (distance !== 0) {\n this.state.vx = velocity * distanceX / distance;\n this.state.vy = velocity * distanceY / distance;\n this.state.x += Math.trunc(this.state.vx);\n this.state.y += Math.trunc(this.state.vy);\n const environment = { ...context.environment, targetX, targetY };\n const animation = this.definition.animations?.find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, environment, true));\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n }\n if (distance <= velocity) { this.state.x = targetX; this.state.y = targetY; }\n return \"running\";\n }\n\n private distance(context: RuntimeContext): { targetX: number; targetY: number; distanceX: number; distanceY: number; distance: number } {\n const targetX = Math.trunc(this.values.number(\"targetX\", this.definition.targetX, context.environment, 0));\n const targetY = Math.trunc(this.values.number(\"targetY\", this.definition.targetY, context.environment, 0));\n const distanceX = targetX - this.state.x;\n const distanceY = targetY - this.state.y - Math.abs(distanceX) / 2;\n return { targetX, targetY, distanceX, distanceY, distance: Math.hypot(distanceX, distanceY) };\n }\n}\n\nclass FallRuntime extends RuntimeBase {\n private modX = 0;\n private modY = 0;\n\n public constructor(definition: ActionDefinition, protected readonly state: MascotState, random: () => number, private readonly defaultGravity: number) {\n super(definition, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n this.modX = 0;\n this.modY = 0;\n this.state.vx = Math.trunc(this.values.number(\"initialVx\", this.definition.initialVx, context.environment, 0));\n this.state.vy = Math.trunc(this.values.number(\"initialVy\", this.definition.initialVy, context.environment, 0));\n }\n\n protected override hasMore(context: RuntimeContext): boolean {\n return !isOnFloor(this.state, context.bounds, context.platforms) && !isOnWall(this.state, context.bounds, this.state.lookRight, context.platforms);\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n if (this.state.vx !== 0) this.state.lookRight = this.state.vx > 0;\n const resistanceX = this.values.number(\"resistanceX\", this.definition.resistanceX, context.environment, 0.05);\n const resistanceY = this.values.number(\"resistanceY\", this.definition.resistanceY, context.environment, 0.1);\n const gravity = this.values.number(\"gravity\", this.definition.gravity, context.environment, this.defaultGravity);\n this.state.vx -= this.state.vx * resistanceX;\n this.state.vy = this.state.vy - this.state.vy * resistanceY + gravity;\n this.modX += this.state.vx % 1;\n this.modY += this.state.vy % 1;\n const dx = Math.trunc(this.state.vx) + Math.trunc(this.modX);\n const dy = Math.trunc(this.state.vy) + Math.trunc(this.modY);\n this.modX %= 1;\n this.modY %= 1;\n const divisions = Math.max(1, Math.abs(dx), Math.abs(dy));\n const start = { x: this.state.x, y: this.state.y };\n let stopped = false;\n for (let index = 0; index <= divisions; index += 1) {\n const x = start.x + Math.trunc((dx * index) / divisions);\n const y = start.y + Math.trunc((dy * index) / divisions);\n this.state.x = x;\n this.state.y = y;\n if (dy > 0) {\n for (let offset = -80; offset <= 0; offset += 1) {\n this.state.y = y + offset;\n if (isOnFloor(this.state, context.bounds, context.platforms)) { stopped = true; break; }\n }\n if (stopped) break;\n this.state.y = y;\n }\n if (isOnWall(this.state, context.bounds, this.state.lookRight, context.platforms)) break;\n }\n const fallEnvironment = { ...context.environment, velocityX: this.state.vx, velocityY: this.state.vy };\n const animation = this.definition.animations?.find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, fallEnvironment, true));\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n return \"running\";\n }\n}\n\nfunction matchingActivePlatform(context: RuntimeContext): PlatformRectangle | undefined {\n const active = context.environment.mascot.environment.activeIE;\n if (!active.visible) return undefined;\n return context.platforms.find((platform) =>\n Math.abs(platform.x - active.x) < 0.001\n && Math.abs(platform.y - active.y) < 0.001\n && Math.abs(platform.width - active.width) < 0.001\n && Math.abs(platform.height - active.height) < 0.001);\n}\n\nfunction carryRelation(state: MascotState, platform: Rectangle, offsetX: number, offsetY: number): boolean {\n const grip = {\n x: state.x + (state.lookRight ? -offsetX : offsetX),\n y: state.y + offsetY,\n };\n return isOnBottom(grip, platform)\n && (state.lookRight ? isOnLeft(grip, platform) : isOnRight(grip, platform));\n}\n\nfunction carriedPlatformPosition(state: MascotState, platform: Rectangle, offsetX: number, offsetY: number): Point {\n return state.lookRight\n ? { x: state.x - offsetX, y: state.y + offsetY - platform.height }\n : { x: state.x + offsetX - platform.width, y: state.y + offsetY - platform.height };\n}\n\nclass CarryFallRuntime extends FallRuntime {\n private element: HTMLElement | undefined;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, gravity: number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random, gravity);\n }\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.element = matchingActivePlatform(context)?.element;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const platform = context.platforms.find((candidate) => candidate.element === this.element);\n const offsetX = Math.trunc(this.values.number(\"ieOffsetX\", this.definition.ieOffsetX, context.environment, 0));\n const offsetY = Math.trunc(this.values.number(\"ieOffsetY\", this.definition.ieOffsetY, context.environment, 0));\n if (!platform || !carryRelation(this.state, platform, offsetX, offsetY)) return \"lost-ground\";\n const result = super.tick(context);\n this.callbacks.movePlatform?.(platform.element, carriedPlatformPosition(this.state, platform, offsetX, offsetY));\n return result;\n }\n}\n\nclass CarryMoveRuntime extends MoveRuntime {\n private element: HTMLElement | undefined;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.element = matchingActivePlatform(context)?.element;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const platform = context.platforms.find((candidate) => candidate.element === this.element);\n const offsetX = Math.trunc(this.values.number(\"ieOffsetX\", this.definition.ieOffsetX, context.environment, 0));\n const offsetY = Math.trunc(this.values.number(\"ieOffsetY\", this.definition.ieOffsetY, context.environment, 0));\n if (!platform || !carryRelation(this.state, platform, offsetX, offsetY)) return \"lost-ground\";\n const result = super.tick(context);\n this.callbacks.movePlatform?.(platform.element, carriedPlatformPosition(this.state, platform, offsetX, offsetY));\n return result;\n }\n}\n\nclass ThrowPlatformRuntime extends AnimateRuntime {\n private element: HTMLElement | undefined;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random);\n }\n\n protected override onInit(context: RuntimeContext): void {\n super.onInit(context);\n this.element = matchingActivePlatform(context)?.element;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n const platform = context.platforms.find((candidate) => candidate.element === this.element);\n if (platform) {\n const vx = Math.trunc(this.values.number(\"initialVx\", this.definition.initialVx, context.environment, 32));\n const vy = Math.trunc(this.values.number(\"initialVy\", this.definition.initialVy, context.environment, -10));\n const gravity = this.values.number(\"gravity\", this.definition.gravity, context.environment, 0.5);\n this.callbacks.movePlatform?.(platform.element, {\n x: platform.x + (this.state.lookRight ? vx : -vx),\n y: platform.y + vy + Math.trunc(this.time * gravity),\n });\n }\n return result;\n }\n}\n\nfunction breed(\n definition: ActionDefinition,\n state: MascotState,\n values: ActionValues,\n context: RuntimeContext,\n callbacks: ActionExecutorCallbacks,\n): void {\n const bornX = Math.trunc(values.number(\"bornX\", definition.bornX, context.environment, 0));\n const bornY = Math.trunc(values.number(\"bornY\", definition.bornY, context.environment, 0));\n const count = Math.trunc(values.number(\"bornCount\", definition.bornCount, context.environment, 1));\n if (count < 1) throw new RangeError(\"BornCount must be positive\");\n for (let index = 0; index < count; index += 1) {\n callbacks.spawn({\n x: state.x + (state.lookRight ? -bornX : bornX),\n y: state.y + bornY,\n lookRight: state.lookRight,\n ...(definition.bornBehavior && { behaviorName: definition.bornBehavior }),\n }, definition.bornMascot);\n }\n}\n\nclass BreedRuntime extends AnimateRuntime {\n private spawned = false;\n\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) {\n super(definition, state, random);\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n if (result === \"lost-ground\") return result;\n const duration = this.animationDuration(context);\n if (!this.spawned && this.time === duration - 1) {\n this.spawned = true;\n breed(this.definition, this.state, this.values, context, this.callbacks);\n }\n return result;\n }\n}\n\nclass BreedMoveRuntime extends MoveRuntime {\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) { super(definition, state, random); }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n if (result === \"lost-ground\") return result;\n const interval = Math.trunc(this.values.number(\"bornInterval\", this.definition.bornInterval, context.environment, 1));\n if (interval < 1) throw new RangeError(\"BornInterval must be positive\");\n if (this.time % interval === 0 && !this.turning) breed(this.definition, this.state, this.values, context, this.callbacks);\n return result;\n }\n}\n\nclass BreedJumpRuntime extends JumpRuntime {\n public constructor(definition: ActionDefinition, private readonly breedState: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) { super(definition, breedState, random); }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n const interval = Math.trunc(this.values.number(\"bornInterval\", this.definition.bornInterval, context.environment, 1));\n if (interval < 1) throw new RangeError(\"BornInterval must be positive\");\n if (this.time % interval === 0) breed(this.definition, this.breedState, this.values, context, this.callbacks);\n return result;\n }\n}\n\nclass DraggedRuntime extends RuntimeBase {\n private footX = 0;\n private footDx = 0;\n private timeToRegist = 250;\n\n public constructor(definition: ActionDefinition, private readonly state: MascotState, random: () => number, private readonly spec: CharacterSpec) { super(definition, random); }\n\n protected override onInit(context: RuntimeContext): void {\n this.footDx = 0;\n this.timeToRegist = 250;\n this.footX = context.environment.mascot.environment.cursor.x + this.offsetX(context);\n }\n\n protected override hasMore(): boolean { return this.time < this.timeToRegist; }\n\n protected override tick(context: RuntimeContext): \"running\" {\n this.state.lookRight = false;\n this.state.dragging = true;\n const cursor = context.environment.mascot.environment.cursor;\n const offsetX = this.offsetX(context);\n const offsetY = this.offsetY(context);\n if (Math.abs(cursor.x - this.state.x + offsetX) >= 5) this.time = 0;\n this.footDx = (this.footDx + (cursor.x - this.footX) * 0.1) * 0.8;\n this.footX += this.footDx;\n const environment = { ...context.environment, footX: this.footX };\n const animation = this.definition.animations?.find((candidate, index) => this.values.boolean(`animation-${index}`, candidate.condition, environment, true));\n const pose = animation && poseAt(animation, this.time);\n if (pose) applyPose(this.state, pose);\n this.state.x = cursor.x + offsetX;\n this.state.y = cursor.y + offsetY;\n if (this.time === this.timeToRegist - 1 && this.values.number(`regist-${this.time}`, \"#{Math.random()}\", environment, 0) >= 0.1) this.timeToRegist += 1;\n return \"running\";\n }\n\n private offsetX(context: RuntimeContext): number {\n const offset = Math.trunc(this.values.number(\"offsetX\", this.definition.offsetX, context.environment, 0));\n return this.definition.offsetType === \"Origin\" ? -offset + this.spriteCenter().x : offset;\n }\n\n private offsetY(context: RuntimeContext): number {\n const offset = Math.trunc(this.values.number(\"offsetY\", this.definition.offsetY, context.environment, 120));\n return this.definition.offsetType === \"Origin\" ? -offset + this.spriteCenter().y : offset;\n }\n\n private spriteCenter(): Point {\n const sprite = this.spec.sprites[this.state.sprite];\n const width = typeof sprite === \"object\" ? (sprite.width ?? 128) : 128;\n return { x: this.state.lookRight ? width - this.state.anchorX : this.state.anchorX, y: this.state.anchorY };\n }\n}\n\nclass RegistRuntime extends AnimatedRuntime {\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly spec: CharacterSpec) { super(definition, state, random); }\n\n protected override hasMore(context: RuntimeContext): boolean {\n const cursor = context.environment.mascot.environment.cursor;\n const rawOffset = Math.trunc(this.values.number(\"offsetX\", this.definition.offsetX, context.environment, 0));\n const sprite = this.spec.sprites[this.state.sprite];\n const width = typeof sprite === \"object\" ? (sprite.width ?? 128) : 128;\n const centerX = this.state.lookRight ? width - this.state.anchorX : this.state.anchorX;\n const offsetX = this.definition.offsetType === \"Origin\" ? -rawOffset + centerX : rawOffset;\n return Math.abs(cursor.x - this.state.x + offsetX) < 5;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n this.state.dragging = true;\n this.applyAnimation(context);\n if (this.time + 1 >= this.animationDuration(context)) {\n this.state.lookRight = this.values.number(`look-${this.time}`, \"#{Math.random()}\", context.environment, 0) < 0.5;\n return \"lost-ground\";\n }\n return \"running\";\n }\n}\n\nclass SelfDestructRuntime extends AnimateRuntime {\n public constructor(definition: ActionDefinition, state: MascotState, random: () => number, private readonly callbacks: ActionExecutorCallbacks) { super(definition, state, random); }\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n const result = super.tick(context);\n if (this.time === this.animationDuration(context) - 1) this.callbacks.remove();\n return result;\n }\n}\n\nclass ComplexRuntime extends RuntimeBase {\n private index = 0;\n private child: Runtime | undefined;\n private selectionMade = false;\n\n public constructor(\n definition: ActionDefinition,\n random: () => number,\n private readonly factory: (definition: ActionDefinition, context: RuntimeContext) => Runtime,\n private readonly selectOnly: boolean,\n ) { super(definition, random); }\n\n protected override onInit(context: RuntimeContext): void {\n this.index = 0;\n this.child = undefined;\n this.selectionMade = false;\n if (this.baseHasNext(context)) this.seek(context);\n }\n\n protected override hasMore(context: RuntimeContext): boolean {\n if (!this.selectOnly) this.seek(context);\n return this.child?.hasNext(context) ?? false;\n }\n\n protected override tick(context: RuntimeContext): \"running\" | \"lost-ground\" {\n return this.child?.hasNext(context) ? this.child.step(context) : \"running\";\n }\n\n private seek(context: RuntimeContext): void {\n const definitions = this.definition.actions ?? [];\n if (definitions.length === 0) return;\n for (let guard = 0; guard <= definitions.length; guard += 1) {\n if (this.child?.hasNext(context)) { this.selectionMade = true; return; }\n if (this.selectOnly && this.selectionMade) { this.child = undefined; return; }\n if (this.index >= definitions.length) {\n if (this.definition.loop !== true) { this.child = undefined; return; }\n this.index = 0;\n }\n const definition = definitions[this.index++];\n if (!definition) { this.child = undefined; return; }\n this.child = this.factory(definition, context);\n this.child.init(context);\n }\n this.child = undefined;\n }\n}\n\n/** Executes normalized action trees using Shimeji-ee's discrete action lifecycle. */\nexport class ActionExecutor {\n private runtime: Runtime | undefined;\n private accumulator = 0;\n private readonly random: () => number;\n\n public constructor(\n private readonly spec: CharacterSpec,\n private readonly state: MascotState,\n private readonly options: ActionExecutorOptions,\n private readonly callbacks: ActionExecutorCallbacks,\n ) { this.random = options.random ?? Math.random; }\n\n /** Starts the action whose name matches a selected behavior. */\n public start(\n actionName: string,\n environment: MascotEnvironment,\n _preserveLookRight = false,\n bounds: Rectangle = environment.mascot.environment.workArea,\n platforms: readonly PlatformRectangle[] = [],\n ): boolean {\n const definition = this.spec.actions.find((action) => action.name === actionName);\n this.accumulator = 0;\n if (!definition) { this.runtime = undefined; return false; }\n const context = { environment, bounds, platforms };\n this.runtime = this.createRuntime(definition, context, new Set());\n this.runtime.init(context);\n return true;\n }\n\n /** Advances by elapsed milliseconds and reports completion. */\n public tick(deltaMs: number, environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[] = []): boolean {\n this.accumulator += Math.max(0, deltaMs);\n let result: ActionTickResult = this.runtime?.hasNext({ environment, bounds, platforms }) ? \"running\" : \"complete\";\n while (this.accumulator >= this.options.frameDuration && result === \"running\") {\n this.accumulator -= this.options.frameDuration;\n result = this.step(environment, bounds, platforms);\n }\n return result !== \"running\";\n }\n\n /** Advances exactly one legacy frame. */\n public step(environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[] = []): ActionTickResult {\n const context = { environment, bounds, platforms };\n if (!this.runtime?.hasNext(context)) return \"complete\";\n const result = this.runtime.step(context);\n if (result === \"lost-ground\") return result;\n return this.runtime.hasNext(context) ? \"running\" : \"complete\";\n }\n\n /** Returns whether the current action can execute another legacy frame. */\n public hasNext(environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[] = []): boolean {\n return this.runtime?.hasNext({ environment, bounds, platforms }) ?? false;\n }\n\n /** Retained for source compatibility with the previous collision API. */\n public consumeViewportWallCollision(): boolean { return false; }\n\n /** Cancels the current action tree. */\n public cancel(): void { this.runtime = undefined; this.accumulator = 0; }\n\n private createRuntime(definition: ActionDefinition, context: RuntimeContext, references: Set<string>): Runtime {\n if (definition.type === \"Reference\") {\n if (!definition.name || references.has(definition.name)) return new InstantRuntime(definition, this.state, this.random, \"noop\");\n const referenced = this.spec.actions.find((action) => action.name === definition.name);\n if (!referenced) return new InstantRuntime(definition, this.state, this.random, \"noop\");\n return this.createRuntime({ ...referenced, ...definition, type: referenced.type, name: definition.name }, context, new Set(references).add(definition.name));\n }\n if (definition.type === \"Sequence\" || definition.type === \"Select\") {\n return new ComplexRuntime(definition, this.random, (child, nextContext) => this.createRuntime(child, nextContext, new Set(references)), definition.type === \"Select\");\n }\n if (definition.type === \"Stay\") return new StayRuntime(definition, this.state, this.random);\n if (definition.type === \"Animate\") return new AnimateRuntime(definition, this.state, this.random);\n if (definition.type === \"Move\") return new MoveRuntime(definition, this.state, this.random);\n switch (definition.embedType) {\n case \"Fall\": return new FallRuntime(definition, this.state, this.random, this.options.gravity);\n case \"FallWithIE\": return new CarryFallRuntime(definition, this.state, this.random, this.options.gravity, this.callbacks);\n case \"Jump\": case \"ComplexJump\": case \"ScanJump\": case \"BroadcastJump\": return new JumpRuntime(definition, this.state, this.random);\n case \"WalkWithIE\": return new CarryMoveRuntime(definition, this.state, this.random, this.callbacks);\n case \"MoveWithTurn\": return new MoveWithTurnRuntime(definition, this.state, this.random);\n case \"ComplexMove\": case \"ScanMove\": case \"BroadcastMove\": return new MoveRuntime(definition, this.state, this.random);\n case \"Turn\": return new TurnRuntime(definition, this.state, this.random);\n case \"Look\": return new InstantRuntime(definition, this.state, this.random, \"look\");\n case \"Offset\": return new InstantRuntime(definition, this.state, this.random, \"offset\");\n case \"Mute\": case \"Reboot\": return new InstantRuntime(definition, this.state, this.random, \"noop\");\n case \"Breed\": return new BreedRuntime(definition, this.state, this.random, this.callbacks);\n case \"BreedMove\": return new BreedMoveRuntime(definition, this.state, this.random, this.callbacks);\n case \"BreedJump\": return new BreedJumpRuntime(definition, this.state, this.random, this.callbacks);\n case \"ThrowIE\": return new ThrowPlatformRuntime(definition, this.state, this.random, this.callbacks);\n case \"SelfDestruct\": case \"Exit\": return new SelfDestructRuntime(definition, this.state, this.random, this.callbacks);\n case \"Dragged\": return new DraggedRuntime(definition, this.state, this.random, this.spec);\n case \"Regist\": return new RegistRuntime(definition, this.state, this.random, this.spec);\n case \"Broadcast\": case \"Interact\": case \"ScanInteract\": case \"Transform\": return new AnimateRuntime(definition, this.state, this.random);\n case \"BroadcastStay\": return new StayRuntime(definition, this.state, this.random);\n default: return new StayRuntime(definition, this.state, this.random);\n }\n }\n}\n","import { ActionExecutor } from \"./action\";\nimport { BehaviorController } from \"./behavior\";\nimport type { DomManager, MascotDomHandle } from \"./dom\";\nimport { isOnBottom, isOnFloor, isOnLeft, isOnRight, isOnTop } from \"./physics\";\nimport type { PlatformRectangle } from \"./platform\";\nimport type { BehaviorDefinition, CharacterSpec, EnvironmentEdge, EnvironmentRectangle, MascotEnvironment, MascotState, Point, Rectangle, ShimejiEngineOptions, SpawnOptions } from \"./types\";\n\n/** Callbacks through which a mascot communicates with its owning engine. */\nexport interface MascotCallbacks {\n /** Returns the latest pointer position and velocity in work-area coordinates. */\n pointer(): Point & { dx: number; dy: number };\n /** Returns the current number of live mascots. */\n count(): number;\n /** Requests a sibling mascot. */\n spawn(characterId: string, options: SpawnOptions): void;\n /** Requests removal of this mascot. */\n remove(id: string): void;\n /** Moves a registered platform for legacy IE interaction actions. */\n movePlatform?(element: HTMLElement, point: Point): void;\n /** Reports a click without a drag gesture. */\n click(state: MascotState): void;\n /** Reports a recoverable runtime failure. */\n error(error: Error): void;\n}\n\nfunction edge(predicate: (point: Point) => boolean): EnvironmentEdge { return { isOn: predicate }; }\n\nfunction environmentRectangle(bounds: Rectangle): EnvironmentRectangle {\n const left = bounds.x;\n const right = bounds.x + bounds.width;\n const top = bounds.y;\n const bottom = bounds.y + bounds.height;\n return {\n x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height,\n left, right, top, bottom,\n topBorder: edge((point) => isOnTop(point, bounds)),\n leftBorder: edge((point) => isOnLeft(point, bounds)),\n rightBorder: edge((point) => isOnRight(point, bounds)),\n bottomBorder: edge((point) => isOnBottom(point, bounds)),\n };\n}\n\nconst PLATFORM_NEARBY_DISTANCE = 400;\nconst PLATFORM_EDGE_TOLERANCE = 2;\nconst MASCOT_HITBOX_MAX_WIDTH = 32;\nconst MASCOT_HITBOX_MAX_HEIGHT = 64;\nconst MASCOT_COLLISION_LOOKAHEAD = 4;\nconst IE_BEHAVIOR_NAME_PATTERN = /wall|climb|crawl|壁|登|よじ/i;\n\n/** Lightweight geometry shared between mascots for behavioral collision avoidance. */\nexport interface MascotCollisionBox extends Rectangle {\n id: string;\n /** Stable anchor position, unaffected by sprite mirroring. */\n positionX: number;\n}\n\nfunction isIEBehavior(behavior: BehaviorDefinition): boolean {\n return behavior.conditions.some((condition) => /activeIE/i.test(condition))\n || behavior.name.includes(\"IE\")\n || behavior.name.includes(\"IE\")\n || IE_BEHAVIOR_NAME_PATTERN.test(behavior.name)\n || (behavior.actionName !== undefined && (\n behavior.actionName.includes(\"IE\")\n || behavior.actionName.includes(\"IE\")\n || IE_BEHAVIOR_NAME_PATTERN.test(behavior.actionName)\n ));\n}\n\nfunction distanceToRectangle(point: Point, rectangle: Rectangle): number {\n const dx = Math.max(rectangle.x - point.x, 0, point.x - rectangle.x - rectangle.width);\n const dy = Math.max(rectangle.y - point.y, 0, point.y - rectangle.y - rectangle.height);\n return Math.hypot(dx, dy);\n}\n\n/** Owns one mascot's state machine, interaction listeners, and DOM resource. */\nexport class Mascot {\n /** Mutable internal state; callers should consume snapshots from the engine. */\n public readonly state: MascotState;\n private readonly domHandle: MascotDomHandle;\n private readonly behavior: BehaviorController;\n private readonly actions: ActionExecutor;\n private readonly disposers: Array<() => void> = [];\n private currentBehavior: BehaviorDefinition | undefined;\n private destroyed = false;\n private dragOffset: Point = { x: 0, y: 0 };\n private pointerId: number | undefined;\n private pointerDown: Point | undefined;\n private lastPointer: Point | undefined;\n private activePlatformElement: HTMLElement | undefined;\n private platforms: readonly PlatformRectangle[] = [];\n private accumulatedMs = 0;\n private readonly frameDuration: number;\n private readonly random: () => number;\n private readonly forceInitialFall: boolean;\n\n /** Creates a mascot and immediately installs its pointer handlers. */\n public constructor(\n public readonly id: string,\n public readonly spec: CharacterSpec,\n private readonly dom: DomManager,\n options: Required<Pick<ShimejiEngineOptions, \"frameDuration\" | \"gravity\" | \"mascotClassName\">> & { random: (() => number) | undefined },\n spawnOptions: SpawnOptions,\n private readonly callbacks: MascotCallbacks,\n ) {\n const initialPose = spec.actions.flatMap((action) => action.animations ?? []).flatMap((animation) => animation.poses)[0];\n this.state = {\n id,\n characterId: spec.id,\n x: spawnOptions.x ?? 0,\n y: spawnOptions.y ?? 0,\n vx: spawnOptions.vx ?? 0,\n vy: spawnOptions.vy ?? 0,\n sprite: initialPose?.sprite ?? Object.keys(spec.sprites)[0] ?? \"\",\n anchorX: initialPose?.anchor.x ?? 64,\n anchorY: initialPose?.anchor.y ?? 128,\n lookRight: spawnOptions.lookRight ?? false,\n behaviorName: spawnOptions.behaviorName ?? \"Fall\",\n dragging: false,\n };\n this.domHandle = dom.createMascot(spec, id, options.mascotClassName || undefined);\n this.frameDuration = options.frameDuration;\n this.random = options.random ?? Math.random;\n this.forceInitialFall = spawnOptions.behaviorName === undefined;\n this.behavior = new BehaviorController(spec, options.random);\n this.actions = new ActionExecutor(spec, this.state, options, {\n spawn: (position, characterId) => this.callbacks.spawn(characterId ?? this.spec.id, position),\n remove: () => this.callbacks.remove(this.id),\n ...(this.callbacks.movePlatform && { movePlatform: this.callbacks.movePlatform }),\n });\n this.installPointerHandlers();\n }\n\n /** Advances behavior, animation, physics, and rendering by one clock tick. */\n public tick(\n deltaMs: number,\n bounds: Rectangle,\n platforms: readonly PlatformRectangle[] = [],\n siblings: readonly MascotCollisionBox[] = [],\n ): void {\n if (this.destroyed) return;\n this.platforms = platforms;\n try {\n this.ensureBehavior(bounds, platforms, true);\n this.accumulatedMs += Math.max(0, deltaMs);\n while (this.accumulatedMs >= this.frameDuration && !this.destroyed) {\n this.accumulatedMs -= this.frameDuration;\n this.legacyTick(bounds, platforms, siblings);\n }\n } catch (error) {\n this.callbacks.error(error instanceof Error ? error : new Error(String(error)));\n this.currentBehavior = undefined;\n this.actions.cancel();\n }\n this.dom.render(this.domHandle, this.spec, this.state);\n }\n\n /** Returns a detached snapshot safe for application code to retain. */\n public snapshot(): MascotState { return { ...this.state }; }\n\n /** Returns the mascot's compact, feet-aligned behavioral collision box. */\n public collisionBox(): MascotCollisionBox {\n const sprite = this.spec.sprites[this.state.sprite];\n const spriteWidth = typeof sprite === \"object\" && sprite.width !== undefined ? sprite.width : 128;\n const spriteHeight = typeof sprite === \"object\" && sprite.height !== undefined ? sprite.height : 128;\n const width = Math.min(spriteWidth, MASCOT_HITBOX_MAX_WIDTH);\n const height = Math.min(spriteHeight, MASCOT_HITBOX_MAX_HEIGHT);\n const anchorX = this.state.lookRight ? spriteWidth - this.state.anchorX : this.state.anchorX;\n const visualLeft = this.state.x - anchorX;\n const visualTop = this.state.y - this.state.anchorY;\n return {\n id: this.id,\n positionX: this.state.x,\n x: visualLeft + (spriteWidth - width) / 2,\n y: visualTop + spriteHeight - height,\n width,\n height,\n };\n }\n\n /** Removes listeners, DOM nodes, and object URLs owned by this mascot. */\n public destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.actions.cancel();\n for (const dispose of this.disposers.splice(0)) dispose();\n this.dom.removeMascot(this.domHandle);\n }\n\n private startBehavior(environment: MascotEnvironment, bounds: Rectangle, platforms: readonly PlatformRectangle[]): boolean {\n if (!this.currentBehavior) return false;\n this.state.behaviorName = this.currentBehavior.name;\n return this.actions.start(this.currentBehavior.actionName ?? this.currentBehavior.name, environment, false, bounds, platforms);\n }\n\n private ensureBehavior(bounds: Rectangle, platforms: readonly PlatformRectangle[], initial: boolean): void {\n for (let guard = 0; guard < 32 && !this.destroyed; guard += 1) {\n const environment = this.createEnvironment(bounds, platforms);\n if (!this.currentBehavior) {\n this.currentBehavior = initial\n ? this.forceInitialFall\n ? this.findFallBehavior() ?? this.behavior.selectInitial(environment)\n : this.behavior.selectInitial(environment, this.state.behaviorName)\n : this.selectNextBehavior(environment, bounds);\n initial = false;\n if (!this.currentBehavior) this.currentBehavior = this.findFallBehavior();\n if (!this.currentBehavior || !this.startBehavior(environment, bounds, platforms)) return;\n }\n if (this.actions.hasNext(environment, bounds, platforms)) return;\n this.currentBehavior = this.selectNextBehavior(environment, bounds) ?? this.findFallBehavior();\n if (!this.currentBehavior) return;\n if (!this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms)) return;\n }\n }\n\n private legacyTick(\n bounds: Rectangle,\n platforms: readonly PlatformRectangle[],\n siblings: readonly MascotCollisionBox[],\n ): void {\n this.ensureBehavior(bounds, platforms, false);\n if (!this.currentBehavior) return;\n const previous = { x: this.state.x, y: this.state.y };\n const result = this.actions.step(this.createEnvironment(bounds, platforms), bounds, platforms);\n if (this.destroyed) return;\n this.avoidSiblingCollision(previous, bounds, platforms, siblings);\n if (result === \"lost-ground\") {\n this.state.dragging = false;\n this.actions.cancel();\n this.currentBehavior = this.selectEdgeBehavior(bounds, platforms);\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms);\n } else if (result === \"complete\") {\n this.currentBehavior = this.selectNextBehavior(this.createEnvironment(bounds, platforms), bounds);\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms);\n this.ensureBehavior(bounds, platforms, false);\n } else if (this.isOutsideVisibleBounds(bounds)) {\n this.state.x = Math.trunc(bounds.x + this.random() * bounds.width);\n this.state.y = bounds.y - 256;\n this.actions.cancel();\n this.currentBehavior = this.findFallBehavior();\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(bounds, platforms), bounds, platforms);\n }\n }\n\n private avoidSiblingCollision(\n previous: Point,\n bounds: Rectangle,\n platforms: readonly PlatformRectangle[],\n siblings: readonly MascotCollisionBox[],\n ): void {\n const dx = this.state.x - previous.x;\n if (this.state.dragging || dx === 0 || this.state.y !== previous.y) return;\n const onHorizontalSurface = isOnFloor(previous, bounds, platforms)\n || isOnTop(previous, bounds)\n || platforms.some((platform) => isOnBottom(previous, platform));\n if (!onHorizontalSurface) return;\n\n const currentBox = this.collisionBox();\n const offsetX = currentBox.x - this.state.x;\n const previousBox = { ...currentBox, x: previous.x + offsetX };\n const movingRight = dx > 0;\n const sweptLeft = Math.min(previousBox.x, currentBox.x) - (movingRight ? 0 : MASCOT_COLLISION_LOOKAHEAD);\n const sweptRight = Math.max(previousBox.x + previousBox.width, currentBox.x + currentBox.width)\n + (movingRight ? MASCOT_COLLISION_LOOKAHEAD : 0);\n\n const overlappingSiblings = siblings.filter((sibling) => {\n if (sibling.id === this.id) return false;\n const overlapsVertically = currentBox.y < sibling.y + sibling.height\n && sibling.y < currentBox.y + currentBox.height;\n const overlapsHorizontally = previousBox.x < sibling.x + sibling.width\n && sibling.x < previousBox.x + previousBox.width;\n return overlapsVertically && (overlapsHorizontally || sibling.positionX === previous.x);\n });\n if (overlappingSiblings.length > 0) {\n const coincidentIds = [\n this.id,\n ...overlappingSiblings\n .filter((sibling) => sibling.positionX === previous.x)\n .map((sibling) => sibling.id),\n ].sort();\n const escapeRight = coincidentIds.length > 1\n ? coincidentIds.indexOf(this.id) >= coincidentIds.length / 2\n : overlappingSiblings.reduce((sum, sibling) => sum + sibling.positionX, 0)\n / overlappingSiblings.length < previous.x;\n if (movingRight !== escapeRight) {\n this.state.x = previous.x;\n this.state.vx = 0;\n this.state.lookRight = !this.state.lookRight;\n }\n return;\n }\n\n const collision = siblings.some((sibling) => {\n if (sibling.id === this.id) return false;\n const isAhead = movingRight ? sibling.positionX > previous.x : sibling.positionX < previous.x;\n const overlapsVertically = currentBox.y < sibling.y + sibling.height\n && sibling.y < currentBox.y + currentBox.height;\n const crossesHorizontally = sweptLeft <= sibling.x + sibling.width && sibling.x <= sweptRight;\n return isAhead && overlapsVertically && crossesHorizontally;\n });\n if (!collision) return;\n\n this.state.x = previous.x;\n this.state.vx = 0;\n this.state.lookRight = !this.state.lookRight;\n }\n\n private isOutsideVisibleBounds(bounds: Rectangle): boolean {\n const sprite = this.spec.sprites[this.state.sprite];\n const width = typeof sprite === \"object\" && \"width\" in sprite && sprite.width !== undefined ? sprite.width : 128;\n const height = typeof sprite === \"object\" && \"height\" in sprite && sprite.height !== undefined ? sprite.height : 128;\n const anchorX = this.state.lookRight ? width - this.state.anchorX : this.state.anchorX;\n const left = this.state.x - anchorX;\n const top = this.state.y - this.state.anchorY;\n return left + width <= bounds.x || bounds.x + bounds.width <= left || bounds.y + bounds.height <= top;\n }\n\n private findFallBehavior(): BehaviorDefinition | undefined {\n return this.behavior.force(\"Fall\") ?? this.behavior.force(\"落下する\");\n }\n\n private selectNextBehavior(environment: MascotEnvironment, bounds: Rectangle, relocateOnFallback = true): BehaviorDefinition | undefined {\n const selected = this.behavior.selectNext(environment);\n if (relocateOnFallback && this.behavior.usedFallback()) {\n this.state.x = Math.trunc(bounds.x + this.random() * bounds.width);\n this.state.y = bounds.y - 256;\n }\n return selected;\n }\n\n private selectEdgeBehavior(bounds: Rectangle, platforms: readonly PlatformRectangle[]): BehaviorDefinition | undefined {\n const original = { x: this.state.x, y: this.state.y };\n const platform = platforms.find((candidate) => candidate.element === this.activePlatformElement);\n if (platform) {\n const left = platform.x;\n const right = platform.x + platform.width;\n const top = platform.y;\n const bottom = platform.y + platform.height;\n if (Math.abs(this.state.y - top) <= PLATFORM_EDGE_TOLERANCE || Math.abs(this.state.y - bottom) <= PLATFORM_EDGE_TOLERANCE) {\n if (this.state.x < left) this.state.x = left;\n else if (this.state.x > right) this.state.x = right;\n } else if (Math.abs(this.state.x - left) <= PLATFORM_EDGE_TOLERANCE || Math.abs(this.state.x - right) <= PLATFORM_EDGE_TOLERANCE) {\n if (this.state.y < top) this.state.y = top;\n else if (this.state.y > bottom) this.state.y = bottom;\n }\n }\n\n const environment = this.createEnvironment(bounds, platforms);\n const interruptedBehavior = this.currentBehavior;\n const selected = this.behavior.trySelectNext(environment, (candidate) => (\n candidate.name !== interruptedBehavior?.name && isIEBehavior(candidate)\n ))\n ?? this.selectNextBehavior(environment, bounds, false);\n if (this.behavior.usedFallback() || selected?.name === \"Fall\" || selected?.name === \"落下する\") {\n this.state.x = original.x;\n this.state.y = original.y;\n }\n return selected ?? this.findFallBehavior();\n }\n\n private createEnvironment(bounds: Rectangle, platforms: readonly PlatformRectangle[] = this.platforms): MascotEnvironment {\n const workArea = environmentRectangle(bounds);\n const inactive = environmentRectangle({ x: -100, y: -100, width: 0, height: 0 });\n const platform = this.selectActivePlatform(platforms);\n const activeIE = platform\n ? { ...environmentRectangle(platform), visible: true }\n : { ...inactive, visible: false };\n return {\n gap: 0,\n maxCount: 999,\n mascot: {\n totalCount: this.callbacks.count(),\n anchor: { x: this.state.x, y: this.state.y },\n lookRight: this.state.lookRight,\n environment: {\n cursor: this.callbacks.pointer(),\n screen: workArea,\n workArea,\n floor: edge((point) => isOnFloor(point, bounds, platforms)),\n ceiling: edge((point) => isOnTop(point, bounds) || platforms.some((candidate) => isOnBottom(point, candidate))),\n activeIE,\n },\n },\n };\n }\n\n private selectActivePlatform(platforms: readonly PlatformRectangle[]): PlatformRectangle | undefined {\n if (platforms.length === 0) {\n this.activePlatformElement = undefined;\n return undefined;\n }\n const anchor = this.state;\n const current = platforms.find((platform) => platform.element === this.activePlatformElement);\n if (current && (\n isOnTop(anchor, current, PLATFORM_EDGE_TOLERANCE)\n || isOnBottom(anchor, current, PLATFORM_EDGE_TOLERANCE)\n || isOnLeft(anchor, current, PLATFORM_EDGE_TOLERANCE)\n || isOnRight(anchor, current, PLATFORM_EDGE_TOLERANCE)\n )) return current;\n\n if (this.state.vy >= 0) {\n const landingPlatform = platforms\n .filter((platform) => anchor.x >= platform.x && anchor.x <= platform.x + platform.width && platform.y >= anchor.y - 1)\n .sort((left, right) => left.y - right.y)[0];\n if (landingPlatform) {\n this.activePlatformElement = landingPlatform.element;\n return landingPlatform;\n }\n }\n\n const nearby = [...platforms]\n .map((platform) => ({ platform, distance: distanceToRectangle(anchor, platform) }))\n .filter(({ distance }) => distance <= PLATFORM_NEARBY_DISTANCE)\n .sort((left, right) => left.distance - right.distance)[0]?.platform;\n this.activePlatformElement = nearby?.element;\n return nearby;\n }\n\n private installPointerHandlers(): void {\n const element = this.domHandle.spriteElement;\n const document = element.ownerDocument;\n const listen = <K extends keyof HTMLElementEventMap>(target: EventTarget, type: K, listener: (event: HTMLElementEventMap[K]) => void): void => {\n target.addEventListener(type, listener as EventListener);\n this.disposers.push(() => target.removeEventListener(type, listener as EventListener));\n };\n listen(element, \"pointerdown\", (event) => {\n const pointerEvent = event as PointerEvent;\n if (pointerEvent.button !== 0) return;\n event.preventDefault();\n const point = this.dom.toLocalPoint(pointerEvent.clientX, pointerEvent.clientY);\n this.pointerId = pointerEvent.pointerId;\n this.pointerDown = point;\n this.lastPointer = point;\n this.dragOffset = { x: this.state.x - point.x, y: this.state.y - point.y };\n this.state.dragging = true;\n this.currentBehavior = this.behavior.force(\"Dragged\") ?? this.behavior.force(\"ドラッグされる\");\n if (this.currentBehavior) this.startBehavior(this.createEnvironment(this.dom.getBounds()), this.dom.getBounds(), this.platforms);\n element.setPointerCapture?.(pointerEvent.pointerId);\n });\n listen(document, \"pointermove\", (event) => {\n const pointerEvent = event as PointerEvent;\n if (!this.state.dragging || pointerEvent.pointerId !== this.pointerId) return;\n const point = this.dom.toLocalPoint(pointerEvent.clientX, pointerEvent.clientY);\n const previous = this.lastPointer ?? point;\n const bounds = this.dom.getBounds();\n this.state.vx = (point.x - previous.x) * 0.8;\n this.state.vy = (point.y - previous.y) * 0.8;\n this.state.x = point.x + this.dragOffset.x;\n this.state.y = point.y + this.dragOffset.y;\n this.lastPointer = point;\n });\n listen(document, \"pointerup\", (event) => {\n const pointerEvent = event as PointerEvent;\n if (!this.state.dragging || pointerEvent.pointerId !== this.pointerId) return;\n this.state.dragging = false;\n const moved = this.pointerDown ? Math.hypot(this.lastPointer!.x - this.pointerDown.x, this.lastPointer!.y - this.pointerDown.y) : 0;\n this.pointerId = undefined;\n this.currentBehavior = this.behavior.force(\"Thrown\") ?? this.behavior.force(\"投げられる\") ?? this.findFallBehavior();\n if (this.currentBehavior) {\n const bounds = this.dom.getBounds();\n this.startBehavior(this.createEnvironment(bounds), bounds, this.platforms);\n }\n if (moved < 4) this.callbacks.click(this.snapshot());\n });\n }\n}\n","import type { Rectangle } from \"./types\";\n\n/** A platform rectangle paired with the DOM element that produced it. */\nexport interface PlatformRectangle extends Rectangle {\n element: HTMLElement;\n}\n\n/** Resolves a platform option into connected DOM elements contained by the supplied root. */\nexport function resolvePlatformElements(\n source: string | readonly HTMLElement[],\n root: Document | HTMLElement,\n excludedRoot?: HTMLElement,\n): HTMLElement[] {\n let elements: readonly Element[];\n if (typeof source === \"string\") {\n try {\n elements = [...root.querySelectorAll(source)];\n } catch {\n return [];\n }\n } else {\n elements = source;\n }\n const document = root.nodeType === 9 ? root as Document : root.ownerDocument;\n if (!document) return [];\n const HTMLElementConstructor = document.defaultView?.HTMLElement;\n if (!HTMLElementConstructor) return [];\n return [...new Set(elements)].filter((element): element is HTMLElement =>\n element instanceof HTMLElementConstructor\n && element.isConnected\n && root.contains(element)\n && (!excludedRoot || !excludedRoot.contains(element)),\n );\n}\n\n/** Reads platform bounds once and converts viewport coordinates to the supplied origin. */\nexport function readPlatformRectangles(\n elements: readonly HTMLElement[],\n workAreaRectangle: Pick<DOMRect, \"left\" | \"top\">,\n): PlatformRectangle[] {\n const rectangles: PlatformRectangle[] = [];\n for (const element of elements) {\n const rectangle = element.getBoundingClientRect();\n if (rectangle.width <= 0 || rectangle.height <= 0) continue;\n rectangles.push({\n element,\n x: rectangle.left - workAreaRectangle.left,\n y: rectangle.top - workAreaRectangle.top,\n width: rectangle.width,\n height: rectangle.height,\n });\n }\n return rectangles;\n}\n","import type { CharacterSpec, IndividualSprite, SpriteRectangle } from \"./types\";\n\n/** A resolved image and optional atlas crop for one sprite frame. */\nexport interface ResolvedSprite {\n /** Browser-loadable image URL. */\n url: string;\n /** Optional atlas crop. */\n rectangle?: SpriteRectangle;\n}\n\n/** A per-mascot spritesheet resource whose temporary URL can be released. */\nexport interface SpriteLease {\n /** URL used to render atlas-backed frames. */\n url: string;\n /** Releases any object URL owned by this lease. */\n release(): void;\n}\n\nfunction dataUriToBlob(source: string): Blob {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/s.exec(source);\n if (!match) throw new TypeError(\"Invalid image data URI\");\n const mimeType = match[1] ?? \"application/octet-stream\";\n const encoded = match[3] ?? \"\";\n const binary = match[2] ? atob(encoded) : decodeURIComponent(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);\n return new Blob([bytes], { type: mimeType });\n}\n\n/** Owns temporary sprite URLs and resolves atlas or individual image frames. */\nexport class SpriteManager {\n private readonly leases = new Set<SpriteLease>();\n\n /** Creates a separately releasable spritesheet lease for a mascot. */\n public acquire(source: string | Blob): SpriteLease {\n let url = typeof source === \"string\" ? source : \"\";\n let owned = false;\n if (typeof URL.createObjectURL === \"function\" && (typeof source !== \"string\" || source.startsWith(\"data:image\"))) {\n try {\n url = URL.createObjectURL(typeof source === \"string\" ? dataUriToBlob(source) : source);\n owned = true;\n } catch {\n if (typeof source !== \"string\") throw new Error(\"The current environment cannot create a URL for the spritesheet Blob\");\n }\n }\n let released = false;\n const lease: SpriteLease = {\n url,\n release: () => {\n if (released) return;\n released = true;\n this.leases.delete(lease);\n if (owned) URL.revokeObjectURL(url);\n },\n };\n this.leases.add(lease);\n return lease;\n }\n\n /** Resolves a sprite key using a lease and the character's sprite map. */\n public resolve(spec: CharacterSpec, lease: SpriteLease, spriteName: string): ResolvedSprite | undefined {\n const key = Object.keys(spec.sprites).find((candidate) => candidate.toLowerCase() === spriteName.toLowerCase());\n const sprite = key ? spec.sprites[key] : undefined;\n if (typeof sprite === \"string\") return { url: sprite };\n if (sprite && \"url\" in sprite && typeof sprite.url === \"string\" && !(\"x\" in sprite)) return { url: sprite.url };\n if (sprite && \"x\" in sprite) return { url: sprite.url ?? lease.url, rectangle: sprite };\n if (/^(?:data:|blob:|https?:|\\/)/.test(spriteName)) return { url: spriteName };\n return undefined;\n }\n\n /** Revokes every object URL that has not already been released. */\n public destroy(): void {\n for (const lease of [...this.leases]) lease.release();\n }\n}\n\n/** Returns whether a sprite definition is a standalone image object. */\nexport function isIndividualSprite(sprite: SpriteRectangle | IndividualSprite | string): sprite is IndividualSprite {\n return typeof sprite === \"object\" && \"url\" in sprite && !(\"x\" in sprite);\n}\n","import { DomManager } from \"./dom\";\nimport { normalizeCharacterSpec } from \"./loader\";\nimport { Mascot, type MascotCollisionBox } from \"./mascot\";\nimport { readPlatformRectangles, resolvePlatformElements, type PlatformRectangle } from \"./platform\";\nimport { SpriteManager } from \"./sprite\";\nimport type { CharacterSpec, MascotState, ShimejiEngineEventMap, ShimejiEngineOptions, ShimejiEventListener, SpawnOptions } from \"./types\";\n\nclass EventEmitter<Events extends object> {\n private readonly listeners = new Map<keyof Events, Set<(payload: never) => void>>();\n public on<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): () => void {\n const listeners = this.listeners.get(event) ?? new Set();\n listeners.add(listener as (payload: never) => void);\n this.listeners.set(event, listeners);\n return () => { listeners.delete(listener as (payload: never) => void); };\n }\n public emit<K extends keyof Events>(event: K, payload: Events[K]): void {\n for (const listener of [...(this.listeners.get(event) ?? [])]) listener(payload as never);\n }\n public clear(): void { this.listeners.clear(); }\n}\n\nconst defaults = {\n frameDuration: 40,\n gravity: 2,\n maxDeltaTime: 100,\n workAreaClassName: \"\",\n mascotClassName: \"\",\n platforms: [] as readonly HTMLElement[],\n} as const;\n\ntype ResolvedEngineOptions = Required<Omit<ShimejiEngineOptions, \"random\">> & { random: (() => number) | undefined };\n\n/** Framework-agnostic manager for character registration and live Shimeji mascots. */\nexport class ShimejiEngine {\n private readonly specs = new Map<string, CharacterSpec>();\n private readonly mascots = new Map<string, Mascot>();\n private readonly sprites = new SpriteManager();\n private readonly dom: DomManager;\n private readonly events = new EventEmitter<ShimejiEngineEventMap>();\n private readonly disposers: Array<() => void> = [];\n private readonly intervals = new Set<number>();\n private readonly options: ResolvedEngineOptions;\n private pointer = { x: 0, y: 0, dx: 0, dy: 0 };\n private animationFrame: number | undefined;\n private lastFrameTime: number | undefined;\n private nextMascotId = 1;\n private destroyed = false;\n private initialized = false;\n private platformSource: string | readonly HTMLElement[];\n private additionalPlatformElements: readonly HTMLElement[] = [];\n private readonly movedPlatforms = new Map<HTMLElement, { originalTransform: string; x: number; y: number }>();\n private readonly platformRectangles = new Map<HTMLElement, PlatformRectangle>();\n\n /** Creates and initializes an engine inside a host DOM element. */\n public constructor(private readonly container: HTMLElement, options: ShimejiEngineOptions = {}) {\n if (!container) throw new TypeError(\"ShimejiEngine requires a container element\");\n this.options = { ...defaults, ...options, random: options.random };\n this.platformSource = this.options.platforms;\n this.dom = new DomManager(container, this.sprites);\n this.initialize();\n }\n\n /** Starts the clock and container-aware listeners. Calling this method more than once is harmless. */\n public initialize(): void {\n this.assertAlive();\n if (this.initialized) return;\n this.initialized = true;\n const document = this.container.ownerDocument;\n const view = document.defaultView;\n if (!view) throw new Error(\"ShimejiEngine requires a container connected to a window\");\n this.listen(document, \"pointermove\", (event) => {\n const pointerEvent = event as PointerEvent;\n const { x, y } = this.dom.toLocalPoint(pointerEvent.clientX, pointerEvent.clientY);\n this.pointer = { x, y, dx: x - this.pointer.x, dy: y - this.pointer.y };\n });\n this.listen(view, \"resize\", () => this.renderAll());\n const maintenance = view.setInterval(() => this.dom.ensureMounted(), 2_000);\n this.intervals.add(maintenance);\n this.animationFrame = view.requestAnimationFrame(this.onAnimationFrame);\n }\n\n /** Registers or replaces a parsed or legacy character specification. */\n public registerCharacter(spec: CharacterSpec | unknown): string {\n this.assertAlive();\n const normalized = normalizeCharacterSpec(spec);\n this.specs.set(normalized.id, normalized);\n return normalized.id;\n }\n\n /** Unregisters a character and optionally removes all of its live mascots. */\n public unregisterCharacter(characterId: string, removeMascots = true): boolean {\n this.assertAlive();\n if (removeMascots) {\n for (const state of this.getState()) if (state.characterId === characterId) this.remove(state.id);\n }\n return this.specs.delete(characterId);\n }\n\n /** Returns identifiers for all currently registered characters. */\n public getCharacterIds(): string[] { return [...this.specs.keys()]; }\n\n /** Creates a mascot from a registered character and returns its instance id. */\n public spawn(characterId: string, position: SpawnOptions = {}): string {\n this.assertAlive();\n const spec = this.specs.get(characterId);\n if (!spec) throw new Error(`Character '${characterId}' is not registered`);\n const { bounds, platforms } = this.readFrameGeometry();\n const random = this.options.random ?? Math.random;\n const randomX = Math.trunc(bounds.x + random() * bounds.width);\n const spawnInset = Math.min(2, bounds.width / 2);\n const spawnOptions: SpawnOptions = {\n ...position,\n // Fall treats the wall in the facing direction as ground. Keep implicit\n // spawns clear of both side-wall tolerances so even random() === 0 falls.\n x: position.x ?? Math.min(Math.max(randomX, bounds.x + spawnInset), bounds.x + bounds.width - spawnInset),\n y: position.y ?? bounds.y + 2,\n };\n const id = `shimeji-${this.nextMascotId++}`;\n const mascot = new Mascot(id, spec, this.dom, this.options, spawnOptions, {\n pointer: () => ({ ...this.pointer }),\n count: () => this.mascots.size,\n spawn: (nextCharacterId, nextPosition) => { if (!this.destroyed) this.spawn(nextCharacterId, nextPosition); },\n remove: (mascotId) => { if (!this.destroyed) this.remove(mascotId); },\n movePlatform: (element, point) => this.movePlatform(element, point),\n click: (state) => this.events.emit(\"click\", state),\n error: (error) => this.events.emit(\"error\", error),\n });\n this.mascots.set(id, mascot);\n mascot.tick(0, bounds, platforms);\n const state = mascot.snapshot();\n this.events.emit(\"spawn\", state);\n this.emitState();\n return id;\n }\n\n /** Removes one mascot and all resources associated with it. */\n public remove(mascotId: string): boolean {\n this.assertAlive();\n const mascot = this.mascots.get(mascotId);\n if (!mascot) return false;\n const state = mascot.snapshot();\n this.mascots.delete(mascotId);\n mascot.destroy();\n this.events.emit(\"remove\", state);\n this.emitState();\n return true;\n }\n\n /** Removes every live mascot while leaving registered character specs available. */\n public removeAll(): void {\n this.assertAlive();\n for (const id of [...this.mascots.keys()]) this.remove(id);\n }\n\n /** Returns detached snapshots of every live mascot. */\n public getState(): MascotState[] { return [...this.mascots.values()].map((mascot) => mascot.snapshot()); }\n\n /** Subscribes to a typed engine event and returns an unsubscribe function. */\n public on<K extends keyof ShimejiEngineEventMap>(event: K, listener: ShimejiEventListener<K>): () => void {\n this.assertAlive();\n return this.events.on(event, listener);\n }\n\n /** Replaces the primary platform source and any additional registered elements. */\n public setPlatforms(platforms: string | readonly HTMLElement[], additionalPlatforms: readonly HTMLElement[] = []): void {\n this.assertAlive();\n this.platformSource = platforms;\n this.additionalPlatformElements = additionalPlatforms;\n }\n\n /** Stops animation and timers, removes listeners and DOM, and revokes all object URLs. */\n public destroy(): void {\n if (this.destroyed) return;\n for (const mascot of this.mascots.values()) mascot.destroy();\n this.mascots.clear();\n const view = this.container.ownerDocument.defaultView;\n if (this.animationFrame !== undefined) view?.cancelAnimationFrame(this.animationFrame);\n this.animationFrame = undefined;\n for (const interval of this.intervals) view?.clearInterval(interval);\n this.intervals.clear();\n for (const dispose of this.disposers.splice(0)) dispose();\n this.dom.destroy();\n for (const [element, movement] of this.movedPlatforms) element.style.transform = movement.originalTransform;\n this.movedPlatforms.clear();\n this.platformRectangles.clear();\n this.sprites.destroy();\n this.specs.clear();\n this.events.clear();\n this.destroyed = true;\n this.initialized = false;\n }\n\n /** Returns whether this engine has completed permanent teardown. */\n public isDestroyed(): boolean { return this.destroyed; }\n\n private readonly onAnimationFrame = (timestamp: number): void => {\n if (this.destroyed) return;\n const rawDelta = this.lastFrameTime === undefined ? this.options.frameDuration : timestamp - this.lastFrameTime;\n this.lastFrameTime = timestamp;\n const delta = Math.max(0, Math.min(rawDelta, this.options.maxDeltaTime));\n const { bounds, platforms } = this.readFrameGeometry();\n const mascots = [...this.mascots.values()];\n const collisionBoxes: MascotCollisionBox[] = mascots.map((mascot) => mascot.collisionBox());\n for (const mascot of mascots) mascot.tick(delta, bounds, platforms, collisionBoxes);\n this.emitState();\n this.animationFrame = this.container.ownerDocument.defaultView?.requestAnimationFrame(this.onAnimationFrame);\n };\n\n private renderAll(): void {\n const { bounds, platforms } = this.readFrameGeometry();\n for (const mascot of this.mascots.values()) mascot.tick(0, bounds, platforms);\n }\n\n private readFrameGeometry(): { bounds: ReturnType<DomManager[\"getBounds\"]>; platforms: PlatformRectangle[] } {\n const bounds = this.dom.getBounds();\n const elements = [...new Set([\n ...resolvePlatformElements(this.platformSource, this.container),\n ...resolvePlatformElements(this.additionalPlatformElements, this.container),\n ])].filter((element) => !this.dom.owns(element));\n const platforms = readPlatformRectangles(elements, this.container.getBoundingClientRect());\n this.platformRectangles.clear();\n for (const platform of platforms) this.platformRectangles.set(platform.element, platform);\n return { bounds, platforms };\n }\n\n private movePlatform(element: HTMLElement, point: { x: number; y: number }): void {\n const rectangle = this.platformRectangles.get(element);\n if (!rectangle) return;\n const movement = this.movedPlatforms.get(element) ?? { originalTransform: element.style.transform, x: 0, y: 0 };\n movement.x += point.x - rectangle.x;\n movement.y += point.y - rectangle.y;\n const translate = `translate(${movement.x}px, ${movement.y}px)`;\n element.style.transform = movement.originalTransform ? `${movement.originalTransform} ${translate}` : translate;\n rectangle.x = point.x;\n rectangle.y = point.y;\n this.movedPlatforms.set(element, movement);\n }\n\n private emitState(): void { this.events.emit(\"statechange\", this.getState()); }\n\n private listen(target: EventTarget, type: string, listener: EventListener): void {\n target.addEventListener(type, listener);\n this.disposers.push(() => target.removeEventListener(type, listener));\n }\n\n private assertAlive(): void {\n if (this.destroyed) throw new Error(\"ShimejiEngine has been destroyed\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,aAAN,MAAiB;AAAA;AAAA,EAKf,YACY,WACA,SACjB;AAFiB;AACA;AAEjB,UAAM,OAAO,UAAU,cAAc;AACrC,UAAM,gBAAgB,MAAM,iBAAiB,SAA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