@rohal12/spindle 0.12.0 → 0.13.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.
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.2.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var _t,O,Si,qe,vr,ki,Ci,Ii,Yn,wn,Sn,Ai,Rt={},Lt=[],po=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,yt=Array.isArray;function Ce(e,t){for(var n in t)e[n]=t[n];return e}function Zn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ye(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?_t.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return ut(e,o,r,i,null)}function ut(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Si,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function mo(){return{current:null}}function G(e){return e.children}function Ie(e,t){this.props=e,this.context=t}function Ze(e,t){if(t==null)return e.__?Ze(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?Ze(e):null}function go(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ce({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),Jn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ze(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Ti(r,a,i),t.__e=t.__=null,a.__e!=n&&Ei(a)}}function Ei(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Ei(e)}function kn(e){(!e.__d&&(e.__d=!0)&&qe.push(e)&&!Mt.__r++||vr!=O.debounceRendering)&&((vr=O.debounceRendering)||ki)(Mt)}function Mt(){for(var e,t=1;qe.length;)qe.length>t&&qe.sort(Ci),e=qe.shift(),t=qe.length,go(e);Mt.__r=0}function Pi(e,t,n,r,i,a,o,s,u,l,h){var c,d,f,g,w,I,b,x=r&&r.__k||Lt,k=t.length;for(u=_o(n,t,x,u,k),c=0;c<k;c++)(f=n.__k[c])!=null&&(d=f.__i!=-1&&x[f.__i]||Rt,f.__i=c,I=Jn(e,f,d,i,a,o,s,u,l,h),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&Xn(d.ref,null,f),h.push(f.ref,f.__c||g,f)),w==null&&g!=null&&(w=g),(b=!!(4&f.__u))||d.__k===f.__k?u=$i(f,u,e,b):typeof f.type==\"function\"&&I!==void 0?u=I:g&&(u=g.nextSibling),f.__u&=-7);return n.__e=w,u}function _o(e,t,n,r,i){var a,o,s,u,l,h=n.length,c=h,d=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=ut(null,o,null,null,null):yt(o)?o=e.__k[a]=ut(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=ut(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+d,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=yo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>h?d--:i<h&&d++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<h;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=Ze(s)),Ni(s,s));return r}function $i(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=$i(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ze(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function De(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(yt(e)?e.some(function(n){De(n,t)}):t.push(e)),t}function yo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],h=l!=null&&(2&l.__u)==0;if(l===null&&s==null||h&&s==l.key&&u==l.type)return n;if(r>(h?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function xr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||po.test(t)?n:n+\"px\"}function St(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||xr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||xr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Ii,\"$1\")),o=t.toLowerCase(),t=o in e||t==\"onFocusOut\"||t==\"onFocusIn\"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=Yn,e.addEventListener(t,a?Sn:wn,a)):e.removeEventListener(t,a?Sn:wn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function wr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Yn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Jn(e,t,n,r,i,a,o,s,u,l){var h,c,d,f,g,w,I,b,x,k,N,E,v,z,F,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(h=O.__b)&&h(t);e:if(typeof M==\"function\")try{if(b=t.props,x=\"prototype\"in M&&M.prototype.render,k=(h=M.contextType)&&r[h.__c],N=h?k?k.props.value:h.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(x?t.__c=c=new M(b,N):(t.__c=c=new Ie(b,N),c.constructor=M,c.render=vo),k&&k.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),x&&c.__s==null&&(c.__s=c.state),x&&M.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ce({},c.__s)),Ce(c.__s,M.getDerivedStateFromProps(b,c.__s))),f=c.props,g=c.state,c.__v=t,d)x&&M.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),x&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(x&&M.getDerivedStateFromProps==null&&b!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,N),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,N)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),Lt.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,N),x&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,g,w)})}if(c.context=N,c.props=b,c.__P=e,c.__e=!1,E=O.__r,v=0,x)c.state=c.__s,c.__d=!1,E&&E(t),h=c.render(c.props,c.state,c.context),Lt.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),h=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++v<25);c.state=c.__s,c.getChildContext!=null&&(r=Ce(Ce({},r),c.getChildContext())),x&&!d&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(f,g)),z=h!=null&&h.type===G&&h.key==null?Di(h.props.children):h,s=Pi(e,yt(z)?z:[z],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||a!=null)if(y.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(F=a.length;F--;)Zn(a[F]);Cn(t)}else t.__e=n.__e,t.__k=n.__k,y.then||Cn(t);O.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=bo(n.__e,t,n,r,i,a,o,u,l);return(h=O.diffed)&&h(t),128&t.__u?void 0:s}function Cn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Cn))}function Ti(e,t,n){for(var r=0;r<n.length;r++)Xn(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function Di(e){return typeof e!=\"object\"||e==null||e.__b>0?e:yt(e)?e.map(Di):Ce({},e)}function bo(e,t,n,r,i,a,o,s,u){var l,h,c,d,f,g,w,I=n.props||Rt,b=t.props,x=t.type;if(x==\"svg\"?i=\"http://www.w3.org/2000/svg\":x==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((f=a[l])&&\"setAttribute\"in f==!!x&&(x?f.localName==x:f.nodeType==3)){e=f,a[l]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(x==null)I===b||s&&e.data==b||(e.data=b);else{if(a=a&&_t.call(e.childNodes),!s&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(f=e.attributes[l]).name]=f.value;for(l in I)f=I[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||St(e,l,null,f,i);for(l in b)f=b[l],l==\"children\"?d=f:l==\"dangerouslySetInnerHTML\"?h=f:l==\"value\"?g=f:l==\"checked\"?w=f:s&&typeof f!=\"function\"||I[l]===f||St(e,l,f,I[l],i);if(h)s||c&&(h.__html==c.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),Pi(t.type==\"template\"?e.content:e,yt(d)?d:[d],t,n,r,x==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&Ze(n,0),s,u),a!=null)for(l=a.length;l--;)Zn(a[l]);s||(l=\"value\",x==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[l]||x==\"progress\"&&!g||x==\"option\"&&g!=I[l])&&St(e,l,g,I[l],i),l=\"checked\",w!=null&&w!=e[l]&&St(e,l,w,I[l],i))}return e}function Xn(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){O.__e(i,n)}}function Ni(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Xn(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ni(r[i],t,n||typeof e.type!=\"function\");n||Zn(e.__e),e.__c=e.__=e.__e=void 0}function vo(e,t,n){return this.constructor(e,n)}function Je(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],Jn(t,e=(!r&&n||t).__k=ye(G,null,[e]),i||Rt,Rt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?_t.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Ti(a,e,o)}function Fi(e,t){Je(e,t,Fi)}function xo(e,t,n){var r,i,a,o,s=Ce({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?_t.call(arguments,2):n),ut(e.type,s,r||e.key,i||e.ref,null)}function er(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,kn(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+Ai++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}_t=Lt.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},Si=0,Ie.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ce({},this.state),typeof e==\"function\"&&(e=e(Ce({},n),this.props)),e&&Ce(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),kn(this))},Ie.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),kn(this))},Ie.prototype.render=G,qe=[],ki=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ci=function(e,t){return e.__v.__b-t.__v.__b},Mt.__r=0,Ii=/(PointerCapture)$|Capture$/i,Yn=0,wn=wr(!1),Sn=wr(!0),Ai=0;var wo=0;function _(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--wo,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var ze,W,hn,Sr,Xe=0,zi=[],Q=O,kr=Q.__b,Cr=Q.__r,Ir=Q.diffed,Ar=Q.__c,Er=Q.unmount,Pr=Q.__;function nt(e,t){Q.__h&&Q.__h(W,e,Xe||t),Xe=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function K(e){return Xe=1,tr(Mi,e)}function tr(e,t,n){var r=nt(ze++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Mi(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return d.__c});if(h.every(function(d){return!d.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return h.some(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var h=a;a=void 0,i(s,u,l),a=h}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Ee(e,t){var n=nt(ze++,3);!Q.__s&&nr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function ve(e,t){var n=nt(ze++,4);!Q.__s&&nr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function Ae(e){return Xe=5,Re(function(){return{current:e}},[])}function Oi(e,t,n){Xe=6,ve(function(){if(typeof e==\"function\"){var r=e(t());return function(){e(null),r&&typeof r==\"function\"&&r()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function Re(e,t){var n=nt(ze++,7);return nr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function We(e,t){return Xe=8,Re(function(){return e},t)}function xe(e){var t=W.context[e.__c],n=nt(ze++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Ri(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function Li(){var e=nt(ze++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function So(){for(var e;e=zi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some($t),t.__h.some(In),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,kr&&kr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Pr&&Pr(e,t)},Q.__r=function(e){Cr&&Cr(e),ze=0;var t=(W=e.__c).__H;t&&(hn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some($t),t.__h.some(In),t.__h=[],ze=0)),hn=W},Q.diffed=function(e){Ir&&Ir(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(zi.push(t)!==1&&Sr===Q.requestAnimationFrame||((Sr=Q.requestAnimationFrame)||ko)(So)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),hn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some($t),n.__h=n.__h.filter(function(r){return!r.__||In(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Ar&&Ar(e,t)},Q.unmount=function(e){Er&&Er(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{$t(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var $r=typeof requestAnimationFrame==\"function\";function ko(e){var t,n=function(){clearTimeout(r),$r&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);$r&&(t=requestAnimationFrame(n))}function $t(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function In(e){var t=W;e.__c=e.__(),W=t}function nr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Mi(e,t){return typeof t==\"function\"?t(e):t}const Tr=e=>{let t;const n=new Set,r=(l,h)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=h??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,d))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},Co=(e=>e?Tr(e):Tr);function Bi(e,t){for(var n in t)e[n]=t[n];return e}function An(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function Vi(e,t){var n=t(),r=K({t:{__:n,u:t}}),i=r[0].t,a=r[1];return ve(function(){i.__=n,i.u=t,dn(i)&&a({t:i})},[e,n,t]),Ee(function(){return dn(i)&&a({t:i}),e(function(){dn(i)&&a({t:i})})},[e]),n}function dn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function Hi(e){e()}function qi(e){return e}function Ui(){return[!1,Hi]}var ji=ve;function En(e,t){this.props=e,this.context=t}function Io(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:An(this.props,i)}function r(i){return this.shouldComponentUpdate=n,ye(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(En.prototype=new Ie).isPureReactComponent=!0,En.prototype.shouldComponentUpdate=function(e,t){return An(this.props,e)||An(this.state,t)};var Dr=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Dr&&Dr(e)};var Ao=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Eo(e){function t(n){var r=Bi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Ao,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Nr=function(e,t){return e==null?null:De(De(e).map(t))},Po={map:Nr,forEach:Nr,count:function(e){return e?De(e).length:0},only:function(e){var t=De(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:De},$o=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}$o(e,t,n,r)};var Fr=O.unmount;function Wi(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c==\"function\"&&r.__c()}),e.__c.__H=null),(e=Bi({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return Wi(r,t,n)})),e}function Qi(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Qi(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Tt(){this.__u=0,this.o=null,this.__b=null}function Gi(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function To(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?ye(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function lt(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Fr&&Fr(e)},(Tt.prototype=new Ie).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Gi(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Qi(l,l.__c.__P,l.__c.__O)}var h;for(r.setState({__a:r.__b=null});h=r.o.pop();)h.__P=s,h.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Tt.prototype.componentWillUnmount=function(){this.o=[]},Tt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=Wi(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&ye(G,null,e.fallback);return i&&(i.__u&=-33),[ye(G,null,t.__a?null:e.children),i]};var zr=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Do(e){return this.getChildContext=function(){return e.context},e.children}function No(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Je(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,a){this.childNodes.push(i),t.h.insertBefore(i,a)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}Je(ye(Do,{context:t.context},e.__v),t.v)}function Fo(e,t){var n=ye(No,{__v:e,h:t});return n.containerInfo=t,n}(lt.prototype=new Ie).__a=function(e){var t=this,n=Gi(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),zr(t,e,r)):i()};n?n(a):a()}},lt.prototype.render=function(e){this.i=null,this.l=new Map;var t=De(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},lt.prototype.componentDidUpdate=lt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){zr(e,n,t)})};var Ki=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,zo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Oo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ro=/[A-Z0-9]/g,Lo=typeof document<\"u\",Mo=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Bo(e,t,n){return t.__k==null&&(t.textContent=\"\"),Je(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Vo(e,t,n){return Fi(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ie.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ie.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Or=O.event;function Ho(){}function qo(){return this.cancelBubble}function Uo(){return this.defaultPrevented}O.event=function(e){return Or&&(e=Or(e)),e.persist=Ho,e.isPropagationStopped=qo,e.isDefaultPrevented=Uo,e.nativeEvent=e};var rr,jo={enumerable:!1,configurable:!0,get:function(){return this.class}},Rr=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||Lo&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Mo(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":Oo.test(o)&&(o=u):u=o=\"oninput\":a&&zo.test(o)?o=o.replace(Ro,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=De(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=De(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",jo)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ki,Rr&&Rr(e)};var Lr=O.__r;O.__r=function(e){Lr&&Lr(e),rr=e.__c};var Mr=O.diffed;O.diffed=function(e){Mr&&Mr(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),rr=null};var Wo={ReactCurrentDispatcher:{current:{readContext:function(e){return rr.__n[e.__c].props.value},useCallback:We,useContext:xe,useDebugValue:Ri,useDeferredValue:qi,useEffect:Ee,useId:Li,useImperativeHandle:Oi,useInsertionEffect:ji,useLayoutEffect:ve,useMemo:Re,useReducer:tr,useRef:Ae,useState:K,useSyncExternalStore:Vi,useTransition:Ui}}};function Qo(e){return ye.bind(null,e)}function Zt(e){return!!e&&e.$$typeof===Ki}function Go(e){return Zt(e)&&e.type===G}function Ko(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Yo(e){return Zt(e)?xo.apply(null,arguments):e}function Zo(e){return!!e.__k&&(Je(null,e),!0)}function Jo(e){return e&&(e.base||e.nodeType===1&&e)||null}var Xo=function(e,t){return e(t)},es=function(e,t){return e(t)},ts=G,ns=Zt,kt={useState:K,useId:Li,useReducer:tr,useEffect:Ee,useLayoutEffect:ve,useInsertionEffect:ji,useTransition:Ui,useDeferredValue:qi,useSyncExternalStore:Vi,startTransition:Hi,useRef:Ae,useImperativeHandle:Oi,useMemo:Re,useCallback:We,useContext:xe,useDebugValue:Ri,version:\"18.3.1\",Children:Po,render:Bo,hydrate:Vo,unmountComponentAtNode:Zo,createPortal:Fo,createElement:ye,createContext:er,createFactory:Qo,cloneElement:Yo,createRef:mo,Fragment:G,isValidElement:Zt,isElement:ns,isFragment:Go,isMemo:Ko,findDOMNode:Jo,Component:Ie,PureComponent:En,memo:Io,forwardRef:Eo,flushSync:es,unstable_batchedUpdates:Xo,StrictMode:ts,Suspense:Tt,SuspenseList:lt,lazy:To,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Wo};const rs=e=>e;function is(e,t=rs){const n=kt.useSyncExternalStore(e.subscribe,kt.useCallback(()=>t(e.getState()),[e,t]),kt.useCallback(()=>t(e.getInitialState()),[e,t]));return kt.useDebugValue(n),n}const as=e=>{const t=Co(e),n=r=>is(t,r);return Object.assign(n,t),n},os=(e=>as);var Yi=Symbol.for(\"immer-nothing\"),Br=Symbol.for(\"immer-draftable\"),ie=Symbol.for(\"immer-state\");function _e(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ce=Object,et=ce.getPrototypeOf,Bt=\"constructor\",Jt=\"prototype\",Pn=\"configurable\",Vt=\"enumerable\",Dt=\"writable\",ft=\"value\",Oe=e=>!!e&&!!e[ie];function Ne(e){return e?Zi(e)||en(e)||!!e[Br]||!!e[Bt]?.[Br]||tn(e)||nn(e):!1}var ss=ce[Jt][Bt].toString(),Vr=new WeakMap;function Zi(e){if(!e||!ir(e))return!1;const t=et(e);if(t===null||t===ce[Jt])return!0;const n=ce.hasOwnProperty.call(t,Bt)&&t[Bt];if(n===Object)return!0;if(!Ke(n))return!1;let r=Vr.get(n);return r===void 0&&(r=Function.toString.call(n),Vr.set(n,r)),r===ss}function Xt(e,t,n=!0){bt(e)===0?(n?Reflect.ownKeys(e):ce.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function bt(e){const t=e[ie];return t?t.type_:en(e)?1:tn(e)?2:nn(e)?3:0}var Hr=(e,t,n=bt(e))=>n===2?e.has(t):ce[Jt].hasOwnProperty.call(e,t),$n=(e,t,n=bt(e))=>n===2?e.get(t):e[t],Ht=(e,t,n,r=bt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function ls(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var en=Array.isArray,tn=e=>e instanceof Map,nn=e=>e instanceof Set,ir=e=>typeof e==\"object\",Ke=e=>typeof e==\"function\",pn=e=>typeof e==\"boolean\";function us(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Te=e=>e.copy_||e.base_,ar=e=>e.modified_?e.copy_:e.base_;function Tn(e,t){if(tn(e))return new Map(e);if(nn(e))return new Set(e);if(en(e))return Array[Jt].slice.call(e);const n=Zi(e);if(t===!0||t===\"class_only\"&&!n){const r=ce.getOwnPropertyDescriptors(e);delete r[ie];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[Dt]===!1&&(s[Dt]=!0,s[Pn]=!0),(s.get||s.set)&&(r[o]={[Pn]:!0,[Dt]:!0,[Vt]:s[Vt],[ft]:e[o]})}return ce.create(et(e),r)}else{const r=et(e);if(r!==null&&n)return{...e};const i=ce.create(r);return ce.assign(i,e)}}function or(e,t=!1){return rn(e)||Oe(e)||!Ne(e)||(bt(e)>1&&ce.defineProperties(e,{set:Ct,add:Ct,clear:Ct,delete:Ct}),ce.freeze(e),t&&Xt(e,(n,r)=>{or(r,!0)},!1)),e}function cs(){_e(2)}var Ct={[ft]:cs};function rn(e){return e===null||!ir(e)?!0:ce.isFrozen(e)}var qt=\"MapSet\",Dn=\"Patches\",qr=\"ArrayMethods\",Ji={};function Ue(e){const t=Ji[e];return t||_e(0,e),t}var Ur=e=>!!Ji[e],ht,Xi=()=>ht,fs=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Ur(qt)?Ue(qt):void 0,arrayMethodsPlugin_:Ur(qr)?Ue(qr):void 0});function jr(e,t){t&&(e.patchPlugin_=Ue(Dn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Nn(e){Fn(e),e.drafts_.forEach(hs),e.drafts_=null}function Fn(e){e===ht&&(ht=e.parent_)}var Wr=e=>ht=fs(ht,e);function hs(e){const t=e[ie];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Qr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ie].modified_&&(Nn(t),_e(4)),Ne(e)&&(e=Gr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ie].base_,e,t)}else e=Gr(t,n);return ds(t,e,!0),Nn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Yi?e:void 0}function Gr(e,t){if(rn(t))return t;const n=t[ie];if(!n)return Ut(t,e.handledSet_,e);if(!an(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);na(n,e)}return n.copy_}function ds(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&or(t,n)}function ea(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var an=(e,t)=>e.scope_===t,ps=[];function ta(e,t,n,r){const i=Te(e),a=e.type_;if(r!==void 0&&$n(i,r,a)===t){Ht(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Xt(i,(u,l)=>{if(Oe(l)){const h=s.get(l)||[];h.push(u),s.set(l,h)}})}const o=e.draftLocations_.get(t)??ps;for(const s of o)Ht(i,s,n,a)}function ms(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!an(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=ar(a);ta(e,a.draft_??a,o,n),na(a,i)})}function na(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}ea(e)}}function gs(e,t,n){const{scope_:r}=e;if(Oe(n)){const i=n[ie];an(i,r)&&i.callbacks_.push(function(){Nt(e);const o=ar(i);ta(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Te(e);e.type_===3?a.has(n)&&Ut(n,r.handledSet_,r):$n(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Ut($n(e.copy_,t,e.type_),r.handledSet_,r)})}function Ut(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Oe(e)||t.has(e)||!Ne(e)||rn(e)||(t.add(e),Xt(e,(r,i)=>{if(Oe(i)){const a=i[ie];if(an(a,n)){const o=ar(a);Ht(e,r,o,e.type_),ea(a)}}else Ne(i)&&Ut(i,t,n)})),e}function _s(e,t){const n=en(e),r={type_:n?1:0,scope_:t?t.scope_:Xi(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=jt;n&&(i=[r],a=dt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var jt={get(e,t){if(t===ie)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Te(e);if(!Hr(i,t,e.type_))return ys(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&us(t))return a;if(a===mn(e.base_,t)){Nt(e);const o=e.type_===1?+t:t,s=On(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Te(e)},ownKeys(e){return Reflect.ownKeys(Te(e))},set(e,t,n){const r=ra(Te(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=mn(Te(e),t),a=i?.[ie];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(ls(n,i)&&(n!==void 0||Hr(e.base_,t,e.type_)))return!0;Nt(e),zn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),gs(e,t,n)),!0},deleteProperty(e,t){return Nt(e),mn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),zn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Te(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Dt]:!0,[Pn]:e.type_!==1||t!==\"length\",[Vt]:r[Vt],[ft]:n[t]}},defineProperty(){_e(11)},getPrototypeOf(e){return et(e.base_)},setPrototypeOf(){_e(12)}},dt={};for(let e in jt){let t=jt[e];dt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}dt.deleteProperty=function(e,t){return dt.set.call(this,e,t,void 0)};dt.set=function(e,t,n){return jt.set.call(this,e[0],t,n,e[0])};function mn(e,t){const n=e[ie];return(n?Te(n):e)[t]}function ys(e,t,n){const r=ra(t,n);return r?ft in r?r[ft]:r.get?.call(e.draft_):void 0}function ra(e,t){if(!(t in e))return;let n=et(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=et(n)}}function zn(e){e.modified_||(e.modified_=!0,e.parent_&&zn(e.parent_))}function Nt(e){e.copy_||(e.assigned_=new Map,e.copy_=Tn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var bs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ke(t)&&!Ke(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,h=>n.call(this,h,...l))}}Ke(n)||_e(6),r!==void 0&&!Ke(r)&&_e(7);let i;if(Ne(t)){const a=Wr(this),o=On(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Nn(a):Fn(a)}return jr(a,r),Qr(i,a)}else if(!t||!ir(t)){if(i=n(t),i===void 0&&(i=t),i===Yi&&(i=void 0),this.autoFreeze_&&or(i,!0),r){const a=[],o=[];Ue(Dn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else _e(1,t)},this.produceWithPatches=(t,n)=>{if(Ke(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},pn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),pn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),pn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||_e(8),Oe(e)&&(e=vs(e));const t=Wr(this),n=On(t,e,void 0);return n[ie].isManual_=!0,Fn(t),n}finishDraft(e,t){const n=e&&e[ie];(!n||!n.isManual_)&&_e(9);const{scope_:r}=n;return jr(r,t),Qr(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Ue(Dn).applyPatches_;return Oe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function On(e,t,n,r){const[i,a]=tn(t)?Ue(qt).proxyMap_(t,n):nn(t)?Ue(qt).proxySet_(t,n):_s(t,n);return(n?.scope_??Xi()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?ms(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function vs(e){return Oe(e)||_e(10,e),ia(e)}function ia(e){if(!Ne(e)||rn(e))return e;const t=e[ie];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Tn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Tn(e,!0);return Xt(n,(i,a)=>{Ht(n,i,ia(a))},r),t&&(t.finalized_=!1),n}var xs=new bs,ws=xs.produce;const Ss=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?ws(i):i;return t(s,a,...o)},e(r.setState,n,r)),ks=Ss,Cs=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),Is=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function As(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function Kr(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function Yr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function Es(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function vt(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const g=Yr(e,n);o=g.className||void 0,s=g.id||void 0,n=g.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const h=e.slice(l,n);n+=2;const{display:c,target:d}=As(h),f={type:\"link\",display:c,target:d,start:a,end:n};o&&(f.className=o),s&&(f.id=s),t.push(f),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=Yr(e,n+1);s=l.className||void 0,u=l.id||void 0;let h=l.endIdx;e[h]===\" \"&&h++;const c=e[h];if(c===\"$\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"variable\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"temporary\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"local\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=h;let d=1;const f=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const g=e.slice(f,n);n++;const{name:w,rawArgs:I,isClose:b}=Kr(g),x={type:\"macro\",name:w,rawArgs:I,isClose:b,start:a,end:n};s&&(x.className=s),u&&(x.id=u),t.push(x),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const h=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(h,n);n++;const{name:d,rawArgs:f,isClose:g}=Kr(c);t.push({type:\"macro\",name:d,rawArgs:f,isClose:g,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&Cs.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const h=Es(e,o);o=h.endIdx;let c=Is.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:h.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Ps=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),Zr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},$s=new Set([\"if\",\"switch\",\"timed\"]);function xt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const a={type:\"link\",display:i.display,target:i.target};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const o=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${o} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(Zr[i.name]){const a=Zr[i.name],o=n.length>0?n[n.length-1].node:null;if(!o||o.type!==\"macro\"||o.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches.push(s);break}if(Ps.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if($s.has(i.name)){const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),a.branches=[o]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function aa(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function oa(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let rt=!1,wt=\"\",je=0,tt=null;function Ts(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,wt=n,je=0,tt=aa(oa(n)),rt=!0}function Rn(e,t){wt=e,je=0,tt=aa(oa(e)),rt=!0;for(let n=0;n<t;n++)tt();je=t}function Ft(){rt=!1,wt=\"\",je=0,tt=null}function zt(){return rt?{seed:wt,pull:je}:null}function sr(){return!rt||!tt?Math.random():(je++,tt())}function sa(e,t){return e>t&&([e,t]=[t,e]),Math.floor(sr()*(t-e+1))+e}function Ds(){return rt}function Ns(){return wt}function Fs(){return je}const zs=500,He=new Map,Os=/\\$(\\w+)/g,Rs=/\\b_(\\w+)/g,Ls=/@(\\w+)/g;function Ms(e){return e.replace(Os,'variables[\"$1\"]').replace(Rs,'temporary[\"$1\"]').replace(Ls,'locals[\"$1\"]')}function lr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Ms(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=lr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Bs=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function la(e,t){const n=He.get(e);if(n)return He.delete(e),He.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Bs+t);if(He.set(e,r),He.size>zs){const i=He.keys().next().value;i!==void 0&&He.delete(i)}return r}let It=null,Jr=null,Xr=null;function ua(){const e=S.getState(),{visitCounts:t,renderCounts:n}=e;if(It&&Jr===t&&Xr===n)return It;const r=f=>t[f]??0,i=f=>r(f)>0,a=(...f)=>f.some(g=>r(g)>0),o=(...f)=>f.every(g=>r(g)>0),s=f=>n[f]??0;return It={currentPassage:()=>{const f=S.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=S.getState();if(f.historyIndex<=0)return;const g=f.history[f.historyIndex-1]?.passage;return g?f.storyData?.passages.get(g):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:f=>s(f)>0,hasRenderedAny:(...f)=>f.some(g=>s(g)>0),hasRenderedAll:(...f)=>f.every(g=>s(g)>0),random:sr,randomInt:sa},Jr=t,Xr=n,It}function be(e,t,n,r={}){const a=`return (${lr(e)});`;return la(a,a)(t,n,r,ua())}function Ln(e,t,n,r={}){const i=lr(e);la(\"exec:\"+i,i)(t,n,r,ua())}const Vs=\"spindle\",Hs=1;let At=null,gn=null;function Le(){return gn||(gn={saves:new Map,playthroughs:new Map,meta:new Map}),gn}function qs(){return At||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(At=new Promise((e,t)=>{const n=indexedDB.open(Vs,Hs);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),At))}function Me(e,t){return qs().then(n=>n.transaction(e,t).objectStore(e))}function Be(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function on(e){try{const t=await Me(\"saves\",\"readwrite\");await Be(t.put(e))}catch{Le().saves.set(e.meta.id,e)}}async function sn(e){try{const t=await Me(\"saves\",\"readonly\");return await Be(t.get(e))??void 0}catch{return Le().saves.get(e)}}async function Us(e){try{const t=await Me(\"saves\",\"readwrite\");await Be(t.delete(e))}catch{Le().saves.delete(e)}}async function js(e){try{const n=(await Me(\"saves\",\"readonly\")).index(\"ifid\");return await Be(n.getAll(e))??[]}catch{return[...Le().saves.values()].filter(t=>t.meta.ifid===e)}}async function ca(e){try{const t=await Me(\"playthroughs\",\"readwrite\");await Be(t.put(e))}catch{Le().playthroughs.set(e.id,e)}}async function ur(e){try{const n=(await Me(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Be(n.getAll(e))??[]}catch{return[...Le().playthroughs.values()].filter(t=>t.ifid===e)}}async function cr(e){try{const t=await Me(\"meta\",\"readonly\"),n=await Be(t.get(e));return n?n.value:void 0}catch{return Le().meta.get(e)}}async function fa(e,t){try{const n=await Me(\"meta\",\"readwrite\");await Be(n.put({key:e,value:t}))}catch{Le().meta.set(e,t)}}const ha=new Map,ln=new Map;function Ws(e,t){ha.set(e,t),ln.set(t,e)}function Qs(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function J(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(ln.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(Qs(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Mn=\"__spindle_class__\",Bn=\"__spindle_data__\";function Wt(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=ln.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Mn]:o,[Bn]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Qt(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(o=>t(o));const r=n;if(Mn in r&&Bn in r){const o=r[Mn],s=r[Bn],u=ha.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const h={};for(const c of Object.keys(s))h[c]=t(s[c]);return h}const l=Object.create(u.prototype);for(const h of Object.keys(s))l[h]=t(s[h]);return l}const i=r.constructor;if(ln.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Vn=null,Hn=null,ei=!1;function Gs(e){Vn=e}function Ks(e){Hn=e}function Ys(e){if(Hn)try{const i=new Function(\"passage\",\"variables\",Hn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Vn)try{const r=Vn(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function Zs(){ei||(ei=!0)}async function ti(e){const n=(await ur(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await ca(i),await fa(`currentPlaythroughId.${e}`,r),r}async function Js(e){return cr(`currentPlaythroughId.${e}`)}async function da(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Ys(n),passage:n.passage,custom:r},o=J(n);o.variables=Wt(o.variables),o.history=o.history.map(u=>({...u,variables:Wt(u.variables)}));const s={meta:a,payload:o};return await on(s),s}async function pa(e,t){const n=await sn(e);if(!n)return;const r=J(t);r.variables=Wt(r.variables),r.history=r.history.map(a=>({...a,variables:Wt(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await on(i),i}async function Xs(e){const t=await sn(e);if(!t)return;const n=t.payload;return n.variables=Qt(n.variables),n.history=n.history.map(r=>({...r,variables:Qt(r.variables)})),n}async function el(e){await Us(e)}async function tl(e,t){const n=await sn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await on(r)}async function nl(e){const[t,n]=await Promise.all([js(e),ur(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const ma=\"autosave.\";async function rl(e,t,n){const r=`${ma}${e}`,i=await cr(r);if(i){const o=await pa(i,n);if(o)return o}const a=await da(e,t,n,{isAutosave:!0});return await fa(r,a.meta.id),a}async function il(e){const t=`${ma}${e}`,n=await cr(t);if(n)return Xs(n)}async function al(e){const t=await sn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function ol(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=J(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await ur(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await ca(a)}return await on(n),n}function sl(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Ln(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Ln(i,t,n)}}}function ga(){const e=S.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=vt(t.content),r=xt(n),i=J(e.variables),a=J(e.temporary);sl(r,i,a);for(const s of Object.keys(i))i[s]!==e.variables[s]&&e.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==e.temporary[s]&&e.setTemporary(s,a[s]);const o=e.storyData.passages.get(\"SaveTitle\");o&&Ks(o.content)}function ni(e){e?.prng?Rn(e.prng.seed,e.prng.pull):e&&Ft()}const S=os()(ks((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",saveError:null,loadError:null,init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=J(r);e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,variables:J(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}});const o=n.ifid;Zs().then(async()=>{const s=await Js(o);if(s)e(u=>{u.playthroughId=s});else{const u=await ti(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:J(i.variables),timestamp:Date.now(),prng:zt()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=J(r.variables),n.temporary={}}),ni(t().history[t().historyIndex])},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=J(r.variables),n.temporary={}}),ni(t().history[t().historyIndex])},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;Ft();const a=J(r);e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,variables:J(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),ga(),ti(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:a,history:o,historyIndex:s,visitCounts:u,renderCounts:l}=t();if(!n)return;const h={passage:i,variables:J(a),history:J(o),historyIndex:s,visitCounts:{...u},renderCounts:{...l},prng:zt()};e(c=>{c.saveError=null}),rl(n.ifid,r,h).then(()=>{e(c=>{c.saveVersion++})}).catch(c=>{console.error(\"spindle: failed to quick save\",c),e(d=>{d.saveError=c instanceof Error?c.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),il(n.ifid).then(r=>{r&&(e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}}),r.prng?Rn(r.prng.seed,r.prng.pull):Ft())}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t();return{passage:n,variables:J(r),history:J(i),historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:zt()}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Qt(n.variables),r.history=n.history.map(i=>({...i,variables:Qt(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}}),n.prng?Rn(n.prng.seed,n.prng.pull):Ft()}}))),Gt=new Map,qn=new Set,Un=new Map;function ll(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Un.get(r)??0)+1;return Un.set(r,i),i===1?r:`${r}:${i}`}function ul(e){return Gt.set(e.id,e),ii(),()=>{Gt.delete(e.id),ii()}}function ri(){return Array.from(Gt.values())}function cl(e){return Gt.get(e)}function fl(){Un.clear()}function hl(e){return qn.add(e),()=>{qn.delete(e)}}function ii(){for(const e of qn)e()}function ae(e){const t=Ae(\"\");t.current||(t.current=ll(e.type,e.key,e.authorId));const n=t.current;return ve(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),ul(r)}),n}function se(){const e=S(r=>r.variables),t=S(r=>r.temporary),n=xe(Pe);return Re(()=>{const r={};for(const[i,a]of Object.entries(n.values))i.startsWith(\"@\")&&(r[i.slice(1)]=a);return[e,t,r]},[e,t,n.values])}const dl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,pl=/\\{[\\$_@][\\w.]+\\}/;function _a(e){return pl.test(e)}function ml(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function ya(e,t,n,r){return e.replace(dl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let h;return o===\"$\"?h=t[l]:o===\"_\"?h=n[l]:h=r[l],u.length>1&&(h=ml(h,u)),h==null?\"\":String(h)})}function pe(){const[e,t,n]=se();return We(r=>r===void 0||!_a(r)?r:ya(r,e,t,n),[e,t,n])}function gl({target:e,className:t,id:n,children:r}){const i=S(u=>u.navigate),a=pe();t=a(t),n=a(n);const o=u=>{u.preventDefault(),i(e)};ae({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return _(\"a\",{href:\"#\",id:n,class:s,onClick:o,children:r})}function _l({name:e,scope:t,className:n,id:r}){const i=pe();n=i(n),r=i(r);const a=xe(Pe),o=e.split(\".\"),s=o[0],u=S(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;if(t===\"local\"){const c=`@${s}`;l=c in a.values?a.values[c]:void 0}else l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=o[c];l=l[d]}const h=l==null?\"\":String(l);return n||r?_(\"span\",{id:r,class:n,children:h}):_(G,{children:h})}function pt(e,t,n){const r=S.getState(),i=J(r.variables),a=J(r.temporary),o={...t};Ln(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(`@${s}`,o[s])}function ba(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function re(){const e=S.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?ba(t):\"\"}function yl({rawArgs:e}){const t=xe(Pe),[,,n]=se(),r=Ae(!1);if(!r.current){r.current=!0;try{pt(e,n,t.update)}catch(i){return console.error(`spindle: Error in {set ${e}}${re()}:`,i),null}}return null}function bl({rawArgs:e,className:t,id:n}){const r=pe();t=r(t),n=r(n);const[i,a,o]=se();try{const s=be(e,i,a,o),u=s==null?\"\":String(s);return t||n?_(\"span\",{id:n,class:t,children:u}):_(G,{children:u})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{print error${re()}: ${s instanceof Error?s.message:String(s)}}`})}}function vl({branches:e}){const t=pe(),[n,r,i]=se();function a(o){const s=de(o.children),u=t(o.className),l=t(o.id);return u||l?_(\"span\",{id:l,class:u,children:s}):_(G,{children:s})}for(const o of e){if(o.rawArgs===\"\")return a(o);try{if(be(o.rawArgs,n,r,i))return a(o)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{if error${re()}: ${s instanceof Error?s.message:String(s)}}`})}}return null}function xl(e){const t=e.indexOf(\" of \");if(t===-1)throw new Error(`{for} requires \"of\" keyword: {for ${e}}`);const n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(\",\").map(s=>s.trim()),a=i[0],o=i.length>1?i[1]:null;if(!a.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(o&&!o.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${o}\"`);return{itemVar:a,indexVar:o,listExpr:r}}function wl({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=K(()=>({...e,...t,...n})),o=We((u,l)=>{a(h=>({...h,[u]:l}))},[]),s={values:i,update:o};return _(Pe.Provider,{value:s,children:de(r)})}function Sl({rawArgs:e,children:t,className:n,id:r}){const i=pe();n=i(n),r=i(r);const a=xe(Pe),[o,s,u]=se();let l;try{l=xl(e)}catch(w){return _(\"span\",{class:\"error\",title:String(w),children:`{for error${re()}: ${w instanceof Error?w.message:String(w)}}`})}const{itemVar:h,indexVar:c,listExpr:d}=l;let f;try{const w=be(d,o,s,u);if(!Array.isArray(w))return _(\"span\",{class:\"error\",children:`{for error${re()}: expression did not evaluate to an array}`});f=w}catch(w){return _(\"span\",{class:\"error\",title:String(w),children:`{for error${re()}: ${w instanceof Error?w.message:String(w)}}`})}const g=f.map((w,I)=>{const b={[h]:w,...c?{[c]:I}:void 0};return _(wl,{parentValues:a.values,ownKeys:b,initialValues:{},children:t},I)});return n||r?_(\"span\",{id:r,class:n,children:g}):_(G,{children:g})}function kl(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Cl({children:e}){const t=kl(e),n=xe(Pe),[,,r]=se();return ve(()=>{try{pt(t,r,n.update)}catch(i){console.error(`spindle: Error in {do}${re()}:`,i)}},[]),null}function va(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Il({rawArgs:e,children:t,className:n,id:r}){const i=pe();n=i(n),r=i(r);const a=xe(Pe),[,,o]=se(),s=()=>{try{pt(e,o,a.update)}catch(l){console.error(`spindle: Error in {button ${e}}${re()}:`,l)}};ae({type:\"button\",key:e,authorId:r,label:va(t)||e,perform:s});const u=n?`macro-button ${n}`:\"macro-button\";return _(\"button\",{id:r,class:u,onClick:s,children:La(t)})}function Al({className:e,id:t}){const n=S(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return _(\"span\",{id:t,class:r,children:n})}function El({className:e,id:t}){const n=S(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return ae({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),_(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}function Pl({className:e,id:t}){const n=S(a=>a.goBack),r=S(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function $l({className:e,id:t}){const n=S(a=>a.goForward),r=S(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function Tl({className:e,id:t}){const n=S(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),_(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function Dl({className:e,id:t}){const n=S(s=>s.load),r=S(s=>s.hasSave);S(s=>s.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r(),o=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return ae({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:a,perform:()=>n()}),_(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:o,children:\"QuickLoad\"})}const ot=new Map;let ne={},ai=!1;function xa(){return`spindle.${S.getState().storyData?.ifid||\"unknown\"}.settings`}function Nl(){localStorage.setItem(xa(),JSON.stringify(ne))}function _n(){if(!ai){ai=!0;try{const e=localStorage.getItem(xa());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ne={...ne,...t})}}catch{}}}const mt={addToggle(e,t){ot.set(e,{type:\"toggle\",config:t}),e in ne||(ne[e]=t.default),_n()},addList(e,t){ot.set(e,{type:\"list\",config:t}),e in ne||(ne[e]=t.default),_n()},addRange(e,t){ot.set(e,{type:\"range\",config:t}),e in ne||(ne[e]=t.default),_n()},get(e){return ne[e]},getToggle(e){const t=ne[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ne[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ne[e];return typeof t==\"number\"?t:0},set(e,t){ne[e]=t,Nl()},getAll(){return{...ne}},getDefinitions(){return ot},hasAny(){return ot.size>0}};function Fl({name:e,def:t}){const[n,r]=K(()=>mt.get(e)),i=a=>{r(a),mt.set(e,a)};switch(t.type){case\"toggle\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>_(\"option\",{value:a,children:a},a))})]});case\"range\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:[t.config.label,\": \",String(n)]}),_(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function zl({onClose:e}){const t=mt.getDefinitions();return _(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:_(\"div\",{class:\"settings-panel\",children:[_(\"div\",{class:\"settings-header\",children:[_(\"span\",{children:\"Settings\"}),_(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>_(Fl,{name:r,def:i},r))})]})})}function Ol({className:e,id:t}){const[n,r]=K(!1);if(!mt.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return _(G,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&_(zl,{onClose:()=>r(!1)})]})}function Rl(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Ll(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function Ml(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Bl({onClose:e}){const[t,n]=K(\"load\"),[r,i]=K([]),[a,o]=K(!0),[s,u]=K(null),[l,h]=K(()=>new Set),[c,d]=K(null),[f,g]=K(\"\"),w=Ae(null),I=Ae(null),b=S(A=>A.storyData),x=S(A=>A.playthroughId),k=S(A=>A.getSavePayload),N=S(A=>A.loadFromPayload),E=b?.ifid??\"\",v=We(async()=>{if(!E)return;const A=await nl(E);i(A),o(!1)},[E]);Ee(()=>{v()},[v]),Ee(()=>{c&&w.current&&(w.current.focus(),w.current.select())},[c]);const z=Ae(),F=(A,p=\"success\")=>{clearTimeout(z.current),u({text:A,type:p}),z.current=window.setTimeout(()=>u(null),3e3)},M=A=>{h(p=>{const q=new Set(p);return q.has(A)?q.delete(A):q.add(A),q})},y=async()=>{if(!(!E||!x))try{const A=k();await da(E,x,A),F(\"Save created\"),await v()}catch{F(\"Failed to create save\",\"error\")}},P=async A=>{try{const p=k();await pa(A,p),F(\"Save overwritten\"),await v()}catch{F(\"Failed to overwrite save\",\"error\")}},$=async A=>{try{N(A.payload),F(\"Game loaded\"),setTimeout(e,500)}catch{F(\"Failed to load save\",\"error\")}},V=async A=>{if(confirm(\"Delete this save?\"))try{await el(A),F(\"Save deleted\"),await v()}catch{F(\"Failed to delete save\",\"error\")}},H=A=>{d(A.meta.id),g(A.meta.title)},R=async()=>{if(!(!c||!f.trim()))try{await tl(c,f.trim()),d(null),F(\"Save renamed\"),await v()}catch{F(\"Failed to rename\",\"error\")}},Z=A=>{A.key===\"Enter\"?R():A.key===\"Escape\"&&d(null)},Y=async A=>{try{const p=await al(A);if(!p)return;const q=new Blob([JSON.stringify(p,null,2)],{type:\"application/json\"}),j=URL.createObjectURL(q),U=document.createElement(\"a\");U.href=j,U.download=`save-${p.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,U.click(),URL.revokeObjectURL(j),F(\"Save exported\")}catch{F(\"Failed to export save\",\"error\")}},le=()=>{I.current?.click()},me=async A=>{const p=A.target,q=p.files?.[0];if(q){p.value=\"\";try{const j=await q.text(),U=JSON.parse(j);if(!Rl(U))throw new Error(\"Invalid save file format\");await ol(U,E),F(\"Save imported\"),await v()}catch(j){F(j instanceof Error?j.message:\"Failed to import save\",\"error\")}}},m=A=>{A.target.classList.contains(\"saves-overlay\")&&e()},ue=r.reduce((A,p)=>A+p.saves.length,0);return _(\"div\",{class:\"saves-overlay\",onClick:m,children:_(\"div\",{class:\"saves-panel\",children:[_(\"div\",{class:\"saves-header\",children:[_(\"div\",{class:\"saves-header-left\",children:_(\"div\",{class:\"saves-mode-toggle\",children:[_(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),_(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),_(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"saves-toolbar\",children:[_(\"button\",{class:\"saves-toolbar-button\",onClick:le,children:\"Import\"}),_(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:me})]}),_(\"div\",{class:\"saves-body\",children:[a?_(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):ue===0&&t===\"load\"?_(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(A=>{const p=l.has(A.playthrough.id),q=A.playthrough.id===x;return t===\"save\"&&!q||t===\"load\"&&A.saves.length===0&&!q?null:_(\"div\",{class:\"playthrough-group\",children:[_(\"div\",{class:\"playthrough-header\",onClick:()=>M(A.playthrough.id),children:[_(\"span\",{class:`playthrough-chevron ${p?\"\":\"open\"}`,children:\"▶\"}),_(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,q?\" (current)\":\"\"]}),_(\"span\",{class:\"playthrough-date\",children:Ml(A.playthrough.createdAt)})]}),!p&&_(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(j=>_(\"div\",{class:\"save-slot\",children:[_(\"div\",{class:\"save-slot-info\",children:[c===j.meta.id?_(\"input\",{ref:w,class:\"save-rename-input\",value:f,onInput:U=>g(U.target.value),onKeyDown:Z,onBlur:R}):_(\"div\",{class:\"save-slot-title\",children:j.meta.title}),_(\"div\",{class:\"save-slot-meta\",children:[_(\"span\",{children:j.meta.passage}),_(\"span\",{children:Ll(j.meta.updatedAt)})]})]}),_(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?_(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(j.meta.id),children:\"Save Here\"}):_(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(j),children:\"Load\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>H(j),children:\"Rename\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>Y(j.meta.id),children:\"Export\"}),_(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(j.meta.id),children:\"Delete\"})]})]},j.meta.id)),t===\"save\"&&q&&_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})]})]},A.playthrough.id)}),t===\"save\"&&!a&&!r.some(A=>A.playthrough.id===x)&&_(\"div\",{class:\"playthrough-group\",children:_(\"div\",{class:\"playthrough-saves\",children:_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})})})]}),s&&_(\"div\",{class:`saves-status ${s.type===\"error\"?\"error\":\"\"}`,children:s.text})]})})}function Vl({className:e,id:t}){const[n,r]=K(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return _(G,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&_(Bl,{onClose:()=>r(!1)})]})}function Hl({rawArgs:e,className:t,id:n}){const r=pe();t=r(t),n=r(n);const i=S(f=>f.storyData),[a,o,s]=se();if(!i)return null;let u;try{const f=be(e,a,o,s);u=String(f)}catch{u=e.replace(/^[\"']|[\"']$/g,\"\")}const l=i.passages.get(u);if(l&&S.getState().trackRender(u),!l)return _(\"span\",{class:\"error\",children:`{include${re()}: passage \"${u}\" not found}`});const h=vt(l.content),c=xt(h),d=de(c);return t||n?_(\"span\",{id:n,class:t,children:d}):_(G,{children:d})}function ql({rawArgs:e}){const[t,n,r]=se();return ve(()=>{let i;try{const a=be(e,t,n,r);i=String(a)}catch{i=e.replace(/^[\"']|[\"']$/g,\"\")}S.getState().navigate(i)},[]),null}function Ul({rawArgs:e}){const t=Ae(!1);if(!t.current){t.current=!0;const n=S.getState(),r=e.trim();r.startsWith(\"$\")?n.deleteVariable(r.slice(1)):r.startsWith(\"_\")?n.deleteTemporary(r.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${r}\"`)}return null}function jl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Wl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=jl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"textbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:o,perform:l=>s(a,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return _(\"input\",{type:\"text\",id:n,class:u,value:o==null?\"\":String(o),placeholder:i,onInput:l=>s(a,l.target.value)})}function Ql(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Gl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Ql(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"numberbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:o,perform:l=>s(a,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return _(\"input\",{type:\"number\",id:n,class:u,value:o==null?\"\":String(o),placeholder:i,onInput:l=>{const h=l.target.value;s(a,h===\"\"?0:Number(h))}})}function Kl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Yl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Kl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"textarea\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:o,perform:l=>s(a,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return _(\"textarea\",{id:n,class:u,value:o==null?\"\":String(o),placeholder:i,onInput:l=>s(a,l.target.value)})}function Zl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}function Jl({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=Zl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"checkbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:!!o,perform:l=>s(a,l!==void 0?!!l:!o)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return _(\"label\",{id:n,class:u,children:[_(\"input\",{type:\"checkbox\",checked:!!o,onChange:()=>s(a,!o)}),i?` ${i}`:null]})}function Xl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}function eu({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=Xl(e),o=r.startsWith(\"$\")?r.slice(1):r,s=S(h=>h.variables[o]),u=S(h=>h.setVariable);ae({type:\"radiobutton\",key:`$${o}:${i}`,authorId:n,label:a||i,variable:o,value:s,perform:()=>u(o,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return _(\"label\",{id:n,class:l,children:[_(\"input\",{type:\"radio\",name:`radio-${o}`,checked:s===i,onChange:()=>u(o,i)}),a?` ${a}`:null]})}function wa(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function tu({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,o=S(h=>h.variables[a]),s=S(h=>h.setVariable),u=wa(t);ae({type:\"listbox\",key:`$${a}`,authorId:r,label:a,variable:a,options:u,value:o,perform:h=>{h!==void 0&&s(a,String(h))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return _(\"select\",{id:r,class:l,value:o==null?\"\":String(o),onChange:h=>s(a,h.target.value),children:u.map(h=>_(\"option\",{value:h,children:h},h))})}function nu({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,o=S(c=>c.variables[a]),s=S(c=>c.setVariable),u=wa(t),l=()=>{if(u.length===0)return;const d=(u.indexOf(String(o))+1)%u.length;s(a,u[d])};ae({type:\"cycle\",key:`$${a}`,authorId:r,label:o==null?u[0]||\"\":String(o),variable:a,options:u,value:o,perform:c=>{c!==void 0?s(a,c):l()}});const h=n?`macro-cycle ${n}`:\"macro-cycle\";return _(\"button\",{id:r,class:h,onClick:l,children:o==null?u[0]||\"\":String(o)})}function ru(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function oi(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")try{pt(r.rawArgs,t,n)}catch(i){console.error(`spindle: Error in {link} child {set}${re()}:`,i)}else if(r.name===\"do\"){const i=va(r.children);try{pt(i,t,n)}catch(a){console.error(`spindle: Error in {link} child {do}${re()}:`,a)}}}}function iu({rawArgs:e,children:t,className:n,id:r}){const i=pe();n=i(n),r=i(r);const{display:a,passage:o}=ru(e),s=xe(Pe),[,,u]=se(),l=c=>{c.preventDefault(),oi(t,u,s.update),o&&S.getState().navigate(o)};ae({type:\"link\",key:o||a,authorId:r,label:a,target:o??void 0,perform:()=>{oi(t,u,s.update),o&&S.getState().navigate(o)}});const h=n?`macro-link ${n}`:\"macro-link\";return _(\"a\",{id:r,class:h,href:\"#\",onClick:l,children:a})}function au({rawArgs:e,branches:t}){const[n,r,i]=se();let a;try{a=be(e,n,r,i)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{switch error${re()}: ${s instanceof Error?s.message:String(s)}}`})}let o=null;for(let s=1;s<t.length;s++){const u=t[s];if(u.rawArgs===\"\"){o=u;continue}try{const l=be(u.rawArgs,n,r,i);if(a===l)return _(G,{children:de(u.children)})}catch(l){return _(\"span\",{class:\"error\",title:String(l),children:`{case error${re()}: ${l instanceof Error?l.message:String(l)}}`})}}return o?_(G,{children:de(o.children)}):null}function Kt(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function ou({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=pe();r=a(r),i=a(i);const o=Re(()=>{const h=[];h.push({delay:Kt(e),nodes:t});for(const c of n){const d=c.rawArgs?Kt(c.rawArgs):0;h.push({delay:d,nodes:c.children})}return h},[e,t,n]),[s,u]=K(-1);if(Ee(()=>{if(s>=o.length-1)return;const h=s+1,c=o[h].delay,d=setTimeout(()=>{u(h)},c);return()=>clearTimeout(d)},[s,o]),s<0)return null;const l=de(o[s].nodes);return r||i?_(\"span\",{id:i,class:r,children:l}):_(G,{children:l})}const Sa=er({stop:()=>{}});function su({rawArgs:e,children:t,className:n,id:r}){const[i,a]=Re(()=>{const g=w=>{if(!w||!_a(w))return w;const I=S.getState();return ya(w,I.variables,I.temporary,{})};return[g(n),g(r)]},[n,r]),o=Kt(e),[s,u]=K(0),[l,h]=K(!1),c=We(()=>h(!0),[]);if(Ee(()=>{if(l)return;const g=setInterval(()=>{u(w=>w+1)},o);return()=>clearInterval(g)},[o,l]),s===0&&!l)return null;const d=i?`macro-repeat ${i}`:void 0,f=_(Sa.Provider,{value:{stop:c},children:_(\"span\",{children:de(t)},s)});return d||a?_(\"span\",{id:a,class:d,children:f}):f}function lu(){const{stop:e}=xe(Sa);return ve(()=>{e()},[e]),null}function uu({rawArgs:e,children:t,className:n,id:r}){const i=pe();n=i(n),r=i(r);const a=Kt(e),o=Ae(null),[s,u]=K(0),[l,h]=K(0);Ee(()=>{if(o.current){const f=o.current.textContent||\"\";u(f.length)}},[]),Ee(()=>{if(s===0||l>=s)return;const f=setInterval(()=>{h(g=>g>=s?(clearInterval(f),g):g+1)},a);return()=>clearInterval(f)},[s,a]);const c=l>=s&&s>0,d=[\"macro-type\",c?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return _(\"span\",{id:r,class:d,ref:o,style:{clipPath:(s>0&&!c,void 0)},children:[_(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!c?`inset(0 ${(s-l)/s*100}% 0 0)`:void 0},children:La(t)}),!c&&s>0&&_(\"span\",{class:\"macro-type-cursor\"})]})}const ka=new Map;function Ca(e,t,n){ka.set(e.toLowerCase(),{body:t,params:n})}function cu(e){return ka.get(e.toLowerCase())}function fu(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}function hu({rawArgs:e,children:t}){const{name:n,params:r}=fu(e);return ve(()=>{Ca(n,t,r)},[]),null}function du(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function pu({body:e,parentValues:t,ownKeys:n}){const[r,i]=K(()=>({...t,...n})),a=We((s,u)=>{i(l=>({...l,[s]:u}))},[]),o={values:r,update:a};return _(Pe.Provider,{value:o,children:de(e)})}function mu({body:e,params:t,rawArgs:n}){const r=xe(Pe),[i,a,o]=se();if(t.length===0||!n)return _(G,{children:de(e)});const s=du(n),u={};for(let l=0;l<t.length;l++){const h=t[l],c=s[l];let d;if(c!==void 0)try{d=be(c,i,a,o)}catch{d=void 0}u[h]=d}return _(pu,{body:e,parentValues:r.values,ownKeys:u})}function gu(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function _u(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function si(e,t,n,r,i,a,o){const s=S.getState();let u;try{u=be(e,r,i,a)}catch(h){console.error(`spindle: Error in {computed ${o}}${re()}:`,h);return}const l=n?s.temporary[t]:s.variables[t];_u(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}function yu({rawArgs:e}){const[t,n,r]=se();let i,a;try{({target:i,expr:a}=gu(e))}catch(l){return _(\"span\",{class:\"error\",title:String(l),children:`{computed error${re()}: ${l instanceof Error?l.message:String(l)}}`})}const o=i.startsWith(\"_\"),s=i.slice(1),u=Ae(!1);if(!u.current){u.current=!0;const l=S.getState();si(a,s,o,l.variables,l.temporary,r,e)}return ve(()=>{si(a,s,o,t,n,r,e)},[t,n,r]),null}function bu(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const a=vu(r);if(a.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:a[0],maxExpr:a.slice(1).join(\" \"),labelMode:n}}function vu(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const a=e[i];if(a===\"(\"||a===\"[\")r++,n+=a;else if(a===\")\"||a===\"]\")r--,n+=a;else if(/\\s/.test(a)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=a}return n.length>0&&t.push(n),t}function xu(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function wu({rawArgs:e,className:t,id:n}){const r=pe();t=r(t),n=r(n);const[i,a,o]=se();try{const{currentExpr:s,maxExpr:u,labelMode:l}=bu(e),h=Number(be(s,i,a,o)),c=Number(be(u,i,a,o)),d=c===0?0:Math.max(0,Math.min(100,h/c*100)),f=xu(h,c,l),g=[\"macro-meter\",t].filter(Boolean).join(\" \");return _(\"div\",{class:g,id:n,children:[_(\"div\",{class:\"macro-meter-fill\",style:`width: ${d}%`}),f!=null&&_(\"span\",{class:\"macro-meter-label\",children:f})]})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{meter error: ${s instanceof Error?s.message:String(s)}}`})}}function Su({passage:e}){const t=Re(()=>{try{const n=vt(e.content),r=xt(n);return de(r)}catch(n){return _(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",ba(e),\": \",n.message]})}},[e.content,e.name]);return _(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}function ku({className:e,id:t}){const n=pe();e=n(e),t=n(t);const r=S(o=>o.currentPassage),a=S(o=>o.storyData)?.passages.get(r);return a?_(\"div\",{id:t??\"story\",class:e??\"story\",children:_(Su,{passage:a},r)}):_(\"div\",{class:\"error\",children:[\"Error: Passage “\",r,\"” not found.\"]})}const Cu=new Map;function Iu(e){return Cu.get(e.toLowerCase())}const li=document.createElement(\"i\");function Ia(e){const t=\"&\"+e+\";\";li.innerHTML=t;const n=li.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function he(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ee(e,t){return e.length>0?(he(e,e.length,0,t),e):t}const jn={}.hasOwnProperty;function Au(e){const t={};let n=-1;for(;++n<e.length;)Eu(t,e[n]);return t}function Eu(e,t){let n;for(n in t){const i=(jn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){jn.call(i,o)||(i[o]=[]);const s=a[o];Pu(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Pu(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);he(e,0,0,r)}function $u(e){const t={};let n=-1;for(;++n<e.length;)Tu(t,e[n]);return t}function Tu(e,t){let n;for(n in t){const i=(jn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function Du(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const Nu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Aa(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Nu[n]+\";\"}}function gt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const ke=Ve(/[A-Za-z]/),fe=Ve(/[\\dA-Za-z]/),Fu=Ve(/[#-'*+\\--9=?A-Z^-~]/);function Wn(e){return e!==null&&(e<32||e===127)}const Qn=Ve(/\\d/),zu=Ve(/[\\dA-Fa-f]/),Ou=Ve(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Ru=Ve(/\\p{P}|\\p{S}/u),Lu=Ve(/\\s/);function Ve(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Et(e,t){const n=Aa(Mu(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),o=n.indexOf(\"/\");return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Mu(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&fe(e.charCodeAt(n+1))&&fe(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o=\"�\"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const ui={}.hasOwnProperty,ci=/^(https?|ircs?|mailto|xmpp)$/i,Bu=/^https?$/i;function Vu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=$u([{enter:{blockQuote:R,codeFenced:me,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:A,codeText:ao,content:Qa,definition:Va,definitionDestinationString:qa,definitionLabelString:I,definitionTitleString:I,emphasis:ro,htmlFlow:no,htmlText:mr,image:q,label:I,link:j,listItemMarker:P,listItemValue:y,listOrdered:F,listUnordered:M,paragraph:Y,reference:I,resource:Qe,resourceDestinationString:Ge,resourceTitleString:I,setextHeading:Ka,strong:io},exit:{atxHeading:Za,atxHeadingSequence:Ga,autolinkEmail:ho,autolinkProtocol:fo,blockQuote:Z,characterEscapeValue:at,characterReferenceMarkerHexadecimal:gr,characterReferenceMarkerNumeric:gr,characterReferenceValue:co,codeFenced:p,codeFencedFence:ue,codeFencedFenceInfo:m,codeFencedFenceMeta:z,codeFlowValue:to,codeIndented:p,codeText:oo,codeTextData:at,data:at,definition:Wa,definitionDestinationString:Ua,definitionLabelString:Ha,definitionTitleString:ja,emphasis:so,hardBreakEscape:dr,hardBreakTrailing:dr,htmlFlow:pr,htmlFlowData:at,htmlText:pr,htmlTextData:at,image:hr,label:it,labelText:U,lineEnding:eo,link:hr,listOrdered:$,listUnordered:V,paragraph:le,reference:z,referenceString:Fe,resource:z,resourceDestinationString:fn,resourceTitleString:Ba,setextHeading:Xa,setextHeadingLineSequence:Ja,setextHeadingText:Ya,strong:lo,thematicBreak:uo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},h={buffer:I,encode:v,getData:w,lineEndingIfNeeded:E,options:t,raw:k,resume:b,setData:g,tag:x};let c=t.defaultLineEnding;return d;function d(C){let T=-1,X=0;const ge=[];let we=[],$e=[];for(;++T<C.length;)!c&&(C[T][1].type===\"lineEnding\"||C[T][1].type===\"lineEndingBlank\")&&(c=C[T][2].sliceSerialize(C[T][1])),(C[T][1].type===\"listOrdered\"||C[T][1].type===\"listUnordered\")&&(C[T][0]===\"enter\"?ge.push(T):f(C.slice(ge.pop(),T))),C[T][1].type===\"definition\"&&(C[T][0]===\"enter\"?($e=ee($e,C.slice(X,T)),X=T):(we=ee(we,C.slice(X,T+1)),X=T+1));we=ee(we,$e),we=ee(we,C.slice(X)),T=-1;const Se=we;for(u.enter.null&&u.enter.null.call(h);++T<C.length;){const _r=u[Se[T][0]],yr=Se[T][1].type,br=_r[yr];ui.call(_r,yr)&&br&&br.call({sliceSerialize:Se[T][2].sliceSerialize,...h},Se[T][1])}return u.exit.null&&u.exit.null.call(h),i[0].join(\"\")}function f(C){const T=C.length;let X=0,ge=0,we=!1,$e;for(;++X<T;){const Se=C[X];if(Se[1]._container)$e=void 0,Se[0]===\"enter\"?ge++:ge--;else switch(Se[1].type){case\"listItemPrefix\":{Se[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Se[0]===\"enter\"&&!ge&&($e?$e=void 0:we=!0);break}default:$e=void 0}}C[0][1]._loose=we}function g(C,T){l[C]=T}function w(C){return l[C]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function x(C){n&&(g(\"lastWasTag\",!0),i[i.length-1].push(C))}function k(C){g(\"lastWasTag\"),i[i.length-1].push(C)}function N(){k(c||`\n`)}function E(){const C=i[i.length-1],T=C[C.length-1],X=T?T.charCodeAt(T.length-1):null;X===10||X===13||X===null||N()}function v(C){return w(\"ignoreEncode\")?C:Aa(C)}function z(){b()}function F(C){o.push(!C._loose),E(),x(\"<ol\"),g(\"expectFirstItem\",!0)}function M(C){o.push(!C._loose),E(),x(\"<ul\"),g(\"expectFirstItem\",!0)}function y(C){if(w(\"expectFirstItem\")){const T=Number.parseInt(this.sliceSerialize(C),10);T!==1&&x(' start=\"'+v(String(T))+'\"')}}function P(){w(\"expectFirstItem\")?x(\">\"):H(),E(),x(\"<li>\"),g(\"expectFirstItem\"),g(\"lastWasTag\")}function $(){H(),o.pop(),N(),x(\"</ol>\")}function V(){H(),o.pop(),N(),x(\"</ul>\")}function H(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&E(),x(\"</li>\"),g(\"slurpAllLineEndings\")}function R(){o.push(!1),E(),x(\"<blockquote>\")}function Z(){o.pop(),E(),x(\"</blockquote>\"),g(\"slurpAllLineEndings\")}function Y(){o[o.length-1]||(E(),x(\"<p>\")),g(\"slurpAllLineEndings\")}function le(){o[o.length-1]?g(\"slurpAllLineEndings\",!0):x(\"</p>\")}function me(){E(),x(\"<pre><code\"),g(\"fencesCount\",0)}function m(){const C=b();x(' class=\"language-'+C+'\"')}function ue(){const C=w(\"fencesCount\")||0;C||(x(\">\"),g(\"slurpOneLineEnding\",!0)),g(\"fencesCount\",C+1)}function A(){E(),x(\"<pre><code>\")}function p(){const C=w(\"fencesCount\");C!==void 0&&C<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&N(),w(\"flowCodeSeenData\")&&E(),x(\"</code></pre>\"),C!==void 0&&C<2&&E(),g(\"flowCodeSeenData\"),g(\"fencesCount\"),g(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function j(){a.push({})}function U(C){a[a.length-1].labelId=this.sliceSerialize(C)}function it(){a[a.length-1].label=b()}function Fe(C){a[a.length-1].referenceId=this.sliceSerialize(C)}function Qe(){I(),a[a.length-1].destination=\"\"}function Ge(){I(),g(\"ignoreEncode\",!0)}function fn(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function Ba(){a[a.length-1].title=b()}function hr(){let C=a.length-1;const T=a[C],X=T.referenceId||T.labelId,ge=T.destination===void 0?r[gt(X)]:T;for(n=!0;C--;)if(a[C].image){n=void 0;break}T.image?(x('<img src=\"'+Et(ge.destination,t.allowDangerousProtocol?void 0:Bu)+'\" alt=\"'),k(T.label),x('\"')):x('<a href=\"'+Et(ge.destination,t.allowDangerousProtocol?void 0:ci)+'\"'),x(ge.title?' title=\"'+ge.title+'\"':\"\"),T.image?x(\" />\"):(x(\">\"),k(T.label),x(\"</a>\")),a.pop()}function Va(){I(),a.push({})}function Ha(C){b(),a[a.length-1].labelId=this.sliceSerialize(C)}function qa(){I(),g(\"ignoreEncode\",!0)}function Ua(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function ja(){a[a.length-1].title=b()}function Wa(){const C=a[a.length-1],T=gt(C.labelId);b(),ui.call(r,T)||(r[T]=a[a.length-1]),a.pop()}function Qa(){g(\"slurpAllLineEndings\",!0)}function Ga(C){w(\"headingRank\")||(g(\"headingRank\",this.sliceSerialize(C).length),E(),x(\"<h\"+w(\"headingRank\")+\">\"))}function Ka(){I(),g(\"slurpAllLineEndings\")}function Ya(){g(\"slurpAllLineEndings\",!0)}function Za(){x(\"</h\"+w(\"headingRank\")+\">\"),g(\"headingRank\")}function Ja(C){g(\"headingRank\",this.sliceSerialize(C).charCodeAt(0)===61?1:2)}function Xa(){const C=b();E(),x(\"<h\"+w(\"headingRank\")+\">\"),k(C),x(\"</h\"+w(\"headingRank\")+\">\"),g(\"slurpAllLineEndings\"),g(\"headingRank\")}function at(C){k(v(this.sliceSerialize(C)))}function eo(C){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){g(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){k(\" \");return}k(v(this.sliceSerialize(C)))}}function to(C){k(v(this.sliceSerialize(C))),g(\"flowCodeSeenData\",!0)}function dr(){x(\"<br />\")}function no(){E(),mr()}function pr(){g(\"ignoreEncode\")}function mr(){t.allowDangerousHtml&&g(\"ignoreEncode\",!0)}function ro(){x(\"<em>\")}function io(){x(\"<strong>\")}function ao(){g(\"inCodeText\",!0),x(\"<code>\")}function oo(){g(\"inCodeText\"),x(\"</code>\")}function so(){x(\"</em>\")}function lo(){x(\"</strong>\")}function uo(){E(),x(\"<hr />\")}function gr(C){g(\"characterReferenceType\",C.type)}function co(C){const T=this.sliceSerialize(C),X=w(\"characterReferenceType\")?Du(T,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Ia(T);k(v(X)),g(\"characterReferenceType\")}function fo(C){const T=this.sliceSerialize(C);x('<a href=\"'+Et(T,t.allowDangerousProtocol?void 0:ci)+'\">'),k(v(T)),x(\"</a>\")}function ho(C){const T=this.sliceSerialize(C);x('<a href=\"'+Et(\"mailto:\"+T)+'\">'),k(v(T)),x(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Hu={tokenize:qu};function qu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return D(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Uu={tokenize:ju},fi={tokenize:Wu};function ju(e){const t=this,n=[];let r=0,i,a,o;return s;function s(k){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,u,l)(k)}return l(k)}function u(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const N=t.events.length;let E=N,v;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){v=t.events[E][1].end;break}b(r);let z=N;for(;z<t.events.length;)t.events[z][1].end={...v},z++;return he(t.events,E+1,0,t.events.slice(N)),t.events.length=z,l(k)}return s(k)}function l(k){if(r===n.length){if(!i)return d(k);if(i.currentConstruct&&i.currentConstruct.concrete)return g(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fi,h,c)(k)}function h(k){return i&&x(),b(r),d(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(k)}function d(k){return t.containerState={},e.attempt(fi,f,g)(k)}function f(k){return r++,n.push([t.currentConstruct,t.containerState]),d(k)}function g(k){if(k===null){i&&x(),b(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(k)}function w(k){if(k===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(k);return}return D(k)?(e.consume(k),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(k),w)}function I(k,N){const E=t.sliceStream(k);if(N&&E.push(null),k.previous=a,a&&(a.next=k),a=k,i.defineSkip(k.start),i.write(E),t.parser.lazy[k.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<o&&(!i.events[v][1].end||i.events[v][1].end.offset>o))return;const z=t.events.length;let F=z,M,y;for(;F--;)if(t.events[F][0]===\"exit\"&&t.events[F][1].type===\"chunkFlow\"){if(M){y=t.events[F][1].end;break}M=!0}for(b(r),v=z;v<t.events.length;)t.events[v][1].end={...y},v++;he(t.events,F+1,0,t.events.slice(z)),t.events.length=v}}function b(k){let N=n.length;for(;N-- >k;){const E=n[N];t.containerState=E[1],E[0].exit.call(t,e)}n.length=k}function x(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Wu(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Yt(e){if(e===null||te(e)||Lu(e))return 1;if(Ru(e))return 2}function un(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Gn={name:\"attention\",resolveAll:Qu,tokenize:Gu};function Qu(e,t){let n=-1,r,i,a,o,s,u,l,h;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};hi(c,-u),hi(d,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ee(l,un(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,l=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):h=0,he(e,r-1,n-r+3,l),n=r+l.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Gu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Yt(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),h=Yt(u),c=!h||h===2&&i||n.includes(u),d=!i||i===2&&h||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(h||!c)),t(u)}}function hi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ku={name:\"autolink\",tokenize:Yu};function Yu(e,t,n){let r=0;return i;function i(f){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(f){return ke(f)?(e.consume(f),o):f===64?n(f):l(f)}function o(f){return f===43||f===45||f===46||fe(f)?(r=1,s(f)):l(f)}function s(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||fe(f))&&r++<32?(e.consume(f),s):(r=0,l(f))}function u(f){return f===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):f===null||f===32||f===60||Wn(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),h):Fu(f)?(e.consume(f),l):n(f)}function h(f){return fe(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(f)}function d(f){if((f===45||fe(f))&&r++<63){const g=f===45?d:c;return e.consume(f),g}return n(f)}}const cn={partial:!0,tokenize:Zu};function Zu(e,t,n){return r;function r(a){return L(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||D(a)?t(a):n(a)}}const Ea={continuation:{tokenize:Xu},exit:ec,name:\"blockQuote\",tokenize:Ju};function Ju(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function Xu(e,t,n){const r=this;return i;function i(o){return L(o)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Ea,t,n)(o)}}function ec(e){e.exit(\"blockQuote\")}const Pa={name:\"characterEscape\",tokenize:tc};function tc(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return Ou(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const $a={name:\"characterReference\",tokenize:nc};function nc(e,t,n){const r=this;let i=0,a,o;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=fe,h(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=zu,h):(e.enter(\"characterReferenceValue\"),a=7,o=Qn,h(c))}function h(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return o===fe&&!Ia(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),h):n(c)}}const di={partial:!0,tokenize:ic},pi={concrete:!0,name:\"codeFenced\",tokenize:rc};function rc(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,o=0,s;return u;function u(v){return l(v)}function l(v){const z=r.events[r.events.length-1];return a=z&&z[1].type===\"linePrefix\"?z[2].sliceSerialize(z[1],!0).length:0,s=v,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),h(v)}function h(v){return v===s?(o++,e.consume(v),h):o<3?n(v):(e.exit(\"codeFencedFenceSequence\"),L(v)?B(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||D(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(di,w,N)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(v))}function d(v){return v===null||D(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):L(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,f,\"whitespace\")(v)):v===96&&v===s?n(v):(e.consume(v),d)}function f(v){return v===null||D(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),g(v))}function g(v){return v===null||D(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===s?n(v):(e.consume(v),g)}function w(v){return e.attempt(i,N,I)(v)}function I(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),b}function b(v){return a>0&&L(v)?B(e,x,\"linePrefix\",a+1)(v):x(v)}function x(v){return v===null||D(v)?e.check(di,w,N)(v):(e.enter(\"codeFlowValue\"),k(v))}function k(v){return v===null||D(v)?(e.exit(\"codeFlowValue\"),x(v)):(e.consume(v),k)}function N(v){return e.exit(\"codeFenced\"),t(v)}function E(v,z,F){let M=0;return y;function y(R){return v.enter(\"lineEnding\"),v.consume(R),v.exit(\"lineEnding\"),P}function P(R){return v.enter(\"codeFencedFence\"),L(R)?B(v,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):$(R)}function $(R){return R===s?(v.enter(\"codeFencedFenceSequence\"),V(R)):F(R)}function V(R){return R===s?(M++,v.consume(R),V):M>=o?(v.exit(\"codeFencedFenceSequence\"),L(R)?B(v,H,\"whitespace\")(R):H(R)):F(R)}function H(R){return R===null||D(R)?(v.exit(\"codeFencedFence\"),z(R)):F(R)}}}function ic(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const yn={name:\"codeIndented\",tokenize:oc},ac={partial:!0,tokenize:sc};function oc(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(e,a,\"linePrefix\",5)(l)}function a(l){const h=r.events[r.events.length-1];return h&&h[1].type===\"linePrefix\"&&h[2].sliceSerialize(h[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):D(l)?e.attempt(ac,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||D(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function sc(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):D(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):D(o)?i(o):n(o)}}const lc={name:\"codeText\",previous:cc,resolve:uc,tokenize:fc};function uc(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function cc(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function fc(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,h(c)):D(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||D(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function h(c){return c===96?(e.consume(c),i++,h):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class hc{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&st(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),st(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),st(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);st(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);st(this.left,n.reverse())}}}function st(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ta(e){const t={};let n=-1,r,i,a,o,s,u,l;const h=new hc(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type===\"chunkFlow\"&&h.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,dc(h,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=h.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(h.get(i)[1].type=\"lineEndingBlank\"),o[1].type=\"lineEnding\",i=a);else if(!(o[1].type===\"linePrefix\"||o[1].type===\"listItemIndent\"))break;i&&(r[1].end={...h.get(i)[1].start},s=h.slice(i,n),s.unshift(r),h.splice(i,n-i+1,s))}}return he(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!l}function dc(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let h,c,d=-1,f=n,g=0,w=0;const I=[w];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),c&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(h),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++d<s.length;)s[d][0]===\"exit\"&&s[d-1][0]===\"enter\"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,I.push(w),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):I.pop(),d=I.length;d--;){const b=s.slice(I[d],I[d+1]),x=a.pop();u.push([x,x+b.length-1]),e.splice(x,2,b)}for(u.reverse(),d=-1;++d<u.length;)l[g+u[d][0]]=g+u[d][1],g+=u[d][1]-u[d][0]-1;return l}const pc={resolve:gc,tokenize:_c},mc={partial:!0,tokenize:yc};function gc(e){return Ta(e),e}function _c(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):D(s)?e.check(mc,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function yc(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(o){if(o===null||D(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Da(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let h=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),d):b===null||b===32||b===41||Wn(b)?n(b):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(b))}function d(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),f(b))}function f(b){return b===62?(e.exit(\"chunkString\"),e.exit(s),d(b)):b===null||b===60||D(b)?n(b):(e.consume(b),b===92?g:f)}function g(b){return b===60||b===62||b===92?(e.consume(b),f):f(b)}function w(b){return!h&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(b)):h<l&&b===40?(e.consume(b),h++,w):b===41?(e.consume(b),h--,w):b===null||b===32||b===40||Wn(b)?n(b):(e.consume(b),b===92?I:w)}function I(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function Na(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),h}function h(f){return s>999||f===null||f===91||f===93&&!u||f===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):D(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),h):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||D(f)||s++>999?(e.exit(\"chunkString\"),h(f)):(e.consume(f),u||(u=!L(f)),f===92?d:c)}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function Fa(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,u):n(d)}function u(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===o?(e.exit(a),u(o)):d===null?n(d):D(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),h(d))}function h(d){return d===o||d===null||D(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:h)}function c(d){return d===o||d===92?(e.consume(d),h):h(d)}}function ct(e,t){let n;return r;function r(i){return D(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const bc={name:\"definition\",tokenize:xc},vc={partial:!0,tokenize:wc};function xc(e,t,n){const r=this;let i;return a;function a(f){return e.enter(\"definition\"),o(f)}function o(f){return Na.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function s(f){return i=gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter(\"definitionMarker\"),e.consume(f),e.exit(\"definitionMarker\"),u):n(f)}function u(f){return te(f)?ct(e,l)(f):l(f)}function l(f){return Da(e,h,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function h(f){return e.attempt(vc,c,c)(f)}function c(f){return L(f)?B(e,d,\"whitespace\")(f):d(f)}function d(f){return f===null||D(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function wc(e,t,n){return r;function r(s){return te(s)?ct(e,i)(s):n(s)}function i(s){return Fa(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?B(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||D(s)?t(s):n(s)}}const Sc={name:\"hardBreakEscape\",tokenize:kc};function kc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return D(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Cc={name:\"headingAtx\",resolve:Ic,tokenize:Ac};function Ic(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},he(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Ac(e,t,n){let r=0;return i;function i(h){return e.enter(\"atxHeading\"),a(h)}function a(h){return e.enter(\"atxHeadingSequence\"),o(h)}function o(h){return h===35&&r++<6?(e.consume(h),o):h===null||te(h)?(e.exit(\"atxHeadingSequence\"),s(h)):n(h)}function s(h){return h===35?(e.enter(\"atxHeadingSequence\"),u(h)):h===null||D(h)?(e.exit(\"atxHeading\"),t(h)):L(h)?B(e,s,\"whitespace\")(h):(e.enter(\"atxHeadingText\"),l(h))}function u(h){return h===35?(e.consume(h),u):(e.exit(\"atxHeadingSequence\"),s(h))}function l(h){return h===null||h===35||te(h)?(e.exit(\"atxHeadingText\"),s(h)):(e.consume(h),l)}}const Ec=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],mi=[\"pre\",\"script\",\"style\",\"textarea\"],Pc={concrete:!0,name:\"htmlFlow\",resolveTo:Dc,tokenize:Nc},$c={partial:!0,tokenize:zc},Tc={partial:!0,tokenize:Fc};function Dc(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Nc(e,t,n){const r=this;let i,a,o,s,u;return l;function l(p){return h(p)}function h(p){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(p),c}function c(p){return p===33?(e.consume(p),d):p===47?(e.consume(p),a=!0,w):p===63?(e.consume(p),i=3,r.interrupt?t:m):ke(p)?(e.consume(p),o=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,f):p===91?(e.consume(p),i=5,s=0,g):ke(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function f(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function g(p){const q=\"CDATA[\";return p===q.charCodeAt(s++)?(e.consume(p),s===q.length?r.interrupt?t:$:g):n(p)}function w(p){return ke(p)?(e.consume(p),o=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||te(p)){const q=p===47,j=o.toLowerCase();return!q&&!a&&mi.includes(j)?(i=1,r.interrupt?t(p):$(p)):Ec.includes(o.toLowerCase())?(i=6,q?(e.consume(p),b):r.interrupt?t(p):$(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):a?x(p):k(p))}return p===45||fe(p)?(e.consume(p),o+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:$):n(p)}function x(p){return L(p)?(e.consume(p),x):y(p)}function k(p){return p===47?(e.consume(p),y):p===58||p===95||ke(p)?(e.consume(p),N):L(p)?(e.consume(p),k):y(p)}function N(p){return p===45||p===46||p===58||p===95||fe(p)?(e.consume(p),N):E(p)}function E(p){return p===61?(e.consume(p),v):L(p)?(e.consume(p),E):k(p)}function v(p){return p===null||p===60||p===61||p===62||p===96?n(p):p===34||p===39?(e.consume(p),u=p,z):L(p)?(e.consume(p),v):F(p)}function z(p){return p===u?(e.consume(p),u=null,M):p===null||D(p)?n(p):(e.consume(p),z)}function F(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||te(p)?E(p):(e.consume(p),F)}function M(p){return p===47||p===62||L(p)?k(p):n(p)}function y(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||D(p)?$(p):L(p)?(e.consume(p),P):n(p)}function $(p){return p===45&&i===2?(e.consume(p),Z):p===60&&i===1?(e.consume(p),Y):p===62&&i===4?(e.consume(p),ue):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),me):D(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check($c,A,V)(p)):p===null||D(p)?(e.exit(\"htmlFlowData\"),V(p)):(e.consume(p),$)}function V(p){return e.check(Tc,H,A)(p)}function H(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),R}function R(p){return p===null||D(p)?V(p):(e.enter(\"htmlFlowData\"),$(p))}function Z(p){return p===45?(e.consume(p),m):$(p)}function Y(p){return p===47?(e.consume(p),o=\"\",le):$(p)}function le(p){if(p===62){const q=o.toLowerCase();return mi.includes(q)?(e.consume(p),ue):$(p)}return ke(p)&&o.length<8?(e.consume(p),o+=String.fromCharCode(p),le):$(p)}function me(p){return p===93?(e.consume(p),m):$(p)}function m(p){return p===62?(e.consume(p),ue):p===45&&i===2?(e.consume(p),m):$(p)}function ue(p){return p===null||D(p)?(e.exit(\"htmlFlowData\"),A(p)):(e.consume(p),ue)}function A(p){return e.exit(\"htmlFlow\"),t(p)}}function Fc(e,t,n){const r=this;return i;function i(o){return D(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function zc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(cn,t,n)}}const Oc={name:\"htmlText\",tokenize:Rc};function Rc(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),E):m===63?(e.consume(m),k):ke(m)?(e.consume(m),F):n(m)}function l(m){return m===45?(e.consume(m),h):m===91?(e.consume(m),a=0,g):ke(m)?(e.consume(m),x):n(m)}function h(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):D(m)?(o=c,Y(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?Z(m):m===45?d(m):c(m)}function g(m){const ue=\"CDATA[\";return m===ue.charCodeAt(a++)?(e.consume(m),a===ue.length?w:g):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),I):D(m)?(o=w,Y(m)):(e.consume(m),w)}function I(m){return m===93?(e.consume(m),b):w(m)}function b(m){return m===62?Z(m):m===93?(e.consume(m),b):w(m)}function x(m){return m===null||m===62?Z(m):D(m)?(o=x,Y(m)):(e.consume(m),x)}function k(m){return m===null?n(m):m===63?(e.consume(m),N):D(m)?(o=k,Y(m)):(e.consume(m),k)}function N(m){return m===62?Z(m):k(m)}function E(m){return ke(m)?(e.consume(m),v):n(m)}function v(m){return m===45||fe(m)?(e.consume(m),v):z(m)}function z(m){return D(m)?(o=z,Y(m)):L(m)?(e.consume(m),z):Z(m)}function F(m){return m===45||fe(m)?(e.consume(m),F):m===47||m===62||te(m)?M(m):n(m)}function M(m){return m===47?(e.consume(m),Z):m===58||m===95||ke(m)?(e.consume(m),y):D(m)?(o=M,Y(m)):L(m)?(e.consume(m),M):Z(m)}function y(m){return m===45||m===46||m===58||m===95||fe(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),$):D(m)?(o=P,Y(m)):L(m)?(e.consume(m),P):M(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):D(m)?(o=$,Y(m)):L(m)?(e.consume(m),$):(e.consume(m),H)}function V(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):D(m)?(o=V,Y(m)):(e.consume(m),V)}function H(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?M(m):(e.consume(m),H)}function R(m){return m===47||m===62||te(m)?M(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function Y(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),le}function le(m){return L(m)?B(e,me,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):me(m)}function me(m){return e.enter(\"htmlTextData\"),o(m)}}const fr={name:\"labelEnd\",resolveAll:Vc,resolveTo:Hc,tokenize:qc},Lc={tokenize:Uc},Mc={tokenize:jc},Bc={tokenize:Wc};function Vc(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&he(e,0,e.length,n),e}function Hc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},h={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ee(s,e.slice(a+1,a+r+3)),s=ee(s,[[\"enter\",h,t]]),s=ee(s,un(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ee(s,[[\"exit\",h,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ee(s,e.slice(o+1)),s=ee(s,[[\"exit\",u,t]]),he(e,a,e.length,s),e}function qc(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(d){return a?a._inactive?c(d):(o=r.parser.defined.includes(gt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(Lc,h,o?h:c)(d):d===91?e.attempt(Mc,h,o?l:c)(d):o?h(d):c(d)}function l(d){return e.attempt(Bc,h,c)(d)}function h(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function Uc(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return te(c)?ct(e,a)(c):a(c)}function a(c){return c===41?h(c):Da(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return te(c)?ct(e,u)(c):h(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Fa(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):h(c)}function l(c){return te(c)?ct(e,h)(c):h(c)}function h(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function jc(e,t,n){const r=this;return i;function i(s){return Na.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(gt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Wc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const Qc={name:\"labelStartImage\",resolveAll:fr.resolveAll,tokenize:Gc};function Gc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),a}function a(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),o):n(s)}function o(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const Kc={name:\"labelStartLink\",resolveAll:fr.resolveAll,tokenize:Yc};function Yc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const bn={name:\"lineEnding\",tokenize:Zc};function Zc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Ot={name:\"thematicBreak\",tokenize:Jc};function Jc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||D(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?B(e,s,\"whitespace\")(l):s(l))}}const oe={continuation:{tokenize:nf},exit:af,name:\"list\",tokenize:tf},Xc={partial:!0,tokenize:of},ef={partial:!0,tokenize:rf};function tf(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(f){const g=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(g===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:Qn(f)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(Ot,n,l)(f):l(f);if(!r.interrupt||f===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(f)}return n(f)}function u(f){return Qn(f)&&++o<10?(e.consume(f),u):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit(\"listItemValue\"),l(f)):n(f)}function l(f){return e.enter(\"listItemMarker\"),e.consume(f),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||f,e.check(cn,r.interrupt?n:h,e.attempt(Xc,d,c))}function h(f){return r.containerState.initialBlankLine=!0,a++,d(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),d):n(f)}function d(f){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function nf(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(cn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(ef,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(oe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function rf(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function af(e){e.exit(this.containerState.type)}function of(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const gi={name:\"setextUnderline\",resolveTo:sf,tokenize:lf};function sf(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function lf(e,t,n){const r=this;let i;return a;function a(l){let h=r.events.length,c;for(;h--;)if(r.events[h][1].type!==\"lineEnding\"&&r.events[h][1].type!==\"linePrefix\"&&r.events[h][1].type!==\"content\"){c=r.events[h][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||D(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const uf={tokenize:cf};function cf(e){const t=this,n=e.attempt(cn,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(pc,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const ff={resolveAll:Oa()},hf=za(\"string\"),df=za(\"text\");function za(e){return{resolveAll:Oa(e===\"text\"?pf:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(h){return l(h)?a(h):s(h)}function s(h){if(h===null){n.consume(h);return}return n.enter(\"data\"),n.consume(h),u}function u(h){return l(h)?(n.exit(\"data\"),a(h)):(n.consume(h),u)}function l(h){if(h===null)return!0;const c=i[h];let d=-1;if(c)for(;++d<c.length;){const f=c[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Oa(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function pf(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const mf={42:oe,43:oe,45:oe,48:oe,49:oe,50:oe,51:oe,52:oe,53:oe,54:oe,55:oe,56:oe,57:oe,62:Ea},gf={91:bc},_f={[-2]:yn,[-1]:yn,32:yn},yf={35:Cc,42:Ot,45:[gi,Ot],60:Pc,61:gi,95:Ot,96:pi,126:pi},bf={38:$a,92:Pa},vf={[-5]:bn,[-4]:bn,[-3]:bn,33:Qc,38:$a,42:Gn,60:[Ku,Oc],91:Kc,92:[Sc,Pa],93:fr,95:Gn,96:lc},xf={null:[Gn,ff]},wf={null:[42,95]},Sf={null:[]},kf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:wf,contentInitial:gf,disable:Sf,document:mf,flow:yf,flowInitial:_f,insideSpan:xf,string:bf,text:vf},Symbol.toStringTag,{value:\"Module\"}));function Cf(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:z(E),check:z(v),consume:x,enter:k,exit:N,interrupt:z(v,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:f,write:c};let h=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(P){return o=ee(o,P),I(),o[o.length-1]!==null?[]:(F(t,0),l.events=un(a,l.events,l),l.events)}function d(P,$){return Af(f(P),$)}function f(P){return If(o,P)}function g(){const{_bufferIndex:P,_index:$,line:V,column:H,offset:R}=r;return{_bufferIndex:P,_index:$,line:V,column:H,offset:R}}function w(P){i[P.line]=P.column,y()}function I(){let P;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(P){h=h(P)}function x(P){D(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function k(P,$){const V=$||{};return V.type=P,V.start=g(),l.events.push([\"enter\",V,l]),s.push(V),V}function N(P){const $=s.pop();return $.end=g(),l.events.push([\"exit\",$,l]),$}function E(P,$){F(P,$.from)}function v(P,$){$.restore()}function z(P,$){return V;function V(H,R,Z){let Y,le,me,m;return Array.isArray(H)?A(H):\"tokenize\"in H?A([H]):ue(H);function ue(U){return it;function it(Fe){const Qe=Fe!==null&&U[Fe],Ge=Fe!==null&&U.null,fn=[...Array.isArray(Qe)?Qe:Qe?[Qe]:[],...Array.isArray(Ge)?Ge:Ge?[Ge]:[]];return A(fn)(Fe)}}function A(U){return Y=U,le=0,U.length===0?Z:p(U[le])}function p(U){return it;function it(Fe){return m=M(),me=U,U.partial||(l.currentConstruct=U),U.name&&l.parser.constructs.disable.null.includes(U.name)?j():U.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,j)(Fe)}}function q(U){return P(me,m),R}function j(U){return m.restore(),++le<Y.length?p(Y[le]):Z}}}function F(P,$){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&he(l.events,$,l.events.length-$,P.resolve(l.events.slice($),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function M(){const P=g(),$=l.previous,V=l.currentConstruct,H=l.events.length,R=Array.from(s);return{from:H,restore:Z};function Z(){r=P,l.previous=$,l.currentConstruct=V,l.events.length=H,s=R,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function If(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s==\"string\"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Af(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a==\"string\")o=a;else switch(a){case-5:{o=\"\\r\";break}case-4:{o=`\n`;break}case-3:{o=`\\r\n`;break}case-2:{o=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;o=\" \";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(\"\")}function Ef(e){const r={constructs:Au([kf,...(e||{}).extensions||[]]),content:i(Hu),defined:[],document:i(Uu),flow:i(uf),lazy:{},string:i(hf),text:i(df)};return r;function i(a){return o;function o(s){return Cf(r,a,s)}}}function Pf(e){for(;!Ta(e););return e}const _i=/[\\0\\t\\n\\r]/g;function $f(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,h,c,d,f;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(_i.lastIndex=c,l=_i.exec(a),d=l&&l.index!==void 0?l.index:a.length,f=a.charCodeAt(d),!l){t=a.slice(c);break}if(f===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),f){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Tf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Vu(n)(Pf(Ef(n).document().write($f()(e,t,!0))))}const vn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Df(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=vn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=vn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,Nf)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+vn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Nf(e,t){return t===\"|\"?t:e}class Ff{constructor(){this.map=[]}add(t,n,r){zf(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function zf(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Of(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function Rf(){return{flow:{null:{name:\"table\",tokenize:Lf,resolveAll:Mf}}}}function Lf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(y){let P=r.events.length-1;for(;P>-1;){const H=r.events[P][1].type;if(H===\"lineEnding\"||H===\"linePrefix\")P--;else break}const $=P>-1?r.events[P][1].type:null,V=$===\"tableHead\"||$===\"tableRow\"?v:u;return V===v&&r.parser.lazy[r.now().line]?n(y):V(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(o=!0,a+=1),h(y)}function h(y){return y===null?n(y):D(y)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),f):n(y):L(y)?B(e,h,\"whitespace\")(y):(a+=1,o&&(o=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),o=!0,h):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||te(y)?(e.exit(\"data\"),h(y)):(e.consume(y),y===92?d:c)}function d(y){return y===92||y===124?(e.consume(y),c):c(y)}function f(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),o=!1,L(y)?B(e,g,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):g(y))}function g(y){return y===45||y===58?I(y):y===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),w):E(y)}function w(y){return L(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(a+=1,b(y)):y===null||D(y)?N(y):E(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),x(y)):E(y)}function x(y){return y===45?(e.consume(y),x):y===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),k):(e.exit(\"tableDelimiterFiller\"),k(y))}function k(y){return L(y)?B(e,N,\"whitespace\")(y):N(y)}function N(y){return y===124?g(y):y===null||D(y)?!o||i!==a?E(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):E(y)}function E(y){return n(y)}function v(y){return e.enter(\"tableRow\"),z(y)}function z(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),z):y===null||D(y)?(e.exit(\"tableRow\"),t(y)):L(y)?B(e,z,\"whitespace\")(y):(e.enter(\"data\"),F(y))}function F(y){return y===null||y===124||te(y)?(e.exit(\"data\"),z(y)):(e.consume(y),y===92?M:F)}function M(y){return y===92||y===124?(e.consume(y),F):F(y)}}function Mf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,h,c;const d=new Ff;for(;++n<e.length;){const f=e[n],g=f[1];f[0]===\"enter\"?g.type===\"tableHead\"?(s=!1,u!==0&&(yi(d,t,u,l,h),h=void 0,u=0),l={type:\"table\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",l,t]])):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,h={type:\"tableBody\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",h,t]])),i=g.type===\"tableDelimiterRow\"?2:h?3:1):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Pt(d,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):g.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Pt(d,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):g.type===\"tableHead\"?(s=!0,u=n):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Pt(d,t,a,i,n,c)):o[1]!==0&&(c=Pt(d,t,o,i,n,c)),i=0):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&yi(d,t,u,l,h),d.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=Of(t.events,n))}return e}function Pt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Ye(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Ye(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=Ye(t.events,n[2]),h=Ye(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],f=t.events[n[3]];if(d[1].end=Object.assign({},f[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const g=n[2]+1,w=n[3]-n[2]-1;e.add(g,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},Ye(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function yi(e,t,n,r,i){const a=[],o=Ye(t.events,n);i&&(i.end=Object.assign({},o),a.push([\"exit\",i,t])),r.end=Object.assign({},o),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function Ye(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Bf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Vf(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const h={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},d=[[\"enter\",h,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],f=s.parser.constructs.insideSpan.null;f&&he(d,d.length,0,un(f,o.slice(l+1,u),s)),he(d,d.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",h,s]]),he(o,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,h=this.events;let c=0;return d;function d(g){return l===126&&h[h.length-1][1].type!==\"characterEscape\"?u(g):(o.enter(\"strikethroughSequenceTemporary\"),f(g))}function f(g){const w=Yt(l);if(g===126)return c>1?u(g):(o.consume(g),c++,f);if(c<2&&!n)return u(g);const I=o.exit(\"strikethroughSequenceTemporary\"),b=Yt(g);return I._open=!b||b===2&&!!w,I._close=!w||w===2&&!!b,s(g)}}}function Hf(e){return Tf(e,{allowDangerousHtml:!0,extensions:[Rf(),Vf()],htmlExtensions:[Df(),Bf()]})}const qf={values:{},update:()=>{}},Pe=er(qf),xn=[];function Uf(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>Ra(i,a,t));return _(G,{children:r})}function Ra(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>Ra(u,l,n));return ye(i,o,...s)}return null}function jf({node:e}){const t=pe(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return ye(e.tag,n,e.children.length>0?de(e.children):void 0)}function Wf(e,t){switch(e.name){case\"set\":return _(yl,{rawArgs:e.rawArgs},t);case\"computed\":return _(yu,{rawArgs:e.rawArgs},t);case\"print\":return _(bl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return _(wu,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"passage\":return _(ku,{className:e.className,id:e.id},t);case\"if\":return _(vl,{branches:e.branches??xn},t);case\"for\":return _(Sl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return _(Cl,{children:e.children},t);case\"button\":return _(Il,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return _(Al,{className:e.className,id:e.id},t);case\"back\":return _(Pl,{className:e.className,id:e.id},t);case\"forward\":return _($l,{className:e.className,id:e.id},t);case\"restart\":return _(El,{className:e.className,id:e.id},t);case\"quicksave\":return _(Tl,{className:e.className,id:e.id},t);case\"quickload\":return _(Dl,{className:e.className,id:e.id},t);case\"settings\":return _(Ol,{className:e.className,id:e.id},t);case\"saves\":return _(Vl,{className:e.className,id:e.id},t);case\"include\":return _(Hl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return _(ql,{rawArgs:e.rawArgs},t);case\"unset\":return _(Ul,{rawArgs:e.rawArgs},t);case\"textbox\":return _(Wl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return _(Gl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return _(Yl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return _(Jl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return _(eu,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return _(tu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return _(nu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return _(iu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return _(au,{rawArgs:e.rawArgs,branches:e.branches??xn},t);case\"timed\":{const n=e.branches?.[0];return _(ou,{rawArgs:e.rawArgs,children:e.children,branches:e.branches??xn,className:e.className??n?.className,id:e.id??n?.id},t)}case\"repeat\":return _(su,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return _(lu,{},t);case\"type\":return _(uu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return _(hu,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=cu(e.name);if(n)return _(mu,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Iu(e.name);return r?_(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:de(e.children)},t):_(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function Kn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return _(gl,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return _(_l,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Wf(e,t);case\"html\":return _(jf,{node:e},t);default:return e}}function La(e){return e.length===0?null:e.map((t,n)=>Kn(t,n))}function Qf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Gf(e){const t=S.getState(),n=e.name.split(\".\"),r=n[0];let i;e.scope===\"variable\"?i=t.variables[r]:e.scope===\"temporary\"&&(i=t.temporary[r]);for(let a=1;a<n.length;a++){if(i==null||typeof i!=\"object\")return\"\";i=i[n[a]]}return i==null?\"\":String(i)}function de(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,o)=>Kn(a,o));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const o=e[a];if(o.type===\"text\")r+=o.value.replace(/^[ \\t]{4,}/gm,\" \");else if(o.type===\"variable\"&&Qf(r))r+=Gf(o);else{const s=n.length;n.push(Kn(o,a)),r+=`<span data-tw=\"${s}\"></span>`}}const i=Hf(r);return Uf(i,n)}const Kf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Yf(){const t=S(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Kf;try{const r=vt(n),i=xt(r);return _(G,{children:de(i)})}catch(r){return _(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function Zf(){const e=S(n=>n.storyData),t=S(n=>n.currentPassage);return Ee(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),S.getState().save()):r.key===\"F9\"&&(r.preventDefault(),S.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?_(\"div\",{class:\"loading\",children:\"Loading...\"}):_(Yf,{})}function Jf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",h=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(d.getAttribute(\"pid\")||\"0\",10),g=d.getAttribute(\"name\")||\"\",w=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(N=>N.length>0),I=d.textContent||\"\",b={},x=new Set([\"pid\",\"name\",\"tags\"]);for(const N of d.attributes)x.has(N.name)||(b[N.name]=N.value);const k={pid:f,name:g,tags:w,metadata:b,content:I};h.set(g,k),c.set(f,k)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:h,passagesById:c,userCSS:s,userScript:l}}function Xf(){return{get(e){return S.getState().variables[e]},set(e,t){const n=S.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){S.getState().navigate(e)},back(){S.getState().goBack()},forward(){S.getState().goForward()},restart(){S.getState().restart()},save(e){S.getState().save(e)},load(e){S.getState().load(e)},hasSave(e){return S.getState().hasSave(e)},visited(e){return S.getState().visitCounts[e]??0},hasVisited(e){return(S.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return S.getState().renderCounts[e]??0},hasRendered(e){return(S.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=S.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=S.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return S.getState().storyData?.name||\"\"},get passage(){return S.getState().currentPassage},settings:mt,registerClass(e,t){Ws(e,t)},saves:{setTitleGenerator(e){Gs(e)}},getActions(){return ri()},performAction(e,t){const n=cl(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=S.getState().currentPassage;return S.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return hl(t);if(e===\"variableChanged\"){let n={...S.getState().variables};return S.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(ri())})})})},random(){return sr()},randomInt(e,t){return sa(e,t)},prng:{init(e,t){Ts(e,t);const{historyIndex:n}=S.getState();S.setState(r=>{const i=r.history[n];i&&(i.prng=zt())})},isEnabled(){return Ds()},get seed(){return Ns()},get pull(){return Fs()}}}}function eh(){window.Story=Xf()}const th=/^\\$(\\w+)\\s*=\\s*(.+)$/,bi=/\\$(\\w+(?:\\.\\w+)*)/g,vi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,nh=new Set([\"number\",\"string\",\"boolean\"]);function Ma(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,Ma(i));return{type:\"object\",fields:n}}const t=typeof e;if(!nh.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function rh(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(th);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=Ma(s);t.set(a,{...u,name:a,default:s})}return t}function ih(e){const t=new Set;let n;for(vi.lastIndex=0;(n=vi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function ah(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function oh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=ih(i.content);let o;for(bi.lastIndex=0;(o=bi.exec(i.content))!==null;){const s=o[1],u=ah(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function sh(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function xi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const o=document.createElement(\"li\");o.textContent=a,i.appendChild(o)}n.appendChild(i),e.appendChild(n)}function wi(){const e=Jf();if(eh(),e.userCSS){const u=document.createElement(\"style\");u.textContent=e.userCSS,document.head.appendChild(u)}if(e.userScript)try{new Function(e.userScript)()}catch(u){console.error(\"spindle: Error in story JavaScript:\",u)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const u=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",l=document.getElementById(\"root\");throw l&&xi(l,[u]),new Error(`spindle: ${u}`)}const r=rh(n.content),i=oh(e.passages,r);if(i.length>0){const u=document.getElementById(\"root\");throw u&&xi(u,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=sh(r),S.getState().init(e,t),ga();for(const[,u]of e.passages)if(u.tags.includes(\"widget\")){const l=vt(u.content),h=xt(l);for(const c of h)if(c.type===\"macro\"&&c.name===\"widget\"&&c.rawArgs){const d=c.rawArgs.trim().split(/\\s+/),f=d[0].replace(/[\"']/g,\"\"),g=d.slice(1).filter(w=>w.startsWith(\"$\")||w.startsWith(\"_\")||w.startsWith(\"@\"));Ca(f,c.children,g)}}let a=\"\";S.subscribe(u=>{u.currentPassage!==a&&(a=u.currentPassage,fl())});const o=e.passages.get(\"StoryInterface\");o&&!o.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const s=document.getElementById(\"root\");if(!s)throw new Error('spindle: No <div id=\"root\"> element found.');Je(_(Zf,{}),s),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",wi):wi();</script>\n <style rel=\"stylesheet\" crossorigin>*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.2.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var yt,O,ki,qe,xr,Ci,Ii,Ai,Zn,Sn,kn,Ei,Lt={},Mt=[],mo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,bt=Array.isArray;function ke(e,t){for(var n in t)e[n]=t[n];return e}function Jn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function _e(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?yt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return ct(e,o,r,i,null)}function ct(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ki,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function go(){return{current:null}}function G(e){return e.children}function Ce(e,t){this.props=e,this.context=t}function Ze(e,t){if(t==null)return e.__?Ze(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?Ze(e):null}function _o(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=ke({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),Xn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ze(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Di(r,a,i),t.__e=t.__=null,a.__e!=n&&Pi(a)}}function Pi(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Pi(e)}function Cn(e){(!e.__d&&(e.__d=!0)&&qe.push(e)&&!Bt.__r++||xr!=O.debounceRendering)&&((xr=O.debounceRendering)||Ci)(Bt)}function Bt(){for(var e,t=1;qe.length;)qe.length>t&&qe.sort(Ii),e=qe.shift(),t=qe.length,_o(e);Bt.__r=0}function $i(e,t,n,r,i,a,o,s,u,l,h){var c,d,f,g,w,I,b,x=r&&r.__k||Mt,k=t.length;for(u=yo(n,t,x,u,k),c=0;c<k;c++)(f=n.__k[c])!=null&&(d=f.__i!=-1&&x[f.__i]||Lt,f.__i=c,I=Xn(e,f,d,i,a,o,s,u,l,h),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&er(d.ref,null,f),h.push(f.ref,f.__c||g,f)),w==null&&g!=null&&(w=g),(b=!!(4&f.__u))||d.__k===f.__k?u=Ti(f,u,e,b):typeof f.type==\"function\"&&I!==void 0?u=I:g&&(u=g.nextSibling),f.__u&=-7);return n.__e=w,u}function yo(e,t,n,r,i){var a,o,s,u,l,h=n.length,c=h,d=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=ct(null,o,null,null,null):bt(o)?o=e.__k[a]=ct(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=ct(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+d,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=bo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>h?d--:i<h&&d++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<h;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=Ze(s)),Fi(s,s));return r}function Ti(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Ti(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ze(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function De(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(bt(e)?e.some(function(n){De(n,t)}):t.push(e)),t}function bo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],h=l!=null&&(2&l.__u)==0;if(l===null&&s==null||h&&s==l.key&&u==l.type)return n;if(r>(h?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function wr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||mo.test(t)?n:n+\"px\"}function kt(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||wr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||wr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Ai,\"$1\")),o=t.toLowerCase(),t=o in e||t==\"onFocusOut\"||t==\"onFocusIn\"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=Zn,e.addEventListener(t,a?kn:Sn,a)):e.removeEventListener(t,a?kn:Sn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Sr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Zn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Xn(e,t,n,r,i,a,o,s,u,l){var h,c,d,f,g,w,I,b,x,k,N,E,v,z,F,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(h=O.__b)&&h(t);e:if(typeof M==\"function\")try{if(b=t.props,x=\"prototype\"in M&&M.prototype.render,k=(h=M.contextType)&&r[h.__c],N=h?k?k.props.value:h.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(x?t.__c=c=new M(b,N):(t.__c=c=new Ce(b,N),c.constructor=M,c.render=xo),k&&k.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),x&&c.__s==null&&(c.__s=c.state),x&&M.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=ke({},c.__s)),ke(c.__s,M.getDerivedStateFromProps(b,c.__s))),f=c.props,g=c.state,c.__v=t,d)x&&M.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),x&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(x&&M.getDerivedStateFromProps==null&&b!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,N),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,N)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),Mt.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,N),x&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,g,w)})}if(c.context=N,c.props=b,c.__P=e,c.__e=!1,E=O.__r,v=0,x)c.state=c.__s,c.__d=!1,E&&E(t),h=c.render(c.props,c.state,c.context),Mt.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),h=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++v<25);c.state=c.__s,c.getChildContext!=null&&(r=ke(ke({},r),c.getChildContext())),x&&!d&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(f,g)),z=h!=null&&h.type===G&&h.key==null?Ni(h.props.children):h,s=$i(e,bt(z)?z:[z],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||a!=null)if(y.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(F=a.length;F--;)Jn(a[F]);In(t)}else t.__e=n.__e,t.__k=n.__k,y.then||In(t);O.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=vo(n.__e,t,n,r,i,a,o,u,l);return(h=O.diffed)&&h(t),128&t.__u?void 0:s}function In(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(In))}function Di(e,t,n){for(var r=0;r<n.length;r++)er(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function Ni(e){return typeof e!=\"object\"||e==null||e.__b>0?e:bt(e)?e.map(Ni):ke({},e)}function vo(e,t,n,r,i,a,o,s,u){var l,h,c,d,f,g,w,I=n.props||Lt,b=t.props,x=t.type;if(x==\"svg\"?i=\"http://www.w3.org/2000/svg\":x==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((f=a[l])&&\"setAttribute\"in f==!!x&&(x?f.localName==x:f.nodeType==3)){e=f,a[l]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(x==null)I===b||s&&e.data==b||(e.data=b);else{if(a=a&&yt.call(e.childNodes),!s&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(f=e.attributes[l]).name]=f.value;for(l in I)f=I[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||kt(e,l,null,f,i);for(l in b)f=b[l],l==\"children\"?d=f:l==\"dangerouslySetInnerHTML\"?h=f:l==\"value\"?g=f:l==\"checked\"?w=f:s&&typeof f!=\"function\"||I[l]===f||kt(e,l,f,I[l],i);if(h)s||c&&(h.__html==c.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),$i(t.type==\"template\"?e.content:e,bt(d)?d:[d],t,n,r,x==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&Ze(n,0),s,u),a!=null)for(l=a.length;l--;)Jn(a[l]);s||(l=\"value\",x==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[l]||x==\"progress\"&&!g||x==\"option\"&&g!=I[l])&&kt(e,l,g,I[l],i),l=\"checked\",w!=null&&w!=e[l]&&kt(e,l,w,I[l],i))}return e}function er(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){O.__e(i,n)}}function Fi(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||er(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Fi(r[i],t,n||typeof e.type!=\"function\");n||Jn(e.__e),e.__c=e.__=e.__e=void 0}function xo(e,t,n){return this.constructor(e,n)}function Je(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],Xn(t,e=(!r&&n||t).__k=_e(G,null,[e]),i||Lt,Lt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?yt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Di(a,e,o)}function zi(e,t){Je(e,t,zi)}function wo(e,t,n){var r,i,a,o,s=ke({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?yt.call(arguments,2):n),ct(e.type,s,r||e.key,i||e.ref,null)}function tr(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,Cn(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+Ei++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}yt=Mt.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},ki=0,Ce.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ke({},this.state),typeof e==\"function\"&&(e=e(ke({},n),this.props)),e&&ke(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Cn(this))},Ce.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Cn(this))},Ce.prototype.render=G,qe=[],Ci=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ii=function(e,t){return e.__v.__b-t.__v.__b},Bt.__r=0,Ai=/(PointerCapture)$|Capture$/i,Zn=0,Sn=Sr(!1),kn=Sr(!0),Ei=0;var So=0;function _(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--So,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var ze,W,dn,kr,Xe=0,Oi=[],Q=O,Cr=Q.__b,Ir=Q.__r,Ar=Q.diffed,Er=Q.__c,Pr=Q.unmount,$r=Q.__;function rt(e,t){Q.__h&&Q.__h(W,e,Xe||t),Xe=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function K(e){return Xe=1,nr(Bi,e)}function nr(e,t,n){var r=rt(ze++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Bi(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return d.__c});if(h.every(function(d){return!d.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return h.some(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var h=a;a=void 0,i(s,u,l),a=h}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Ae(e,t){var n=rt(ze++,3);!Q.__s&&rr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function be(e,t){var n=rt(ze++,4);!Q.__s&&rr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function Ie(e){return Xe=5,Re(function(){return{current:e}},[])}function Ri(e,t,n){Xe=6,be(function(){if(typeof e==\"function\"){var r=e(t());return function(){e(null),r&&typeof r==\"function\"&&r()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function Re(e,t){var n=rt(ze++,7);return rr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function We(e,t){return Xe=8,Re(function(){return e},t)}function ve(e){var t=W.context[e.__c],n=rt(ze++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Li(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function Mi(){var e=rt(ze++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function ko(){for(var e;e=Oi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Tt),t.__h.some(An),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Cr&&Cr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),$r&&$r(e,t)},Q.__r=function(e){Ir&&Ir(e),ze=0;var t=(W=e.__c).__H;t&&(dn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Tt),t.__h.some(An),t.__h=[],ze=0)),dn=W},Q.diffed=function(e){Ar&&Ar(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Oi.push(t)!==1&&kr===Q.requestAnimationFrame||((kr=Q.requestAnimationFrame)||Co)(ko)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),dn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Tt),n.__h=n.__h.filter(function(r){return!r.__||An(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Er&&Er(e,t)},Q.unmount=function(e){Pr&&Pr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Tt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Tr=typeof requestAnimationFrame==\"function\";function Co(e){var t,n=function(){clearTimeout(r),Tr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Tr&&(t=requestAnimationFrame(n))}function Tt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function An(e){var t=W;e.__c=e.__(),W=t}function rr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Bi(e,t){return typeof t==\"function\"?t(e):t}const Dr=e=>{let t;const n=new Set,r=(l,h)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=h??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,d))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},Io=(e=>e?Dr(e):Dr);function Vi(e,t){for(var n in t)e[n]=t[n];return e}function En(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function Hi(e,t){var n=t(),r=K({t:{__:n,u:t}}),i=r[0].t,a=r[1];return be(function(){i.__=n,i.u=t,pn(i)&&a({t:i})},[e,n,t]),Ae(function(){return pn(i)&&a({t:i}),e(function(){pn(i)&&a({t:i})})},[e]),n}function pn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function qi(e){e()}function Ui(e){return e}function ji(){return[!1,qi]}var Wi=be;function Pn(e,t){this.props=e,this.context=t}function Ao(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:En(this.props,i)}function r(i){return this.shouldComponentUpdate=n,_e(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Pn.prototype=new Ce).isPureReactComponent=!0,Pn.prototype.shouldComponentUpdate=function(e,t){return En(this.props,e)||En(this.state,t)};var Nr=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Nr&&Nr(e)};var Eo=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function Po(e){function t(n){var r=Vi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=Eo,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Fr=function(e,t){return e==null?null:De(De(e).map(t))},$o={map:Fr,forEach:Fr,count:function(e){return e?De(e).length:0},only:function(e){var t=De(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:De},To=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}To(e,t,n,r)};var zr=O.unmount;function Qi(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c==\"function\"&&r.__c()}),e.__c.__H=null),(e=Vi({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return Qi(r,t,n)})),e}function Gi(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Gi(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function Dt(){this.__u=0,this.o=null,this.__b=null}function Ki(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Do(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?_e(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function ut(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),zr&&zr(e)},(Dt.prototype=new Ce).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Ki(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Gi(l,l.__c.__P,l.__c.__O)}var h;for(r.setState({__a:r.__b=null});h=r.o.pop();)h.__P=s,h.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},Dt.prototype.componentWillUnmount=function(){this.o=[]},Dt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=Qi(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&_e(G,null,e.fallback);return i&&(i.__u&=-33),[_e(G,null,t.__a?null:e.children),i]};var Or=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function No(e){return this.getChildContext=function(){return e.context},e.children}function Fo(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Je(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,a){this.childNodes.push(i),t.h.insertBefore(i,a)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}Je(_e(No,{context:t.context},e.__v),t.v)}function zo(e,t){var n=_e(Fo,{__v:e,h:t});return n.containerInfo=t,n}(ut.prototype=new Ce).__a=function(e){var t=this,n=Ki(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Or(t,e,r)):i()};n?n(a):a()}},ut.prototype.render=function(e){this.i=null,this.l=new Map;var t=De(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},ut.prototype.componentDidUpdate=ut.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Or(e,n,t)})};var Yi=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,Oo=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Ro=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Lo=/[A-Z0-9]/g,Mo=typeof document<\"u\",Bo=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Vo(e,t,n){return t.__k==null&&(t.textContent=\"\"),Je(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ho(e,t,n){return zi(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ce.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ce.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Rr=O.event;function qo(){}function Uo(){return this.cancelBubble}function jo(){return this.defaultPrevented}O.event=function(e){return Rr&&(e=Rr(e)),e.persist=qo,e.isPropagationStopped=Uo,e.isDefaultPrevented=jo,e.nativeEvent=e};var ir,Wo={enumerable:!1,configurable:!0,get:function(){return this.class}},Lr=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||Mo&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Bo(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":Ro.test(o)&&(o=u):u=o=\"oninput\":a&&Oo.test(o)?o=o.replace(Lo,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=De(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=De(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Wo)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Yi,Lr&&Lr(e)};var Mr=O.__r;O.__r=function(e){Mr&&Mr(e),ir=e.__c};var Br=O.diffed;O.diffed=function(e){Br&&Br(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),ir=null};var Qo={ReactCurrentDispatcher:{current:{readContext:function(e){return ir.__n[e.__c].props.value},useCallback:We,useContext:ve,useDebugValue:Li,useDeferredValue:Ui,useEffect:Ae,useId:Mi,useImperativeHandle:Ri,useInsertionEffect:Wi,useLayoutEffect:be,useMemo:Re,useReducer:nr,useRef:Ie,useState:K,useSyncExternalStore:Hi,useTransition:ji}}};function Go(e){return _e.bind(null,e)}function Jt(e){return!!e&&e.$$typeof===Yi}function Ko(e){return Jt(e)&&e.type===G}function Yo(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Zo(e){return Jt(e)?wo.apply(null,arguments):e}function Jo(e){return!!e.__k&&(Je(null,e),!0)}function Xo(e){return e&&(e.base||e.nodeType===1&&e)||null}var es=function(e,t){return e(t)},ts=function(e,t){return e(t)},ns=G,rs=Jt,Ct={useState:K,useId:Mi,useReducer:nr,useEffect:Ae,useLayoutEffect:be,useInsertionEffect:Wi,useTransition:ji,useDeferredValue:Ui,useSyncExternalStore:Hi,startTransition:qi,useRef:Ie,useImperativeHandle:Ri,useMemo:Re,useCallback:We,useContext:ve,useDebugValue:Li,version:\"18.3.1\",Children:$o,render:Vo,hydrate:Ho,unmountComponentAtNode:Jo,createPortal:zo,createElement:_e,createContext:tr,createFactory:Go,cloneElement:Zo,createRef:go,Fragment:G,isValidElement:Jt,isElement:rs,isFragment:Ko,isMemo:Yo,findDOMNode:Xo,Component:Ce,PureComponent:Pn,memo:Ao,forwardRef:Po,flushSync:ts,unstable_batchedUpdates:es,StrictMode:ns,Suspense:Dt,SuspenseList:ut,lazy:Do,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Qo};const is=e=>e;function as(e,t=is){const n=Ct.useSyncExternalStore(e.subscribe,Ct.useCallback(()=>t(e.getState()),[e,t]),Ct.useCallback(()=>t(e.getInitialState()),[e,t]));return Ct.useDebugValue(n),n}const os=e=>{const t=Io(e),n=r=>as(t,r);return Object.assign(n,t),n},ss=(e=>os);var Zi=Symbol.for(\"immer-nothing\"),Vr=Symbol.for(\"immer-draftable\"),ie=Symbol.for(\"immer-state\");function ge(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ue=Object,et=ue.getPrototypeOf,Vt=\"constructor\",Xt=\"prototype\",$n=\"configurable\",Ht=\"enumerable\",Nt=\"writable\",ht=\"value\",Oe=e=>!!e&&!!e[ie];function Ne(e){return e?Ji(e)||tn(e)||!!e[Vr]||!!e[Vt]?.[Vr]||nn(e)||rn(e):!1}var ls=ue[Xt][Vt].toString(),Hr=new WeakMap;function Ji(e){if(!e||!ar(e))return!1;const t=et(e);if(t===null||t===ue[Xt])return!0;const n=ue.hasOwnProperty.call(t,Vt)&&t[Vt];if(n===Object)return!0;if(!Ke(n))return!1;let r=Hr.get(n);return r===void 0&&(r=Function.toString.call(n),Hr.set(n,r)),r===ls}function en(e,t,n=!0){vt(e)===0?(n?Reflect.ownKeys(e):ue.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function vt(e){const t=e[ie];return t?t.type_:tn(e)?1:nn(e)?2:rn(e)?3:0}var qr=(e,t,n=vt(e))=>n===2?e.has(t):ue[Xt].hasOwnProperty.call(e,t),Tn=(e,t,n=vt(e))=>n===2?e.get(t):e[t],qt=(e,t,n,r=vt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function us(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var tn=Array.isArray,nn=e=>e instanceof Map,rn=e=>e instanceof Set,ar=e=>typeof e==\"object\",Ke=e=>typeof e==\"function\",mn=e=>typeof e==\"boolean\";function cs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Te=e=>e.copy_||e.base_,or=e=>e.modified_?e.copy_:e.base_;function Dn(e,t){if(nn(e))return new Map(e);if(rn(e))return new Set(e);if(tn(e))return Array[Xt].slice.call(e);const n=Ji(e);if(t===!0||t===\"class_only\"&&!n){const r=ue.getOwnPropertyDescriptors(e);delete r[ie];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[Nt]===!1&&(s[Nt]=!0,s[$n]=!0),(s.get||s.set)&&(r[o]={[$n]:!0,[Nt]:!0,[Ht]:s[Ht],[ht]:e[o]})}return ue.create(et(e),r)}else{const r=et(e);if(r!==null&&n)return{...e};const i=ue.create(r);return ue.assign(i,e)}}function sr(e,t=!1){return an(e)||Oe(e)||!Ne(e)||(vt(e)>1&&ue.defineProperties(e,{set:It,add:It,clear:It,delete:It}),ue.freeze(e),t&&en(e,(n,r)=>{sr(r,!0)},!1)),e}function fs(){ge(2)}var It={[ht]:fs};function an(e){return e===null||!ar(e)?!0:ue.isFrozen(e)}var Ut=\"MapSet\",Nn=\"Patches\",Ur=\"ArrayMethods\",Xi={};function Ue(e){const t=Xi[e];return t||ge(0,e),t}var jr=e=>!!Xi[e],dt,ea=()=>dt,hs=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:jr(Ut)?Ue(Ut):void 0,arrayMethodsPlugin_:jr(Ur)?Ue(Ur):void 0});function Wr(e,t){t&&(e.patchPlugin_=Ue(Nn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Fn(e){zn(e),e.drafts_.forEach(ds),e.drafts_=null}function zn(e){e===dt&&(dt=e.parent_)}var Qr=e=>dt=hs(dt,e);function ds(e){const t=e[ie];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Gr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ie].modified_&&(Fn(t),ge(4)),Ne(e)&&(e=Kr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ie].base_,e,t)}else e=Kr(t,n);return ps(t,e,!0),Fn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Zi?e:void 0}function Kr(e,t){if(an(t))return t;const n=t[ie];if(!n)return jt(t,e.handledSet_,e);if(!on(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);ra(n,e)}return n.copy_}function ps(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&sr(t,n)}function ta(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var on=(e,t)=>e.scope_===t,ms=[];function na(e,t,n,r){const i=Te(e),a=e.type_;if(r!==void 0&&Tn(i,r,a)===t){qt(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;en(i,(u,l)=>{if(Oe(l)){const h=s.get(l)||[];h.push(u),s.set(l,h)}})}const o=e.draftLocations_.get(t)??ms;for(const s of o)qt(i,s,n,a)}function gs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!on(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=or(a);na(e,a.draft_??a,o,n),ra(a,i)})}function ra(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}ta(e)}}function _s(e,t,n){const{scope_:r}=e;if(Oe(n)){const i=n[ie];on(i,r)&&i.callbacks_.push(function(){Ft(e);const o=or(i);na(e,n,o,t)})}else Ne(n)&&e.callbacks_.push(function(){const a=Te(e);e.type_===3?a.has(n)&&jt(n,r.handledSet_,r):Tn(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&jt(Tn(e.copy_,t,e.type_),r.handledSet_,r)})}function jt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Oe(e)||t.has(e)||!Ne(e)||an(e)||(t.add(e),en(e,(r,i)=>{if(Oe(i)){const a=i[ie];if(on(a,n)){const o=or(a);qt(e,r,o,e.type_),ta(a)}}else Ne(i)&&jt(i,t,n)})),e}function ys(e,t){const n=tn(e),r={type_:n?1:0,scope_:t?t.scope_:ea(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=Wt;n&&(i=[r],a=pt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var Wt={get(e,t){if(t===ie)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Te(e);if(!qr(i,t,e.type_))return bs(e,i,t);const a=i[t];if(e.finalized_||!Ne(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&cs(t))return a;if(a===gn(e.base_,t)){Ft(e);const o=e.type_===1?+t:t,s=Rn(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Te(e)},ownKeys(e){return Reflect.ownKeys(Te(e))},set(e,t,n){const r=ia(Te(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=gn(Te(e),t),a=i?.[ie];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(us(n,i)&&(n!==void 0||qr(e.base_,t,e.type_)))return!0;Ft(e),On(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),_s(e,t,n)),!0},deleteProperty(e,t){return Ft(e),gn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),On(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Te(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Nt]:!0,[$n]:e.type_!==1||t!==\"length\",[Ht]:r[Ht],[ht]:n[t]}},defineProperty(){ge(11)},getPrototypeOf(e){return et(e.base_)},setPrototypeOf(){ge(12)}},pt={};for(let e in Wt){let t=Wt[e];pt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}pt.deleteProperty=function(e,t){return pt.set.call(this,e,t,void 0)};pt.set=function(e,t,n){return Wt.set.call(this,e[0],t,n,e[0])};function gn(e,t){const n=e[ie];return(n?Te(n):e)[t]}function bs(e,t,n){const r=ia(t,n);return r?ht in r?r[ht]:r.get?.call(e.draft_):void 0}function ia(e,t){if(!(t in e))return;let n=et(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=et(n)}}function On(e){e.modified_||(e.modified_=!0,e.parent_&&On(e.parent_))}function Ft(e){e.copy_||(e.assigned_=new Map,e.copy_=Dn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var vs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ke(t)&&!Ke(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,h=>n.call(this,h,...l))}}Ke(n)||ge(6),r!==void 0&&!Ke(r)&&ge(7);let i;if(Ne(t)){const a=Qr(this),o=Rn(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Fn(a):zn(a)}return Wr(a,r),Gr(i,a)}else if(!t||!ar(t)){if(i=n(t),i===void 0&&(i=t),i===Zi&&(i=void 0),this.autoFreeze_&&sr(i,!0),r){const a=[],o=[];Ue(Nn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ge(1,t)},this.produceWithPatches=(t,n)=>{if(Ke(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},mn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),mn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),mn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ne(e)||ge(8),Oe(e)&&(e=xs(e));const t=Qr(this),n=Rn(t,e,void 0);return n[ie].isManual_=!0,zn(t),n}finishDraft(e,t){const n=e&&e[ie];(!n||!n.isManual_)&&ge(9);const{scope_:r}=n;return Wr(r,t),Gr(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Ue(Nn).applyPatches_;return Oe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Rn(e,t,n,r){const[i,a]=nn(t)?Ue(Ut).proxyMap_(t,n):rn(t)?Ue(Ut).proxySet_(t,n):ys(t,n);return(n?.scope_??ea()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?gs(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function xs(e){return Oe(e)||ge(10,e),aa(e)}function aa(e){if(!Ne(e)||an(e))return e;const t=e[ie];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Dn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Dn(e,!0);return en(n,(i,a)=>{qt(n,i,aa(a))},r),t&&(t.finalized_=!1),n}var ws=new vs,Ss=ws.produce;const ks=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?Ss(i):i;return t(s,a,...o)},e(r.setState,n,r)),Cs=ks,Is=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),As=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function Es(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function Yr(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function Zr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function Ps(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function xt(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const g=Zr(e,n);o=g.className||void 0,s=g.id||void 0,n=g.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const h=e.slice(l,n);n+=2;const{display:c,target:d}=Es(h),f={type:\"link\",display:c,target:d,start:a,end:n};o&&(f.className=o),s&&(f.id=s),t.push(f),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=Zr(e,n+1);s=l.className||void 0,u=l.id||void 0;let h=l.endIdx;e[h]===\" \"&&h++;const c=e[h];if(c===\"$\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"variable\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"temporary\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:f,scope:\"local\",start:a,end:n};s&&(g.className=s),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=h;let d=1;const f=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const g=e.slice(f,n);n++;const{name:w,rawArgs:I,isClose:b}=Yr(g),x={type:\"macro\",name:w,rawArgs:I,isClose:b,start:a,end:n};s&&(x.className=s),u&&(x.id=u),t.push(x),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const h=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(h,n);n++;const{name:d,rawArgs:f,isClose:g}=Yr(c);t.push({type:\"macro\",name:d,rawArgs:f,isClose:g,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&Is.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const h=Ps(e,o);o=h.endIdx;let c=As.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:h.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const $s=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),Jr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},Ts=new Set([\"if\",\"switch\",\"timed\"]);function wt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const a={type:\"link\",display:i.display,target:i.target};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const o=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${o} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(Jr[i.name]){const a=Jr[i.name],o=n.length>0?n[n.length-1].node:null;if(!o||o.type!==\"macro\"||o.name!==a)throw new Error(`{${i.name}} without matching {${a}} (at character ${i.start})`);const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches.push(s);break}if($s.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(Ts.has(i.name)){const o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),a.branches=[o]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function oa(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function sa(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let it=!1,St=\"\",je=0,tt=null;function Ds(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,St=n,je=0,tt=oa(sa(n)),it=!0}function Ln(e,t){St=e,je=0,tt=oa(sa(e)),it=!0;for(let n=0;n<t;n++)tt();je=t}function zt(){it=!1,St=\"\",je=0,tt=null}function Ot(){return it?{seed:St,pull:je}:null}function lr(){return!it||!tt?Math.random():(je++,tt())}function la(e,t){return e>t&&([e,t]=[t,e]),Math.floor(lr()*(t-e+1))+e}function Ns(){return it}function Fs(){return St}function zs(){return je}const Os=500,He=new Map,Rs=/\\$(\\w+)/g,Ls=/\\b_(\\w+)/g,Ms=/@(\\w+)/g;function Bs(e){return e.replace(Rs,'variables[\"$1\"]').replace(Ls,'temporary[\"$1\"]').replace(Ms,'locals[\"$1\"]')}function ur(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Bs(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=ur(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Vs=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function ua(e,t){const n=He.get(e);if(n)return He.delete(e),He.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Vs+t);if(He.set(e,r),He.size>Os){const i=He.keys().next().value;i!==void 0&&He.delete(i)}return r}let At=null,Xr=null,ei=null;function ca(){const e=S.getState(),{visitCounts:t,renderCounts:n}=e;if(At&&Xr===t&&ei===n)return At;const r=f=>t[f]??0,i=f=>r(f)>0,a=(...f)=>f.some(g=>r(g)>0),o=(...f)=>f.every(g=>r(g)>0),s=f=>n[f]??0;return At={currentPassage:()=>{const f=S.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=S.getState();if(f.historyIndex<=0)return;const g=f.history[f.historyIndex-1]?.passage;return g?f.storyData?.passages.get(g):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:f=>s(f)>0,hasRenderedAny:(...f)=>f.some(g=>s(g)>0),hasRenderedAll:(...f)=>f.every(g=>s(g)>0),random:lr,randomInt:la},Xr=t,ei=n,At}function ye(e,t,n,r={}){const a=`return (${ur(e)});`;return ua(a,a)(t,n,r,ca())}function Mn(e,t,n,r={}){const i=ur(e);ua(\"exec:\"+i,i)(t,n,r,ca())}const Hs=\"spindle\",qs=1;let Et=null,_n=null;function Le(){return _n||(_n={saves:new Map,playthroughs:new Map,meta:new Map}),_n}function Us(){return Et||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Et=new Promise((e,t)=>{const n=indexedDB.open(Hs,qs);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),Et))}function Me(e,t){return Us().then(n=>n.transaction(e,t).objectStore(e))}function Be(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function sn(e){try{const t=await Me(\"saves\",\"readwrite\");await Be(t.put(e))}catch{Le().saves.set(e.meta.id,e)}}async function ln(e){try{const t=await Me(\"saves\",\"readonly\");return await Be(t.get(e))??void 0}catch{return Le().saves.get(e)}}async function js(e){try{const t=await Me(\"saves\",\"readwrite\");await Be(t.delete(e))}catch{Le().saves.delete(e)}}async function Ws(e){try{const n=(await Me(\"saves\",\"readonly\")).index(\"ifid\");return await Be(n.getAll(e))??[]}catch{return[...Le().saves.values()].filter(t=>t.meta.ifid===e)}}async function fa(e){try{const t=await Me(\"playthroughs\",\"readwrite\");await Be(t.put(e))}catch{Le().playthroughs.set(e.id,e)}}async function cr(e){try{const n=(await Me(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Be(n.getAll(e))??[]}catch{return[...Le().playthroughs.values()].filter(t=>t.ifid===e)}}async function fr(e){try{const t=await Me(\"meta\",\"readonly\"),n=await Be(t.get(e));return n?n.value:void 0}catch{return Le().meta.get(e)}}async function ha(e,t){try{const n=await Me(\"meta\",\"readwrite\");await Be(n.put({key:e,value:t}))}catch{Le().meta.set(e,t)}}const da=new Map,un=new Map;function Qs(e,t){da.set(e,t),un.set(t,e)}function Gs(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function J(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(un.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(Gs(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Bn=\"__spindle_class__\",Vn=\"__spindle_data__\";function Qt(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=un.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Bn]:o,[Vn]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Gt(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(o=>t(o));const r=n;if(Bn in r&&Vn in r){const o=r[Bn],s=r[Vn],u=da.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const h={};for(const c of Object.keys(s))h[c]=t(s[c]);return h}const l=Object.create(u.prototype);for(const h of Object.keys(s))l[h]=t(s[h]);return l}const i=r.constructor;if(un.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let Hn=null,qn=null,ti=!1;function Ks(e){Hn=e}function Ys(e){qn=e}function Zs(e){if(qn)try{const i=new Function(\"passage\",\"variables\",qn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Hn)try{const r=Hn(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function Js(){ti||(ti=!0)}async function ni(e){const n=(await cr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await fa(i),await ha(`currentPlaythroughId.${e}`,r),r}async function Xs(e){return fr(`currentPlaythroughId.${e}`)}async function pa(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Zs(n),passage:n.passage,custom:r},o=J(n);o.variables=Qt(o.variables),o.history=o.history.map(u=>({...u,variables:Qt(u.variables)}));const s={meta:a,payload:o};return await sn(s),s}async function ma(e,t){const n=await ln(e);if(!n)return;const r=J(t);r.variables=Qt(r.variables),r.history=r.history.map(a=>({...a,variables:Qt(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await sn(i),i}async function el(e){const t=await ln(e);if(!t)return;const n=t.payload;return n.variables=Gt(n.variables),n.history=n.history.map(r=>({...r,variables:Gt(r.variables)})),n}async function tl(e){await js(e)}async function nl(e,t){const n=await ln(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await sn(r)}async function rl(e){const[t,n]=await Promise.all([Ws(e),cr(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const ga=\"autosave.\";async function il(e,t,n){const r=`${ga}${e}`,i=await fr(r);if(i){const o=await ma(i,n);if(o)return o}const a=await pa(e,t,n,{isAutosave:!0});return await ha(r,a.meta.id),a}async function al(e){const t=`${ga}${e}`,n=await fr(t);if(n)return el(n)}async function ol(e){const t=await ln(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function sl(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=J(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await cr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await fa(a)}return await sn(n),n}function ll(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Mn(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Mn(i,t,n)}}}function _a(){const e=S.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=xt(t.content),r=wt(n),i=J(e.variables),a=J(e.temporary);ll(r,i,a);for(const s of Object.keys(i))i[s]!==e.variables[s]&&e.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==e.temporary[s]&&e.setTemporary(s,a[s]);const o=e.storyData.passages.get(\"SaveTitle\");o&&Ys(o.content)}function ri(e){e?.prng?Ln(e.prng.seed,e.prng.pull):e&&zt()}const S=ss()(Cs((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",saveError:null,loadError:null,init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=J(r);e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,variables:J(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}});const o=n.ifid;Js().then(async()=>{const s=await Xs(o);if(s)e(u=>{u.playthroughId=s});else{const u=await ni(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:J(i.variables),timestamp:Date.now(),prng:Ot()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=J(r.variables),n.temporary={}}),ri(t().history[t().historyIndex])},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=J(r.variables),n.temporary={}}),ri(t().history[t().historyIndex])},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;zt();const a=J(r);e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,variables:J(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),_a(),ni(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:a,history:o,historyIndex:s,visitCounts:u,renderCounts:l}=t();if(!n)return;const h={passage:i,variables:J(a),history:J(o),historyIndex:s,visitCounts:{...u},renderCounts:{...l},prng:Ot()};e(c=>{c.saveError=null}),il(n.ifid,r,h).then(()=>{e(c=>{c.saveVersion++})}).catch(c=>{console.error(\"spindle: failed to quick save\",c),e(d=>{d.saveError=c instanceof Error?c.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),al(n.ifid).then(r=>{r&&(e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}}),r.prng?Ln(r.prng.seed,r.prng.pull):zt())}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t();return{passage:n,variables:J(r),history:J(i),historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:Ot()}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Gt(n.variables),r.history=n.history.map(i=>({...i,variables:Gt(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}}),n.prng?Ln(n.prng.seed,n.prng.pull):zt()}}))),Kt=new Map,Un=new Set,jn=new Map;function ul(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(jn.get(r)??0)+1;return jn.set(r,i),i===1?r:`${r}:${i}`}function cl(e){return Kt.set(e.id,e),ai(),()=>{Kt.delete(e.id),ai()}}function ii(){return Array.from(Kt.values())}function fl(e){return Kt.get(e)}function hl(){jn.clear()}function dl(e){return Un.add(e),()=>{Un.delete(e)}}function ai(){for(const e of Un)e()}function ae(e){const t=Ie(\"\");t.current||(t.current=ul(e.type,e.key,e.authorId));const n=t.current;return be(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),cl(r)}),n}function nt(e){const t={};for(const[n,r]of Object.entries(e))n.startsWith(\"@\")&&(t[n.slice(1)]=r);return t}function Ee(){const e=S(r=>r.variables),t=S(r=>r.temporary),n=ve(Pe);return Re(()=>[e,t,nt(n.values)],[e,t,n.values])}const pl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,ml=/\\{[\\$_@][\\w.]+\\}/;function ya(e){return ml.test(e)}function gl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function ba(e,t,n,r){return e.replace(pl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let h;return o===\"$\"?h=t[l]:o===\"_\"?h=n[l]:h=r[l],u.length>1&&(h=gl(h,u)),h==null?\"\":String(h)})}function de(){const[e,t,n]=Ee();return We(r=>r===void 0||!ya(r)?r:ba(r,e,t,n),[e,t,n])}function _l({target:e,className:t,id:n,children:r}){const i=S(u=>u.navigate),a=de();t=a(t),n=a(n);const o=u=>{u.preventDefault(),i(e)};ae({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return _(\"a\",{href:\"#\",id:n,class:s,onClick:o,children:r})}function yl({name:e,scope:t,className:n,id:r}){const i=de();n=i(n),r=i(r);const a=ve(Pe),o=e.split(\".\"),s=o[0],u=S(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;if(t===\"local\"){const c=`@${s}`;l=c in a.values?a.values[c]:void 0}else l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=o[c];l=l[d]}const h=l==null?\"\":String(l);return n||r?_(\"span\",{id:r,class:n,children:h}):_(G,{children:h})}function mt(e,t,n){const r=S.getState(),i=J(r.variables),a=J(r.temporary),o={...t};Mn(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(`@${s}`,o[s])}function va(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function re(){const e=S.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?va(t):\"\"}function bl({rawArgs:e}){const t=ve(Pe),n=Ie(!1);if(!n.current){n.current=!0;try{mt(e,nt(t.values),t.update)}catch(r){return console.error(`spindle: Error in {set ${e}}${re()}:`,r),null}}return null}function vl({rawArgs:e,className:t,id:n}){const r=de();t=r(t),n=r(n);const[i,a,o]=Ee();try{const s=ye(e,i,a,o),u=s==null?\"\":String(s);return t||n?_(\"span\",{id:n,class:t,children:u}):_(G,{children:u})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{print error${re()}: ${s instanceof Error?s.message:String(s)}}`})}}function xl({branches:e}){const t=de(),[n,r,i]=Ee();function a(o){const s=he(o.children),u=t(o.className),l=t(o.id);return u||l?_(\"span\",{id:l,class:u,children:s}):_(G,{children:s})}for(const o of e){if(o.rawArgs===\"\")return a(o);try{if(ye(o.rawArgs,n,r,i))return a(o)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{if error${re()}: ${s instanceof Error?s.message:String(s)}}`})}}return null}function wl(e){const t=e.indexOf(\" of \");if(t===-1)throw new Error(`{for} requires \"of\" keyword: {for ${e}}`);const n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(\",\").map(s=>s.trim()),a=i[0],o=i.length>1?i[1]:null;if(!a.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(o&&!o.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${o}\"`);return{itemVar:a,indexVar:o,listExpr:r}}function Sl({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=K(()=>({...e,...t,...n})),o=We((u,l)=>{a(h=>({...h,[u]:l}))},[]),s={values:i,update:o};return _(Pe.Provider,{value:s,children:he(r)})}function kl({rawArgs:e,children:t,className:n,id:r}){const i=de();n=i(n),r=i(r);const a=ve(Pe),[o,s,u]=Ee();let l;try{l=wl(e)}catch(w){return _(\"span\",{class:\"error\",title:String(w),children:`{for error${re()}: ${w instanceof Error?w.message:String(w)}}`})}const{itemVar:h,indexVar:c,listExpr:d}=l;let f;try{const w=ye(d,o,s,u);if(!Array.isArray(w))return _(\"span\",{class:\"error\",children:`{for error${re()}: expression did not evaluate to an array}`});f=w}catch(w){return _(\"span\",{class:\"error\",title:String(w),children:`{for error${re()}: ${w instanceof Error?w.message:String(w)}}`})}const g=f.map((w,I)=>{const b={[h]:w,...c?{[c]:I}:void 0};return _(Sl,{parentValues:a.values,ownKeys:b,initialValues:{},children:t},I)});return n||r?_(\"span\",{id:r,class:n,children:g}):_(G,{children:g})}function Cl(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Il({children:e}){const t=Cl(e),n=ve(Pe);return be(()=>{try{mt(t,nt(n.values),n.update)}catch(r){console.error(`spindle: Error in {do}${re()}:`,r)}},[]),null}function xa(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function Al({rawArgs:e,children:t,className:n,id:r}){const i=de();n=i(n),r=i(r);const a=ve(Pe),o=()=>{try{mt(e,nt(a.values),a.update)}catch(u){console.error(`spindle: Error in {button ${e}}${re()}:`,u)}};ae({type:\"button\",key:e,authorId:r,label:xa(t)||e,perform:o});const s=n?`macro-button ${n}`:\"macro-button\";return _(\"button\",{id:r,class:s,onClick:o,children:Ma(t)})}function El({className:e,id:t}){const n=S(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return _(\"span\",{id:t,class:r,children:n})}function Pl({className:e,id:t}){const n=S(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return ae({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),_(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}function $l({className:e,id:t}){const n=S(a=>a.goBack),r=S(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function Tl({className:e,id:t}){const n=S(a=>a.goForward),r=S(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function Dl({className:e,id:t}){const n=S(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return ae({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),_(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function Nl({className:e,id:t}){const n=S(s=>s.load),r=S(s=>s.hasSave);S(s=>s.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r(),o=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return ae({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:a,perform:()=>n()}),_(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:o,children:\"QuickLoad\"})}const st=new Map;let ne={},oi=!1;function wa(){return`spindle.${S.getState().storyData?.ifid||\"unknown\"}.settings`}function Fl(){localStorage.setItem(wa(),JSON.stringify(ne))}function yn(){if(!oi){oi=!0;try{const e=localStorage.getItem(wa());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ne={...ne,...t})}}catch{}}}const gt={addToggle(e,t){st.set(e,{type:\"toggle\",config:t}),e in ne||(ne[e]=t.default),yn()},addList(e,t){st.set(e,{type:\"list\",config:t}),e in ne||(ne[e]=t.default),yn()},addRange(e,t){st.set(e,{type:\"range\",config:t}),e in ne||(ne[e]=t.default),yn()},get(e){return ne[e]},getToggle(e){const t=ne[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ne[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ne[e];return typeof t==\"number\"?t:0},set(e,t){ne[e]=t,Fl()},getAll(){return{...ne}},getDefinitions(){return st},hasAny(){return st.size>0}};function zl({name:e,def:t}){const[n,r]=K(()=>gt.get(e)),i=a=>{r(a),gt.set(e,a)};switch(t.type){case\"toggle\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>_(\"option\",{value:a,children:a},a))})]});case\"range\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:[t.config.label,\": \",String(n)]}),_(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function Ol({onClose:e}){const t=gt.getDefinitions();return _(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:_(\"div\",{class:\"settings-panel\",children:[_(\"div\",{class:\"settings-header\",children:[_(\"span\",{children:\"Settings\"}),_(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>_(zl,{name:r,def:i},r))})]})})}function Rl({className:e,id:t}){const[n,r]=K(!1);if(!gt.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return _(G,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&_(Ol,{onClose:()=>r(!1)})]})}function Ll(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Ml(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function Bl(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Vl({onClose:e}){const[t,n]=K(\"load\"),[r,i]=K([]),[a,o]=K(!0),[s,u]=K(null),[l,h]=K(()=>new Set),[c,d]=K(null),[f,g]=K(\"\"),w=Ie(null),I=Ie(null),b=S(A=>A.storyData),x=S(A=>A.playthroughId),k=S(A=>A.getSavePayload),N=S(A=>A.loadFromPayload),E=b?.ifid??\"\",v=We(async()=>{if(!E)return;const A=await rl(E);i(A),o(!1)},[E]);Ae(()=>{v()},[v]),Ae(()=>{c&&w.current&&(w.current.focus(),w.current.select())},[c]);const z=Ie(),F=(A,p=\"success\")=>{clearTimeout(z.current),u({text:A,type:p}),z.current=window.setTimeout(()=>u(null),3e3)},M=A=>{h(p=>{const q=new Set(p);return q.has(A)?q.delete(A):q.add(A),q})},y=async()=>{if(!(!E||!x))try{const A=k();await pa(E,x,A),F(\"Save created\"),await v()}catch{F(\"Failed to create save\",\"error\")}},P=async A=>{try{const p=k();await ma(A,p),F(\"Save overwritten\"),await v()}catch{F(\"Failed to overwrite save\",\"error\")}},$=async A=>{try{N(A.payload),F(\"Game loaded\"),setTimeout(e,500)}catch{F(\"Failed to load save\",\"error\")}},V=async A=>{if(confirm(\"Delete this save?\"))try{await tl(A),F(\"Save deleted\"),await v()}catch{F(\"Failed to delete save\",\"error\")}},H=A=>{d(A.meta.id),g(A.meta.title)},R=async()=>{if(!(!c||!f.trim()))try{await nl(c,f.trim()),d(null),F(\"Save renamed\"),await v()}catch{F(\"Failed to rename\",\"error\")}},Z=A=>{A.key===\"Enter\"?R():A.key===\"Escape\"&&d(null)},Y=async A=>{try{const p=await ol(A);if(!p)return;const q=new Blob([JSON.stringify(p,null,2)],{type:\"application/json\"}),j=URL.createObjectURL(q),U=document.createElement(\"a\");U.href=j,U.download=`save-${p.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,U.click(),URL.revokeObjectURL(j),F(\"Save exported\")}catch{F(\"Failed to export save\",\"error\")}},se=()=>{I.current?.click()},pe=async A=>{const p=A.target,q=p.files?.[0];if(q){p.value=\"\";try{const j=await q.text(),U=JSON.parse(j);if(!Ll(U))throw new Error(\"Invalid save file format\");await sl(U,E),F(\"Save imported\"),await v()}catch(j){F(j instanceof Error?j.message:\"Failed to import save\",\"error\")}}},m=A=>{A.target.classList.contains(\"saves-overlay\")&&e()},le=r.reduce((A,p)=>A+p.saves.length,0);return _(\"div\",{class:\"saves-overlay\",onClick:m,children:_(\"div\",{class:\"saves-panel\",children:[_(\"div\",{class:\"saves-header\",children:[_(\"div\",{class:\"saves-header-left\",children:_(\"div\",{class:\"saves-mode-toggle\",children:[_(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),_(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),_(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"saves-toolbar\",children:[_(\"button\",{class:\"saves-toolbar-button\",onClick:se,children:\"Import\"}),_(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:pe})]}),_(\"div\",{class:\"saves-body\",children:[a?_(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):le===0&&t===\"load\"?_(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(A=>{const p=l.has(A.playthrough.id),q=A.playthrough.id===x;return t===\"save\"&&!q||t===\"load\"&&A.saves.length===0&&!q?null:_(\"div\",{class:\"playthrough-group\",children:[_(\"div\",{class:\"playthrough-header\",onClick:()=>M(A.playthrough.id),children:[_(\"span\",{class:`playthrough-chevron ${p?\"\":\"open\"}`,children:\"▶\"}),_(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,q?\" (current)\":\"\"]}),_(\"span\",{class:\"playthrough-date\",children:Bl(A.playthrough.createdAt)})]}),!p&&_(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(j=>_(\"div\",{class:\"save-slot\",children:[_(\"div\",{class:\"save-slot-info\",children:[c===j.meta.id?_(\"input\",{ref:w,class:\"save-rename-input\",value:f,onInput:U=>g(U.target.value),onKeyDown:Z,onBlur:R}):_(\"div\",{class:\"save-slot-title\",children:j.meta.title}),_(\"div\",{class:\"save-slot-meta\",children:[_(\"span\",{children:j.meta.passage}),_(\"span\",{children:Ml(j.meta.updatedAt)})]})]}),_(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?_(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(j.meta.id),children:\"Save Here\"}):_(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(j),children:\"Load\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>H(j),children:\"Rename\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>Y(j.meta.id),children:\"Export\"}),_(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(j.meta.id),children:\"Delete\"})]})]},j.meta.id)),t===\"save\"&&q&&_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})]})]},A.playthrough.id)}),t===\"save\"&&!a&&!r.some(A=>A.playthrough.id===x)&&_(\"div\",{class:\"playthrough-group\",children:_(\"div\",{class:\"playthrough-saves\",children:_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})})})]}),s&&_(\"div\",{class:`saves-status ${s.type===\"error\"?\"error\":\"\"}`,children:s.text})]})})}function Hl({className:e,id:t}){const[n,r]=K(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return _(G,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&_(Vl,{onClose:()=>r(!1)})]})}function ql({rawArgs:e,className:t,id:n}){const r=de();t=r(t),n=r(n);const i=S(f=>f.storyData),[a,o,s]=Ee();if(!i)return null;let u;try{const f=ye(e,a,o,s);u=String(f)}catch{u=e.replace(/^[\"']|[\"']$/g,\"\")}const l=i.passages.get(u);if(l&&S.getState().trackRender(u),!l)return _(\"span\",{class:\"error\",children:`{include${re()}: passage \"${u}\" not found}`});const h=xt(l.content),c=wt(h),d=he(c);return t||n?_(\"span\",{id:n,class:t,children:d}):_(G,{children:d})}function Ul({rawArgs:e}){const[t,n,r]=Ee();return be(()=>{let i;try{const a=ye(e,t,n,r);i=String(a)}catch{i=e.replace(/^[\"']|[\"']$/g,\"\")}S.getState().navigate(i)},[]),null}function jl({rawArgs:e}){const t=Ie(!1);if(!t.current){t.current=!0;const n=S.getState(),r=e.trim();r.startsWith(\"$\")?n.deleteVariable(r.slice(1)):r.startsWith(\"_\")?n.deleteTemporary(r.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${r}\"`)}return null}function Wl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Ql({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Wl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"textbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:o,perform:l=>s(a,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return _(\"input\",{type:\"text\",id:n,class:u,value:o==null?\"\":String(o),placeholder:i,onInput:l=>s(a,l.target.value)})}function Gl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Kl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Gl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"numberbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:o,perform:l=>s(a,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return _(\"input\",{type:\"number\",id:n,class:u,value:o==null?\"\":String(o),placeholder:i,onInput:l=>{const h=l.target.value;s(a,h===\"\"?0:Number(h))}})}function Yl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function Zl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Yl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"textarea\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:o,perform:l=>s(a,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return _(\"textarea\",{id:n,class:u,value:o==null?\"\":String(o),placeholder:i,onInput:l=>s(a,l.target.value)})}function Jl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}function Xl({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=Jl(e),a=r.startsWith(\"$\")?r.slice(1):r,o=S(l=>l.variables[a]),s=S(l=>l.setVariable);ae({type:\"checkbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:!!o,perform:l=>s(a,l!==void 0?!!l:!o)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return _(\"label\",{id:n,class:u,children:[_(\"input\",{type:\"checkbox\",checked:!!o,onChange:()=>s(a,!o)}),i?` ${i}`:null]})}function eu(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}function tu({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=eu(e),o=r.startsWith(\"$\")?r.slice(1):r,s=S(h=>h.variables[o]),u=S(h=>h.setVariable);ae({type:\"radiobutton\",key:`$${o}:${i}`,authorId:n,label:a||i,variable:o,value:s,perform:()=>u(o,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return _(\"label\",{id:n,class:l,children:[_(\"input\",{type:\"radio\",name:`radio-${o}`,checked:s===i,onChange:()=>u(o,i)}),a?` ${a}`:null]})}function Sa(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function nu({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,o=S(h=>h.variables[a]),s=S(h=>h.setVariable),u=Sa(t);ae({type:\"listbox\",key:`$${a}`,authorId:r,label:a,variable:a,options:u,value:o,perform:h=>{h!==void 0&&s(a,String(h))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return _(\"select\",{id:r,class:l,value:o==null?\"\":String(o),onChange:h=>s(a,h.target.value),children:u.map(h=>_(\"option\",{value:h,children:h},h))})}function ru({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,o=S(c=>c.variables[a]),s=S(c=>c.setVariable),u=Sa(t),l=()=>{if(u.length===0)return;const d=(u.indexOf(String(o))+1)%u.length;s(a,u[d])};ae({type:\"cycle\",key:`$${a}`,authorId:r,label:o==null?u[0]||\"\":String(o),variable:a,options:u,value:o,perform:c=>{c!==void 0?s(a,c):l()}});const h=n?`macro-cycle ${n}`:\"macro-cycle\";return _(\"button\",{id:r,class:h,onClick:l,children:o==null?u[0]||\"\":String(o)})}function iu(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function si(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")try{mt(r.rawArgs,t,n)}catch(i){console.error(`spindle: Error in {link} child {set}${re()}:`,i)}else if(r.name===\"do\"){const i=xa(r.children);try{mt(i,t,n)}catch(a){console.error(`spindle: Error in {link} child {do}${re()}:`,a)}}}}function au({rawArgs:e,children:t,className:n,id:r}){const i=de();n=i(n),r=i(r);const{display:a,passage:o}=iu(e),s=ve(Pe),u=h=>{h.preventDefault(),si(t,nt(s.values),s.update),o&&S.getState().navigate(o)};ae({type:\"link\",key:o||a,authorId:r,label:a,target:o??void 0,perform:()=>{si(t,nt(s.values),s.update),o&&S.getState().navigate(o)}});const l=n?`macro-link ${n}`:\"macro-link\";return _(\"a\",{id:r,class:l,href:\"#\",onClick:u,children:a})}function ou({rawArgs:e,branches:t}){const[n,r,i]=Ee();let a;try{a=ye(e,n,r,i)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{switch error${re()}: ${s instanceof Error?s.message:String(s)}}`})}let o=null;for(let s=1;s<t.length;s++){const u=t[s];if(u.rawArgs===\"\"){o=u;continue}try{const l=ye(u.rawArgs,n,r,i);if(a===l)return _(G,{children:he(u.children)})}catch(l){return _(\"span\",{class:\"error\",title:String(l),children:`{case error${re()}: ${l instanceof Error?l.message:String(l)}}`})}}return o?_(G,{children:he(o.children)}):null}function Yt(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function su({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=de();r=a(r),i=a(i);const o=Re(()=>{const h=[];h.push({delay:Yt(e),nodes:t});for(const c of n){const d=c.rawArgs?Yt(c.rawArgs):0;h.push({delay:d,nodes:c.children})}return h},[e,t,n]),[s,u]=K(-1);if(Ae(()=>{if(s>=o.length-1)return;const h=s+1,c=o[h].delay,d=setTimeout(()=>{u(h)},c);return()=>clearTimeout(d)},[s,o]),s<0)return null;const l=he(o[s].nodes);return r||i?_(\"span\",{id:i,class:r,children:l}):_(G,{children:l})}const ka=tr({stop:()=>{}});function lu({rawArgs:e,children:t,className:n,id:r}){const[i,a]=Re(()=>{const g=w=>{if(!w||!ya(w))return w;const I=S.getState();return ba(w,I.variables,I.temporary,{})};return[g(n),g(r)]},[n,r]),o=Yt(e),[s,u]=K(0),[l,h]=K(!1),c=We(()=>h(!0),[]);if(Ae(()=>{if(l)return;const g=setInterval(()=>{u(w=>w+1)},o);return()=>clearInterval(g)},[o,l]),s===0&&!l)return null;const d=i?`macro-repeat ${i}`:void 0,f=_(ka.Provider,{value:{stop:c},children:_(\"span\",{children:he(t)},s)});return d||a?_(\"span\",{id:a,class:d,children:f}):f}function uu(){const{stop:e}=ve(ka);return be(()=>{e()},[e]),null}function cu({rawArgs:e,children:t,className:n,id:r}){const i=de();n=i(n),r=i(r);const a=Yt(e),o=Ie(null),[s,u]=K(0),[l,h]=K(0);Ae(()=>{if(o.current){const f=o.current.textContent||\"\";u(f.length)}},[]),Ae(()=>{if(s===0||l>=s)return;const f=setInterval(()=>{h(g=>g>=s?(clearInterval(f),g):g+1)},a);return()=>clearInterval(f)},[s,a]);const c=l>=s&&s>0,d=[\"macro-type\",c?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return _(\"span\",{id:r,class:d,ref:o,style:{clipPath:(s>0&&!c,void 0)},children:[_(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!c?`inset(0 ${(s-l)/s*100}% 0 0)`:void 0},children:Ma(t)}),!c&&s>0&&_(\"span\",{class:\"macro-type-cursor\"})]})}const Ca=new Map;function Ia(e,t,n){Ca.set(e.toLowerCase(),{body:t,params:n})}function fu(e){return Ca.get(e.toLowerCase())}function hu(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}function du({rawArgs:e,children:t}){const{name:n,params:r}=hu(e);return be(()=>{Ia(n,t,r)},[]),null}function pu(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function mu({body:e,parentValues:t,ownKeys:n}){const[r,i]=K(()=>({...t,...n})),a=We((s,u)=>{i(l=>({...l,[s]:u}))},[]),o={values:r,update:a};return _(Pe.Provider,{value:o,children:he(e)})}function gu({body:e,params:t,rawArgs:n}){const r=ve(Pe),[i,a,o]=Ee();if(t.length===0||!n)return _(G,{children:he(e)});const s=pu(n),u={};for(let l=0;l<t.length;l++){const h=t[l],c=s[l];let d;if(c!==void 0)try{d=ye(c,i,a,o)}catch{d=void 0}u[h]=d}return _(mu,{body:e,parentValues:r.values,ownKeys:u})}function _u(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function yu(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function li(e,t,n,r,i,a,o){const s=S.getState();let u;try{u=ye(e,r,i,a)}catch(h){console.error(`spindle: Error in {computed ${o}}${re()}:`,h);return}const l=n?s.temporary[t]:s.variables[t];yu(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}function bu({rawArgs:e}){const[t,n,r]=Ee();let i,a;try{({target:i,expr:a}=_u(e))}catch(l){return _(\"span\",{class:\"error\",title:String(l),children:`{computed error${re()}: ${l instanceof Error?l.message:String(l)}}`})}const o=i.startsWith(\"_\"),s=i.slice(1),u=Ie(!1);if(!u.current){u.current=!0;const l=S.getState();li(a,s,o,l.variables,l.temporary,r,e)}return be(()=>{li(a,s,o,t,n,r,e)},[t,n,r]),null}function vu(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const a=xu(r);if(a.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:a[0],maxExpr:a.slice(1).join(\" \"),labelMode:n}}function xu(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const a=e[i];if(a===\"(\"||a===\"[\")r++,n+=a;else if(a===\")\"||a===\"]\")r--,n+=a;else if(/\\s/.test(a)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=a}return n.length>0&&t.push(n),t}function wu(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function Su({rawArgs:e,className:t,id:n}){const r=de();t=r(t),n=r(n);const[i,a,o]=Ee();try{const{currentExpr:s,maxExpr:u,labelMode:l}=vu(e),h=Number(ye(s,i,a,o)),c=Number(ye(u,i,a,o)),d=c===0?0:Math.max(0,Math.min(100,h/c*100)),f=wu(h,c,l),g=[\"macro-meter\",t].filter(Boolean).join(\" \");return _(\"div\",{class:g,id:n,children:[_(\"div\",{class:\"macro-meter-fill\",style:`width: ${d}%`}),f!=null&&_(\"span\",{class:\"macro-meter-label\",children:f})]})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{meter error: ${s instanceof Error?s.message:String(s)}}`})}}function ku({passage:e}){const t=Re(()=>{try{const n=xt(e.content),r=wt(n);return he(r)}catch(n){return _(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",va(e),\": \",n.message]})}},[e.content,e.name]);return _(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}function Cu({className:e,id:t}){const n=de();e=n(e),t=n(t);const r=S(o=>o.currentPassage),a=S(o=>o.storyData)?.passages.get(r);return a?_(\"div\",{id:t??\"story\",class:e??\"story\",children:_(ku,{passage:a},r)}):_(\"div\",{class:\"error\",children:[\"Error: Passage “\",r,\"” not found.\"]})}const Iu=new Map;function Au(e){return Iu.get(e.toLowerCase())}const ui=document.createElement(\"i\");function Aa(e){const t=\"&\"+e+\";\";ui.innerHTML=t;const n=ui.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function fe(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ee(e,t){return e.length>0?(fe(e,e.length,0,t),e):t}const Wn={}.hasOwnProperty;function Eu(e){const t={};let n=-1;for(;++n<e.length;)Pu(t,e[n]);return t}function Pu(e,t){let n;for(n in t){const i=(Wn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){Wn.call(i,o)||(i[o]=[]);const s=a[o];$u(i[o],Array.isArray(s)?s:s?[s]:[])}}}function $u(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);fe(e,0,0,r)}function Tu(e){const t={};let n=-1;for(;++n<e.length;)Du(t,e[n]);return t}function Du(e,t){let n;for(n in t){const i=(Wn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function Nu(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const Fu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ea(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Fu[n]+\";\"}}function _t(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Se=Ve(/[A-Za-z]/),ce=Ve(/[\\dA-Za-z]/),zu=Ve(/[#-'*+\\--9=?A-Z^-~]/);function Qn(e){return e!==null&&(e<32||e===127)}const Gn=Ve(/\\d/),Ou=Ve(/[\\dA-Fa-f]/),Ru=Ve(/[!-/:-@[-`{-~]/);function D(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Lu=Ve(/\\p{P}|\\p{S}/u),Mu=Ve(/\\s/);function Ve(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Pt(e,t){const n=Ea(Bu(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),o=n.indexOf(\"/\");return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Bu(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&ce(e.charCodeAt(n+1))&&ce(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o=\"�\"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const ci={}.hasOwnProperty,fi=/^(https?|ircs?|mailto|xmpp)$/i,Vu=/^https?$/i;function Hu(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Tu([{enter:{blockQuote:R,codeFenced:pe,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:A,codeText:oo,content:Ga,definition:Ha,definitionDestinationString:Ua,definitionLabelString:I,definitionTitleString:I,emphasis:io,htmlFlow:ro,htmlText:gr,image:q,label:I,link:j,listItemMarker:P,listItemValue:y,listOrdered:F,listUnordered:M,paragraph:Y,reference:I,resource:Qe,resourceDestinationString:Ge,resourceTitleString:I,setextHeading:Ya,strong:ao},exit:{atxHeading:Ja,atxHeadingSequence:Ka,autolinkEmail:po,autolinkProtocol:ho,blockQuote:Z,characterEscapeValue:ot,characterReferenceMarkerHexadecimal:_r,characterReferenceMarkerNumeric:_r,characterReferenceValue:fo,codeFenced:p,codeFencedFence:le,codeFencedFenceInfo:m,codeFencedFenceMeta:z,codeFlowValue:no,codeIndented:p,codeText:so,codeTextData:ot,data:ot,definition:Qa,definitionDestinationString:ja,definitionLabelString:qa,definitionTitleString:Wa,emphasis:lo,hardBreakEscape:pr,hardBreakTrailing:pr,htmlFlow:mr,htmlFlowData:ot,htmlText:mr,htmlTextData:ot,image:dr,label:at,labelText:U,lineEnding:to,link:dr,listOrdered:$,listUnordered:V,paragraph:se,reference:z,referenceString:Fe,resource:z,resourceDestinationString:hn,resourceTitleString:Va,setextHeading:eo,setextHeadingLineSequence:Xa,setextHeadingText:Za,strong:uo,thematicBreak:co}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},h={buffer:I,encode:v,getData:w,lineEndingIfNeeded:E,options:t,raw:k,resume:b,setData:g,tag:x};let c=t.defaultLineEnding;return d;function d(C){let T=-1,X=0;const me=[];let xe=[],$e=[];for(;++T<C.length;)!c&&(C[T][1].type===\"lineEnding\"||C[T][1].type===\"lineEndingBlank\")&&(c=C[T][2].sliceSerialize(C[T][1])),(C[T][1].type===\"listOrdered\"||C[T][1].type===\"listUnordered\")&&(C[T][0]===\"enter\"?me.push(T):f(C.slice(me.pop(),T))),C[T][1].type===\"definition\"&&(C[T][0]===\"enter\"?($e=ee($e,C.slice(X,T)),X=T):(xe=ee(xe,C.slice(X,T+1)),X=T+1));xe=ee(xe,$e),xe=ee(xe,C.slice(X)),T=-1;const we=xe;for(u.enter.null&&u.enter.null.call(h);++T<C.length;){const yr=u[we[T][0]],br=we[T][1].type,vr=yr[br];ci.call(yr,br)&&vr&&vr.call({sliceSerialize:we[T][2].sliceSerialize,...h},we[T][1])}return u.exit.null&&u.exit.null.call(h),i[0].join(\"\")}function f(C){const T=C.length;let X=0,me=0,xe=!1,$e;for(;++X<T;){const we=C[X];if(we[1]._container)$e=void 0,we[0]===\"enter\"?me++:me--;else switch(we[1].type){case\"listItemPrefix\":{we[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{we[0]===\"enter\"&&!me&&($e?$e=void 0:xe=!0);break}default:$e=void 0}}C[0][1]._loose=xe}function g(C,T){l[C]=T}function w(C){return l[C]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function x(C){n&&(g(\"lastWasTag\",!0),i[i.length-1].push(C))}function k(C){g(\"lastWasTag\"),i[i.length-1].push(C)}function N(){k(c||`\n`)}function E(){const C=i[i.length-1],T=C[C.length-1],X=T?T.charCodeAt(T.length-1):null;X===10||X===13||X===null||N()}function v(C){return w(\"ignoreEncode\")?C:Ea(C)}function z(){b()}function F(C){o.push(!C._loose),E(),x(\"<ol\"),g(\"expectFirstItem\",!0)}function M(C){o.push(!C._loose),E(),x(\"<ul\"),g(\"expectFirstItem\",!0)}function y(C){if(w(\"expectFirstItem\")){const T=Number.parseInt(this.sliceSerialize(C),10);T!==1&&x(' start=\"'+v(String(T))+'\"')}}function P(){w(\"expectFirstItem\")?x(\">\"):H(),E(),x(\"<li>\"),g(\"expectFirstItem\"),g(\"lastWasTag\")}function $(){H(),o.pop(),N(),x(\"</ol>\")}function V(){H(),o.pop(),N(),x(\"</ul>\")}function H(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&E(),x(\"</li>\"),g(\"slurpAllLineEndings\")}function R(){o.push(!1),E(),x(\"<blockquote>\")}function Z(){o.pop(),E(),x(\"</blockquote>\"),g(\"slurpAllLineEndings\")}function Y(){o[o.length-1]||(E(),x(\"<p>\")),g(\"slurpAllLineEndings\")}function se(){o[o.length-1]?g(\"slurpAllLineEndings\",!0):x(\"</p>\")}function pe(){E(),x(\"<pre><code\"),g(\"fencesCount\",0)}function m(){const C=b();x(' class=\"language-'+C+'\"')}function le(){const C=w(\"fencesCount\")||0;C||(x(\">\"),g(\"slurpOneLineEnding\",!0)),g(\"fencesCount\",C+1)}function A(){E(),x(\"<pre><code>\")}function p(){const C=w(\"fencesCount\");C!==void 0&&C<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&N(),w(\"flowCodeSeenData\")&&E(),x(\"</code></pre>\"),C!==void 0&&C<2&&E(),g(\"flowCodeSeenData\"),g(\"fencesCount\"),g(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function j(){a.push({})}function U(C){a[a.length-1].labelId=this.sliceSerialize(C)}function at(){a[a.length-1].label=b()}function Fe(C){a[a.length-1].referenceId=this.sliceSerialize(C)}function Qe(){I(),a[a.length-1].destination=\"\"}function Ge(){I(),g(\"ignoreEncode\",!0)}function hn(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function Va(){a[a.length-1].title=b()}function dr(){let C=a.length-1;const T=a[C],X=T.referenceId||T.labelId,me=T.destination===void 0?r[_t(X)]:T;for(n=!0;C--;)if(a[C].image){n=void 0;break}T.image?(x('<img src=\"'+Pt(me.destination,t.allowDangerousProtocol?void 0:Vu)+'\" alt=\"'),k(T.label),x('\"')):x('<a href=\"'+Pt(me.destination,t.allowDangerousProtocol?void 0:fi)+'\"'),x(me.title?' title=\"'+me.title+'\"':\"\"),T.image?x(\" />\"):(x(\">\"),k(T.label),x(\"</a>\")),a.pop()}function Ha(){I(),a.push({})}function qa(C){b(),a[a.length-1].labelId=this.sliceSerialize(C)}function Ua(){I(),g(\"ignoreEncode\",!0)}function ja(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function Wa(){a[a.length-1].title=b()}function Qa(){const C=a[a.length-1],T=_t(C.labelId);b(),ci.call(r,T)||(r[T]=a[a.length-1]),a.pop()}function Ga(){g(\"slurpAllLineEndings\",!0)}function Ka(C){w(\"headingRank\")||(g(\"headingRank\",this.sliceSerialize(C).length),E(),x(\"<h\"+w(\"headingRank\")+\">\"))}function Ya(){I(),g(\"slurpAllLineEndings\")}function Za(){g(\"slurpAllLineEndings\",!0)}function Ja(){x(\"</h\"+w(\"headingRank\")+\">\"),g(\"headingRank\")}function Xa(C){g(\"headingRank\",this.sliceSerialize(C).charCodeAt(0)===61?1:2)}function eo(){const C=b();E(),x(\"<h\"+w(\"headingRank\")+\">\"),k(C),x(\"</h\"+w(\"headingRank\")+\">\"),g(\"slurpAllLineEndings\"),g(\"headingRank\")}function ot(C){k(v(this.sliceSerialize(C)))}function to(C){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){g(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){k(\" \");return}k(v(this.sliceSerialize(C)))}}function no(C){k(v(this.sliceSerialize(C))),g(\"flowCodeSeenData\",!0)}function pr(){x(\"<br />\")}function ro(){E(),gr()}function mr(){g(\"ignoreEncode\")}function gr(){t.allowDangerousHtml&&g(\"ignoreEncode\",!0)}function io(){x(\"<em>\")}function ao(){x(\"<strong>\")}function oo(){g(\"inCodeText\",!0),x(\"<code>\")}function so(){g(\"inCodeText\"),x(\"</code>\")}function lo(){x(\"</em>\")}function uo(){x(\"</strong>\")}function co(){E(),x(\"<hr />\")}function _r(C){g(\"characterReferenceType\",C.type)}function fo(C){const T=this.sliceSerialize(C),X=w(\"characterReferenceType\")?Nu(T,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Aa(T);k(v(X)),g(\"characterReferenceType\")}function ho(C){const T=this.sliceSerialize(C);x('<a href=\"'+Pt(T,t.allowDangerousProtocol?void 0:fi)+'\">'),k(v(T)),x(\"</a>\")}function po(C){const T=this.sliceSerialize(C);x('<a href=\"'+Pt(\"mailto:\"+T)+'\">'),k(v(T)),x(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const qu={tokenize:Uu};function Uu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return D(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const ju={tokenize:Wu},hi={tokenize:Qu};function Wu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(k){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,u,l)(k)}return l(k)}function u(k){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const N=t.events.length;let E=N,v;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){v=t.events[E][1].end;break}b(r);let z=N;for(;z<t.events.length;)t.events[z][1].end={...v},z++;return fe(t.events,E+1,0,t.events.slice(N)),t.events.length=z,l(k)}return s(k)}function l(k){if(r===n.length){if(!i)return d(k);if(i.currentConstruct&&i.currentConstruct.concrete)return g(k);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(hi,h,c)(k)}function h(k){return i&&x(),b(r),d(k)}function c(k){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(k)}function d(k){return t.containerState={},e.attempt(hi,f,g)(k)}function f(k){return r++,n.push([t.currentConstruct,t.containerState]),d(k)}function g(k){if(k===null){i&&x(),b(0),e.consume(k);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(k)}function w(k){if(k===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(k);return}return D(k)?(e.consume(k),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(k),w)}function I(k,N){const E=t.sliceStream(k);if(N&&E.push(null),k.previous=a,a&&(a.next=k),a=k,i.defineSkip(k.start),i.write(E),t.parser.lazy[k.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<o&&(!i.events[v][1].end||i.events[v][1].end.offset>o))return;const z=t.events.length;let F=z,M,y;for(;F--;)if(t.events[F][0]===\"exit\"&&t.events[F][1].type===\"chunkFlow\"){if(M){y=t.events[F][1].end;break}M=!0}for(b(r),v=z;v<t.events.length;)t.events[v][1].end={...y},v++;fe(t.events,F+1,0,t.events.slice(z)),t.events.length=v}}function b(k){let N=n.length;for(;N-- >k;){const E=n[N];t.containerState=E[1],E[0].exit.call(t,e)}n.length=k}function x(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Qu(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Zt(e){if(e===null||te(e)||Mu(e))return 1;if(Lu(e))return 2}function cn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Kn={name:\"attention\",resolveAll:Gu,tokenize:Ku};function Gu(e,t){let n=-1,r,i,a,o,s,u,l,h;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};di(c,-u),di(d,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ee(l,cn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,l=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):h=0,fe(e,r-1,n-r+3,l),n=r+l.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Ku(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Zt(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),h=Zt(u),c=!h||h===2&&i||n.includes(u),d=!i||i===2&&h||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(h||!c)),t(u)}}function di(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Yu={name:\"autolink\",tokenize:Zu};function Zu(e,t,n){let r=0;return i;function i(f){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(f){return Se(f)?(e.consume(f),o):f===64?n(f):l(f)}function o(f){return f===43||f===45||f===46||ce(f)?(r=1,s(f)):l(f)}function s(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||ce(f))&&r++<32?(e.consume(f),s):(r=0,l(f))}function u(f){return f===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):f===null||f===32||f===60||Qn(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),h):zu(f)?(e.consume(f),l):n(f)}function h(f){return ce(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(f)}function d(f){if((f===45||ce(f))&&r++<63){const g=f===45?d:c;return e.consume(f),g}return n(f)}}const fn={partial:!0,tokenize:Ju};function Ju(e,t,n){return r;function r(a){return L(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||D(a)?t(a):n(a)}}const Pa={continuation:{tokenize:ec},exit:tc,name:\"blockQuote\",tokenize:Xu};function Xu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function ec(e,t,n){const r=this;return i;function i(o){return L(o)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Pa,t,n)(o)}}function tc(e){e.exit(\"blockQuote\")}const $a={name:\"characterEscape\",tokenize:nc};function nc(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return Ru(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Ta={name:\"characterReference\",tokenize:rc};function rc(e,t,n){const r=this;let i=0,a,o;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=ce,h(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=Ou,h):(e.enter(\"characterReferenceValue\"),a=7,o=Gn,h(c))}function h(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return o===ce&&!Aa(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),h):n(c)}}const pi={partial:!0,tokenize:ac},mi={concrete:!0,name:\"codeFenced\",tokenize:ic};function ic(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,o=0,s;return u;function u(v){return l(v)}function l(v){const z=r.events[r.events.length-1];return a=z&&z[1].type===\"linePrefix\"?z[2].sliceSerialize(z[1],!0).length:0,s=v,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),h(v)}function h(v){return v===s?(o++,e.consume(v),h):o<3?n(v):(e.exit(\"codeFencedFenceSequence\"),L(v)?B(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||D(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(pi,w,N)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(v))}function d(v){return v===null||D(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):L(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,f,\"whitespace\")(v)):v===96&&v===s?n(v):(e.consume(v),d)}function f(v){return v===null||D(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),g(v))}function g(v){return v===null||D(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===s?n(v):(e.consume(v),g)}function w(v){return e.attempt(i,N,I)(v)}function I(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),b}function b(v){return a>0&&L(v)?B(e,x,\"linePrefix\",a+1)(v):x(v)}function x(v){return v===null||D(v)?e.check(pi,w,N)(v):(e.enter(\"codeFlowValue\"),k(v))}function k(v){return v===null||D(v)?(e.exit(\"codeFlowValue\"),x(v)):(e.consume(v),k)}function N(v){return e.exit(\"codeFenced\"),t(v)}function E(v,z,F){let M=0;return y;function y(R){return v.enter(\"lineEnding\"),v.consume(R),v.exit(\"lineEnding\"),P}function P(R){return v.enter(\"codeFencedFence\"),L(R)?B(v,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):$(R)}function $(R){return R===s?(v.enter(\"codeFencedFenceSequence\"),V(R)):F(R)}function V(R){return R===s?(M++,v.consume(R),V):M>=o?(v.exit(\"codeFencedFenceSequence\"),L(R)?B(v,H,\"whitespace\")(R):H(R)):F(R)}function H(R){return R===null||D(R)?(v.exit(\"codeFencedFence\"),z(R)):F(R)}}}function ac(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const bn={name:\"codeIndented\",tokenize:sc},oc={partial:!0,tokenize:lc};function sc(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(e,a,\"linePrefix\",5)(l)}function a(l){const h=r.events[r.events.length-1];return h&&h[1].type===\"linePrefix\"&&h[2].sliceSerialize(h[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):D(l)?e.attempt(oc,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||D(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function lc(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):D(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):D(o)?i(o):n(o)}}const uc={name:\"codeText\",previous:fc,resolve:cc,tokenize:hc};function cc(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function fc(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function hc(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,h(c)):D(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||D(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function h(c){return c===96?(e.consume(c),i++,h):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class dc{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&<(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),lt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),lt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);lt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);lt(this.left,n.reverse())}}}function lt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Da(e){const t={};let n=-1,r,i,a,o,s,u,l;const h=new dc(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type===\"chunkFlow\"&&h.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,pc(h,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=h.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(h.get(i)[1].type=\"lineEndingBlank\"),o[1].type=\"lineEnding\",i=a);else if(!(o[1].type===\"linePrefix\"||o[1].type===\"listItemIndent\"))break;i&&(r[1].end={...h.get(i)[1].start},s=h.slice(i,n),s.unshift(r),h.splice(i,n-i+1,s))}}return fe(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!l}function pc(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let h,c,d=-1,f=n,g=0,w=0;const I=[w];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),c&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(h),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++d<s.length;)s[d][0]===\"exit\"&&s[d-1][0]===\"enter\"&&s[d][1].type===s[d-1][1].type&&s[d][1].start.line!==s[d][1].end.line&&(w=d+1,I.push(w),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):I.pop(),d=I.length;d--;){const b=s.slice(I[d],I[d+1]),x=a.pop();u.push([x,x+b.length-1]),e.splice(x,2,b)}for(u.reverse(),d=-1;++d<u.length;)l[g+u[d][0]]=g+u[d][1],g+=u[d][1]-u[d][0]-1;return l}const mc={resolve:_c,tokenize:yc},gc={partial:!0,tokenize:bc};function _c(e){return Da(e),e}function yc(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):D(s)?e.check(gc,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function bc(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(o){if(o===null||D(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Na(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let h=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),d):b===null||b===32||b===41||Qn(b)?n(b):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(b))}function d(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),f(b))}function f(b){return b===62?(e.exit(\"chunkString\"),e.exit(s),d(b)):b===null||b===60||D(b)?n(b):(e.consume(b),b===92?g:f)}function g(b){return b===60||b===62||b===92?(e.consume(b),f):f(b)}function w(b){return!h&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(b)):h<l&&b===40?(e.consume(b),h++,w):b===41?(e.consume(b),h--,w):b===null||b===32||b===40||Qn(b)?n(b):(e.consume(b),b===92?I:w)}function I(b){return b===40||b===41||b===92?(e.consume(b),w):w(b)}}function Fa(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),h}function h(f){return s>999||f===null||f===91||f===93&&!u||f===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):D(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),h):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||D(f)||s++>999?(e.exit(\"chunkString\"),h(f)):(e.consume(f),u||(u=!L(f)),f===92?d:c)}function d(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function za(e,t,n,r,i,a){let o;return s;function s(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,u):n(d)}function u(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===o?(e.exit(a),u(o)):d===null?n(d):D(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),h(d))}function h(d){return d===o||d===null||D(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:h)}function c(d){return d===o||d===92?(e.consume(d),h):h(d)}}function ft(e,t){let n;return r;function r(i){return D(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const vc={name:\"definition\",tokenize:wc},xc={partial:!0,tokenize:Sc};function wc(e,t,n){const r=this;let i;return a;function a(f){return e.enter(\"definition\"),o(f)}function o(f){return Fa.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function s(f){return i=_t(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter(\"definitionMarker\"),e.consume(f),e.exit(\"definitionMarker\"),u):n(f)}function u(f){return te(f)?ft(e,l)(f):l(f)}function l(f){return Na(e,h,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function h(f){return e.attempt(xc,c,c)(f)}function c(f){return L(f)?B(e,d,\"whitespace\")(f):d(f)}function d(f){return f===null||D(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function Sc(e,t,n){return r;function r(s){return te(s)?ft(e,i)(s):n(s)}function i(s){return za(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?B(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||D(s)?t(s):n(s)}}const kc={name:\"hardBreakEscape\",tokenize:Cc};function Cc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return D(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Ic={name:\"headingAtx\",resolve:Ac,tokenize:Ec};function Ac(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},fe(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Ec(e,t,n){let r=0;return i;function i(h){return e.enter(\"atxHeading\"),a(h)}function a(h){return e.enter(\"atxHeadingSequence\"),o(h)}function o(h){return h===35&&r++<6?(e.consume(h),o):h===null||te(h)?(e.exit(\"atxHeadingSequence\"),s(h)):n(h)}function s(h){return h===35?(e.enter(\"atxHeadingSequence\"),u(h)):h===null||D(h)?(e.exit(\"atxHeading\"),t(h)):L(h)?B(e,s,\"whitespace\")(h):(e.enter(\"atxHeadingText\"),l(h))}function u(h){return h===35?(e.consume(h),u):(e.exit(\"atxHeadingSequence\"),s(h))}function l(h){return h===null||h===35||te(h)?(e.exit(\"atxHeadingText\"),s(h)):(e.consume(h),l)}}const Pc=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],gi=[\"pre\",\"script\",\"style\",\"textarea\"],$c={concrete:!0,name:\"htmlFlow\",resolveTo:Nc,tokenize:Fc},Tc={partial:!0,tokenize:Oc},Dc={partial:!0,tokenize:zc};function Nc(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Fc(e,t,n){const r=this;let i,a,o,s,u;return l;function l(p){return h(p)}function h(p){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(p),c}function c(p){return p===33?(e.consume(p),d):p===47?(e.consume(p),a=!0,w):p===63?(e.consume(p),i=3,r.interrupt?t:m):Se(p)?(e.consume(p),o=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,f):p===91?(e.consume(p),i=5,s=0,g):Se(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function f(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function g(p){const q=\"CDATA[\";return p===q.charCodeAt(s++)?(e.consume(p),s===q.length?r.interrupt?t:$:g):n(p)}function w(p){return Se(p)?(e.consume(p),o=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||te(p)){const q=p===47,j=o.toLowerCase();return!q&&!a&&gi.includes(j)?(i=1,r.interrupt?t(p):$(p)):Pc.includes(o.toLowerCase())?(i=6,q?(e.consume(p),b):r.interrupt?t(p):$(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):a?x(p):k(p))}return p===45||ce(p)?(e.consume(p),o+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:$):n(p)}function x(p){return L(p)?(e.consume(p),x):y(p)}function k(p){return p===47?(e.consume(p),y):p===58||p===95||Se(p)?(e.consume(p),N):L(p)?(e.consume(p),k):y(p)}function N(p){return p===45||p===46||p===58||p===95||ce(p)?(e.consume(p),N):E(p)}function E(p){return p===61?(e.consume(p),v):L(p)?(e.consume(p),E):k(p)}function v(p){return p===null||p===60||p===61||p===62||p===96?n(p):p===34||p===39?(e.consume(p),u=p,z):L(p)?(e.consume(p),v):F(p)}function z(p){return p===u?(e.consume(p),u=null,M):p===null||D(p)?n(p):(e.consume(p),z)}function F(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||te(p)?E(p):(e.consume(p),F)}function M(p){return p===47||p===62||L(p)?k(p):n(p)}function y(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||D(p)?$(p):L(p)?(e.consume(p),P):n(p)}function $(p){return p===45&&i===2?(e.consume(p),Z):p===60&&i===1?(e.consume(p),Y):p===62&&i===4?(e.consume(p),le):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),pe):D(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Tc,A,V)(p)):p===null||D(p)?(e.exit(\"htmlFlowData\"),V(p)):(e.consume(p),$)}function V(p){return e.check(Dc,H,A)(p)}function H(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),R}function R(p){return p===null||D(p)?V(p):(e.enter(\"htmlFlowData\"),$(p))}function Z(p){return p===45?(e.consume(p),m):$(p)}function Y(p){return p===47?(e.consume(p),o=\"\",se):$(p)}function se(p){if(p===62){const q=o.toLowerCase();return gi.includes(q)?(e.consume(p),le):$(p)}return Se(p)&&o.length<8?(e.consume(p),o+=String.fromCharCode(p),se):$(p)}function pe(p){return p===93?(e.consume(p),m):$(p)}function m(p){return p===62?(e.consume(p),le):p===45&&i===2?(e.consume(p),m):$(p)}function le(p){return p===null||D(p)?(e.exit(\"htmlFlowData\"),A(p)):(e.consume(p),le)}function A(p){return e.exit(\"htmlFlow\"),t(p)}}function zc(e,t,n){const r=this;return i;function i(o){return D(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Oc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(fn,t,n)}}const Rc={name:\"htmlText\",tokenize:Lc};function Lc(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),E):m===63?(e.consume(m),k):Se(m)?(e.consume(m),F):n(m)}function l(m){return m===45?(e.consume(m),h):m===91?(e.consume(m),a=0,g):Se(m)?(e.consume(m),x):n(m)}function h(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):D(m)?(o=c,Y(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?Z(m):m===45?d(m):c(m)}function g(m){const le=\"CDATA[\";return m===le.charCodeAt(a++)?(e.consume(m),a===le.length?w:g):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),I):D(m)?(o=w,Y(m)):(e.consume(m),w)}function I(m){return m===93?(e.consume(m),b):w(m)}function b(m){return m===62?Z(m):m===93?(e.consume(m),b):w(m)}function x(m){return m===null||m===62?Z(m):D(m)?(o=x,Y(m)):(e.consume(m),x)}function k(m){return m===null?n(m):m===63?(e.consume(m),N):D(m)?(o=k,Y(m)):(e.consume(m),k)}function N(m){return m===62?Z(m):k(m)}function E(m){return Se(m)?(e.consume(m),v):n(m)}function v(m){return m===45||ce(m)?(e.consume(m),v):z(m)}function z(m){return D(m)?(o=z,Y(m)):L(m)?(e.consume(m),z):Z(m)}function F(m){return m===45||ce(m)?(e.consume(m),F):m===47||m===62||te(m)?M(m):n(m)}function M(m){return m===47?(e.consume(m),Z):m===58||m===95||Se(m)?(e.consume(m),y):D(m)?(o=M,Y(m)):L(m)?(e.consume(m),M):Z(m)}function y(m){return m===45||m===46||m===58||m===95||ce(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),$):D(m)?(o=P,Y(m)):L(m)?(e.consume(m),P):M(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):D(m)?(o=$,Y(m)):L(m)?(e.consume(m),$):(e.consume(m),H)}function V(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):D(m)?(o=V,Y(m)):(e.consume(m),V)}function H(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?M(m):(e.consume(m),H)}function R(m){return m===47||m===62||te(m)?M(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function Y(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),se}function se(m){return L(m)?B(e,pe,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):pe(m)}function pe(m){return e.enter(\"htmlTextData\"),o(m)}}const hr={name:\"labelEnd\",resolveAll:Hc,resolveTo:qc,tokenize:Uc},Mc={tokenize:jc},Bc={tokenize:Wc},Vc={tokenize:Qc};function Hc(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&fe(e,0,e.length,n),e}function qc(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},h={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ee(s,e.slice(a+1,a+r+3)),s=ee(s,[[\"enter\",h,t]]),s=ee(s,cn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ee(s,[[\"exit\",h,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ee(s,e.slice(o+1)),s=ee(s,[[\"exit\",u,t]]),fe(e,a,e.length,s),e}function Uc(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(d){return a?a._inactive?c(d):(o=r.parser.defined.includes(_t(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(Mc,h,o?h:c)(d):d===91?e.attempt(Bc,h,o?l:c)(d):o?h(d):c(d)}function l(d){return e.attempt(Vc,h,c)(d)}function h(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function jc(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return te(c)?ft(e,a)(c):a(c)}function a(c){return c===41?h(c):Na(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return te(c)?ft(e,u)(c):h(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?za(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):h(c)}function l(c){return te(c)?ft(e,h)(c):h(c)}function h(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Wc(e,t,n){const r=this;return i;function i(s){return Fa.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(_t(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Qc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const Gc={name:\"labelStartImage\",resolveAll:hr.resolveAll,tokenize:Kc};function Kc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),a}function a(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),o):n(s)}function o(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const Yc={name:\"labelStartLink\",resolveAll:hr.resolveAll,tokenize:Zc};function Zc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const vn={name:\"lineEnding\",tokenize:Jc};function Jc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Rt={name:\"thematicBreak\",tokenize:Xc};function Xc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||D(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?B(e,s,\"whitespace\")(l):s(l))}}const oe={continuation:{tokenize:rf},exit:of,name:\"list\",tokenize:nf},ef={partial:!0,tokenize:sf},tf={partial:!0,tokenize:af};function nf(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(f){const g=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(g===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:Gn(f)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(Rt,n,l)(f):l(f);if(!r.interrupt||f===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(f)}return n(f)}function u(f){return Gn(f)&&++o<10?(e.consume(f),u):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit(\"listItemValue\"),l(f)):n(f)}function l(f){return e.enter(\"listItemMarker\"),e.consume(f),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||f,e.check(fn,r.interrupt?n:h,e.attempt(ef,d,c))}function h(f){return r.containerState.initialBlankLine=!0,a++,d(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),d):n(f)}function d(f){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function rf(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(fn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tf,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(oe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function af(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function of(e){e.exit(this.containerState.type)}function sf(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const _i={name:\"setextUnderline\",resolveTo:lf,tokenize:uf};function lf(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function uf(e,t,n){const r=this;let i;return a;function a(l){let h=r.events.length,c;for(;h--;)if(r.events[h][1].type!==\"lineEnding\"&&r.events[h][1].type!==\"linePrefix\"&&r.events[h][1].type!==\"content\"){c=r.events[h][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||D(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const cf={tokenize:ff};function ff(e){const t=this,n=e.attempt(fn,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mc,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const hf={resolveAll:Ra()},df=Oa(\"string\"),pf=Oa(\"text\");function Oa(e){return{resolveAll:Ra(e===\"text\"?mf:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(h){return l(h)?a(h):s(h)}function s(h){if(h===null){n.consume(h);return}return n.enter(\"data\"),n.consume(h),u}function u(h){return l(h)?(n.exit(\"data\"),a(h)):(n.consume(h),u)}function l(h){if(h===null)return!0;const c=i[h];let d=-1;if(c)for(;++d<c.length;){const f=c[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Ra(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function mf(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const gf={42:oe,43:oe,45:oe,48:oe,49:oe,50:oe,51:oe,52:oe,53:oe,54:oe,55:oe,56:oe,57:oe,62:Pa},_f={91:vc},yf={[-2]:bn,[-1]:bn,32:bn},bf={35:Ic,42:Rt,45:[_i,Rt],60:$c,61:_i,95:Rt,96:mi,126:mi},vf={38:Ta,92:$a},xf={[-5]:vn,[-4]:vn,[-3]:vn,33:Gc,38:Ta,42:Kn,60:[Yu,Rc],91:Yc,92:[kc,$a],93:hr,95:Kn,96:uc},wf={null:[Kn,hf]},Sf={null:[42,95]},kf={null:[]},Cf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Sf,contentInitial:_f,disable:kf,document:gf,flow:bf,flowInitial:yf,insideSpan:wf,string:vf,text:xf},Symbol.toStringTag,{value:\"Module\"}));function If(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:z(E),check:z(v),consume:x,enter:k,exit:N,interrupt:z(v,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:f,write:c};let h=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(P){return o=ee(o,P),I(),o[o.length-1]!==null?[]:(F(t,0),l.events=cn(a,l.events,l),l.events)}function d(P,$){return Ef(f(P),$)}function f(P){return Af(o,P)}function g(){const{_bufferIndex:P,_index:$,line:V,column:H,offset:R}=r;return{_bufferIndex:P,_index:$,line:V,column:H,offset:R}}function w(P){i[P.line]=P.column,y()}function I(){let P;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(P){h=h(P)}function x(P){D(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function k(P,$){const V=$||{};return V.type=P,V.start=g(),l.events.push([\"enter\",V,l]),s.push(V),V}function N(P){const $=s.pop();return $.end=g(),l.events.push([\"exit\",$,l]),$}function E(P,$){F(P,$.from)}function v(P,$){$.restore()}function z(P,$){return V;function V(H,R,Z){let Y,se,pe,m;return Array.isArray(H)?A(H):\"tokenize\"in H?A([H]):le(H);function le(U){return at;function at(Fe){const Qe=Fe!==null&&U[Fe],Ge=Fe!==null&&U.null,hn=[...Array.isArray(Qe)?Qe:Qe?[Qe]:[],...Array.isArray(Ge)?Ge:Ge?[Ge]:[]];return A(hn)(Fe)}}function A(U){return Y=U,se=0,U.length===0?Z:p(U[se])}function p(U){return at;function at(Fe){return m=M(),pe=U,U.partial||(l.currentConstruct=U),U.name&&l.parser.constructs.disable.null.includes(U.name)?j():U.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,j)(Fe)}}function q(U){return P(pe,m),R}function j(U){return m.restore(),++se<Y.length?p(Y[se]):Z}}}function F(P,$){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&fe(l.events,$,l.events.length-$,P.resolve(l.events.slice($),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function M(){const P=g(),$=l.previous,V=l.currentConstruct,H=l.events.length,R=Array.from(s);return{from:H,restore:Z};function Z(){r=P,l.previous=$,l.currentConstruct=V,l.events.length=H,s=R,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Af(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s==\"string\"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Ef(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a==\"string\")o=a;else switch(a){case-5:{o=\"\\r\";break}case-4:{o=`\n`;break}case-3:{o=`\\r\n`;break}case-2:{o=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;o=\" \";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(\"\")}function Pf(e){const r={constructs:Eu([Cf,...(e||{}).extensions||[]]),content:i(qu),defined:[],document:i(ju),flow:i(cf),lazy:{},string:i(df),text:i(pf)};return r;function i(a){return o;function o(s){return If(r,a,s)}}}function $f(e){for(;!Da(e););return e}const yi=/[\\0\\t\\n\\r]/g;function Tf(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,h,c,d,f;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(yi.lastIndex=c,l=yi.exec(a),d=l&&l.index!==void 0?l.index:a.length,f=a.charCodeAt(d),!l){t=a.slice(c);break}if(f===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),f){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Df(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Hu(n)($f(Pf(n).document().write(Tf()(e,t,!0))))}const xn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Nf(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=xn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=xn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,Ff)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+xn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Ff(e,t){return t===\"|\"?t:e}class zf{constructor(){this.map=[]}add(t,n,r){Of(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function Of(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Rf(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function Lf(){return{flow:{null:{name:\"table\",tokenize:Mf,resolveAll:Bf}}}}function Mf(e,t,n){const r=this;let i=0,a=0,o;return s;function s(y){let P=r.events.length-1;for(;P>-1;){const H=r.events[P][1].type;if(H===\"lineEnding\"||H===\"linePrefix\")P--;else break}const $=P>-1?r.events[P][1].type:null,V=$===\"tableHead\"||$===\"tableRow\"?v:u;return V===v&&r.parser.lazy[r.now().line]?n(y):V(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(o=!0,a+=1),h(y)}function h(y){return y===null?n(y):D(y)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),f):n(y):L(y)?B(e,h,\"whitespace\")(y):(a+=1,o&&(o=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),o=!0,h):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||te(y)?(e.exit(\"data\"),h(y)):(e.consume(y),y===92?d:c)}function d(y){return y===92||y===124?(e.consume(y),c):c(y)}function f(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),o=!1,L(y)?B(e,g,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):g(y))}function g(y){return y===45||y===58?I(y):y===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),w):E(y)}function w(y){return L(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(a+=1,b(y)):y===null||D(y)?N(y):E(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),x(y)):E(y)}function x(y){return y===45?(e.consume(y),x):y===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),k):(e.exit(\"tableDelimiterFiller\"),k(y))}function k(y){return L(y)?B(e,N,\"whitespace\")(y):N(y)}function N(y){return y===124?g(y):y===null||D(y)?!o||i!==a?E(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):E(y)}function E(y){return n(y)}function v(y){return e.enter(\"tableRow\"),z(y)}function z(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),z):y===null||D(y)?(e.exit(\"tableRow\"),t(y)):L(y)?B(e,z,\"whitespace\")(y):(e.enter(\"data\"),F(y))}function F(y){return y===null||y===124||te(y)?(e.exit(\"data\"),z(y)):(e.consume(y),y===92?M:F)}function M(y){return y===92||y===124?(e.consume(y),F):F(y)}}function Bf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,h,c;const d=new zf;for(;++n<e.length;){const f=e[n],g=f[1];f[0]===\"enter\"?g.type===\"tableHead\"?(s=!1,u!==0&&(bi(d,t,u,l,h),h=void 0,u=0),l={type:\"table\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",l,t]])):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,h={type:\"tableBody\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",h,t]])),i=g.type===\"tableDelimiterRow\"?2:h?3:1):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=$t(d,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):g.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=$t(d,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):g.type===\"tableHead\"?(s=!0,u=n):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=$t(d,t,a,i,n,c)):o[1]!==0&&(c=$t(d,t,o,i,n,c)),i=0):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&bi(d,t,u,l,h),d.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=Rf(t.events,n))}return e}function $t(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Ye(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Ye(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=Ye(t.events,n[2]),h=Ye(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],f=t.events[n[3]];if(d[1].end=Object.assign({},f[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const g=n[2]+1,w=n[3]-n[2]-1;e.add(g,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},Ye(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function bi(e,t,n,r,i){const a=[],o=Ye(t.events,n);i&&(i.end=Object.assign({},o),a.push([\"exit\",i,t])),r.end=Object.assign({},o),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function Ye(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Vf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Hf(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const h={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},d=[[\"enter\",h,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],f=s.parser.constructs.insideSpan.null;f&&fe(d,d.length,0,cn(f,o.slice(l+1,u),s)),fe(d,d.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",h,s]]),fe(o,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,h=this.events;let c=0;return d;function d(g){return l===126&&h[h.length-1][1].type!==\"characterEscape\"?u(g):(o.enter(\"strikethroughSequenceTemporary\"),f(g))}function f(g){const w=Zt(l);if(g===126)return c>1?u(g):(o.consume(g),c++,f);if(c<2&&!n)return u(g);const I=o.exit(\"strikethroughSequenceTemporary\"),b=Zt(g);return I._open=!b||b===2&&!!w,I._close=!w||w===2&&!!b,s(g)}}}function qf(e){return Df(e,{allowDangerousHtml:!0,extensions:[Lf(),Hf()],htmlExtensions:[Nf(),Vf()]})}const Uf={values:{},update:()=>{}},Pe=tr(Uf),wn=[];function jf(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>La(i,a,t));return _(G,{children:r})}function La(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>La(u,l,n));return _e(i,o,...s)}return null}function Wf({node:e}){const t=de(),n={};for(const[r,i]of Object.entries(e.attributes))n[r]=t(i)??i;return _e(e.tag,n,e.children.length>0?he(e.children):void 0)}function Qf(e,t){switch(e.name){case\"set\":return _(bl,{rawArgs:e.rawArgs},t);case\"computed\":return _(bu,{rawArgs:e.rawArgs},t);case\"print\":return _(vl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return _(Su,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"passage\":return _(Cu,{className:e.className,id:e.id},t);case\"if\":return _(xl,{branches:e.branches??wn},t);case\"for\":return _(kl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return _(Il,{children:e.children},t);case\"button\":return _(Al,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return _(El,{className:e.className,id:e.id},t);case\"back\":return _($l,{className:e.className,id:e.id},t);case\"forward\":return _(Tl,{className:e.className,id:e.id},t);case\"restart\":return _(Pl,{className:e.className,id:e.id},t);case\"quicksave\":return _(Dl,{className:e.className,id:e.id},t);case\"quickload\":return _(Nl,{className:e.className,id:e.id},t);case\"settings\":return _(Rl,{className:e.className,id:e.id},t);case\"saves\":return _(Hl,{className:e.className,id:e.id},t);case\"include\":return _(ql,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return _(Ul,{rawArgs:e.rawArgs},t);case\"unset\":return _(jl,{rawArgs:e.rawArgs},t);case\"textbox\":return _(Ql,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return _(Kl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return _(Zl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return _(Xl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return _(tu,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return _(nu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return _(ru,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return _(au,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return _(ou,{rawArgs:e.rawArgs,branches:e.branches??wn},t);case\"timed\":{const n=e.branches?.[0];return _(su,{rawArgs:e.rawArgs,children:e.children,branches:e.branches??wn,className:e.className??n?.className,id:e.id??n?.id},t)}case\"repeat\":return _(lu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return _(uu,{},t);case\"type\":return _(cu,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return _(du,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=fu(e.name);if(n)return _(gu,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Au(e.name);return r?_(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:he(e.children)},t):_(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function Yn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return _(_l,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return _(yl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Qf(e,t);case\"html\":return _(Wf,{node:e},t);default:return e}}function Ma(e){return e.length===0?null:e.map((t,n)=>Yn(t,n))}function Gf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Kf(e){const t=S.getState(),n=e.name.split(\".\"),r=n[0];let i;e.scope===\"variable\"?i=t.variables[r]:e.scope===\"temporary\"&&(i=t.temporary[r]);for(let a=1;a<n.length;a++){if(i==null||typeof i!=\"object\")return\"\";i=i[n[a]]}return i==null?\"\":String(i)}function he(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,o)=>Yn(a,o));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const o=e[a];if(o.type===\"text\")r+=o.value.replace(/^[ \\t]{4,}/gm,\" \");else if(o.type===\"variable\"&&Gf(r))r+=Kf(o);else{const s=n.length;n.push(Yn(o,a)),r+=`<span data-tw=\"${s}\"></span>`}}const i=qf(r);return jf(i,n)}const Yf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Zf(){const t=S(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Yf;try{const r=xt(n),i=wt(r);return _(G,{children:he(i)})}catch(r){return _(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function Jf(){const e=S(n=>n.storyData),t=S(n=>n.currentPassage);return Ae(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),S.getState().save()):r.key===\"F9\"&&(r.preventDefault(),S.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?_(\"div\",{class:\"loading\",children:\"Loading...\"}):_(Zf,{})}function Xf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",h=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(d.getAttribute(\"pid\")||\"0\",10),g=d.getAttribute(\"name\")||\"\",w=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(N=>N.length>0),I=d.textContent||\"\",b={},x=new Set([\"pid\",\"name\",\"tags\"]);for(const N of d.attributes)x.has(N.name)||(b[N.name]=N.value);const k={pid:f,name:g,tags:w,metadata:b,content:I};h.set(g,k),c.set(f,k)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:h,passagesById:c,userCSS:s,userScript:l}}function eh(){return{get(e){return S.getState().variables[e]},set(e,t){const n=S.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){S.getState().navigate(e)},back(){S.getState().goBack()},forward(){S.getState().goForward()},restart(){S.getState().restart()},save(e){S.getState().save(e)},load(e){S.getState().load(e)},hasSave(e){return S.getState().hasSave(e)},visited(e){return S.getState().visitCounts[e]??0},hasVisited(e){return(S.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return S.getState().renderCounts[e]??0},hasRendered(e){return(S.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=S.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=S.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=S.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=S.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return S.getState().storyData?.name||\"\"},get passage(){return S.getState().currentPassage},settings:gt,registerClass(e,t){Qs(e,t)},saves:{setTitleGenerator(e){Ks(e)}},getActions(){return ii()},performAction(e,t){const n=fl(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=S.getState().currentPassage;return S.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return dl(t);if(e===\"variableChanged\"){let n={...S.getState().variables};return S.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(ii())})})})},random(){return lr()},randomInt(e,t){return la(e,t)},prng:{init(e,t){Ds(e,t);const{historyIndex:n}=S.getState();S.setState(r=>{const i=r.history[n];i&&(i.prng=Ot())})},isEnabled(){return Ns()},get seed(){return Fs()},get pull(){return zs()}}}}function th(){window.Story=eh()}const nh=/^\\$(\\w+)\\s*=\\s*(.+)$/,vi=/\\$(\\w+(?:\\.\\w+)*)/g,xi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,rh=new Set([\"number\",\"string\",\"boolean\"]);function Ba(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,Ba(i));return{type:\"object\",fields:n}}const t=typeof e;if(!rh.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function ih(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(nh);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=Ba(s);t.set(a,{...u,name:a,default:s})}return t}function ah(e){const t=new Set;let n;for(xi.lastIndex=0;(n=xi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function oh(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function sh(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=ah(i.content);let o;for(vi.lastIndex=0;(o=vi.exec(i.content))!==null;){const s=o[1],u=oh(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function lh(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function wi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const o=document.createElement(\"li\");o.textContent=a,i.appendChild(o)}n.appendChild(i),e.appendChild(n)}function Si(){const e=Xf();if(th(),e.userCSS){const u=document.createElement(\"style\");u.textContent=e.userCSS,document.head.appendChild(u)}if(e.userScript)try{new Function(e.userScript)()}catch(u){console.error(\"spindle: Error in story JavaScript:\",u)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const u=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",l=document.getElementById(\"root\");throw l&&wi(l,[u]),new Error(`spindle: ${u}`)}const r=ih(n.content),i=sh(e.passages,r);if(i.length>0){const u=document.getElementById(\"root\");throw u&&wi(u,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=lh(r),S.getState().init(e,t),_a();for(const[,u]of e.passages)if(u.tags.includes(\"widget\")){const l=xt(u.content),h=wt(l);for(const c of h)if(c.type===\"macro\"&&c.name===\"widget\"&&c.rawArgs){const d=c.rawArgs.trim().split(/\\s+/),f=d[0].replace(/[\"']/g,\"\"),g=d.slice(1).filter(w=>w.startsWith(\"$\")||w.startsWith(\"_\")||w.startsWith(\"@\"));Ia(f,c.children,g)}}let a=\"\";S.subscribe(u=>{u.currentPassage!==a&&(a=u.currentPassage,hl())});const o=e.passages.get(\"StoryInterface\");o&&!o.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const s=document.getElementById(\"root\");if(!s)throw new Error('spindle: No <div id=\"root\"> element found.');Je(_(Jf,{}),s),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Si):Si();</script>\n <style rel=\"stylesheet\" crossorigin>*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { useContext } from 'preact/hooks';
|
|
|
2
2
|
import { renderInlineNodes, LocalsContext } from '../../markup/render';
|
|
3
3
|
import { collectText } from '../../utils/extract-text';
|
|
4
4
|
import { useAction } from '../../hooks/use-action';
|
|
5
|
-
import {
|
|
5
|
+
import { stripLocalsPrefix } from '../../hooks/use-merged-locals';
|
|
6
6
|
import { useInterpolate } from '../../hooks/use-interpolate';
|
|
7
7
|
import { executeMutation } from '../../execute-mutation';
|
|
8
8
|
import { currentSourceLocation } from '../../utils/source-location';
|
|
@@ -20,11 +20,10 @@ export function Button({ rawArgs, children, className, id }: ButtonProps) {
|
|
|
20
20
|
className = resolve(className);
|
|
21
21
|
id = resolve(id);
|
|
22
22
|
const scope = useContext(LocalsContext);
|
|
23
|
-
const [, , mergedLocals] = useMergedLocals();
|
|
24
23
|
|
|
25
24
|
const handleClick = () => {
|
|
26
25
|
try {
|
|
27
|
-
executeMutation(rawArgs,
|
|
26
|
+
executeMutation(rawArgs, stripLocalsPrefix(scope.values), scope.update);
|
|
28
27
|
} catch (err) {
|
|
29
28
|
console.error(
|
|
30
29
|
`spindle: Error in {button ${rawArgs}}${currentSourceLocation()}:`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useLayoutEffect, useContext } from 'preact/hooks';
|
|
2
2
|
import type { ASTNode } from '../../markup/ast';
|
|
3
3
|
import { LocalsContext } from '../../markup/render';
|
|
4
|
-
import {
|
|
4
|
+
import { stripLocalsPrefix } from '../../hooks/use-merged-locals';
|
|
5
5
|
import { executeMutation } from '../../execute-mutation';
|
|
6
6
|
import { currentSourceLocation } from '../../utils/source-location';
|
|
7
7
|
|
|
@@ -19,11 +19,10 @@ function collectText(nodes: ASTNode[]): string {
|
|
|
19
19
|
export function Do({ children }: DoProps) {
|
|
20
20
|
const code = collectText(children);
|
|
21
21
|
const scope = useContext(LocalsContext);
|
|
22
|
-
const [, , mergedLocals] = useMergedLocals();
|
|
23
22
|
|
|
24
23
|
useLayoutEffect(() => {
|
|
25
24
|
try {
|
|
26
|
-
executeMutation(code,
|
|
25
|
+
executeMutation(code, stripLocalsPrefix(scope.values), scope.update);
|
|
27
26
|
} catch (err) {
|
|
28
27
|
console.error(`spindle: Error in {do}${currentSourceLocation()}:`, err);
|
|
29
28
|
}
|
|
@@ -2,7 +2,7 @@ import { useContext } from 'preact/hooks';
|
|
|
2
2
|
import { useStoryStore } from '../../store';
|
|
3
3
|
import type { ASTNode } from '../../markup/ast';
|
|
4
4
|
import { LocalsContext } from '../../markup/render';
|
|
5
|
-
import {
|
|
5
|
+
import { stripLocalsPrefix } from '../../hooks/use-merged-locals';
|
|
6
6
|
import { useInterpolate } from '../../hooks/use-interpolate';
|
|
7
7
|
import { executeMutation } from '../../execute-mutation';
|
|
8
8
|
import { currentSourceLocation } from '../../utils/source-location';
|
|
@@ -82,11 +82,10 @@ export function MacroLink({
|
|
|
82
82
|
id = resolve(id);
|
|
83
83
|
const { display, passage } = parseArgs(rawArgs);
|
|
84
84
|
const scope = useContext(LocalsContext);
|
|
85
|
-
const [, , mergedLocals] = useMergedLocals();
|
|
86
85
|
|
|
87
86
|
const handleClick = (e: Event) => {
|
|
88
87
|
e.preventDefault();
|
|
89
|
-
executeChildren(children,
|
|
88
|
+
executeChildren(children, stripLocalsPrefix(scope.values), scope.update);
|
|
90
89
|
if (passage) {
|
|
91
90
|
useStoryStore.getState().navigate(passage);
|
|
92
91
|
}
|
|
@@ -99,7 +98,7 @@ export function MacroLink({
|
|
|
99
98
|
label: display,
|
|
100
99
|
target: passage ?? undefined,
|
|
101
100
|
perform: () => {
|
|
102
|
-
executeChildren(children,
|
|
101
|
+
executeChildren(children, stripLocalsPrefix(scope.values), scope.update);
|
|
103
102
|
if (passage) {
|
|
104
103
|
useStoryStore.getState().navigate(passage);
|
|
105
104
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRef, useContext } from 'preact/hooks';
|
|
2
2
|
import { LocalsContext } from '../../markup/render';
|
|
3
|
-
import {
|
|
3
|
+
import { stripLocalsPrefix } from '../../hooks/use-merged-locals';
|
|
4
4
|
import { executeMutation } from '../../execute-mutation';
|
|
5
5
|
import { currentSourceLocation } from '../../utils/source-location';
|
|
6
6
|
|
|
@@ -10,14 +10,13 @@ interface SetProps {
|
|
|
10
10
|
|
|
11
11
|
export function Set({ rawArgs }: SetProps) {
|
|
12
12
|
const scope = useContext(LocalsContext);
|
|
13
|
-
const [, , mergedLocals] = useMergedLocals();
|
|
14
13
|
const ran = useRef(false);
|
|
15
14
|
|
|
16
15
|
if (!ran.current) {
|
|
17
16
|
ran.current = true;
|
|
18
17
|
|
|
19
18
|
try {
|
|
20
|
-
executeMutation(rawArgs,
|
|
19
|
+
executeMutation(rawArgs, stripLocalsPrefix(scope.values), scope.update);
|
|
21
20
|
} catch (err) {
|
|
22
21
|
console.error(
|
|
23
22
|
`spindle: Error in {set ${rawArgs}}${currentSourceLocation()}:`,
|
|
@@ -2,6 +2,22 @@ import { useContext, useMemo } from 'preact/hooks';
|
|
|
2
2
|
import { useStoryStore } from '../store';
|
|
3
3
|
import { LocalsContext } from '../markup/render';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Strip `@` prefix from locals scope values so they can be passed
|
|
7
|
+
* directly to evaluate/execute.
|
|
8
|
+
*/
|
|
9
|
+
export function stripLocalsPrefix(
|
|
10
|
+
values: Record<string, unknown>,
|
|
11
|
+
): Record<string, unknown> {
|
|
12
|
+
const locals: Record<string, unknown> = {};
|
|
13
|
+
for (const [key, val] of Object.entries(values)) {
|
|
14
|
+
if (key.startsWith('@')) {
|
|
15
|
+
locals[key.slice(1)] = val;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return locals;
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
/**
|
|
6
22
|
* Return store variables, temporary, and @-prefixed locals from context.
|
|
7
23
|
* Locals use `@` prefix keys internally; the returned locals dict has
|
|
@@ -17,12 +33,6 @@ export function useMergedLocals(): readonly [
|
|
|
17
33
|
const scope = useContext(LocalsContext);
|
|
18
34
|
|
|
19
35
|
return useMemo(() => {
|
|
20
|
-
|
|
21
|
-
for (const [key, val] of Object.entries(scope.values)) {
|
|
22
|
-
if (key.startsWith('@')) {
|
|
23
|
-
locals[key.slice(1)] = val;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return [variables, temporary, locals] as const;
|
|
36
|
+
return [variables, temporary, stripLocalsPrefix(scope.values)] as const;
|
|
27
37
|
}, [variables, temporary, scope.values]);
|
|
28
38
|
}
|