UNPKG

@drincs/pixi-vn-ink

Version:

Pixi'VN gives you the ability to write your own narrative using Ink

4 lines 328 kB
import {storage,RegisteredLabels,shakeEffect,ZoomTicker,canvas,RotateTicker,MoveTicker,FadeAlphaTicker,narration,ImageContainer,VideoSprite,ImageSprite,sound,LabelAbstract,SYSTEM_RESERVED_STORAGE_KEYS,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade,Assets,createExportableElement,NarrationManagerStatic,getCharacterById}from'@drincs/pixi-vn';var hh=Object.create;var Jo=Object.defineProperty;var ch=Object.getOwnPropertyDescriptor;var dh=Object.getOwnPropertyNames;var fh=Object.getPrototypeOf,ph=Object.prototype.hasOwnProperty;var tt=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var m=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var gh=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of dh(e))!ph.call(s,i)&&i!==t&&Jo(s,i,{get:()=>e[i],enumerable:!(n=ch(e,i))||n.enumerable});return s};var mh=(s,e,t)=>(t=s!=null?hh(fh(s)):{},gh(Jo(t,"default",{value:s,enumerable:true}),s));var ps=m(qn=>{Object.defineProperty(qn,"__esModule",{value:true});qn.CompilerOptions=void 0;var fs=class{constructor(e=null,t=[],n=false,i=null,a=null){this.sourceFilename=e,this.pluginNames=t,this.countAllVisits=n,this.errorHandler=i,this.fileHandler=a;}};qn.CompilerOptions=fs;});var il=m(jn=>{Object.defineProperty(jn,"__esModule",{value:true});jn.DebugSourceRange=void 0;var gs=class{constructor(e,t,n){this.length=e,this.debugMetadata=t,this.text=n;}};jn.DebugSourceRange=gs;});var Bn=m(Mn=>{Object.defineProperty(Mn,"__esModule",{value:true});Mn.ErrorType=void 0;var rl;(function(s){s[s.Author=0]="Author",s[s.Warning=1]="Warning",s[s.Error=2]="Error";})(rl||(Mn.ErrorType=rl={}));});var sl=m(Gn=>{Object.defineProperty(Gn,"__esModule",{value:true});Gn.Argument=void 0;var ms=class{constructor(e=null,t=null,n=null){this.identifier=e,this.isByReference=t,this.isDivertTarget=n;}get typeName(){return "Argument"}};Gn.Argument=ms;});var R=m(z=>{Object.defineProperty(z,"__esModule",{value:true});z.filterUndef=z.isEquatable=z.nullIfUndefined=z.asINamedContentOrNull=z.asBooleanOrThrows=z.asNumberOrThrows=z.asOrThrows=z.asOrNull=void 0;function sc(s,e){return s instanceof e?al(s):null}z.asOrNull=sc;function ac(s,e){if(s instanceof e)return al(s);throw new Error(`${s} is not of type ${e}`)}z.asOrThrows=ac;function oc(s){if(typeof s=="number")return s;throw new Error(`${s} is not a number`)}z.asNumberOrThrows=oc;function lc(s){if(typeof s=="boolean")return s;throw new Error(`${s} is not a boolean`)}z.asBooleanOrThrows=lc;function uc(s){return s.hasValidName&&s.name?s:null}z.asINamedContentOrNull=uc;function hc(s){return typeof s>"u"?null:s}z.nullIfUndefined=hc;function cc(s){return typeof s=="object"&&typeof s.Equals=="function"}z.isEquatable=cc;function al(s,e){return s}function dc(s){return s!=null}z.filterUndef=dc;});var j=m($n=>{Object.defineProperty($n,"__esModule",{value:true});$n.ParsedObject=void 0;var ol=R(),Cs=class{constructor(){this._alreadyHadError=false,this._alreadyHadWarning=false,this._debugMetadata=null,this._runtimeObject=null,this.content=[],this.parent=null,this.GetType=()=>this.typeName,this.AddContent=e=>{this.content===null&&(this.content=[]);let t=Array.isArray(e)?e:[e];for(let n of t)n.hasOwnProperty("parent")&&(n.parent=this),this.content.push(n);if(!Array.isArray(e))return e},this.InsertContent=(e,t)=>(this.content===null&&(this.content=[]),t.parent=this,this.content.splice(e,0,t),t),this.Find=e=>(t=null)=>{let n=(0, ol.asOrNull)(this,e);if(n!==null&&(t===null||t(n)===true))return n;if(this.content===null)return null;for(let i of this.content){let a=i.Find&&i.Find(e)(t);if(a)return a}return null},this.FindAll=e=>(t,n)=>{let i=Array.isArray(n)?n:[],a=(0, ol.asOrNull)(this,e);if(a!==null&&(!t||t(a)===true)&&i.push(a),this.content===null)return [];for(let r of this.content)r.FindAll&&r.FindAll(e)(t,i);return i},this.Warning=(e,t=null)=>{this.Error(e,t,true);};}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(e){this._debugMetadata=e;}get hasOwnDebugMetadata(){return !!this.debugMetadata}get typeName(){return "ParsedObject"}get story(){let e=this;for(;e.parent;)e=e.parent;return e}get runtimeObject(){return this._runtimeObject||(this._runtimeObject=this.GenerateRuntimeObject(),this._runtimeObject&&(this._runtimeObject.debugMetadata=this.debugMetadata)),this._runtimeObject}set runtimeObject(e){this._runtimeObject=e;}get runtimePath(){if(!this.runtimeObject.path)throw new Error;return this.runtimeObject.path}get containerForCounting(){return this.runtimeObject}get ancestry(){let e=[],t=this.parent;for(;t;)e.push(t),t=t.parent;return e=e.reverse(),e}ResolveReferences(e){if(this.content!==null)for(let t of this.content)t.ResolveReferences(e);}Error(e,t=null,n=false){if(t===null&&(t=this),!(t._alreadyHadError&&!n||t._alreadyHadWarning&&n)){if(this.parent)this.parent.Error(e,t,n);else throw new Error(`No parent object to send error to: ${e}`);n?t._alreadyHadWarning=true:t._alreadyHadError=true;}}};$n.ParsedObject=Cs;});var Hn=m(Jn=>{Object.defineProperty(Jn,"__esModule",{value:true});Jn.AuthorWarning=void 0;var fc=j(),vs=class extends fc.ParsedObject{constructor(e){super(),this.warningMessage=e,this.GenerateRuntimeObject=()=>(this.Warning(this.warningMessage),null);}get typeName(){return "AuthorWarning"}};Jn.AuthorWarning=vs;});var le=m(Kt=>{Object.defineProperty(Kt,"__esModule",{value:true});Kt.Path=void 0;var Ct=class s{constructor(){if(this._components=[],this._componentsString=null,this._isRelative=false,typeof arguments[0]=="string"){let e=arguments[0];this.componentsString=e;}else if(arguments[0]instanceof s.Component&&arguments[1]instanceof s){let e=arguments[0],t=arguments[1];this._components.push(e),this._components=this._components.concat(t._components);}else if(arguments[0]instanceof Array){let e=arguments[0],t=!!arguments[1];this._components=this._components.concat(e),this._isRelative=t;}}get isRelative(){return this._isRelative}get componentCount(){return this._components.length}get head(){return this._components.length>0?this._components[0]:null}get tail(){if(this._components.length>=2){let e=this._components.slice(1,this._components.length);return new s(e)}else return s.self}get length(){return this._components.length}get lastComponent(){let e=this._components.length-1;return e>=0?this._components[e]:null}get containsNamedComponent(){for(let e=0,t=this._components.length;e<t;e++)if(!this._components[e].isIndex)return true;return false}static get self(){let e=new s;return e._isRelative=true,e}GetComponent(e){return this._components[e]}PathByAppendingPath(e){let t=new s,n=0;for(let i=0;i<e._components.length&&e._components[i].isParent;++i)n++;for(let i=0;i<this._components.length-n;++i)t._components.push(this._components[i]);for(let i=n;i<e._components.length;++i)t._components.push(e._components[i]);return t}get componentsString(){return this._componentsString==null&&(this._componentsString=this._components.join("."),this.isRelative&&(this._componentsString="."+this._componentsString)),this._componentsString}set componentsString(e){if(this._components.length=0,this._componentsString=e,this._componentsString==null||this._componentsString=="")return;this._componentsString[0]=="."&&(this._isRelative=true,this._componentsString=this._componentsString.substring(1));let t=this._componentsString.split(".");for(let n of t)/^(\-|\+)?([0-9]+|Infinity)$/.test(n)?this._components.push(new s.Component(parseInt(n))):this._components.push(new s.Component(n));}toString(){return this.componentsString}Equals(e){if(e==null||e._components.length!=this._components.length||e.isRelative!=this.isRelative)return false;for(let t=0,n=e._components.length;t<n;t++)if(!e._components[t].Equals(this._components[t]))return false;return true}PathByAppendingComponent(e){let t=new s;return t._components.push(...this._components),t._components.push(e),t}};Kt.Path=Ct;Ct.parentId="^";(function(s){class e{constructor(n){this.index=-1,this.name=null,typeof n=="string"?this.name=n:this.index=n;}get isIndex(){return this.index>=0}get isParent(){return this.name==s.parentId}static ToParent(){return new e(s.parentId)}toString(){return this.isIndex?this.index.toString():this.name}Equals(n){return n!=null&&n.isIndex==this.isIndex?this.isIndex?this.index==n.index:this.name==n.name:false}}s.Component=e;})(Ct||(Kt.Path=Ct={}));});var zt=m(Un=>{Object.defineProperty(Un,"__esModule",{value:true});Un.Debug=void 0;var ll;(function(s){function e(n,i,a){t(n instanceof i,a);}s.AssertType=e;function t(n,i){if(!n)throw typeof i<"u"&&console.warn(i),console.trace&&console.trace(),new Error("")}s.Assert=t;})(ll||(Un.Debug=ll={}));});var te=m(vt=>{Object.defineProperty(vt,"__esModule",{value:true});vt.throwNullException=vt.NullException=void 0;var Kn=class extends Error{};vt.NullException=Kn;function pc(s){throw new Kn(`${s} is null or undefined`)}vt.throwNullException=pc;});var ue=m(Xn=>{Object.defineProperty(Xn,"__esModule",{value:true});Xn.InkObject=void 0;var yt=le(),Xt=$(),ys=zt(),St=R(),zn=te(),Ss=class{constructor(){this.parent=null,this._debugMetadata=null,this._path=null;}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(e){this._debugMetadata=e;}get ownDebugMetadata(){return this._debugMetadata}DebugLineNumberOfPath(e){if(e===null)return null;let t=this.rootContentContainer;if(t){let n=t.ContentAtPath(e).obj;if(n){let i=n.debugMetadata;if(i!==null)return i.startLineNumber}}return null}get path(){if(this._path==null)if(this.parent==null)this._path=new yt.Path;else {let e=[],t=this,n=(0, St.asOrNull)(t.parent,Xt.Container);for(;n!==null;){let i=(0, St.asINamedContentOrNull)(t);if(i!=null&&i.hasValidName){if(i.name===null)return (0, zn.throwNullException)("namedChild.name");e.unshift(new yt.Path.Component(i.name));}else e.unshift(new yt.Path.Component(n.content.indexOf(t)));t=n,n=(0, St.asOrNull)(n.parent,Xt.Container);}this._path=new yt.Path(e);}return this._path}ResolvePath(e){if(e===null)return (0, zn.throwNullException)("path");if(e.isRelative){let t=(0, St.asOrNull)(this,Xt.Container);return t===null&&(ys.Debug.Assert(this.parent!==null,"Can't resolve relative path because we don't have a parent"),t=(0, St.asOrNull)(this.parent,Xt.Container),ys.Debug.Assert(t!==null,"Expected parent to be a container"),ys.Debug.Assert(e.GetComponent(0).isParent),e=e.tail),t===null?(0, zn.throwNullException)("nearestContainer"):t.ContentAtPath(e)}else {let t=this.rootContentContainer;return t===null?(0, zn.throwNullException)("contentContainer"):t.ContentAtPath(e)}}ConvertPathToRelative(e){let t=this.path,n=Math.min(e.length,t.length),i=-1;for(let l=0;l<n;++l){let u=t.GetComponent(l),h=e.GetComponent(l);if(u.Equals(h))i=l;else break}if(i==-1)return e;let a=t.componentCount-1-i,r=[];for(let l=0;l<a;++l)r.push(yt.Path.Component.ToParent());for(let l=i+1;l<e.componentCount;++l)r.push(e.GetComponent(l));return new yt.Path(r,true)}CompactPathString(e){let t=null,n=null;return e.isRelative?(n=e.componentsString,t=this.path.PathByAppendingPath(e).componentsString):(n=this.ConvertPathToRelative(e).componentsString,t=e.componentsString),n.length<t.length?n:t}get rootContentContainer(){let e=this;for(;e.parent;)e=e.parent;return (0, St.asOrNull)(e,Xt.Container)}Copy(){throw Error("Not Implemented: Doesn't support copying")}SetChild(e,t,n){e[t]&&(e[t]=null),e[t]=n,e[t]&&(e[t].parent=this);}Equals(e){return e===this}};Xn.InkObject=Ss;});var rt=m(Yn=>{Object.defineProperty(Yn,"__esModule",{value:true});Yn.StringBuilder=void 0;var bs=class{constructor(e){e=typeof e<"u"?e.toString():"",this.string=e;}get Length(){return this.string.length}Append(e){e!==null&&(this.string+=e);}AppendLine(e){typeof e<"u"&&this.Append(e),this.string+=` `;}AppendFormat(e,...t){this.string+=e.replace(/{(\d+)}/g,(n,i)=>typeof t[i]<"u"?t[i]:n);}toString(){return this.string}Clear(){this.string="";}};Yn.StringBuilder=bs;});var ce=m(bt=>{Object.defineProperty(bt,"__esModule",{value:true});bt.InkList=bt.InkListItem=void 0;var Pe=te(),gc=rt(),he=class s{constructor(){if(this.originName=null,this.itemName=null,typeof arguments[1]<"u"){let e=arguments[0],t=arguments[1];this.originName=e,this.itemName=t;}else if(arguments[0]){let t=arguments[0].toString().split(".");this.originName=t[0],this.itemName=t[1];}}static get Null(){return new s(null,null)}get isNull(){return this.originName==null&&this.itemName==null}get fullName(){return (this.originName!==null?this.originName:"?")+"."+this.itemName}toString(){return this.fullName}Equals(e){if(e instanceof s){let t=e;return t.itemName==this.itemName&&t.originName==this.originName}return false}copy(){return new s(this.originName,this.itemName)}serialized(){return JSON.stringify({originName:this.originName,itemName:this.itemName})}static fromSerializedKey(e){let t=JSON.parse(e);if(!s.isLikeInkListItem(t))return s.Null;let n=t;return new s(n.originName,n.itemName)}static isLikeInkListItem(e){return !(typeof e!="object"||!e.hasOwnProperty("originName")||!e.hasOwnProperty("itemName")||typeof e.originName!="string"&&typeof e.originName!==null||typeof e.itemName!="string"&&typeof e.itemName!==null)}};bt.InkListItem=he;var _s=class s extends Map{constructor(){if(super(arguments[0]instanceof s?arguments[0]:[]),this.origins=null,this._originNames=[],arguments[0]instanceof s){let e=arguments[0],t=e.originNames;t!==null&&(this._originNames=t.slice()),e.origins!==null&&(this.origins=e.origins.slice());}else if(typeof arguments[0]=="string"){let e=arguments[0],t=arguments[1];if(this.SetInitialOriginName(e),t.listDefinitions===null)return (0, Pe.throwNullException)("originStory.listDefinitions");let n=t.listDefinitions.TryListGetDefinition(e,null);if(n.exists){if(n.result===null)return (0, Pe.throwNullException)("def.result");this.origins=[n.result];}else throw new Error("InkList origin could not be found in story when constructing new list: "+e)}else if(typeof arguments[0]=="object"&&arguments[0].hasOwnProperty("Key")&&arguments[0].hasOwnProperty("Value")){let e=arguments[0];this.Add(e.Key,e.Value);}}static FromString(e,t){var n;if(e==null||e=="")return new s;let i=(n=t.listDefinitions)===null||n===void 0?void 0:n.FindSingleItemListWithName(e);if(i)return i.value===null?(0, Pe.throwNullException)("listValue.value"):new s(i.value);throw new Error("Could not find the InkListItem from the string '"+e+"' to create an InkList because it doesn't exist in the original list definition in ink.")}AddItem(e,t=null){if(e instanceof he){let n=e;if(n.originName==null){this.AddItem(n.itemName);return}if(this.origins===null)return (0, Pe.throwNullException)("this.origins");for(let i of this.origins)if(i.name==n.originName){let a=i.TryGetValueForItem(n,0);if(a.exists){this.Add(n,a.result);return}else throw new Error("Could not add the item "+n+" to this list because it doesn't exist in the original list definition in ink.")}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.")}else if(e!==null){let n=e,i=null;if(this.origins===null)return (0, Pe.throwNullException)("this.origins");for(let a of this.origins){if(n===null)return (0, Pe.throwNullException)("itemName");if(a.ContainsItemWithName(n)){if(i!=null)throw new Error("Could not add the item "+n+" to this list because it could come from either "+a.name+" or "+i.name);i=a;}}if(i==null){if(t==null)throw new Error("Could not add the item "+n+" to this list because it isn't known to any list definitions previously associated with this list.");{let a=s.FromString(n,t).orderedItems[0];this.Add(a.Key,a.Value);}}else {let a=new he(i.name,n),r=i.ValueForItem(a);this.Add(a,r);}}}ContainsItemNamed(e){for(let[t]of this)if(he.fromSerializedKey(t).itemName==e)return true;return false}ContainsKey(e){return this.has(e.serialized())}Add(e,t){let n=e.serialized();if(this.has(n))throw new Error(`The Map already contains an entry for ${e}`);this.set(n,t);}Remove(e){return this.delete(e.serialized())}get Count(){return this.size}get originOfMaxItem(){if(this.origins==null)return null;let e=this.maxItem.Key.originName,t=null;return this.origins.every(n=>n.name==e?(t=n,false):true),t}get originNames(){if(this.Count>0){this._originNames==null&&this.Count>0?this._originNames=[]:(this._originNames||(this._originNames=[]),this._originNames.length=0);for(let[e]of this){let t=he.fromSerializedKey(e);if(t.originName===null)return (0, Pe.throwNullException)("item.originName");this._originNames.push(t.originName);}}return this._originNames}SetInitialOriginName(e){this._originNames=[e];}SetInitialOriginNames(e){e==null?this._originNames=null:this._originNames=e.slice();}get maxItem(){let e={Key:he.Null,Value:0};for(let[t,n]of this){let i=he.fromSerializedKey(t);(e.Key.isNull||n>e.Value)&&(e={Key:i,Value:n});}return e}get minItem(){let e={Key:he.Null,Value:0};for(let[t,n]of this){let i=he.fromSerializedKey(t);(e.Key.isNull||n<e.Value)&&(e={Key:i,Value:n});}return e}get inverse(){let e=new s;if(this.origins!=null)for(let t of this.origins)for(let[n,i]of t.items){let a=he.fromSerializedKey(n);this.ContainsKey(a)||e.Add(a,i);}return e}get all(){let e=new s;if(this.origins!=null)for(let t of this.origins)for(let[n,i]of t.items){let a=he.fromSerializedKey(n);e.set(a.serialized(),i);}return e}Union(e){let t=new s(this);for(let[n,i]of e)t.set(n,i);return t}Intersect(e){let t=new s;for(let[n,i]of this)e.has(n)&&t.set(n,i);return t}HasIntersection(e){for(let[t]of this)if(e.has(t))return true;return false}Without(e){let t=new s(this);for(let[n]of e)t.delete(n);return t}Contains(e){if(typeof e=="string")return this.ContainsItemNamed(e);let t=e;if(t.size==0||this.size==0)return false;for(let[n]of t)if(!this.has(n))return false;return true}GreaterThan(e){return this.Count==0?false:e.Count==0?true:this.minItem.Value>e.maxItem.Value}GreaterThanOrEquals(e){return this.Count==0?false:e.Count==0?true:this.minItem.Value>=e.minItem.Value&&this.maxItem.Value>=e.maxItem.Value}LessThan(e){return e.Count==0?false:this.Count==0?true:this.maxItem.Value<e.minItem.Value}LessThanOrEquals(e){return e.Count==0?false:this.Count==0?true:this.maxItem.Value<=e.maxItem.Value&&this.minItem.Value<=e.minItem.Value}MaxAsList(){return this.Count>0?new s(this.maxItem):new s}MinAsList(){return this.Count>0?new s(this.minItem):new s}ListWithSubRange(e,t){if(this.Count==0)return new s;let n=this.orderedItems,i=0,a=Number.MAX_SAFE_INTEGER;Number.isInteger(e)?i=e:e instanceof s&&e.Count>0&&(i=e.minItem.Value),Number.isInteger(t)?a=t:t instanceof s&&t.Count>0&&(a=t.maxItem.Value);let r=new s;r.SetInitialOriginNames(this.originNames);for(let o of n)o.Value>=i&&o.Value<=a&&r.Add(o.Key,o.Value);return r}Equals(e){if(!(e instanceof s)||e.Count!=this.Count)return false;for(let[t]of this)if(!e.has(t))return false;return true}get orderedItems(){let e=new Array;for(let[t,n]of this){let i=he.fromSerializedKey(t);e.push({Key:i,Value:n});}return e.sort((t,n)=>t.Key.originName===null?(0, Pe.throwNullException)("x.Key.originName"):n.Key.originName===null?(0, Pe.throwNullException)("y.Key.originName"):t.Value==n.Value?t.Key.originName.localeCompare(n.Key.originName):t.Value<n.Value?-1:t.Value>n.Value?1:0),e}get singleItem(){for(let e of this.orderedItems)return e.Key;return null}toString(){let e=this.orderedItems,t=new gc.StringBuilder;for(let n=0;n<e.length;n++){n>0&&t.Append(", ");let i=e[n].Key;if(i.itemName===null)return (0, Pe.throwNullException)("item.itemName");t.Append(i.itemName);}return t.toString()}valueOf(){return NaN}};bt.InkList=_s;});var Yt=m(Qn=>{Object.defineProperty(Qn,"__esModule",{value:true});Qn.StoryException=void 0;var Es=class extends Error{constructor(e){super(e),this.useEndLineNumber=false,this.message=e,this.name="StoryException";}};Qn.StoryException=Es;});var _t=m(Ge=>{Object.defineProperty(Ge,"__esModule",{value:true});Ge.tryParseFloat=Ge.tryParseInt=Ge.tryGetValueFromMap=void 0;function mc(s,e,t){if(s===null)return {result:t,exists:false};let n=s.get(e);return typeof n>"u"?{result:t,exists:false}:{result:n,exists:true}}Ge.tryGetValueFromMap=mc;function Cc(s,e=0){let t=parseInt(s);return Number.isNaN(t)?{result:e,exists:false}:{result:t,exists:true}}Ge.tryParseInt=Cc;function vc(s,e=0){let t=parseFloat(s);return Number.isNaN(t)?{result:e,exists:false}:{result:t,exists:true}}Ge.tryParseFloat=vc;});var M=m(B=>{Object.defineProperty(B,"__esModule",{value:true});B.ValueType=B.ListValue=B.VariablePointerValue=B.DivertTargetValue=B.StringValue=B.FloatValue=B.IntValue=B.BoolValue=B.Value=B.AbstractValue=void 0;var ul=ue(),hl=le(),st=ce(),yc=Yt(),Qt=R(),cl=_t(),ve=te(),Zn=class s extends ul.InkObject{static Create(e,t){if(t){if(t===q.Int&&Number.isInteger(Number(e)))return new Ne(Number(e));if(t===q.Float&&!isNaN(e))return new Ae(Number(e))}if(typeof e=="boolean")return new Et(!!e);if(typeof e=="string")return new qe(String(e));if(Number.isInteger(Number(e)))return new Ne(Number(e));if(isNaN(e)){if(e instanceof hl.Path)return new ei((0, Qt.asOrThrows)(e,hl.Path));if(e instanceof st.InkList)return new ti((0, Qt.asOrThrows)(e,st.InkList))}else return new Ae(Number(e));return null}Copy(){return (0, Qt.asOrThrows)(s.Create(this.valueObject),ul.InkObject)}BadCastException(e){return new yc.StoryException("Can't cast "+this.valueObject+" from "+this.valueType+" to "+e)}};B.AbstractValue=Zn;var Oe=class extends Zn{constructor(e){super(),this.value=e;}get valueObject(){return this.value}toString(){return this.value===null?(0, ve.throwNullException)("Value.value"):this.value.toString()}};B.Value=Oe;var Et=class extends Oe{constructor(e){super(e||false);}get isTruthy(){return !!this.value}get valueType(){return q.Bool}Cast(e){if(this.value===null)return (0, ve.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==q.Int)return new Ne(this.value?1:0);if(e==q.Float)return new Ae(this.value?1:0);if(e==q.String)return new qe(this.value?"true":"false");throw this.BadCastException(e)}toString(){return this.value?"true":"false"}};B.BoolValue=Et;var Ne=class extends Oe{constructor(e){super(e||0);}get isTruthy(){return this.value!=0}get valueType(){return q.Int}Cast(e){if(this.value===null)return (0, ve.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==q.Bool)return new Et(this.value!==0);if(e==q.Float)return new Ae(this.value);if(e==q.String)return new qe(""+this.value);throw this.BadCastException(e)}};B.IntValue=Ne;var Ae=class extends Oe{constructor(e){super(e||0);}get isTruthy(){return this.value!=0}get valueType(){return q.Float}Cast(e){if(this.value===null)return (0, ve.throwNullException)("Value.value");if(e==this.valueType)return this;if(e==q.Bool)return new Et(this.value!==0);if(e==q.Int)return new Ne(this.value);if(e==q.String)return new qe(""+this.value);throw this.BadCastException(e)}};B.FloatValue=Ae;var qe=class extends Oe{constructor(e){if(super(e||""),this._isNewline=this.value==` `,this._isInlineWhitespace=true,this.value===null)return (0, ve.throwNullException)("Value.value");this.value.length>0&&this.value.split("").every(t=>t!=" "&&t!=" "?(this._isInlineWhitespace=false,false):true);}get valueType(){return q.String}get isTruthy(){return this.value===null?(0, ve.throwNullException)("Value.value"):this.value.length>0}get isNewline(){return this._isNewline}get isInlineWhitespace(){return this._isInlineWhitespace}get isNonWhitespace(){return !this.isNewline&&!this.isInlineWhitespace}Cast(e){if(e==this.valueType)return this;if(e==q.Int){let t=(0, cl.tryParseInt)(this.value);if(t.exists)return new Ne(t.result);throw this.BadCastException(e)}if(e==q.Float){let t=(0, cl.tryParseFloat)(this.value);if(t.exists)return new Ae(t.result);throw this.BadCastException(e)}throw this.BadCastException(e)}};B.StringValue=qe;var ei=class extends Oe{constructor(e=null){super(e);}get valueType(){return q.DivertTarget}get targetPath(){return this.value===null?(0, ve.throwNullException)("Value.value"):this.value}set targetPath(e){this.value=e;}get isTruthy(){throw new Error("Shouldn't be checking the truthiness of a divert target")}Cast(e){if(e==this.valueType)return this;throw this.BadCastException(e)}toString(){return "DivertTargetValue("+this.targetPath+")"}};B.DivertTargetValue=ei;var Ts=class s extends Oe{constructor(e,t=-1){super(e),this._contextIndex=t;}get contextIndex(){return this._contextIndex}set contextIndex(e){this._contextIndex=e;}get variableName(){return this.value===null?(0, ve.throwNullException)("Value.value"):this.value}set variableName(e){this.value=e;}get valueType(){return q.VariablePointer}get isTruthy(){throw new Error("Shouldn't be checking the truthiness of a variable pointer")}Cast(e){if(e==this.valueType)return this;throw this.BadCastException(e)}toString(){return "VariablePointerValue("+this.variableName+")"}Copy(){return new s(this.variableName,this.contextIndex)}};B.VariablePointerValue=Ts;var ti=class s extends Oe{get isTruthy(){return this.value===null?(0, ve.throwNullException)("this.value"):this.value.Count>0}get valueType(){return q.List}Cast(e){if(this.value===null)return (0, ve.throwNullException)("Value.value");if(e==q.Int){let t=this.value.maxItem;return t.Key.isNull?new Ne(0):new Ne(t.Value)}else if(e==q.Float){let t=this.value.maxItem;return t.Key.isNull?new Ae(0):new Ae(t.Value)}else if(e==q.String){let t=this.value.maxItem;return t.Key.isNull?new qe(""):new qe(t.Key.toString())}if(e==this.valueType)return this;throw this.BadCastException(e)}constructor(e,t){super(null),!e&&!t?this.value=new st.InkList:e instanceof st.InkList?this.value=new st.InkList(e):e instanceof st.InkListItem&&typeof t=="number"&&(this.value=new st.InkList({Key:e,Value:t}));}static RetainListOriginsForAssignment(e,t){let n=(0, Qt.asOrNull)(e,s),i=(0, Qt.asOrNull)(t,s);if(i&&i.value===null)return (0, ve.throwNullException)("newList.value");if(n&&n.value===null)return (0, ve.throwNullException)("oldList.value");n&&i&&i.value.Count==0&&i.value.SetInitialOriginNames(n.value.originNames);}};B.ListValue=ti;var q;(function(s){s[s.Bool=-1]="Bool",s[s.Int=0]="Int",s[s.Float=1]="Float",s[s.List=2]="List",s[s.String=3]="String",s[s.DivertTarget=4]="DivertTarget",s[s.VariablePointer=5]="VariablePointer";})(q||(B.ValueType=q={}));});var dl=m(ni=>{Object.defineProperty(ni,"__esModule",{value:true});ni.SearchResult=void 0;var Sc=$(),ws=class s{constructor(){this.obj=null,this.approximate=false;}get correctObj(){return this.approximate?null:this.obj}get container(){return this.obj instanceof Sc.Container?this.obj:null}copy(){let e=new s;return e.obj=this.obj,e.approximate=this.approximate,e}};ni.SearchResult=ws;});var $=m(en=>{Object.defineProperty(en,"__esModule",{value:true});en.Container=void 0;var bc=M(),fl=te(),_c=rt(),Tt=ue(),Ec=dl(),pl=le(),gl=zt(),Tc=_t(),$e=R(),Zt=class s extends Tt.InkObject{constructor(){super(...arguments),this.name=null,this._content=[],this.namedContent=new Map,this.visitsShouldBeCounted=false,this.turnIndexShouldBeCounted=false,this.countingAtStartOnly=false,this._pathToFirstLeafContent=null;}get hasValidName(){return this.name!=null&&this.name.length>0}get content(){return this._content}set content(e){this.AddContent(e);}get namedOnlyContent(){let e=new Map;for(let[t,n]of this.namedContent){let i=(0, $e.asOrThrows)(n,Tt.InkObject);e.set(t,i);}for(let t of this.content){let n=(0, $e.asINamedContentOrNull)(t);n!=null&&n.hasValidName&&e.delete(n.name);}return e.size==0&&(e=null),e}set namedOnlyContent(e){let t=this.namedOnlyContent;if(t!=null)for(let[n]of t)this.namedContent.delete(n);if(e!=null)for(let[,n]of e){let i=(0, $e.asINamedContentOrNull)(n);i!=null&&this.AddToNamedContentOnly(i);}}get countFlags(){let e=0;return this.visitsShouldBeCounted&&(e|=s.CountFlags.Visits),this.turnIndexShouldBeCounted&&(e|=s.CountFlags.Turns),this.countingAtStartOnly&&(e|=s.CountFlags.CountStartOnly),e==s.CountFlags.CountStartOnly&&(e=0),e}set countFlags(e){let t=e;(t&s.CountFlags.Visits)>0&&(this.visitsShouldBeCounted=true),(t&s.CountFlags.Turns)>0&&(this.turnIndexShouldBeCounted=true),(t&s.CountFlags.CountStartOnly)>0&&(this.countingAtStartOnly=true);}get pathToFirstLeafContent(){return this._pathToFirstLeafContent==null&&(this._pathToFirstLeafContent=this.path.PathByAppendingPath(this.internalPathToFirstLeafContent)),this._pathToFirstLeafContent}get internalPathToFirstLeafContent(){let e=[],t=this;for(;t instanceof s;)t.content.length>0&&(e.push(new pl.Path.Component(0)),t=t.content[0]);return new pl.Path(e)}AddContent(e){if(e instanceof Array){let t=e;for(let n of t)this.AddContent(n);}else {let t=e;if(this._content.push(t),t.parent)throw new Error("content is already in "+t.parent);t.parent=this,this.TryAddNamedContent(t);}}TryAddNamedContent(e){let t=(0, $e.asINamedContentOrNull)(e);t!=null&&t.hasValidName&&this.AddToNamedContentOnly(t);}AddToNamedContentOnly(e){gl.Debug.AssertType(e,Tt.InkObject,"Can only add Runtime.Objects to a Runtime.Container");let t=(0, $e.asOrThrows)(e,Tt.InkObject);if(t.parent=this,e.name===null)return (0, fl.throwNullException)("namedContentObj.name");this.namedContent.set(e.name,e);}ContentAtPath(e,t=0,n=-1){n==-1&&(n=e.length);let i=new Ec.SearchResult;i.approximate=false;let a=this,r=this;for(let o=t;o<n;++o){let l=e.GetComponent(o);if(a==null){i.approximate=true;break}let u=a.ContentWithPathComponent(l);if(u==null){i.approximate=true;break}let h=(0, $e.asOrNull)(u,s);if(o<n-1&&h==null){i.approximate=true;break}r=u,a=h;}return i.obj=r,i}InsertContent(e,t){if(this.content.splice(t,0,e),e.parent)throw new Error("content is already in "+e.parent);e.parent=this,this.TryAddNamedContent(e);}AddContentsOfContainer(e){this.content.push(...e.content);for(let t of e.content)t.parent=this,this.TryAddNamedContent(t);}ContentWithPathComponent(e){if(e.isIndex)return e.index>=0&&e.index<this.content.length?this.content[e.index]:null;if(e.isParent)return this.parent;{if(e.name===null)return (0, fl.throwNullException)("component.name");let t=(0, Tc.tryGetValueFromMap)(this.namedContent,e.name,null);return t.exists?(0, $e.asOrThrows)(t.result,Tt.InkObject):null}}BuildStringOfHierarchy(){let e;if(arguments.length==0)return e=new _c.StringBuilder,this.BuildStringOfHierarchy(e,0,null),e.toString();e=arguments[0];let t=arguments[1],n=arguments[2];function i(){for(let o=0;o<4*t;++o)e.Append(" ");}i(),e.Append("["),this.hasValidName&&e.AppendFormat(" ({0})",this.name),this==n&&e.Append(" <---"),e.AppendLine(),t++;for(let r=0;r<this.content.length;++r){let o=this.content[r];o instanceof s?o.BuildStringOfHierarchy(e,t,n):(i(),o instanceof bc.StringValue?(e.Append('"'),e.Append(o.toString().replace(` `,"\\n")),e.Append('"')):e.Append(o.toString())),r!=this.content.length-1&&e.Append(","),!(o instanceof s)&&o==n&&e.Append(" <---"),e.AppendLine();}let a=new Map;for(let[r,o]of this.namedContent)this.content.indexOf((0, $e.asOrThrows)(o,Tt.InkObject))>=0||a.set(r,o);if(a.size>0){i(),e.AppendLine("-- named: --");for(let[,r]of a)gl.Debug.AssertType(r,s,"Can only print out named Containers"),r.BuildStringOfHierarchy(e,t,n),e.AppendLine();}t--,i(),e.Append("]");}};en.Container=Zt;(function(s){(function(t){t[t.Start=0]="Start",t[t.Visits=1]="Visits",t[t.Turns=2]="Turns",t[t.CountStartOnly=4]="CountStartOnly";})(s.CountFlags||(s.CountFlags={}));})(Zt||(en.Container=Zt={}));});var ne=m(nn=>{Object.defineProperty(nn,"__esModule",{value:true});nn.ControlCommand=void 0;var wc=ue(),tn=class s extends wc.InkObject{get commandType(){return this._commandType}constructor(e=s.CommandType.NotSet){super(),this._commandType=e;}Copy(){return new s(this.commandType)}static EvalStart(){return new s(s.CommandType.EvalStart)}static EvalOutput(){return new s(s.CommandType.EvalOutput)}static EvalEnd(){return new s(s.CommandType.EvalEnd)}static Duplicate(){return new s(s.CommandType.Duplicate)}static PopEvaluatedValue(){return new s(s.CommandType.PopEvaluatedValue)}static PopFunction(){return new s(s.CommandType.PopFunction)}static PopTunnel(){return new s(s.CommandType.PopTunnel)}static BeginString(){return new s(s.CommandType.BeginString)}static EndString(){return new s(s.CommandType.EndString)}static NoOp(){return new s(s.CommandType.NoOp)}static ChoiceCount(){return new s(s.CommandType.ChoiceCount)}static Turns(){return new s(s.CommandType.Turns)}static TurnsSince(){return new s(s.CommandType.TurnsSince)}static ReadCount(){return new s(s.CommandType.ReadCount)}static Random(){return new s(s.CommandType.Random)}static SeedRandom(){return new s(s.CommandType.SeedRandom)}static VisitIndex(){return new s(s.CommandType.VisitIndex)}static SequenceShuffleIndex(){return new s(s.CommandType.SequenceShuffleIndex)}static StartThread(){return new s(s.CommandType.StartThread)}static Done(){return new s(s.CommandType.Done)}static End(){return new s(s.CommandType.End)}static ListFromInt(){return new s(s.CommandType.ListFromInt)}static ListRange(){return new s(s.CommandType.ListRange)}static ListRandom(){return new s(s.CommandType.ListRandom)}static BeginTag(){return new s(s.CommandType.BeginTag)}static EndTag(){return new s(s.CommandType.EndTag)}toString(){return "ControlCommand "+this.commandType.toString()}};nn.ControlCommand=tn;(function(s){(function(t){t[t.NotSet=-1]="NotSet",t[t.EvalStart=0]="EvalStart",t[t.EvalOutput=1]="EvalOutput",t[t.EvalEnd=2]="EvalEnd",t[t.Duplicate=3]="Duplicate",t[t.PopEvaluatedValue=4]="PopEvaluatedValue",t[t.PopFunction=5]="PopFunction",t[t.PopTunnel=6]="PopTunnel",t[t.BeginString=7]="BeginString",t[t.EndString=8]="EndString",t[t.NoOp=9]="NoOp",t[t.ChoiceCount=10]="ChoiceCount",t[t.Turns=11]="Turns",t[t.TurnsSince=12]="TurnsSince",t[t.ReadCount=13]="ReadCount",t[t.Random=14]="Random",t[t.SeedRandom=15]="SeedRandom",t[t.VisitIndex=16]="VisitIndex",t[t.SequenceShuffleIndex=17]="SequenceShuffleIndex",t[t.StartThread=18]="StartThread",t[t.Done=19]="Done",t[t.End=20]="End",t[t.ListFromInt=21]="ListFromInt",t[t.ListRange=22]="ListRange",t[t.ListRandom=23]="ListRandom",t[t.BeginTag=24]="BeginTag",t[t.EndTag=25]="EndTag",t[t.TOTAL_VALUES=26]="TOTAL_VALUES";})(s.CommandType||(s.CommandType={}));})(tn||(nn.ControlCommand=tn={}));});var ye=m(ii=>{Object.defineProperty(ii,"__esModule",{value:true});ii.Expression=void 0;var ml=$(),xs=ne(),xc=j(),Ps=class extends xc.ParsedObject{constructor(){super(...arguments),this._prototypeRuntimeConstantExpression=null,this.outputWhenComplete=false,this.GenerateRuntimeObject=()=>{let e=new ml.Container;return e.AddContent(xs.ControlCommand.EvalStart()),this.GenerateIntoContainer(e),this.outputWhenComplete&&e.AddContent(xs.ControlCommand.EvalOutput()),e.AddContent(xs.ControlCommand.EvalEnd()),e},this.GenerateConstantIntoContainer=e=>{this._prototypeRuntimeConstantExpression===null&&(this._prototypeRuntimeConstantExpression=new ml.Container,this.GenerateIntoContainer(this._prototypeRuntimeConstantExpression));for(let t of this._prototypeRuntimeConstantExpression.content){let n=t.Copy();n&&e.AddContent(n);}},this.toString=()=>"No string value in JavaScript.";}get typeName(){return "Expression"}Equals(e){return false}};ii.Expression=Ps;});var at=m(ri=>{Object.defineProperty(ri,"__esModule",{value:true});ri.Void=void 0;var Pc=ue(),Os=class extends Pc.InkObject{toString(){return "Void"}};ri.Void=Os;});var Ie=m(ai=>{Object.defineProperty(ai,"__esModule",{value:true});ai.NativeFunctionCall=void 0;var E=M(),rn=Yt(),Oc=at(),si=ce(),Nc=ue(),Se=R(),de=te(),A=class s extends Nc.InkObject{static CallWithName(e){return new s(e)}static CallExistsWithName(e){return this.GenerateNativeFunctionsIfNecessary(),this._nativeFunctions.get(e)}get name(){return this._name===null?(0, de.throwNullException)("NativeFunctionCall._name"):this._name}set name(e){this._name=e,this._isPrototype||(s._nativeFunctions===null?(0, de.throwNullException)("NativeFunctionCall._nativeFunctions"):this._prototype=s._nativeFunctions.get(this._name)||null);}get numberOfParameters(){return this._prototype?this._prototype.numberOfParameters:this._numberOfParameters}set numberOfParameters(e){this._numberOfParameters=e;}Call(e){if(this._prototype)return this._prototype.Call(e);if(this.numberOfParameters!=e.length)throw new Error("Unexpected number of parameters");let t=false;for(let a of e){if(a instanceof Oc.Void)throw new rn.StoryException("Attempting to perform "+this.name+' on a void value. Did you forget to "return" a value from a function you called here?');a instanceof E.ListValue&&(t=true);}if(e.length==2&&t)return this.CallBinaryListOperation(e);let n=this.CoerceValuesToSingleType(e),i=n[0].valueType;return i==E.ValueType.Int?this.CallType(n):i==E.ValueType.Float?this.CallType(n):i==E.ValueType.String?this.CallType(n):i==E.ValueType.DivertTarget?this.CallType(n):i==E.ValueType.List?this.CallType(n):null}CallType(e){let t=(0, Se.asOrThrows)(e[0],E.Value),n=t.valueType,i=t,a=e.length;if(a==2||a==1){if(this._operationFuncs===null)return (0, de.throwNullException)("NativeFunctionCall._operationFuncs");let r=this._operationFuncs.get(n);if(!r){let o=E.ValueType[n];throw new rn.StoryException("Cannot perform operation "+this.name+" on "+o)}if(a==2){let l=(0, Se.asOrThrows)(e[1],E.Value),u=r;if(i.value===null||l.value===null)return (0, de.throwNullException)("NativeFunctionCall.Call BinaryOp values");let h=u(i.value,l.value);return E.Value.Create(h)}else {let o=r;if(i.value===null)return (0, de.throwNullException)("NativeFunctionCall.Call UnaryOp value");let l=o(i.value);return this.name===s.Int?E.Value.Create(l,E.ValueType.Int):this.name===s.Float?E.Value.Create(l,E.ValueType.Float):E.Value.Create(l,t.valueType)}}else throw new Error("Unexpected number of parameters to NativeFunctionCall: "+e.length)}CallBinaryListOperation(e){if((this.name=="+"||this.name=="-")&&e[0]instanceof E.ListValue&&e[1]instanceof E.IntValue)return this.CallListIncrementOperation(e);let t=(0, Se.asOrThrows)(e[0],E.Value),n=(0, Se.asOrThrows)(e[1],E.Value);if((this.name=="&&"||this.name=="||")&&(t.valueType!=E.ValueType.List||n.valueType!=E.ValueType.List)){if(this._operationFuncs===null)return (0, de.throwNullException)("NativeFunctionCall._operationFuncs");let i=this._operationFuncs.get(E.ValueType.Int);if(i===null)return (0, de.throwNullException)("NativeFunctionCall.CallBinaryListOperation op");let a=(0, Se.asBooleanOrThrows)(i(t.isTruthy?1:0,n.isTruthy?1:0));return new E.BoolValue(a)}if(t.valueType==E.ValueType.List&&n.valueType==E.ValueType.List)return this.CallType([t,n]);throw new rn.StoryException("Can not call use "+this.name+" operation on "+E.ValueType[t.valueType]+" and "+E.ValueType[n.valueType])}CallListIncrementOperation(e){let t=(0, Se.asOrThrows)(e[0],E.ListValue),n=(0, Se.asOrThrows)(e[1],E.IntValue),i=new si.InkList;if(t.value===null)return (0, de.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value");for(let[a,r]of t.value){let o=si.InkListItem.fromSerializedKey(a);if(this._operationFuncs===null)return (0, de.throwNullException)("NativeFunctionCall._operationFuncs");let l=this._operationFuncs.get(E.ValueType.Int);if(n.value===null)return (0, de.throwNullException)("NativeFunctionCall.CallListIncrementOperation intVal.value");let u=l(r,n.value),h=null;if(t.value.origins===null)return (0, de.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value.origins");for(let c of t.value.origins)if(c.name==o.originName){h=c;break}if(h!=null){let c=h.TryGetItemWithValue(u,si.InkListItem.Null);c.exists&&i.Add(c.result,u);}}return new E.ListValue(i)}CoerceValuesToSingleType(e){let t=E.ValueType.Int,n=null;for(let a of e){let r=(0, Se.asOrThrows)(a,E.Value);r.valueType>t&&(t=r.valueType),r.valueType==E.ValueType.List&&(n=(0, Se.asOrNull)(r,E.ListValue));}let i=[];if(E.ValueType[t]==E.ValueType[E.ValueType.List])for(let a of e){let r=(0, Se.asOrThrows)(a,E.Value);if(r.valueType==E.ValueType.List)i.push(r);else if(r.valueType==E.ValueType.Int){let o=parseInt(r.valueObject);if(n=(0, Se.asOrThrows)(n,E.ListValue),n.value===null)return (0, de.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType specialCaseList.value");let l=n.value.originOfMaxItem;if(l===null)return (0, de.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType list");let u=l.TryGetItemWithValue(o,si.InkListItem.Null);if(u.exists){let h=new E.ListValue(u.result,o);i.push(h);}else throw new rn.StoryException("Could not find List item with the value "+o+" in "+l.name)}else {let o=E.ValueType[r.valueType];throw new rn.StoryException("Cannot mix Lists and "+o+" values in this operation")}}else for(let a of e){let o=(0, Se.asOrThrows)(a,E.Value).Cast(t);i.push(o);}return i}constructor(){if(super(),this._name=null,this._numberOfParameters=0,this._prototype=null,this._isPrototype=false,this._operationFuncs=null,arguments.length===0)s.GenerateNativeFunctionsIfNecessary();else if(arguments.length===1){let e=arguments[0];s.GenerateNativeFunctionsIfNecessary(),this.name=e;}else if(arguments.length===2){let e=arguments[0],t=arguments[1];this._isPrototype=true,this.name=e,this.numberOfParameters=t;}}static Identity(e){return e}static GenerateNativeFunctionsIfNecessary(){if(this._nativeFunctions==null){this._nativeFunctions=new Map,this.AddIntBinaryOp(this.Add,(n,i)=>n+i),this.AddIntBinaryOp(this.Subtract,(n,i)=>n-i),this.AddIntBinaryOp(this.Multiply,(n,i)=>n*i),this.AddIntBinaryOp(this.Divide,(n,i)=>Math.floor(n/i)),this.AddIntBinaryOp(this.Mod,(n,i)=>n%i),this.AddIntUnaryOp(this.Negate,n=>-n),this.AddIntBinaryOp(this.Equal,(n,i)=>n==i),this.AddIntBinaryOp(this.Greater,(n,i)=>n>i),this.AddIntBinaryOp(this.Less,(n,i)=>n<i),this.AddIntBinaryOp(this.GreaterThanOrEquals,(n,i)=>n>=i),this.AddIntBinaryOp(this.LessThanOrEquals,(n,i)=>n<=i),this.AddIntBinaryOp(this.NotEquals,(n,i)=>n!=i),this.AddIntUnaryOp(this.Not,n=>n==0),this.AddIntBinaryOp(this.And,(n,i)=>n!=0&&i!=0),this.AddIntBinaryOp(this.Or,(n,i)=>n!=0||i!=0),this.AddIntBinaryOp(this.Max,(n,i)=>Math.max(n,i)),this.AddIntBinaryOp(this.Min,(n,i)=>Math.min(n,i)),this.AddIntBinaryOp(this.Pow,(n,i)=>Math.pow(n,i)),this.AddIntUnaryOp(this.Floor,s.Identity),this.AddIntUnaryOp(this.Ceiling,s.Identity),this.AddIntUnaryOp(this.Int,s.Identity),this.AddIntUnaryOp(this.Float,n=>n),this.AddFloatBinaryOp(this.Add,(n,i)=>n+i),this.AddFloatBinaryOp(this.Subtract,(n,i)=>n-i),this.AddFloatBinaryOp(this.Multiply,(n,i)=>n*i),this.AddFloatBinaryOp(this.Divide,(n,i)=>n/i),this.AddFloatBinaryOp(this.Mod,(n,i)=>n%i),this.AddFloatUnaryOp(this.Negate,n=>-n),this.AddFloatBinaryOp(this.Equal,(n,i)=>n==i),this.AddFloatBinaryOp(this.Greater,(n,i)=>n>i),this.AddFloatBinaryOp(this.Less,(n,i)=>n<i),this.AddFloatBinaryOp(this.GreaterThanOrEquals,(n,i)=>n>=i),this.AddFloatBinaryOp(this.LessThanOrEquals,(n,i)=>n<=i),this.AddFloatBinaryOp(this.NotEquals,(n,i)=>n!=i),this.AddFloatUnaryOp(this.Not,n=>n==0),this.AddFloatBinaryOp(this.And,(n,i)=>n!=0&&i!=0),this.AddFloatBinaryOp(this.Or,(n,i)=>n!=0||i!=0),this.AddFloatBinaryOp(this.Max,(n,i)=>Math.max(n,i)),this.AddFloatBinaryOp(this.Min,(n,i)=>Math.min(n,i)),this.AddFloatBinaryOp(this.Pow,(n,i)=>Math.pow(n,i)),this.AddFloatUnaryOp(this.Floor,n=>Math.floor(n)),this.AddFloatUnaryOp(this.Ceiling,n=>Math.ceil(n)),this.AddFloatUnaryOp(this.Int,n=>Math.floor(n)),this.AddFloatUnaryOp(this.Float,s.Identity),this.AddStringBinaryOp(this.Add,(n,i)=>n+i),this.AddStringBinaryOp(this.Equal,(n,i)=>n===i),this.AddStringBinaryOp(this.NotEquals,(n,i)=>n!==i),this.AddStringBinaryOp(this.Has,(n,i)=>n.includes(i)),this.AddStringBinaryOp(this.Hasnt,(n,i)=>!n.includes(i)),this.AddListBinaryOp(this.Add,(n,i)=>n.Union(i)),this.AddListBinaryOp(this.Subtract,(n,i)=>n.Without(i)),this.AddListBinaryOp(this.Has,(n,i)=>n.Contains(i)),this.AddListBinaryOp(this.Hasnt,(n,i)=>!n.Contains(i)),this.AddListBinaryOp(this.Intersect,(n,i)=>n.Intersect(i)),this.AddListBinaryOp(this.Equal,(n,i)=>n.Equals(i)),this.AddListBinaryOp(this.Greater,(n,i)=>n.GreaterThan(i)),this.AddListBinaryOp(this.Less,(n,i)=>n.LessThan(i)),this.AddListBinaryOp(this.GreaterThanOrEquals,(n,i)=>n.GreaterThanOrEquals(i)),this.AddListBinaryOp(this.LessThanOrEquals,(n,i)=>n.LessThanOrEquals(i)),this.AddListBinaryOp(this.NotEquals,(n,i)=>!n.Equals(i)),this.AddListBinaryOp(this.And,(n,i)=>n.Count>0&&i.Count>0),this.AddListBinaryOp(this.Or,(n,i)=>n.Count>0||i.Count>0),this.AddListUnaryOp(this.Not,n=>n.Count==0?1:0),this.AddListUnaryOp(this.Invert,n=>n.inverse),this.AddListUnaryOp(this.All,n=>n.all),this.AddListUnaryOp(this.ListMin,n=>n.MinAsList()),this.AddListUnaryOp(this.ListMax,n=>n.MaxAsList()),this.AddListUnaryOp(this.Count,n=>n.Count),this.AddListUnaryOp(this.ValueOfList,n=>n.maxItem.Value);let e=(n,i)=>n.Equals(i),t=(n,i)=>!n.Equals(i);this.AddOpToNativeFunc(this.Equal,2,E.ValueType.DivertTarget,e),this.AddOpToNativeFunc(this.NotEquals,2,E.ValueType.DivertTarget,t);}}AddOpFuncForType(e,t){this._operationFuncs==null&&(this._operationFuncs=new Map),this._operationFuncs.set(e,t);}static AddOpToNativeFunc(e,t,n,i){if(this._nativeFunctions===null)return (0, de.throwNullException)("NativeFunctionCall._nativeFunctions");let a=this._nativeFunctions.get(e);a||(a=new s(e,t),this._nativeFunctions.set(e,a)),a.AddOpFuncForType(n,i);}static AddIntBinaryOp(e,t){this.AddOpToNativeFunc(e,2,E.ValueType.Int,t);}static AddIntUnaryOp(e,t){this.AddOpToNativeFunc(e,1,E.ValueType.Int,t);}static AddFloatBinaryOp(e,t){this.AddOpToNativeFunc(e,2,E.ValueType.Float,t);}static AddFloatUnaryOp(e,t){this.AddOpToNativeFunc(e,1,E.ValueType.Float,t);}static AddStringBinaryOp(e,t){this.AddOpToNativeFunc(e,2,E.ValueType.String,t);}static AddListBinaryOp(e,t){this.AddOpToNativeFunc(e,2,E.ValueType.List,t);}static AddListUnaryOp(e,t){this.AddOpToNativeFunc(e,1,E.ValueType.List,t);}toString(){return 'Native "'+this.name+'"'}};ai.NativeFunctionCall=A;A.Add="+";A.Subtract="-";A.Divide="/";A.Multiply="*";A.Mod="%";A.Negate="_";A.Equal="==";A.Greater=">";A.Less="<";A.GreaterThanOrEquals=">=";A.LessThanOrEquals="<=";A.NotEquals="!=";A.Not="!";A.And="&&";A.Or="||";A.Min="MIN";A.Max="MAX";A.Pow="POW";A.Floor="FLOOR";A.Ceiling="CEILING";A.Int="INT";A.Float="FLOAT";A.Has="?";A.Hasnt="!?";A.Intersect="^";A.ListMin="LIST_MIN";A.ListMax="LIST_MAX";A.All="LIST_ALL";A.Count="LIST_COUNT";A.ValueOfList="LIST_VALUE";A.Invert="LIST_INVERT";A._nativeFunctions=null;});var li=m(oi=>{Object.defineProperty(oi,"__esModule",{value:true});oi.NumberExpression=void 0;var Ac=ye(),Ns=M(),Ic=R(),As=class s extends Ac.Expression{constructor(e,t){if(super(),this.isInt=()=>this.subtype=="int",this.isFloat=()=>this.subtype=="float",this.isBool=()=>this.subtype=="bool",this.GenerateIntoContainer=n=>{this.isInt()?n.AddContent(new Ns.IntValue(this.value)):this.isFloat()?n.AddContent(new Ns.FloatValue(this.value)):this.isBool()&&n.AddContent(new Ns.BoolValue(this.value));},this.toString=()=>String(this.value),typeof e=="number"&&!Number.isNaN(e)||typeof e=="boolean")this.value=e,this.subtype=t;else throw new Error("Unexpected object type in NumberExpression.")}get typeName(){return "Number"}Equals(e){let t=(0, Ic.asOrNull)(e,s);return t?t.subtype==this.subtype&&t.value==this.value:false}};oi.NumberExpression=As;});var Is=m(ui=>{Object.defineProperty(ui,"__esModule",{value:true});ui.UnaryExpression=void 0;var Fc=ye(),Vc=Ie(),wt=li(),kc=R(),sn=class extends Fc.Expression{get nativeNameForOp(){return this.op==="-"?"_":this.op==="not"?"!":this.op}constructor(e,t){super(),this.op=t,this.GenerateIntoContainer=n=>{this.innerExpression.GenerateIntoContainer(n),n.AddContent(Vc.NativeFunctionCall.CallWithName(this.nativeNameForOp));},this.toString=()=>this.nativeNameForOp+this.innerExpression,this.innerExpression=this.AddContent(e);}get typeName(){return "UnaryExpression"}};ui.UnaryExpression=sn;sn.WithInner=(s,e)=>{let t=(0, kc.asOrNull)(s,wt.NumberExpression);if(t){if(e==="-"){if(t.isInt())return new wt.NumberExpression(-t.value,"int");if(t.isFloat())return new wt.NumberExpression(-t.value,"float")}else if(e=="!"||e=="not"){if(t.isInt())return new wt.NumberExpression(t.value==0,"bool");if(t.isFloat())return new wt.NumberExpression(t.value==0,"bool");if(t.isBool())return new wt.NumberExpression(!t.value,"bool")}throw new Error("Unexpected operation or number type")}return new sn(s,e)};});var Vs=m(hi=>{Object.defineProperty(hi,"__esModule",{value:true});hi.BinaryExpression=void 0;var Rc=ye(),Dc=Ie(),Lc=Is(),Wc=R(),Fs=class extends Rc.Expression{constructor(e,t,n){super(),this.opName=n,this.GenerateIntoContainer=i=>{this.leftExpression.GenerateIntoContainer(i),this.rightExpression.GenerateIntoContainer(i),this.opName=this.NativeNameForOp(this.opName),i.AddContent(Dc.NativeFunctionCall.CallWithName(this.opName));},this.NativeNameForOp=i=>i==="and"?"&&":i==="or"?"||":i==="mod"?"%":i==="has"?"?":i==="hasnt"?"!?":i,this.toString=()=>`(${this.leftExpression} ${this.opName} ${this.rightExpression})`,this.leftExpression=this.AddContent(e),this.rightExpression=this.AddContent(t),this.opName=n;}get typeName(){return "BinaryExpression"}ResolveReferences(e){if(super.ResolveReferences(e),this.NativeNameForOp(this.opName)==="?"){let t=(0, Wc.asOrNull)(this.leftExpression,Lc.UnaryExpression);t!==null&&(t.op==="not"||t.op==="!")&&this.Error(`Using 'not' or '!' here negates '${t.innerExpression}' rather than the result of the '?' or 'has' operator. You need to add parentheses around the (A ? B) expression.`);}}};hi.BinaryExpression=Fs;});var on=m(ci=>{Object.defineProperty(ci,"__esModule",{value:true});ci.CharacterSet=void 0;var an=class{constructor(e){this.set=new Set,this.Add=t=>this.set.add(t),this.AddRange=(t,n)=>{for(let i=t.charCodeAt(0);i<=n.charCodeAt(0);++i)this.Add(String.fromCharCode(i));return this},this.AddCharacters=t=>{if(typeof t=="string"||Array.isArray(t))for(let n of t)this.Add(n);else for(let n of t.set)this.Add(n);return