@rohal12/spindle 0.28.3 → 0.29.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.
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.28.3","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 Ot,O,Ji,Qe,Ur,Zi,Xi,ea,pr,Hn,qn,ta,an={},on=[],Qo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Mt=Array.isArray;function Ae(e,t){for(var n in t)e[n]=t[n];return e}function gr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function K(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?Ot.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??++Ji,__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 Pe(e,t){this.props=e,this.context=t}function ct(e,t){if(t==null)return e.__?ct(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\"?ct(e):null}function Yo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ae({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),mr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ct(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,aa(r,a,i),t.__e=t.__=null,a.__e!=n&&na(a)}}function na(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}),na(e)}function Un(e){(!e.__d&&(e.__d=!0)&&Qe.push(e)&&!sn.__r++||Ur!=O.debounceRendering)&&((Ur=O.debounceRendering)||Zi)(sn)}function sn(){for(var e,t=1;Qe.length;)Qe.length>t&&Qe.sort(Xi),e=Qe.shift(),t=Qe.length,Yo(e);sn.__r=0}function ra(e,t,n,r,i,a,o,s,u,l,f){var c,h,d,p,k,x,_,v=r&&r.__k||on,S=t.length;for(u=Ko(n,t,v,u,S),c=0;c<S;c++)(d=n.__k[c])!=null&&(h=d.__i!=-1&&v[d.__i]||an,d.__i=c,x=mr(e,d,h,i,a,o,s,u,l,f),p=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&_r(h.ref,null,d),f.push(d.ref,d.__c||p,d)),k==null&&p!=null&&(k=p),(_=!!(4&d.__u))||h.__k===d.__k?u=ia(d,u,e,_):typeof d.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),d.__u&=-7);return n.__e=k,u}function Ko(e,t,n,r,i){var a,o,s,u,l,f=n.length,c=f,h=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):Mt(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+h,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Jo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>f?h--:i<f&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<f;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ct(s)),sa(s,s));return r}function ia(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=ia(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ct(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Fe(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Mt(e)?e.some(function(n){Fe(n,t)}):t.push(e)),t}function Jo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&s==null||f&&s==l.key&&u==l.type)return n;if(r>(f?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 jr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Qo.test(t)?n:n+\"px\"}function Wt(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||jr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||jr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(ea,\"$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=pr,e.addEventListener(t,a?qn:Hn,a)):e.removeEventListener(t,a?qn:Hn,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=pr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function mr(e,t,n,r,i,a,o,s,u,l){var f,c,h,d,p,k,x,_,v,S,E,I,y,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(f=O.__b)&&f(t);e:if(typeof z==\"function\")try{if(_=t.props,v=\"prototype\"in z&&z.prototype.render,S=(f=z.contextType)&&r[f.__c],E=f?S?S.props.value:f.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(v?t.__c=c=new z(_,E):(t.__c=c=new Pe(_,E),c.constructor=z,c.render=Xo),S&&S.sub(c),c.state||(c.state={}),c.__n=r,h=c.__d=!0,c.__h=[],c._sb=[]),v&&c.__s==null&&(c.__s=c.state),v&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ae({},c.__s)),Ae(c.__s,z.getDerivedStateFromProps(_,c.__s))),d=c.props,p=c.state,c.__v=t,h)v&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),v&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(v&&z.getDerivedStateFromProps==null&&_!==d&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,E),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,E)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),on.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,E),v&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,p,k)})}if(c.context=E,c.props=_,c.__P=e,c.__e=!1,I=O.__r,y=0,v)c.state=c.__s,c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),on.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,I&&I(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Ae(Ae({},r),c.getChildContext())),v&&!h&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(d,p)),P=f!=null&&f.type===G&&f.key==null?oa(f.props.children):f,s=ra(e,Mt(P)?P:[P],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(b){if(t.__v=null,u||a!=null)if(b.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(T=a.length;T--;)gr(a[T]);jn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||jn(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Zo(n.__e,t,n,r,i,a,o,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:s}function jn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(jn))}function aa(e,t,n){for(var r=0;r<n.length;r++)_r(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 oa(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Mt(e)?e.map(oa):Ae({},e)}function Zo(e,t,n,r,i,a,o,s,u){var l,f,c,h,d,p,k,x=n.props||an,_=t.props,v=t.type;if(v==\"svg\"?i=\"http://www.w3.org/2000/svg\":v==\"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((d=a[l])&&\"setAttribute\"in d==!!v&&(v?d.localName==v:d.nodeType==3)){e=d,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(v==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Ot.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(d=e.attributes[l]).name]=d.value;for(l in x)d=x[l],l==\"dangerouslySetInnerHTML\"?c=d:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||Wt(e,l,null,d,i);for(l in _)d=_[l],l==\"children\"?h=d:l==\"dangerouslySetInnerHTML\"?f=d:l==\"value\"?p=d:l==\"checked\"?k=d:s&&typeof d!=\"function\"||x[l]===d||Wt(e,l,d,x[l],i);if(f)s||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ra(t.type==\"template\"?e.content:e,Mt(h)?h:[h],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&ct(n,0),s,u),a!=null)for(l=a.length;l--;)gr(a[l]);s||(l=\"value\",v==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||v==\"progress\"&&!p||v==\"option\"&&p!=x[l])&&Wt(e,l,p,x[l],i),l=\"checked\",k!=null&&k!=e[l]&&Wt(e,l,k,x[l],i))}return e}function _r(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 sa(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||_r(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]&&sa(r[i],t,n||typeof e.type!=\"function\");n||gr(e.__e),e.__c=e.__=e.__e=void 0}function Xo(e,t,n){return this.constructor(e,n)}function be(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=[],mr(t,e=(!r&&n||t).__k=K(G,null,[e]),i||an,an,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Ot.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),aa(a,e,o)}function la(e,t){be(e,t,la)}function es(e,t,n){var r,i,a,o,s=Ae({},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?Ot.call(arguments,2):n),Ct(e.type,s,r||e.key,i||e.ref,null)}function pt(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,Un(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\"+ta++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Ot=on.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}},Ji=0,Pe.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ae({},this.state),typeof e==\"function\"&&(e=e(Ae({},n),this.props)),e&&Ae(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Un(this))},Pe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Un(this))},Pe.prototype.render=G,Qe=[],Zi=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Xi=function(e,t){return e.__v.__b-t.__v.__b},sn.__r=0,ea=/(PointerCapture)$|Capture$/i,pr=0,Hn=Wr(!1),qn=Wr(!0),ta=0;var ts=0;function w(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:--ts,__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 Le,W,An,Qr,ft=0,ua=[],Q=O,Gr=Q.__b,Yr=Q.__r,Kr=Q.diffed,Jr=Q.__c,Zr=Q.unmount,Xr=Q.__;function gt(e,t){Q.__h&&Q.__h(W,e,ft||t),ft=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return ft=1,yr(ha,e)}function yr(e,t,n){var r=gt(Le++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ha(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 f=r.__c.__H.__.filter(function(h){return h.__c});if(f.every(function(h){return!h.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return f.some(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[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 f=a;a=void 0,i(s,u,l),a=f}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Se(e,t){var n=gt(Le++,3);!Q.__s&&br(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function nt(e,t){var n=gt(Le++,4);!Q.__s&&br(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function ue(e){return ft=5,de(function(){return{current:e}},[])}function ca(e,t,n){ft=6,nt(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 de(e,t){var n=gt(Le++,7);return br(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return ft=8,de(function(){return e},t)}function ce(e){var t=W.context[e.__c],n=gt(Le++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function fa(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function da(){var e=gt(Le++,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 ns(){for(var e;e=ua.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Xt),t.__h.some(Wn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Gr&&Gr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Xr&&Xr(e,t)},Q.__r=function(e){Yr&&Yr(e),Le=0;var t=(W=e.__c).__H;t&&(An===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Xt),t.__h.some(Wn),t.__h=[],Le=0)),An=W},Q.diffed=function(e){Kr&&Kr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ua.push(t)!==1&&Qr===Q.requestAnimationFrame||((Qr=Q.requestAnimationFrame)||rs)(ns)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),An=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Xt),n.__h=n.__h.filter(function(r){return!r.__||Wn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Jr&&Jr(e,t)},Q.unmount=function(e){Zr&&Zr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Xt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ei=typeof requestAnimationFrame==\"function\";function rs(e){var t,n=function(){clearTimeout(r),ei&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ei&&(t=requestAnimationFrame(n))}function Xt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Wn(e){var t=W;e.__c=e.__(),W=t}function br(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ha(e,t){return typeof t==\"function\"?t(e):t}const ti=e=>{let t;const n=new Set,r=(l,f)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const h=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(d=>d(t,h))}},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},is=(e=>e?ti(e):ti);function pa(e,t){for(var n in t)e[n]=t[n];return e}function Qn(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 ga(e,t){var n=t(),r=Z({t:{__:n,u:t}}),i=r[0].t,a=r[1];return nt(function(){i.__=n,i.u=t,Pn(i)&&a({t:i})},[e,n,t]),Se(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 ma(e){e()}function _a(e){return e}function ya(){return[!1,ma]}var ba=nt;function Gn(e,t){this.props=e,this.context=t}function as(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:Qn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,K(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Gn.prototype=new Pe).isPureReactComponent=!0,Gn.prototype.shouldComponentUpdate=function(e,t){return Qn(this.props,e)||Qn(this.state,t)};var ni=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ni&&ni(e)};var os=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ss(e){function t(n){var r=pa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=os,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ri=function(e,t){return e==null?null:Fe(Fe(e).map(t))},ls={map:ri,forEach:ri,count:function(e){return e?Fe(e).length:0},only:function(e){var t=Fe(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Fe},us=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)}us(e,t,n,r)};var ii=O.unmount;function va(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=pa({},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 va(r,t,n)})),e}function wa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return wa(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 en(){this.__u=0,this.o=null,this.__b=null}function ka(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function cs(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?K(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function St(){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),ii&&ii(e)},(en.prototype=new Pe).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ka(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]=wa(l,l.__c.__P,l.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=s,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},en.prototype.componentWillUnmount=function(){this.o=[]},en.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]=va(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&K(G,null,e.fallback);return i&&(i.__u&=-33),[K(G,null,t.__a?null:e.children),i]};var ai=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 fs(e){return this.getChildContext=function(){return e.context},e.children}function ds(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){be(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)}}}be(K(fs,{context:t.context},e.__v),t.v)}function hs(e,t){var n=K(ds,{__v:e,h:t});return n.containerInfo=t,n}(St.prototype=new Pe).__a=function(e){var t=this,n=ka(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ai(t,e,r)):i()};n?n(a):a()}},St.prototype.render=function(e){this.i=null,this.l=new Map;var t=Fe(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},St.prototype.componentDidUpdate=St.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ai(e,n,t)})};var Sa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ps=/^(?: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]/,gs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ms=/[A-Z0-9]/g,_s=typeof document<\"u\",ys=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function bs(e,t,n){return t.__k==null&&(t.textContent=\"\"),be(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function vs(e,t,n){return la(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Pe.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Pe.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var oi=O.event;function ws(){}function ks(){return this.cancelBubble}function Ss(){return this.defaultPrevented}O.event=function(e){return oi&&(e=oi(e)),e.persist=ws,e.isPropagationStopped=ks,e.isDefaultPrevented=Ss,e.nativeEvent=e};var vr,xs={enumerable:!1,configurable:!0,get:function(){return this.class}},si=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||_s&&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\"||ys(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":gs.test(o)&&(o=u):u=o=\"oninput\":a&&ps.test(o)?o=o.replace(ms,\"-$&\").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=Fe(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Fe(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\",xs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Sa,si&&si(e)};var li=O.__r;O.__r=function(e){li&&li(e),vr=e.__c};var ui=O.diffed;O.diffed=function(e){ui&&ui(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),vr=null};var Cs={ReactCurrentDispatcher:{current:{readContext:function(e){return vr.__n[e.__c].props.value},useCallback:ve,useContext:ce,useDebugValue:fa,useDeferredValue:_a,useEffect:Se,useId:da,useImperativeHandle:ca,useInsertionEffect:ba,useLayoutEffect:nt,useMemo:de,useReducer:yr,useRef:ue,useState:Z,useSyncExternalStore:ga,useTransition:ya}}};function Is(e){return K.bind(null,e)}function yn(e){return!!e&&e.$$typeof===Sa}function Es(e){return yn(e)&&e.type===G}function As(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ps(e){return yn(e)?es.apply(null,arguments):e}function Ts(e){return!!e.__k&&(be(null,e),!0)}function Ns(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ds=function(e,t){return e(t)},$s=function(e,t){return e(t)},zs=G,Fs=yn,Qt={useState:Z,useId:da,useReducer:yr,useEffect:Se,useLayoutEffect:nt,useInsertionEffect:ba,useTransition:ya,useDeferredValue:_a,useSyncExternalStore:ga,startTransition:ma,useRef:ue,useImperativeHandle:ca,useMemo:de,useCallback:ve,useContext:ce,useDebugValue:fa,version:\"18.3.1\",Children:ls,render:bs,hydrate:vs,unmountComponentAtNode:Ts,createPortal:hs,createElement:K,createContext:pt,createFactory:Is,cloneElement:Ps,createRef:Go,Fragment:G,isValidElement:yn,isElement:Fs,isFragment:Es,isMemo:As,findDOMNode:Ns,Component:Pe,PureComponent:Gn,memo:as,forwardRef:ss,flushSync:$s,unstable_batchedUpdates:Ds,StrictMode:zs,Suspense:en,SuspenseList:St,lazy:cs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Cs};const Rs=e=>e;function Os(e,t=Rs){const n=Qt.useSyncExternalStore(e.subscribe,Qt.useCallback(()=>t(e.getState()),[e,t]),Qt.useCallback(()=>t(e.getInitialState()),[e,t]));return Qt.useDebugValue(n),n}const Ms=e=>{const t=is(e),n=r=>Os(t,r);return Object.assign(n,t),n},Ls=(e=>Ms);var wr=Symbol.for(\"immer-nothing\"),It=Symbol.for(\"immer-draftable\"),ee=Symbol.for(\"immer-state\");function ie(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var he=Object,Ze=he.getPrototypeOf,Tt=\"constructor\",Lt=\"prototype\",Yn=\"configurable\",ln=\"enumerable\",tn=\"writable\",Nt=\"value\",Re=e=>!!e&&!!e[ee];function Te(e){return e?xa(e)||Bt(e)||!!e[It]||!!e[Tt]?.[It]||Ht(e)||qt(e):!1}var Vs=he[Lt][Tt].toString(),ci=new WeakMap;function xa(e){if(!e||!dt(e))return!1;const t=Ze(e);if(t===null||t===he[Lt])return!0;const n=he.hasOwnProperty.call(t,Tt)&&t[Tt];if(n===Object)return!0;if(!Ge(n))return!1;let r=ci.get(n);return r===void 0&&(r=Function.toString.call(n),ci.set(n,r)),r===Vs}function Vt(e,t,n=!0){Xe(e)===0?(n?Reflect.ownKeys(e):he.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Xe(e){const t=e[ee];return t?t.type_:Bt(e)?1:Ht(e)?2:qt(e)?3:0}var Et=(e,t,n=Xe(e))=>n===2?e.has(t):he[Lt].hasOwnProperty.call(e,t),$e=(e,t,n=Xe(e))=>n===2?e.get(t):e[t],un=(e,t,n,r=Xe(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Bs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Bt=Array.isArray,Ht=e=>e instanceof Map,qt=e=>e instanceof Set,dt=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",Tn=e=>typeof e==\"boolean\";function Hs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var qs=e=>dt(e)?e?.[ee]:null,ze=e=>e.copy_||e.base_,kr=e=>e.modified_?e.copy_:e.base_;function Kn(e,t){if(Ht(e))return new Map(e);if(qt(e))return new Set(e);if(Bt(e))return Array[Lt].slice.call(e);const n=xa(e);if(t===!0||t===\"class_only\"&&!n){const r=he.getOwnPropertyDescriptors(e);delete r[ee];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[tn]===!1&&(s[tn]=!0,s[Yn]=!0),(s.get||s.set)&&(r[o]={[Yn]:!0,[tn]:!0,[ln]:s[ln],[Nt]:e[o]})}return he.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=he.create(r);return he.assign(i,e)}}function Sr(e,t=!1){return bn(e)||Re(e)||!Te(e)||(Xe(e)>1&&he.defineProperties(e,{set:Gt,add:Gt,clear:Gt,delete:Gt}),he.freeze(e),t&&Vt(e,(n,r)=>{Sr(r,!0)},!1)),e}function Us(){ie(2)}var Gt={[Nt]:Us};function bn(e){return e===null||!dt(e)?!0:he.isFrozen(e)}var cn=\"MapSet\",fn=\"Patches\",fi=\"ArrayMethods\",dn={};function et(e){const t=dn[e];return t||ie(0,e),t}var di=e=>!!dn[e];function js(e,t){dn[e]||(dn[e]=t)}var Dt,Ca=()=>Dt,Ws=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:di(cn)?et(cn):void 0,arrayMethodsPlugin_:di(fi)?et(fi):void 0});function hi(e,t){t&&(e.patchPlugin_=et(fn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Jn(e){Zn(e),e.drafts_.forEach(Qs),e.drafts_=null}function Zn(e){e===Dt&&(Dt=e.parent_)}var pi=e=>Dt=Ws(Dt,e);function Qs(e){const t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function gi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ee].modified_&&(Jn(t),ie(4)),Te(e)&&(e=mi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ee].base_,e,t)}else e=mi(t,n);return Gs(t,e,!0),Jn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==wr?e:void 0}function mi(e,t){if(bn(t))return t;const n=t[ee];if(!n)return hn(t,e.handledSet_,e);if(!vn(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);Aa(n,e)}return n.copy_}function Gs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sr(t,n)}function Ia(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var vn=(e,t)=>e.scope_===t,Ys=[];function Ea(e,t,n,r){const i=ze(e),a=e.type_;if(r!==void 0&&$e(i,r,a)===t){un(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Vt(i,(u,l)=>{if(Re(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??Ys;for(const s of o)un(i,s,n,a)}function Ks(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!vn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=kr(a);Ea(e,a.draft_??a,o,n),Aa(a,i)})}function Aa(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)}Ia(e)}}function Js(e,t,n){const{scope_:r}=e;if(Re(n)){const i=n[ee];vn(i,r)&&i.callbacks_.push(function(){nn(e);const o=kr(i);Ea(e,n,o,t)})}else Te(n)&&e.callbacks_.push(function(){const a=ze(e);e.type_===3?a.has(n)&&hn(n,r.handledSet_,r):$e(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&hn($e(e.copy_,t,e.type_),r.handledSet_,r)})}function hn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Re(e)||t.has(e)||!Te(e)||bn(e)||(t.add(e),Vt(e,(r,i)=>{if(Re(i)){const a=i[ee];if(vn(a,n)){const o=kr(a);un(e,r,o,e.type_),Ia(a)}}else Te(i)&&hn(i,t,n)})),e}function Zs(e,t){const n=Bt(e),r={type_:n?1:0,scope_:t?t.scope_:Ca(),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=pn;n&&(i=[r],a=$t);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var pn={get(e,t){if(t===ee)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=ze(e);if(!Et(i,t,e.type_))return Xs(e,i,t);const a=i[t];if(e.finalized_||!Te(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Hs(t))return a;if(a===Nn(e.base_,t)){nn(e);const o=e.type_===1?+t:t,s=er(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in ze(e)},ownKeys(e){return Reflect.ownKeys(ze(e))},set(e,t,n){const r=Pa(ze(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Nn(ze(e),t),a=i?.[ee];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Bs(n,i)&&(n!==void 0||Et(e.base_,t,e.type_)))return!0;nn(e),Xn(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),Js(e,t,n)),!0},deleteProperty(e,t){return nn(e),Nn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Xn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ze(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[tn]:!0,[Yn]:e.type_!==1||t!==\"length\",[ln]:r[ln],[Nt]:n[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ie(12)}},$t={};for(let e in pn){let t=pn[e];$t[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}$t.deleteProperty=function(e,t){return $t.set.call(this,e,t,void 0)};$t.set=function(e,t,n){return pn.set.call(this,e[0],t,n,e[0])};function Nn(e,t){const n=e[ee];return(n?ze(n):e)[t]}function Xs(e,t,n){const r=Pa(t,n);return r?Nt in r?r[Nt]:r.get?.call(e.draft_):void 0}function Pa(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function Xn(e){e.modified_||(e.modified_=!0,e.parent_&&Xn(e.parent_))}function nn(e){e.copy_||(e.assigned_=new Map,e.copy_=Kn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var el=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ge(t)&&!Ge(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,f=>n.call(this,f,...l))}}Ge(n)||ie(6),r!==void 0&&!Ge(r)&&ie(7);let i;if(Te(t)){const a=pi(this),o=er(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Jn(a):Zn(a)}return hi(a,r),gi(i,a)}else if(!t||!dt(t)){if(i=n(t),i===void 0&&(i=t),i===wr&&(i=void 0),this.autoFreeze_&&Sr(i,!0),r){const a=[],o=[];et(fn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ie(1,t)},this.produceWithPatches=(t,n)=>{if(Ge(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]},Tn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Tn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Tn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Te(e)||ie(8),Re(e)&&(e=tl(e));const t=pi(this),n=er(t,e,void 0);return n[ee].isManual_=!0,Zn(t),n}finishDraft(e,t){const n=e&&e[ee];(!n||!n.isManual_)&&ie(9);const{scope_:r}=n;return hi(r,t),gi(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=et(fn).applyPatches_;return Re(e)?r(e,t):this.produce(e,i=>r(i,t))}};function er(e,t,n,r){const[i,a]=Ht(t)?et(cn).proxyMap_(t,n):qt(t)?et(cn).proxySet_(t,n):Zs(t,n);return(n?.scope_??Ca()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Ks(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 tl(e){return Re(e)||ie(10,e),Ta(e)}function Ta(e){if(!Te(e)||bn(e))return e;const t=e[ee];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Kn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Kn(e,!0);return Vt(n,(i,a)=>{un(n,i,Ta(a))},r),t&&(t.finalized_=!1),n}function nl(){function t(p,k=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=qs($e(x,p.key_)),v=$e(x,p.key_);if(v===void 0||v!==p.draft_&&v!==p.base_&&v!==p.copy_||_!=null&&_.base_!==p.base_)return null;const S=p.parent_.type_===3;let E;if(S){const I=p.parent_;E=Array.from(I.drafts_.keys()).indexOf(p.key_)}else E=p.key_;if(!(S&&x.size>E||Et(x,E)))return null;k.push(E)}if(p.parent_)return t(p.parent_,k);k.reverse();try{n(p.copy_,k)}catch{return null}return k}function n(p,k){let x=p;for(let _=0;_<k.length-1;_++){const v=k[_];if(x=$e(x,v),!dt(x)||x===null)throw new Error(`Cannot resolve path at '${k.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,k,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:v}=x;switch(p.type_){case 0:case 2:return u(p,k,_,v);case 1:return s(p,k,_,v);case 3:return l(p,k,_,v)}}function s(p,k,x,_){let{base_:v,assigned_:S}=p,E=p.copy_;E.length<v.length&&([v,E]=[E,v],[x,_]=[_,x]);const I=p.allIndicesReassigned_===!0;for(let y=0;y<v.length;y++){const P=E[y],T=v[y];if((I||S?.get(y.toString()))&&P!==T){const b=P?.[ee];if(b&&b.modified_)continue;const N=k.concat([y]);x.push({op:r,path:N,value:d(P)}),_.push({op:r,path:N,value:d(T)})}}for(let y=v.length;y<E.length;y++){const P=k.concat([y]);x.push({op:i,path:P,value:d(E[y])})}for(let y=E.length-1;v.length<=y;--y){const P=k.concat([y]);_.push({op:a,path:P})}}function u(p,k,x,_){const{base_:v,copy_:S,type_:E}=p;Vt(p.assigned_,(I,y)=>{const P=$e(v,I,E),T=$e(S,I,E),z=y?Et(v,I)?r:i:a;if(P===T&&z===r)return;const b=k.concat(I);x.push(z===a?{op:z,path:b}:{op:z,path:b,value:d(T)}),_.push(z===i?{op:a,path:b}:z===a?{op:i,path:b,value:d(P)}:{op:r,path:b,value:d(P)})})}function l(p,k,x,_){let{base_:v,copy_:S}=p,E=0;v.forEach(I=>{if(!S.has(I)){const y=k.concat([E]);x.push({op:a,path:y,value:I}),_.unshift({op:i,path:y,value:I})}E++}),E=0,S.forEach(I=>{if(!v.has(I)){const y=k.concat([E]);x.push({op:i,path:y,value:I}),_.unshift({op:a,path:y,value:I})}E++})}function f(p,k,x){const{patches_:_,inversePatches_:v}=x;_.push({op:r,path:[],value:k===wr?void 0:k}),v.push({op:r,path:[],value:p})}function c(p,k){return k.forEach(x=>{const{path:_,op:v}=x;let S=p;for(let P=0;P<_.length-1;P++){const T=Xe(S);let z=_[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===Tt)&&ie(19),Ge(S)&&z===Lt&&ie(19),S=$e(S,z),dt(S)||ie(18,_.join(\"/\"))}const E=Xe(S),I=h(x.value),y=_[_.length-1];switch(v){case r:switch(E){case 2:return S.set(y,I);case 3:ie(16);default:return S[y]=I}case i:switch(E){case 1:return y===\"-\"?S.push(I):S.splice(y,0,I);case 2:return S.set(y,I);case 3:return S.add(I);default:return S[y]=I}case a:switch(E){case 1:return S.splice(y,1);case 2:return S.delete(y);case 3:return S.delete(x.value);default:return delete S[y]}default:ie(17,v)}}),p}function h(p){if(!Te(p))return p;if(Bt(p))return p.map(h);if(Ht(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,h(_)]));if(qt(p))return new Set(Array.from(p).map(h));const k=Object.create(Ze(p));for(const x in p)k[x]=h(p[x]);return Et(p,It)&&(k[It]=p[It]),k}function d(p){return Re(p)?h(p):p}js(fn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var zt=new el,rl=zt.produce,il=zt.produceWithPatches.bind(zt),lt=zt.applyPatches.bind(zt);const al=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?rl(i):i;return t(s,a,...o)},e(r.setState,n,r)),ol=al,sl=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\"]),ll=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function ul(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 _i(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 yi(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 cl(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;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;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 mt(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 p=yi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.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 f=e.slice(l,n);n+=2;const{display:c,target:h}=ul(f),d={type:\"link\",display:c,target:h,start:a,end:n};o&&(d.className=o),s&&(d.id=s),t.push(d),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=yi(e,n+1);s=l.className||void 0,u=l.id||void 0;let f=l.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:d,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:d,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:d,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let h=1;const d=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=a+1,r=a;continue}const p=e.slice(d,n);n++;const{name:k,rawArgs:x,isClose:_}=_i(p),v={type:\"macro\",name:k,rawArgs:x,isClose:_,start:a,end:n};s&&(v.className=s),u&&(v.id=u),t.push(v),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 f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,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 f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,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 f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,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 f=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(f,n);n++;const{name:h,rawArgs:d,isClose:p}=_i(c);t.push({type:\"macro\",name:h,rawArgs:d,isClose:p,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&&sl.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 f=cl(e,o);o=f.endIdx;let c=ll.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Na=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function fl(e){Na.add(e.toLowerCase())}const bi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},dl=new Set([\"if\",\"switch\",\"timed\"]);function _t(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 o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);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\":{const a=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(bi[a]){const o=bi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const u={rawArgs:i.rawArgs,children:[]};i.className&&(u.className=i.className),i.id&&(u.id=i.id),s.branches.push(u);break}if(Na.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(dl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}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 xr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=ce(He);return de(()=>[e,t,n],[e,t,n])}const hl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,pl=/\\{[\\$_@][\\w.]+\\}/;function Da(e){return pl.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 $a(e,t,n,r){return e.replace(hl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let f;return o===\"$\"?f=t[l]:o===\"_\"?f=n[l]:f=r[l],u.length>1&&(f=gl(f,u)),f==null?\"\":String(f)})}function Cr(){const[e,t,n]=xr();return ve(r=>r===void 0||!Da(r)?r:$a(r,e,t,n),[e,t,n])}function ml({name:e,scope:t,className:n,id:r}){const i=Cr();n=i(n),r=i(r);const a=ce(He),o=e.split(\".\"),s=o[0],u=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=o[c];l=l[h]}const f=l==null?\"\":String(l);return n||r?w(\"span\",{id:r,class:n,children:f}):w(G,{children:f})}function za(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 Fa(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let yt=!1,Ut=\"\",tt=0,ht=null;function _l(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Ut=n,tt=0,ht=za(Fa(n)),yt=!0}function Ra(e,t){Ut=e,tt=0,ht=za(Fa(e)),yt=!0;for(let n=0;n<t;n++)ht();tt=t}function tr(){yt=!1,Ut=\"\",tt=0,ht=null}function gn(){return yt?{seed:Ut,pull:tt}:null}function Ir(){return!yt||!ht?Math.random():(tt++,ht())}function Oa(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Ir()*(t-e+1))+e}function yl(){return yt}function bl(){return Ut}function vl(){return tt}const wl=500,We=new Map,kl=/\\$(\\w+)/g,Sl=/\\b_(\\w+)/g,xl=/@(\\w+)/g;function Cl(e){return e.replace(kl,'variables[\"$1\"]').replace(Sl,'temporary[\"$1\"]').replace(xl,'locals[\"$1\"]')}function Er(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Cl(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+=Er(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 Il=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Ma(e,t){const n=We.get(e);if(n)return We.delete(e),We.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Il+t);if(We.set(e,r),We.size>wl){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let Yt=null,vi=null,wi=null;function La(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(Yt&&vi===t&&wi===n)return Yt;const r=d=>t[d??C.getState().currentPassage]??0,i=d=>r(d)>0,a=(...d)=>d.some(p=>r(p)>0),o=(...d)=>d.every(p=>r(p)>0),s=d=>n[d??C.getState().currentPassage]??0;return Yt={currentPassage:()=>{const d=C.getState();return d.storyData?.passages.get(d.currentPassage)},previousPassage:()=>{const d=C.getState();if(d.historyIndex<=0)return;const p=d.history[d.historyIndex-1]?.passage;return p?d.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:d=>s(d)>0,hasRenderedAny:(...d)=>d.some(p=>s(p)>0),hasRenderedAll:(...d)=>d.every(p=>s(p)>0),random:Ir,randomInt:Oa},vi=t,wi=n,Yt}function wn(e,t,n,r={}){const a=`return (${Er(e)});`;return Ma(a,a)(t,n,r,La())}function Va(e,t,n,r={}){const i=Er(e);Ma(\"exec:\"+i,i)(t,n,r,La())}function El(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 Al({body:e,parentValues:t,ownKeys:n}){const r=ce(Ne),[i,a]=Z({}),o={...t,...n,...i},s=ue(o);s.current=o;const u=ve(()=>s.current,[]),l=ve((c,h)=>{a(d=>({...d,[c]:h}))},[]),f=de(()=>({update:l,getValues:u}),[l,u]);return w(jt.Provider,{value:f,children:w(He.Provider,{value:o,children:xe(e,r?{nobr:!0}:void 0)})})}function Pl({body:e,params:t,rawArgs:n}){const r=ce(He),i=ce(Ne),[a,o,s]=xr();if(t.length===0||!n)return w(G,{children:xe(e,i?{nobr:!0}:void 0)});const u=El(n),l={};for(let f=0;f<t.length;f++){const c=t[f],h=u[f];let d;if(h!==void 0)try{d=wn(h,a,o,s)}catch{d=void 0}l[c.startsWith(\"@\")?c.slice(1):c]=d}return w(Al,{body:e,parentValues:r,ownKeys:l})}const Ba=new Map;function Ha(e,t,n){Ba.set(e.toLowerCase(),{body:t,params:n})}function Tl(e){return Ba.get(e.toLowerCase())}const qa=new Map;function Nl(e,t){qa.set(e.toLowerCase(),t)}function Dl(e){return qa.get(e.toLowerCase())}const Ua=new Set;function $l(e){Ua.add(e.toLowerCase())}function zl(e){return Ua.has(e.toLowerCase())}const ki=document.createElement(\"i\");function ja(e){const t=\"&\"+e+\";\";ki.innerHTML=t;const n=ki.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function ge(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 re(e,t){return e.length>0?(ge(e,e.length,0,t),e):t}const nr={}.hasOwnProperty;function Fl(e){const t={};let n=-1;for(;++n<e.length;)Rl(t,e[n]);return t}function Rl(e,t){let n;for(n in t){const i=(nr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){nr.call(i,o)||(i[o]=[]);const s=a[o];Ol(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Ol(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);ge(e,0,0,r)}function Ml(e){const t={};let n=-1;for(;++n<e.length;)Ll(t,e[n]);return t}function Ll(e,t){let n;for(n in t){const i=(nr.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 Vl(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 Bl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Wa(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Bl[n]+\";\"}}function Ft(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Ee=Be(/[A-Za-z]/),pe=Be(/[\\dA-Za-z]/),Hl=Be(/[#-'*+\\--9=?A-Z^-~]/);function rr(e){return e!==null&&(e<32||e===127)}const ir=Be(/\\d/),ql=Be(/[\\dA-Fa-f]/),Ul=Be(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function ae(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const jl=Be(/\\p{P}|\\p{S}/u),Wl=Be(/\\s/);function Be(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Kt(e,t){const n=Wa(Ql(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 Ql(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&pe(e.charCodeAt(n+1))&&pe(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 Si={}.hasOwnProperty,xi=/^(https?|ircs?|mailto|xmpp)$/i,Gl=/^https?$/i;function Yl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Ml([{enter:{blockQuote:M,codeFenced:we,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:Lo,content:Eo,definition:wo,definitionDestinationString:So,definitionLabelString:x,definitionTitleString:x,emphasis:Oo,htmlFlow:Ro,htmlText:Lr,image:q,label:x,link:oe,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:Y,reference:x,resource:at,resourceDestinationString:ot,resourceTitleString:x,setextHeading:Po,strong:Mo},exit:{atxHeading:No,atxHeadingSequence:Ao,autolinkEmail:Wo,autolinkProtocol:jo,blockQuote:J,characterEscapeValue:vt,characterReferenceMarkerHexadecimal:Vr,characterReferenceMarkerNumeric:Vr,characterReferenceValue:Uo,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Fo,codeIndented:g,codeText:Vo,codeTextData:vt,data:vt,definition:Io,definitionDestinationString:xo,definitionLabelString:ko,definitionTitleString:Co,emphasis:Bo,hardBreakEscape:Or,hardBreakTrailing:Or,htmlFlow:Mr,htmlFlowData:vt,htmlText:Mr,htmlTextData:vt,image:Rr,label:bt,labelText:X,lineEnding:zo,link:Rr,listOrdered:$,listUnordered:B,paragraph:fe,reference:P,referenceString:Oe,resource:P,resourceDestinationString:En,resourceTitleString:vo,setextHeading:$o,setextHeadingLineSequence:Do,setextHeadingText:To,strong:Ho,thematicBreak:qo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},f={buffer:x,encode:y,getData:k,lineEndingIfNeeded:I,options:t,raw:S,resume:_,setData:p,tag:v};let c=t.defaultLineEnding;return h;function h(A){let F=-1,te=0;const ke=[];let Ce=[],De=[];for(;++F<A.length;)!c&&(A[F][1].type===\"lineEnding\"||A[F][1].type===\"lineEndingBlank\")&&(c=A[F][2].sliceSerialize(A[F][1])),(A[F][1].type===\"listOrdered\"||A[F][1].type===\"listUnordered\")&&(A[F][0]===\"enter\"?ke.push(F):d(A.slice(ke.pop(),F))),A[F][1].type===\"definition\"&&(A[F][0]===\"enter\"?(De=re(De,A.slice(te,F)),te=F):(Ce=re(Ce,A.slice(te,F+1)),te=F+1));Ce=re(Ce,De),Ce=re(Ce,A.slice(te)),F=-1;const Ie=Ce;for(u.enter.null&&u.enter.null.call(f);++F<A.length;){const Br=u[Ie[F][0]],Hr=Ie[F][1].type,qr=Br[Hr];Si.call(Br,Hr)&&qr&&qr.call({sliceSerialize:Ie[F][2].sliceSerialize,...f},Ie[F][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function d(A){const F=A.length;let te=0,ke=0,Ce=!1,De;for(;++te<F;){const Ie=A[te];if(Ie[1]._container)De=void 0,Ie[0]===\"enter\"?ke++:ke--;else switch(Ie[1].type){case\"listItemPrefix\":{Ie[0]===\"exit\"&&(De=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ie[0]===\"enter\"&&!ke&&(De?De=void 0:Ce=!0);break}default:De=void 0}}A[0][1]._loose=Ce}function p(A,F){l[A]=F}function k(A){return l[A]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function v(A){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(A))}function S(A){p(\"lastWasTag\"),i[i.length-1].push(A)}function E(){S(c||`\n`)}function I(){const A=i[i.length-1],F=A[A.length-1],te=F?F.charCodeAt(F.length-1):null;te===10||te===13||te===null||E()}function y(A){return k(\"ignoreEncode\")?A:Wa(A)}function P(){_()}function T(A){o.push(!A._loose),I(),v(\"<ol\"),p(\"expectFirstItem\",!0)}function z(A){o.push(!A._loose),I(),v(\"<ul\"),p(\"expectFirstItem\",!0)}function b(A){if(k(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(A),10);F!==1&&v(' start=\"'+y(String(F))+'\"')}}function N(){k(\"expectFirstItem\")?v(\">\"):U(),I(),v(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),E(),v(\"</ol>\")}function B(){U(),o.pop(),E(),v(\"</ul>\")}function U(){k(\"lastWasTag\")&&!k(\"slurpAllLineEndings\")&&I(),v(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),I(),v(\"<blockquote>\")}function J(){o.pop(),I(),v(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function Y(){o[o.length-1]||(I(),v(\"<p>\")),p(\"slurpAllLineEndings\")}function fe(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):v(\"</p>\")}function we(){I(),v(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const A=_();v(' class=\"language-'+A+'\"')}function D(){const A=k(\"fencesCount\")||0;A||(v(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",A+1)}function j(){I(),v(\"<pre><code>\")}function g(){const A=k(\"fencesCount\");A!==void 0&&A<2&&l.tightStack.length>0&&!k(\"lastWasTag\")&&E(),k(\"flowCodeSeenData\")&&I(),v(\"</code></pre>\"),A!==void 0&&A<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function oe(){a.push({})}function X(A){a[a.length-1].labelId=this.sliceSerialize(A)}function bt(){a[a.length-1].label=_()}function Oe(A){a[a.length-1].referenceId=this.sliceSerialize(A)}function at(){x(),a[a.length-1].destination=\"\"}function ot(){x(),p(\"ignoreEncode\",!0)}function En(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function vo(){a[a.length-1].title=_()}function Rr(){let A=a.length-1;const F=a[A],te=F.referenceId||F.labelId,ke=F.destination===void 0?r[Ft(te)]:F;for(n=!0;A--;)if(a[A].image){n=void 0;break}F.image?(v('<img src=\"'+Kt(ke.destination,t.allowDangerousProtocol?void 0:Gl)+'\" alt=\"'),S(F.label),v('\"')):v('<a href=\"'+Kt(ke.destination,t.allowDangerousProtocol?void 0:xi)+'\"'),v(ke.title?' title=\"'+ke.title+'\"':\"\"),F.image?v(\" />\"):(v(\">\"),S(F.label),v(\"</a>\")),a.pop()}function wo(){x(),a.push({})}function ko(A){_(),a[a.length-1].labelId=this.sliceSerialize(A)}function So(){x(),p(\"ignoreEncode\",!0)}function xo(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function Co(){a[a.length-1].title=_()}function Io(){const A=a[a.length-1],F=Ft(A.labelId);_(),Si.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Eo(){p(\"slurpAllLineEndings\",!0)}function Ao(A){k(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(A).length),I(),v(\"<h\"+k(\"headingRank\")+\">\"))}function Po(){x(),p(\"slurpAllLineEndings\")}function To(){p(\"slurpAllLineEndings\",!0)}function No(){v(\"</h\"+k(\"headingRank\")+\">\"),p(\"headingRank\")}function Do(A){p(\"headingRank\",this.sliceSerialize(A).charCodeAt(0)===61?1:2)}function $o(){const A=_();I(),v(\"<h\"+k(\"headingRank\")+\">\"),S(A),v(\"</h\"+k(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function vt(A){S(y(this.sliceSerialize(A)))}function zo(A){if(!k(\"slurpAllLineEndings\")){if(k(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(k(\"inCodeText\")){S(\" \");return}S(y(this.sliceSerialize(A)))}}function Fo(A){S(y(this.sliceSerialize(A))),p(\"flowCodeSeenData\",!0)}function Or(){v(\"<br />\")}function Ro(){I(),Lr()}function Mr(){p(\"ignoreEncode\")}function Lr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Oo(){v(\"<em>\")}function Mo(){v(\"<strong>\")}function Lo(){p(\"inCodeText\",!0),v(\"<code>\")}function Vo(){p(\"inCodeText\"),v(\"</code>\")}function Bo(){v(\"</em>\")}function Ho(){v(\"</strong>\")}function qo(){I(),v(\"<hr />\")}function Vr(A){p(\"characterReferenceType\",A.type)}function Uo(A){const F=this.sliceSerialize(A),te=k(\"characterReferenceType\")?Vl(F,k(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):ja(F);S(y(te)),p(\"characterReferenceType\")}function jo(A){const F=this.sliceSerialize(A);v('<a href=\"'+Kt(F,t.allowDangerousProtocol?void 0:xi)+'\">'),S(y(F)),v(\"</a>\")}function Wo(A){const F=this.sliceSerialize(A);v('<a href=\"'+Kt(\"mailto:\"+F)+'\">'),S(y(F)),v(\"</a>\")}}function H(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 Kl={tokenize:Jl};function Jl(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\"),H(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 R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Zl={tokenize:Xl},Ci={tokenize:eu};function Xl(e){const t=this,n=[];let r=0,i,a,o;return s;function s(S){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,u,l)(S)}return l(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const E=t.events.length;let I=E,y;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){y=t.events[I][1].end;break}_(r);let P=E;for(;P<t.events.length;)t.events[P][1].end={...y},P++;return ge(t.events,I+1,0,t.events.slice(E)),t.events.length=P,l(S)}return s(S)}function l(S){if(r===n.length){if(!i)return h(S);if(i.currentConstruct&&i.currentConstruct.concrete)return p(S);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ci,f,c)(S)}function f(S){return i&&v(),_(r),h(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(S)}function h(S){return t.containerState={},e.attempt(Ci,d,p)(S)}function d(S){return r++,n.push([t.currentConstruct,t.containerState]),h(S)}function p(S){if(S===null){i&&v(),_(0),e.consume(S);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),k(S)}function k(S){if(S===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(S);return}return R(S)?(e.consume(S),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(S),k)}function x(S,E){const I=t.sliceStream(S);if(E&&I.push(null),S.previous=a,a&&(a.next=S),a=S,i.defineSkip(S.start),i.write(I),t.parser.lazy[S.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const P=t.events.length;let T=P,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(_(r),y=P;y<t.events.length;)t.events[y][1].end={...b},y++;ge(t.events,T+1,0,t.events.slice(P)),t.events.length=y}}function _(S){let E=n.length;for(;E-- >S;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=S}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function eu(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function mn(e){if(e===null||ae(e)||Wl(e))return 1;if(jl(e))return 2}function kn(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 ar={name:\"attention\",resolveAll:tu,tokenize:nu};function tu(e,t){let n=-1,r,i,a,o,s,u,l,f;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},h={...e[n][1].start};Ii(c,-u),Ii(h,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:h},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=re(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=re(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=re(l,kn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=re(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=re(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,ge(e,r-1,n-r+3,l),n=r+l.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function nu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=mn(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\"),f=mn(u),c=!f||f===2&&i||n.includes(u),h=!i||i===2&&f||n.includes(r);return l._open=!!(a===42?c:c&&(i||!h)),l._close=!!(a===42?h:h&&(f||!c)),t(u)}}function Ii(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ru={name:\"autolink\",tokenize:iu};function iu(e,t,n){let r=0;return i;function i(d){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(d){return Ee(d)?(e.consume(d),o):d===64?n(d):l(d)}function o(d){return d===43||d===45||d===46||pe(d)?(r=1,s(d)):l(d)}function s(d){return d===58?(e.consume(d),r=0,u):(d===43||d===45||d===46||pe(d))&&r++<32?(e.consume(d),s):(r=0,l(d))}function u(d){return d===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d===null||d===32||d===60||rr(d)?n(d):(e.consume(d),u)}function l(d){return d===64?(e.consume(d),f):Hl(d)?(e.consume(d),l):n(d)}function f(d){return pe(d)?c(d):n(d)}function c(d){return d===46?(e.consume(d),r=0,f):d===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(d),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(d)}function h(d){if((d===45||pe(d))&&r++<63){const p=d===45?h:c;return e.consume(d),p}return n(d)}}const Sn={partial:!0,tokenize:au};function au(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const Qa={continuation:{tokenize:su},exit:lu,name:\"blockQuote\",tokenize:ou};function ou(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 su(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Qa,t,n)(o)}}function lu(e){e.exit(\"blockQuote\")}const Ga={name:\"characterEscape\",tokenize:uu};function uu(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 Ul(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Ya={name:\"characterReference\",tokenize:cu};function cu(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=pe,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=ql,f):(e.enter(\"characterReferenceValue\"),a=7,o=ir,f(c))}function f(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===pe&&!ja(r.sliceSerialize(h))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),f):n(c)}}const Ei={partial:!0,tokenize:du},Ai={concrete:!0,name:\"codeFenced\",tokenize:fu};function fu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(y)}function f(y){return y===s?(o++,e.consume(y),f):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),L(y)?H(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||R(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(Ei,k,E)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(y))}function h(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):L(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,d,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),h)}function d(y){return y===null||R(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function k(y){return e.attempt(i,E,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&L(y)?H(e,v,\"linePrefix\",a+1)(y):v(y)}function v(y){return y===null||R(y)?e.check(Ei,k,E)(y):(e.enter(\"codeFlowValue\"),S(y))}function S(y){return y===null||R(y)?(e.exit(\"codeFlowValue\"),v(y)):(e.consume(y),S)}function E(y){return e.exit(\"codeFenced\"),t(y)}function I(y,P,T){let z=0;return b;function b(M){return y.enter(\"lineEnding\"),y.consume(M),y.exit(\"lineEnding\"),N}function N(M){return y.enter(\"codeFencedFence\"),L(M)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(y.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,y.consume(M),B):z>=o?(y.exit(\"codeFencedFenceSequence\"),L(M)?H(y,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(y.exit(\"codeFencedFence\"),P(M)):T(M)}}}function du(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 Dn={name:\"codeIndented\",tokenize:pu},hu={partial:!0,tokenize:gu};function pu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(hu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function gu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(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):R(o)?i(o):n(o)}}const mu={name:\"codeText\",previous:yu,resolve:_u,tokenize:bu};function _u(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 yu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function bu(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,f(c)):R(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||R(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class vu{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&&wt(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),wt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wt(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);wt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wt(this.left,n.reverse())}}}function wt(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 Ka(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new vu(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type===\"chunkFlow\"&&f.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,wu(f,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=f.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(f.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={...f.get(i)[1].start},s=f.slice(i,n),s.unshift(r),f.splice(i,n-i+1,s))}}return ge(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function wu(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 f,c,h=-1,d=n,p=0,k=0;const x=[k];for(;d;){for(;e.get(++i)[1]!==d;);a.push(i),d._tokenizer||(f=r.sliceStream(d),d.next||f.push(null),c&&o.defineSkip(d.start),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(f),d._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=d,d=d.next}for(d=n;++h<s.length;)s[h][0]===\"exit\"&&s[h-1][0]===\"enter\"&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(k=h+1,x.push(k),d._tokenizer=void 0,d.previous=void 0,d=d.next);for(o.events=[],d?(d._tokenizer=void 0,d.previous=void 0):x.pop(),h=x.length;h--;){const _=s.slice(x[h],x[h+1]),v=a.pop();u.push([v,v+_.length-1]),e.splice(v,2,_)}for(u.reverse(),h=-1;++h<u.length;)l[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return l}const ku={resolve:xu,tokenize:Cu},Su={partial:!0,tokenize:Iu};function xu(e){return Ka(e),e}function Cu(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):R(s)?e.check(Su,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 Iu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||R(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 Ja(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),h):_===null||_===32||_===41||rr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),k(_))}function h(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),d(_))}function d(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),h(_)):_===null||_===60||R(_)?n(_):(e.consume(_),_===92?p:d)}function p(_){return _===60||_===62||_===92?(e.consume(_),d):d(_)}function k(_){return!f&&(_===null||_===41||ae(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):f<l&&_===40?(e.consume(_),f++,k):_===41?(e.consume(_),f--,k):_===null||_===32||_===40||rr(_)?n(_):(e.consume(_),_===92?x:k)}function x(_){return _===40||_===41||_===92?(e.consume(_),k):k(_)}}function Za(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(d){return e.enter(r),e.enter(i),e.consume(d),e.exit(i),e.enter(a),f}function f(d){return s>999||d===null||d===91||d===93&&!u||d===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(d):d===93?(e.exit(a),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):R(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(d))}function c(d){return d===null||d===91||d===93||R(d)||s++>999?(e.exit(\"chunkString\"),f(d)):(e.consume(d),u||(u=!L(d)),d===92?h:c)}function h(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function Xa(e,t,n,r,i,a){let o;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,u):n(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),l(h))}function l(h){return h===o?(e.exit(a),u(o)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(h))}function f(h){return h===o||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?c:f)}function c(h){return h===o||h===92?(e.consume(h),f):f(h)}}function At(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Eu={name:\"definition\",tokenize:Pu},Au={partial:!0,tokenize:Tu};function Pu(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return Za.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Ft(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(e.enter(\"definitionMarker\"),e.consume(d),e.exit(\"definitionMarker\"),u):n(d)}function u(d){return ae(d)?At(e,l)(d):l(d)}function l(d){return Ja(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(Au,c,c)(d)}function c(d){return L(d)?H(e,h,\"whitespace\")(d):h(d)}function h(d){return d===null||R(d)?(e.exit(\"definition\"),r.parser.defined.push(i),t(d)):n(d)}}function Tu(e,t,n){return r;function r(s){return ae(s)?At(e,i)(s):n(s)}function i(s){return Xa(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||R(s)?t(s):n(s)}}const Nu={name:\"hardBreakEscape\",tokenize:Du};function Du(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const $u={name:\"headingAtx\",resolve:zu,tokenize:Fu};function zu(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\"},ge(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Fu(e,t,n){let r=0;return i;function i(f){return e.enter(\"atxHeading\"),a(f)}function a(f){return e.enter(\"atxHeadingSequence\"),o(f)}function o(f){return f===35&&r++<6?(e.consume(f),o):f===null||ae(f)?(e.exit(\"atxHeadingSequence\"),s(f)):n(f)}function s(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||R(f)?(e.exit(\"atxHeading\"),t(f)):L(f)?H(e,s,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),s(f))}function l(f){return f===null||f===35||ae(f)?(e.exit(\"atxHeadingText\"),s(f)):(e.consume(f),l)}}const Ru=[\"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\"],Pi=[\"pre\",\"script\",\"style\",\"textarea\"],Ou={concrete:!0,name:\"htmlFlow\",resolveTo:Vu,tokenize:Bu},Mu={partial:!0,tokenize:qu},Lu={partial:!0,tokenize:Hu};function Vu(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 Bu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return f(g)}function f(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,k):g===63?(e.consume(g),i=3,r.interrupt?t:m):Ee(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function h(g){return g===45?(e.consume(g),i=2,d):g===91?(e.consume(g),i=5,s=0,p):Ee(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function d(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:p):n(g)}function k(g){return Ee(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function x(g){if(g===null||g===47||g===62||ae(g)){const q=g===47,oe=o.toLowerCase();return!q&&!a&&Pi.includes(oe)?(i=1,r.interrupt?t(g):$(g)):Ru.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?v(g):S(g))}return g===45||pe(g)?(e.consume(g),o+=String.fromCharCode(g),x):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function v(g){return L(g)?(e.consume(g),v):b(g)}function S(g){return g===47?(e.consume(g),b):g===58||g===95||Ee(g)?(e.consume(g),E):L(g)?(e.consume(g),S):b(g)}function E(g){return g===45||g===46||g===58||g===95||pe(g)?(e.consume(g),E):I(g)}function I(g){return g===61?(e.consume(g),y):L(g)?(e.consume(g),I):S(g)}function y(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),y):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||ae(g)?I(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?S(g):n(g)}function b(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),J):g===60&&i===1?(e.consume(g),Y):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),we):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Mu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Lu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function J(g){return g===45?(e.consume(g),m):$(g)}function Y(g){return g===47?(e.consume(g),o=\"\",fe):$(g)}function fe(g){if(g===62){const q=o.toLowerCase();return Pi.includes(q)?(e.consume(g),D):$(g)}return Ee(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),fe):$(g)}function we(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function Hu(e,t,n){const r=this;return i;function i(o){return R(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 qu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Sn,t,n)}}const Uu={name:\"htmlText\",tokenize:ju};function ju(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),I):m===63?(e.consume(m),S):Ee(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,p):Ee(m)?(e.consume(m),v):n(m)}function f(m){return m===45?(e.consume(m),d):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(o=c,Y(m)):(e.consume(m),c)}function h(m){return m===45?(e.consume(m),d):c(m)}function d(m){return m===62?J(m):m===45?h(m):c(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(a++)?(e.consume(m),a===D.length?k:p):n(m)}function k(m){return m===null?n(m):m===93?(e.consume(m),x):R(m)?(o=k,Y(m)):(e.consume(m),k)}function x(m){return m===93?(e.consume(m),_):k(m)}function _(m){return m===62?J(m):m===93?(e.consume(m),_):k(m)}function v(m){return m===null||m===62?J(m):R(m)?(o=v,Y(m)):(e.consume(m),v)}function S(m){return m===null?n(m):m===63?(e.consume(m),E):R(m)?(o=S,Y(m)):(e.consume(m),S)}function E(m){return m===62?J(m):S(m)}function I(m){return Ee(m)?(e.consume(m),y):n(m)}function y(m){return m===45||pe(m)?(e.consume(m),y):P(m)}function P(m){return R(m)?(o=P,Y(m)):L(m)?(e.consume(m),P):J(m)}function T(m){return m===45||pe(m)?(e.consume(m),T):m===47||m===62||ae(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),J):m===58||m===95||Ee(m)?(e.consume(m),b):R(m)?(o=z,Y(m)):L(m)?(e.consume(m),z):J(m)}function b(m){return m===45||m===46||m===58||m===95||pe(m)?(e.consume(m),b):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(o=N,Y(m)):L(m)?(e.consume(m),N):z(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,B):R(m)?(o=$,Y(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(o=B,Y(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||ae(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||ae(m)?z(m):n(m)}function J(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\"),fe}function fe(m){return L(m)?H(e,we,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):we(m)}function we(m){return e.enter(\"htmlTextData\"),o(m)}}const Ar={name:\"labelEnd\",resolveAll:Yu,resolveTo:Ku,tokenize:Ju},Wu={tokenize:Zu},Qu={tokenize:Xu},Gu={tokenize:ec};function Yu(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&&ge(e,0,e.length,n),e}function Ku(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}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=re(s,e.slice(a+1,a+r+3)),s=re(s,[[\"enter\",f,t]]),s=re(s,kn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=re(s,[[\"exit\",f,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=re(s,e.slice(o+1)),s=re(s,[[\"exit\",u,t]]),ge(e,a,e.length,s),e}function Ju(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(h){return a?a._inactive?c(h):(o=r.parser.defined.includes(Ft(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(h)}function u(h){return h===40?e.attempt(Wu,f,o?f:c)(h):h===91?e.attempt(Qu,f,o?l:c)(h):o?f(h):c(h)}function l(h){return e.attempt(Gu,f,c)(h)}function f(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function Zu(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 ae(c)?At(e,a)(c):a(c)}function a(c){return c===41?f(c):Ja(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ae(c)?At(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Xa(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return ae(c)?At(e,f)(c):f(c)}function f(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Xu(e,t,n){const r=this;return i;function i(s){return Za.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Ft(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function ec(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 tc={name:\"labelStartImage\",resolveAll:Ar.resolveAll,tokenize:nc};function nc(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 rc={name:\"labelStartLink\",resolveAll:Ar.resolveAll,tokenize:ic};function ic(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 $n={name:\"lineEnding\",tokenize:ac};function ac(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const rn={name:\"thematicBreak\",tokenize:oc};function oc(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||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?H(e,s,\"whitespace\")(l):s(l))}}const le={continuation:{tokenize:cc},exit:dc,name:\"list\",tokenize:uc},sc={partial:!0,tokenize:hc},lc={partial:!0,tokenize:fc};function uc(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(d){const p=r.containerState.type||(d===42||d===43||d===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||d===r.containerState.marker:ir(d)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),d===42||d===45?e.check(rn,n,l)(d):l(d);if(!r.interrupt||d===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(d)}return n(d)}function u(d){return ir(d)&&++o<10?(e.consume(d),u):(!r.interrupt||o<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(e.exit(\"listItemValue\"),l(d)):n(d)}function l(d){return e.enter(\"listItemMarker\"),e.consume(d),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||d,e.check(Sn,r.interrupt?n:f,e.attempt(sc,h,c))}function f(d){return r.containerState.initialBlankLine=!0,a++,h(d)}function c(d){return L(d)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(d),e.exit(\"listItemPrefixWhitespace\"),h):n(d)}function h(d){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(d)}}function cc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Sn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(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(lc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(le,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function fc(e,t,n){const r=this;return H(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 dc(e){e.exit(this.containerState.type)}function hc(e,t,n){const r=this;return H(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 Ti={name:\"setextUnderline\",resolveTo:pc,tokenize:gc};function pc(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 gc(e,t,n){const r=this;let i;return a;function a(l){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!==\"lineEnding\"&&r.events[f][1].type!==\"linePrefix\"&&r.events[f][1].type!==\"content\"){c=r.events[f][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)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const mc={tokenize:_c};function _c(e){const t=this,n=e.attempt(Sn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ku,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 yc={resolveAll:to()},bc=eo(\"string\"),vc=eo(\"text\");function eo(e){return{resolveAll:to(e===\"text\"?wc: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(f){return l(f)?a(f):s(f)}function s(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),u}function u(f){return l(f)?(n.exit(\"data\"),a(f)):(n.consume(f),u)}function l(f){if(f===null)return!0;const c=i[f];let h=-1;if(c)for(;++h<c.length;){const d=c[h];if(!d.previous||d.previous.call(r,r.previous))return!0}return!1}}}function to(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 wc(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 kc={42:le,43:le,45:le,48:le,49:le,50:le,51:le,52:le,53:le,54:le,55:le,56:le,57:le,62:Qa},Sc={91:Eu},xc={[-2]:Dn,[-1]:Dn,32:Dn},Cc={35:$u,42:rn,45:[Ti,rn],60:Ou,61:Ti,95:rn,96:Ai,126:Ai},Ic={38:Ya,92:Ga},Ec={[-5]:$n,[-4]:$n,[-3]:$n,33:tc,38:Ya,42:ar,60:[ru,Uu],91:rc,92:[Nu,Ga],93:Ar,95:ar,96:mu},Ac={null:[ar,yc]},Pc={null:[42,95]},Tc={null:[]},Nc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Pc,contentInitial:Sc,disable:Tc,document:kc,flow:Cc,flowInitial:xc,insideSpan:Ac,string:Ic,text:Ec},Symbol.toStringTag,{value:\"Module\"}));function Dc(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:P(I),check:P(y),consume:v,enter:S,exit:E,interrupt:P(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:k,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:d,write:c};let f=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(N){return o=re(o,N),x(),o[o.length-1]!==null?[]:(T(t,0),l.events=kn(a,l.events,l),l.events)}function h(N,$){return zc(d(N),$)}function d(N){return $c(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:M}}function k(N){i[N.line]=N.column,b()}function x(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(N){f=f(N)}function v(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,b()):N!==-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=N}function S(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function E(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function I(N,$){T(N,$.from)}function y(N,$){$.restore()}function P(N,$){return B;function B(U,M,J){let Y,fe,we,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(X){return bt;function bt(Oe){const at=Oe!==null&&X[Oe],ot=Oe!==null&&X.null,En=[...Array.isArray(at)?at:at?[at]:[],...Array.isArray(ot)?ot:ot?[ot]:[]];return j(En)(Oe)}}function j(X){return Y=X,fe=0,X.length===0?J:g(X[fe])}function g(X){return bt;function bt(Oe){return m=z(),we=X,X.partial||(l.currentConstruct=X),X.name&&l.parser.constructs.disable.null.includes(X.name)?oe():X.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,oe)(Oe)}}function q(X){return N(we,m),M}function oe(X){return m.restore(),++fe<Y.length?g(Y[fe]):J}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&ge(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:J};function J(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function $c(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 zc(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 Fc(e){const r={constructs:Fl([Nc,...(e||{}).extensions||[]]),content:i(Kl),defined:[],document:i(Zl),flow:i(mc),lazy:{},string:i(bc),text:i(vc)};return r;function i(a){return o;function o(s){return Dc(r,a,s)}}}function Rc(e){for(;!Ka(e););return e}const Ni=/[\\0\\t\\n\\r]/g;function Oc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,f,c,h,d;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(Ni.lastIndex=c,l=Ni.exec(a),h=l&&l.index!==void 0?l.index:a.length,d=a.charCodeAt(h),!l){t=a.slice(c);break}if(d===10&&c===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<h&&(u.push(a.slice(c,h)),e+=h-c),d){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Mc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Yl(n)(Rc(Fc(n).document().write(Oc()(e,t,!0))))}const zn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Lc(){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=zn[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=zn[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,Vc)),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\"+zn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Vc(e,t){return t===\"|\"?t:e}class Bc{constructor(){this.map=[]}add(t,n,r){Hc(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 Hc(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 qc(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 Uc(){return{flow:{null:{name:\"table\",tokenize:jc,resolveAll:Wc}}}}function jc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?y:u;return B===y&&r.parser.lazy[r.now().line]?n(b):B(b)}function u(b){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(b)}function l(b){return b===124||(o=!0,a+=1),f(b)}function f(b){return b===null?n(b):R(b)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),d):n(b):L(b)?H(e,f,\"whitespace\")(b):(a+=1,o&&(o=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),o=!0,f):(e.enter(\"data\"),c(b)))}function c(b){return b===null||b===124||ae(b)?(e.exit(\"data\"),f(b)):(e.consume(b),b===92?h:c)}function h(b){return b===92||b===124?(e.consume(b),c):c(b)}function d(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),o=!1,L(b)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):p(b))}function p(b){return b===45||b===58?x(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),k):I(b)}function k(b){return L(b)?H(e,x,\"whitespace\")(b):x(b)}function x(b){return b===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),_):b===45?(a+=1,_(b)):b===null||R(b)?E(b):I(b)}function _(b){return b===45?(e.enter(\"tableDelimiterFiller\"),v(b)):I(b)}function v(b){return b===45?(e.consume(b),v):b===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),S):(e.exit(\"tableDelimiterFiller\"),S(b))}function S(b){return L(b)?H(e,E,\"whitespace\")(b):E(b)}function E(b){return b===124?p(b):b===null||R(b)?!o||i!==a?I(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):I(b)}function I(b){return n(b)}function y(b){return e.enter(\"tableRow\"),P(b)}function P(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),P):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,P,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||ae(b)?(e.exit(\"data\"),P(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Wc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,f,c;const h=new Bc;for(;++n<e.length;){const d=e[n],p=d[1];d[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Di(h,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,f={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",f,t]])),i=p.type===\"tableDelimiterRow\"?2:f?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Jt(h,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Jt(h,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Jt(h,t,a,i,n,c)):o[1]!==0&&(c=Jt(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Di(h,t,u,l,f),h.consume(t.events),n=-1;++n<t.events.length;){const d=t.events[n];d[0]===\"enter\"&&d[1].type===\"table\"&&(d[1]._align=qc(t.events,n))}return e}function Jt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},st(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=st(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=st(t.events,n[2]),f=st(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const h=t.events[n[2]],d=t.events[n[3]];if(h[1].end=Object.assign({},d[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,k=n[3]-n[2]-1;e.add(p,k,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},st(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Di(e,t,n,r,i){const a=[],o=st(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 st(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Qc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Gc(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 f={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)},h=[[\"enter\",f,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],d=s.parser.constructs.insideSpan.null;d&&ge(h,h.length,0,kn(d,o.slice(l+1,u),s)),ge(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),ge(o,l-1,u-l+3,h),u=l+h.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,f=this.events;let c=0;return h;function h(p){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),d(p))}function d(p){const k=mn(l);if(p===126)return c>1?u(p):(o.consume(p),c++,d);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=mn(p);return x._open=!_||_===2&&!!k,x._close=!k||k===2&&!!_,s(p)}}}function Yc(e){return Mc(e,{allowDangerousHtml:!0,extensions:[Uc(),Gc()],htmlExtensions:[Lc(),Qc()]})}const Kc={update:()=>{},getValues:()=>({})},He=pt({}),jt=pt(Kc),Ne=pt(!1);function Jc(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>no(a,o,t));return w(G,{children:i})}function no(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,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)=>no(u,l,n));return K(i,o,...s)}return null}function Zc({node:e}){const t=Cr(),n=ce(Ne),r={};for(const[i,a]of Object.entries(e.attributes))r[i]=t(a)??a;return K(e.tag,r,e.children.length>0?xe(e.children,n?{nobr:!0}:void 0):void 0)}function Xc(e,t){if(zl(e.name))return null;const n=Tl(e.name);if(n)return w(Pl,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Dl(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function or(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return w(ml,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Xc(e,t);case\"html\":return w(Zc,{node:e},t);default:return e}}function ro(e){return e.length===0?null:e.map((t,n)=>or(t,n))}function ef(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function tf(e){const t=C.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 xe(e,t){if(e.length===0)return null;if(!e.some(o=>o.type===\"text\"))return e.map((o,s)=>or(o,s));const r=[];let i=\"\";for(let o=0;o<e.length;o++){const s=e[o];if(s.type===\"text\")i+=s.value.replace(/^[ \\t]{4,}/gm,\" \");else if(s.type===\"variable\"&&ef(i))i+=tf(s);else{const u=r.length;r.push(or(s,o)),i+=`<span data-tw=\"${u}\"></span>`}}const a=Yc(i);return Jc(a,r,t?.nobr)}const nf=\"spindle\",rf=1;let Zt=null,Fn=null;function qe(){return Fn||(Fn={saves:new Map,playthroughs:new Map,meta:new Map}),Fn}function af(){return Zt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Zt=new Promise((e,t)=>{const n=indexedDB.open(nf,rf);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)}),Zt))}function Ue(e,t){return af().then(n=>n.transaction(e,t).objectStore(e))}function je(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function xn(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.put(e))}catch{qe().saves.set(e.meta.id,e)}}async function Cn(e){try{const t=await Ue(\"saves\",\"readonly\");return await je(t.get(e))??void 0}catch{return qe().saves.get(e)}}async function of(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.delete(e))}catch{qe().saves.delete(e)}}async function sf(e){try{const n=(await Ue(\"saves\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().saves.values()].filter(t=>t.meta.ifid===e)}}async function io(e){try{const t=await Ue(\"playthroughs\",\"readwrite\");await je(t.put(e))}catch{qe().playthroughs.set(e.id,e)}}async function Pr(e){try{const n=(await Ue(\"playthroughs\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().playthroughs.values()].filter(t=>t.ifid===e)}}async function Tr(e){try{const t=await Ue(\"meta\",\"readonly\"),n=await je(t.get(e));return n?n.value:void 0}catch{return qe().meta.get(e)}}async function ao(e,t){try{const n=await Ue(\"meta\",\"readwrite\");await je(n.put({key:e,value:t}))}catch{qe().meta.set(e,t)}}const oo=new Map,In=new Map;function lf(e,t){oo.set(e,t),In.set(t,e)}function uf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ne(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(In.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(uf(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 sr=\"__spindle_class__\",lr=\"__spindle_data__\";function Ke(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=In.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[sr]:o,[lr]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Je(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(sr in r&&lr in r){const o=r[sr],s=r[lr],u=oo.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(s))f[c]=t(s[c]);return f}const l=Object.create(u.prototype);for(const f of Object.keys(s))l[f]=t(s[f]);return l}const i=r.constructor;if(In.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let ur=null,cr=null,$i=!1;function cf(e){ur=e}function ff(e){cr=e}function df(e){if(cr)try{const i=new Function(\"passage\",\"variables\",cr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(ur)try{const r=ur(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 hf(){$i||($i=!0)}async function zi(e){const n=(await Pr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await io(i),await ao(`currentPlaythroughId.${e}`,r),r}async function pf(e){return Tr(`currentPlaythroughId.${e}`)}async function so(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:df(n),passage:n.passage,custom:r},o=ne(n);o.variables=Ke(o.variables),o.history=o.history.map(u=>({...u,variables:Ke(u.variables)}));const s={meta:a,payload:o};return await xn(s),s}async function lo(e,t){const n=await Cn(e);if(!n)return;const r=ne(t);r.variables=Ke(r.variables),r.history=r.history.map(a=>({...a,variables:Ke(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await xn(i),i}async function gf(e){const t=await Cn(e);if(!t)return;const n=t.payload;return n.variables=Je(n.variables),n.history=n.history.map(r=>({...r,variables:Je(r.variables)})),n}async function mf(e){await of(e)}async function _f(e,t){const n=await Cn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await xn(r)}async function yf(e){const[t,n]=await Promise.all([sf(e),Pr(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 uo=\"autosave.\";async function bf(e,t,n){const r=`${uo}${e}`,i=await Tr(r);if(i){const o=await lo(i,n);if(o)return o}const a=await so(e,t,n,{isAutosave:!0});return await ao(r,a.meta.id),a}async function vf(e){const t=`${uo}${e}`,n=await Tr(t);if(n)return gf(n)}const Nr=\"spindle.session.\";function wf(e,t){try{sessionStorage.setItem(`${Nr}${e}`,JSON.stringify(t))}catch{}}function kf(e){try{const t=sessionStorage.getItem(`${Nr}${e}`);if(!t)return;const n=JSON.parse(t);return n.variables=Je(n.variables),n.history=n.history.map(r=>({...r,variables:Je(r.variables)})),n}catch{return}}function Sf(e){try{sessionStorage.removeItem(`${Nr}${e}`)}catch{}}async function xf(e){const t=await Cn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Cf(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=ne(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Pr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await io(a)}return await xn(n),n}function co(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=mt(t.content),i=_t(r),a=document.createElement(\"div\");be(K(()=>xe(i),null),a),be(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&ff(n.content)}let fo=0,ye=[],Rn=!1,rt=[],Pt=null,ut=null;function Dr(e){const t=C.getState();try{return!!wn(e,t.variables,t.temporary)}catch{return!1}}function ho(e,t){const n=fo++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:Dr(e),priority:i?.priority??0};return ye.push(o),ye.sort((s,u)=>u.priority-s.priority),()=>{ye=ye.filter(s=>s.id!==n)}}function po(e){ye=ye.filter(t=>t.name!==e)}function If(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Va(n.run,r.variables,r.temporary)}n.dialog&&(rt.push({passageName:n.dialog}),Pt?.()),n.goto&&C.getState().navigate(n.goto)}}const Ef=10;function Af(){if(!Rn){Rn=!0;try{for(let e=0;e<Ef;e++){let t=!1;const n=[...ye];for(const r of n){if(!ye.includes(r))continue;const i=Dr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ye=ye.filter(o=>o.id!==r.id)),If(r))}if(!t)break}}finally{Rn=!1}}}function Pf(){for(const e of ye)e.lastResult=Dr(e.condition)}function Tf(){ye=[],rt=[],fo=0,ut?.close()}function Nf(e){return Pt=e,rt.length>0&&e(),()=>{Pt===e&&(Pt=null)}}function Fi(){return rt.shift()}function Df(){return rt.length}function $f(e){rt.push(e),Pt?.()}function zf(){rt=[]}function Ff(e){return ut=e,()=>{ut===e&&(ut=null)}}function Ri(){ut?.close()}function Rf(){return ut?.isOpen()??!1}nl();const Of=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ye={},me=[],Me={};function Oi(e){return e.map(t=>({...t,value:t.value!==void 0?ne(t.value):void 0}))}function Mi(e,t){const[,n,r]=il(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:Oi(n),inverse:Oi(r)}}function Mf(e){let t=Ye;for(let n=0;n<e;n++)t=lt(t,me[n].forward);return t}let _e=[];function On(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(_e.length>i.length&&(_e.length=i.length),_e.length<i.length)if(i.length-_e.length===1){const l=i.length-1;_e[l]={passage:i[l].passage,variables:Ke(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ye;for(let f=0;f<i.length;f++)if(f>0&&(l=lt(l,me[f-1].forward)),f>=_e.length){const c=f===i.length-1?r:l;_e[f]={passage:i[f].passage,variables:Ke(c),timestamp:i[f].timestamp,prng:i[f].prng}}}wf(t.ifid,{passage:n,variables:Ke(r),history:_e,historyIndex:a,visitCounts:o,renderCounts:s,prng:gn()})}}function Li(e){Ye=e,me=[],Me=e,_e=[]}function Vi(e){e?.prng?Ra(e.prng.seed,e.prng.pull):e&&tr()}const C=Ls()(ol((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},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=ne(r);Li(ne(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Me=t().variables;const o=n.ifid;hf().then(async()=>{const s=await pf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await zi(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Of.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=Mi(Me,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),me.length=o.historyIndex,me.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:gn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ye=lt(Ye,me[u].forward);o.history=o.history.slice(s),me=me.slice(s),_e=_e.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Me=t().variables,On(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ne(lt(r,me[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Me=t().variables,Vi(t().history[t().historyIndex]),On(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ne(lt(i,me[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Me=t().variables,Vi(t().history[t().historyIndex]),On(t)},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;tr(),Tf();const a=ne(r);Li(ne(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Me=t().variables,co(),Sf(n.ifid),zi(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}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),bf(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),vf(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).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(),u=[];let l=Ye;for(let f=0;f<i.length;f++)f>0&&(l=lt(l,me[f-1].forward)),u.push({passage:i[f].passage,variables:ne(l),timestamp:i[f].timestamp,prng:i[f].prng});return{passage:n,variables:ne(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:gn()}},loadFromPayload:n=>{const r=Je(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=Je(n.history[o].variables);i.push(Mi(a,s)),a=s}Ye=ne(r),me=i,_e=[],e(o=>{o.currentPassage=n.passage,o.variables=Je(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=n.historyIndex,o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),Me=t().variables,n.prng?Ra(n.prng.seed,n.prng.pull):tr()},getHistoryVariables:n=>ne(Mf(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n}}))),Lf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Vf(){const t=C(i=>i.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Lf,r=t?.tags.includes(\"nobr\")??!1;try{const i=mt(n),a=_t(i),o=w(G,{children:ro(a)});return r?w(Ne.Provider,{value:!0,children:o}):o}catch(i){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",i.message]})}}const go=pt(null);function $r({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=C(c=>c.storyData),s=(e?a?.passages.get(e):void 0)?.content??t,u=de(()=>{if(!s)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=mt(s),h=_t(c);return xe(h)}catch(c){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",c.message]})}},[s]),l=c=>{c.target.classList.contains(\"dialog-overlay\")&&r()},f=n?`dialog-panel ${n}`:\"dialog-panel\";return w(go.Provider,{value:r,children:w(\"div\",{class:\"dialog-overlay\",onClick:l,children:w(\"div\",{class:f,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:u})]})})})}function Bf(){const[e,t]=Z(null),n=ue(e);n.current=e;const r=ve(()=>{const a=Fi();t(a??null)},[]),i=ve(()=>{t(null),Df()>0&&requestAnimationFrame(r)},[r]);return Se(()=>Ff({close:i,isOpen:()=>n.current!==null}),[i]),Se(()=>Nf(()=>{t(a=>a!==null?a:Fi()??null)}),[]),e?w($r,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton}):null}function Hf(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(Se(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),C.getState().save()):a.key===\"F9\"&&(a.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(G,{children:[w(Vf,{}),w(Bf,{})]});return n?w(Ne.Provider,{value:!0,children:r}):r}function qf(e){return e.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&#39;/g,\"'\").replace(/&amp;/g,\"&\")}function Uf(){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||\"\",f=new Map,c=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const d=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",k=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(E=>E.length>0),x=qf(h.innerHTML),_={},v=new Set([\"pid\",\"name\",\"tags\"]);for(const E of h.attributes)v.has(E.name)||(_[E.name]=E.value);const S={pid:d,name:p,tags:k,metadata:_,content:x};f.set(p,S),c.set(d,S)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:s,userScript:l}}const kt=new Map;let se={},Bi=!1;function mo(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function jf(){localStorage.setItem(mo(),JSON.stringify(se))}function Mn(){if(!Bi){Bi=!0;try{const e=localStorage.getItem(mo());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(se={...se,...t})}}catch{}}}const Rt={addToggle(e,t){kt.set(e,{type:\"toggle\",config:t}),e in se||(se[e]=t.default),Mn()},addList(e,t){kt.set(e,{type:\"list\",config:t}),e in se||(se[e]=t.default),Mn()},addRange(e,t){kt.set(e,{type:\"range\",config:t}),e in se||(se[e]=t.default),Mn()},get(e){return se[e]},getToggle(e){const t=se[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=se[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=se[e];return typeof t==\"number\"?t:0},set(e,t){se[e]=t,jf()},getAll(){return{...se}},getDefinitions(){return kt},hasAny(){return kt.size>0}};function Wf(e,t,n){const r=C.getState(),i=ne(r.variables),a=ne(r.temporary),o={...t};Va(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])}const _n=new Map,fr=new Set,dr=new Map;function Qf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(dr.get(r)??0)+1;return dr.set(r,i),i===1?r:`${r}:${i}`}function Gf(e){return _n.set(e.id,e),qi(),()=>{_n.delete(e.id),qi()}}function Hi(){return Array.from(_n.values())}function Yf(e){return _n.get(e)}function Kf(){dr.clear()}function Jf(e){return fr.add(e),()=>{fr.delete(e)}}function qi(){for(const e of fr)e()}function Zf(e){const t=ue(\"\");t.current||(t.current=Qf(e.type,e.key,e.authorId));const n=t.current;return nt(()=>{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),Gf(r)}),n}function Xf(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function _o(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function zr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?_o(t):\"\"}function ed(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 td(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 nd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const rd={useState:Z,useRef:ue,useEffect:Se,useLayoutEffect:nt,useCallback:ve,useMemo:de,useContext:ce};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=Cr(),r=a(r),i=a(i));const{update:o,getValues:s}=ce(jt),l=ce(Ne)?(c,h)=>xe(c,{nobr:!0,...h}):xe,f={collectText:Xf,sourceLocation:zr,parseVarArgs:ed,extractOptions:td,h:K,renderNodes:l,renderInlineNodes:ro,hooks:rd,useAction:Zf,className:r,id:i,resolve:a,cls:nd(e.name,r),mutate:c=>Wf(c,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){f.merged=xr();const c=f.merged;f.evaluate=h=>wn(h,c[0],c[1],c[2])}if(e.storeVar){const h=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");f.varName=h,f.value=C(p=>p.variables[h]);const d=C(p=>p.setVariable);f.setValue=p=>d(h,p)}return f.wrap=c=>f.className||f.id?K(\"span\",{id:f.id,class:f.className},c):K(G,null,c),e.render(n,f)}if(Nl(e.name,t),e.subMacros)for(const n of e.subMacros)$l(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&fl(e.name)}function id(){return{get(e){return C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e){C.getState().save(e)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=C.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=C.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 C.getState().storyData?.name||\"\"},get passage(){return C.getState().currentPassage},settings:Rt,registerClass(e,t){lf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){cf(e)}},getActions(){return Hi()},performAction(e,t){const n=Yf(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=C.getState().currentPassage;return C.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return Jf(t);if(e===\"variableChanged\"){let n={...C.getState().variables};return C.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(Hi())})})})},watch(e,t){return ho(e,t)},unwatch(e){po(e)},openDialog(e,t){$f({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Ri()},closeAllDialogs(){zf(),Ri()},isDialogOpen(){return Rf()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},random(){return Ir()},randomInt(e,t){return Oa(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){_l(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=gn())})},isEnabled(){return yl()},get seed(){return bl()},get pull(){return vl()}}}}function ad(){window.Story=id()}const od=/^\\$(\\w+)\\s*=\\s*(.+)$/,Ui=/\\$(\\w+(?:\\.\\w+)*)/g,ji=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,sd=new Set([\"number\",\"string\",\"boolean\"]);function yo(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,yo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!sd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function ld(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(od);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=yo(s);t.set(a,{...u,name:a,default:s})}return t}function ud(e){const t=new Set;let n;for(ji.lastIndex=0;(n=ji.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function cd(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 fd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=ud(i.content);let o;for(Ui.lastIndex=0;(o=Ui.exec(i.content))!==null;){const s=o[1],u=cd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function dd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Ve({macro:e,error:t}){return w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${zr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return w(Ve,{macro:\"print\",error:n})}}});function hd(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 pd(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 Wi(e,t,n,r,i,a,o){const s=C.getState();let u;try{u=wn(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${zr()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];pd(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=hd(e))}catch(f){return w(Ve,{macro:\"computed\",error:f})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);if(!l.current){l.current=!0;const f=C.getState();Wi(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{Wi(o,u,s,n,r,i,e)},[n,r,i]),null}});function gd(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=md(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 md(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 _d(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=gd(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=_d(a,o,i),l=t.cls;return w(\"div\",{class:l,id:t.id,children:[w(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&w(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return w(Ve,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?w(\"span\",{id:o,class:a,children:i}):w(G,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return w(Ve,{macro:\"if\",error:i})}}return null}});function yd(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.slice(1),indexVar:o?o.slice(1):null,listExpr:r}}function bd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=Z(()=>({...e,...t,...n})),o=ue(i);o.current=i;const s=ve(()=>o.current,[]),u=ve((c,h)=>{a(d=>({...d,[c]:h}))},[]),l=de(()=>({update:u,getValues:s}),[u,s]),f=ce(Ne);return w(jt.Provider,{value:l,children:w(He.Provider,{value:i,children:xe(r,f?{nobr:!0}:void 0)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=ce(He);let i;try{i=yd(e)}catch(f){return w(Ve,{macro:\"for\",error:f})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const f=n.evaluate(s);if(!Array.isArray(f))return w(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=f}catch(f){return w(Ve,{macro:\"for\",error:f})}const l=u.map((f,c)=>{const h={[a]:f,...o?{[o]:c}:void 0};return w(bd,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${c}-${JSON.stringify(f)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=()=>{const a=document.createElement(\"div\"),o=K(jt.Provider,{value:{update:n.update,getValues:n.getValues}},K(He.Provider,{value:n.getValues()},xe(t)));be(o,a),be(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:i}),w(\"button\",{id:n.id,class:n.cls,onClick:i,children:r})}});function vd(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Qi(e,t,n){const r=document.createElement(\"div\"),i=K(jt.Provider,{value:{update:n,getValues:t}},K(He.Provider,{value:t()},xe(e)));be(i,r),be(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=vd(e),a=o=>{o.preventDefault(),Qi(t,n.getValues,n.update),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Qi(t,n.getValues,n.update),i&&C.getState().navigate(i)}}),w(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:a,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return w(Ve,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return w(G,{children:n.renderNodes(o.children)})}catch(s){return w(Ve,{macro:\"case\",error:s})}}return i?w(G,{children:n.renderNodes(i.children)}):null}});function Fr(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)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(d=>({delay:d.rawArgs?Fr(d.rawArgs):0,nodes:d.children,className:d.className,id:d.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const d=o+1,p=a[d].delay,k=setTimeout(()=>{s(d)},p);return()=>clearTimeout(k)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),f=t.resolve(u.className),c=t.resolve(u.id),h=f||c?w(\"span\",{id:c,class:f,children:l}):l;return t.wrap(h)}});const bo=pt({stop:()=>{}});V({name:\"repeat\",render({rawArgs:e,children:t=[],className:n,id:r},i){const{useState:a,useEffect:o,useCallback:s,useMemo:u}=i.hooks,[l,f]=u(()=>{const S=E=>{if(!E||!Da(E))return E;const I=C.getState();return $a(E,I.variables,I.temporary,{})};return[S(n),S(r)]},[n,r]),c=Fr(e),[h,d]=a(0),[p,k]=a(!1),x=s(()=>k(!0),[]);if(o(()=>{if(p)return;const S=setInterval(()=>{d(E=>E+1)},c);return()=>clearInterval(S)},[c,p]),h===0&&!p)return null;const _=l?`macro-repeat ${l}`:void 0,v=w(bo.Provider,{value:{stop:x},children:w(\"span\",{children:i.renderNodes(t)},h)});return _||f?w(\"span\",{id:f,class:_,children:v}):v}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(bo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Fr(e),s=a(null),[u,l]=r(0),[f,c]=r(0);i(()=>{if(s.current){const p=s.current.textContent||\"\";l(p.length)}},[]),i(()=>{if(u===0||f>=u)return;const p=setInterval(()=>{c(k=>k>=u?(clearInterval(p),k):k+1)},o);return()=>clearInterval(p)},[u,o]);const h=f>=u&&u>0,d=[\"macro-type\",h?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return w(\"span\",{id:n.id,class:d,ref:s,style:{clipPath:(u>0&&!h,void 0)},children:[w(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!h?`inset(0 ${(u-f)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!h&&u>0&&w(\"span\",{class:\"macro-type-cursor\"})]})}});function wd(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}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=wd(e);return n.hooks.useLayoutEffect(()=>{Ha(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return w(\"span\",{id:t.id,class:r,children:n})}});function it(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=e.dialog?Z(!1):[!1,void 0],a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),w(G,{children:[w(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w($r,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}it({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});it({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});it({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});it({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=C(n=>n.load),t=C(n=>n.hasSave);return C(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});it({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});it({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});it({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Rt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w($r,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function kd(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 Sd(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 xd(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Cd(){const[e,t]=Z(\"load\"),[n,r]=Z([]),[i,a]=Z(!0),[o,s]=Z(null),[u,l]=Z(()=>new Set),[f,c]=Z(null),[h,d]=Z(\"\"),p=ue(null),k=ue(null),x=ce(go),_=C(D=>D.storyData),v=C(D=>D.playthroughId),S=C(D=>D.getSavePayload),E=C(D=>D.loadFromPayload),I=_?.ifid??\"\",y=ve(async()=>{if(!I)return;const D=await yf(I);r(D),a(!1)},[I]);Se(()=>{y()},[y]),Se(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const P=ue(),T=(D,j=\"success\")=>{clearTimeout(P.current),s({text:D,type:j}),P.current=window.setTimeout(()=>s(null),3e3)},z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},b=async()=>{if(!(!I||!v))try{const D=S();await so(I,v,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=S();await lo(D,j),T(\"Save overwritten\"),await y()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{E(D.payload),T(\"Game loaded\"),x&&setTimeout(x,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await mf(D),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{c(D.meta.id),d(D.meta.title)},M=async()=>{if(!(!f||!h.trim()))try{await _f(f,h.trim()),c(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},J=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&c(null)},Y=async D=>{try{const j=await xf(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),oe=document.createElement(\"a\");oe.href=q,oe.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,oe.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},fe=()=>{k.current?.click()},we=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),oe=JSON.parse(q);if(!kd(oe))throw new Error(\"Invalid save file format\");await Cf(oe,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick:fe,children:\"Import\"}),w(\"input\",{ref:k,type:\"file\",accept:\".json\",style:\"display:none\",onChange:we})]}),w(\"div\",{class:\"saves-body\",children:[i?w(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===v;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:xd(D.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[f===q.meta.id?w(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:oe=>d(oe.target.value),onKeyDown:J,onBlur:M}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:Sd(q.meta.updatedAt)})]})]}),w(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?w(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):w(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>Y(q.meta.id),children:\"Export\"}),w(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&w(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===v)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return w(Cd,{})}});function Id({name:e,def:t}){const[n,r]=Z(()=>Rt.get(e)),i=a=>{r(a),Rt.set(e,a)};switch(t.type){case\"toggle\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"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 Ed(){const e=Rt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(Id,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return w(Ed,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return w(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=mt(o.content),l=_t(u),f=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(Ne.Provider,{value:!0},f)):t.wrap(f)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(Ne.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}C.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=C.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),w(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Ad(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}}V({name:\"checkbox\",render({rawArgs:e},t){const{varName:n,label:r}=Ad(e),i=n.startsWith(\"$\")?n.slice(1):n,a=C(s=>s.variables[i]),o=C(s=>s.setVariable);return t.useAction({type:\"checkbox\",key:`$${i}`,authorId:t.id,label:r||i,variable:i,value:!!a,perform:s=>o(i,s!==void 0?!!s:!a)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"checkbox\",checked:!!a,onChange:()=>o(i,!a)}),r?` ${r}`:null]})}});function Pd(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]}}V({name:\"radiobutton\",render({rawArgs:e},t){const{varName:n,value:r,label:i}=Pd(e),a=n.startsWith(\"$\")?n.slice(1):n,o=C(u=>u.variables[a]),s=C(u=>u.setVariable);return t.useAction({type:\"radiobutton\",key:`$${a}:${r}`,authorId:t.id,label:i||r,variable:a,value:o,perform:()=>s(a,r)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${a}`,checked:o===r,onChange:()=>s(a,r)}),i?` ${i}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),w(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>w(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const a=(n.indexOf(String(t.value))+1)%n.length;t.setValue(n[a])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function xt(e){const t=mt(e.content),n=_t(t),r=e.tags.includes(\"nobr\");return xe(n,r?{nobr:!0}:void 0)}const Td=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Nd({passage:e,dataTransition:t}){const n=C(k=>k.storyData),r=Td.has(e.name),[i,a]=Z(!1),o=de(()=>{try{return xt(e)}catch(k){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",_o(e),\": \",k.message]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),f=de(()=>{if(!s)return null;try{return xt(s)}catch(k){return console.error(\"spindle: Error in PassageHeader:\",k),null}},[s?.content]),c=de(()=>{if(!u)return null;try{return xt(u)}catch(k){return console.error(\"spindle: Error in PassageFooter:\",k),null}},[u?.content]);Se(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return xt(l)}catch(k){return console.error(\"spindle: Error in PassageDone:\",k),null}},[i,l?.content]),d=e.tags.includes(\"nobr\"),p=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[f&&w(\"div\",{class:\"passage-header\",children:f}),o,c&&w(\"div\",{class:\"passage-footer\",children:c}),h&&w(\"div\",{hidden:!0,children:h})]});return d?w(Ne.Provider,{value:!0,children:p}):p}const Dd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),hr={type:\"fade-through\",duration:300,pause:50};function $d(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Dd.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function Ln(e){return{type:e.type,duration:e.duration??hr.duration,pause:e.pause??hr.pause}}function zd(e,t,n){const r=$d(e);return r?Ln(r):t?Ln(t):n?Ln(n):{...hr}}function Gi(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function Vn(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function Bn(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=C(d=>d.currentPassage),r=C(d=>d.storyData),[i,a]=Z(n),o=ue(\"fade\"),s=ue(0),u=ue(null),l=ue([]),f=ve(()=>{for(const d of l.current)clearTimeout(d);l.current=[],Bn(u.current)},[]);Se(()=>{const d=C.getState(),{history:p,historyIndex:k,transitionConfig:x}=d,_=d.consumeNextTransition(),v=s.current;s.current=p.length;const S=!i,E=p.length===1&&k===0&&v>1,I=p.length>1&&k===p.length-1&&v>1&&Math.abs(p.length-v)>1;if(n===i)return;f();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(S||E||I){o.current=\"fade\",a(n);return}const P=zd(y.tags,_,x);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&Vn(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}Vn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Gi(z,P.type);T.appendChild(b),a(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{a(n)},N),B=N+P.duration,U=setTimeout(()=>{Bn(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}Vn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Gi(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const N=setTimeout(()=>{Bn(T)},P.duration);l.current=[N];return}a(n)},[n]);const c=i?r?.passages.get(i):null;if(!c&&i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&w(\"div\",{hidden:!0,children:xt(h)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:c&&w(Nd,{passage:c,dataTransition:o.current},i)})]})}});V({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const c=l[1]??l[5],h=l[2]??l[3]??l[4];if(c)switch(c){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const f=n.useRef(!1);return f.current||(f.current=!0,ho(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,po(r)),null}});const Fd='*,*: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-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.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}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{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}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 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-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-link:active{color:#42a5f5}.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}}';function Yi(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 Ki(){const e=Uf(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Fd,document.head.appendChild(t),ad(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",d=document.getElementById(\"root\");throw d&&Yi(d,[h]),new Error(`spindle: ${h}`)}const i=ld(r.content),a=fd(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&Yi(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=dd(i),C.getState().init(e,n),co();const o=kf(e.ifid);o&&C.getState().loadFromPayload(o);for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const d=mt(h.content),p=_t(d);for(const k of p)if(k.type===\"macro\"&&k.name===\"widget\"&&k.rawArgs){const x=k.rawArgs.trim().split(/\\s+/),_=x[0].replace(/[\"']/g,\"\"),v=x.slice(1).filter(S=>S.startsWith(\"$\")||S.startsWith(\"_\")||S.startsWith(\"@\"));Ha(_,k.children,v)}}let s=\"\";C.subscribe(h=>{h.currentPassage!==s&&(s=h.currentPassage,Kf())});let u=C.getState().variables,l=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===l?Af():Pf()),u=h.variables,l=h.historyIndex});const f=e.passages.get(\"StoryInterface\");f&&!f.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const c=document.getElementById(\"root\");if(!c)throw new Error('spindle: No <div id=\"root\"> element found.');be(w(Hf,{}),c),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Ki):Ki();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
1
+ window.storyFormat({"name":"spindle","version":"0.29.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 Ot,O,Xi,Qe,Wr,ea,ta,na,mr,qn,Un,ra,on={},sn=[],Go=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Mt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function _r(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function K(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?Ot.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??++Xi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Yo(){return{current:null}}function G(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function ft(e,t){if(t==null)return e.__?ft(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\"?ft(e):null}function Ko(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Te({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),yr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ft(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,sa(r,a,i),t.__e=t.__=null,a.__e!=n&&ia(a)}}function ia(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}),ia(e)}function jn(e){(!e.__d&&(e.__d=!0)&&Qe.push(e)&&!ln.__r++||Wr!=O.debounceRendering)&&((Wr=O.debounceRendering)||ea)(ln)}function ln(){for(var e,t=1;Qe.length;)Qe.length>t&&Qe.sort(ta),e=Qe.shift(),t=Qe.length,Ko(e);ln.__r=0}function aa(e,t,n,r,i,a,o,s,u,l,d){var c,h,f,p,v,x,_,k=r&&r.__k||sn,S=t.length;for(u=Jo(n,t,k,u,S),c=0;c<S;c++)(f=n.__k[c])!=null&&(h=f.__i!=-1&&k[f.__i]||on,f.__i=c,x=yr(e,f,h,i,a,o,s,u,l,d),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&br(h.ref,null,f),d.push(f.ref,f.__c||p,f)),v==null&&p!=null&&(v=p),(_=!!(4&f.__u))||h.__k===f.__k?u=oa(f,u,e,_):typeof f.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),f.__u&=-7);return n.__e=v,u}function Jo(e,t,n,r,i){var a,o,s,u,l,d=n.length,c=d,h=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):Mt(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+h,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Zo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<d;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ft(s)),ua(s,s));return r}function oa(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=oa(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ft(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Re(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Mt(e)?e.some(function(n){Re(n,t)}):t.push(e)),t}function Zo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?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 Qr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Go.test(t)?n:n+\"px\"}function Wt(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||Qr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Qr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(na,\"$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=mr,e.addEventListener(t,a?Un:qn,a)):e.removeEventListener(t,a?Un:qn,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 Gr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=mr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function yr(e,t,n,r,i,a,o,s,u,l){var d,c,h,f,p,v,x,_,k,S,P,C,y,A,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(_=t.props,k=\"prototype\"in z&&z.prototype.render,S=(d=z.contextType)&&r[d.__c],P=d?S?S.props.value:d.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(k?t.__c=c=new z(_,P):(t.__c=c=new Ne(_,P),c.constructor=z,c.render=es),S&&S.sub(c),c.state||(c.state={}),c.__n=r,h=c.__d=!0,c.__h=[],c._sb=[]),k&&c.__s==null&&(c.__s=c.state),k&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Te({},c.__s)),Te(c.__s,z.getDerivedStateFromProps(_,c.__s))),f=c.props,p=c.state,c.__v=t,h)k&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),k&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(k&&z.getDerivedStateFromProps==null&&_!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,P),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,P)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),sn.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,P),k&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,p,v)})}if(c.context=P,c.props=_,c.__P=e,c.__e=!1,C=O.__r,y=0,k)c.state=c.__s,c.__d=!1,C&&C(t),d=c.render(c.props,c.state,c.context),sn.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,C&&C(t),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Te(Te({},r),c.getChildContext())),k&&!h&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(f,p)),A=d!=null&&d.type===G&&d.key==null?la(d.props.children):d,s=aa(e,Mt(A)?A:[A],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(b){if(t.__v=null,u||a!=null)if(b.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(T=a.length;T--;)_r(a[T]);Wn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Wn(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Xo(n.__e,t,n,r,i,a,o,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function Wn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Wn))}function sa(e,t,n){for(var r=0;r<n.length;r++)br(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 la(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Mt(e)?e.map(la):Te({},e)}function Xo(e,t,n,r,i,a,o,s,u){var l,d,c,h,f,p,v,x=n.props||on,_=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"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==!!k&&(k?f.localName==k:f.nodeType==3)){e=f,a[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(_);e=document.createElementNS(i,k,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(k==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Ot.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(f=e.attributes[l]).name]=f.value;for(l in x)f=x[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||Wt(e,l,null,f,i);for(l in _)f=_[l],l==\"children\"?h=f:l==\"dangerouslySetInnerHTML\"?d=f:l==\"value\"?p=f:l==\"checked\"?v=f:s&&typeof f!=\"function\"||x[l]===f||Wt(e,l,f,x[l],i);if(d)s||c&&(d.__html==c.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),aa(t.type==\"template\"?e.content:e,Mt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&ft(n,0),s,u),a!=null)for(l=a.length;l--;)_r(a[l]);s||(l=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||k==\"progress\"&&!p||k==\"option\"&&p!=x[l])&&Wt(e,l,p,x[l],i),l=\"checked\",v!=null&&v!=e[l]&&Wt(e,l,v,x[l],i))}return e}function br(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 ua(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||br(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]&&ua(r[i],t,n||typeof e.type!=\"function\");n||_r(e.__e),e.__c=e.__=e.__e=void 0}function es(e,t,n){return this.constructor(e,n)}function be(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=[],yr(t,e=(!r&&n||t).__k=K(G,null,[e]),i||on,on,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Ot.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),sa(a,e,o)}function ca(e,t){be(e,t,ca)}function ts(e,t,n){var r,i,a,o,s=Te({},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?Ot.call(arguments,2):n),Ct(e.type,s,r||e.key,i||e.ref,null)}function nt(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,jn(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\"+ra++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Ot=sn.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}},Xi=0,Ne.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof e==\"function\"&&(e=e(Te({},n),this.props)),e&&Te(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),jn(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),jn(this))},Ne.prototype.render=G,Qe=[],ea=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ta=function(e,t){return e.__v.__b-t.__v.__b},ln.__r=0,na=/(PointerCapture)$|Capture$/i,mr=0,qn=Gr(!1),Un=Gr(!0),ra=0;var ns=0;function w(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:--ns,__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 Ve,W,An,Yr,dt=0,fa=[],Q=O,Kr=Q.__b,Jr=Q.__r,Zr=Q.diffed,Xr=Q.__c,ei=Q.unmount,ti=Q.__;function gt(e,t){Q.__h&&Q.__h(W,e,dt||t),dt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return dt=1,vr(ga,e)}function vr(e,t,n){var r=gt(Ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ga(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 d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return d.some(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[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 d=a;a=void 0,i(s,u,l),a=d}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Se(e,t){var n=gt(Ve++,3);!Q.__s&&wr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function rt(e,t){var n=gt(Ve++,4);!Q.__s&&wr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function ce(e){return dt=5,fe(function(){return{current:e}},[])}function da(e,t,n){dt=6,rt(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 fe(e,t){var n=gt(Ve++,7);return wr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return dt=8,fe(function(){return e},t)}function J(e){var t=W.context[e.__c],n=gt(Ve++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function ha(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function pa(){var e=gt(Ve++,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 rs(){for(var e;e=fa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Xt),t.__h.some(Qn),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),ti&&ti(e,t)},Q.__r=function(e){Jr&&Jr(e),Ve=0;var t=(W=e.__c).__H;t&&(An===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Xt),t.__h.some(Qn),t.__h=[],Ve=0)),An=W},Q.diffed=function(e){Zr&&Zr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fa.push(t)!==1&&Yr===Q.requestAnimationFrame||((Yr=Q.requestAnimationFrame)||is)(rs)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),An=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Xt),n.__h=n.__h.filter(function(r){return!r.__||Qn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Xr&&Xr(e,t)},Q.unmount=function(e){ei&&ei(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Xt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ni=typeof requestAnimationFrame==\"function\";function is(e){var t,n=function(){clearTimeout(r),ni&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ni&&(t=requestAnimationFrame(n))}function Xt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Qn(e){var t=W;e.__c=e.__(),W=t}function wr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ga(e,t){return typeof t==\"function\"?t(e):t}const ri=e=>{let t;const n=new Set,r=(l,d)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const h=t;t=d??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,h))}},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},as=(e=>e?ri(e):ri);function ma(e,t){for(var n in t)e[n]=t[n];return e}function Gn(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 _a(e,t){var n=t(),r=X({t:{__:n,u:t}}),i=r[0].t,a=r[1];return rt(function(){i.__=n,i.u=t,Tn(i)&&a({t:i})},[e,n,t]),Se(function(){return Tn(i)&&a({t:i}),e(function(){Tn(i)&&a({t:i})})},[e]),n}function Tn(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 ya(e){e()}function ba(e){return e}function va(){return[!1,ya]}var wa=rt;function Yn(e,t){this.props=e,this.context=t}function os(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:Gn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,K(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Yn.prototype=new Ne).isPureReactComponent=!0,Yn.prototype.shouldComponentUpdate=function(e,t){return Gn(this.props,e)||Gn(this.state,t)};var ii=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ii&&ii(e)};var ss=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ls(e){function t(n){var r=ma({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=ss,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ai=function(e,t){return e==null?null:Re(Re(e).map(t))},us={map:ai,forEach:ai,count:function(e){return e?Re(e).length:0},only:function(e){var t=Re(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Re},cs=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)}cs(e,t,n,r)};var oi=O.unmount;function ka(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=ma({},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 ka(r,t,n)})),e}function Sa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Sa(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 en(){this.__u=0,this.o=null,this.__b=null}function xa(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function fs(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?K(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function St(){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),oi&&oi(e)},(en.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=xa(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]=Sa(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},en.prototype.componentWillUnmount=function(){this.o=[]},en.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]=ka(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&K(G,null,e.fallback);return i&&(i.__u&=-33),[K(G,null,t.__a?null:e.children),i]};var si=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 ds(e){return this.getChildContext=function(){return e.context},e.children}function hs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){be(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)}}}be(K(ds,{context:t.context},e.__v),t.v)}function ps(e,t){var n=K(hs,{__v:e,h:t});return n.containerInfo=t,n}(St.prototype=new Ne).__a=function(e){var t=this,n=xa(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),si(t,e,r)):i()};n?n(a):a()}},St.prototype.render=function(e){this.i=null,this.l=new Map;var t=Re(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},St.prototype.componentDidUpdate=St.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){si(e,n,t)})};var Ca=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,gs=/^(?: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]/,ms=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,_s=/[A-Z0-9]/g,ys=typeof document<\"u\",bs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function vs(e,t,n){return t.__k==null&&(t.textContent=\"\"),be(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ws(e,t,n){return ca(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ne.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ne.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var li=O.event;function ks(){}function Ss(){return this.cancelBubble}function xs(){return this.defaultPrevented}O.event=function(e){return li&&(e=li(e)),e.persist=ks,e.isPropagationStopped=Ss,e.isDefaultPrevented=xs,e.nativeEvent=e};var kr,Cs={enumerable:!1,configurable:!0,get:function(){return this.class}},ui=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||ys&&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\"||bs(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":ms.test(o)&&(o=u):u=o=\"oninput\":a&&gs.test(o)?o=o.replace(_s,\"-$&\").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=Re(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Re(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\",Cs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ca,ui&&ui(e)};var ci=O.__r;O.__r=function(e){ci&&ci(e),kr=e.__c};var fi=O.diffed;O.diffed=function(e){fi&&fi(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),kr=null};var Is={ReactCurrentDispatcher:{current:{readContext:function(e){return kr.__n[e.__c].props.value},useCallback:ve,useContext:J,useDebugValue:ha,useDeferredValue:ba,useEffect:Se,useId:pa,useImperativeHandle:da,useInsertionEffect:wa,useLayoutEffect:rt,useMemo:fe,useReducer:vr,useRef:ce,useState:X,useSyncExternalStore:_a,useTransition:va}}};function Es(e){return K.bind(null,e)}function bn(e){return!!e&&e.$$typeof===Ca}function Ps(e){return bn(e)&&e.type===G}function As(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ts(e){return bn(e)?ts.apply(null,arguments):e}function Ns(e){return!!e.__k&&(be(null,e),!0)}function Ds(e){return e&&(e.base||e.nodeType===1&&e)||null}var $s=function(e,t){return e(t)},zs=function(e,t){return e(t)},Fs=G,Rs=bn,Qt={useState:X,useId:pa,useReducer:vr,useEffect:Se,useLayoutEffect:rt,useInsertionEffect:wa,useTransition:va,useDeferredValue:ba,useSyncExternalStore:_a,startTransition:ya,useRef:ce,useImperativeHandle:da,useMemo:fe,useCallback:ve,useContext:J,useDebugValue:ha,version:\"18.3.1\",Children:us,render:vs,hydrate:ws,unmountComponentAtNode:Ns,createPortal:ps,createElement:K,createContext:nt,createFactory:Es,cloneElement:Ts,createRef:Yo,Fragment:G,isValidElement:bn,isElement:Rs,isFragment:Ps,isMemo:As,findDOMNode:Ds,Component:Ne,PureComponent:Yn,memo:os,forwardRef:ls,flushSync:zs,unstable_batchedUpdates:$s,StrictMode:Fs,Suspense:en,SuspenseList:St,lazy:fs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Is};const Os=e=>e;function Ms(e,t=Os){const n=Qt.useSyncExternalStore(e.subscribe,Qt.useCallback(()=>t(e.getState()),[e,t]),Qt.useCallback(()=>t(e.getInitialState()),[e,t]));return Qt.useDebugValue(n),n}const Ls=e=>{const t=as(e),n=r=>Ms(t,r);return Object.assign(n,t),n},Vs=(e=>Ls);var Sr=Symbol.for(\"immer-nothing\"),It=Symbol.for(\"immer-draftable\"),te=Symbol.for(\"immer-state\");function ae(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var he=Object,Ze=he.getPrototypeOf,Tt=\"constructor\",Lt=\"prototype\",Kn=\"configurable\",un=\"enumerable\",tn=\"writable\",Nt=\"value\",Oe=e=>!!e&&!!e[te];function De(e){return e?Ia(e)||Bt(e)||!!e[It]||!!e[Tt]?.[It]||Ht(e)||qt(e):!1}var Bs=he[Lt][Tt].toString(),di=new WeakMap;function Ia(e){if(!e||!ht(e))return!1;const t=Ze(e);if(t===null||t===he[Lt])return!0;const n=he.hasOwnProperty.call(t,Tt)&&t[Tt];if(n===Object)return!0;if(!Ge(n))return!1;let r=di.get(n);return r===void 0&&(r=Function.toString.call(n),di.set(n,r)),r===Bs}function Vt(e,t,n=!0){Xe(e)===0?(n?Reflect.ownKeys(e):he.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Xe(e){const t=e[te];return t?t.type_:Bt(e)?1:Ht(e)?2:qt(e)?3:0}var Et=(e,t,n=Xe(e))=>n===2?e.has(t):he[Lt].hasOwnProperty.call(e,t),ze=(e,t,n=Xe(e))=>n===2?e.get(t):e[t],cn=(e,t,n,r=Xe(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Hs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Bt=Array.isArray,Ht=e=>e instanceof Map,qt=e=>e instanceof Set,ht=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",Nn=e=>typeof e==\"boolean\";function qs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Us=e=>ht(e)?e?.[te]:null,Fe=e=>e.copy_||e.base_,xr=e=>e.modified_?e.copy_:e.base_;function Jn(e,t){if(Ht(e))return new Map(e);if(qt(e))return new Set(e);if(Bt(e))return Array[Lt].slice.call(e);const n=Ia(e);if(t===!0||t===\"class_only\"&&!n){const r=he.getOwnPropertyDescriptors(e);delete r[te];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[tn]===!1&&(s[tn]=!0,s[Kn]=!0),(s.get||s.set)&&(r[o]={[Kn]:!0,[tn]:!0,[un]:s[un],[Nt]:e[o]})}return he.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=he.create(r);return he.assign(i,e)}}function Cr(e,t=!1){return vn(e)||Oe(e)||!De(e)||(Xe(e)>1&&he.defineProperties(e,{set:Gt,add:Gt,clear:Gt,delete:Gt}),he.freeze(e),t&&Vt(e,(n,r)=>{Cr(r,!0)},!1)),e}function js(){ae(2)}var Gt={[Nt]:js};function vn(e){return e===null||!ht(e)?!0:he.isFrozen(e)}var fn=\"MapSet\",dn=\"Patches\",hi=\"ArrayMethods\",hn={};function et(e){const t=hn[e];return t||ae(0,e),t}var pi=e=>!!hn[e];function Ws(e,t){hn[e]||(hn[e]=t)}var Dt,Ea=()=>Dt,Qs=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:pi(fn)?et(fn):void 0,arrayMethodsPlugin_:pi(hi)?et(hi):void 0});function gi(e,t){t&&(e.patchPlugin_=et(dn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Zn(e){Xn(e),e.drafts_.forEach(Gs),e.drafts_=null}function Xn(e){e===Dt&&(Dt=e.parent_)}var mi=e=>Dt=Qs(Dt,e);function Gs(e){const t=e[te];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _i(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[te].modified_&&(Zn(t),ae(4)),De(e)&&(e=yi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[te].base_,e,t)}else e=yi(t,n);return Ys(t,e,!0),Zn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Sr?e:void 0}function yi(e,t){if(vn(t))return t;const n=t[te];if(!n)return pn(t,e.handledSet_,e);if(!wn(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);Ta(n,e)}return n.copy_}function Ys(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Cr(t,n)}function Pa(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var wn=(e,t)=>e.scope_===t,Ks=[];function Aa(e,t,n,r){const i=Fe(e),a=e.type_;if(r!==void 0&&ze(i,r,a)===t){cn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Vt(i,(u,l)=>{if(Oe(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const o=e.draftLocations_.get(t)??Ks;for(const s of o)cn(i,s,n,a)}function Js(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!wn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=xr(a);Aa(e,a.draft_??a,o,n),Ta(a,i)})}function Ta(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)}Pa(e)}}function Zs(e,t,n){const{scope_:r}=e;if(Oe(n)){const i=n[te];wn(i,r)&&i.callbacks_.push(function(){nn(e);const o=xr(i);Aa(e,n,o,t)})}else De(n)&&e.callbacks_.push(function(){const a=Fe(e);e.type_===3?a.has(n)&&pn(n,r.handledSet_,r):ze(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&pn(ze(e.copy_,t,e.type_),r.handledSet_,r)})}function pn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Oe(e)||t.has(e)||!De(e)||vn(e)||(t.add(e),Vt(e,(r,i)=>{if(Oe(i)){const a=i[te];if(wn(a,n)){const o=xr(a);cn(e,r,o,e.type_),Pa(a)}}else De(i)&&pn(i,t,n)})),e}function Xs(e,t){const n=Bt(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=gn;n&&(i=[r],a=$t);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var gn={get(e,t){if(t===te)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=Fe(e);if(!Et(i,t,e.type_))return el(e,i,t);const a=i[t];if(e.finalized_||!De(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&qs(t))return a;if(a===Dn(e.base_,t)){nn(e);const o=e.type_===1?+t:t,s=tr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=Na(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Dn(Fe(e),t),a=i?.[te];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Hs(n,i)&&(n!==void 0||Et(e.base_,t,e.type_)))return!0;nn(e),er(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),Zs(e,t,n)),!0},deleteProperty(e,t){return nn(e),Dn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),er(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[tn]:!0,[Kn]:e.type_!==1||t!==\"length\",[un]:r[un],[Nt]:n[t]}},defineProperty(){ae(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ae(12)}},$t={};for(let e in gn){let t=gn[e];$t[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}$t.deleteProperty=function(e,t){return $t.set.call(this,e,t,void 0)};$t.set=function(e,t,n){return gn.set.call(this,e[0],t,n,e[0])};function Dn(e,t){const n=e[te];return(n?Fe(n):e)[t]}function el(e,t,n){const r=Na(t,n);return r?Nt in r?r[Nt]:r.get?.call(e.draft_):void 0}function Na(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function er(e){e.modified_||(e.modified_=!0,e.parent_&&er(e.parent_))}function nn(e){e.copy_||(e.assigned_=new Map,e.copy_=Jn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var tl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ge(t)&&!Ge(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,d=>n.call(this,d,...l))}}Ge(n)||ae(6),r!==void 0&&!Ge(r)&&ae(7);let i;if(De(t)){const a=mi(this),o=tr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Zn(a):Xn(a)}return gi(a,r),_i(i,a)}else if(!t||!ht(t)){if(i=n(t),i===void 0&&(i=t),i===Sr&&(i=void 0),this.autoFreeze_&&Cr(i,!0),r){const a=[],o=[];et(dn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ae(1,t)},this.produceWithPatches=(t,n)=>{if(Ge(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]},Nn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Nn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Nn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){De(e)||ae(8),Oe(e)&&(e=nl(e));const t=mi(this),n=tr(t,e,void 0);return n[te].isManual_=!0,Xn(t),n}finishDraft(e,t){const n=e&&e[te];(!n||!n.isManual_)&&ae(9);const{scope_:r}=n;return gi(r,t),_i(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=et(dn).applyPatches_;return Oe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function tr(e,t,n,r){const[i,a]=Ht(t)?et(fn).proxyMap_(t,n):qt(t)?et(fn).proxySet_(t,n):Xs(t,n);return(n?.scope_??Ea()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Js(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 nl(e){return Oe(e)||ae(10,e),Da(e)}function Da(e){if(!De(e)||vn(e))return e;const t=e[te];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Jn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Jn(e,!0);return Vt(n,(i,a)=>{cn(n,i,Da(a))},r),t&&(t.finalized_=!1),n}function rl(){function t(p,v=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Us(ze(x,p.key_)),k=ze(x,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||_!=null&&_.base_!==p.base_)return null;const S=p.parent_.type_===3;let P;if(S){const C=p.parent_;P=Array.from(C.drafts_.keys()).indexOf(p.key_)}else P=p.key_;if(!(S&&x.size>P||Et(x,P)))return null;v.push(P)}if(p.parent_)return t(p.parent_,v);v.reverse();try{n(p.copy_,v)}catch{return null}return v}function n(p,v){let x=p;for(let _=0;_<v.length-1;_++){const k=v[_];if(x=ze(x,k),!ht(x)||x===null)throw new Error(`Cannot resolve path at '${v.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,v,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:k}=x;switch(p.type_){case 0:case 2:return u(p,v,_,k);case 1:return s(p,v,_,k);case 3:return l(p,v,_,k)}}function s(p,v,x,_){let{base_:k,assigned_:S}=p,P=p.copy_;P.length<k.length&&([k,P]=[P,k],[x,_]=[_,x]);const C=p.allIndicesReassigned_===!0;for(let y=0;y<k.length;y++){const A=P[y],T=k[y];if((C||S?.get(y.toString()))&&A!==T){const b=A?.[te];if(b&&b.modified_)continue;const N=v.concat([y]);x.push({op:r,path:N,value:f(A)}),_.push({op:r,path:N,value:f(T)})}}for(let y=k.length;y<P.length;y++){const A=v.concat([y]);x.push({op:i,path:A,value:f(P[y])})}for(let y=P.length-1;k.length<=y;--y){const A=v.concat([y]);_.push({op:a,path:A})}}function u(p,v,x,_){const{base_:k,copy_:S,type_:P}=p;Vt(p.assigned_,(C,y)=>{const A=ze(k,C,P),T=ze(S,C,P),z=y?Et(k,C)?r:i:a;if(A===T&&z===r)return;const b=v.concat(C);x.push(z===a?{op:z,path:b}:{op:z,path:b,value:f(T)}),_.push(z===i?{op:a,path:b}:z===a?{op:i,path:b,value:f(A)}:{op:r,path:b,value:f(A)})})}function l(p,v,x,_){let{base_:k,copy_:S}=p,P=0;k.forEach(C=>{if(!S.has(C)){const y=v.concat([P]);x.push({op:a,path:y,value:C}),_.unshift({op:i,path:y,value:C})}P++}),P=0,S.forEach(C=>{if(!k.has(C)){const y=v.concat([P]);x.push({op:i,path:y,value:C}),_.unshift({op:a,path:y,value:C})}P++})}function d(p,v,x){const{patches_:_,inversePatches_:k}=x;_.push({op:r,path:[],value:v===Sr?void 0:v}),k.push({op:r,path:[],value:p})}function c(p,v){return v.forEach(x=>{const{path:_,op:k}=x;let S=p;for(let A=0;A<_.length-1;A++){const T=Xe(S);let z=_[A];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===Tt)&&ae(19),Ge(S)&&z===Lt&&ae(19),S=ze(S,z),ht(S)||ae(18,_.join(\"/\"))}const P=Xe(S),C=h(x.value),y=_[_.length-1];switch(k){case r:switch(P){case 2:return S.set(y,C);case 3:ae(16);default:return S[y]=C}case i:switch(P){case 1:return y===\"-\"?S.push(C):S.splice(y,0,C);case 2:return S.set(y,C);case 3:return S.add(C);default:return S[y]=C}case a:switch(P){case 1:return S.splice(y,1);case 2:return S.delete(y);case 3:return S.delete(x.value);default:return delete S[y]}default:ae(17,k)}}),p}function h(p){if(!De(p))return p;if(Bt(p))return p.map(h);if(Ht(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,h(_)]));if(qt(p))return new Set(Array.from(p).map(h));const v=Object.create(Ze(p));for(const x in p)v[x]=h(p[x]);return Et(p,It)&&(v[It]=p[It]),v}function f(p){return Oe(p)?h(p):p}Ws(dn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var zt=new tl,il=zt.produce,al=zt.produceWithPatches.bind(zt),ut=zt.applyPatches.bind(zt);const ol=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?il(i):i;return t(s,a,...o)},e(r.setState,n,r)),sl=ol,ll=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\"]),ul=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function cl(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 bi(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 vi(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 fl(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;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;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 mt(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 p=vi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.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 d=e.slice(l,n);n+=2;const{display:c,target:h}=cl(d),f={type:\"link\",display:c,target:h,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=vi(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const c=e[d];if(c===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=d;let h=1;const f=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=a+1,r=a;continue}const p=e.slice(f,n);n++;const{name:v,rawArgs:x,isClose:_}=bi(p),k={type:\"macro\",name:v,rawArgs:x,isClose:_,start:a,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),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 d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,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 d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,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 d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,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 d=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(d,n);n++;const{name:h,rawArgs:f,isClose:p}=bi(c);t.push({type:\"macro\",name:h,rawArgs:f,isClose:p,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&&ll.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 d=fl(e,o);o=d.endIdx;let c=ul.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const $a=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function za(e){$a.add(e.toLowerCase())}const wi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},dl=new Set([\"if\",\"switch\",\"timed\"]);function _t(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 o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);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\":{const a=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(wi[a]){const o=wi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const u={rawArgs:i.rawArgs,children:[]};i.className&&(u.className=i.className),i.id&&(u.id=i.id),s.branches.push(u);break}if($a.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(dl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}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 Ir(){const e=I(r=>r.variables),t=I(r=>r.temporary),n=J(xe);return fe(()=>[e,t,n],[e,t,n])}const hl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,pl=/\\{[\\$_@][\\w.]+\\}/;function gl(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 _l(e,t,n,r){return e.replace(hl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let d;return o===\"$\"?d=t[l]:o===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=ml(d,u)),d==null?\"\":String(d)})}function Er(){const[e,t,n]=Ir();return ve(r=>r===void 0||!gl(r)?r:_l(r,e,t,n),[e,t,n])}function yl({name:e,scope:t,className:n,id:r}){const i=Er();n=i(n),r=i(r);const a=J(xe),o=e.split(\".\"),s=o[0],u=I(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=o[c];l=l[h]}const d=l==null?\"\":String(l);return n||r?w(\"span\",{id:r,class:n,children:d}):w(G,{children:d})}function Fa(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 Ra(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let yt=!1,Ut=\"\",tt=0,pt=null;function bl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Ut=n,tt=0,pt=Fa(Ra(n)),yt=!0}function Oa(e,t){Ut=e,tt=0,pt=Fa(Ra(e)),yt=!0;for(let n=0;n<t;n++)pt();tt=t}function nr(){yt=!1,Ut=\"\",tt=0,pt=null}function mn(){return yt?{seed:Ut,pull:tt}:null}function Pr(){return!yt||!pt?Math.random():(tt++,pt())}function Ma(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Pr()*(t-e+1))+e}function vl(){return yt}function wl(){return Ut}function kl(){return tt}const Sl=500,We=new Map,xl=/\\$(\\w+)/g,Cl=/(?<![.\\w])_(\\w+)/g,Il=/@(\\w+)/g;function El(e){return e.replace(xl,'variables[\"$1\"]').replace(Cl,'temporary[\"$1\"]').replace(Il,'locals[\"$1\"]')}function Ar(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=El(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+=Ar(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 Pl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function La(e,t){const n=We.get(e);if(n)return We.delete(e),We.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Pl+t);if(We.set(e,r),We.size>Sl){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let Yt=null,ki=null,Si=null;function Va(){const e=I.getState(),{visitCounts:t,renderCounts:n}=e;if(Yt&&ki===t&&Si===n)return Yt;const r=f=>t[f??I.getState().currentPassage]??0,i=f=>r(f)>0,a=(...f)=>f.some(p=>r(p)>0),o=(...f)=>f.every(p=>r(p)>0),s=f=>n[f??I.getState().currentPassage]??0;return Yt={currentPassage:()=>{const f=I.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=I.getState();if(f.historyIndex<=0)return;const p=f.history[f.historyIndex-1]?.passage;return p?f.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:f=>s(f)>0,hasRenderedAny:(...f)=>f.some(p=>s(p)>0),hasRenderedAll:(...f)=>f.every(p=>s(p)>0),random:Pr,randomInt:Ma},ki=t,Si=n,Yt}function kn(e,t,n,r={}){const a=`return (${Ar(e)});`;return La(a,a)(t,n,r,Va())}function Ba(e,t,n,r={}){const i=Ar(e);La(\"exec:\"+i,i)(t,n,r,Va())}function Al(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 Tl({body:e,parentValues:t,ownKeys:n}){const r=J(Ce),[i,a]=X({}),o={...t,...n,...i},s=ce(o);s.current=o;const u=ve(()=>s.current,[]),l=ve((c,h)=>{a(f=>({...f,[c]:h}))},[]),d=fe(()=>({update:l,getValues:u}),[l,u]);return w(jt.Provider,{value:d,children:w(xe.Provider,{value:o,children:Ie(e,{nobr:r,locals:o})})})}function Nl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=J(xe),a=J(Ce),[o,s,u]=Ir(),l=r?.length?r:null;if(t.length===0||!n)return w(sr.Provider,{value:l,children:Ie(e,{nobr:a,locals:i})});const d=Al(n),c={};for(let h=0;h<t.length;h++){const f=t[h],p=d[h];let v;if(p!==void 0)try{v=kn(p,o,s,u)}catch{v=void 0}c[f.startsWith(\"@\")?f.slice(1):f]=v}return w(sr.Provider,{value:l,children:w(Tl,{body:e,parentValues:i,ownKeys:c})})}const Ha=new Map;function qa(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");Ha.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Dl(e){return Ha.get(e.toLowerCase())}const Ua=new Map;function $l(e,t){Ua.set(e.toLowerCase(),t)}function zl(e){return Ua.get(e.toLowerCase())}const ja=new Set;function Fl(e){ja.add(e.toLowerCase())}function Rl(e){return ja.has(e.toLowerCase())}const xi=document.createElement(\"i\");function Wa(e){const t=\"&\"+e+\";\";xi.innerHTML=t;const n=xi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function ge(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 ie(e,t){return e.length>0?(ge(e,e.length,0,t),e):t}const rr={}.hasOwnProperty;function Ol(e){const t={};let n=-1;for(;++n<e.length;)Ml(t,e[n]);return t}function Ml(e,t){let n;for(n in t){const i=(rr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){rr.call(i,o)||(i[o]=[]);const s=a[o];Ll(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Ll(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);ge(e,0,0,r)}function Vl(e){const t={};let n=-1;for(;++n<e.length;)Bl(t,e[n]);return t}function Bl(e,t){let n;for(n in t){const i=(rr.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 Hl(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 ql={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Qa(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+ql[n]+\";\"}}function Ft(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Ae=He(/[A-Za-z]/),pe=He(/[\\dA-Za-z]/),Ul=He(/[#-'*+\\--9=?A-Z^-~]/);function ir(e){return e!==null&&(e<32||e===127)}const ar=He(/\\d/),jl=He(/[\\dA-Fa-f]/),Wl=He(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function oe(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Ql=He(/\\p{P}|\\p{S}/u),Gl=He(/\\s/);function He(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Kt(e,t){const n=Qa(Yl(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 Yl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&pe(e.charCodeAt(n+1))&&pe(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,Ii=/^(https?|ircs?|mailto|xmpp)$/i,Kl=/^https?$/i;function Jl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Vl([{enter:{blockQuote:M,codeFenced:we,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:Vo,content:Po,definition:ko,definitionDestinationString:xo,definitionLabelString:x,definitionTitleString:x,emphasis:Mo,htmlFlow:Oo,htmlText:Br,image:q,label:x,link:se,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:Y,reference:x,resource:ot,resourceDestinationString:st,resourceTitleString:x,setextHeading:To,strong:Lo},exit:{atxHeading:Do,atxHeadingSequence:Ao,autolinkEmail:Qo,autolinkProtocol:Wo,blockQuote:Z,characterEscapeValue:vt,characterReferenceMarkerHexadecimal:Hr,characterReferenceMarkerNumeric:Hr,characterReferenceValue:jo,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:A,codeFlowValue:Ro,codeIndented:g,codeText:Bo,codeTextData:vt,data:vt,definition:Eo,definitionDestinationString:Co,definitionLabelString:So,definitionTitleString:Io,emphasis:Ho,hardBreakEscape:Lr,hardBreakTrailing:Lr,htmlFlow:Vr,htmlFlowData:vt,htmlText:Vr,htmlTextData:vt,image:Mr,label:bt,labelText:ee,lineEnding:Fo,link:Mr,listOrdered:$,listUnordered:B,paragraph:de,reference:A,referenceString:Me,resource:A,resourceDestinationString:Pn,resourceTitleString:wo,setextHeading:zo,setextHeadingLineSequence:$o,setextHeadingText:No,strong:qo,thematicBreak:Uo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:x,encode:y,getData:v,lineEndingIfNeeded:C,options:t,raw:S,resume:_,setData:p,tag:k};let c=t.defaultLineEnding;return h;function h(E){let F=-1,ne=0;const ke=[];let Ee=[],$e=[];for(;++F<E.length;)!c&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(c=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?ke.push(F):f(E.slice(ke.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?($e=ie($e,E.slice(ne,F)),ne=F):(Ee=ie(Ee,E.slice(ne,F+1)),ne=F+1));Ee=ie(Ee,$e),Ee=ie(Ee,E.slice(ne)),F=-1;const Pe=Ee;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const qr=u[Pe[F][0]],Ur=Pe[F][1].type,jr=qr[Ur];Ci.call(qr,Ur)&&jr&&jr.call({sliceSerialize:Pe[F][2].sliceSerialize,...d},Pe[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function f(E){const F=E.length;let ne=0,ke=0,Ee=!1,$e;for(;++ne<F;){const Pe=E[ne];if(Pe[1]._container)$e=void 0,Pe[0]===\"enter\"?ke++:ke--;else switch(Pe[1].type){case\"listItemPrefix\":{Pe[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Pe[0]===\"enter\"&&!ke&&($e?$e=void 0:Ee=!0);break}default:$e=void 0}}E[0][1]._loose=Ee}function p(E,F){l[E]=F}function v(E){return l[E]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function k(E){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(E))}function S(E){p(\"lastWasTag\"),i[i.length-1].push(E)}function P(){S(c||`\n`)}function C(){const E=i[i.length-1],F=E[E.length-1],ne=F?F.charCodeAt(F.length-1):null;ne===10||ne===13||ne===null||P()}function y(E){return v(\"ignoreEncode\")?E:Qa(E)}function A(){_()}function T(E){o.push(!E._loose),C(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){o.push(!E._loose),C(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function b(E){if(v(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&k(' start=\"'+y(String(F))+'\"')}}function N(){v(\"expectFirstItem\")?k(\">\"):U(),C(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),P(),k(\"</ol>\")}function B(){U(),o.pop(),P(),k(\"</ul>\")}function U(){v(\"lastWasTag\")&&!v(\"slurpAllLineEndings\")&&C(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),C(),k(\"<blockquote>\")}function Z(){o.pop(),C(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function Y(){o[o.length-1]||(C(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function de(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function we(){C(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=_();k(' class=\"language-'+E+'\"')}function D(){const E=v(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){C(),k(\"<pre><code>\")}function g(){const E=v(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!v(\"lastWasTag\")&&P(),v(\"flowCodeSeenData\")&&C(),k(\"</code></pre>\"),E!==void 0&&E<2&&C(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function se(){a.push({})}function ee(E){a[a.length-1].labelId=this.sliceSerialize(E)}function bt(){a[a.length-1].label=_()}function Me(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function ot(){x(),a[a.length-1].destination=\"\"}function st(){x(),p(\"ignoreEncode\",!0)}function Pn(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function wo(){a[a.length-1].title=_()}function Mr(){let E=a.length-1;const F=a[E],ne=F.referenceId||F.labelId,ke=F.destination===void 0?r[Ft(ne)]:F;for(n=!0;E--;)if(a[E].image){n=void 0;break}F.image?(k('<img src=\"'+Kt(ke.destination,t.allowDangerousProtocol?void 0:Kl)+'\" alt=\"'),S(F.label),k('\"')):k('<a href=\"'+Kt(ke.destination,t.allowDangerousProtocol?void 0:Ii)+'\"'),k(ke.title?' title=\"'+ke.title+'\"':\"\"),F.image?k(\" />\"):(k(\">\"),S(F.label),k(\"</a>\")),a.pop()}function ko(){x(),a.push({})}function So(E){_(),a[a.length-1].labelId=this.sliceSerialize(E)}function xo(){x(),p(\"ignoreEncode\",!0)}function Co(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function Io(){a[a.length-1].title=_()}function Eo(){const E=a[a.length-1],F=Ft(E.labelId);_(),Ci.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Po(){p(\"slurpAllLineEndings\",!0)}function Ao(E){v(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),C(),k(\"<h\"+v(\"headingRank\")+\">\"))}function To(){x(),p(\"slurpAllLineEndings\")}function No(){p(\"slurpAllLineEndings\",!0)}function Do(){k(\"</h\"+v(\"headingRank\")+\">\"),p(\"headingRank\")}function $o(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function zo(){const E=_();C(),k(\"<h\"+v(\"headingRank\")+\">\"),S(E),k(\"</h\"+v(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function vt(E){S(y(this.sliceSerialize(E)))}function Fo(E){if(!v(\"slurpAllLineEndings\")){if(v(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(v(\"inCodeText\")){S(\" \");return}S(y(this.sliceSerialize(E)))}}function Ro(E){S(y(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Lr(){k(\"<br />\")}function Oo(){C(),Br()}function Vr(){p(\"ignoreEncode\")}function Br(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Mo(){k(\"<em>\")}function Lo(){k(\"<strong>\")}function Vo(){p(\"inCodeText\",!0),k(\"<code>\")}function Bo(){p(\"inCodeText\"),k(\"</code>\")}function Ho(){k(\"</em>\")}function qo(){k(\"</strong>\")}function Uo(){C(),k(\"<hr />\")}function Hr(E){p(\"characterReferenceType\",E.type)}function jo(E){const F=this.sliceSerialize(E),ne=v(\"characterReferenceType\")?Hl(F,v(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Wa(F);S(y(ne)),p(\"characterReferenceType\")}function Wo(E){const F=this.sliceSerialize(E);k('<a href=\"'+Kt(F,t.allowDangerousProtocol?void 0:Ii)+'\">'),S(y(F)),k(\"</a>\")}function Qo(E){const F=this.sliceSerialize(E);k('<a href=\"'+Kt(\"mailto:\"+F)+'\">'),S(y(F)),k(\"</a>\")}}function H(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 Zl={tokenize:Xl};function Xl(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\"),H(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 R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const eu={tokenize:tu},Ei={tokenize:nu};function tu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(S){if(r<n.length){const P=n[r];return t.containerState=P[1],e.attempt(P[0].continuation,u,l)(S)}return l(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const P=t.events.length;let C=P,y;for(;C--;)if(t.events[C][0]===\"exit\"&&t.events[C][1].type===\"chunkFlow\"){y=t.events[C][1].end;break}_(r);let A=P;for(;A<t.events.length;)t.events[A][1].end={...y},A++;return ge(t.events,C+1,0,t.events.slice(P)),t.events.length=A,l(S)}return s(S)}function l(S){if(r===n.length){if(!i)return h(S);if(i.currentConstruct&&i.currentConstruct.concrete)return p(S);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ei,d,c)(S)}function d(S){return i&&k(),_(r),h(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(S)}function h(S){return t.containerState={},e.attempt(Ei,f,p)(S)}function f(S){return r++,n.push([t.currentConstruct,t.containerState]),h(S)}function p(S){if(S===null){i&&k(),_(0),e.consume(S);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),v(S)}function v(S){if(S===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(S);return}return R(S)?(e.consume(S),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(S),v)}function x(S,P){const C=t.sliceStream(S);if(P&&C.push(null),S.previous=a,a&&(a.next=S),a=S,i.defineSkip(S.start),i.write(C),t.parser.lazy[S.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const A=t.events.length;let T=A,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(_(r),y=A;y<t.events.length;)t.events[y][1].end={...b},y++;ge(t.events,T+1,0,t.events.slice(A)),t.events.length=y}}function _(S){let P=n.length;for(;P-- >S;){const C=n[P];t.containerState=C[1],C[0].exit.call(t,e)}n.length=S}function k(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function nu(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function _n(e){if(e===null||oe(e)||Gl(e))return 1;if(Ql(e))return 2}function Sn(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 or={name:\"attention\",resolveAll:ru,tokenize:iu};function ru(e,t){let n=-1,r,i,a,o,s,u,l,d;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},h={...e[n][1].start};Pi(c,-u),Pi(h,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:h},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=ie(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ie(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ie(l,Sn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ie(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=ie(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,ge(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function iu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=_n(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\"),d=_n(u),c=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?c:c&&(i||!h)),l._close=!!(a===42?h:h&&(d||!c)),t(u)}}function Pi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const au={name:\"autolink\",tokenize:ou};function ou(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 Ae(f)?(e.consume(f),o):f===64?n(f):l(f)}function o(f){return f===43||f===45||f===46||pe(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||pe(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||ir(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),d):Ul(f)?(e.consume(f),l):n(f)}function d(f){return pe(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,d):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(f)}function h(f){if((f===45||pe(f))&&r++<63){const p=f===45?h:c;return e.consume(f),p}return n(f)}}const xn={partial:!0,tokenize:su};function su(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const Ga={continuation:{tokenize:uu},exit:cu,name:\"blockQuote\",tokenize:lu};function lu(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 uu(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Ga,t,n)(o)}}function cu(e){e.exit(\"blockQuote\")}const Ya={name:\"characterEscape\",tokenize:fu};function fu(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 Wl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Ka={name:\"characterReference\",tokenize:du};function du(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=pe,d(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=jl,d):(e.enter(\"characterReferenceValue\"),a=7,o=ar,d(c))}function d(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===pe&&!Wa(r.sliceSerialize(h))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),d):n(c)}}const Ai={partial:!0,tokenize:pu},Ti={concrete:!0,name:\"codeFenced\",tokenize:hu};function hu(e,t,n){const r=this,i={partial:!0,tokenize:C};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const A=r.events[r.events.length-1];return a=A&&A[1].type===\"linePrefix\"?A[2].sliceSerialize(A[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(y)}function d(y){return y===s?(o++,e.consume(y),d):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),L(y)?H(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||R(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(Ai,v,P)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(y))}function h(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):L(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,f,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),h)}function f(y){return y===null||R(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function v(y){return e.attempt(i,P,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&L(y)?H(e,k,\"linePrefix\",a+1)(y):k(y)}function k(y){return y===null||R(y)?e.check(Ai,v,P)(y):(e.enter(\"codeFlowValue\"),S(y))}function S(y){return y===null||R(y)?(e.exit(\"codeFlowValue\"),k(y)):(e.consume(y),S)}function P(y){return e.exit(\"codeFenced\"),t(y)}function C(y,A,T){let z=0;return b;function b(M){return y.enter(\"lineEnding\"),y.consume(M),y.exit(\"lineEnding\"),N}function N(M){return y.enter(\"codeFencedFence\"),L(M)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(y.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,y.consume(M),B):z>=o?(y.exit(\"codeFencedFenceSequence\"),L(M)?H(y,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(y.exit(\"codeFencedFence\"),A(M)):T(M)}}}function pu(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 $n={name:\"codeIndented\",tokenize:mu},gu={partial:!0,tokenize:_u};function mu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(gu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function _u(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(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):R(o)?i(o):n(o)}}const yu={name:\"codeText\",previous:vu,resolve:bu,tokenize:wu};function bu(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 vu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function wu(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,d(c)):R(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||R(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function d(c){return c===96?(e.consume(c),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class ku{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&&wt(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),wt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wt(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);wt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wt(this.left,n.reverse())}}}function wt(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 Ja(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new ku(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.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,Su(d,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=d.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(d.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={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return ge(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function Su(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 d,c,h=-1,f=n,p=0,v=0;const x=[v];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),c&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++h<s.length;)s[h][0]===\"exit\"&&s[h-1][0]===\"enter\"&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(v=h+1,x.push(v),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),h=x.length;h--;){const _=s.slice(x[h],x[h+1]),k=a.pop();u.push([k,k+_.length-1]),e.splice(k,2,_)}for(u.reverse(),h=-1;++h<u.length;)l[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return l}const xu={resolve:Iu,tokenize:Eu},Cu={partial:!0,tokenize:Pu};function Iu(e){return Ja(e),e}function Eu(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):R(s)?e.check(Cu,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 Pu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||R(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 Za(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),h):_===null||_===32||_===41||ir(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),v(_))}function h(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),f(_))}function f(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),h(_)):_===null||_===60||R(_)?n(_):(e.consume(_),_===92?p:f)}function p(_){return _===60||_===62||_===92?(e.consume(_),f):f(_)}function v(_){return!d&&(_===null||_===41||oe(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):d<l&&_===40?(e.consume(_),d++,v):_===41?(e.consume(_),d--,v):_===null||_===32||_===40||ir(_)?n(_):(e.consume(_),_===92?x:v)}function x(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function Xa(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),d}function d(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):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||R(f)||s++>999?(e.exit(\"chunkString\"),d(f)):(e.consume(f),u||(u=!L(f)),f===92?h:c)}function h(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function eo(e,t,n,r,i,a){let o;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,u):n(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),l(h))}function l(h){return h===o?(e.exit(a),u(o)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===o||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?c:d)}function c(h){return h===o||h===92?(e.consume(h),d):d(h)}}function Pt(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Au={name:\"definition\",tokenize:Nu},Tu={partial:!0,tokenize:Du};function Nu(e,t,n){const r=this;let i;return a;function a(f){return e.enter(\"definition\"),o(f)}function o(f){return Xa.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function s(f){return i=Ft(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 oe(f)?Pt(e,l)(f):l(f)}function l(f){return Za(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function d(f){return e.attempt(Tu,c,c)(f)}function c(f){return L(f)?H(e,h,\"whitespace\")(f):h(f)}function h(f){return f===null||R(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function Du(e,t,n){return r;function r(s){return oe(s)?Pt(e,i)(s):n(s)}function i(s){return eo(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||R(s)?t(s):n(s)}}const $u={name:\"hardBreakEscape\",tokenize:zu};function zu(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Fu={name:\"headingAtx\",resolve:Ru,tokenize:Ou};function Ru(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\"},ge(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Ou(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),a(d)}function a(d){return e.enter(\"atxHeadingSequence\"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||oe(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||oe(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Mu=[\"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\"],Ni=[\"pre\",\"script\",\"style\",\"textarea\"],Lu={concrete:!0,name:\"htmlFlow\",resolveTo:Hu,tokenize:qu},Vu={partial:!0,tokenize:ju},Bu={partial:!0,tokenize:Uu};function Hu(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 qu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,v):g===63?(e.consume(g),i=3,r.interrupt?t:m):Ae(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function h(g){return g===45?(e.consume(g),i=2,f):g===91?(e.consume(g),i=5,s=0,p):Ae(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function f(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:p):n(g)}function v(g){return Ae(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function x(g){if(g===null||g===47||g===62||oe(g)){const q=g===47,se=o.toLowerCase();return!q&&!a&&Ni.includes(se)?(i=1,r.interrupt?t(g):$(g)):Mu.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?k(g):S(g))}return g===45||pe(g)?(e.consume(g),o+=String.fromCharCode(g),x):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function k(g){return L(g)?(e.consume(g),k):b(g)}function S(g){return g===47?(e.consume(g),b):g===58||g===95||Ae(g)?(e.consume(g),P):L(g)?(e.consume(g),S):b(g)}function P(g){return g===45||g===46||g===58||g===95||pe(g)?(e.consume(g),P):C(g)}function C(g){return g===61?(e.consume(g),y):L(g)?(e.consume(g),C):S(g)}function y(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,A):L(g)?(e.consume(g),y):T(g)}function A(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),A)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||oe(g)?C(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?S(g):n(g)}function b(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),Y):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),we):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Vu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Bu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function Z(g){return g===45?(e.consume(g),m):$(g)}function Y(g){return g===47?(e.consume(g),o=\"\",de):$(g)}function de(g){if(g===62){const q=o.toLowerCase();return Ni.includes(q)?(e.consume(g),D):$(g)}return Ae(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),de):$(g)}function we(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function Uu(e,t,n){const r=this;return i;function i(o){return R(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 ju(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(xn,t,n)}}const Wu={name:\"htmlText\",tokenize:Qu};function Qu(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),C):m===63?(e.consume(m),S):Ae(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),a=0,p):Ae(m)?(e.consume(m),k):n(m)}function d(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(o=c,Y(m)):(e.consume(m),c)}function h(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?Z(m):m===45?h(m):c(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(a++)?(e.consume(m),a===D.length?v:p):n(m)}function v(m){return m===null?n(m):m===93?(e.consume(m),x):R(m)?(o=v,Y(m)):(e.consume(m),v)}function x(m){return m===93?(e.consume(m),_):v(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):v(m)}function k(m){return m===null||m===62?Z(m):R(m)?(o=k,Y(m)):(e.consume(m),k)}function S(m){return m===null?n(m):m===63?(e.consume(m),P):R(m)?(o=S,Y(m)):(e.consume(m),S)}function P(m){return m===62?Z(m):S(m)}function C(m){return Ae(m)?(e.consume(m),y):n(m)}function y(m){return m===45||pe(m)?(e.consume(m),y):A(m)}function A(m){return R(m)?(o=A,Y(m)):L(m)?(e.consume(m),A):Z(m)}function T(m){return m===45||pe(m)?(e.consume(m),T):m===47||m===62||oe(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),Z):m===58||m===95||Ae(m)?(e.consume(m),b):R(m)?(o=z,Y(m)):L(m)?(e.consume(m),z):Z(m)}function b(m){return m===45||m===46||m===58||m===95||pe(m)?(e.consume(m),b):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(o=N,Y(m)):L(m)?(e.consume(m),N):z(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,B):R(m)?(o=$,Y(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(o=B,Y(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||oe(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||oe(m)?z(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\"),de}function de(m){return L(m)?H(e,we,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):we(m)}function we(m){return e.enter(\"htmlTextData\"),o(m)}}const Tr={name:\"labelEnd\",resolveAll:Ju,resolveTo:Zu,tokenize:Xu},Gu={tokenize:ec},Yu={tokenize:tc},Ku={tokenize:nc};function Ju(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&&ge(e,0,e.length,n),e}function Zu(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}},d={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ie(s,e.slice(a+1,a+r+3)),s=ie(s,[[\"enter\",d,t]]),s=ie(s,Sn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ie(s,[[\"exit\",d,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ie(s,e.slice(o+1)),s=ie(s,[[\"exit\",u,t]]),ge(e,a,e.length,s),e}function Xu(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(h){return a?a._inactive?c(h):(o=r.parser.defined.includes(Ft(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(h)}function u(h){return h===40?e.attempt(Gu,d,o?d:c)(h):h===91?e.attempt(Yu,d,o?l:c)(h):o?d(h):c(h)}function l(h){return e.attempt(Ku,d,c)(h)}function d(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function ec(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 oe(c)?Pt(e,a)(c):a(c)}function a(c){return c===41?d(c):Za(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return oe(c)?Pt(e,u)(c):d(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?eo(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):d(c)}function l(c){return oe(c)?Pt(e,d)(c):d(c)}function d(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function tc(e,t,n){const r=this;return i;function i(s){return Xa.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Ft(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function nc(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 rc={name:\"labelStartImage\",resolveAll:Tr.resolveAll,tokenize:ic};function ic(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 ac={name:\"labelStartLink\",resolveAll:Tr.resolveAll,tokenize:oc};function oc(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 zn={name:\"lineEnding\",tokenize:sc};function sc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const rn={name:\"thematicBreak\",tokenize:lc};function lc(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||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?H(e,s,\"whitespace\")(l):s(l))}}const ue={continuation:{tokenize:dc},exit:pc,name:\"list\",tokenize:fc},uc={partial:!0,tokenize:gc},cc={partial:!0,tokenize:hc};function fc(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 p=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:ar(f)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(rn,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 ar(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(xn,r.interrupt?n:d,e.attempt(uc,h,c))}function d(f){return r.containerState.initialBlankLine=!0,a++,h(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),h):n(f)}function h(f){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function dc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(xn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(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(cc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(ue,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function hc(e,t,n){const r=this;return H(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 pc(e){e.exit(this.containerState.type)}function gc(e,t,n){const r=this;return H(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 Di={name:\"setextUnderline\",resolveTo:mc,tokenize:_c};function mc(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 _c(e,t,n){const r=this;let i;return a;function a(l){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){c=r.events[d][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)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const yc={tokenize:bc};function bc(e){const t=this,n=e.attempt(xn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xu,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 vc={resolveAll:no()},wc=to(\"string\"),kc=to(\"text\");function to(e){return{resolveAll:no(e===\"text\"?Sc: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(d){return l(d)?a(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),a(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const c=i[d];let h=-1;if(c)for(;++h<c.length;){const f=c[h];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function no(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 Sc(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 xc={42:ue,43:ue,45:ue,48:ue,49:ue,50:ue,51:ue,52:ue,53:ue,54:ue,55:ue,56:ue,57:ue,62:Ga},Cc={91:Au},Ic={[-2]:$n,[-1]:$n,32:$n},Ec={35:Fu,42:rn,45:[Di,rn],60:Lu,61:Di,95:rn,96:Ti,126:Ti},Pc={38:Ka,92:Ya},Ac={[-5]:zn,[-4]:zn,[-3]:zn,33:rc,38:Ka,42:or,60:[au,Wu],91:ac,92:[$u,Ya],93:Tr,95:or,96:yu},Tc={null:[or,vc]},Nc={null:[42,95]},Dc={null:[]},$c=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Nc,contentInitial:Cc,disable:Dc,document:xc,flow:Ec,flowInitial:Ic,insideSpan:Tc,string:Pc,text:Ac},Symbol.toStringTag,{value:\"Module\"}));function zc(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:A(C),check:A(y),consume:k,enter:S,exit:P,interrupt:A(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:v,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:f,write:c};let d=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(N){return o=ie(o,N),x(),o[o.length-1]!==null?[]:(T(t,0),l.events=Sn(a,l.events,l),l.events)}function h(N,$){return Rc(f(N),$)}function f(N){return Fc(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:M}}function v(N){i[N.line]=N.column,b()}function x(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(N){d=d(N)}function k(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,b()):N!==-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=N}function S(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function P(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function C(N,$){T(N,$.from)}function y(N,$){$.restore()}function A(N,$){return B;function B(U,M,Z){let Y,de,we,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(ee){return bt;function bt(Me){const ot=Me!==null&&ee[Me],st=Me!==null&&ee.null,Pn=[...Array.isArray(ot)?ot:ot?[ot]:[],...Array.isArray(st)?st:st?[st]:[]];return j(Pn)(Me)}}function j(ee){return Y=ee,de=0,ee.length===0?Z:g(ee[de])}function g(ee){return bt;function bt(Me){return m=z(),we=ee,ee.partial||(l.currentConstruct=ee),ee.name&&l.parser.constructs.disable.null.includes(ee.name)?se():ee.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,se)(Me)}}function q(ee){return N(we,m),M}function se(ee){return m.restore(),++de<Y.length?g(Y[de]):Z}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&ge(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Fc(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 Rc(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 Oc(e){const r={constructs:Ol([$c,...(e||{}).extensions||[]]),content:i(Zl),defined:[],document:i(eu),flow:i(yc),lazy:{},string:i(wc),text:i(kc)};return r;function i(a){return o;function o(s){return zc(r,a,s)}}}function Mc(e){for(;!Ja(e););return e}const $i=/[\\0\\t\\n\\r]/g;function Lc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,c,h,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),h=l&&l.index!==void 0?l.index:a.length,f=a.charCodeAt(h),!l){t=a.slice(c);break}if(f===10&&c===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<h&&(u.push(a.slice(c,h)),e+=h-c),f){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Vc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Jl(n)(Mc(Oc(n).document().write(Lc()(e,t,!0))))}const Fn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Bc(){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=Fn[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=Fn[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,Hc)),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\"+Fn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Hc(e,t){return t===\"|\"?t:e}class qc{constructor(){this.map=[]}add(t,n,r){Uc(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 Uc(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 jc(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 Wc(){return{flow:{null:{name:\"table\",tokenize:Qc,resolveAll:Gc}}}}function Qc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?y:u;return B===y&&r.parser.lazy[r.now().line]?n(b):B(b)}function u(b){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(b)}function l(b){return b===124||(o=!0,a+=1),d(b)}function d(b){return b===null?n(b):R(b)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),f):n(b):L(b)?H(e,d,\"whitespace\")(b):(a+=1,o&&(o=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),o=!0,d):(e.enter(\"data\"),c(b)))}function c(b){return b===null||b===124||oe(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?h:c)}function h(b){return b===92||b===124?(e.consume(b),c):c(b)}function f(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),o=!1,L(b)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):p(b))}function p(b){return b===45||b===58?x(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),v):C(b)}function v(b){return L(b)?H(e,x,\"whitespace\")(b):x(b)}function x(b){return b===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),_):b===45?(a+=1,_(b)):b===null||R(b)?P(b):C(b)}function _(b){return b===45?(e.enter(\"tableDelimiterFiller\"),k(b)):C(b)}function k(b){return b===45?(e.consume(b),k):b===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),S):(e.exit(\"tableDelimiterFiller\"),S(b))}function S(b){return L(b)?H(e,P,\"whitespace\")(b):P(b)}function P(b){return b===124?p(b):b===null||R(b)?!o||i!==a?C(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):C(b)}function C(b){return n(b)}function y(b){return e.enter(\"tableRow\"),A(b)}function A(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),A):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,A,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||oe(b)?(e.exit(\"data\"),A(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Gc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,d,c;const h=new qc;for(;++n<e.length;){const f=e[n],p=f[1];f[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(zi(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Jt(h,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Jt(h,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Jt(h,t,a,i,n,c)):o[1]!==0&&(c=Jt(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&zi(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=jc(t.events,n))}return e}function Jt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},lt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=lt(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=lt(t.events,n[2]),d=lt(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const h=t.events[n[2]],f=t.events[n[3]];if(h[1].end=Object.assign({},f[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,v=n[3]-n[2]-1;e.add(p,v,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},lt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function zi(e,t,n,r,i){const a=[],o=lt(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 lt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Yc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Kc(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 d={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)},h=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],f=s.parser.constructs.insideSpan.null;f&&ge(h,h.length,0,Sn(f,o.slice(l+1,u),s)),ge(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",d,s]]),ge(o,l-1,u-l+3,h),u=l+h.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,d=this.events;let c=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),f(p))}function f(p){const v=_n(l);if(p===126)return c>1?u(p):(o.consume(p),c++,f);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=_n(p);return x._open=!_||_===2&&!!v,x._close=!v||v===2&&!!_,s(p)}}}function Jc(e){return Vc(e,{allowDangerousHtml:!0,extensions:[Wc(),Kc()],htmlExtensions:[Bc(),Yc()]})}const Zc={update:()=>{},getValues:()=>({})},xe=nt({}),jt=nt(Zc),Ce=nt(!1),sr=nt(null);function Xc(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>ro(a,o,t));return w(G,{children:i})}function ro(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,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)=>ro(u,l,n));return K(i,o,...s)}return null}function ef({node:e}){const t=Er(),n=J(Ce),r=J(xe),i={};for(const[a,o]of Object.entries(e.attributes))i[a]=t(o)??o;return K(e.tag,i,e.children.length>0?Ie(e.children,{nobr:n,locals:r}):void 0)}function tf(){const e=J(sr),t=J(Ce),n=J(xe);return!e||e.length===0?null:w(G,{children:Ie(e,{nobr:t,locals:n})})}function nf(e,t){if(Rl(e.name))return null;const n=Dl(e.name);if(n)return w(Nl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=zl(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function lr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(tf,{},t):w(yl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return nf(e,t);case\"html\":return w(ef,{node:e},t);default:return e}}function io(e){return e.length===0?null:e.map((t,n)=>lr(t,n))}function rf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function af(e,t){const n=I.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function Ie(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>lr(s,u));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value.replace(/^[ \\t]{4,}/gm,\" \");else if(u.type===\"variable\"&&rf(i))i+=af(u,a);else{const l=r.length;r.push(lr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=Jc(i);return Xc(o,r,t?.nobr)}function of(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 sf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||typeof t.historyIndex!=\"number\")}const lf=\"spindle\",uf=1;let Zt=null,Rn=null;function qe(){return Rn||(Rn={saves:new Map,playthroughs:new Map,meta:new Map}),Rn}function cf(){return Zt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Zt=new Promise((e,t)=>{const n=indexedDB.open(lf,uf);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)}),Zt))}function Ue(e,t){return cf().then(n=>n.transaction(e,t).objectStore(e))}function je(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function Cn(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.put(e))}catch{qe().saves.set(e.meta.id,e)}}async function In(e){try{const t=await Ue(\"saves\",\"readonly\");return await je(t.get(e))??void 0}catch{return qe().saves.get(e)}}async function ff(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.delete(e))}catch{qe().saves.delete(e)}}async function df(e){try{const n=(await Ue(\"saves\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().saves.values()].filter(t=>t.meta.ifid===e)}}async function ao(e){try{const t=await Ue(\"playthroughs\",\"readwrite\");await je(t.put(e))}catch{qe().playthroughs.set(e.id,e)}}async function Nr(e){try{const n=(await Ue(\"playthroughs\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().playthroughs.values()].filter(t=>t.ifid===e)}}async function Dr(e){try{const t=await Ue(\"meta\",\"readonly\"),n=await je(t.get(e));return n?n.value:void 0}catch{return qe().meta.get(e)}}async function oo(e,t){try{const n=await Ue(\"meta\",\"readwrite\");await je(n.put({key:e,value:t}))}catch{qe().meta.set(e,t)}}const so=new Map,En=new Map;function hf(e,t){so.set(e,t),En.set(t,e)}function pf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function re(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(En.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(pf(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 ur=\"__spindle_class__\",cr=\"__spindle_data__\";function Ke(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=En.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[ur]:o,[cr]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Je(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(ur in r&&cr in r){const o=r[ur],s=r[cr],u=so.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const d={};for(const c of Object.keys(s))d[c]=t(s[c]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(En.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let fr=null,dr=null,Fi=!1;function gf(e){fr=e}function mf(e){dr=e}function _f(e){if(dr)try{const i=new Function(\"passage\",\"variables\",dr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(fr)try{const r=fr(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 yf(){Fi||(Fi=!0)}async function Ri(e){const n=(await Nr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await ao(i),await oo(`currentPlaythroughId.${e}`,r),r}async function bf(e){return Dr(`currentPlaythroughId.${e}`)}async function lo(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:_f(n),passage:n.passage,custom:r},o=re(n);o.variables=Ke(o.variables),o.history=o.history.map(u=>({...u,variables:Ke(u.variables)}));const s={meta:a,payload:o};return await Cn(s),s}async function uo(e,t){const n=await In(e);if(!n)return;const r=re(t);r.variables=Ke(r.variables),r.history=r.history.map(a=>({...a,variables:Ke(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await Cn(i),i}async function vf(e){const t=await In(e);if(!t)return;const n=t.payload;return n.variables=Je(n.variables),n.history=n.history.map(r=>({...r,variables:Je(r.variables)})),n}async function wf(e){await ff(e)}async function kf(e,t){const n=await In(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await Cn(r)}async function Sf(e){const[t,n]=await Promise.all([df(e),Nr(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 co=\"autosave.\";async function xf(e,t,n){const r=`${co}${e}`,i=await Dr(r);if(i){const o=await uo(i,n);if(o)return o}const a=await lo(e,t,n,{isAutosave:!0});return await oo(r,a.meta.id),a}async function Cf(e){const t=`${co}${e}`,n=await Dr(t);if(n)return vf(n)}const $r=\"spindle.session.\";function If(e,t){try{sessionStorage.setItem(`${$r}${e}`,JSON.stringify(t))}catch{}}function Ef(e){try{const t=sessionStorage.getItem(`${$r}${e}`);if(!t)return;const n=JSON.parse(t);if(!sf(n))return;const r=n;return r.variables=Je(r.variables),r.history=r.history.map(i=>({...i,variables:Je(i.variables)})),r}catch{return}}function Pf(e){try{sessionStorage.removeItem(`${$r}${e}`)}catch{}}async function Af(e){const t=await In(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Tf(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=re(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Nr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await ao(a)}return await Cn(n),n}function fo(){const e=I.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=mt(t.content),i=_t(r),a=document.createElement(\"div\");be(K(()=>Ie(i),null),a),be(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&mf(n.content)}let ho=0,ye=[],On=!1,it=[],At=null,ct=null;function zr(e){const t=I.getState();try{return!!kn(e,t.variables,t.temporary)}catch{return!1}}function po(e,t){const n=ho++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:zr(e),priority:i?.priority??0};return ye.push(o),ye.sort((s,u)=>u.priority-s.priority),()=>{ye=ye.filter(s=>s.id!==n)}}function go(e){ye=ye.filter(t=>t.name!==e)}function Nf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=I.getState();Ba(n.run,r.variables,r.temporary)}n.dialog&&(it.push({passageName:n.dialog}),At?.()),n.goto&&I.getState().navigate(n.goto)}}const Df=10;function $f(){if(!On){On=!0;try{for(let e=0;e<Df;e++){let t=!1;const n=[...ye];for(const r of n){if(!ye.includes(r))continue;const i=zr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ye=ye.filter(o=>o.id!==r.id)),Nf(r))}if(!t)break}}finally{On=!1}}}function zf(){for(const e of ye)e.lastResult=zr(e.condition)}function Ff(){ye=[],it=[],ho=0,ct?.close()}function Rf(e){return At=e,it.length>0&&e(),()=>{At===e&&(At=null)}}function Oi(){return it.shift()}function Of(){return it.length}function Mf(e){it.push(e),At?.()}function Lf(){it=[]}function Vf(e){return ct=e,()=>{ct===e&&(ct=null)}}function Mi(){ct?.close()}function Bf(){return ct?.isOpen()??!1}rl();const Hf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ye={},me=[],Le={};function Li(e){return e.map(t=>({...t,value:t.value!==void 0?re(t.value):void 0}))}function Vi(e,t){const[,n,r]=al(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:Li(n),inverse:Li(r)}}function qf(e){let t=Ye;for(let n=0;n<e;n++)t=ut(t,me[n].forward);return t}let _e=[];function Mn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(_e.length>i.length&&(_e.length=i.length),_e.length<i.length)if(i.length-_e.length===1){const l=i.length-1;_e[l]={passage:i[l].passage,variables:Ke(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ye;for(let d=0;d<i.length;d++)if(d>0&&(l=ut(l,me[d-1].forward)),d>=_e.length){const c=d===i.length-1?r:l;_e[d]={passage:i[d].passage,variables:Ke(c),timestamp:i[d].timestamp,prng:i[d].prng}}}If(t.ifid,{passage:n,variables:Ke(r),history:_e,historyIndex:a,visitCounts:o,renderCounts:s,prng:mn()})}}function Bi(e){Ye=e,me=[],Le=e,_e=[]}function Hi(e){e?.prng?Oa(e.prng.seed,e.prng.pull):e&&nr()}const I=Vs()(sl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},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=re(r);Bi(re(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Le=t().variables;const o=n.ifid;yf().then(async()=>{const s=await bf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await Ri(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Hf.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=Vi(Le,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),me.length=o.historyIndex,me.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:mn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ye=ut(Ye,me[u].forward);o.history=o.history.slice(s),me=me.slice(s),_e=_e.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Le=t().variables,Mn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=re(ut(r,me[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Le=t().variables,Hi(t().history[t().historyIndex]),Mn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=re(ut(i,me[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Le=t().variables,Hi(t().history[t().historyIndex]),Mn(t)},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;nr(),Ff();const a=re(r);Bi(re(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Le=t().variables,fo(),Pf(n.ifid),Ri(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}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),xf(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),Cf(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).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(),u=[];let l=Ye;for(let d=0;d<i.length;d++)d>0&&(l=ut(l,me[d-1].forward)),u.push({passage:i[d].passage,variables:re(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:re(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:mn()}},loadFromPayload:n=>{const r=Je(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=Je(n.history[o].variables);i.push(Vi(a,s)),a=s}Ye=re(r),me=i,_e=[],e(o=>{o.currentPassage=n.passage,o.variables=Je(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=Math.max(0,Math.min(n.historyIndex,o.history.length-1)),o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),Le=t().variables,n.prng?Oa(n.prng.seed,n.prng.pull):nr()},getHistoryVariables:n=>re(qf(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n}}))),Uf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function jf(){const t=I(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Uf,r=t?.tags.includes(\"nobr\")??!1,i=fe(()=>{try{const a=mt(n),o=_t(a);return w(G,{children:io(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(Ce.Provider,{value:!0,children:i}):i}const mo=nt(null);function Fr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=I(c=>c.storyData),s=(e?a?.passages.get(e):void 0)?.content??t,u=fe(()=>{if(!s)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=mt(s),h=_t(c);return Ie(h)}catch(c){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",c.message]})}},[s]),l=c=>{c.target.classList.contains(\"dialog-overlay\")&&r()},d=n?`dialog-panel ${n}`:\"dialog-panel\";return w(mo.Provider,{value:r,children:w(\"div\",{class:\"dialog-overlay\",onClick:l,children:w(\"div\",{class:d,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:u})]})})})}function Wf(){const[e,t]=X(null),n=ce(e);n.current=e;const r=ve(()=>{const a=Oi();t(a??null)},[]),i=ve(()=>{t(null),Of()>0&&requestAnimationFrame(r)},[r]);return Se(()=>Vf({close:i,isOpen:()=>n.current!==null}),[i]),Se(()=>Rf(()=>{t(a=>a!==null?a:Oi()??null)}),[]),e?w(Fr,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton}):null}function Qf(){const e=I(i=>i.storyData),t=I(i=>i.currentPassage),n=I(i=>i.nobr);if(Se(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),I.getState().save()):a.key===\"F9\"&&(a.preventDefault(),I.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(G,{children:[w(jf,{}),w(Wf,{})]});return n?w(Ce.Provider,{value:!0,children:r}):r}function Gf(e){return e.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&#39;/g,\"'\").replace(/&amp;/g,\"&\")}function Yf(){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||\"\",d=new Map,c=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",v=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(P=>P.length>0),x=Gf(h.innerHTML),_={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const P of h.attributes)k.has(P.name)||(_[P.name]=P.value);const S={pid:f,name:p,tags:v,metadata:_,content:x};d.set(p,S),c.set(f,S)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:d,passagesById:c,userCSS:s,userScript:l}}const kt=new Map;let le={},qi=!1;function _o(){return`spindle.${I.getState().storyData?.ifid||\"unknown\"}.settings`}function Kf(){localStorage.setItem(_o(),JSON.stringify(le))}function Ln(){if(!qi){qi=!0;try{const e=localStorage.getItem(_o());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(le={...le,...t})}}catch{}}}const Rt={addToggle(e,t){kt.set(e,{type:\"toggle\",config:t}),e in le||(le[e]=t.default),Ln()},addList(e,t){kt.set(e,{type:\"list\",config:t}),e in le||(le[e]=t.default),Ln()},addRange(e,t){kt.set(e,{type:\"range\",config:t}),e in le||(le[e]=t.default),Ln()},get(e){return le[e]},getToggle(e){const t=le[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=le[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=le[e];return typeof t==\"number\"?t:0},set(e,t){le[e]=t,Kf()},getAll(){return{...le}},getDefinitions(){return kt},hasAny(){return kt.size>0}};function Jf(e,t,n){const r=I.getState(),i=re(r.variables),a=re(r.temporary),o={...t};Ba(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]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in a||r.deleteTemporary(s);for(const s of Object.keys(t))s in o||n(s,void 0)}const yn=new Map,hr=new Set,pr=new Map;function Zf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(pr.get(r)??0)+1;return pr.set(r,i),i===1?r:`${r}:${i}`}function Xf(e){return yn.set(e.id,e),ji(),()=>{yn.delete(e.id),ji()}}function Ui(){return Array.from(yn.values())}function ed(e){return yn.get(e)}function td(){pr.clear()}function nd(e){return hr.add(e),()=>{hr.delete(e)}}function ji(){for(const e of hr)e()}function rd(e){const t=ce(\"\");t.current||(t.current=Zf(e.type,e.key,e.authorId));const n=t.current;return rt(()=>{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),Xf(r)}),n}function id(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function yo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Rr(){const e=I.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?yo(t):\"\"}function ad(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 od(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 sd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const ld={useState:X,useRef:ce,useEffect:Se,useLayoutEffect:rt,useCallback:ve,useMemo:fe,useContext:J};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=Er(),r=a(r),i=a(i));const{update:o,getValues:s}=J(jt),u=J(Ce),l=J(xe),c={collectText:id,sourceLocation:Rr,parseVarArgs:ad,extractOptions:od,h:K,renderNodes:(h,f)=>Ie(h,{nobr:u,locals:l,...f}),renderInlineNodes:io,hooks:ld,useAction:rd,className:r,id:i,resolve:a,cls:sd(e.name,r),mutate:h=>Jf(h,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){c.merged=Ir();const h=c.merged;c.evaluate=f=>kn(f,h[0],h[1],h[2])}if(e.storeVar){const f=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");c.varName=f,c.value=I(v=>v.variables[f]);const p=I(v=>v.setVariable);c.setValue=v=>p(f,v)}return c.wrap=h=>c.className||c.id?K(\"span\",{id:c.id,class:c.className},h):K(G,null,h),e.render(n,c)}if($l(e.name,t),e.subMacros)for(const n of e.subMacros)Fl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&za(e.name)}function ud(){return{get(e){return I.getState().variables[e]},set(e,t){const n=I.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){I.getState().navigate(e)},back(){I.getState().goBack()},forward(){I.getState().goForward()},restart(){I.getState().restart()},save(e){I.getState().save(e)},load(e){I.getState().load(e)},hasSave(e){return I.getState().hasSave(e)},visited(e){const t=I.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=I.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=I.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=I.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 I.getState().storyData?.name||\"\"},get passage(){return I.getState().currentPassage},settings:Rt,registerClass(e,t){hf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){gf(e)}},getActions(){return Ui()},performAction(e,t){const n=ed(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=I.getState().currentPassage;return I.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return nd(t);if(e===\"variableChanged\"){let n={...I.getState().variables};return I.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(Ui())})})})},watch(e,t){return po(e,t)},unwatch(e){go(e)},openDialog(e,t){Mf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Mi()},closeAllDialogs(){Lf(),Mi()},isDialogOpen(){return Bf()},setNobr(e){I.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){I.getState().setTransition(e)},setNextTransition(e){I.getState().setNextTransition(e)},random(){return Pr()},randomInt(e,t){return Ma(e,t)},config:{get maxHistory(){return I.getState().maxHistory},set maxHistory(e){I.getState().setMaxHistory(e)}},prng:{init(e,t){bl(e,t);const{historyIndex:n}=I.getState();I.setState(r=>{const i=r.history[n];i&&(i.prng=mn())})},isEnabled(){return vl()},get seed(){return wl()},get pull(){return kl()}}}}function cd(){window.Story=ud()}const fd=/^\\$(\\w+)\\s*=\\s*(.+)$/,Wi=/\\$(\\w+(?:\\.\\w+)*)/g,Qi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,dd=new Set([\"number\",\"string\",\"boolean\"]);function bo(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,bo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!dd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function hd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(fd);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=bo(s);t.set(a,{...u,name:a,default:s})}return t}function pd(e){const t=new Set;let n;for(Qi.lastIndex=0;(n=Qi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function gd(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 md(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=pd(i.content);let o;for(Wi.lastIndex=0;(o=Wi.exec(i.content))!==null;){const s=o[1],u=gd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function _d(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function an(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&an(t.children))return!0;if(t.type===\"macro\"){if(an(t.children))return!0;if(t.branches){for(const n of t.branches)if(an(n.children))return!0}}}return!1}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Be({macro:e,error:t}){return w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Rr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return w(Be,{macro:\"print\",error:n})}}});function yd(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 bd(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 Gi(e,t,n,r,i,a,o){const s=I.getState();let u;try{u=kn(e,r,i,a)}catch(d){console.error(`spindle: Error in {computed ${o}}${Rr()}:`,d);return}const l=n?s.temporary[t]:s.variables[t];bd(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=yd(e))}catch(d){return w(Be,{macro:\"computed\",error:d})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);if(!l.current){l.current=!0;const d=I.getState();Gi(o,u,s,d.variables,d.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{Gi(o,u,s,n,r,i,e)},[n,r,i]),null}});function vd(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=wd(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 wd(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 kd(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=vd(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=kd(a,o,i),l=t.cls;return w(\"div\",{class:l,id:t.id,children:[w(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&w(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return w(Be,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?w(\"span\",{id:o,class:a,children:i}):w(G,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return w(Be,{macro:\"if\",error:i})}}return null}});function Sd(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.slice(1),indexVar:o?o.slice(1):null,listExpr:r}}function xd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=X(()=>({...e,...t,...n})),o=ce(i);o.current=i;const s=ve(()=>o.current,[]),u=ve((c,h)=>{a(f=>({...f,[c]:h}))},[]),l=fe(()=>({update:u,getValues:s}),[u,s]),d=J(Ce);return w(jt.Provider,{value:l,children:w(xe.Provider,{value:i,children:Ie(r,{nobr:d,locals:i})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=J(xe);let i;try{i=Sd(e)}catch(d){return w(Be,{macro:\"for\",error:d})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return w(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return w(Be,{macro:\"for\",error:d})}const l=u.map((d,c)=>{const h={[a]:d,...o?{[o]:c}:void 0};return w(xd,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${c}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=()=>{const a=document.createElement(\"div\"),o=K(jt.Provider,{value:{update:n.update,getValues:n.getValues}},K(xe.Provider,{value:n.getValues()},Ie(t)));be(o,a),be(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:i}),w(\"button\",{id:n.id,class:n.cls,onClick:i,children:r})}});function Cd(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Yi(e,t,n){const r=document.createElement(\"div\"),i=K(jt.Provider,{value:{update:n,getValues:t}},K(xe.Provider,{value:t()},Ie(e)));be(i,r),be(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Cd(e),a=o=>{o.preventDefault(),Yi(t,n.getValues,n.update),i&&I.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Yi(t,n.getValues,n.update),i&&I.getState().navigate(i)}}),w(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:a,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return w(Be,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return w(G,{children:n.renderNodes(o.children)})}catch(s){return w(Be,{macro:\"case\",error:s})}}return i?w(G,{children:n.renderNodes(i.children)}):null}});function Or(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)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(f=>({delay:f.rawArgs?Or(f.rawArgs):0,nodes:f.children,className:f.className,id:f.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const f=o+1,p=a[f].delay,v=setTimeout(()=>{s(f)},p);return()=>clearTimeout(v)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),d=t.resolve(u.className),c=t.resolve(u.id),h=d||c?w(\"span\",{id:c,class:d,children:l}):l;return t.wrap(h)}});const vo=nt({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Or(e),[s,u]=r(0),[l,d]=r(!1),c=a(()=>d(!0),[]);if(i(()=>{if(l)return;const f=setInterval(()=>{u(p=>p+1)},o);return()=>clearInterval(f)},[o,l]),s===0&&!l)return null;const h=w(vo.Provider,{value:{stop:c},children:w(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?w(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(vo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Or(e),s=a(null),[u,l]=r(0),[d,c]=r(0);i(()=>{if(s.current){const p=s.current.textContent||\"\";l(p.length)}},[]),i(()=>{if(u===0||d>=u)return;const p=setInterval(()=>{c(v=>v>=u?(clearInterval(p),v):v+1)},o);return()=>clearInterval(p)},[u,o]);const h=d>=u&&u>0,f=[\"macro-type\",h?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return w(\"span\",{id:n.id,class:f,ref:s,style:{clipPath:(u>0&&!h,void 0)},children:[w(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!h?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!h&&u>0&&w(\"span\",{class:\"macro-type-cursor\"})]})}});function Id(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}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=Id(e);return n.hooks.useLayoutEffect(()=>{qa(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=I(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return w(\"span\",{id:t.id,class:r,children:n})}});function at(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=X(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),w(G,{children:[w(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w(Fr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}at({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:I(e=>e.goBack),disabled:!I(e=>e.historyIndex>0)})});at({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:I(e=>e.goForward),disabled:!I(e=>e.historyIndex<e.history.length-1)})});at({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:I(e=>e.save)})});at({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=I(n=>n.load),t=I(n=>n.hasSave);return I(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});at({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:I(e=>e.restart)})});at({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});at({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Rt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(Fr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function Ed(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 Pd(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Ad(){const[e,t]=X(\"load\"),[n,r]=X([]),[i,a]=X(!0),[o,s]=X(null),[u,l]=X(()=>new Set),[d,c]=X(null),[h,f]=X(\"\"),p=ce(null),v=ce(null),x=J(mo),_=I(D=>D.storyData),k=I(D=>D.playthroughId),S=I(D=>D.getSavePayload),P=I(D=>D.loadFromPayload),C=_?.ifid??\"\",y=ve(async()=>{if(!C)return;const D=await Sf(C);r(D),a(!1)},[C]);Se(()=>{y()},[y]),Se(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const A=ce(),T=(D,j=\"success\")=>{clearTimeout(A.current),s({text:D,type:j}),A.current=window.setTimeout(()=>s(null),3e3)},z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},b=async()=>{if(!(!C||!k))try{const D=S();await lo(C,k,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=S();await uo(D,j),T(\"Save overwritten\"),await y()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{P(D.payload),T(\"Game loaded\"),x&&setTimeout(x,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await wf(D),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{c(D.meta.id),f(D.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await kf(d,h.trim()),c(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&c(null)},Y=async D=>{try{const j=await Af(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),se=document.createElement(\"a\");se.href=q,se.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,se.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},de=()=>{v.current?.click()},we=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),se=JSON.parse(q);if(!of(se))throw new Error(\"Invalid save file format\");await Tf(se,C),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick:de,children:\"Import\"}),w(\"input\",{ref:v,type:\"file\",accept:\".json\",style:\"display:none\",onChange:we})]}),w(\"div\",{class:\"saves-body\",children:[i?w(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:Pd(D.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?w(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:se=>f(se.target.value),onKeyDown:Z,onBlur:M}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:Ed(q.meta.updatedAt)})]})]}),w(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?w(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):w(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>Y(q.meta.id),children:\"Export\"}),w(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&w(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===k)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return w(Ad,{})}});function Td({name:e,def:t}){const[n,r]=X(()=>Rt.get(e)),i=a=>{r(a),Rt.set(e,a)};switch(t.type){case\"toggle\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"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 Nd(){const e=Rt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(Td,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return w(Nd,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=I(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&I.getState().trackRender(a),!o)return w(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=mt(o.content),l=_t(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(Ce.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(Ce.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}I.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=I.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),w(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Dd(e){return e.match(/^\\s*[\"']?\\$?\\w+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Dd(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function $d(e){const t=e.match(/^\\s*[\"']?\\$?\\w+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=$d(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),w(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>w(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=I.getState().variables[t.varName],o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function xt(e){const t=mt(e.content),n=_t(t),r=e.tags.includes(\"nobr\");return Ie(n,r?{nobr:!0}:void 0)}const zd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Fd({passage:e,dataTransition:t}){const n=I(v=>v.storyData),r=zd.has(e.name),[i,a]=X(!1),o=fe(()=>{try{return xt(e)}catch(v){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",yo(e),\": \",v.message]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=fe(()=>{if(!s)return null;try{return xt(s)}catch(v){return console.error(\"spindle: Error in PassageHeader:\",v),null}},[s?.content]),c=fe(()=>{if(!u)return null;try{return xt(u)}catch(v){return console.error(\"spindle: Error in PassageFooter:\",v),null}},[u?.content]);Se(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=fe(()=>{if(!i||!l)return null;try{return xt(l)}catch(v){return console.error(\"spindle: Error in PassageDone:\",v),null}},[i,l?.content]),f=e.tags.includes(\"nobr\"),p=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&w(\"div\",{class:\"passage-header\",children:d}),o,c&&w(\"div\",{class:\"passage-footer\",children:c}),h&&w(\"div\",{hidden:!0,children:h})]});return f?w(Ce.Provider,{value:!0,children:p}):p}const Rd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),gr={type:\"fade-through\",duration:300,pause:50};function Od(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Rd.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function Vn(e){return{type:e.type,duration:e.duration??gr.duration,pause:e.pause??gr.pause}}function Md(e,t,n){const r=Od(e);return r?Vn(r):t?Vn(t):n?Vn(n):{...gr}}function Ki(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function Bn(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function Hn(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=I(f=>f.currentPassage),r=I(f=>f.storyData),[i,a]=X(n),o=ce(\"fade\"),s=ce(0),u=ce(null),l=ce([]),d=ve(()=>{for(const f of l.current)clearTimeout(f);l.current=[],Hn(u.current)},[]);Se(()=>{const f=I.getState(),{history:p,historyIndex:v,transitionConfig:x}=f,_=f.consumeNextTransition(),k=s.current;s.current=p.length;const S=!i,P=p.length===1&&v===0&&k>1,C=p.length>1&&v===p.length-1&&k>1&&Math.abs(p.length-k)>1;if(n===i)return;d();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(S||P||C){o.current=\"fade\",a(n);return}const A=Md(y.tags,_,x);o.current=A.type;const T=u.current;if(A.type===\"none\"){a(n);return}if(A.type===\"fade\"){T&&Bn(T,A),a(n);return}if(A.type===\"fade-through\"){if(!T){a(n);return}Bn(T,A);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Ki(z,A.type);T.appendChild(b),a(\"\");const N=A.duration+A.pause,$=setTimeout(()=>{a(n)},N),B=N+A.duration,U=setTimeout(()=>{Hn(T)},B);l.current=[$,U];return}if(A.type===\"crossfade\"){if(!T){a(n);return}Bn(T,A);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Ki(z,A.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const N=setTimeout(()=>{Hn(T)},A.duration);l.current=[N];return}a(n)},[n]);const c=i?r?.passages.get(i):null;if(!c&&i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&w(\"div\",{hidden:!0,children:xt(h)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:c&&w(Fd,{passage:c,dataTransition:o.current},i)})]})}});V({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const c=l[1]??l[5],h=l[2]??l[3]??l[4];if(c)switch(c){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,po(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,go(r)),null}});const Ld='*,*: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-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.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}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{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}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 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-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-link:active{color:#42a5f5}.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}}';function Ji(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 Zi(){const e=Yf(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Ld,document.head.appendChild(t),cd(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",f=document.getElementById(\"root\");throw f&&Ji(f,[h]),new Error(`spindle: ${h}`)}const i=hd(r.content),a=md(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&Ji(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=_d(i),I.getState().init(e,n),fo();const o=Ef(e.ifid);o&&I.getState().loadFromPayload(o);for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const f=mt(h.content),p=_t(f);for(const v of p)if(v.type===\"macro\"&&v.name===\"widget\"&&v.rawArgs){const x=v.rawArgs.trim().split(/\\s+/),_=x[0].replace(/[\"']/g,\"\"),k=x.slice(1).filter(C=>C.startsWith(\"$\")||C.startsWith(\"_\")||C.startsWith(\"@\")),S=v.children,P=an(S);qa(_,S,k,P),P&&za(_)}}let s=\"\";I.subscribe(h=>{h.currentPassage!==s&&(s=h.currentPassage,td())});let u=I.getState().variables,l=I.getState().historyIndex;I.subscribe(h=>{h.variables!==u&&(h.historyIndex===l?$f():zf()),u=h.variables,l=h.historyIndex});const d=e.passages.get(\"StoryInterface\");d&&!d.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const c=document.getElementById(\"root\");if(!c)throw new Error('spindle: No <div id=\"root\"> element found.');be(w(Qf,{}),c),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Zi):Zi();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})