@inkweave/core 1.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/state/createSelectors.ts","../src/state/contents.ts","../src/types.ts","../src/extensions/Tags.ts","../src/extensions/ChoiceParser.ts","../src/state/choices.ts","../src/state/variables.ts","../src/extensions/Patches.ts","../src/extensions/Parser.ts","../src/extensions/ExternalFunctions.ts","../src/story/InkStory.ts","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/CompilerOptions.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/DebugSourceRange.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ErrorType.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Argument.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/TypeAssertion.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Object.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/AuthorWarning.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Path.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Debug.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/NullException.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Object.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/StringBuilder.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/InkList.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/StoryException.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/TryGetResult.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Value.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/SearchResult.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Container.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/ControlCommand.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/Expression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Void.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/NativeFunctionCall.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/NumberExpression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/UnaryExpression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/BinaryExpression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/CharacterSet.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/CharacterRange.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/ChoicePoint.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/PushPop.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Pointer.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Divert.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/SymbolType.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/VariableAssignment.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Choice.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/StringParser/StringParserElement.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/StringParser/StringParserState.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/StringParser/StringParser.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/CommentEliminator.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Conditional/Conditional.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Text.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Declaration/ConstantDeclaration.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Flow/FlowLevel.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Gather/Gather.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Path.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/ReturnType.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Flow/ClosestFlowBase.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Identifier.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Flow/FlowBase.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/ContentList.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/VariableReference.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Variable/VariableReference.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/FunctionCall.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/MultipleConditionExpression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Divert/DivertTarget.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Divert/Divert.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Gather/GatherPointToResolve.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Sequence/SequenceDivertToResolve.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Sequence/SequenceType.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Sequence/Sequence.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/TunnelOnwards.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/ListDefinition.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/List/ListDefinition.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Variable/VariableAssignment.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Weave.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Conditional/ConditionalSingleBranch.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/CustomFlags.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/DebugMetadata.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Declaration/ExternalDeclaration.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/FlowDecl.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Wrap.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Glue.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Glue.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/IncDecExpression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/IncludedFile.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/InfixOperator.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Knot.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/List/List.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/List/ListElementDefinition.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/StatementLevel.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Stitch.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Tag.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Choice.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/ListDefinitionsOrigin.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/JsonSerialisation.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/CallStack.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/VariablesState.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/PRNG.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/StatePatch.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/SimpleJson.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Flow.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/StoryState.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/StopWatch.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Error.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/engine/Story.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Story.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Expression/StringExpression.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/ParsedHierarchy/Tag.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/FileHandler/DefaultFileHandler.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Parser/InkParser.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Stats.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/FileHandler/JsonFileHandler.js","../../../node_modules/.bun/inkjs@2.4.0/node_modules/inkjs/compiler/Compiler.js","../src/create.ts"],"sourcesContent":["import { StoreApi, UseBoundStore } from 'zustand';\n\ntype WithSelectors<S> = S extends { getState: () => infer T }\n\t? S & { use: { [K in keyof T]: () => T[K] } }\n\t: never;\n\nconst createSelectors = <S extends UseBoundStore<StoreApi<object>>>(\n\t_store: S\n) => {\n\tlet store = _store as WithSelectors<typeof _store>;\n\n\tstore.use = new Proxy({} as WithSelectors<typeof _store>['use'], {\n\t\tget: (_, prop: string) => {\n\t\t\treturn () => store((s) => (s as Record<string, unknown>)[prop]);\n\t\t}\n\t});\n\n\treturn store;\n};\n\nexport default createSelectors;","import { create } from 'zustand';\nimport createSelectors from './createSelectors';\n\ntype StoryContent = {\n\tcontents: string[];\n\tsetContents: (contents: string[]) => void;\n\tadd: (content: string[]) => void;\n\tclear: () => void;\n};\n\nconst contentsStore = create<StoryContent>((set) => ({\n\tcontents: [],\n\tsetContents: (contents) => set({ contents }),\n\tadd: (content) => {\n\t\tset((state) => ({\n\t\t\tcontents: [...state.contents, ...content],\n\t\t}));\n\t},\n\tclear: () => set({ contents: [] }),\n}));\n\nexport default createSelectors(contentsStore);","// Constants\nexport const CHOICE_SEPARATOR = '\\x00ink-divider\\x00';\n\nexport const DEFAULT_STORY_OPTIONS: InkStoryOptions = {\n\tdebug: false,\n\tlinedelay: 0.05,\n};\n\n// Types\nexport interface FileHandler {\n\tloadFile(filename: string): string;\n}\n\nexport class BaseFileHandler implements FileHandler {\n\tprotected basePath: string;\n\n\tconstructor(options?: { basePath?: string }) {\n\t\tthis.basePath = options?.basePath || '';\n\t}\n\n\tresolveFilename(filename: string): string {\n\t\tif (this.basePath) {\n\t\t\treturn this.basePath + '/' + filename;\n\t\t}\n\t\treturn filename;\n\t}\n\n\tloadFile(_filename: string): string {\n\t\tthrow new Error('loadFile must be implemented by subclass');\n\t}\n}\n\nexport interface InkStoryOptions {\n\ttitle?: string;\n\tdebug?: boolean;\n\tlinedelay?: number;\n\tfileHandler?: FileHandler;\n\t[key: string]: unknown;\n}\n\nexport interface InkStoryContext {\n\toptions: InkStoryOptions;\n\tsave_label: string[];\n\tclears: Array<() => void>;\n\tcleanups: Array<() => void>;\n\t_side_effects: Array<() => void>;\n\t[key: string]: unknown;\n}\n\nexport interface SaveData {\n\tstate: string;\n\tcontents?: string[];\n\timage?: string;\n\t[key: string]: unknown;\n}\n\nexport class Choice {\n\ttext: string;\n\tindex: number;\n\ttype: string;\n\tval?: string;\n\tconstructor(text: string, index: number, type: string = 'default') {\n\t\tthis.text = text || '';\n\t\tthis.index = index;\n\t\tthis.type = type;\n\t}\n}","import type { InkStory } from '../story/InkStory';\n\ntype TagFunction = (val: string | null | undefined, ink: InkStory) => void;\n\nexport class Tags {\n\tprivate static _functions: Map<string, TagFunction> = new Map();\n\tprivate static readonly excludeKeys: Set<string> = new Set([\n\t\t'clear',\n\t\t'restart',\n\t]);\n\n\tstatic get functions() {\n\t\treturn Tags._functions;\n\t}\n\n\tstatic clear() {\n\t\tfor (const [key, _] of this._functions.entries()) {\n\t\t\tif (!this.excludeKeys.has(key)) {\n\t\t\t\tthis._functions.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic add(tagName: string, callback: TagFunction) {\n\t\tTags.functions.set(tagName, callback);\n\t}\n\n\tstatic process = (ink: InkStory, inputString: string) => {\n\t\tconst splitTag = splitAtCharacter(inputString, ':');\n\t\tif (splitTag) {\n\t\t\tif (Tags.functions.has(splitTag.before)) {\n\t\t\t\tTags.functions.get(splitTag.before)?.(splitTag.after, ink);\n\t\t\t} else {\n\t\t\t\tconst options = ink.options as Record<string, unknown>;\n\t\t\t\tif (options[splitTag.before] != undefined) {\n\t\t\t\t\tlet newValue: string | number | boolean | undefined = splitTag.after;\n\t\t\t\t\tconst optionType = typeof options[splitTag.before];\n\t\t\t\t\tswitch (optionType) {\n\t\t\t\t\t\tcase 'string':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\tif (typeof newValue === 'string') {\n\t\t\t\t\t\t\t\tnewValue = parseFloat(newValue);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewValue = undefined;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\tnewValue = !!newValue;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tnewValue = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tif (newValue !== undefined && !Number.isNaN(newValue)) {\n\t\t\t\t\t\toptions[splitTag.before] = newValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport const splitAtCharacter = (text: string, character: string) => {\n\tif (!text) {\n\t\treturn;\n\t}\n\n\tlet splitIndex = text.indexOf(character);\n\n\tif (splitIndex == -1) {\n\t\treturn {\n\t\t\tbefore: text.trim().toLowerCase(),\n\t\t};\n\t} else {\n\t\treturn {\n\t\t\tbefore: text.slice(0, splitIndex).trim().toLowerCase(),\n\t\t\tafter: text.slice(splitIndex + 1).trim(),\n\t\t};\n\t}\n};\n\nTags.add('clear', (_: string | null | undefined, ink: InkStory) => {\n\tink.clear();\n});\n\nTags.add('restart', (_: string | null | undefined, ink: InkStory) => {\n\tink.restart();\n});","import { Choice } from '../types';\nimport { splitAtCharacter } from './Tags';\nimport type { Choice as InkChoice } from 'inkjs/engine/Choice';\n\nexport class ChoiceParser {\n\tprivate static _tags: Map<string, (choice: Choice, val?: string) => void> = new Map();\n\tprivate static readonly excludeKeys: Set<string> = new Set(['unclickable']);\n\n\tstatic get tags() {\n\t\treturn ChoiceParser._tags;\n\t}\n\n\tstatic clear = () => {\n\t\tfor (const [key, _] of this._tags.entries()) {\n\t\t\tif (!this.excludeKeys.has(key)) {\n\t\t\t\tthis._tags.delete(key);\n\t\t\t}\n\t\t}\n\t};\n\n\tstatic add = (\n\t\ttag: string,\n\t\tcallback: (choice: Choice, val?: string) => void\n\t) => {\n\t\tChoiceParser.tags.set(tag, callback);\n\t};\n\n\tstatic process = (item: InkChoice, choice: Choice) => {\n\t\tif (!item.text) return choice;\n\n\t\tif (item.tags && item.tags.length && ChoiceParser.tags.size) {\n\t\t\titem.tags.forEach(function (tag) {\n\t\t\t\tlet splitTag = splitAtCharacter(tag, ':');\n\n\t\t\t\tif (splitTag && ChoiceParser.tags.has(splitTag.before)) {\n\t\t\t\t\tChoiceParser.tags.get(splitTag.before)?.(\n\t\t\t\t\t\tchoice,\n\t\t\t\t\t\tsplitTag.after\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n}\n\nChoiceParser.add('unclickable', (new_choice) => {\n\tnew_choice.type = 'unclickable';\n});","import { create } from 'zustand';\nimport createSelectors from './createSelectors';\nimport { Choice } from '../types';\nimport { ChoiceParser } from '../extensions/ChoiceParser';\nimport type { Choice as InkChoice } from 'inkjs/engine/Choice';\n\ntype StoryChoices = {\n\tchoices: Choice[];\n\tsetChoices: (choices: InkChoice[]) => void;\n\tclear: () => void;\n};\n\nconst choicesStore = create<StoryChoices>((set) => ({\n\tchoices: [],\n\tsetChoices: (ink_choices) => {\n\t\tconst choices = ink_choices.map((choice) => {\n\t\t\tconst new_choice = new Choice(choice.text, choice.index);\n\t\t\tif (choice.tags && choice.tags.length) {\n\t\t\t\tChoiceParser.process(choice, new_choice);\n\t\t\t}\n\t\t\treturn new_choice;\n\t\t});\n\t\tset({ choices });\n\t},\n\tclear: () => set({ choices: [] }),\n}));\n\nexport default createSelectors(choicesStore);","import { create } from 'zustand';\nimport createSelectors from './createSelectors';\nimport type { VariablesState } from 'inkjs/engine/VariablesState';\n\ntype StoryVariables = {\n\tvariables: Map<string, unknown>;\n\tsetGlobalVars: (variablesState: VariablesState) => void;\n};\n\ninterface GlobalVariableEntry {\n\tvalue: unknown;\n}\n\ninterface GlobalVariablesMap {\n\tkeys(): IterableIterator<string>;\n\tget(key: string): GlobalVariableEntry | undefined;\n}\n\nconst variablesStore = create<StoryVariables>((set) => ({\n\tvariables: new Map<string, unknown>(),\n\tsetGlobalVars: (variablesState) => {\n\t\tconst globalVars = new Map<string, unknown>();\n\n\t\t// Access inkjs internal _globalVariables\n\t\t// Note: This relies on inkjs internal implementation.\n\t\t// If inkjs updates and breaks this, we'll need to find an alternative.\n\t\tconst variablesStateAny = variablesState as unknown as {\n\t\t\t_globalVariables?: GlobalVariablesMap;\n\t\t};\n\t\tconst globalVariables = variablesStateAny._globalVariables;\n\t\t\n\t\tif (globalVariables) {\n\t\t\tfor (const key of globalVariables.keys()) {\n\t\t\t\tconst entry = globalVariables.get(key);\n\t\t\t\tif (entry) {\n\t\t\t\t\tglobalVars.set(key, entry.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tset({ variables: globalVars });\n\t},\n}));\n\nexport default createSelectors(variablesStore);","import type { InkStoryContext } from '../types';\n\nexport type PatchFunction = (this: InkStoryContext, content: string) => void;\n\nexport class Patches {\n\tprivate static _patches: PatchFunction[] = [];\n\tprivate static _options: Record<string, unknown> = {};\n\n\tstatic get patches() {\n\t\treturn Patches._patches;\n\t}\n\n\tstatic set patches(value: PatchFunction[]) {\n\t\tPatches._patches = value;\n\t}\n\n\tstatic add(\n\t\tcallback: PatchFunction | null,\n\t\tpatchOptions: Record<string, unknown> = {}\n\t) {\n\t\tObject.assign(this._options, patchOptions);\n\t\tif (callback) Patches._patches.push(callback);\n\t}\n\n\tstatic apply(story: InkStoryContext | object, content: string) {\n\t\tconst storyCtx = story as InkStoryContext;\n\t\tObject.assign(storyCtx.options, Patches._options);\n\t\tfor (const patch of Patches._patches) {\n\t\t\tif (patch) {\n\t\t\t\tpatch.bind(storyCtx, content)();\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic clear() {\n\t\tPatches._patches = [];\n\t\tPatches._options = {};\n\t}\n}","import { splitAtCharacter } from './Tags';\n\nexport interface ParserLine {\n\ttext: string;\n\ttags: string[];\n\tclasses: string[];\n}\n\nexport class Parser {\n\tprivate static _tags: { [key: string]: Function } = {};\n\tprivate static _patterns: {\n\t\tmatcher: string | RegExp;\n\t\tcallback: Function;\n\t}[] = [];\n\n\tstatic get tags() {\n\t\treturn Parser._tags;\n\t}\n\n\tstatic get patterns() {\n\t\treturn Parser._patterns;\n\t}\n\n\tstatic clear = () => {\n\t\tParser._tags = {};\n\t\tParser._patterns = [];\n\t};\n\n\tstatic tag(tag: string, callback: Function) {\n\t\tParser.tags[tag] = callback;\n\t}\n\n\tstatic pattern(pattern: string | RegExp, callback: Function) {\n\t\tParser.patterns.push({ matcher: pattern, callback: callback });\n\t}\n\n\tstatic process = (text: string, tags: string[] = []): string => {\n\t\tif (!text) return '';\n\n\t\tlet line: ParserLine = { text: text, tags: tags, classes: [] };\n\n\t\tif (line.tags.length && Object.keys(Parser.tags).length) {\n\t\t\tline.tags.forEach(function (tag) {\n\t\t\t\tlet splitTag = splitAtCharacter(tag, ':');\n\n\t\t\t\tif (splitTag && splitTag.before in Parser.tags) {\n\t\t\t\t\tParser.tags[splitTag.before](\n\t\t\t\t\t\tline,\n\t\t\t\t\t\tsplitTag.before,\n\t\t\t\t\t\tsplitTag.after\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (line.text && Parser.patterns.length) {\n\t\t\tParser.patterns.forEach(function (pattern) {\n\t\t\t\tif (\n\t\t\t\t\t(typeof pattern.matcher === 'string' &&\n\t\t\t\t\t\tline.text.includes(pattern.matcher)) ||\n\t\t\t\t\t(pattern.matcher instanceof RegExp &&\n\t\t\t\t\t\tline.text.match(pattern.matcher))\n\t\t\t\t) {\n\t\t\t\t\tpattern.callback(line);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn line.text;\n\t};\n}","import type { InkStory } from '../story/InkStory';\n\nexport class ExternalFunctions {\n\tprivate static _functions: Map<string, Function> = new Map();\n\n\tstatic get functions() {\n\t\treturn ExternalFunctions._functions;\n\t}\n\n\tstatic set functions(value: Map<string, Function>) {\n\t\tExternalFunctions._functions = value;\n\t}\n\n\tstatic add(id: string, func: Function) {\n\t\tExternalFunctions.functions.set(id, func);\n\t}\n\n\tstatic get(id: string) {\n\t\treturn ExternalFunctions.functions.get(id);\n\t}\n\n\tstatic bind(ink: InkStory, id: string) {\n\t\tconst externalFunction =\n\t\t\tExternalFunctions.get(id) ||\n\t\t\t(typeof window !== 'undefined' ? (window as unknown as Record<string, Function>)[id] : undefined);\n\t\tif (externalFunction) {\n\t\t\tink.story.BindExternalFunction(id, externalFunction.bind(ink));\n\t\t}\n\t}\n\n\tstatic clear() {\n\t\tExternalFunctions.functions.clear();\n\t}\n}","import { Story } from 'inkjs/engine/Story';\nimport contentsStore from '../state/contents';\nimport choicesStore from '../state/choices';\nimport variablesStore from '../state/variables';\nimport { Patches } from '../extensions/Patches';\nimport { Tags } from '../extensions/Tags';\nimport { Parser } from '../extensions/Parser';\nimport { ExternalFunctions } from '../extensions/ExternalFunctions';\nimport type { InkStoryOptions, InkStoryContext } from '../types';\nimport { DEFAULT_STORY_OPTIONS, CHOICE_SEPARATOR } from '../types';\n\ntype CleanupFunction = () => void;\ntype SideEffectFunction = () => void;\ntype ClearFunction = () => void;\n\nexport class InkStory implements InkStoryContext {\n\ttitle: string;\n\tstory: Story;\n\toptions: InkStoryOptions;\n\t_side_effects: SideEffectFunction[] = [];\n\t_cleanups: CleanupFunction[] = [];\n\t_clears: ClearFunction[] = [];\n\t_save_label: string[] = ['contents'];\n\t[key: string]: unknown;\n\n\tconstructor(story: Story, title: string, options?: InkStoryOptions) {\n\t\tthis.options = { ...DEFAULT_STORY_OPTIONS, ...options };\n\t\tthis.story = story;\n\t\tthis.title = title;\n\t\tconst content = this.story.ToJson() || '';\n\t\tbindFunctions(this);\n\t\tPatches.apply(this, content);\n\t\tthis.bindExternalFunctions(content);\n\t\tthis.clears.push(() => {\n\t\t\tthis.contents.length = 0;\n\t\t});\n\t}\n\n\tget contents() {\n\t\treturn contentsStore.getState().contents;\n\t}\n\n\tset contents(newContent: string[]) {\n\t\tcontentsStore.getState().setContents(newContent);\n\t}\n\n\tget choices() {\n\t\treturn choicesStore.getState().choices;\n\t}\n\n\tget clears() {\n\t\treturn this._clears;\n\t}\n\n\tget cleanups() {\n\t\treturn this._cleanups;\n\t}\n\n\tget effects() {\n\t\treturn this._side_effects;\n\t}\n\n\tget save_label() {\n\t\treturn this._save_label;\n\t}\n\n\tcontinue() {\n\t\tconst newContent: string[] = [];\n\n\t\twhile (this.story.canContinue) {\n\t\t\tlet current_text = this.story.Continue() || '';\n\t\t\tif (this.story.currentTags) {\n\t\t\t\tthis.story.currentTags.forEach((tag) => {\n\t\t\t\t\tTags.process(this, tag);\n\t\t\t\t\tif (tag === 'clear' || tag === 'restart') {\n\t\t\t\t\t\tnewContent.length = 0;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (current_text && this.story.currentTags.length) {\n\t\t\t\t\tcurrent_text = Parser.process(\n\t\t\t\t\t\tcurrent_text,\n\t\t\t\t\t\tthis.story.currentTags\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (current_text.trim()) newContent.push(current_text);\n\t\t}\n\t\tcontentsStore.getState().add(newContent);\n\n\t\tconst { currentChoices, variablesState } = this.story;\n\t\tchoicesStore.getState().setChoices(currentChoices);\n\t\tvariablesStore.getState().setGlobalVars(variablesState);\n\t}\n\n\tchoose(index: number) {\n\t\tthis.story.ChooseChoiceIndex(index);\n\t\tcontentsStore.getState().add([CHOICE_SEPARATOR]);\n\t\tthis.continue();\n\t}\n\n\tclear() {\n\t\tthis.clears.map((clear) => {\n\t\t\tclear();\n\t\t});\n\t}\n\n\trestart() {\n\t\tthis.story.ResetState();\n\t\tthis.clear();\n\t\tthis.continue();\n\t}\n\n\tuseEffect() {\n\t\tthis.effects.map((effect) => {\n\t\t\tif (effect) {\n\t\t\t\teffect();\n\t\t\t}\n\t\t});\n\t}\n\n\tdispose() {\n\t\tthis.cleanups.map((cleanup) => {\n\t\t\tif (cleanup) {\n\t\t\t\tcleanup();\n\t\t\t}\n\t\t});\n\t}\n\n\tbindExternalFunctions = (content: string) => {\n\t\tnew Set(\n\t\t\tArray.from(content.matchAll(/\\\"x\\(\\)\\\":\\\"(\\w+)/gi), (m) => m['1'])\n\t\t).forEach((match) => {\n\t\t\tExternalFunctions.bind(this, match);\n\t\t});\n\t};\n}\n\nfunction bindFunctions(target: object) {\n\tconst prototype = Object.getPrototypeOf(target);\n\n\tObject.getOwnPropertyNames(prototype).forEach(function (property) {\n\t\tif (\n\t\t\tproperty !== 'constructor' &&\n\t\t\ttypeof Object.getOwnPropertyDescriptor(prototype, property)?.value ===\n\t\t\t\t'function'\n\t\t) {\n\t\t\tconst targetRecord = target as Record<string, (...args: unknown[]) => unknown>;\n\t\t\ttargetRecord[property] = targetRecord[property].bind(target);\n\t\t}\n\t});\n}","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CompilerOptions = void 0;\nclass CompilerOptions {\n constructor(sourceFilename = null, pluginNames = [], countAllVisits = false, errorHandler = null, fileHandler = null) {\n this.sourceFilename = sourceFilename;\n this.pluginNames = pluginNames;\n this.countAllVisits = countAllVisits;\n this.errorHandler = errorHandler;\n this.fileHandler = fileHandler;\n }\n}\nexports.CompilerOptions = CompilerOptions;\n//# sourceMappingURL=CompilerOptions.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DebugSourceRange = void 0;\nclass DebugSourceRange {\n constructor(length, debugMetadata, text) {\n this.length = length;\n this.debugMetadata = debugMetadata;\n this.text = text;\n }\n}\nexports.DebugSourceRange = DebugSourceRange;\n//# sourceMappingURL=DebugSourceRange.js.map","\"use strict\";\n// TODO: Unifify with Engine.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ErrorType = void 0;\nvar ErrorType;\n(function (ErrorType) {\n ErrorType[ErrorType[\"Author\"] = 0] = \"Author\";\n ErrorType[ErrorType[\"Warning\"] = 1] = \"Warning\";\n ErrorType[ErrorType[\"Error\"] = 2] = \"Error\";\n})(ErrorType || (exports.ErrorType = ErrorType = {}));\n//# sourceMappingURL=ErrorType.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Argument = void 0;\nclass Argument {\n constructor(identifier = null, isByReference = null, isDivertTarget = null) {\n this.identifier = identifier;\n this.isByReference = isByReference;\n this.isDivertTarget = isDivertTarget;\n }\n get typeName() {\n return \"Argument\";\n }\n}\nexports.Argument = Argument;\n//# sourceMappingURL=Argument.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.filterUndef = exports.isEquatable = exports.nullIfUndefined = exports.asINamedContentOrNull = exports.asBooleanOrThrows = exports.asNumberOrThrows = exports.asOrThrows = exports.asOrNull = void 0;\nfunction asOrNull(obj, type) {\n if (obj instanceof type) {\n return unsafeTypeAssertion(obj, type);\n }\n else {\n return null;\n }\n}\nexports.asOrNull = asOrNull;\nfunction asOrThrows(obj, type) {\n if (obj instanceof type) {\n return unsafeTypeAssertion(obj, type);\n }\n else {\n throw new Error(`${obj} is not of type ${type}`);\n }\n}\nexports.asOrThrows = asOrThrows;\nfunction asNumberOrThrows(obj) {\n if (typeof obj === \"number\") {\n return obj;\n }\n else {\n throw new Error(`${obj} is not a number`);\n }\n}\nexports.asNumberOrThrows = asNumberOrThrows;\nfunction asBooleanOrThrows(obj) {\n if (typeof obj === \"boolean\") {\n return obj;\n }\n else {\n throw new Error(`${obj} is not a boolean`);\n }\n}\nexports.asBooleanOrThrows = asBooleanOrThrows;\n// So here, in the reference implementation, contentObj is casted to an INamedContent\n// but here we use js-style duck typing: if it implements the same props as the interface,\n// we treat it as valid.\nfunction asINamedContentOrNull(obj) {\n if (obj.hasValidName && obj.name) {\n return obj;\n }\n return null;\n}\nexports.asINamedContentOrNull = asINamedContentOrNull;\nfunction nullIfUndefined(obj) {\n if (typeof obj === \"undefined\") {\n return null;\n }\n return obj;\n}\nexports.nullIfUndefined = nullIfUndefined;\nfunction isEquatable(type) {\n return typeof type === \"object\" && typeof type.Equals === \"function\";\n}\nexports.isEquatable = isEquatable;\nfunction unsafeTypeAssertion(obj, \n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype) {\n return obj;\n}\nfunction filterUndef(element) {\n return element != undefined;\n}\nexports.filterUndef = filterUndef;\n//# sourceMappingURL=TypeAssertion.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ParsedObject = void 0;\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\nclass ParsedObject {\n constructor() {\n this._alreadyHadError = false;\n this._alreadyHadWarning = false;\n this._debugMetadata = null;\n this._runtimeObject = null;\n this.content = [];\n this.parent = null;\n this.GetType = () => this.typeName;\n /*\n get descriptionOfScope(): string {\n const locationNames: string[] = [];\n \n let ancestor: ParsedObject | null = this;\n while (ancestor) {\n var ancestorFlow = ancestor as FlowBase;\n if (ancestorFlow && ancestorFlow.name != null) {\n locationNames.push(`'${ancestorFlow.name}'`);\n }\n ancestor = ancestor.parent;\n }\n \n let scopeSB = '';\n if (locationNames.length > 0) {\n const locationsListStr = locationNames.join(', ');\n scopeSB += `${locationsListStr} and`;\n }\n \n scopeSB += 'at top scope';\n \n return scopeSB;\n }\n */\n // Return the object so that method can be chained easily\n this.AddContent = (subContent) => {\n if (this.content === null) {\n this.content = [];\n }\n const sub = Array.isArray(subContent) ? subContent : [subContent];\n // Make resilient to content not existing, which can happen\n // in the case of parse errors where we've already reported\n // an error but still want a valid structure so we can\n // carry on parsing.\n for (const ss of sub) {\n if (ss.hasOwnProperty(\"parent\")) {\n ss.parent = this;\n }\n this.content.push(ss);\n }\n if (Array.isArray(subContent)) {\n return;\n }\n else {\n return subContent;\n }\n };\n this.InsertContent = (index, subContent) => {\n if (this.content === null) {\n this.content = [];\n }\n subContent.parent = this;\n this.content.splice(index, 0, subContent);\n return subContent;\n };\n this.Find = (type) => (queryFunc = null) => {\n let tObj = (0, TypeAssertion_1.asOrNull)(this, type);\n if (tObj !== null && (queryFunc === null || queryFunc(tObj) === true)) {\n return tObj;\n }\n if (this.content === null) {\n return null;\n }\n for (const obj of this.content) {\n let nestedResult = obj.Find && obj.Find(type)(queryFunc);\n if (nestedResult) {\n return nestedResult;\n }\n }\n return null;\n };\n this.FindAll = (type) => (queryFunc, foundSoFar) => {\n const found = Array.isArray(foundSoFar) ? foundSoFar : [];\n const tObj = (0, TypeAssertion_1.asOrNull)(this, type);\n if (tObj !== null && (!queryFunc || queryFunc(tObj) === true)) {\n found.push(tObj);\n }\n if (this.content === null) {\n return [];\n }\n for (const obj of this.content) {\n obj.FindAll && obj.FindAll(type)(queryFunc, found);\n }\n return found;\n };\n this.Warning = (message, source = null) => {\n this.Error(message, source, true);\n };\n }\n get debugMetadata() {\n if (this._debugMetadata === null && this.parent) {\n return this.parent.debugMetadata;\n }\n return this._debugMetadata;\n }\n set debugMetadata(value) {\n this._debugMetadata = value;\n }\n get hasOwnDebugMetadata() {\n return Boolean(this.debugMetadata);\n }\n get typeName() {\n return \"ParsedObject\";\n }\n get story() {\n let ancestor = this;\n while (ancestor.parent) {\n ancestor = ancestor.parent;\n }\n return ancestor;\n }\n get runtimeObject() {\n if (!this._runtimeObject) {\n this._runtimeObject = this.GenerateRuntimeObject();\n if (this._runtimeObject) {\n this._runtimeObject.debugMetadata = this.debugMetadata;\n }\n }\n return this._runtimeObject;\n }\n set runtimeObject(value) {\n this._runtimeObject = value;\n }\n get runtimePath() {\n if (!this.runtimeObject.path) {\n throw new Error();\n }\n return this.runtimeObject.path;\n }\n // When counting visits and turns since, different object\n // types may have different containers that needs to be counted.\n // For most it'll just be the object's main runtime object,\n // but for e.g. choices, it'll be the target container.\n get containerForCounting() {\n return this.runtimeObject;\n }\n get ancestry() {\n let result = [];\n let ancestor = this.parent;\n while (ancestor) {\n result.push(ancestor);\n ancestor = ancestor.parent;\n }\n result = result.reverse();\n return result;\n }\n ResolveReferences(context) {\n if (this.content !== null) {\n for (const obj of this.content) {\n obj.ResolveReferences(context);\n }\n }\n }\n Error(message, source = null, isWarning = false) {\n if (source === null) {\n source = this;\n }\n // Only allow a single parsed object to have a single error *directly* associated with it\n if ((source._alreadyHadError && !isWarning) ||\n (source._alreadyHadWarning && isWarning)) {\n return;\n }\n if (this.parent) {\n this.parent.Error(message, source, isWarning);\n }\n else {\n throw new Error(`No parent object to send error to: ${message}`);\n }\n if (isWarning) {\n source._alreadyHadWarning = true;\n }\n else {\n source._alreadyHadError = true;\n }\n }\n}\nexports.ParsedObject = ParsedObject;\n//# sourceMappingURL=Object.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AuthorWarning = void 0;\nconst Object_1 = require(\"./Object\");\nclass AuthorWarning extends Object_1.ParsedObject {\n constructor(warningMessage) {\n super();\n this.warningMessage = warningMessage;\n this.GenerateRuntimeObject = () => {\n this.Warning(this.warningMessage);\n return null;\n };\n }\n get typeName() {\n return \"AuthorWarning\";\n }\n}\nexports.AuthorWarning = AuthorWarning;\n//# sourceMappingURL=AuthorWarning.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Path = void 0;\nclass Path {\n constructor() {\n this._components = [];\n this._componentsString = null;\n this._isRelative = false;\n if (typeof arguments[0] == \"string\") {\n let componentsString = arguments[0];\n this.componentsString = componentsString;\n }\n else if (arguments[0] instanceof Path.Component &&\n arguments[1] instanceof Path) {\n let head = arguments[0];\n let tail = arguments[1];\n this._components.push(head);\n this._components = this._components.concat(tail._components);\n }\n else if (arguments[0] instanceof Array) {\n let head = arguments[0];\n let relative = !!arguments[1];\n this._components = this._components.concat(head);\n this._isRelative = relative;\n }\n }\n get isRelative() {\n return this._isRelative;\n }\n get componentCount() {\n return this._components.length;\n }\n get head() {\n if (this._components.length > 0) {\n return this._components[0];\n }\n else {\n return null;\n }\n }\n get tail() {\n if (this._components.length >= 2) {\n // careful, the original code uses length-1 here. This is because the second argument of\n // List.GetRange is a number of elements to extract, wherease Array.slice uses an index\n let tailComps = this._components.slice(1, this._components.length);\n return new Path(tailComps);\n }\n else {\n return Path.self;\n }\n }\n get length() {\n return this._components.length;\n }\n get lastComponent() {\n let lastComponentIdx = this._components.length - 1;\n if (lastComponentIdx >= 0) {\n return this._components[lastComponentIdx];\n }\n else {\n return null;\n }\n }\n get containsNamedComponent() {\n for (let i = 0, l = this._components.length; i < l; i++) {\n if (!this._components[i].isIndex) {\n return true;\n }\n }\n return false;\n }\n static get self() {\n let path = new Path();\n path._isRelative = true;\n return path;\n }\n GetComponent(index) {\n return this._components[index];\n }\n PathByAppendingPath(pathToAppend) {\n let p = new Path();\n let upwardMoves = 0;\n for (let i = 0; i < pathToAppend._components.length; ++i) {\n if (pathToAppend._components[i].isParent) {\n upwardMoves++;\n }\n else {\n break;\n }\n }\n for (let i = 0; i < this._components.length - upwardMoves; ++i) {\n p._components.push(this._components[i]);\n }\n for (let i = upwardMoves; i < pathToAppend._components.length; ++i) {\n p._components.push(pathToAppend._components[i]);\n }\n return p;\n }\n get componentsString() {\n if (this._componentsString == null) {\n this._componentsString = this._components.join(\".\");\n if (this.isRelative)\n this._componentsString = \".\" + this._componentsString;\n }\n return this._componentsString;\n }\n set componentsString(value) {\n this._components.length = 0;\n this._componentsString = value;\n if (this._componentsString == null || this._componentsString == \"\")\n return;\n if (this._componentsString[0] == \".\") {\n this._isRelative = true;\n this._componentsString = this._componentsString.substring(1);\n }\n let componentStrings = this._componentsString.split(\".\");\n for (let str of componentStrings) {\n // we need to distinguish between named components that start with a number, eg \"42somewhere\", and indexed components\n // the normal parseInt won't do for the detection because it's too relaxed.\n // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt\n if (/^(\\-|\\+)?([0-9]+|Infinity)$/.test(str)) {\n this._components.push(new Path.Component(parseInt(str)));\n }\n else {\n this._components.push(new Path.Component(str));\n }\n }\n }\n toString() {\n return this.componentsString;\n }\n Equals(otherPath) {\n if (otherPath == null)\n return false;\n if (otherPath._components.length != this._components.length)\n return false;\n if (otherPath.isRelative != this.isRelative)\n return false;\n // the original code uses SequenceEqual here, so we need to iterate over the components manually.\n for (let i = 0, l = otherPath._components.length; i < l; i++) {\n // it's not quite clear whether this test should use Equals or a simple == operator,\n // see https://github.com/y-lohse/inkjs/issues/22\n if (!otherPath._components[i].Equals(this._components[i]))\n return false;\n }\n return true;\n }\n PathByAppendingComponent(c) {\n let p = new Path();\n p._components.push(...this._components);\n p._components.push(c);\n return p;\n }\n}\nexports.Path = Path;\nPath.parentId = \"^\";\n(function (Path) {\n class Component {\n constructor(indexOrName) {\n this.index = -1;\n this.name = null;\n if (typeof indexOrName == \"string\") {\n this.name = indexOrName;\n }\n else {\n this.index = indexOrName;\n }\n }\n get isIndex() {\n return this.index >= 0;\n }\n get isParent() {\n return this.name == Path.parentId;\n }\n static ToParent() {\n return new Component(Path.parentId);\n }\n toString() {\n if (this.isIndex) {\n return this.index.toString();\n }\n else {\n return this.name;\n }\n }\n Equals(otherComp) {\n if (otherComp != null && otherComp.isIndex == this.isIndex) {\n if (this.isIndex) {\n return this.index == otherComp.index;\n }\n else {\n return this.name == otherComp.name;\n }\n }\n return false;\n }\n }\n Path.Component = Component;\n})(Path || (exports.Path = Path = {}));\n//# sourceMappingURL=Path.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Debug = void 0;\nvar Debug;\n(function (Debug) {\n function AssertType(variable, type, message) {\n Assert(variable instanceof type, message);\n }\n Debug.AssertType = AssertType;\n function Assert(condition, message) {\n if (!condition) {\n if (typeof message !== \"undefined\") {\n console.warn(message);\n }\n if (console.trace) {\n console.trace();\n }\n throw new Error(\"\");\n }\n }\n Debug.Assert = Assert;\n})(Debug || (exports.Debug = Debug = {}));\n//# sourceMappingURL=Debug.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.throwNullException = exports.NullException = void 0;\n/**\n * In the original C# code, a SystemException would be thrown when passing\n * null to methods expected a valid instance. Javascript has no such\n * concept, but TypeScript will not allow `null` to be passed to methods\n * explicitely requiring a valid type.\n *\n * Whenever TypeScript complain about the possibility of a `null` value,\n * check the offending value and it it's null, throw this exception using\n * `throwNullException(name: string)`.\n */\nclass NullException extends Error {\n}\nexports.NullException = NullException;\n/**\n * Throw a NullException.\n *\n * @param name a short description of the offending value (often its name within the code).\n */\nfunction throwNullException(name) {\n throw new NullException(`${name} is null or undefined`);\n}\nexports.throwNullException = throwNullException;\n//# sourceMappingURL=NullException.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InkObject = void 0;\nconst Path_1 = require(\"./Path\");\nconst Container_1 = require(\"./Container\");\nconst Debug_1 = require(\"./Debug\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst NullException_1 = require(\"./NullException\");\nclass InkObject {\n constructor() {\n this.parent = null;\n this._debugMetadata = null;\n this._path = null;\n }\n get debugMetadata() {\n if (this._debugMetadata === null) {\n if (this.parent) {\n return this.parent.debugMetadata;\n }\n }\n return this._debugMetadata;\n }\n set debugMetadata(value) {\n this._debugMetadata = value;\n }\n get ownDebugMetadata() {\n return this._debugMetadata;\n }\n DebugLineNumberOfPath(path) {\n if (path === null)\n return null;\n // Try to get a line number from debug metadata\n let root = this.rootContentContainer;\n if (root) {\n let targetContent = root.ContentAtPath(path).obj;\n if (targetContent) {\n let dm = targetContent.debugMetadata;\n if (dm !== null) {\n return dm.startLineNumber;\n }\n }\n }\n return null;\n }\n get path() {\n if (this._path == null) {\n if (this.parent == null) {\n this._path = new Path_1.Path();\n }\n else {\n let comps = [];\n let child = this;\n let container = (0, TypeAssertion_1.asOrNull)(child.parent, Container_1.Container);\n while (container !== null) {\n let namedChild = (0, TypeAssertion_1.asINamedContentOrNull)(child);\n if (namedChild != null && namedChild.hasValidName) {\n if (namedChild.name === null)\n return (0, NullException_1.throwNullException)(\"namedChild.name\");\n comps.unshift(new Path_1.Path.Component(namedChild.name));\n }\n else {\n comps.unshift(new Path_1.Path.Component(container.content.indexOf(child)));\n }\n child = container;\n container = (0, TypeAssertion_1.asOrNull)(container.parent, Container_1.Container);\n }\n this._path = new Path_1.Path(comps);\n }\n }\n return this._path;\n }\n ResolvePath(path) {\n if (path === null)\n return (0, NullException_1.throwNullException)(\"path\");\n if (path.isRelative) {\n let nearestContainer = (0, TypeAssertion_1.asOrNull)(this, Container_1.Container);\n if (nearestContainer === null) {\n Debug_1.Debug.Assert(this.parent !== null, \"Can't resolve relative path because we don't have a parent\");\n nearestContainer = (0, TypeAssertion_1.asOrNull)(this.parent, Container_1.Container);\n Debug_1.Debug.Assert(nearestContainer !== null, \"Expected parent to be a container\");\n Debug_1.Debug.Assert(path.GetComponent(0).isParent);\n path = path.tail;\n }\n if (nearestContainer === null) {\n return (0, NullException_1.throwNullException)(\"nearestContainer\");\n }\n return nearestContainer.ContentAtPath(path);\n }\n else {\n let contentContainer = this.rootContentContainer;\n if (contentContainer === null) {\n return (0, NullException_1.throwNullException)(\"contentContainer\");\n }\n return contentContainer.ContentAtPath(path);\n }\n }\n ConvertPathToRelative(globalPath) {\n let ownPath = this.path;\n let minPathLength = Math.min(globalPath.length, ownPath.length);\n let lastSharedPathCompIndex = -1;\n for (let i = 0; i < minPathLength; ++i) {\n let ownComp = ownPath.GetComponent(i);\n let otherComp = globalPath.GetComponent(i);\n if (ownComp.Equals(otherComp)) {\n lastSharedPathCompIndex = i;\n }\n else {\n break;\n }\n }\n // No shared path components, so just use global path\n if (lastSharedPathCompIndex == -1)\n return globalPath;\n let numUpwardsMoves = ownPath.componentCount - 1 - lastSharedPathCompIndex;\n let newPathComps = [];\n for (let up = 0; up < numUpwardsMoves; ++up)\n newPathComps.push(Path_1.Path.Component.ToParent());\n for (let down = lastSharedPathCompIndex + 1; down < globalPath.componentCount; ++down)\n newPathComps.push(globalPath.GetComponent(down));\n let relativePath = new Path_1.Path(newPathComps, true);\n return relativePath;\n }\n CompactPathString(otherPath) {\n let globalPathStr = null;\n let relativePathStr = null;\n if (otherPath.isRelative) {\n relativePathStr = otherPath.componentsString;\n globalPathStr = this.path.PathByAppendingPath(otherPath).componentsString;\n }\n else {\n let relativePath = this.ConvertPathToRelative(otherPath);\n relativePathStr = relativePath.componentsString;\n globalPathStr = otherPath.componentsString;\n }\n if (relativePathStr.length < globalPathStr.length)\n return relativePathStr;\n else\n return globalPathStr;\n }\n get rootContentContainer() {\n let ancestor = this;\n while (ancestor.parent) {\n ancestor = ancestor.parent;\n }\n return (0, TypeAssertion_1.asOrNull)(ancestor, Container_1.Container);\n }\n Copy() {\n throw Error(\"Not Implemented: Doesn't support copying\");\n }\n // SetChild works slightly diferently in the js implementation.\n // Since we can't pass an objets property by reference, we instead pass\n // the object and the property string.\n // TODO: This method can probably be rewritten with type-safety in mind.\n SetChild(obj, prop, value) {\n if (obj[prop])\n obj[prop] = null;\n obj[prop] = value;\n if (obj[prop])\n obj[prop].parent = this;\n }\n Equals(obj) {\n return obj === this;\n }\n}\nexports.InkObject = InkObject;\n//# sourceMappingURL=Object.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StringBuilder = void 0;\nclass StringBuilder {\n constructor(str) {\n str = typeof str !== \"undefined\" ? str.toString() : \"\";\n this.string = str;\n }\n get Length() {\n return this.string.length;\n }\n Append(str) {\n if (str !== null) {\n this.string += str;\n }\n }\n AppendLine(str) {\n if (typeof str !== \"undefined\")\n this.Append(str);\n this.string += \"\\n\";\n }\n AppendFormat(format, ...args) {\n // taken from http://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format\n this.string += format.replace(/{(\\d+)}/g, (match, num) => typeof args[num] != \"undefined\" ? args[num] : match);\n }\n toString() {\n return this.string;\n }\n Clear() {\n this.string = \"\";\n }\n}\nexports.StringBuilder = StringBuilder;\n//# sourceMappingURL=StringBuilder.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InkList = exports.InkListItem = void 0;\nconst NullException_1 = require(\"./NullException\");\nconst StringBuilder_1 = require(\"./StringBuilder\");\nclass InkListItem {\n constructor() {\n // InkListItem is a struct\n this.originName = null;\n this.itemName = null;\n if (typeof arguments[1] !== \"undefined\") {\n let originName = arguments[0];\n let itemName = arguments[1];\n this.originName = originName;\n this.itemName = itemName;\n }\n else if (arguments[0]) {\n let fullName = arguments[0];\n let nameParts = fullName.toString().split(\".\");\n this.originName = nameParts[0];\n this.itemName = nameParts[1];\n }\n }\n static get Null() {\n return new InkListItem(null, null);\n }\n get isNull() {\n return this.originName == null && this.itemName == null;\n }\n get fullName() {\n return ((this.originName !== null ? this.originName : \"?\") + \".\" + this.itemName);\n }\n toString() {\n return this.fullName;\n }\n Equals(obj) {\n if (obj instanceof InkListItem) {\n let otherItem = obj;\n return (otherItem.itemName == this.itemName &&\n otherItem.originName == this.originName);\n }\n return false;\n }\n // These methods did not exist in the original C# code. Their purpose is to\n // make `InkListItem` mimics the value-type semantics of the original\n // struct. Please refer to the end of this file, for a more in-depth\n // explanation.\n /**\n * Returns a shallow clone of the current instance.\n */\n copy() {\n return new InkListItem(this.originName, this.itemName);\n }\n /**\n * Returns a `SerializedInkListItem` representing the current\n * instance. The result is intended to be used as a key inside a Map.\n */\n serialized() {\n // We are simply using a JSON representation as a value-typed key.\n return JSON.stringify({\n originName: this.originName,\n itemName: this.itemName,\n });\n }\n /**\n * Reconstructs a `InkListItem` from the given SerializedInkListItem.\n */\n static fromSerializedKey(key) {\n let obj = JSON.parse(key);\n if (!InkListItem.isLikeInkListItem(obj))\n return InkListItem.Null;\n let inkListItem = obj;\n return new InkListItem(inkListItem.originName, inkListItem.itemName);\n }\n /**\n * Determines whether the given item is sufficiently `InkListItem`-like\n * to be used as a template when reconstructing the InkListItem.\n */\n static isLikeInkListItem(item) {\n if (typeof item !== \"object\")\n return false;\n if (!item.hasOwnProperty(\"originName\") || !item.hasOwnProperty(\"itemName\"))\n return false;\n if (typeof item.originName !== \"string\" && typeof item.originName !== null)\n return false;\n if (typeof item.itemName !== \"string\" && typeof item.itemName !== null)\n return false;\n return true;\n }\n}\nexports.InkListItem = InkListItem;\nclass InkList extends Map {\n constructor() {\n // Trying to be smart here, this emulates the constructor inheritance found\n // in the original code, but only if otherList is an InkList. IIFE FTW.\n super((() => {\n if (arguments[0] instanceof InkList) {\n return arguments[0];\n }\n else {\n return [];\n }\n })());\n this.origins = null;\n this._originNames = [];\n if (arguments[0] instanceof InkList) {\n let otherList = arguments[0];\n let otherOriginNames = otherList.originNames;\n if (otherOriginNames !== null)\n this._originNames = otherOriginNames.slice();\n if (otherList.origins !== null) {\n this.origins = otherList.origins.slice();\n }\n }\n else if (typeof arguments[0] === \"string\") {\n let singleOriginListName = arguments[0];\n let originStory = arguments[1];\n this.SetInitialOriginName(singleOriginListName);\n if (originStory.listDefinitions === null) {\n return (0, NullException_1.throwNullException)(\"originStory.listDefinitions\");\n }\n let def = originStory.listDefinitions.TryListGetDefinition(singleOriginListName, null);\n if (def.exists) {\n // Throwing now, because if the value is `null` it will\n // eventually throw down the line.\n if (def.result === null) {\n return (0, NullException_1.throwNullException)(\"def.result\");\n }\n this.origins = [def.result];\n }\n else {\n throw new Error(\"InkList origin could not be found in story when constructing new list: \" +\n singleOriginListName);\n }\n }\n else if (typeof arguments[0] === \"object\" &&\n arguments[0].hasOwnProperty(\"Key\") &&\n arguments[0].hasOwnProperty(\"Value\")) {\n let singleElement = arguments[0];\n this.Add(singleElement.Key, singleElement.Value);\n }\n }\n static FromString(myListItem, originStory) {\n var _a;\n if (myListItem == null || myListItem == \"\")\n return new InkList();\n let listValue = (_a = originStory.listDefinitions) === null || _a === void 0 ? void 0 : _a.FindSingleItemListWithName(myListItem);\n if (listValue) {\n if (listValue.value === null) {\n return (0, NullException_1.throwNullException)(\"listValue.value\");\n }\n return new InkList(listValue.value);\n }\n else {\n throw new Error(\"Could not find the InkListItem from the string '\" +\n myListItem +\n \"' to create an InkList because it doesn't exist in the original list definition in ink.\");\n }\n }\n AddItem(itemOrItemName, storyObject = null) {\n if (itemOrItemName instanceof InkListItem) {\n let item = itemOrItemName;\n if (item.originName == null) {\n this.AddItem(item.itemName);\n return;\n }\n if (this.origins === null)\n return (0, NullException_1.throwNullException)(\"this.origins\");\n for (let origin of this.origins) {\n if (origin.name == item.originName) {\n let intVal = origin.TryGetValueForItem(item, 0);\n if (intVal.exists) {\n this.Add(item, intVal.result);\n return;\n }\n else {\n throw new Error(\"Could not add the item \" +\n item +\n \" to this list because it doesn't exist in the original list definition in ink.\");\n }\n }\n }\n throw new Error(\"Failed to add item to list because the item was from a new list definition that wasn't previously known to this list. Only items from previously known lists can be used, so that the int value can be found.\");\n }\n else if (itemOrItemName !== null) {\n //itemOrItemName is a string\n let itemName = itemOrItemName;\n let foundListDef = null;\n if (this.origins === null)\n return (0, NullException_1.throwNullException)(\"this.origins\");\n for (let origin of this.origins) {\n if (itemName === null)\n return (0, NullException_1.throwNullException)(\"itemName\");\n if (origin.ContainsItemWithName(itemName)) {\n if (foundListDef != null) {\n throw new Error(\"Could not add the item \" +\n itemName +\n \" to this list because it could come from either \" +\n origin.name +\n \" or \" +\n foundListDef.name);\n }\n else {\n foundListDef = origin;\n }\n }\n }\n if (foundListDef == null) {\n if (storyObject == null) {\n throw new Error(\"Could not add the item \" +\n itemName +\n \" to this list because it isn't known to any list definitions previously associated with this list.\");\n }\n else {\n let newItem = InkList.FromString(itemName, storyObject)\n .orderedItems[0];\n this.Add(newItem.Key, newItem.Value);\n }\n }\n else {\n let item = new InkListItem(foundListDef.name, itemName);\n let itemVal = foundListDef.ValueForItem(item);\n this.Add(item, itemVal);\n }\n }\n }\n ContainsItemNamed(itemName) {\n for (let [key] of this) {\n let item = InkListItem.fromSerializedKey(key);\n if (item.itemName == itemName)\n return true;\n }\n return false;\n }\n ContainsKey(key) {\n return this.has(key.serialized());\n }\n Add(key, value) {\n let serializedKey = key.serialized();\n if (this.has(serializedKey)) {\n // Throw an exception to match the C# behavior.\n throw new Error(`The Map already contains an entry for ${key}`);\n }\n this.set(serializedKey, value);\n }\n Remove(key) {\n return this.delete(key.serialized());\n }\n get Count() {\n return this.size;\n }\n get originOfMaxItem() {\n if (this.origins == null)\n return null;\n let maxOriginName = this.maxItem.Key.originName;\n let result = null;\n this.origins.every((origin) => {\n if (origin.name == maxOriginName) {\n result = origin;\n return false;\n }\n else\n return true;\n });\n return result;\n }\n get originNames() {\n if (this.Count > 0) {\n if (this._originNames == null && this.Count > 0)\n this._originNames = [];\n else {\n if (!this._originNames)\n this._originNames = [];\n this._originNames.length = 0;\n }\n for (let [key] of this) {\n let item = InkListItem.fromSerializedKey(key);\n if (item.originName === null)\n return (0, NullException_1.throwNullException)(\"item.originName\");\n this._originNames.push(item.originName);\n }\n }\n return this._originNames;\n }\n SetInitialOriginName(initialOriginName) {\n this._originNames = [initialOriginName];\n }\n SetInitialOriginNames(initialOriginNames) {\n if (initialOriginNames == null)\n this._originNames = null;\n else\n this._originNames = initialOriginNames.slice(); // store a copy\n }\n get maxItem() {\n let max = {\n Key: InkListItem.Null,\n Value: 0,\n };\n for (let [key, value] of this) {\n let item = InkListItem.fromSerializedKey(key);\n if (max.Key.isNull || value > max.Value)\n max = { Key: item, Value: value };\n }\n return max;\n }\n get minItem() {\n let min = {\n Key: InkListItem.Null,\n Value: 0,\n };\n for (let [key, value] of this) {\n let item = InkListItem.fromSerializedKey(key);\n if (min.Key.isNull || value < min.Value) {\n min = { Key: item, Value: value };\n }\n }\n return min;\n }\n get inverse() {\n let list = new InkList();\n if (this.origins != null) {\n for (let origin of this.origins) {\n for (let [key, value] of origin.items) {\n let item = InkListItem.fromSerializedKey(key);\n if (!this.ContainsKey(item))\n list.Add(item, value);\n }\n }\n }\n return list;\n }\n get all() {\n let list = new InkList();\n if (this.origins != null) {\n for (let origin of this.origins) {\n for (let [key, value] of origin.items) {\n let item = InkListItem.fromSerializedKey(key);\n list.set(item.serialized(), value);\n }\n }\n }\n return list;\n }\n Union(otherList) {\n let union = new InkList(this);\n for (let [key, value] of otherList) {\n union.set(key, value);\n }\n return union;\n }\n Intersect(otherList) {\n let intersection = new InkList();\n for (let [key, value] of this) {\n if (otherList.has(key))\n intersection.set(key, value);\n }\n return intersection;\n }\n HasIntersection(otherList) {\n for (let [key] of this) {\n if (otherList.has(key))\n return true;\n }\n return false;\n }\n Without(listToRemove) {\n let result = new InkList(this);\n for (let [key] of listToRemove) {\n result.delete(key);\n }\n return result;\n }\n Contains(what) {\n if (typeof what == \"string\")\n return this.ContainsItemNamed(what);\n const otherList = what;\n if (otherList.size == 0 || this.size == 0)\n return false;\n for (let [key] of otherList) {\n if (!this.has(key))\n return false;\n }\n return true;\n }\n GreaterThan(otherList) {\n if (this.Count == 0)\n return false;\n if (otherList.Count == 0)\n return true;\n return this.minItem.Value > otherList.maxItem.Value;\n }\n GreaterThanOrEquals(otherList) {\n if (this.Count == 0)\n return false;\n if (otherList.Count == 0)\n return true;\n return (this.minItem.Value >= otherList.minItem.Value &&\n this.maxItem.Value >= otherList.maxItem.Value);\n }\n LessThan(otherList) {\n if (otherList.Count == 0)\n return false;\n if (this.Count == 0)\n return true;\n return this.maxItem.Value < otherList.minItem.Value;\n }\n LessThanOrEquals(otherList) {\n if (otherList.Count == 0)\n return false;\n if (this.Count == 0)\n return true;\n return (this.maxItem.Value <= otherList.maxItem.Value &&\n this.minItem.Value <= otherList.minItem.Value);\n }\n MaxAsList() {\n if (this.Count > 0)\n return new InkList(this.maxItem);\n else\n return new InkList();\n }\n MinAsList() {\n if (this.Count > 0)\n return new InkList(this.minItem);\n else\n return new InkList();\n }\n ListWithSubRange(minBound, maxBound) {\n if (this.Count == 0)\n return new InkList();\n let ordered = this.orderedItems;\n let minValue = 0;\n let maxValue = Number.MAX_SAFE_INTEGER;\n if (Number.isInteger(minBound)) {\n minValue = minBound;\n }\n else {\n if (minBound instanceof InkList && minBound.Count > 0)\n minValue = minBound.minItem.Value;\n }\n if (Number.isInteger(maxBound)) {\n maxValue = maxBound;\n }\n else {\n if (maxBound instanceof InkList && maxBound.Count > 0)\n maxValue = maxBound.maxItem.Value;\n }\n let subList = new InkList();\n subList.SetInitialOriginNames(this.originNames);\n for (let item of ordered) {\n if (item.Value >= minValue && item.Value <= maxValue) {\n subList.Add(item.Key, item.Value);\n }\n }\n return subList;\n }\n Equals(otherInkList) {\n if (otherInkList instanceof InkList === false)\n return false;\n if (otherInkList.Count != this.Count)\n return false;\n for (let [key] of this) {\n if (!otherInkList.has(key))\n return false;\n }\n return true;\n }\n // GetHashCode not implemented\n get orderedItems() {\n // List<KeyValuePair<InkListItem, int>>\n let ordered = new Array();\n for (let [key, value] of this) {\n let item = InkListItem.fromSerializedKey(key);\n ordered.push({ Key: item, Value: value });\n }\n ordered.sort((x, y) => {\n if (x.Key.originName === null) {\n return (0, NullException_1.throwNullException)(\"x.Key.originName\");\n }\n if (y.Key.originName === null) {\n return (0, NullException_1.throwNullException)(\"y.Key.originName\");\n }\n if (x.Value == y.Value) {\n return x.Key.originName.localeCompare(y.Key.originName);\n }\n else {\n // TODO: refactor this bit into a numberCompareTo method?\n if (x.Value < y.Value)\n return -1;\n return x.Value > y.Value ? 1 : 0;\n }\n });\n return ordered;\n }\n get singleItem() {\n for (let item of this.orderedItems) {\n return item.Key;\n }\n return null;\n }\n toString() {\n let ordered = this.orderedItems;\n let sb = new StringBuilder_1.StringBuilder();\n for (let i = 0; i < ordered.length; i++) {\n if (i > 0)\n sb.Append(\", \");\n let item = ordered[i].Key;\n if (item.itemName === null)\n return (0, NullException_1.throwNullException)(\"item.itemName\");\n sb.Append(item.itemName);\n }\n return sb.toString();\n }\n // casting a InkList to a Number, for somereason, actually gives a number.\n // This messes up the type detection when creating a Value from a InkList.\n // Returning NaN here prevents that.\n valueOf() {\n return NaN;\n }\n}\nexports.InkList = InkList;\n//# sourceMappingURL=InkList.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StoryException = void 0;\nclass StoryException extends Error {\n constructor(message) {\n super(message);\n this.useEndLineNumber = false;\n this.message = message;\n this.name = \"StoryException\";\n }\n}\nexports.StoryException = StoryException;\n//# sourceMappingURL=StoryException.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.tryParseFloat = exports.tryParseInt = exports.tryGetValueFromMap = void 0;\nfunction tryGetValueFromMap(map, key, \n/* out */ value) {\n if (map === null) {\n return { result: value, exists: false };\n }\n let val = map.get(key);\n if (typeof val === \"undefined\") {\n return { result: value, exists: false };\n }\n else {\n return { result: val, exists: true };\n }\n}\nexports.tryGetValueFromMap = tryGetValueFromMap;\nfunction tryParseInt(value, \n/* out */ defaultValue = 0) {\n let val = parseInt(value);\n if (!Number.isNaN(val)) {\n return { result: val, exists: true };\n }\n else {\n return { result: defaultValue, exists: false };\n }\n}\nexports.tryParseInt = tryParseInt;\nfunction tryParseFloat(value, \n/* out */ defaultValue = 0) {\n let val = parseFloat(value);\n if (!Number.isNaN(val)) {\n return { result: val, exists: true };\n }\n else {\n return { result: defaultValue, exists: false };\n }\n}\nexports.tryParseFloat = tryParseFloat;\n//# sourceMappingURL=TryGetResult.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ValueType = exports.ListValue = exports.VariablePointerValue = exports.DivertTargetValue = exports.StringValue = exports.FloatValue = exports.IntValue = exports.BoolValue = exports.Value = exports.AbstractValue = void 0;\nconst Object_1 = require(\"./Object\");\nconst Path_1 = require(\"./Path\");\nconst InkList_1 = require(\"./InkList\");\nconst StoryException_1 = require(\"./StoryException\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst TryGetResult_1 = require(\"./TryGetResult\");\nconst NullException_1 = require(\"./NullException\");\nclass AbstractValue extends Object_1.InkObject {\n static Create(val, preferredNumberType) {\n // This code doesn't exist in upstream and is simply here to enforce\n // the creation of the proper number value.\n // If `preferredNumberType` is not provided or if value doesn't match\n // `preferredNumberType`, this conditional does nothing.\n if (preferredNumberType) {\n if (preferredNumberType === ValueType.Int &&\n Number.isInteger(Number(val))) {\n return new IntValue(Number(val));\n }\n else if (preferredNumberType === ValueType.Float &&\n !isNaN(val)) {\n return new FloatValue(Number(val));\n }\n }\n if (typeof val === \"boolean\") {\n return new BoolValue(Boolean(val));\n }\n // https://github.com/y-lohse/inkjs/issues/425\n // Changed condition sequence, because Number('') is\n // parsed to 0, which made setting string to empty\n // impossible\n if (typeof val === \"string\") {\n return new StringValue(String(val));\n }\n else if (Number.isInteger(Number(val))) {\n return new IntValue(Number(val));\n }\n else if (!isNaN(val)) {\n return new FloatValue(Number(val));\n }\n else if (val instanceof Path_1.Path) {\n return new DivertTargetValue((0, TypeAssertion_1.asOrThrows)(val, Path_1.Path));\n }\n else if (val instanceof InkList_1.InkList) {\n return new ListValue((0, TypeAssertion_1.asOrThrows)(val, InkList_1.InkList));\n }\n return null;\n }\n Copy() {\n return (0, TypeAssertion_1.asOrThrows)(AbstractValue.Create(this.valueObject), Object_1.InkObject);\n }\n BadCastException(targetType) {\n return new StoryException_1.StoryException(\"Can't cast \" +\n this.valueObject +\n \" from \" +\n this.valueType +\n \" to \" +\n targetType);\n }\n}\nexports.AbstractValue = AbstractValue;\nclass Value extends AbstractValue {\n constructor(val) {\n super();\n this.value = val;\n }\n get valueObject() {\n return this.value;\n }\n toString() {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n return this.value.toString();\n }\n}\nexports.Value = Value;\nclass BoolValue extends Value {\n constructor(val) {\n super(val || false);\n }\n get isTruthy() {\n return Boolean(this.value);\n }\n get valueType() {\n return ValueType.Bool;\n }\n Cast(newType) {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n if (newType == this.valueType) {\n return this;\n }\n if (newType == ValueType.Int) {\n return new IntValue(this.value ? 1 : 0);\n }\n if (newType == ValueType.Float) {\n return new FloatValue(this.value ? 1.0 : 0.0);\n }\n if (newType == ValueType.String) {\n return new StringValue(this.value ? \"true\" : \"false\");\n }\n throw this.BadCastException(newType);\n }\n toString() {\n return this.value ? \"true\" : \"false\";\n }\n}\nexports.BoolValue = BoolValue;\nclass IntValue extends Value {\n constructor(val) {\n super(val || 0);\n }\n get isTruthy() {\n return this.value != 0;\n }\n get valueType() {\n return ValueType.Int;\n }\n Cast(newType) {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n if (newType == this.valueType) {\n return this;\n }\n if (newType == ValueType.Bool) {\n return new BoolValue(this.value === 0 ? false : true);\n }\n if (newType == ValueType.Float) {\n return new FloatValue(this.value);\n }\n if (newType == ValueType.String) {\n return new StringValue(\"\" + this.value);\n }\n throw this.BadCastException(newType);\n }\n}\nexports.IntValue = IntValue;\nclass FloatValue extends Value {\n constructor(val) {\n super(val || 0.0);\n }\n get isTruthy() {\n return this.value != 0.0;\n }\n get valueType() {\n return ValueType.Float;\n }\n Cast(newType) {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n if (newType == this.valueType) {\n return this;\n }\n if (newType == ValueType.Bool) {\n return new BoolValue(this.value === 0.0 ? false : true);\n }\n if (newType == ValueType.Int) {\n return new IntValue(this.value);\n }\n if (newType == ValueType.String) {\n return new StringValue(\"\" + this.value);\n }\n throw this.BadCastException(newType);\n }\n}\nexports.FloatValue = FloatValue;\nclass StringValue extends Value {\n constructor(val) {\n super(val || \"\");\n this._isNewline = this.value == \"\\n\";\n this._isInlineWhitespace = true;\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n if (this.value.length > 0) {\n this.value.split(\"\").every((c) => {\n if (c != \" \" && c != \"\\t\") {\n this._isInlineWhitespace = false;\n return false;\n }\n return true;\n });\n }\n }\n get valueType() {\n return ValueType.String;\n }\n get isTruthy() {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n return this.value.length > 0;\n }\n get isNewline() {\n return this._isNewline;\n }\n get isInlineWhitespace() {\n return this._isInlineWhitespace;\n }\n get isNonWhitespace() {\n return !this.isNewline && !this.isInlineWhitespace;\n }\n Cast(newType) {\n if (newType == this.valueType) {\n return this;\n }\n if (newType == ValueType.Int) {\n let parsedInt = (0, TryGetResult_1.tryParseInt)(this.value);\n if (parsedInt.exists) {\n return new IntValue(parsedInt.result);\n }\n else {\n throw this.BadCastException(newType);\n }\n }\n if (newType == ValueType.Float) {\n let parsedFloat = (0, TryGetResult_1.tryParseFloat)(this.value);\n if (parsedFloat.exists) {\n return new FloatValue(parsedFloat.result);\n }\n else {\n throw this.BadCastException(newType);\n }\n }\n throw this.BadCastException(newType);\n }\n}\nexports.StringValue = StringValue;\nclass DivertTargetValue extends Value {\n constructor(targetPath = null) {\n super(targetPath);\n }\n get valueType() {\n return ValueType.DivertTarget;\n }\n get targetPath() {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n return this.value;\n }\n set targetPath(value) {\n this.value = value;\n }\n get isTruthy() {\n throw new Error(\"Shouldn't be checking the truthiness of a divert target\");\n }\n Cast(newType) {\n if (newType == this.valueType)\n return this;\n throw this.BadCastException(newType);\n }\n toString() {\n return \"DivertTargetValue(\" + this.targetPath + \")\";\n }\n}\nexports.DivertTargetValue = DivertTargetValue;\nclass VariablePointerValue extends Value {\n constructor(variableName, contextIndex = -1) {\n super(variableName);\n this._contextIndex = contextIndex;\n }\n get contextIndex() {\n return this._contextIndex;\n }\n set contextIndex(value) {\n this._contextIndex = value;\n }\n get variableName() {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n return this.value;\n }\n set variableName(value) {\n this.value = value;\n }\n get valueType() {\n return ValueType.VariablePointer;\n }\n get isTruthy() {\n throw new Error(\"Shouldn't be checking the truthiness of a variable pointer\");\n }\n Cast(newType) {\n if (newType == this.valueType)\n return this;\n throw this.BadCastException(newType);\n }\n toString() {\n return \"VariablePointerValue(\" + this.variableName + \")\";\n }\n Copy() {\n return new VariablePointerValue(this.variableName, this.contextIndex);\n }\n}\nexports.VariablePointerValue = VariablePointerValue;\nclass ListValue extends Value {\n get isTruthy() {\n if (this.value === null) {\n return (0, NullException_1.throwNullException)(\"this.value\");\n }\n return this.value.Count > 0;\n }\n get valueType() {\n return ValueType.List;\n }\n Cast(newType) {\n if (this.value === null)\n return (0, NullException_1.throwNullException)(\"Value.value\");\n if (newType == ValueType.Int) {\n let max = this.value.maxItem;\n if (max.Key.isNull)\n return new IntValue(0);\n else\n return new IntValue(max.Value);\n }\n else if (newType == ValueType.Float) {\n let max = this.value.maxItem;\n if (max.Key.isNull)\n return new FloatValue(0.0);\n else\n return new FloatValue(max.Value);\n }\n else if (newType == ValueType.String) {\n let max = this.value.maxItem;\n if (max.Key.isNull)\n return new StringValue(\"\");\n else {\n return new StringValue(max.Key.toString());\n }\n }\n if (newType == this.valueType)\n return this;\n throw this.BadCastException(newType);\n }\n constructor(listOrSingleItem, singleValue) {\n super(null);\n if (!listOrSingleItem && !singleValue) {\n this.value = new InkList_1.InkList();\n }\n else if (listOrSingleItem instanceof InkList_1.InkList) {\n this.value = new InkList_1.InkList(listOrSingleItem);\n }\n else if (listOrSingleItem instanceof InkList_1.InkListItem &&\n typeof singleValue === \"number\") {\n this.value = new InkList_1.InkList({\n Key: listOrSingleItem,\n Value: singleValue,\n });\n }\n }\n static RetainListOriginsForAssignment(oldValue, newValue) {\n let oldList = (0, TypeAssertion_1.asOrNull)(oldValue, ListValue);\n let newList = (0, TypeAssertion_1.asOrNull)(newValue, ListValue);\n if (newList && newList.value === null)\n return (0, NullException_1.throwNullException)(\"newList.value\");\n if (oldList && oldList.value === null)\n return (0, NullException_1.throwNullException)(\"oldList.value\");\n // When assigning the empty list, try to retain any initial origin names\n if (oldList && newList && newList.value.Count == 0)\n newList.value.SetInitialOriginNames(oldList.value.originNames);\n }\n}\nexports.ListValue = ListValue;\nvar ValueType;\n(function (ValueType) {\n ValueType[ValueType[\"Bool\"] = -1] = \"Bool\";\n ValueType[ValueType[\"Int\"] = 0] = \"Int\";\n ValueType[ValueType[\"Float\"] = 1] = \"Float\";\n ValueType[ValueType[\"List\"] = 2] = \"List\";\n ValueType[ValueType[\"String\"] = 3] = \"String\";\n ValueType[ValueType[\"DivertTarget\"] = 4] = \"DivertTarget\";\n ValueType[ValueType[\"VariablePointer\"] = 5] = \"VariablePointer\";\n})(ValueType || (exports.ValueType = ValueType = {}));\n//# sourceMappingURL=Value.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SearchResult = void 0;\nconst Container_1 = require(\"./Container\");\nclass SearchResult {\n constructor() {\n this.obj = null;\n this.approximate = false;\n }\n get correctObj() {\n return this.approximate ? null : this.obj;\n }\n get container() {\n return this.obj instanceof Container_1.Container ? this.obj : null;\n }\n copy() {\n let searchResult = new SearchResult();\n searchResult.obj = this.obj;\n searchResult.approximate = this.approximate;\n return searchResult;\n }\n}\nexports.SearchResult = SearchResult;\n//# sourceMappingURL=SearchResult.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Container = void 0;\nconst Value_1 = require(\"./Value\");\nconst NullException_1 = require(\"./NullException\");\nconst StringBuilder_1 = require(\"./StringBuilder\");\nconst Object_1 = require(\"./Object\");\nconst SearchResult_1 = require(\"./SearchResult\");\nconst Path_1 = require(\"./Path\");\nconst Debug_1 = require(\"./Debug\");\nconst TryGetResult_1 = require(\"./TryGetResult\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nclass Container extends Object_1.InkObject {\n constructor() {\n super(...arguments);\n this.name = null;\n this._content = [];\n this.namedContent = new Map();\n this.visitsShouldBeCounted = false;\n this.turnIndexShouldBeCounted = false;\n this.countingAtStartOnly = false;\n this._pathToFirstLeafContent = null;\n }\n get hasValidName() {\n return this.name != null && this.name.length > 0;\n }\n get content() {\n return this._content;\n }\n set content(value) {\n this.AddContent(value);\n }\n get namedOnlyContent() {\n let namedOnlyContentDict = new Map();\n for (let [key, value] of this.namedContent) {\n let inkObject = (0, TypeAssertion_1.asOrThrows)(value, Object_1.InkObject);\n namedOnlyContentDict.set(key, inkObject);\n }\n for (let c of this.content) {\n let named = (0, TypeAssertion_1.asINamedContentOrNull)(c);\n if (named != null && named.hasValidName) {\n namedOnlyContentDict.delete(named.name);\n }\n }\n if (namedOnlyContentDict.size == 0)\n namedOnlyContentDict = null;\n return namedOnlyContentDict;\n }\n set namedOnlyContent(value) {\n let existingNamedOnly = this.namedOnlyContent;\n if (existingNamedOnly != null) {\n for (let [key] of existingNamedOnly) {\n this.namedContent.delete(key);\n }\n }\n if (value == null)\n return;\n for (let [, val] of value) {\n let named = (0, TypeAssertion_1.asINamedContentOrNull)(val);\n if (named != null)\n this.AddToNamedContentOnly(named);\n }\n }\n get countFlags() {\n let flags = 0;\n if (this.visitsShouldBeCounted)\n flags |= Container.CountFlags.Visits;\n if (this.turnIndexShouldBeCounted)\n flags |= Container.CountFlags.Turns;\n if (this.countingAtStartOnly)\n flags |= Container.CountFlags.CountStartOnly;\n if (flags == Container.CountFlags.CountStartOnly) {\n flags = 0;\n }\n return flags;\n }\n set countFlags(value) {\n let flag = value;\n if ((flag & Container.CountFlags.Visits) > 0)\n this.visitsShouldBeCounted = true;\n if ((flag & Container.CountFlags.Turns) > 0)\n this.turnIndexShouldBeCounted = true;\n if ((flag & Container.CountFlags.CountStartOnly) > 0)\n this.countingAtStartOnly = true;\n }\n get pathToFirstLeafContent() {\n if (this._pathToFirstLeafContent == null)\n this._pathToFirstLeafContent = this.path.PathByAppendingPath(this.internalPathToFirstLeafContent);\n return this._pathToFirstLeafContent;\n }\n get internalPathToFirstLeafContent() {\n let components = [];\n let container = this;\n while (container instanceof Container) {\n if (container.content.length > 0) {\n components.push(new Path_1.Path.Component(0));\n container = container.content[0];\n }\n }\n return new Path_1.Path(components);\n }\n AddContent(contentObjOrList) {\n if (contentObjOrList instanceof Array) {\n let contentList = contentObjOrList;\n for (let c of contentList) {\n this.AddContent(c);\n }\n }\n else {\n let contentObj = contentObjOrList;\n this._content.push(contentObj);\n if (contentObj.parent) {\n throw new Error(\"content is already in \" + contentObj.parent);\n }\n contentObj.parent = this;\n this.TryAddNamedContent(contentObj);\n }\n }\n TryAddNamedContent(contentObj) {\n let namedContentObj = (0, TypeAssertion_1.asINamedContentOrNull)(contentObj);\n if (namedContentObj != null && namedContentObj.hasValidName) {\n this.AddToNamedContentOnly(namedContentObj);\n }\n }\n AddToNamedContentOnly(namedContentObj) {\n Debug_1.Debug.AssertType(namedContentObj, Object_1.InkObject, \"Can only add Runtime.Objects to a Runtime.Container\");\n let runtimeObj = (0, TypeAssertion_1.asOrThrows)(namedContentObj, Object_1.InkObject);\n runtimeObj.parent = this;\n if (namedContentObj.name === null)\n return (0, NullException_1.throwNullException)(\"namedContentObj.name\");\n this.namedContent.set(namedContentObj.name, namedContentObj);\n }\n ContentAtPath(path, partialPathStart = 0, partialPathLength = -1) {\n if (partialPathLength == -1)\n partialPathLength = path.length;\n let result = new SearchResult_1.SearchResult();\n result.approximate = false;\n let currentContainer = this;\n let currentObj = this;\n for (let i = partialPathStart; i < partialPathLength; ++i) {\n let comp = path.GetComponent(i);\n if (currentContainer == null) {\n result.approximate = true;\n break;\n }\n let foundObj = currentContainer.ContentWithPathComponent(comp);\n // Couldn't resolve entire path?\n if (foundObj == null) {\n result.approximate = true;\n break;\n }\n // Are we about to loop into another container?\n // Is the object a container as expected? It might\n // no longer be if the content has shuffled around, so what\n // was originally a container no longer is.\n const nextContainer = (0, TypeAssertion_1.asOrNull)(foundObj, Container);\n if (i < partialPathLength - 1 && nextContainer == null) {\n result.approximate = true;\n break;\n }\n currentObj = foundObj;\n currentContainer = nextContainer;\n }\n result.obj = currentObj;\n return result;\n }\n InsertContent(contentObj, index) {\n this.content.splice(index, 0, contentObj);\n if (contentObj.parent) {\n throw new Error(\"content is already in \" + contentObj.parent);\n }\n contentObj.parent = this;\n this.TryAddNamedContent(contentObj);\n }\n AddContentsOfContainer(otherContainer) {\n this.content.push(...otherContainer.content);\n for (let obj of otherContainer.content) {\n obj.parent = this;\n this.TryAddNamedContent(obj);\n }\n }\n ContentWithPathComponent(component) {\n if (component.isIndex) {\n if (component.index >= 0 && component.index < this.content.length) {\n return this.content[component.index];\n }\n else {\n return null;\n }\n }\n else if (component.isParent) {\n return this.parent;\n }\n else {\n if (component.name === null) {\n return (0, NullException_1.throwNullException)(\"component.name\");\n }\n let foundContent = (0, TryGetResult_1.tryGetValueFromMap)(this.namedContent, component.name, null);\n if (foundContent.exists) {\n return (0, TypeAssertion_1.asOrThrows)(foundContent.result, Object_1.InkObject);\n }\n else {\n return null;\n }\n }\n }\n BuildStringOfHierarchy() {\n let sb;\n if (arguments.length == 0) {\n sb = new StringBuilder_1.StringBuilder();\n this.BuildStringOfHierarchy(sb, 0, null);\n return sb.toString();\n }\n sb = arguments[0];\n let indentation = arguments[1];\n let pointedObj = arguments[2];\n function appendIndentation() {\n const spacesPerIndent = 4; // Truly const in the original code\n for (let i = 0; i < spacesPerIndent * indentation; ++i) {\n sb.Append(\" \");\n }\n }\n appendIndentation();\n sb.Append(\"[\");\n if (this.hasValidName) {\n sb.AppendFormat(\" ({0})\", this.name);\n }\n if (this == pointedObj) {\n sb.Append(\" <---\");\n }\n sb.AppendLine();\n indentation++;\n for (let i = 0; i < this.content.length; ++i) {\n let obj = this.content[i];\n if (obj instanceof Container) {\n let container = obj;\n container.BuildStringOfHierarchy(sb, indentation, pointedObj);\n }\n else {\n appendIndentation();\n if (obj instanceof Value_1.StringValue) {\n sb.Append('\"');\n sb.Append(obj.toString().replace(\"\\n\", \"\\\\n\"));\n sb.Append('\"');\n }\n else {\n sb.Append(obj.toString());\n }\n }\n if (i != this.content.length - 1) {\n sb.Append(\",\");\n }\n if (!(obj instanceof Container) && obj == pointedObj) {\n sb.Append(\" <---\");\n }\n sb.AppendLine();\n }\n let onlyNamed = new Map();\n for (let [key, value] of this.namedContent) {\n if (this.content.indexOf((0, TypeAssertion_1.asOrThrows)(value, Object_1.InkObject)) >= 0) {\n continue;\n }\n else {\n onlyNamed.set(key, value);\n }\n }\n if (onlyNamed.size > 0) {\n appendIndentation();\n sb.AppendLine(\"-- named: --\");\n for (let [, value] of onlyNamed) {\n Debug_1.Debug.AssertType(value, Container, \"Can only print out named Containers\");\n let container = value;\n container.BuildStringOfHierarchy(sb, indentation, pointedObj);\n sb.AppendLine();\n }\n }\n indentation--;\n appendIndentation();\n sb.Append(\"]\");\n }\n}\nexports.Container = Container;\n(function (Container) {\n let CountFlags;\n (function (CountFlags) {\n CountFlags[CountFlags[\"Start\"] = 0] = \"Start\";\n CountFlags[CountFlags[\"Visits\"] = 1] = \"Visits\";\n CountFlags[CountFlags[\"Turns\"] = 2] = \"Turns\";\n CountFlags[CountFlags[\"CountStartOnly\"] = 4] = \"CountStartOnly\";\n })(CountFlags = Container.CountFlags || (Container.CountFlags = {}));\n})(Container || (exports.Container = Container = {}));\n//# sourceMappingURL=Container.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ControlCommand = void 0;\nconst Object_1 = require(\"./Object\");\nclass ControlCommand extends Object_1.InkObject {\n get commandType() {\n return this._commandType;\n }\n constructor(commandType = ControlCommand.CommandType.NotSet) {\n super();\n this._commandType = commandType;\n }\n Copy() {\n return new ControlCommand(this.commandType);\n }\n static EvalStart() {\n return new ControlCommand(ControlCommand.CommandType.EvalStart);\n }\n static EvalOutput() {\n return new ControlCommand(ControlCommand.CommandType.EvalOutput);\n }\n static EvalEnd() {\n return new ControlCommand(ControlCommand.CommandType.EvalEnd);\n }\n static Duplicate() {\n return new ControlCommand(ControlCommand.CommandType.Duplicate);\n }\n static PopEvaluatedValue() {\n return new ControlCommand(ControlCommand.CommandType.PopEvaluatedValue);\n }\n static PopFunction() {\n return new ControlCommand(ControlCommand.CommandType.PopFunction);\n }\n static PopTunnel() {\n return new ControlCommand(ControlCommand.CommandType.PopTunnel);\n }\n static BeginString() {\n return new ControlCommand(ControlCommand.CommandType.BeginString);\n }\n static EndString() {\n return new ControlCommand(ControlCommand.CommandType.EndString);\n }\n static NoOp() {\n return new ControlCommand(ControlCommand.CommandType.NoOp);\n }\n static ChoiceCount() {\n return new ControlCommand(ControlCommand.CommandType.ChoiceCount);\n }\n static Turns() {\n return new ControlCommand(ControlCommand.CommandType.Turns);\n }\n static TurnsSince() {\n return new ControlCommand(ControlCommand.CommandType.TurnsSince);\n }\n static ReadCount() {\n return new ControlCommand(ControlCommand.CommandType.ReadCount);\n }\n static Random() {\n return new ControlCommand(ControlCommand.CommandType.Random);\n }\n static SeedRandom() {\n return new ControlCommand(ControlCommand.CommandType.SeedRandom);\n }\n static VisitIndex() {\n return new ControlCommand(ControlCommand.CommandType.VisitIndex);\n }\n static SequenceShuffleIndex() {\n return new ControlCommand(ControlCommand.CommandType.SequenceShuffleIndex);\n }\n static StartThread() {\n return new ControlCommand(ControlCommand.CommandType.StartThread);\n }\n static Done() {\n return new ControlCommand(ControlCommand.CommandType.Done);\n }\n static End() {\n return new ControlCommand(ControlCommand.CommandType.End);\n }\n static ListFromInt() {\n return new ControlCommand(ControlCommand.CommandType.ListFromInt);\n }\n static ListRange() {\n return new ControlCommand(ControlCommand.CommandType.ListRange);\n }\n static ListRandom() {\n return new ControlCommand(ControlCommand.CommandType.ListRandom);\n }\n static BeginTag() {\n return new ControlCommand(ControlCommand.CommandType.BeginTag);\n }\n static EndTag() {\n return new ControlCommand(ControlCommand.CommandType.EndTag);\n }\n toString() {\n return \"ControlCommand \" + this.commandType.toString();\n }\n}\nexports.ControlCommand = ControlCommand;\n(function (ControlCommand) {\n let CommandType;\n (function (CommandType) {\n CommandType[CommandType[\"NotSet\"] = -1] = \"NotSet\";\n CommandType[CommandType[\"EvalStart\"] = 0] = \"EvalStart\";\n CommandType[CommandType[\"EvalOutput\"] = 1] = \"EvalOutput\";\n CommandType[CommandType[\"EvalEnd\"] = 2] = \"EvalEnd\";\n CommandType[CommandType[\"Duplicate\"] = 3] = \"Duplicate\";\n CommandType[CommandType[\"PopEvaluatedValue\"] = 4] = \"PopEvaluatedValue\";\n CommandType[CommandType[\"PopFunction\"] = 5] = \"PopFunction\";\n CommandType[CommandType[\"PopTunnel\"] = 6] = \"PopTunnel\";\n CommandType[CommandType[\"BeginString\"] = 7] = \"BeginString\";\n CommandType[CommandType[\"EndString\"] = 8] = \"EndString\";\n CommandType[CommandType[\"NoOp\"] = 9] = \"NoOp\";\n CommandType[CommandType[\"ChoiceCount\"] = 10] = \"ChoiceCount\";\n CommandType[CommandType[\"Turns\"] = 11] = \"Turns\";\n CommandType[CommandType[\"TurnsSince\"] = 12] = \"TurnsSince\";\n CommandType[CommandType[\"ReadCount\"] = 13] = \"ReadCount\";\n CommandType[CommandType[\"Random\"] = 14] = \"Random\";\n CommandType[CommandType[\"SeedRandom\"] = 15] = \"SeedRandom\";\n CommandType[CommandType[\"VisitIndex\"] = 16] = \"VisitIndex\";\n CommandType[CommandType[\"SequenceShuffleIndex\"] = 17] = \"SequenceShuffleIndex\";\n CommandType[CommandType[\"StartThread\"] = 18] = \"StartThread\";\n CommandType[CommandType[\"Done\"] = 19] = \"Done\";\n CommandType[CommandType[\"End\"] = 20] = \"End\";\n CommandType[CommandType[\"ListFromInt\"] = 21] = \"ListFromInt\";\n CommandType[CommandType[\"ListRange\"] = 22] = \"ListRange\";\n CommandType[CommandType[\"ListRandom\"] = 23] = \"ListRandom\";\n CommandType[CommandType[\"BeginTag\"] = 24] = \"BeginTag\";\n CommandType[CommandType[\"EndTag\"] = 25] = \"EndTag\";\n CommandType[CommandType[\"TOTAL_VALUES\"] = 26] = \"TOTAL_VALUES\";\n })(CommandType = ControlCommand.CommandType || (ControlCommand.CommandType = {}));\n})(ControlCommand || (exports.ControlCommand = ControlCommand = {}));\n//# sourceMappingURL=ControlCommand.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Expression = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../../engine/ControlCommand\");\nconst Object_1 = require(\"../Object\");\nclass Expression extends Object_1.ParsedObject {\n constructor() {\n super(...arguments);\n this._prototypeRuntimeConstantExpression = null;\n this.outputWhenComplete = false;\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n // Tell Runtime to start evaluating the following content as an expression\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n this.GenerateIntoContainer(container);\n // Tell Runtime to output the result of the expression evaluation to the output stream\n if (this.outputWhenComplete) {\n container.AddContent(ControlCommand_1.ControlCommand.EvalOutput());\n }\n // Tell Runtime to stop evaluating the content as an expression\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n return container;\n };\n // When generating the value of a constant expression,\n // we can't just keep generating the same constant expression into\n // different places where the constant value is referenced, since then\n // the same runtime objects would be used in multiple places, which\n // is impossible since each runtime object should have one parent.\n // Instead, we generate a prototype of the runtime object(s), then\n // copy them each time they're used.\n this.GenerateConstantIntoContainer = (container) => {\n if (this._prototypeRuntimeConstantExpression === null) {\n this._prototypeRuntimeConstantExpression = new Container_1.Container();\n this.GenerateIntoContainer(this._prototypeRuntimeConstantExpression);\n }\n for (const runtimeObj of this._prototypeRuntimeConstantExpression.content) {\n const copy = runtimeObj.Copy();\n if (copy) {\n container.AddContent(copy);\n }\n }\n };\n this.toString = () => \"No string value in JavaScript.\";\n }\n get typeName() {\n return \"Expression\";\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Equals(obj) {\n return false;\n }\n}\nexports.Expression = Expression;\n//# sourceMappingURL=Expression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Void = void 0;\nconst Object_1 = require(\"./Object\");\nclass Void extends Object_1.InkObject {\n toString() {\n return \"Void\";\n }\n}\nexports.Void = Void;\n//# sourceMappingURL=Void.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.NativeFunctionCall = void 0;\nconst Value_1 = require(\"./Value\");\nconst StoryException_1 = require(\"./StoryException\");\nconst Void_1 = require(\"./Void\");\nconst InkList_1 = require(\"./InkList\");\nconst Object_1 = require(\"./Object\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst NullException_1 = require(\"./NullException\");\nclass NativeFunctionCall extends Object_1.InkObject {\n static CallWithName(functionName) {\n return new NativeFunctionCall(functionName);\n }\n static CallExistsWithName(functionName) {\n this.GenerateNativeFunctionsIfNecessary();\n return this._nativeFunctions.get(functionName);\n }\n get name() {\n if (this._name === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall._name\");\n return this._name;\n }\n set name(value) {\n this._name = value;\n if (!this._isPrototype) {\n if (NativeFunctionCall._nativeFunctions === null)\n (0, NullException_1.throwNullException)(\"NativeFunctionCall._nativeFunctions\");\n else\n this._prototype =\n NativeFunctionCall._nativeFunctions.get(this._name) || null;\n }\n }\n get numberOfParameters() {\n if (this._prototype) {\n return this._prototype.numberOfParameters;\n }\n else {\n return this._numberOfParameters;\n }\n }\n set numberOfParameters(value) {\n this._numberOfParameters = value;\n }\n Call(parameters) {\n if (this._prototype) {\n return this._prototype.Call(parameters);\n }\n if (this.numberOfParameters != parameters.length) {\n throw new Error(\"Unexpected number of parameters\");\n }\n let hasList = false;\n for (let p of parameters) {\n if (p instanceof Void_1.Void)\n throw new StoryException_1.StoryException(\"Attempting to perform \" +\n this.name +\n ' on a void value. Did you forget to \"return\" a value from a function you called here?');\n if (p instanceof Value_1.ListValue)\n hasList = true;\n }\n if (parameters.length == 2 && hasList) {\n return this.CallBinaryListOperation(parameters);\n }\n let coercedParams = this.CoerceValuesToSingleType(parameters);\n let coercedType = coercedParams[0].valueType;\n if (coercedType == Value_1.ValueType.Int) {\n return this.CallType(coercedParams);\n }\n else if (coercedType == Value_1.ValueType.Float) {\n return this.CallType(coercedParams);\n }\n else if (coercedType == Value_1.ValueType.String) {\n return this.CallType(coercedParams);\n }\n else if (coercedType == Value_1.ValueType.DivertTarget) {\n return this.CallType(coercedParams);\n }\n else if (coercedType == Value_1.ValueType.List) {\n return this.CallType(coercedParams);\n }\n return null;\n }\n CallType(parametersOfSingleType) {\n let param1 = (0, TypeAssertion_1.asOrThrows)(parametersOfSingleType[0], Value_1.Value);\n let valType = param1.valueType;\n let val1 = param1;\n let paramCount = parametersOfSingleType.length;\n if (paramCount == 2 || paramCount == 1) {\n if (this._operationFuncs === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall._operationFuncs\");\n let opForTypeObj = this._operationFuncs.get(valType);\n if (!opForTypeObj) {\n const key = Value_1.ValueType[valType];\n throw new StoryException_1.StoryException(\"Cannot perform operation \" + this.name + \" on \" + key);\n }\n if (paramCount == 2) {\n let param2 = (0, TypeAssertion_1.asOrThrows)(parametersOfSingleType[1], Value_1.Value);\n let val2 = param2;\n let opForType = opForTypeObj;\n if (val1.value === null || val2.value === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.Call BinaryOp values\");\n let resultVal = opForType(val1.value, val2.value);\n return Value_1.Value.Create(resultVal);\n }\n else {\n let opForType = opForTypeObj;\n if (val1.value === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.Call UnaryOp value\");\n let resultVal = opForType(val1.value);\n // This code is different from upstream. Since JavaScript treats\n // integers and floats as the same numbers, it's impossible\n // to force an number to be either an integer or a float.\n //\n // It can be useful to force a specific number type\n // (especially for divisions), so the result of INT() & FLOAT()\n // is coerced to the the proper value type.\n //\n // Note that we also force all other unary operation to\n // return the same value type, although this is only\n // meaningful for numbers. See `Value.Create`.\n if (this.name === NativeFunctionCall.Int) {\n return Value_1.Value.Create(resultVal, Value_1.ValueType.Int);\n }\n else if (this.name === NativeFunctionCall.Float) {\n return Value_1.Value.Create(resultVal, Value_1.ValueType.Float);\n }\n else {\n return Value_1.Value.Create(resultVal, param1.valueType);\n }\n }\n }\n else {\n throw new Error(\"Unexpected number of parameters to NativeFunctionCall: \" +\n parametersOfSingleType.length);\n }\n }\n CallBinaryListOperation(parameters) {\n if ((this.name == \"+\" || this.name == \"-\") &&\n parameters[0] instanceof Value_1.ListValue &&\n parameters[1] instanceof Value_1.IntValue)\n return this.CallListIncrementOperation(parameters);\n let v1 = (0, TypeAssertion_1.asOrThrows)(parameters[0], Value_1.Value);\n let v2 = (0, TypeAssertion_1.asOrThrows)(parameters[1], Value_1.Value);\n if ((this.name == \"&&\" || this.name == \"||\") &&\n (v1.valueType != Value_1.ValueType.List || v2.valueType != Value_1.ValueType.List)) {\n if (this._operationFuncs === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall._operationFuncs\");\n let op = this._operationFuncs.get(Value_1.ValueType.Int);\n if (op === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.CallBinaryListOperation op\");\n let result = (0, TypeAssertion_1.asBooleanOrThrows)(op(v1.isTruthy ? 1 : 0, v2.isTruthy ? 1 : 0));\n return new Value_1.BoolValue(result);\n }\n if (v1.valueType == Value_1.ValueType.List && v2.valueType == Value_1.ValueType.List)\n return this.CallType([v1, v2]);\n throw new StoryException_1.StoryException(\"Can not call use \" +\n this.name +\n \" operation on \" +\n Value_1.ValueType[v1.valueType] +\n \" and \" +\n Value_1.ValueType[v2.valueType]);\n }\n CallListIncrementOperation(listIntParams) {\n let listVal = (0, TypeAssertion_1.asOrThrows)(listIntParams[0], Value_1.ListValue);\n let intVal = (0, TypeAssertion_1.asOrThrows)(listIntParams[1], Value_1.IntValue);\n let resultInkList = new InkList_1.InkList();\n if (listVal.value === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.CallListIncrementOperation listVal.value\");\n for (let [listItemKey, listItemValue] of listVal.value) {\n let listItem = InkList_1.InkListItem.fromSerializedKey(listItemKey);\n if (this._operationFuncs === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall._operationFuncs\");\n let intOp = this._operationFuncs.get(Value_1.ValueType.Int);\n if (intVal.value === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.CallListIncrementOperation intVal.value\");\n let targetInt = intOp(listItemValue, intVal.value);\n let itemOrigin = null;\n if (listVal.value.origins === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.CallListIncrementOperation listVal.value.origins\");\n for (let origin of listVal.value.origins) {\n if (origin.name == listItem.originName) {\n itemOrigin = origin;\n break;\n }\n }\n if (itemOrigin != null) {\n let incrementedItem = itemOrigin.TryGetItemWithValue(targetInt, InkList_1.InkListItem.Null);\n if (incrementedItem.exists)\n resultInkList.Add(incrementedItem.result, targetInt);\n }\n }\n return new Value_1.ListValue(resultInkList);\n }\n CoerceValuesToSingleType(parametersIn) {\n let valType = Value_1.ValueType.Int;\n let specialCaseList = null;\n for (let obj of parametersIn) {\n let val = (0, TypeAssertion_1.asOrThrows)(obj, Value_1.Value);\n if (val.valueType > valType) {\n valType = val.valueType;\n }\n if (val.valueType == Value_1.ValueType.List) {\n specialCaseList = (0, TypeAssertion_1.asOrNull)(val, Value_1.ListValue);\n }\n }\n let parametersOut = [];\n if (Value_1.ValueType[valType] == Value_1.ValueType[Value_1.ValueType.List]) {\n for (let inkObjectVal of parametersIn) {\n let val = (0, TypeAssertion_1.asOrThrows)(inkObjectVal, Value_1.Value);\n if (val.valueType == Value_1.ValueType.List) {\n parametersOut.push(val);\n }\n else if (val.valueType == Value_1.ValueType.Int) {\n let intVal = parseInt(val.valueObject);\n specialCaseList = (0, TypeAssertion_1.asOrThrows)(specialCaseList, Value_1.ListValue);\n if (specialCaseList.value === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.CoerceValuesToSingleType specialCaseList.value\");\n let list = specialCaseList.value.originOfMaxItem;\n if (list === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall.CoerceValuesToSingleType list\");\n let item = list.TryGetItemWithValue(intVal, InkList_1.InkListItem.Null);\n if (item.exists) {\n let castedValue = new Value_1.ListValue(item.result, intVal);\n parametersOut.push(castedValue);\n }\n else\n throw new StoryException_1.StoryException(\"Could not find List item with the value \" +\n intVal +\n \" in \" +\n list.name);\n }\n else {\n const key = Value_1.ValueType[val.valueType];\n throw new StoryException_1.StoryException(\"Cannot mix Lists and \" + key + \" values in this operation\");\n }\n }\n }\n else {\n for (let inkObjectVal of parametersIn) {\n let val = (0, TypeAssertion_1.asOrThrows)(inkObjectVal, Value_1.Value);\n let castedValue = val.Cast(valType);\n parametersOut.push(castedValue);\n }\n }\n return parametersOut;\n }\n constructor() {\n super();\n this._name = null;\n this._numberOfParameters = 0;\n this._prototype = null;\n this._isPrototype = false;\n this._operationFuncs = null;\n if (arguments.length === 0) {\n NativeFunctionCall.GenerateNativeFunctionsIfNecessary();\n }\n else if (arguments.length === 1) {\n let name = arguments[0];\n NativeFunctionCall.GenerateNativeFunctionsIfNecessary();\n this.name = name;\n }\n else if (arguments.length === 2) {\n let name = arguments[0];\n let numberOfParameters = arguments[1];\n this._isPrototype = true;\n this.name = name;\n this.numberOfParameters = numberOfParameters;\n }\n }\n static Identity(t) {\n return t;\n }\n static GenerateNativeFunctionsIfNecessary() {\n if (this._nativeFunctions == null) {\n this._nativeFunctions = new Map();\n // Int operations\n this.AddIntBinaryOp(this.Add, (x, y) => x + y);\n this.AddIntBinaryOp(this.Subtract, (x, y) => x - y);\n this.AddIntBinaryOp(this.Multiply, (x, y) => x * y);\n this.AddIntBinaryOp(this.Divide, (x, y) => Math.floor(x / y));\n this.AddIntBinaryOp(this.Mod, (x, y) => x % y);\n this.AddIntUnaryOp(this.Negate, (x) => -x);\n this.AddIntBinaryOp(this.Equal, (x, y) => x == y);\n this.AddIntBinaryOp(this.Greater, (x, y) => x > y);\n this.AddIntBinaryOp(this.Less, (x, y) => x < y);\n this.AddIntBinaryOp(this.GreaterThanOrEquals, (x, y) => x >= y);\n this.AddIntBinaryOp(this.LessThanOrEquals, (x, y) => x <= y);\n this.AddIntBinaryOp(this.NotEquals, (x, y) => x != y);\n this.AddIntUnaryOp(this.Not, (x) => x == 0);\n this.AddIntBinaryOp(this.And, (x, y) => x != 0 && y != 0);\n this.AddIntBinaryOp(this.Or, (x, y) => x != 0 || y != 0);\n this.AddIntBinaryOp(this.Max, (x, y) => Math.max(x, y));\n this.AddIntBinaryOp(this.Min, (x, y) => Math.min(x, y));\n this.AddIntBinaryOp(this.Pow, (x, y) => Math.pow(x, y));\n this.AddIntUnaryOp(this.Floor, NativeFunctionCall.Identity);\n this.AddIntUnaryOp(this.Ceiling, NativeFunctionCall.Identity);\n this.AddIntUnaryOp(this.Int, NativeFunctionCall.Identity);\n this.AddIntUnaryOp(this.Float, (x) => x);\n // Float operations\n this.AddFloatBinaryOp(this.Add, (x, y) => x + y);\n this.AddFloatBinaryOp(this.Subtract, (x, y) => x - y);\n this.AddFloatBinaryOp(this.Multiply, (x, y) => x * y);\n this.AddFloatBinaryOp(this.Divide, (x, y) => x / y);\n this.AddFloatBinaryOp(this.Mod, (x, y) => x % y);\n this.AddFloatUnaryOp(this.Negate, (x) => -x);\n this.AddFloatBinaryOp(this.Equal, (x, y) => x == y);\n this.AddFloatBinaryOp(this.Greater, (x, y) => x > y);\n this.AddFloatBinaryOp(this.Less, (x, y) => x < y);\n this.AddFloatBinaryOp(this.GreaterThanOrEquals, (x, y) => x >= y);\n this.AddFloatBinaryOp(this.LessThanOrEquals, (x, y) => x <= y);\n this.AddFloatBinaryOp(this.NotEquals, (x, y) => x != y);\n this.AddFloatUnaryOp(this.Not, (x) => x == 0.0);\n this.AddFloatBinaryOp(this.And, (x, y) => x != 0.0 && y != 0.0);\n this.AddFloatBinaryOp(this.Or, (x, y) => x != 0.0 || y != 0.0);\n this.AddFloatBinaryOp(this.Max, (x, y) => Math.max(x, y));\n this.AddFloatBinaryOp(this.Min, (x, y) => Math.min(x, y));\n this.AddFloatBinaryOp(this.Pow, (x, y) => Math.pow(x, y));\n this.AddFloatUnaryOp(this.Floor, (x) => Math.floor(x));\n this.AddFloatUnaryOp(this.Ceiling, (x) => Math.ceil(x));\n this.AddFloatUnaryOp(this.Int, (x) => Math.floor(x));\n this.AddFloatUnaryOp(this.Float, NativeFunctionCall.Identity);\n // String operations\n this.AddStringBinaryOp(this.Add, (x, y) => x + y); // concat\n this.AddStringBinaryOp(this.Equal, (x, y) => x === y);\n this.AddStringBinaryOp(this.NotEquals, (x, y) => !(x === y));\n this.AddStringBinaryOp(this.Has, (x, y) => x.includes(y));\n this.AddStringBinaryOp(this.Hasnt, (x, y) => !x.includes(y));\n this.AddListBinaryOp(this.Add, (x, y) => x.Union(y));\n this.AddListBinaryOp(this.Subtract, (x, y) => x.Without(y));\n this.AddListBinaryOp(this.Has, (x, y) => x.Contains(y));\n this.AddListBinaryOp(this.Hasnt, (x, y) => !x.Contains(y));\n this.AddListBinaryOp(this.Intersect, (x, y) => x.Intersect(y));\n this.AddListBinaryOp(this.Equal, (x, y) => x.Equals(y));\n this.AddListBinaryOp(this.Greater, (x, y) => x.GreaterThan(y));\n this.AddListBinaryOp(this.Less, (x, y) => x.LessThan(y));\n this.AddListBinaryOp(this.GreaterThanOrEquals, (x, y) => x.GreaterThanOrEquals(y));\n this.AddListBinaryOp(this.LessThanOrEquals, (x, y) => x.LessThanOrEquals(y));\n this.AddListBinaryOp(this.NotEquals, (x, y) => !x.Equals(y));\n this.AddListBinaryOp(this.And, (x, y) => x.Count > 0 && y.Count > 0);\n this.AddListBinaryOp(this.Or, (x, y) => x.Count > 0 || y.Count > 0);\n this.AddListUnaryOp(this.Not, (x) => (x.Count == 0 ? 1 : 0));\n this.AddListUnaryOp(this.Invert, (x) => x.inverse);\n this.AddListUnaryOp(this.All, (x) => x.all);\n this.AddListUnaryOp(this.ListMin, (x) => x.MinAsList());\n this.AddListUnaryOp(this.ListMax, (x) => x.MaxAsList());\n this.AddListUnaryOp(this.Count, (x) => x.Count);\n this.AddListUnaryOp(this.ValueOfList, (x) => x.maxItem.Value);\n let divertTargetsEqual = (d1, d2) => d1.Equals(d2);\n let divertTargetsNotEqual = (d1, d2) => !d1.Equals(d2);\n this.AddOpToNativeFunc(this.Equal, 2, Value_1.ValueType.DivertTarget, divertTargetsEqual);\n this.AddOpToNativeFunc(this.NotEquals, 2, Value_1.ValueType.DivertTarget, divertTargetsNotEqual);\n }\n }\n AddOpFuncForType(valType, op) {\n if (this._operationFuncs == null) {\n this._operationFuncs = new Map();\n }\n this._operationFuncs.set(valType, op);\n }\n static AddOpToNativeFunc(name, args, valType, op) {\n if (this._nativeFunctions === null)\n return (0, NullException_1.throwNullException)(\"NativeFunctionCall._nativeFunctions\");\n let nativeFunc = this._nativeFunctions.get(name);\n if (!nativeFunc) {\n nativeFunc = new NativeFunctionCall(name, args);\n this._nativeFunctions.set(name, nativeFunc);\n }\n nativeFunc.AddOpFuncForType(valType, op);\n }\n static AddIntBinaryOp(name, op) {\n this.AddOpToNativeFunc(name, 2, Value_1.ValueType.Int, op);\n }\n static AddIntUnaryOp(name, op) {\n this.AddOpToNativeFunc(name, 1, Value_1.ValueType.Int, op);\n }\n static AddFloatBinaryOp(name, op) {\n this.AddOpToNativeFunc(name, 2, Value_1.ValueType.Float, op);\n }\n static AddFloatUnaryOp(name, op) {\n this.AddOpToNativeFunc(name, 1, Value_1.ValueType.Float, op);\n }\n static AddStringBinaryOp(name, op) {\n this.AddOpToNativeFunc(name, 2, Value_1.ValueType.String, op);\n }\n static AddListBinaryOp(name, op) {\n this.AddOpToNativeFunc(name, 2, Value_1.ValueType.List, op);\n }\n static AddListUnaryOp(name, op) {\n this.AddOpToNativeFunc(name, 1, Value_1.ValueType.List, op);\n }\n toString() {\n return 'Native \"' + this.name + '\"';\n }\n}\nexports.NativeFunctionCall = NativeFunctionCall;\nNativeFunctionCall.Add = \"+\";\nNativeFunctionCall.Subtract = \"-\";\nNativeFunctionCall.Divide = \"/\";\nNativeFunctionCall.Multiply = \"*\";\nNativeFunctionCall.Mod = \"%\";\nNativeFunctionCall.Negate = \"_\";\nNativeFunctionCall.Equal = \"==\";\nNativeFunctionCall.Greater = \">\";\nNativeFunctionCall.Less = \"<\";\nNativeFunctionCall.GreaterThanOrEquals = \">=\";\nNativeFunctionCall.LessThanOrEquals = \"<=\";\nNativeFunctionCall.NotEquals = \"!=\";\nNativeFunctionCall.Not = \"!\";\nNativeFunctionCall.And = \"&&\";\nNativeFunctionCall.Or = \"||\";\nNativeFunctionCall.Min = \"MIN\";\nNativeFunctionCall.Max = \"MAX\";\nNativeFunctionCall.Pow = \"POW\";\nNativeFunctionCall.Floor = \"FLOOR\";\nNativeFunctionCall.Ceiling = \"CEILING\";\nNativeFunctionCall.Int = \"INT\";\nNativeFunctionCall.Float = \"FLOAT\";\nNativeFunctionCall.Has = \"?\";\nNativeFunctionCall.Hasnt = \"!?\";\nNativeFunctionCall.Intersect = \"^\";\nNativeFunctionCall.ListMin = \"LIST_MIN\";\nNativeFunctionCall.ListMax = \"LIST_MAX\";\nNativeFunctionCall.All = \"LIST_ALL\";\nNativeFunctionCall.Count = \"LIST_COUNT\";\nNativeFunctionCall.ValueOfList = \"LIST_VALUE\";\nNativeFunctionCall.Invert = \"LIST_INVERT\";\nNativeFunctionCall._nativeFunctions = null;\n//# sourceMappingURL=NativeFunctionCall.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.NumberExpression = void 0;\nconst Expression_1 = require(\"./Expression\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\n// This class is named Number in the C# codebase\n// but this conflict with the built-in Number class\nclass NumberExpression extends Expression_1.Expression {\n constructor(value, subtype) {\n super();\n this.isInt = () => this.subtype == \"int\";\n this.isFloat = () => this.subtype == \"float\";\n this.isBool = () => this.subtype == \"bool\";\n this.GenerateIntoContainer = (container) => {\n if (this.isInt()) {\n container.AddContent(new Value_1.IntValue(this.value));\n }\n else if (this.isFloat()) {\n container.AddContent(new Value_1.FloatValue(this.value));\n }\n else if (this.isBool()) {\n container.AddContent(new Value_1.BoolValue(this.value));\n }\n };\n this.toString = () => String(this.value);\n if ((typeof value === \"number\" && !Number.isNaN(value)) ||\n typeof value == \"boolean\") {\n this.value = value;\n this.subtype = subtype;\n }\n else {\n throw new Error(\"Unexpected object type in NumberExpression.\");\n }\n }\n get typeName() {\n return \"Number\";\n }\n Equals(obj) {\n const numberExpression = (0, TypeAssertion_1.asOrNull)(obj, NumberExpression);\n if (!numberExpression)\n return false;\n return (numberExpression.subtype == this.subtype &&\n numberExpression.value == this.value);\n }\n}\nexports.NumberExpression = NumberExpression;\n//# sourceMappingURL=NumberExpression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.UnaryExpression = void 0;\nconst Expression_1 = require(\"./Expression\");\nconst NativeFunctionCall_1 = require(\"../../../../engine/NativeFunctionCall\");\nconst NumberExpression_1 = require(\"./NumberExpression\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass UnaryExpression extends Expression_1.Expression {\n get nativeNameForOp() {\n // Replace \"-\" with \"_\" to make it unique (compared to subtraction)\n if (this.op === \"-\") {\n return \"_\";\n }\n else if (this.op === \"not\") {\n return \"!\";\n }\n return this.op;\n }\n constructor(inner, op) {\n super();\n this.op = op;\n this.GenerateIntoContainer = (container) => {\n this.innerExpression.GenerateIntoContainer(container);\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(this.nativeNameForOp));\n };\n this.toString = () => this.nativeNameForOp + this.innerExpression;\n this.innerExpression = this.AddContent(inner);\n }\n get typeName() {\n return \"UnaryExpression\";\n }\n}\nexports.UnaryExpression = UnaryExpression;\n// Attempt to flatten inner expression immediately\n// e.g. convert (-(5)) into (-5)\nUnaryExpression.WithInner = (inner, op) => {\n const innerNumber = (0, TypeAssertion_1.asOrNull)(inner, NumberExpression_1.NumberExpression);\n if (innerNumber) {\n if (op === \"-\") {\n if (innerNumber.isInt()) {\n return new NumberExpression_1.NumberExpression(-innerNumber.value, \"int\");\n }\n else if (innerNumber.isFloat()) {\n return new NumberExpression_1.NumberExpression(-innerNumber.value, \"float\");\n }\n }\n else if (op == \"!\" || op == \"not\") {\n if (innerNumber.isInt()) {\n return new NumberExpression_1.NumberExpression(innerNumber.value == 0, \"bool\");\n }\n else if (innerNumber.isFloat()) {\n return new NumberExpression_1.NumberExpression(innerNumber.value == 0.0, \"bool\");\n }\n else if (innerNumber.isBool()) {\n return new NumberExpression_1.NumberExpression(!innerNumber.value, \"bool\");\n }\n }\n throw new Error(\"Unexpected operation or number type\");\n }\n // Normal fallback\n const unary = new UnaryExpression(inner, op);\n return unary;\n};\n//# sourceMappingURL=UnaryExpression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.BinaryExpression = void 0;\nconst Expression_1 = require(\"./Expression\");\nconst NativeFunctionCall_1 = require(\"../../../../engine/NativeFunctionCall\");\nconst UnaryExpression_1 = require(\"./UnaryExpression\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass BinaryExpression extends Expression_1.Expression {\n constructor(left, right, opName) {\n super();\n this.opName = opName;\n this.GenerateIntoContainer = (container) => {\n this.leftExpression.GenerateIntoContainer(container);\n this.rightExpression.GenerateIntoContainer(container);\n this.opName = this.NativeNameForOp(this.opName);\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(this.opName));\n };\n this.NativeNameForOp = (opName) => {\n if (opName === \"and\") {\n return \"&&\";\n }\n else if (opName === \"or\") {\n return \"||\";\n }\n else if (opName === \"mod\") {\n return \"%\";\n }\n else if (opName === \"has\") {\n return \"?\";\n }\n else if (opName === \"hasnt\") {\n return \"!?\";\n }\n return opName;\n };\n this.toString = () => `(${this.leftExpression} ${this.opName} ${this.rightExpression})`;\n this.leftExpression = this.AddContent(left);\n this.rightExpression = this.AddContent(right);\n this.opName = opName;\n }\n get typeName() {\n return \"BinaryExpression\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n // Check for the following case:\n //\n // (not A) ? B\n //\n // Since this easy to accidentally do:\n //\n // not A ? B\n //\n // when you intend:\n //\n // not (A ? B)\n if (this.NativeNameForOp(this.opName) === \"?\") {\n const leftUnary = (0, TypeAssertion_1.asOrNull)(this.leftExpression, UnaryExpression_1.UnaryExpression);\n if (leftUnary !== null &&\n (leftUnary.op === \"not\" || leftUnary.op === \"!\")) {\n this.Error(`Using 'not' or '!' here negates '${leftUnary.innerExpression}' rather than the result of the '?' or 'has' operator. You need to add parentheses around the (A ? B) expression.`);\n }\n }\n }\n}\nexports.BinaryExpression = BinaryExpression;\n//# sourceMappingURL=BinaryExpression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CharacterSet = void 0;\nclass CharacterSet {\n constructor(arg) {\n this.set = new Set();\n this.Add = (arg) => this.set.add(arg);\n this.AddRange = (start, end) => {\n for (let c = start.charCodeAt(0); c <= end.charCodeAt(0); ++c) {\n this.Add(String.fromCharCode(c));\n }\n return this;\n };\n this.AddCharacters = (chars) => {\n if (typeof chars === \"string\" || Array.isArray(chars)) {\n for (const c of chars) {\n this.Add(c);\n }\n }\n else {\n for (const c of chars.set) {\n this.Add(c);\n }\n }\n return this;\n };\n if (arg) {\n this.AddCharacters(arg);\n }\n }\n}\nexports.CharacterSet = CharacterSet;\nCharacterSet.FromRange = (start, end) => new CharacterSet().AddRange(start, end);\n//# sourceMappingURL=CharacterSet.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CharacterRange = void 0;\nconst CharacterSet_1 = require(\"./CharacterSet\");\n/// <summary>\n/// A class representing a character range. Allows for lazy-loading a corresponding <see cref=\"CharacterSet\">character set</see>.\n/// </summary>\nclass CharacterRange {\n constructor(_start, _end, excludes = []) {\n this._start = _start;\n this._end = _end;\n this._correspondingCharSet = new CharacterSet_1.CharacterSet();\n this._excludes = new Set();\n /// <summary>\n /// Returns a <see cref=\"CharacterSet\">character set</see> instance corresponding to the character range\n /// represented by the current instance.\n /// </summary>\n /// <remarks>\n /// The internal character set is created once and cached in memory.\n /// </remarks>\n /// <returns>The char set.</returns>\n this.ToCharacterSet = () => {\n if (this._correspondingCharSet.set.size === 0) {\n for (let ii = this.start.charCodeAt(0), c; ii <= this.end.charCodeAt(0); ii += 1) {\n c = String.fromCharCode(ii);\n if (!this._excludes.has(c)) {\n this._correspondingCharSet.AddCharacters(c);\n }\n }\n }\n return this._correspondingCharSet;\n };\n if (excludes instanceof CharacterSet_1.CharacterSet) {\n this._excludes = excludes.set;\n }\n else {\n for (const item of excludes) {\n this._excludes.add(item);\n }\n }\n }\n get start() {\n return this._start;\n }\n get end() {\n return this._end;\n }\n}\nexports.CharacterRange = CharacterRange;\nCharacterRange.Define = (start, end, excludes = []) => new CharacterRange(start, end, excludes);\n//# sourceMappingURL=CharacterRange.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ChoicePoint = void 0;\nconst Object_1 = require(\"./Object\");\nconst Path_1 = require(\"./Path\");\nconst NullException_1 = require(\"./NullException\");\nclass ChoicePoint extends Object_1.InkObject {\n constructor(onceOnly = true) {\n super();\n this._pathOnChoice = null;\n this.hasCondition = false;\n this.hasStartContent = false;\n this.hasChoiceOnlyContent = false;\n this.isInvisibleDefault = false;\n this.onceOnly = true;\n this.onceOnly = onceOnly;\n }\n get pathOnChoice() {\n if (this._pathOnChoice != null && this._pathOnChoice.isRelative) {\n let choiceTargetObj = this.choiceTarget;\n if (choiceTargetObj) {\n this._pathOnChoice = choiceTargetObj.path;\n }\n }\n return this._pathOnChoice;\n }\n set pathOnChoice(value) {\n this._pathOnChoice = value;\n }\n get choiceTarget() {\n if (this._pathOnChoice === null)\n return (0, NullException_1.throwNullException)(\"ChoicePoint._pathOnChoice\");\n return this.ResolvePath(this._pathOnChoice).container;\n }\n get pathStringOnChoice() {\n if (this.pathOnChoice === null)\n return (0, NullException_1.throwNullException)(\"ChoicePoint.pathOnChoice\");\n return this.CompactPathString(this.pathOnChoice);\n }\n set pathStringOnChoice(value) {\n this.pathOnChoice = new Path_1.Path(value);\n }\n get flags() {\n let flags = 0;\n if (this.hasCondition)\n flags |= 1;\n if (this.hasStartContent)\n flags |= 2;\n if (this.hasChoiceOnlyContent)\n flags |= 4;\n if (this.isInvisibleDefault)\n flags |= 8;\n if (this.onceOnly)\n flags |= 16;\n return flags;\n }\n set flags(value) {\n this.hasCondition = (value & 1) > 0;\n this.hasStartContent = (value & 2) > 0;\n this.hasChoiceOnlyContent = (value & 4) > 0;\n this.isInvisibleDefault = (value & 8) > 0;\n this.onceOnly = (value & 16) > 0;\n }\n toString() {\n if (this.pathOnChoice === null)\n return (0, NullException_1.throwNullException)(\"ChoicePoint.pathOnChoice\");\n // int? targetLineNum = DebugLineNumberOfPath (pathOnChoice);\n let targetLineNum = null;\n let targetString = this.pathOnChoice.toString();\n if (targetLineNum != null) {\n targetString = \" line \" + targetLineNum + \"(\" + targetString + \")\";\n }\n return \"Choice: -> \" + targetString;\n }\n}\nexports.ChoicePoint = ChoicePoint;\n//# sourceMappingURL=ChoicePoint.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PushPopType = void 0;\nvar PushPopType;\n(function (PushPopType) {\n PushPopType[PushPopType[\"Tunnel\"] = 0] = \"Tunnel\";\n PushPopType[PushPopType[\"Function\"] = 1] = \"Function\";\n PushPopType[PushPopType[\"FunctionEvaluationFromGame\"] = 2] = \"FunctionEvaluationFromGame\";\n})(PushPopType || (exports.PushPopType = PushPopType = {}));\n//# sourceMappingURL=PushPop.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Pointer = void 0;\nconst Path_1 = require(\"./Path\");\nclass Pointer {\n constructor() {\n this.container = null;\n this.index = -1;\n if (arguments.length === 2) {\n this.container = arguments[0];\n this.index = arguments[1];\n }\n }\n Resolve() {\n if (this.index < 0)\n return this.container;\n if (this.container == null)\n return null;\n if (this.container.content.length == 0)\n return this.container;\n if (this.index >= this.container.content.length)\n return null;\n return this.container.content[this.index];\n }\n get isNull() {\n return this.container == null;\n }\n get path() {\n if (this.isNull)\n return null;\n if (this.index >= 0)\n return this.container.path.PathByAppendingComponent(new Path_1.Path.Component(this.index));\n else\n return this.container.path;\n }\n toString() {\n if (!this.container)\n return \"Ink Pointer (null)\";\n return (\"Ink Pointer -> \" +\n this.container.path.toString() +\n \" -- index \" +\n this.index);\n }\n // This method does not exist in the original C# code, but is here to maintain the\n // value semantics of Pointer.\n copy() {\n return new Pointer(this.container, this.index);\n }\n static StartOf(container) {\n return new Pointer(container, 0);\n }\n static get Null() {\n return new Pointer(null, -1);\n }\n}\nexports.Pointer = Pointer;\n//# sourceMappingURL=Pointer.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Divert = void 0;\nconst Path_1 = require(\"./Path\");\nconst PushPop_1 = require(\"./PushPop\");\nconst StringBuilder_1 = require(\"./StringBuilder\");\nconst Object_1 = require(\"./Object\");\nconst Pointer_1 = require(\"./Pointer\");\nconst Container_1 = require(\"./Container\");\nconst NullException_1 = require(\"./NullException\");\nclass Divert extends Object_1.InkObject {\n get targetPath() {\n if (this._targetPath != null && this._targetPath.isRelative) {\n let targetObj = this.targetPointer.Resolve();\n if (targetObj) {\n this._targetPath = targetObj.path;\n }\n }\n return this._targetPath;\n }\n set targetPath(value) {\n this._targetPath = value;\n this._targetPointer = Pointer_1.Pointer.Null;\n }\n get targetPointer() {\n if (this._targetPointer.isNull) {\n let targetObj = this.ResolvePath(this._targetPath).obj;\n if (this._targetPath === null)\n return (0, NullException_1.throwNullException)(\"this._targetPath\");\n if (this._targetPath.lastComponent === null)\n return (0, NullException_1.throwNullException)(\"this._targetPath.lastComponent\");\n if (this._targetPath.lastComponent.isIndex) {\n if (targetObj === null)\n return (0, NullException_1.throwNullException)(\"targetObj\");\n this._targetPointer.container =\n targetObj.parent instanceof Container_1.Container ? targetObj.parent : null;\n this._targetPointer.index = this._targetPath.lastComponent.index;\n }\n else {\n this._targetPointer = Pointer_1.Pointer.StartOf(targetObj instanceof Container_1.Container ? targetObj : null);\n }\n }\n return this._targetPointer.copy();\n }\n get targetPathString() {\n if (this.targetPath == null)\n return null;\n return this.CompactPathString(this.targetPath);\n }\n set targetPathString(value) {\n if (value == null) {\n this.targetPath = null;\n }\n else {\n this.targetPath = new Path_1.Path(value);\n }\n }\n get hasVariableTarget() {\n return this.variableDivertName != null;\n }\n constructor(stackPushType) {\n super();\n this._targetPath = null;\n this._targetPointer = Pointer_1.Pointer.Null;\n this.variableDivertName = null;\n this.pushesToStack = false;\n this.stackPushType = 0;\n this.isExternal = false;\n this.externalArgs = 0;\n this.isConditional = false;\n this.pushesToStack = false;\n if (typeof stackPushType !== \"undefined\") {\n this.pushesToStack = true;\n this.stackPushType = stackPushType;\n }\n }\n Equals(obj) {\n let otherDivert = obj;\n if (otherDivert instanceof Divert) {\n if (this.hasVariableTarget == otherDivert.hasVariableTarget) {\n if (this.hasVariableTarget) {\n return this.variableDivertName == otherDivert.variableDivertName;\n }\n else {\n if (this.targetPath === null)\n return (0, NullException_1.throwNullException)(\"this.targetPath\");\n return this.targetPath.Equals(otherDivert.targetPath);\n }\n }\n }\n return false;\n }\n toString() {\n if (this.hasVariableTarget) {\n return \"Divert(variable: \" + this.variableDivertName + \")\";\n }\n else if (this.targetPath == null) {\n return \"Divert(null)\";\n }\n else {\n let sb = new StringBuilder_1.StringBuilder();\n let targetStr = this.targetPath.toString();\n // int? targetLineNum = DebugLineNumberOfPath (targetPath);\n let targetLineNum = null;\n if (targetLineNum != null) {\n targetStr = \"line \" + targetLineNum;\n }\n sb.Append(\"Divert\");\n if (this.isConditional)\n sb.Append(\"?\");\n if (this.pushesToStack) {\n if (this.stackPushType == PushPop_1.PushPopType.Function) {\n sb.Append(\" function\");\n }\n else {\n sb.Append(\" tunnel\");\n }\n }\n sb.Append(\" -> \");\n sb.Append(this.targetPathString);\n sb.Append(\" (\");\n sb.Append(targetStr);\n sb.Append(\")\");\n return sb.toString();\n }\n }\n}\nexports.Divert = Divert;\n//# sourceMappingURL=Divert.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SymbolType = void 0;\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Knot\"] = 0] = \"Knot\";\n SymbolType[SymbolType[\"List\"] = 1] = \"List\";\n SymbolType[SymbolType[\"ListItem\"] = 2] = \"ListItem\";\n SymbolType[SymbolType[\"Var\"] = 3] = \"Var\";\n SymbolType[SymbolType[\"SubFlowAndWeave\"] = 4] = \"SubFlowAndWeave\";\n SymbolType[SymbolType[\"Arg\"] = 5] = \"Arg\";\n SymbolType[SymbolType[\"Temp\"] = 6] = \"Temp\";\n})(SymbolType || (exports.SymbolType = SymbolType = {}));\n//# sourceMappingURL=SymbolType.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VariableAssignment = void 0;\nconst Object_1 = require(\"./Object\");\nclass VariableAssignment extends Object_1.InkObject {\n constructor(variableName, isNewDeclaration) {\n super();\n this.variableName = variableName || null;\n this.isNewDeclaration = !!isNewDeclaration;\n this.isGlobal = false;\n }\n toString() {\n return \"VarAssign to \" + this.variableName;\n }\n}\nexports.VariableAssignment = VariableAssignment;\n//# sourceMappingURL=VariableAssignment.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Choice = void 0;\nconst ChoicePoint_1 = require(\"../../../engine/ChoicePoint\");\nconst Container_1 = require(\"../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../engine/ControlCommand\");\nconst Divert_1 = require(\"../../../engine/Divert\");\nconst Value_1 = require(\"../../../engine/Value\");\nconst Object_1 = require(\"./Object\");\nconst SymbolType_1 = require(\"./SymbolType\");\nconst VariableAssignment_1 = require(\"../../../engine/VariableAssignment\");\nclass Choice extends Object_1.ParsedObject {\n get runtimeChoice() {\n if (!this._runtimeChoice) {\n throw new Error();\n }\n return this._runtimeChoice;\n }\n get name() {\n var _a;\n return ((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || null;\n }\n get condition() {\n return this._condition;\n }\n set condition(value) {\n this._condition = value;\n if (value) {\n this.AddContent(value);\n }\n }\n // Required for IWeavePoint interface\n // Choice's target container. Used by weave to append any extra\n // nested weave content into.\n get runtimeContainer() {\n return this._innerContentContainer;\n }\n get innerContentContainer() {\n return this._innerContentContainer;\n }\n get containerForCounting() {\n return this._innerContentContainer;\n }\n // Override runtimePath to point to the Choice's target content (after it's chosen),\n // as opposed to the default implementation which would point to the choice itself\n // (or it's outer container), which is what runtimeObject is.\n get runtimePath() {\n if (!this.innerContentContainer || !this.innerContentContainer.path) {\n throw new Error();\n }\n return this.innerContentContainer.path;\n }\n constructor(startContent, choiceOnlyContent, innerContent) {\n super();\n this._condition = null;\n this._innerContentContainer = null;\n this._outerContainer = null;\n this._runtimeChoice = null;\n this._returnToR1 = null;\n this._returnToR2 = null;\n this._r1Label = null;\n this._r2Label = null;\n this._divertToStartContentOuter = null;\n this._divertToStartContentInner = null;\n this._startContentRuntimeContainer = null;\n this.isInvisibleDefault = false;\n this.hasWeaveStyleInlineBrackets = false;\n this.GenerateRuntimeObject = () => {\n this._outerContainer = new Container_1.Container();\n // Content names for different types of choice:\n // * start content [choice only content] inner content\n // * start content -> divert\n // * start content\n // * [choice only content]\n // Hmm, this structure has become slightly insane!\n //\n // [\n // EvalStart\n // assign $r = $r1 -- return target = return label 1\n // BeginString\n // -> s\n // [(r1)] -- return label 1 (after start content)\n // EndString\n // BeginString\n // ... choice only content\n // EndEval\n // Condition expression\n // choice: -> \"c-0\"\n // (s) = [\n // start content\n // -> r -- goto return label 1 or 2\n // ]\n // ]\n //\n // in parent's container: (the inner content for the choice)\n //\n // (c-0) = [\n // EvalStart\n // assign $r = $r2 -- return target = return label 2\n // EndEval\n // -> s\n // [(r2)] -- return label 1 (after start content)\n // inner content\n // ]\n //\n this._runtimeChoice = new ChoicePoint_1.ChoicePoint(this.onceOnly);\n this._runtimeChoice.isInvisibleDefault = this.isInvisibleDefault;\n if (this.startContent || this.choiceOnlyContent || this.condition) {\n this._outerContainer.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n }\n // Start content is put into a named container that's referenced both\n // when displaying the choice initially, and when generating the text\n // when the choice is chosen.\n if (this.startContent) {\n // Generate start content and return\n // - We can't use a function since it uses a call stack element, which would\n // put temporary values out of scope. Instead we manually divert around.\n // - $r is a variable divert target contains the return point\n this._returnToR1 = new Value_1.DivertTargetValue();\n this._outerContainer.AddContent(this._returnToR1);\n const varAssign = new VariableAssignment_1.VariableAssignment(\"$r\", true);\n this._outerContainer.AddContent(varAssign);\n // Mark the start of the choice text generation, so that the runtime\n // knows where to rewind to to extract the content from the output stream.\n this._outerContainer.AddContent(ControlCommand_1.ControlCommand.BeginString());\n this._divertToStartContentOuter = new Divert_1.Divert();\n this._outerContainer.AddContent(this._divertToStartContentOuter);\n // Start content itself in a named container\n this._startContentRuntimeContainer =\n this.startContent.GenerateRuntimeObject();\n this._startContentRuntimeContainer.name = \"s\";\n // Effectively, the \"return\" statement - return to the point specified by $r\n const varDivert = new Divert_1.Divert();\n varDivert.variableDivertName = \"$r\";\n this._startContentRuntimeContainer.AddContent(varDivert);\n // Add the container\n this._outerContainer.AddToNamedContentOnly(this._startContentRuntimeContainer);\n // This is the label to return to\n this._r1Label = new Container_1.Container();\n this._r1Label.name = \"$r1\";\n this._outerContainer.AddContent(this._r1Label);\n this._outerContainer.AddContent(ControlCommand_1.ControlCommand.EndString());\n this._runtimeChoice.hasStartContent = true;\n }\n // Choice only content - mark the start, then generate it directly into the outer container\n if (this.choiceOnlyContent) {\n this._outerContainer.AddContent(ControlCommand_1.ControlCommand.BeginString());\n const choiceOnlyRuntimeContent = this.choiceOnlyContent.GenerateRuntimeObject();\n this._outerContainer.AddContentsOfContainer(choiceOnlyRuntimeContent);\n this._outerContainer.AddContent(ControlCommand_1.ControlCommand.EndString());\n this._runtimeChoice.hasChoiceOnlyContent = true;\n }\n // Generate any condition for this choice\n if (this.condition) {\n this.condition.GenerateIntoContainer(this._outerContainer);\n this._runtimeChoice.hasCondition = true;\n }\n if (this.startContent || this.choiceOnlyContent || this.condition) {\n this._outerContainer.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n }\n // Add choice itself\n this._outerContainer.AddContent(this._runtimeChoice);\n // Container that choice points to for when it's chosen\n this._innerContentContainer = new Container_1.Container();\n // Repeat start content by diverting to its container\n if (this.startContent) {\n // Set the return point when jumping back into the start content\n // - In this case, it's the $r2 point, within the choice content \"c\".\n this._returnToR2 = new Value_1.DivertTargetValue();\n this._innerContentContainer.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n this._innerContentContainer.AddContent(this._returnToR2);\n this._innerContentContainer.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n const varAssign = new VariableAssignment_1.VariableAssignment(\"$r\", true);\n this._innerContentContainer.AddContent(varAssign);\n // Main divert into start content\n this._divertToStartContentInner = new Divert_1.Divert();\n this._innerContentContainer.AddContent(this._divertToStartContentInner);\n // Define label to return to\n this._r2Label = new Container_1.Container();\n this._r2Label.name = \"$r2\";\n this._innerContentContainer.AddContent(this._r2Label);\n }\n // Choice's own inner content\n if (this.innerContent) {\n const innerChoiceOnlyContent = this.innerContent.GenerateRuntimeObject();\n this._innerContentContainer.AddContentsOfContainer(innerChoiceOnlyContent);\n }\n if (this.story.countAllVisits) {\n this._innerContentContainer.visitsShouldBeCounted = true;\n }\n this._innerContentContainer.countingAtStartOnly = true;\n return this._outerContainer;\n };\n this.toString = () => {\n if (this.choiceOnlyContent !== null) {\n return `* ${this.startContent}[${this.choiceOnlyContent}]...`;\n }\n return `* ${this.startContent}...`;\n };\n this.startContent = startContent;\n this.choiceOnlyContent = choiceOnlyContent;\n this.innerContent = innerContent;\n this.indentationDepth = 1;\n if (startContent) {\n this.AddContent(this.startContent);\n }\n if (choiceOnlyContent) {\n this.AddContent(this.choiceOnlyContent);\n }\n if (innerContent) {\n this.AddContent(this.innerContent);\n }\n this.onceOnly = true; // default\n }\n get typeName() {\n return \"Choice\";\n }\n ResolveReferences(context) {\n var _a;\n // Weave style choice - target own content container\n if (this._innerContentContainer) {\n this.runtimeChoice.pathOnChoice = this._innerContentContainer.path;\n if (this.onceOnly) {\n this._innerContentContainer.visitsShouldBeCounted = true;\n }\n }\n if (this._returnToR1) {\n if (!this._r1Label) {\n throw new Error();\n }\n this._returnToR1.targetPath = this._r1Label.path;\n }\n if (this._returnToR2) {\n if (!this._r2Label) {\n throw new Error();\n }\n this._returnToR2.targetPath = this._r2Label.path;\n }\n if (this._divertToStartContentOuter) {\n if (!this._startContentRuntimeContainer) {\n throw new Error();\n }\n this._divertToStartContentOuter.targetPath =\n this._startContentRuntimeContainer.path;\n }\n if (this._divertToStartContentInner) {\n if (!this._startContentRuntimeContainer) {\n throw new Error();\n }\n this._divertToStartContentInner.targetPath =\n this._startContentRuntimeContainer.path;\n }\n super.ResolveReferences(context);\n if (this.identifier && (((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || \"\").length > 0) {\n context.CheckForNamingCollisions(this, this.identifier, SymbolType_1.SymbolType.SubFlowAndWeave);\n }\n }\n}\nexports.Choice = Choice;\n//# sourceMappingURL=Choice.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StringParserElement = void 0;\nclass StringParserElement {\n constructor() {\n this.characterIndex = 0;\n this.characterInLineIndex = 0;\n this.lineIndex = 0;\n this.reportedErrorInScope = false;\n this.uniqueId = 0;\n this.customFlags = 0;\n this.CopyFrom = (fromElement) => {\n StringParserElement._uniqueIdCounter++;\n this.uniqueId = StringParserElement._uniqueIdCounter;\n this.characterIndex = fromElement.characterIndex;\n this.characterInLineIndex = fromElement.characterInLineIndex;\n this.lineIndex = fromElement.lineIndex;\n this.customFlags = fromElement.customFlags;\n this.reportedErrorInScope = false;\n };\n // Squash is used when succeeding from a rule,\n // so only the state information we wanted to carry forward is\n // retained. e.g. characterIndex and lineIndex are global,\n // however uniqueId is specific to the individual rule,\n // and likewise, custom flags are designed for the temporary\n // state of the individual rule too.\n this.SquashFrom = (fromElement) => {\n this.characterIndex = fromElement.characterIndex;\n this.characterInLineIndex = fromElement.characterInLineIndex;\n this.lineIndex = fromElement.lineIndex;\n this.reportedErrorInScope = fromElement.reportedErrorInScope;\n this.customFlags = fromElement.customFlags;\n };\n }\n}\nexports.StringParserElement = StringParserElement;\nStringParserElement._uniqueIdCounter = 1000;\n//# sourceMappingURL=StringParserElement.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StringParserState = void 0;\nconst StringParserElement_1 = require(\"./StringParserElement\");\nclass StringParserState {\n get currentElement() {\n return this._stack[this._numElements - 1];\n }\n get lineIndex() {\n return this.currentElement.lineIndex;\n }\n set lineIndex(value) {\n this.currentElement.lineIndex = value;\n }\n get characterIndex() {\n return this.currentElement.characterIndex;\n }\n set characterIndex(value) {\n this.currentElement.characterIndex = value;\n }\n get characterInLineIndex() {\n return this.currentElement.characterInLineIndex;\n }\n set characterInLineIndex(value) {\n this.currentElement.characterInLineIndex = value;\n }\n get customFlags() {\n return this.currentElement.customFlags;\n }\n set customFlags(value) {\n this.currentElement.customFlags = value;\n }\n get errorReportedAlreadyInScope() {\n return this.currentElement.reportedErrorInScope;\n }\n get stackHeight() {\n return this._numElements;\n }\n constructor() {\n this._stack = [];\n this._numElements = 0;\n this.StringParserState = () => {\n const kExpectedMaxStackDepth = 200;\n this._stack = new Array(kExpectedMaxStackDepth);\n for (let ii = 0; ii < kExpectedMaxStackDepth; ++ii) {\n this._stack[ii] = new StringParserElement_1.StringParserElement();\n }\n this._numElements = 1;\n };\n this.Push = () => {\n if (this._numElements >= this._stack.length && this._numElements > 0) {\n throw new Error(\"Stack overflow in parser state.\");\n }\n const prevElement = this._stack[this._numElements - 1];\n const newElement = this._stack[this._numElements];\n this._numElements++;\n newElement.CopyFrom(prevElement);\n return newElement.uniqueId;\n };\n this.Pop = (expectedRuleId) => {\n if (this._numElements == 1) {\n throw new Error(\"Attempting to remove final stack element is illegal! Mismatched Begin/Succceed/Fail?\");\n }\n if (this.currentElement.uniqueId != expectedRuleId) {\n throw new Error(\"Mismatched rule IDs while Poping - do you have mismatched Begin/Succeed/Fail?\");\n }\n // Restore state\n this._numElements -= 1;\n };\n this.Peek = (expectedRuleId) => {\n if (this.currentElement.uniqueId != expectedRuleId) {\n throw new Error(\"Mismatched rule IDs while Peeking - do you have mismatched Begin/Succeed/Fail?\");\n }\n return this._stack[this._numElements - 1];\n };\n this.PeekPenultimate = () => {\n if (this._numElements >= 2) {\n return this._stack[this._numElements - 2];\n }\n return null;\n };\n // Reduce stack height while maintaining currentElement\n // Remove second last element: i.e. \"squash last two elements together\"\n // Used when succeeding from a rule (and ONLY when succeeding, since\n // the state of the top element is retained).\n this.Squash = () => {\n if (this._numElements < 2) {\n throw new Error(\"Attempting to remove final stack element is illegal! Mismatched Begin/Succceed/Fail?\");\n }\n const penultimateEl = this._stack[this._numElements - 2];\n const lastEl = this._stack[this._numElements - 1];\n penultimateEl.SquashFrom(lastEl);\n this._numElements -= 1;\n };\n this.NoteErrorReported = () => {\n for (const el of this._stack) {\n el.reportedErrorInScope = true;\n }\n };\n const kExpectedMaxStackDepth = 200;\n for (let i = 0; i < kExpectedMaxStackDepth; i++) {\n this._stack[i] = new StringParserElement_1.StringParserElement();\n }\n this._numElements = 1;\n }\n}\nexports.StringParserState = StringParserState;\n//# sourceMappingURL=StringParserState.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StringParser = exports.ParseSuccess = void 0;\nconst CharacterSet_1 = require(\"../CharacterSet\");\nconst StringParserState_1 = require(\"./StringParserState\");\nexports.ParseSuccess = Symbol(\"ParseSuccessStruct\");\nclass StringParser {\n constructor(str) {\n this.ParseRule = null;\n this.errorHandler = null;\n this.hadError = false;\n //--------------------------------\n // Parse state\n //--------------------------------\n this.BeginRule = () => this.state.Push();\n this.FailRule = (expectedRuleId) => {\n this.state.Pop(expectedRuleId);\n return null;\n };\n this.CancelRule = (expectedRuleId) => {\n this.state.Pop(expectedRuleId);\n };\n this.SucceedRule = (expectedRuleId, result = null) => {\n // Get state at point where this rule stared evaluating\n const stateAtSucceedRule = this.state.Peek(expectedRuleId);\n const stateAtBeginRule = this.state.PeekPenultimate();\n // Allow subclass to receive callback\n if (this.RuleDidSucceed) {\n this.RuleDidSucceed(result, stateAtBeginRule, stateAtSucceedRule);\n }\n // Flatten state stack so that we maintain the same values,\n // but remove one level in the stack.\n this.state.Squash();\n let finalResult = result;\n if (finalResult === null) {\n finalResult = StringParser.ParseSuccess;\n }\n return finalResult;\n };\n this.Expect = (rule, message = null, recoveryRule = null) => {\n let result = this.ParseObject(rule);\n if (result === null) {\n if (message === null) {\n message = rule.name;\n }\n let butSaw;\n const lineRemainder = this.LineRemainder();\n if (lineRemainder === null || lineRemainder.length === 0) {\n butSaw = \"end of line\";\n }\n else {\n butSaw = `'${lineRemainder}'`;\n }\n this.Error(`Expected ${message} but saw ${butSaw}`);\n if (recoveryRule !== null) {\n result = recoveryRule();\n }\n }\n return result;\n };\n this.Error = (message, isWarning = false) => {\n this.ErrorOnLine(message, this.lineIndex + 1, isWarning);\n };\n this.ErrorWithParsedObject = (message, result, isWarning = false) => {\n this.ErrorOnLine(message, result.debugMetadata ? result.debugMetadata.startLineNumber : -1, isWarning);\n };\n this.ErrorOnLine = (message, lineNumber, isWarning) => {\n if (!this.state.errorReportedAlreadyInScope) {\n const errorType = isWarning ? \"Warning\" : \"Error\";\n if (!this.errorHandler) {\n throw new Error(`${errorType} on line ${lineNumber}: ${message}`);\n }\n else {\n this.errorHandler(message, this.index, lineNumber - 1, isWarning);\n }\n this.state.NoteErrorReported();\n }\n if (!isWarning) {\n this.hadError = true;\n }\n };\n this.Warning = (message) => this.Error(message, true);\n this.LineRemainder = () => this.Peek(() => this.ParseUntilCharactersFromString(\"\\n\\r\"));\n this.SetFlag = (flag, trueOrFalse) => {\n if (trueOrFalse) {\n this.state.customFlags |= flag;\n }\n else {\n this.state.customFlags &= ~flag;\n }\n };\n this.GetFlag = (flag) => Boolean(this.state.customFlags & flag);\n //--------------------------------\n // Structuring\n //--------------------------------\n this.ParseObject = (rule) => {\n const ruleId = this.BeginRule();\n const stackHeightBefore = this.state.stackHeight;\n const result = rule();\n if (stackHeightBefore !== this.state.stackHeight) {\n throw new Error(\"Mismatched Begin/Fail/Succeed rules\");\n }\n if (result === null) {\n return this.FailRule(ruleId);\n }\n this.SucceedRule(ruleId, result);\n return result;\n };\n this.Parse = (rule) => {\n const ruleId = this.BeginRule();\n const result = rule();\n if (result === null) {\n this.FailRule(ruleId);\n return null;\n }\n this.SucceedRule(ruleId, result);\n return result;\n };\n this.OneOf = (array) => {\n for (const rule of array) {\n const result = this.ParseObject(rule);\n if (result !== null) {\n return result;\n }\n }\n return null;\n };\n this.OneOrMore = (rule) => {\n const results = [];\n let result = null;\n do {\n result = this.ParseObject(rule);\n if (result !== null) {\n results.push(result);\n }\n } while (result !== null);\n if (results.length > 0) {\n return results;\n }\n return null;\n };\n this.Optional = (rule) => () => {\n const result = this.ParseObject(rule);\n if (result === null)\n return StringParser.ParseSuccess;\n return result;\n };\n // Return ParseSuccess instead the real result so that it gets excluded\n // from result arrays (e.g. Interleave)\n this.Exclude = (rule) => () => this.ParseObject(rule) && StringParser.ParseSuccess;\n // Combination of both of the above\n this.OptionalExclude = (rule) => () => {\n this.ParseObject(rule);\n return StringParser.ParseSuccess;\n };\n // Convenience method for creating more readable ParseString rules that can be combined\n // in other structuring rules (like OneOf etc)\n // e.g. OneOf(String(\"one\"), String(\"two\"))\n this.String = (str) => () => this.ParseString(str);\n this.TryAddResultToList = (result, list, flatten = true) => {\n if (result === StringParser.ParseSuccess) {\n return;\n }\n if (flatten && Array.isArray(result)) {\n const resultCollection = result;\n if (resultCollection !== null) {\n for (const obj of resultCollection) {\n list.push(obj);\n }\n return;\n }\n }\n list.push(result);\n };\n this.Interleave = (ruleA, ruleB, untilTerminator = null, flatten = true) => {\n const ruleId = this.BeginRule();\n const results = [];\n // First outer padding\n const firstA = this.ParseObject(ruleA);\n if (firstA === null) {\n return this.FailRule(ruleId);\n }\n else {\n this.TryAddResultToList(firstA, results, flatten);\n }\n let lastMainResult = null;\n let outerResult = null;\n do {\n // \"until\" condition hit?\n if (untilTerminator !== null && this.Peek(untilTerminator) !== null) {\n break;\n }\n // Main inner\n lastMainResult = this.ParseObject(ruleB);\n if (lastMainResult === null) {\n break;\n }\n else {\n this.TryAddResultToList(lastMainResult, results, flatten);\n }\n // Outer result (i.e. last A in ABA)\n outerResult = null;\n if (lastMainResult !== null) {\n outerResult = this.ParseObject(ruleA);\n if (outerResult === null) {\n break;\n }\n else {\n this.TryAddResultToList(outerResult, results, flatten);\n }\n }\n // Stop if there are no results, or if both are the placeholder \"ParseSuccess\" (i.e. Optional success rather than a true value)\n } while ((lastMainResult !== null || outerResult !== null) &&\n !(lastMainResult === StringParser.ParseSuccess &&\n outerResult == StringParser.ParseSuccess) &&\n this.remainingLength > 0);\n if (results.length === 0) {\n return this.FailRule(ruleId);\n }\n return this.SucceedRule(ruleId, results);\n };\n //--------------------------------\n // Basic string parsing\n //--------------------------------\n this.ParseString = (str) => {\n if (str.length > this.remainingLength) {\n return null;\n }\n const ruleId = this.BeginRule();\n // Optimisation from profiling:\n // Store in temporary local variables\n // since they're properties that would have to access\n // the rule stack every time otherwise.\n let i = this.index;\n let cli = this.characterInLineIndex;\n let li = this.lineIndex;\n let success = true;\n for (let tempIdx = 0; tempIdx < str.length; tempIdx += 1) {\n const c = str[tempIdx];\n if (this._chars[i] !== c) {\n success = false;\n break;\n }\n if (c === \"\\n\") {\n li++;\n cli = -1;\n }\n i++;\n cli++;\n }\n this.index = i;\n this.characterInLineIndex = cli;\n this.lineIndex = li;\n if (success) {\n return this.SucceedRule(ruleId, str);\n }\n return this.FailRule(ruleId);\n };\n this.ParseSingleCharacter = () => {\n if (this.remainingLength > 0) {\n const c = this._chars[this.index];\n if (c === \"\\n\") {\n this.lineIndex += 1;\n this.characterInLineIndex = -1;\n }\n this.index += 1;\n this.characterInLineIndex += 1;\n return c;\n }\n return \"0\";\n };\n this.ParseUntilCharactersFromString = (str, maxCount = -1) => this.ParseCharactersFromString(str, false, maxCount);\n this.ParseUntilCharactersFromCharSet = (charSet, maxCount = -1) => this.ParseCharactersFromCharSet(charSet, false, maxCount);\n this.ParseCharactersFromString = (str, maxCountOrShouldIncludeStrChars = -1, maxCount = -1) => {\n const charSet = new CharacterSet_1.CharacterSet(str);\n if (typeof maxCountOrShouldIncludeStrChars === \"number\") {\n return this.ParseCharactersFromCharSet(charSet, true, maxCountOrShouldIncludeStrChars);\n }\n return this.ParseCharactersFromCharSet(charSet, maxCountOrShouldIncludeStrChars, maxCount);\n };\n this.ParseCharactersFromCharSet = (charSet, shouldIncludeChars = true, maxCount = -1) => {\n if (maxCount === -1) {\n maxCount = Number.MAX_SAFE_INTEGER;\n }\n const startIndex = this.index;\n // Optimisation from profiling:\n // Store in temporary local variables\n // since they're properties that would have to access\n // the rule stack every time otherwise.\n let ii = this.index;\n let cli = this.characterInLineIndex;\n let li = this.lineIndex;\n let count = 0;\n while (ii < this._chars.length &&\n charSet.set.has(this._chars[ii]) === shouldIncludeChars &&\n count < maxCount) {\n if (this._chars[ii] === \"\\n\") {\n li += 1;\n cli = -1;\n }\n ii += 1;\n cli += 1;\n count += 1;\n }\n this.index = ii;\n this.characterInLineIndex = cli;\n this.lineIndex = li;\n const lastCharIndex = this.index;\n if (lastCharIndex > startIndex) {\n return this._chars.slice(startIndex, this.index).join(\"\");\n }\n return null;\n };\n this.Peek = (rule) => {\n const ruleId = this.BeginRule();\n const result = rule();\n this.CancelRule(ruleId);\n return result;\n };\n // No need to Begin/End rule since we never parse a newline, so keeping oldIndex is good enough\n this.ParseInt = () => {\n const oldIndex = this.index;\n const oldCharacterInLineIndex = this.characterInLineIndex;\n const negative = this.ParseString(\"-\") !== null;\n // Optional whitespace\n this.ParseCharactersFromString(\" \\t\");\n const parsedString = this.ParseCharactersFromCharSet(StringParser.numbersCharacterSet);\n if (parsedString === null) {\n // Roll back and fail\n this.index = oldIndex;\n this.characterInLineIndex = oldCharacterInLineIndex;\n return null;\n }\n let parsedInt;\n if (!Number.isNaN(Number(parsedString))) {\n parsedInt = Number(parsedString);\n return negative ? -parsedInt : parsedInt;\n }\n this.Error(\"Failed to read integer value: \" +\n parsedString +\n \". Perhaps it's out of the range of acceptable numbers ink supports? (\" +\n Number.MIN_SAFE_INTEGER +\n \" to \" +\n Number.MAX_SAFE_INTEGER +\n \")\");\n return null;\n };\n // No need to Begin/End rule since we never parse a newline, so keeping oldIndex is good enough\n this.ParseFloat = () => {\n const oldIndex = this.index;\n const oldCharacterInLineIndex = this.characterInLineIndex;\n const leadingInt = this.ParseInt();\n if (leadingInt !== null) {\n if (this.ParseString(\".\") !== null) {\n const afterDecimalPointStr = this.ParseCharactersFromCharSet(StringParser.numbersCharacterSet);\n return Number(`${leadingInt}.${afterDecimalPointStr}`);\n }\n }\n // Roll back and fail\n this.index = oldIndex;\n this.characterInLineIndex = oldCharacterInLineIndex;\n return null;\n };\n this.ParseNewline = () => {\n const ruleId = this.BeginRule();\n // Optional \\r, definite \\n to support Windows (\\r\\n) and Mac/Unix (\\n)\n // 2nd May 2016: Always collapse \\r\\n to just \\n\n this.ParseString(\"\\r\");\n if (this.ParseString(\"\\n\") === null) {\n return this.FailRule(ruleId);\n }\n return this.SucceedRule(ruleId, \"\\n\");\n };\n const strPreProc = this.PreProcessInputString(str);\n this.state = new StringParserState_1.StringParserState();\n if (str) {\n this._chars = strPreProc.split(\"\");\n }\n else {\n this._chars = [];\n }\n this.inputString = strPreProc;\n }\n get currentCharacter() {\n if (this.index >= 0 && this.remainingLength > 0) {\n return this._chars[this.index];\n }\n return \"0\";\n }\n // Don't do anything by default, but provide ability for subclasses\n // to manipulate the string before it's used as input (converted to a char array)\n PreProcessInputString(str) {\n return str;\n }\n get endOfInput() {\n return this.index >= this._chars.length;\n }\n get remainingString() {\n return this._chars\n .slice(this.index, this.index + this.remainingLength)\n .join(\"\");\n }\n get remainingLength() {\n return this._chars.length - this.index;\n }\n get lineIndex() {\n return this.state.lineIndex;\n }\n set lineIndex(value) {\n this.state.lineIndex = value;\n }\n set characterInLineIndex(value) {\n this.state.characterInLineIndex = value;\n }\n get characterInLineIndex() {\n return this.state.characterInLineIndex;\n }\n get index() {\n // If we want subclass parsers to be able to set the index directly,\n // then we would need to know what the lineIndex of the new\n // index would be - would we have to step through manually\n // counting the newlines to do so?\n return this.state.characterIndex;\n }\n set index(value) {\n this.state.characterIndex = value;\n }\n ParseUntil(stopRule, pauseCharacters = null, endCharacters = null) {\n const ruleId = this.BeginRule();\n const pauseAndEnd = new CharacterSet_1.CharacterSet();\n if (pauseCharacters !== null) {\n pauseAndEnd.set = new Set([\n ...pauseAndEnd.set.values(),\n ...pauseCharacters.set.values(),\n ]);\n }\n if (endCharacters !== null) {\n pauseAndEnd.set = new Set([\n ...pauseAndEnd.set.values(),\n ...endCharacters.set.values(),\n ]);\n }\n let parsedString = \"\";\n let ruleResultAtPause = null;\n // Keep attempting to parse strings up to the pause (and end) points.\n // - At each of the pause points, attempt to parse according to the rule\n // - When the end point is reached (or EOF), we're done\n do {\n // TODO: Perhaps if no pause or end characters are passed, we should check *every* character for stopRule?\n const partialParsedString = this.ParseUntilCharactersFromCharSet(pauseAndEnd);\n if (partialParsedString) {\n parsedString += partialParsedString;\n }\n // Attempt to run the parse rule at this pause point\n ruleResultAtPause = this.Peek(stopRule);\n // Rule completed - we're done\n if (ruleResultAtPause !== null) {\n break;\n }\n else {\n if (this.endOfInput) {\n break;\n }\n // Reached a pause point, but rule failed. Step past and continue parsing string\n const pauseCharacter = this.currentCharacter;\n if (pauseCharacters !== null &&\n pauseCharacters.set.has(pauseCharacter)) {\n parsedString += pauseCharacter;\n if (pauseCharacter === \"\\n\") {\n this.lineIndex += 1;\n this.characterInLineIndex = -1;\n }\n this.index += 1;\n this.characterInLineIndex += 1;\n continue;\n }\n else {\n break;\n }\n }\n } while (true);\n if (parsedString.length > 0) {\n return this.SucceedRule(ruleId, String(parsedString));\n }\n return this.FailRule(ruleId);\n }\n}\nexports.StringParser = StringParser;\nStringParser.ParseSuccess = exports.ParseSuccess;\nStringParser.numbersCharacterSet = new CharacterSet_1.CharacterSet(\"0123456789\");\n//# sourceMappingURL=StringParser.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CommentEliminator = void 0;\nconst CharacterSet_1 = require(\"./CharacterSet\");\nconst StringParser_1 = require(\"./StringParser/StringParser\");\n/// <summary>\n/// Pre-pass before main ink parser runs. It actually performs two main tasks:\n/// - comment elimination to simplify the parse rules in the main parser\n/// - Conversion of Windows line endings (\\r\\n) to the simpler Unix style (\\n), so\n/// we don't have to worry about them later.\n/// </summary>\nclass CommentEliminator extends StringParser_1.StringParser {\n constructor() {\n super(...arguments);\n this._commentOrNewlineStartCharacter = new CharacterSet_1.CharacterSet(\"/\\r\\n\");\n this._commentBlockEndCharacter = new CharacterSet_1.CharacterSet(\"*\");\n this._newlineCharacters = new CharacterSet_1.CharacterSet(\"\\n\\r\");\n this.Process = () => {\n // Make both comments and non-comments optional to handle trivial empty file case (or *only* comments)\n const stringList = this.Interleave(this.Optional(this.CommentsAndNewlines), this.Optional(this.MainInk));\n if (stringList !== null) {\n return stringList.join(\"\");\n }\n else {\n return \"\";\n }\n };\n this.MainInk = () => this.ParseUntil(this.CommentsAndNewlines, this._commentOrNewlineStartCharacter, null);\n this.CommentsAndNewlines = () => {\n let newLines = this.Interleave(this.Optional(this.ParseNewline), this.Optional(this.ParseSingleComment));\n if (newLines !== null) {\n return newLines.join(\"\");\n }\n return null;\n };\n // Valid comments always return either an empty string or pure newlines,\n // which we want to keep so that line numbers stay the same\n this.ParseSingleComment = () => this.OneOf([this.EndOfLineComment, this.BlockComment]);\n this.EndOfLineComment = () => {\n if (this.ParseString(\"//\") === null) {\n return null;\n }\n this.ParseUntilCharactersFromCharSet(this._newlineCharacters);\n return \"\";\n };\n this.BlockComment = () => {\n if (this.ParseString(\"/*\") === null) {\n return null;\n }\n const startLineIndex = this.lineIndex;\n const commentResult = this.ParseUntil(this.String(\"*/\"), this._commentBlockEndCharacter, null);\n if (!this.endOfInput) {\n this.ParseString(\"*/\");\n }\n // Count the number of lines that were inside the block, and replicate them as newlines\n // so that the line indexing still works from the original source\n if (commentResult != null) {\n return \"\\n\".repeat(this.lineIndex - startLineIndex);\n }\n // No comment at all\n return null;\n };\n }\n PreProcessInputString(str) {\n return str;\n }\n}\nexports.CommentEliminator = CommentEliminator;\n//# sourceMappingURL=CommentEliminator.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Conditional = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../../engine/ControlCommand\");\nconst Object_1 = require(\"../Object\");\nclass Conditional extends Object_1.ParsedObject {\n constructor(initialCondition, branches) {\n super();\n this.initialCondition = initialCondition;\n this.branches = branches;\n this._reJoinTarget = null;\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n // Initial condition\n if (this.initialCondition) {\n container.AddContent(this.initialCondition.runtimeObject);\n }\n // Individual branches\n for (const branch of this.branches) {\n const branchContainer = branch.runtimeObject;\n container.AddContent(branchContainer);\n }\n // If it's a switch-like conditional, each branch\n // will have a \"duplicate\" operation for the original\n // switched value. If there's no final else clause\n // and we fall all the way through, we need to clean up.\n // (An else clause doesn't dup but it *does* pop)\n if (this.initialCondition !== null &&\n this.branches[0].ownExpression !== null &&\n !this.branches[this.branches.length - 1].isElse) {\n container.AddContent(ControlCommand_1.ControlCommand.PopEvaluatedValue());\n }\n // Target for branches to rejoin to\n this._reJoinTarget = ControlCommand_1.ControlCommand.NoOp();\n container.AddContent(this._reJoinTarget);\n return container;\n };\n if (this.initialCondition) {\n this.AddContent(this.initialCondition);\n }\n if (this.branches !== null) {\n this.AddContent(this.branches);\n }\n }\n get typeName() {\n return \"Conditional\";\n }\n ResolveReferences(context) {\n const pathToReJoin = this._reJoinTarget.path;\n for (const branch of this.branches) {\n if (!branch.returnDivert) {\n throw new Error();\n }\n branch.returnDivert.targetPath = pathToReJoin;\n }\n super.ResolveReferences(context);\n }\n}\nexports.Conditional = Conditional;\n//# sourceMappingURL=Conditional.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Text = void 0;\nconst Object_1 = require(\"./Object\");\nconst Value_1 = require(\"../../../engine/Value\");\nclass Text extends Object_1.ParsedObject {\n constructor(text) {\n super();\n this.text = text;\n this.GenerateRuntimeObject = () => new Value_1.StringValue(this.text);\n this.toString = () => this.text;\n }\n get typeName() {\n return \"Text\";\n }\n}\nexports.Text = Text;\n//# sourceMappingURL=Text.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ConstantDeclaration = void 0;\nconst Object_1 = require(\"../Object\");\nconst SymbolType_1 = require(\"../SymbolType\");\nclass ConstantDeclaration extends Object_1.ParsedObject {\n get constantName() {\n var _a;\n return (_a = this.constantIdentifier) === null || _a === void 0 ? void 0 : _a.name;\n }\n get expression() {\n if (!this._expression) {\n throw new Error();\n }\n return this._expression;\n }\n constructor(name, assignedExpression) {\n super();\n this._expression = null;\n this.GenerateRuntimeObject = () => {\n // Global declarations don't generate actual procedural\n // runtime objects, but instead add a global variable to the story itself.\n // The story then initialises them all in one go at the start of the game.\n return null;\n };\n this.constantIdentifier = name;\n // Defensive programming in case parsing of assignedExpression failed\n if (assignedExpression) {\n this._expression = this.AddContent(assignedExpression);\n }\n }\n get typeName() {\n return \"CONST\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n context.CheckForNamingCollisions(this, this.constantIdentifier, SymbolType_1.SymbolType.Var);\n }\n}\nexports.ConstantDeclaration = ConstantDeclaration;\n//# sourceMappingURL=ConstantDeclaration.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.FlowLevel = void 0;\nvar FlowLevel;\n(function (FlowLevel) {\n FlowLevel[FlowLevel[\"Story\"] = 0] = \"Story\";\n FlowLevel[FlowLevel[\"Knot\"] = 1] = \"Knot\";\n FlowLevel[FlowLevel[\"Stitch\"] = 2] = \"Stitch\";\n // not actually a FlowBase, but used for diverts\n FlowLevel[FlowLevel[\"WeavePoint\"] = 3] = \"WeavePoint\";\n})(FlowLevel || (exports.FlowLevel = FlowLevel = {}));\n//# sourceMappingURL=FlowLevel.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Gather = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst Object_1 = require(\"../Object\");\nconst SymbolType_1 = require(\"../SymbolType\");\nclass Gather extends Object_1.ParsedObject {\n get name() {\n var _a;\n return ((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || null;\n }\n get runtimeContainer() {\n return this.runtimeObject;\n }\n constructor(identifier, indentationDepth) {\n super();\n this.indentationDepth = indentationDepth;\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n container.name = this.name;\n if (this.story.countAllVisits) {\n container.visitsShouldBeCounted = true;\n }\n container.countingAtStartOnly = true;\n // A gather can have null content, e.g. it's just purely a line with \"-\"\n if (this.content) {\n for (const c of this.content) {\n container.AddContent(c.runtimeObject);\n }\n }\n return container;\n };\n this.toString = () => { var _a, _b; return `- ${((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) ? \"(\" + ((_b = this.identifier) === null || _b === void 0 ? void 0 : _b.name) + \")\" : \"gather\"}`; };\n if (identifier)\n this.identifier = identifier;\n }\n get typeName() {\n return \"Gather\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n if (this.identifier && (this.identifier.name || \"\").length > 0) {\n context.CheckForNamingCollisions(this, this.identifier, SymbolType_1.SymbolType.SubFlowAndWeave);\n }\n }\n}\nexports.Gather = Gather;\n//# sourceMappingURL=Gather.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Path = void 0;\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\nconst FlowBase_1 = require(\"./Flow/FlowBase\");\nconst FlowLevel_1 = require(\"./Flow/FlowLevel\");\nconst Weave_1 = require(\"./Weave\");\nclass Path {\n get baseTargetLevel() {\n if (this.baseLevelIsAmbiguous) {\n return FlowLevel_1.FlowLevel.Story;\n }\n return this._baseTargetLevel;\n }\n get baseLevelIsAmbiguous() {\n return !this._baseTargetLevel;\n }\n get firstComponent() {\n if (this.components == null || !this.components.length) {\n return null;\n }\n return this.components[0].name;\n }\n get numberOfComponents() {\n return this.components ? this.components.length : 0;\n }\n get dotSeparatedComponents() {\n if (this._dotSeparatedComponents == null) {\n this._dotSeparatedComponents = (this.components ? this.components : [])\n .map((c) => c.name)\n .filter(TypeAssertion_1.filterUndef)\n .join(\".\");\n }\n return this._dotSeparatedComponents;\n }\n constructor(argOne, argTwo) {\n this._dotSeparatedComponents = null;\n this.toString = () => {\n if (this.components === null || this.components.length === 0) {\n if (this.baseTargetLevel === FlowLevel_1.FlowLevel.WeavePoint) {\n return \"-> <next gather point>\";\n }\n return \"<invalid Path>\";\n }\n return `-> ${this.dotSeparatedComponents}`;\n };\n this.ResolveFromContext = (context) => {\n if (this.components == null || this.components.length == 0) {\n return null;\n }\n // Find base target of path from current context. e.g.\n // ==> BASE.sub.sub\n let baseTargetObject = this.ResolveBaseTarget(context);\n if (baseTargetObject === null) {\n return null;\n }\n // Given base of path, resolve final target by working deeper into hierarchy\n // e.g. ==> base.mid.FINAL\n if (this.components.length > 1) {\n return this.ResolveTailComponents(baseTargetObject);\n }\n return baseTargetObject;\n };\n // Find the root object from the base, i.e. root from:\n // root.sub1.sub2\n this.ResolveBaseTarget = (originalContext) => {\n const firstComp = this.firstComponent;\n // Work up the ancestry to find the node that has the named object\n let ancestorContext = originalContext;\n while (ancestorContext) {\n // Only allow deep search when searching deeper from original context.\n // Don't allow search upward *then* downward, since that's searching *everywhere*!\n // Allowed examples:\n // - From an inner gather of a stitch, you should search up to find a knot called 'x'\n // at the root of a story, but not a stitch called 'x' in that knot.\n // - However, from within a knot, you should be able to find a gather/choice\n // anywhere called 'x'\n // (that latter example is quite loose, but we allow it)\n const deepSearch = ancestorContext === originalContext;\n const foundBase = this.GetChildFromContext(ancestorContext, firstComp, null, deepSearch);\n if (foundBase) {\n return foundBase;\n }\n ancestorContext = ancestorContext.parent;\n }\n return null;\n };\n // Find the final child from path given root, i.e.:\n // root.sub.finalChild\n this.ResolveTailComponents = (rootTarget) => {\n let foundComponent = rootTarget;\n if (!this.components)\n return null;\n for (let ii = 1; ii < this.components.length; ++ii) {\n const compName = this.components[ii].name;\n let minimumExpectedLevel;\n let foundFlow = (0, TypeAssertion_1.asOrNull)(foundComponent, FlowBase_1.FlowBase);\n if (foundFlow !== null) {\n minimumExpectedLevel = (foundFlow.flowLevel + 1);\n }\n else {\n minimumExpectedLevel = FlowLevel_1.FlowLevel.WeavePoint;\n }\n foundComponent = this.GetChildFromContext(foundComponent, compName, minimumExpectedLevel);\n if (foundComponent === null) {\n break;\n }\n }\n return foundComponent;\n };\n // See whether \"context\" contains a child with a given name at a given flow level\n // Can either be a named knot/stitch (a FlowBase) or a weave point within a Weave (Choice or Gather)\n // This function also ignores any other object types that are neither FlowBase nor Weave.\n // Called from both ResolveBase (force deep) and ResolveTail for the individual components.\n this.GetChildFromContext = (context, childName, minimumLevel, forceDeepSearch = false) => {\n // null childLevel means that we don't know where to find it\n const ambiguousChildLevel = minimumLevel === null;\n // Search for WeavePoint within Weave\n const weaveContext = (0, TypeAssertion_1.asOrNull)(context, Weave_1.Weave);\n if (childName &&\n weaveContext !== null &&\n (ambiguousChildLevel || minimumLevel === FlowLevel_1.FlowLevel.WeavePoint)) {\n return weaveContext.WeavePointNamed(childName);\n }\n // Search for content within Flow (either a sub-Flow or a WeavePoint)\n let flowContext = (0, TypeAssertion_1.asOrNull)(context, FlowBase_1.FlowBase);\n if (childName && flowContext !== null) {\n // When searching within a Knot, allow a deep searches so that\n // named weave points (choices and gathers) can be found within any stitch\n // Otherwise, we just search within the immediate object.\n const shouldDeepSearch = forceDeepSearch || flowContext.flowLevel === FlowLevel_1.FlowLevel.Knot;\n return flowContext.ContentWithNameAtLevel(childName, minimumLevel, shouldDeepSearch);\n }\n return null;\n };\n if (Object.values(FlowLevel_1.FlowLevel).includes(argOne)) {\n this._baseTargetLevel = argOne;\n this.components = argTwo || [];\n }\n else if (Array.isArray(argOne)) {\n this._baseTargetLevel = null;\n this.components = argOne || [];\n }\n else {\n this._baseTargetLevel = null;\n this.components = [argOne];\n }\n }\n get typeName() {\n return \"Path\";\n }\n}\nexports.Path = Path;\n//# sourceMappingURL=Path.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReturnType = void 0;\nconst Object_1 = require(\"./Object\");\nconst Container_1 = require(\"../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../engine/ControlCommand\");\nconst Void_1 = require(\"../../../engine/Void\");\nclass ReturnType extends Object_1.ParsedObject {\n constructor(returnedExpression = null) {\n super();\n this.returnedExpression = null;\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n if (this.returnedExpression) {\n // Evaluate expression\n container.AddContent(this.returnedExpression.runtimeObject);\n }\n else {\n // Return Runtime.Void when there's no expression to evaluate\n // (This evaluation will just add the Void object to the evaluation stack)\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n container.AddContent(new Void_1.Void());\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n }\n // Then pop the call stack\n // (the evaluated expression will leave the return value on the evaluation stack)\n container.AddContent(ControlCommand_1.ControlCommand.PopFunction());\n return container;\n };\n if (returnedExpression) {\n this.returnedExpression = this.AddContent(returnedExpression);\n }\n }\n get typeName() {\n return \"ReturnType\";\n }\n}\nexports.ReturnType = ReturnType;\n//# sourceMappingURL=ReturnType.js.map","\"use strict\";\n// import { FlowBase } from './FlowBase';\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ClosestFlowBase = void 0;\nfunction ClosestFlowBase(obj) {\n let ancestor = obj.parent;\n while (ancestor) {\n if (ancestor.hasOwnProperty(\"iamFlowbase\") && ancestor.iamFlowbase()) {\n return ancestor;\n }\n ancestor = ancestor.parent;\n }\n return null;\n}\nexports.ClosestFlowBase = ClosestFlowBase;\n//# sourceMappingURL=ClosestFlowBase.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Identifier = void 0;\nclass Identifier {\n constructor(name) {\n this.debugMetadata = null;\n this.toString = () => this.name || \"undefined identifer\";\n this.name = name;\n }\n get typeName() {\n return \"Identifier\";\n }\n static Done() {\n return new Identifier(\"DONE\");\n }\n}\nexports.Identifier = Identifier;\n//# sourceMappingURL=Identifier.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.FlowBase = void 0;\nconst Choice_1 = require(\"../Choice\");\nconst Divert_1 = require(\"../Divert/Divert\");\nconst DivertTarget_1 = require(\"../Divert/DivertTarget\");\nconst FlowLevel_1 = require(\"./FlowLevel\");\nconst Gather_1 = require(\"../Gather/Gather\");\n// import { Knot } from '../Knot';\nconst Object_1 = require(\"../Object\");\nconst Path_1 = require(\"../Path\");\nconst ReturnType_1 = require(\"../ReturnType\");\nconst Container_1 = require(\"../../../../engine/Container\");\nconst Divert_2 = require(\"../../../../engine/Divert\");\nconst VariableAssignment_1 = require(\"../../../../engine/VariableAssignment\");\n//import { Story } from '../Story';\nconst SymbolType_1 = require(\"../SymbolType\");\nconst Weave_1 = require(\"../Weave\");\nconst ClosestFlowBase_1 = require(\"./ClosestFlowBase\");\nconst Identifier_1 = require(\"../Identifier\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\n// Base class for Knots and Stitches\nclass FlowBase extends Object_1.ParsedObject {\n get hasParameters() {\n return this.args !== null && this.args.length > 0;\n }\n get subFlowsByName() {\n return this._subFlowsByName;\n }\n get typeName() {\n if (this.isFunction) {\n return \"Function\";\n }\n return String(this.flowLevel);\n }\n get name() {\n var _a;\n return ((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || null;\n }\n constructor(identifier, topLevelObjects = null, args = null, isFunction = false, isIncludedStory = false) {\n super();\n this.isFunction = isFunction;\n this._rootWeave = null;\n this._subFlowsByName = new Map();\n this._startingSubFlowDivert = null;\n this._startingSubFlowRuntime = null;\n this._firstChildFlow = null;\n this.variableDeclarations = new Map();\n this.identifier = null;\n this.args = null;\n this.iamFlowbase = () => true;\n this.SplitWeaveAndSubFlowContent = (contentObjs, isRootStory) => {\n var _a, _b;\n const weaveObjs = [];\n const subFlowObjs = [];\n this._subFlowsByName = new Map();\n for (const obj of contentObjs) {\n const subFlow = (0, TypeAssertion_1.asOrNull)(obj, FlowBase);\n if (subFlow) {\n if (this._firstChildFlow === null) {\n this._firstChildFlow = subFlow;\n }\n subFlowObjs.push(obj);\n if ((_a = subFlow.identifier) === null || _a === void 0 ? void 0 : _a.name) {\n this._subFlowsByName.set((_b = subFlow.identifier) === null || _b === void 0 ? void 0 : _b.name, subFlow);\n }\n }\n else {\n weaveObjs.push(obj);\n }\n }\n // Implicit final gather in top level story for ending without warning that you run out of content\n if (isRootStory) {\n weaveObjs.push(new Gather_1.Gather(null, 1), new Divert_1.Divert(new Path_1.Path(Identifier_1.Identifier.Done())));\n }\n const finalContent = [];\n if (weaveObjs.length > 0) {\n this._rootWeave = new Weave_1.Weave(weaveObjs, 0);\n finalContent.push(this._rootWeave);\n }\n if (subFlowObjs.length > 0) {\n finalContent.push(...subFlowObjs);\n }\n return finalContent;\n };\n this.ResolveVariableWithName = (varName, fromNode) => {\n var _a;\n const result = {};\n // Search in the stitch / knot that owns the node first\n const ownerFlow = fromNode === null ? this : (0, ClosestFlowBase_1.ClosestFlowBase)(fromNode);\n if (ownerFlow) {\n // Argument\n if (ownerFlow.args !== null) {\n for (const arg of ownerFlow.args) {\n if (((_a = arg.identifier) === null || _a === void 0 ? void 0 : _a.name) === varName) {\n result.found = true;\n result.isArgument = true;\n result.ownerFlow = ownerFlow;\n return result;\n }\n }\n }\n // Temp\n if (ownerFlow !== this.story &&\n ownerFlow.variableDeclarations.has(varName)) {\n result.found = true;\n result.ownerFlow = ownerFlow;\n result.isTemporary = true;\n return result;\n }\n }\n // Global\n if (this.story.variableDeclarations.has(varName)) {\n result.found = true;\n result.ownerFlow = this.story;\n result.isGlobal = true;\n return result;\n }\n result.found = false;\n return result;\n };\n this.AddNewVariableDeclaration = (varDecl) => {\n const varName = varDecl.variableName;\n if (this.variableDeclarations.has(varName)) {\n const varab = this.variableDeclarations.get(varName);\n let prevDeclError = \"\";\n const debugMetadata = varab.debugMetadata;\n if (debugMetadata) {\n prevDeclError = ` (${varab.debugMetadata})`;\n }\n this.Error(`found declaration variable '${varName}' that was already declared${prevDeclError}`, varDecl, false);\n return;\n }\n this.variableDeclarations.set(varDecl.variableName, varDecl);\n };\n this.ResolveWeavePointNaming = () => {\n // Find all weave points and organise them by name ready for\n // diverting. Also detect naming collisions.\n if (this._rootWeave) {\n this._rootWeave.ResolveWeavePointNaming();\n }\n for (const [, value] of this._subFlowsByName) {\n if (value.hasOwnProperty(\"ResolveWeavePointNaming\")) {\n value.ResolveWeavePointNaming();\n }\n }\n };\n this.GenerateRuntimeObject = () => {\n var _a;\n let foundReturn = null;\n if (this.isFunction) {\n this.CheckForDisallowedFunctionFlowControl();\n }\n else if (this.flowLevel === FlowLevel_1.FlowLevel.Knot ||\n this.flowLevel === FlowLevel_1.FlowLevel.Stitch) {\n // Non-functon: Make sure knots and stitches don't attempt to use Return statement\n foundReturn = this.Find(ReturnType_1.ReturnType)();\n if (foundReturn !== null) {\n this.Error(`Return statements can only be used in knots that are declared as functions: == function ${this.identifier} ==`, foundReturn);\n }\n }\n const container = new Container_1.Container();\n container.name = (_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name;\n if (this.story.countAllVisits) {\n container.visitsShouldBeCounted = true;\n }\n this.GenerateArgumentVariableAssignments(container);\n // Run through content defined for this knot/stitch:\n // - First of all, any initial content before a sub-stitch\n // or any weave content is added to the main content container\n // - The first inner knot/stitch is automatically entered, while\n // the others are only accessible by an explicit divert\n // - The exception to this rule is if the knot/stitch takes\n // parameters, in which case it can't be auto-entered.\n // - Any Choices and Gathers (i.e. IWeavePoint) found are\n // processsed by GenerateFlowContent.\n let contentIdx = 0;\n while (this.content !== null && contentIdx < this.content.length) {\n const obj = this.content[contentIdx];\n // Inner knots and stitches\n if (obj instanceof FlowBase) {\n const childFlow = obj;\n const childFlowRuntime = childFlow.runtimeObject;\n // First inner stitch - automatically step into it\n // 20/09/2016 - let's not auto step into knots\n if (contentIdx === 0 &&\n !childFlow.hasParameters &&\n this.flowLevel === FlowLevel_1.FlowLevel.Knot) {\n this._startingSubFlowDivert = new Divert_2.Divert();\n container.AddContent(this._startingSubFlowDivert);\n this._startingSubFlowRuntime = childFlowRuntime;\n }\n // Check for duplicate knots/stitches with same name\n const namedChild = childFlowRuntime;\n const existingChild = container.namedContent.get(namedChild.name) || null;\n if (existingChild) {\n const errorMsg = `${this.GetType()} already contains flow named '${namedChild.name}' (at ${existingChild.debugMetadata})`;\n this.Error(errorMsg, childFlow);\n }\n container.AddToNamedContentOnly(namedChild);\n }\n else if (obj) {\n // Other content (including entire Weaves that were grouped in the constructor)\n // At the time of writing, all FlowBases have a maximum of one piece of \"other content\"\n // and it's always the root Weave\n container.AddContent(obj.runtimeObject);\n }\n contentIdx += 1;\n }\n // CHECK FOR FINAL LOOSE ENDS!\n // Notes:\n // - Functions don't need to terminate - they just implicitly return\n // - If return statement was found, don't continue finding warnings for missing control flow,\n // since it's likely that a return statement has been used instead of a ->-> or something,\n // or the writer failed to mark the knot as a function.\n // - _rootWeave may be null if it's a knot that only has stitches\n if (this.flowLevel !== FlowLevel_1.FlowLevel.Story &&\n !this.isFunction &&\n this._rootWeave !== null &&\n foundReturn === null) {\n this._rootWeave.ValidateTermination(this.WarningInTermination);\n }\n return container;\n };\n this.GenerateArgumentVariableAssignments = (container) => {\n var _a;\n if (this.args === null || this.args.length === 0) {\n return;\n }\n // Assign parameters in reverse since they'll be popped off the evaluation stack\n // No need to generate EvalStart and EvalEnd since there's nothing being pushed\n // back onto the evaluation stack.\n for (let ii = this.args.length - 1; ii >= 0; --ii) {\n const paramName = ((_a = this.args[ii].identifier) === null || _a === void 0 ? void 0 : _a.name) || null;\n const assign = new VariableAssignment_1.VariableAssignment(paramName, true);\n container.AddContent(assign);\n }\n };\n this.ContentWithNameAtLevel = (name, level = null, deepSearch = false) => {\n var _a;\n // Referencing self?\n if (level === this.flowLevel || level === null) {\n if (name === ((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name)) {\n return this;\n }\n }\n if (level === FlowLevel_1.FlowLevel.WeavePoint || level === null) {\n let weavePointResult = null;\n if (this._rootWeave) {\n weavePointResult = this._rootWeave.WeavePointNamed(name);\n if (weavePointResult) {\n return weavePointResult;\n }\n }\n // Stop now if we only wanted a result if it's a weave point?\n if (level === FlowLevel_1.FlowLevel.WeavePoint) {\n return deepSearch ? this.DeepSearchForAnyLevelContent(name) : null;\n }\n }\n // If this flow would be incapable of containing the requested level, early out\n // (e.g. asking for a Knot from a Stitch)\n if (level !== null && level < this.flowLevel) {\n return null;\n }\n let subFlow = this._subFlowsByName.get(name) || null;\n if (subFlow && (level === null || level === subFlow.flowLevel)) {\n return subFlow;\n }\n return deepSearch ? this.DeepSearchForAnyLevelContent(name) : null;\n };\n this.DeepSearchForAnyLevelContent = (name) => {\n const weaveResultSelf = this.ContentWithNameAtLevel(name, FlowLevel_1.FlowLevel.WeavePoint, false);\n if (weaveResultSelf) {\n return weaveResultSelf;\n }\n for (const [, value] of this._subFlowsByName) {\n const deepResult = value.ContentWithNameAtLevel(name, null, true);\n if (deepResult) {\n return deepResult;\n }\n }\n return null;\n };\n this.CheckForDisallowedFunctionFlowControl = () => {\n // if (!(this instanceof Knot)) { // cannont use Knot here because of circular dependancy\n if (this.flowLevel !== FlowLevel_1.FlowLevel.Knot) {\n this.Error(\"Functions cannot be stitches - i.e. they should be defined as '== function myFunc ==' rather than internal to another knot.\");\n }\n // Not allowed sub-flows\n for (const [key, value] of this._subFlowsByName) {\n this.Error(`Functions may not contain stitches, but saw '${key}' within the function '${this.identifier}'`, value);\n }\n if (!this._rootWeave) {\n throw new Error();\n }\n const allDiverts = this._rootWeave.FindAll(Divert_1.Divert)();\n for (const divert of allDiverts) {\n if (!divert.isFunctionCall && !(divert.parent instanceof DivertTarget_1.DivertTarget)) {\n this.Error(`Functions may not contain diverts, but saw '${divert}'`, divert);\n }\n }\n const allChoices = this._rootWeave.FindAll(Choice_1.Choice)();\n for (const choice of allChoices) {\n this.Error(`Functions may not contain choices, but saw '${choice}'`, choice);\n }\n };\n this.WarningInTermination = (terminatingObject) => {\n let message = \"Apparent loose end exists where the flow runs out. Do you need a '-> DONE' statement, choice or divert?\";\n if (terminatingObject.parent === this._rootWeave && this._firstChildFlow) {\n message = `${message} Note that if you intend to enter '${this._firstChildFlow.identifier}' next, you need to divert to it explicitly.`;\n }\n const terminatingDivert = (0, TypeAssertion_1.asOrNull)(terminatingObject, Divert_1.Divert);\n if (terminatingDivert && terminatingDivert.isTunnel) {\n message += ` When final tunnel to '${terminatingDivert.target} ->' returns it won't have anywhere to go.`;\n }\n this.Warning(message, terminatingObject);\n };\n this.toString = () => `${this.typeName} '${this.identifier}'`;\n this.identifier = identifier;\n this.args = args;\n if (topLevelObjects === null) {\n topLevelObjects = [];\n }\n // Used by story to add includes\n this.PreProcessTopLevelObjects(topLevelObjects);\n topLevelObjects = this.SplitWeaveAndSubFlowContent(topLevelObjects, this.GetType() == \"Story\" && !isIncludedStory);\n this.AddContent(topLevelObjects);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n PreProcessTopLevelObjects(_) {\n // empty by default, used by Story to process included file references\n }\n ResolveReferences(context) {\n var _a, _b;\n if (this._startingSubFlowDivert) {\n if (!this._startingSubFlowRuntime) {\n throw new Error();\n }\n this._startingSubFlowDivert.targetPath =\n this._startingSubFlowRuntime.path;\n }\n super.ResolveReferences(context);\n // Check validity of parameter names\n if (this.args !== null) {\n for (const arg of this.args) {\n context.CheckForNamingCollisions(this, arg.identifier, SymbolType_1.SymbolType.Arg, \"argument\");\n }\n // Separately, check for duplicate arugment names, since they aren't Parsed.Objects,\n // so have to be checked independently.\n for (let ii = 0; ii < this.args.length; ii += 1) {\n for (let jj = ii + 1; jj < this.args.length; jj += 1) {\n if (((_a = this.args[ii].identifier) === null || _a === void 0 ? void 0 : _a.name) == ((_b = this.args[jj].identifier) === null || _b === void 0 ? void 0 : _b.name)) {\n this.Error(`Multiple arguments with the same name: '${this.args[ii].identifier}'`);\n }\n }\n }\n }\n // Check naming collisions for knots and stitches\n if (this.flowLevel !== FlowLevel_1.FlowLevel.Story) {\n // Weave points aren't FlowBases, so this will only be knot or stitch\n const symbolType = this.flowLevel === FlowLevel_1.FlowLevel.Knot\n ? SymbolType_1.SymbolType.Knot\n : SymbolType_1.SymbolType.SubFlowAndWeave;\n context.CheckForNamingCollisions(this, this.identifier, symbolType);\n }\n }\n}\nexports.FlowBase = FlowBase;\n//# sourceMappingURL=FlowBase.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ContentList = void 0;\nconst Container_1 = require(\"../../../engine/Container\");\nconst Object_1 = require(\"./Object\");\nconst Text_1 = require(\"./Text\");\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\nclass ContentList extends Object_1.ParsedObject {\n get runtimeContainer() {\n return this.runtimeObject;\n }\n constructor(objects, ...moreObjects) {\n super();\n this.dontFlatten = false;\n this.TrimTrailingWhitespace = () => {\n for (let ii = this.content.length - 1; ii >= 0; --ii) {\n const text = (0, TypeAssertion_1.asOrNull)(this.content[ii], Text_1.Text);\n if (text === null) {\n break;\n }\n text.text = text.text.replace(new RegExp(/[ \\t]/g), \"\");\n if (text.text.length === 0) {\n this.content.splice(ii, 1);\n }\n else {\n break;\n }\n }\n };\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n if (this.content !== null) {\n for (const obj of this.content) {\n const contentObjRuntime = obj.runtimeObject;\n // Some objects (e.g. author warnings) don't generate runtime objects\n if (contentObjRuntime) {\n container.AddContent(contentObjRuntime);\n }\n }\n }\n if (this.dontFlatten) {\n this.story.DontFlattenContainer(container);\n }\n return container;\n };\n this.toString = () => `ContentList(${this.content.join(\", \")})`;\n if (objects) {\n this.AddContent(objects);\n }\n if (moreObjects) {\n this.AddContent(moreObjects);\n }\n }\n get typeName() {\n return \"ContentList\";\n }\n}\nexports.ContentList = ContentList;\n//# sourceMappingURL=ContentList.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VariableReference = void 0;\nconst Object_1 = require(\"./Object\");\nconst Path_1 = require(\"./Path\");\nclass VariableReference extends Object_1.InkObject {\n get containerForCount() {\n if (this.pathForCount === null)\n return null;\n return this.ResolvePath(this.pathForCount).container;\n }\n get pathStringForCount() {\n if (this.pathForCount === null)\n return null;\n return this.CompactPathString(this.pathForCount);\n }\n set pathStringForCount(value) {\n if (value === null)\n this.pathForCount = null;\n else\n this.pathForCount = new Path_1.Path(value);\n }\n constructor(name = null) {\n super();\n this.pathForCount = null;\n this.name = name;\n }\n toString() {\n if (this.name != null) {\n return \"var(\" + this.name + \")\";\n }\n else {\n let pathStr = this.pathStringForCount;\n return \"read_count(\" + pathStr + \")\";\n }\n }\n}\nexports.VariableReference = VariableReference;\n//# sourceMappingURL=VariableReference.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VariableReference = void 0;\nconst ContentList_1 = require(\"../ContentList\");\nconst Expression_1 = require(\"../Expression/Expression\");\nconst FlowBase_1 = require(\"../Flow/FlowBase\");\nconst Path_1 = require(\"../Path\");\nconst VariableReference_1 = require(\"../../../../engine/VariableReference\");\nconst Weave_1 = require(\"../Weave\");\nconst Identifier_1 = require(\"../Identifier\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass VariableReference extends Expression_1.Expression {\n // - Normal variables have a single item in their \"path\"\n // - Knot/stitch names for read counts are actual dot-separated paths\n // (though this isn't actually used at time of writing)\n // - List names are dot separated: listName.itemName (or just itemName)\n get name() {\n return this.path.join(\".\");\n }\n get path() {\n return this.pathIdentifiers.map((id) => id.name).filter(TypeAssertion_1.filterUndef);\n }\n get identifier() {\n if (!this.pathIdentifiers || this.pathIdentifiers.length == 0) {\n return null;\n }\n const name = this.path.join(\".\");\n const id = new Identifier_1.Identifier(name);\n return id;\n }\n get runtimeVarRef() {\n return this._runtimeVarRef;\n }\n constructor(pathIdentifiers) {\n super();\n this.pathIdentifiers = pathIdentifiers;\n this._runtimeVarRef = null;\n // Only known after GenerateIntoContainer has run\n this.isConstantReference = false;\n this.isListItemReference = false;\n this.GenerateIntoContainer = (container) => {\n let constantValue = this.story.constants.get(this.name);\n // If it's a constant reference, just generate the literal expression value\n // It's okay to access the constants at code generation time, since the\n // first thing the ExportRuntime function does it search for all the constants\n // in the story hierarchy, so they're all available.\n if (constantValue) {\n constantValue.GenerateConstantIntoContainer(container);\n this.isConstantReference = true;\n return;\n }\n this._runtimeVarRef = new VariableReference_1.VariableReference(this.name);\n // List item reference?\n // Path might be to a list (listName.listItemName or just listItemName)\n if (this.path.length === 1 || this.path.length === 2) {\n let listItemName = \"\";\n let listName = \"\";\n if (this.path.length === 1) {\n listItemName = this.path[0];\n }\n else {\n listName = this.path[0];\n listItemName = this.path[1];\n }\n const listItem = this.story.ResolveListItem(listName, listItemName, this);\n if (listItem) {\n this.isListItemReference = true;\n }\n }\n container.AddContent(this._runtimeVarRef);\n };\n this.toString = () => `{${this.path.join(\".\")}}`;\n }\n get typeName() {\n return \"ref\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n // Work is already done if it's a constant or list item reference\n if (this.isConstantReference || this.isListItemReference) {\n return;\n }\n // Is it a read count?\n const parsedPath = new Path_1.Path(this.pathIdentifiers);\n const targetForCount = parsedPath.ResolveFromContext(this);\n if (targetForCount) {\n if (!targetForCount.containerForCounting) {\n throw new Error();\n }\n targetForCount.containerForCounting.visitsShouldBeCounted = true;\n // If this is an argument to a function that wants a variable to be\n // passed by reference, then the Parsed.Divert will have generated a\n // Runtime.VariablePointerValue instead of allowing this object\n // to generate its RuntimeVariableReference. This only happens under\n // error condition since we shouldn't be passing a read count by\n // reference, but we don't want it to crash!\n if (this._runtimeVarRef === null) {\n return;\n }\n this._runtimeVarRef.pathForCount = targetForCount.runtimePath;\n this._runtimeVarRef.name = null;\n // Check for very specific writer error: getting read count and\n // printing it as content rather than as a piece of logic\n // e.g. Writing {myFunc} instead of {myFunc()}\n let targetFlow = (0, TypeAssertion_1.asOrNull)(targetForCount, FlowBase_1.FlowBase);\n if (targetFlow && targetFlow.isFunction) {\n // Is parent context content rather than logic?\n if (this.parent instanceof Weave_1.Weave ||\n this.parent instanceof ContentList_1.ContentList ||\n this.parent instanceof FlowBase_1.FlowBase) {\n this.Warning(`'${targetFlow.identifier}' being used as read count rather than being called as function. Perhaps you intended to write ${targetFlow.identifier}()`);\n }\n }\n return;\n }\n // Couldn't find this multi-part path at all, whether as a divert\n // target or as a list item reference.\n if (this.path.length > 1) {\n let errorMsg = `Could not find target for read count: ${parsedPath}`;\n if (this.path.length <= 2) {\n errorMsg += `, or couldn't find list item with the name ${this.path.join(\",\")}`;\n }\n this.Error(errorMsg);\n return;\n }\n if (!context.ResolveVariableWithName(this.name, this).found) {\n this.Error(`Unresolved variable: ${this.name}`, this);\n }\n }\n}\nexports.VariableReference = VariableReference;\n//# sourceMappingURL=VariableReference.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.FunctionCall = void 0;\nconst ControlCommand_1 = require(\"../../../engine/ControlCommand\");\nconst Divert_1 = require(\"./Divert/Divert\");\nconst DivertTarget_1 = require(\"./Divert/DivertTarget\");\nconst Expression_1 = require(\"./Expression/Expression\");\nconst InkList_1 = require(\"../../../engine/InkList\");\nconst Value_1 = require(\"../../../engine/Value\");\nconst NativeFunctionCall_1 = require(\"../../../engine/NativeFunctionCall\");\nconst NumberExpression_1 = require(\"./Expression/NumberExpression\");\nconst Path_1 = require(\"./Path\");\nconst Value_2 = require(\"../../../engine/Value\");\nconst VariableReference_1 = require(\"./Variable/VariableReference\");\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\nclass FunctionCall extends Expression_1.Expression {\n get proxyDivert() {\n return this._proxyDivert;\n }\n get name() {\n return this._proxyDivert.target.firstComponent || \"\";\n }\n get args() {\n return this._proxyDivert.args;\n }\n get runtimeDivert() {\n return this._proxyDivert.runtimeDivert;\n }\n get isChoiceCount() {\n return this.name === \"CHOICE_COUNT\";\n }\n get isTurns() {\n return this.name === \"TURNS\";\n }\n get isTurnsSince() {\n return this.name === \"TURNS_SINCE\";\n }\n get isRandom() {\n return this.name === \"RANDOM\";\n }\n get isSeedRandom() {\n return this.name === \"SEED_RANDOM\";\n }\n get isListRange() {\n return this.name === \"LIST_RANGE\";\n }\n get isListRandom() {\n return this.name === \"LIST_RANDOM\";\n }\n get isReadCount() {\n return this.name === \"READ_COUNT\";\n }\n constructor(functionName, args) {\n super();\n this._divertTargetToCount = null;\n this._variableReferenceToCount = null;\n this.shouldPopReturnedValue = false;\n this.GenerateIntoContainer = (container) => {\n const foundList = this.story.ResolveList(this.name);\n let usingProxyDivert = false;\n if (this.isChoiceCount) {\n if (this.args.length > 0) {\n this.Error(\"The CHOICE_COUNT() function shouldn't take any arguments\");\n }\n container.AddContent(ControlCommand_1.ControlCommand.ChoiceCount());\n }\n else if (this.isTurns) {\n if (this.args.length > 0) {\n this.Error(\"The TURNS() function shouldn't take any arguments\");\n }\n container.AddContent(ControlCommand_1.ControlCommand.Turns());\n }\n else if (this.isTurnsSince || this.isReadCount) {\n const divertTarget = (0, TypeAssertion_1.asOrNull)(this.args[0], DivertTarget_1.DivertTarget);\n const variableDivertTarget = (0, TypeAssertion_1.asOrNull)(this.args[0], VariableReference_1.VariableReference);\n if (this.args.length !== 1 ||\n (divertTarget === null && variableDivertTarget === null)) {\n this.Error(`The ${this.name}() function should take one argument: a divert target to the target knot, stitch, gather or choice you want to check. e.g. TURNS_SINCE(-> myKnot)`);\n return;\n }\n if (divertTarget) {\n this._divertTargetToCount = divertTarget;\n this.AddContent(this._divertTargetToCount);\n this._divertTargetToCount.GenerateIntoContainer(container);\n }\n else if (variableDivertTarget) {\n this._variableReferenceToCount = variableDivertTarget;\n this.AddContent(this._variableReferenceToCount);\n this._variableReferenceToCount.GenerateIntoContainer(container);\n }\n if (this.isTurnsSince) {\n container.AddContent(ControlCommand_1.ControlCommand.TurnsSince());\n }\n else {\n container.AddContent(ControlCommand_1.ControlCommand.ReadCount());\n }\n }\n else if (this.isRandom) {\n if (this.args.length !== 2) {\n this.Error(\"RANDOM should take 2 parameters: a minimum and a maximum integer\");\n }\n // We can type check single values, but not complex expressions\n for (let ii = 0; ii < this.args.length; ii += 1) {\n const num = (0, TypeAssertion_1.asOrNull)(this.args[ii], NumberExpression_1.NumberExpression);\n if (num && !num.isInt()) {\n const paramName = ii === 0 ? \"minimum\" : \"maximum\";\n this.Error(`RANDOM's ${paramName} parameter should be an integer`);\n }\n this.args[ii].GenerateIntoContainer(container);\n }\n container.AddContent(ControlCommand_1.ControlCommand.Random());\n }\n else if (this.isSeedRandom) {\n if (this.args.length !== 1) {\n this.Error(\"SEED_RANDOM should take 1 parameter - an integer seed\");\n }\n const num = (0, TypeAssertion_1.asOrNull)(this.args[0], NumberExpression_1.NumberExpression);\n if (num && !num.isInt()) {\n this.Error(\"SEED_RANDOM's parameter should be an integer seed\");\n }\n this.args[0].GenerateIntoContainer(container);\n container.AddContent(ControlCommand_1.ControlCommand.SeedRandom());\n }\n else if (this.isListRange) {\n if (this.args.length !== 3) {\n this.Error(\"LIST_RANGE should take 3 parameters - a list, a min and a max\");\n }\n for (let ii = 0; ii < this.args.length; ii += 1) {\n this.args[ii].GenerateIntoContainer(container);\n }\n container.AddContent(ControlCommand_1.ControlCommand.ListRange());\n }\n else if (this.isListRandom) {\n if (this.args.length !== 1) {\n this.Error(\"LIST_RANDOM should take 1 parameter - a list\");\n }\n this.args[0].GenerateIntoContainer(container);\n container.AddContent(ControlCommand_1.ControlCommand.ListRandom());\n }\n else if (NativeFunctionCall_1.NativeFunctionCall.CallExistsWithName(this.name)) {\n const nativeCall = NativeFunctionCall_1.NativeFunctionCall.CallWithName(this.name);\n if (nativeCall.numberOfParameters !== this.args.length) {\n let msg = `${FunctionCall.name} should take ${nativeCall.numberOfParameters} parameter`;\n if (nativeCall.numberOfParameters > 1) {\n msg += \"s\";\n }\n this.Error(msg);\n }\n for (let ii = 0; ii < this.args.length; ii += 1) {\n this.args[ii].GenerateIntoContainer(container);\n }\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(this.name));\n }\n else if (foundList !== null) {\n if (this.args.length > 1) {\n this.Error(\"Can currently only construct a list from one integer (or an empty list from a given list definition)\");\n }\n // List item from given int\n if (this.args.length === 1) {\n container.AddContent(new Value_2.StringValue(this.name));\n this.args[0].GenerateIntoContainer(container);\n container.AddContent(ControlCommand_1.ControlCommand.ListFromInt());\n }\n else {\n // Empty list with given origin.\n const list = new InkList_1.InkList();\n list.SetInitialOriginName(this.name);\n container.AddContent(new Value_1.ListValue(list));\n }\n }\n else {\n // Normal function call\n container.AddContent(this._proxyDivert.runtimeObject);\n usingProxyDivert = true;\n }\n // Don't attempt to resolve as a divert if we're not doing a normal function call\n if (!usingProxyDivert) {\n this.content.splice(this.content.indexOf(this._proxyDivert), 1);\n }\n // Function calls that are used alone on a tilda-based line:\n // ~ func()\n // Should tidy up any returned value from the evaluation stack,\n // since it's unused.\n if (this.shouldPopReturnedValue) {\n container.AddContent(ControlCommand_1.ControlCommand.PopEvaluatedValue());\n }\n };\n this.toString = () => {\n const strArgs = this.args.join(\", \");\n return `${this.name}(${strArgs})`;\n };\n this._proxyDivert = new Divert_1.Divert(new Path_1.Path(functionName), args);\n this._proxyDivert.isFunctionCall = true;\n this.AddContent(this._proxyDivert);\n }\n get typeName() {\n return \"FunctionCall\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n // If we aren't using the proxy divert after all (e.g. if\n // it's a native function call), but we still have arguments,\n // we need to make sure they get resolved since the proxy divert\n // is no longer in the content array.\n if (!this.content.includes(this._proxyDivert) && this.args !== null) {\n for (const arg of this.args) {\n arg.ResolveReferences(context);\n }\n }\n if (this._divertTargetToCount) {\n const divert = this._divertTargetToCount.divert;\n const attemptingTurnCountOfVariableTarget = divert.runtimeDivert.variableDivertName != null;\n if (attemptingTurnCountOfVariableTarget) {\n this.Error(`When getting the TURNS_SINCE() of a variable target, remove the '->' - i.e. it should just be TURNS_SINCE(${divert.runtimeDivert.variableDivertName})`);\n return;\n }\n const targetObject = divert.targetContent;\n if (targetObject === null) {\n if (!attemptingTurnCountOfVariableTarget) {\n this.Error(`Failed to find target for TURNS_SINCE: '${divert.target}'`);\n }\n }\n else {\n if (!targetObject.containerForCounting) {\n throw new Error();\n }\n targetObject.containerForCounting.turnIndexShouldBeCounted = true;\n }\n }\n else if (this._variableReferenceToCount) {\n const runtimeVarRef = this._variableReferenceToCount.runtimeVarRef;\n if (!runtimeVarRef) {\n throw new Error();\n }\n if (runtimeVarRef.pathForCount !== null) {\n this.Error(`Should be '${FunctionCall.name}'(-> '${this._variableReferenceToCount.name}). Usage without the '->' only makes sense for variable targets.`);\n }\n }\n }\n}\nexports.FunctionCall = FunctionCall;\nFunctionCall.IsBuiltIn = (name) => {\n if (NativeFunctionCall_1.NativeFunctionCall.CallExistsWithName(name)) {\n return true;\n }\n return (name === \"CHOICE_COUNT\" ||\n name === \"TURNS_SINCE\" ||\n name === \"TURNS\" ||\n name === \"RANDOM\" ||\n name === \"SEED_RANDOM\" ||\n name === \"LIST_VALUE\" ||\n name === \"LIST_RANDOM\" ||\n name === \"READ_COUNT\");\n};\n//# sourceMappingURL=FunctionCall.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.MultipleConditionExpression = void 0;\nconst Expression_1 = require(\"./Expression\");\nconst NativeFunctionCall_1 = require(\"../../../../engine/NativeFunctionCall\");\nclass MultipleConditionExpression extends Expression_1.Expression {\n get subExpressions() {\n return this.content;\n }\n constructor(conditionExpressions) {\n super();\n this.GenerateIntoContainer = (container) => {\n // A && B && C && D\n // => (((A B &&) C &&) D &&) etc\n let isFirst = true;\n for (const conditionExpr of this.subExpressions) {\n conditionExpr.GenerateIntoContainer(container);\n if (!isFirst) {\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(\"&&\"));\n }\n isFirst = false;\n }\n };\n this.AddContent(conditionExpressions);\n }\n get typeName() {\n return \"MultipleConditionExpression\";\n }\n}\nexports.MultipleConditionExpression = MultipleConditionExpression;\n//# sourceMappingURL=MultipleConditionExpression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DivertTarget = void 0;\nconst BinaryExpression_1 = require(\"../Expression/BinaryExpression\");\nconst Choice_1 = require(\"../Choice\");\nconst Conditional_1 = require(\"../Conditional/Conditional\");\nconst ConditionalSingleBranch_1 = require(\"../Conditional/ConditionalSingleBranch\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst Expression_1 = require(\"../Expression/Expression\");\nconst FlowBase_1 = require(\"../Flow/FlowBase\");\nconst FunctionCall_1 = require(\"../FunctionCall\");\nconst MultipleConditionExpression_1 = require(\"../Expression/MultipleConditionExpression\");\nconst VariableReference_1 = require(\"../Variable/VariableReference\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass DivertTarget extends Expression_1.Expression {\n get runtimeDivert() {\n if (!this._runtimeDivert) {\n throw new Error();\n }\n return this._runtimeDivert;\n }\n get runtimeDivertTargetValue() {\n if (!this._runtimeDivertTargetValue) {\n throw new Error();\n }\n return this._runtimeDivertTargetValue;\n }\n constructor(divert) {\n super();\n this._runtimeDivert = null;\n this._runtimeDivertTargetValue = null;\n this.GenerateIntoContainer = (container) => {\n this.divert.GenerateRuntimeObject();\n this._runtimeDivert = this.divert.runtimeDivert;\n this._runtimeDivertTargetValue = new Value_1.DivertTargetValue();\n container.AddContent(this.runtimeDivertTargetValue);\n };\n // Equals override necessary in order to check for CONST multiple definition equality\n this.Equals = (obj) => {\n const otherDivTarget = (0, TypeAssertion_1.asOrNull)(obj, DivertTarget);\n if (!otherDivTarget ||\n !this.divert.target ||\n !otherDivTarget.divert.target) {\n return false;\n }\n const targetStr = this.divert.target.dotSeparatedComponents;\n const otherTargetStr = otherDivTarget.divert.target.dotSeparatedComponents;\n return targetStr === otherTargetStr;\n };\n this.divert = this.AddContent(divert);\n }\n get typeName() {\n return \"DivertTarget\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n if (this.divert.isDone || this.divert.isEnd) {\n this.Error(`Can't use -> DONE or -> END as variable divert targets`, this);\n return;\n }\n let usageContext = this;\n while (usageContext && usageContext instanceof Expression_1.Expression) {\n let badUsage = false;\n let foundUsage = false;\n const usageParent = usageContext.parent;\n if (usageParent instanceof BinaryExpression_1.BinaryExpression) {\n // Only allowed to compare for equality\n const binaryExprParent = usageParent;\n if (binaryExprParent.opName !== \"==\" &&\n binaryExprParent.opName !== \"!=\") {\n badUsage = true;\n }\n else {\n if (!(binaryExprParent.leftExpression instanceof DivertTarget ||\n binaryExprParent.leftExpression instanceof VariableReference_1.VariableReference)) {\n badUsage = true;\n }\n else if (!(binaryExprParent.rightExpression instanceof DivertTarget ||\n binaryExprParent.rightExpression instanceof VariableReference_1.VariableReference)) {\n badUsage = true;\n }\n }\n foundUsage = true;\n }\n else if (usageParent instanceof FunctionCall_1.FunctionCall) {\n const funcCall = usageParent;\n if (!funcCall.isTurnsSince && !funcCall.isReadCount) {\n badUsage = true;\n }\n foundUsage = true;\n }\n else if (usageParent instanceof Expression_1.Expression) {\n badUsage = true;\n foundUsage = true;\n }\n else if (usageParent instanceof MultipleConditionExpression_1.MultipleConditionExpression) {\n badUsage = true;\n foundUsage = true;\n }\n else if (usageParent instanceof Choice_1.Choice &&\n usageParent.condition === usageContext) {\n badUsage = true;\n foundUsage = true;\n }\n else if (usageParent instanceof Conditional_1.Conditional ||\n usageParent instanceof ConditionalSingleBranch_1.ConditionalSingleBranch) {\n badUsage = true;\n foundUsage = true;\n }\n if (badUsage) {\n this.Error(`Can't use a divert target like that. Did you intend to call '${this.divert.target}' as a function: likeThis(), or check the read count: likeThis, with no arrows?`, this);\n }\n if (foundUsage) {\n break;\n }\n usageContext = usageParent;\n }\n // Example ink for this case:\n //\n // VAR x = -> blah\n //\n // ...which means that \"blah\" is expected to be a literal stitch target rather\n // than a variable name. We can't really intelligently recover from this (e.g. if blah happens to\n // contain a divert target itself) since really we should be generating a variable reference\n // rather than a concrete DivertTarget, so we list it as an error.\n if (this.runtimeDivert.hasVariableTarget) {\n if (!this.divert.target) {\n throw new Error();\n }\n this.Error(`Since '${this.divert.target.dotSeparatedComponents}' is a variable, it shouldn't be preceded by '->' here.`);\n }\n // Main resolve\n this.runtimeDivert.targetPath &&\n (this.runtimeDivertTargetValue.targetPath =\n this.runtimeDivert.targetPath);\n // Tell hard coded (yet variable) divert targets that they also need to be counted\n // TODO: Only detect DivertTargets that are values rather than being used directly for\n // read or turn counts. Should be able to detect this by looking for other uses of containerForCounting\n let targetContent = this.divert.targetContent;\n if (targetContent !== null) {\n let target = targetContent.containerForCounting;\n if (target !== null) {\n // Purpose is known: used directly in TURNS_SINCE(-> divTarg)\n const parentFunc = (0, TypeAssertion_1.asOrNull)(this.parent, FunctionCall_1.FunctionCall);\n if (parentFunc && parentFunc.isTurnsSince) {\n target.turnIndexShouldBeCounted = true;\n }\n else {\n // Unknown purpose, count everything\n target.visitsShouldBeCounted = true;\n target.turnIndexShouldBeCounted = true;\n }\n }\n // Unfortunately not possible:\n // https://github.com/inkle/ink/issues/538\n //\n // VAR func = -> double\n //\n // === function double(ref x)\n // ~ x = x * 2\n //\n // Because when generating the parameters for a function\n // to be called, it needs to know ahead of time when\n // compiling whether to pass a variable reference or value.\n //\n let targetFlow = (0, TypeAssertion_1.asOrNull)(targetContent, FlowBase_1.FlowBase);\n if (targetFlow != null && targetFlow.args !== null) {\n for (const arg of targetFlow.args) {\n if (arg.isByReference) {\n this.Error(`Can't store a divert target to a knot or function that has by-reference arguments ('${targetFlow.identifier}' has 'ref ${arg.identifier}').`);\n }\n }\n }\n }\n }\n}\nexports.DivertTarget = DivertTarget;\n//# sourceMappingURL=DivertTarget.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Divert = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../../engine/ControlCommand\");\nconst Divert_1 = require(\"../../../../engine/Divert\");\nconst DivertTarget_1 = require(\"./DivertTarget\");\nconst FlowBase_1 = require(\"../Flow/FlowBase\");\nconst FunctionCall_1 = require(\"../FunctionCall\");\nconst Object_1 = require(\"../Object\");\nconst Path_1 = require(\"../Path\");\nconst Path_2 = require(\"../../../../engine/Path\");\nconst PushPop_1 = require(\"../../../../engine/PushPop\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst VariableReference_1 = require(\"../Variable/VariableReference\");\nconst ClosestFlowBase_1 = require(\"../Flow/ClosestFlowBase\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass Divert extends Object_1.ParsedObject {\n get runtimeDivert() {\n if (!this._runtimeDivert) {\n throw new Error();\n }\n return this._runtimeDivert;\n }\n set runtimeDivert(value) {\n this._runtimeDivert = value;\n }\n get isEnd() {\n return Boolean(this.target && this.target.dotSeparatedComponents === \"END\");\n }\n get isDone() {\n return Boolean(this.target && this.target.dotSeparatedComponents === \"DONE\");\n }\n constructor(target, args) {\n super();\n this.args = [];\n this.target = null;\n this.targetContent = null;\n this._runtimeDivert = null;\n this.isFunctionCall = false;\n this.isEmpty = false;\n this.isTunnel = false;\n this.isThread = false;\n this.GenerateRuntimeObject = () => {\n // End = end flow immediately\n // Done = return from thread or instruct the flow that it's safe to exit\n if (this.isEnd) {\n return ControlCommand_1.ControlCommand.End();\n }\n else if (this.isDone) {\n return ControlCommand_1.ControlCommand.Done();\n }\n this.runtimeDivert = new Divert_1.Divert();\n // Normally we resolve the target content during the\n // Resolve phase, since we expect all runtime objects to\n // be available in order to find the final runtime path for\n // the destination. However, we need to resolve the target\n // (albeit without the runtime target) early so that\n // we can get information about the arguments - whether\n // they're by reference - since it affects the code we\n // generate here.\n this.ResolveTargetContent();\n this.CheckArgumentValidity();\n // Passing arguments to the knot\n const requiresArgCodeGen = this.args !== null && this.args.length > 0;\n if (requiresArgCodeGen ||\n this.isFunctionCall ||\n this.isTunnel ||\n this.isThread) {\n const container = new Container_1.Container();\n // Generate code for argument evaluation\n // This argument generation is coded defensively - it should\n // attempt to generate the code for all the parameters, even if\n // they don't match the expected arguments. This is so that the\n // parameter objects themselves are generated correctly and don't\n // get into a state of attempting to resolve references etc\n // without being generated.\n if (requiresArgCodeGen) {\n // Function calls already in an evaluation context\n if (!this.isFunctionCall) {\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n }\n let targetArguments = null;\n if (this.targetContent) {\n targetArguments = this.targetContent.args;\n }\n for (let ii = 0; ii < this.args.length; ++ii) {\n const argToPass = this.args[ii];\n let argExpected = null;\n if (targetArguments && ii < targetArguments.length) {\n argExpected = targetArguments[ii];\n }\n // Pass by reference: argument needs to be a variable reference\n if (argExpected && argExpected.isByReference) {\n const varRef = (0, TypeAssertion_1.asOrNull)(argToPass, VariableReference_1.VariableReference);\n if (!varRef) {\n this.Error(`Expected variable name to pass by reference to 'ref ${argExpected.identifier}' but saw ${argToPass}`);\n break;\n }\n // Check that we're not attempting to pass a read count by reference\n const targetPath = new Path_1.Path(varRef.pathIdentifiers);\n const targetForCount = targetPath.ResolveFromContext(this);\n if (targetForCount) {\n this.Error(`can't pass a read count by reference. '${targetPath.dotSeparatedComponents}' is a knot/stitch/label, but '${this.target.dotSeparatedComponents}' requires the name of a VAR to be passed.`);\n break;\n }\n const varPointer = new Value_1.VariablePointerValue(varRef.name);\n container.AddContent(varPointer);\n }\n else {\n // Normal value being passed: evaluate it as normal\n argToPass.GenerateIntoContainer(container);\n }\n }\n // Function calls were already in an evaluation context\n if (!this.isFunctionCall) {\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n }\n }\n // Starting a thread? A bit like a push to the call stack below... but not.\n // It sort of puts the call stack on a thread stack (argh!) - forks the full flow.\n if (this.isThread) {\n container.AddContent(ControlCommand_1.ControlCommand.StartThread());\n }\n else if (this.isFunctionCall || this.isTunnel) {\n // If this divert is a function call, tunnel, we push to the call stack\n // so we can return again\n this.runtimeDivert.pushesToStack = true;\n this.runtimeDivert.stackPushType = this.isFunctionCall\n ? PushPop_1.PushPopType.Function\n : PushPop_1.PushPopType.Tunnel;\n }\n // Jump into the \"function\" (knot/stitch)\n container.AddContent(this.runtimeDivert);\n return container;\n }\n // Simple divert\n return this.runtimeDivert;\n };\n // When the divert is to a target that's actually a variable name\n // rather than an explicit knot/stitch name, try interpretting it\n // as such by getting the variable name.\n this.PathAsVariableName = () => this.target ? this.target.firstComponent : null;\n this.ResolveTargetContent = () => {\n if (this.isEmpty || this.isEnd) {\n return;\n }\n if (this.targetContent === null) {\n // Is target of this divert a variable name that will be de-referenced\n // at runtime? If so, there won't be any further reference resolution\n // we can do at this point.\n let variableTargetName = this.PathAsVariableName();\n if (variableTargetName !== null) {\n const flowBaseScope = (0, TypeAssertion_1.asOrNull)((0, ClosestFlowBase_1.ClosestFlowBase)(this), FlowBase_1.FlowBase);\n if (flowBaseScope) {\n const resolveResult = flowBaseScope.ResolveVariableWithName(variableTargetName, this);\n if (resolveResult.found) {\n // Make sure that the flow was typed correctly, given that we know that this\n // is meant to be a divert target\n if (resolveResult.isArgument &&\n resolveResult.ownerFlow &&\n resolveResult.ownerFlow.args) {\n let argument = resolveResult.ownerFlow.args.find((a) => { var _a; return ((_a = a.identifier) === null || _a === void 0 ? void 0 : _a.name) == variableTargetName; });\n if (argument && !argument.isDivertTarget) {\n this.Error(`Since '${argument.identifier}' is used as a variable divert target (on ${this.debugMetadata}), it should be marked as: -> ${argument.identifier}`, resolveResult.ownerFlow);\n }\n }\n this.runtimeDivert.variableDivertName = variableTargetName;\n return;\n }\n }\n }\n if (!this.target) {\n throw new Error();\n }\n this.targetContent = this.target.ResolveFromContext(this);\n }\n };\n // Returns false if there's an error\n this.CheckArgumentValidity = () => {\n if (this.isEmpty) {\n return;\n }\n // Argument passing: Check for errors in number of arguments\n let numArgs = 0;\n if (this.args !== null && this.args.length > 0) {\n numArgs = this.args.length;\n }\n // Missing content?\n // Can't check arguments properly. It'll be due to some\n // other error though, so although there's a problem and\n // we report false, we don't need to report a specific error.\n // It may also be because it's a valid call to an external\n // function, that we check at the resolve stage.\n if (this.targetContent === null) {\n return;\n }\n const targetFlow = (0, TypeAssertion_1.asOrNull)(this.targetContent, FlowBase_1.FlowBase);\n // No error, crikey!\n if (numArgs === 0 && (targetFlow === null || !targetFlow.hasParameters)) {\n return;\n }\n else if (targetFlow === null && numArgs > 0) {\n this.Error(\"target needs to be a knot or stitch in order to pass arguments\");\n return;\n }\n else if (targetFlow !== null &&\n (targetFlow.args === null || (!targetFlow.args && numArgs > 0))) {\n this.Error(`target (${targetFlow.name}) doesn't take parameters`);\n return;\n }\n else if (this.parent instanceof DivertTarget_1.DivertTarget) {\n if (numArgs > 0) {\n this.Error(`can't store arguments in a divert target variable`);\n }\n return;\n }\n const paramCount = targetFlow.args.length;\n if (paramCount !== numArgs) {\n let butClause;\n if (numArgs === 0) {\n butClause = \"but there weren't any passed to it\";\n }\n else if (numArgs < paramCount) {\n butClause = `but only got ${numArgs}`;\n }\n else {\n butClause = `but got ${numArgs}`;\n }\n this.Error(`to '${targetFlow.identifier}' requires ${paramCount} arguments, ${butClause}`);\n return;\n }\n // Light type-checking for divert target arguments\n for (let ii = 0; ii < paramCount; ++ii) {\n const flowArg = targetFlow.args[ii];\n const divArgExpr = this.args[ii];\n // Expecting a divert target as an argument, let's do some basic type checking\n if (flowArg.isDivertTarget) {\n // Not passing a divert target or any kind of variable reference?\n let varRef = (0, TypeAssertion_1.asOrNull)(divArgExpr, VariableReference_1.VariableReference);\n if (!(divArgExpr instanceof DivertTarget_1.DivertTarget) && varRef === null) {\n this.Error(`Target '${targetFlow.identifier}' expects a divert target for the parameter named -> ${flowArg.identifier} but saw ${divArgExpr}`, divArgExpr);\n }\n else if (varRef) {\n // Passing 'a' instead of '-> a'?\n // i.e. read count instead of divert target\n // Unfortunately have to manually resolve here since we're still in code gen\n const knotCountPath = new Path_1.Path(varRef.pathIdentifiers);\n const targetForCount = knotCountPath.ResolveFromContext(varRef);\n if (targetForCount) {\n this.Error(`Passing read count of '${knotCountPath.dotSeparatedComponents}' instead of a divert target. You probably meant '${knotCountPath}'`);\n }\n }\n }\n }\n if (targetFlow === null) {\n this.Error(\"Can't call as a function or with arguments unless it's a knot or stitch\");\n return;\n }\n return;\n };\n this.CheckExternalArgumentValidity = (context) => {\n const externalName = this.target\n ? this.target.firstComponent\n : null;\n const external = context.externals.get(externalName);\n if (!external) {\n throw new Error(\"external not found\");\n }\n const externalArgCount = external.argumentNames.length;\n let ownArgCount = 0;\n if (this.args) {\n ownArgCount = this.args.length;\n }\n if (ownArgCount !== externalArgCount) {\n this.Error(`incorrect number of arguments sent to external function '${externalName}'. Expected ${externalArgCount} but got ${ownArgCount}`);\n }\n };\n this.toString = () => {\n let returnString = \"\";\n if (this.target !== null) {\n returnString += this.target.toString();\n }\n else {\n return \"-> <empty divert>\";\n }\n if (this.isTunnel) {\n returnString += \" ->\";\n }\n if (this.isFunctionCall) {\n returnString += \" ()\";\n }\n return returnString;\n };\n if (target) {\n this.target = target;\n }\n if (args) {\n this.args = args;\n this.AddContent(args);\n }\n }\n get typeName() {\n return \"Divert\";\n }\n ResolveReferences(context) {\n if (this.isEmpty || this.isEnd || this.isDone) {\n return;\n }\n else if (!this.runtimeDivert) {\n throw new Error();\n }\n if (this.targetContent) {\n this.runtimeDivert.targetPath = this.targetContent.runtimePath;\n }\n // Resolve children (the arguments)\n super.ResolveReferences(context);\n // May be null if it's a built in function (e.g. TURNS_SINCE)\n // or if it's a variable target.\n let targetFlow = (0, TypeAssertion_1.asOrNull)(this.targetContent, FlowBase_1.FlowBase);\n if (targetFlow) {\n if (!targetFlow.isFunction && this.isFunctionCall) {\n super.Error(`${targetFlow.identifier} hasn't been marked as a function, but it's being called as one. Do you need to declare the knot as '== function ${targetFlow.identifier} =='?`);\n }\n else if (targetFlow.isFunction &&\n !this.isFunctionCall &&\n !(this.parent instanceof DivertTarget_1.DivertTarget)) {\n super.Error(targetFlow.identifier +\n \" can't be diverted to. It can only be called as a function since it's been marked as such: '\" +\n targetFlow.identifier +\n \"(...)'\");\n }\n }\n // Check validity of target content\n const targetWasFound = this.targetContent !== null;\n let isBuiltIn = false;\n let isExternal = false;\n if (!this.target) {\n throw new Error();\n }\n else if (this.target.numberOfComponents === 1) {\n if (!this.target.firstComponent) {\n throw new Error();\n }\n // BuiltIn means TURNS_SINCE, CHOICE_COUNT, RANDOM or SEED_RANDOM\n isBuiltIn = FunctionCall_1.FunctionCall.IsBuiltIn(this.target.firstComponent);\n // Client-bound function?\n isExternal = context.IsExternal(this.target.firstComponent);\n if (isBuiltIn || isExternal) {\n if (!this.isFunctionCall) {\n super.Error(`${this.target.firstComponent} must be called as a function: ~ ${this.target.firstComponent}()`);\n }\n if (isExternal) {\n this.runtimeDivert.isExternal = true;\n if (this.args !== null) {\n this.runtimeDivert.externalArgs = this.args.length;\n }\n this.runtimeDivert.pushesToStack = false;\n this.runtimeDivert.targetPath = new Path_2.Path(this.target.firstComponent);\n this.CheckExternalArgumentValidity(context);\n }\n return;\n }\n }\n // Variable target?\n if (this.runtimeDivert.variableDivertName != null) {\n return;\n }\n if (!targetWasFound && !isBuiltIn && !isExternal) {\n this.Error(`target not found: '${this.target}'`);\n }\n }\n Error(message, source = null, isWarning = false) {\n // Could be getting an error from a nested Divert\n if (source !== this && source) {\n super.Error(message, source);\n return;\n }\n if (this.isFunctionCall) {\n super.Error(`Function call ${message}`, source, isWarning);\n }\n else {\n super.Error(`Divert ${message}`, source, isWarning);\n }\n }\n}\nexports.Divert = Divert;\n//# sourceMappingURL=Divert.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GatherPointToResolve = void 0;\nclass GatherPointToResolve {\n constructor(divert, targetRuntimeObj) {\n this.divert = divert;\n this.targetRuntimeObj = targetRuntimeObj;\n }\n}\nexports.GatherPointToResolve = GatherPointToResolve;\n//# sourceMappingURL=GatherPointToResolve.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SequenceDivertToResolve = void 0;\nclass SequenceDivertToResolve {\n constructor(divert, targetContent) {\n this.divert = divert;\n this.targetContent = targetContent;\n }\n}\nexports.SequenceDivertToResolve = SequenceDivertToResolve;\n//# sourceMappingURL=SequenceDivertToResolve.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SequenceType = void 0;\nvar SequenceType;\n(function (SequenceType) {\n SequenceType[SequenceType[\"Stopping\"] = 1] = \"Stopping\";\n SequenceType[SequenceType[\"Cycle\"] = 2] = \"Cycle\";\n SequenceType[SequenceType[\"Shuffle\"] = 4] = \"Shuffle\";\n SequenceType[SequenceType[\"Once\"] = 8] = \"Once\";\n})(SequenceType || (exports.SequenceType = SequenceType = {}));\n//# sourceMappingURL=SequenceType.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Sequence = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../../engine/ControlCommand\");\nconst Divert_1 = require(\"../../../../engine/Divert\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst NativeFunctionCall_1 = require(\"../../../../engine/NativeFunctionCall\");\nconst Object_1 = require(\"../Object\");\nconst SequenceDivertToResolve_1 = require(\"./SequenceDivertToResolve\");\nconst SequenceType_1 = require(\"./SequenceType\");\nconst Weave_1 = require(\"../Weave\");\nclass Sequence extends Object_1.ParsedObject {\n constructor(elementContentLists, sequenceType) {\n super();\n this.sequenceType = sequenceType;\n this._sequenceDivertsToResolve = [];\n // Generate runtime code that looks like:\n //\n // chosenIndex = MIN(sequence counter, num elements) e.g. for \"Stopping\"\n // if chosenIndex == 0, divert to s0\n // if chosenIndex == 1, divert to s1 [etc]\n //\n // - s0:\n // <content for sequence element>\n // divert to no-op\n // - s1:\n // <content for sequence element>\n // divert to no-op\n // - s2:\n // empty branch if using \"once\"\n // divert to no-op\n //\n // no-op\n //\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n container.visitsShouldBeCounted = true;\n container.countingAtStartOnly = true;\n this._sequenceDivertsToResolve = [];\n // Get sequence read count\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n container.AddContent(ControlCommand_1.ControlCommand.VisitIndex());\n const once = (this.sequenceType & SequenceType_1.SequenceType.Once) > 0;\n const cycle = (this.sequenceType & SequenceType_1.SequenceType.Cycle) > 0;\n const stopping = (this.sequenceType & SequenceType_1.SequenceType.Stopping) > 0;\n const shuffle = (this.sequenceType & SequenceType_1.SequenceType.Shuffle) > 0;\n let seqBranchCount = this.sequenceElements.length;\n if (once) {\n seqBranchCount += 1;\n }\n // Chosen sequence index:\n // - Stopping: take the MIN(read count, num elements - 1)\n // - Once: take the MIN(read count, num elements)\n // (the last one being empty)\n if (stopping || once) {\n //var limit = stopping ? seqBranchCount-1 : seqBranchCount;\n container.AddContent(new Value_1.IntValue(seqBranchCount - 1));\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(\"MIN\"));\n }\n else if (cycle) {\n // - Cycle: take (read count % num elements)\n container.AddContent(new Value_1.IntValue(this.sequenceElements.length));\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(\"%\"));\n }\n // Shuffle\n if (shuffle) {\n // Create point to return to when sequence is complete\n const postShuffleNoOp = ControlCommand_1.ControlCommand.NoOp();\n // When visitIndex == lastIdx, we skip the shuffle\n if (once || stopping) {\n // if( visitIndex == lastIdx ) -> skipShuffle\n const lastIdx = stopping\n ? this.sequenceElements.length - 1\n : this.sequenceElements.length;\n container.AddContent(ControlCommand_1.ControlCommand.Duplicate());\n container.AddContent(new Value_1.IntValue(lastIdx));\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(\"==\"));\n const skipShuffleDivert = new Divert_1.Divert();\n skipShuffleDivert.isConditional = true;\n container.AddContent(skipShuffleDivert);\n this.AddDivertToResolve(skipShuffleDivert, postShuffleNoOp);\n }\n // This one's a bit more complex! Choose the index at runtime.\n let elementCountToShuffle = this.sequenceElements.length;\n if (stopping) {\n elementCountToShuffle -= 1;\n }\n container.AddContent(new Value_1.IntValue(elementCountToShuffle));\n container.AddContent(ControlCommand_1.ControlCommand.SequenceShuffleIndex());\n if (once || stopping) {\n container.AddContent(postShuffleNoOp);\n }\n }\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n // Create point to return to when sequence is complete\n const postSequenceNoOp = ControlCommand_1.ControlCommand.NoOp();\n // Each of the main sequence branches, and one extra empty branch if\n // we have a \"once\" sequence.\n for (let elIndex = 0; elIndex < seqBranchCount; elIndex += 1) {\n // This sequence element:\n // if( chosenIndex == this index ) divert to this sequence element\n // duplicate chosen sequence index, since it'll be consumed by \"==\"\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n container.AddContent(ControlCommand_1.ControlCommand.Duplicate());\n container.AddContent(new Value_1.IntValue(elIndex));\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(\"==\"));\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n // Divert branch for this sequence element\n const sequenceDivert = new Divert_1.Divert();\n sequenceDivert.isConditional = true;\n container.AddContent(sequenceDivert);\n let contentContainerForSequenceBranch;\n // Generate content for this sequence element\n if (elIndex < this.sequenceElements.length) {\n const el = this.sequenceElements[elIndex];\n contentContainerForSequenceBranch =\n el.runtimeObject;\n }\n else {\n // Final empty branch for \"once\" sequences\n contentContainerForSequenceBranch = new Container_1.Container();\n }\n contentContainerForSequenceBranch.name = `s${elIndex}`;\n contentContainerForSequenceBranch.InsertContent(ControlCommand_1.ControlCommand.PopEvaluatedValue(), 0);\n // When sequence element is complete, divert back to end of sequence\n const seqBranchCompleteDivert = new Divert_1.Divert();\n contentContainerForSequenceBranch.AddContent(seqBranchCompleteDivert);\n container.AddToNamedContentOnly(contentContainerForSequenceBranch);\n // Save the diverts for reference resolution later (in ResolveReferences)\n this.AddDivertToResolve(sequenceDivert, contentContainerForSequenceBranch);\n this.AddDivertToResolve(seqBranchCompleteDivert, postSequenceNoOp);\n }\n container.AddContent(postSequenceNoOp);\n return container;\n };\n this.AddDivertToResolve = (divert, targetContent) => {\n this._sequenceDivertsToResolve.push(new SequenceDivertToResolve_1.SequenceDivertToResolve(divert, targetContent));\n };\n this.sequenceType = sequenceType;\n this.sequenceElements = [];\n for (const elementContentList of elementContentLists) {\n const contentObjs = elementContentList.content;\n let seqElObject = null;\n // Don't attempt to create a weave for the sequence element\n // if the content list is empty. Weaves don't like it!\n if (contentObjs === null || contentObjs.length === 0) {\n seqElObject = elementContentList;\n }\n else {\n seqElObject = new Weave_1.Weave(contentObjs);\n }\n this.sequenceElements.push(seqElObject);\n this.AddContent(seqElObject);\n }\n }\n get typeName() {\n return \"Sequence\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n for (const toResolve of this._sequenceDivertsToResolve) {\n toResolve.divert.targetPath = toResolve.targetContent.path;\n }\n }\n}\nexports.Sequence = Sequence;\n//# sourceMappingURL=Sequence.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.TunnelOnwards = void 0;\nconst Container_1 = require(\"../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../engine/ControlCommand\");\nconst Divert_1 = require(\"../../../engine/Divert\");\nconst Value_1 = require(\"../../../engine/Value\");\nconst Object_1 = require(\"./Object\");\nconst Void_1 = require(\"../../../engine/Void\");\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\nconst VariableReference_1 = require(\"../../../engine/VariableReference\");\nclass TunnelOnwards extends Object_1.ParsedObject {\n constructor() {\n super(...arguments);\n this._overrideDivertTarget = null;\n this._divertAfter = null;\n this.GenerateRuntimeObject = () => {\n const container = new Container_1.Container();\n // Set override path for tunnel onwards (or nothing)\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n if (this.divertAfter) {\n // Generate runtime object's generated code and steal the arguments runtime code\n const returnRuntimeObj = this.divertAfter.GenerateRuntimeObject();\n const returnRuntimeContainer = returnRuntimeObj;\n if (returnRuntimeContainer) {\n // Steal all code for generating arguments from the divert\n const args = this.divertAfter.args;\n if (args !== null && args.length > 0) {\n // Steal everything betwen eval start and eval end\n let evalStart = -1;\n let evalEnd = -1;\n for (let ii = 0; ii < returnRuntimeContainer.content.length; ii += 1) {\n const cmd = returnRuntimeContainer.content[ii];\n if (cmd) {\n if (evalStart == -1 &&\n cmd.commandType === ControlCommand_1.ControlCommand.CommandType.EvalStart) {\n evalStart = ii;\n }\n else if (cmd.commandType === ControlCommand_1.ControlCommand.CommandType.EvalEnd) {\n evalEnd = ii;\n }\n }\n }\n for (let ii = evalStart + 1; ii < evalEnd; ii += 1) {\n const obj = returnRuntimeContainer.content[ii];\n obj.parent = null; // prevent error of being moved between owners\n container.AddContent(returnRuntimeContainer.content[ii]);\n }\n }\n }\n // Supply the divert target for the tunnel onwards target, either variable or more commonly, the explicit name\n // var returnDivertObj = returnRuntimeObj as Runtime.Divert;\n let returnDivertObj = (0, TypeAssertion_1.asOrNull)(returnRuntimeObj, Divert_1.Divert);\n if (returnDivertObj != null && returnDivertObj.hasVariableTarget) {\n let runtimeVarRef = new VariableReference_1.VariableReference(returnDivertObj.variableDivertName);\n container.AddContent(runtimeVarRef);\n }\n else {\n this._overrideDivertTarget = new Value_1.DivertTargetValue();\n container.AddContent(this._overrideDivertTarget);\n }\n }\n else {\n // No divert after tunnel onwards\n container.AddContent(new Void_1.Void());\n }\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n container.AddContent(ControlCommand_1.ControlCommand.PopTunnel());\n return container;\n };\n this.toString = () => {\n return ` -> ${this._divertAfter}`;\n };\n }\n get divertAfter() {\n return this._divertAfter;\n }\n set divertAfter(value) {\n this._divertAfter = value;\n if (this._divertAfter) {\n this.AddContent(this._divertAfter);\n }\n }\n get typeName() {\n return \"TunnelOnwards\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n if (this.divertAfter && this.divertAfter.targetContent) {\n this._overrideDivertTarget.targetPath =\n this.divertAfter.targetContent.runtimePath;\n }\n }\n}\nexports.TunnelOnwards = TunnelOnwards;\n//# sourceMappingURL=TunnelOnwards.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ListDefinition = void 0;\nconst InkList_1 = require(\"./InkList\");\nclass ListDefinition {\n constructor(name, items) {\n this._name = name || \"\";\n this._items = null;\n this._itemNameToValues = items || new Map();\n }\n get name() {\n return this._name;\n }\n get items() {\n if (this._items == null) {\n this._items = new Map();\n for (let [key, value] of this._itemNameToValues) {\n let item = new InkList_1.InkListItem(this.name, key);\n this._items.set(item.serialized(), value);\n }\n }\n return this._items;\n }\n ValueForItem(item) {\n if (!item.itemName)\n return 0;\n let intVal = this._itemNameToValues.get(item.itemName);\n if (typeof intVal !== \"undefined\")\n return intVal;\n else\n return 0;\n }\n ContainsItem(item) {\n if (!item.itemName)\n return false;\n if (item.originName != this.name)\n return false;\n return this._itemNameToValues.has(item.itemName);\n }\n ContainsItemWithName(itemName) {\n return this._itemNameToValues.has(itemName);\n }\n TryGetItemWithValue(val, \n /* out */ item) {\n for (let [key, value] of this._itemNameToValues) {\n if (value == val) {\n item = new InkList_1.InkListItem(this.name, key);\n return { result: item, exists: true };\n }\n }\n item = InkList_1.InkListItem.Null;\n return { result: item, exists: false };\n }\n TryGetValueForItem(item, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n /* out */ intVal) {\n if (!item.itemName)\n return { result: 0, exists: false };\n let value = this._itemNameToValues.get(item.itemName);\n if (!value)\n return { result: 0, exists: false };\n return { result: value, exists: true };\n }\n}\nexports.ListDefinition = ListDefinition;\n//# sourceMappingURL=ListDefinition.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ListDefinition = void 0;\nconst InkList_1 = require(\"../../../../engine/InkList\");\nconst InkList_2 = require(\"../../../../engine/InkList\");\nconst ListDefinition_1 = require(\"../../../../engine/ListDefinition\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst Object_1 = require(\"../Object\");\nconst SymbolType_1 = require(\"../SymbolType\");\nclass ListDefinition extends Object_1.ParsedObject {\n get typeName() {\n return \"ListDefinition\";\n }\n get runtimeListDefinition() {\n var _a;\n const allItems = new Map();\n for (const e of this.itemDefinitions) {\n if (!allItems.has(e.name)) {\n allItems.set(e.name, e.seriesValue);\n }\n else {\n this.Error(`List '${this.identifier}' contains duplicate items called '${e.name}'`);\n }\n }\n return new ListDefinition_1.ListDefinition(((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || \"\", allItems);\n }\n constructor(itemDefinitions) {\n super();\n this.itemDefinitions = itemDefinitions;\n this.identifier = null;\n this.variableAssignment = null;\n this._elementsByName = null;\n this.ItemNamed = (itemName) => {\n if (this._elementsByName === null) {\n this._elementsByName = new Map();\n for (const el of this.itemDefinitions) {\n this._elementsByName.set(el.name, el);\n }\n }\n const foundElement = this._elementsByName.get(itemName) || null;\n return foundElement;\n };\n this.GenerateRuntimeObject = () => {\n var _a, _b;\n const initialValues = new InkList_1.InkList();\n for (const itemDef of this.itemDefinitions) {\n if (itemDef.inInitialList) {\n const item = new InkList_2.InkListItem(((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || null, itemDef.name || null);\n initialValues.Add(item, itemDef.seriesValue);\n }\n }\n // Set origin name, so\n initialValues.SetInitialOriginName(((_b = this.identifier) === null || _b === void 0 ? void 0 : _b.name) || \"\");\n return new Value_1.ListValue(initialValues);\n };\n let currentValue = 1;\n for (const e of this.itemDefinitions) {\n if (e.explicitValue !== null) {\n currentValue = e.explicitValue;\n }\n e.seriesValue = currentValue;\n currentValue += 1;\n }\n this.AddContent(itemDefinitions);\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n context.CheckForNamingCollisions(this, this.identifier, SymbolType_1.SymbolType.List);\n }\n}\nexports.ListDefinition = ListDefinition;\n//# sourceMappingURL=ListDefinition.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VariableAssignment = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst ClosestFlowBase_1 = require(\"../Flow/ClosestFlowBase\");\nconst ListDefinition_1 = require(\"../List/ListDefinition\");\nconst Object_1 = require(\"../Object\");\nconst SymbolType_1 = require(\"../SymbolType\");\nconst VariableAssignment_1 = require(\"../../../../engine/VariableAssignment\");\nconst VariableReference_1 = require(\"./VariableReference\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass VariableAssignment extends Object_1.ParsedObject {\n get variableName() {\n return this.variableIdentifier.name;\n }\n get typeName() {\n if (this.isNewTemporaryDeclaration) {\n return \"temp\";\n }\n else if (this.isGlobalDeclaration) {\n if (this.listDefinition !== null) {\n return \"LIST\";\n }\n return \"VAR\";\n }\n return \"variable assignment\";\n }\n get isDeclaration() {\n return this.isGlobalDeclaration || this.isNewTemporaryDeclaration;\n }\n constructor({ assignedExpression, isGlobalDeclaration, isTemporaryNewDeclaration, listDef, variableIdentifier, }) {\n super();\n this._runtimeAssignment = null;\n this.expression = null;\n this.listDefinition = null;\n this.GenerateRuntimeObject = () => {\n let newDeclScope = null;\n if (this.isGlobalDeclaration) {\n newDeclScope = this.story;\n }\n else if (this.isNewTemporaryDeclaration) {\n newDeclScope = (0, ClosestFlowBase_1.ClosestFlowBase)(this);\n }\n if (newDeclScope) {\n newDeclScope.AddNewVariableDeclaration(this);\n }\n // Global declarations don't generate actual procedural\n // runtime objects, but instead add a global variable to the story itself.\n // The story then initialises them all in one go at the start of the game.\n if (this.isGlobalDeclaration) {\n return null;\n }\n const container = new Container_1.Container();\n // The expression's runtimeObject is actually another nested container\n if (this.expression) {\n container.AddContent(this.expression.runtimeObject);\n }\n else if (this.listDefinition) {\n container.AddContent(this.listDefinition.runtimeObject);\n }\n this._runtimeAssignment = new VariableAssignment_1.VariableAssignment(this.variableName, this.isNewTemporaryDeclaration);\n container.AddContent(this._runtimeAssignment);\n return container;\n };\n this.toString = () => `${this.isGlobalDeclaration\n ? \"VAR\"\n : this.isNewTemporaryDeclaration\n ? \"~ temp\"\n : \"\"} ${this.variableName}`;\n this.variableIdentifier = variableIdentifier;\n this.isGlobalDeclaration = Boolean(isGlobalDeclaration);\n this.isNewTemporaryDeclaration = Boolean(isTemporaryNewDeclaration);\n // Defensive programming in case parsing of assignedExpression failed\n if (listDef instanceof ListDefinition_1.ListDefinition) {\n this.listDefinition = this.AddContent(listDef);\n this.listDefinition.variableAssignment = this;\n // List definitions are always global\n this.isGlobalDeclaration = true;\n }\n else if (assignedExpression) {\n this.expression = this.AddContent(assignedExpression);\n }\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n // List definitions are checked for conflicts separately\n if (this.isDeclaration && this.listDefinition === null) {\n context.CheckForNamingCollisions(this, this.variableIdentifier, this.isGlobalDeclaration ? SymbolType_1.SymbolType.Var : SymbolType_1.SymbolType.Temp);\n }\n // Initial VAR x = [intialValue] declaration, not re-assignment\n if (this.isGlobalDeclaration) {\n const variableReference = (0, TypeAssertion_1.asOrNull)(this.expression, VariableReference_1.VariableReference);\n if (variableReference &&\n !variableReference.isConstantReference &&\n !variableReference.isListItemReference) {\n this.Error(\"global variable assignments cannot refer to other variables, only literal values, constants and list items\");\n }\n }\n if (!this.isNewTemporaryDeclaration) {\n const resolvedVarAssignment = context.ResolveVariableWithName(this.variableName, this);\n if (!resolvedVarAssignment.found) {\n if (this.variableName in this.story.constants) {\n this.Error(`Can't re-assign to a constant (do you need to use VAR when declaring '${this.variableName}'?)`, this);\n }\n else {\n this.Error(`Variable could not be found to assign to: '${this.variableName}'`, this);\n }\n }\n // A runtime assignment may not have been generated if it's the initial global declaration,\n // since these are hoisted out and handled specially in Story.ExportRuntime.\n if (this._runtimeAssignment) {\n this._runtimeAssignment.isGlobal = resolvedVarAssignment.isGlobal;\n }\n }\n }\n}\nexports.VariableAssignment = VariableAssignment;\n//# sourceMappingURL=VariableAssignment.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Weave = void 0;\nconst AuthorWarning_1 = require(\"./AuthorWarning\");\nconst Choice_1 = require(\"./Choice\");\nconst Conditional_1 = require(\"./Conditional/Conditional\");\nconst ConstantDeclaration_1 = require(\"./Declaration/ConstantDeclaration\");\nconst Container_1 = require(\"../../../engine/Container\");\nconst Divert_1 = require(\"./Divert/Divert\");\nconst Divert_2 = require(\"../../../engine/Divert\");\nconst DivertTarget_1 = require(\"./Divert/DivertTarget\");\nconst FlowBase_1 = require(\"./Flow/FlowBase\");\nconst Gather_1 = require(\"./Gather/Gather\");\nconst GatherPointToResolve_1 = require(\"./Gather/GatherPointToResolve\");\nconst Object_1 = require(\"./Object\");\nconst Sequence_1 = require(\"./Sequence/Sequence\");\nconst Text_1 = require(\"./Text\");\nconst TunnelOnwards_1 = require(\"./TunnelOnwards\");\nconst VariableAssignment_1 = require(\"./Variable/VariableAssignment\");\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\n// Used by the FlowBase when constructing the weave flow from\n// a flat list of content objects.\nclass Weave extends Object_1.ParsedObject {\n // Containers can be chained as multiple gather points\n // get created as the same indentation level.\n // rootContainer is always the first in the chain, while\n // currentContainer is the latest.\n get rootContainer() {\n if (!this._rootContainer) {\n this._rootContainer = this.GenerateRuntimeObject();\n }\n return this._rootContainer;\n }\n get namedWeavePoints() {\n return this._namedWeavePoints;\n }\n get lastParsedSignificantObject() {\n if (this.content.length === 0) {\n return null;\n }\n // Don't count extraneous newlines or VAR/CONST declarations,\n // since they're \"empty\" statements outside of the main flow.\n let lastObject = null;\n for (let ii = this.content.length - 1; ii >= 0; --ii) {\n lastObject = this.content[ii];\n let lastText = (0, TypeAssertion_1.asOrNull)(lastObject, Text_1.Text);\n if (lastText && lastText.text === \"\\n\") {\n continue;\n }\n if (this.IsGlobalDeclaration(lastObject)) {\n continue;\n }\n break;\n }\n const lastWeave = (0, TypeAssertion_1.asOrNull)(lastObject, Weave);\n if (lastWeave) {\n lastObject = lastWeave.lastParsedSignificantObject;\n }\n return lastObject;\n }\n constructor(cont, indentIndex = -1) {\n super();\n // Keep track of previous weave point (Choice or Gather)\n // at the current indentation level:\n // - to add ordinary content to be nested under it\n // - to add nested content under it when it's indented\n // - to remove it from the list of loose ends when\n // - it has indented content since it's no longer a loose end\n // - it's a gather and it has a choice added to it\n this.previousWeavePoint = null;\n this.addContentToPreviousWeavePoint = false;\n // Used for determining whether the next Gather should auto-enter\n this.hasSeenChoiceInSection = false;\n this.currentContainer = null;\n this._unnamedGatherCount = 0;\n this._choiceCount = 0;\n this._rootContainer = null;\n this._namedWeavePoints = new Map();\n // Loose ends are:\n // - Choices or Gathers that need to be joined up\n // - Explicit Divert to gather points (i.e. \"->\" without a target)\n this.looseEnds = [];\n this.gatherPointsToResolve = [];\n this.ResolveWeavePointNaming = () => {\n var _a, _b, _c;\n const namedWeavePoints = [\n ...this.FindAll(Gather_1.Gather)((w) => !(w.name === null || w.name === undefined)),\n ...this.FindAll(Choice_1.Choice)((w) => !(w.name === null || w.name === undefined)),\n ];\n this._namedWeavePoints = new Map();\n for (const weavePoint of namedWeavePoints) {\n // Check for weave point naming collisions\n const existingWeavePoint = this.namedWeavePoints.get(((_a = weavePoint.identifier) === null || _a === void 0 ? void 0 : _a.name) || \"\");\n if (existingWeavePoint) {\n const typeName = existingWeavePoint instanceof Gather_1.Gather ? \"gather\" : \"choice\";\n const existingObj = existingWeavePoint;\n this.Error(`A ${typeName} with the same label name '${weavePoint.name}' already exists in this context on line ${existingObj.debugMetadata\n ? existingObj.debugMetadata.startLineNumber\n : \"NO DEBUG METADATA AVAILABLE\"}`, weavePoint);\n }\n if ((_b = weavePoint.identifier) === null || _b === void 0 ? void 0 : _b.name) {\n this.namedWeavePoints.set((_c = weavePoint.identifier) === null || _c === void 0 ? void 0 : _c.name, weavePoint);\n }\n }\n };\n this.ConstructWeaveHierarchyFromIndentation = () => {\n // Find nested indentation and convert to a proper object hierarchy\n // (i.e. indented content is replaced with a Weave object that contains\n // that nested content)\n let contentIdx = 0;\n while (contentIdx < this.content.length) {\n const obj = this.content[contentIdx];\n // Choice or Gather\n if (obj instanceof Choice_1.Choice || obj instanceof Gather_1.Gather) {\n const weavePoint = obj;\n const weaveIndentIdx = weavePoint.indentationDepth - 1;\n // Inner level indentation - recurse\n if (weaveIndentIdx > this.baseIndentIndex) {\n // Step through content until indent jumps out again\n let innerWeaveStartIdx = contentIdx;\n while (contentIdx < this.content.length) {\n const innerWeaveObj = (0, TypeAssertion_1.asOrNull)(this.content[contentIdx], Choice_1.Choice) ||\n (0, TypeAssertion_1.asOrNull)(this.content[contentIdx], Gather_1.Gather);\n if (innerWeaveObj !== null) {\n const innerIndentIdx = innerWeaveObj.indentationDepth - 1;\n if (innerIndentIdx <= this.baseIndentIndex) {\n break;\n }\n }\n contentIdx += 1;\n }\n const weaveContentCount = contentIdx - innerWeaveStartIdx;\n const weaveContent = this.content.slice(innerWeaveStartIdx, innerWeaveStartIdx + weaveContentCount);\n this.content.splice(innerWeaveStartIdx, weaveContentCount);\n const weave = new Weave(weaveContent, weaveIndentIdx);\n this.InsertContent(innerWeaveStartIdx, weave);\n // Continue iteration from this point\n contentIdx = innerWeaveStartIdx;\n }\n }\n contentIdx += 1;\n }\n };\n // When the indentation wasn't told to us at construction time using\n // a choice point with a known indentation level, we may be told to\n // determine the indentation level by incrementing from our closest ancestor.\n this.DetermineBaseIndentationFromContent = (contentList) => {\n for (const obj of contentList) {\n if (obj instanceof Choice_1.Choice || obj instanceof Gather_1.Gather) {\n return obj.indentationDepth - 1;\n }\n }\n // No weave points, so it doesn't matter\n return 0;\n };\n this.GenerateRuntimeObject = () => {\n this._rootContainer = new Container_1.Container();\n this.currentContainer = this._rootContainer;\n this.looseEnds = [];\n this.gatherPointsToResolve = [];\n // Iterate through content for the block at this level of indentation\n // - Normal content is nested under Choices and Gathers\n // - Blocks that are further indented cause recursion\n // - Keep track of loose ends so that they can be diverted to Gathers\n for (const obj of this.content) {\n // Choice or Gather\n if (obj instanceof Choice_1.Choice || obj instanceof Gather_1.Gather) {\n this.AddRuntimeForWeavePoint(obj);\n }\n else {\n // Non-weave point\n if (obj instanceof Weave) {\n // Nested weave\n const weave = obj;\n this.AddRuntimeForNestedWeave(weave);\n this.gatherPointsToResolve.splice(0, 0, ...weave.gatherPointsToResolve);\n }\n else {\n // Other object\n // May be complex object that contains statements - e.g. a multi-line conditional\n this.AddGeneralRuntimeContent(obj.runtimeObject);\n }\n }\n }\n // Pass any loose ends up the hierarhcy\n this.PassLooseEndsToAncestors();\n return this._rootContainer;\n };\n // Found gather point:\n // - gather any loose ends\n // - set the gather as the main container to dump new content in\n this.AddRuntimeForGather = (gather) => {\n // Determine whether this Gather should be auto-entered:\n // - It is auto-entered if there were no choices in the last section\n // - A section is \"since the previous gather\" - so reset now\n const autoEnter = !this.hasSeenChoiceInSection;\n this.hasSeenChoiceInSection = false;\n const gatherContainer = gather.runtimeContainer;\n if (!gather.name) {\n // Use disallowed character so it's impossible to have a name collision\n gatherContainer.name = `g-${this._unnamedGatherCount}`;\n this._unnamedGatherCount += 1;\n }\n if (autoEnter) {\n if (!this.currentContainer) {\n throw new Error();\n }\n // Auto-enter: include in main content\n this.currentContainer.AddContent(gatherContainer);\n }\n else {\n // Don't auto-enter:\n // Add this gather to the main content, but only accessible\n // by name so that it isn't stepped into automatically, but only via\n // a divert from a loose end.\n this.rootContainer.AddToNamedContentOnly(gatherContainer);\n }\n // Consume loose ends: divert them to this gather\n for (const looseEndWeavePoint of this.looseEnds) {\n const looseEnd = looseEndWeavePoint;\n // Skip gather loose ends that are at the same level\n // since they'll be handled by the auto-enter code below\n // that only jumps into the gather if (current runtime choices == 0)\n if (looseEnd instanceof Gather_1.Gather) {\n const prevGather = looseEnd;\n if (prevGather.indentationDepth == gather.indentationDepth) {\n continue;\n }\n }\n let divert = null;\n if (looseEnd instanceof Divert_1.Divert) {\n divert = looseEnd.runtimeObject;\n }\n else {\n divert = new Divert_2.Divert();\n const looseWeavePoint = looseEnd;\n if (!looseWeavePoint.runtimeContainer) {\n throw new Error();\n }\n looseWeavePoint.runtimeContainer.AddContent(divert);\n }\n // Pass back knowledge of this loose end being diverted\n // to the FlowBase so that it can maintain a list of them,\n // and resolve the divert references later\n this.gatherPointsToResolve.push(new GatherPointToResolve_1.GatherPointToResolve(divert, gatherContainer));\n }\n this.looseEnds = [];\n // Replace the current container itself\n this.currentContainer = gatherContainer;\n };\n this.AddRuntimeForWeavePoint = (weavePoint) => {\n // Current level Gather\n if (weavePoint instanceof Gather_1.Gather) {\n this.AddRuntimeForGather(weavePoint);\n }\n // Current level choice\n else if (weavePoint instanceof Choice_1.Choice) {\n if (!this.currentContainer) {\n throw new Error();\n }\n // Gathers that contain choices are no longer loose ends\n // (same as when weave points get nested content)\n if (this.previousWeavePoint instanceof Gather_1.Gather) {\n this.looseEnds.splice(this.looseEnds.indexOf(this.previousWeavePoint), 1);\n }\n // Add choice point content\n const choice = weavePoint; //, Choice);\n this.currentContainer.AddContent(choice.runtimeObject);\n if (!choice.innerContentContainer) {\n throw new Error();\n } //guaranteed not to happen\n // Add choice's inner content to self\n choice.innerContentContainer.name = `c-${this._choiceCount}`;\n this.currentContainer.AddToNamedContentOnly(choice.innerContentContainer);\n this._choiceCount += 1;\n this.hasSeenChoiceInSection = true;\n }\n // Keep track of loose ends\n this.addContentToPreviousWeavePoint = false; // default\n if (this.WeavePointHasLooseEnd(weavePoint)) {\n this.looseEnds.push(weavePoint);\n const looseChoice = (0, TypeAssertion_1.asOrNull)(weavePoint, Choice_1.Choice);\n if (looseChoice) {\n this.addContentToPreviousWeavePoint = true;\n }\n }\n this.previousWeavePoint = weavePoint;\n };\n // Add nested block at a greater indentation level\n this.AddRuntimeForNestedWeave = (nestedResult) => {\n // Add this inner block to current container\n // (i.e. within the main container, or within the last defined Choice/Gather)\n this.AddGeneralRuntimeContent(nestedResult.rootContainer);\n // Now there's a deeper indentation level, the previous weave point doesn't\n // count as a loose end (since it will have content to go to)\n if (this.previousWeavePoint !== null) {\n this.looseEnds.splice(this.looseEnds.indexOf(this.previousWeavePoint), 1);\n this.addContentToPreviousWeavePoint = false;\n }\n };\n // Normal content gets added into the latest Choice or Gather by default,\n // unless there hasn't been one yet.\n this.AddGeneralRuntimeContent = (content) => {\n // Content is allowed to evaluate runtimeObject to null\n // (e.g. AuthorWarning, which doesn't make it into the runtime)\n if (content === null) {\n return;\n }\n if (this.addContentToPreviousWeavePoint) {\n if (!this.previousWeavePoint ||\n !this.previousWeavePoint.runtimeContainer) {\n throw new Error();\n }\n this.previousWeavePoint.runtimeContainer.AddContent(content);\n }\n else {\n if (!this.currentContainer) {\n throw new Error();\n }\n this.currentContainer.AddContent(content);\n }\n };\n this.PassLooseEndsToAncestors = () => {\n if (this.looseEnds.length === 0) {\n return;\n }\n // Search for Weave ancestor to pass loose ends to for gathering.\n // There are two types depending on whether the current weave\n // is separated by a conditional or sequence.\n // - An \"inner\" weave is one that is directly connected to the current\n // weave - i.e. you don't have to pass through a conditional or\n // sequence to get to it. We're allowed to pass all loose ends to\n // one of these.\n // - An \"outer\" weave is one that is outside of a conditional/sequence\n // that the current weave is nested within. We're only allowed to\n // pass gathers (i.e. 'normal flow') loose ends up there, not normal\n // choices. The rule is that choices have to be diverted explicitly\n // by the author since it's ambiguous where flow should go otherwise.\n //\n // e.g.:\n //\n // - top <- e.g. outer weave\n // {true:\n // * choice <- e.g. inner weave\n // * * choice 2\n // more content <- e.g. current weave\n // * choice 2\n // }\n // - more of outer weave\n //\n let closestInnerWeaveAncestor = null;\n let closestOuterWeaveAncestor = null;\n // Find inner and outer ancestor weaves as defined above.\n let nested = false;\n for (let ancestor = this.parent; ancestor !== null; ancestor = ancestor.parent) {\n // Found ancestor?\n const weaveAncestor = (0, TypeAssertion_1.asOrNull)(ancestor, Weave);\n if (weaveAncestor) {\n if (!nested && closestInnerWeaveAncestor === null) {\n closestInnerWeaveAncestor = weaveAncestor;\n }\n if (nested && closestOuterWeaveAncestor === null) {\n closestOuterWeaveAncestor = weaveAncestor;\n }\n }\n // Weaves nested within Sequences or Conditionals are\n // \"sealed\" - any loose ends require explicit diverts.\n if (ancestor instanceof Sequence_1.Sequence || ancestor instanceof Conditional_1.Conditional) {\n nested = true;\n }\n }\n // No weave to pass loose ends to at all?\n if (closestInnerWeaveAncestor === null &&\n closestOuterWeaveAncestor === null) {\n return;\n }\n // Follow loose end passing logic as defined above\n for (let ii = this.looseEnds.length - 1; ii >= 0; ii -= 1) {\n const looseEnd = this.looseEnds[ii];\n let received = false;\n if (nested) {\n // This weave is nested within a conditional or sequence:\n // - choices can only be passed up to direct ancestor (\"inner\") weaves\n // - gathers can be passed up to either, but favour the closer (inner) weave\n // if there is one\n if (looseEnd instanceof Choice_1.Choice && closestInnerWeaveAncestor !== null) {\n closestInnerWeaveAncestor.ReceiveLooseEnd(looseEnd);\n received = true;\n }\n else if (!(looseEnd instanceof Choice_1.Choice)) {\n const receivingWeave = closestInnerWeaveAncestor || closestOuterWeaveAncestor;\n if (receivingWeave !== null) {\n receivingWeave.ReceiveLooseEnd(looseEnd);\n received = true;\n }\n }\n }\n else {\n // No nesting, all loose ends can be safely passed up\n if (closestInnerWeaveAncestor === null || closestInnerWeaveAncestor === void 0 ? void 0 : closestInnerWeaveAncestor.hasOwnProperty(\"ReceiveLooseEnd\")) {\n closestInnerWeaveAncestor.ReceiveLooseEnd(looseEnd);\n }\n received = true;\n }\n if (received) {\n this.looseEnds.splice(ii, 1);\n }\n }\n };\n this.ReceiveLooseEnd = (childWeaveLooseEnd) => {\n this.looseEnds.push(childWeaveLooseEnd);\n };\n this.WeavePointNamed = (name) => {\n if (!this.namedWeavePoints) {\n return null;\n }\n let weavePointResult = this.namedWeavePoints.get(name);\n if (weavePointResult) {\n return weavePointResult;\n }\n return null;\n };\n // Global VARs and CONSTs are treated as \"outside of the flow\"\n // when iterating over content that follows loose ends\n this.IsGlobalDeclaration = (obj) => {\n const varAss = (0, TypeAssertion_1.asOrNull)(obj, VariableAssignment_1.VariableAssignment);\n if (varAss && varAss.isGlobalDeclaration && varAss.isDeclaration) {\n return true;\n }\n const constDecl = (0, TypeAssertion_1.asOrNull)(obj, ConstantDeclaration_1.ConstantDeclaration);\n if (constDecl) {\n return true;\n }\n return false;\n };\n // While analysing final loose ends, we look to see whether there\n // are any diverts etc which choices etc divert from\n this.ContentThatFollowsWeavePoint = (weavePoint) => {\n const returned = [];\n const obj = weavePoint;\n // Inner content first (e.g. for a choice)\n if (obj.content !== null) {\n for (const contentObj of obj.content) {\n // Global VARs and CONSTs are treated as \"outside of the flow\"\n if (this.IsGlobalDeclaration(contentObj)) {\n continue;\n }\n returned.push(contentObj);\n }\n }\n const parentWeave = (0, TypeAssertion_1.asOrNull)(obj.parent, Weave);\n if (parentWeave === null) {\n throw new Error(\"Expected weave point parent to be weave?\");\n }\n const weavePointIdx = parentWeave.content.indexOf(obj);\n for (let ii = weavePointIdx + 1; ii < parentWeave.content.length; ii += 1) {\n const laterObj = parentWeave.content[ii];\n // Global VARs and CONSTs are treated as \"outside of the flow\"\n if (this.IsGlobalDeclaration(laterObj)) {\n continue;\n }\n // End of the current flow\n // if (laterObj instanceof IWeavePoint) // cannot test on interface in ts\n if (laterObj instanceof Choice_1.Choice || laterObj instanceof Gather_1.Gather) {\n break;\n }\n // Other weaves will be have their own loose ends\n if (laterObj instanceof Weave) {\n break;\n }\n returned.push(laterObj);\n }\n return returned;\n };\n this.ValidateTermination = (badTerminationHandler) => {\n // Don't worry if the last object in the flow is a \"TODO\",\n // even if there are other loose ends in other places\n if (this.lastParsedSignificantObject instanceof AuthorWarning_1.AuthorWarning) {\n return;\n }\n // By now, any sub-weaves will have passed loose ends up to the root weave (this).\n // So there are 2 possible situations:\n // - There are loose ends from somewhere in the flow.\n // These aren't necessarily \"real\" loose ends - they're weave points\n // that don't connect to any lower weave points, so we just\n // have to check that they terminate properly.\n // - This weave is just a list of content with no actual weave points,\n // so we just need to check that the list of content terminates.\n const hasLooseEnds = this.looseEnds !== null && this.looseEnds.length > 0;\n if (hasLooseEnds) {\n for (const looseEnd of this.looseEnds) {\n const looseEndFlow = this.ContentThatFollowsWeavePoint(looseEnd);\n this.ValidateFlowOfObjectsTerminates(looseEndFlow, looseEnd, badTerminationHandler);\n }\n }\n else {\n // No loose ends... is there any inner weaving at all?\n // If not, make sure the single content stream is terminated correctly\n //\n // If there's any actual weaving, assume that content is\n // terminated correctly since we would've had a loose end otherwise\n for (const obj of this.content) {\n if (obj instanceof Choice_1.Choice || obj instanceof Divert_1.Divert) {\n return;\n }\n }\n // Straight linear flow? Check it terminates\n this.ValidateFlowOfObjectsTerminates(this.content, this, badTerminationHandler);\n }\n };\n this.BadNestedTerminationHandler = (terminatingObj) => {\n let conditional = null;\n for (let ancestor = terminatingObj.parent; ancestor !== null; ancestor = ancestor.parent) {\n if (ancestor instanceof Sequence_1.Sequence || ancestor instanceof Conditional_1.Conditional) {\n conditional = (0, TypeAssertion_1.asOrNull)(ancestor, Conditional_1.Conditional);\n break;\n }\n }\n let errorMsg = \"Choices nested in conditionals or sequences need to explicitly divert afterwards.\";\n // Tutorialise proper choice syntax if this looks like a single choice within a condition, e.g.\n // { condition:\n // * choice\n // }\n if (conditional !== null) {\n let numChoices = conditional.FindAll(Choice_1.Choice)().length;\n if (numChoices === 1) {\n errorMsg = `Choices with conditions should be written: '* {condition} choice'. Otherwise, ${errorMsg.toLowerCase()}`;\n }\n }\n this.Error(errorMsg, terminatingObj);\n };\n this.ValidateFlowOfObjectsTerminates = (objFlow, defaultObj, badTerminationHandler) => {\n let terminated = false;\n let terminatingObj = defaultObj;\n for (const flowObj of objFlow) {\n const divert = flowObj.Find(Divert_1.Divert)((d) => !d.isThread &&\n !d.isTunnel &&\n !d.isFunctionCall &&\n !(d.parent instanceof DivertTarget_1.DivertTarget));\n if (divert !== null) {\n terminated = true;\n }\n if (flowObj.Find(TunnelOnwards_1.TunnelOnwards)() != null) {\n terminated = true;\n break;\n }\n terminatingObj = flowObj;\n }\n if (!terminated) {\n // Author has left a note to self here - clearly we don't need\n // to leave them with another warning since they know what they're doing.\n if (terminatingObj instanceof AuthorWarning_1.AuthorWarning) {\n return;\n }\n badTerminationHandler(terminatingObj);\n }\n };\n this.WeavePointHasLooseEnd = (weavePoint) => {\n // No content, must be a loose end.\n if (weavePoint.content === null) {\n return true;\n }\n // If a weave point is diverted from, it doesn't have a loose end.\n // Detect a divert object within a weavePoint's main content\n // Work backwards since we're really interested in the end,\n // although it doesn't actually make a difference!\n // (content after a divert will simply be inaccessible)\n for (let ii = weavePoint.content.length - 1; ii >= 0; --ii) {\n let innerDivert = (0, TypeAssertion_1.asOrNull)(weavePoint.content[ii], Divert_1.Divert);\n if (innerDivert) {\n const willReturn = innerDivert.isThread ||\n innerDivert.isTunnel ||\n innerDivert.isFunctionCall;\n if (!willReturn) {\n return false;\n }\n }\n }\n return true;\n };\n // Enforce rule that weave points must not have the same\n // name as any stitches or knots upwards in the hierarchy\n this.CheckForWeavePointNamingCollisions = () => {\n if (!this.namedWeavePoints) {\n return;\n }\n const ancestorFlows = [];\n for (const obj of this.ancestry) {\n const flow = (0, TypeAssertion_1.asOrNull)(obj, FlowBase_1.FlowBase);\n if (flow) {\n ancestorFlows.push(flow);\n }\n else {\n break;\n }\n }\n for (const [weavePointName, weavePoint] of this.namedWeavePoints) {\n for (const flow of ancestorFlows) {\n // Shallow search\n const otherContentWithName = flow.ContentWithNameAtLevel(weavePointName);\n if (otherContentWithName && otherContentWithName !== weavePoint) {\n const errorMsg = `${weavePoint.GetType()} '${weavePointName}' has the same label name as a ${otherContentWithName.GetType()} (on ${otherContentWithName.debugMetadata})`;\n this.Error(errorMsg, weavePoint);\n }\n }\n }\n };\n if (indentIndex == -1) {\n this.baseIndentIndex = this.DetermineBaseIndentationFromContent(cont);\n }\n else {\n this.baseIndentIndex = indentIndex;\n }\n this.AddContent(cont);\n this.ConstructWeaveHierarchyFromIndentation();\n }\n get typeName() {\n return \"Weave\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n // Check that choices nested within conditionals and sequences are terminated\n if (this.looseEnds !== null && this.looseEnds.length > 0) {\n let isNestedWeave = false;\n for (let ancestor = this.parent; ancestor !== null; ancestor = ancestor.parent) {\n if (ancestor instanceof Sequence_1.Sequence || ancestor instanceof Conditional_1.Conditional) {\n isNestedWeave = true;\n break;\n }\n }\n if (isNestedWeave) {\n this.ValidateTermination(this.BadNestedTerminationHandler);\n }\n }\n for (const gatherPoint of this.gatherPointsToResolve) {\n gatherPoint.divert.targetPath = gatherPoint.targetRuntimeObj.path;\n }\n this.CheckForWeavePointNamingCollisions();\n }\n}\nexports.Weave = Weave;\n//# sourceMappingURL=Weave.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ConditionalSingleBranch = void 0;\nconst Container_1 = require(\"../../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../../engine/ControlCommand\");\nconst Divert_1 = require(\"../../../../engine/Divert\");\nconst Object_1 = require(\"../Object\");\nconst NativeFunctionCall_1 = require(\"../../../../engine/NativeFunctionCall\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst Text_1 = require(\"../Text\");\nconst Weave_1 = require(\"../Weave\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass ConditionalSingleBranch extends Object_1.ParsedObject {\n // When each branch has its own expression like a switch statement,\n // this is non-null. e.g.\n // { x:\n // - 4: the value of x is four (ownExpression is the value 4)\n // - 3: the value of x is three\n // }\n get ownExpression() {\n return this._ownExpression;\n }\n set ownExpression(value) {\n this._ownExpression = value;\n if (this._ownExpression) {\n this.AddContent(this._ownExpression);\n }\n }\n constructor(content) {\n super();\n this._contentContainer = null;\n this._conditionalDivert = null;\n this._ownExpression = null;\n this._innerWeave = null;\n // bool condition, e.g.:\n // { 5 == 4:\n // - the true branch\n // - the false branch\n // }\n this.isTrueBranch = false;\n // In the above example, match equality of x with 4 for the first branch.\n // This is as opposed to simply evaluating boolean equality for each branch,\n // example when shouldMatchEquality is FALSE:\n // {\n // 3 > 2: This will happen\n // 2 > 3: This won't happen\n // }\n this.matchingEquality = false;\n this.isElse = false;\n this.isInline = false;\n this.returnDivert = null;\n // Runtime content can be summarised as follows:\n // - Evaluate an expression if necessary to branch on\n // - Branch to a named container if true\n // - Divert back to main flow\n // (owner Conditional is in control of this target point)\n this.GenerateRuntimeObject = () => {\n // Check for common mistake, of putting \"else:\" instead of \"- else:\"\n if (this._innerWeave) {\n for (const c of this._innerWeave.content) {\n const text = (0, TypeAssertion_1.asOrNull)(c, Text_1.Text);\n if (text) {\n // Don't need to trim at the start since the parser handles that already\n if (text.text.startsWith(\"else:\")) {\n this.Warning(\"Saw the text 'else:' which is being treated as content. Did you mean '- else:'?\", text);\n }\n }\n }\n }\n const container = new Container_1.Container();\n // Are we testing against a condition that's used for more than just this\n // branch? If so, the first thing we need to do is replicate the value that's\n // on the evaluation stack so that we don't fully consume it, in case other\n // branches need to use it.\n const duplicatesStackValue = this.matchingEquality && !this.isElse;\n if (duplicatesStackValue) {\n container.AddContent(ControlCommand_1.ControlCommand.Duplicate());\n }\n this._conditionalDivert = new Divert_1.Divert();\n // else clause is unconditional catch-all, otherwise the divert is conditional\n this._conditionalDivert.isConditional = !this.isElse;\n // Need extra evaluation?\n if (!this.isTrueBranch && !this.isElse) {\n const needsEval = this.ownExpression !== null;\n if (needsEval) {\n container.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n }\n if (this.ownExpression) {\n this.ownExpression.GenerateIntoContainer(container);\n }\n // Uses existing duplicated value\n if (this.matchingEquality) {\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(\"==\"));\n }\n if (needsEval) {\n container.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n }\n }\n // Will pop from stack if conditional\n container.AddContent(this._conditionalDivert);\n this._contentContainer = this.GenerateRuntimeForContent();\n this._contentContainer.name = \"b\";\n // Multi-line conditionals get a newline at the start of each branch\n // (as opposed to the start of the multi-line conditional since the condition\n // may evaluate to false.)\n if (!this.isInline) {\n this._contentContainer.InsertContent(new Value_1.StringValue(\"\\n\"), 0);\n }\n if (duplicatesStackValue || (this.isElse && this.matchingEquality)) {\n this._contentContainer.InsertContent(ControlCommand_1.ControlCommand.PopEvaluatedValue(), 0);\n }\n container.AddToNamedContentOnly(this._contentContainer);\n this.returnDivert = new Divert_1.Divert();\n this._contentContainer.AddContent(this.returnDivert);\n return container;\n };\n this.GenerateRuntimeForContent = () => {\n // Empty branch - create empty container\n if (this._innerWeave === null) {\n return new Container_1.Container();\n }\n return this._innerWeave.rootContainer;\n };\n // Branches are allowed to be empty\n if (content) {\n this._innerWeave = new Weave_1.Weave(content);\n this.AddContent(this._innerWeave);\n }\n }\n get typeName() {\n return \"ConditionalSingleBranch\";\n }\n ResolveReferences(context) {\n if (!this._conditionalDivert || !this._contentContainer) {\n throw new Error();\n }\n this._conditionalDivert.targetPath = this._contentContainer.path;\n super.ResolveReferences(context);\n }\n}\nexports.ConditionalSingleBranch = ConditionalSingleBranch;\n//# sourceMappingURL=ConditionalSingleBranch.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CustomFlags = void 0;\nvar CustomFlags;\n(function (CustomFlags) {\n CustomFlags[CustomFlags[\"ParsingString\"] = 1] = \"ParsingString\";\n CustomFlags[CustomFlags[\"TagActive\"] = 2] = \"TagActive\";\n})(CustomFlags || (exports.CustomFlags = CustomFlags = {}));\n//# sourceMappingURL=CustomFlags.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DebugMetadata = void 0;\nclass DebugMetadata {\n constructor() {\n this.startLineNumber = 0;\n this.endLineNumber = 0;\n this.startCharacterNumber = 0;\n this.endCharacterNumber = 0;\n this.fileName = null;\n this.sourceName = null;\n }\n Merge(dm) {\n let newDebugMetadata = new DebugMetadata();\n newDebugMetadata.fileName = this.fileName;\n newDebugMetadata.sourceName = this.sourceName;\n if (this.startLineNumber < dm.startLineNumber) {\n newDebugMetadata.startLineNumber = this.startLineNumber;\n newDebugMetadata.startCharacterNumber = this.startCharacterNumber;\n }\n else if (this.startLineNumber > dm.startLineNumber) {\n newDebugMetadata.startLineNumber = dm.startLineNumber;\n newDebugMetadata.startCharacterNumber = dm.startCharacterNumber;\n }\n else {\n newDebugMetadata.startLineNumber = this.startLineNumber;\n newDebugMetadata.startCharacterNumber = Math.min(this.startCharacterNumber, dm.startCharacterNumber);\n }\n if (this.endLineNumber > dm.endLineNumber) {\n newDebugMetadata.endLineNumber = this.endLineNumber;\n newDebugMetadata.endCharacterNumber = this.endCharacterNumber;\n }\n else if (this.endLineNumber < dm.endLineNumber) {\n newDebugMetadata.endLineNumber = dm.endLineNumber;\n newDebugMetadata.endCharacterNumber = dm.endCharacterNumber;\n }\n else {\n newDebugMetadata.endLineNumber = this.endLineNumber;\n newDebugMetadata.endCharacterNumber = Math.max(this.endCharacterNumber, dm.endCharacterNumber);\n }\n return newDebugMetadata;\n }\n toString() {\n if (this.fileName !== null) {\n return `line ${this.startLineNumber} of ${this.fileName}\"`;\n }\n else {\n return \"line \" + this.startLineNumber;\n }\n }\n}\nexports.DebugMetadata = DebugMetadata;\n//# sourceMappingURL=DebugMetadata.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ExternalDeclaration = void 0;\nconst Object_1 = require(\"../Object\");\nclass ExternalDeclaration extends Object_1.ParsedObject {\n get name() {\n var _a;\n return ((_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name) || null;\n }\n constructor(identifier, argumentNames) {\n super();\n this.identifier = identifier;\n this.argumentNames = argumentNames;\n this.GenerateRuntimeObject = () => {\n this.story.AddExternal(this);\n // No runtime code exists for an external, only metadata\n return null;\n };\n }\n get typeName() {\n return \"EXTERNAL\";\n }\n toString() {\n var _a;\n return `EXTERNAL ${(_a = this.identifier) === null || _a === void 0 ? void 0 : _a.name}`;\n }\n}\nexports.ExternalDeclaration = ExternalDeclaration;\n//# sourceMappingURL=ExternalDeclaration.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.FlowDecl = void 0;\nclass FlowDecl {\n constructor(name, args, isFunction) {\n this.name = name;\n this.args = args;\n this.isFunction = isFunction;\n }\n}\nexports.FlowDecl = FlowDecl;\n//# sourceMappingURL=FlowDecl.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Wrap = void 0;\nconst Object_1 = require(\"./Object\");\nclass Wrap extends Object_1.ParsedObject {\n constructor(_objToWrap) {\n super();\n this._objToWrap = _objToWrap;\n this.GenerateRuntimeObject = () => this._objToWrap;\n }\n}\nexports.Wrap = Wrap;\n//# sourceMappingURL=Wrap.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Glue = void 0;\nconst Wrap_1 = require(\"./Wrap\");\nclass Glue extends Wrap_1.Wrap {\n constructor(glue) {\n super(glue);\n }\n get typeName() {\n return \"Glue\";\n }\n}\nexports.Glue = Glue;\n//# sourceMappingURL=Glue.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Glue = void 0;\nconst Object_1 = require(\"./Object\");\nclass Glue extends Object_1.InkObject {\n toString() {\n return \"Glue\";\n }\n}\nexports.Glue = Glue;\n//# sourceMappingURL=Glue.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.IncDecExpression = void 0;\nconst ContentList_1 = require(\"../ContentList\");\nconst Expression_1 = require(\"./Expression\");\nconst FlowBase_1 = require(\"../Flow/FlowBase\");\nconst NativeFunctionCall_1 = require(\"../../../../engine/NativeFunctionCall\");\nconst Value_1 = require(\"../../../../engine/Value\");\nconst VariableAssignment_1 = require(\"../../../../engine/VariableAssignment\");\nconst VariableReference_1 = require(\"../../../../engine/VariableReference\");\nconst Weave_1 = require(\"../Weave\");\nclass IncDecExpression extends Expression_1.Expression {\n constructor(varIdentifier, isIncOrExpression, isInc) {\n super();\n this.varIdentifier = varIdentifier;\n this._runtimeAssignment = null;\n this.expression = null;\n this.GenerateIntoContainer = (container) => {\n // x = x + y\n // ^^^ ^ ^ ^\n // 4 1 3 2\n // Reverse polish notation: (x 1 +) (assign to x)\n var _a, _b;\n // 1.\n container.AddContent(new VariableReference_1.VariableReference(((_a = this.varIdentifier) === null || _a === void 0 ? void 0 : _a.name) || null));\n // 2.\n // - Expression used in the form ~ x += y\n // - Simple version: ~ x++\n if (this.expression) {\n this.expression.GenerateIntoContainer(container);\n }\n else {\n container.AddContent(new Value_1.IntValue(1));\n }\n // 3.\n container.AddContent(NativeFunctionCall_1.NativeFunctionCall.CallWithName(this.isInc ? \"+\" : \"-\"));\n // 4.\n this._runtimeAssignment = new VariableAssignment_1.VariableAssignment(((_b = this.varIdentifier) === null || _b === void 0 ? void 0 : _b.name) || null, false);\n container.AddContent(this._runtimeAssignment);\n };\n this.toString = () => {\n var _a, _b;\n if (this.expression) {\n return `${(_a = this.varIdentifier) === null || _a === void 0 ? void 0 : _a.name}${this.isInc ? \" += \" : \" -= \"}${this.expression}`;\n }\n return `${(_b = this.varIdentifier) === null || _b === void 0 ? void 0 : _b.name}` + (this.isInc ? \"++\" : \"--\");\n };\n if (isIncOrExpression instanceof Expression_1.Expression) {\n this.expression = isIncOrExpression;\n this.AddContent(this.expression);\n this.isInc = Boolean(isInc);\n }\n else {\n this.isInc = isIncOrExpression;\n }\n }\n get typeName() {\n return \"IncDecExpression\";\n }\n ResolveReferences(context) {\n var _a;\n super.ResolveReferences(context);\n const varResolveResult = context.ResolveVariableWithName(((_a = this.varIdentifier) === null || _a === void 0 ? void 0 : _a.name) || \"\", this);\n if (!varResolveResult.found) {\n this.Error(`variable for ${this.incrementDecrementWord} could not be found: '${this.varIdentifier}' after searching: {this.descriptionOfScope}`);\n }\n if (!this._runtimeAssignment) {\n throw new Error();\n }\n this._runtimeAssignment.isGlobal = varResolveResult.isGlobal;\n if (!(this.parent instanceof Weave_1.Weave) &&\n !(this.parent instanceof FlowBase_1.FlowBase) &&\n !(this.parent instanceof ContentList_1.ContentList)) {\n this.Error(`Can't use ${this.incrementDecrementWord} as sub-expression`);\n }\n }\n get incrementDecrementWord() {\n if (this.isInc) {\n return \"increment\";\n }\n return \"decrement\";\n }\n}\nexports.IncDecExpression = IncDecExpression;\n//# sourceMappingURL=IncDecExpression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.IncludedFile = void 0;\nconst Object_1 = require(\"./Object\");\nclass IncludedFile extends Object_1.ParsedObject {\n constructor(includedStory) {\n super();\n this.includedStory = includedStory;\n this.GenerateRuntimeObject = () => {\n // Left to the main story to process\n return null;\n };\n }\n get typeName() {\n return \"IncludedFile\";\n }\n}\nexports.IncludedFile = IncludedFile;\n//# sourceMappingURL=IncludedFile.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InfixOperator = void 0;\nclass InfixOperator {\n constructor(type, precedence, requireWhitespace) {\n this.type = type;\n this.precedence = precedence;\n this.requireWhitespace = requireWhitespace;\n this.toString = () => this.type;\n }\n}\nexports.InfixOperator = InfixOperator;\n//# sourceMappingURL=InfixOperator.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Knot = void 0;\nconst FlowBase_1 = require(\"./Flow/FlowBase\");\nconst FlowLevel_1 = require(\"./Flow/FlowLevel\");\nclass Knot extends FlowBase_1.FlowBase {\n get flowLevel() {\n return FlowLevel_1.FlowLevel.Knot;\n }\n constructor(name, topLevelObjects, args, isFunction) {\n super(name, topLevelObjects, args, isFunction);\n }\n get typeName() {\n return this.isFunction ? \"Function\" : \"Knot\";\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n let parentStory = this.story;\n // Enforce rule that stitches must not have the same\n // name as any knots that exist in the story\n for (const stitchName in this.subFlowsByName) {\n const knotWithStitchName = parentStory.ContentWithNameAtLevel(stitchName, FlowLevel_1.FlowLevel.Knot, false);\n if (knotWithStitchName) {\n const stitch = this.subFlowsByName.get(stitchName);\n const errorMsg = `Stitch '${stitch ? stitch.name : \"NO STITCH FOUND\"}' has the same name as a knot (on ${knotWithStitchName.debugMetadata})`;\n this.Error(errorMsg, stitch);\n }\n }\n }\n}\nexports.Knot = Knot;\n//# sourceMappingURL=Knot.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.List = void 0;\nconst Expression_1 = require(\"../Expression/Expression\");\nconst InkList_1 = require(\"../../../../engine/InkList\");\nconst InkList_2 = require(\"../../../../engine/InkList\");\nconst Value_1 = require(\"../../../../engine/Value\");\nclass List extends Expression_1.Expression {\n constructor(itemIdentifierList) {\n super();\n this.itemIdentifierList = itemIdentifierList;\n this.GenerateIntoContainer = (container) => {\n var _a, _b;\n const runtimeRawList = new InkList_1.InkList();\n if (this.itemIdentifierList != null) {\n for (const itemIdentifier of this.itemIdentifierList) {\n const nameParts = ((_a = itemIdentifier === null || itemIdentifier === void 0 ? void 0 : itemIdentifier.name) === null || _a === void 0 ? void 0 : _a.split(\".\")) || [];\n let listName = null;\n let listItemName = \"\";\n if (nameParts.length > 1) {\n listName = nameParts[0];\n listItemName = nameParts[1];\n }\n else {\n listItemName = nameParts[0];\n }\n const listItem = this.story.ResolveListItem(listName, listItemName, this);\n if (listItem === null) {\n if (listName === null) {\n this.Error(`Could not find list definition that contains item '${itemIdentifier}'`);\n }\n else {\n this.Error(`Could not find list item ${itemIdentifier}`);\n }\n }\n else {\n if (listItem.parent == null) {\n this.Error(`Could not find list definition for item ${itemIdentifier}`);\n return;\n }\n if (!listName) {\n listName = ((_b = listItem.parent.identifier) === null || _b === void 0 ? void 0 : _b.name) || null;\n }\n const item = new InkList_2.InkListItem(listName, listItem.name || null);\n if (runtimeRawList.has(item.serialized())) {\n this.Warning(`Duplicate of item '${itemIdentifier}' in list.`);\n }\n else {\n runtimeRawList.Add(item, listItem.seriesValue);\n }\n }\n }\n }\n container.AddContent(new Value_1.ListValue(runtimeRawList));\n };\n }\n get typeName() {\n return \"List\";\n }\n}\nexports.List = List;\n//# sourceMappingURL=List.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ListElementDefinition = void 0;\nconst Object_1 = require(\"../Object\");\nconst SymbolType_1 = require(\"../SymbolType\");\nclass ListElementDefinition extends Object_1.ParsedObject {\n get fullName() {\n var _a;\n const parentList = this.parent;\n if (parentList === null) {\n throw new Error(\"Can't get full name without a parent list.\");\n }\n return `${(_a = parentList.identifier) === null || _a === void 0 ? void 0 : _a.name}.${this.name}`;\n }\n get typeName() {\n return \"ListElement\";\n }\n get name() {\n var _a;\n return ((_a = this.indentifier) === null || _a === void 0 ? void 0 : _a.name) || null;\n }\n constructor(indentifier, inInitialList, explicitValue = null) {\n super();\n this.indentifier = indentifier;\n this.inInitialList = inInitialList;\n this.explicitValue = explicitValue;\n this.seriesValue = 0;\n this.parent = null;\n this.GenerateRuntimeObject = () => {\n throw new Error(\"Not implemented.\");\n };\n this.toString = () => this.fullName;\n this.parent = this.parent;\n }\n ResolveReferences(context) {\n super.ResolveReferences(context);\n context.CheckForNamingCollisions(this, this.indentifier, SymbolType_1.SymbolType.ListItem);\n }\n}\nexports.ListElementDefinition = ListElementDefinition;\n//# sourceMappingURL=ListElementDefinition.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StatementLevel = void 0;\nvar StatementLevel;\n(function (StatementLevel) {\n StatementLevel[StatementLevel[\"InnerBlock\"] = 0] = \"InnerBlock\";\n StatementLevel[StatementLevel[\"Stitch\"] = 1] = \"Stitch\";\n StatementLevel[StatementLevel[\"Knot\"] = 2] = \"Knot\";\n StatementLevel[StatementLevel[\"Top\"] = 3] = \"Top\";\n})(StatementLevel || (exports.StatementLevel = StatementLevel = {}));\n//# sourceMappingURL=StatementLevel.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Stitch = void 0;\nconst FlowBase_1 = require(\"./Flow/FlowBase\");\nconst FlowLevel_1 = require(\"./Flow/FlowLevel\");\nclass Stitch extends FlowBase_1.FlowBase {\n get flowLevel() {\n return FlowLevel_1.FlowLevel.Stitch;\n }\n constructor(name, topLevelObjects, args, isFunction) {\n super(name, topLevelObjects, args, isFunction);\n // Fixes TS issue with not being able to access the prototype via `super` in functions\n // attached to the class as properties.\n this.baseToString = this.toString;\n this.toString = () => {\n return `${this.parent !== null ? this.parent + \" > \" : \"\"}${this.baseToString()}`;\n };\n }\n get typeName() {\n return \"Stitch\";\n }\n}\nexports.Stitch = Stitch;\n//# sourceMappingURL=Stitch.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Tag = void 0;\nconst Object_1 = require(\"./Object\");\n// New version of tags is dynamic - it constructs the tags\n// at runtime based on BeginTag and EndTag control commands.\n// Plain text that's in the output stream is turned into tags\n// when you do story.currentTags.\n// The only place this is used is when flattening tags down\n// to string in advance, during dynamic string generation if\n// there's a tag embedded in it. See how ControlCommand.EndString\n// is implemented in Story.cs for more details + comment\nclass Tag extends Object_1.InkObject {\n constructor(tagText) {\n super();\n this.text = tagText.toString() || \"\";\n }\n toString() {\n return \"# \" + this.text;\n }\n}\nexports.Tag = Tag;\n//# sourceMappingURL=Tag.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Choice = void 0;\nconst Path_1 = require(\"./Path\");\nconst NullException_1 = require(\"./NullException\");\nconst Object_1 = require(\"./Object\");\nclass Choice extends Object_1.InkObject {\n constructor() {\n super(...arguments);\n this.text = \"\";\n this.index = 0;\n this.threadAtGeneration = null;\n this.sourcePath = \"\";\n this.targetPath = null;\n this.isInvisibleDefault = false;\n this.tags = null;\n this.originalThreadIndex = 0;\n }\n get pathStringOnChoice() {\n if (this.targetPath === null)\n return (0, NullException_1.throwNullException)(\"Choice.targetPath\");\n return this.targetPath.toString();\n }\n set pathStringOnChoice(value) {\n this.targetPath = new Path_1.Path(value);\n }\n Clone() {\n let copy = new Choice();\n copy.text = this.text;\n copy.sourcePath = this.sourcePath;\n copy.index = this.index;\n copy.targetPath = this.targetPath;\n copy.originalThreadIndex = this.originalThreadIndex;\n copy.isInvisibleDefault = this.isInvisibleDefault;\n if (this.threadAtGeneration !== null)\n copy.threadAtGeneration = this.threadAtGeneration.Copy();\n return copy;\n }\n}\nexports.Choice = Choice;\n//# sourceMappingURL=Choice.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ListDefinitionsOrigin = void 0;\nconst InkList_1 = require(\"./InkList\");\nconst Value_1 = require(\"./Value\");\nconst NullException_1 = require(\"./NullException\");\nclass ListDefinitionsOrigin {\n constructor(lists) {\n this._lists = new Map();\n this._allUnambiguousListValueCache = new Map();\n for (let list of lists) {\n this._lists.set(list.name, list);\n for (let [key, val] of list.items) {\n let item = InkList_1.InkListItem.fromSerializedKey(key);\n let listValue = new Value_1.ListValue(item, val);\n if (!item.itemName) {\n throw new Error(\"item.itemName is null or undefined.\");\n }\n this._allUnambiguousListValueCache.set(item.itemName, listValue);\n this._allUnambiguousListValueCache.set(item.fullName, listValue);\n }\n }\n }\n get lists() {\n let listOfLists = [];\n for (let [, value] of this._lists) {\n listOfLists.push(value);\n }\n return listOfLists;\n }\n TryListGetDefinition(name, \n /* out */ def) {\n if (name === null) {\n return { result: def, exists: false };\n }\n // initially, this function returns a boolean and the second parameter is an out.\n let definition = this._lists.get(name);\n if (!definition)\n return { result: def, exists: false };\n return { result: definition, exists: true };\n }\n FindSingleItemListWithName(name) {\n if (name === null) {\n return (0, NullException_1.throwNullException)(\"name\");\n }\n let val = this._allUnambiguousListValueCache.get(name);\n if (typeof val !== \"undefined\") {\n return val;\n }\n return null;\n }\n}\nexports.ListDefinitionsOrigin = ListDefinitionsOrigin;\n//# sourceMappingURL=ListDefinitionsOrigin.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.JsonSerialisation = void 0;\nconst Container_1 = require(\"./Container\");\nconst Value_1 = require(\"./Value\");\nconst Glue_1 = require(\"./Glue\");\nconst ControlCommand_1 = require(\"./ControlCommand\");\nconst PushPop_1 = require(\"./PushPop\");\nconst Divert_1 = require(\"./Divert\");\nconst ChoicePoint_1 = require(\"./ChoicePoint\");\nconst VariableReference_1 = require(\"./VariableReference\");\nconst VariableAssignment_1 = require(\"./VariableAssignment\");\nconst NativeFunctionCall_1 = require(\"./NativeFunctionCall\");\nconst Void_1 = require(\"./Void\");\nconst Tag_1 = require(\"./Tag\");\nconst Path_1 = require(\"./Path\");\nconst Choice_1 = require(\"./Choice\");\nconst ListDefinition_1 = require(\"./ListDefinition\");\nconst ListDefinitionsOrigin_1 = require(\"./ListDefinitionsOrigin\");\nconst InkList_1 = require(\"./InkList\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst NullException_1 = require(\"./NullException\");\nclass JsonSerialisation {\n static JArrayToRuntimeObjList(jArray, skipLast = false) {\n let count = jArray.length;\n if (skipLast)\n count--;\n let list = [];\n for (let i = 0; i < count; i++) {\n let jTok = jArray[i];\n let runtimeObj = this.JTokenToRuntimeObject(jTok);\n if (runtimeObj === null) {\n return (0, NullException_1.throwNullException)(\"runtimeObj\");\n }\n list.push(runtimeObj);\n }\n return list;\n }\n static WriteDictionaryRuntimeObjs(writer, dictionary) {\n writer.WriteObjectStart();\n for (let [key, value] of dictionary) {\n writer.WritePropertyStart(key);\n this.WriteRuntimeObject(writer, value);\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n }\n static WriteListRuntimeObjs(writer, list) {\n writer.WriteArrayStart();\n for (let value of list) {\n this.WriteRuntimeObject(writer, value);\n }\n writer.WriteArrayEnd();\n }\n static WriteIntDictionary(writer, dict) {\n writer.WriteObjectStart();\n for (let [key, value] of dict) {\n writer.WriteIntProperty(key, value);\n }\n writer.WriteObjectEnd();\n }\n static WriteRuntimeObject(writer, obj) {\n let container = (0, TypeAssertion_1.asOrNull)(obj, Container_1.Container);\n if (container) {\n this.WriteRuntimeContainer(writer, container);\n return;\n }\n let divert = (0, TypeAssertion_1.asOrNull)(obj, Divert_1.Divert);\n if (divert) {\n let divTypeKey = \"->\";\n if (divert.isExternal) {\n divTypeKey = \"x()\";\n }\n else if (divert.pushesToStack) {\n if (divert.stackPushType == PushPop_1.PushPopType.Function) {\n divTypeKey = \"f()\";\n }\n else if (divert.stackPushType == PushPop_1.PushPopType.Tunnel) {\n divTypeKey = \"->t->\";\n }\n }\n let targetStr;\n if (divert.hasVariableTarget) {\n targetStr = divert.variableDivertName;\n }\n else {\n targetStr = divert.targetPathString;\n }\n writer.WriteObjectStart();\n writer.WriteProperty(divTypeKey, targetStr);\n if (divert.hasVariableTarget) {\n writer.WriteProperty(\"var\", true);\n }\n if (divert.isConditional) {\n writer.WriteProperty(\"c\", true);\n }\n if (divert.externalArgs > 0) {\n writer.WriteIntProperty(\"exArgs\", divert.externalArgs);\n }\n writer.WriteObjectEnd();\n return;\n }\n let choicePoint = (0, TypeAssertion_1.asOrNull)(obj, ChoicePoint_1.ChoicePoint);\n if (choicePoint) {\n writer.WriteObjectStart();\n writer.WriteProperty(\"*\", choicePoint.pathStringOnChoice);\n writer.WriteIntProperty(\"flg\", choicePoint.flags);\n writer.WriteObjectEnd();\n return;\n }\n let boolVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.BoolValue);\n if (boolVal) {\n writer.WriteBool(boolVal.value);\n return;\n }\n let intVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.IntValue);\n if (intVal) {\n writer.WriteInt(intVal.value);\n return;\n }\n let floatVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.FloatValue);\n if (floatVal) {\n writer.WriteFloat(floatVal.value);\n return;\n }\n let strVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.StringValue);\n if (strVal) {\n if (strVal.isNewline) {\n writer.Write(\"\\n\", false);\n }\n else {\n writer.WriteStringStart();\n writer.WriteStringInner(\"^\");\n writer.WriteStringInner(strVal.value);\n writer.WriteStringEnd();\n }\n return;\n }\n let listVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.ListValue);\n if (listVal) {\n this.WriteInkList(writer, listVal);\n return;\n }\n let divTargetVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.DivertTargetValue);\n if (divTargetVal) {\n writer.WriteObjectStart();\n if (divTargetVal.value === null) {\n return (0, NullException_1.throwNullException)(\"divTargetVal.value\");\n }\n writer.WriteProperty(\"^->\", divTargetVal.value.componentsString);\n writer.WriteObjectEnd();\n return;\n }\n let varPtrVal = (0, TypeAssertion_1.asOrNull)(obj, Value_1.VariablePointerValue);\n if (varPtrVal) {\n writer.WriteObjectStart();\n writer.WriteProperty(\"^var\", varPtrVal.value);\n writer.WriteIntProperty(\"ci\", varPtrVal.contextIndex);\n writer.WriteObjectEnd();\n return;\n }\n let glue = (0, TypeAssertion_1.asOrNull)(obj, Glue_1.Glue);\n if (glue) {\n writer.Write(\"<>\");\n return;\n }\n let controlCmd = (0, TypeAssertion_1.asOrNull)(obj, ControlCommand_1.ControlCommand);\n if (controlCmd) {\n writer.Write(JsonSerialisation._controlCommandNames[controlCmd.commandType]);\n return;\n }\n let nativeFunc = (0, TypeAssertion_1.asOrNull)(obj, NativeFunctionCall_1.NativeFunctionCall);\n if (nativeFunc) {\n let name = nativeFunc.name;\n if (name == \"^\")\n name = \"L^\";\n writer.Write(name);\n return;\n }\n let varRef = (0, TypeAssertion_1.asOrNull)(obj, VariableReference_1.VariableReference);\n if (varRef) {\n writer.WriteObjectStart();\n let readCountPath = varRef.pathStringForCount;\n if (readCountPath != null) {\n writer.WriteProperty(\"CNT?\", readCountPath);\n }\n else {\n writer.WriteProperty(\"VAR?\", varRef.name);\n }\n writer.WriteObjectEnd();\n return;\n }\n let varAss = (0, TypeAssertion_1.asOrNull)(obj, VariableAssignment_1.VariableAssignment);\n if (varAss) {\n writer.WriteObjectStart();\n let key = varAss.isGlobal ? \"VAR=\" : \"temp=\";\n writer.WriteProperty(key, varAss.variableName);\n // Reassignment?\n if (!varAss.isNewDeclaration)\n writer.WriteProperty(\"re\", true);\n writer.WriteObjectEnd();\n return;\n }\n let voidObj = (0, TypeAssertion_1.asOrNull)(obj, Void_1.Void);\n if (voidObj) {\n writer.Write(\"void\");\n return;\n }\n let tag = (0, TypeAssertion_1.asOrNull)(obj, Tag_1.Tag);\n if (tag) {\n writer.WriteObjectStart();\n writer.WriteProperty(\"#\", tag.text);\n writer.WriteObjectEnd();\n return;\n }\n let choice = (0, TypeAssertion_1.asOrNull)(obj, Choice_1.Choice);\n if (choice) {\n this.WriteChoice(writer, choice);\n return;\n }\n throw new Error(\"Failed to convert runtime object to Json token: \" + obj);\n }\n static JObjectToDictionaryRuntimeObjs(jObject) {\n let dict = new Map();\n for (let key in jObject) {\n if (jObject.hasOwnProperty(key)) {\n let inkObject = this.JTokenToRuntimeObject(jObject[key]);\n if (inkObject === null) {\n return (0, NullException_1.throwNullException)(\"inkObject\");\n }\n dict.set(key, inkObject);\n }\n }\n return dict;\n }\n static JObjectToIntDictionary(jObject) {\n let dict = new Map();\n for (let key in jObject) {\n if (jObject.hasOwnProperty(key)) {\n dict.set(key, parseInt(jObject[key]));\n }\n }\n return dict;\n }\n static JTokenToRuntimeObject(token) {\n if ((typeof token === \"number\" && !isNaN(token)) ||\n typeof token === \"boolean\") {\n return Value_1.Value.Create(token);\n }\n if (typeof token === \"string\") {\n let str = token.toString();\n //Explicit float value of the form \"123.00f\"\n const floatRepresentation = /^([0-9]+.[0-9]+f)$/.exec(str);\n if (floatRepresentation) {\n return new Value_1.FloatValue(parseFloat(floatRepresentation[0]));\n }\n // String value\n let firstChar = str[0];\n if (firstChar == \"^\")\n return new Value_1.StringValue(str.substring(1));\n else if (firstChar == \"\\n\" && str.length == 1)\n return new Value_1.StringValue(\"\\n\");\n // Glue\n if (str == \"<>\")\n return new Glue_1.Glue();\n // Control commands (would looking up in a hash set be faster?)\n for (let i = 0; i < JsonSerialisation._controlCommandNames.length; ++i) {\n let cmdName = JsonSerialisation._controlCommandNames[i];\n if (str == cmdName) {\n return new ControlCommand_1.ControlCommand(i);\n }\n }\n // Native functions\n if (str == \"L^\")\n str = \"^\";\n if (NativeFunctionCall_1.NativeFunctionCall.CallExistsWithName(str))\n return NativeFunctionCall_1.NativeFunctionCall.CallWithName(str);\n // Pop\n if (str == \"->->\")\n return ControlCommand_1.ControlCommand.PopTunnel();\n else if (str == \"~ret\")\n return ControlCommand_1.ControlCommand.PopFunction();\n // Void\n if (str == \"void\")\n return new Void_1.Void();\n }\n if (typeof token === \"object\" && !Array.isArray(token)) {\n let obj = token;\n let propValue;\n // Divert target value to path\n if (obj[\"^->\"]) {\n propValue = obj[\"^->\"];\n return new Value_1.DivertTargetValue(new Path_1.Path(propValue.toString()));\n }\n // VariablePointerValue\n if (obj[\"^var\"]) {\n propValue = obj[\"^var\"];\n let varPtr = new Value_1.VariablePointerValue(propValue.toString());\n if (\"ci\" in obj) {\n propValue = obj[\"ci\"];\n varPtr.contextIndex = parseInt(propValue);\n }\n return varPtr;\n }\n // Divert\n let isDivert = false;\n let pushesToStack = false;\n let divPushType = PushPop_1.PushPopType.Function;\n let external = false;\n if ((propValue = obj[\"->\"])) {\n isDivert = true;\n }\n else if ((propValue = obj[\"f()\"])) {\n isDivert = true;\n pushesToStack = true;\n divPushType = PushPop_1.PushPopType.Function;\n }\n else if ((propValue = obj[\"->t->\"])) {\n isDivert = true;\n pushesToStack = true;\n divPushType = PushPop_1.PushPopType.Tunnel;\n }\n else if ((propValue = obj[\"x()\"])) {\n isDivert = true;\n external = true;\n pushesToStack = false;\n divPushType = PushPop_1.PushPopType.Function;\n }\n if (isDivert) {\n let divert = new Divert_1.Divert();\n divert.pushesToStack = pushesToStack;\n divert.stackPushType = divPushType;\n divert.isExternal = external;\n let target = propValue.toString();\n if ((propValue = obj[\"var\"]))\n divert.variableDivertName = target;\n else\n divert.targetPathString = target;\n divert.isConditional = !!obj[\"c\"];\n if (external) {\n if ((propValue = obj[\"exArgs\"]))\n divert.externalArgs = parseInt(propValue);\n }\n return divert;\n }\n // Choice\n if ((propValue = obj[\"*\"])) {\n let choice = new ChoicePoint_1.ChoicePoint();\n choice.pathStringOnChoice = propValue.toString();\n if ((propValue = obj[\"flg\"]))\n choice.flags = parseInt(propValue);\n return choice;\n }\n // Variable reference\n if ((propValue = obj[\"VAR?\"])) {\n return new VariableReference_1.VariableReference(propValue.toString());\n }\n else if ((propValue = obj[\"CNT?\"])) {\n let readCountVarRef = new VariableReference_1.VariableReference();\n readCountVarRef.pathStringForCount = propValue.toString();\n return readCountVarRef;\n }\n // Variable assignment\n let isVarAss = false;\n let isGlobalVar = false;\n if ((propValue = obj[\"VAR=\"])) {\n isVarAss = true;\n isGlobalVar = true;\n }\n else if ((propValue = obj[\"temp=\"])) {\n isVarAss = true;\n isGlobalVar = false;\n }\n if (isVarAss) {\n let varName = propValue.toString();\n let isNewDecl = !obj[\"re\"];\n let varAss = new VariableAssignment_1.VariableAssignment(varName, isNewDecl);\n varAss.isGlobal = isGlobalVar;\n return varAss;\n }\n if (obj[\"#\"] !== undefined) {\n propValue = obj[\"#\"];\n return new Tag_1.Tag(propValue.toString());\n }\n // List value\n if ((propValue = obj[\"list\"])) {\n // var listContent = (Dictionary<string, object>)propValue;\n let listContent = propValue;\n let rawList = new InkList_1.InkList();\n if ((propValue = obj[\"origins\"])) {\n // var namesAsObjs = (List<object>)propValue;\n let namesAsObjs = propValue;\n // rawList.SetInitialOriginNames(namesAsObjs.Cast<string>().ToList());\n rawList.SetInitialOriginNames(namesAsObjs);\n }\n for (let key in listContent) {\n if (listContent.hasOwnProperty(key)) {\n let nameToVal = listContent[key];\n let item = new InkList_1.InkListItem(key);\n let val = parseInt(nameToVal);\n rawList.Add(item, val);\n }\n }\n return new Value_1.ListValue(rawList);\n }\n if (obj[\"originalChoicePath\"] != null)\n return this.JObjectToChoice(obj);\n }\n // Array is always a Runtime.Container\n if (Array.isArray(token)) {\n return this.JArrayToContainer(token);\n }\n if (token === null || token === undefined)\n return null;\n throw new Error(\"Failed to convert token to runtime object: \" +\n this.toJson(token, [\"parent\"]));\n }\n static toJson(me, removes, space) {\n return JSON.stringify(me, (k, v) => ((removes === null || removes === void 0 ? void 0 : removes.some((r) => r === k)) ? undefined : v), space);\n }\n static WriteRuntimeContainer(writer, container, withoutName = false) {\n writer.WriteArrayStart();\n if (container === null) {\n return (0, NullException_1.throwNullException)(\"container\");\n }\n for (let c of container.content)\n this.WriteRuntimeObject(writer, c);\n let namedOnlyContent = container.namedOnlyContent;\n let countFlags = container.countFlags;\n let hasNameProperty = container.name != null && !withoutName;\n let hasTerminator = namedOnlyContent != null || countFlags > 0 || hasNameProperty;\n if (hasTerminator) {\n writer.WriteObjectStart();\n }\n if (namedOnlyContent != null) {\n for (let [key, value] of namedOnlyContent) {\n let name = key;\n let namedContainer = (0, TypeAssertion_1.asOrNull)(value, Container_1.Container);\n writer.WritePropertyStart(name);\n this.WriteRuntimeContainer(writer, namedContainer, true);\n writer.WritePropertyEnd();\n }\n }\n if (countFlags > 0)\n writer.WriteIntProperty(\"#f\", countFlags);\n if (hasNameProperty)\n writer.WriteProperty(\"#n\", container.name);\n if (hasTerminator)\n writer.WriteObjectEnd();\n else\n writer.WriteNull();\n writer.WriteArrayEnd();\n }\n static JArrayToContainer(jArray) {\n let container = new Container_1.Container();\n container.content = this.JArrayToRuntimeObjList(jArray, true);\n let terminatingObj = jArray[jArray.length - 1];\n if (terminatingObj != null) {\n let namedOnlyContent = new Map();\n for (let key in terminatingObj) {\n if (key == \"#f\") {\n container.countFlags = parseInt(terminatingObj[key]);\n }\n else if (key == \"#n\") {\n container.name = terminatingObj[key].toString();\n }\n else {\n let namedContentItem = this.JTokenToRuntimeObject(terminatingObj[key]);\n // var namedSubContainer = namedContentItem as Container;\n let namedSubContainer = (0, TypeAssertion_1.asOrNull)(namedContentItem, Container_1.Container);\n if (namedSubContainer)\n namedSubContainer.name = key;\n namedOnlyContent.set(key, namedContentItem);\n }\n }\n container.namedOnlyContent = namedOnlyContent;\n }\n return container;\n }\n static JObjectToChoice(jObj) {\n let choice = new Choice_1.Choice();\n choice.text = jObj[\"text\"].toString();\n choice.index = parseInt(jObj[\"index\"]);\n choice.sourcePath = jObj[\"originalChoicePath\"].toString();\n choice.originalThreadIndex = parseInt(jObj[\"originalThreadIndex\"]);\n choice.pathStringOnChoice = jObj[\"targetPath\"].toString();\n choice.tags = this.JArrayToTags(jObj);\n choice.isInvisibleDefault = !!jObj[\"isInvisibleDefault\"];\n return choice;\n }\n static JArrayToTags(jObj) {\n if (jObj[\"tags\"]) {\n return jObj[\"tags\"];\n }\n else {\n return null;\n }\n }\n static WriteChoice(writer, choice) {\n writer.WriteObjectStart();\n writer.WriteProperty(\"text\", choice.text);\n writer.WriteIntProperty(\"index\", choice.index);\n writer.WriteProperty(\"originalChoicePath\", choice.sourcePath);\n writer.WriteIntProperty(\"originalThreadIndex\", choice.originalThreadIndex);\n writer.WriteProperty(\"targetPath\", choice.pathStringOnChoice);\n writer.WriteProperty(\"isInvisibleDefault\", choice.isInvisibleDefault);\n this.WriteChoiceTags(writer, choice);\n writer.WriteObjectEnd();\n }\n static WriteChoiceTags(writer, choice) {\n if (choice.tags && choice.tags.length > 0) {\n writer.WritePropertyStart(\"tags\");\n writer.WriteArrayStart();\n for (const tag of choice.tags) {\n writer.Write(tag);\n }\n writer.WriteArrayEnd();\n writer.WritePropertyEnd();\n }\n }\n static WriteInkList(writer, listVal) {\n let rawList = listVal.value;\n if (rawList === null) {\n return (0, NullException_1.throwNullException)(\"rawList\");\n }\n writer.WriteObjectStart();\n writer.WritePropertyStart(\"list\");\n writer.WriteObjectStart();\n for (let [key, val] of rawList) {\n let item = InkList_1.InkListItem.fromSerializedKey(key);\n let itemVal = val;\n if (item.itemName === null) {\n return (0, NullException_1.throwNullException)(\"item.itemName\");\n }\n writer.WritePropertyNameStart();\n writer.WritePropertyNameInner(item.originName ? item.originName : \"?\");\n writer.WritePropertyNameInner(\".\");\n writer.WritePropertyNameInner(item.itemName);\n writer.WritePropertyNameEnd();\n writer.Write(itemVal);\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n writer.WritePropertyEnd();\n if (rawList.Count == 0 &&\n rawList.originNames != null &&\n rawList.originNames.length > 0) {\n writer.WritePropertyStart(\"origins\");\n writer.WriteArrayStart();\n for (let name of rawList.originNames)\n writer.Write(name);\n writer.WriteArrayEnd();\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n }\n static ListDefinitionsToJToken(origin) {\n let result = {};\n for (let def of origin.lists) {\n let listDefJson = {};\n for (let [key, val] of def.items) {\n let item = InkList_1.InkListItem.fromSerializedKey(key);\n if (item.itemName === null) {\n return (0, NullException_1.throwNullException)(\"item.itemName\");\n }\n listDefJson[item.itemName] = val;\n }\n result[def.name] = listDefJson;\n }\n return result;\n }\n static JTokenToListDefinitions(obj) {\n // var defsObj = (Dictionary<string, object>)obj;\n let defsObj = obj;\n let allDefs = [];\n for (let key in defsObj) {\n if (defsObj.hasOwnProperty(key)) {\n let name = key.toString();\n // var listDefJson = (Dictionary<string, object>)kv.Value;\n let listDefJson = defsObj[key];\n // Cast (string, object) to (string, int) for items\n let items = new Map();\n for (let nameValueKey in listDefJson) {\n if (defsObj.hasOwnProperty(key)) {\n let nameValue = listDefJson[nameValueKey];\n items.set(nameValueKey, parseInt(nameValue));\n }\n }\n let def = new ListDefinition_1.ListDefinition(name, items);\n allDefs.push(def);\n }\n }\n return new ListDefinitionsOrigin_1.ListDefinitionsOrigin(allDefs);\n }\n}\nexports.JsonSerialisation = JsonSerialisation;\nJsonSerialisation._controlCommandNames = (() => {\n let _controlCommandNames = [];\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.EvalStart] = \"ev\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.EvalOutput] = \"out\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.EvalEnd] = \"/ev\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.Duplicate] = \"du\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.PopEvaluatedValue] = \"pop\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.PopFunction] = \"~ret\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.PopTunnel] = \"->->\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.BeginString] = \"str\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.EndString] = \"/str\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.NoOp] = \"nop\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.ChoiceCount] = \"choiceCnt\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.Turns] = \"turn\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.TurnsSince] = \"turns\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.ReadCount] = \"readc\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.Random] = \"rnd\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.SeedRandom] = \"srnd\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.VisitIndex] = \"visit\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.SequenceShuffleIndex] =\n \"seq\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.StartThread] = \"thread\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.Done] = \"done\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.End] = \"end\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.ListFromInt] = \"listInt\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.ListRange] = \"range\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.ListRandom] = \"lrnd\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.BeginTag] = \"#\";\n _controlCommandNames[ControlCommand_1.ControlCommand.CommandType.EndTag] = \"/#\";\n for (let i = 0; i < ControlCommand_1.ControlCommand.CommandType.TOTAL_VALUES; ++i) {\n if (_controlCommandNames[i] == null)\n throw new Error(\"Control command not accounted for in serialisation\");\n }\n return _controlCommandNames;\n})();\n//# sourceMappingURL=JsonSerialisation.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.CallStack = void 0;\nconst PushPop_1 = require(\"./PushPop\");\nconst Path_1 = require(\"./Path\");\nconst Story_1 = require(\"./Story\");\nconst JsonSerialisation_1 = require(\"./JsonSerialisation\");\nconst Value_1 = require(\"./Value\");\nconst StringBuilder_1 = require(\"./StringBuilder\");\nconst Pointer_1 = require(\"./Pointer\");\nconst Debug_1 = require(\"./Debug\");\nconst TryGetResult_1 = require(\"./TryGetResult\");\nconst NullException_1 = require(\"./NullException\");\nclass CallStack {\n get elements() {\n return this.callStack;\n }\n get depth() {\n return this.elements.length;\n }\n get currentElement() {\n let thread = this._threads[this._threads.length - 1];\n let cs = thread.callstack;\n return cs[cs.length - 1];\n }\n get currentElementIndex() {\n return this.callStack.length - 1;\n }\n get currentThread() {\n return this._threads[this._threads.length - 1];\n }\n set currentThread(value) {\n Debug_1.Debug.Assert(this._threads.length == 1, \"Shouldn't be directly setting the current thread when we have a stack of them\");\n this._threads.length = 0;\n this._threads.push(value);\n }\n get canPop() {\n return this.callStack.length > 1;\n }\n constructor() {\n this._threadCounter = 0;\n this._startOfRoot = Pointer_1.Pointer.Null;\n if (arguments[0] instanceof Story_1.Story) {\n let storyContext = arguments[0];\n this._startOfRoot = Pointer_1.Pointer.StartOf(storyContext.rootContentContainer);\n this.Reset();\n }\n else {\n let toCopy = arguments[0];\n this._threads = [];\n for (let otherThread of toCopy._threads) {\n this._threads.push(otherThread.Copy());\n }\n this._threadCounter = toCopy._threadCounter;\n this._startOfRoot = toCopy._startOfRoot.copy();\n }\n }\n Reset() {\n this._threads = [];\n this._threads.push(new CallStack.Thread());\n this._threads[0].callstack.push(new CallStack.Element(PushPop_1.PushPopType.Tunnel, this._startOfRoot));\n }\n SetJsonToken(jObject, storyContext) {\n this._threads.length = 0;\n // TODO: (List<object>) jObject [\"threads\"];\n let jThreads = jObject[\"threads\"];\n for (let jThreadTok of jThreads) {\n // TODO: var jThreadObj = (Dictionary<string, object>)jThreadTok;\n let jThreadObj = jThreadTok;\n let thread = new CallStack.Thread(jThreadObj, storyContext);\n this._threads.push(thread);\n }\n // TODO: (int)jObject [\"threadCounter\"];\n this._threadCounter = parseInt(jObject[\"threadCounter\"]);\n this._startOfRoot = Pointer_1.Pointer.StartOf(storyContext.rootContentContainer);\n }\n WriteJson(w) {\n w.WriteObject((writer) => {\n writer.WritePropertyStart(\"threads\");\n writer.WriteArrayStart();\n for (let thread of this._threads) {\n thread.WriteJson(writer);\n }\n writer.WriteArrayEnd();\n writer.WritePropertyEnd();\n writer.WritePropertyStart(\"threadCounter\");\n writer.WriteInt(this._threadCounter);\n writer.WritePropertyEnd();\n });\n }\n PushThread() {\n let newThread = this.currentThread.Copy();\n this._threadCounter++;\n newThread.threadIndex = this._threadCounter;\n this._threads.push(newThread);\n }\n ForkThread() {\n let forkedThread = this.currentThread.Copy();\n this._threadCounter++;\n forkedThread.threadIndex = this._threadCounter;\n return forkedThread;\n }\n PopThread() {\n if (this.canPopThread) {\n this._threads.splice(this._threads.indexOf(this.currentThread), 1); // should be equivalent to a pop()\n }\n else {\n throw new Error(\"Can't pop thread\");\n }\n }\n get canPopThread() {\n return this._threads.length > 1 && !this.elementIsEvaluateFromGame;\n }\n get elementIsEvaluateFromGame() {\n return this.currentElement.type == PushPop_1.PushPopType.FunctionEvaluationFromGame;\n }\n Push(type, externalEvaluationStackHeight = 0, outputStreamLengthWithPushed = 0) {\n let element = new CallStack.Element(type, this.currentElement.currentPointer, false);\n element.evaluationStackHeightWhenPushed = externalEvaluationStackHeight;\n element.functionStartInOutputStream = outputStreamLengthWithPushed;\n this.callStack.push(element);\n }\n CanPop(type = null) {\n if (!this.canPop)\n return false;\n if (type == null)\n return true;\n return this.currentElement.type == type;\n }\n Pop(type = null) {\n if (this.CanPop(type)) {\n this.callStack.pop();\n return;\n }\n else {\n throw new Error(\"Mismatched push/pop in Callstack\");\n }\n }\n GetTemporaryVariableWithName(name, contextIndex = -1) {\n // contextIndex 0 means global, so index is actually 1-based\n if (contextIndex == -1)\n contextIndex = this.currentElementIndex + 1;\n let contextElement = this.callStack[contextIndex - 1];\n let varValue = (0, TryGetResult_1.tryGetValueFromMap)(contextElement.temporaryVariables, name, null);\n if (varValue.exists) {\n return varValue.result;\n }\n else {\n return null;\n }\n }\n SetTemporaryVariable(name, value, declareNew, contextIndex = -1) {\n if (contextIndex == -1)\n contextIndex = this.currentElementIndex + 1;\n let contextElement = this.callStack[contextIndex - 1];\n if (!declareNew && !contextElement.temporaryVariables.get(name)) {\n throw new Error(\"Could not find temporary variable to set: \" + name);\n }\n let oldValue = (0, TryGetResult_1.tryGetValueFromMap)(contextElement.temporaryVariables, name, null);\n if (oldValue.exists)\n Value_1.ListValue.RetainListOriginsForAssignment(oldValue.result, value);\n contextElement.temporaryVariables.set(name, value);\n }\n ContextForVariableNamed(name) {\n if (this.currentElement.temporaryVariables.get(name)) {\n return this.currentElementIndex + 1;\n }\n else {\n return 0;\n }\n }\n ThreadWithIndex(index) {\n let filtered = this._threads.filter((t) => {\n if (t.threadIndex == index)\n return t;\n });\n return filtered.length > 0 ? filtered[0] : null;\n }\n get callStack() {\n return this.currentThread.callstack;\n }\n get callStackTrace() {\n let sb = new StringBuilder_1.StringBuilder();\n for (let t = 0; t < this._threads.length; t++) {\n let thread = this._threads[t];\n let isCurrent = t == this._threads.length - 1;\n sb.AppendFormat(\"=== THREAD {0}/{1} {2}===\\n\", t + 1, this._threads.length, isCurrent ? \"(current) \" : \"\");\n for (let i = 0; i < thread.callstack.length; i++) {\n if (thread.callstack[i].type == PushPop_1.PushPopType.Function)\n sb.Append(\" [FUNCTION] \");\n else\n sb.Append(\" [TUNNEL] \");\n let pointer = thread.callstack[i].currentPointer;\n if (!pointer.isNull) {\n sb.Append(\"<SOMEWHERE IN \");\n if (pointer.container === null) {\n return (0, NullException_1.throwNullException)(\"pointer.container\");\n }\n sb.Append(pointer.container.path.toString());\n sb.AppendLine(\">\");\n }\n }\n }\n return sb.toString();\n }\n}\nexports.CallStack = CallStack;\n(function (CallStack) {\n class Element {\n constructor(type, pointer, inExpressionEvaluation = false) {\n this.evaluationStackHeightWhenPushed = 0;\n this.functionStartInOutputStream = 0;\n this.currentPointer = pointer.copy();\n this.inExpressionEvaluation = inExpressionEvaluation;\n this.temporaryVariables = new Map();\n this.type = type;\n }\n Copy() {\n let copy = new Element(this.type, this.currentPointer, this.inExpressionEvaluation);\n copy.temporaryVariables = new Map(this.temporaryVariables);\n copy.evaluationStackHeightWhenPushed =\n this.evaluationStackHeightWhenPushed;\n copy.functionStartInOutputStream = this.functionStartInOutputStream;\n return copy;\n }\n }\n CallStack.Element = Element;\n class Thread {\n constructor() {\n this.threadIndex = 0;\n this.previousPointer = Pointer_1.Pointer.Null;\n this.callstack = [];\n if (arguments[0] && arguments[1]) {\n let jThreadObj = arguments[0];\n let storyContext = arguments[1];\n // TODO: (int) jThreadObj['threadIndex'] can raise;\n this.threadIndex = parseInt(jThreadObj[\"threadIndex\"]);\n let jThreadCallstack = jThreadObj[\"callstack\"];\n for (let jElTok of jThreadCallstack) {\n let jElementObj = jElTok;\n // TODO: (int) jElementObj['type'] can raise;\n let pushPopType = parseInt(jElementObj[\"type\"]);\n let pointer = Pointer_1.Pointer.Null;\n let currentContainerPathStr;\n // TODO: jElementObj.TryGetValue (\"cPath\", out currentContainerPathStrToken);\n let currentContainerPathStrToken = jElementObj[\"cPath\"];\n if (typeof currentContainerPathStrToken !== \"undefined\") {\n currentContainerPathStr = currentContainerPathStrToken.toString();\n let threadPointerResult = storyContext.ContentAtPath(new Path_1.Path(currentContainerPathStr));\n pointer.container = threadPointerResult.container;\n pointer.index = parseInt(jElementObj[\"idx\"]);\n if (threadPointerResult.obj == null)\n throw new Error(\"When loading state, internal story location couldn't be found: \" +\n currentContainerPathStr +\n \". Has the story changed since this save data was created?\");\n else if (threadPointerResult.approximate) {\n if (pointer.container !== null) {\n storyContext.Warning(\"When loading state, exact internal story location couldn't be found: '\" +\n currentContainerPathStr +\n \"', so it was approximated to '\" +\n pointer.container.path.toString() +\n \"' to recover. Has the story changed since this save data was created?\");\n }\n else {\n storyContext.Warning(\"When loading state, exact internal story location couldn't be found: '\" +\n currentContainerPathStr +\n \"' and it may not be recoverable. Has the story changed since this save data was created?\");\n }\n }\n }\n let inExpressionEvaluation = !!jElementObj[\"exp\"];\n let el = new Element(pushPopType, pointer, inExpressionEvaluation);\n let temps = jElementObj[\"temp\"];\n if (typeof temps !== \"undefined\") {\n el.temporaryVariables =\n JsonSerialisation_1.JsonSerialisation.JObjectToDictionaryRuntimeObjs(temps);\n }\n else {\n el.temporaryVariables.clear();\n }\n this.callstack.push(el);\n }\n let prevContentObjPath = jThreadObj[\"previousContentObject\"];\n if (typeof prevContentObjPath !== \"undefined\") {\n let prevPath = new Path_1.Path(prevContentObjPath.toString());\n this.previousPointer = storyContext.PointerAtPath(prevPath);\n }\n }\n }\n Copy() {\n let copy = new Thread();\n copy.threadIndex = this.threadIndex;\n for (let e of this.callstack) {\n copy.callstack.push(e.Copy());\n }\n copy.previousPointer = this.previousPointer.copy();\n return copy;\n }\n WriteJson(writer) {\n writer.WriteObjectStart();\n writer.WritePropertyStart(\"callstack\");\n writer.WriteArrayStart();\n for (let el of this.callstack) {\n writer.WriteObjectStart();\n if (!el.currentPointer.isNull) {\n if (el.currentPointer.container === null) {\n return (0, NullException_1.throwNullException)(\"el.currentPointer.container\");\n }\n writer.WriteProperty(\"cPath\", el.currentPointer.container.path.componentsString);\n writer.WriteIntProperty(\"idx\", el.currentPointer.index);\n }\n writer.WriteProperty(\"exp\", el.inExpressionEvaluation);\n writer.WriteIntProperty(\"type\", el.type);\n if (el.temporaryVariables.size > 0) {\n writer.WritePropertyStart(\"temp\");\n JsonSerialisation_1.JsonSerialisation.WriteDictionaryRuntimeObjs(writer, el.temporaryVariables);\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n }\n writer.WriteArrayEnd();\n writer.WritePropertyEnd();\n writer.WriteIntProperty(\"threadIndex\", this.threadIndex);\n if (!this.previousPointer.isNull) {\n let resolvedPointer = this.previousPointer.Resolve();\n if (resolvedPointer === null) {\n return (0, NullException_1.throwNullException)(\"this.previousPointer.Resolve()\");\n }\n writer.WriteProperty(\"previousContentObject\", resolvedPointer.path.toString());\n }\n writer.WriteObjectEnd();\n }\n }\n CallStack.Thread = Thread;\n})(CallStack || (exports.CallStack = CallStack = {}));\n//# sourceMappingURL=CallStack.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.VariablesState = void 0;\nconst Value_1 = require(\"./Value\");\nconst StoryException_1 = require(\"./StoryException\");\nconst JsonSerialisation_1 = require(\"./JsonSerialisation\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst TryGetResult_1 = require(\"./TryGetResult\");\nconst NullException_1 = require(\"./NullException\");\n// Fake class wrapper around VariableState to have correct typing\n// when using the Proxy syntax in typescript\nfunction VariablesStateAccessor() {\n return class {\n };\n}\nclass VariablesState extends VariablesStateAccessor() {\n variableChangedEvent(variableName, newValue) {\n for (let callback of this.variableChangedEventCallbacks) {\n callback(variableName, newValue);\n }\n }\n StartVariableObservation() {\n this._batchObservingVariableChanges = true;\n this._changedVariablesForBatchObs = new Set();\n }\n CompleteVariableObservation() {\n this._batchObservingVariableChanges = false;\n let changedVars = new Map();\n if (this._changedVariablesForBatchObs != null) {\n for (let variableName of this._changedVariablesForBatchObs) {\n let currentValue = this._globalVariables.get(variableName);\n this.variableChangedEvent(variableName, currentValue);\n }\n }\n // Patch may still be active - e.g. if we were in the middle of a background save\n if (this.patch != null) {\n for (let variableName of this.patch.changedVariables) {\n let patchedVal = this.patch.TryGetGlobal(variableName, null);\n if (patchedVal.exists)\n changedVars.set(variableName, patchedVal);\n }\n }\n this._changedVariablesForBatchObs = null;\n return changedVars;\n }\n NotifyObservers(changedVars) {\n for (const [key, value] of changedVars) {\n this.variableChangedEvent(key, value);\n }\n }\n get callStack() {\n return this._callStack;\n }\n set callStack(callStack) {\n this._callStack = callStack;\n }\n $(variableName, value) {\n if (typeof value === \"undefined\") {\n let varContents = null;\n if (this.patch !== null) {\n varContents = this.patch.TryGetGlobal(variableName, null);\n if (varContents.exists)\n return varContents.result.valueObject;\n }\n varContents = this._globalVariables.get(variableName);\n if (typeof varContents === \"undefined\") {\n varContents = this._defaultGlobalVariables.get(variableName);\n }\n if (typeof varContents !== \"undefined\")\n return varContents.valueObject;\n else\n return null;\n }\n else {\n if (typeof this._defaultGlobalVariables.get(variableName) === \"undefined\")\n throw new StoryException_1.StoryException(\"Cannot assign to a variable (\" +\n variableName +\n \") that hasn't been declared in the story\");\n let val = Value_1.Value.Create(value);\n if (val == null) {\n if (value == null) {\n throw new Error(\"Cannot pass null to VariableState\");\n }\n else {\n throw new Error(\"Invalid value passed to VariableState: \" + value.toString());\n }\n }\n this.SetGlobal(variableName, val);\n }\n }\n constructor(callStack, listDefsOrigin) {\n super();\n // The way variableChangedEvent is a bit different than the reference implementation.\n // Originally it uses the C# += operator to add delegates, but in js we need to maintain\n // an actual collection of delegates (ie. callbacks) to register a new one, there is a\n // special ObserveVariableChange method below.\n this.variableChangedEventCallbacks = [];\n this.patch = null;\n this._defaultGlobalVariables = new Map();\n this._changedVariablesForBatchObs = new Set();\n this._batchObservingVariableChanges = false;\n this._globalVariables = new Map();\n this._callStack = callStack;\n this._listDefsOrigin = listDefsOrigin;\n // if es6 proxies are available, use them.\n try {\n // the proxy is used to allow direct manipulation of global variables.\n // It first tries to access the objects own property, and if none is\n // found it delegates the call to the $ method, defined below\n let p = new Proxy(this, {\n get(target, name) {\n return name in target ? target[name] : target.$(name);\n },\n set(target, name, value) {\n if (name in target)\n target[name] = value;\n else\n target.$(name, value);\n return true; // returning a falsy value make the trap fail\n },\n ownKeys(target) {\n return [\n ...new Set([\n ...target._defaultGlobalVariables.keys(),\n ...target._globalVariables.keys(),\n ]),\n ];\n },\n getOwnPropertyDescriptor(target, name) {\n // called for every property\n return {\n enumerable: true,\n configurable: true,\n value: target.$(name),\n };\n },\n });\n return p;\n }\n catch (e) {\n // the proxy object is not available in this context. we should warn the\n // dev but writing to the console feels a bit intrusive.\n // console.log(\"ES6 Proxy not available - direct manipulation of global variables can't work, use $() instead.\");\n }\n }\n ApplyPatch() {\n if (this.patch === null) {\n return (0, NullException_1.throwNullException)(\"this.patch\");\n }\n for (let [namedVarKey, namedVarValue] of this.patch.globals) {\n this._globalVariables.set(namedVarKey, namedVarValue);\n }\n if (this._changedVariablesForBatchObs !== null) {\n for (let name of this.patch.changedVariables) {\n this._changedVariablesForBatchObs.add(name);\n }\n }\n this.patch = null;\n }\n SetJsonToken(jToken) {\n this._globalVariables.clear();\n for (let [varValKey, varValValue] of this._defaultGlobalVariables) {\n let loadedToken = jToken[varValKey];\n if (typeof loadedToken !== \"undefined\") {\n let tokenInkObject = JsonSerialisation_1.JsonSerialisation.JTokenToRuntimeObject(loadedToken);\n if (tokenInkObject === null) {\n return (0, NullException_1.throwNullException)(\"tokenInkObject\");\n }\n this._globalVariables.set(varValKey, tokenInkObject);\n }\n else {\n this._globalVariables.set(varValKey, varValValue);\n }\n }\n }\n WriteJson(writer) {\n writer.WriteObjectStart();\n for (let [keyValKey, keyValValue] of this._globalVariables) {\n let name = keyValKey;\n let val = keyValValue;\n if (VariablesState.dontSaveDefaultValues) {\n if (this._defaultGlobalVariables.has(name)) {\n let defaultVal = this._defaultGlobalVariables.get(name);\n if (this.RuntimeObjectsEqual(val, defaultVal))\n continue;\n }\n }\n writer.WritePropertyStart(name);\n JsonSerialisation_1.JsonSerialisation.WriteRuntimeObject(writer, val);\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n }\n RuntimeObjectsEqual(obj1, obj2) {\n if (obj1 === null) {\n return (0, NullException_1.throwNullException)(\"obj1\");\n }\n if (obj2 === null) {\n return (0, NullException_1.throwNullException)(\"obj2\");\n }\n if (obj1.constructor !== obj2.constructor)\n return false;\n let boolVal = (0, TypeAssertion_1.asOrNull)(obj1, Value_1.BoolValue);\n if (boolVal !== null) {\n return boolVal.value === (0, TypeAssertion_1.asOrThrows)(obj2, Value_1.BoolValue).value;\n }\n let intVal = (0, TypeAssertion_1.asOrNull)(obj1, Value_1.IntValue);\n if (intVal !== null) {\n return intVal.value === (0, TypeAssertion_1.asOrThrows)(obj2, Value_1.IntValue).value;\n }\n let floatVal = (0, TypeAssertion_1.asOrNull)(obj1, Value_1.FloatValue);\n if (floatVal !== null) {\n return floatVal.value === (0, TypeAssertion_1.asOrThrows)(obj2, Value_1.FloatValue).value;\n }\n let val1 = (0, TypeAssertion_1.asOrNull)(obj1, Value_1.Value);\n let val2 = (0, TypeAssertion_1.asOrNull)(obj2, Value_1.Value);\n if (val1 !== null && val2 !== null) {\n if ((0, TypeAssertion_1.isEquatable)(val1.valueObject) && (0, TypeAssertion_1.isEquatable)(val2.valueObject)) {\n return val1.valueObject.Equals(val2.valueObject);\n }\n else {\n return val1.valueObject === val2.valueObject;\n }\n }\n throw new Error(\"FastRoughDefinitelyEquals: Unsupported runtime object type: \" +\n obj1.constructor.name);\n }\n GetVariableWithName(name, contextIndex = -1) {\n let varValue = this.GetRawVariableWithName(name, contextIndex);\n // var varPointer = varValue as VariablePointerValue;\n let varPointer = (0, TypeAssertion_1.asOrNull)(varValue, Value_1.VariablePointerValue);\n if (varPointer !== null) {\n varValue = this.ValueAtVariablePointer(varPointer);\n }\n return varValue;\n }\n TryGetDefaultVariableValue(name) {\n let val = (0, TryGetResult_1.tryGetValueFromMap)(this._defaultGlobalVariables, name, null);\n return val.exists ? val.result : null;\n }\n GlobalVariableExistsWithName(name) {\n return (this._globalVariables.has(name) ||\n (this._defaultGlobalVariables !== null &&\n this._defaultGlobalVariables.has(name)));\n }\n GetRawVariableWithName(name, contextIndex) {\n let varValue = null;\n if (contextIndex == 0 || contextIndex == -1) {\n let variableValue = null;\n if (this.patch !== null) {\n variableValue = this.patch.TryGetGlobal(name, null);\n if (variableValue.exists)\n return variableValue.result;\n }\n // this is a conditional assignment\n variableValue = (0, TryGetResult_1.tryGetValueFromMap)(this._globalVariables, name, null);\n if (variableValue.exists)\n return variableValue.result;\n if (this._defaultGlobalVariables !== null) {\n variableValue = (0, TryGetResult_1.tryGetValueFromMap)(this._defaultGlobalVariables, name, null);\n if (variableValue.exists)\n return variableValue.result;\n }\n if (this._listDefsOrigin === null)\n return (0, NullException_1.throwNullException)(\"VariablesState._listDefsOrigin\");\n let listItemValue = this._listDefsOrigin.FindSingleItemListWithName(name);\n if (listItemValue)\n return listItemValue;\n }\n varValue = this._callStack.GetTemporaryVariableWithName(name, contextIndex);\n return varValue;\n }\n ValueAtVariablePointer(pointer) {\n return this.GetVariableWithName(pointer.variableName, pointer.contextIndex);\n }\n Assign(varAss, value) {\n let name = varAss.variableName;\n if (name === null) {\n return (0, NullException_1.throwNullException)(\"name\");\n }\n let contextIndex = -1;\n let setGlobal = false;\n if (varAss.isNewDeclaration) {\n setGlobal = varAss.isGlobal;\n }\n else {\n setGlobal = this.GlobalVariableExistsWithName(name);\n }\n if (varAss.isNewDeclaration) {\n // var varPointer = value as VariablePointerValue;\n let varPointer = (0, TypeAssertion_1.asOrNull)(value, Value_1.VariablePointerValue);\n if (varPointer !== null) {\n let fullyResolvedVariablePointer = this.ResolveVariablePointer(varPointer);\n value = fullyResolvedVariablePointer;\n }\n }\n else {\n let existingPointer = null;\n do {\n // existingPointer = GetRawVariableWithName (name, contextIndex) as VariablePointerValue;\n existingPointer = (0, TypeAssertion_1.asOrNull)(this.GetRawVariableWithName(name, contextIndex), Value_1.VariablePointerValue);\n if (existingPointer != null) {\n name = existingPointer.variableName;\n contextIndex = existingPointer.contextIndex;\n setGlobal = contextIndex == 0;\n }\n } while (existingPointer != null);\n }\n if (setGlobal) {\n this.SetGlobal(name, value);\n }\n else {\n this._callStack.SetTemporaryVariable(name, value, varAss.isNewDeclaration, contextIndex);\n }\n }\n SnapshotDefaultGlobals() {\n this._defaultGlobalVariables = new Map(this._globalVariables);\n }\n RetainListOriginsForAssignment(oldValue, newValue) {\n let oldList = (0, TypeAssertion_1.asOrThrows)(oldValue, Value_1.ListValue);\n let newList = (0, TypeAssertion_1.asOrThrows)(newValue, Value_1.ListValue);\n if (oldList.value && newList.value && newList.value.Count == 0) {\n newList.value.SetInitialOriginNames(oldList.value.originNames);\n }\n }\n SetGlobal(variableName, value) {\n let oldValue = null;\n if (this.patch === null) {\n oldValue = (0, TryGetResult_1.tryGetValueFromMap)(this._globalVariables, variableName, null);\n }\n if (this.patch !== null) {\n oldValue = this.patch.TryGetGlobal(variableName, null);\n if (!oldValue.exists) {\n oldValue = (0, TryGetResult_1.tryGetValueFromMap)(this._globalVariables, variableName, null);\n }\n }\n Value_1.ListValue.RetainListOriginsForAssignment(oldValue.result, value);\n if (variableName === null) {\n return (0, NullException_1.throwNullException)(\"variableName\");\n }\n if (this.patch !== null) {\n this.patch.SetGlobal(variableName, value);\n }\n else {\n this._globalVariables.set(variableName, value);\n }\n // TODO: Not sure !== is equivalent to !value.Equals(oldValue)\n if (this.variableChangedEvent !== null &&\n oldValue !== null &&\n value !== oldValue.result) {\n if (this._batchObservingVariableChanges) {\n if (this._changedVariablesForBatchObs === null) {\n return (0, NullException_1.throwNullException)(\"this._changedVariablesForBatchObs\");\n }\n if (this.patch !== null) {\n this.patch.AddChangedVariable(variableName);\n }\n else if (this._changedVariablesForBatchObs !== null) {\n this._changedVariablesForBatchObs.add(variableName);\n }\n }\n else {\n this.variableChangedEvent(variableName, value);\n }\n }\n }\n ResolveVariablePointer(varPointer) {\n let contextIndex = varPointer.contextIndex;\n if (contextIndex == -1)\n contextIndex = this.GetContextIndexOfVariableNamed(varPointer.variableName);\n let valueOfVariablePointedTo = this.GetRawVariableWithName(varPointer.variableName, contextIndex);\n // var doubleRedirectionPointer = valueOfVariablePointedTo as VariablePointerValue;\n let doubleRedirectionPointer = (0, TypeAssertion_1.asOrNull)(valueOfVariablePointedTo, Value_1.VariablePointerValue);\n if (doubleRedirectionPointer != null) {\n return doubleRedirectionPointer;\n }\n else {\n return new Value_1.VariablePointerValue(varPointer.variableName, contextIndex);\n }\n }\n GetContextIndexOfVariableNamed(varName) {\n if (this.GlobalVariableExistsWithName(varName))\n return 0;\n return this._callStack.currentElementIndex;\n }\n /**\n * This function is specific to the js version of ink. It allows to register a\n * callback that will be called when a variable changes. The original code uses\n * `state.variableChangedEvent += callback` instead.\n *\n * @param {function} callback\n */\n ObserveVariableChange(callback) {\n this.variableChangedEventCallbacks.push(callback);\n }\n}\nexports.VariablesState = VariablesState;\nVariablesState.dontSaveDefaultValues = true;\n//# sourceMappingURL=VariablesState.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PRNG = void 0;\n// Taken from https://gist.github.com/blixt/f17b47c62508be59987b\n// Ink uses a seedable PRNG of which there is none in native javascript.\nclass PRNG {\n constructor(seed) {\n this.seed = seed % 2147483647;\n if (this.seed <= 0)\n this.seed += 2147483646;\n }\n next() {\n return (this.seed = (this.seed * 48271) % 2147483647);\n }\n nextFloat() {\n return (this.next() - 1) / 2147483646;\n }\n}\nexports.PRNG = PRNG;\n//# sourceMappingURL=PRNG.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StatePatch = void 0;\nclass StatePatch {\n get globals() {\n return this._globals;\n }\n get changedVariables() {\n return this._changedVariables;\n }\n get visitCounts() {\n return this._visitCounts;\n }\n get turnIndices() {\n return this._turnIndices;\n }\n constructor() {\n this._changedVariables = new Set();\n this._visitCounts = new Map();\n this._turnIndices = new Map();\n if (arguments.length === 1 && arguments[0] !== null) {\n let toCopy = arguments[0];\n this._globals = new Map(toCopy._globals);\n this._changedVariables = new Set(toCopy._changedVariables);\n this._visitCounts = new Map(toCopy._visitCounts);\n this._turnIndices = new Map(toCopy._turnIndices);\n }\n else {\n this._globals = new Map();\n this._changedVariables = new Set();\n this._visitCounts = new Map();\n this._turnIndices = new Map();\n }\n }\n TryGetGlobal(name, /* out */ value) {\n if (name !== null && this._globals.has(name)) {\n return { result: this._globals.get(name), exists: true };\n }\n return { result: value, exists: false };\n }\n SetGlobal(name, value) {\n this._globals.set(name, value);\n }\n AddChangedVariable(name) {\n return this._changedVariables.add(name);\n }\n TryGetVisitCount(container, /* out */ count) {\n if (this._visitCounts.has(container)) {\n return { result: this._visitCounts.get(container), exists: true };\n }\n return { result: count, exists: false };\n }\n SetVisitCount(container, count) {\n this._visitCounts.set(container, count);\n }\n SetTurnIndex(container, index) {\n this._turnIndices.set(container, index);\n }\n TryGetTurnIndex(container, /* out */ index) {\n if (this._turnIndices.has(container)) {\n return { result: this._turnIndices.get(container), exists: true };\n }\n return { result: index, exists: false };\n }\n}\nexports.StatePatch = StatePatch;\n//# sourceMappingURL=StatePatch.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SimpleJson = void 0;\nclass SimpleJson {\n static TextToDictionary(text) {\n return new SimpleJson.Reader(text).ToDictionary();\n }\n static TextToArray(text) {\n return new SimpleJson.Reader(text).ToArray();\n }\n}\nexports.SimpleJson = SimpleJson;\n(function (SimpleJson) {\n class Reader {\n constructor(text) {\n // Before parsing the JSON, all floats of the form \"123.0\" are transformed into \"123.0f\"\n // so that they are recognized as FLOAT in the ink runtime\n const nativeFloatParsing = JSON.parse(\"0\", \n // @ts-expect-error : typing\n (_, __, context) => context != null);\n if (!nativeFloatParsing) {\n // When the nativeFloatParsing argument is false,\n // we aggressively replace using a regexp\n // At time of writing : only happen for Safari iOS and Mac\n const jsonWithExplicitFloat = text.replace(/(,\\s*)([0-9]+\\.[0]+)([,]*)/g, '$1\"$2f\"$3');\n this._rootObject = JSON.parse(jsonWithExplicitFloat);\n }\n else {\n // @ts-expect-error : typing\n const explicitFloatReviver = (_, value, context) => {\n // When the nativeFloatParsing argument is true,\n // we use a custom reviver function\n //see https://github.com/y-lohse/inkjs/pull/1100#issuecomment-2733148441\n if (Number.isInteger(value) && context.source.endsWith(\".0\")) {\n return context.source + \"f\";\n }\n return value;\n };\n // @ts-expect-error : typing\n this._rootObject = JSON.parse(text, explicitFloatReviver);\n }\n }\n ToDictionary() {\n return this._rootObject;\n }\n ToArray() {\n return this._rootObject;\n }\n }\n SimpleJson.Reader = Reader;\n // In C#, this class writes json tokens directly to a StringWriter or\n // another stream. Here, a temporary hierarchy is created in the form\n // of a javascript object, which is serialised in the `toString` method.\n // See individual methods and properties for more information.\n class Writer {\n constructor() {\n // In addition to `_stateStack` present in the original code,\n // this implementation of SimpleJson use two other stacks and two\n // temporary variables holding the current context.\n // Used to keep track of the current property name being built\n // with `WritePropertyNameStart`, `WritePropertyNameInner` and\n // `WritePropertyNameEnd`.\n this._currentPropertyName = null;\n // Used to keep track of the current string value being built\n // with `WriteStringStart`, `WriteStringInner` and\n // `WriteStringEnd`.\n this._currentString = null;\n this._stateStack = [];\n // Keep track of the current collection being built (either an array\n // or an object). For instance, at the '?' step during the hiarchy\n // creation, this hierarchy:\n // [3, {a: [b, ?]}] will have this corresponding stack:\n // (bottom) [Array, Object, Array] (top)\n this._collectionStack = [];\n // Keep track of the current property being assigned. For instance, at\n // the '?' step during the hiarchy creation, this hierarchy:\n // [3, {a: [b, {c: ?}]}] will have this corresponding stack:\n // (bottom) [a, c] (top)\n this._propertyNameStack = [];\n // Object containing the entire hiearchy.\n this._jsonObject = null;\n }\n WriteObject(inner) {\n this.WriteObjectStart();\n inner(this);\n this.WriteObjectEnd();\n }\n // Add a new object.\n WriteObjectStart() {\n this.StartNewObject(true);\n let newObject = {};\n if (this.state === SimpleJson.Writer.State.Property) {\n // This object is created as the value of a property,\n // inside an other object.\n this.Assert(this.currentCollection !== null);\n this.Assert(this.currentPropertyName !== null);\n let propertyName = this._propertyNameStack.pop();\n this.currentCollection[propertyName] = newObject;\n this._collectionStack.push(newObject);\n }\n else if (this.state === SimpleJson.Writer.State.Array) {\n // This object is created as the child of an array.\n this.Assert(this.currentCollection !== null);\n this.currentCollection.push(newObject);\n this._collectionStack.push(newObject);\n }\n else {\n // This object is the root object.\n this.Assert(this.state === SimpleJson.Writer.State.None);\n this._jsonObject = newObject;\n this._collectionStack.push(newObject);\n }\n this._stateStack.push(new SimpleJson.Writer.StateElement(SimpleJson.Writer.State.Object));\n }\n WriteObjectEnd() {\n this.Assert(this.state === SimpleJson.Writer.State.Object);\n this._collectionStack.pop();\n this._stateStack.pop();\n }\n // Write a property name / value pair to the current object.\n WriteProperty(name, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n innerOrContent) {\n this.WritePropertyStart(name);\n if (arguments[1] instanceof Function) {\n let inner = arguments[1];\n inner(this);\n }\n else {\n let content = arguments[1];\n this.Write(content);\n }\n this.WritePropertyEnd();\n }\n // Int and Float are separate calls, since there both are\n // numbers in JavaScript, but need to be handled differently.\n WriteIntProperty(name, content) {\n this.WritePropertyStart(name);\n this.WriteInt(content);\n this.WritePropertyEnd();\n }\n WriteFloatProperty(name, content) {\n this.WritePropertyStart(name);\n this.WriteFloat(content);\n this.WritePropertyEnd();\n }\n // Prepare a new property name, which will be use to add the\n // new object when calling _addToCurrentObject() from a Write\n // method.\n WritePropertyStart(name) {\n this.Assert(this.state === SimpleJson.Writer.State.Object);\n this._propertyNameStack.push(name);\n this.IncrementChildCount();\n this._stateStack.push(new SimpleJson.Writer.StateElement(SimpleJson.Writer.State.Property));\n }\n WritePropertyEnd() {\n this.Assert(this.state === SimpleJson.Writer.State.Property);\n this.Assert(this.childCount === 1);\n this._stateStack.pop();\n }\n // Prepare a new property name, except this time, the property name\n // will be created by concatenating all the strings passed to\n // WritePropertyNameInner.\n WritePropertyNameStart() {\n this.Assert(this.state === SimpleJson.Writer.State.Object);\n this.IncrementChildCount();\n this._currentPropertyName = \"\";\n this._stateStack.push(new SimpleJson.Writer.StateElement(SimpleJson.Writer.State.Property));\n this._stateStack.push(new SimpleJson.Writer.StateElement(SimpleJson.Writer.State.PropertyName));\n }\n WritePropertyNameEnd() {\n this.Assert(this.state === SimpleJson.Writer.State.PropertyName);\n this.Assert(this._currentPropertyName !== null);\n this._propertyNameStack.push(this._currentPropertyName);\n this._currentPropertyName = null;\n this._stateStack.pop();\n }\n WritePropertyNameInner(str) {\n this.Assert(this.state === SimpleJson.Writer.State.PropertyName);\n this.Assert(this._currentPropertyName !== null);\n this._currentPropertyName += str;\n }\n // Add a new array.\n WriteArrayStart() {\n this.StartNewObject(true);\n let newObject = [];\n if (this.state === SimpleJson.Writer.State.Property) {\n // This array is created as the value of a property,\n // inside an object.\n this.Assert(this.currentCollection !== null);\n this.Assert(this.currentPropertyName !== null);\n let propertyName = this._propertyNameStack.pop();\n this.currentCollection[propertyName] = newObject;\n this._collectionStack.push(newObject);\n }\n else if (this.state === SimpleJson.Writer.State.Array) {\n // This array is created as the child of another array.\n this.Assert(this.currentCollection !== null);\n this.currentCollection.push(newObject);\n this._collectionStack.push(newObject);\n }\n else {\n // This array is the root object.\n this.Assert(this.state === SimpleJson.Writer.State.None);\n this._jsonObject = newObject;\n this._collectionStack.push(newObject);\n }\n this._stateStack.push(new SimpleJson.Writer.StateElement(SimpleJson.Writer.State.Array));\n }\n WriteArrayEnd() {\n this.Assert(this.state === SimpleJson.Writer.State.Array);\n this._collectionStack.pop();\n this._stateStack.pop();\n }\n // Add the value to the appropriate collection (array / object), given the current\n // context.\n Write(value, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n escape = true) {\n if (value === null) {\n console.error(\"Warning: trying to write a null value\");\n return;\n }\n this.StartNewObject(false);\n this._addToCurrentObject(value);\n }\n WriteBool(value) {\n if (value === null) {\n return;\n }\n this.StartNewObject(false);\n this._addToCurrentObject(value);\n }\n WriteInt(value) {\n if (value === null) {\n return;\n }\n this.StartNewObject(false);\n // Math.floor is used as a precaution:\n // 1. to ensure that the value is written as an integer\n // (without a fractional part -> 1 instead of 1.0), even\n // though it should be the default behaviour of\n // JSON.serialize;\n // 2. to ensure that if a floating number is passed\n // accidentally, it's converted to an integer.\n //\n // This guarantees savegame compatibility with the reference\n // implementation.\n this._addToCurrentObject(Math.floor(value));\n }\n // Since JSON doesn't support NaN and Infinity, these values\n // are converted here.\n WriteFloat(value) {\n if (value === null) {\n return;\n }\n this.StartNewObject(false);\n if (value == Number.POSITIVE_INFINITY) {\n this._addToCurrentObject(3.4e38);\n }\n else if (value == Number.NEGATIVE_INFINITY) {\n this._addToCurrentObject(-3.4e38);\n }\n else if (isNaN(value)) {\n this._addToCurrentObject(0.0);\n }\n else {\n this._addToCurrentObject(value);\n }\n }\n WriteNull() {\n this.StartNewObject(false);\n this._addToCurrentObject(null);\n }\n // Prepare a string before adding it to the current collection in\n // WriteStringEnd(). The string will be a concatenation of all the\n // strings passed to WriteStringInner.\n WriteStringStart() {\n this.StartNewObject(false);\n this._currentString = \"\";\n this._stateStack.push(new SimpleJson.Writer.StateElement(SimpleJson.Writer.State.String));\n }\n WriteStringEnd() {\n this.Assert(this.state == SimpleJson.Writer.State.String);\n this._stateStack.pop();\n this._addToCurrentObject(this._currentString);\n this._currentString = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n WriteStringInner(str, escape = true) {\n this.Assert(this.state === SimpleJson.Writer.State.String);\n if (str === null) {\n console.error(\"Warning: trying to write a null string\");\n return;\n }\n this._currentString += str;\n }\n // Serialise the root object into a JSON string.\n toString() {\n if (this._jsonObject === null) {\n return \"\";\n }\n return JSON.stringify(this._jsonObject);\n }\n // Prepare the state stack when adding new objects / values.\n StartNewObject(container) {\n if (container) {\n this.Assert(this.state === SimpleJson.Writer.State.None ||\n this.state === SimpleJson.Writer.State.Property ||\n this.state === SimpleJson.Writer.State.Array);\n }\n else {\n this.Assert(this.state === SimpleJson.Writer.State.Property ||\n this.state === SimpleJson.Writer.State.Array);\n }\n if (this.state === SimpleJson.Writer.State.Property) {\n this.Assert(this.childCount === 0);\n }\n if (this.state === SimpleJson.Writer.State.Array ||\n this.state === SimpleJson.Writer.State.Property) {\n this.IncrementChildCount();\n }\n }\n // These getters peek all the different stacks.\n get state() {\n if (this._stateStack.length > 0) {\n return this._stateStack[this._stateStack.length - 1].type;\n }\n else {\n return SimpleJson.Writer.State.None;\n }\n }\n get childCount() {\n if (this._stateStack.length > 0) {\n return this._stateStack[this._stateStack.length - 1].childCount;\n }\n else {\n return 0;\n }\n }\n get currentCollection() {\n if (this._collectionStack.length > 0) {\n return this._collectionStack[this._collectionStack.length - 1];\n }\n else {\n return null;\n }\n }\n get currentPropertyName() {\n if (this._propertyNameStack.length > 0) {\n return this._propertyNameStack[this._propertyNameStack.length - 1];\n }\n else {\n return null;\n }\n }\n IncrementChildCount() {\n this.Assert(this._stateStack.length > 0);\n let currEl = this._stateStack.pop();\n currEl.childCount++;\n this._stateStack.push(currEl);\n }\n Assert(condition) {\n if (!condition)\n throw Error(\"Assert failed while writing JSON\");\n }\n // This method did not exist in the original C# code. It adds\n // the given value to the current collection (used by Write methods).\n _addToCurrentObject(value) {\n this.Assert(this.currentCollection !== null);\n if (this.state === SimpleJson.Writer.State.Array) {\n this.Assert(Array.isArray(this.currentCollection));\n this.currentCollection.push(value);\n }\n else if (this.state === SimpleJson.Writer.State.Property) {\n this.Assert(!Array.isArray(this.currentCollection));\n this.Assert(this.currentPropertyName !== null);\n this.currentCollection[this.currentPropertyName] = value;\n this._propertyNameStack.pop();\n }\n }\n }\n SimpleJson.Writer = Writer;\n (function (Writer) {\n let State;\n (function (State) {\n State[State[\"None\"] = 0] = \"None\";\n State[State[\"Object\"] = 1] = \"Object\";\n State[State[\"Array\"] = 2] = \"Array\";\n State[State[\"Property\"] = 3] = \"Property\";\n State[State[\"PropertyName\"] = 4] = \"PropertyName\";\n State[State[\"String\"] = 5] = \"String\";\n })(State = Writer.State || (Writer.State = {}));\n class StateElement {\n constructor(type) {\n this.type = SimpleJson.Writer.State.None;\n this.childCount = 0;\n this.type = type;\n }\n }\n Writer.StateElement = StateElement;\n })(Writer = SimpleJson.Writer || (SimpleJson.Writer = {}));\n})(SimpleJson || (exports.SimpleJson = SimpleJson = {}));\n//# sourceMappingURL=SimpleJson.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Flow = void 0;\nconst CallStack_1 = require(\"./CallStack\");\nconst JsonSerialisation_1 = require(\"./JsonSerialisation\");\nconst NullException_1 = require(\"./NullException\");\nclass Flow {\n constructor() {\n let name = arguments[0];\n let story = arguments[1];\n this.name = name;\n this.callStack = new CallStack_1.CallStack(story);\n if (arguments[2]) {\n let jObject = arguments[2];\n this.callStack.SetJsonToken(jObject[\"callstack\"], story);\n this.outputStream = JsonSerialisation_1.JsonSerialisation.JArrayToRuntimeObjList(jObject[\"outputStream\"]);\n this.currentChoices = JsonSerialisation_1.JsonSerialisation.JArrayToRuntimeObjList(jObject[\"currentChoices\"]);\n let jChoiceThreadsObj = jObject[\"choiceThreads\"];\n if (typeof jChoiceThreadsObj !== \"undefined\") {\n this.LoadFlowChoiceThreads(jChoiceThreadsObj, story);\n }\n }\n else {\n this.outputStream = [];\n this.currentChoices = [];\n }\n }\n WriteJson(writer) {\n writer.WriteObjectStart();\n writer.WriteProperty(\"callstack\", (w) => this.callStack.WriteJson(w));\n writer.WriteProperty(\"outputStream\", (w) => JsonSerialisation_1.JsonSerialisation.WriteListRuntimeObjs(w, this.outputStream));\n let hasChoiceThreads = false;\n for (let c of this.currentChoices) {\n if (c.threadAtGeneration === null)\n return (0, NullException_1.throwNullException)(\"c.threadAtGeneration\");\n c.originalThreadIndex = c.threadAtGeneration.threadIndex;\n if (this.callStack.ThreadWithIndex(c.originalThreadIndex) === null) {\n if (!hasChoiceThreads) {\n hasChoiceThreads = true;\n writer.WritePropertyStart(\"choiceThreads\");\n writer.WriteObjectStart();\n }\n writer.WritePropertyStart(c.originalThreadIndex);\n c.threadAtGeneration.WriteJson(writer);\n writer.WritePropertyEnd();\n }\n }\n if (hasChoiceThreads) {\n writer.WriteObjectEnd();\n writer.WritePropertyEnd();\n }\n writer.WriteProperty(\"currentChoices\", (w) => {\n w.WriteArrayStart();\n for (let c of this.currentChoices) {\n JsonSerialisation_1.JsonSerialisation.WriteChoice(w, c);\n }\n w.WriteArrayEnd();\n });\n writer.WriteObjectEnd();\n }\n LoadFlowChoiceThreads(jChoiceThreads, story) {\n for (let choice of this.currentChoices) {\n let foundActiveThread = this.callStack.ThreadWithIndex(choice.originalThreadIndex);\n if (foundActiveThread !== null) {\n choice.threadAtGeneration = foundActiveThread.Copy();\n }\n else {\n let jSavedChoiceThread = jChoiceThreads[`${choice.originalThreadIndex}`];\n choice.threadAtGeneration = new CallStack_1.CallStack.Thread(jSavedChoiceThread, story);\n }\n }\n }\n}\nexports.Flow = Flow;\n//# sourceMappingURL=Flow.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StoryState = void 0;\nconst CallStack_1 = require(\"./CallStack\");\nconst VariablesState_1 = require(\"./VariablesState\");\nconst Value_1 = require(\"./Value\");\nconst PushPop_1 = require(\"./PushPop\");\nconst Tag_1 = require(\"./Tag\");\nconst Glue_1 = require(\"./Glue\");\nconst Path_1 = require(\"./Path\");\nconst ControlCommand_1 = require(\"./ControlCommand\");\nconst StringBuilder_1 = require(\"./StringBuilder\");\nconst JsonSerialisation_1 = require(\"./JsonSerialisation\");\nconst PRNG_1 = require(\"./PRNG\");\nconst Void_1 = require(\"./Void\");\nconst Pointer_1 = require(\"./Pointer\");\nconst TryGetResult_1 = require(\"./TryGetResult\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst Debug_1 = require(\"./Debug\");\nconst NullException_1 = require(\"./NullException\");\nconst Story_1 = require(\"./Story\");\nconst StatePatch_1 = require(\"./StatePatch\");\nconst SimpleJson_1 = require(\"./SimpleJson\");\nconst Flow_1 = require(\"./Flow\");\nconst InkList_1 = require(\"./InkList\");\nclass StoryState {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ToJson(indented = false) {\n let writer = new SimpleJson_1.SimpleJson.Writer();\n this.WriteJson(writer);\n return writer.toString();\n }\n toJson(indented = false) {\n return this.ToJson(indented);\n }\n LoadJson(json) {\n let jObject = SimpleJson_1.SimpleJson.TextToDictionary(json);\n this.LoadJsonObj(jObject);\n if (this.onDidLoadState !== null)\n this.onDidLoadState();\n }\n VisitCountAtPathString(pathString) {\n let visitCountOut;\n if (this._patch !== null) {\n let container = this.story.ContentAtPath(new Path_1.Path(pathString)).container;\n if (container === null)\n throw new Error(\"Content at path not found: \" + pathString);\n visitCountOut = this._patch.TryGetVisitCount(container, 0);\n if (visitCountOut.exists)\n return visitCountOut.result;\n }\n visitCountOut = (0, TryGetResult_1.tryGetValueFromMap)(this._visitCounts, pathString, null);\n if (visitCountOut.exists)\n return visitCountOut.result;\n return 0;\n }\n VisitCountForContainer(container) {\n if (container === null) {\n return (0, NullException_1.throwNullException)(\"container\");\n }\n if (!container.visitsShouldBeCounted) {\n this.story.Error(\"Read count for target (\" +\n container.name +\n \" - on \" +\n container.debugMetadata +\n \") unknown. The story may need to be compiled with countAllVisits flag (-c).\");\n return 0;\n }\n if (this._patch !== null) {\n let count = this._patch.TryGetVisitCount(container, 0);\n if (count.exists) {\n return count.result;\n }\n }\n let containerPathStr = container.path.toString();\n let count2 = (0, TryGetResult_1.tryGetValueFromMap)(this._visitCounts, containerPathStr, null);\n if (count2.exists) {\n return count2.result;\n }\n return 0;\n }\n IncrementVisitCountForContainer(container) {\n if (this._patch !== null) {\n let currCount = this.VisitCountForContainer(container);\n currCount++;\n this._patch.SetVisitCount(container, currCount);\n return;\n }\n let containerPathStr = container.path.toString();\n let count = (0, TryGetResult_1.tryGetValueFromMap)(this._visitCounts, containerPathStr, null);\n if (count.exists) {\n this._visitCounts.set(containerPathStr, count.result + 1);\n }\n else {\n this._visitCounts.set(containerPathStr, 1);\n }\n }\n RecordTurnIndexVisitToContainer(container) {\n if (this._patch !== null) {\n this._patch.SetTurnIndex(container, this.currentTurnIndex);\n return;\n }\n let containerPathStr = container.path.toString();\n this._turnIndices.set(containerPathStr, this.currentTurnIndex);\n }\n TurnsSinceForContainer(container) {\n if (!container.turnIndexShouldBeCounted) {\n this.story.Error(\"TURNS_SINCE() for target (\" +\n container.name +\n \" - on \" +\n container.debugMetadata +\n \") unknown. The story may need to be compiled with countAllVisits flag (-c).\");\n }\n if (this._patch !== null) {\n let index = this._patch.TryGetTurnIndex(container, 0);\n if (index.exists) {\n return this.currentTurnIndex - index.result;\n }\n }\n let containerPathStr = container.path.toString();\n let index2 = (0, TryGetResult_1.tryGetValueFromMap)(this._turnIndices, containerPathStr, 0);\n if (index2.exists) {\n return this.currentTurnIndex - index2.result;\n }\n else {\n return -1;\n }\n }\n get callstackDepth() {\n return this.callStack.depth;\n }\n get outputStream() {\n return this._currentFlow.outputStream;\n }\n get currentChoices() {\n // If we can continue generating text content rather than choices,\n // then we reflect the choice list as being empty, since choices\n // should always come at the end.\n if (this.canContinue)\n return [];\n return this._currentFlow.currentChoices;\n }\n get generatedChoices() {\n return this._currentFlow.currentChoices;\n }\n get currentErrors() {\n return this._currentErrors;\n }\n get currentWarnings() {\n return this._currentWarnings;\n }\n get variablesState() {\n return this._variablesState;\n }\n set variablesState(value) {\n this._variablesState = value;\n }\n get callStack() {\n return this._currentFlow.callStack;\n }\n get evaluationStack() {\n return this._evaluationStack;\n }\n get currentTurnIndex() {\n return this._currentTurnIndex;\n }\n set currentTurnIndex(value) {\n this._currentTurnIndex = value;\n }\n get currentPathString() {\n let pointer = this.currentPointer;\n if (pointer.isNull) {\n return null;\n }\n else {\n if (pointer.path === null) {\n return (0, NullException_1.throwNullException)(\"pointer.path\");\n }\n return pointer.path.toString();\n }\n }\n get previousPathString() {\n let pointer = this.previousPointer;\n if (pointer.isNull) {\n return null;\n }\n else {\n if (pointer.path === null) {\n return (0, NullException_1.throwNullException)(\"previousPointer.path\");\n }\n return pointer.path.toString();\n }\n }\n get currentPointer() {\n return this.callStack.currentElement.currentPointer.copy();\n }\n set currentPointer(value) {\n this.callStack.currentElement.currentPointer = value.copy();\n }\n get previousPointer() {\n return this.callStack.currentThread.previousPointer.copy();\n }\n set previousPointer(value) {\n this.callStack.currentThread.previousPointer = value.copy();\n }\n get canContinue() {\n return !this.currentPointer.isNull && !this.hasError;\n }\n get hasError() {\n return this.currentErrors != null && this.currentErrors.length > 0;\n }\n get hasWarning() {\n return this.currentWarnings != null && this.currentWarnings.length > 0;\n }\n get currentText() {\n if (this._outputStreamTextDirty) {\n let sb = new StringBuilder_1.StringBuilder();\n let inTag = false;\n for (let outputObj of this.outputStream) {\n // var textContent = outputObj as StringValue;\n let textContent = (0, TypeAssertion_1.asOrNull)(outputObj, Value_1.StringValue);\n if (!inTag && textContent !== null) {\n sb.Append(textContent.value);\n }\n else {\n let controlCommand = (0, TypeAssertion_1.asOrNull)(outputObj, ControlCommand_1.ControlCommand);\n if (controlCommand !== null) {\n if (controlCommand.commandType == ControlCommand_1.ControlCommand.CommandType.BeginTag) {\n inTag = true;\n }\n else if (controlCommand.commandType == ControlCommand_1.ControlCommand.CommandType.EndTag) {\n inTag = false;\n }\n }\n }\n }\n this._currentText = this.CleanOutputWhitespace(sb.toString());\n this._outputStreamTextDirty = false;\n }\n return this._currentText;\n }\n CleanOutputWhitespace(str) {\n let sb = new StringBuilder_1.StringBuilder();\n let currentWhitespaceStart = -1;\n let startOfLine = 0;\n for (let i = 0; i < str.length; i++) {\n let c = str.charAt(i);\n let isInlineWhitespace = c == \" \" || c == \"\\t\";\n if (isInlineWhitespace && currentWhitespaceStart == -1)\n currentWhitespaceStart = i;\n if (!isInlineWhitespace) {\n if (c != \"\\n\" &&\n currentWhitespaceStart > 0 &&\n currentWhitespaceStart != startOfLine) {\n sb.Append(\" \");\n }\n currentWhitespaceStart = -1;\n }\n if (c == \"\\n\")\n startOfLine = i + 1;\n if (!isInlineWhitespace)\n sb.Append(c);\n }\n return sb.toString();\n }\n get currentTags() {\n if (this._outputStreamTagsDirty) {\n this._currentTags = [];\n let inTag = false;\n let sb = new StringBuilder_1.StringBuilder();\n for (let outputObj of this.outputStream) {\n let controlCommand = (0, TypeAssertion_1.asOrNull)(outputObj, ControlCommand_1.ControlCommand);\n if (controlCommand != null) {\n if (controlCommand.commandType == ControlCommand_1.ControlCommand.CommandType.BeginTag) {\n if (inTag && sb.Length > 0) {\n let txt = this.CleanOutputWhitespace(sb.toString());\n this._currentTags.push(txt);\n sb.Clear();\n }\n inTag = true;\n }\n else if (controlCommand.commandType == ControlCommand_1.ControlCommand.CommandType.EndTag) {\n if (sb.Length > 0) {\n let txt = this.CleanOutputWhitespace(sb.toString());\n this._currentTags.push(txt);\n sb.Clear();\n }\n inTag = false;\n }\n }\n else if (inTag) {\n let strVal = (0, TypeAssertion_1.asOrNull)(outputObj, Value_1.StringValue);\n if (strVal !== null) {\n sb.Append(strVal.value);\n }\n }\n else {\n let tag = (0, TypeAssertion_1.asOrNull)(outputObj, Tag_1.Tag);\n if (tag != null && tag.text != null && tag.text.length > 0) {\n this._currentTags.push(tag.text); // tag.text has whitespae already cleaned\n }\n }\n }\n if (sb.Length > 0) {\n let txt = this.CleanOutputWhitespace(sb.toString());\n this._currentTags.push(txt);\n sb.Clear();\n }\n this._outputStreamTagsDirty = false;\n }\n return this._currentTags;\n }\n get currentFlowName() {\n return this._currentFlow.name;\n }\n get currentFlowIsDefaultFlow() {\n return this._currentFlow.name == this.kDefaultFlowName;\n }\n get aliveFlowNames() {\n if (this._aliveFlowNamesDirty) {\n this._aliveFlowNames = [];\n if (this._namedFlows != null) {\n for (let flowName of this._namedFlows.keys()) {\n if (flowName != this.kDefaultFlowName) {\n this._aliveFlowNames.push(flowName);\n }\n }\n }\n this._aliveFlowNamesDirty = false;\n }\n return this._aliveFlowNames;\n }\n get inExpressionEvaluation() {\n return this.callStack.currentElement.inExpressionEvaluation;\n }\n set inExpressionEvaluation(value) {\n this.callStack.currentElement.inExpressionEvaluation = value;\n }\n constructor(story) {\n // Backward compatible changes since v8:\n // v10: dynamic tags\n // v9: multi-flows\n this.kInkSaveStateVersion = 10;\n this.kMinCompatibleLoadVersion = 8;\n this.onDidLoadState = null;\n this._currentErrors = null;\n this._currentWarnings = null;\n this.divertedPointer = Pointer_1.Pointer.Null;\n this._currentTurnIndex = 0;\n this.storySeed = 0;\n this.previousRandom = 0;\n this.didSafeExit = false;\n this._currentText = null;\n this._currentTags = null;\n this._outputStreamTextDirty = true;\n this._outputStreamTagsDirty = true;\n this._patch = null;\n this._aliveFlowNames = null;\n this._namedFlows = null;\n this.kDefaultFlowName = \"DEFAULT_FLOW\";\n this._aliveFlowNamesDirty = true;\n this.story = story;\n this._currentFlow = new Flow_1.Flow(this.kDefaultFlowName, story);\n this.OutputStreamDirty();\n this._aliveFlowNamesDirty = true;\n this._evaluationStack = [];\n this._variablesState = new VariablesState_1.VariablesState(this.callStack, story.listDefinitions);\n this._visitCounts = new Map();\n this._turnIndices = new Map();\n this.currentTurnIndex = -1;\n let timeSeed = new Date().getTime();\n this.storySeed = new PRNG_1.PRNG(timeSeed).next() % 100;\n this.previousRandom = 0;\n this.GoToStart();\n }\n GoToStart() {\n this.callStack.currentElement.currentPointer = Pointer_1.Pointer.StartOf(this.story.mainContentContainer);\n }\n SwitchFlow_Internal(flowName) {\n if (flowName === null)\n throw new Error(\"Must pass a non-null string to Story.SwitchFlow\");\n if (this._namedFlows === null) {\n this._namedFlows = new Map();\n this._namedFlows.set(this.kDefaultFlowName, this._currentFlow);\n }\n if (flowName === this._currentFlow.name) {\n return;\n }\n let flow;\n let content = (0, TryGetResult_1.tryGetValueFromMap)(this._namedFlows, flowName, null);\n if (content.exists) {\n flow = content.result;\n }\n else {\n flow = new Flow_1.Flow(flowName, this.story);\n this._namedFlows.set(flowName, flow);\n this._aliveFlowNamesDirty = true;\n }\n this._currentFlow = flow;\n this.variablesState.callStack = this._currentFlow.callStack;\n this.OutputStreamDirty();\n }\n SwitchToDefaultFlow_Internal() {\n if (this._namedFlows === null)\n return;\n this.SwitchFlow_Internal(this.kDefaultFlowName);\n }\n RemoveFlow_Internal(flowName) {\n if (flowName === null)\n throw new Error(\"Must pass a non-null string to Story.DestroyFlow\");\n if (flowName === this.kDefaultFlowName)\n throw new Error(\"Cannot destroy default flow\");\n if (this._currentFlow.name === flowName) {\n this.SwitchToDefaultFlow_Internal();\n }\n if (this._namedFlows === null)\n return (0, NullException_1.throwNullException)(\"this._namedFlows\");\n this._namedFlows.delete(flowName);\n this._aliveFlowNamesDirty = true;\n }\n CopyAndStartPatching(forBackgroundSave) {\n let copy = new StoryState(this.story);\n copy._patch = new StatePatch_1.StatePatch(this._patch);\n copy._currentFlow.name = this._currentFlow.name;\n copy._currentFlow.callStack = new CallStack_1.CallStack(this._currentFlow.callStack);\n copy._currentFlow.outputStream.push(...this._currentFlow.outputStream);\n copy.OutputStreamDirty();\n // When background saving we need to make copies of choices since they each have\n // a snapshot of the thread at the time of generation since the game could progress\n // significantly and threads modified during the save process.\n // However, when doing internal saving and restoring of snapshots this isn't an issue,\n // and we can simply ref-copy the choices with their existing threads.\n if (forBackgroundSave) {\n for (let choice of this._currentFlow.currentChoices) {\n copy._currentFlow.currentChoices.push(choice.Clone());\n }\n }\n else {\n copy._currentFlow.currentChoices.push(...this._currentFlow.currentChoices);\n }\n if (this._namedFlows !== null) {\n copy._namedFlows = new Map();\n for (let [namedFlowKey, namedFlowValue] of this._namedFlows) {\n copy._namedFlows.set(namedFlowKey, namedFlowValue);\n copy._aliveFlowNamesDirty = true;\n }\n copy._namedFlows.set(this._currentFlow.name, copy._currentFlow);\n }\n if (this.hasError) {\n copy._currentErrors = [];\n copy._currentErrors.push(...(this.currentErrors || []));\n }\n if (this.hasWarning) {\n copy._currentWarnings = [];\n copy._currentWarnings.push(...(this.currentWarnings || []));\n }\n copy.variablesState = this.variablesState;\n copy.variablesState.callStack = copy.callStack;\n copy.variablesState.patch = copy._patch;\n copy.evaluationStack.push(...this.evaluationStack);\n if (!this.divertedPointer.isNull)\n copy.divertedPointer = this.divertedPointer.copy();\n copy.previousPointer = this.previousPointer.copy();\n copy._visitCounts = this._visitCounts;\n copy._turnIndices = this._turnIndices;\n copy.currentTurnIndex = this.currentTurnIndex;\n copy.storySeed = this.storySeed;\n copy.previousRandom = this.previousRandom;\n copy.didSafeExit = this.didSafeExit;\n return copy;\n }\n RestoreAfterPatch() {\n this.variablesState.callStack = this.callStack;\n this.variablesState.patch = this._patch;\n }\n ApplyAnyPatch() {\n if (this._patch === null)\n return;\n this.variablesState.ApplyPatch();\n for (let [key, value] of this._patch.visitCounts)\n this.ApplyCountChanges(key, value, true);\n for (let [key, value] of this._patch.turnIndices)\n this.ApplyCountChanges(key, value, false);\n this._patch = null;\n }\n ApplyCountChanges(container, newCount, isVisit) {\n let counts = isVisit ? this._visitCounts : this._turnIndices;\n counts.set(container.path.toString(), newCount);\n }\n WriteJson(writer) {\n writer.WriteObjectStart();\n writer.WritePropertyStart(\"flows\");\n writer.WriteObjectStart();\n // NOTE: Never pass `WriteJson` directly as an argument to `WriteProperty`.\n // Call it inside a function to make sure `this` is correctly bound\n // and passed down the call hierarchy.\n if (this._namedFlows !== null) {\n for (let [namedFlowKey, namedFlowValue] of this._namedFlows) {\n writer.WriteProperty(namedFlowKey, (w) => namedFlowValue.WriteJson(w));\n }\n }\n else {\n writer.WriteProperty(this._currentFlow.name, (w) => this._currentFlow.WriteJson(w));\n }\n writer.WriteObjectEnd();\n writer.WritePropertyEnd();\n writer.WriteProperty(\"currentFlowName\", this._currentFlow.name);\n writer.WriteProperty(\"variablesState\", (w) => this.variablesState.WriteJson(w));\n writer.WriteProperty(\"evalStack\", (w) => JsonSerialisation_1.JsonSerialisation.WriteListRuntimeObjs(w, this.evaluationStack));\n if (!this.divertedPointer.isNull) {\n if (this.divertedPointer.path === null) {\n return (0, NullException_1.throwNullException)(\"divertedPointer\");\n }\n writer.WriteProperty(\"currentDivertTarget\", this.divertedPointer.path.componentsString);\n }\n writer.WriteProperty(\"visitCounts\", (w) => JsonSerialisation_1.JsonSerialisation.WriteIntDictionary(w, this._visitCounts));\n writer.WriteProperty(\"turnIndices\", (w) => JsonSerialisation_1.JsonSerialisation.WriteIntDictionary(w, this._turnIndices));\n writer.WriteIntProperty(\"turnIdx\", this.currentTurnIndex);\n writer.WriteIntProperty(\"storySeed\", this.storySeed);\n writer.WriteIntProperty(\"previousRandom\", this.previousRandom);\n writer.WriteIntProperty(\"inkSaveVersion\", this.kInkSaveStateVersion);\n writer.WriteIntProperty(\"inkFormatVersion\", Story_1.Story.inkVersionCurrent);\n writer.WriteObjectEnd();\n }\n LoadJsonObj(value) {\n let jObject = value;\n let jSaveVersion = jObject[\"inkSaveVersion\"];\n if (jSaveVersion == null) {\n throw new Error(\"ink save format incorrect, can't load.\");\n }\n else if (parseInt(jSaveVersion) < this.kMinCompatibleLoadVersion) {\n throw new Error(\"Ink save format isn't compatible with the current version (saw '\" +\n jSaveVersion +\n \"', but minimum is \" +\n this.kMinCompatibleLoadVersion +\n \"), so can't load.\");\n }\n let flowsObj = jObject[\"flows\"];\n if (flowsObj != null) {\n let flowsObjDict = flowsObj;\n // Single default flow\n if (Object.keys(flowsObjDict).length === 1) {\n this._namedFlows = null;\n }\n else if (this._namedFlows === null) {\n this._namedFlows = new Map();\n }\n else {\n this._namedFlows.clear();\n }\n let flowsObjDictEntries = Object.entries(flowsObjDict);\n for (let [namedFlowObjKey, namedFlowObjValue] of flowsObjDictEntries) {\n let name = namedFlowObjKey;\n let flowObj = namedFlowObjValue;\n let flow = new Flow_1.Flow(name, this.story, flowObj);\n if (Object.keys(flowsObjDict).length === 1) {\n this._currentFlow = new Flow_1.Flow(name, this.story, flowObj);\n }\n else {\n if (this._namedFlows === null)\n return (0, NullException_1.throwNullException)(\"this._namedFlows\");\n this._namedFlows.set(name, flow);\n }\n }\n if (this._namedFlows != null && this._namedFlows.size > 1) {\n let currFlowName = jObject[\"currentFlowName\"];\n // Adding a bang at the end, because we're trusting the save, as\n // done in upstream. If the save is corrupted, the execution\n // is undefined.\n this._currentFlow = this._namedFlows.get(currFlowName);\n }\n }\n else {\n this._namedFlows = null;\n this._currentFlow.name = this.kDefaultFlowName;\n this._currentFlow.callStack.SetJsonToken(jObject[\"callstackThreads\"], this.story);\n this._currentFlow.outputStream = JsonSerialisation_1.JsonSerialisation.JArrayToRuntimeObjList(jObject[\"outputStream\"]);\n this._currentFlow.currentChoices =\n JsonSerialisation_1.JsonSerialisation.JArrayToRuntimeObjList(jObject[\"currentChoices\"]);\n let jChoiceThreadsObj = jObject[\"choiceThreads\"];\n this._currentFlow.LoadFlowChoiceThreads(jChoiceThreadsObj, this.story);\n }\n this.OutputStreamDirty();\n this._aliveFlowNamesDirty = true;\n this.variablesState.SetJsonToken(jObject[\"variablesState\"]);\n this.variablesState.callStack = this._currentFlow.callStack;\n this._evaluationStack = JsonSerialisation_1.JsonSerialisation.JArrayToRuntimeObjList(jObject[\"evalStack\"]);\n let currentDivertTargetPath = jObject[\"currentDivertTarget\"];\n if (currentDivertTargetPath != null) {\n let divertPath = new Path_1.Path(currentDivertTargetPath.toString());\n this.divertedPointer = this.story.PointerAtPath(divertPath);\n }\n this._visitCounts = JsonSerialisation_1.JsonSerialisation.JObjectToIntDictionary(jObject[\"visitCounts\"]);\n this._turnIndices = JsonSerialisation_1.JsonSerialisation.JObjectToIntDictionary(jObject[\"turnIndices\"]);\n this.currentTurnIndex = parseInt(jObject[\"turnIdx\"]);\n this.storySeed = parseInt(jObject[\"storySeed\"]);\n this.previousRandom = parseInt(jObject[\"previousRandom\"]);\n }\n ResetErrors() {\n this._currentErrors = null;\n this._currentWarnings = null;\n }\n ResetOutput(objs = null) {\n this.outputStream.length = 0;\n if (objs !== null)\n this.outputStream.push(...objs);\n this.OutputStreamDirty();\n }\n PushToOutputStream(obj) {\n // var text = obj as StringValue;\n let text = (0, TypeAssertion_1.asOrNull)(obj, Value_1.StringValue);\n if (text !== null) {\n let listText = this.TrySplittingHeadTailWhitespace(text);\n if (listText !== null) {\n for (let textObj of listText) {\n this.PushToOutputStreamIndividual(textObj);\n }\n this.OutputStreamDirty();\n return;\n }\n }\n this.PushToOutputStreamIndividual(obj);\n this.OutputStreamDirty();\n }\n PopFromOutputStream(count) {\n this.outputStream.splice(this.outputStream.length - count, count);\n this.OutputStreamDirty();\n }\n TrySplittingHeadTailWhitespace(single) {\n let str = single.value;\n if (str === null) {\n return (0, NullException_1.throwNullException)(\"single.value\");\n }\n let headFirstNewlineIdx = -1;\n let headLastNewlineIdx = -1;\n for (let i = 0; i < str.length; i++) {\n let c = str[i];\n if (c == \"\\n\") {\n if (headFirstNewlineIdx == -1)\n headFirstNewlineIdx = i;\n headLastNewlineIdx = i;\n }\n else if (c == \" \" || c == \"\\t\")\n continue;\n else\n break;\n }\n let tailLastNewlineIdx = -1;\n let tailFirstNewlineIdx = -1;\n for (let i = str.length - 1; i >= 0; i--) {\n let c = str[i];\n if (c == \"\\n\") {\n if (tailLastNewlineIdx == -1)\n tailLastNewlineIdx = i;\n tailFirstNewlineIdx = i;\n }\n else if (c == \" \" || c == \"\\t\")\n continue;\n else\n break;\n }\n // No splitting to be done?\n if (headFirstNewlineIdx == -1 && tailLastNewlineIdx == -1)\n return null;\n let listTexts = [];\n let innerStrStart = 0;\n let innerStrEnd = str.length;\n if (headFirstNewlineIdx != -1) {\n if (headFirstNewlineIdx > 0) {\n let leadingSpaces = new Value_1.StringValue(str.substring(0, headFirstNewlineIdx));\n listTexts.push(leadingSpaces);\n }\n listTexts.push(new Value_1.StringValue(\"\\n\"));\n innerStrStart = headLastNewlineIdx + 1;\n }\n if (tailLastNewlineIdx != -1) {\n innerStrEnd = tailFirstNewlineIdx;\n }\n if (innerStrEnd > innerStrStart) {\n let innerStrText = str.substring(innerStrStart, innerStrEnd);\n listTexts.push(new Value_1.StringValue(innerStrText));\n }\n if (tailLastNewlineIdx != -1 && tailFirstNewlineIdx > headLastNewlineIdx) {\n listTexts.push(new Value_1.StringValue(\"\\n\"));\n if (tailLastNewlineIdx < str.length - 1) {\n let numSpaces = str.length - tailLastNewlineIdx - 1;\n let trailingSpaces = new Value_1.StringValue(str.substring(tailLastNewlineIdx + 1, tailLastNewlineIdx + 1 + numSpaces));\n listTexts.push(trailingSpaces);\n }\n }\n return listTexts;\n }\n PushToOutputStreamIndividual(obj) {\n let glue = (0, TypeAssertion_1.asOrNull)(obj, Glue_1.Glue);\n let text = (0, TypeAssertion_1.asOrNull)(obj, Value_1.StringValue);\n let includeInOutput = true;\n if (glue) {\n this.TrimNewlinesFromOutputStream();\n includeInOutput = true;\n }\n else if (text) {\n let functionTrimIndex = -1;\n let currEl = this.callStack.currentElement;\n if (currEl.type == PushPop_1.PushPopType.Function) {\n functionTrimIndex = currEl.functionStartInOutputStream;\n }\n let glueTrimIndex = -1;\n for (let i = this.outputStream.length - 1; i >= 0; i--) {\n let o = this.outputStream[i];\n let c = o instanceof ControlCommand_1.ControlCommand ? o : null;\n let g = o instanceof Glue_1.Glue ? o : null;\n if (g != null) {\n glueTrimIndex = i;\n break;\n }\n else if (c != null &&\n c.commandType == ControlCommand_1.ControlCommand.CommandType.BeginString) {\n if (i >= functionTrimIndex) {\n functionTrimIndex = -1;\n }\n break;\n }\n }\n let trimIndex = -1;\n if (glueTrimIndex != -1 && functionTrimIndex != -1)\n trimIndex = Math.min(functionTrimIndex, glueTrimIndex);\n else if (glueTrimIndex != -1)\n trimIndex = glueTrimIndex;\n else\n trimIndex = functionTrimIndex;\n if (trimIndex != -1) {\n if (text.isNewline) {\n includeInOutput = false;\n }\n else if (text.isNonWhitespace) {\n if (glueTrimIndex > -1)\n this.RemoveExistingGlue();\n if (functionTrimIndex > -1) {\n let callStackElements = this.callStack.elements;\n for (let i = callStackElements.length - 1; i >= 0; i--) {\n let el = callStackElements[i];\n if (el.type == PushPop_1.PushPopType.Function) {\n el.functionStartInOutputStream = -1;\n }\n else {\n break;\n }\n }\n }\n }\n }\n else if (text.isNewline) {\n if (this.outputStreamEndsInNewline || !this.outputStreamContainsContent)\n includeInOutput = false;\n }\n }\n if (includeInOutput) {\n if (obj === null) {\n return (0, NullException_1.throwNullException)(\"obj\");\n }\n this.outputStream.push(obj);\n this.OutputStreamDirty();\n }\n }\n TrimNewlinesFromOutputStream() {\n let removeWhitespaceFrom = -1;\n let i = this.outputStream.length - 1;\n while (i >= 0) {\n let obj = this.outputStream[i];\n let cmd = (0, TypeAssertion_1.asOrNull)(obj, ControlCommand_1.ControlCommand);\n let txt = (0, TypeAssertion_1.asOrNull)(obj, Value_1.StringValue);\n if (cmd != null || (txt != null && txt.isNonWhitespace)) {\n break;\n }\n else if (txt != null && txt.isNewline) {\n removeWhitespaceFrom = i;\n }\n i--;\n }\n // Remove the whitespace\n if (removeWhitespaceFrom >= 0) {\n i = removeWhitespaceFrom;\n while (i < this.outputStream.length) {\n let text = (0, TypeAssertion_1.asOrNull)(this.outputStream[i], Value_1.StringValue);\n if (text) {\n this.outputStream.splice(i, 1);\n }\n else {\n i++;\n }\n }\n }\n this.OutputStreamDirty();\n }\n RemoveExistingGlue() {\n for (let i = this.outputStream.length - 1; i >= 0; i--) {\n let c = this.outputStream[i];\n if (c instanceof Glue_1.Glue) {\n this.outputStream.splice(i, 1);\n }\n else if (c instanceof ControlCommand_1.ControlCommand) {\n break;\n }\n }\n this.OutputStreamDirty();\n }\n get outputStreamEndsInNewline() {\n if (this.outputStream.length > 0) {\n for (let i = this.outputStream.length - 1; i >= 0; i--) {\n let obj = this.outputStream[i];\n if (obj instanceof ControlCommand_1.ControlCommand)\n break;\n let text = this.outputStream[i];\n if (text instanceof Value_1.StringValue) {\n if (text.isNewline)\n return true;\n else if (text.isNonWhitespace)\n break;\n }\n }\n }\n return false;\n }\n get outputStreamContainsContent() {\n for (let content of this.outputStream) {\n if (content instanceof Value_1.StringValue)\n return true;\n }\n return false;\n }\n get inStringEvaluation() {\n for (let i = this.outputStream.length - 1; i >= 0; i--) {\n let cmd = (0, TypeAssertion_1.asOrNull)(this.outputStream[i], ControlCommand_1.ControlCommand);\n if (cmd instanceof ControlCommand_1.ControlCommand &&\n cmd.commandType == ControlCommand_1.ControlCommand.CommandType.BeginString) {\n return true;\n }\n }\n return false;\n }\n PushEvaluationStack(obj) {\n // var listValue = obj as ListValue;\n let listValue = (0, TypeAssertion_1.asOrNull)(obj, Value_1.ListValue);\n if (listValue) {\n // Update origin when list is has something to indicate the list origin\n let rawList = listValue.value;\n if (rawList === null) {\n return (0, NullException_1.throwNullException)(\"rawList\");\n }\n if (rawList.originNames != null) {\n if (!rawList.origins)\n rawList.origins = [];\n rawList.origins.length = 0;\n for (let n of rawList.originNames) {\n if (this.story.listDefinitions === null)\n return (0, NullException_1.throwNullException)(\"StoryState.story.listDefinitions\");\n let def = this.story.listDefinitions.TryListGetDefinition(n, null);\n if (def.result === null)\n return (0, NullException_1.throwNullException)(\"StoryState def.result\");\n if (rawList.origins.indexOf(def.result) < 0)\n rawList.origins.push(def.result);\n }\n }\n }\n if (obj === null) {\n return (0, NullException_1.throwNullException)(\"obj\");\n }\n this.evaluationStack.push(obj);\n }\n PopEvaluationStack(numberOfObjects) {\n if (typeof numberOfObjects === \"undefined\") {\n let obj = this.evaluationStack.pop();\n return (0, TypeAssertion_1.nullIfUndefined)(obj);\n }\n else {\n if (numberOfObjects > this.evaluationStack.length) {\n throw new Error(\"trying to pop too many objects\");\n }\n let popped = this.evaluationStack.splice(this.evaluationStack.length - numberOfObjects, numberOfObjects);\n return (0, TypeAssertion_1.nullIfUndefined)(popped);\n }\n }\n PeekEvaluationStack() {\n return this.evaluationStack[this.evaluationStack.length - 1];\n }\n ForceEnd() {\n this.callStack.Reset();\n this._currentFlow.currentChoices.length = 0;\n this.currentPointer = Pointer_1.Pointer.Null;\n this.previousPointer = Pointer_1.Pointer.Null;\n this.didSafeExit = true;\n }\n TrimWhitespaceFromFunctionEnd() {\n Debug_1.Debug.Assert(this.callStack.currentElement.type == PushPop_1.PushPopType.Function);\n let functionStartPoint = this.callStack.currentElement.functionStartInOutputStream;\n if (functionStartPoint == -1) {\n functionStartPoint = 0;\n }\n for (let i = this.outputStream.length - 1; i >= functionStartPoint; i--) {\n let obj = this.outputStream[i];\n let txt = (0, TypeAssertion_1.asOrNull)(obj, Value_1.StringValue);\n let cmd = (0, TypeAssertion_1.asOrNull)(obj, ControlCommand_1.ControlCommand);\n if (txt == null)\n continue;\n if (cmd)\n break;\n if (txt.isNewline || txt.isInlineWhitespace) {\n this.outputStream.splice(i, 1);\n this.OutputStreamDirty();\n }\n else {\n break;\n }\n }\n }\n PopCallStack(popType = null) {\n if (this.callStack.currentElement.type == PushPop_1.PushPopType.Function)\n this.TrimWhitespaceFromFunctionEnd();\n this.callStack.Pop(popType);\n }\n SetChosenPath(path, incrementingTurnIndex) {\n // Changing direction, assume we need to clear current set of choices\n this._currentFlow.currentChoices.length = 0;\n let newPointer = this.story.PointerAtPath(path);\n if (!newPointer.isNull && newPointer.index == -1)\n newPointer.index = 0;\n this.currentPointer = newPointer;\n if (incrementingTurnIndex) {\n this.currentTurnIndex++;\n }\n }\n StartFunctionEvaluationFromGame(funcContainer, args) {\n this.callStack.Push(PushPop_1.PushPopType.FunctionEvaluationFromGame, this.evaluationStack.length);\n this.callStack.currentElement.currentPointer =\n Pointer_1.Pointer.StartOf(funcContainer);\n this.PassArgumentsToEvaluationStack(args);\n }\n PassArgumentsToEvaluationStack(args) {\n if (args !== null) {\n for (let i = 0; i < args.length; i++) {\n if (!(typeof args[i] === \"number\" ||\n typeof args[i] === \"string\" ||\n typeof args[i] === \"boolean\" ||\n args[i] instanceof InkList_1.InkList)) {\n throw new Error(\"ink arguments when calling EvaluateFunction / ChoosePathStringWithParameters must be\" +\n \"number, string, bool or InkList. Argument was \" +\n ((0, TypeAssertion_1.nullIfUndefined)(args[i]) === null\n ? \"null\"\n : args[i].constructor.name));\n }\n this.PushEvaluationStack(Value_1.Value.Create(args[i]));\n }\n }\n }\n TryExitFunctionEvaluationFromGame() {\n if (this.callStack.currentElement.type ==\n PushPop_1.PushPopType.FunctionEvaluationFromGame) {\n this.currentPointer = Pointer_1.Pointer.Null;\n this.didSafeExit = true;\n return true;\n }\n return false;\n }\n CompleteFunctionEvaluationFromGame() {\n if (this.callStack.currentElement.type !=\n PushPop_1.PushPopType.FunctionEvaluationFromGame) {\n throw new Error(\"Expected external function evaluation to be complete. Stack trace: \" +\n this.callStack.callStackTrace);\n }\n let originalEvaluationStackHeight = this.callStack.currentElement.evaluationStackHeightWhenPushed;\n let returnedObj = null;\n while (this.evaluationStack.length > originalEvaluationStackHeight) {\n let poppedObj = this.PopEvaluationStack();\n if (returnedObj === null)\n returnedObj = poppedObj;\n }\n this.PopCallStack(PushPop_1.PushPopType.FunctionEvaluationFromGame);\n if (returnedObj) {\n if (returnedObj instanceof Void_1.Void)\n return null;\n // Some kind of value, if not void\n // var returnVal = returnedObj as Runtime.Value;\n let returnVal = (0, TypeAssertion_1.asOrThrows)(returnedObj, Value_1.Value);\n // DivertTargets get returned as the string of components\n // (rather than a Path, which isn't public)\n if (returnVal.valueType == Value_1.ValueType.DivertTarget) {\n return \"-> \" + returnVal.valueObject.toString();\n }\n // Other types can just have their exact object type:\n // int, float, string. VariablePointers get returned as strings.\n return returnVal.valueObject;\n }\n return null;\n }\n AddError(message, isWarning) {\n if (!isWarning) {\n if (this._currentErrors == null)\n this._currentErrors = [];\n this._currentErrors.push(message);\n }\n else {\n if (this._currentWarnings == null)\n this._currentWarnings = [];\n this._currentWarnings.push(message);\n }\n }\n OutputStreamDirty() {\n this._outputStreamTextDirty = true;\n this._outputStreamTagsDirty = true;\n }\n}\nexports.StoryState = StoryState;\n//# sourceMappingURL=StoryState.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Stopwatch = void 0;\n// This is simple replacement of the Stopwatch class from the .NET Framework.\n// The original class can count time with much more accuracy than the Javascript version.\n// It might be worth considering using `window.performance` in the browser\n// or `process.hrtime()` in node.\nclass Stopwatch {\n constructor() {\n this.startTime = undefined;\n }\n get ElapsedMilliseconds() {\n if (typeof this.startTime === \"undefined\") {\n return 0;\n }\n return new Date().getTime() - this.startTime;\n }\n Start() {\n this.startTime = new Date().getTime();\n }\n Stop() {\n this.startTime = undefined;\n }\n}\nexports.Stopwatch = Stopwatch;\n//# sourceMappingURL=StopWatch.js.map","\"use strict\";\n// TODO: Unify with Compiler.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ErrorType = void 0;\nvar ErrorType;\n(function (ErrorType) {\n ErrorType[ErrorType[\"Author\"] = 0] = \"Author\";\n ErrorType[ErrorType[\"Warning\"] = 1] = \"Warning\";\n ErrorType[ErrorType[\"Error\"] = 2] = \"Error\";\n})(ErrorType || (exports.ErrorType = ErrorType = {}));\n//# sourceMappingURL=Error.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Story = exports.InkList = void 0;\nconst Container_1 = require(\"./Container\");\nconst Object_1 = require(\"./Object\");\nconst JsonSerialisation_1 = require(\"./JsonSerialisation\");\nconst StoryState_1 = require(\"./StoryState\");\nconst ControlCommand_1 = require(\"./ControlCommand\");\nconst PushPop_1 = require(\"./PushPop\");\nconst ChoicePoint_1 = require(\"./ChoicePoint\");\nconst Choice_1 = require(\"./Choice\");\nconst Divert_1 = require(\"./Divert\");\nconst Value_1 = require(\"./Value\");\nconst Path_1 = require(\"./Path\");\nconst Void_1 = require(\"./Void\");\nconst Tag_1 = require(\"./Tag\");\nconst VariableAssignment_1 = require(\"./VariableAssignment\");\nconst VariableReference_1 = require(\"./VariableReference\");\nconst NativeFunctionCall_1 = require(\"./NativeFunctionCall\");\nconst StoryException_1 = require(\"./StoryException\");\nconst PRNG_1 = require(\"./PRNG\");\nconst StringBuilder_1 = require(\"./StringBuilder\");\nconst ListDefinitionsOrigin_1 = require(\"./ListDefinitionsOrigin\");\nconst StopWatch_1 = require(\"./StopWatch\");\nconst Pointer_1 = require(\"./Pointer\");\nconst InkList_1 = require(\"./InkList\");\nconst TypeAssertion_1 = require(\"./TypeAssertion\");\nconst NullException_1 = require(\"./NullException\");\nconst SimpleJson_1 = require(\"./SimpleJson\");\nconst Error_1 = require(\"./Error\");\nvar InkList_2 = require(\"./InkList\");\nObject.defineProperty(exports, \"InkList\", { enumerable: true, get: function () { return InkList_2.InkList; } });\nif (!Number.isInteger) {\n Number.isInteger = function isInteger(nVal) {\n return (typeof nVal === \"number\" &&\n isFinite(nVal) &&\n nVal > -9007199254740992 &&\n nVal < 9007199254740992 &&\n Math.floor(nVal) === nVal);\n };\n}\nclass Story extends Object_1.InkObject {\n get currentChoices() {\n let choices = [];\n if (this._state === null) {\n return (0, NullException_1.throwNullException)(\"this._state\");\n }\n for (let c of this._state.currentChoices) {\n if (!c.isInvisibleDefault) {\n c.index = choices.length;\n choices.push(c);\n }\n }\n return choices;\n }\n get currentText() {\n this.IfAsyncWeCant(\"call currentText since it's a work in progress\");\n return this.state.currentText;\n }\n get currentTags() {\n this.IfAsyncWeCant(\"call currentTags since it's a work in progress\");\n return this.state.currentTags;\n }\n get currentErrors() {\n return this.state.currentErrors;\n }\n get currentWarnings() {\n return this.state.currentWarnings;\n }\n get currentFlowName() {\n return this.state.currentFlowName;\n }\n get currentFlowIsDefaultFlow() {\n return this.state.currentFlowIsDefaultFlow;\n }\n get aliveFlowNames() {\n return this.state.aliveFlowNames;\n }\n get hasError() {\n return this.state.hasError;\n }\n get hasWarning() {\n return this.state.hasWarning;\n }\n get variablesState() {\n return this.state.variablesState;\n }\n get listDefinitions() {\n return this._listDefinitions;\n }\n get state() {\n return this._state;\n }\n // TODO: Implement Profiler\n StartProfiling() {\n /* */\n }\n EndProfiling() {\n /* */\n }\n constructor() {\n super();\n this.inkVersionMinimumCompatible = 18;\n this.onError = null;\n this.onDidContinue = null;\n this.onMakeChoice = null;\n this.onEvaluateFunction = null;\n this.onCompleteEvaluateFunction = null;\n this.onChoosePathString = null;\n this._prevContainers = [];\n this.allowExternalFunctionFallbacks = false;\n this._listDefinitions = null;\n this._variableObservers = null;\n this._hasValidatedExternals = false;\n this._temporaryEvaluationContainer = null;\n this._asyncContinueActive = false;\n this._stateSnapshotAtLastNewline = null;\n this._sawLookaheadUnsafeFunctionAfterNewline = false;\n this._recursiveContinueCount = 0;\n this._asyncSaving = false;\n this._profiler = null; // TODO: Profiler\n // Discrimination between constructors\n let contentContainer;\n let lists = null;\n let json = null;\n if (arguments[0] instanceof Container_1.Container) {\n contentContainer = arguments[0];\n if (typeof arguments[1] !== \"undefined\") {\n lists = arguments[1];\n }\n // ------ Story (Container contentContainer, List<Runtime.ListDefinition> lists = null)\n this._mainContentContainer = contentContainer;\n // ------\n }\n else {\n if (typeof arguments[0] === \"string\") {\n let jsonString = arguments[0];\n json = SimpleJson_1.SimpleJson.TextToDictionary(jsonString);\n }\n else {\n json = arguments[0];\n }\n }\n // ------ Story (Container contentContainer, List<Runtime.ListDefinition> lists = null)\n if (lists != null)\n this._listDefinitions = new ListDefinitionsOrigin_1.ListDefinitionsOrigin(lists);\n this._externals = new Map();\n // ------\n // ------ Story(string jsonString) : this((Container)null)\n if (json !== null) {\n let rootObject = json;\n let versionObj = rootObject[\"inkVersion\"];\n if (versionObj == null)\n throw new Error(\"ink version number not found. Are you sure it's a valid .ink.json file?\");\n let formatFromFile = parseInt(versionObj);\n if (formatFromFile > Story.inkVersionCurrent) {\n throw new Error(\"Version of ink used to build story was newer than the current version of the engine\");\n }\n else if (formatFromFile < this.inkVersionMinimumCompatible) {\n throw new Error(\"Version of ink used to build story is too old to be loaded by this version of the engine\");\n }\n else if (formatFromFile != Story.inkVersionCurrent) {\n console.warn(`WARNING: Version of ink ${Story.inkVersionCurrent} used to build story doesn't match current version of engine (${formatFromFile}). Non-critical, but recommend synchronising.`);\n }\n let rootToken = rootObject[\"root\"];\n if (rootToken == null)\n throw new Error(\"Root node for ink not found. Are you sure it's a valid .ink.json file?\");\n let listDefsObj;\n if ((listDefsObj = rootObject[\"listDefs\"])) {\n this._listDefinitions =\n JsonSerialisation_1.JsonSerialisation.JTokenToListDefinitions(listDefsObj);\n }\n this._mainContentContainer = (0, TypeAssertion_1.asOrThrows)(JsonSerialisation_1.JsonSerialisation.JTokenToRuntimeObject(rootToken), Container_1.Container);\n this.ResetState();\n }\n // ------\n }\n // Merge together `public string ToJson()` and `void ToJson(SimpleJson.Writer writer)`.\n // Will only return a value if writer was not provided.\n ToJson(writer) {\n let shouldReturn = false;\n if (!writer) {\n shouldReturn = true;\n writer = new SimpleJson_1.SimpleJson.Writer();\n }\n writer.WriteObjectStart();\n writer.WriteIntProperty(\"inkVersion\", Story.inkVersionCurrent);\n writer.WriteProperty(\"root\", (w) => JsonSerialisation_1.JsonSerialisation.WriteRuntimeContainer(w, this._mainContentContainer));\n if (this._listDefinitions != null) {\n writer.WritePropertyStart(\"listDefs\");\n writer.WriteObjectStart();\n for (let def of this._listDefinitions.lists) {\n writer.WritePropertyStart(def.name);\n writer.WriteObjectStart();\n for (let [key, value] of def.items) {\n let item = InkList_1.InkListItem.fromSerializedKey(key);\n let val = value;\n writer.WriteIntProperty(item.itemName, val);\n }\n writer.WriteObjectEnd();\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n writer.WritePropertyEnd();\n }\n writer.WriteObjectEnd();\n if (shouldReturn)\n return writer.toString();\n }\n ResetState() {\n this.IfAsyncWeCant(\"ResetState\");\n this._state = new StoryState_1.StoryState(this);\n this._state.variablesState.ObserveVariableChange(this.VariableStateDidChangeEvent.bind(this));\n this.ResetGlobals();\n }\n ResetErrors() {\n if (this._state === null) {\n return (0, NullException_1.throwNullException)(\"this._state\");\n }\n this._state.ResetErrors();\n }\n ResetCallstack() {\n this.IfAsyncWeCant(\"ResetCallstack\");\n if (this._state === null) {\n return (0, NullException_1.throwNullException)(\"this._state\");\n }\n this._state.ForceEnd();\n }\n ResetGlobals() {\n if (this._mainContentContainer.namedContent.get(\"global decl\")) {\n let originalPointer = this.state.currentPointer.copy();\n this.ChoosePath(new Path_1.Path(\"global decl\"), false);\n this.ContinueInternal();\n this.state.currentPointer = originalPointer;\n }\n this.state.variablesState.SnapshotDefaultGlobals();\n }\n SwitchFlow(flowName) {\n this.IfAsyncWeCant(\"switch flow\");\n if (this._asyncSaving) {\n throw new Error(\"Story is already in background saving mode, can't switch flow to \" +\n flowName);\n }\n this.state.SwitchFlow_Internal(flowName);\n }\n RemoveFlow(flowName) {\n this.state.RemoveFlow_Internal(flowName);\n }\n SwitchToDefaultFlow() {\n this.state.SwitchToDefaultFlow_Internal();\n }\n Continue() {\n this.ContinueAsync(0);\n return this.currentText;\n }\n get canContinue() {\n return this.state.canContinue;\n }\n get asyncContinueComplete() {\n return !this._asyncContinueActive;\n }\n ContinueAsync(millisecsLimitAsync) {\n if (!this._hasValidatedExternals)\n this.ValidateExternalBindings();\n this.ContinueInternal(millisecsLimitAsync);\n }\n ContinueInternal(millisecsLimitAsync = 0) {\n if (this._profiler != null)\n this._profiler.PreContinue();\n let isAsyncTimeLimited = millisecsLimitAsync > 0;\n this._recursiveContinueCount++;\n if (!this._asyncContinueActive) {\n this._asyncContinueActive = isAsyncTimeLimited;\n if (!this.canContinue) {\n throw new Error(\"Can't continue - should check canContinue before calling Continue\");\n }\n this._state.didSafeExit = false;\n this._state.ResetOutput();\n if (this._recursiveContinueCount == 1)\n this._state.variablesState.StartVariableObservation();\n }\n else if (this._asyncContinueActive && !isAsyncTimeLimited) {\n this._asyncContinueActive = false;\n }\n let durationStopwatch = new StopWatch_1.Stopwatch();\n durationStopwatch.Start();\n let outputStreamEndsInNewline = false;\n this._sawLookaheadUnsafeFunctionAfterNewline = false;\n do {\n try {\n outputStreamEndsInNewline = this.ContinueSingleStep();\n }\n catch (e) {\n if (!(e instanceof StoryException_1.StoryException))\n throw e;\n this.AddError(e.message, undefined, e.useEndLineNumber);\n break;\n }\n if (outputStreamEndsInNewline)\n break;\n if (this._asyncContinueActive &&\n durationStopwatch.ElapsedMilliseconds > millisecsLimitAsync) {\n break;\n }\n } while (this.canContinue);\n durationStopwatch.Stop();\n let changedVariablesToObserve = null;\n if (outputStreamEndsInNewline || !this.canContinue) {\n if (this._stateSnapshotAtLastNewline !== null) {\n this.RestoreStateSnapshot();\n }\n if (!this.canContinue) {\n if (this.state.callStack.canPopThread)\n this.AddError(\"Thread available to pop, threads should always be flat by the end of evaluation?\");\n if (this.state.generatedChoices.length == 0 &&\n !this.state.didSafeExit &&\n this._temporaryEvaluationContainer == null) {\n if (this.state.callStack.CanPop(PushPop_1.PushPopType.Tunnel))\n this.AddError(\"unexpectedly reached end of content. Do you need a '->->' to return from a tunnel?\");\n else if (this.state.callStack.CanPop(PushPop_1.PushPopType.Function))\n this.AddError(\"unexpectedly reached end of content. Do you need a '~ return'?\");\n else if (!this.state.callStack.canPop)\n this.AddError(\"ran out of content. Do you need a '-> DONE' or '-> END'?\");\n else\n this.AddError(\"unexpectedly reached end of content for unknown reason. Please debug compiler!\");\n }\n }\n this.state.didSafeExit = false;\n this._sawLookaheadUnsafeFunctionAfterNewline = false;\n if (this._recursiveContinueCount == 1)\n changedVariablesToObserve =\n this._state.variablesState.CompleteVariableObservation();\n this._asyncContinueActive = false;\n if (this.onDidContinue !== null)\n this.onDidContinue();\n }\n this._recursiveContinueCount--;\n if (this._profiler != null)\n this._profiler.PostContinue();\n // In the following code, we're masking a lot of non-null assertion,\n // because testing for against `hasError` or `hasWarning` makes sure\n // the arrays are present and contain at least one element.\n if (this.state.hasError || this.state.hasWarning) {\n if (this.onError !== null) {\n if (this.state.hasError) {\n for (let err of this.state.currentErrors) {\n this.onError(err, Error_1.ErrorType.Error);\n }\n }\n if (this.state.hasWarning) {\n for (let err of this.state.currentWarnings) {\n this.onError(err, Error_1.ErrorType.Warning);\n }\n }\n this.ResetErrors();\n }\n else {\n let sb = new StringBuilder_1.StringBuilder();\n sb.Append(\"Ink had \");\n if (this.state.hasError) {\n sb.Append(`${this.state.currentErrors.length}`);\n sb.Append(this.state.currentErrors.length == 1 ? \" error\" : \" errors\");\n if (this.state.hasWarning)\n sb.Append(\" and \");\n }\n if (this.state.hasWarning) {\n sb.Append(`${this.state.currentWarnings.length}`);\n sb.Append(this.state.currentWarnings.length == 1 ? \" warning\" : \" warnings\");\n if (this.state.hasWarning)\n sb.Append(\" and \");\n }\n sb.Append(\". It is strongly suggested that you assign an error handler to story.onError. The first issue was: \");\n sb.Append(this.state.hasError\n ? this.state.currentErrors[0]\n : this.state.currentWarnings[0]);\n throw new StoryException_1.StoryException(sb.toString());\n }\n }\n if (changedVariablesToObserve != null &&\n Object.keys(changedVariablesToObserve).length > 0) {\n this._state.variablesState.NotifyObservers(changedVariablesToObserve);\n }\n }\n ContinueSingleStep() {\n if (this._profiler != null)\n this._profiler.PreStep();\n this.Step();\n if (this._profiler != null)\n this._profiler.PostStep();\n if (!this.canContinue && !this.state.callStack.elementIsEvaluateFromGame) {\n this.TryFollowDefaultInvisibleChoice();\n }\n if (this._profiler != null)\n this._profiler.PreSnapshot();\n if (!this.state.inStringEvaluation) {\n if (this._stateSnapshotAtLastNewline !== null) {\n if (this._stateSnapshotAtLastNewline.currentTags === null) {\n return (0, NullException_1.throwNullException)(\"this._stateAtLastNewline.currentTags\");\n }\n if (this.state.currentTags === null) {\n return (0, NullException_1.throwNullException)(\"this.state.currentTags\");\n }\n let change = this.CalculateNewlineOutputStateChange(this._stateSnapshotAtLastNewline.currentText, this.state.currentText, this._stateSnapshotAtLastNewline.currentTags.length, this.state.currentTags.length);\n if (change == Story.OutputStateChange.ExtendedBeyondNewline ||\n this._sawLookaheadUnsafeFunctionAfterNewline) {\n this.RestoreStateSnapshot();\n return true;\n }\n else if (change == Story.OutputStateChange.NewlineRemoved) {\n this.DiscardSnapshot();\n }\n }\n if (this.state.outputStreamEndsInNewline) {\n if (this.canContinue) {\n if (this._stateSnapshotAtLastNewline == null)\n this.StateSnapshot();\n }\n else {\n this.DiscardSnapshot();\n }\n }\n }\n if (this._profiler != null)\n this._profiler.PostSnapshot();\n return false;\n }\n CalculateNewlineOutputStateChange(prevText, currText, prevTagCount, currTagCount) {\n if (prevText === null) {\n return (0, NullException_1.throwNullException)(\"prevText\");\n }\n if (currText === null) {\n return (0, NullException_1.throwNullException)(\"currText\");\n }\n let newlineStillExists = currText.length >= prevText.length &&\n prevText.length > 0 &&\n currText.charAt(prevText.length - 1) == \"\\n\";\n if (prevTagCount == currTagCount &&\n prevText.length == currText.length &&\n newlineStillExists)\n return Story.OutputStateChange.NoChange;\n if (!newlineStillExists) {\n return Story.OutputStateChange.NewlineRemoved;\n }\n if (currTagCount > prevTagCount)\n return Story.OutputStateChange.ExtendedBeyondNewline;\n for (let i = prevText.length; i < currText.length; i++) {\n let c = currText.charAt(i);\n if (c != \" \" && c != \"\\t\") {\n return Story.OutputStateChange.ExtendedBeyondNewline;\n }\n }\n return Story.OutputStateChange.NoChange;\n }\n ContinueMaximally() {\n this.IfAsyncWeCant(\"ContinueMaximally\");\n let sb = new StringBuilder_1.StringBuilder();\n while (this.canContinue) {\n sb.Append(this.Continue());\n }\n return sb.toString();\n }\n ContentAtPath(path) {\n return this.mainContentContainer.ContentAtPath(path);\n }\n KnotContainerWithName(name) {\n let namedContainer = this.mainContentContainer.namedContent.get(name);\n if (namedContainer instanceof Container_1.Container)\n return namedContainer;\n else\n return null;\n }\n PointerAtPath(path) {\n if (path.length == 0)\n return Pointer_1.Pointer.Null;\n let p = new Pointer_1.Pointer();\n let pathLengthToUse = path.length;\n let result = null;\n if (path.lastComponent === null) {\n return (0, NullException_1.throwNullException)(\"path.lastComponent\");\n }\n if (path.lastComponent.isIndex) {\n pathLengthToUse = path.length - 1;\n result = this.mainContentContainer.ContentAtPath(path, undefined, pathLengthToUse);\n p.container = result.container;\n p.index = path.lastComponent.index;\n }\n else {\n result = this.mainContentContainer.ContentAtPath(path);\n p.container = result.container;\n p.index = -1;\n }\n if (result.obj == null ||\n (result.obj == this.mainContentContainer && pathLengthToUse > 0)) {\n this.Error(\"Failed to find content at path '\" +\n path +\n \"', and no approximation of it was possible.\");\n }\n else if (result.approximate)\n this.Warning(\"Failed to find content at path '\" +\n path +\n \"', so it was approximated to: '\" +\n result.obj.path +\n \"'.\");\n return p;\n }\n StateSnapshot() {\n this._stateSnapshotAtLastNewline = this._state;\n this._state = this._state.CopyAndStartPatching(false);\n }\n RestoreStateSnapshot() {\n if (this._stateSnapshotAtLastNewline === null) {\n (0, NullException_1.throwNullException)(\"_stateSnapshotAtLastNewline\");\n }\n this._stateSnapshotAtLastNewline.RestoreAfterPatch();\n this._state = this._stateSnapshotAtLastNewline;\n this._stateSnapshotAtLastNewline = null;\n if (!this._asyncSaving) {\n this._state.ApplyAnyPatch();\n }\n }\n DiscardSnapshot() {\n if (!this._asyncSaving)\n this._state.ApplyAnyPatch();\n this._stateSnapshotAtLastNewline = null;\n }\n CopyStateForBackgroundThreadSave() {\n this.IfAsyncWeCant(\"start saving on a background thread\");\n if (this._asyncSaving)\n throw new Error(\"Story is already in background saving mode, can't call CopyStateForBackgroundThreadSave again!\");\n let stateToSave = this._state;\n this._state = this._state.CopyAndStartPatching(true);\n this._asyncSaving = true;\n return stateToSave;\n }\n BackgroundSaveComplete() {\n if (this._stateSnapshotAtLastNewline === null) {\n this._state.ApplyAnyPatch();\n }\n this._asyncSaving = false;\n }\n Step() {\n let shouldAddToStream = true;\n let pointer = this.state.currentPointer.copy();\n if (pointer.isNull) {\n return;\n }\n // Container containerToEnter = pointer.Resolve () as Container;\n let containerToEnter = (0, TypeAssertion_1.asOrNull)(pointer.Resolve(), Container_1.Container);\n while (containerToEnter) {\n this.VisitContainer(containerToEnter, true);\n // No content? the most we can do is step past it\n if (containerToEnter.content.length == 0) {\n break;\n }\n pointer = Pointer_1.Pointer.StartOf(containerToEnter);\n // containerToEnter = pointer.Resolve() as Container;\n containerToEnter = (0, TypeAssertion_1.asOrNull)(pointer.Resolve(), Container_1.Container);\n }\n this.state.currentPointer = pointer.copy();\n if (this._profiler != null)\n this._profiler.Step(this.state.callStack);\n // Is the current content object:\n // - Normal content\n // - Or a logic/flow statement - if so, do it\n // Stop flow if we hit a stack pop when we're unable to pop (e.g. return/done statement in knot\n // that was diverted to rather than called as a function)\n let currentContentObj = pointer.Resolve();\n let isLogicOrFlowControl = this.PerformLogicAndFlowControl(currentContentObj);\n // Has flow been forced to end by flow control above?\n if (this.state.currentPointer.isNull) {\n return;\n }\n if (isLogicOrFlowControl) {\n shouldAddToStream = false;\n }\n // Choice with condition?\n // var choicePoint = currentContentObj as ChoicePoint;\n let choicePoint = (0, TypeAssertion_1.asOrNull)(currentContentObj, ChoicePoint_1.ChoicePoint);\n if (choicePoint) {\n let choice = this.ProcessChoice(choicePoint);\n if (choice) {\n this.state.generatedChoices.push(choice);\n }\n currentContentObj = null;\n shouldAddToStream = false;\n }\n // If the container has no content, then it will be\n // the \"content\" itself, but we skip over it.\n if (currentContentObj instanceof Container_1.Container) {\n shouldAddToStream = false;\n }\n // Content to add to evaluation stack or the output stream\n if (shouldAddToStream) {\n // If we're pushing a variable pointer onto the evaluation stack, ensure that it's specific\n // to our current (possibly temporary) context index. And make a copy of the pointer\n // so that we're not editing the original runtime object.\n // var varPointer = currentContentObj as VariablePointerValue;\n let varPointer = (0, TypeAssertion_1.asOrNull)(currentContentObj, Value_1.VariablePointerValue);\n if (varPointer && varPointer.contextIndex == -1) {\n // Create new object so we're not overwriting the story's own data\n let contextIdx = this.state.callStack.ContextForVariableNamed(varPointer.variableName);\n currentContentObj = new Value_1.VariablePointerValue(varPointer.variableName, contextIdx);\n }\n // Expression evaluation content\n if (this.state.inExpressionEvaluation) {\n this.state.PushEvaluationStack(currentContentObj);\n }\n // Output stream content (i.e. not expression evaluation)\n else {\n this.state.PushToOutputStream(currentContentObj);\n }\n }\n // Increment the content pointer, following diverts if necessary\n this.NextContent();\n // Starting a thread should be done after the increment to the content pointer,\n // so that when returning from the thread, it returns to the content after this instruction.\n // var controlCmd = currentContentObj as ;\n let controlCmd = (0, TypeAssertion_1.asOrNull)(currentContentObj, ControlCommand_1.ControlCommand);\n if (controlCmd &&\n controlCmd.commandType == ControlCommand_1.ControlCommand.CommandType.StartThread) {\n this.state.callStack.PushThread();\n }\n }\n VisitContainer(container, atStart) {\n if (!container.countingAtStartOnly || atStart) {\n if (container.visitsShouldBeCounted)\n this.state.IncrementVisitCountForContainer(container);\n if (container.turnIndexShouldBeCounted)\n this.state.RecordTurnIndexVisitToContainer(container);\n }\n }\n VisitChangedContainersDueToDivert() {\n let previousPointer = this.state.previousPointer.copy();\n let pointer = this.state.currentPointer.copy();\n if (pointer.isNull || pointer.index == -1)\n return;\n this._prevContainers.length = 0;\n if (!previousPointer.isNull) {\n // Container prevAncestor = previousPointer.Resolve() as Container ?? previousPointer.container as Container;\n let resolvedPreviousAncestor = previousPointer.Resolve();\n let prevAncestor = (0, TypeAssertion_1.asOrNull)(resolvedPreviousAncestor, Container_1.Container) ||\n (0, TypeAssertion_1.asOrNull)(previousPointer.container, Container_1.Container);\n while (prevAncestor) {\n this._prevContainers.push(prevAncestor);\n // prevAncestor = prevAncestor.parent as Container;\n prevAncestor = (0, TypeAssertion_1.asOrNull)(prevAncestor.parent, Container_1.Container);\n }\n }\n let currentChildOfContainer = pointer.Resolve();\n if (currentChildOfContainer == null)\n return;\n // Container currentContainerAncestor = currentChildOfContainer.parent as Container;\n let currentContainerAncestor = (0, TypeAssertion_1.asOrNull)(currentChildOfContainer.parent, Container_1.Container);\n let allChildrenEnteredAtStart = true;\n while (currentContainerAncestor &&\n (this._prevContainers.indexOf(currentContainerAncestor) < 0 ||\n currentContainerAncestor.countingAtStartOnly)) {\n // Check whether this ancestor container is being entered at the start,\n // by checking whether the child object is the first.\n let enteringAtStart = currentContainerAncestor.content.length > 0 &&\n currentChildOfContainer == currentContainerAncestor.content[0] &&\n allChildrenEnteredAtStart;\n if (!enteringAtStart)\n allChildrenEnteredAtStart = false;\n // Mark a visit to this container\n this.VisitContainer(currentContainerAncestor, enteringAtStart);\n currentChildOfContainer = currentContainerAncestor;\n // currentContainerAncestor = currentContainerAncestor.parent as Container;\n currentContainerAncestor = (0, TypeAssertion_1.asOrNull)(currentContainerAncestor.parent, Container_1.Container);\n }\n }\n PopChoiceStringAndTags(tags) {\n let choiceOnlyStrVal = (0, TypeAssertion_1.asOrThrows)(this.state.PopEvaluationStack(), Value_1.StringValue);\n while (this.state.evaluationStack.length > 0 &&\n (0, TypeAssertion_1.asOrNull)(this.state.PeekEvaluationStack(), Tag_1.Tag) != null) {\n let tag = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Tag_1.Tag);\n if (tag)\n tags.push(tag.text);\n }\n return choiceOnlyStrVal.value;\n }\n ProcessChoice(choicePoint) {\n let showChoice = true;\n // Don't create choice if choice point doesn't pass conditional\n if (choicePoint.hasCondition) {\n let conditionValue = this.state.PopEvaluationStack();\n if (!this.IsTruthy(conditionValue)) {\n showChoice = false;\n }\n }\n let startText = \"\";\n let choiceOnlyText = \"\";\n let tags = [];\n if (choicePoint.hasChoiceOnlyContent) {\n choiceOnlyText = this.PopChoiceStringAndTags(tags) || \"\";\n }\n if (choicePoint.hasStartContent) {\n startText = this.PopChoiceStringAndTags(tags) || \"\";\n }\n // Don't create choice if player has already read this content\n if (choicePoint.onceOnly) {\n let visitCount = this.state.VisitCountForContainer(choicePoint.choiceTarget);\n if (visitCount > 0) {\n showChoice = false;\n }\n }\n // We go through the full process of creating the choice above so\n // that we consume the content for it, since otherwise it'll\n // be shown on the output stream.\n if (!showChoice) {\n return null;\n }\n let choice = new Choice_1.Choice();\n choice.targetPath = choicePoint.pathOnChoice;\n choice.sourcePath = choicePoint.path.toString();\n choice.isInvisibleDefault = choicePoint.isInvisibleDefault;\n choice.threadAtGeneration = this.state.callStack.ForkThread();\n choice.tags = tags.reverse(); //C# is a stack\n choice.text = (startText + choiceOnlyText).replace(/^[ \\t]+|[ \\t]+$/g, \"\");\n return choice;\n }\n IsTruthy(obj) {\n let truthy = false;\n if (obj instanceof Value_1.Value) {\n let val = obj;\n if (val instanceof Value_1.DivertTargetValue) {\n let divTarget = val;\n this.Error(\"Shouldn't use a divert target (to \" +\n divTarget.targetPath +\n \") as a conditional value. Did you intend a function call 'likeThis()' or a read count check 'likeThis'? (no arrows)\");\n return false;\n }\n return val.isTruthy;\n }\n return truthy;\n }\n PerformLogicAndFlowControl(contentObj) {\n if (contentObj == null) {\n return false;\n }\n // Divert\n if (contentObj instanceof Divert_1.Divert) {\n let currentDivert = contentObj;\n if (currentDivert.isConditional) {\n let conditionValue = this.state.PopEvaluationStack();\n // False conditional? Cancel divert\n if (!this.IsTruthy(conditionValue))\n return true;\n }\n if (currentDivert.hasVariableTarget) {\n let varName = currentDivert.variableDivertName;\n let varContents = this.state.variablesState.GetVariableWithName(varName);\n if (varContents == null) {\n this.Error(\"Tried to divert using a target from a variable that could not be found (\" +\n varName +\n \")\");\n }\n else if (!(varContents instanceof Value_1.DivertTargetValue)) {\n // var intContent = varContents as IntValue;\n let intContent = (0, TypeAssertion_1.asOrNull)(varContents, Value_1.IntValue);\n let errorMessage = \"Tried to divert to a target from a variable, but the variable (\" +\n varName +\n \") didn't contain a divert target, it \";\n if (intContent instanceof Value_1.IntValue && intContent.value == 0) {\n errorMessage += \"was empty/null (the value 0).\";\n }\n else {\n errorMessage += \"contained '\" + varContents + \"'.\";\n }\n this.Error(errorMessage);\n }\n let target = (0, TypeAssertion_1.asOrThrows)(varContents, Value_1.DivertTargetValue);\n this.state.divertedPointer = this.PointerAtPath(target.targetPath);\n }\n else if (currentDivert.isExternal) {\n this.CallExternalFunction(currentDivert.targetPathString, currentDivert.externalArgs);\n return true;\n }\n else {\n this.state.divertedPointer = currentDivert.targetPointer.copy();\n }\n if (currentDivert.pushesToStack) {\n this.state.callStack.Push(currentDivert.stackPushType, undefined, this.state.outputStream.length);\n }\n if (this.state.divertedPointer.isNull && !currentDivert.isExternal) {\n if (currentDivert &&\n currentDivert.debugMetadata &&\n currentDivert.debugMetadata.sourceName != null) {\n this.Error(\"Divert target doesn't exist: \" +\n currentDivert.debugMetadata.sourceName);\n }\n else {\n this.Error(\"Divert resolution failed: \" + currentDivert);\n }\n }\n return true;\n }\n // Start/end an expression evaluation? Or print out the result?\n else if (contentObj instanceof ControlCommand_1.ControlCommand) {\n let evalCommand = contentObj;\n switch (evalCommand.commandType) {\n case ControlCommand_1.ControlCommand.CommandType.EvalStart:\n this.Assert(this.state.inExpressionEvaluation === false, \"Already in expression evaluation?\");\n this.state.inExpressionEvaluation = true;\n break;\n case ControlCommand_1.ControlCommand.CommandType.EvalEnd:\n this.Assert(this.state.inExpressionEvaluation === true, \"Not in expression evaluation mode\");\n this.state.inExpressionEvaluation = false;\n break;\n case ControlCommand_1.ControlCommand.CommandType.EvalOutput:\n // If the expression turned out to be empty, there may not be anything on the stack\n if (this.state.evaluationStack.length > 0) {\n let output = this.state.PopEvaluationStack();\n // Functions may evaluate to Void, in which case we skip output\n if (!(output instanceof Void_1.Void)) {\n // TODO: Should we really always blanket convert to string?\n // It would be okay to have numbers in the output stream the\n // only problem is when exporting text for viewing, it skips over numbers etc.\n let text = new Value_1.StringValue(output.toString());\n this.state.PushToOutputStream(text);\n }\n }\n break;\n case ControlCommand_1.ControlCommand.CommandType.NoOp:\n break;\n case ControlCommand_1.ControlCommand.CommandType.Duplicate:\n this.state.PushEvaluationStack(this.state.PeekEvaluationStack());\n break;\n case ControlCommand_1.ControlCommand.CommandType.PopEvaluatedValue:\n this.state.PopEvaluationStack();\n break;\n case ControlCommand_1.ControlCommand.CommandType.PopFunction:\n case ControlCommand_1.ControlCommand.CommandType.PopTunnel:\n let popType = evalCommand.commandType == ControlCommand_1.ControlCommand.CommandType.PopFunction\n ? PushPop_1.PushPopType.Function\n : PushPop_1.PushPopType.Tunnel;\n let overrideTunnelReturnTarget = null;\n if (popType == PushPop_1.PushPopType.Tunnel) {\n let popped = this.state.PopEvaluationStack();\n // overrideTunnelReturnTarget = popped as DivertTargetValue;\n overrideTunnelReturnTarget = (0, TypeAssertion_1.asOrNull)(popped, Value_1.DivertTargetValue);\n if (overrideTunnelReturnTarget === null) {\n this.Assert(popped instanceof Void_1.Void, \"Expected void if ->-> doesn't override target\");\n }\n }\n if (this.state.TryExitFunctionEvaluationFromGame()) {\n break;\n }\n else if (this.state.callStack.currentElement.type != popType ||\n !this.state.callStack.canPop) {\n let names = new Map();\n names.set(PushPop_1.PushPopType.Function, \"function return statement (~ return)\");\n names.set(PushPop_1.PushPopType.Tunnel, \"tunnel onwards statement (->->)\");\n let expected = names.get(this.state.callStack.currentElement.type);\n if (!this.state.callStack.canPop) {\n expected = \"end of flow (-> END or choice)\";\n }\n let errorMsg = \"Found \" + names.get(popType) + \", when expected \" + expected;\n this.Error(errorMsg);\n }\n else {\n this.state.PopCallStack();\n if (overrideTunnelReturnTarget)\n this.state.divertedPointer = this.PointerAtPath(overrideTunnelReturnTarget.targetPath);\n }\n break;\n case ControlCommand_1.ControlCommand.CommandType.BeginString:\n this.state.PushToOutputStream(evalCommand);\n this.Assert(this.state.inExpressionEvaluation === true, \"Expected to be in an expression when evaluating a string\");\n this.state.inExpressionEvaluation = false;\n break;\n // Leave it to story.currentText and story.currentTags to sort out the text from the tags\n // This is mostly because we can't always rely on the existence of EndTag, and we don't want\n // to try and flatten dynamic tags to strings every time \\n is pushed to output\n case ControlCommand_1.ControlCommand.CommandType.BeginTag:\n this.state.PushToOutputStream(evalCommand);\n break;\n // EndTag has 2 modes:\n // - When in string evaluation (for choices)\n // - Normal\n //\n // The only way you could have an EndTag in the middle of\n // string evaluation is if we're currently generating text for a\n // choice, such as:\n //\n // + choice # tag\n //\n // In the above case, the ink will be run twice:\n // - First, to generate the choice text. String evaluation\n // will be on, and the final string will be pushed to the\n // evaluation stack, ready to be popped to make a Choice\n // object.\n // - Second, when ink generates text after choosing the choice.\n // On this ocassion, it's not in string evaluation mode.\n //\n // On the writing side, we disallow manually putting tags within\n // strings like this:\n //\n // {\"hello # world\"}\n //\n // So we know that the tag must be being generated as part of\n // choice content. Therefore, when the tag has been generated,\n // we push it onto the evaluation stack in the exact same way\n // as the string for the choice content.\n case ControlCommand_1.ControlCommand.CommandType.EndTag: {\n if (this.state.inStringEvaluation) {\n let contentStackForTag = [];\n let outputCountConsumed = 0;\n for (let i = this.state.outputStream.length - 1; i >= 0; --i) {\n let obj = this.state.outputStream[i];\n outputCountConsumed++;\n // var command = obj as ControlCommand;\n let command = (0, TypeAssertion_1.asOrNull)(obj, ControlCommand_1.ControlCommand);\n if (command != null) {\n if (command.commandType == ControlCommand_1.ControlCommand.CommandType.BeginTag) {\n break;\n }\n else {\n this.Error(\"Unexpected ControlCommand while extracting tag from choice\");\n break;\n }\n }\n if (obj instanceof Value_1.StringValue) {\n contentStackForTag.push(obj);\n }\n }\n // Consume the content that was produced for this string\n this.state.PopFromOutputStream(outputCountConsumed);\n // Build string out of the content we collected\n let sb = new StringBuilder_1.StringBuilder();\n for (let strVal of contentStackForTag.reverse()) {\n sb.Append(strVal.toString());\n }\n let choiceTag = new Tag_1.Tag(this.state.CleanOutputWhitespace(sb.toString()));\n // Pushing to the evaluation stack means it gets picked up\n // when a Choice is generated from the next Choice Point.\n this.state.PushEvaluationStack(choiceTag);\n }\n else {\n // Otherwise! Simply push EndTag, so that in the output stream we\n // have a structure of: [BeginTag, \"the tag content\", EndTag]\n this.state.PushToOutputStream(evalCommand);\n }\n break;\n }\n case ControlCommand_1.ControlCommand.CommandType.EndString: {\n let contentStackForString = [];\n let contentToRetain = [];\n let outputCountConsumed = 0;\n for (let i = this.state.outputStream.length - 1; i >= 0; --i) {\n let obj = this.state.outputStream[i];\n outputCountConsumed++;\n // var command = obj as ControlCommand;\n let command = (0, TypeAssertion_1.asOrNull)(obj, ControlCommand_1.ControlCommand);\n if (command &&\n command.commandType == ControlCommand_1.ControlCommand.CommandType.BeginString) {\n break;\n }\n if (obj instanceof Tag_1.Tag) {\n contentToRetain.push(obj);\n }\n if (obj instanceof Value_1.StringValue) {\n contentStackForString.push(obj);\n }\n }\n // Consume the content that was produced for this string\n this.state.PopFromOutputStream(outputCountConsumed);\n // Rescue the tags that we want actually to keep on the output stack\n // rather than consume as part of the string we're building.\n // At the time of writing, this only applies to Tag objects generated\n // by choices, which are pushed to the stack during string generation.\n for (let rescuedTag of contentToRetain)\n this.state.PushToOutputStream(rescuedTag);\n // The C# version uses a Stack for contentStackForString, but we're\n // using a simple array, so we need to reverse it before using it\n contentStackForString = contentStackForString.reverse();\n // Build string out of the content we collected\n let sb = new StringBuilder_1.StringBuilder();\n for (let c of contentStackForString) {\n sb.Append(c.toString());\n }\n // Return to expression evaluation (from content mode)\n this.state.inExpressionEvaluation = true;\n this.state.PushEvaluationStack(new Value_1.StringValue(sb.toString()));\n break;\n }\n case ControlCommand_1.ControlCommand.CommandType.ChoiceCount:\n let choiceCount = this.state.generatedChoices.length;\n this.state.PushEvaluationStack(new Value_1.IntValue(choiceCount));\n break;\n case ControlCommand_1.ControlCommand.CommandType.Turns:\n this.state.PushEvaluationStack(new Value_1.IntValue(this.state.currentTurnIndex + 1));\n break;\n case ControlCommand_1.ControlCommand.CommandType.TurnsSince:\n case ControlCommand_1.ControlCommand.CommandType.ReadCount:\n let target = this.state.PopEvaluationStack();\n if (!(target instanceof Value_1.DivertTargetValue)) {\n let extraNote = \"\";\n if (target instanceof Value_1.IntValue)\n extraNote =\n \". Did you accidentally pass a read count ('knot_name') instead of a target ('-> knot_name')?\";\n this.Error(\"TURNS_SINCE / READ_COUNT expected a divert target (knot, stitch, label name), but saw \" +\n target +\n extraNote);\n break;\n }\n // var divertTarget = target as DivertTargetValue;\n let divertTarget = (0, TypeAssertion_1.asOrThrows)(target, Value_1.DivertTargetValue);\n // var container = ContentAtPath (divertTarget.targetPath).correctObj as Container;\n let container = (0, TypeAssertion_1.asOrNull)(this.ContentAtPath(divertTarget.targetPath).correctObj, Container_1.Container);\n let eitherCount;\n if (container != null) {\n if (evalCommand.commandType == ControlCommand_1.ControlCommand.CommandType.TurnsSince)\n eitherCount = this.state.TurnsSinceForContainer(container);\n else\n eitherCount = this.state.VisitCountForContainer(container);\n }\n else {\n if (evalCommand.commandType == ControlCommand_1.ControlCommand.CommandType.TurnsSince)\n eitherCount = -1;\n else\n eitherCount = 0;\n this.Warning(\"Failed to find container for \" +\n evalCommand.toString() +\n \" lookup at \" +\n divertTarget.targetPath.toString());\n }\n this.state.PushEvaluationStack(new Value_1.IntValue(eitherCount));\n break;\n case ControlCommand_1.ControlCommand.CommandType.Random: {\n let maxInt = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.IntValue);\n let minInt = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.IntValue);\n if (minInt == null || minInt instanceof Value_1.IntValue === false)\n return this.Error(\"Invalid value for minimum parameter of RANDOM(min, max)\");\n if (maxInt == null || maxInt instanceof Value_1.IntValue === false)\n return this.Error(\"Invalid value for maximum parameter of RANDOM(min, max)\");\n // Originally a primitive type, but here, can be null.\n // TODO: Replace by default value?\n if (maxInt.value === null) {\n return (0, NullException_1.throwNullException)(\"maxInt.value\");\n }\n if (minInt.value === null) {\n return (0, NullException_1.throwNullException)(\"minInt.value\");\n }\n // This code is differs a bit from the reference implementation, since\n // JavaScript has no true integers. Hence integer arithmetics and\n // interger overflows don't apply here. A loss of precision can\n // happen with big numbers however.\n //\n // The case where 'randomRange' is lower than zero is handled below,\n // so there's no need to test against Number.MIN_SAFE_INTEGER.\n let randomRange = maxInt.value - minInt.value + 1;\n if (!isFinite(randomRange) || randomRange > Number.MAX_SAFE_INTEGER) {\n randomRange = Number.MAX_SAFE_INTEGER;\n this.Error(\"RANDOM was called with a range that exceeds the size that ink numbers can use.\");\n }\n if (randomRange <= 0)\n this.Error(\"RANDOM was called with minimum as \" +\n minInt.value +\n \" and maximum as \" +\n maxInt.value +\n \". The maximum must be larger\");\n let resultSeed = this.state.storySeed + this.state.previousRandom;\n let random = new PRNG_1.PRNG(resultSeed);\n let nextRandom = random.next();\n let chosenValue = (nextRandom % randomRange) + minInt.value;\n this.state.PushEvaluationStack(new Value_1.IntValue(chosenValue));\n // Next random number (rather than keeping the Random object around)\n this.state.previousRandom = nextRandom;\n break;\n }\n case ControlCommand_1.ControlCommand.CommandType.SeedRandom:\n let seed = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.IntValue);\n if (seed == null || seed instanceof Value_1.IntValue === false)\n return this.Error(\"Invalid value passed to SEED_RANDOM\");\n // Originally a primitive type, but here, can be null.\n // TODO: Replace by default value?\n if (seed.value === null) {\n return (0, NullException_1.throwNullException)(\"minInt.value\");\n }\n this.state.storySeed = seed.value;\n this.state.previousRandom = 0;\n this.state.PushEvaluationStack(new Void_1.Void());\n break;\n case ControlCommand_1.ControlCommand.CommandType.VisitIndex:\n let count = this.state.VisitCountForContainer(this.state.currentPointer.container) - 1; // index not count\n this.state.PushEvaluationStack(new Value_1.IntValue(count));\n break;\n case ControlCommand_1.ControlCommand.CommandType.SequenceShuffleIndex:\n let shuffleIndex = this.NextSequenceShuffleIndex();\n this.state.PushEvaluationStack(new Value_1.IntValue(shuffleIndex));\n break;\n case ControlCommand_1.ControlCommand.CommandType.StartThread:\n // Handled in main step function\n break;\n case ControlCommand_1.ControlCommand.CommandType.Done:\n // We may exist in the context of the initial\n // act of creating the thread, or in the context of\n // evaluating the content.\n if (this.state.callStack.canPopThread) {\n this.state.callStack.PopThread();\n }\n // In normal flow - allow safe exit without warning\n else {\n this.state.didSafeExit = true;\n // Stop flow in current thread\n this.state.currentPointer = Pointer_1.Pointer.Null;\n }\n break;\n // Force flow to end completely\n case ControlCommand_1.ControlCommand.CommandType.End:\n this.state.ForceEnd();\n break;\n case ControlCommand_1.ControlCommand.CommandType.ListFromInt:\n // var intVal = state.PopEvaluationStack () as IntValue;\n let intVal = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.IntValue);\n // var listNameVal = state.PopEvaluationStack () as StringValue;\n let listNameVal = (0, TypeAssertion_1.asOrThrows)(this.state.PopEvaluationStack(), Value_1.StringValue);\n if (intVal === null) {\n throw new StoryException_1.StoryException(\"Passed non-integer when creating a list element from a numerical value.\");\n }\n let generatedListValue = null;\n if (this.listDefinitions === null) {\n return (0, NullException_1.throwNullException)(\"this.listDefinitions\");\n }\n let foundListDef = this.listDefinitions.TryListGetDefinition(listNameVal.value, null);\n if (foundListDef.exists) {\n // Originally a primitive type, but here, can be null.\n // TODO: Replace by default value?\n if (intVal.value === null) {\n return (0, NullException_1.throwNullException)(\"minInt.value\");\n }\n let foundItem = foundListDef.result.TryGetItemWithValue(intVal.value, InkList_1.InkListItem.Null);\n if (foundItem.exists) {\n generatedListValue = new Value_1.ListValue(foundItem.result, intVal.value);\n }\n }\n else {\n throw new StoryException_1.StoryException(\"Failed to find LIST called \" + listNameVal.value);\n }\n if (generatedListValue == null)\n generatedListValue = new Value_1.ListValue();\n this.state.PushEvaluationStack(generatedListValue);\n break;\n case ControlCommand_1.ControlCommand.CommandType.ListRange:\n let max = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.Value);\n let min = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.Value);\n // var targetList = state.PopEvaluationStack () as ListValue;\n let targetList = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.ListValue);\n if (targetList === null || min === null || max === null)\n throw new StoryException_1.StoryException(\"Expected list, minimum and maximum for LIST_RANGE\");\n if (targetList.value === null) {\n return (0, NullException_1.throwNullException)(\"targetList.value\");\n }\n let result = targetList.value.ListWithSubRange(min.valueObject, max.valueObject);\n this.state.PushEvaluationStack(new Value_1.ListValue(result));\n break;\n case ControlCommand_1.ControlCommand.CommandType.ListRandom: {\n let listVal = this.state.PopEvaluationStack();\n if (listVal === null)\n throw new StoryException_1.StoryException(\"Expected list for LIST_RANDOM\");\n let list = listVal.value;\n let newList = null;\n if (list === null) {\n throw (0, NullException_1.throwNullException)(\"list\");\n }\n if (list.Count == 0) {\n newList = new InkList_1.InkList();\n }\n else {\n // Generate a random index for the element to take\n let resultSeed = this.state.storySeed + this.state.previousRandom;\n let random = new PRNG_1.PRNG(resultSeed);\n let nextRandom = random.next();\n let listItemIndex = nextRandom % list.Count;\n // This bit is a little different from the original\n // C# code, since iterators do not work in the same way.\n // First, we iterate listItemIndex - 1 times, calling next().\n // The listItemIndex-th time is made outside of the loop,\n // in order to retrieve the value.\n let listEnumerator = list.entries();\n for (let i = 0; i <= listItemIndex - 1; i++) {\n listEnumerator.next();\n }\n let value = listEnumerator.next().value;\n let randomItem = {\n Key: InkList_1.InkListItem.fromSerializedKey(value[0]),\n Value: value[1],\n };\n // Origin list is simply the origin of the one element\n if (randomItem.Key.originName === null) {\n return (0, NullException_1.throwNullException)(\"randomItem.Key.originName\");\n }\n newList = new InkList_1.InkList(randomItem.Key.originName, this);\n newList.Add(randomItem.Key, randomItem.Value);\n this.state.previousRandom = nextRandom;\n }\n this.state.PushEvaluationStack(new Value_1.ListValue(newList));\n break;\n }\n default:\n this.Error(\"unhandled ControlCommand: \" + evalCommand);\n break;\n }\n return true;\n }\n // Variable assignment\n else if (contentObj instanceof VariableAssignment_1.VariableAssignment) {\n let varAss = contentObj;\n let assignedVal = this.state.PopEvaluationStack();\n this.state.variablesState.Assign(varAss, assignedVal);\n return true;\n }\n // Variable reference\n else if (contentObj instanceof VariableReference_1.VariableReference) {\n let varRef = contentObj;\n let foundValue = null;\n // Explicit read count value\n if (varRef.pathForCount != null) {\n let container = varRef.containerForCount;\n let count = this.state.VisitCountForContainer(container);\n foundValue = new Value_1.IntValue(count);\n }\n // Normal variable reference\n else {\n foundValue = this.state.variablesState.GetVariableWithName(varRef.name);\n if (foundValue == null) {\n this.Warning(\"Variable not found: '\" +\n varRef.name +\n \"'. Using default value of 0 (false). This can happen with temporary variables if the declaration hasn't yet been hit. Globals are always given a default value on load if a value doesn't exist in the save state.\");\n foundValue = new Value_1.IntValue(0);\n }\n }\n this.state.PushEvaluationStack(foundValue);\n return true;\n }\n // Native function call\n else if (contentObj instanceof NativeFunctionCall_1.NativeFunctionCall) {\n let func = contentObj;\n let funcParams = this.state.PopEvaluationStack(func.numberOfParameters);\n let result = func.Call(funcParams);\n this.state.PushEvaluationStack(result);\n return true;\n }\n // No control content, must be ordinary content\n return false;\n }\n ChoosePathString(path, resetCallstack = true, args = []) {\n this.IfAsyncWeCant(\"call ChoosePathString right now\");\n if (this.onChoosePathString !== null)\n this.onChoosePathString(path, args);\n if (resetCallstack) {\n this.ResetCallstack();\n }\n else {\n if (this.state.callStack.currentElement.type == PushPop_1.PushPopType.Function) {\n let funcDetail = \"\";\n let container = this.state.callStack.currentElement.currentPointer.container;\n if (container != null) {\n funcDetail = \"(\" + container.path.toString() + \") \";\n }\n throw new Error(\"Story was running a function \" +\n funcDetail +\n \"when you called ChoosePathString(\" +\n path +\n \") - this is almost certainly not not what you want! Full stack trace: \\n\" +\n this.state.callStack.callStackTrace);\n }\n }\n this.state.PassArgumentsToEvaluationStack(args);\n this.ChoosePath(new Path_1.Path(path));\n }\n IfAsyncWeCant(activityStr) {\n if (this._asyncContinueActive)\n throw new Error(\"Can't \" +\n activityStr +\n \". Story is in the middle of a ContinueAsync(). Make more ContinueAsync() calls or a single Continue() call beforehand.\");\n }\n ChoosePath(p, incrementingTurnIndex = true) {\n this.state.SetChosenPath(p, incrementingTurnIndex);\n // Take a note of newly visited containers for read counts etc\n this.VisitChangedContainersDueToDivert();\n }\n ChooseChoiceIndex(choiceIdx) {\n choiceIdx = choiceIdx;\n let choices = this.currentChoices;\n this.Assert(choiceIdx >= 0 && choiceIdx < choices.length, \"choice out of range\");\n let choiceToChoose = choices[choiceIdx];\n if (this.onMakeChoice !== null)\n this.onMakeChoice(choiceToChoose);\n if (choiceToChoose.threadAtGeneration === null) {\n return (0, NullException_1.throwNullException)(\"choiceToChoose.threadAtGeneration\");\n }\n if (choiceToChoose.targetPath === null) {\n return (0, NullException_1.throwNullException)(\"choiceToChoose.targetPath\");\n }\n this.state.callStack.currentThread = choiceToChoose.threadAtGeneration;\n this.ChoosePath(choiceToChoose.targetPath);\n }\n HasFunction(functionName) {\n try {\n return this.KnotContainerWithName(functionName) != null;\n }\n catch (e) {\n return false;\n }\n }\n EvaluateFunction(functionName, args = [], returnTextOutput = false) {\n // EvaluateFunction behaves slightly differently than the C# version.\n // In C#, you can pass a (second) parameter `out textOutput` to get the\n // text outputted by the function. This is not possible in js. Instead,\n // we maintain the regular signature (functionName, args), plus an\n // optional third parameter returnTextOutput. If set to true, we will\n // return both the textOutput and the returned value, as an object.\n if (this.onEvaluateFunction !== null)\n this.onEvaluateFunction(functionName, args);\n this.IfAsyncWeCant(\"evaluate a function\");\n if (functionName == null) {\n throw new Error(\"Function is null\");\n }\n else if (functionName == \"\" || functionName.trim() == \"\") {\n throw new Error(\"Function is empty or white space.\");\n }\n let funcContainer = this.KnotContainerWithName(functionName);\n if (funcContainer == null) {\n throw new Error(\"Function doesn't exist: '\" + functionName + \"'\");\n }\n let outputStreamBefore = [];\n outputStreamBefore.push(...this.state.outputStream);\n this._state.ResetOutput();\n this.state.StartFunctionEvaluationFromGame(funcContainer, args);\n // Evaluate the function, and collect the string output\n let stringOutput = new StringBuilder_1.StringBuilder();\n while (this.canContinue) {\n stringOutput.Append(this.Continue());\n }\n let textOutput = stringOutput.toString();\n this._state.ResetOutput(outputStreamBefore);\n let result = this.state.CompleteFunctionEvaluationFromGame();\n if (this.onCompleteEvaluateFunction != null)\n this.onCompleteEvaluateFunction(functionName, args, textOutput, result);\n return returnTextOutput ? { returned: result, output: textOutput } : result;\n }\n EvaluateExpression(exprContainer) {\n let startCallStackHeight = this.state.callStack.elements.length;\n this.state.callStack.Push(PushPop_1.PushPopType.Tunnel);\n this._temporaryEvaluationContainer = exprContainer;\n this.state.GoToStart();\n let evalStackHeight = this.state.evaluationStack.length;\n this.Continue();\n this._temporaryEvaluationContainer = null;\n // Should have fallen off the end of the Container, which should\n // have auto-popped, but just in case we didn't for some reason,\n // manually pop to restore the state (including currentPath).\n if (this.state.callStack.elements.length > startCallStackHeight) {\n this.state.PopCallStack();\n }\n let endStackHeight = this.state.evaluationStack.length;\n if (endStackHeight > evalStackHeight) {\n return this.state.PopEvaluationStack();\n }\n else {\n return null;\n }\n }\n CallExternalFunction(funcName, numberOfArguments) {\n if (funcName === null) {\n return (0, NullException_1.throwNullException)(\"funcName\");\n }\n let funcDef = this._externals.get(funcName);\n let fallbackFunctionContainer = null;\n let foundExternal = typeof funcDef !== \"undefined\";\n if (foundExternal &&\n !funcDef.lookAheadSafe &&\n this._state.inStringEvaluation) {\n this.Error(\"External function \" +\n funcName +\n ' could not be called because 1) it wasn\\'t marked as lookaheadSafe when BindExternalFunction was called and 2) the story is in the middle of string generation, either because choice text is being generated, or because you have ink like \"hello {func()}\". You can work around this by generating the result of your function into a temporary variable before the string or choice gets generated: ~ temp x = ' +\n funcName +\n \"()\");\n }\n if (foundExternal &&\n !funcDef.lookAheadSafe &&\n this._stateSnapshotAtLastNewline !== null) {\n this._sawLookaheadUnsafeFunctionAfterNewline = true;\n return;\n }\n if (!foundExternal) {\n if (this.allowExternalFunctionFallbacks) {\n fallbackFunctionContainer = this.KnotContainerWithName(funcName);\n this.Assert(fallbackFunctionContainer !== null, \"Trying to call EXTERNAL function '\" +\n funcName +\n \"' which has not been bound, and fallback ink function could not be found.\");\n // Divert direct into fallback function and we're done\n this.state.callStack.Push(PushPop_1.PushPopType.Function, undefined, this.state.outputStream.length);\n this.state.divertedPointer = Pointer_1.Pointer.StartOf(fallbackFunctionContainer);\n return;\n }\n else {\n this.Assert(false, \"Trying to call EXTERNAL function '\" +\n funcName +\n \"' which has not been bound (and ink fallbacks disabled).\");\n }\n }\n // Pop arguments\n let args = [];\n for (let i = 0; i < numberOfArguments; ++i) {\n // var poppedObj = state.PopEvaluationStack () as Value;\n let poppedObj = (0, TypeAssertion_1.asOrThrows)(this.state.PopEvaluationStack(), Value_1.Value);\n let valueObj = poppedObj.valueObject;\n args.push(valueObj);\n }\n // Reverse arguments from the order they were popped,\n // so they're the right way round again.\n args.reverse();\n // Run the function!\n let funcResult = funcDef.function(args);\n // Convert return value (if any) to the a type that the ink engine can use\n let returnObj = null;\n if (funcResult != null) {\n returnObj = Value_1.Value.Create(funcResult);\n this.Assert(returnObj !== null, \"Could not create ink value from returned object of type \" +\n typeof funcResult);\n }\n else {\n returnObj = new Void_1.Void();\n }\n this.state.PushEvaluationStack(returnObj);\n }\n BindExternalFunctionGeneral(funcName, func, lookaheadSafe = true) {\n this.IfAsyncWeCant(\"bind an external function\");\n this.Assert(!this._externals.has(funcName), \"Function '\" + funcName + \"' has already been bound.\");\n this._externals.set(funcName, {\n function: func,\n lookAheadSafe: lookaheadSafe,\n });\n }\n TryCoerce(value) {\n // We're skipping type coercition in this implementation. First of, js\n // is loosely typed, so it's not that important. Secondly, there is no\n // clean way (AFAIK) for the user to describe what type of parameters\n // they expect.\n return value;\n }\n BindExternalFunction(funcName, func, lookaheadSafe = false) {\n this.Assert(func != null, \"Can't bind a null function\");\n this.BindExternalFunctionGeneral(funcName, (args) => {\n this.Assert(args.length >= func.length, \"External function expected \" + func.length + \" arguments\");\n let coercedArgs = [];\n for (let i = 0, l = args.length; i < l; i++) {\n coercedArgs[i] = this.TryCoerce(args[i]);\n }\n return func.apply(null, coercedArgs);\n }, lookaheadSafe);\n }\n UnbindExternalFunction(funcName) {\n this.IfAsyncWeCant(\"unbind an external a function\");\n this.Assert(this._externals.has(funcName), \"Function '\" + funcName + \"' has not been bound.\");\n this._externals.delete(funcName);\n }\n ValidateExternalBindings() {\n let c = null;\n let o = null;\n let missingExternals = arguments[1] || new Set();\n if (arguments[0] instanceof Container_1.Container) {\n c = arguments[0];\n }\n if (arguments[0] instanceof Object_1.InkObject) {\n o = arguments[0];\n }\n if (c === null && o === null) {\n this.ValidateExternalBindings(this._mainContentContainer, missingExternals);\n this._hasValidatedExternals = true;\n // No problem! Validation complete\n if (missingExternals.size == 0) {\n this._hasValidatedExternals = true;\n }\n else {\n let message = \"Error: Missing function binding for external\";\n message += missingExternals.size > 1 ? \"s\" : \"\";\n message += \": '\";\n message += Array.from(missingExternals).join(\"', '\");\n message += \"' \";\n message += this.allowExternalFunctionFallbacks\n ? \", and no fallback ink function found.\"\n : \" (ink fallbacks disabled)\";\n this.Error(message);\n }\n }\n else if (c != null) {\n for (let innerContent of c.content) {\n let container = innerContent;\n if (container == null || !container.hasValidName)\n this.ValidateExternalBindings(innerContent, missingExternals);\n }\n for (let [, value] of c.namedContent) {\n this.ValidateExternalBindings((0, TypeAssertion_1.asOrNull)(value, Object_1.InkObject), missingExternals);\n }\n }\n else if (o != null) {\n let divert = (0, TypeAssertion_1.asOrNull)(o, Divert_1.Divert);\n if (divert && divert.isExternal) {\n let name = divert.targetPathString;\n if (name === null) {\n return (0, NullException_1.throwNullException)(\"name\");\n }\n if (!this._externals.has(name)) {\n if (this.allowExternalFunctionFallbacks) {\n let fallbackFound = this.mainContentContainer.namedContent.has(name);\n if (!fallbackFound) {\n missingExternals.add(name);\n }\n }\n else {\n missingExternals.add(name);\n }\n }\n }\n }\n }\n ObserveVariable(variableName, observer) {\n this.IfAsyncWeCant(\"observe a new variable\");\n if (this._variableObservers === null)\n this._variableObservers = new Map();\n if (!this.state.variablesState.GlobalVariableExistsWithName(variableName))\n throw new Error(\"Cannot observe variable '\" +\n variableName +\n \"' because it wasn't declared in the ink story.\");\n if (this._variableObservers.has(variableName)) {\n this._variableObservers.get(variableName).push(observer);\n }\n else {\n this._variableObservers.set(variableName, [observer]);\n }\n }\n ObserveVariables(variableNames, observers) {\n for (let i = 0, l = variableNames.length; i < l; i++) {\n this.ObserveVariable(variableNames[i], observers[i]);\n }\n }\n RemoveVariableObserver(observer, specificVariableName) {\n // A couple of things to know about this method:\n //\n // 1. Since `RemoveVariableObserver` is exposed to the JavaScript world,\n // optionality is marked as `undefined` rather than `null`.\n // To keep things simple, null-checks are performed using regular\n // equality operators, where undefined == null.\n //\n // 2. Since C# delegates are translated to arrays of functions,\n // -= becomes a call to splice and null-checks are replaced by\n // emptiness-checks.\n //\n this.IfAsyncWeCant(\"remove a variable observer\");\n if (this._variableObservers === null)\n return;\n if (specificVariableName != null) {\n if (this._variableObservers.has(specificVariableName)) {\n if (observer != null) {\n let variableObservers = this._variableObservers.get(specificVariableName);\n if (variableObservers != null) {\n variableObservers.splice(variableObservers.indexOf(observer), 1);\n if (variableObservers.length === 0) {\n this._variableObservers.delete(specificVariableName);\n }\n }\n }\n else {\n this._variableObservers.delete(specificVariableName);\n }\n }\n }\n else if (observer != null) {\n let keys = this._variableObservers.keys();\n for (let varName of keys) {\n let variableObservers = this._variableObservers.get(varName);\n if (variableObservers != null) {\n variableObservers.splice(variableObservers.indexOf(observer), 1);\n if (variableObservers.length === 0) {\n this._variableObservers.delete(varName);\n }\n }\n }\n }\n }\n VariableStateDidChangeEvent(variableName, newValueObj) {\n if (this._variableObservers === null)\n return;\n let observers = this._variableObservers.get(variableName);\n if (typeof observers !== \"undefined\") {\n if (!(newValueObj instanceof Value_1.Value)) {\n throw new Error(\"Tried to get the value of a variable that isn't a standard type\");\n }\n // var val = newValueObj as Value;\n let val = (0, TypeAssertion_1.asOrThrows)(newValueObj, Value_1.Value);\n for (let observer of observers) {\n observer(variableName, val.valueObject);\n }\n }\n }\n get globalTags() {\n return this.TagsAtStartOfFlowContainerWithPathString(\"\");\n }\n TagsForContentAtPath(path) {\n return this.TagsAtStartOfFlowContainerWithPathString(path);\n }\n TagsAtStartOfFlowContainerWithPathString(pathString) {\n let path = new Path_1.Path(pathString);\n let flowContainer = this.ContentAtPath(path).container;\n if (flowContainer === null) {\n return (0, NullException_1.throwNullException)(\"flowContainer\");\n }\n while (true) {\n let firstContent = flowContainer.content[0];\n if (firstContent instanceof Container_1.Container)\n flowContainer = firstContent;\n else\n break;\n }\n let inTag = false;\n let tags = null;\n for (let c of flowContainer.content) {\n // var tag = c as Runtime.Tag;\n let command = (0, TypeAssertion_1.asOrNull)(c, ControlCommand_1.ControlCommand);\n if (command != null) {\n if (command.commandType == ControlCommand_1.ControlCommand.CommandType.BeginTag) {\n inTag = true;\n }\n else if (command.commandType == ControlCommand_1.ControlCommand.CommandType.EndTag) {\n inTag = false;\n }\n }\n else if (inTag) {\n let str = (0, TypeAssertion_1.asOrNull)(c, Value_1.StringValue);\n if (str !== null) {\n if (tags === null)\n tags = [];\n if (str.value !== null)\n tags.push(str.value);\n }\n else {\n this.Error(\"Tag contained non-text content. Only plain text is allowed when using globalTags or TagsAtContentPath. If you want to evaluate dynamic content, you need to use story.Continue().\");\n }\n }\n else {\n break;\n }\n }\n return tags;\n }\n BuildStringOfHierarchy() {\n let sb = new StringBuilder_1.StringBuilder();\n this.mainContentContainer.BuildStringOfHierarchy(sb, 0, this.state.currentPointer.Resolve());\n return sb.toString();\n }\n BuildStringOfContainer(container) {\n let sb = new StringBuilder_1.StringBuilder();\n container.BuildStringOfHierarchy(sb, 0, this.state.currentPointer.Resolve());\n return sb.toString();\n }\n NextContent() {\n this.state.previousPointer = this.state.currentPointer.copy();\n if (!this.state.divertedPointer.isNull) {\n this.state.currentPointer = this.state.divertedPointer.copy();\n this.state.divertedPointer = Pointer_1.Pointer.Null;\n this.VisitChangedContainersDueToDivert();\n if (!this.state.currentPointer.isNull) {\n return;\n }\n }\n let successfulPointerIncrement = this.IncrementContentPointer();\n if (!successfulPointerIncrement) {\n let didPop = false;\n if (this.state.callStack.CanPop(PushPop_1.PushPopType.Function)) {\n this.state.PopCallStack(PushPop_1.PushPopType.Function);\n if (this.state.inExpressionEvaluation) {\n this.state.PushEvaluationStack(new Void_1.Void());\n }\n didPop = true;\n }\n else if (this.state.callStack.canPopThread) {\n this.state.callStack.PopThread();\n didPop = true;\n }\n else {\n this.state.TryExitFunctionEvaluationFromGame();\n }\n if (didPop && !this.state.currentPointer.isNull) {\n this.NextContent();\n }\n }\n }\n IncrementContentPointer() {\n let successfulIncrement = true;\n let pointer = this.state.callStack.currentElement.currentPointer.copy();\n pointer.index++;\n if (pointer.container === null) {\n return (0, NullException_1.throwNullException)(\"pointer.container\");\n }\n while (pointer.index >= pointer.container.content.length) {\n successfulIncrement = false;\n // Container nextAncestor = pointer.container.parent as Container;\n let nextAncestor = (0, TypeAssertion_1.asOrNull)(pointer.container.parent, Container_1.Container);\n if (nextAncestor instanceof Container_1.Container === false) {\n break;\n }\n let indexInAncestor = nextAncestor.content.indexOf(pointer.container);\n if (indexInAncestor == -1) {\n break;\n }\n pointer = new Pointer_1.Pointer(nextAncestor, indexInAncestor);\n pointer.index++;\n successfulIncrement = true;\n if (pointer.container === null) {\n return (0, NullException_1.throwNullException)(\"pointer.container\");\n }\n }\n if (!successfulIncrement)\n pointer = Pointer_1.Pointer.Null;\n this.state.callStack.currentElement.currentPointer = pointer.copy();\n return successfulIncrement;\n }\n TryFollowDefaultInvisibleChoice() {\n let allChoices = this._state.currentChoices;\n let invisibleChoices = allChoices.filter((c) => c.isInvisibleDefault);\n if (invisibleChoices.length == 0 ||\n allChoices.length > invisibleChoices.length)\n return false;\n let choice = invisibleChoices[0];\n if (choice.targetPath === null) {\n return (0, NullException_1.throwNullException)(\"choice.targetPath\");\n }\n if (choice.threadAtGeneration === null) {\n return (0, NullException_1.throwNullException)(\"choice.threadAtGeneration\");\n }\n this.state.callStack.currentThread = choice.threadAtGeneration;\n if (this._stateSnapshotAtLastNewline !== null) {\n this.state.callStack.currentThread = this.state.callStack.ForkThread();\n }\n this.ChoosePath(choice.targetPath, false);\n return true;\n }\n NextSequenceShuffleIndex() {\n // var numElementsIntVal = state.PopEvaluationStack () as IntValue;\n let numElementsIntVal = (0, TypeAssertion_1.asOrNull)(this.state.PopEvaluationStack(), Value_1.IntValue);\n if (!(numElementsIntVal instanceof Value_1.IntValue)) {\n this.Error(\"expected number of elements in sequence for shuffle index\");\n return 0;\n }\n let seqContainer = this.state.currentPointer.container;\n if (seqContainer === null) {\n return (0, NullException_1.throwNullException)(\"seqContainer\");\n }\n // Originally a primitive type, but here, can be null.\n // TODO: Replace by default value?\n if (numElementsIntVal.value === null) {\n return (0, NullException_1.throwNullException)(\"numElementsIntVal.value\");\n }\n let numElements = numElementsIntVal.value;\n // var seqCountVal = state.PopEvaluationStack () as IntValue;\n let seqCountVal = (0, TypeAssertion_1.asOrThrows)(this.state.PopEvaluationStack(), Value_1.IntValue);\n let seqCount = seqCountVal.value;\n // Originally a primitive type, but here, can be null.\n // TODO: Replace by default value?\n if (seqCount === null) {\n return (0, NullException_1.throwNullException)(\"seqCount\");\n }\n let loopIndex = seqCount / numElements;\n let iterationIndex = seqCount % numElements;\n let seqPathStr = seqContainer.path.toString();\n let sequenceHash = 0;\n for (let i = 0, l = seqPathStr.length; i < l; i++) {\n sequenceHash += seqPathStr.charCodeAt(i) || 0;\n }\n let randomSeed = sequenceHash + loopIndex + this.state.storySeed;\n let random = new PRNG_1.PRNG(Math.floor(randomSeed));\n let unpickedIndices = [];\n for (let i = 0; i < numElements; ++i) {\n unpickedIndices.push(i);\n }\n for (let i = 0; i <= iterationIndex; ++i) {\n let chosen = random.next() % unpickedIndices.length;\n let chosenIndex = unpickedIndices[chosen];\n unpickedIndices.splice(chosen, 1);\n if (i == iterationIndex) {\n return chosenIndex;\n }\n }\n throw new Error(\"Should never reach here\");\n }\n Error(message, useEndLineNumber = false) {\n let e = new StoryException_1.StoryException(message);\n e.useEndLineNumber = useEndLineNumber;\n throw e;\n }\n Warning(message) {\n this.AddError(message, true);\n }\n AddError(message, isWarning = false, useEndLineNumber = false) {\n let dm = this.currentDebugMetadata;\n let errorTypeStr = isWarning ? \"WARNING\" : \"ERROR\";\n if (dm != null) {\n let lineNum = useEndLineNumber ? dm.endLineNumber : dm.startLineNumber;\n message =\n \"RUNTIME \" +\n errorTypeStr +\n \": '\" +\n dm.fileName +\n \"' line \" +\n lineNum +\n \": \" +\n message;\n }\n else if (!this.state.currentPointer.isNull) {\n message =\n \"RUNTIME \" +\n errorTypeStr +\n \": (\" +\n this.state.currentPointer +\n \"): \" +\n message;\n }\n else {\n message = \"RUNTIME \" + errorTypeStr + \": \" + message;\n }\n this.state.AddError(message, isWarning);\n // In a broken state don't need to know about any other errors.\n if (!isWarning)\n this.state.ForceEnd();\n }\n Assert(condition, message = null) {\n if (condition == false) {\n if (message == null) {\n message = \"Story assert\";\n }\n throw new Error(message + \" \" + this.currentDebugMetadata);\n }\n }\n get currentDebugMetadata() {\n let dm;\n let pointer = this.state.currentPointer;\n if (!pointer.isNull && pointer.Resolve() !== null) {\n dm = pointer.Resolve().debugMetadata;\n if (dm !== null) {\n return dm;\n }\n }\n for (let i = this.state.callStack.elements.length - 1; i >= 0; --i) {\n pointer = this.state.callStack.elements[i].currentPointer;\n if (!pointer.isNull && pointer.Resolve() !== null) {\n dm = pointer.Resolve().debugMetadata;\n if (dm !== null) {\n return dm;\n }\n }\n }\n for (let i = this.state.outputStream.length - 1; i >= 0; --i) {\n let outputObj = this.state.outputStream[i];\n dm = outputObj.debugMetadata;\n if (dm !== null) {\n return dm;\n }\n }\n return null;\n }\n get mainContentContainer() {\n if (this._temporaryEvaluationContainer) {\n return this._temporaryEvaluationContainer;\n }\n else {\n return this._mainContentContainer;\n }\n }\n}\nexports.Story = Story;\nStory.inkVersionCurrent = 21;\n(function (Story) {\n let OutputStateChange;\n (function (OutputStateChange) {\n OutputStateChange[OutputStateChange[\"NoChange\"] = 0] = \"NoChange\";\n OutputStateChange[OutputStateChange[\"ExtendedBeyondNewline\"] = 1] = \"ExtendedBeyondNewline\";\n OutputStateChange[OutputStateChange[\"NewlineRemoved\"] = 2] = \"NewlineRemoved\";\n })(OutputStateChange = Story.OutputStateChange || (Story.OutputStateChange = {}));\n})(Story || (exports.Story = Story = {}));\n//# sourceMappingURL=Story.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Story = void 0;\nconst AuthorWarning_1 = require(\"./AuthorWarning\");\nconst ConstantDeclaration_1 = require(\"./Declaration/ConstantDeclaration\");\nconst Container_1 = require(\"../../../engine/Container\");\nconst ControlCommand_1 = require(\"../../../engine/ControlCommand\");\nconst ErrorType_1 = require(\"../ErrorType\");\nconst FlowBase_1 = require(\"./Flow/FlowBase\");\nconst FlowLevel_1 = require(\"./Flow/FlowLevel\");\nconst IncludedFile_1 = require(\"./IncludedFile\");\nconst ListDefinition_1 = require(\"./List/ListDefinition\");\nconst ListElementDefinition_1 = require(\"./List/ListElementDefinition\");\nconst Story_1 = require(\"../../../engine/Story\");\nconst SymbolType_1 = require(\"./SymbolType\");\nconst Text_1 = require(\"./Text\");\nconst VariableAssignment_1 = require(\"../../../engine/VariableAssignment\");\nconst TypeAssertion_1 = require(\"../../../engine/TypeAssertion\");\nconst ClosestFlowBase_1 = require(\"./Flow/ClosestFlowBase\");\nconst FunctionCall_1 = require(\"./FunctionCall\");\nconst Path_1 = require(\"./Path\");\nclass Story extends FlowBase_1.FlowBase {\n get flowLevel() {\n return FlowLevel_1.FlowLevel.Story;\n }\n get hadError() {\n return this._hadError;\n }\n get hadWarning() {\n return this._hadWarning;\n }\n constructor(toplevelObjects, isInclude = false) {\n // Don't do anything much on construction, leave it lightweight until\n // the ExportRuntime method is called.\n super(null, toplevelObjects, null, false, isInclude);\n this._errorHandler = null;\n this._hadError = false;\n this._hadWarning = false;\n this._dontFlattenContainers = new Set();\n this._listDefs = new Map();\n this.constants = new Map();\n this.externals = new Map();\n // Build setting for exporting:\n // When true, the visit count for *all* knots, stitches, choices,\n // and gathers is counted. When false, only those that are direclty\n // referenced by the ink are recorded. Use this flag to allow game-side\n // querying of arbitrary knots/stitches etc.\n // Storing all counts is more robust and future proof (updates to the story file\n // that reference previously uncounted visits are possible, but generates a much\n // larger safe file, with a lot of potentially redundant counts.\n this.countAllVisits = false;\n this.ExportRuntime = (errorHandler = null) => {\n var _a, _b;\n this._errorHandler = errorHandler;\n // Find all constants before main export begins, so that VariableReferences know\n // whether to generate a runtime variable reference or the literal value\n this.constants = new Map();\n for (const constDecl of this.FindAll(ConstantDeclaration_1.ConstantDeclaration)()) {\n // Check for duplicate definitions\n const existingDefinition = this.constants.get(constDecl.constantName);\n if (existingDefinition) {\n if (!existingDefinition.Equals(constDecl.expression)) {\n const errorMsg = `CONST '${constDecl.constantName}' has been redefined with a different value. Multiple definitions of the same CONST are valid so long as they contain the same value. Initial definition was on ${existingDefinition.debugMetadata}.`;\n this.Error(errorMsg, constDecl, false);\n }\n }\n this.constants.set(constDecl.constantName, constDecl.expression);\n }\n // List definitions are treated like constants too - they should be usable\n // from other variable declarations.\n this._listDefs = new Map();\n for (const listDef of this.FindAll(ListDefinition_1.ListDefinition)()) {\n if ((_a = listDef.identifier) === null || _a === void 0 ? void 0 : _a.name) {\n this._listDefs.set((_b = listDef.identifier) === null || _b === void 0 ? void 0 : _b.name, listDef);\n }\n }\n this.externals = new Map();\n // Resolution of weave point names has to come first, before any runtime code generation\n // since names have to be ready before diverts start getting created.\n // (It used to be done in the constructor for a weave, but didn't allow us to generate\n // errors when name resolution failed.)\n this.ResolveWeavePointNaming();\n // Get default implementation of runtimeObject, which calls ContainerBase's generation method\n const rootContainer = this.runtimeObject;\n // Export initialisation of global variables\n // TODO: We *could* add this as a declarative block to the story itself...\n const variableInitialisation = new Container_1.Container();\n variableInitialisation.AddContent(ControlCommand_1.ControlCommand.EvalStart());\n // Global variables are those that are local to the story and marked as global\n const runtimeLists = [];\n for (const [key, value] of this.variableDeclarations) {\n if (value.isGlobalDeclaration) {\n if (value.listDefinition) {\n this._listDefs.set(key, value.listDefinition);\n variableInitialisation.AddContent(value.listDefinition.runtimeObject);\n runtimeLists.push(value.listDefinition.runtimeListDefinition);\n }\n else {\n if (!value.expression) {\n throw new Error();\n }\n value.expression.GenerateIntoContainer(variableInitialisation);\n }\n const runtimeVarAss = new VariableAssignment_1.VariableAssignment(key, true);\n runtimeVarAss.isGlobal = true;\n variableInitialisation.AddContent(runtimeVarAss);\n }\n }\n variableInitialisation.AddContent(ControlCommand_1.ControlCommand.EvalEnd());\n variableInitialisation.AddContent(ControlCommand_1.ControlCommand.End());\n if (this.variableDeclarations.size > 0) {\n variableInitialisation.name = \"global decl\";\n rootContainer.AddToNamedContentOnly(variableInitialisation);\n }\n // Signal that it's safe to exit without error, even if there are no choices generated\n // (this only happens at the end of top level content that isn't in any particular knot)\n rootContainer.AddContent(ControlCommand_1.ControlCommand.Done());\n // Replace runtimeObject with Story object instead of the Runtime.Container generated by Parsed.ContainerBase\n const runtimeStory = new Story_1.Story(rootContainer, runtimeLists);\n this.runtimeObject = runtimeStory;\n if (this.hadError) {\n return null;\n }\n // Optimisation step - inline containers that can be\n this.FlattenContainersIn(rootContainer);\n // Now that the story has been fulled parsed into a hierarchy,\n // and the derived runtime hierarchy has been built, we can\n // resolve referenced symbols such as variables and paths.\n // e.g. for paths \" -> knotName --> stitchName\" into an INKPath (knotName.stitchName)\n // We don't make any assumptions that the INKPath follows the same\n // conventions as the script format, so we resolve to actual objects before\n // translating into an INKPath. (This also allows us to choose whether\n // we want the paths to be absolute)\n this.ResolveReferences(this);\n if (this.hadError) {\n return null;\n }\n runtimeStory.ResetState();\n return runtimeStory;\n };\n this.ResolveList = (listName) => {\n let list = this._listDefs.get(listName);\n if (!list) {\n return null;\n }\n return list;\n };\n this.ResolveListItem = (listName, itemName, source = null) => {\n let listDef = null;\n // Search a specific list if we know its name (i.e. the form listName.itemName)\n if (listName) {\n if (!(listDef = this._listDefs.get(listName))) {\n return null;\n }\n return listDef.ItemNamed(itemName);\n }\n else {\n // Otherwise, try to search all lists\n let foundItem = null;\n let originalFoundList = null;\n for (const [, value] of this._listDefs.entries()) {\n const itemInThisList = value.ItemNamed(itemName);\n if (itemInThisList) {\n if (foundItem) {\n this.Error(`Ambiguous item name '${itemName}' found in multiple sets, including ${originalFoundList.identifier} and ${value.identifier}`, source, false);\n }\n else {\n foundItem = itemInThisList;\n originalFoundList = value;\n }\n }\n }\n return foundItem;\n }\n };\n this.FlattenContainersIn = (container) => {\n // Need to create a collection to hold the inner containers\n // because otherwise we'd end up modifying during iteration\n const innerContainers = new Set();\n if (container.content) {\n for (const c of container.content) {\n const innerContainer = (0, TypeAssertion_1.asOrNull)(c, Container_1.Container);\n if (innerContainer) {\n innerContainers.add(innerContainer);\n }\n }\n }\n // Can't flatten the named inner containers, but we can at least\n // iterate through their children\n if (container.namedContent) {\n for (const [, value] of container.namedContent) {\n const namedInnerContainer = (0, TypeAssertion_1.asOrNull)(value, Container_1.Container);\n if (namedInnerContainer) {\n innerContainers.add(namedInnerContainer);\n }\n }\n }\n for (const innerContainer of innerContainers) {\n this.TryFlattenContainer(innerContainer);\n this.FlattenContainersIn(innerContainer);\n }\n };\n this.TryFlattenContainer = (container) => {\n if ((container.namedContent && container.namedContent.size > 0) ||\n container.hasValidName ||\n this._dontFlattenContainers.has(container)) {\n return;\n }\n // Inline all the content in container into the parent\n const parentContainer = (0, TypeAssertion_1.asOrNull)(container.parent, Container_1.Container);\n if (parentContainer) {\n let contentIdx = parentContainer.content.indexOf(container);\n parentContainer.content.splice(contentIdx, 1);\n const dm = container.ownDebugMetadata;\n if (container.content) {\n for (const innerContent of container.content) {\n innerContent.parent = null;\n if (dm !== null && innerContent.ownDebugMetadata === null) {\n innerContent.debugMetadata = dm;\n }\n parentContainer.InsertContent(innerContent, contentIdx);\n contentIdx += 1;\n }\n }\n }\n };\n this.Error = (message, source, isWarning) => {\n let errorType = isWarning ? ErrorType_1.ErrorType.Warning : ErrorType_1.ErrorType.Error;\n let sb = \"\";\n if (source instanceof AuthorWarning_1.AuthorWarning) {\n sb += \"TODO: \";\n errorType = ErrorType_1.ErrorType.Author;\n }\n else if (isWarning) {\n sb += \"WARNING: \";\n }\n else {\n sb += \"ERROR: \";\n }\n if (source &&\n source.debugMetadata !== null &&\n source.debugMetadata.startLineNumber >= 1) {\n if (source.debugMetadata.fileName != null) {\n sb += `'${source.debugMetadata.fileName}' `;\n }\n sb += `line ${source.debugMetadata.startLineNumber}: `;\n }\n sb += message;\n message = sb;\n if (this._errorHandler !== null) {\n this._errorHandler(message, errorType);\n }\n else {\n throw new Error(message);\n }\n this._hadError = errorType === ErrorType_1.ErrorType.Error;\n this._hadWarning = errorType === ErrorType_1.ErrorType.Warning;\n };\n this.ResetError = () => {\n this._hadError = false;\n this._hadWarning = false;\n };\n this.IsExternal = (namedFuncTarget) => this.externals.has(namedFuncTarget);\n this.AddExternal = (decl) => {\n if (this.externals.has(decl.name)) {\n this.Error(`Duplicate EXTERNAL definition of '${decl.name}'`, decl, false);\n }\n else if (decl.name) {\n this.externals.set(decl.name, decl);\n }\n };\n this.DontFlattenContainer = (container) => {\n this._dontFlattenContainers.add(container);\n };\n this.NameConflictError = (obj, name, existingObj, typeNameToPrint) => {\n obj.Error(`${typeNameToPrint} '${name}': name has already been used for a ${existingObj.typeName.toLowerCase()} on ${existingObj.debugMetadata}`);\n };\n // Check given symbol type against everything that's of a higher priority in the ordered SymbolType enum (above).\n // When the given symbol type level is reached, we early-out / return.\n this.CheckForNamingCollisions = (obj, identifier, symbolType, typeNameOverride = \"\") => {\n var _a;\n const typeNameToPrint = typeNameOverride || obj.typeName;\n if (Story.IsReservedKeyword(identifier === null || identifier === void 0 ? void 0 : identifier.name)) {\n obj.Error(`'${identifier}' cannot be used for the name of a ${typeNameToPrint.toLowerCase()} because it's a reserved keyword`);\n return;\n }\n else if (FunctionCall_1.FunctionCall.IsBuiltIn((identifier === null || identifier === void 0 ? void 0 : identifier.name) || \"\")) {\n obj.Error(`'${identifier}' cannot be used for the name of a ${typeNameToPrint.toLowerCase()} because it's a built in function`);\n return;\n }\n // Top level knots\n const maybeKnotOrFunction = this.ContentWithNameAtLevel((identifier === null || identifier === void 0 ? void 0 : identifier.name) || \"\", FlowLevel_1.FlowLevel.Knot);\n const knotOrFunction = (0, TypeAssertion_1.asOrNull)(maybeKnotOrFunction, FlowBase_1.FlowBase);\n if (knotOrFunction &&\n (knotOrFunction !== obj || symbolType === SymbolType_1.SymbolType.Arg)) {\n this.NameConflictError(obj, (identifier === null || identifier === void 0 ? void 0 : identifier.name) || \"\", knotOrFunction, typeNameToPrint);\n return;\n }\n if (symbolType < SymbolType_1.SymbolType.List) {\n return;\n }\n // Lists\n for (const [key, value] of this._listDefs) {\n if ((identifier === null || identifier === void 0 ? void 0 : identifier.name) === key &&\n obj !== value &&\n value.variableAssignment !== obj) {\n this.NameConflictError(obj, identifier === null || identifier === void 0 ? void 0 : identifier.name, value, typeNameToPrint);\n }\n // We don't check for conflicts between individual elements in\n // different lists because they are namespaced.\n if (!(obj instanceof ListElementDefinition_1.ListElementDefinition)) {\n for (const item of value.itemDefinitions) {\n if ((identifier === null || identifier === void 0 ? void 0 : identifier.name) === item.name) {\n this.NameConflictError(obj, (identifier === null || identifier === void 0 ? void 0 : identifier.name) || \"\", item, typeNameToPrint);\n }\n }\n }\n }\n // Don't check for VAR->VAR conflicts because that's handled separately\n // (necessary since checking looks up in a dictionary)\n if (symbolType <= SymbolType_1.SymbolType.Var) {\n return;\n }\n // Global variable collision\n const varDecl = ((identifier === null || identifier === void 0 ? void 0 : identifier.name) && this.variableDeclarations.get(identifier === null || identifier === void 0 ? void 0 : identifier.name)) ||\n null;\n if (varDecl &&\n varDecl !== obj &&\n varDecl.isGlobalDeclaration &&\n varDecl.listDefinition == null) {\n this.NameConflictError(obj, (identifier === null || identifier === void 0 ? void 0 : identifier.name) || \"\", varDecl, typeNameToPrint);\n }\n if (symbolType < SymbolType_1.SymbolType.SubFlowAndWeave) {\n return;\n }\n // Stitches, Choices and Gathers\n const path = new Path_1.Path(identifier);\n const targetContent = path.ResolveFromContext(obj);\n if (targetContent && targetContent !== obj) {\n this.NameConflictError(obj, (identifier === null || identifier === void 0 ? void 0 : identifier.name) || \"\", targetContent, typeNameToPrint);\n return;\n }\n if (symbolType < SymbolType_1.SymbolType.Arg) {\n return;\n }\n // Arguments to the current flow\n if (symbolType !== SymbolType_1.SymbolType.Arg) {\n let flow = (0, TypeAssertion_1.asOrNull)(obj, FlowBase_1.FlowBase);\n if (!flow) {\n flow = (0, ClosestFlowBase_1.ClosestFlowBase)(obj);\n }\n if (flow && flow.hasParameters && flow.args) {\n for (const arg of flow.args) {\n if (((_a = arg.identifier) === null || _a === void 0 ? void 0 : _a.name) === (identifier === null || identifier === void 0 ? void 0 : identifier.name)) {\n obj.Error(`${typeNameToPrint} '${identifier}': name has already been used for a argument to ${flow.identifier} on ${flow.debugMetadata}`);\n return;\n }\n }\n }\n }\n };\n }\n get typeName() {\n return \"Story\";\n }\n // Before this function is called, we have IncludedFile objects interspersed\n // in our content wherever an include statement was.\n // So that the include statement can be added in a sensible place (e.g. the\n // top of the file) without side-effects of jumping into a knot that was\n // defined in that include, we separate knots and stitches from anything\n // else defined at the top scope of the included file.\n //\n // Algorithm: For each IncludedFile we find, split its contents into\n // knots/stiches and any other content. Insert the normal content wherever\n // the include statement was, and append the knots/stitches to the very\n // end of the main story.\n PreProcessTopLevelObjects(topLevelContent) {\n super.PreProcessTopLevelObjects(topLevelContent);\n const flowsFromOtherFiles = [];\n // Inject included files\n for (let obj of topLevelContent) {\n if (obj instanceof IncludedFile_1.IncludedFile) {\n const file = obj;\n // Remove the IncludedFile itself\n const posOfObj = topLevelContent.indexOf(obj);\n topLevelContent.splice(posOfObj, 1);\n // When an included story fails to load, the include\n // line itself is still valid, so we have to handle it here\n if (file.includedStory) {\n const nonFlowContent = [];\n const subStory = file.includedStory;\n // Allow empty file\n if (subStory.content != null) {\n for (const subStoryObj of subStory.content) {\n if (subStoryObj instanceof FlowBase_1.FlowBase) {\n flowsFromOtherFiles.push(subStoryObj);\n }\n else {\n nonFlowContent.push(subStoryObj);\n }\n }\n // Add newline on the end of the include\n nonFlowContent.push(new Text_1.Text(\"\\n\"));\n // Add contents of the file in its place\n topLevelContent.splice(posOfObj, 0, ...nonFlowContent);\n // Skip past the content of this sub story\n // (since it will already have recursively included\n // any lines from other files)\n }\n }\n // Include object has been removed, with possible content inserted,\n // and position of 'i' will have been determined already.\n continue;\n }\n }\n // Add the flows we collected from the included files to the\n // end of our list of our content\n topLevelContent.splice(0, 0, ...flowsFromOtherFiles);\n }\n}\nexports.Story = Story;\nStory.IsReservedKeyword = (name) => {\n switch (name) {\n case \"true\":\n case \"false\":\n case \"not\":\n case \"return\":\n case \"else\":\n case \"VAR\":\n case \"CONST\":\n case \"temp\":\n case \"LIST\":\n case \"function\":\n return true;\n }\n return false;\n};\n//# sourceMappingURL=Story.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.StringExpression = void 0;\nconst ControlCommand_1 = require(\"../../../../engine/ControlCommand\");\nconst Expression_1 = require(\"./Expression\");\nconst Text_1 = require(\"../Text\");\nconst TypeAssertion_1 = require(\"../../../../engine/TypeAssertion\");\nclass StringExpression extends Expression_1.Expression {\n get isSingleString() {\n if (this.content.length !== 1) {\n return false;\n }\n const c = this.content[0];\n if (!(c instanceof Text_1.Text)) {\n return false;\n }\n return true;\n }\n constructor(content) {\n super();\n this.GenerateIntoContainer = (container) => {\n container.AddContent(ControlCommand_1.ControlCommand.BeginString());\n for (const c of this.content) {\n container.AddContent(c.runtimeObject);\n }\n container.AddContent(ControlCommand_1.ControlCommand.EndString());\n };\n this.toString = () => {\n let sb = \"\";\n for (const c of this.content) {\n sb += c;\n }\n return sb;\n };\n this.AddContent(content);\n }\n get typeName() {\n return \"String\";\n }\n // Equals override necessary in order to check for CONST multiple definition equality\n Equals(obj) {\n const otherStr = (0, TypeAssertion_1.asOrNull)(obj, StringExpression);\n if (otherStr === null) {\n return false;\n }\n // Can only compare direct equality on single strings rather than\n // complex string expressions that contain dynamic logic\n if (!this.isSingleString || !otherStr.isSingleString) {\n return false;\n }\n const thisTxt = this.toString();\n const otherTxt = otherStr.toString();\n return thisTxt === otherTxt;\n }\n}\nexports.StringExpression = StringExpression;\n//# sourceMappingURL=StringExpression.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.LegacyTag = exports.Tag = void 0;\nconst Object_1 = require(\"./Object\");\nconst ControlCommand_1 = require(\"../../../engine/ControlCommand\");\nclass Tag extends Object_1.ParsedObject {\n constructor(isStart, inChoice = false) {\n super();\n this.GenerateRuntimeObject = () => {\n if (this.isStart) {\n return ControlCommand_1.ControlCommand.BeginTag();\n }\n else {\n return ControlCommand_1.ControlCommand.EndTag();\n }\n };\n this.toString = () => {\n if (this.isStart) {\n return \"#StartTag\";\n }\n else {\n return \"#EndTag\";\n }\n };\n this.isStart = isStart;\n this.inChoice = inChoice;\n }\n get typeName() {\n return \"Tag\";\n }\n}\nexports.Tag = Tag;\nconst Wrap_1 = require(\"./Wrap\");\nclass LegacyTag extends Wrap_1.Wrap {\n constructor(tag) {\n super(tag);\n }\n get typeName() {\n return \"Tag\";\n }\n}\nexports.LegacyTag = LegacyTag;\n//# sourceMappingURL=Tag.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DefaultFileHandler = void 0;\n// This class replaces upstream's DefaultFileHandler. It doesn't perform any\n// resolution and warns the user about providing a proper file handler when\n// INCLUDE statements are parsed. Since the JavaScript parser can be executed in\n// different environments, we let the user decide which FileHandler is best for\n// their use-case. See PosixFileHandler and JsonFileHandler.\nclass DefaultFileHandler {\n constructor(rootPath) {\n this.rootPath = rootPath;\n this.ResolveInkFilename = () => {\n throw Error(\"Can't resolve filename because no FileHandler was provided when instantiating the parser / compiler.\");\n };\n this.LoadInkFileContents = () => {\n throw Error(\"Can't load ink content because no FileHandler was provided when instantiating the parser / compiler.\");\n };\n }\n}\nexports.DefaultFileHandler = DefaultFileHandler;\n//# sourceMappingURL=DefaultFileHandler.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InkParser = void 0;\nconst Argument_1 = require(\"./ParsedHierarchy/Argument\");\nconst AuthorWarning_1 = require(\"./ParsedHierarchy/AuthorWarning\");\nconst BinaryExpression_1 = require(\"./ParsedHierarchy/Expression/BinaryExpression\");\nconst CharacterRange_1 = require(\"./CharacterRange\");\nconst CharacterSet_1 = require(\"./CharacterSet\");\nconst Choice_1 = require(\"./ParsedHierarchy/Choice\");\nconst CommentEliminator_1 = require(\"./CommentEliminator\");\nconst Conditional_1 = require(\"./ParsedHierarchy/Conditional/Conditional\");\nconst ConditionalSingleBranch_1 = require(\"./ParsedHierarchy/Conditional/ConditionalSingleBranch\");\nconst ContentList_1 = require(\"./ParsedHierarchy/ContentList\");\nconst ConstantDeclaration_1 = require(\"./ParsedHierarchy/Declaration/ConstantDeclaration\");\nconst CustomFlags_1 = require(\"./CustomFlags\");\nconst DebugMetadata_1 = require(\"../../engine/DebugMetadata\");\nconst Divert_1 = require(\"./ParsedHierarchy/Divert/Divert\");\nconst DivertTarget_1 = require(\"./ParsedHierarchy/Divert/DivertTarget\");\nconst Expression_1 = require(\"./ParsedHierarchy/Expression/Expression\");\nconst ExternalDeclaration_1 = require(\"./ParsedHierarchy/Declaration/ExternalDeclaration\");\nconst FlowDecl_1 = require(\"./FlowDecl\");\nconst FunctionCall_1 = require(\"./ParsedHierarchy/FunctionCall\");\nconst Gather_1 = require(\"./ParsedHierarchy/Gather/Gather\");\nconst Glue_1 = require(\"./ParsedHierarchy/Glue\");\nconst Glue_2 = require(\"../../engine/Glue\");\nconst IncDecExpression_1 = require(\"./ParsedHierarchy/Expression/IncDecExpression\");\nconst IncludedFile_1 = require(\"./ParsedHierarchy/IncludedFile\");\nconst InfixOperator_1 = require(\"./InfixOperator\");\nconst Knot_1 = require(\"./ParsedHierarchy/Knot\");\nconst List_1 = require(\"./ParsedHierarchy/List/List\");\nconst ListDefinition_1 = require(\"./ParsedHierarchy/List/ListDefinition\");\nconst ListElementDefinition_1 = require(\"./ParsedHierarchy/List/ListElementDefinition\");\nconst MultipleConditionExpression_1 = require(\"./ParsedHierarchy/Expression/MultipleConditionExpression\");\nconst Object_1 = require(\"./ParsedHierarchy/Object\");\nconst Path_1 = require(\"./ParsedHierarchy/Path\");\nconst ReturnType_1 = require(\"./ParsedHierarchy/ReturnType\");\nconst Sequence_1 = require(\"./ParsedHierarchy/Sequence/Sequence\");\nconst SequenceType_1 = require(\"./ParsedHierarchy/Sequence/SequenceType\");\nconst StatementLevel_1 = require(\"./StatementLevel\");\nconst Stitch_1 = require(\"./ParsedHierarchy/Stitch\");\nconst Story_1 = require(\"./ParsedHierarchy/Story\");\nconst StringExpression_1 = require(\"./ParsedHierarchy/Expression/StringExpression\");\nconst StringParser_1 = require(\"./StringParser/StringParser\");\nconst Tag_1 = require(\"./ParsedHierarchy/Tag\");\nconst Text_1 = require(\"./ParsedHierarchy/Text\");\nconst TunnelOnwards_1 = require(\"./ParsedHierarchy/TunnelOnwards\");\nconst VariableAssignment_1 = require(\"./ParsedHierarchy/Variable/VariableAssignment\");\nconst VariableReference_1 = require(\"./ParsedHierarchy/Variable/VariableReference\");\nconst UnaryExpression_1 = require(\"./ParsedHierarchy/Expression/UnaryExpression\");\nconst TypeAssertion_1 = require(\"../../engine/TypeAssertion\");\nconst Identifier_1 = require(\"./ParsedHierarchy/Identifier\");\nconst NumberExpression_1 = require(\"./ParsedHierarchy/Expression/NumberExpression\");\nconst ErrorType_1 = require(\"./ErrorType\");\nconst DefaultFileHandler_1 = require(\"../FileHandler/DefaultFileHandler\");\nclass InkParser extends StringParser_1.StringParser {\n /**\n * Begin base InkParser section.\n */\n get fileHandler() {\n if (!this._fileHandler) {\n throw new Error(\"No FileHandler defined\");\n }\n return this._fileHandler;\n }\n set fileHandler(value) {\n this._fileHandler = value;\n }\n constructor(str, filename = null, externalErrorHandler = null, rootParser = null, fileHandler = null) {\n super(str);\n // Main entry point\n // NOTE: This method is named Parse() in upstream.\n this.ParseStory = () => {\n const topLevelContent = this.StatementsAtLevel(StatementLevel_1.StatementLevel.Top);\n // Note we used to return null if there were any errors, but this would mean\n // that include files would return completely empty rather than attempting to\n // continue with errors. Returning an empty include files meant that anything\n // that *did* compile successfully would otherwise be ignored, generating way\n // more errors than necessary.\n return new Story_1.Story(topLevelContent, this._rootParser !== this);\n };\n this.SeparatedList = (mainRule, separatorRule) => {\n const firstElement = this.Parse(mainRule);\n if (firstElement === null) {\n return null;\n }\n const allElements = [];\n allElements.push(firstElement);\n do {\n const nextElementRuleId = this.BeginRule();\n let sep = separatorRule();\n if (sep === null) {\n this.FailRule(nextElementRuleId);\n break;\n }\n const nextElement = this.Parse(mainRule);\n if (nextElement === null) {\n this.FailRule(nextElementRuleId);\n break;\n }\n this.SucceedRule(nextElementRuleId);\n allElements.push(nextElement);\n } while (true);\n return allElements;\n };\n this.CreateDebugMetadata = (stateAtStart, stateAtEnd) => {\n const md = new DebugMetadata_1.DebugMetadata();\n md.startLineNumber = ((stateAtStart === null || stateAtStart === void 0 ? void 0 : stateAtStart.lineIndex) || 0) + 1;\n md.endLineNumber = stateAtEnd.lineIndex + 1;\n md.startCharacterNumber = ((stateAtStart === null || stateAtStart === void 0 ? void 0 : stateAtStart.characterInLineIndex) || 0) + 1;\n md.endCharacterNumber = stateAtEnd.characterInLineIndex + 1;\n md.fileName = this._filename;\n return md;\n };\n this.RuleDidSucceed = (result, stateAtStart, stateAtEnd) => {\n // Apply DebugMetadata based on the state at the start of the rule\n // (i.e. use line number as it was at the start of the rule)\n const parsedObj = (0, TypeAssertion_1.asOrNull)(result, Object_1.ParsedObject);\n if (parsedObj) {\n parsedObj.debugMetadata = this.CreateDebugMetadata(stateAtStart, stateAtEnd);\n }\n // A list of objects that doesn't already have metadata?\n const parsedListObjs = Array.isArray(result)\n ? result\n : null;\n if (parsedListObjs !== null) {\n for (const parsedListObj of parsedListObjs) {\n const singleObj = (0, TypeAssertion_1.asOrNull)(parsedListObj, Object_1.ParsedObject);\n if (!singleObj)\n continue;\n if (!parsedListObj.hasOwnDebugMetadata) {\n parsedListObj.debugMetadata = this.CreateDebugMetadata(stateAtStart, stateAtEnd);\n }\n }\n }\n const id = (0, TypeAssertion_1.asOrNull)(result, Identifier_1.Identifier);\n if (id != null) {\n id.debugMetadata = this.CreateDebugMetadata(stateAtStart, stateAtEnd);\n }\n };\n this.OnStringParserError = (message, index, lineIndex = 0, isWarning = false) => {\n const warningType = isWarning ? \"WARNING:\" : \"ERROR:\";\n let fullMessage = warningType;\n if (this._filename !== null) {\n fullMessage += ` '${this._filename}'`;\n }\n fullMessage += ` line ${lineIndex + 1}: ${message}`;\n if (this._externalErrorHandler !== null) {\n this._externalErrorHandler(fullMessage, isWarning ? ErrorType_1.ErrorType.Warning : ErrorType_1.ErrorType.Error);\n }\n else {\n throw new Error(fullMessage);\n }\n };\n this.AuthorWarning = () => {\n this.Whitespace();\n const identifier = this.Parse(this.IdentifierWithMetadata);\n if (identifier === null || identifier.name !== \"TODO\") {\n return null;\n }\n this.Whitespace();\n this.ParseString(\":\");\n this.Whitespace();\n const message = this.ParseUntilCharactersFromString(\"\\n\\r\");\n if (message) {\n return new AuthorWarning_1.AuthorWarning(message);\n }\n return null;\n };\n this.ExtendIdentifierCharacterRanges = (identifierCharSet) => {\n const characterRanges = InkParser.ListAllCharacterRanges();\n for (const charRange of characterRanges) {\n identifierCharSet.AddCharacters(charRange.ToCharacterSet());\n }\n };\n /**\n * End CharacterRanges section.\n */\n /**\n * Begin Choices section.\n */\n this._parsingChoice = false;\n this.Choice = () => {\n let onceOnlyChoice = true;\n let bullets = this.Interleave(this.OptionalExclude(this.Whitespace), this.String(\"*\"));\n if (!bullets) {\n bullets = this.Interleave(this.OptionalExclude(this.Whitespace), this.String(\"+\"));\n if (bullets === null) {\n return null;\n }\n onceOnlyChoice = false;\n }\n // Optional name for the choice\n const optionalName = this.Parse(this.BracketedName);\n this.Whitespace();\n // Allow optional newline right after a choice name\n if (optionalName != null)\n this.Newline();\n // Optional condition for whether the choice should be shown to the player\n const conditionExpr = this.Parse(this.ChoiceCondition);\n this.Whitespace();\n // Ordinarily we avoid parser state variables like these, since\n // nesting would require us to store them in a stack. But since you should\n // never be able to nest choices within choice content, it's fine here.\n if (this._parsingChoice) {\n throw new Error(\"Already parsing a choice - shouldn't have nested choices\");\n }\n this._parsingChoice = true;\n let startContent = null;\n const startTextAndLogic = this.Parse(this.MixedTextAndLogic);\n if (startTextAndLogic) {\n startContent = new ContentList_1.ContentList(startTextAndLogic);\n }\n let optionOnlyContent = null;\n let innerContent = null;\n // Check for a the weave style format:\n // * \"Hello[.\"],\" he said.\n const hasWeaveStyleInlineBrackets = this.ParseString(\"[\") !== null;\n if (hasWeaveStyleInlineBrackets) {\n this.EndTagIfNecessary(startContent);\n const optionOnlyTextAndLogic = this.Parse(this.MixedTextAndLogic);\n if (optionOnlyTextAndLogic !== null) {\n optionOnlyContent = new ContentList_1.ContentList(optionOnlyTextAndLogic);\n }\n this.Expect(this.String(\"]\"), \"closing ']' for weave-style option\");\n this.EndTagIfNecessary(optionOnlyContent);\n let innerTextAndLogic = this.Parse(this.MixedTextAndLogic);\n if (innerTextAndLogic !== null) {\n innerContent = new ContentList_1.ContentList(innerTextAndLogic);\n }\n }\n this.Whitespace();\n this.EndTagIfNecessary(innerContent !== null && innerContent !== void 0 ? innerContent : startContent);\n // Finally, now we know we're at the end of the main choice body, parse\n // any diverts separately.\n const diverts = this.Parse(this.MultiDivert);\n this._parsingChoice = false;\n this.Whitespace();\n // Completely empty choice without even an empty divert?\n const emptyContent = !startContent && !innerContent && !optionOnlyContent;\n if (emptyContent && diverts === null) {\n this.Warning(\"Choice is completely empty. Interpretting as a default fallback choice. Add a divert arrow to remove this warning: * ->\");\n }\n if (!startContent && hasWeaveStyleInlineBrackets && !optionOnlyContent) {\n // * [] some text\n this.Warning(\"Blank choice - if you intended a default fallback choice, use the `* ->` syntax\");\n }\n if (!innerContent) {\n innerContent = new ContentList_1.ContentList();\n }\n this.EndTagIfNecessary(innerContent);\n // Normal diverts on the end of a choice - simply add to the normal content\n if (diverts !== null) {\n for (const divObj of diverts) {\n // may be TunnelOnwards\n const div = (0, TypeAssertion_1.asOrNull)(divObj, Divert_1.Divert);\n // Empty divert serves no purpose other than to say\n // \"this choice is intentionally left blank\"\n // (as an invisible default choice)\n if (div && div.isEmpty) {\n continue;\n }\n innerContent.AddContent(divObj);\n }\n }\n // Terminate main content with a newline since this is the end of the line\n // Note that this will be redundant if the diverts above definitely take\n // the flow away permanently.\n innerContent.AddContent(new Text_1.Text(\"\\n\"));\n const choice = new Choice_1.Choice(startContent, optionOnlyContent, innerContent);\n if (optionalName)\n choice.identifier = optionalName;\n choice.indentationDepth = bullets.length;\n choice.hasWeaveStyleInlineBrackets = hasWeaveStyleInlineBrackets;\n choice.condition = conditionExpr;\n choice.onceOnly = onceOnlyChoice;\n choice.isInvisibleDefault = emptyContent;\n return choice;\n };\n this.ChoiceCondition = () => {\n const conditions = this.Interleave(this.ChoiceSingleCondition, this.ChoiceConditionsSpace);\n if (conditions === null) {\n return null;\n }\n else if (conditions.length === 1) {\n return conditions[0];\n }\n return new MultipleConditionExpression_1.MultipleConditionExpression(conditions);\n };\n this.ChoiceConditionsSpace = () => {\n // Both optional\n // Newline includes initial end of line whitespace\n this.Newline();\n this.Whitespace();\n return StringParser_1.ParseSuccess;\n };\n this.ChoiceSingleCondition = () => {\n if (this.ParseString(\"{\") === null) {\n return null;\n }\n const condExpr = this.Expect(this.Expression, \"choice condition inside { }\");\n this.DisallowIncrement(condExpr);\n this.Expect(this.String(\"}\"), \"closing '}' for choice condition\");\n return condExpr;\n };\n this.Gather = () => {\n const gatherDashCountObj = this.Parse(this.GatherDashes);\n if (gatherDashCountObj === null) {\n return null;\n }\n const gatherDashCount = Number(gatherDashCountObj);\n // Optional name for the gather\n const optionalName = this.Parse(this.BracketedName);\n const gather = new Gather_1.Gather(optionalName, gatherDashCount);\n // Optional newline before gather's content begins\n this.Newline();\n return gather;\n };\n this.GatherDashes = () => {\n this.Whitespace();\n let gatherDashCount = 0;\n while (this.ParseDashNotArrow() !== null) {\n gatherDashCount += 1;\n this.Whitespace();\n }\n if (gatherDashCount === 0) {\n return null;\n }\n return gatherDashCount;\n };\n this.ParseDashNotArrow = () => {\n const ruleId = this.BeginRule();\n if (this.ParseString(\"->\") === null &&\n this.ParseSingleCharacter() === \"-\") {\n return this.SucceedRule(ruleId);\n }\n return this.FailRule(ruleId);\n };\n this.BracketedName = () => {\n if (this.ParseString(\"(\") === null) {\n return null;\n }\n this.Whitespace();\n const name = this.Parse(this.IdentifierWithMetadata);\n if (name === null) {\n return null;\n }\n this.Whitespace();\n this.Expect(this.String(\")\"), \"closing ')' for bracketed name\");\n return name;\n };\n /**\n * End Choices section.\n */\n /**\n * Begin Conditional section.\n */\n this.InnerConditionalContent = (initialQueryExpression) => {\n if (initialQueryExpression === undefined) {\n const initialQueryExpression = this.Parse(this.ConditionExpression);\n const conditional = this.Parse(() => this.InnerConditionalContent(initialQueryExpression));\n if (conditional === null) {\n return null;\n }\n return conditional;\n }\n let alternatives;\n const canBeInline = initialQueryExpression !== null;\n const isInline = this.Parse(this.Newline) === null;\n if (isInline && !canBeInline) {\n return null;\n }\n if (isInline) {\n // Inline innards\n alternatives = this.InlineConditionalBranches();\n }\n else {\n // Multiline innards\n alternatives = this.MultilineConditionalBranches();\n if (alternatives === null) {\n // Allow single piece of content within multi-line expression, e.g.:\n // { true:\n // Some content that isn't preceded by '-'\n // }\n if (initialQueryExpression) {\n let soleContent = this.StatementsAtLevel(StatementLevel_1.StatementLevel.InnerBlock);\n if (soleContent !== null) {\n const soleBranch = new ConditionalSingleBranch_1.ConditionalSingleBranch(soleContent);\n alternatives = [soleBranch];\n // Also allow a final \"- else:\" clause\n const elseBranch = this.Parse(this.SingleMultilineCondition);\n if (elseBranch) {\n if (!elseBranch.isElse) {\n this.ErrorWithParsedObject(\"Expected an '- else:' clause here rather than an extra condition\", elseBranch);\n elseBranch.isElse = true;\n }\n alternatives.push(elseBranch);\n }\n }\n }\n // Still null?\n if (alternatives === null) {\n return null;\n }\n }\n else if (alternatives.length === 1 &&\n alternatives[0].isElse &&\n initialQueryExpression) {\n // Empty true branch - didn't get parsed, but should insert one for semantic correctness,\n // and to make sure that any evaluation stack values get tidied up correctly.\n const emptyTrueBranch = new ConditionalSingleBranch_1.ConditionalSingleBranch(null);\n emptyTrueBranch.isTrueBranch = true;\n alternatives.unshift(emptyTrueBranch);\n }\n // Like a switch statement\n // { initialQueryExpression:\n // ... match the expression\n // }\n if (initialQueryExpression) {\n let earlierBranchesHaveOwnExpression = false;\n for (let ii = 0; ii < alternatives.length; ++ii) {\n const branch = alternatives[ii];\n const isLast = ii === alternatives.length - 1;\n // Matching equality with initial query expression\n // We set this flag even for the \"else\" clause so that\n // it knows to tidy up the evaluation stack at the end\n // Match query\n if (branch.ownExpression) {\n branch.matchingEquality = true;\n earlierBranchesHaveOwnExpression = true;\n }\n else if (earlierBranchesHaveOwnExpression && isLast) {\n // Else (final branch)\n branch.matchingEquality = true;\n branch.isElse = true;\n }\n else {\n // Binary condition:\n // { trueOrFalse:\n // - when true\n // - when false\n // }\n if (!isLast && alternatives.length > 2) {\n this.ErrorWithParsedObject(\"Only final branch can be an 'else'. Did you miss a ':'?\", branch);\n }\n else {\n if (ii === 0) {\n branch.isTrueBranch = true;\n }\n else {\n branch.isElse = true;\n }\n }\n }\n }\n }\n else {\n // No initial query, so just a multi-line conditional. e.g.:\n // {\n // - x > 3: greater than three\n // - x == 3: equal to three\n // - x < 3: less than three\n // }\n for (let ii = 0; ii < alternatives.length; ++ii) {\n const alt = alternatives[ii];\n const isLast = ii === alternatives.length - 1;\n if (alt.ownExpression === null) {\n if (isLast) {\n alt.isElse = true;\n }\n else {\n if (alt.isElse) {\n // Do we ALSO have a valid \"else\" at the end? Let's report the error there.\n const finalClause = alternatives[alternatives.length - 1];\n if (finalClause.isElse) {\n this.ErrorWithParsedObject(\"Multiple 'else' cases. Can have a maximum of one, at the end.\", finalClause);\n }\n else {\n this.ErrorWithParsedObject(\"'else' case in conditional should always be the final one\", alt);\n }\n }\n else {\n this.ErrorWithParsedObject(\"Branch doesn't have condition. Are you missing a ':'? \", alt);\n }\n }\n }\n }\n if (alternatives.length === 1 &&\n alternatives[0].ownExpression === null) {\n this.ErrorWithParsedObject(\"Condition block with no conditions\", alternatives[0]);\n }\n }\n }\n // TODO: Come up with water-tight error conditions... it's quite a flexible system!\n // e.g.\n // - inline conditionals must have exactly 1 or 2 alternatives\n // - multiline expression shouldn't have mixed existence of branch-conditions?\n if (alternatives === null) {\n return null;\n }\n for (const branch of alternatives) {\n branch.isInline = isInline;\n }\n const cond = new Conditional_1.Conditional(initialQueryExpression, alternatives);\n return cond;\n };\n this.InlineConditionalBranches = () => {\n const listOfLists = this.Interleave(this.MixedTextAndLogic, this.Exclude(this.String(\"|\")), null, false);\n if (listOfLists === null || listOfLists.length === 0) {\n return null;\n }\n const result = [];\n if (listOfLists.length > 2) {\n this.Error(\"Expected one or two alternatives separated by '|' in inline conditional\");\n }\n else {\n const trueBranch = new ConditionalSingleBranch_1.ConditionalSingleBranch(listOfLists[0]);\n trueBranch.isTrueBranch = true;\n result.push(trueBranch);\n if (listOfLists.length > 1) {\n const elseBranch = new ConditionalSingleBranch_1.ConditionalSingleBranch(listOfLists[1]);\n elseBranch.isElse = true;\n result.push(elseBranch);\n }\n }\n return result;\n };\n this.MultilineConditionalBranches = () => {\n this.MultilineWhitespace();\n const multipleConditions = this.OneOrMore(this.SingleMultilineCondition);\n if (multipleConditions === null) {\n return null;\n }\n this.MultilineWhitespace();\n return multipleConditions;\n };\n this.SingleMultilineCondition = () => {\n this.Whitespace();\n if (\n // Make sure we're not accidentally parsing a divert\n this.ParseString(\"->\") !== null ||\n this.ParseString(\"-\") === null) {\n return null;\n }\n this.Whitespace();\n let expr = null;\n const isElse = this.Parse(this.ElseExpression) !== null;\n if (!isElse) {\n expr = this.Parse(this.ConditionExpression);\n }\n let content = this.StatementsAtLevel(StatementLevel_1.StatementLevel.InnerBlock);\n if (expr === null && content === null) {\n this.Error(\"expected content for the conditional branch following '-'\");\n // Recover\n content = [new Text_1.Text(\"\")];\n }\n // Allow additional multiline whitespace, if the statements were empty (valid)\n // then their surrounding multiline whitespacce needs to be handled manually.\n // e.g.\n // { x:\n // - 1: // intentionally left blank, but newline needs to be parsed\n // - 2: etc\n // }\n this.MultilineWhitespace();\n const branch = new ConditionalSingleBranch_1.ConditionalSingleBranch(content);\n branch.ownExpression = expr;\n branch.isElse = isElse;\n return branch;\n };\n this.ConditionExpression = () => {\n const expr = this.Parse(this.Expression);\n if (expr === null) {\n return null;\n }\n this.DisallowIncrement(expr);\n this.Whitespace();\n if (this.ParseString(\":\") === null) {\n return null;\n }\n return expr;\n };\n this.ElseExpression = () => {\n if (this.ParseString(\"else\") === null) {\n return null;\n }\n this.Whitespace();\n if (this.ParseString(\":\") === null) {\n return null;\n }\n return StringParser_1.ParseSuccess;\n };\n /**\n * End Conditional section.\n */\n /**\n * Begin Content section.\n */\n this._nonTextPauseCharacters = null;\n this._nonTextEndCharacters = null;\n this._notTextEndCharactersChoice = null;\n this._notTextEndCharactersString = null;\n this.TrimEndWhitespace = (mixedTextAndLogicResults, terminateWithSpace) => {\n // Trim whitespace from end\n if (mixedTextAndLogicResults.length > 0) {\n const lastObjIdx = mixedTextAndLogicResults.length - 1;\n const lastObj = mixedTextAndLogicResults[lastObjIdx];\n if (lastObj instanceof Text_1.Text) {\n const textObj = lastObj;\n textObj.text = textObj.text.replace(new RegExp(/[ \\t]+$/g), \"\");\n if (terminateWithSpace) {\n textObj.text += \" \";\n }\n else if (textObj.text.length === 0) {\n // No content left at all? trim the whole object\n mixedTextAndLogicResults.splice(lastObjIdx, 1);\n // Recurse in case there's more whitespace\n this.TrimEndWhitespace(mixedTextAndLogicResults, false);\n }\n }\n }\n };\n this.LineOfMixedTextAndLogic = () => {\n // Consume any whitespace at the start of the line\n // (Except for escaped whitespace)\n this.Parse(this.Whitespace);\n let result = this.Parse(this.MixedTextAndLogic);\n if (!result || !result.length) {\n return null;\n }\n // Warn about accidentally writing \"return\" without \"~\"\n const firstText = result[0];\n if (firstText && firstText.text && firstText.text.startsWith(\"return\")) {\n this.Warning(\"Do you need a '~' before 'return'? If not, perhaps use a glue: <> (since it's lowercase) or rewrite somehow?\");\n }\n if (result.length === 0) {\n return null;\n }\n const lastObj = result[result.length - 1];\n if (!(lastObj instanceof Divert_1.Divert)) {\n this.TrimEndWhitespace(result, false);\n }\n this.EndTagIfNecessary(result);\n // If the line doens't actually contain any normal text content\n // but is in fact entirely a tag, then let's not append\n // a newline, since we want the tag (or tags) to be associated\n // with the line below rather than being completely independent.\n let lineIsPureTag = result.length > 0 && result[0] instanceof Tag_1.Tag && result[0].isStart;\n if (!lineIsPureTag) {\n result.push(new Text_1.Text(\"\\n\"));\n }\n this.Expect(this.EndOfLine, \"end of line\", this.SkipToNextLine);\n return result;\n };\n this.MixedTextAndLogic = () => {\n // Check for disallowed \"~\" within this context\n const disallowedTilde = this.ParseObject(this.Spaced(this.String(\"~\")));\n if (disallowedTilde !== null) {\n this.Error(\"You shouldn't use a '~' here - tildas are for logic that's on its own line. To do inline logic, use { curly braces } instead\");\n }\n // Either, or both interleaved\n let results = this.Interleave(this.Optional(this.ContentText), this.Optional(this.InlineLogicOrGlueOrStartTag));\n // Terminating divert?\n // (When parsing content for the text of a choice, diverts aren't allowed.\n // The divert on the end of the body of a choice is handled specially.)\n if (!this._parsingChoice) {\n const diverts = this.Parse(this.MultiDivert);\n if (diverts !== null) {\n // May not have had any results at all if there's *only* a divert!\n if (results === null) {\n results = [];\n }\n // End previously active tag if necessary\n this.EndTagIfNecessary(results);\n this.TrimEndWhitespace(results, true);\n results.push(...diverts);\n }\n }\n if (!results) {\n return null;\n }\n return results;\n };\n this.ContentText = () => {\n return this.ContentTextAllowingEscapeChar();\n };\n this.ContentTextAllowingEscapeChar = () => {\n let sb = null;\n do {\n let str = this.Parse(this.ContentTextNoEscape);\n const gotEscapeChar = this.ParseString(\"\\\\\") !== null;\n if (gotEscapeChar || str !== null) {\n if (sb === null) {\n sb = \"\";\n }\n if (str !== null) {\n sb += String(str);\n }\n if (gotEscapeChar) {\n const c = this.ParseSingleCharacter();\n sb += c;\n }\n }\n else {\n break;\n }\n } while (true);\n if (sb !== null) {\n return new Text_1.Text(sb);\n }\n return null;\n };\n // Content text is an unusual parse rule compared with most since it's\n // less about saying \"this is is the small selection of stuff that we parse\"\n // and more \"we parse ANYTHING except this small selection of stuff\".\n this.ContentTextNoEscape = () => {\n // Eat through text, pausing at the following characters, and\n // attempt to parse the nonTextRule.\n // \"-\": possible start of divert or start of gather\n // \"<\": possible start of glue\n if (this._nonTextPauseCharacters === null) {\n this._nonTextPauseCharacters = new CharacterSet_1.CharacterSet(\"-<\");\n }\n // If we hit any of these characters, we stop *immediately* without bothering to even check the nonTextRule\n // \"{\" for start of logic\n // \"|\" for mid logic branch\n if (this._nonTextEndCharacters === null) {\n this._nonTextEndCharacters = new CharacterSet_1.CharacterSet(\"{}|\\n\\r\\\\#\");\n this._notTextEndCharactersChoice = new CharacterSet_1.CharacterSet(this._nonTextEndCharacters);\n this._notTextEndCharactersChoice.AddCharacters(\"[]\");\n this._notTextEndCharactersString = new CharacterSet_1.CharacterSet(this._nonTextEndCharacters);\n this._notTextEndCharactersString.AddCharacters('\"');\n }\n // When the ParseUntil pauses, check these rules in case they evaluate successfully\n const nonTextRule = () => this.OneOf([\n this.ParseDivertArrow,\n this.ParseThreadArrow,\n this.EndOfLine,\n this.Glue,\n ]);\n let endChars = null;\n if (this.parsingStringExpression) {\n endChars = this._notTextEndCharactersString;\n }\n else if (this._parsingChoice) {\n endChars = this._notTextEndCharactersChoice;\n }\n else {\n endChars = this._nonTextEndCharacters;\n }\n const pureTextContent = this.ParseUntil(nonTextRule, this._nonTextPauseCharacters, endChars);\n if (pureTextContent !== null) {\n return pureTextContent;\n }\n return null;\n };\n /**\n * End Content section.\n */\n /**\n * Begin Divert section.\n */\n this.MultiDivert = () => {\n this.Whitespace();\n let diverts = [];\n // Try single thread first\n const threadDivert = this.Parse(this.StartThread);\n if (threadDivert) {\n diverts = [threadDivert];\n return diverts;\n }\n // Normal diverts and tunnels\n const arrowsAndDiverts = this.Interleave(this.ParseDivertArrowOrTunnelOnwards, this.DivertIdentifierWithArguments);\n if (!arrowsAndDiverts) {\n return null;\n }\n diverts = [];\n this.EndTagIfNecessary(diverts);\n // Possible patterns:\n // -> -- explicit gather\n // ->-> -- tunnel onwards\n // -> div -- normal divert\n // ->-> div -- tunnel onwards, followed by override divert\n // -> div -> -- normal tunnel\n // -> div ->-> -- tunnel then tunnel continue\n // -> div -> div -- tunnel then divert\n // -> div -> div -> -- tunnel then tunnel\n // -> div -> div ->->\n // -> div -> div ->-> div (etc)\n // Look at the arrows and diverts\n for (let ii = 0; ii < arrowsAndDiverts.length; ++ii) {\n const isArrow = ii % 2 === 0;\n // Arrow string\n if (isArrow) {\n // Tunnel onwards\n if (arrowsAndDiverts[ii] === \"->->\") {\n const tunnelOnwardsPlacementValid = ii === 0 ||\n ii === arrowsAndDiverts.length - 1 ||\n ii === arrowsAndDiverts.length - 2;\n if (!tunnelOnwardsPlacementValid) {\n this.Error(\"Tunnel onwards '->->' must only come at the begining or the start of a divert\");\n }\n const tunnelOnwards = new TunnelOnwards_1.TunnelOnwards();\n if (ii < arrowsAndDiverts.length - 1) {\n const tunnelOnwardDivert = (0, TypeAssertion_1.asOrNull)(arrowsAndDiverts[ii + 1], Divert_1.Divert);\n tunnelOnwards.divertAfter = tunnelOnwardDivert;\n }\n diverts.push(tunnelOnwards);\n // Not allowed to do anything after a tunnel onwards.\n // If we had anything left it would be caused in the above Error for\n // the positioning of a ->->\n break;\n }\n }\n else {\n // Divert\n const divert = arrowsAndDiverts[ii];\n // More to come? (further arrows) Must be tunnelling.\n if (ii < arrowsAndDiverts.length - 1) {\n divert.isTunnel = true;\n }\n diverts.push(divert);\n }\n }\n // Single -> (used for default choices)\n if (diverts.length === 0 && arrowsAndDiverts.length === 1) {\n const gatherDivert = new Divert_1.Divert(null);\n gatherDivert.isEmpty = true;\n diverts.push(gatherDivert);\n if (!this._parsingChoice) {\n this.Error(\"Empty diverts (->) are only valid on choices\");\n }\n }\n return diverts;\n };\n this.StartThread = () => {\n this.Whitespace();\n if (this.ParseThreadArrow() === null) {\n return null;\n }\n this.Whitespace();\n const divert = this.Expect(this.DivertIdentifierWithArguments, \"target for new thread\", () => new Divert_1.Divert(null));\n divert.isThread = true;\n return divert;\n };\n this.DivertIdentifierWithArguments = () => {\n this.Whitespace();\n const targetComponents = this.Parse(this.DotSeparatedDivertPathComponents);\n if (!targetComponents) {\n return null;\n }\n this.Whitespace();\n const optionalArguments = this.Parse(this.ExpressionFunctionCallArguments);\n this.Whitespace();\n const targetPath = new Path_1.Path(targetComponents);\n return new Divert_1.Divert(targetPath, optionalArguments);\n };\n this.SingleDivert = () => {\n const diverts = this.Parse(this.MultiDivert);\n if (!diverts) {\n return null;\n }\n // Ideally we'd report errors if we get the\n // wrong kind of divert, but unfortunately we\n // have to hack around the fact that sequences use\n // a very similar syntax.\n // i.e. if you have a multi-divert at the start\n // of a sequence, it initially tries to parse it\n // as a divert target (part of an expression of\n // a conditional) and gives errors. So instead\n // we just have to blindly reject it as a single\n // divert, and give a slightly less nice error\n // when you DO use a multi divert as a divert taret.\n if (diverts.length !== 1) {\n return null;\n }\n const singleDivert = diverts[0];\n if (singleDivert instanceof TunnelOnwards_1.TunnelOnwards) {\n return null;\n }\n const divert = diverts[0];\n if (divert.isTunnel) {\n return null;\n }\n return divert;\n };\n this.DotSeparatedDivertPathComponents = () => this.Interleave(this.Spaced(this.IdentifierWithMetadata), this.Exclude(this.String(\".\")));\n this.ParseDivertArrowOrTunnelOnwards = () => {\n let numArrows = 0;\n while (this.ParseString(\"->\") !== null) {\n numArrows += 1;\n }\n if (numArrows === 0) {\n return null;\n }\n else if (numArrows === 1) {\n return \"->\";\n }\n else if (numArrows === 2) {\n return \"->->\";\n }\n this.Error(\"Unexpected number of arrows in divert. Should only have '->' or '->->'\");\n return \"->->\";\n };\n this.ParseDivertArrow = () => this.ParseString(\"->\");\n this.ParseThreadArrow = () => this.ParseString(\"<-\");\n /**\n * End Divert section.\n */\n /**\n * Begin Expressions section.\n */\n this._binaryOperators = [];\n this._maxBinaryOpLength = 0;\n this.TempDeclarationOrAssignment = () => {\n this.Whitespace();\n const isNewDeclaration = this.ParseTempKeyword();\n this.Whitespace();\n let varIdentifier = null;\n if (isNewDeclaration) {\n varIdentifier = this.Expect(this.IdentifierWithMetadata, \"variable name\");\n }\n else {\n varIdentifier = this.Parse(this.IdentifierWithMetadata);\n }\n if (varIdentifier === null) {\n return null;\n }\n this.Whitespace();\n // += -=\n const isIncrement = this.ParseString(\"+\") !== null;\n const isDecrement = this.ParseString(\"-\") !== null;\n if (isIncrement && isDecrement) {\n this.Error(\"Unexpected sequence '+-'\");\n }\n if (this.ParseString(\"=\") === null) {\n // Definitely in an assignment expression?\n if (isNewDeclaration) {\n this.Error(\"Expected '='\");\n }\n return null;\n }\n const assignedExpression = this.Expect(this.Expression, \"value expression to be assigned\");\n if (isIncrement || isDecrement) {\n const result = new IncDecExpression_1.IncDecExpression(varIdentifier, assignedExpression, isIncrement);\n return result;\n }\n const result = new VariableAssignment_1.VariableAssignment({\n variableIdentifier: varIdentifier,\n assignedExpression,\n isTemporaryNewDeclaration: isNewDeclaration,\n });\n return result;\n };\n this.DisallowIncrement = (expr) => {\n if (expr instanceof IncDecExpression_1.IncDecExpression) {\n this.Error(\"Can't use increment/decrement here. It can only be used on a ~ line\");\n }\n };\n this.ParseTempKeyword = () => {\n const ruleId = this.BeginRule();\n if (this.Parse(this.Identifier) === \"temp\") {\n this.SucceedRule(ruleId);\n return true;\n }\n this.FailRule(ruleId);\n return false;\n };\n this.ReturnStatement = () => {\n this.Whitespace();\n const returnOrDone = this.Parse(this.Identifier);\n if (returnOrDone !== \"return\") {\n return null;\n }\n this.Whitespace();\n const expr = this.Parse(this.Expression);\n const returnObj = new ReturnType_1.ReturnType(expr);\n return returnObj;\n };\n // Pratt Parser\n // aka \"Top down operator precedence parser\"\n // http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/\n // Algorithm overview:\n // The two types of precedence are handled in two different ways:\n // ((((a . b) . c) . d) . e)\t\t\t#1\n // (a . (b . (c . (d . e))))\t\t\t#2\n // Where #1 is automatically handled by successive loops within the main 'while' in this function,\n // so long as continuing operators have lower (or equal) precedence (e.g. imagine some series of \"*\"s then \"+\" above.\n // ...and #2 is handled by recursion of the right hand term in the binary expression parser.\n // (see link for advice on how to extend for postfix and mixfix operators)\n this.Expression = (minimumPrecedence = 0) => {\n this.Whitespace();\n // First parse a unary expression e.g. \"-a\" or parethensised \"(1 + 2)\"\n let expr = this.ExpressionUnary();\n if (expr === null) {\n return null;\n }\n this.Whitespace();\n // Attempt to parse (possibly multiple) continuing infix expressions (e.g. 1 + 2 + 3)\n while (true) {\n const ruleId = this.BeginRule();\n // Operator\n const infixOp = this.ParseInfixOperator();\n if (infixOp !== null && infixOp.precedence > minimumPrecedence) {\n // Expect right hand side of operator\n const expectationMessage = `right side of '${infixOp.type}' expression`;\n const multiaryExpr = this.Expect(() => this.ExpressionInfixRight(expr, infixOp), expectationMessage);\n if (multiaryExpr === null) {\n // Fail for operator and right-hand side of multiary expression\n this.FailRule(ruleId);\n return null;\n }\n expr = this.SucceedRule(ruleId, multiaryExpr);\n continue;\n }\n this.FailRule(ruleId);\n break;\n }\n this.Whitespace();\n return expr;\n };\n this.ExpressionUnary = () => {\n // Divert target is a special case - it can't have any other operators\n // applied to it, and we also want to check for it first so that we don't\n // confuse \"->\" for subtraction.\n const divertTarget = this.Parse(this.ExpressionDivertTarget);\n if (divertTarget !== null) {\n return divertTarget;\n }\n let prefixOp = this.OneOf([\n this.String(\"-\"),\n this.String(\"!\"),\n ]);\n // Don't parse like the string rules above, in case its actually\n // a variable that simply starts with \"not\", e.g. \"notable\".\n // This rule uses the Identifier rule, which will scan as much text\n // as possible before returning.\n if (prefixOp === null) {\n prefixOp = this.Parse(this.ExpressionNot);\n }\n this.Whitespace();\n // - Since we allow numbers at the start of variable names, variable names are checked before literals\n // - Function calls before variable names in case we see parentheses\n let expr = this.OneOf([\n this.ExpressionList,\n this.ExpressionParen,\n this.ExpressionFunctionCall,\n this.ExpressionVariableName,\n this.ExpressionLiteral,\n ]);\n // Only recurse immediately if we have one of the (usually optional) unary ops\n if (expr === null && prefixOp !== null) {\n expr = this.ExpressionUnary();\n }\n if (expr === null) {\n return null;\n }\n else if (prefixOp !== null) {\n expr = UnaryExpression_1.UnaryExpression.WithInner(expr, prefixOp);\n }\n this.Whitespace();\n const postfixOp = this.OneOf([this.String(\"++\"), this.String(\"--\")]);\n if (postfixOp !== null) {\n const isInc = postfixOp === \"++\";\n if (!(expr instanceof VariableReference_1.VariableReference)) {\n this.Error(`can only increment and decrement variables, but saw '${expr}'.`);\n // Drop down and succeed without the increment after reporting error\n }\n else {\n const varRef = expr;\n expr = new IncDecExpression_1.IncDecExpression(varRef.identifier, isInc);\n }\n }\n return expr;\n };\n this.ExpressionNot = () => {\n const id = this.Identifier();\n if (id === \"not\") {\n return id;\n }\n return null;\n };\n this.ExpressionLiteral = () => this.OneOf([\n this.ExpressionFloat,\n this.ExpressionInt,\n this.ExpressionBool,\n this.ExpressionString,\n ]);\n this.ExpressionDivertTarget = () => {\n this.Whitespace();\n const divert = this.Parse(this.SingleDivert);\n if (!divert || (divert && divert.isThread)) {\n return null;\n }\n this.Whitespace();\n return new DivertTarget_1.DivertTarget(divert);\n };\n this.ExpressionInt = () => {\n const intOrNull = this.ParseInt();\n if (intOrNull === null) {\n return null;\n }\n return new NumberExpression_1.NumberExpression(intOrNull, \"int\");\n };\n this.ExpressionFloat = () => {\n const floatOrNull = this.ParseFloat();\n if (floatOrNull === null) {\n return null;\n }\n return new NumberExpression_1.NumberExpression(floatOrNull, \"float\");\n };\n this.ExpressionString = () => {\n const openQuote = this.ParseString('\"');\n if (openQuote === null) {\n return null;\n }\n // Set custom parser state flag so that within the text parser,\n // it knows to treat the quote character (\") as an end character\n this.parsingStringExpression = true;\n let textAndLogic = this.Parse(this.MixedTextAndLogic);\n this.Expect(this.String('\"'), \"close quote for string expression\");\n this.parsingStringExpression = false;\n if (textAndLogic === null) {\n textAndLogic = [new Text_1.Text(\"\")];\n }\n else if (textAndLogic.find((c) => c instanceof Divert_1.Divert)) {\n this.Error(\"String expressions cannot contain diverts (->)\");\n }\n return new StringExpression_1.StringExpression(textAndLogic);\n };\n this.ExpressionBool = () => {\n const id = this.Parse(this.Identifier);\n if (id === \"true\") {\n return new NumberExpression_1.NumberExpression(true, \"bool\");\n }\n else if (id === \"false\") {\n return new NumberExpression_1.NumberExpression(false, \"bool\");\n }\n return null;\n };\n this.ExpressionFunctionCall = () => {\n const iden = this.Parse(this.IdentifierWithMetadata);\n if (iden === null) {\n return null;\n }\n this.Whitespace();\n const args = this.Parse(this.ExpressionFunctionCallArguments);\n if (args === null) {\n return null;\n }\n return new FunctionCall_1.FunctionCall(iden, args);\n };\n this.ExpressionFunctionCallArguments = () => {\n if (this.ParseString(\"(\") === null) {\n return null;\n }\n // \"Exclude\" requires the rule to succeed, but causes actual comma string to be excluded from the list of results\n const commas = this.Exclude(this.String(\",\"));\n let args = this.Interleave(this.Expression, commas);\n if (args === null) {\n args = [];\n }\n this.Whitespace();\n this.Expect(this.String(\")\"), \"closing ')' for function call\");\n return args;\n };\n this.ExpressionVariableName = () => {\n const path = this.Interleave(this.IdentifierWithMetadata, this.Exclude(this.Spaced(this.String(\".\"))));\n if (path === null || Story_1.Story.IsReservedKeyword(path[0].name)) {\n return null;\n }\n return new VariableReference_1.VariableReference(path);\n };\n this.ExpressionParen = () => {\n if (this.ParseString(\"(\") === null) {\n return null;\n }\n const innerExpr = this.Parse(this.Expression);\n if (innerExpr === null) {\n return null;\n }\n this.Whitespace();\n this.Expect(this.String(\")\"), \"closing parenthesis ')' for expression\");\n return innerExpr;\n };\n this.ExpressionInfixRight = (left, op) => {\n if (!left) {\n return null;\n }\n this.Whitespace();\n const right = this.Parse(() => this.Expression(op.precedence));\n if (right) {\n // We assume that the character we use for the operator's type is the same\n // as that used internally by e.g. Runtime.Expression.Add, Runtime.Expression.Multiply etc\n const expr = new BinaryExpression_1.BinaryExpression(left, right, op.type);\n return expr;\n }\n return null;\n };\n this.ParseInfixOperator = () => {\n for (const op of this._binaryOperators) {\n const ruleId = this.BeginRule();\n if (this.ParseString(op.type) !== null) {\n if (op.requireWhitespace) {\n if (this.Whitespace() === null) {\n this.FailRule(ruleId);\n continue;\n }\n }\n return this.SucceedRule(ruleId, op);\n }\n this.FailRule(ruleId);\n }\n return null;\n };\n this.ExpressionList = () => {\n this.Whitespace();\n if (this.ParseString(\"(\") === null) {\n return null;\n }\n this.Whitespace();\n // When list has:\n // - 0 elements (null list) - this is okay, it's an empty list: \"()\"\n // - 1 element - it could be confused for a single non-list related\n // identifier expression in brackets, but this is a useless thing\n // to do, so we reserve that syntax for a list with one item.\n // - 2 or more elements - normal!\n const memberNames = this.SeparatedList(this.ListMember, this.Spaced(this.String(\",\")));\n this.Whitespace();\n // May have failed to parse the inner list - the parentheses may\n // be for a normal expression\n if (this.ParseString(\")\") === null) {\n return null;\n }\n return new List_1.List(memberNames);\n };\n this.ListMember = () => {\n this.Whitespace();\n let identifier = this.Parse(this.IdentifierWithMetadata);\n if (identifier === null) {\n return null;\n }\n const dot = this.ParseString(\".\");\n if (dot !== null) {\n const identifier2 = this.Expect(this.IdentifierWithMetadata, `element name within the set ${identifier}`);\n identifier.name += `.${identifier2 === null || identifier2 === void 0 ? void 0 : identifier2.name}`;\n }\n this.Whitespace();\n return identifier;\n };\n this.RegisterExpressionOperators = () => {\n // These will be tried in order, so we need \"<=\" before \"<\"\n // for correctness\n this.RegisterBinaryOperator(\"&&\", 1);\n this.RegisterBinaryOperator(\"||\", 1);\n this.RegisterBinaryOperator(\"and\", 1, true);\n this.RegisterBinaryOperator(\"or\", 1, true);\n this.RegisterBinaryOperator(\"==\", 2);\n this.RegisterBinaryOperator(\">=\", 2);\n this.RegisterBinaryOperator(\"<=\", 2);\n this.RegisterBinaryOperator(\"<\", 2);\n this.RegisterBinaryOperator(\">\", 2);\n this.RegisterBinaryOperator(\"!=\", 2);\n // (apples, oranges) + cabbages has (oranges, cabbages) === true\n this.RegisterBinaryOperator(\"?\", 3);\n this.RegisterBinaryOperator(\"has\", 3, true);\n this.RegisterBinaryOperator(\"!?\", 3);\n this.RegisterBinaryOperator(\"hasnt\", 3, true);\n this.RegisterBinaryOperator(\"^\", 3);\n this.RegisterBinaryOperator(\"+\", 4);\n this.RegisterBinaryOperator(\"-\", 5);\n this.RegisterBinaryOperator(\"*\", 6);\n this.RegisterBinaryOperator(\"/\", 7);\n this.RegisterBinaryOperator(\"%\", 8);\n this.RegisterBinaryOperator(\"mod\", 8, true);\n };\n this.RegisterBinaryOperator = (op, precedence, requireWhitespace = false) => {\n const infix = new InfixOperator_1.InfixOperator(op, precedence, requireWhitespace);\n this._binaryOperators.push(infix);\n this._maxBinaryOpLength = Math.max(this._maxBinaryOpLength, op.length);\n };\n this._openFilenames = [];\n this.IncludeStatement = () => {\n this.Whitespace();\n if (this.ParseString(\"INCLUDE\") === null) {\n return null;\n }\n this.Whitespace();\n let filename = this.Expect(() => this.ParseUntilCharactersFromString(\"\\n\\r\"), \"filename for include statement\");\n filename = filename.replace(new RegExp(/[ \\t]+$/g), \"\");\n // Working directory should already have been set up relative to the root ink file.\n const fullFilename = this.fileHandler.ResolveInkFilename(filename, this._filename);\n if (this.FilenameIsAlreadyOpen(fullFilename)) {\n this.Error(`Recursive INCLUDE detected: '${fullFilename}' is already open.`);\n this.ParseUntilCharactersFromString(\"\\r\\n\");\n return new IncludedFile_1.IncludedFile(null);\n }\n else {\n this.AddOpenFilename(fullFilename);\n }\n let includedStory = null;\n let includedString = \"\";\n try {\n includedString = this._rootParser.fileHandler.LoadInkFileContents(fullFilename, this._filename);\n }\n catch (err) {\n this.Error(`Failed to load: '${filename}'.\\nError:${err}`);\n }\n if (includedString != null) {\n const parser = new InkParser(includedString, filename, this._externalErrorHandler, this._rootParser, this.fileHandler);\n includedStory = parser.ParseStory();\n }\n this.RemoveOpenFilename(fullFilename);\n // Return valid IncludedFile object even if there were errors when parsing.\n // We don't want to attempt to re-parse the include line as something else,\n // and we want to include the bits that *are* valid, so we don't generate\n // more errors than necessary.\n return new IncludedFile_1.IncludedFile(includedStory);\n };\n this.FilenameIsAlreadyOpen = (fullFilename) => this._rootParser._openFilenames.includes(fullFilename);\n this.AddOpenFilename = (fullFilename) => {\n this._rootParser._openFilenames.push(fullFilename);\n };\n this.RemoveOpenFilename = (fullFilename) => {\n this._rootParser._openFilenames.splice(this._rootParser._openFilenames.indexOf(fullFilename), 1);\n };\n /**\n * End Include section.\n */\n /**\n * Begin Knot section.\n */\n this.KnotDefinition = () => {\n const knotDecl = this.Parse(this.KnotDeclaration);\n if (knotDecl === null) {\n return null;\n }\n this.Expect(this.EndOfLine, \"end of line after knot name definition\", this.SkipToNextLine);\n const innerKnotStatements = () => this.StatementsAtLevel(StatementLevel_1.StatementLevel.Knot);\n const content = this.Expect(innerKnotStatements, \"at least one line within the knot\", this.KnotStitchNoContentRecoveryRule);\n return new Knot_1.Knot(knotDecl.name, content, knotDecl.args, knotDecl.isFunction);\n };\n this.KnotDeclaration = () => {\n this.Whitespace();\n if (this.KnotTitleEquals() === null) {\n return null;\n }\n this.Whitespace();\n const identifier = this.Parse(this.IdentifierWithMetadata);\n let knotName;\n const isFunc = (identifier === null || identifier === void 0 ? void 0 : identifier.name) === \"function\";\n if (isFunc) {\n this.Expect(this.Whitespace, \"whitespace after the 'function' keyword\");\n knotName = this.Parse(this.IdentifierWithMetadata);\n }\n else {\n knotName = identifier;\n }\n if (knotName === null) {\n this.Error(`Expected the name of the ${isFunc ? \"function\" : \"knot\"}`);\n knotName = new Identifier_1.Identifier(\"\"); // prevent later null ref\n }\n this.Whitespace();\n const parameterNames = this.Parse(this.BracketedKnotDeclArguments);\n this.Whitespace();\n // Optional equals after name\n this.Parse(this.KnotTitleEquals);\n return new FlowDecl_1.FlowDecl(knotName, parameterNames, isFunc);\n };\n this.KnotTitleEquals = () => {\n // 2+ \"=\" starts a knot\n const multiEquals = this.ParseCharactersFromString(\"=\");\n if (multiEquals === null || multiEquals.length <= 1) {\n return null;\n }\n return multiEquals;\n };\n this.StitchDefinition = () => {\n const decl = this.Parse(this.StitchDeclaration);\n if (decl === null) {\n return null;\n }\n this.Expect(this.EndOfLine, \"end of line after stitch name\", this.SkipToNextLine);\n const innerStitchStatements = () => this.StatementsAtLevel(StatementLevel_1.StatementLevel.Stitch);\n const content = this.Expect(innerStitchStatements, \"at least one line within the stitch\", this.KnotStitchNoContentRecoveryRule);\n return new Stitch_1.Stitch(decl.name, content, decl.args, decl.isFunction);\n };\n this.StitchDeclaration = () => {\n this.Whitespace();\n // Single \"=\" to define a stitch\n if (this.ParseString(\"=\") === null) {\n return null;\n }\n // If there's more than one \"=\", that's actually a knot definition (or divert), so this rule should fail\n if (this.ParseString(\"=\") !== null) {\n return null;\n }\n this.Whitespace();\n // Stitches aren't allowed to be functions, but we parse it anyway and report the error later\n const isFunc = this.ParseString(\"function\") !== null;\n if (isFunc) {\n this.Whitespace();\n }\n const stitchName = this.Parse(this.IdentifierWithMetadata);\n if (stitchName === null) {\n return null;\n }\n this.Whitespace();\n const flowArgs = this.Parse(this.BracketedKnotDeclArguments);\n this.Whitespace();\n return new FlowDecl_1.FlowDecl(stitchName, flowArgs, isFunc);\n };\n this.KnotStitchNoContentRecoveryRule = () => {\n // Jump ahead to the next knot or the end of the file\n this.ParseUntil(this.KnotDeclaration, new CharacterSet_1.CharacterSet(\"=\"), null);\n const recoveredFlowContent = [new Text_1.Text(\"<ERROR IN FLOW>\")];\n return recoveredFlowContent;\n };\n this.BracketedKnotDeclArguments = () => {\n if (this.ParseString(\"(\") === null) {\n return null;\n }\n let flowArguments = this.Interleave(this.Spaced(this.FlowDeclArgument), this.Exclude(this.String(\",\")));\n this.Expect(this.String(\")\"), \"closing ')' for parameter list\");\n // If no parameters, create an empty list so that this method is type safe and\n // doesn't attempt to return the ParseSuccess object\n if (flowArguments === null) {\n flowArguments = [];\n }\n return flowArguments;\n };\n this.FlowDeclArgument = () => {\n // Possible forms:\n // name\n // -> name (variable divert target argument\n // ref name\n // ref -> name (variable divert target by reference)\n const firstIden = this.Parse(this.IdentifierWithMetadata);\n this.Whitespace();\n const divertArrow = this.ParseDivertArrow();\n this.Whitespace();\n const secondIden = this.Parse(this.IdentifierWithMetadata);\n if (firstIden == null && secondIden === null) {\n return null;\n }\n const flowArg = new Argument_1.Argument();\n if (divertArrow !== null) {\n flowArg.isDivertTarget = true;\n }\n // Passing by reference\n if (firstIden !== null && firstIden.name === \"ref\") {\n if (secondIden === null) {\n this.Error(\"Expected an parameter name after 'ref'\");\n }\n flowArg.identifier = secondIden;\n flowArg.isByReference = true;\n }\n else {\n // Simple argument name\n if (flowArg.isDivertTarget) {\n flowArg.identifier = secondIden;\n }\n else {\n flowArg.identifier = firstIden;\n }\n if (flowArg.identifier === null) {\n this.Error(\"Expected an parameter name\");\n }\n flowArg.isByReference = false;\n }\n return flowArg;\n };\n this.ExternalDeclaration = () => {\n this.Whitespace();\n const external = this.Parse(this.IdentifierWithMetadata);\n if (external === null || external.name != \"EXTERNAL\") {\n return null;\n }\n this.Whitespace();\n const funcIdentifier = this.Expect(this.IdentifierWithMetadata, \"name of external function\") || new Identifier_1.Identifier(\"\");\n this.Whitespace();\n let parameterNames = this.Expect(this.BracketedKnotDeclArguments, `declaration of arguments for EXTERNAL, even if empty, i.e. 'EXTERNAL ${funcIdentifier}()'`);\n if (parameterNames === null) {\n parameterNames = [];\n }\n const argNames = parameterNames\n .map((arg) => { var _a; return (_a = arg.identifier) === null || _a === void 0 ? void 0 : _a.name; })\n .filter(TypeAssertion_1.filterUndef);\n return new ExternalDeclaration_1.ExternalDeclaration(funcIdentifier, argNames);\n };\n /**\n * End Knot section.\n */\n /**\n * Start Logic section.\n */\n this._identifierCharSet = null;\n this.LogicLine = () => {\n this.Whitespace();\n if (this.ParseString(\"~\") === null) {\n return null;\n }\n this.Whitespace();\n // Some example lines we need to be able to distinguish between:\n // ~ temp x = 5 -- var decl + assign\n // ~ temp x -- var decl\n // ~ x = 5 -- var assign\n // ~ x -- expr (not var decl or assign)\n // ~ f() -- expr\n // We don't treat variable decl/assign as an expression since we don't want an assignment\n // to have a return value, or to be used in compound expressions.\n const afterTilde = () => this.OneOf([\n this.ReturnStatement,\n this.TempDeclarationOrAssignment,\n this.Expression,\n ]);\n let result = this.Expect(afterTilde, \"expression after '~'\", this.SkipToNextLine);\n // Prevent further errors, already reported expected expression and have skipped to next line.\n if (result === null) {\n return new ContentList_1.ContentList();\n }\n // Parse all expressions, but tell the writer off if they did something useless like:\n // ~ 5 + 4\n // And even:\n // ~ false && myFunction()\n // ...since it's bad practice, and won't do what they expect if\n // they're expecting C's lazy evaluation.\n if (result instanceof Expression_1.Expression &&\n !(result instanceof FunctionCall_1.FunctionCall || result instanceof IncDecExpression_1.IncDecExpression)) {\n this.Error(\"Logic following a '~' can't be that type of expression. It can only be something like:\\n\\t~ return\\n\\t~ var x = blah\\n\\t~ x++\\n\\t~ myFunction()\");\n }\n // Line is pure function call? e.g.\n // ~ f()\n // Add extra pop to make sure we tidy up after ourselves.\n // We no longer need anything on the evaluation stack.\n const funCall = (0, TypeAssertion_1.asOrNull)(result, FunctionCall_1.FunctionCall);\n if (funCall) {\n funCall.shouldPopReturnedValue = true;\n }\n // If the expression contains a function call, then it could produce a text side effect,\n // in which case it needs a newline on the end. e.g.\n // ~ printMyName()\n // ~ x = 1 + returnAValueAndAlsoPrintStuff()\n // If no text gets printed, then the extra newline will have to be culled later.\n // Multiple newlines on the output will be removed, so there will be no \"leak\" for\n // long running calculations. It's disappointingly messy though :-/\n if (result.Find(FunctionCall_1.FunctionCall)() !== null) {\n result = new ContentList_1.ContentList(result, new Text_1.Text(\"\\n\"));\n }\n this.Expect(this.EndOfLine, \"end of line\", this.SkipToNextLine);\n return result;\n };\n this.VariableDeclaration = () => {\n this.Whitespace();\n const id = this.Parse(this.Identifier);\n if (id !== \"VAR\") {\n return null;\n }\n this.Whitespace();\n const varName = this.Expect(this.IdentifierWithMetadata, \"variable name\");\n this.Whitespace();\n this.Expect(this.String(\"=\"), \"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)\");\n this.Whitespace();\n const definition = this.Expect(this.Expression, \"initial value for \");\n const expr = definition;\n if (expr) {\n const check = expr instanceof NumberExpression_1.NumberExpression ||\n expr instanceof StringExpression_1.StringExpression ||\n expr instanceof DivertTarget_1.DivertTarget ||\n expr instanceof VariableReference_1.VariableReference ||\n expr instanceof List_1.List;\n if (!check) {\n this.Error(\"initial value for a variable must be a number, constant, list or divert target\");\n }\n if (this.Parse(this.ListElementDefinitionSeparator) !== null) {\n this.Error(\"Unexpected ','. If you're trying to declare a new list, use the LIST keyword, not VAR\");\n }\n else if (expr instanceof StringExpression_1.StringExpression) {\n // Ensure string expressions are simple\n const strExpr = expr;\n if (!strExpr.isSingleString) {\n this.Error(\"Constant strings cannot contain any logic.\");\n }\n }\n const result = new VariableAssignment_1.VariableAssignment({\n assignedExpression: expr,\n isGlobalDeclaration: true,\n variableIdentifier: varName,\n });\n return result;\n }\n return null;\n };\n this.ListDeclaration = () => {\n this.Whitespace();\n const id = this.Parse(this.Identifier);\n if (id != \"LIST\") {\n return null;\n }\n this.Whitespace();\n const varName = this.Expect(this.IdentifierWithMetadata, \"list name\");\n this.Whitespace();\n this.Expect(this.String(\"=\"), \"the '=' for an assignment of the list definition\");\n this.Whitespace();\n const definition = this.Expect(this.ListDefinition, \"list item names\");\n if (definition) {\n definition.identifier = new Identifier_1.Identifier(varName.name);\n return new VariableAssignment_1.VariableAssignment({\n variableIdentifier: varName,\n listDef: definition,\n });\n }\n return null;\n };\n this.ListDefinition = () => {\n this.AnyWhitespace();\n const allElements = this.SeparatedList(this.ListElementDefinition, this.ListElementDefinitionSeparator);\n if (allElements === null) {\n return null;\n }\n return new ListDefinition_1.ListDefinition(allElements);\n };\n this.ListElementDefinitionSeparator = () => {\n this.AnyWhitespace();\n if (this.ParseString(\",\") === null) {\n return null;\n }\n this.AnyWhitespace();\n return \",\";\n };\n this.ListElementDefinition = () => {\n const inInitialList = this.ParseString(\"(\") !== null;\n let needsToCloseParen = inInitialList;\n this.Whitespace();\n const name = this.Parse(this.IdentifierWithMetadata);\n if (name === null) {\n return null;\n }\n this.Whitespace();\n if (inInitialList) {\n if (this.ParseString(\")\") != null) {\n needsToCloseParen = false;\n this.Whitespace();\n }\n }\n let elementValue = null;\n if (this.ParseString(\"=\") !== null) {\n this.Whitespace();\n const elementValueNum = this.Expect(this.ExpressionInt, \"value to be assigned to list item\");\n if (elementValueNum !== null) {\n elementValue = elementValueNum.value;\n }\n if (needsToCloseParen) {\n this.Whitespace();\n if (this.ParseString(\")\") !== null) {\n needsToCloseParen = false;\n }\n }\n }\n if (needsToCloseParen) {\n this.Error(\"Expected closing ')'\");\n }\n return new ListElementDefinition_1.ListElementDefinition(name, inInitialList, elementValue);\n };\n this.ConstDeclaration = () => {\n this.Whitespace();\n const id = this.Parse(this.Identifier);\n if (id !== \"CONST\") {\n return null;\n }\n this.Whitespace();\n const varName = this.Expect(this.IdentifierWithMetadata, \"constant name\");\n this.Whitespace();\n this.Expect(this.String(\"=\"), \"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)\");\n this.Whitespace();\n const expr = this.Expect(this.Expression, \"initial value for \");\n const check = expr instanceof NumberExpression_1.NumberExpression ||\n expr instanceof DivertTarget_1.DivertTarget ||\n expr instanceof StringExpression_1.StringExpression;\n if (!check) {\n this.Error(\"initial value for a constant must be a number or divert target\");\n }\n else if (expr instanceof StringExpression_1.StringExpression) {\n // Ensure string expressions are simple\n const strExpr = expr;\n if (!strExpr.isSingleString) {\n this.Error(\"Constant strings cannot contain any logic.\");\n }\n }\n const result = new ConstantDeclaration_1.ConstantDeclaration(varName, expr);\n return result;\n };\n this.InlineLogicOrGlueOrStartTag = () => this.OneOf([this.InlineLogic, this.Glue, this.StartTag]);\n this.Glue = () => {\n // Don't want to parse whitespace, since it might be important\n // surrounding the glue.\n const glueStr = this.ParseString(\"<>\");\n if (glueStr !== null) {\n return new Glue_1.Glue(new Glue_2.Glue());\n }\n return null;\n };\n this.InlineLogic = () => {\n if (this.ParseString(\"{\") === null) {\n return null;\n }\n let wasParsingString = this.parsingStringExpression;\n let wasTagActive = this.tagActive;\n this.Whitespace();\n const logic = this.Expect(this.InnerLogic, \"some kind of logic, conditional or sequence within braces: { ... }\");\n if (logic === null) {\n this.parsingStringExpression = wasParsingString;\n return null;\n }\n this.DisallowIncrement(logic);\n let contentList = (0, TypeAssertion_1.asOrNull)(logic, ContentList_1.ContentList);\n if (!contentList) {\n contentList = new ContentList_1.ContentList(logic);\n }\n this.Whitespace();\n this.Expect(this.String(\"}\"), \"closing brace '}' for inline logic\");\n // Allow nested strings and logic\n this.parsingStringExpression = wasParsingString;\n // Difference between:\n //\n // 1) A thing # {image}.jpg\n // 2) A {red #red|blue #blue} sequence.\n //\n // When logic ends in (1) we still want tag to continue.\n // When logic ends in (2) we want to auto-end the tag.\n // Side note: we simply disallow tags within strings.\n if (!wasTagActive)\n this.EndTagIfNecessary(contentList);\n return contentList;\n };\n this.InnerLogic = () => {\n this.Whitespace();\n // Explicitly try the combinations of inner logic\n // that could potentially have conflicts first.\n // Explicit sequence annotation?\n const explicitSeqType = this.ParseObject(this.SequenceTypeAnnotation);\n if (explicitSeqType !== null) {\n const contentLists = this.Expect(this.InnerSequenceObjects, \"sequence elements (for cycle/stoping etc)\");\n if (contentLists === null) {\n return null;\n }\n return new Sequence_1.Sequence(contentLists, explicitSeqType);\n }\n // Conditional with expression?\n const initialQueryExpression = this.Parse(this.ConditionExpression);\n if (initialQueryExpression) {\n const conditional = this.Expect(() => this.InnerConditionalContent(initialQueryExpression), \"conditional content following query\");\n return conditional;\n }\n // Now try to evaluate each of the \"full\" rules in turn\n const rules = [\n // Conditional still necessary, since you can have a multi-line conditional\n // without an initial query expression:\n // {\n // - true: this is true\n // - false: this is false\n // }\n this.InnerConditionalContent,\n this.InnerSequence,\n this.InnerExpression,\n ];\n //let wasTagActiveAtStartOfScope = this.tagActive;\n // Adapted from \"OneOf\" structuring rule except that in\n // order for the rule to succeed, it has to maximally\n // cover the entire string within the { }. Used to\n // differentiate between:\n // {myVar} -- Expression (try first)\n // {my content is jolly} -- sequence with single element\n for (const rule of rules) {\n const ruleId = this.BeginRule();\n const result = this.ParseObject(rule);\n if (result) {\n // Not yet at end?\n if (this.Peek(this.Spaced(this.String(\"}\"))) === null) {\n this.FailRule(ruleId);\n }\n else {\n // Full parse of content within braces\n return this.SucceedRule(ruleId, result);\n }\n }\n else {\n this.FailRule(ruleId);\n }\n }\n return null;\n };\n this.InnerExpression = () => {\n const expr = this.Parse(this.Expression);\n if (expr) {\n expr.outputWhenComplete = true;\n }\n return expr;\n };\n this.IdentifierWithMetadata = () => {\n const id = this.Identifier();\n if (id === null) {\n return null;\n }\n return new Identifier_1.Identifier(id);\n };\n // Note: we allow identifiers that start with a number,\n // but not if they *only* comprise numbers\n this.Identifier = () => {\n // Parse remaining characters (if any)\n const name = this.ParseCharactersFromCharSet(this.identifierCharSet);\n if (name === null) {\n return null;\n }\n // Reject if it's just a number\n let isNumberCharsOnly = true;\n for (let c of name) {\n if (!(c >= \"0\" && c <= \"9\")) {\n isNumberCharsOnly = false;\n break;\n }\n }\n if (isNumberCharsOnly) {\n return null;\n }\n return name;\n };\n /**\n * End Logic section.\n */\n /**\n * Begin Sequences section.\n */\n this._sequenceTypeSymbols = new CharacterSet_1.CharacterSet(\"!&~$\");\n this.InnerSequence = () => {\n this.Whitespace();\n // Default sequence type\n let seqType = SequenceType_1.SequenceType.Stopping;\n // Optional explicit sequence type\n const parsedSeqType = this.Parse(this.SequenceTypeAnnotation);\n if (parsedSeqType !== null) {\n seqType = parsedSeqType;\n }\n const contentLists = this.Parse(this.InnerSequenceObjects);\n if (contentLists === null || contentLists.length <= 1) {\n return null;\n }\n return new Sequence_1.Sequence(contentLists, seqType);\n };\n this.SequenceTypeAnnotation = () => {\n let annotation = this.Parse(this.SequenceTypeSymbolAnnotation);\n if (annotation === null) {\n annotation = this.Parse(this.SequenceTypeWordAnnotation);\n }\n if (annotation === null) {\n return null;\n }\n switch (annotation) {\n case SequenceType_1.SequenceType.Once:\n case SequenceType_1.SequenceType.Cycle:\n case SequenceType_1.SequenceType.Stopping:\n case SequenceType_1.SequenceType.Shuffle:\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case SequenceType_1.SequenceType.Shuffle | SequenceType_1.SequenceType.Stopping:\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n case SequenceType_1.SequenceType.Shuffle | SequenceType_1.SequenceType.Once:\n break;\n default:\n this.Error(`Sequence type combination not supported: ${annotation}`);\n return SequenceType_1.SequenceType.Stopping;\n }\n return annotation;\n };\n this.SequenceTypeSymbolAnnotation = () => {\n if (this._sequenceTypeSymbols === null) {\n this._sequenceTypeSymbols = new CharacterSet_1.CharacterSet(\"!&~$ \");\n }\n let sequenceType = 0;\n const sequenceAnnotations = this.ParseCharactersFromCharSet(this._sequenceTypeSymbols);\n if (sequenceAnnotations === null) {\n return null;\n }\n for (const symbolChar of sequenceAnnotations) {\n switch (symbolChar) {\n case \"!\":\n sequenceType |= SequenceType_1.SequenceType.Once;\n break;\n case \"&\":\n sequenceType |= SequenceType_1.SequenceType.Cycle;\n break;\n case \"~\":\n sequenceType |= SequenceType_1.SequenceType.Shuffle;\n break;\n case \"$\":\n sequenceType |= SequenceType_1.SequenceType.Stopping;\n break;\n }\n }\n if (sequenceType === 0) {\n return null;\n }\n return sequenceType;\n };\n this.SequenceTypeWordAnnotation = () => {\n const sequenceTypes = this.Interleave(this.SequenceTypeSingleWord, this.Exclude(this.Whitespace));\n if (sequenceTypes === null || sequenceTypes.length === 0) {\n return null;\n }\n if (this.ParseString(\":\") === null) {\n return null;\n }\n let combinedSequenceType = 0;\n for (const seqType of sequenceTypes) {\n combinedSequenceType |= seqType;\n }\n return combinedSequenceType;\n };\n this.SequenceTypeSingleWord = () => {\n let seqType = null;\n const word = this.Parse(this.IdentifierWithMetadata);\n if (word !== null) {\n switch (word.name) {\n case \"once\":\n seqType = SequenceType_1.SequenceType.Once;\n break;\n case \"cycle\":\n seqType = SequenceType_1.SequenceType.Cycle;\n break;\n case \"shuffle\":\n seqType = SequenceType_1.SequenceType.Shuffle;\n break;\n case \"stopping\":\n seqType = SequenceType_1.SequenceType.Stopping;\n break;\n }\n }\n if (seqType === null) {\n return null;\n }\n return seqType;\n };\n this.InnerSequenceObjects = () => {\n const multiline = this.Parse(this.Newline) !== null;\n let result = null;\n if (multiline) {\n result = this.Parse(this.InnerMultilineSequenceObjects);\n }\n else {\n result = this.Parse(this.InnerInlineSequenceObjects);\n }\n return result;\n };\n this.InnerInlineSequenceObjects = () => {\n const interleavedContentAndPipes = this.Interleave(this.Optional(this.MixedTextAndLogic), this.String(\"|\"), null, false);\n if (interleavedContentAndPipes === null) {\n return null;\n }\n const result = [];\n // The content and pipes won't necessarily be perfectly interleaved in the sense that\n // the content can be missing, but in that case it's intended that there's blank content.\n let justHadContent = false;\n for (const contentOrPipe of interleavedContentAndPipes) {\n // Pipe/separator\n if (contentOrPipe === \"|\") {\n // Expected content, saw pipe - need blank content now\n if (!justHadContent) {\n // Add blank content\n result.push(new ContentList_1.ContentList());\n }\n justHadContent = false;\n }\n else {\n // Real content\n const content = contentOrPipe;\n if (content === null) {\n this.Error(`Expected content, but got ${contentOrPipe} (this is an ink compiler bug!)`);\n }\n else {\n result.push(new ContentList_1.ContentList(content));\n }\n justHadContent = true;\n }\n }\n // Ended in a pipe? Need to insert final blank content\n if (!justHadContent) {\n result.push(new ContentList_1.ContentList());\n }\n return result;\n };\n this.InnerMultilineSequenceObjects = () => {\n this.MultilineWhitespace();\n const contentLists = this.OneOrMore(this.SingleMultilineSequenceElement);\n if (contentLists === null) {\n return null;\n }\n return contentLists;\n };\n this.SingleMultilineSequenceElement = () => {\n this.Whitespace();\n // Make sure we're not accidentally parsing a divert\n if (this.ParseString(\"->\") !== null) {\n return null;\n }\n if (this.ParseString(\"-\") === null) {\n return null;\n }\n this.Whitespace();\n const content = this.StatementsAtLevel(StatementLevel_1.StatementLevel.InnerBlock);\n if (content === null) {\n this.MultilineWhitespace();\n }\n else {\n // Add newline at the start of each branch\n content.unshift(new Text_1.Text(\"\\n\"));\n }\n return new ContentList_1.ContentList(content);\n };\n /**\n * End Sequences section.\n */\n /**\n * Begin Statements section.\n */\n this._statementRulesAtLevel = [];\n this._statementBreakRulesAtLevel = [];\n this.StatementsAtLevel = (level) => {\n // Check for error: Should not be allowed gather dashes within an inner block\n if (level === StatementLevel_1.StatementLevel.InnerBlock) {\n const badGatherDashCount = this.Parse(this.GatherDashes);\n if (badGatherDashCount !== null) {\n this.Error(\"You can't use a gather (the dashes) within the { curly braces } context. For multi-line sequences and conditions, you should only use one dash.\");\n }\n }\n return this.Interleave(this.Optional(this.MultilineWhitespace), () => this.StatementAtLevel(level), () => this.StatementsBreakForLevel(level));\n };\n this.StatementAtLevel = (level) => {\n const rulesAtLevel = this._statementRulesAtLevel[level];\n const statement = this.OneOf(rulesAtLevel);\n // For some statements, allow them to parse, but create errors, since\n // writers may think they can use the statement, so it's useful to have\n // the error message.\n if (level === StatementLevel_1.StatementLevel.Top) {\n if (statement instanceof ReturnType_1.ReturnType) {\n this.Error(\"should not have return statement outside of a knot\");\n }\n }\n return statement;\n };\n this.StatementsBreakForLevel = (level) => {\n this.Whitespace();\n const breakRules = this._statementBreakRulesAtLevel[level];\n const breakRuleResult = this.OneOf(breakRules);\n if (breakRuleResult === null) {\n return null;\n }\n return breakRuleResult;\n };\n this.GenerateStatementLevelRules = () => {\n const levels = Object.values(StatementLevel_1.StatementLevel);\n this._statementRulesAtLevel = \"f\"\n .repeat(levels.length)\n .split(\"f\")\n .map(() => []);\n this._statementBreakRulesAtLevel = \"f\"\n .repeat(levels.length)\n .split(\"f\")\n .map(() => []);\n for (const level of levels) {\n const rulesAtLevel = [];\n const breakingRules = [];\n // Diverts can go anywhere\n rulesAtLevel.push(this.Line(this.MultiDivert));\n // Knots can only be parsed at Top/Global scope\n if (level >= StatementLevel_1.StatementLevel.Top) {\n rulesAtLevel.push(this.KnotDefinition);\n }\n rulesAtLevel.push(this.Line(this.Choice));\n rulesAtLevel.push(this.Line(this.AuthorWarning));\n // Gather lines would be confused with multi-line block separators, like\n // within a multi-line if statement\n if (level > StatementLevel_1.StatementLevel.InnerBlock) {\n rulesAtLevel.push(this.Gather);\n }\n // Stitches (and gathers) can (currently) only go in Knots and top level\n if (level >= StatementLevel_1.StatementLevel.Knot) {\n rulesAtLevel.push(this.StitchDefinition);\n }\n // Global variable declarations can go anywhere\n rulesAtLevel.push(this.Line(this.ListDeclaration));\n rulesAtLevel.push(this.Line(this.VariableDeclaration));\n rulesAtLevel.push(this.Line(this.ConstDeclaration));\n rulesAtLevel.push(this.Line(this.ExternalDeclaration));\n // Global include can go anywhere\n rulesAtLevel.push(this.Line(this.IncludeStatement));\n // Normal logic / text can go anywhere\n rulesAtLevel.push(this.LogicLine);\n rulesAtLevel.push(this.LineOfMixedTextAndLogic);\n // --------\n // Breaking rules\n // Break current knot with a new knot\n if (level <= StatementLevel_1.StatementLevel.Knot) {\n breakingRules.push(this.KnotDeclaration);\n }\n // Break current stitch with a new stitch\n if (level <= StatementLevel_1.StatementLevel.Stitch) {\n breakingRules.push(this.StitchDeclaration);\n }\n // Breaking an inner block (like a multi-line condition statement)\n if (level <= StatementLevel_1.StatementLevel.InnerBlock) {\n breakingRules.push(this.ParseDashNotArrow);\n breakingRules.push(this.String(\"}\"));\n }\n this._statementRulesAtLevel[level] = rulesAtLevel;\n this._statementBreakRulesAtLevel[level] = breakingRules;\n }\n };\n this.SkipToNextLine = () => {\n this.ParseUntilCharactersFromString(\"\\n\\r\");\n this.ParseNewline();\n return StringParser_1.ParseSuccess;\n };\n // Modifier to turn a rule into one that expects a newline on the end.\n // e.g. anywhere you can use \"MixedTextAndLogic\" as a rule, you can use\n // \"Line(MixedTextAndLogic)\" to specify that it expects a newline afterwards.\n this.Line = (inlineRule) => () => {\n const result = this.ParseObject(inlineRule);\n if (result === null) {\n return null;\n }\n this.Expect(this.EndOfLine, \"end of line\", this.SkipToNextLine);\n return result;\n };\n /**\n * End Statements section.\n */\n /**\n * Begin Tags section.\n */\n this.StartTag = () => {\n this.Whitespace();\n if (this.ParseString(\"#\") === null) {\n return null;\n }\n if (this.parsingStringExpression) {\n this.Error(\"Tags aren't allowed inside of strings. Please use \\\\# if you want a hash symbol.\");\n }\n let result = null;\n if (this.tagActive) {\n let contentList = new ContentList_1.ContentList();\n contentList.AddContent(new Tag_1.Tag(/*isStart:*/ false));\n contentList.AddContent(new Tag_1.Tag(/*isStart:*/ true));\n result = contentList;\n }\n else {\n result = new Tag_1.Tag(/*isStart:*/ true);\n }\n this.tagActive = true;\n this.Whitespace();\n return result;\n };\n /**\n * End Tags section.\n */\n /**\n * Begin Whitespace section.\n */\n this._inlineWhitespaceChars = new CharacterSet_1.CharacterSet(\" \\t\");\n // Handles both newline and endOfFile\n this.EndOfLine = () => this.OneOf([this.Newline, this.EndOfFile]);\n // Allow whitespace before the actual newline\n this.Newline = () => {\n this.Whitespace();\n const gotNewline = this.ParseNewline() !== null;\n // Optional \\r, definite \\n to support Windows (\\r\\n) and Mac/Unix (\\n)\n if (!gotNewline) {\n return null;\n }\n return StringParser_1.ParseSuccess;\n };\n this.EndOfFile = () => {\n this.Whitespace();\n if (!this.endOfInput)\n return null;\n return StringParser_1.ParseSuccess;\n };\n // General purpose space, returns N-count newlines (fails if no newlines)\n this.MultilineWhitespace = () => {\n let newlines = this.OneOrMore(this.Newline);\n if (newlines === null) {\n return null;\n }\n // Use content field of Token to say how many newlines there were\n // (in most circumstances it's unimportant)\n const numNewlines = newlines.length;\n if (numNewlines >= 1) {\n return StringParser_1.ParseSuccess;\n }\n return null;\n };\n this.Whitespace = () => {\n const doneParsed = this.ParseCharactersFromCharSet(this._inlineWhitespaceChars);\n if (doneParsed !== null) {\n return StringParser_1.ParseSuccess;\n }\n return null;\n };\n this.Spaced = (rule) => () => {\n this.Whitespace();\n const result = this.ParseObject(rule);\n if (result === null) {\n return null;\n }\n this.Whitespace();\n return result;\n };\n this.AnyWhitespace = () => {\n let anyWhitespace = false;\n while (this.OneOf([this.Whitespace, this.MultilineWhitespace]) !== null) {\n anyWhitespace = true;\n }\n return anyWhitespace ? StringParser_1.ParseSuccess : null;\n };\n this.MultiSpaced = (rule) => () => {\n this.AnyWhitespace();\n const result = this.ParseObject(rule);\n if (result === null) {\n return null;\n }\n this.AnyWhitespace();\n return result;\n };\n this._filename = null;\n this._externalErrorHandler = null;\n this._fileHandler = null;\n this._filename = filename;\n this.RegisterExpressionOperators();\n this.GenerateStatementLevelRules();\n this.errorHandler = this.OnStringParserError;\n this._externalErrorHandler = externalErrorHandler;\n if (fileHandler === null) {\n this._fileHandler = new DefaultFileHandler_1.DefaultFileHandler();\n }\n else {\n this._fileHandler = fileHandler;\n }\n if (rootParser === null) {\n this._rootParser = this;\n this._openFilenames = [];\n if (this._filename !== null) {\n const fullRootInkPath = this.fileHandler.ResolveInkFilename(this._filename);\n this._openFilenames.push(fullRootInkPath);\n }\n }\n else {\n this._rootParser = rootParser;\n }\n }\n PreProcessInputString(str) {\n const commentEliminator = new CommentEliminator_1.CommentEliminator(str);\n return commentEliminator.Process();\n }\n get parsingStringExpression() {\n return this.GetFlag(Number(CustomFlags_1.CustomFlags.ParsingString));\n }\n set parsingStringExpression(value) {\n this.SetFlag(Number(CustomFlags_1.CustomFlags.ParsingString), value);\n }\n get tagActive() {\n return this.GetFlag(Number(CustomFlags_1.CustomFlags.TagActive));\n }\n set tagActive(value) {\n this.SetFlag(Number(CustomFlags_1.CustomFlags.TagActive), value);\n }\n get identifierCharSet() {\n if (this._identifierCharSet === null) {\n (this._identifierCharSet = new CharacterSet_1.CharacterSet())\n .AddRange(\"A\", \"Z\")\n .AddRange(\"a\", \"z\")\n .AddRange(\"0\", \"9\")\n .Add(\"_\");\n // Enable non-ASCII characters for story identifiers.\n this.ExtendIdentifierCharacterRanges(this._identifierCharSet);\n }\n return this._identifierCharSet;\n }\n EndTagIfNecessary(outputContentList) {\n if (this.tagActive) {\n if (outputContentList != null) {\n if (outputContentList instanceof ContentList_1.ContentList) {\n outputContentList.AddContent(new Tag_1.Tag(/*isStart:*/ false));\n }\n else {\n outputContentList.push(new Tag_1.Tag(/*isStart:*/ false));\n }\n }\n this.tagActive = false;\n }\n }\n}\nexports.InkParser = InkParser;\n/**\n * End base InkParser section.\n */\n/**\n * Begin CharacterRanges section.\n */\nInkParser.LatinBasic = CharacterRange_1.CharacterRange.Define(\"\\u0041\", \"\\u007A\", new CharacterSet_1.CharacterSet().AddRange(\"\\u005B\", \"\\u0060\"));\nInkParser.LatinExtendedA = CharacterRange_1.CharacterRange.Define(\"\\u0100\", \"\\u017F\"\n// no excludes here\n);\nInkParser.LatinExtendedB = CharacterRange_1.CharacterRange.Define(\"\\u0180\", \"\\u024F\"\n// no excludes here\n);\nInkParser.Greek = CharacterRange_1.CharacterRange.Define(\"\\u0370\", \"\\u03FF\", new CharacterSet_1.CharacterSet()\n .AddRange(\"\\u0378\", \"\\u0385\")\n .AddCharacters(\"\\u0374\\u0375\\u0378\\u0387\\u038B\\u038D\\u03A2\"));\nInkParser.Cyrillic = CharacterRange_1.CharacterRange.Define(\"\\u0400\", \"\\u04FF\", new CharacterSet_1.CharacterSet().AddRange(\"\\u0482\", \"\\u0489\"));\nInkParser.Armenian = CharacterRange_1.CharacterRange.Define(\"\\u0530\", \"\\u058F\", new CharacterSet_1.CharacterSet()\n .AddCharacters(\"\\u0530\")\n .AddRange(\"\\u0557\", \"\\u0560\")\n .AddRange(\"\\u0588\", \"\\u058E\"));\nInkParser.Hebrew = CharacterRange_1.CharacterRange.Define(\"\\u0590\", \"\\u05FF\", new CharacterSet_1.CharacterSet());\nInkParser.Arabic = CharacterRange_1.CharacterRange.Define(\"\\u0600\", \"\\u06FF\", new CharacterSet_1.CharacterSet());\nInkParser.Korean = CharacterRange_1.CharacterRange.Define(\"\\uAC00\", \"\\uD7AF\", new CharacterSet_1.CharacterSet());\nInkParser.Latin1Supplement = CharacterRange_1.CharacterRange.Define(\"\\u0080\", \"\\u00FF\", new CharacterSet_1.CharacterSet());\nInkParser.Chinese = CharacterRange_1.CharacterRange.Define(\"\\u4E00\", \"\\u9FFF\", new CharacterSet_1.CharacterSet());\n/// <summary>\n/// Gets an array of <see cref=\"CharacterRange\" /> representing all of the currently supported\n/// non-ASCII character ranges that can be used in identifier names.\n/// </summary>\n/// <returns>\n/// An array of <see cref=\"CharacterRange\" /> representing all of the currently supported\n/// non-ASCII character ranges that can be used in identifier names.\n/// </returns>\nInkParser.ListAllCharacterRanges = () => [\n InkParser.LatinBasic,\n InkParser.LatinExtendedA,\n InkParser.LatinExtendedB,\n InkParser.Arabic,\n InkParser.Armenian,\n InkParser.Cyrillic,\n InkParser.Greek,\n InkParser.Hebrew,\n InkParser.Korean,\n InkParser.Latin1Supplement,\n InkParser.Chinese,\n];\n//# sourceMappingURL=InkParser.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GenerateStoryStats = void 0;\nconst Choice_1 = require(\"./Parser/ParsedHierarchy/Choice\");\nconst Divert_1 = require(\"./Parser/ParsedHierarchy/Divert/Divert\");\nconst Gather_1 = require(\"./Parser/ParsedHierarchy/Gather/Gather\");\nconst Knot_1 = require(\"./Parser/ParsedHierarchy/Knot\");\nconst Stitch_1 = require(\"./Parser/ParsedHierarchy/Stitch\");\nconst Text_1 = require(\"./Parser/ParsedHierarchy/Text\");\nfunction GenerateStoryStats(story) {\n let allText = story.FindAll(Text_1.Text)();\n let words = 0;\n for (const text of allText) {\n let wordsInThisStr = 0;\n let wasWhiteSpace = true;\n for (const c of text.text) {\n if (c == \" \" || c == \"\\t\" || c == \"\\n\" || c == \"\\r\") {\n wasWhiteSpace = true;\n }\n else if (wasWhiteSpace) {\n wordsInThisStr++;\n wasWhiteSpace = false;\n }\n }\n words += wordsInThisStr;\n }\n const knots = story.FindAll(Knot_1.Knot)();\n const stitches = story.FindAll(Stitch_1.Stitch)();\n const choices = story.FindAll(Choice_1.Choice)();\n const gathers = story.FindAll(Gather_1.Gather)((g) => g.debugMetadata != null);\n const diverts = story.FindAll(Divert_1.Divert)();\n return {\n words,\n knots: knots.length,\n functions: knots.filter((k) => k.isFunction).length,\n stitches: stitches.length,\n gathers: gathers.length,\n diverts: diverts.length - 1,\n choices: choices.length,\n };\n}\nexports.GenerateStoryStats = GenerateStoryStats;\n//# sourceMappingURL=Stats.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.JsonFileHandler = void 0;\nclass JsonFileHandler {\n constructor(fileHierarchy) {\n this.fileHierarchy = fileHierarchy;\n this.ResolveInkFilename = (filename) => {\n if (Object.keys(this.fileHierarchy).includes(filename))\n return filename;\n throw new Error(`Cannot locate ${filename}. Are you trying a relative import ? This is not yet implemented.`);\n };\n this.LoadInkFileContents = (filename) => {\n if (Object.keys(this.fileHierarchy).includes(filename)) {\n return this.fileHierarchy[filename];\n }\n else {\n throw new Error(`Cannot open ${filename}.`);\n }\n };\n }\n}\nexports.JsonFileHandler = JsonFileHandler;\n//# sourceMappingURL=JsonFileHandler.js.map","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Compiler = exports.Story = exports.InkList = exports.JsonFileHandler = exports.StatementLevel = exports.InkParser = exports.CompilerOptions = void 0;\nconst CompilerOptions_1 = require(\"./CompilerOptions\");\nconst DebugSourceRange_1 = require(\"./DebugSourceRange\");\nconst ErrorType_1 = require(\"./Parser/ErrorType\");\nconst InkParser_1 = require(\"./Parser/InkParser\");\nconst Value_1 = require(\"../engine/Value\");\nconst TypeAssertion_1 = require(\"../engine/TypeAssertion\");\nconst Stats_1 = require(\"./Stats\");\nvar CompilerOptions_2 = require(\"./CompilerOptions\");\nObject.defineProperty(exports, \"CompilerOptions\", { enumerable: true, get: function () { return CompilerOptions_2.CompilerOptions; } });\nvar InkParser_2 = require(\"./Parser/InkParser\");\nObject.defineProperty(exports, \"InkParser\", { enumerable: true, get: function () { return InkParser_2.InkParser; } });\nvar StatementLevel_1 = require(\"./Parser/StatementLevel\");\nObject.defineProperty(exports, \"StatementLevel\", { enumerable: true, get: function () { return StatementLevel_1.StatementLevel; } });\nvar JsonFileHandler_1 = require(\"./FileHandler/JsonFileHandler\");\nObject.defineProperty(exports, \"JsonFileHandler\", { enumerable: true, get: function () { return JsonFileHandler_1.JsonFileHandler; } });\nvar Story_1 = require(\"../engine/Story\");\nObject.defineProperty(exports, \"InkList\", { enumerable: true, get: function () { return Story_1.InkList; } });\nObject.defineProperty(exports, \"Story\", { enumerable: true, get: function () { return Story_1.Story; } });\nclass Compiler {\n get errors() {\n return this._errors;\n }\n get warnings() {\n return this._warnings;\n }\n get authorMessages() {\n return this._authorMessages;\n }\n get inputString() {\n return this._inputString;\n }\n get options() {\n return this._options;\n }\n get parsedStory() {\n if (!this._parsedStory) {\n throw new Error();\n }\n return this._parsedStory;\n }\n get runtimeStory() {\n if (!this._runtimeStory) {\n throw new Error(\"Compilation failed.\");\n }\n return this._runtimeStory;\n }\n get parser() {\n if (!this._parser) {\n throw new Error();\n }\n return this._parser;\n }\n get debugSourceRanges() {\n return this._debugSourceRanges;\n }\n constructor(inkSource, options = null) {\n this._errors = [];\n this._warnings = [];\n this._authorMessages = [];\n this._parsedStory = null;\n this._runtimeStory = null;\n this._parser = null;\n this._debugSourceRanges = [];\n this.Compile = () => {\n this._parser = new InkParser_1.InkParser(this.inputString, this.options.sourceFilename || null, this.OnError, null, this.options.fileHandler);\n this._parsedStory = this.parser.ParseStory();\n if (this.errors.length === 0) {\n this.parsedStory.countAllVisits = this.options.countAllVisits;\n this._runtimeStory = this.parsedStory.ExportRuntime(this.OnError);\n }\n else {\n this._runtimeStory = null;\n }\n return this.runtimeStory;\n };\n this.RetrieveDebugSourceForLatestContent = () => {\n var _a;\n for (const outputObj of this.runtimeStory.state.outputStream) {\n const textContent = (0, TypeAssertion_1.asOrNull)(outputObj, Value_1.StringValue);\n if (textContent !== null) {\n const range = new DebugSourceRange_1.DebugSourceRange(((_a = textContent.value) === null || _a === void 0 ? void 0 : _a.length) || 0, textContent.debugMetadata, textContent.value || \"unknown\");\n this.debugSourceRanges.push(range);\n }\n }\n };\n this.GenerateStats = () => {\n if (this._parsedStory === null) {\n return null;\n }\n return (0, Stats_1.GenerateStoryStats)(this._parsedStory);\n };\n this.DebugMetadataForContentAtOffset = (offset) => {\n let currOffset = 0;\n let lastValidMetadata = null;\n for (const range of this.debugSourceRanges) {\n if (range.debugMetadata !== null) {\n lastValidMetadata = range.debugMetadata;\n }\n if (offset >= currOffset && offset < currOffset + range.length) {\n return lastValidMetadata;\n }\n currOffset += range.length;\n }\n return null;\n };\n this.OnError = (message, errorType) => {\n switch (errorType) {\n case ErrorType_1.ErrorType.Author:\n this._authorMessages.push(message);\n break;\n case ErrorType_1.ErrorType.Warning:\n this._warnings.push(message);\n break;\n case ErrorType_1.ErrorType.Error:\n this._errors.push(message);\n break;\n }\n if (this.options.errorHandler !== null) {\n this.options.errorHandler(message, errorType);\n }\n };\n this._inputString = inkSource;\n this._options = options || new CompilerOptions_1.CompilerOptions();\n }\n}\nexports.Compiler = Compiler;\n//# sourceMappingURL=Compiler.js.map","import { Story } from 'inkjs/engine/Story';\nimport { Compiler } from 'inkjs/compiler/Compiler';\nimport { CompilerOptions } from 'inkjs/compiler/CompilerOptions';\nimport { InkStory } from './story/InkStory';\nimport type { FileHandler, InkStoryOptions } from './types';\nimport { BaseFileHandler } from './types';\n\nclass InkjsFileHandler {\n\tprivate handler: FileHandler;\n\tprivate resolve: (filename: string) => string;\n\n\tconstructor(handler: FileHandler) {\n\t\tthis.handler = handler;\n\t\tthis.resolve = handler instanceof BaseFileHandler\n\t\t\t? (f: string) => handler.resolveFilename(f)\n\t\t\t: (f: string) => f;\n\t}\n\n\treadonly ResolveInkFilename = (filename: string): string => {\n\t\treturn this.resolve(filename);\n\t};\n\n\treadonly LoadInkFileContents = (filename: string): string => {\n\t\treturn this.handler.loadFile(filename);\n\t};\n}\n\nfunction isCompiledJson(input: string): boolean {\n\tconst trimmed = input.trim();\n\treturn trimmed.startsWith('{') && trimmed.endsWith('}');\n}\n\nexport function createInkStory(\n\tsource: string | Story,\n\toptions?: InkStoryOptions\n): InkStory {\n\tlet story: Story;\n\n\tif (source instanceof Story) {\n\t\tstory = source;\n\t} else if (typeof source === 'string') {\n\t\tif (isCompiledJson(source)) {\n\t\t\tstory = new Story(source);\n\t\t} else {\n\t\t\tconst inkjsHandler = options?.fileHandler\n\t\t\t\t? new InkjsFileHandler(options.fileHandler)\n\t\t\t\t: null;\n\t\t\tconst compilerOptions = new CompilerOptions(null, [], false, null, inkjsHandler);\n\t\t\tconst compiler = new Compiler(source, compilerOptions);\n\t\t\tstory = compiler.Compile();\n\t\t}\n\t} else {\n\t\tthrow new Error('Invalid source type: expected string or Story');\n\t}\n\n\treturn new InkStory(story, options?.title || 'Ink Story', options);\n}"],"names":["createSelectors","_store","store","_","prop","s","contentsStore","create","set","contents","content","state","CHOICE_SEPARATOR","DEFAULT_STORY_OPTIONS","BaseFileHandler","options","__publicField","filename","_filename","Choice$2","text","index","type","_Tags","key","tagName","callback","ink","inputString","splitTag","splitAtCharacter","_a","newValue","Tags","character","splitIndex","_ChoiceParser","tag","item","choice","ChoiceParser","new_choice","choicesStore","ink_choices","choices","Choice","variablesStore","variablesState","globalVars","globalVariables","entry","_Patches","value","patchOptions","story","storyCtx","patch","Patches","_Parser","pattern","tags","line","Parser","_ExternalFunctions","id","func","externalFunction","ExternalFunctions","InkStory","title","m","match","bindFunctions","newContent","current_text","currentChoices","clear","effect","cleanup","target","prototype","property","targetRecord","CompilerOptions_1","CompilerOptions$1","sourceFilename","pluginNames","countAllVisits","errorHandler","fileHandler","CompilerOptions","DebugSourceRange_1","DebugSourceRange$1","length","debugMetadata","DebugSourceRange","ErrorType_1","ErrorType","Argument_1","Argument$1","identifier","isByReference","isDivertTarget","Argument","TypeAssertion","asOrNull","obj","unsafeTypeAssertion","asOrThrows","asNumberOrThrows","asBooleanOrThrows","asINamedContentOrNull","nullIfUndefined","isEquatable","filterUndef","element","_Object","TypeAssertion_1","require$$0","ParsedObject","subContent","sub","ss","queryFunc","tObj","nestedResult","foundSoFar","found","message","source","ancestor","result","context","isWarning","AuthorWarning_1","Object_1","AuthorWarning$1","warningMessage","AuthorWarning","Path_1","Path","componentsString","head","tail","relative","tailComps","lastComponentIdx","i","l","path","pathToAppend","p","upwardMoves","componentStrings","str","otherPath","c","Component","indexOrName","otherComp","Debug_1","Debug","AssertType","variable","Assert","condition","NullException_1","NullException","throwNullException","name","Container_1","require$$1","require$$2","require$$3","require$$4","InkObject","root","targetContent","dm","comps","child","container","namedChild","nearestContainer","contentContainer","globalPath","ownPath","minPathLength","lastSharedPathCompIndex","ownComp","numUpwardsMoves","newPathComps","up","down","globalPathStr","relativePathStr","StringBuilder_1","StringBuilder$1","format","args","num","StringBuilder","InkList_1","InkListItem","originName","itemName","nameParts","otherItem","inkListItem","InkList","otherList","otherOriginNames","singleOriginListName","originStory","def","singleElement","myListItem","listValue","itemOrItemName","storyObject","origin","intVal","foundListDef","newItem","itemVal","serializedKey","maxOriginName","initialOriginName","initialOriginNames","max","min","list","union","intersection","listToRemove","what","minBound","maxBound","ordered","minValue","maxValue","subList","otherInkList","x","y","sb","StoryException_1","StoryException","TryGetResult","tryGetValueFromMap","map","val","tryParseInt","defaultValue","tryParseFloat","Value_1","TryGetResult_1","require$$5","require$$6","AbstractValue","preferredNumberType","ValueType","IntValue","FloatValue","BoolValue","StringValue","DivertTargetValue","ListValue","targetType","Value","newType","parsedInt","parsedFloat","targetPath","VariablePointerValue","variableName","contextIndex","listOrSingleItem","singleValue","oldValue","oldList","newList","SearchResult_1","SearchResult$1","SearchResult","searchResult","require$$7","require$$8","Container$1","Container","namedOnlyContentDict","inkObject","named","existingNamedOnly","flags","flag","components","contentObjOrList","contentList","contentObj","namedContentObj","runtimeObj","partialPathStart","partialPathLength","currentContainer","currentObj","comp","foundObj","nextContainer","otherContainer","component","foundContent","indentation","pointedObj","appendIndentation","onlyNamed","CountFlags","ControlCommand_1","ControlCommand$1","ControlCommand","commandType","CommandType","Expression_1","Expression$1","copy","Expression","Void_1","Void$1","Void","NativeFunctionCall_1","NativeFunctionCall$1","NativeFunctionCall","functionName","parameters","hasList","coercedParams","coercedType","parametersOfSingleType","param1","valType","val1","paramCount","opForTypeObj","val2","opForType","resultVal","v1","v2","op","listIntParams","listVal","resultInkList","listItemKey","listItemValue","listItem","intOp","targetInt","itemOrigin","incrementedItem","parametersIn","specialCaseList","parametersOut","inkObjectVal","castedValue","numberOfParameters","t","divertTargetsEqual","d1","d2","divertTargetsNotEqual","nativeFunc","NumberExpression_1","NumberExpression$1","NumberExpression","subtype","numberExpression","UnaryExpression_1","UnaryExpression$1","inner","UnaryExpression","innerNumber","BinaryExpression_1","BinaryExpression$1","left","right","opName","leftUnary","BinaryExpression","CharacterSet_1","CharacterSet$1","arg","start","end","chars","CharacterSet","CharacterRange_1","CharacterRange$1","_start","_end","excludes","ii","CharacterRange","ChoicePoint_1","ChoicePoint$1","onceOnly","choiceTargetObj","ChoicePoint","PushPop","PushPopType","Pointer_1","Pointer$1","Pointer","Divert_1","PushPop_1","Divert","targetObj","stackPushType","otherDivert","targetStr","SymbolType_1","SymbolType","VariableAssignment_1","VariableAssignment","isNewDeclaration","Choice_1","startContent","choiceOnlyContent","innerContent","varAssign","varDivert","choiceOnlyRuntimeContent","innerChoiceOnlyContent","StringParserElement_1","StringParserElement$1","StringParserElement","fromElement","StringParserState_1","StringParserState$1","prevElement","newElement","expectedRuleId","penultimateEl","lastEl","el","kExpectedMaxStackDepth","StringParserState","exports","StringParser","stateAtSucceedRule","stateAtBeginRule","finalResult","rule","recoveryRule","butSaw","lineRemainder","lineNumber","errorType","trueOrFalse","ruleId","stackHeightBefore","array","results","flatten","resultCollection","ruleA","ruleB","untilTerminator","firstA","lastMainResult","outerResult","cli","li","success","tempIdx","maxCount","charSet","maxCountOrShouldIncludeStrChars","shouldIncludeChars","startIndex","count","oldIndex","oldCharacterInLineIndex","negative","parsedString","leadingInt","afterDecimalPointStr","strPreProc","stopRule","pauseCharacters","endCharacters","pauseAndEnd","ruleResultAtPause","partialParsedString","pauseCharacter","CommentEliminator_1","StringParser_1","CommentEliminator$1","stringList","newLines","startLineIndex","commentResult","CommentEliminator","Conditional_1","Conditional$1","initialCondition","branches","branch","branchContainer","pathToReJoin","Conditional","Text_1","Text$1","Text","ConstantDeclaration_1","ConstantDeclaration$1","assignedExpression","ConstantDeclaration","FlowLevel_1","FlowLevel","Gather_1","Gather$1","indentationDepth","_b","Gather","FlowBase_1","Weave_1","Path$1","argOne","argTwo","baseTargetObject","originalContext","firstComp","ancestorContext","deepSearch","foundBase","rootTarget","foundComponent","compName","minimumExpectedLevel","foundFlow","childName","minimumLevel","forceDeepSearch","ambiguousChildLevel","weaveContext","flowContext","shouldDeepSearch","ReturnType_1","ReturnType$1","returnedExpression","ReturnType","ClosestFlowBase_1","ClosestFlowBase","Identifier_1","Identifier$1","Identifier","DivertTarget_1","Divert_2","require$$9","require$$10","require$$11","require$$12","require$$13","require$$14","require$$15","FlowBase$1","FlowBase","topLevelObjects","isFunction","isIncludedStory","contentObjs","isRootStory","weaveObjs","subFlowObjs","subFlow","finalContent","varName","fromNode","ownerFlow","varDecl","varab","prevDeclError","foundReturn","contentIdx","childFlow","childFlowRuntime","existingChild","errorMsg","paramName","assign","level","weavePointResult","weaveResultSelf","deepResult","allDiverts","divert","allChoices","terminatingObject","terminatingDivert","jj","symbolType","ContentList_1","ContentList$1","objects","moreObjects","contentObjRuntime","ContentList","VariableReference_1","VariableReference$1","VariableReference","VariableReference_2","pathIdentifiers","constantValue","listItemName","listName","parsedPath","targetForCount","targetFlow","FunctionCall_1","Value_2","FunctionCall$1","FunctionCall","foundList","usingProxyDivert","divertTarget","variableDivertTarget","nativeCall","msg","strArgs","attemptingTurnCountOfVariableTarget","targetObject","runtimeVarRef","MultipleConditionExpression_1","MultipleConditionExpression$1","conditionExpressions","isFirst","conditionExpr","MultipleConditionExpression","ConditionalSingleBranch_1","DivertTarget$1","DivertTarget","otherDivTarget","otherTargetStr","usageContext","badUsage","foundUsage","usageParent","binaryExprParent","funcCall","parentFunc","Path_2","Divert$1","requiresArgCodeGen","targetArguments","argToPass","argExpected","varRef","varPointer","variableTargetName","flowBaseScope","resolveResult","argument","a","numArgs","butClause","flowArg","divArgExpr","knotCountPath","externalName","external","externalArgCount","ownArgCount","returnString","targetWasFound","isBuiltIn","isExternal","GatherPointToResolve_1","GatherPointToResolve$1","targetRuntimeObj","GatherPointToResolve","SequenceDivertToResolve_1","SequenceDivertToResolve$1","SequenceDivertToResolve","SequenceType_1","SequenceType","Sequence_1","Sequence$1","elementContentLists","sequenceType","once","cycle","stopping","shuffle","seqBranchCount","postShuffleNoOp","lastIdx","skipShuffleDivert","elementCountToShuffle","postSequenceNoOp","elIndex","sequenceDivert","contentContainerForSequenceBranch","seqBranchCompleteDivert","elementContentList","seqElObject","toResolve","Sequence","TunnelOnwards_1","TunnelOnwards$1","returnRuntimeObj","returnRuntimeContainer","evalStart","evalEnd","cmd","returnDivertObj","TunnelOnwards","ListDefinition_1","ListDefinition$1","items","ListDefinition","ListDefinition_2","InkList_2","allItems","e","itemDefinitions","initialValues","itemDef","currentValue","VariableAssignment_2","VariableAssignment$1","isGlobalDeclaration","isTemporaryNewDeclaration","listDef","variableIdentifier","newDeclScope","variableReference","resolvedVarAssignment","require$$16","Weave$1","Weave","lastObject","lastText","lastWeave","cont","indentIndex","_c","namedWeavePoints","w","weavePoint","existingWeavePoint","typeName","existingObj","weaveIndentIdx","innerWeaveStartIdx","innerWeaveObj","weaveContentCount","weaveContent","weave","gather","autoEnter","gatherContainer","looseEndWeavePoint","looseEnd","looseWeavePoint","closestInnerWeaveAncestor","closestOuterWeaveAncestor","nested","weaveAncestor","received","receivingWeave","childWeaveLooseEnd","varAss","returned","parentWeave","weavePointIdx","laterObj","badTerminationHandler","looseEndFlow","terminatingObj","conditional","objFlow","defaultObj","terminated","flowObj","d","innerDivert","ancestorFlows","flow","weavePointName","otherContentWithName","isNestedWeave","gatherPoint","ConditionalSingleBranch$1","duplicatesStackValue","needsEval","ConditionalSingleBranch","CustomFlags_1","CustomFlags","DebugMetadata_1","DebugMetadata$1","DebugMetadata","newDebugMetadata","ExternalDeclaration_1","ExternalDeclaration$1","argumentNames","ExternalDeclaration","FlowDecl_1","FlowDecl$1","FlowDecl","Wrap_1","Wrap$1","_objToWrap","Wrap","Glue_1","Glue","glue","Glue$1","IncDecExpression_1","IncDecExpression$1","varIdentifier","isIncOrExpression","isInc","varResolveResult","IncDecExpression","IncludedFile_1","IncludedFile$1","includedStory","IncludedFile","InfixOperator_1","InfixOperator$1","precedence","requireWhitespace","InfixOperator","Knot_1","Knot$1","parentStory","stitchName","knotWithStitchName","stitch","Knot","List_1","List$1","itemIdentifierList","runtimeRawList","itemIdentifier","List","ListElementDefinition_1","ListElementDefinition$1","parentList","indentifier","inInitialList","explicitValue","ListElementDefinition","StatementLevel_1","StatementLevel","Stitch_1","Stitch$1","Stitch","Tag_1","Tag","tagText","Choice$1","ListDefinitionsOrigin_1","ListDefinitionsOrigin$1","lists","listOfLists","definition","ListDefinitionsOrigin","JsonSerialisation_1","require$$17","require$$18","JsonSerialisation$1","JsonSerialisation","jArray","skipLast","jTok","writer","dictionary","dict","divTypeKey","choicePoint","boolVal","floatVal","strVal","divTargetVal","varPtrVal","controlCmd","readCountPath","jObject","token","floatRepresentation","firstChar","cmdName","propValue","varPtr","isDivert","pushesToStack","divPushType","readCountVarRef","isVarAss","isGlobalVar","isNewDecl","listContent","rawList","namesAsObjs","nameToVal","me","removes","space","k","v","r","withoutName","namedOnlyContent","countFlags","hasNameProperty","hasTerminator","namedContainer","namedContentItem","namedSubContainer","jObj","listDefJson","defsObj","allDefs","nameValueKey","nameValue","_controlCommandNames","CallStack_1","Story_1","CallStack$1","CallStack","cs","storyContext","toCopy","otherThread","jThreads","jThreadTok","jThreadObj","thread","newThread","forkedThread","externalEvaluationStackHeight","outputStreamLengthWithPushed","contextElement","varValue","declareNew","filtered","isCurrent","pointer","Element","inExpressionEvaluation","Thread","jThreadCallstack","jElTok","jElementObj","pushPopType","currentContainerPathStr","currentContainerPathStrToken","threadPointerResult","temps","prevContentObjPath","prevPath","resolvedPointer","VariablesState_1","VariablesStateAccessor","VariablesState$1","VariablesState","changedVars","patchedVal","callStack","varContents","listDefsOrigin","namedVarKey","namedVarValue","jToken","varValKey","varValValue","loadedToken","tokenInkObject","keyValKey","keyValValue","defaultVal","obj1","obj2","variableValue","setGlobal","existingPointer","valueOfVariablePointedTo","doubleRedirectionPointer","PRNG_1","PRNG$1","seed","PRNG","StatePatch_1","StatePatch$1","StatePatch","SimpleJson_1","SimpleJson$1","SimpleJson","Reader","__","explicitFloatReviver","jsonWithExplicitFloat","Writer","newObject","propertyName","innerOrContent","escape","currEl","State","StateElement","Flow_1","Flow$1","jChoiceThreadsObj","hasChoiceThreads","jChoiceThreads","foundActiveThread","jSavedChoiceThread","Flow","StoryState_1","require$$19","require$$20","require$$21","StoryState$1","StoryState","indented","json","pathString","visitCountOut","containerPathStr","count2","currCount","index2","inTag","outputObj","textContent","controlCommand","currentWhitespaceStart","startOfLine","isInlineWhitespace","txt","flowName","timeSeed","forBackgroundSave","namedFlowKey","namedFlowValue","newCount","isVisit","jSaveVersion","flowsObj","flowsObjDict","flowsObjDictEntries","namedFlowObjKey","namedFlowObjValue","currFlowName","currentDivertTargetPath","divertPath","objs","listText","textObj","single","headFirstNewlineIdx","headLastNewlineIdx","tailLastNewlineIdx","tailFirstNewlineIdx","listTexts","innerStrStart","innerStrEnd","leadingSpaces","innerStrText","numSpaces","trailingSpaces","includeInOutput","functionTrimIndex","glueTrimIndex","o","trimIndex","callStackElements","removeWhitespaceFrom","n","numberOfObjects","popped","functionStartPoint","popType","incrementingTurnIndex","newPointer","funcContainer","originalEvaluationStackHeight","returnedObj","poppedObj","returnVal","StopWatch","Stopwatch","_Error","StopWatch_1","require$$22","require$$23","require$$24","require$$25","Error_1","require$$26","nVal","Story","jsonString","rootObject","versionObj","formatFromFile","rootToken","listDefsObj","shouldReturn","originalPointer","millisecsLimitAsync","isAsyncTimeLimited","durationStopwatch","outputStreamEndsInNewline","changedVariablesToObserve","err","change","prevText","currText","prevTagCount","currTagCount","newlineStillExists","pathLengthToUse","stateToSave","shouldAddToStream","containerToEnter","currentContentObj","isLogicOrFlowControl","contextIdx","atStart","previousPointer","resolvedPreviousAncestor","prevAncestor","currentChildOfContainer","currentContainerAncestor","allChildrenEnteredAtStart","enteringAtStart","choiceOnlyStrVal","showChoice","conditionValue","startText","choiceOnlyText","truthy","divTarget","currentDivert","intContent","errorMessage","evalCommand","output","overrideTunnelReturnTarget","names","expected","contentStackForTag","outputCountConsumed","command","choiceTag","contentStackForString","contentToRetain","rescuedTag","choiceCount","extraNote","eitherCount","maxInt","minInt","randomRange","resultSeed","nextRandom","chosenValue","shuffleIndex","listNameVal","generatedListValue","foundItem","targetList","listItemIndex","listEnumerator","randomItem","assignedVal","foundValue","funcParams","resetCallstack","funcDetail","activityStr","choiceIdx","choiceToChoose","returnTextOutput","outputStreamBefore","stringOutput","textOutput","exprContainer","startCallStackHeight","evalStackHeight","funcName","numberOfArguments","funcDef","fallbackFunctionContainer","foundExternal","valueObj","funcResult","returnObj","lookaheadSafe","coercedArgs","missingExternals","observer","variableNames","observers","specificVariableName","variableObservers","keys","newValueObj","flowContainer","firstContent","didPop","successfulIncrement","nextAncestor","indexInAncestor","invisibleChoices","numElementsIntVal","seqContainer","numElements","seqCount","loopIndex","iterationIndex","seqPathStr","sequenceHash","randomSeed","random","unpickedIndices","chosen","chosenIndex","useEndLineNumber","errorTypeStr","lineNum","OutputStateChange","Story_2","toplevelObjects","isInclude","constDecl","existingDefinition","rootContainer","variableInitialisation","runtimeLists","runtimeVarAss","runtimeStory","originalFoundList","itemInThisList","innerContainers","innerContainer","namedInnerContainer","parentContainer","namedFuncTarget","decl","typeNameToPrint","typeNameOverride","maybeKnotOrFunction","knotOrFunction","topLevelContent","flowsFromOtherFiles","file","posOfObj","nonFlowContent","subStory","subStoryObj","StringExpression_1","StringExpression$1","StringExpression","otherStr","thisTxt","otherTxt","Tag$1","isStart","inChoice","LegacyTag","DefaultFileHandler_1","DefaultFileHandler$1","rootPath","DefaultFileHandler","InkParser_1","Glue_2","require$$27","require$$28","require$$29","require$$30","require$$31","require$$32","require$$33","require$$34","require$$35","require$$36","require$$37","require$$38","require$$39","require$$40","require$$41","require$$42","require$$43","require$$44","require$$45","require$$46","require$$47","require$$48","require$$49","require$$50","InkParser$1","InkParser","externalErrorHandler","rootParser","mainRule","separatorRule","firstElement","allElements","nextElementRuleId","nextElement","stateAtStart","stateAtEnd","md","parsedObj","parsedListObjs","parsedListObj","lineIndex","fullMessage","identifierCharSet","characterRanges","charRange","onceOnlyChoice","bullets","optionalName","startTextAndLogic","optionOnlyContent","hasWeaveStyleInlineBrackets","optionOnlyTextAndLogic","innerTextAndLogic","diverts","emptyContent","divObj","div","conditions","condExpr","gatherDashCountObj","gatherDashCount","initialQueryExpression","alternatives","canBeInline","isInline","soleContent","elseBranch","emptyTrueBranch","earlierBranchesHaveOwnExpression","isLast","alt","finalClause","trueBranch","multipleConditions","expr","isElse","mixedTextAndLogicResults","terminateWithSpace","lastObjIdx","lastObj","firstText","gotEscapeChar","nonTextRule","endChars","pureTextContent","threadDivert","arrowsAndDiverts","tunnelOnwards","tunnelOnwardDivert","gatherDivert","targetComponents","optionalArguments","numArrows","isIncrement","isDecrement","minimumPrecedence","infixOp","expectationMessage","multiaryExpr","prefixOp","postfixOp","intOrNull","floatOrNull","textAndLogic","iden","commas","innerExpr","memberNames","identifier2","infix","fullFilename","includedString","knotDecl","innerKnotStatements","knotName","isFunc","parameterNames","multiEquals","innerStitchStatements","flowArgs","flowArguments","firstIden","divertArrow","secondIden","funcIdentifier","argNames","afterTilde","funCall","needsToCloseParen","elementValue","elementValueNum","wasParsingString","wasTagActive","logic","explicitSeqType","contentLists","rules","isNumberCharsOnly","seqType","parsedSeqType","annotation","sequenceAnnotations","symbolChar","sequenceTypes","combinedSequenceType","word","multiline","interleavedContentAndPipes","justHadContent","contentOrPipe","rulesAtLevel","statement","breakRules","breakRuleResult","levels","breakingRules","inlineRule","newlines","anyWhitespace","fullRootInkPath","outputContentList","Stats","GenerateStoryStats","allText","words","wordsInThisStr","wasWhiteSpace","knots","stitches","gathers","g","JsonFileHandler_1","JsonFileHandler$1","fileHierarchy","JsonFileHandler","Stats_1","CompilerOptions_2","InkParser_2","Compiler","inkSource","range","offset","currOffset","lastValidMetadata","InkjsFileHandler","handler","f","isCompiledJson","input","trimmed","createInkStory","inkjsHandler","compilerOptions"],"mappings":"qTAMMA,GACLC,GACI,CACJ,IAAIC,EAAQD,EAEZ,OAAAC,EAAM,IAAM,IAAI,MAAM,GAA2C,CAChE,IAAK,CAACC,EAAGC,IACD,IAAMF,EAAOG,GAAOA,EAA8BD,CAAI,CAAC,CAC/D,CACA,EAEMF,CACR,ECRMI,GAAgBC,GAAAA,OAAsBC,IAAS,CACpD,SAAU,CAAA,EACV,YAAcC,GAAaD,EAAI,CAAE,SAAAC,EAAU,EAC3C,IAAMC,GAAY,CACjBF,EAAKG,IAAW,CACf,SAAU,CAAC,GAAGA,EAAM,SAAU,GAAGD,CAAO,CAAA,EACvC,CACH,EACA,MAAO,IAAMF,EAAI,CAAE,SAAU,CAAA,EAAI,CAClC,EAAE,EAEFF,GAAeN,GAAgBM,EAAa,ECpB/BM,GAAmB,kBAEnBC,GAAyC,CACrD,MAAO,GACP,UAAW,GACZ,EAOO,MAAMC,EAAuC,CAGnD,YAAYC,EAAiC,CAFnCC,EAAA,iBAGT,KAAK,UAAWD,GAAA,YAAAA,EAAS,WAAY,EACtC,CAEA,gBAAgBE,EAA0B,CACzC,OAAI,KAAK,SACD,KAAK,SAAW,IAAMA,EAEvBA,CACR,CAEA,SAASC,EAA2B,CACnC,MAAM,IAAI,MAAM,0CAA0C,CAC3D,CACD,CA0BO,IA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6C,GAAiBx6C,EAAQ,WAAW,EACxC,KACGg7C,EAAkB,IAAIr2C,mBAAgB,KAAM,CAAA,EAAI,GAAO,KAAMo2C,CAAY,EAE/Ex4C,EADiB,IAAI23C,YAAShzC,EAAQ8zC,CAAe,EACpC,QAAA,CAClB,KAEA,OAAM,IAAI,MAAM,+CAA+C,EAGhE,OAAO,IAAI33C,GAASd,GAAOvC,GAAA,YAAAA,EAAS,QAAS,YAAaA,CAAO,CAClE","x_google_ignoreList":[11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112]}