UNPKG

botscripten

Version:

Craft rich bot conversations using the Twine/Twee format

1 lines 25.1 kB
window.storyFormat({"name":"Botscripten","description":"An interactive chat viewer","author":"Jakob Heuser","image":"icon.svg","url":"github:aibexhq/botscripten","version":"2.0.0","proofing":false,"source":"<!doctype html><html><head><title>{{STORY_NAME}}</title><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,shrink-to-fit=no\"></head><body><!-- prettier-ignore --><twine>{{STORY_DATA}}</twine><nav><div id=\"nav-reset\"><h1>{{STORY_NAME}}</h1><div id=\"toggles\"><label><input type=\"checkbox\" name=\"show_directives\" id=\"show_directives\" checked=\"checked\">show directives</label><label><input type=\"checkbox\" name=\"proofing\" id=\"proofing\">show proofing</label></div></div></nav><section id=\"runtime\"><main id=\"chat-panel\"><div id=\"passages\"><div id=\"history\"></div><div id=\"active-passage\"></div><div id=\"animation-container\"><div class=\"chat-passage-wrapper\"><div class=\"chat-passage\"><div class=\"wave\"><span class=\"dot\"></span><span class=\"dot\"></span><span class=\"dot\"></span></div></div></div></div></div><div id=\"user-response-wrapper\"><div id=\"user-response-panel\"></div></div></main></section><!-- prettier-ignore --><section id=\"format\"><style>:root{--nav-height:46px;--nav-buffer:10px;--max-width:768px;--bg-color:#4d5263;--user-color:#7aaebb;--speaker-color:rgb( 136, 136, 136 );--directive-border:#c3c3c3;--navbar-bg-color:#fff;--passage-bg-color:#fff;--passage-text-color:#222}body{font-family:\"Lucida Sans\",\"Lucida Sans Regular\",\"Lucida Grande\",\"Lucida Sans Unicode\",Geneva,Verdana,sans-serif;font-size:16px;margin:0;padding:0}body.proof twine{padding:50px;font-size:12px}#twine-user-script,#twine-user-stylesheet,.proof #runtime main,.proof #user-response-panel,twine{display:none!important}.proof twine,.proof twine *{display:block!important;font-family:monospace;white-space:pre}nav{position:fixed;z-index:1;height:var(--nav-height);background:var(--navbar-bg-color);width:100vw;max-width:var(--max-width);top:0;border:5px solid var(--speaker-color);border-top:0;border-left:0;border-right:0}nav h1{margin:0;font-size:26px;padding:10px 1em 0 1em;line-height:26px}#nav-reset{position:relative}#toggles{position:absolute;right:1em;top:50%}#toggles label{margin-left:1em}#runtime,twine{margin-top:var(--nav-height)}.proof tw-storydata::before{content:\":: StoryTitle\\A\"attr(name);color:green}.proof tw-passagedata::before{content:\":: \" attr(name) \" [\" attr(tags) \"]\";color:#00f;margin:1em 0 0 0;display:block;font-weight:700}.proof tw-passagedata.start::before{content:\"🚀 :: \" attr(name) \" [\" attr(tags) \"]\"}.proof tw-passagedata+tw-passagedata{border-top:1pt dashed #000;padding:1em 0;margin:1em 0 0 0}.proof #runtime{position:absolute;top:0}#runtime{display:flex;flex-direction:column;height:calc(100vh - var(--nav-height));max-height:calc(100% - var(--nav-height));max-width:var(--max-width)}#runtime main{flex:1 1 auto;background-color:var(--bg-color);padding:var(--nav-buffer) 15px 15px 15px}.chat-passage-reset{position:relative}.chat-passage:before{content:attr(data-speaker);display:block;font-size:.75rem;text-transform:capitalize;color:var(--speaker-color)}.chat-passage{background:var(--passage-bg-color);margin:0 0 1em 0;padding:.33em}.chat-passage p{margin:0}.chat-passage-wrapper{display:flex;flex-direction:row}.chat-passage-wrapper[data-speaker=you]{flex-direction:row-reverse}.chat-passage-wrapper .chat-passage{margin-left:45px}.chat-passage-wrapper[data-speaker=you] .chat-passage{margin-right:45px}.chat-passage-wrapper:before{margin-right:5px;position:absolute;vertical-align:top;content:\"\";width:30px;height:30px;background-size:30px 30px;border-radius:15px;background-color:var(--speaker-color)}.chat-passage-wrapper[data-speaker=you]:before{display:none}.chat-passage-wrapper[data-speaker=you]:after{margin-left:-30px;position:absolute;top:0;right:0;vertical-align:top;content:\"\";width:30px;height:30px;background-size:30px 30px;border-radius:15px;background-color:var(--user-color)}body.show-directives .directives{display:block}.directives{display:none;font-family:Consolas,\"Andale Mono WT\",\"Andale Mono\",\"Lucida Console\",\"Lucida Sans Typewriter\",\"DejaVu Sans Mono\",\"Bitstream Vera Sans Mono\",\"Liberation Mono\",\"Nimbus Mono L\",Monaco,\"Courier New\",Courier,monospace;font-size:12px}.directive{white-space:pre;border:1px dashed var(--directive-border);position:relative;overflow-x:auto;padding-top:20px;color:var(--passage-bg-color);margin-bottom:1em}.directive::after{content:attr(name);position:absolute;right:2px;top:2px;font-weight:700;font-size:14px;letter-spacing:.2em;color:var(--passage-bg-color)}#user-response-wrapper{padding-right:15px;padding-left:15px;flex:1 1 auto;display:flex;flex-direction:column;justify-content:end;border-top:3px solid var(--directive-border)}#user-response-panel{height:100px;display:flex;flex-direction:row;align-items:center;justify-content:center}#user-response-panel .user-response{display:inline-block;padding:.5rem;margin:.25rem;background-color:#fff;color:#333;border-top:2px solid transparent;transition:border-color .15s ease-in}#user-response-panel .user-response:hover{text-decoration:none;border-color:var(--user-color)}#animation-container .wave{position:relative;text-align:center;margin-left:auto;margin-right:auto}#animation-container .dot{display:inline-block;width:6px;height:6px;border-radius:50%;margin-right:2px;background:var(--passage-text-color);animation:wave 1.2s ease-in-out infinite}#animation-container .dot:nth-child(2){animation-delay:.1s}#animation-container .dot:nth-child(3){animation-delay:.2s}@keyframes wave{0%,100%,50%{transform:initial}25%{transform:translateY(-15px)}}</style><script>!function(t){\"function\"==typeof define&&define.amd?define(t):t()}(function(){\"use strict\";var a=function(t,e){if(!(t instanceof e))throw new TypeError(\"Cannot call a class as a function\")};var s=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t};var n=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n};var e=function(t){if(Array.isArray(t))return n(t)};var r=function(t){if(\"undefined\"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)};var o=function(t,e){if(t){if(\"string\"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return\"Object\"===r&&t.constructor&&(r=t.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(r):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}};var i=function(){throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")};var c=function(t){return e(t)||r(t)||o(t)||i()},t=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{};var u,d=(function(t){var e=function(a){var c,t=Object.prototype,l=t.hasOwnProperty,e=\"function\"==typeof Symbol?Symbol:{},o=e.iterator||\"@@iterator\",r=e.asyncIterator||\"@@asyncIterator\",n=e.toStringTag||\"@@toStringTag\";function s(t,e,r,n){var i,a,s,c,o=e&&e.prototype instanceof g?e:g,u=Object.create(o.prototype),l=new k(n||[]);return u._invoke=(i=t,a=r,s=l,c=h,function(t,e){if(c===p)throw new Error(\"Generator is already running\");if(c===v){if(\"throw\"===t)throw e;return _()}for(s.method=t,s.arg=e;;){var r=s.delegate;if(r){var n=E(r,s);if(n){if(n===y)continue;return n}}if(\"next\"===s.method)s.sent=s._sent=s.arg;else if(\"throw\"===s.method){if(c===h)throw c=v,s.arg;s.dispatchException(s.arg)}else\"return\"===s.method&&s.abrupt(\"return\",s.arg);c=p;var o=f(i,a,s);if(\"normal\"===o.type){if(c=s.done?v:d,o.arg===y)continue;return{value:o.arg,done:s.done}}\"throw\"===o.type&&(c=v,s.method=\"throw\",s.arg=o.arg)}}),u}function f(t,e,r){try{return{type:\"normal\",arg:t.call(e,r)}}catch(t){return{type:\"throw\",arg:t}}}a.wrap=s;var h=\"suspendedStart\",d=\"suspendedYield\",p=\"executing\",v=\"completed\",y={};function g(){}function i(){}function u(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,w=b&&b(b(T([])));w&&w!==t&&l.call(w,o)&&(m=w);var x=u.prototype=g.prototype=Object.create(m);function L(t){[\"next\",\"throw\",\"return\"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function O(c,u){var e;this._invoke=function(r,n){function t(){return new u(function(t,e){!function e(t,r,n,o){var i=f(c[t],c,r);if(\"throw\"!==i.type){var a=i.arg,s=a.value;return s&&\"object\"==typeof s&&l.call(s,\"__await\")?u.resolve(s.__await).then(function(t){e(\"next\",t,n,o)},function(t){e(\"throw\",t,n,o)}):u.resolve(s).then(function(t){a.value=t,n(a)},function(t){return e(\"throw\",t,n,o)})}o(i.arg)}(r,n,t,e)})}return e=e?e.then(t,t):t()}}function E(t,e){var r=t.iterator[e.method];if(r===c){if(e.delegate=null,\"throw\"===e.method){if(t.iterator.return&&(e.method=\"return\",e.arg=c,E(t,e),\"throw\"===e.method))return y;e.method=\"throw\",e.arg=new TypeError(\"The iterator does not provide a 'throw' method\")}return y}var n=f(r,t.iterator,e.arg);if(\"throw\"===n.type)return e.method=\"throw\",e.arg=n.arg,e.delegate=null,y;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,\"return\"!==e.method&&(e.method=\"next\",e.arg=c),e.delegate=null,y):o:(e.method=\"throw\",e.arg=new TypeError(\"iterator result is not an object\"),e.delegate=null,y)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type=\"normal\",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:\"root\"}],t.forEach(j,this),this.reset(!0)}function T(e){if(e){var t=e[o];if(t)return t.call(e);if(\"function\"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(l.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=c,t.done=!0,t};return n.next=n}}return{next:_}}function _(){return{value:c,done:!0}}return i.prototype=x.constructor=u,u.constructor=i,u[n]=i.displayName=\"GeneratorFunction\",a.isGeneratorFunction=function(t){var e=\"function\"==typeof t&&t.constructor;return!!e&&(e===i||\"GeneratorFunction\"===(e.displayName||e.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,n in t||(t[n]=\"GeneratorFunction\")),t.prototype=Object.create(x),t},a.awrap=function(t){return{__await:t}},L(O.prototype),O.prototype[r]=function(){return this},a.AsyncIterator=O,a.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var i=new O(s(t,e,r,n),o);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},L(x),x[n]=\"Generator\",x[o]=function(){return this},x.toString=function(){return\"[object Generator]\"},a.keys=function(r){var n=[];for(var t in r)n.push(t);return n.reverse(),function t(){for(;n.length;){var e=n.pop();if(e in r)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method=\"next\",this.arg=c,this.tryEntries.forEach(S),!t)for(var e in this)\"t\"===e.charAt(0)&&l.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=c)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if(\"throw\"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var n=this;function t(t,e){return i.type=\"throw\",i.arg=r,n.next=t,e&&(n.method=\"next\",n.arg=c),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if(\"root\"===o.tryLoc)return t(\"end\");if(o.tryLoc<=this.prev){var a=l.call(o,\"catchLoc\"),s=l.call(o,\"finallyLoc\");if(a&&s){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!s)throw new Error(\"try statement without catch or finally\");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;0<=r;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&l.call(n,\"finallyLoc\")&&this.prev<n.finallyLoc){var o=n;break}}o&&(\"break\"===t||\"continue\"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method=\"next\",this.next=o.finallyLoc,y):this.complete(i)},complete:function(t,e){if(\"throw\"===t.type)throw t.arg;return\"break\"===t.type||\"continue\"===t.type?this.next=t.arg:\"return\"===t.type?(this.rval=this.arg=t.arg,this.method=\"return\",this.next=\"end\"):\"normal\"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if(\"throw\"===n.type){var o=n.arg;S(r)}return o}}throw new Error(\"illegal catch attempt\")},delegateYield:function(t,e,r){return this.delegate={iterator:T(t),resultName:e,nextLoc:r},\"next\"===this.method&&(this.arg=c),y}},a}(t.exports);try{regeneratorRuntime=e}catch(t){Function(\"r\",\"regeneratorRuntime = r\")(e)}}(u={exports:{}}),u.exports);function l(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}var f=function(s){return function(){var t=this,a=arguments;return new Promise(function(e,r){var n=s.apply(t,a);function o(t){l(n,e,r,o,i,\"next\",t)}function i(t){l(n,e,r,o,i,\"throw\",t)}o(void 0)})}},h=1/0,p=\"[object Symbol]\",v=/&(?:amp|lt|gt|quot|#39|#96);/g,y=RegExp(v.source),g=\"object\"==typeof t&&t&&t.Object===Object&&t,m=\"object\"==typeof self&&self&&self.Object===Object&&self,b=g||m||Function(\"return this\")();var w,x=(w={\"&amp;\":\"&\",\"&lt;\":\"<\",\"&gt;\":\">\",\"&quot;\":'\"',\"&#39;\":\"'\",\"&#96;\":\"`\"},function(t){return null==w?void 0:w[t]}),L=Object.prototype.toString,O=b.Symbol,E=O?O.prototype:void 0,j=E?E.toString:void 0;function S(t){if(\"string\"==typeof t)return t;if(\"symbol\"==typeof(e=t)||function(t){return t&&\"object\"==typeof t}(e)&&L.call(e)==p)return j?j.call(t):\"\";var e,r=t+\"\";return\"0\"==r&&1/t==-h?\"-0\":r}var k=function(t){var e;return(t=null==(e=t)?\"\":S(e))&&y.test(t)?t.replace(v,x):t},T=/^###@([\\S]+)([\\s\\S]*?)###/gm,_=/^#@([\\S]+)(.*)$/gm,P=/\\[\\[(.*?)\\]\\]/gm,A=\"__TOKEN_ESCAPED_BACKSLASH_OCTO__\",M=/###[\\s\\S]*?###/gm,H=/^#.*$/gm;function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function D(r){var t=r.source,e=function(t){var n=[];for(t=t.replace(\"\\\\#\",\"__TOKEN_ESCAPED_BACKSLASH_OCTO__\");t.match(T);)t=t.replace(T,function(t,e,r){return n.push({name:\"@\".concat(e),content:r.trim()}),\"\"});for(;t.match(_);)t=t.replace(_,function(t,e,r){return n.push({name:\"@\".concat(e),content:r.trim()}),\"\"});return n}(t),n=t.replace(\"\\\\#\",A).replace(M,\"\").replace(H,\"\").replace(A,\"#\").trim();r&&(r.links=[]);var o=function(t){for(var s=[],e=t;t.match(P);)t=t.replace(P,function(t,e){var r=e,n=e,o=e.indexOf(\"|\"),i=e.indexOf(\"->\"),a=e.indexOf(\"<-\");switch(!0){case 0<=o:r=e.substr(0,o),n=e.substr(o+1);break;case 0<=i:r=e.substr(0,i),n=e.substr(i+2);break;case 0<=a:r=e.substr(a+2),n=e.substr(0,a)}return s.push({display:r,target:n}),\"\"});return{links:s,updated:t,original:e}}(n);if(n=o.updated,r&&(r.links=o.links),e.forEach(function(e){r.story.directives[e.name]&&r.story.directives[e.name].forEach(function(t){n=t(e.content,n,r,r.story)})}),!r.getSpeaker())return{directives:e,text:[]};if(r){var i=r.prefixTag(\"prompt\");i.length&&r.story.prompt(i[0])}return r.hasTag(\"oneline\")?{directives:e,text:[n]}:{directives:e,text:(n=n.trim()).split(/[\\r\\n]+/g)}}function q(t,e,r,n,o){var i=this;a(this,q),s(this,\"id\",null),s(this,\"name\",null),s(this,\"tags\",null),s(this,\"tagDict\",{}),s(this,\"source\",null),s(this,\"links\",[]),s(this,\"getSpeaker\",function(){var t=i.tags.find(function(t){return 0===t.indexOf(\"speaker-\")})||\"\";return t?t.replace(/^speaker-/,\"\"):null}),s(this,\"prefixTag\",function(e,r){return i.tags.filter(function(t){return 0===t.indexOf(\"\".concat(e,\"-\"))}).map(function(t){return t.replace(\"\".concat(e,\"-\"),\"\")}).reduce(function(t,e){return r?function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},t,s({},e,1)):[].concat(c(t),[e])},r?{}:[])}),s(this,\"hasTag\",function(t){return i.tagDict[t]}),s(this,\"render\",function(){return D(i)}),this.id=t,this.name=e,this.tags=r,this.source=k(n),this.story=o,this.tags.forEach(function(t){return i.tagDict[t]=1})}s(q,\"render\",function(t){return D(new q(null,null,null,t,(e=window||null)&&e.story?e.story:{state:{}}));var e});var N=1/0,F=\"[object Symbol]\",G=/[&<>\"'`]/g,I=RegExp(G.source),B=\"object\"==typeof t&&t&&t.Object===Object&&t,K=\"object\"==typeof self&&self&&self.Object===Object&&self,R=B||K||Function(\"return this\")();var $,U=($={\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\",'\"':\"&quot;\",\"'\":\"&#39;\",\"`\":\"&#96;\"},function(t){return null==$?void 0:$[t]}),Y=Object.prototype.toString,z=R.Symbol,J=z?z.prototype:void 0,Q=J?J.toString:void 0;function V(t){if(\"string\"==typeof t)return t;if(\"symbol\"==typeof(e=t)||function(t){return t&&\"object\"==typeof t}(e)&&Y.call(e)==F)return Q?Q.call(t):\"\";var e,r=t+\"\";return\"0\"==r&&1/t==-N?\"-0\":r}function W(t,e){return t.querySelector(e)}function X(t,e){return c(t.querySelectorAll(e))||[]}function Z(t,e){var h=this;a(this,Z),s(this,\"version\",2),s(this,\"document\",null),s(this,\"story\",null),s(this,\"name\",\"\"),s(this,\"startsAt\",0),s(this,\"current\",0),s(this,\"history\",[]),s(this,\"passages\",{}),s(this,\"showPrompt\",!1),s(this,\"errorMessage\",\"⚠ %s\"),s(this,\"directives\",{}),s(this,\"elements\",{}),s(this,\"userScripts\",[]),s(this,\"userStyles\",[]),s(this,\"start\",function(){h.userStyles.forEach(function(t){var e=h.document.createElement(\"style\");e.innerHTML=t,h.document.body.appendChild(e)}),h.userScripts.forEach(function(t){globalEval(t)}),h.document.body.addEventListener(\"click\",function(t){t.target.matches(\"#user-response-panel a[data-passage]\")&&h.advance(h.findPassage(t.target.getAttribute(\"data-passage\")),t.target.innerHTML)}),h.document.body.addEventListener(\"click\",function(t){if(t.target.matches(\"#user-response-panel button[data-passage]\")){var e=W(h.document,\"#user-response-panel input\").value;h.showPrompt=!1,h.advance(h.findPassage(t.target.getAttribute(\"data-passage\")),e)}}),h.advance(h.findPassage(h.startsAt))}),s(this,\"findPassage\",function(e){if(e=\"\".concat(e).trim(),t=e,it.test(t))return h.passages[e];var t,r=X(h.story,\"tw-passagedata\").filter(function(t){return k(t.getAttribute(\"name\")).trim()===e})[0];return r?h.passages[r.getAttribute(\"pid\")]:null}),s(this,\"advance\",function(){var e=f(d.mark(function t(e){var r,n,o,i=arguments;return d.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=1<i.length&&void 0!==i[1]?i[1]:null,h.history.push(e.id),n=h.current,o=h.elements.active.innerHTML,h.elements.active.innerHTML=\"\",h.elements.history.innerHTML+=o,r&&h.renderUserMessage(n,r,function(t){return h.elements.history.innerHTML+=t}),t.next=9,h.renderPassage(e,function(t){return h.elements.active.innerHTML+=t});case 9:if(e.hasTag(\"wait\")||1!==e.links.length){t.next=12;break}return h.advance(h.findPassage(e.links[0].target)),t.abrupt(\"return\");case 12:h.renderChoices(e);case 13:case\"end\":return t.stop()}},t)}));return function(t){return e.apply(this,arguments)}}()),s(this,\"renderUserMessage\",function(){var n=f(d.mark(function t(o,i,a){return d.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a((0,r=(e={id:o,text:i}).id,n=e.text,'\\n <div class=\"chat-passage-reset\">\\n <div class=\"chat-passage-wrapper\" data-speaker=\"you\">\\n <div class=\"chat-passage\" data-speaker=\"you\" data-upassage=\"'.concat(r,'\">\\n ').concat(n,\"\\n </div>\\n </div>\\n </div>\\n\")));case 2:return h.scrollToBottom(),t.abrupt(\"return\",Promise.resolve());case 4:case\"end\":return t.stop()}var e,r,n},t)}));return function(t,e,r){return n.apply(this,arguments)}}()),s(this,\"renderPassage\",function(){var r=f(d.mark(function t(a,s){var c,u,l,f;return d.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return c=a.getSpeaker(),u=a.render(),console.log(u.directives),t.next=5,s((i=u.directives,'\\n <div class=\"directives\">\\n '.concat(i.map(function(t){var e=t.name,r=t.content;return'<div class=\"directive\" name=\"'.concat(e,'\">').concat(r.trim(),\"</div>\")}).join(\"\"),\"\\n </div>\\n\")));case 5:l=u.text.shift(),h.showTyping();case 7:if(l)return e={speaker:c,tags:a.tags,text:l},n=void 0,r=e.speaker,n=e.tags,o=e.text,f='\\n <div class=\"chat-passage-reset\">\\n <div data-speaker=\"'.concat(r,'\" class=\"chat-passage-wrapper ').concat(n.join(\" \"),'\">\\n <div data-speaker=\"').concat(r,'\" class=\"chat-passage\">\\n ').concat(o,\"\\n </div>\\n </div>\\n </div>\\n\"),t.next=11,at(h.calculateDelay(l));t.next=16;break;case 11:return t.next=13,s(f);case 13:l=u.text.shift(),t.next=7;break;case 16:return h.hideTyping(),h.scrollToBottom(),t.abrupt(\"return\",Promise.resolve());case 19:case\"end\":return t.stop()}var e,r,n,o,i},t)}));return function(t,e){return r.apply(this,arguments)}}()),s(this,\"calculateDelay\",function(t){return 20*t.length*.3}),s(this,\"showTyping\",function(){W(h.document,ot).style.visibility=\"visible\"}),s(this,\"hideTyping\",function(){W(h.document,ot).style.visibility=\"hidden\"}),s(this,\"scrollToBottom\",function(){var t=W(h.document,rt);document.scrollingElement.scrollTop=t.offsetHeight}),s(this,\"removeChoices\",function(){W(h.document,nt).innerHTML=\"\"}),s(this,\"renderChoices\",function(t){h.removeChoices();var e=W(h.document,nt);t.links.forEach(function(t){e.innerHTML+='<a href=\"javascript:void(0)\" class=\"user-response\" data-passage=\"'.concat(et(t.target),'\">').concat(t.display,\"</a>\")})}),s(this,\"directive\",function(t,e){h.directives[t]||(h.directives[t]=[]),h.directives[t].push(e)}),this.window=t,this.document=e?document.implementation.createHTMLDocument(\"Botscripten Injected Content\"):document,this.story=W(this.document,\"tw-storydata\"),this.elements={active:W(this.document,\"#active-passage\"),history:W(this.document,rt)},this.name=this.story.getAttribute(\"name\")||\"\",this.startsAt=this.story.getAttribute(\"startnode\")||0,X(this.story,\"tw-passagedata\").forEach(function(t){var e=parseInt(t.getAttribute(\"pid\")),r=t.getAttribute(\"name\"),n=(t.getAttribute(\"tags\")||\"\").split(/\\s+/g),o=t.innerHTML||\"\";h.passages[e]=new q(e,r,n,o,h)}),W(this.document,\"title\").innerHTML=this.name,this.userScripts=(X(this.document,'*[type=\"text/twine-javascript\"]')||[]).map(function(t){return t.innerHTML}),this.userStyles=(X(this.document,'*[type=\"text/twine-css\"]')||[]).map(function(t){return t.innerHTML})}var tt,et=function(t){var e;return(t=null==(e=t)?\"\":V(e))&&I.test(t)?t.replace(G,U):t},rt=\"#history\",nt=\"#user-response-panel\",ot=\"#animation-container\",it=/^[\\d]+$/,at=function(){var t=f(d.mark(function t(){var e,r=arguments;return d.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<r.length&&void 0!==r[0]?r[0]:0,t.abrupt(\"return\",new Promise(function(t){return setTimeout(t,e)}));case 2:case\"end\":return t.stop()}},t)}));return function(){return t.apply(this,arguments)}}();void 0!==(tt=window||void 0)&&(tt.document.addEventListener(\"DOMContentLoaded\",function(t){tt.globalEval=eval,tt.story=new Z(tt),tt.story.start(),tt.document.querySelector(\"#show_directives\").checked&&tt.document.body.classList.add(\"show-directives\"),tt.document.querySelector(\"#proofing\").checked?tt.document.body.classList.add(\"proof\"):tt.document.body.classList.add(\"run\")}),tt.document.querySelector(\"#show_directives\").addEventListener(\"change\",function(t){t.target.checked?tt.document.body.classList.add(\"show-directives\"):tt.document.body.classList.remove(\"show-directives\")}),tt.document.querySelector(\"#proofing\").addEventListener(\"change\",function(t){t.target.checked?(tt.document.body.classList.add(\"proof\"),tt.document.body.classList.remove(\"run\")):(tt.document.body.classList.add(\"run\"),tt.document.body.classList.remove(\"proof\"))}),document.querySelector(\"tw-passagedata[pid='\"+document.querySelector(\"tw-storydata\").getAttribute(\"startnode\")+\"']\").classList.add(\"start\"))});</script></section></body></html>"})