=h.length&&!g.isFront)continue}d0)h.shift().demote();return e}function o(e,t,n){var i=e.children.indexOf(t),s=e.children.indexOf(n),o,u;t.children=e.children.splice(s+1,i-(s+1)),t.children.forEach(function(e){r(t,e)}),t.type=t.matches[n.type],t.innerText="";for(o=0,u=t.children.length;o=this.end)return null;if(this.childAt)return this.childAt[t]&&this.childAt[t].tokenAt(t)||this;if(this.children.length)for(n=0;n=this.end)return[];if(this.childAt)return(this.childAt[t]&&this.childAt[t].pathAt(t)||[]).concat(this);if(this.children.length)for(r=0;r=this.end?null:this.children?this.children.reduce(function(e,n){return e||(t>=n.start&&t0&&(e+="["+this.children+"]"),e}},e={lex:function(t,r){var i=s(new n({type:"root",start:r||0,end:t.length,text:t,innerText:t,children:[],childAt:{},innerMode:e.startMode}));return i},rules:t},typeof module=="object"?module.exports=e:typeof define=="function"&&define.amd?define("lexer",[],function(){return e}):typeof StoryFormat=="function"&&this instanceof StoryFormat?(this.modules||(this.modules={}),this.modules.Lexer=e):this.TwineLexer=e}).call(this||(typeof global!="undefined"?global:window)),function(){"use strict";function t(e){return e&&typeof e=="object"?(Object.keys(e).forEach(function(n){e[n]=t(e[n])}),e):(e+"").replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function n(){return"[^"+Array.apply(0,arguments).map(t).join("")+"]*"}function r(e){return function(){return"("+e+Array.apply(0,arguments).join("|")+")"}}var e,i=r("?:"),s=r("?!"),o=r("?="),u="[ \\f\\t\\v - \u2028\u2029 ]*",a=u.replace("*","+"),f="\\b",l="\\\\\\n\\\\?|\\n\\\\",c="\\n(?!\\\\)",h="[\\w\\-À-Þß-ÿŐŰőű]",p="[\\wÀ-Þß-ÿŐŰőű]",d=i("\\n","$"),v="("+i(l,"[^\\n]")+"+)",m="\\*",g=u+"("+m+"+)"+a+v+d,y="(?:0\\.)",b=u+"("+y+"+)"+a+v+d,w=u+"-{3,}"+u+d,E=u+"(#{1,6})"+u+v+d,S=u+"(==+>|<=+|=+><=+|<==+>)"+u+d,x={opener:"\\[\\[(?!\\[)",text:"("+n("]")+")",rightSeparator:i("\\->","\\|"),leftSeparator:"<\\-",closer:"\\]\\]",legacySeparator:"\\|",legacyText:"("+i("[^\\|\\]]","\\]"+s("\\]"))+"+)"},T=h.replace("\\-","")+"*"+h.replace("\\-","").replace("\\w","a-zA-Z")+h.replace("\\-","")+"*",N="\\$("+T+")",C="'s"+a+"("+T+")",k="("+T+")"+a+"of"+f+s("it"+f),L="'s"+a,A="of"+f,O=i("it","time")+f,M="its"+a+"("+T+")",_="its"+a,D="("+T+")"+a+"of"+a+"it"+f,P="of"+f+a+"it"+f,H={opener:"\\(",name:"("+i(h.replace("]","\\/]")+h+"*",N)+"):",closer:"\\)"},B="<<[^>\\s]+\\s*(?:\\\\.|'(?:[^'\\\\]*\\\\.)*[^'\\\\]*'|\"(?:[^\"\\\\]*\\\\.)*[^\"\\\\]*\"|[^'\"\\\\>]|>(?!>))*>>",j={name:"[a-zA-Z][\\w\\-]*",attrs:"(?:\"[^\"]*\"|'[^']*'|[^'\">])*?"},F="\\|("+h.replace("]","_]")+"*)>",I="<("+h.replace("]","_]")+"*)\\|",q="\\b(\\d+(?:\\.\\d+)?(?:[eE][+\\-]?\\d+)?|NaN)"+s("m?s")+"\\b";x.main=x.opener+i(x.text+x.rightSeparator,x.text.replace("*","*?")+x.leftSeparator)+x.text,e={upperLetter:"[A-ZÀ-ÞŐŰ]",lowerLetter:"[a-z0-9_\\-ß-ÿőű]",anyLetter:h,anyLetterStrict:p,whitespace:a,escapedLine:l,br:c,commentFront:"",tag:"<\\/?"+j.name+j.attrs+">",tagPeek:"<",scriptStyleTag:"<("+i("script","style")+")"+j.attrs+">"+"[^]*?"+"<\\/\\1>",scriptStyleTagOpener:"<",url:"("+i("https?","mailto","javascript","ftp","data")+":\\/\\/[^\\s<]+[^<.,:;\"')\\]\\s])",bullet:m,hr:w,heading:E,align:S,bulleted:g,numbered:b,delOpener:t("~~"),italicOpener:t("//"),boldOpener:t("''"),supOpener:t("^^"),strongFront:t("**"),strongBack:t("**"),emFront:t("*"),emBack:t("*"),verbatimOpener:"`+",collapsedFront:"{",collapsedBack:"}",hookAppendedFront:"\\[",hookPrependedFront:F+"\\[",hookAnonymousFront:"\\[",hookBack:"\\]"+s(I),hookAppendedBack:"\\]"+I,passageLink:x.main+x.closer,passageLinkPeek:"[[",legacyLink:x.opener+x.legacyText+x.legacySeparator+x.legacyText+x.closer,legacyLinkPeek:"[[",simpleLink:x.opener+x.legacyText+x.closer,simpleLinkPeek:"[[",macroFront:H.opener+o(H.name),macroFrontPeek:"(",macroName:H.name,groupingFront:"\\("+s(H.name),groupingFrontPeek:"(",groupingBack:"\\)",twine1Macro:B,twine1MacroPeek:"<<",property:C,propertyPeek:"'s",belongingProperty:k,possessiveOperator:L,belongingOperator:A,belongingOperatorPeek:"of",itsOperator:_,itsOperatorPeek:"its",belongingItOperator:P,belongingItOperatorPeek:"of",variable:N,variablePeek:"$",hookRef:"\\?("+h+"+)\\b",hookRefPeek:"?",cssTime:"(\\d+\\.?\\d*|\\d*\\.?\\d+)(m?s)"+f,colour:i(i("Red","Orange","Yellow","Lime","Green","Cyan","Aqua","Blue","Navy","Purple","Fuchsia","Magenta","White","Gray","Grey","Black"),"#[\\dA-Fa-f]{3}(?:[\\dA-Fa-f]{3})?"),number:q,"boolean":i("true","false")+f,identifier:O,itsProperty:M,itsPropertyPeek:"its",belongingItProperty:D,escapedStringChar:"\\\\[^\\n]",singleStringOpener:"'",doubleStringOpener:'"',is:"is"+s(" not"," in")+f,isNot:"is not"+f,and:"and"+f,or:"or"+f,not:"not"+f,inequality:i("<(?!=)","<=",">(?!=)",">="),isIn:"is in"+f,contains:"contains"+f,addition:t("+")+s("="),subtraction:t("-")+s("="),multiplication:t("*")+s("="),division:i("/","%")+s("="),comma:",",spread:"\\.\\.\\."+s("\\."),to:i("to"+f,"="),into:"into"+f,augmentedAssign:i("\\+","\\-","\\*","\\/","%")+"="},typeof module=="object"?module.exports=e:typeof define=="function"&&define.amd?define("patterns",[],function(){return e}):typeof StoryFormat=="function"&&this instanceof StoryFormat?(this.modules||(this.modules={}),this.modules.Patterns=e):this.Patterns=e}.call(this||(typeof global!="undefined"?global:window)),function(){"use strict";function t(t){function f(e){return e=e||"innerText",function(t){var n=t.reduceRight(function(e,t,n){return e||(n?t:"")},""),r={};return r[e]=n,r}}function l(e,t){var n={};return n[e]=t,function(){return{isFront:!0,matches:n}}}function h(e,t){return Object.keys(t).forEach(function(n){var r=t[n].fn;t[n].fn=function(t){var i=r(t);return i.text||(i.text=t[0]),i.type||(i.type=n),i.innerMode||(i.innerMode=e),i}}),t}var n,r,i,s,o,u=[],a=[],c=Object.bind(0,null);return n=h(u,{hr:{fn:c},bulleted:{fn:function(e){return{depth:e[1].length,innerText:e[2]}}},numbered:{fn:function(e){return{depth:e[1].length/2,innerText:e[2]}}},heading:{fn:function(e){return{depth:e[1].length,innerText:e[2]}}},align:{fn:function(e){var t,n=e[1],r=n.indexOf("><");return~r?(t=Math.round(r/(n.length-2)*50),t===25&&(t="center")):n[0]==="<"&&n.slice(-1)===">"?t="justify":n.indexOf(">")>-1?t="right":n.indexOf("<")>-1&&(t="left"),{align:t}}}}),Object.keys(n).forEach(function(e){n[e].canFollow=[null,"br","hr","bulleted","numbered","heading","align"],n[e].cannotFollow=["text"]}),r=h(u,{twine1Macro:{fn:function(){return{type:"error",message:"Twine 2 macros use a different syntax to Twine 1 macros."}}},br:{fn:c},emBack:{fn:function(){return{matches:{emFront:"em"}}}},strongBack:{fn:function(){return{matches:{strongFront:"strong"}}}},strongFront:{fn:function(){return{isFront:!0}}},emFront:{fn:function(){return{isFront:!0}}},boldOpener:{fn:l("boldOpener","bold")},italicOpener:{fn:l("italicOpener","italic")},delOpener:{fn:l("delOpener","del")},supOpener:{fn:l("supOpener","sup")},commentFront:{fn:function(){return{isFront:!0}}},commentBack:{fn:function(){return{matches:{commentFront:"comment"}}}},scriptStyleTag:{fn:c},tag:{fn:c},url:{fn:c},passageLink:{fn:function(e){var t=e[1],n=e[2],r=e[3];return{type:"twineLink",innerText:n?r:t,passage:t?r:n}}},simpleLink:{fn:function(e){return{type:"twineLink",innerText:e[1],passage:e[1]}}},hookPrependedFront:{fn:function(e){return{name:e[1],isFront:!0,tagPosition:"prepended"}}},hookAnonymousFront:{fn:function(){return{isFront:!0,demote:function(){this.error("This tagged hook doesn't have a matching ].")}}},canFollow:["macro","variable"]},hookAppendedFront:{fn:function(){return{isFront:!0}},cannotFollow:["macro","variable"]},hookBack:{fn:function(){return{type:"hookAppendedBack",matches:{hookPrependedFront:"hook",hookAnonymousFront:"hook"}}}},hookAppendedBack:{fn:function(e){return{name:e[1],tagPosition:"appended",matches:{hookAppendedFront:"hook"}}}},verbatimOpener:{fn:function(e){var t=e[0].length,n={};return n["verbatim"+t]="verbatim",{type:"verbatim"+t,isFront:!0,matches:n}}},collapsedFront:{fn:function(){return{isFront:!0}}},collapsedBack:{fn:function(){return{matches:{collapsedFront:"collapsed"}}}},escapedLine:{fn:c},legacyLink:{fn:function(e){return{type:"twineLink",innerText:e[1],passage:e[2]}}}}),i=h(a,{macroFront:{fn:function(e){return{isFront:!0,name:e[1]}}},groupingBack:{fn:function(){return{matches:{groupingFront:"grouping",macroFront:"macro"}}}},hookRef:{fn:f("name")},variable:{fn:f("name")},whitespace:{fn:c,cannotFollow:"text"}}),s=h(a,Object.assign({macroName:{canFollow:["macroFront"],fn:function(e){return e[2]?{isMethodCall:!0,innerText:e[2]}:{isMethodCall:!1}}},groupingFront:{fn:function(){return{isFront:!0}}},property:{fn:f("name"),canFollow:["variable","hookRef","property","itsProperty","belongingItProperty","macro","grouping","string"]},possessiveOperator:{fn:c},itsProperty:{fn:f("name")},itsOperator:{fn:c},belongingItProperty:{cannotFollow:["text"],fn:f("name")},belongingItOperator:{cannotFollow:["text"],fn:c},belongingProperty:{cannotFollow:["text"],fn:f("name")},belongingOperator:{cannotFollow:["text"],fn:c},escapedStringChar:{fn:function(){return{type:"text"}}},singleStringOpener:{fn:function(){return{isFront:!0,matches:{singleStringOpener:"string"}}}},doubleStringOpener:{fn:function(){return{isFront:!0,matches:{doubleStringOpener:"string"}}}},cssTime:{fn:function(e){return{value:+e[1]*(e[2].toLowerCase()==="s"?1e3:1)}}},colour:{cannotFollow:["text"],fn:function(e){var t,n=e[0].toLowerCase(),r={red:"e61919",orange:"e68019",yellow:"e5e619",lime:"80e619",green:"19e619",cyan:"19e5e6",aqua:"19e5e6",blue:"197fe6",navy:"1919e6",purple:"7f19e6",fuchsia:"e619e5",magenta:"e619e5",white:"fff",black:"000",gray:"888",grey:"888"};return Object.hasOwnProperty.call(r,n)?t="#"+r[n]:t=n,{colour:t}}},number:{fn:function(e){return{value:parseFloat(e[0])}}},addition:{fn:c},subtraction:{fn:c},multiplication:{fn:c},division:{fn:c},inequality:{fn:function(e){return{operator:e[0]}}},augmentedAssign:{fn:function(e){return{operator:e[0][0]}}},identifier:{fn:f("name")}},["boolean","is","to","into","and","or","not","isNot","contains","isIn"].reduce(function(e,t){return e[t]={fn:c,cannotFollow:["text"]},e},{}),["comma","spread","addition","subtraction","multiplication","division"].reduce(function(e,t){return e[t]={fn:c},e},{}))),[].push.apply(u,Object.keys(n).concat(Object.keys(r)).concat(Object.keys(i))),[].push.apply(a,Object.keys(i).concat(Object.keys(s))),o=Object.assign({},n,r,i,s),Object.keys(o).forEach(function(t){var n=e[t];typeof n!="string"?o[t].pattern=n:o[t].pattern=new RegExp("^(?:"+n+")","i"),e[t+"Peek"]&&(o[t].peek=e[t+"Peek"])}),Object.assign(t.rules,o),t.startMode=u,t}function n(n){var r=Object.freeze({lex:t(n).lex,Patterns:e});return r}var e;Object.assign=Object.assign||function(t){var n=1,r,i;for(;nHTML tags
are available.","To display special symbols without them being transformed, put them between `backticks`.","To link to another passage, write the link text and the passage name like this: [[link text->passage name]]\nor this: [[passage name<-link text]]\nor this: [[link text]].","Macros like (set:) and (display:) are the programming of your passage. If you've (set:) a $variable, you can just enter its name to print it out.","To make a 'hook', put [single square brackets] around text - or leave it empty [] - then put a macro like (if:), a $variable, or a |nametag> outside the front, |like>[so].","Hooks can be used for many things: showing text (if:) something happened, applying a (text-style:), making a place to (append:) text later on, and much more!","Consult the Harlowe documentation for more information."].join("\n\n"))),{pos:0}},blankLine:function(e){e.pos++},token:function(n,s){var u,a,f,l,c={},h,p="";o&&o(),u=t.pathAt(s.pos),a=u[0];if(!a)return s.pos++,n.next(),null;while(a===a.tokenAt(s.pos)&&!n.eol())s.pos++,n.next();n.eol()&&s.pos++;for(h=0;h1&&(f+="-"+c[f]),c[f]=(c[f]||0)+1;switch(l){case"macroName":i.indexOf(r(u[h].text.slice(0,-1)))===-1&&(f+=" harlowe-error")}p+=f+" "}return p}}}),t=document.querySelector("style#cm-harlowe"),t||(t=document.createElement("style"),t.setAttribute("id","cm-harlowe"),document.head.appendChild(t)),t.innerHTML=function(){function e(e,t,n){return function(r){return"background-color: hsla("+e+","+t+"%,"+n+"%,"+r+");"}}var t=e(40,100,50),n=e(220,100,50),r="color: #a84186;",i=r+"font-style:italic;",s="color: #3333cc;",o="color: firebrick; background-color: hsla(17, 100%, 74%, 0.74);";return{hook:t(.05),"hook-2":t(.1),"hook-3":t(.15),"hook-4":t(.2),"hook-5":t(.25),"hook-6":t(.3),"hook-7":t(.35),"hook-8":t(.4),"^=hook, ^=hook-":"font-weight:bold;",error:o,macro:r,macroName:i,"^=macro ":"font-weight:bold;","bold, strong":"font-weight:bold;","italic, em":"font-style:italic;",verbatim:"background-color: hsla(0,0%,50%,0.1)","^=collapsed":"font-weight:bold; color: hsl(201, 100%, 30%);",collapsed:n(.025),"collapsed.hook":n(.05),"collapsed.hook-2":n(.1),"collapsed.hook-3":n(.15),"collapsed.hook-4":n(.2),"collapsed.hook-5":n(.25),"collapsed.hook-6":n(.3),"collapsed.hook-7":n(.35),"collapsed.hook-8":n(.4),twineLink:s,tag:"color: #4d4d9d;","boolean":"color: #626262;",string:"color: #008282;",number:"color: #A15000;",variable:"color: #005682;",hookRef:"color: #007f54;",heading:"font-weight:bold;",hr:"display:block; background-image: linear-gradient(0deg, transparent, transparent 45%, silver 45%, transparent 55%, transparent);",align:"display:block; color: hsl(14, 99%, 27%); background-color: hsla(14, 99%, 87%, 0.2);",escapedLine:"font-weight:bold; color: hsl(51, 100%, 30%);","identifier, property, belongingProperty, itsProperty, belongingItProperty, belongingItOperator":"color: #0076b2;",toString:function(){return Object.keys(this).reduce(function(e,t){var n;return t==="toString"?e:(n=t.split(", ").map(function r(e){return e.indexOf(".")>-1?e.split(/\./g).map(r).join(""):e.indexOf("^=")===0?"[class^='cm-harlowe-"+e.slice(2)+"']":".cm-harlowe-"+e}),e+n.join(", ")+"{"+this[t]+"}")}.bind(this),"")}}+""}()}.call(this);}});