@rohal12/spindle 0.26.1 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.26.1","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 zt,O,Yi,Qe,qr,Ki,Ji,Zi,hr,Bn,Hn,Xi,rn={},an=[],jo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ft=Array.isArray;function Ee(e,t){for(var n in t)e[n]=t[n];return e}function pr(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?zt.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 St(e,o,r,i,null)}function St(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??++Yi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Wo(){return{current:null}}function G(e){return e.children}function Pe(e,t){this.props=e,this.context=t}function lt(e,t){if(t==null)return e.__?lt(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\"?lt(e):null}function Qo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ee({},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??lt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ra(r,a,i),t.__e=t.__=null,a.__e!=n&&ea(a)}}function ea(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}),ea(e)}function qn(e){(!e.__d&&(e.__d=!0)&&Qe.push(e)&&!on.__r++||qr!=O.debounceRendering)&&((qr=O.debounceRendering)||Ki)(on)}function on(){for(var e,t=1;Qe.length;)Qe.length>t&&Qe.sort(Ji),e=Qe.shift(),t=Qe.length,Qo(e);on.__r=0}function ta(e,t,n,r,i,a,o,s,u,l,f){var c,h,d,p,k,x,_,v=r&&r.__k||an,S=t.length;for(u=Go(n,t,v,u,S),c=0;c<S;c++)(d=n.__k[c])!=null&&(h=d.__i!=-1&&v[d.__i]||rn,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&&gr(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=na(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 Go(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]=St(null,o,null,null,null):Ft(o)?o=e.__k[a]=St(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=St(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=Yo(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=lt(s)),aa(s,s));return r}function na(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=na(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=lt(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\"||(Ft(e)?e.some(function(n){Fe(n,t)}):t.push(e)),t}function Yo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],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 Ur(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||jo.test(t)?n:n+\"px\"}function Ut(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||Ur(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Ur(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Zi,\"$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=hr,e.addEventListener(t,a?Hn:Bn,a)):e.removeEventListener(t,a?Hn:Bn,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 jr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=hr++;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,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]),(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=Jo),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=Ee({},c.__s)),Ee(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)}),an.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),an.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=Ee(Ee({},r),c.getChildContext())),v&&!h&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(d,p)),A=f!=null&&f.type===G&&f.key==null?ia(f.props.children):f,s=ta(e,Ft(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--;)pr(a[T]);Un(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Un(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Ko(n.__e,t,n,r,i,a,o,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:s}function Un(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Un))}function ra(e,t,n){for(var r=0;r<n.length;r++)gr(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 ia(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Ft(e)?e.map(ia):Ee({},e)}function Ko(e,t,n,r,i,a,o,s,u){var l,f,c,h,d,p,k,x=n.props||rn,_=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&&zt.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 _||Ut(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||Ut(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=\"\"),ta(t.type==\"template\"?e.content:e,Ft(h)?h:[h],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&<(n,0),s,u),a!=null)for(l=a.length;l--;)pr(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])&&Ut(e,l,p,x[l],i),l=\"checked\",k!=null&&k!=e[l]&&Ut(e,l,k,x[l],i))}return e}function gr(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 aa(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||gr(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]&&aa(r[i],t,n||typeof e.type!=\"function\");n||pr(e.__e),e.__c=e.__=e.__e=void 0}function Jo(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||rn,rn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?zt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ra(a,e,o)}function oa(e,t){be(e,t,oa)}function Zo(e,t,n){var r,i,a,o,s=Ee({},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?zt.call(arguments,2):n),St(e.type,s,r||e.key,i||e.ref,null)}function dt(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,qn(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\"+Xi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}zt=an.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}},Yi=0,Pe.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ee({},this.state),typeof e==\"function\"&&(e=e(Ee({},n),this.props)),e&&Ee(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qn(this))},Pe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qn(this))},Pe.prototype.render=G,Qe=[],Ki=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ji=function(e,t){return e.__v.__b-t.__v.__b},on.__r=0,Zi=/(PointerCapture)$|Capture$/i,hr=0,Bn=jr(!1),Hn=jr(!0),Xi=0;var Xo=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:--Xo,__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,En,Wr,ut=0,sa=[],Q=O,Qr=Q.__b,Gr=Q.__r,Yr=Q.diffed,Kr=Q.__c,Jr=Q.unmount,Zr=Q.__;function ht(e,t){Q.__h&&Q.__h(W,e,ut||t),ut=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return ut=1,_r(fa,e)}function _r(e,t,n){var r=ht(Le++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):fa(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 Ae(e,t){var n=ht(Le++,3);!Q.__s&&yr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function nt(e,t){var n=ht(Le++,4);!Q.__s&&yr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function fe(e){return ut=5,de(function(){return{current:e}},[])}function la(e,t,n){ut=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=ht(Le++,7);return yr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return ut=8,de(function(){return e},t)}function ue(e){var t=W.context[e.__c],n=ht(Le++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function ua(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function ca(){var e=ht(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 es(){for(var e;e=sa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Jt),t.__h.some(jn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Qr&&Qr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Zr&&Zr(e,t)},Q.__r=function(e){Gr&&Gr(e),Le=0;var t=(W=e.__c).__H;t&&(En===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Jt),t.__h.some(jn),t.__h=[],Le=0)),En=W},Q.diffed=function(e){Yr&&Yr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(sa.push(t)!==1&&Wr===Q.requestAnimationFrame||((Wr=Q.requestAnimationFrame)||ts)(es)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),En=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Jt),n.__h=n.__h.filter(function(r){return!r.__||jn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Kr&&Kr(e,t)},Q.unmount=function(e){Jr&&Jr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Jt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Xr=typeof requestAnimationFrame==\"function\";function ts(e){var t,n=function(){clearTimeout(r),Xr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Xr&&(t=requestAnimationFrame(n))}function Jt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function jn(e){var t=W;e.__c=e.__(),W=t}function yr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function fa(e,t){return typeof t==\"function\"?t(e):t}const ei=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},ns=(e=>e?ei(e):ei);function da(e,t){for(var n in t)e[n]=t[n];return e}function Wn(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 ha(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]),Ae(function(){return Pn(i)&&a({t:i}),e(function(){Pn(i)&&a({t:i})})},[e]),n}function Pn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function pa(e){e()}function ma(e){return e}function ga(){return[!1,pa]}var _a=nt;function Qn(e,t){this.props=e,this.context=t}function rs(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:Wn(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}(Qn.prototype=new Pe).isPureReactComponent=!0,Qn.prototype.shouldComponentUpdate=function(e,t){return Wn(this.props,e)||Wn(this.state,t)};var ti=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ti&&ti(e)};var is=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function as(e){function t(n){var r=da({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=is,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ni=function(e,t){return e==null?null:Fe(Fe(e).map(t))},os={map:ni,forEach:ni,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},ss=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)}ss(e,t,n,r)};var ri=O.unmount;function ya(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=da({},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 ya(r,t,n)})),e}function ba(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ba(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 Zt(){this.__u=0,this.o=null,this.__b=null}function va(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ls(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 wt(){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),ri&&ri(e)},(Zt.prototype=new Pe).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=va(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]=ba(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)},Zt.prototype.componentWillUnmount=function(){this.o=[]},Zt.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]=ya(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 ii=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 us(e){return this.getChildContext=function(){return e.context},e.children}function cs(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(us,{context:t.context},e.__v),t.v)}function fs(e,t){var n=K(cs,{__v:e,h:t});return n.containerInfo=t,n}(wt.prototype=new Pe).__a=function(e){var t=this,n=va(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ii(t,e,r)):i()};n?n(a):a()}},wt.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},wt.prototype.componentDidUpdate=wt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ii(e,n,t)})};var wa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ds=/^(?: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]/,hs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ps=/[A-Z0-9]/g,ms=typeof document<\"u\",gs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function _s(e,t,n){return t.__k==null&&(t.textContent=\"\"),be(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ys(e,t,n){return oa(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 ai=O.event;function bs(){}function vs(){return this.cancelBubble}function ws(){return this.defaultPrevented}O.event=function(e){return ai&&(e=ai(e)),e.persist=bs,e.isPropagationStopped=vs,e.isDefaultPrevented=ws,e.nativeEvent=e};var br,ks={enumerable:!1,configurable:!0,get:function(){return this.class}},oi=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||ms&&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\"||gs(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":hs.test(o)&&(o=u):u=o=\"oninput\":a&&ds.test(o)?o=o.replace(ps,\"-$&\").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\",ks)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=wa,oi&&oi(e)};var si=O.__r;O.__r=function(e){si&&si(e),br=e.__c};var li=O.diffed;O.diffed=function(e){li&&li(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),br=null};var Ss={ReactCurrentDispatcher:{current:{readContext:function(e){return br.__n[e.__c].props.value},useCallback:ve,useContext:ue,useDebugValue:ua,useDeferredValue:ma,useEffect:Ae,useId:ca,useImperativeHandle:la,useInsertionEffect:_a,useLayoutEffect:nt,useMemo:de,useReducer:_r,useRef:fe,useState:Z,useSyncExternalStore:ha,useTransition:ga}}};function xs(e){return K.bind(null,e)}function _n(e){return!!e&&e.$$typeof===wa}function Cs(e){return _n(e)&&e.type===G}function Is(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Es(e){return _n(e)?Zo.apply(null,arguments):e}function Ps(e){return!!e.__k&&(be(null,e),!0)}function As(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ts=function(e,t){return e(t)},Ns=function(e,t){return e(t)},Ds=G,$s=_n,jt={useState:Z,useId:ca,useReducer:_r,useEffect:Ae,useLayoutEffect:nt,useInsertionEffect:_a,useTransition:ga,useDeferredValue:ma,useSyncExternalStore:ha,startTransition:pa,useRef:fe,useImperativeHandle:la,useMemo:de,useCallback:ve,useContext:ue,useDebugValue:ua,version:\"18.3.1\",Children:os,render:_s,hydrate:ys,unmountComponentAtNode:Ps,createPortal:fs,createElement:K,createContext:dt,createFactory:xs,cloneElement:Es,createRef:Wo,Fragment:G,isValidElement:_n,isElement:$s,isFragment:Cs,isMemo:Is,findDOMNode:As,Component:Pe,PureComponent:Qn,memo:rs,forwardRef:as,flushSync:Ns,unstable_batchedUpdates:Ts,StrictMode:Ds,Suspense:Zt,SuspenseList:wt,lazy:ls,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ss};const zs=e=>e;function Fs(e,t=zs){const n=jt.useSyncExternalStore(e.subscribe,jt.useCallback(()=>t(e.getState()),[e,t]),jt.useCallback(()=>t(e.getInitialState()),[e,t]));return jt.useDebugValue(n),n}const Rs=e=>{const t=ns(e),n=r=>Fs(t,r);return Object.assign(n,t),n},Os=(e=>Rs);var vr=Symbol.for(\"immer-nothing\"),xt=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,Et=\"constructor\",Rt=\"prototype\",Gn=\"configurable\",sn=\"enumerable\",Xt=\"writable\",Pt=\"value\",Re=e=>!!e&&!!e[ee];function Te(e){return e?ka(e)||Mt(e)||!!e[xt]||!!e[Et]?.[xt]||Lt(e)||Vt(e):!1}var Ms=he[Rt][Et].toString(),ui=new WeakMap;function ka(e){if(!e||!ct(e))return!1;const t=Ze(e);if(t===null||t===he[Rt])return!0;const n=he.hasOwnProperty.call(t,Et)&&t[Et];if(n===Object)return!0;if(!Ge(n))return!1;let r=ui.get(n);return r===void 0&&(r=Function.toString.call(n),ui.set(n,r)),r===Ms}function Ot(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_:Mt(e)?1:Lt(e)?2:Vt(e)?3:0}var Ct=(e,t,n=Xe(e))=>n===2?e.has(t):he[Rt].hasOwnProperty.call(e,t),$e=(e,t,n=Xe(e))=>n===2?e.get(t):e[t],ln=(e,t,n,r=Xe(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ls(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Mt=Array.isArray,Lt=e=>e instanceof Map,Vt=e=>e instanceof Set,ct=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",An=e=>typeof e==\"boolean\";function Vs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Bs=e=>ct(e)?e?.[ee]:null,ze=e=>e.copy_||e.base_,wr=e=>e.modified_?e.copy_:e.base_;function Yn(e,t){if(Lt(e))return new Map(e);if(Vt(e))return new Set(e);if(Mt(e))return Array[Rt].slice.call(e);const n=ka(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[Xt]===!1&&(s[Xt]=!0,s[Gn]=!0),(s.get||s.set)&&(r[o]={[Gn]:!0,[Xt]:!0,[sn]:s[sn],[Pt]: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 kr(e,t=!1){return yn(e)||Re(e)||!Te(e)||(Xe(e)>1&&he.defineProperties(e,{set:Wt,add:Wt,clear:Wt,delete:Wt}),he.freeze(e),t&&Ot(e,(n,r)=>{kr(r,!0)},!1)),e}function Hs(){ie(2)}var Wt={[Pt]:Hs};function yn(e){return e===null||!ct(e)?!0:he.isFrozen(e)}var un=\"MapSet\",cn=\"Patches\",ci=\"ArrayMethods\",fn={};function et(e){const t=fn[e];return t||ie(0,e),t}var fi=e=>!!fn[e];function qs(e,t){fn[e]||(fn[e]=t)}var At,Sa=()=>At,Us=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:fi(un)?et(un):void 0,arrayMethodsPlugin_:fi(ci)?et(ci):void 0});function di(e,t){t&&(e.patchPlugin_=et(cn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kn(e){Jn(e),e.drafts_.forEach(js),e.drafts_=null}function Jn(e){e===At&&(At=e.parent_)}var hi=e=>At=Us(At,e);function js(e){const t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function pi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ee].modified_&&(Kn(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 Ws(t,e,!0),Kn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==vr?e:void 0}function mi(e,t){if(yn(t))return t;const n=t[ee];if(!n)return dn(t,e.handledSet_,e);if(!bn(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);Ia(n,e)}return n.copy_}function Ws(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&kr(t,n)}function xa(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var bn=(e,t)=>e.scope_===t,Qs=[];function Ca(e,t,n,r){const i=ze(e),a=e.type_;if(r!==void 0&&$e(i,r,a)===t){ln(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Ot(i,(u,l)=>{if(Re(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??Qs;for(const s of o)ln(i,s,n,a)}function Gs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!bn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=wr(a);Ca(e,a.draft_??a,o,n),Ia(a,i)})}function Ia(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)}xa(e)}}function Ys(e,t,n){const{scope_:r}=e;if(Re(n)){const i=n[ee];bn(i,r)&&i.callbacks_.push(function(){en(e);const o=wr(i);Ca(e,n,o,t)})}else Te(n)&&e.callbacks_.push(function(){const a=ze(e);e.type_===3?a.has(n)&&dn(n,r.handledSet_,r):$e(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&dn($e(e.copy_,t,e.type_),r.handledSet_,r)})}function dn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Re(e)||t.has(e)||!Te(e)||yn(e)||(t.add(e),Ot(e,(r,i)=>{if(Re(i)){const a=i[ee];if(bn(a,n)){const o=wr(a);ln(e,r,o,e.type_),xa(a)}}else Te(i)&&dn(i,t,n)})),e}function Ks(e,t){const n=Mt(e),r={type_:n?1:0,scope_:t?t.scope_:Sa(),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=hn;n&&(i=[r],a=Tt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var hn={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(!Ct(i,t,e.type_))return Js(e,i,t);const a=i[t];if(e.finalized_||!Te(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Vs(t))return a;if(a===Tn(e.base_,t)){en(e);const o=e.type_===1?+t:t,s=Xn(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=Ea(ze(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Tn(ze(e),t),a=i?.[ee];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ls(n,i)&&(n!==void 0||Ct(e.base_,t,e.type_)))return!0;en(e),Zn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Ys(e,t,n)),!0},deleteProperty(e,t){return en(e),Tn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Zn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ze(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Xt]:!0,[Gn]:e.type_!==1||t!==\"length\",[sn]:r[sn],[Pt]:n[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ie(12)}},Tt={};for(let e in hn){let t=hn[e];Tt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Tt.deleteProperty=function(e,t){return Tt.set.call(this,e,t,void 0)};Tt.set=function(e,t,n){return hn.set.call(this,e[0],t,n,e[0])};function Tn(e,t){const n=e[ee];return(n?ze(n):e)[t]}function Js(e,t,n){const r=Ea(t,n);return r?Pt in r?r[Pt]:r.get?.call(e.draft_):void 0}function Ea(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 Zn(e){e.modified_||(e.modified_=!0,e.parent_&&Zn(e.parent_))}function en(e){e.copy_||(e.assigned_=new Map,e.copy_=Yn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Zs=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=hi(this),o=Xn(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Kn(a):Jn(a)}return di(a,r),pi(i,a)}else if(!t||!ct(t)){if(i=n(t),i===void 0&&(i=t),i===vr&&(i=void 0),this.autoFreeze_&&kr(i,!0),r){const a=[],o=[];et(cn).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]},An(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),An(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),An(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Te(e)||ie(8),Re(e)&&(e=Xs(e));const t=hi(this),n=Xn(t,e,void 0);return n[ee].isManual_=!0,Jn(t),n}finishDraft(e,t){const n=e&&e[ee];(!n||!n.isManual_)&&ie(9);const{scope_:r}=n;return di(r,t),pi(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(cn).applyPatches_;return Re(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Xn(e,t,n,r){const[i,a]=Lt(t)?et(un).proxyMap_(t,n):Vt(t)?et(un).proxySet_(t,n):Ks(t,n);return(n?.scope_??Sa()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Gs(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function Xs(e){return Re(e)||ie(10,e),Pa(e)}function Pa(e){if(!Te(e)||yn(e))return e;const t=e[ee];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Yn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Yn(e,!0);return Ot(n,(i,a)=>{ln(n,i,Pa(a))},r),t&&(t.finalized_=!1),n}function el(){function t(p,k=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Bs($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||Ct(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),!ct(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 A=E[y],T=v[y];if((I||S?.get(y.toString()))&&A!==T){const b=A?.[ee];if(b&&b.modified_)continue;const N=k.concat([y]);x.push({op:r,path:N,value:d(A)}),_.push({op:r,path:N,value:d(T)})}}for(let y=v.length;y<E.length;y++){const A=k.concat([y]);x.push({op:i,path:A,value:d(E[y])})}for(let y=E.length-1;v.length<=y;--y){const A=k.concat([y]);_.push({op:a,path:A})}}function u(p,k,x,_){const{base_:v,copy_:S,type_:E}=p;Ot(p.assigned_,(I,y)=>{const A=$e(v,I,E),T=$e(S,I,E),z=y?Ct(v,I)?r:i:a;if(A===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(A)}:{op:r,path:b,value:d(A)})})}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===vr?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 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===Et)&&ie(19),Ge(S)&&z===Rt&&ie(19),S=$e(S,z),ct(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(Mt(p))return p.map(h);if(Lt(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,h(_)]));if(Vt(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 Ct(p,xt)&&(k[xt]=p[xt]),k}function d(p){return Re(p)?h(p):p}qs(cn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Nt=new Zs,tl=Nt.produce,nl=Nt.produceWithPatches.bind(Nt),st=Nt.applyPatches.bind(Nt);const rl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?tl(i):i;return t(s,a,...o)},e(r.setState,n,r)),il=rl,al=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\"]),ol=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function sl(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 gi(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 _i(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 ll(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function pt(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=_i(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}=sl(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=_i(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:_}=gi(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}=gi(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&&al.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=ll(e,o);o=f.endIdx;let c=ol.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 Aa=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function ul(e){Aa.add(e.toLowerCase())}const yi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},cl=new Set([\"if\",\"switch\",\"timed\"]);function mt(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(yi[a]){const o=yi[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(Aa.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(cl.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 Sr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=ue(He);return de(()=>[e,t,n],[e,t,n])}const fl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,dl=/\\{[\\$_@][\\w.]+\\}/;function Ta(e){return dl.test(e)}function hl(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 Na(e,t,n,r){return e.replace(fl,(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=hl(f,u)),f==null?\"\":String(f)})}function xr(){const[e,t,n]=Sr();return ve(r=>r===void 0||!Ta(r)?r:Na(r,e,t,n),[e,t,n])}function pl({name:e,scope:t,className:n,id:r}){const i=xr();n=i(n),r=i(r);const a=ue(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 Da(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 $a(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let gt=!1,Bt=\"\",tt=0,ft=null;function ml(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Bt=n,tt=0,ft=Da($a(n)),gt=!0}function za(e,t){Bt=e,tt=0,ft=Da($a(e)),gt=!0;for(let n=0;n<t;n++)ft();tt=t}function er(){gt=!1,Bt=\"\",tt=0,ft=null}function pn(){return gt?{seed:Bt,pull:tt}:null}function Cr(){return!gt||!ft?Math.random():(tt++,ft())}function Fa(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Cr()*(t-e+1))+e}function gl(){return gt}function _l(){return Bt}function yl(){return tt}const bl=500,We=new Map,vl=/\\$(\\w+)/g,wl=/\\b_(\\w+)/g,kl=/@(\\w+)/g;function Sl(e){return e.replace(vl,'variables[\"$1\"]').replace(wl,'temporary[\"$1\"]').replace(kl,'locals[\"$1\"]')}function Ir(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Sl(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+=Ir(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 xl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Ra(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\",xl+t);if(We.set(e,r),We.size>bl){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let Qt=null,bi=null,vi=null;function Oa(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(Qt&&bi===t&&vi===n)return Qt;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 Qt={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:Cr,randomInt:Fa},bi=t,vi=n,Qt}function vn(e,t,n,r={}){const a=`return (${Ir(e)});`;return Ra(a,a)(t,n,r,Oa())}function Ma(e,t,n,r={}){const i=Ir(e);Ra(\"exec:\"+i,i)(t,n,r,Oa())}function Cl(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 Il({body:e,parentValues:t,ownKeys:n}){const r=ue(Ne),[i,a]=Z(()=>({...t,...n})),o=fe(i);o.current=i;const s=ve(()=>o.current,[]),u=ve((f,c)=>{a(h=>({...h,[f]:c}))},[]),l=de(()=>({update:u,getValues:s}),[u,s]);return w(Ht.Provider,{value:l,children:w(He.Provider,{value:i,children:Se(e,r?{nobr:!0}:void 0)})})}function El({body:e,params:t,rawArgs:n}){const r=ue(He),i=ue(Ne),[a,o,s]=Sr();if(t.length===0||!n)return w(G,{children:Se(e,i?{nobr:!0}:void 0)});const u=Cl(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=vn(h,a,o,s)}catch{d=void 0}l[c.startsWith(\"@\")?c.slice(1):c]=d}return w(Il,{body:e,parentValues:r,ownKeys:l})}const La=new Map;function Va(e,t,n){La.set(e.toLowerCase(),{body:t,params:n})}function Pl(e){return La.get(e.toLowerCase())}const Ba=new Map;function Al(e,t){Ba.set(e.toLowerCase(),t)}function Tl(e){return Ba.get(e.toLowerCase())}const Ha=new Set;function Nl(e){Ha.add(e.toLowerCase())}function Dl(e){return Ha.has(e.toLowerCase())}const wi=document.createElement(\"i\");function qa(e){const t=\"&\"+e+\";\";wi.innerHTML=t;const n=wi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function me(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?(me(e,e.length,0,t),e):t}const tr={}.hasOwnProperty;function $l(e){const t={};let n=-1;for(;++n<e.length;)zl(t,e[n]);return t}function zl(e,t){let n;for(n in t){const i=(tr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){tr.call(i,o)||(i[o]=[]);const s=a[o];Fl(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Fl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);me(e,0,0,r)}function Rl(e){const t={};let n=-1;for(;++n<e.length;)Ol(t,e[n]);return t}function Ol(e,t){let n;for(n in t){const i=(tr.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 Ml(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 Ll={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ua(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Ll[n]+\";\"}}function Dt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Ie=Be(/[A-Za-z]/),pe=Be(/[\\dA-Za-z]/),Vl=Be(/[#-'*+\\--9=?A-Z^-~]/);function nr(e){return e!==null&&(e<32||e===127)}const rr=Be(/\\d/),Bl=Be(/[\\dA-Fa-f]/),Hl=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 ql=Be(/\\p{P}|\\p{S}/u),Ul=Be(/\\s/);function Be(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gt(e,t){const n=Ua(jl(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 jl(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 ki={}.hasOwnProperty,Si=/^(https?|ircs?|mailto|xmpp)$/i,Wl=/^https?$/i;function Ql(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Rl([{enter:{blockQuote:M,codeFenced:we,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:Oo,content:Co,definition:bo,definitionDestinationString:wo,definitionLabelString:x,definitionTitleString:x,emphasis:Fo,htmlFlow:zo,htmlText:Mr,image:q,label:x,link:oe,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:Y,reference:x,resource:it,resourceDestinationString:at,resourceTitleString:x,setextHeading:Eo,strong:Ro},exit:{atxHeading:Ao,atxHeadingSequence:Io,autolinkEmail:Uo,autolinkProtocol:qo,blockQuote:J,characterEscapeValue:yt,characterReferenceMarkerHexadecimal:Lr,characterReferenceMarkerNumeric:Lr,characterReferenceValue:Ho,codeFenced:m,codeFencedFence:D,codeFencedFenceInfo:g,codeFencedFenceMeta:A,codeFlowValue:$o,codeIndented:m,codeText:Mo,codeTextData:yt,data:yt,definition:xo,definitionDestinationString:ko,definitionLabelString:vo,definitionTitleString:So,emphasis:Lo,hardBreakEscape:Rr,hardBreakTrailing:Rr,htmlFlow:Or,htmlFlowData:yt,htmlText:Or,htmlTextData:yt,image:Fr,label:_t,labelText:X,lineEnding:Do,link:Fr,listOrdered:$,listUnordered:B,paragraph:ce,reference:A,referenceString:Oe,resource:A,resourceDestinationString:In,resourceTitleString:yo,setextHeading:No,setextHeadingLineSequence:To,setextHeadingText:Po,strong:Vo,thematicBreak:Bo}},...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(P){let F=-1,te=0;const ke=[];let xe=[],De=[];for(;++F<P.length;)!c&&(P[F][1].type===\"lineEnding\"||P[F][1].type===\"lineEndingBlank\")&&(c=P[F][2].sliceSerialize(P[F][1])),(P[F][1].type===\"listOrdered\"||P[F][1].type===\"listUnordered\")&&(P[F][0]===\"enter\"?ke.push(F):d(P.slice(ke.pop(),F))),P[F][1].type===\"definition\"&&(P[F][0]===\"enter\"?(De=re(De,P.slice(te,F)),te=F):(xe=re(xe,P.slice(te,F+1)),te=F+1));xe=re(xe,De),xe=re(xe,P.slice(te)),F=-1;const Ce=xe;for(u.enter.null&&u.enter.null.call(f);++F<P.length;){const Vr=u[Ce[F][0]],Br=Ce[F][1].type,Hr=Vr[Br];ki.call(Vr,Br)&&Hr&&Hr.call({sliceSerialize:Ce[F][2].sliceSerialize,...f},Ce[F][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function d(P){const F=P.length;let te=0,ke=0,xe=!1,De;for(;++te<F;){const Ce=P[te];if(Ce[1]._container)De=void 0,Ce[0]===\"enter\"?ke++:ke--;else switch(Ce[1].type){case\"listItemPrefix\":{Ce[0]===\"exit\"&&(De=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ce[0]===\"enter\"&&!ke&&(De?De=void 0:xe=!0);break}default:De=void 0}}P[0][1]._loose=xe}function p(P,F){l[P]=F}function k(P){return l[P]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function v(P){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(P))}function S(P){p(\"lastWasTag\"),i[i.length-1].push(P)}function E(){S(c||`\n`)}function I(){const P=i[i.length-1],F=P[P.length-1],te=F?F.charCodeAt(F.length-1):null;te===10||te===13||te===null||E()}function y(P){return k(\"ignoreEncode\")?P:Ua(P)}function A(){_()}function T(P){o.push(!P._loose),I(),v(\"<ol\"),p(\"expectFirstItem\",!0)}function z(P){o.push(!P._loose),I(),v(\"<ul\"),p(\"expectFirstItem\",!0)}function b(P){if(k(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(P),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 ce(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):v(\"</p>\")}function we(){I(),v(\"<pre><code\"),p(\"fencesCount\",0)}function g(){const P=_();v(' class=\"language-'+P+'\"')}function D(){const P=k(\"fencesCount\")||0;P||(v(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",P+1)}function j(){I(),v(\"<pre><code>\")}function m(){const P=k(\"fencesCount\");P!==void 0&&P<2&&l.tightStack.length>0&&!k(\"lastWasTag\")&&E(),k(\"flowCodeSeenData\")&&I(),v(\"</code></pre>\"),P!==void 0&&P<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function oe(){a.push({})}function X(P){a[a.length-1].labelId=this.sliceSerialize(P)}function _t(){a[a.length-1].label=_()}function Oe(P){a[a.length-1].referenceId=this.sliceSerialize(P)}function it(){x(),a[a.length-1].destination=\"\"}function at(){x(),p(\"ignoreEncode\",!0)}function In(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function yo(){a[a.length-1].title=_()}function Fr(){let P=a.length-1;const F=a[P],te=F.referenceId||F.labelId,ke=F.destination===void 0?r[Dt(te)]:F;for(n=!0;P--;)if(a[P].image){n=void 0;break}F.image?(v('<img src=\"'+Gt(ke.destination,t.allowDangerousProtocol?void 0:Wl)+'\" alt=\"'),S(F.label),v('\"')):v('<a href=\"'+Gt(ke.destination,t.allowDangerousProtocol?void 0:Si)+'\"'),v(ke.title?' title=\"'+ke.title+'\"':\"\"),F.image?v(\" />\"):(v(\">\"),S(F.label),v(\"</a>\")),a.pop()}function bo(){x(),a.push({})}function vo(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function wo(){x(),p(\"ignoreEncode\",!0)}function ko(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function So(){a[a.length-1].title=_()}function xo(){const P=a[a.length-1],F=Dt(P.labelId);_(),ki.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Co(){p(\"slurpAllLineEndings\",!0)}function Io(P){k(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(P).length),I(),v(\"<h\"+k(\"headingRank\")+\">\"))}function Eo(){x(),p(\"slurpAllLineEndings\")}function Po(){p(\"slurpAllLineEndings\",!0)}function Ao(){v(\"</h\"+k(\"headingRank\")+\">\"),p(\"headingRank\")}function To(P){p(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function No(){const P=_();I(),v(\"<h\"+k(\"headingRank\")+\">\"),S(P),v(\"</h\"+k(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function yt(P){S(y(this.sliceSerialize(P)))}function Do(P){if(!k(\"slurpAllLineEndings\")){if(k(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(k(\"inCodeText\")){S(\" \");return}S(y(this.sliceSerialize(P)))}}function $o(P){S(y(this.sliceSerialize(P))),p(\"flowCodeSeenData\",!0)}function Rr(){v(\"<br />\")}function zo(){I(),Mr()}function Or(){p(\"ignoreEncode\")}function Mr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Fo(){v(\"<em>\")}function Ro(){v(\"<strong>\")}function Oo(){p(\"inCodeText\",!0),v(\"<code>\")}function Mo(){p(\"inCodeText\"),v(\"</code>\")}function Lo(){v(\"</em>\")}function Vo(){v(\"</strong>\")}function Bo(){I(),v(\"<hr />\")}function Lr(P){p(\"characterReferenceType\",P.type)}function Ho(P){const F=this.sliceSerialize(P),te=k(\"characterReferenceType\")?Ml(F,k(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):qa(F);S(y(te)),p(\"characterReferenceType\")}function qo(P){const F=this.sliceSerialize(P);v('<a href=\"'+Gt(F,t.allowDangerousProtocol?void 0:Si)+'\">'),S(y(F)),v(\"</a>\")}function Uo(P){const F=this.sliceSerialize(P);v('<a href=\"'+Gt(\"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 Gl={tokenize:Yl};function Yl(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 Kl={tokenize:Jl},xi={tokenize:Zl};function Jl(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 A=E;for(;A<t.events.length;)t.events[A][1].end={...y},A++;return me(t.events,I+1,0,t.events.slice(E)),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(xi,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(xi,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 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++;me(t.events,T+1,0,t.events.slice(A)),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 Zl(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)||Ul(e))return 1;if(ql(e))return 2}function wn(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 ir={name:\"attention\",resolveAll:Xl,tokenize:eu};function Xl(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};Ci(c,-u),Ci(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,wn(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,me(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 eu(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 Ci(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const tu={name:\"autolink\",tokenize:nu};function nu(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 Ie(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||nr(d)?n(d):(e.consume(d),u)}function l(d){return d===64?(e.consume(d),f):Vl(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 kn={partial:!0,tokenize:ru};function ru(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 ja={continuation:{tokenize:au},exit:ou,name:\"blockQuote\",tokenize:iu};function iu(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 au(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(ja,t,n)(o)}}function ou(e){e.exit(\"blockQuote\")}const Wa={name:\"characterEscape\",tokenize:su};function su(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 Hl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Qa={name:\"characterReference\",tokenize:lu};function lu(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=Bl,f):(e.enter(\"characterReferenceValue\"),a=7,o=rr,f(c))}function f(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===pe&&!qa(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 Ii={partial:!0,tokenize:cu},Ei={concrete:!0,name:\"codeFenced\",tokenize:uu};function uu(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 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\"),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(Ii,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(Ii,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,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 cu(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 Nn={name:\"codeIndented\",tokenize:du},fu={partial:!0,tokenize:hu};function du(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(fu,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 hu(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 pu={name:\"codeText\",previous:gu,resolve:mu,tokenize:_u};function mu(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 gu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function _u(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 yu{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&&bt(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),bt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),bt(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);bt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);bt(this.left,n.reverse())}}}function bt(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 Ga(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new yu(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,bu(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 me(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function bu(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 vu={resolve:ku,tokenize:Su},wu={partial:!0,tokenize:xu};function ku(e){return Ga(e),e}function Su(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(wu,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 xu(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 Ya(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||nr(_)?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||nr(_)?n(_):(e.consume(_),_===92?x:k)}function x(_){return _===40||_===41||_===92?(e.consume(_),k):k(_)}}function Ka(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 Ja(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 It(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 Cu={name:\"definition\",tokenize:Eu},Iu={partial:!0,tokenize:Pu};function Eu(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return Ka.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Dt(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)?It(e,l)(d):l(d)}function l(d){return Ya(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(Iu,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 Pu(e,t,n){return r;function r(s){return ae(s)?It(e,i)(s):n(s)}function i(s){return Ja(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 Au={name:\"hardBreakEscape\",tokenize:Tu};function Tu(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 Nu={name:\"headingAtx\",resolve:Du,tokenize:$u};function Du(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\"},me(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function $u(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 zu=[\"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\"],Fu={concrete:!0,name:\"htmlFlow\",resolveTo:Mu,tokenize:Lu},Ru={partial:!0,tokenize:Bu},Ou={partial:!0,tokenize:Vu};function Mu(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 Lu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(m){return f(m)}function f(m){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(m),c}function c(m){return m===33?(e.consume(m),h):m===47?(e.consume(m),a=!0,k):m===63?(e.consume(m),i=3,r.interrupt?t:g):Ie(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function h(m){return m===45?(e.consume(m),i=2,d):m===91?(e.consume(m),i=5,s=0,p):Ie(m)?(e.consume(m),i=4,r.interrupt?t:g):n(m)}function d(m){return m===45?(e.consume(m),r.interrupt?t:g):n(m)}function p(m){const q=\"CDATA[\";return m===q.charCodeAt(s++)?(e.consume(m),s===q.length?r.interrupt?t:$:p):n(m)}function k(m){return Ie(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function x(m){if(m===null||m===47||m===62||ae(m)){const q=m===47,oe=o.toLowerCase();return!q&&!a&&Pi.includes(oe)?(i=1,r.interrupt?t(m):$(m)):zu.includes(o.toLowerCase())?(i=6,q?(e.consume(m),_):r.interrupt?t(m):$(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(m):a?v(m):S(m))}return m===45||pe(m)?(e.consume(m),o+=String.fromCharCode(m),x):n(m)}function _(m){return m===62?(e.consume(m),r.interrupt?t:$):n(m)}function v(m){return L(m)?(e.consume(m),v):b(m)}function S(m){return m===47?(e.consume(m),b):m===58||m===95||Ie(m)?(e.consume(m),E):L(m)?(e.consume(m),S):b(m)}function E(m){return m===45||m===46||m===58||m===95||pe(m)?(e.consume(m),E):I(m)}function I(m){return m===61?(e.consume(m),y):L(m)?(e.consume(m),I):S(m)}function y(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),u=m,A):L(m)?(e.consume(m),y):T(m)}function A(m){return m===u?(e.consume(m),u=null,z):m===null||R(m)?n(m):(e.consume(m),A)}function T(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||ae(m)?I(m):(e.consume(m),T)}function z(m){return m===47||m===62||L(m)?S(m):n(m)}function b(m){return m===62?(e.consume(m),N):n(m)}function N(m){return m===null||R(m)?$(m):L(m)?(e.consume(m),N):n(m)}function $(m){return m===45&&i===2?(e.consume(m),J):m===60&&i===1?(e.consume(m),Y):m===62&&i===4?(e.consume(m),D):m===63&&i===3?(e.consume(m),g):m===93&&i===5?(e.consume(m),we):R(m)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Ru,j,B)(m)):m===null||R(m)?(e.exit(\"htmlFlowData\"),B(m)):(e.consume(m),$)}function B(m){return e.check(Ou,U,j)(m)}function U(m){return e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),M}function M(m){return m===null||R(m)?B(m):(e.enter(\"htmlFlowData\"),$(m))}function J(m){return m===45?(e.consume(m),g):$(m)}function Y(m){return m===47?(e.consume(m),o=\"\",ce):$(m)}function ce(m){if(m===62){const q=o.toLowerCase();return Pi.includes(q)?(e.consume(m),D):$(m)}return Ie(m)&&o.length<8?(e.consume(m),o+=String.fromCharCode(m),ce):$(m)}function we(m){return m===93?(e.consume(m),g):$(m)}function g(m){return m===62?(e.consume(m),D):m===45&&i===2?(e.consume(m),g):$(m)}function D(m){return m===null||R(m)?(e.exit(\"htmlFlowData\"),j(m)):(e.consume(m),D)}function j(m){return e.exit(\"htmlFlow\"),t(m)}}function Vu(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 Bu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(kn,t,n)}}const Hu={name:\"htmlText\",tokenize:qu};function qu(e,t,n){const r=this;let i,a,o;return s;function s(g){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(g),u}function u(g){return g===33?(e.consume(g),l):g===47?(e.consume(g),I):g===63?(e.consume(g),S):Ie(g)?(e.consume(g),T):n(g)}function l(g){return g===45?(e.consume(g),f):g===91?(e.consume(g),a=0,p):Ie(g)?(e.consume(g),v):n(g)}function f(g){return g===45?(e.consume(g),d):n(g)}function c(g){return g===null?n(g):g===45?(e.consume(g),h):R(g)?(o=c,Y(g)):(e.consume(g),c)}function h(g){return g===45?(e.consume(g),d):c(g)}function d(g){return g===62?J(g):g===45?h(g):c(g)}function p(g){const D=\"CDATA[\";return g===D.charCodeAt(a++)?(e.consume(g),a===D.length?k:p):n(g)}function k(g){return g===null?n(g):g===93?(e.consume(g),x):R(g)?(o=k,Y(g)):(e.consume(g),k)}function x(g){return g===93?(e.consume(g),_):k(g)}function _(g){return g===62?J(g):g===93?(e.consume(g),_):k(g)}function v(g){return g===null||g===62?J(g):R(g)?(o=v,Y(g)):(e.consume(g),v)}function S(g){return g===null?n(g):g===63?(e.consume(g),E):R(g)?(o=S,Y(g)):(e.consume(g),S)}function E(g){return g===62?J(g):S(g)}function I(g){return Ie(g)?(e.consume(g),y):n(g)}function y(g){return g===45||pe(g)?(e.consume(g),y):A(g)}function A(g){return R(g)?(o=A,Y(g)):L(g)?(e.consume(g),A):J(g)}function T(g){return g===45||pe(g)?(e.consume(g),T):g===47||g===62||ae(g)?z(g):n(g)}function z(g){return g===47?(e.consume(g),J):g===58||g===95||Ie(g)?(e.consume(g),b):R(g)?(o=z,Y(g)):L(g)?(e.consume(g),z):J(g)}function b(g){return g===45||g===46||g===58||g===95||pe(g)?(e.consume(g),b):N(g)}function N(g){return g===61?(e.consume(g),$):R(g)?(o=N,Y(g)):L(g)?(e.consume(g),N):z(g)}function $(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),i=g,B):R(g)?(o=$,Y(g)):L(g)?(e.consume(g),$):(e.consume(g),U)}function B(g){return g===i?(e.consume(g),i=void 0,M):g===null?n(g):R(g)?(o=B,Y(g)):(e.consume(g),B)}function U(g){return g===null||g===34||g===39||g===60||g===61||g===96?n(g):g===47||g===62||ae(g)?z(g):(e.consume(g),U)}function M(g){return g===47||g===62||ae(g)?z(g):n(g)}function J(g){return g===62?(e.consume(g),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(g)}function Y(g){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),ce}function ce(g){return L(g)?H(e,we,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(g):we(g)}function we(g){return e.enter(\"htmlTextData\"),o(g)}}const Er={name:\"labelEnd\",resolveAll:Qu,resolveTo:Gu,tokenize:Yu},Uu={tokenize:Ku},ju={tokenize:Ju},Wu={tokenize:Zu};function Qu(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&&me(e,0,e.length,n),e}function Gu(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,wn(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]]),me(e,a,e.length,s),e}function Yu(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(Dt(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(Uu,f,o?f:c)(h):h===91?e.attempt(ju,f,o?l:c)(h):o?f(h):c(h)}function l(h){return e.attempt(Wu,f,c)(h)}function f(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function Ku(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)?It(e,a)(c):a(c)}function a(c){return c===41?f(c):Ya(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ae(c)?It(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Ja(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return ae(c)?It(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 Ju(e,t,n){const r=this;return i;function i(s){return Ka.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Zu(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 Xu={name:\"labelStartImage\",resolveAll:Er.resolveAll,tokenize:ec};function ec(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 tc={name:\"labelStartLink\",resolveAll:Er.resolveAll,tokenize:nc};function nc(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 Dn={name:\"lineEnding\",tokenize:rc};function rc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const tn={name:\"thematicBreak\",tokenize:ic};function ic(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:lc},exit:cc,name:\"list\",tokenize:sc},ac={partial:!0,tokenize:fc},oc={partial:!0,tokenize:uc};function sc(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:rr(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(tn,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 rr(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(kn,r.interrupt?n:f,e.attempt(ac,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 lc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(kn,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(oc,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 uc(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 cc(e){e.exit(this.containerState.type)}function fc(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 Ai={name:\"setextUnderline\",resolveTo:dc,tokenize:hc};function dc(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 hc(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 pc={tokenize:mc};function mc(e){const t=this,n=e.attempt(kn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(vu,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 gc={resolveAll:Xa()},_c=Za(\"string\"),yc=Za(\"text\");function Za(e){return{resolveAll:Xa(e===\"text\"?bc: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 Xa(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 bc(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 vc={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:ja},wc={91:Cu},kc={[-2]:Nn,[-1]:Nn,32:Nn},Sc={35:Nu,42:tn,45:[Ai,tn],60:Fu,61:Ai,95:tn,96:Ei,126:Ei},xc={38:Qa,92:Wa},Cc={[-5]:Dn,[-4]:Dn,[-3]:Dn,33:Xu,38:Qa,42:ir,60:[tu,Hu],91:tc,92:[Au,Wa],93:Er,95:ir,96:pu},Ic={null:[ir,gc]},Ec={null:[42,95]},Pc={null:[]},Ac=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ec,contentInitial:wc,disable:Pc,document:vc,flow:Sc,flowInitial:kc,insideSpan:Ic,string:xc,text:Cc},Symbol.toStringTag,{value:\"Module\"}));function Tc(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(I),check:A(y),consume:v,enter:S,exit:E,interrupt:A(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=wn(a,l.events,l),l.events)}function h(N,$){return Dc(d(N),$)}function d(N){return Nc(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 A(N,$){return B;function B(U,M,J){let Y,ce,we,g;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(X){return _t;function _t(Oe){const it=Oe!==null&&X[Oe],at=Oe!==null&&X.null,In=[...Array.isArray(it)?it:it?[it]:[],...Array.isArray(at)?at:at?[at]:[]];return j(In)(Oe)}}function j(X){return Y=X,ce=0,X.length===0?J:m(X[ce])}function m(X){return _t;function _t(Oe){return g=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,g),M}function oe(X){return g.restore(),++ce<Y.length?m(Y[ce]):J}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&me(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 Nc(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 Dc(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 $c(e){const r={constructs:$l([Ac,...(e||{}).extensions||[]]),content:i(Gl),defined:[],document:i(Kl),flow:i(pc),lazy:{},string:i(_c),text:i(yc)};return r;function i(a){return o;function o(s){return Tc(r,a,s)}}}function zc(e){for(;!Ga(e););return e}const Ti=/[\\0\\t\\n\\r]/g;function Fc(){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(Ti.lastIndex=c,l=Ti.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 Rc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Ql(n)(zc($c(n).document().write(Fc()(e,t,!0))))}const $n={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Oc(){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=$n[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=$n[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,Mc)),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\"+$n[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Mc(e,t){return t===\"|\"?t:e}class Lc{constructor(){this.map=[]}add(t,n,r){Vc(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 Vc(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 Bc(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 Hc(){return{flow:{null:{name:\"table\",tokenize:qc,resolveAll:Uc}}}}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),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\"),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||ae(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 Uc(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 Lc;for(;++n<e.length;){const d=e[n],p=d[1];d[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Ni(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=Yt(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=Yt(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=Yt(h,t,a,i,n,c)):o[1]!==0&&(c=Yt(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Ni(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=Bc(t.events,n))}return e}function Yt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},ot(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=ot(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=ot(t.events,n[2]),f=ot(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({},ot(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ni(e,t,n,r,i){const a=[],o=ot(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 ot(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function jc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Wc(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&&me(h,h.length,0,wn(d,o.slice(l+1,u),s)),me(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),me(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 Qc(e){return Rc(e,{allowDangerousHtml:!0,extensions:[Hc(),Wc()],htmlExtensions:[Oc(),jc()]})}const Gc={update:()=>{},getValues:()=>({})},He=dt({}),Ht=dt(Gc),Ne=dt(!1);function Yc(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)=>eo(a,o,t));return w(G,{children:i})}function eo(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)=>eo(u,l,n));return K(i,o,...s)}return null}function Kc({node:e}){const t=xr(),n=ue(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?Se(e.children,n?{nobr:!0}:void 0):void 0)}function Jc(e,t){if(Dl(e.name))return null;const n=Pl(e.name);if(n)return w(El,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Tl(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 ar(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return w(pl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Jc(e,t);case\"html\":return w(Kc,{node:e},t);default:return e}}function to(e){return e.length===0?null:e.map((t,n)=>ar(t,n))}function Zc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Xc(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 Se(e,t){if(e.length===0)return null;if(!e.some(o=>o.type===\"text\"))return e.map((o,s)=>ar(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\"&&Zc(i))i+=Xc(s);else{const u=r.length;r.push(ar(s,o)),i+=`<span data-tw=\"${u}\"></span>`}}const a=Qc(i);return Yc(a,r,t?.nobr)}const ef=\"spindle\",tf=1;let Kt=null,zn=null;function qe(){return zn||(zn={saves:new Map,playthroughs:new Map,meta:new Map}),zn}function nf(){return Kt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Kt=new Promise((e,t)=>{const n=indexedDB.open(ef,tf);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)}),Kt))}function Ue(e,t){return nf().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 Sn(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.put(e))}catch{qe().saves.set(e.meta.id,e)}}async function xn(e){try{const t=await Ue(\"saves\",\"readonly\");return await je(t.get(e))??void 0}catch{return qe().saves.get(e)}}async function rf(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.delete(e))}catch{qe().saves.delete(e)}}async function af(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 no(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 Ar(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 ro(e,t){try{const n=await Ue(\"meta\",\"readwrite\");await je(n.put({key:e,value:t}))}catch{qe().meta.set(e,t)}}const io=new Map,Cn=new Map;function of(e,t){io.set(e,t),Cn.set(t,e)}function sf(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(Cn.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(sf(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 or=\"__spindle_class__\",sr=\"__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=Cn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[or]:o,[sr]: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(or in r&&sr in r){const o=r[or],s=r[sr],u=io.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(Cn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let lr=null,ur=null,Di=!1;function lf(e){lr=e}function uf(e){ur=e}function cf(e){if(ur)try{const i=new Function(\"passage\",\"variables\",ur)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(lr)try{const r=lr(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 ff(){Di||(Di=!0)}async function $i(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 no(i),await ro(`currentPlaythroughId.${e}`,r),r}async function df(e){return Ar(`currentPlaythroughId.${e}`)}async function ao(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:cf(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 Sn(s),s}async function oo(e,t){const n=await xn(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 Sn(i),i}async function hf(e){const t=await xn(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 pf(e){await rf(e)}async function mf(e,t){const n=await xn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await Sn(r)}async function gf(e){const[t,n]=await Promise.all([af(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 so=\"autosave.\";async function _f(e,t,n){const r=`${so}${e}`,i=await Ar(r);if(i){const o=await oo(i,n);if(o)return o}const a=await ao(e,t,n,{isAutosave:!0});return await ro(r,a.meta.id),a}async function yf(e){const t=`${so}${e}`,n=await Ar(t);if(n)return hf(n)}const Tr=\"spindle.session.\";function bf(e,t){try{sessionStorage.setItem(`${Tr}${e}`,JSON.stringify(t))}catch{}}function vf(e){try{const t=sessionStorage.getItem(`${Tr}${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 wf(e){try{sessionStorage.removeItem(`${Tr}${e}`)}catch{}}async function kf(e){const t=await xn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Sf(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 no(a)}return await Sn(n),n}function lo(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=pt(t.content),i=mt(r),a=document.createElement(\"div\");be(K(()=>Se(i),null),a),be(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&uf(n.content)}let uo=0,ye=[],Fn=!1,qt=[],nn=null;function Nr(e){const t=C.getState();try{return!!vn(e,t.variables,t.temporary)}catch{return!1}}function co(e,t){const n=uo++,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:Nr(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 fo(e){ye=ye.filter(t=>t.name!==e)}function xf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Ma(n.run,r.variables,r.temporary)}n.dialog&&(qt.push(n.dialog),nn?.()),n.goto&&C.getState().navigate(n.goto)}}const Cf=10;function If(){if(!Fn){Fn=!0;try{for(let e=0;e<Cf;e++){let t=!1;const n=[...ye];for(const r of n){if(!ye.includes(r))continue;const i=Nr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ye=ye.filter(o=>o.id!==r.id)),xf(r))}if(!t)break}}finally{Fn=!1}}}function Ef(){for(const e of ye)e.lastResult=Nr(e.condition)}function Pf(){ye=[],qt=[],uo=0}function Af(e){return nn=e,qt.length>0&&e(),()=>{nn===e&&(nn=null)}}function zi(){return qt.shift()}function Tf(){return qt.length}el();const Nf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ye={},ge=[],Me={};function Fi(e){return e.map(t=>({...t,value:t.value!==void 0?ne(t.value):void 0}))}function Ri(e,t){const[,n,r]=nl(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:Fi(n),inverse:Fi(r)}}function Df(e){let t=Ye;for(let n=0;n<e;n++)t=st(t,ge[n].forward);return t}let _e=[];function Rn(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=st(l,ge[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}}}bf(t.ifid,{passage:n,variables:Ke(r),history:_e,historyIndex:a,visitCounts:o,renderCounts:s,prng:pn()})}}function Oi(e){Ye=e,ge=[],Me=e,_e=[]}function Mi(e){e?.prng?za(e.prng.seed,e.prng.pull):e&&er()}const C=Os()(il((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);Oi(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;ff().then(async()=>{const s=await df(o);if(s)e(u=>{u.playthroughId=s});else{const u=await $i(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(Nf.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=Ri(Me,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),ge.length=o.historyIndex,ge.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:pn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ye=st(Ye,ge[u].forward);o.history=o.history.slice(s),ge=ge.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,Rn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ne(st(r,ge[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Me=t().variables,Mi(t().history[t().historyIndex]),Rn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ne(st(i,ge[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Me=t().variables,Mi(t().history[t().historyIndex]),Rn(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;er(),Pf();const a=ne(r);Oi(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,lo(),wf(n.ifid),$i(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}),_f(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}),yf(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=st(l,ge[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:pn()}},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(Ri(a,s)),a=s}Ye=ne(r),ge=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?za(n.prng.seed,n.prng.pull):er()},getHistoryVariables:n=>ne(Df(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}}))),$f=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function zf(){const t=C(i=>i.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:$f,r=t?.tags.includes(\"nobr\")??!1;try{const i=pt(n),a=mt(i),o=w(G,{children:to(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 ho=dt(null);function Dr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r}){const i=C(f=>f.storyData),o=(e?i?.passages.get(e):void 0)?.content??t,s=de(()=>{if(!o)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const f=pt(o),c=mt(f);return Se(c)}catch(f){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",f.message]})}},[o]),u=f=>{f.target.classList.contains(\"dialog-overlay\")&&r()},l=n?`dialog-panel ${n}`:\"dialog-panel\";return w(ho.Provider,{value:r,children:w(\"div\",{class:\"dialog-overlay\",onClick:u,children:w(\"div\",{class:l,children:[w(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:s})]})})})}function Ff(){const[e,t]=Z(null),n=ve(()=>{const i=zi();t(i??null)},[]);Ae(()=>Af(()=>{t(i=>i!==null?i:zi()??null)}),[]);const r=ve(()=>{t(null),Tf()>0&&requestAnimationFrame(n)},[n]);return e?w(Dr,{passageName:e,onClose:r}):null}function Rf(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(Ae(()=>{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(zf,{}),w(Ff,{})]});return n?w(Ne.Provider,{value:!0,children:r}):r}function Of(){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=h.textContent||\"\",_={},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 vt=new Map;let se={},Li=!1;function po(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Mf(){localStorage.setItem(po(),JSON.stringify(se))}function On(){if(!Li){Li=!0;try{const e=localStorage.getItem(po());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(se={...se,...t})}}catch{}}}const $t={addToggle(e,t){vt.set(e,{type:\"toggle\",config:t}),e in se||(se[e]=t.default),On()},addList(e,t){vt.set(e,{type:\"list\",config:t}),e in se||(se[e]=t.default),On()},addRange(e,t){vt.set(e,{type:\"range\",config:t}),e in se||(se[e]=t.default),On()},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,Mf()},getAll(){return{...se}},getDefinitions(){return vt},hasAny(){return vt.size>0}};function Lf(e,t,n){const r=C.getState(),i=ne(r.variables),a=ne(r.temporary),o={...t};Ma(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 gn=new Map,cr=new Set,fr=new Map;function Vf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(fr.get(r)??0)+1;return fr.set(r,i),i===1?r:`${r}:${i}`}function Bf(e){return gn.set(e.id,e),Bi(),()=>{gn.delete(e.id),Bi()}}function Vi(){return Array.from(gn.values())}function Hf(e){return gn.get(e)}function qf(){fr.clear()}function Uf(e){return cr.add(e),()=>{cr.delete(e)}}function Bi(){for(const e of cr)e()}function jf(e){const t=fe(\"\");t.current||(t.current=Vf(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),Bf(r)}),n}function Wf(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function mo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function $r(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?mo(t):\"\"}function Qf(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 Gf(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 Yf(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Kf={useState:Z,useRef:fe,useEffect:Ae,useLayoutEffect:nt,useCallback:ve,useMemo:de,useContext:ue};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=xr(),r=a(r),i=a(i));const{update:o,getValues:s}=ue(Ht),l=ue(Ne)?(c,h)=>Se(c,{nobr:!0,...h}):Se,f={collectText:Wf,sourceLocation:$r,parseVarArgs:Qf,extractOptions:Gf,h:K,renderNodes:l,renderInlineNodes:to,hooks:Kf,useAction:jf,className:r,id:i,resolve:a,cls:Yf(e.name,r),mutate:c=>Lf(c,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){f.merged=Sr();const c=f.merged;f.evaluate=h=>vn(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(Al(e.name,t),e.subMacros)for(const n of e.subMacros)Nl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&ul(e.name)}function Jf(){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:$t,registerClass(e,t){of(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){lf(e)}},getActions(){return Vi()},performAction(e,t){const n=Hf(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 Uf(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(Vi())})})})},watch(e,t){return co(e,t)},unwatch(e){fo(e)},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 Cr()},randomInt(e,t){return Fa(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){ml(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=pn())})},isEnabled(){return gl()},get seed(){return _l()},get pull(){return yl()}}}}function Zf(){window.Story=Jf()}const Xf=/^\\$(\\w+)\\s*=\\s*(.+)$/,Hi=/\\$(\\w+(?:\\.\\w+)*)/g,qi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,ed=new Set([\"number\",\"string\",\"boolean\"]);function go(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,go(i));return{type:\"object\",fields:n}}const t=typeof e;if(!ed.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function td(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Xf);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=go(s);t.set(a,{...u,name:a,default:s})}return t}function nd(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 rd(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 id(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=nd(i.content);let o;for(Hi.lastIndex=0;(o=Hi.exec(i.content))!==null;){const s=o[1],u=rd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function ad(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${$r()}: ${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 od(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 sd(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 Ui(e,t,n,r,i,a,o){const s=C.getState();let u;try{u=vn(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${$r()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];sd(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}=od(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();Ui(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{Ui(o,u,s,n,r,i,e)},[n,r,i]),null}});function ld(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=ud(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 ud(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 cd(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}=ld(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=cd(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 fd(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 dd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=Z(()=>({...e,...t,...n})),o=fe(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=ue(Ne);return w(Ht.Provider,{value:l,children:w(He.Provider,{value:i,children:Se(r,f?{nobr:!0}:void 0)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=ue(He);let i;try{i=fd(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(dd,{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(Ht.Provider,{value:{update:n.update,getValues:n.getValues}},K(He.Provider,{value:n.getValues()},Se(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 hd(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 ji(e,t,n){const r=document.createElement(\"div\"),i=K(Ht.Provider,{value:{update:n,getValues:t}},K(He.Provider,{value:t()},Se(e)));be(i,r),be(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=hd(e),a=o=>{o.preventDefault(),ji(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:()=>{ji(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 zr(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?zr(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 _o=dt({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||!Ta(E))return E;const I=C.getState();return Na(E,I.variables,I.temporary,{})};return[S(n),S(r)]},[n,r]),c=zr(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(_o.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(_o);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=zr(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 pd(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}=pd(e);return n.hooks.useLayoutEffect(()=>{Va(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 rt(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(Dr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1)})]})}})}rt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});rt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});rt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});rt({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()}}});rt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});rt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});rt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!$t.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,o=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:a}),r&&w(Dr,{passageName:o,onClose:()=>i(!1)})]})}});function md(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 gd(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 _d(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function yd(){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=fe(null),k=fe(null),x=ue(ho),_=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 gf(I);r(D),a(!1)},[I]);Ae(()=>{y()},[y]),Ae(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const A=fe(),T=(D,j=\"success\")=>{clearTimeout(A.current),s({text:D,type:j}),A.current=window.setTimeout(()=>s(null),3e3)},z=D=>{l(j=>{const m=new Set(j);return m.has(D)?m.delete(D):m.add(D),m})},b=async()=>{if(!(!I||!v))try{const D=S();await ao(I,v,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=S();await oo(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 pf(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 mf(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 kf(D);if(!j)return;const m=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(m),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\")}},ce=()=>{k.current?.click()},we=async D=>{const j=D.target,m=j.files?.[0];if(m){j.value=\"\";try{const q=await m.text(),oe=JSON.parse(q);if(!md(oe))throw new Error(\"Invalid save file format\");await Sf(oe,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},g=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:ce,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...\"}):g===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),m=D.playthrough.id===v;return e===\"save\"&&!m||e===\"load\"&&D.saves.length===0&&!m?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,m?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:_d(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:gd(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\"&&m&&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(yd,{})}});function bd({name:e,def:t}){const[n,r]=Z(()=>$t.get(e)),i=a=>{r(a),$t.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 vd(){const e=$t.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(bd,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return w(vd,{})}});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=pt(o.content),l=mt(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 wd(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}=wd(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 kd(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}=kd(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 kt(e){const t=pt(e.content),n=mt(t),r=e.tags.includes(\"nobr\");return Se(n,r?{nobr:!0}:void 0)}const Sd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function xd({passage:e,dataTransition:t}){const n=C(k=>k.storyData),r=Sd.has(e.name),[i,a]=Z(!1),o=de(()=>{try{return kt(e)}catch(k){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",mo(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 kt(s)}catch(k){return console.error(\"spindle: Error in PassageHeader:\",k),null}},[s?.content]),c=de(()=>{if(!u)return null;try{return kt(u)}catch(k){return console.error(\"spindle: Error in PassageFooter:\",k),null}},[u?.content]);Ae(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return kt(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 Cd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),dr={type:\"fade-through\",duration:300,pause:50};function Id(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Cd.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 Mn(e){return{type:e.type,duration:e.duration??dr.duration,pause:e.pause??dr.pause}}function Ed(e,t,n){const r=Id(e);return r?Mn(r):t?Mn(t):n?Mn(n):{...dr}}function Wi(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 Ln(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 Vn(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=fe(\"fade\"),s=fe(0),u=fe(null),l=fe([]),f=ve(()=>{for(const d of l.current)clearTimeout(d);l.current=[],Vn(u.current)},[]);Ae(()=>{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 A=Ed(y.tags,_,x);o.current=A.type;const T=u.current;if(A.type===\"none\"){a(n);return}if(A.type===\"fade\"){T&&Ln(T,A),a(n);return}if(A.type===\"fade-through\"){if(!T){a(n);return}Ln(T,A);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Wi(z,A.type);T.appendChild(b),a(\"\");const N=A.duration+A.pause,$=setTimeout(()=>{a(n)},N),B=N+A.duration,U=setTimeout(()=>{Vn(T)},B);l.current=[$,U];return}if(A.type===\"crossfade\"){if(!T){a(n);return}Ln(T,A);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Wi(z,A.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const N=setTimeout(()=>{Vn(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:kt(h)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:c&&w(xd,{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,co(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,fo(r)),null}});const Pd='*,*: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 Qi(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 Gi(){const e=Of(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Pd,document.head.appendChild(t),Zf(),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&&Qi(d,[h]),new Error(`spindle: ${h}`)}const i=td(r.content),a=id(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&Qi(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=ad(i),C.getState().init(e,n),lo();const o=vf(e.ifid);o&&C.getState().loadFromPayload(o);for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const d=pt(h.content),p=mt(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(\"@\"));Va(_,k.children,v)}}let s=\"\";C.subscribe(h=>{h.currentPassage!==s&&(s=h.currentPassage,qf())});let u=C.getState().variables,l=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===l?If():Ef()),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(Rf,{}),c),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Gi):Gi();</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.26.2","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 zt,O,Yi,Qe,qr,Ki,Ji,Zi,hr,Bn,Hn,Xi,rn={},an=[],jo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ft=Array.isArray;function Ee(e,t){for(var n in t)e[n]=t[n];return e}function pr(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?zt.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 St(e,o,r,i,null)}function St(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??++Yi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Wo(){return{current:null}}function G(e){return e.children}function Pe(e,t){this.props=e,this.context=t}function lt(e,t){if(t==null)return e.__?lt(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\"?lt(e):null}function Qo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ee({},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??lt(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,ra(r,a,i),t.__e=t.__=null,a.__e!=n&&ea(a)}}function ea(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}),ea(e)}function qn(e){(!e.__d&&(e.__d=!0)&&Qe.push(e)&&!on.__r++||qr!=O.debounceRendering)&&((qr=O.debounceRendering)||Ki)(on)}function on(){for(var e,t=1;Qe.length;)Qe.length>t&&Qe.sort(Ji),e=Qe.shift(),t=Qe.length,Qo(e);on.__r=0}function ta(e,t,n,r,i,a,o,s,u,l,f){var c,h,d,p,k,x,_,v=r&&r.__k||an,S=t.length;for(u=Go(n,t,v,u,S),c=0;c<S;c++)(d=n.__k[c])!=null&&(h=d.__i!=-1&&v[d.__i]||rn,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&&gr(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=na(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 Go(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]=St(null,o,null,null,null):Ft(o)?o=e.__k[a]=St(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=St(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=Yo(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=lt(s)),aa(s,s));return r}function na(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=na(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=lt(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\"||(Ft(e)?e.some(function(n){Fe(n,t)}):t.push(e)),t}function Yo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],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 Ur(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||jo.test(t)?n:n+\"px\"}function Ut(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||Ur(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Ur(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(Zi,\"$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=hr,e.addEventListener(t,a?Hn:Bn,a)):e.removeEventListener(t,a?Hn:Bn,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 jr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=hr++;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,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]),(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=Jo),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=Ee({},c.__s)),Ee(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)}),an.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),an.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=Ee(Ee({},r),c.getChildContext())),v&&!h&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(d,p)),A=f!=null&&f.type===G&&f.key==null?ia(f.props.children):f,s=ta(e,Ft(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--;)pr(a[T]);Un(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Un(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Ko(n.__e,t,n,r,i,a,o,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:s}function Un(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Un))}function ra(e,t,n){for(var r=0;r<n.length;r++)gr(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 ia(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Ft(e)?e.map(ia):Ee({},e)}function Ko(e,t,n,r,i,a,o,s,u){var l,f,c,h,d,p,k,x=n.props||rn,_=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&&zt.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 _||Ut(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||Ut(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=\"\"),ta(t.type==\"template\"?e.content:e,Ft(h)?h:[h],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&<(n,0),s,u),a!=null)for(l=a.length;l--;)pr(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])&&Ut(e,l,p,x[l],i),l=\"checked\",k!=null&&k!=e[l]&&Ut(e,l,k,x[l],i))}return e}function gr(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 aa(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||gr(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]&&aa(r[i],t,n||typeof e.type!=\"function\");n||pr(e.__e),e.__c=e.__=e.__e=void 0}function Jo(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||rn,rn,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?zt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),ra(a,e,o)}function oa(e,t){be(e,t,oa)}function Zo(e,t,n){var r,i,a,o,s=Ee({},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?zt.call(arguments,2):n),St(e.type,s,r||e.key,i||e.ref,null)}function dt(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,qn(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\"+Xi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}zt=an.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}},Yi=0,Pe.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ee({},this.state),typeof e==\"function\"&&(e=e(Ee({},n),this.props)),e&&Ee(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qn(this))},Pe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qn(this))},Pe.prototype.render=G,Qe=[],Ki=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ji=function(e,t){return e.__v.__b-t.__v.__b},on.__r=0,Zi=/(PointerCapture)$|Capture$/i,hr=0,Bn=jr(!1),Hn=jr(!0),Xi=0;var Xo=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:--Xo,__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,En,Wr,ut=0,sa=[],Q=O,Qr=Q.__b,Gr=Q.__r,Yr=Q.diffed,Kr=Q.__c,Jr=Q.unmount,Zr=Q.__;function ht(e,t){Q.__h&&Q.__h(W,e,ut||t),ut=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return ut=1,_r(fa,e)}function _r(e,t,n){var r=ht(Le++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):fa(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 Ae(e,t){var n=ht(Le++,3);!Q.__s&&yr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function nt(e,t){var n=ht(Le++,4);!Q.__s&&yr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function fe(e){return ut=5,de(function(){return{current:e}},[])}function la(e,t,n){ut=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=ht(Le++,7);return yr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return ut=8,de(function(){return e},t)}function ue(e){var t=W.context[e.__c],n=ht(Le++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function ua(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function ca(){var e=ht(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 es(){for(var e;e=sa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Jt),t.__h.some(jn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Qr&&Qr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Zr&&Zr(e,t)},Q.__r=function(e){Gr&&Gr(e),Le=0;var t=(W=e.__c).__H;t&&(En===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Jt),t.__h.some(jn),t.__h=[],Le=0)),En=W},Q.diffed=function(e){Yr&&Yr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(sa.push(t)!==1&&Wr===Q.requestAnimationFrame||((Wr=Q.requestAnimationFrame)||ts)(es)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),En=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Jt),n.__h=n.__h.filter(function(r){return!r.__||jn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Kr&&Kr(e,t)},Q.unmount=function(e){Jr&&Jr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Jt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var Xr=typeof requestAnimationFrame==\"function\";function ts(e){var t,n=function(){clearTimeout(r),Xr&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Xr&&(t=requestAnimationFrame(n))}function Jt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function jn(e){var t=W;e.__c=e.__(),W=t}function yr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function fa(e,t){return typeof t==\"function\"?t(e):t}const ei=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},ns=(e=>e?ei(e):ei);function da(e,t){for(var n in t)e[n]=t[n];return e}function Wn(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 ha(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]),Ae(function(){return Pn(i)&&a({t:i}),e(function(){Pn(i)&&a({t:i})})},[e]),n}function Pn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function pa(e){e()}function ma(e){return e}function ga(){return[!1,pa]}var _a=nt;function Qn(e,t){this.props=e,this.context=t}function rs(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:Wn(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}(Qn.prototype=new Pe).isPureReactComponent=!0,Qn.prototype.shouldComponentUpdate=function(e,t){return Wn(this.props,e)||Wn(this.state,t)};var ti=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ti&&ti(e)};var is=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function as(e){function t(n){var r=da({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=is,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ni=function(e,t){return e==null?null:Fe(Fe(e).map(t))},os={map:ni,forEach:ni,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},ss=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)}ss(e,t,n,r)};var ri=O.unmount;function ya(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=da({},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 ya(r,t,n)})),e}function ba(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return ba(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 Zt(){this.__u=0,this.o=null,this.__b=null}function va(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ls(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 wt(){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),ri&&ri(e)},(Zt.prototype=new Pe).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=va(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]=ba(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)},Zt.prototype.componentWillUnmount=function(){this.o=[]},Zt.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]=ya(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 ii=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 us(e){return this.getChildContext=function(){return e.context},e.children}function cs(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(us,{context:t.context},e.__v),t.v)}function fs(e,t){var n=K(cs,{__v:e,h:t});return n.containerInfo=t,n}(wt.prototype=new Pe).__a=function(e){var t=this,n=va(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ii(t,e,r)):i()};n?n(a):a()}},wt.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},wt.prototype.componentDidUpdate=wt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ii(e,n,t)})};var wa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ds=/^(?: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]/,hs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ps=/[A-Z0-9]/g,ms=typeof document<\"u\",gs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function _s(e,t,n){return t.__k==null&&(t.textContent=\"\"),be(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ys(e,t,n){return oa(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 ai=O.event;function bs(){}function vs(){return this.cancelBubble}function ws(){return this.defaultPrevented}O.event=function(e){return ai&&(e=ai(e)),e.persist=bs,e.isPropagationStopped=vs,e.isDefaultPrevented=ws,e.nativeEvent=e};var br,ks={enumerable:!1,configurable:!0,get:function(){return this.class}},oi=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||ms&&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\"||gs(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":hs.test(o)&&(o=u):u=o=\"oninput\":a&&ds.test(o)?o=o.replace(ps,\"-$&\").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\",ks)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=wa,oi&&oi(e)};var si=O.__r;O.__r=function(e){si&&si(e),br=e.__c};var li=O.diffed;O.diffed=function(e){li&&li(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),br=null};var Ss={ReactCurrentDispatcher:{current:{readContext:function(e){return br.__n[e.__c].props.value},useCallback:ve,useContext:ue,useDebugValue:ua,useDeferredValue:ma,useEffect:Ae,useId:ca,useImperativeHandle:la,useInsertionEffect:_a,useLayoutEffect:nt,useMemo:de,useReducer:_r,useRef:fe,useState:Z,useSyncExternalStore:ha,useTransition:ga}}};function xs(e){return K.bind(null,e)}function _n(e){return!!e&&e.$$typeof===wa}function Cs(e){return _n(e)&&e.type===G}function Is(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Es(e){return _n(e)?Zo.apply(null,arguments):e}function Ps(e){return!!e.__k&&(be(null,e),!0)}function As(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ts=function(e,t){return e(t)},Ns=function(e,t){return e(t)},Ds=G,$s=_n,jt={useState:Z,useId:ca,useReducer:_r,useEffect:Ae,useLayoutEffect:nt,useInsertionEffect:_a,useTransition:ga,useDeferredValue:ma,useSyncExternalStore:ha,startTransition:pa,useRef:fe,useImperativeHandle:la,useMemo:de,useCallback:ve,useContext:ue,useDebugValue:ua,version:\"18.3.1\",Children:os,render:_s,hydrate:ys,unmountComponentAtNode:Ps,createPortal:fs,createElement:K,createContext:dt,createFactory:xs,cloneElement:Es,createRef:Wo,Fragment:G,isValidElement:_n,isElement:$s,isFragment:Cs,isMemo:Is,findDOMNode:As,Component:Pe,PureComponent:Qn,memo:rs,forwardRef:as,flushSync:Ns,unstable_batchedUpdates:Ts,StrictMode:Ds,Suspense:Zt,SuspenseList:wt,lazy:ls,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ss};const zs=e=>e;function Fs(e,t=zs){const n=jt.useSyncExternalStore(e.subscribe,jt.useCallback(()=>t(e.getState()),[e,t]),jt.useCallback(()=>t(e.getInitialState()),[e,t]));return jt.useDebugValue(n),n}const Rs=e=>{const t=ns(e),n=r=>Fs(t,r);return Object.assign(n,t),n},Os=(e=>Rs);var vr=Symbol.for(\"immer-nothing\"),xt=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,Et=\"constructor\",Rt=\"prototype\",Gn=\"configurable\",sn=\"enumerable\",Xt=\"writable\",Pt=\"value\",Re=e=>!!e&&!!e[ee];function Te(e){return e?ka(e)||Mt(e)||!!e[xt]||!!e[Et]?.[xt]||Lt(e)||Vt(e):!1}var Ms=he[Rt][Et].toString(),ui=new WeakMap;function ka(e){if(!e||!ct(e))return!1;const t=Ze(e);if(t===null||t===he[Rt])return!0;const n=he.hasOwnProperty.call(t,Et)&&t[Et];if(n===Object)return!0;if(!Ge(n))return!1;let r=ui.get(n);return r===void 0&&(r=Function.toString.call(n),ui.set(n,r)),r===Ms}function Ot(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_:Mt(e)?1:Lt(e)?2:Vt(e)?3:0}var Ct=(e,t,n=Xe(e))=>n===2?e.has(t):he[Rt].hasOwnProperty.call(e,t),$e=(e,t,n=Xe(e))=>n===2?e.get(t):e[t],ln=(e,t,n,r=Xe(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ls(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Mt=Array.isArray,Lt=e=>e instanceof Map,Vt=e=>e instanceof Set,ct=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",An=e=>typeof e==\"boolean\";function Vs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Bs=e=>ct(e)?e?.[ee]:null,ze=e=>e.copy_||e.base_,wr=e=>e.modified_?e.copy_:e.base_;function Yn(e,t){if(Lt(e))return new Map(e);if(Vt(e))return new Set(e);if(Mt(e))return Array[Rt].slice.call(e);const n=ka(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[Xt]===!1&&(s[Xt]=!0,s[Gn]=!0),(s.get||s.set)&&(r[o]={[Gn]:!0,[Xt]:!0,[sn]:s[sn],[Pt]: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 kr(e,t=!1){return yn(e)||Re(e)||!Te(e)||(Xe(e)>1&&he.defineProperties(e,{set:Wt,add:Wt,clear:Wt,delete:Wt}),he.freeze(e),t&&Ot(e,(n,r)=>{kr(r,!0)},!1)),e}function Hs(){ie(2)}var Wt={[Pt]:Hs};function yn(e){return e===null||!ct(e)?!0:he.isFrozen(e)}var un=\"MapSet\",cn=\"Patches\",ci=\"ArrayMethods\",fn={};function et(e){const t=fn[e];return t||ie(0,e),t}var fi=e=>!!fn[e];function qs(e,t){fn[e]||(fn[e]=t)}var At,Sa=()=>At,Us=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:fi(un)?et(un):void 0,arrayMethodsPlugin_:fi(ci)?et(ci):void 0});function di(e,t){t&&(e.patchPlugin_=et(cn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kn(e){Jn(e),e.drafts_.forEach(js),e.drafts_=null}function Jn(e){e===At&&(At=e.parent_)}var hi=e=>At=Us(At,e);function js(e){const t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function pi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ee].modified_&&(Kn(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 Ws(t,e,!0),Kn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==vr?e:void 0}function mi(e,t){if(yn(t))return t;const n=t[ee];if(!n)return dn(t,e.handledSet_,e);if(!bn(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);Ia(n,e)}return n.copy_}function Ws(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&kr(t,n)}function xa(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var bn=(e,t)=>e.scope_===t,Qs=[];function Ca(e,t,n,r){const i=ze(e),a=e.type_;if(r!==void 0&&$e(i,r,a)===t){ln(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Ot(i,(u,l)=>{if(Re(l)){const f=s.get(l)||[];f.push(u),s.set(l,f)}})}const o=e.draftLocations_.get(t)??Qs;for(const s of o)ln(i,s,n,a)}function Gs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!bn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=wr(a);Ca(e,a.draft_??a,o,n),Ia(a,i)})}function Ia(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)}xa(e)}}function Ys(e,t,n){const{scope_:r}=e;if(Re(n)){const i=n[ee];bn(i,r)&&i.callbacks_.push(function(){en(e);const o=wr(i);Ca(e,n,o,t)})}else Te(n)&&e.callbacks_.push(function(){const a=ze(e);e.type_===3?a.has(n)&&dn(n,r.handledSet_,r):$e(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&dn($e(e.copy_,t,e.type_),r.handledSet_,r)})}function dn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Re(e)||t.has(e)||!Te(e)||yn(e)||(t.add(e),Ot(e,(r,i)=>{if(Re(i)){const a=i[ee];if(bn(a,n)){const o=wr(a);ln(e,r,o,e.type_),xa(a)}}else Te(i)&&dn(i,t,n)})),e}function Ks(e,t){const n=Mt(e),r={type_:n?1:0,scope_:t?t.scope_:Sa(),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=hn;n&&(i=[r],a=Tt);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var hn={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(!Ct(i,t,e.type_))return Js(e,i,t);const a=i[t];if(e.finalized_||!Te(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Vs(t))return a;if(a===Tn(e.base_,t)){en(e);const o=e.type_===1?+t:t,s=Xn(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=Ea(ze(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Tn(ze(e),t),a=i?.[ee];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ls(n,i)&&(n!==void 0||Ct(e.base_,t,e.type_)))return!0;en(e),Zn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Ys(e,t,n)),!0},deleteProperty(e,t){return en(e),Tn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Zn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ze(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Xt]:!0,[Gn]:e.type_!==1||t!==\"length\",[sn]:r[sn],[Pt]:n[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ie(12)}},Tt={};for(let e in hn){let t=hn[e];Tt[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Tt.deleteProperty=function(e,t){return Tt.set.call(this,e,t,void 0)};Tt.set=function(e,t,n){return hn.set.call(this,e[0],t,n,e[0])};function Tn(e,t){const n=e[ee];return(n?ze(n):e)[t]}function Js(e,t,n){const r=Ea(t,n);return r?Pt in r?r[Pt]:r.get?.call(e.draft_):void 0}function Ea(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 Zn(e){e.modified_||(e.modified_=!0,e.parent_&&Zn(e.parent_))}function en(e){e.copy_||(e.assigned_=new Map,e.copy_=Yn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Zs=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=hi(this),o=Xn(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Kn(a):Jn(a)}return di(a,r),pi(i,a)}else if(!t||!ct(t)){if(i=n(t),i===void 0&&(i=t),i===vr&&(i=void 0),this.autoFreeze_&&kr(i,!0),r){const a=[],o=[];et(cn).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]},An(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),An(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),An(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Te(e)||ie(8),Re(e)&&(e=Xs(e));const t=hi(this),n=Xn(t,e,void 0);return n[ee].isManual_=!0,Jn(t),n}finishDraft(e,t){const n=e&&e[ee];(!n||!n.isManual_)&&ie(9);const{scope_:r}=n;return di(r,t),pi(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(cn).applyPatches_;return Re(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Xn(e,t,n,r){const[i,a]=Lt(t)?et(un).proxyMap_(t,n):Vt(t)?et(un).proxySet_(t,n):Ks(t,n);return(n?.scope_??Sa()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Gs(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function Xs(e){return Re(e)||ie(10,e),Pa(e)}function Pa(e){if(!Te(e)||yn(e))return e;const t=e[ee];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Yn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Yn(e,!0);return Ot(n,(i,a)=>{ln(n,i,Pa(a))},r),t&&(t.finalized_=!1),n}function el(){function t(p,k=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Bs($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||Ct(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),!ct(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 A=E[y],T=v[y];if((I||S?.get(y.toString()))&&A!==T){const b=A?.[ee];if(b&&b.modified_)continue;const N=k.concat([y]);x.push({op:r,path:N,value:d(A)}),_.push({op:r,path:N,value:d(T)})}}for(let y=v.length;y<E.length;y++){const A=k.concat([y]);x.push({op:i,path:A,value:d(E[y])})}for(let y=E.length-1;v.length<=y;--y){const A=k.concat([y]);_.push({op:a,path:A})}}function u(p,k,x,_){const{base_:v,copy_:S,type_:E}=p;Ot(p.assigned_,(I,y)=>{const A=$e(v,I,E),T=$e(S,I,E),z=y?Ct(v,I)?r:i:a;if(A===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(A)}:{op:r,path:b,value:d(A)})})}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===vr?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 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===Et)&&ie(19),Ge(S)&&z===Rt&&ie(19),S=$e(S,z),ct(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(Mt(p))return p.map(h);if(Lt(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,h(_)]));if(Vt(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 Ct(p,xt)&&(k[xt]=p[xt]),k}function d(p){return Re(p)?h(p):p}qs(cn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:f,getPath:t})}var Nt=new Zs,tl=Nt.produce,nl=Nt.produceWithPatches.bind(Nt),st=Nt.applyPatches.bind(Nt);const rl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?tl(i):i;return t(s,a,...o)},e(r.setState,n,r)),il=rl,al=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\"]),ol=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function sl(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 gi(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 _i(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 ll(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function pt(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=_i(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}=sl(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=_i(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:_}=gi(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}=gi(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&&al.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=ll(e,o);o=f.endIdx;let c=ol.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 Aa=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function ul(e){Aa.add(e.toLowerCase())}const yi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},cl=new Set([\"if\",\"switch\",\"timed\"]);function mt(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(yi[a]){const o=yi[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(Aa.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(cl.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 Sr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=ue(He);return de(()=>[e,t,n],[e,t,n])}const fl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,dl=/\\{[\\$_@][\\w.]+\\}/;function Ta(e){return dl.test(e)}function hl(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 Na(e,t,n,r){return e.replace(fl,(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=hl(f,u)),f==null?\"\":String(f)})}function xr(){const[e,t,n]=Sr();return ve(r=>r===void 0||!Ta(r)?r:Na(r,e,t,n),[e,t,n])}function pl({name:e,scope:t,className:n,id:r}){const i=xr();n=i(n),r=i(r);const a=ue(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 Da(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 $a(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let gt=!1,Bt=\"\",tt=0,ft=null;function ml(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Bt=n,tt=0,ft=Da($a(n)),gt=!0}function za(e,t){Bt=e,tt=0,ft=Da($a(e)),gt=!0;for(let n=0;n<t;n++)ft();tt=t}function er(){gt=!1,Bt=\"\",tt=0,ft=null}function pn(){return gt?{seed:Bt,pull:tt}:null}function Cr(){return!gt||!ft?Math.random():(tt++,ft())}function Fa(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Cr()*(t-e+1))+e}function gl(){return gt}function _l(){return Bt}function yl(){return tt}const bl=500,We=new Map,vl=/\\$(\\w+)/g,wl=/\\b_(\\w+)/g,kl=/@(\\w+)/g;function Sl(e){return e.replace(vl,'variables[\"$1\"]').replace(wl,'temporary[\"$1\"]').replace(kl,'locals[\"$1\"]')}function Ir(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Sl(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+=Ir(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 xl=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Ra(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\",xl+t);if(We.set(e,r),We.size>bl){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let Qt=null,bi=null,vi=null;function Oa(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(Qt&&bi===t&&vi===n)return Qt;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 Qt={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:Cr,randomInt:Fa},bi=t,vi=n,Qt}function vn(e,t,n,r={}){const a=`return (${Ir(e)});`;return Ra(a,a)(t,n,r,Oa())}function Ma(e,t,n,r={}){const i=Ir(e);Ra(\"exec:\"+i,i)(t,n,r,Oa())}function Cl(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 Il({body:e,parentValues:t,ownKeys:n}){const r=ue(Ne),[i,a]=Z({}),o={...t,...n,...i},s=fe(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(Ht.Provider,{value:f,children:w(He.Provider,{value:o,children:Se(e,r?{nobr:!0}:void 0)})})}function El({body:e,params:t,rawArgs:n}){const r=ue(He),i=ue(Ne),[a,o,s]=Sr();if(t.length===0||!n)return w(G,{children:Se(e,i?{nobr:!0}:void 0)});const u=Cl(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=vn(h,a,o,s)}catch{d=void 0}l[c.startsWith(\"@\")?c.slice(1):c]=d}return w(Il,{body:e,parentValues:r,ownKeys:l})}const La=new Map;function Va(e,t,n){La.set(e.toLowerCase(),{body:t,params:n})}function Pl(e){return La.get(e.toLowerCase())}const Ba=new Map;function Al(e,t){Ba.set(e.toLowerCase(),t)}function Tl(e){return Ba.get(e.toLowerCase())}const Ha=new Set;function Nl(e){Ha.add(e.toLowerCase())}function Dl(e){return Ha.has(e.toLowerCase())}const wi=document.createElement(\"i\");function qa(e){const t=\"&\"+e+\";\";wi.innerHTML=t;const n=wi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function me(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?(me(e,e.length,0,t),e):t}const tr={}.hasOwnProperty;function $l(e){const t={};let n=-1;for(;++n<e.length;)zl(t,e[n]);return t}function zl(e,t){let n;for(n in t){const i=(tr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){tr.call(i,o)||(i[o]=[]);const s=a[o];Fl(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Fl(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);me(e,0,0,r)}function Rl(e){const t={};let n=-1;for(;++n<e.length;)Ol(t,e[n]);return t}function Ol(e,t){let n;for(n in t){const i=(tr.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 Ml(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 Ll={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ua(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Ll[n]+\";\"}}function Dt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Ie=Be(/[A-Za-z]/),pe=Be(/[\\dA-Za-z]/),Vl=Be(/[#-'*+\\--9=?A-Z^-~]/);function nr(e){return e!==null&&(e<32||e===127)}const rr=Be(/\\d/),Bl=Be(/[\\dA-Fa-f]/),Hl=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 ql=Be(/\\p{P}|\\p{S}/u),Ul=Be(/\\s/);function Be(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gt(e,t){const n=Ua(jl(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 jl(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 ki={}.hasOwnProperty,Si=/^(https?|ircs?|mailto|xmpp)$/i,Wl=/^https?$/i;function Ql(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Rl([{enter:{blockQuote:M,codeFenced:we,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:Oo,content:Co,definition:bo,definitionDestinationString:wo,definitionLabelString:x,definitionTitleString:x,emphasis:Fo,htmlFlow:zo,htmlText:Mr,image:q,label:x,link:oe,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:Y,reference:x,resource:it,resourceDestinationString:at,resourceTitleString:x,setextHeading:Eo,strong:Ro},exit:{atxHeading:Ao,atxHeadingSequence:Io,autolinkEmail:Uo,autolinkProtocol:qo,blockQuote:J,characterEscapeValue:yt,characterReferenceMarkerHexadecimal:Lr,characterReferenceMarkerNumeric:Lr,characterReferenceValue:Ho,codeFenced:m,codeFencedFence:D,codeFencedFenceInfo:g,codeFencedFenceMeta:A,codeFlowValue:$o,codeIndented:m,codeText:Mo,codeTextData:yt,data:yt,definition:xo,definitionDestinationString:ko,definitionLabelString:vo,definitionTitleString:So,emphasis:Lo,hardBreakEscape:Rr,hardBreakTrailing:Rr,htmlFlow:Or,htmlFlowData:yt,htmlText:Or,htmlTextData:yt,image:Fr,label:_t,labelText:X,lineEnding:Do,link:Fr,listOrdered:$,listUnordered:B,paragraph:ce,reference:A,referenceString:Oe,resource:A,resourceDestinationString:In,resourceTitleString:yo,setextHeading:No,setextHeadingLineSequence:To,setextHeadingText:Po,strong:Vo,thematicBreak:Bo}},...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(P){let F=-1,te=0;const ke=[];let xe=[],De=[];for(;++F<P.length;)!c&&(P[F][1].type===\"lineEnding\"||P[F][1].type===\"lineEndingBlank\")&&(c=P[F][2].sliceSerialize(P[F][1])),(P[F][1].type===\"listOrdered\"||P[F][1].type===\"listUnordered\")&&(P[F][0]===\"enter\"?ke.push(F):d(P.slice(ke.pop(),F))),P[F][1].type===\"definition\"&&(P[F][0]===\"enter\"?(De=re(De,P.slice(te,F)),te=F):(xe=re(xe,P.slice(te,F+1)),te=F+1));xe=re(xe,De),xe=re(xe,P.slice(te)),F=-1;const Ce=xe;for(u.enter.null&&u.enter.null.call(f);++F<P.length;){const Vr=u[Ce[F][0]],Br=Ce[F][1].type,Hr=Vr[Br];ki.call(Vr,Br)&&Hr&&Hr.call({sliceSerialize:Ce[F][2].sliceSerialize,...f},Ce[F][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function d(P){const F=P.length;let te=0,ke=0,xe=!1,De;for(;++te<F;){const Ce=P[te];if(Ce[1]._container)De=void 0,Ce[0]===\"enter\"?ke++:ke--;else switch(Ce[1].type){case\"listItemPrefix\":{Ce[0]===\"exit\"&&(De=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ce[0]===\"enter\"&&!ke&&(De?De=void 0:xe=!0);break}default:De=void 0}}P[0][1]._loose=xe}function p(P,F){l[P]=F}function k(P){return l[P]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function v(P){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(P))}function S(P){p(\"lastWasTag\"),i[i.length-1].push(P)}function E(){S(c||`\n`)}function I(){const P=i[i.length-1],F=P[P.length-1],te=F?F.charCodeAt(F.length-1):null;te===10||te===13||te===null||E()}function y(P){return k(\"ignoreEncode\")?P:Ua(P)}function A(){_()}function T(P){o.push(!P._loose),I(),v(\"<ol\"),p(\"expectFirstItem\",!0)}function z(P){o.push(!P._loose),I(),v(\"<ul\"),p(\"expectFirstItem\",!0)}function b(P){if(k(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(P),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 ce(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):v(\"</p>\")}function we(){I(),v(\"<pre><code\"),p(\"fencesCount\",0)}function g(){const P=_();v(' class=\"language-'+P+'\"')}function D(){const P=k(\"fencesCount\")||0;P||(v(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",P+1)}function j(){I(),v(\"<pre><code>\")}function m(){const P=k(\"fencesCount\");P!==void 0&&P<2&&l.tightStack.length>0&&!k(\"lastWasTag\")&&E(),k(\"flowCodeSeenData\")&&I(),v(\"</code></pre>\"),P!==void 0&&P<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function oe(){a.push({})}function X(P){a[a.length-1].labelId=this.sliceSerialize(P)}function _t(){a[a.length-1].label=_()}function Oe(P){a[a.length-1].referenceId=this.sliceSerialize(P)}function it(){x(),a[a.length-1].destination=\"\"}function at(){x(),p(\"ignoreEncode\",!0)}function In(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function yo(){a[a.length-1].title=_()}function Fr(){let P=a.length-1;const F=a[P],te=F.referenceId||F.labelId,ke=F.destination===void 0?r[Dt(te)]:F;for(n=!0;P--;)if(a[P].image){n=void 0;break}F.image?(v('<img src=\"'+Gt(ke.destination,t.allowDangerousProtocol?void 0:Wl)+'\" alt=\"'),S(F.label),v('\"')):v('<a href=\"'+Gt(ke.destination,t.allowDangerousProtocol?void 0:Si)+'\"'),v(ke.title?' title=\"'+ke.title+'\"':\"\"),F.image?v(\" />\"):(v(\">\"),S(F.label),v(\"</a>\")),a.pop()}function bo(){x(),a.push({})}function vo(P){_(),a[a.length-1].labelId=this.sliceSerialize(P)}function wo(){x(),p(\"ignoreEncode\",!0)}function ko(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function So(){a[a.length-1].title=_()}function xo(){const P=a[a.length-1],F=Dt(P.labelId);_(),ki.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Co(){p(\"slurpAllLineEndings\",!0)}function Io(P){k(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(P).length),I(),v(\"<h\"+k(\"headingRank\")+\">\"))}function Eo(){x(),p(\"slurpAllLineEndings\")}function Po(){p(\"slurpAllLineEndings\",!0)}function Ao(){v(\"</h\"+k(\"headingRank\")+\">\"),p(\"headingRank\")}function To(P){p(\"headingRank\",this.sliceSerialize(P).charCodeAt(0)===61?1:2)}function No(){const P=_();I(),v(\"<h\"+k(\"headingRank\")+\">\"),S(P),v(\"</h\"+k(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function yt(P){S(y(this.sliceSerialize(P)))}function Do(P){if(!k(\"slurpAllLineEndings\")){if(k(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(k(\"inCodeText\")){S(\" \");return}S(y(this.sliceSerialize(P)))}}function $o(P){S(y(this.sliceSerialize(P))),p(\"flowCodeSeenData\",!0)}function Rr(){v(\"<br />\")}function zo(){I(),Mr()}function Or(){p(\"ignoreEncode\")}function Mr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Fo(){v(\"<em>\")}function Ro(){v(\"<strong>\")}function Oo(){p(\"inCodeText\",!0),v(\"<code>\")}function Mo(){p(\"inCodeText\"),v(\"</code>\")}function Lo(){v(\"</em>\")}function Vo(){v(\"</strong>\")}function Bo(){I(),v(\"<hr />\")}function Lr(P){p(\"characterReferenceType\",P.type)}function Ho(P){const F=this.sliceSerialize(P),te=k(\"characterReferenceType\")?Ml(F,k(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):qa(F);S(y(te)),p(\"characterReferenceType\")}function qo(P){const F=this.sliceSerialize(P);v('<a href=\"'+Gt(F,t.allowDangerousProtocol?void 0:Si)+'\">'),S(y(F)),v(\"</a>\")}function Uo(P){const F=this.sliceSerialize(P);v('<a href=\"'+Gt(\"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 Gl={tokenize:Yl};function Yl(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 Kl={tokenize:Jl},xi={tokenize:Zl};function Jl(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 A=E;for(;A<t.events.length;)t.events[A][1].end={...y},A++;return me(t.events,I+1,0,t.events.slice(E)),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(xi,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(xi,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 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++;me(t.events,T+1,0,t.events.slice(A)),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 Zl(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)||Ul(e))return 1;if(ql(e))return 2}function wn(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 ir={name:\"attention\",resolveAll:Xl,tokenize:eu};function Xl(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};Ci(c,-u),Ci(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,wn(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,me(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 eu(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 Ci(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const tu={name:\"autolink\",tokenize:nu};function nu(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 Ie(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||nr(d)?n(d):(e.consume(d),u)}function l(d){return d===64?(e.consume(d),f):Vl(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 kn={partial:!0,tokenize:ru};function ru(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 ja={continuation:{tokenize:au},exit:ou,name:\"blockQuote\",tokenize:iu};function iu(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 au(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(ja,t,n)(o)}}function ou(e){e.exit(\"blockQuote\")}const Wa={name:\"characterEscape\",tokenize:su};function su(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 Hl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Qa={name:\"characterReference\",tokenize:lu};function lu(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=Bl,f):(e.enter(\"characterReferenceValue\"),a=7,o=rr,f(c))}function f(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===pe&&!qa(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 Ii={partial:!0,tokenize:cu},Ei={concrete:!0,name:\"codeFenced\",tokenize:uu};function uu(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 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\"),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(Ii,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(Ii,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,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 cu(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 Nn={name:\"codeIndented\",tokenize:du},fu={partial:!0,tokenize:hu};function du(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(fu,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 hu(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 pu={name:\"codeText\",previous:gu,resolve:mu,tokenize:_u};function mu(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 gu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function _u(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 yu{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&&bt(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),bt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),bt(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);bt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);bt(this.left,n.reverse())}}}function bt(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 Ga(e){const t={};let n=-1,r,i,a,o,s,u,l;const f=new yu(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,bu(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 me(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function bu(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 vu={resolve:ku,tokenize:Su},wu={partial:!0,tokenize:xu};function ku(e){return Ga(e),e}function Su(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(wu,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 xu(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 Ya(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||nr(_)?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||nr(_)?n(_):(e.consume(_),_===92?x:k)}function x(_){return _===40||_===41||_===92?(e.consume(_),k):k(_)}}function Ka(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 Ja(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 It(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 Cu={name:\"definition\",tokenize:Eu},Iu={partial:!0,tokenize:Pu};function Eu(e,t,n){const r=this;let i;return a;function a(d){return e.enter(\"definition\"),o(d)}function o(d){return Ka.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(d)}function s(d){return i=Dt(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)?It(e,l)(d):l(d)}function l(d){return Ya(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(d)}function f(d){return e.attempt(Iu,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 Pu(e,t,n){return r;function r(s){return ae(s)?It(e,i)(s):n(s)}function i(s){return Ja(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 Au={name:\"hardBreakEscape\",tokenize:Tu};function Tu(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 Nu={name:\"headingAtx\",resolve:Du,tokenize:$u};function Du(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\"},me(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function $u(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 zu=[\"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\"],Fu={concrete:!0,name:\"htmlFlow\",resolveTo:Mu,tokenize:Lu},Ru={partial:!0,tokenize:Bu},Ou={partial:!0,tokenize:Vu};function Mu(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 Lu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(m){return f(m)}function f(m){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(m),c}function c(m){return m===33?(e.consume(m),h):m===47?(e.consume(m),a=!0,k):m===63?(e.consume(m),i=3,r.interrupt?t:g):Ie(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function h(m){return m===45?(e.consume(m),i=2,d):m===91?(e.consume(m),i=5,s=0,p):Ie(m)?(e.consume(m),i=4,r.interrupt?t:g):n(m)}function d(m){return m===45?(e.consume(m),r.interrupt?t:g):n(m)}function p(m){const q=\"CDATA[\";return m===q.charCodeAt(s++)?(e.consume(m),s===q.length?r.interrupt?t:$:p):n(m)}function k(m){return Ie(m)?(e.consume(m),o=String.fromCharCode(m),x):n(m)}function x(m){if(m===null||m===47||m===62||ae(m)){const q=m===47,oe=o.toLowerCase();return!q&&!a&&Pi.includes(oe)?(i=1,r.interrupt?t(m):$(m)):zu.includes(o.toLowerCase())?(i=6,q?(e.consume(m),_):r.interrupt?t(m):$(m)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(m):a?v(m):S(m))}return m===45||pe(m)?(e.consume(m),o+=String.fromCharCode(m),x):n(m)}function _(m){return m===62?(e.consume(m),r.interrupt?t:$):n(m)}function v(m){return L(m)?(e.consume(m),v):b(m)}function S(m){return m===47?(e.consume(m),b):m===58||m===95||Ie(m)?(e.consume(m),E):L(m)?(e.consume(m),S):b(m)}function E(m){return m===45||m===46||m===58||m===95||pe(m)?(e.consume(m),E):I(m)}function I(m){return m===61?(e.consume(m),y):L(m)?(e.consume(m),I):S(m)}function y(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),u=m,A):L(m)?(e.consume(m),y):T(m)}function A(m){return m===u?(e.consume(m),u=null,z):m===null||R(m)?n(m):(e.consume(m),A)}function T(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||ae(m)?I(m):(e.consume(m),T)}function z(m){return m===47||m===62||L(m)?S(m):n(m)}function b(m){return m===62?(e.consume(m),N):n(m)}function N(m){return m===null||R(m)?$(m):L(m)?(e.consume(m),N):n(m)}function $(m){return m===45&&i===2?(e.consume(m),J):m===60&&i===1?(e.consume(m),Y):m===62&&i===4?(e.consume(m),D):m===63&&i===3?(e.consume(m),g):m===93&&i===5?(e.consume(m),we):R(m)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Ru,j,B)(m)):m===null||R(m)?(e.exit(\"htmlFlowData\"),B(m)):(e.consume(m),$)}function B(m){return e.check(Ou,U,j)(m)}function U(m){return e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),M}function M(m){return m===null||R(m)?B(m):(e.enter(\"htmlFlowData\"),$(m))}function J(m){return m===45?(e.consume(m),g):$(m)}function Y(m){return m===47?(e.consume(m),o=\"\",ce):$(m)}function ce(m){if(m===62){const q=o.toLowerCase();return Pi.includes(q)?(e.consume(m),D):$(m)}return Ie(m)&&o.length<8?(e.consume(m),o+=String.fromCharCode(m),ce):$(m)}function we(m){return m===93?(e.consume(m),g):$(m)}function g(m){return m===62?(e.consume(m),D):m===45&&i===2?(e.consume(m),g):$(m)}function D(m){return m===null||R(m)?(e.exit(\"htmlFlowData\"),j(m)):(e.consume(m),D)}function j(m){return e.exit(\"htmlFlow\"),t(m)}}function Vu(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 Bu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(kn,t,n)}}const Hu={name:\"htmlText\",tokenize:qu};function qu(e,t,n){const r=this;let i,a,o;return s;function s(g){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(g),u}function u(g){return g===33?(e.consume(g),l):g===47?(e.consume(g),I):g===63?(e.consume(g),S):Ie(g)?(e.consume(g),T):n(g)}function l(g){return g===45?(e.consume(g),f):g===91?(e.consume(g),a=0,p):Ie(g)?(e.consume(g),v):n(g)}function f(g){return g===45?(e.consume(g),d):n(g)}function c(g){return g===null?n(g):g===45?(e.consume(g),h):R(g)?(o=c,Y(g)):(e.consume(g),c)}function h(g){return g===45?(e.consume(g),d):c(g)}function d(g){return g===62?J(g):g===45?h(g):c(g)}function p(g){const D=\"CDATA[\";return g===D.charCodeAt(a++)?(e.consume(g),a===D.length?k:p):n(g)}function k(g){return g===null?n(g):g===93?(e.consume(g),x):R(g)?(o=k,Y(g)):(e.consume(g),k)}function x(g){return g===93?(e.consume(g),_):k(g)}function _(g){return g===62?J(g):g===93?(e.consume(g),_):k(g)}function v(g){return g===null||g===62?J(g):R(g)?(o=v,Y(g)):(e.consume(g),v)}function S(g){return g===null?n(g):g===63?(e.consume(g),E):R(g)?(o=S,Y(g)):(e.consume(g),S)}function E(g){return g===62?J(g):S(g)}function I(g){return Ie(g)?(e.consume(g),y):n(g)}function y(g){return g===45||pe(g)?(e.consume(g),y):A(g)}function A(g){return R(g)?(o=A,Y(g)):L(g)?(e.consume(g),A):J(g)}function T(g){return g===45||pe(g)?(e.consume(g),T):g===47||g===62||ae(g)?z(g):n(g)}function z(g){return g===47?(e.consume(g),J):g===58||g===95||Ie(g)?(e.consume(g),b):R(g)?(o=z,Y(g)):L(g)?(e.consume(g),z):J(g)}function b(g){return g===45||g===46||g===58||g===95||pe(g)?(e.consume(g),b):N(g)}function N(g){return g===61?(e.consume(g),$):R(g)?(o=N,Y(g)):L(g)?(e.consume(g),N):z(g)}function $(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),i=g,B):R(g)?(o=$,Y(g)):L(g)?(e.consume(g),$):(e.consume(g),U)}function B(g){return g===i?(e.consume(g),i=void 0,M):g===null?n(g):R(g)?(o=B,Y(g)):(e.consume(g),B)}function U(g){return g===null||g===34||g===39||g===60||g===61||g===96?n(g):g===47||g===62||ae(g)?z(g):(e.consume(g),U)}function M(g){return g===47||g===62||ae(g)?z(g):n(g)}function J(g){return g===62?(e.consume(g),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(g)}function Y(g){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),ce}function ce(g){return L(g)?H(e,we,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(g):we(g)}function we(g){return e.enter(\"htmlTextData\"),o(g)}}const Er={name:\"labelEnd\",resolveAll:Qu,resolveTo:Gu,tokenize:Yu},Uu={tokenize:Ku},ju={tokenize:Ju},Wu={tokenize:Zu};function Qu(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&&me(e,0,e.length,n),e}function Gu(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,wn(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]]),me(e,a,e.length,s),e}function Yu(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(Dt(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(Uu,f,o?f:c)(h):h===91?e.attempt(ju,f,o?l:c)(h):o?f(h):c(h)}function l(h){return e.attempt(Wu,f,c)(h)}function f(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function Ku(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)?It(e,a)(c):a(c)}function a(c){return c===41?f(c):Ya(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return ae(c)?It(e,u)(c):f(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Ja(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return ae(c)?It(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 Ju(e,t,n){const r=this;return i;function i(s){return Ka.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function Zu(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 Xu={name:\"labelStartImage\",resolveAll:Er.resolveAll,tokenize:ec};function ec(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 tc={name:\"labelStartLink\",resolveAll:Er.resolveAll,tokenize:nc};function nc(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 Dn={name:\"lineEnding\",tokenize:rc};function rc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const tn={name:\"thematicBreak\",tokenize:ic};function ic(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:lc},exit:cc,name:\"list\",tokenize:sc},ac={partial:!0,tokenize:fc},oc={partial:!0,tokenize:uc};function sc(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:rr(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(tn,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 rr(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(kn,r.interrupt?n:f,e.attempt(ac,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 lc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(kn,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(oc,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 uc(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 cc(e){e.exit(this.containerState.type)}function fc(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 Ai={name:\"setextUnderline\",resolveTo:dc,tokenize:hc};function dc(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 hc(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 pc={tokenize:mc};function mc(e){const t=this,n=e.attempt(kn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(vu,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 gc={resolveAll:Xa()},_c=Za(\"string\"),yc=Za(\"text\");function Za(e){return{resolveAll:Xa(e===\"text\"?bc: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 Xa(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 bc(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 vc={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:ja},wc={91:Cu},kc={[-2]:Nn,[-1]:Nn,32:Nn},Sc={35:Nu,42:tn,45:[Ai,tn],60:Fu,61:Ai,95:tn,96:Ei,126:Ei},xc={38:Qa,92:Wa},Cc={[-5]:Dn,[-4]:Dn,[-3]:Dn,33:Xu,38:Qa,42:ir,60:[tu,Hu],91:tc,92:[Au,Wa],93:Er,95:ir,96:pu},Ic={null:[ir,gc]},Ec={null:[42,95]},Pc={null:[]},Ac=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ec,contentInitial:wc,disable:Pc,document:vc,flow:Sc,flowInitial:kc,insideSpan:Ic,string:xc,text:Cc},Symbol.toStringTag,{value:\"Module\"}));function Tc(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(I),check:A(y),consume:v,enter:S,exit:E,interrupt:A(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=wn(a,l.events,l),l.events)}function h(N,$){return Dc(d(N),$)}function d(N){return Nc(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 A(N,$){return B;function B(U,M,J){let Y,ce,we,g;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(X){return _t;function _t(Oe){const it=Oe!==null&&X[Oe],at=Oe!==null&&X.null,In=[...Array.isArray(it)?it:it?[it]:[],...Array.isArray(at)?at:at?[at]:[]];return j(In)(Oe)}}function j(X){return Y=X,ce=0,X.length===0?J:m(X[ce])}function m(X){return _t;function _t(Oe){return g=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,g),M}function oe(X){return g.restore(),++ce<Y.length?m(Y[ce]):J}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&me(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 Nc(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 Dc(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 $c(e){const r={constructs:$l([Ac,...(e||{}).extensions||[]]),content:i(Gl),defined:[],document:i(Kl),flow:i(pc),lazy:{},string:i(_c),text:i(yc)};return r;function i(a){return o;function o(s){return Tc(r,a,s)}}}function zc(e){for(;!Ga(e););return e}const Ti=/[\\0\\t\\n\\r]/g;function Fc(){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(Ti.lastIndex=c,l=Ti.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 Rc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Ql(n)(zc($c(n).document().write(Fc()(e,t,!0))))}const $n={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Oc(){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=$n[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=$n[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,Mc)),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\"+$n[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Mc(e,t){return t===\"|\"?t:e}class Lc{constructor(){this.map=[]}add(t,n,r){Vc(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 Vc(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 Bc(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 Hc(){return{flow:{null:{name:\"table\",tokenize:qc,resolveAll:Uc}}}}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),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\"),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||ae(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 Uc(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 Lc;for(;++n<e.length;){const d=e[n],p=d[1];d[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Ni(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=Yt(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=Yt(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=Yt(h,t,a,i,n,c)):o[1]!==0&&(c=Yt(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Ni(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=Bc(t.events,n))}return e}function Yt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},ot(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=ot(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=ot(t.events,n[2]),f=ot(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({},ot(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Ni(e,t,n,r,i){const a=[],o=ot(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 ot(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function jc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Wc(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&&me(h,h.length,0,wn(d,o.slice(l+1,u),s)),me(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",f,s]]),me(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 Qc(e){return Rc(e,{allowDangerousHtml:!0,extensions:[Hc(),Wc()],htmlExtensions:[Oc(),jc()]})}const Gc={update:()=>{},getValues:()=>({})},He=dt({}),Ht=dt(Gc),Ne=dt(!1);function Yc(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)=>eo(a,o,t));return w(G,{children:i})}function eo(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)=>eo(u,l,n));return K(i,o,...s)}return null}function Kc({node:e}){const t=xr(),n=ue(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?Se(e.children,n?{nobr:!0}:void 0):void 0)}function Jc(e,t){if(Dl(e.name))return null;const n=Pl(e.name);if(n)return w(El,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Tl(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 ar(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return w(pl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Jc(e,t);case\"html\":return w(Kc,{node:e},t);default:return e}}function to(e){return e.length===0?null:e.map((t,n)=>ar(t,n))}function Zc(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function Xc(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 Se(e,t){if(e.length===0)return null;if(!e.some(o=>o.type===\"text\"))return e.map((o,s)=>ar(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\"&&Zc(i))i+=Xc(s);else{const u=r.length;r.push(ar(s,o)),i+=`<span data-tw=\"${u}\"></span>`}}const a=Qc(i);return Yc(a,r,t?.nobr)}const ef=\"spindle\",tf=1;let Kt=null,zn=null;function qe(){return zn||(zn={saves:new Map,playthroughs:new Map,meta:new Map}),zn}function nf(){return Kt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Kt=new Promise((e,t)=>{const n=indexedDB.open(ef,tf);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)}),Kt))}function Ue(e,t){return nf().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 Sn(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.put(e))}catch{qe().saves.set(e.meta.id,e)}}async function xn(e){try{const t=await Ue(\"saves\",\"readonly\");return await je(t.get(e))??void 0}catch{return qe().saves.get(e)}}async function rf(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.delete(e))}catch{qe().saves.delete(e)}}async function af(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 no(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 Ar(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 ro(e,t){try{const n=await Ue(\"meta\",\"readwrite\");await je(n.put({key:e,value:t}))}catch{qe().meta.set(e,t)}}const io=new Map,Cn=new Map;function of(e,t){io.set(e,t),Cn.set(t,e)}function sf(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(Cn.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(sf(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 or=\"__spindle_class__\",sr=\"__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=Cn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[or]:o,[sr]: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(or in r&&sr in r){const o=r[or],s=r[sr],u=io.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(Cn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let lr=null,ur=null,Di=!1;function lf(e){lr=e}function uf(e){ur=e}function cf(e){if(ur)try{const i=new Function(\"passage\",\"variables\",ur)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(lr)try{const r=lr(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 ff(){Di||(Di=!0)}async function $i(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 no(i),await ro(`currentPlaythroughId.${e}`,r),r}async function df(e){return Ar(`currentPlaythroughId.${e}`)}async function ao(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:cf(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 Sn(s),s}async function oo(e,t){const n=await xn(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 Sn(i),i}async function hf(e){const t=await xn(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 pf(e){await rf(e)}async function mf(e,t){const n=await xn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await Sn(r)}async function gf(e){const[t,n]=await Promise.all([af(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 so=\"autosave.\";async function _f(e,t,n){const r=`${so}${e}`,i=await Ar(r);if(i){const o=await oo(i,n);if(o)return o}const a=await ao(e,t,n,{isAutosave:!0});return await ro(r,a.meta.id),a}async function yf(e){const t=`${so}${e}`,n=await Ar(t);if(n)return hf(n)}const Tr=\"spindle.session.\";function bf(e,t){try{sessionStorage.setItem(`${Tr}${e}`,JSON.stringify(t))}catch{}}function vf(e){try{const t=sessionStorage.getItem(`${Tr}${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 wf(e){try{sessionStorage.removeItem(`${Tr}${e}`)}catch{}}async function kf(e){const t=await xn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Sf(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 no(a)}return await Sn(n),n}function lo(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=pt(t.content),i=mt(r),a=document.createElement(\"div\");be(K(()=>Se(i),null),a),be(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&uf(n.content)}let uo=0,ye=[],Fn=!1,qt=[],nn=null;function Nr(e){const t=C.getState();try{return!!vn(e,t.variables,t.temporary)}catch{return!1}}function co(e,t){const n=uo++,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:Nr(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 fo(e){ye=ye.filter(t=>t.name!==e)}function xf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Ma(n.run,r.variables,r.temporary)}n.dialog&&(qt.push(n.dialog),nn?.()),n.goto&&C.getState().navigate(n.goto)}}const Cf=10;function If(){if(!Fn){Fn=!0;try{for(let e=0;e<Cf;e++){let t=!1;const n=[...ye];for(const r of n){if(!ye.includes(r))continue;const i=Nr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ye=ye.filter(o=>o.id!==r.id)),xf(r))}if(!t)break}}finally{Fn=!1}}}function Ef(){for(const e of ye)e.lastResult=Nr(e.condition)}function Pf(){ye=[],qt=[],uo=0}function Af(e){return nn=e,qt.length>0&&e(),()=>{nn===e&&(nn=null)}}function zi(){return qt.shift()}function Tf(){return qt.length}el();const Nf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ye={},ge=[],Me={};function Fi(e){return e.map(t=>({...t,value:t.value!==void 0?ne(t.value):void 0}))}function Ri(e,t){const[,n,r]=nl(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:Fi(n),inverse:Fi(r)}}function Df(e){let t=Ye;for(let n=0;n<e;n++)t=st(t,ge[n].forward);return t}let _e=[];function Rn(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=st(l,ge[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}}}bf(t.ifid,{passage:n,variables:Ke(r),history:_e,historyIndex:a,visitCounts:o,renderCounts:s,prng:pn()})}}function Oi(e){Ye=e,ge=[],Me=e,_e=[]}function Mi(e){e?.prng?za(e.prng.seed,e.prng.pull):e&&er()}const C=Os()(il((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);Oi(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;ff().then(async()=>{const s=await df(o);if(s)e(u=>{u.playthroughId=s});else{const u=await $i(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(Nf.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=Ri(Me,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),ge.length=o.historyIndex,ge.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:pn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ye=st(Ye,ge[u].forward);o.history=o.history.slice(s),ge=ge.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,Rn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ne(st(r,ge[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Me=t().variables,Mi(t().history[t().historyIndex]),Rn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ne(st(i,ge[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Me=t().variables,Mi(t().history[t().historyIndex]),Rn(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;er(),Pf();const a=ne(r);Oi(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,lo(),wf(n.ifid),$i(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}),_f(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}),yf(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=st(l,ge[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:pn()}},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(Ri(a,s)),a=s}Ye=ne(r),ge=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?za(n.prng.seed,n.prng.pull):er()},getHistoryVariables:n=>ne(Df(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}}))),$f=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function zf(){const t=C(i=>i.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:$f,r=t?.tags.includes(\"nobr\")??!1;try{const i=pt(n),a=mt(i),o=w(G,{children:to(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 ho=dt(null);function Dr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r}){const i=C(f=>f.storyData),o=(e?i?.passages.get(e):void 0)?.content??t,s=de(()=>{if(!o)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const f=pt(o),c=mt(f);return Se(c)}catch(f){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",f.message]})}},[o]),u=f=>{f.target.classList.contains(\"dialog-overlay\")&&r()},l=n?`dialog-panel ${n}`:\"dialog-panel\";return w(ho.Provider,{value:r,children:w(\"div\",{class:\"dialog-overlay\",onClick:u,children:w(\"div\",{class:l,children:[w(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:s})]})})})}function Ff(){const[e,t]=Z(null),n=ve(()=>{const i=zi();t(i??null)},[]);Ae(()=>Af(()=>{t(i=>i!==null?i:zi()??null)}),[]);const r=ve(()=>{t(null),Tf()>0&&requestAnimationFrame(n)},[n]);return e?w(Dr,{passageName:e,onClose:r}):null}function Rf(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(Ae(()=>{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(zf,{}),w(Ff,{})]});return n?w(Ne.Provider,{value:!0,children:r}):r}function Of(){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=h.textContent||\"\",_={},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 vt=new Map;let se={},Li=!1;function po(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Mf(){localStorage.setItem(po(),JSON.stringify(se))}function On(){if(!Li){Li=!0;try{const e=localStorage.getItem(po());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(se={...se,...t})}}catch{}}}const $t={addToggle(e,t){vt.set(e,{type:\"toggle\",config:t}),e in se||(se[e]=t.default),On()},addList(e,t){vt.set(e,{type:\"list\",config:t}),e in se||(se[e]=t.default),On()},addRange(e,t){vt.set(e,{type:\"range\",config:t}),e in se||(se[e]=t.default),On()},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,Mf()},getAll(){return{...se}},getDefinitions(){return vt},hasAny(){return vt.size>0}};function Lf(e,t,n){const r=C.getState(),i=ne(r.variables),a=ne(r.temporary),o={...t};Ma(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 gn=new Map,cr=new Set,fr=new Map;function Vf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(fr.get(r)??0)+1;return fr.set(r,i),i===1?r:`${r}:${i}`}function Bf(e){return gn.set(e.id,e),Bi(),()=>{gn.delete(e.id),Bi()}}function Vi(){return Array.from(gn.values())}function Hf(e){return gn.get(e)}function qf(){fr.clear()}function Uf(e){return cr.add(e),()=>{cr.delete(e)}}function Bi(){for(const e of cr)e()}function jf(e){const t=fe(\"\");t.current||(t.current=Vf(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),Bf(r)}),n}function Wf(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function mo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function $r(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?mo(t):\"\"}function Qf(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 Gf(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 Yf(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const Kf={useState:Z,useRef:fe,useEffect:Ae,useLayoutEffect:nt,useCallback:ve,useMemo:de,useContext:ue};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=xr(),r=a(r),i=a(i));const{update:o,getValues:s}=ue(Ht),l=ue(Ne)?(c,h)=>Se(c,{nobr:!0,...h}):Se,f={collectText:Wf,sourceLocation:$r,parseVarArgs:Qf,extractOptions:Gf,h:K,renderNodes:l,renderInlineNodes:to,hooks:Kf,useAction:jf,className:r,id:i,resolve:a,cls:Yf(e.name,r),mutate:c=>Lf(c,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){f.merged=Sr();const c=f.merged;f.evaluate=h=>vn(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(Al(e.name,t),e.subMacros)for(const n of e.subMacros)Nl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&ul(e.name)}function Jf(){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:$t,registerClass(e,t){of(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){lf(e)}},getActions(){return Vi()},performAction(e,t){const n=Hf(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 Uf(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(Vi())})})})},watch(e,t){return co(e,t)},unwatch(e){fo(e)},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 Cr()},randomInt(e,t){return Fa(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){ml(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=pn())})},isEnabled(){return gl()},get seed(){return _l()},get pull(){return yl()}}}}function Zf(){window.Story=Jf()}const Xf=/^\\$(\\w+)\\s*=\\s*(.+)$/,Hi=/\\$(\\w+(?:\\.\\w+)*)/g,qi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,ed=new Set([\"number\",\"string\",\"boolean\"]);function go(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,go(i));return{type:\"object\",fields:n}}const t=typeof e;if(!ed.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function td(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Xf);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=go(s);t.set(a,{...u,name:a,default:s})}return t}function nd(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 rd(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 id(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=nd(i.content);let o;for(Hi.lastIndex=0;(o=Hi.exec(i.content))!==null;){const s=o[1],u=rd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function ad(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${$r()}: ${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 od(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 sd(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 Ui(e,t,n,r,i,a,o){const s=C.getState();let u;try{u=vn(e,r,i,a)}catch(f){console.error(`spindle: Error in {computed ${o}}${$r()}:`,f);return}const l=n?s.temporary[t]:s.variables[t];sd(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}=od(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();Ui(o,u,s,f.variables,f.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{Ui(o,u,s,n,r,i,e)},[n,r,i]),null}});function ld(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=ud(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 ud(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 cd(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}=ld(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=cd(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 fd(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 dd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=Z(()=>({...e,...t,...n})),o=fe(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=ue(Ne);return w(Ht.Provider,{value:l,children:w(He.Provider,{value:i,children:Se(r,f?{nobr:!0}:void 0)})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=ue(He);let i;try{i=fd(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(dd,{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(Ht.Provider,{value:{update:n.update,getValues:n.getValues}},K(He.Provider,{value:n.getValues()},Se(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 hd(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 ji(e,t,n){const r=document.createElement(\"div\"),i=K(Ht.Provider,{value:{update:n,getValues:t}},K(He.Provider,{value:t()},Se(e)));be(i,r),be(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=hd(e),a=o=>{o.preventDefault(),ji(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:()=>{ji(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 zr(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?zr(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 _o=dt({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||!Ta(E))return E;const I=C.getState();return Na(E,I.variables,I.temporary,{})};return[S(n),S(r)]},[n,r]),c=zr(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(_o.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(_o);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=zr(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 pd(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}=pd(e);return n.hooks.useLayoutEffect(()=>{Va(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 rt(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(Dr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1)})]})}})}rt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});rt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});rt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});rt({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()}}});rt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});rt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});rt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!$t.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,o=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(G,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:a}),r&&w(Dr,{passageName:o,onClose:()=>i(!1)})]})}});function md(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 gd(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 _d(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function yd(){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=fe(null),k=fe(null),x=ue(ho),_=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 gf(I);r(D),a(!1)},[I]);Ae(()=>{y()},[y]),Ae(()=>{f&&p.current&&(p.current.focus(),p.current.select())},[f]);const A=fe(),T=(D,j=\"success\")=>{clearTimeout(A.current),s({text:D,type:j}),A.current=window.setTimeout(()=>s(null),3e3)},z=D=>{l(j=>{const m=new Set(j);return m.has(D)?m.delete(D):m.add(D),m})},b=async()=>{if(!(!I||!v))try{const D=S();await ao(I,v,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=S();await oo(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 pf(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 mf(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 kf(D);if(!j)return;const m=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(m),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\")}},ce=()=>{k.current?.click()},we=async D=>{const j=D.target,m=j.files?.[0];if(m){j.value=\"\";try{const q=await m.text(),oe=JSON.parse(q);if(!md(oe))throw new Error(\"Invalid save file format\");await Sf(oe,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},g=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:ce,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...\"}):g===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),m=D.playthrough.id===v;return e===\"save\"&&!m||e===\"load\"&&D.saves.length===0&&!m?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,m?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:_d(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:gd(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\"&&m&&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(yd,{})}});function bd({name:e,def:t}){const[n,r]=Z(()=>$t.get(e)),i=a=>{r(a),$t.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 vd(){const e=$t.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(bd,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return w(vd,{})}});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=pt(o.content),l=mt(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 wd(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}=wd(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 kd(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}=kd(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 kt(e){const t=pt(e.content),n=mt(t),r=e.tags.includes(\"nobr\");return Se(n,r?{nobr:!0}:void 0)}const Sd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function xd({passage:e,dataTransition:t}){const n=C(k=>k.storyData),r=Sd.has(e.name),[i,a]=Z(!1),o=de(()=>{try{return kt(e)}catch(k){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",mo(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 kt(s)}catch(k){return console.error(\"spindle: Error in PassageHeader:\",k),null}},[s?.content]),c=de(()=>{if(!u)return null;try{return kt(u)}catch(k){return console.error(\"spindle: Error in PassageFooter:\",k),null}},[u?.content]);Ae(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return kt(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 Cd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),dr={type:\"fade-through\",duration:300,pause:50};function Id(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Cd.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 Mn(e){return{type:e.type,duration:e.duration??dr.duration,pause:e.pause??dr.pause}}function Ed(e,t,n){const r=Id(e);return r?Mn(r):t?Mn(t):n?Mn(n):{...dr}}function Wi(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 Ln(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 Vn(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=fe(\"fade\"),s=fe(0),u=fe(null),l=fe([]),f=ve(()=>{for(const d of l.current)clearTimeout(d);l.current=[],Vn(u.current)},[]);Ae(()=>{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 A=Ed(y.tags,_,x);o.current=A.type;const T=u.current;if(A.type===\"none\"){a(n);return}if(A.type===\"fade\"){T&&Ln(T,A),a(n);return}if(A.type===\"fade-through\"){if(!T){a(n);return}Ln(T,A);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Wi(z,A.type);T.appendChild(b),a(\"\");const N=A.duration+A.pause,$=setTimeout(()=>{a(n)},N),B=N+A.duration,U=setTimeout(()=>{Vn(T)},B);l.current=[$,U];return}if(A.type===\"crossfade\"){if(!T){a(n);return}Ln(T,A);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Wi(z,A.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const N=setTimeout(()=>{Vn(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:kt(h)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:c&&w(xd,{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,co(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,fo(r)),null}});const Pd='*,*: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 Qi(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 Gi(){const e=Of(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Pd,document.head.appendChild(t),Zf(),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&&Qi(d,[h]),new Error(`spindle: ${h}`)}const i=td(r.content),a=id(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&Qi(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=ad(i),C.getState().init(e,n),lo();const o=vf(e.ifid);o&&C.getState().loadFromPayload(o);for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const d=pt(h.content),p=mt(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(\"@\"));Va(_,k.children,v)}}let s=\"\";C.subscribe(h=>{h.currentPassage!==s&&(s=h.currentPassage,qf())});let u=C.getState().variables,l=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===l?If():Ef()),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(Rf,{}),c),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Gi):Gi();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
package/package.json
CHANGED
|
@@ -81,17 +81,19 @@ function WidgetBody({
|
|
|
81
81
|
ownKeys: Record<string, unknown>;
|
|
82
82
|
}) {
|
|
83
83
|
const nobr = useContext(NobrContext);
|
|
84
|
-
const [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const [localMutations, setLocalMutations] = useState<Record<string, unknown>>(
|
|
85
|
+
{},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Recomputed every render — picks up new ownKeys from parent
|
|
89
|
+
const localState = { ...parentValues, ...ownKeys, ...localMutations };
|
|
88
90
|
|
|
89
91
|
const valuesRef = useRef(localState);
|
|
90
92
|
valuesRef.current = localState;
|
|
91
93
|
|
|
92
94
|
const getValues = useCallback(() => valuesRef.current, []);
|
|
93
95
|
const update = useCallback((key: string, value: unknown) => {
|
|
94
|
-
|
|
96
|
+
setLocalMutations((prev) => ({ ...prev, [key]: value }));
|
|
95
97
|
}, []);
|
|
96
98
|
const updater = useMemo(() => ({ update, getValues }), [update, getValues]);
|
|
97
99
|
|