@rohal12/spindle 0.31.1 → 0.31.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 +1 -1
- package/package.json +1 -1
- package/src/define-macro.ts +2 -1
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.31.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 o of i)if(o.type===\"childList\")for(const a of o.addedNodes)a.tagName===\"LINK\"&&a.rel===\"modulepreload\"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?o.credentials=\"include\":i.crossOrigin===\"anonymous\"?o.credentials=\"omit\":o.credentials=\"same-origin\",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Lt,O,Xi,Ge,Qr,eo,to,no,_r,jn,Wn,ro,ln={},un=[],Qa=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Vt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function yr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function G(e,t,n){var r,i,o,a={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?Lt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return Et(e,a,r,i,null)}function Et(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Xi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(o),o}function Ga(){return{current:null}}function Y(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function ht(e,t){if(t==null)return e.__?ht(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\"?ht(e):null}function Ka(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=Te({},t);o.__v=t.__v+1,O.vnode&&O.vnode(o),br(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ht(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,so(r,o,i),t.__e=t.__=null,o.__e!=n&&io(o)}}function io(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}),io(e)}function Qn(e){(!e.__d&&(e.__d=!0)&&Ge.push(e)&&!cn.__r++||Qr!=O.debounceRendering)&&((Qr=O.debounceRendering)||eo)(cn)}function cn(){for(var e,t=1;Ge.length;)Ge.length>t&&Ge.sort(to),e=Ge.shift(),t=Ge.length,Ka(e);cn.__r=0}function oo(e,t,n,r,i,o,a,s,u,l,d){var f,h,c,p,w,S,y,k=r&&r.__k||un,x=t.length;for(u=Ya(n,t,k,u,x),f=0;f<x;f++)(c=n.__k[f])!=null&&(h=c.__i!=-1&&k[c.__i]||ln,c.__i=f,S=br(e,c,h,i,o,a,s,u,l,d),p=c.__e,c.ref&&h.ref!=c.ref&&(h.ref&&vr(h.ref,null,c),d.push(c.ref,c.__c||p,c)),w==null&&p!=null&&(w=p),(y=!!(4&c.__u))||h.__k===c.__k?u=ao(c,u,e,y):typeof c.type==\"function\"&&S!==void 0?u=S:p&&(u=p.nextSibling),c.__u&=-7);return n.__e=w,u}function Ya(e,t,n,r,i){var o,a,s,u,l,d=n.length,f=d,h=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!=\"boolean\"&&typeof a!=\"function\"?(typeof a==\"string\"||typeof a==\"number\"||typeof a==\"bigint\"||a.constructor==String?a=e.__k[o]=Et(null,a,null,null,null):Vt(a)?a=e.__k[o]=Et(Y,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=Et(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,u=o+h,a.__=e,a.__b=e.__b+1,s=null,(l=a.__i=Ja(a,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof a.type!=\"function\"&&(a.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,a.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<d;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ht(s)),uo(s,s));return r}function ao(e,t,n,r){var i,o;if(typeof e.type==\"function\"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=ao(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ht(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Re(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Vt(e)?e.some(function(n){Re(n,t)}):t.push(e)),t}function Ja(e,t,n,r){var i,o,a,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((l=t[a=i>=0?i--:o++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return a}return-1}function Gr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Qa.test(t)?n:n+\"px\"}function Gt(e,t,n,r,i){var o,a;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||Gr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Gr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")o=t!=(t=t.replace(no,\"$1\")),a=t.toLowerCase(),t=a in e||t==\"onFocusOut\"||t==\"onFocusIn\"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=_r,e.addEventListener(t,o?Wn:jn,o)):e.removeEventListener(t,o?Wn:jn,o);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 Kr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=_r++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function br(e,t,n,r,i,o,a,s,u,l){var d,f,h,c,p,w,S,y,k,x,A,C,_,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),o=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(y=t.props,k=\"prototype\"in z&&z.prototype.render,x=(d=z.contextType)&&r[d.__c],A=d?x?x.props.value:d.__:r,n.__c?S=(f=t.__c=n.__c).__=f.__E:(k?t.__c=f=new z(y,A):(t.__c=f=new Ne(y,A),f.constructor=z,f.render=Xa),x&&x.sub(f),f.state||(f.state={}),f.__n=r,h=f.__d=!0,f.__h=[],f._sb=[]),k&&f.__s==null&&(f.__s=f.state),k&&z.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Te({},f.__s)),Te(f.__s,z.getDerivedStateFromProps(y,f.__s))),c=f.props,p=f.state,f.__v=t,h)k&&z.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),k&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(k&&z.getDerivedStateFromProps==null&&y!==c&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,A),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,A)===!1){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),un.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&a.push(f);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,A),k&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(c,p,w)})}if(f.context=A,f.props=y,f.__P=e,f.__e=!1,C=O.__r,_=0,k)f.state=f.__s,f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),un.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++_<25);f.state=f.__s,f.getChildContext!=null&&(r=Te(Te({},r),f.getChildContext())),k&&!h&&f.getSnapshotBeforeUpdate!=null&&(w=f.getSnapshotBeforeUpdate(c,p)),P=d!=null&&d.type===Y&&d.key==null?lo(d.props.children):d,s=oo(e,Vt(P)?P:[P],t,n,r,i,o,a,s,u,l),f.base=t.__e,t.__u&=-161,f.__h.length&&a.push(f),S&&(f.__E=f.__=null)}catch(b){if(t.__v=null,u||o!=null)if(b.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(T=o.length;T--;)yr(o[T]);Gn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Gn(t);O.__e(b,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Za(n.__e,t,n,r,i,o,a,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function Gn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Gn))}function so(e,t,n){for(var r=0;r<n.length;r++)vr(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(o){o.call(i)})}catch(o){O.__e(o,i.__v)}})}function lo(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Vt(e)?e.map(lo):Te({},e)}function Za(e,t,n,r,i,o,a,s,u){var l,d,f,h,c,p,w,S=n.props||ln,y=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),o!=null){for(l=0;l<o.length;l++)if((c=o[l])&&\"setAttribute\"in c==!!k&&(k?c.localName==k:c.nodeType==3)){e=c,o[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(y);e=document.createElementNS(i,k,y.is&&y),s&&(O.__m&&O.__m(t,o),s=!1),o=null}if(k==null)S===y||s&&e.data==y||(e.data=y);else{if(o=o&&Lt.call(e.childNodes),!s&&o!=null)for(S={},l=0;l<e.attributes.length;l++)S[(c=e.attributes[l]).name]=c.value;for(l in S)c=S[l],l==\"dangerouslySetInnerHTML\"?f=c:l==\"children\"||l in y||l==\"value\"&&\"defaultValue\"in y||l==\"checked\"&&\"defaultChecked\"in y||Gt(e,l,null,c,i);for(l in y)c=y[l],l==\"children\"?h=c:l==\"dangerouslySetInnerHTML\"?d=c:l==\"value\"?p=c:l==\"checked\"?w=c:s&&typeof c!=\"function\"||S[l]===c||Gt(e,l,c,S[l],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),oo(t.type==\"template\"?e.content:e,Vt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,o,a,o?o[0]:n.__k&&ht(n,0),s,u),o!=null)for(l=o.length;l--;)yr(o[l]);s||(l=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||k==\"progress\"&&!p||k==\"option\"&&p!=S[l])&&Gt(e,l,p,S[l],i),l=\"checked\",w!=null&&w!=e[l]&&Gt(e,l,w,S[l],i))}return e}function vr(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 uo(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||vr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){O.__e(o,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&uo(r[i],t,n||typeof e.type!=\"function\");n||yr(e.__e),e.__c=e.__=e.__e=void 0}function Xa(e,t,n){return this.constructor(e,n)}function xe(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],a=[],br(t,e=(!r&&n||t).__k=G(Y,null,[e]),i||ln,ln,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Lt.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),so(o,e,a)}function co(e,t){xe(e,t,co)}function es(e,t,n){var r,i,o,a,s=Te({},e.props);for(o in e.type&&e.type.defaultProps&&(a=e.type.defaultProps),t)o==\"key\"?r=t[o]:o==\"ref\"?i=t[o]:s[o]=t[o]===void 0&&a!=null?a[o]:t[o];return arguments.length>2&&(s.children=arguments.length>3?Lt.call(arguments,2):n),Et(e.type,s,r||e.key,i||e.ref,null)}function ot(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(o){this.props.value!=o.value&&r.forEach(function(a){a.__e=!0,Qn(a)})},this.sub=function(o){r.add(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){r&&r.delete(o),a&&a.call(o)}}),n.children}return t.__c=\"__cC\"+ro++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Lt=un.slice,O={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},Xi=0,Ne.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof e==\"function\"&&(e=e(Te({},n),this.props)),e&&Te(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Qn(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Qn(this))},Ne.prototype.render=Y,Ge=[],eo=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,to=function(e,t){return e.__v.__b-t.__v.__b},cn.__r=0,no=/(PointerCapture)$|Capture$/i,_r=0,jn=Kr(!1),Wn=Kr(!0),ro=0;var ts=0;function v(e,t,n,r,i,o){t||(t={});var a,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?a=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ts,__i:-1,__u:0,__source:i,__self:o};if(typeof e==\"function\"&&(a=e.defaultProps))for(s in a)u[s]===void 0&&(u[s]=a[s]);return O.vnode&&O.vnode(l),l}var Be,W,Nn,Yr,pt=0,fo=[],Q=O,Jr=Q.__b,Zr=Q.__r,Xr=Q.diffed,ei=Q.__c,ti=Q.unmount,ni=Q.__;function _t(e,t){Q.__h&&Q.__h(W,e,pt||t),pt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return pt=1,wr(mo,e)}function wr(e,t,n){var r=_t(Be++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):mo(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!o||o.call(this,s,u,l);var f=r.__c.props!==s;return d.some(function(h){if(h.__N){var c=h.__[0];h.__=h.__N,h.__N=void 0,c!==h.__[0]&&(f=!0)}}),o&&o.call(this,s,u,l)||f};W.__f=!0;var o=W.shouldComponentUpdate,a=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var d=o;o=void 0,i(s,u,l),o=d}a&&a.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function we(e,t){var n=_t(Be++,3);!Q.__s&&kr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function at(e,t){var n=_t(Be++,4);!Q.__s&&kr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function ae(e){return pt=5,de(function(){return{current:e}},[])}function ho(e,t,n){pt=6,at(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=_t(Be++,7);return kr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function he(e,t){return pt=8,de(function(){return e},t)}function K(e){var t=W.context[e.__c],n=_t(Be++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function po(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function go(){var e=_t(Be++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function ns(){for(var e;e=fo.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(tn),t.__h.some(Kn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Jr&&Jr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ni&&ni(e,t)},Q.__r=function(e){Zr&&Zr(e),Be=0;var t=(W=e.__c).__H;t&&(Nn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(tn),t.__h.some(Kn),t.__h=[],Be=0)),Nn=W},Q.diffed=function(e){Xr&&Xr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fo.push(t)!==1&&Yr===Q.requestAnimationFrame||((Yr=Q.requestAnimationFrame)||rs)(ns)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Nn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(tn),n.__h=n.__h.filter(function(r){return!r.__||Kn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),ei&&ei(e,t)},Q.unmount=function(e){ti&&ti(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{tn(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ri=typeof requestAnimationFrame==\"function\";function rs(e){var t,n=function(){clearTimeout(r),ri&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ri&&(t=requestAnimationFrame(n))}function tn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Kn(e){var t=W;e.__c=e.__(),W=t}function kr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function mo(e,t){return typeof t==\"function\"?t(e):t}const ii=e=>{let t;const n=new Set,r=(l,d)=>{const f=typeof l==\"function\"?l(t):l;if(!Object.is(f,t)){const h=t;t=d??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(c=>c(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},is=(e=>e?ii(e):ii);function _o(e,t){for(var n in t)e[n]=t[n];return e}function Yn(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 yo(e,t){var n=t(),r=X({t:{__:n,u:t}}),i=r[0].t,o=r[1];return at(function(){i.__=n,i.u=t,Dn(i)&&o({t:i})},[e,n,t]),we(function(){return Dn(i)&&o({t:i}),e(function(){Dn(i)&&o({t:i})})},[e]),n}function Dn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function bo(e){e()}function vo(e){return e}function wo(){return[!1,bo]}var ko=at;function Jn(e,t){this.props=e,this.context=t}function os(e,t){function n(i){var o=this.props.ref,a=o==i.ref;return!a&&o&&(o.call?o(null):o.current=null),t?!t(this.props,i)||!a:Yn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,G(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Jn.prototype=new Ne).isPureReactComponent=!0,Jn.prototype.shouldComponentUpdate=function(e,t){return Yn(this.props,e)||Yn(this.state,t)};var oi=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),oi&&oi(e)};var as=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ss(e){function t(n){var r=_o({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=as,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ai=function(e,t){return e==null?null:Re(Re(e).map(t))},ls={map:ai,forEach:ai,count:function(e){return e?Re(e).length:0},only:function(e){var t=Re(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Re},us=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,o=t;o=o.__;)if((i=o.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}us(e,t,n,r)};var si=O.unmount;function So(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=_o({},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 So(r,t,n)})),e}function xo(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return xo(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 nn(){this.__u=0,this.o=null,this.__b=null}function Co(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function cs(e){var t,n,r,i=null;function o(a){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?G(i,a):null}return o.displayName=\"Lazy\",o.__f=!0,o}function Ct(){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),si&&si(e)},(nn.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Co(r.__v),o=!1,a=function(){o||r.__z||(o=!0,n.__R=null,i?i(u):u())};n.__R=a;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]=xo(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(a,a)},nn.prototype.componentWillUnmount=function(){this.o=[]},nn.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]=So(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&G(Y,null,e.fallback);return i&&(i.__u&=-33),[G(Y,null,t.__a?null:e.children),i]};var li=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function fs(e){return this.getChildContext=function(){return e.context},e.children}function ds(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){xe(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,o){this.childNodes.push(i),t.h.insertBefore(i,o)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}xe(G(fs,{context:t.context},e.__v),t.v)}function hs(e,t){var n=G(ds,{__v:e,h:t});return n.containerInfo=t,n}(Ct.prototype=new Ne).__a=function(e){var t=this,n=Co(t.__v),r=t.l.get(e);return r[0]++,function(i){var o=function(){t.props.revealOrder?(r.push(i),li(t,e,r)):i()};n?n(o):o()}},Ct.prototype.render=function(e){this.i=null,this.l=new Map;var t=Re(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Ct.prototype.componentDidUpdate=Ct.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){li(e,n,t)})};var Io=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ps=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,gs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ms=/[A-Z0-9]/g,_s=typeof document<\"u\",ys=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function bs(e,t,n){return t.__k==null&&(t.textContent=\"\"),xe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function vs(e,t,n){return co(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ne.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ne.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ui=O.event;function ws(){}function ks(){return this.cancelBubble}function Ss(){return this.defaultPrevented}O.event=function(e){return ui&&(e=ui(e)),e.persist=ws,e.isPropagationStopped=ks,e.isDefaultPrevented=Ss,e.nativeEvent=e};var Sr,xs={enumerable:!1,configurable:!0,get:function(){return this.class}},ci=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},o=r.indexOf(\"-\")===-1;for(var a in n){var s=n[a];if(!(a===\"value\"&&\"defaultValue\"in n&&s==null||_s&&a===\"children\"&&r===\"noscript\"||a===\"class\"||a===\"className\")){var u=a.toLowerCase();a===\"defaultValue\"&&\"value\"in n&&n.value==null?a=\"value\":a===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?a=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ys(n.type)?u===\"onfocus\"?a=\"onfocusin\":u===\"onblur\"?a=\"onfocusout\":gs.test(a)&&(a=u):u=a=\"oninput\":o&&ps.test(a)?a=a.replace(ms,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[a=u]&&(a=\"oninputCapture\"),i[a]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",xs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Io,ci&&ci(e)};var fi=O.__r;O.__r=function(e){fi&&fi(e),Sr=e.__c};var di=O.diffed;O.diffed=function(e){di&&di(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),Sr=null};var Cs={ReactCurrentDispatcher:{current:{readContext:function(e){return Sr.__n[e.__c].props.value},useCallback:he,useContext:K,useDebugValue:po,useDeferredValue:vo,useEffect:we,useId:go,useImperativeHandle:ho,useInsertionEffect:ko,useLayoutEffect:at,useMemo:de,useReducer:wr,useRef:ae,useState:X,useSyncExternalStore:yo,useTransition:wo}}};function Is(e){return G.bind(null,e)}function wn(e){return!!e&&e.$$typeof===Io}function Es(e){return wn(e)&&e.type===Y}function As(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ps(e){return wn(e)?es.apply(null,arguments):e}function Ts(e){return!!e.__k&&(xe(null,e),!0)}function Ns(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ds=function(e,t){return e(t)},$s=function(e,t){return e(t)},zs=Y,Fs=wn,Kt={useState:X,useId:go,useReducer:wr,useEffect:we,useLayoutEffect:at,useInsertionEffect:ko,useTransition:wo,useDeferredValue:vo,useSyncExternalStore:yo,startTransition:bo,useRef:ae,useImperativeHandle:ho,useMemo:de,useCallback:he,useContext:K,useDebugValue:po,version:\"18.3.1\",Children:ls,render:bs,hydrate:vs,unmountComponentAtNode:Ts,createPortal:hs,createElement:G,createContext:ot,createFactory:Is,cloneElement:Ps,createRef:Ga,Fragment:Y,isValidElement:wn,isElement:Fs,isFragment:Es,isMemo:As,findDOMNode:Ns,Component:Ne,PureComponent:Jn,memo:os,forwardRef:ss,flushSync:$s,unstable_batchedUpdates:Ds,StrictMode:zs,Suspense:nn,SuspenseList:Ct,lazy:cs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Cs};const Rs=e=>e;function Os(e,t=Rs){const n=Kt.useSyncExternalStore(e.subscribe,Kt.useCallback(()=>t(e.getState()),[e,t]),Kt.useCallback(()=>t(e.getInitialState()),[e,t]));return Kt.useDebugValue(n),n}const Ms=e=>{const t=is(e),n=r=>Os(t,r);return Object.assign(n,t),n},Ls=(e=>Ms);var xr=Symbol.for(\"immer-nothing\"),At=Symbol.for(\"immer-draftable\"),te=Symbol.for(\"immer-state\");function oe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ge=Object,tt=ge.getPrototypeOf,Dt=\"constructor\",Bt=\"prototype\",Zn=\"configurable\",fn=\"enumerable\",rn=\"writable\",$t=\"value\",Me=e=>!!e&&!!e[te];function De(e){return e?Eo(e)||qt(e)||!!e[At]||!!e[Dt]?.[At]||Ut(e)||jt(e):!1}var Vs=ge[Bt][Dt].toString(),hi=new WeakMap;function Eo(e){if(!e||!gt(e))return!1;const t=tt(e);if(t===null||t===ge[Bt])return!0;const n=ge.hasOwnProperty.call(t,Dt)&&t[Dt];if(n===Object)return!0;if(!Ke(n))return!1;let r=hi.get(n);return r===void 0&&(r=Function.toString.call(n),hi.set(n,r)),r===Vs}function Ht(e,t,n=!0){nt(e)===0?(n?Reflect.ownKeys(e):ge.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function nt(e){const t=e[te];return t?t.type_:qt(e)?1:Ut(e)?2:jt(e)?3:0}var Pt=(e,t,n=nt(e))=>n===2?e.has(t):ge[Bt].hasOwnProperty.call(e,t),ze=(e,t,n=nt(e))=>n===2?e.get(t):e[t],dn=(e,t,n,r=nt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Bs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var qt=Array.isArray,Ut=e=>e instanceof Map,jt=e=>e instanceof Set,gt=e=>typeof e==\"object\",Ke=e=>typeof e==\"function\",$n=e=>typeof e==\"boolean\";function Hs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var qs=e=>gt(e)?e?.[te]:null,Fe=e=>e.copy_||e.base_,Cr=e=>e.modified_?e.copy_:e.base_;function Xn(e,t){if(Ut(e))return new Map(e);if(jt(e))return new Set(e);if(qt(e))return Array[Bt].slice.call(e);const n=Eo(e);if(t===!0||t===\"class_only\"&&!n){const r=ge.getOwnPropertyDescriptors(e);delete r[te];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const a=i[o],s=r[a];s[rn]===!1&&(s[rn]=!0,s[Zn]=!0),(s.get||s.set)&&(r[a]={[Zn]:!0,[rn]:!0,[fn]:s[fn],[$t]:e[a]})}return ge.create(tt(e),r)}else{const r=tt(e);if(r!==null&&n)return{...e};const i=ge.create(r);return ge.assign(i,e)}}function Ir(e,t=!1){return kn(e)||Me(e)||!De(e)||(nt(e)>1&&ge.defineProperties(e,{set:Yt,add:Yt,clear:Yt,delete:Yt}),ge.freeze(e),t&&Ht(e,(n,r)=>{Ir(r,!0)},!1)),e}function Us(){oe(2)}var Yt={[$t]:Us};function kn(e){return e===null||!gt(e)?!0:ge.isFrozen(e)}var hn=\"MapSet\",pn=\"Patches\",pi=\"ArrayMethods\",gn={};function rt(e){const t=gn[e];return t||oe(0,e),t}var gi=e=>!!gn[e];function js(e,t){gn[e]||(gn[e]=t)}var zt,Ao=()=>zt,Ws=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:gi(hn)?rt(hn):void 0,arrayMethodsPlugin_:gi(pi)?rt(pi):void 0});function mi(e,t){t&&(e.patchPlugin_=rt(pn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function er(e){tr(e),e.drafts_.forEach(Qs),e.drafts_=null}function tr(e){e===zt&&(zt=e.parent_)}var _i=e=>zt=Ws(zt,e);function Qs(e){const t=e[te];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function yi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[te].modified_&&(er(t),oe(4)),De(e)&&(e=bi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[te].base_,e,t)}else e=bi(t,n);return Gs(t,e,!0),er(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==xr?e:void 0}function bi(e,t){if(kn(t))return t;const n=t[te];if(!n)return mn(t,e.handledSet_,e);if(!Sn(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);No(n,e)}return n.copy_}function Gs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ir(t,n)}function Po(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Sn=(e,t)=>e.scope_===t,Ks=[];function To(e,t,n,r){const i=Fe(e),o=e.type_;if(r!==void 0&&ze(i,r,o)===t){dn(i,r,n,o);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Ht(i,(u,l)=>{if(Me(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const a=e.draftLocations_.get(t)??Ks;for(const s of a)dn(i,s,n,o)}function Ys(e,t,n){e.callbacks_.push(function(i){const o=t;if(!o||!Sn(o,i))return;i.mapSetPlugin_?.fixSetContents(o);const a=Cr(o);To(e,o.draft_??o,a,n),No(o,i)})}function No(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)}Po(e)}}function Js(e,t,n){const{scope_:r}=e;if(Me(n)){const i=n[te];Sn(i,r)&&i.callbacks_.push(function(){on(e);const a=Cr(i);To(e,n,a,t)})}else De(n)&&e.callbacks_.push(function(){const o=Fe(e);e.type_===3?o.has(n)&&mn(n,r.handledSet_,r):ze(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&mn(ze(e.copy_,t,e.type_),r.handledSet_,r)})}function mn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Me(e)||t.has(e)||!De(e)||kn(e)||(t.add(e),Ht(e,(r,i)=>{if(Me(i)){const o=i[te];if(Sn(o,n)){const a=Cr(o);dn(e,r,a,e.type_),Po(o)}}else De(i)&&mn(i,t,n)})),e}function Zs(e,t){const n=qt(e),r={type_:n?1:0,scope_:t?t.scope_:Ao(),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,o=_n;n&&(i=[r],o=Ft);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return r.draft_=s,r.revoke_=a,[s,r]}var _n={get(e,t){if(t===te)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Fe(e);if(!Pt(i,t,e.type_))return Xs(e,i,t);const o=i[t];if(e.finalized_||!De(o)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Hs(t))return o;if(o===zn(e.base_,t)){on(e);const a=e.type_===1?+t:t,s=rr(e.scope_,o,e,a);return e.copy_[a]=s}return o},has(e,t){return t in Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=Do(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=zn(Fe(e),t),o=i?.[te];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Bs(n,i)&&(n!==void 0||Pt(e.base_,t,e.type_)))return!0;on(e),nr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Js(e,t,n)),!0},deleteProperty(e,t){return on(e),zn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),nr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[rn]:!0,[Zn]:e.type_!==1||t!==\"length\",[fn]:r[fn],[$t]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return tt(e.base_)},setPrototypeOf(){oe(12)}},Ft={};for(let e in _n){let t=_n[e];Ft[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Ft.deleteProperty=function(e,t){return Ft.set.call(this,e,t,void 0)};Ft.set=function(e,t,n){return _n.set.call(this,e[0],t,n,e[0])};function zn(e,t){const n=e[te];return(n?Fe(n):e)[t]}function Xs(e,t,n){const r=Do(t,n);return r?$t in r?r[$t]:r.get?.call(e.draft_):void 0}function Do(e,t){if(!(t in e))return;let n=tt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tt(n)}}function nr(e){e.modified_||(e.modified_=!0,e.parent_&&nr(e.parent_))}function on(e){e.copy_||(e.assigned_=new Map,e.copy_=Xn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var el=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ke(t)&&!Ke(n)){const o=n;n=t;const a=this;return function(u=o,...l){return a.produce(u,d=>n.call(this,d,...l))}}Ke(n)||oe(6),r!==void 0&&!Ke(r)&&oe(7);let i;if(De(t)){const o=_i(this),a=rr(o,t,void 0);let s=!0;try{i=n(a),s=!1}finally{s?er(o):tr(o)}return mi(o,r),yi(i,o)}else if(!t||!gt(t)){if(i=n(t),i===void 0&&(i=t),i===xr&&(i=void 0),this.autoFreeze_&&Ir(i,!0),r){const o=[],a=[];rt(pn).generateReplacementPatches_(t,i,{patches_:o,inversePatches_:a}),r(o,a)}return i}else oe(1,t)},this.produceWithPatches=(t,n)=>{if(Ke(t))return(a,...s)=>this.produceWithPatches(a,u=>t(u,...s));let r,i;return[this.produce(t,n,(a,s)=>{r=a,i=s}),r,i]},$n(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),$n(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),$n(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){De(e)||oe(8),Me(e)&&(e=tl(e));const t=_i(this),n=rr(t,e,void 0);return n[te].isManual_=!0,tr(t),n}finishDraft(e,t){const n=e&&e[te];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return mi(r,t),yi(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=rt(pn).applyPatches_;return Me(e)?r(e,t):this.produce(e,i=>r(i,t))}};function rr(e,t,n,r){const[i,o]=Ut(t)?rt(hn).proxyMap_(t,n):jt(t)?rt(hn).proxySet_(t,n):Zs(t,n);return(n?.scope_??Ao()).drafts_.push(i),o.callbacks_=n?.callbacks_??[],o.key_=r,n&&r!==void 0?Ys(n,o,r):o.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:l}=u;o.modified_&&l&&l.generatePatches_(o,[],u)}),i}function tl(e){return Me(e)||oe(10,e),$o(e)}function $o(e){if(!De(e)||kn(e))return e;const t=e[te];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Xn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Xn(e,!0);return Ht(n,(i,o)=>{dn(n,i,$o(o))},r),t&&(t.finalized_=!1),n}function nl(){function t(p,w=[]){if(p.key_!==void 0){const S=p.parent_.copy_??p.parent_.base_,y=qs(ze(S,p.key_)),k=ze(S,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||y!=null&&y.base_!==p.base_)return null;const x=p.parent_.type_===3;let A;if(x){const C=p.parent_;A=Array.from(C.drafts_.keys()).indexOf(p.key_)}else A=p.key_;if(!(x&&S.size>A||Pt(S,A)))return null;w.push(A)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let S=p;for(let y=0;y<w.length-1;y++){const k=w[y];if(S=ze(S,k),!gt(S)||S===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return S}const r=\"replace\",i=\"add\",o=\"remove\";function a(p,w,S){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:y,inversePatches_:k}=S;switch(p.type_){case 0:case 2:return u(p,w,y,k);case 1:return s(p,w,y,k);case 3:return l(p,w,y,k)}}function s(p,w,S,y){let{base_:k,assigned_:x}=p,A=p.copy_;A.length<k.length&&([k,A]=[A,k],[S,y]=[y,S]);const C=p.allIndicesReassigned_===!0;for(let _=0;_<k.length;_++){const P=A[_],T=k[_];if((C||x?.get(_.toString()))&&P!==T){const b=P?.[te];if(b&&b.modified_)continue;const N=w.concat([_]);S.push({op:r,path:N,value:c(P)}),y.push({op:r,path:N,value:c(T)})}}for(let _=k.length;_<A.length;_++){const P=w.concat([_]);S.push({op:i,path:P,value:c(A[_])})}for(let _=A.length-1;k.length<=_;--_){const P=w.concat([_]);y.push({op:o,path:P})}}function u(p,w,S,y){const{base_:k,copy_:x,type_:A}=p;Ht(p.assigned_,(C,_)=>{const P=ze(k,C,A),T=ze(x,C,A),z=_?Pt(k,C)?r:i:o;if(P===T&&z===r)return;const b=w.concat(C);S.push(z===o?{op:z,path:b}:{op:z,path:b,value:c(T)}),y.push(z===i?{op:o,path:b}:z===o?{op:i,path:b,value:c(P)}:{op:r,path:b,value:c(P)})})}function l(p,w,S,y){let{base_:k,copy_:x}=p,A=0;k.forEach(C=>{if(!x.has(C)){const _=w.concat([A]);S.push({op:o,path:_,value:C}),y.unshift({op:i,path:_,value:C})}A++}),A=0,x.forEach(C=>{if(!k.has(C)){const _=w.concat([A]);S.push({op:i,path:_,value:C}),y.unshift({op:o,path:_,value:C})}A++})}function d(p,w,S){const{patches_:y,inversePatches_:k}=S;y.push({op:r,path:[],value:w===xr?void 0:w}),k.push({op:r,path:[],value:p})}function f(p,w){return w.forEach(S=>{const{path:y,op:k}=S;let x=p;for(let P=0;P<y.length-1;P++){const T=nt(x);let z=y[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===Dt)&&oe(19),Ke(x)&&z===Bt&&oe(19),x=ze(x,z),gt(x)||oe(18,y.join(\"/\"))}const A=nt(x),C=h(S.value),_=y[y.length-1];switch(k){case r:switch(A){case 2:return x.set(_,C);case 3:oe(16);default:return x[_]=C}case i:switch(A){case 1:return _===\"-\"?x.push(C):x.splice(_,0,C);case 2:return x.set(_,C);case 3:return x.add(C);default:return x[_]=C}case o:switch(A){case 1:return x.splice(_,1);case 2:return x.delete(_);case 3:return x.delete(S.value);default:return delete x[_]}default:oe(17,k)}}),p}function h(p){if(!De(p))return p;if(qt(p))return p.map(h);if(Ut(p))return new Map(Array.from(p.entries()).map(([S,y])=>[S,h(y)]));if(jt(p))return new Set(Array.from(p).map(h));const w=Object.create(tt(p));for(const S in p)w[S]=h(p[S]);return Pt(p,At)&&(w[At]=p[At]),w}function c(p){return Me(p)?h(p):p}js(pn,{applyPatches_:f,generatePatches_:a,generateReplacementPatches_:d,getPath:t})}var Rt=new el,rl=Rt.produce,il=Rt.produceWithPatches.bind(Rt),dt=Rt.applyPatches.bind(Rt);const ol=e=>(t,n,r)=>(r.setState=(i,o,...a)=>{const s=typeof i==\"function\"?rl(i):i;return t(s,o,...a)},e(r.setState,n,r)),al=ol,sl=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),ll=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function ul(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function vi(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 wi(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const o=e[i];i++;let a=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))a+=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++,a+=e.slice(s,i);else{i=s;break}}else break;a&&(o===\".\"?n.push(a):r=a)}return{className:n.join(\" \"),id:r,endIdx:i}}function cl(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const o=e[t];t++;const a=t;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===o&&s<=0)break;t++}n[i]=e.slice(a,t),t<e.length&&t++}else{const o=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(o,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function yt(e){const t=[];let n=0,r=0;function i(o){o>r&&t.push({type:\"text\",value:e.slice(r,o),start:r,end:o})}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 o=n;n+=2;let a,s;if(e[n]===\".\"||e[n]===\"#\"){const p=wi(e,n);a=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=o+2,r=o;continue}const d=e.slice(l,n);n+=2;const{display:f,target:h}=ul(d),c={type:\"link\",display:f,target:h,start:o,end:n};a&&(c.className=a),s&&(c.id=s),t.push(c),r=n;continue}if(e[n]===\"{\"){const o=n;let a=e[n+1],s,u;if(a===\".\"||a===\"#\"){i(n);const l=wi(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const f=e[d];if(f===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"variable\",start:o,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=o+1,r=o;continue}if(f===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"temporary\",start:o,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=o+1,r=o;continue}if(f===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"local\",start:o,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=o+1,r=o;continue}if(f!==void 0&&/[a-zA-Z]/.test(f)){n=d;let h=1;const c=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=o+1,r=o;continue}const p=e.slice(c,n);n++;const{name:w,rawArgs:S,isClose:y}=vi(p),k={type:\"macro\",name:w,rawArgs:S,isClose:y,start:o,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),r=n;continue}n=o+1,r=o;continue}if(a===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"variable\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"temporary\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"local\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a!==void 0&&(a===\"/\"||/[a-zA-Z]/.test(a))){i(n),n++;let l=1;const d=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=o+1,r=o;continue}const f=e.slice(d,n);n++;const{name:h,rawArgs:c,isClose:p}=vi(f);t.push({type:\"macro\",name:h,rawArgs:c,isClose:p,start:o,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const o=n;let a=n+1;const s=e[a]===\"/\";s&&a++;const u=a;for(;a<e.length&&/[a-zA-Z0-9]/.test(e[a]);)a++;const l=e.slice(u,a).toLowerCase();if(l&&sl.has(l))if(s){for(;a<e.length&&/\\s/.test(e[a]);)a++;if(e[a]===\">\"){a++,i(o),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:o,end:a}),r=a,n=a;continue}}else{const d=cl(e,a);a=d.endIdx;let f=ll.has(l);if(e[a]===\"/\"&&(f=!0,a++),e[a]===\">\"){a++,i(o),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:f,start:o,end:a}),r=a,n=a;continue}}n++;continue}n++}return i(e.length),t}const zo=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function ir(e){zo.add(e.toLowerCase())}const ki={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},fl=new Set([\"if\",\"switch\",\"timed\"]);function bt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const a={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"variable\":{const o={type:\"variable\",name:i.name,scope:i.scope};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);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 a=n[n.length-1];if(a.node.type!==\"html\"||a.node.tag!==i.tag){const s=a.node.type===\"html\"?`</${a.node.tag}>`:`{/${a.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(a.node);break}const o={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:o,start:i.start});break}case\"macro\":{const o=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==o){const s=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(ki[o]){const a=ki[o],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==a)throw new Error(`{${i.name}} without matching {${a}} (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(zo.has(o)){const a={type:\"macro\",name:o,rawArgs:i.rawArgs,children:[]};if(fl.has(o)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),a.branches=[s]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:o,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const o=i;throw new Error(`Unknown token type: ${o.type}`)}}if(n.length>0){const i=n[n.length-1],o=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${o} (opened at character ${i.start})`)}return t}function Er(){const e=I(r=>r.variables),t=I(r=>r.temporary),n=K(Ce);return de(()=>[e,t,n],[e,t,n])}const dl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,hl=/\\{[\\$_@][\\w.]+\\}/;function pl(e){return hl.test(e)}function gl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function ml(e,t,n,r){return e.replace(dl,(i,o)=>{const a=o[0],u=o.slice(1).split(\".\"),l=u[0];let d;return a===\"$\"?d=t[l]:a===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=gl(d,u)),d==null?\"\":String(d)})}function Ar(){const[e,t,n]=Er();return he(r=>r===void 0||!pl(r)?r:ml(r,e,t,n),[e,t,n])}function _l({name:e,scope:t,className:n,id:r}){const i=Ar();n=i(n),r=i(r);const o=K(Ce),a=e.split(\".\"),s=a[0],u=I(f=>t===\"variable\"?f.variables[s]:t===\"temporary\"?f.temporary[s]:void 0);let l;t===\"local\"?l=s in o?o[s]:void 0:l=u;for(let f=1;f<a.length;f++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=a[f];l=l[h]}const d=l==null?\"\":String(l);return n||r?v(\"span\",{id:r,class:n,children:d}):v(Y,{children:d})}function Fo(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 Ro(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let vt=!1,Wt=\"\",it=0,mt=null;function yl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Wt=n,it=0,mt=Fo(Ro(n)),vt=!0}function Oo(e,t){Wt=e,it=0,mt=Fo(Ro(e)),vt=!0;for(let n=0;n<t;n++)mt();it=t}function or(){vt=!1,Wt=\"\",it=0,mt=null}function yn(){return vt?{seed:Wt,pull:it}:null}function Pr(){return!vt||!mt?Math.random():(it++,mt())}function Mo(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Pr()*(t-e+1))+e}function bl(){return vt}function vl(){return Wt}function wl(){return it}const kl=500,Qe=new Map,Sl=/\\$(\\w+)/g,xl=/(?<![.\\w])_(\\w+)/g,Cl=/@(\\w+)/g;function Il(e){return e.replace(Sl,'variables[\"$1\"]').replace(xl,'temporary[\"$1\"]').replace(Cl,'locals[\"$1\"]')}function Tr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Il(n),n=\"\")}for(;r<e.length;){const o=e.charAt(r);if(o==='\"'||o===\"'\"){i();const a=o;let s=a;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===a){s+=a,r++;break}else s+=u,r++}t+=s;continue}if(o===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const a=e.charAt(r);if(a===\"\\\\\"&&r+1<e.length)t+=a+e.charAt(r+1),r+=2;else if(a===\"$\"&&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 if(l===\"\\\\\"&&r+1<e.length)u+=l+e.charAt(r+1),r++;else if(l==='\"'||l===\"'\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===l){u+=d,r++;break}else u+=d,r++}continue}else if(l===\"`\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===\"$\"&&e.charAt(r+1)===\"{\"){u+=\"${\",r+=2;let f=1;for(;r<e.length&&f>0;){const h=e.charAt(r);h===\"{\"?f++:h===\"}\"&&f--,f>0&&(u+=h),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Tr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(a===\"`\"){t+=\"`\",r++;break}else t+=a,r++}continue}n+=o,r++}return i(),t}const El=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Lo(e,t){const n=Qe.get(e);if(n)return Qe.delete(e),Qe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",El+t);if(Qe.set(e,r),Qe.size>kl){const i=Qe.keys().next().value;i!==void 0&&Qe.delete(i)}return r}let Jt=null,Si=null,xi=null;function Vo(){const e=I.getState(),{visitCounts:t,renderCounts:n}=e;if(Jt&&Si===t&&xi===n)return Jt;const r=c=>t[c??I.getState().currentPassage]??0,i=c=>r(c)>0,o=(...c)=>c.some(p=>r(p)>0),a=(...c)=>c.every(p=>r(p)>0),s=c=>n[c??I.getState().currentPassage]??0;return Jt={currentPassage:()=>{const c=I.getState();return c.storyData?.passages.get(c.currentPassage)},previousPassage:()=>{const c=I.getState();if(c.historyIndex<=0)return;const p=c.history[c.historyIndex-1]?.passage;return p?c.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:o,hasVisitedAll:a,rendered:s,hasRendered:c=>s(c)>0,hasRenderedAny:(...c)=>c.some(p=>s(p)>0),hasRenderedAll:(...c)=>c.every(p=>s(p)>0),random:Pr,randomInt:Mo},Si=t,xi=n,Jt}function xn(e,t,n,r={}){const o=`return (${Tr(e)});`;return Lo(o,o)(t,n,r,Vo())}function Bo(e,t,n,r={}){const i=Tr(e);Lo(\"exec:\"+i,i)(t,n,r,Vo())}function Al(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const s=e[a];if(i){n+=s,s===i&&e[a-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 o=n.trim();return o&&t.push(o),t}function Pl({body:e,parentValues:t,ownKeys:n}){const r=K(ce),[i,o]=X({}),a={...t,...n,...i},s=ae(a);s.current=a;const u=he(()=>s.current,[]),l=he((f,h)=>{o(c=>({...c,[f]:h}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]);return v(Qt.Provider,{value:d,children:v(Ce.Provider,{value:a,children:Ie(e,{nobr:r,locals:a})})})}function Tl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=K(Ce),o=K(ce),[a,s,u]=Er(),l=r?.length?r:null;if(t.length===0||!n)return v(cr.Provider,{value:l,children:Ie(e,{nobr:o,locals:i})});const d=Al(n),f={};for(let h=0;h<t.length;h++){const c=t[h],p=d[h];let w;if(p!==void 0)try{w=xn(p,a,s,u)}catch{w=void 0}f[c.startsWith(\"@\")?c.slice(1):c]=w}return v(cr.Provider,{value:l,children:v(Pl,{body:e,parentValues:i,ownKeys:f})})}const Ho=new Map;function qo(e,t,n,r=!1){const i=n.filter(o=>o!==\"@children\");Ho.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Nl(e){return Ho.get(e.toLowerCase())}const Uo=new Map;function Dl(e,t){Uo.set(e.toLowerCase(),t)}function $l(e){return Uo.get(e.toLowerCase())}const jo=new Set;function zl(e){jo.add(e.toLowerCase())}function Fl(e){return jo.has(e.toLowerCase())}const Ci=document.createElement(\"i\");function Wo(e){const t=\"&\"+e+\";\";Ci.innerHTML=t;const n=Ci.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function _e(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function ie(e,t){return e.length>0?(_e(e,e.length,0,t),e):t}const ar={}.hasOwnProperty;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=(ar.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){ar.call(i,a)||(i[a]=[]);const s=o[a];Ml(i[a],Array.isArray(s)?s:s?[s]:[])}}}function Ml(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);_e(e,0,0,r)}function Ll(e){const t={};let n=-1;for(;++n<e.length;)Vl(t,e[n]);return t}function Vl(e,t){let n;for(n in t){const i=(ar.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o)i[a]=o[a]}}function Bl(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 Hl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Qo(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Hl[n]+\";\"}}function Ot(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Pe=qe(/[A-Za-z]/),me=qe(/[\\dA-Za-z]/),ql=qe(/[#-'*+\\--9=?A-Z^-~]/);function sr(e){return e!==null&&(e<32||e===127)}const lr=qe(/\\d/),Ul=qe(/[\\dA-Fa-f]/),jl=qe(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Wl=qe(/\\p{P}|\\p{S}/u),Ql=qe(/\\s/);function qe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Zt(e,t){const n=Qo(Gl(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),o=n.indexOf(\"#\"),a=n.indexOf(\"/\");return r<0||a>-1&&r>a||i>-1&&r>i||o>-1&&r>o||t.test(n.slice(0,r))?n:\"\"}function Gl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a=\"\";if(o===37&&me(e.charCodeAt(n+1))&&me(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const s=e.charCodeAt(n+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a=\"�\"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const Ii={}.hasOwnProperty,Ei=/^(https?|ircs?|mailto|xmpp)$/i,Kl=/^https?$/i;function Yl(e){const t=e||{};let n=!0;const r={},i=[[]],o=[],a=[],u=Ll([{enter:{blockQuote:M,codeFenced:ke,codeFencedFenceInfo:S,codeFencedFenceMeta:S,codeIndented:j,codeText:La,content:Ea,definition:wa,definitionDestinationString:Sa,definitionLabelString:S,definitionTitleString:S,emphasis:Oa,htmlFlow:Ra,htmlText:Hr,image:q,label:S,link:le,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:J,reference:S,resource:ut,resourceDestinationString:ct,resourceTitleString:S,setextHeading:Pa,strong:Ma},exit:{atxHeading:Na,atxHeadingSequence:Aa,autolinkEmail:Wa,autolinkProtocol:ja,blockQuote:Z,characterEscapeValue:kt,characterReferenceMarkerHexadecimal:qr,characterReferenceMarkerNumeric:qr,characterReferenceValue:Ua,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Fa,codeIndented:g,codeText:Va,codeTextData:kt,data:kt,definition:Ia,definitionDestinationString:xa,definitionLabelString:ka,definitionTitleString:Ca,emphasis:Ba,hardBreakEscape:Vr,hardBreakTrailing:Vr,htmlFlow:Br,htmlFlowData:kt,htmlText:Br,htmlTextData:kt,image:Lr,label:wt,labelText:ee,lineEnding:za,link:Lr,listOrdered:$,listUnordered:B,paragraph:pe,reference:P,referenceString:Le,resource:P,resourceDestinationString:Tn,resourceTitleString:va,setextHeading:$a,setextHeadingLineSequence:Da,setextHeadingText:Ta,strong:Ha,thematicBreak:qa}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:a},d={buffer:S,encode:_,getData:w,lineEndingIfNeeded:C,options:t,raw:x,resume:y,setData:p,tag:k};let f=t.defaultLineEnding;return h;function h(E){let F=-1,ne=0;const Se=[];let Ee=[],$e=[];for(;++F<E.length;)!f&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(f=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?Se.push(F):c(E.slice(Se.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?($e=ie($e,E.slice(ne,F)),ne=F):(Ee=ie(Ee,E.slice(ne,F+1)),ne=F+1));Ee=ie(Ee,$e),Ee=ie(Ee,E.slice(ne)),F=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const Ur=u[Ae[F][0]],jr=Ae[F][1].type,Wr=Ur[jr];Ii.call(Ur,jr)&&Wr&&Wr.call({sliceSerialize:Ae[F][2].sliceSerialize,...d},Ae[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function c(E){const F=E.length;let ne=0,Se=0,Ee=!1,$e;for(;++ne<F;){const Ae=E[ne];if(Ae[1]._container)$e=void 0,Ae[0]===\"enter\"?Se++:Se--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Se&&($e?$e=void 0:Ee=!0);break}default:$e=void 0}}E[0][1]._loose=Ee}function p(E,F){l[E]=F}function w(E){return l[E]}function S(){i.push([])}function y(){return i.pop().join(\"\")}function k(E){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(E))}function x(E){p(\"lastWasTag\"),i[i.length-1].push(E)}function A(){x(f||`\n`)}function C(){const E=i[i.length-1],F=E[E.length-1],ne=F?F.charCodeAt(F.length-1):null;ne===10||ne===13||ne===null||A()}function _(E){return w(\"ignoreEncode\")?E:Qo(E)}function P(){y()}function T(E){a.push(!E._loose),C(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){a.push(!E._loose),C(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function b(E){if(w(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&k(' start=\"'+_(String(F))+'\"')}}function N(){w(\"expectFirstItem\")?k(\">\"):U(),C(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),a.pop(),A(),k(\"</ol>\")}function B(){U(),a.pop(),A(),k(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&C(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){a.push(!1),C(),k(\"<blockquote>\")}function Z(){a.pop(),C(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function J(){a[a.length-1]||(C(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function pe(){a[a.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function ke(){C(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=y();k(' class=\"language-'+E+'\"')}function D(){const E=w(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){C(),k(\"<pre><code>\")}function g(){const E=w(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&A(),w(\"flowCodeSeenData\")&&C(),k(\"</code></pre>\"),E!==void 0&&E<2&&C(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){o.push({image:!0}),n=void 0}function le(){o.push({})}function ee(E){o[o.length-1].labelId=this.sliceSerialize(E)}function wt(){o[o.length-1].label=y()}function Le(E){o[o.length-1].referenceId=this.sliceSerialize(E)}function ut(){S(),o[o.length-1].destination=\"\"}function ct(){S(),p(\"ignoreEncode\",!0)}function Tn(){o[o.length-1].destination=y(),p(\"ignoreEncode\")}function va(){o[o.length-1].title=y()}function Lr(){let E=o.length-1;const F=o[E],ne=F.referenceId||F.labelId,Se=F.destination===void 0?r[Ot(ne)]:F;for(n=!0;E--;)if(o[E].image){n=void 0;break}F.image?(k('<img src=\"'+Zt(Se.destination,t.allowDangerousProtocol?void 0:Kl)+'\" alt=\"'),x(F.label),k('\"')):k('<a href=\"'+Zt(Se.destination,t.allowDangerousProtocol?void 0:Ei)+'\"'),k(Se.title?' title=\"'+Se.title+'\"':\"\"),F.image?k(\" />\"):(k(\">\"),x(F.label),k(\"</a>\")),o.pop()}function wa(){S(),o.push({})}function ka(E){y(),o[o.length-1].labelId=this.sliceSerialize(E)}function Sa(){S(),p(\"ignoreEncode\",!0)}function xa(){o[o.length-1].destination=y(),p(\"ignoreEncode\")}function Ca(){o[o.length-1].title=y()}function Ia(){const E=o[o.length-1],F=Ot(E.labelId);y(),Ii.call(r,F)||(r[F]=o[o.length-1]),o.pop()}function Ea(){p(\"slurpAllLineEndings\",!0)}function Aa(E){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),C(),k(\"<h\"+w(\"headingRank\")+\">\"))}function Pa(){S(),p(\"slurpAllLineEndings\")}function Ta(){p(\"slurpAllLineEndings\",!0)}function Na(){k(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function Da(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function $a(){const E=y();C(),k(\"<h\"+w(\"headingRank\")+\">\"),x(E),k(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function kt(E){x(_(this.sliceSerialize(E)))}function za(E){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){x(\" \");return}x(_(this.sliceSerialize(E)))}}function Fa(E){x(_(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Vr(){k(\"<br />\")}function Ra(){C(),Hr()}function Br(){p(\"ignoreEncode\")}function Hr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Oa(){k(\"<em>\")}function Ma(){k(\"<strong>\")}function La(){p(\"inCodeText\",!0),k(\"<code>\")}function Va(){p(\"inCodeText\"),k(\"</code>\")}function Ba(){k(\"</em>\")}function Ha(){k(\"</strong>\")}function qa(){C(),k(\"<hr />\")}function qr(E){p(\"characterReferenceType\",E.type)}function Ua(E){const F=this.sliceSerialize(E),ne=w(\"characterReferenceType\")?Bl(F,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Wo(F);x(_(ne)),p(\"characterReferenceType\")}function ja(E){const F=this.sliceSerialize(E);k('<a href=\"'+Zt(F,t.allowDangerousProtocol?void 0:Ei)+'\">'),x(_(F)),k(\"</a>\")}function Wa(E){const F=this.sliceSerialize(E);k('<a href=\"'+Zt(\"mailto:\"+F)+'\">'),x(_(F)),k(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&o++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Jl={tokenize:Zl};function Zl(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\"),o(s)}function o(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,a(s)}function a(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),o):(e.consume(s),a)}}const Xl={tokenize:eu},Ai={tokenize:tu};function eu(e){const t=this,n=[];let r=0,i,o,a;return s;function s(x){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,l)(x)}return l(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let C=A,_;for(;C--;)if(t.events[C][0]===\"exit\"&&t.events[C][1].type===\"chunkFlow\"){_=t.events[C][1].end;break}y(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={..._},P++;return _e(t.events,C+1,0,t.events.slice(A)),t.events.length=P,l(x)}return s(x)}function l(x){if(r===n.length){if(!i)return h(x);if(i.currentConstruct&&i.currentConstruct.concrete)return p(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ai,d,f)(x)}function d(x){return i&&k(),y(r),h(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,p(x)}function h(x){return t.containerState={},e.attempt(Ai,c,p)(x)}function c(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function p(x){if(x===null){i&&k(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:o}),w(x)}function w(x){if(x===null){S(e.exit(\"chunkFlow\"),!0),y(0),e.consume(x);return}return R(x)?(e.consume(x),S(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),w)}function S(x,A){const C=t.sliceStream(x);if(A&&C.push(null),x.previous=o,o&&(o.next=x),o=x,i.defineSkip(x.start),i.write(C),t.parser.lazy[x.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<a&&(!i.events[_][1].end||i.events[_][1].end.offset>a))return;const P=t.events.length;let T=P,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(y(r),_=P;_<t.events.length;)t.events[_][1].end={...b},_++;_e(t.events,T+1,0,t.events.slice(P)),t.events.length=_}}function y(x){let A=n.length;for(;A-- >x;){const C=n[A];t.containerState=C[1],C[0].exit.call(t,e)}n.length=x}function k(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tu(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 bn(e){if(e===null||se(e)||Ql(e))return 1;if(Wl(e))return 2}function Cn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const ur={name:\"attention\",resolveAll:nu,tokenize:ru};function nu(e,t){let n=-1,r,i,o,a,s,u,l,d;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};Pi(f,-u),Pi(h,u),a={type:u>1?\"strongSequence\":\"emphasisSequence\",start:f,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},o={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ie(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ie(l,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"enter\",o,t]]),l=ie(l,Cn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ie(l,[[\"exit\",o,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=ie(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,_e(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function ru(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=bn(r);let o;return a;function a(u){return o=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===o)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),d=bn(u),f=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(o===42?f:f&&(i||!h)),l._close=!!(o===42?h:h&&(d||!f)),t(u)}}function Pi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const iu={name:\"autolink\",tokenize:ou};function ou(e,t,n){let r=0;return i;function i(c){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),o}function o(c){return Pe(c)?(e.consume(c),a):c===64?n(c):l(c)}function a(c){return c===43||c===45||c===46||me(c)?(r=1,s(c)):l(c)}function s(c){return c===58?(e.consume(c),r=0,u):(c===43||c===45||c===46||me(c))&&r++<32?(e.consume(c),s):(r=0,l(c))}function u(c){return c===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):c===null||c===32||c===60||sr(c)?n(c):(e.consume(c),u)}function l(c){return c===64?(e.consume(c),d):ql(c)?(e.consume(c),l):n(c)}function d(c){return me(c)?f(c):n(c)}function f(c){return c===46?(e.consume(c),r=0,d):c===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(c)}function h(c){if((c===45||me(c))&&r++<63){const p=c===45?h:f;return e.consume(c),p}return n(c)}}const In={partial:!0,tokenize:au};function au(e,t,n){return r;function r(o){return L(o)?H(e,i,\"linePrefix\")(o):i(o)}function i(o){return o===null||R(o)?t(o):n(o)}}const Go={continuation:{tokenize:lu},exit:uu,name:\"blockQuote\",tokenize:su};function su(e,t,n){const r=this;return i;function i(a){if(a===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(a),e.exit(\"blockQuoteMarker\"),o}return n(a)}function o(a){return L(a)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(a),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(a))}}function lu(e,t,n){const r=this;return i;function i(a){return L(a)?H(e,o,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(a):o(a)}function o(a){return e.attempt(Go,t,n)(a)}}function uu(e){e.exit(\"blockQuote\")}const Ko={name:\"characterEscape\",tokenize:cu};function cu(e,t,n){return r;function r(o){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(o),e.exit(\"escapeMarker\"),i}function i(o){return jl(o)?(e.enter(\"characterEscapeValue\"),e.consume(o),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(o)}}const Yo={name:\"characterReference\",tokenize:fu};function fu(e,t,n){const r=this;let i=0,o,a;return s;function s(f){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),u}function u(f){return f===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(f),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),o=31,a=me,d(f))}function l(f){return f===88||f===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(f),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),o=6,a=Ul,d):(e.enter(\"characterReferenceValue\"),o=7,a=lr,d(f))}function d(f){if(f===59&&i){const h=e.exit(\"characterReferenceValue\");return a===me&&!Wo(r.sliceSerialize(h))?n(f):(e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return a(f)&&i++<o?(e.consume(f),d):n(f)}}const Ti={partial:!0,tokenize:hu},Ni={concrete:!0,name:\"codeFenced\",tokenize:du};function du(e,t,n){const r=this,i={partial:!0,tokenize:C};let o=0,a=0,s;return u;function u(_){return l(_)}function l(_){const P=r.events[r.events.length-1];return o=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=_,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(_)}function d(_){return _===s?(a++,e.consume(_),d):a<3?n(_):(e.exit(\"codeFencedFenceSequence\"),L(_)?H(e,f,\"whitespace\")(_):f(_))}function f(_){return _===null||R(_)?(e.exit(\"codeFencedFence\"),r.interrupt?t(_):e.check(Ti,w,A)(_)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),f(_)):L(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,c,\"whitespace\")(_)):_===96&&_===s?n(_):(e.consume(_),h)}function c(_){return _===null||R(_)?f(_):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(_))}function p(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(_)):_===96&&_===s?n(_):(e.consume(_),p)}function w(_){return e.attempt(i,A,S)(_)}function S(_){return e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),y}function y(_){return o>0&&L(_)?H(e,k,\"linePrefix\",o+1)(_):k(_)}function k(_){return _===null||R(_)?e.check(Ti,w,A)(_):(e.enter(\"codeFlowValue\"),x(_))}function x(_){return _===null||R(_)?(e.exit(\"codeFlowValue\"),k(_)):(e.consume(_),x)}function A(_){return e.exit(\"codeFenced\"),t(_)}function C(_,P,T){let z=0;return b;function b(M){return _.enter(\"lineEnding\"),_.consume(M),_.exit(\"lineEnding\"),N}function N(M){return _.enter(\"codeFencedFence\"),L(M)?H(_,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(_.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,_.consume(M),B):z>=a?(_.exit(\"codeFencedFenceSequence\"),L(M)?H(_,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(_.exit(\"codeFencedFence\"),P(M)):T(M)}}}function hu(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Fn={name:\"codeIndented\",tokenize:gu},pu={partial:!0,tokenize:mu};function gu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,o,\"linePrefix\",5)(l)}function o(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?a(l):n(l)}function a(l){return l===null?u(l):R(l)?e.attempt(pu,a,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),a(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function mu(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):R(a)?(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),i):H(e,o,\"linePrefix\",5)(a)}function o(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):R(a)?i(a):n(a)}}const _u={name:\"codeText\",previous:bu,resolve:yu,tokenize:vu};function yu(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 bu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function vu(e,t,n){let r=0,i,o;return a;function a(f){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(f)}function s(f){return f===96?(e.consume(f),r++,s):(e.exit(\"codeTextSequence\"),u(f))}function u(f){return f===null?n(f):f===32?(e.enter(\"space\"),e.consume(f),e.exit(\"space\"),u):f===96?(o=e.enter(\"codeTextSequence\"),i=0,d(f)):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(f))}function l(f){return f===null||f===32||f===96||R(f)?(e.exit(\"codeTextData\"),u(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(f)):(o.type=\"codeTextData\",l(f))}}class wu{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 o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&St(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),St(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),St(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);St(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);St(this.left,n.reverse())}}}function St(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Jo(e){const t={};let n=-1,r,i,o,a,s,u,l;const d=new wu(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type===\"lineEndingBlank\"&&(o+=2),o<u.length&&u[o][1].type===\"content\"))for(;++o<u.length&&u[o][1].type!==\"content\";)u[o][1].type===\"chunkText\"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,ku(d,n)),n=t[n],l=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=d.get(o),a[1].type===\"lineEnding\"||a[1].type===\"lineEndingBlank\")a[0]===\"enter\"&&(i&&(d.get(i)[1].type=\"lineEndingBlank\"),a[1].type=\"lineEnding\",i=o);else if(!(a[1].type===\"linePrefix\"||a[1].type===\"listItemIndent\"))break;i&&(r[1].end={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return _e(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function ku(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const s=a.events,u=[],l={};let d,f,h=-1,c=n,p=0,w=0;const S=[w];for(;c;){for(;e.get(++i)[1]!==c;);o.push(i),c._tokenizer||(d=r.sliceStream(c),c.next||d.push(null),f&&a.defineSkip(c.start),c._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),c._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=c,c=c.next}for(c=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&&(w=h+1,S.push(w),c._tokenizer=void 0,c.previous=void 0,c=c.next);for(a.events=[],c?(c._tokenizer=void 0,c.previous=void 0):S.pop(),h=S.length;h--;){const y=s.slice(S[h],S[h+1]),k=o.pop();u.push([k,k+y.length-1]),e.splice(k,2,y)}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 Su={resolve:Cu,tokenize:Iu},xu={partial:!0,tokenize:Eu};function Cu(e){return Jo(e),e}function Iu(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?o(s):R(s)?e.check(xu,a,o)(s):(e.consume(s),i)}function o(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function a(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Eu(e,t,n){const r=this;return i;function i(a){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),H(e,o,\"linePrefix\")}function o(a){if(a===null||R(a))return n(a);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(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Zo(e,t,n,r,i,o,a,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),h):y===null||y===32||y===41||sr(y)?n(y):(e.enter(r),e.enter(a),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(y))}function h(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),c(y))}function c(y){return y===62?(e.exit(\"chunkString\"),e.exit(s),h(y)):y===null||y===60||R(y)?n(y):(e.consume(y),y===92?p:c)}function p(y){return y===60||y===62||y===92?(e.consume(y),c):c(y)}function w(y){return!d&&(y===null||y===41||se(y))?(e.exit(\"chunkString\"),e.exit(s),e.exit(a),e.exit(r),t(y)):d<l&&y===40?(e.consume(y),d++,w):y===41?(e.consume(y),d--,w):y===null||y===32||y===40||sr(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function Xo(e,t,n,r,i,o){const a=this;let s=0,u;return l;function l(c){return e.enter(r),e.enter(i),e.consume(c),e.exit(i),e.enter(o),d}function d(c){return s>999||c===null||c===91||c===93&&!u||c===94&&!s&&\"_hiddenFootnoteSupport\"in a.parser.constructs?n(c):c===93?(e.exit(o),e.enter(i),e.consume(c),e.exit(i),e.exit(r),t):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),f(c))}function f(c){return c===null||c===91||c===93||R(c)||s++>999?(e.exit(\"chunkString\"),d(c)):(e.consume(c),u||(u=!L(c)),c===92?h:f)}function h(c){return c===91||c===92||c===93?(e.consume(c),s++,f):f(c)}}function ea(e,t,n,r,i,o){let a;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,u):n(h)}function u(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(o),l(h))}function l(h){return h===a?(e.exit(o),u(a)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===a||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function Tt(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Au={name:\"definition\",tokenize:Tu},Pu={partial:!0,tokenize:Nu};function Tu(e,t,n){const r=this;let i;return o;function o(c){return e.enter(\"definition\"),a(c)}function a(c){return Xo.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(c)}function s(c){return i=Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),c===58?(e.enter(\"definitionMarker\"),e.consume(c),e.exit(\"definitionMarker\"),u):n(c)}function u(c){return se(c)?Tt(e,l)(c):l(c)}function l(c){return Zo(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(c)}function d(c){return e.attempt(Pu,f,f)(c)}function f(c){return L(c)?H(e,h,\"whitespace\")(c):h(c)}function h(c){return c===null||R(c)?(e.exit(\"definition\"),r.parser.defined.push(i),t(c)):n(c)}}function Nu(e,t,n){return r;function r(s){return se(s)?Tt(e,i)(s):n(s)}function i(s){return ea(e,o,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function o(s){return L(s)?H(e,a,\"whitespace\")(s):a(s)}function a(s){return s===null||R(s)?t(s):n(s)}}const Du={name:\"hardBreakEscape\",tokenize:$u};function $u(e,t,n){return r;function r(o){return e.enter(\"hardBreakEscape\"),e.consume(o),i}function i(o){return R(o)?(e.exit(\"hardBreakEscape\"),t(o)):n(o)}}const zu={name:\"headingAtx\",resolve:Fu,tokenize:Ru};function Fu(e,t){let n=e.length-2,r=3,i,o;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},o={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},_e(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]])),e}function Ru(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),o(d)}function o(d){return e.enter(\"atxHeadingSequence\"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||se(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||se(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Ou=[\"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\"],Di=[\"pre\",\"script\",\"style\",\"textarea\"],Mu={concrete:!0,name:\"htmlFlow\",resolveTo:Bu,tokenize:Hu},Lu={partial:!0,tokenize:Uu},Vu={partial:!0,tokenize:qu};function Bu(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 Hu(e,t,n){const r=this;let i,o,a,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),f}function f(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),o=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):Pe(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function h(g){return g===45?(e.consume(g),i=2,c):g===91?(e.consume(g),i=5,s=0,p):Pe(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function c(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:p):n(g)}function w(g){return Pe(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||se(g)){const q=g===47,le=a.toLowerCase();return!q&&!o&&Di.includes(le)?(i=1,r.interrupt?t(g):$(g)):Ou.includes(a.toLowerCase())?(i=6,q?(e.consume(g),y):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):o?k(g):x(g))}return g===45||me(g)?(e.consume(g),a+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function k(g){return L(g)?(e.consume(g),k):b(g)}function x(g){return g===47?(e.consume(g),b):g===58||g===95||Pe(g)?(e.consume(g),A):L(g)?(e.consume(g),x):b(g)}function A(g){return g===45||g===46||g===58||g===95||me(g)?(e.consume(g),A):C(g)}function C(g){return g===61?(e.consume(g),_):L(g)?(e.consume(g),C):x(g)}function _(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),_):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||se(g)?C(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?x(g):n(g)}function b(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),J):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ke):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Lu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Vu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function Z(g){return g===45?(e.consume(g),m):$(g)}function J(g){return g===47?(e.consume(g),a=\"\",pe):$(g)}function pe(g){if(g===62){const q=a.toLowerCase();return Di.includes(q)?(e.consume(g),D):$(g)}return Pe(g)&&a.length<8?(e.consume(g),a+=String.fromCharCode(g),pe):$(g)}function ke(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function qu(e,t,n){const r=this;return i;function i(a){return R(a)?(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Uu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(In,t,n)}}const ju={name:\"htmlText\",tokenize:Wu};function Wu(e,t,n){const r=this;let i,o,a;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),C):m===63?(e.consume(m),x):Pe(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),o=0,p):Pe(m)?(e.consume(m),k):n(m)}function d(m){return m===45?(e.consume(m),c):n(m)}function f(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(a=f,J(m)):(e.consume(m),f)}function h(m){return m===45?(e.consume(m),c):f(m)}function c(m){return m===62?Z(m):m===45?h(m):f(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(o++)?(e.consume(m),o===D.length?w:p):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):R(m)?(a=w,J(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?Z(m):m===93?(e.consume(m),y):w(m)}function k(m){return m===null||m===62?Z(m):R(m)?(a=k,J(m)):(e.consume(m),k)}function x(m){return m===null?n(m):m===63?(e.consume(m),A):R(m)?(a=x,J(m)):(e.consume(m),x)}function A(m){return m===62?Z(m):x(m)}function C(m){return Pe(m)?(e.consume(m),_):n(m)}function _(m){return m===45||me(m)?(e.consume(m),_):P(m)}function P(m){return R(m)?(a=P,J(m)):L(m)?(e.consume(m),P):Z(m)}function T(m){return m===45||me(m)?(e.consume(m),T):m===47||m===62||se(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),Z):m===58||m===95||Pe(m)?(e.consume(m),b):R(m)?(a=z,J(m)):L(m)?(e.consume(m),z):Z(m)}function b(m){return m===45||m===46||m===58||m===95||me(m)?(e.consume(m),b):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(a=N,J(m)):L(m)?(e.consume(m),N):z(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,B):R(m)?(a=$,J(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(a=B,J(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||se(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||se(m)?z(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function J(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),pe}function pe(m){return L(m)?H(e,ke,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):ke(m)}function ke(m){return e.enter(\"htmlTextData\"),a(m)}}const Nr={name:\"labelEnd\",resolveAll:Yu,resolveTo:Ju,tokenize:Zu},Qu={tokenize:Xu},Gu={tokenize:ec},Ku={tokenize:tc};function Yu(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&_e(e,0,e.length,n),e}function Ju(e,t){let n=e.length,r=0,i,o,a,s;for(;n--;)if(i=e[n][1],o){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(a){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(o=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(a=n);const u={type:e[o][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[o][1].start},end:{...e[a][1].end}},d={type:\"labelText\",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ie(s,e.slice(o+1,o+r+3)),s=ie(s,[[\"enter\",d,t]]),s=ie(s,Cn(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),s=ie(s,[[\"exit\",d,t],e[a-2],e[a-1],[\"exit\",l,t]]),s=ie(s,e.slice(a+1)),s=ie(s,[[\"exit\",u,t]]),_e(e,o,e.length,s),e}function Zu(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return s;function s(h){return o?o._inactive?f(h):(a=r.parser.defined.includes(Ot(r.sliceSerialize({start:o.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(Qu,d,a?d:f)(h):h===91?e.attempt(Gu,d,a?l:f)(h):a?d(h):f(h)}function l(h){return e.attempt(Ku,d,f)(h)}function d(h){return t(h)}function f(h){return o._balanced=!0,n(h)}}function Xu(e,t,n){return r;function r(f){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),i}function i(f){return se(f)?Tt(e,o)(f):o(f)}function o(f){return f===41?d(f):Zo(e,a,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(f)}function a(f){return se(f)?Tt(e,u)(f):d(f)}function s(f){return n(f)}function u(f){return f===34||f===39||f===40?ea(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(f):d(f)}function l(f){return se(f)?Tt(e,d)(f):d(f)}function d(f){return f===41?(e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(f)}}function ec(e,t,n){const r=this;return i;function i(s){return Xo.call(r,e,o,a,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function o(s){return r.parser.defined.includes(Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function a(s){return n(s)}}function tc(e,t,n){return r;function r(o){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(o),e.exit(\"referenceMarker\"),i}function i(o){return o===93?(e.enter(\"referenceMarker\"),e.consume(o),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(o)}}const nc={name:\"labelStartImage\",resolveAll:Nr.resolveAll,tokenize:rc};function rc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),o}function o(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),a):n(s)}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const ic={name:\"labelStartLink\",resolveAll:Nr.resolveAll,tokenize:oc};function oc(e,t,n){const r=this;return i;function i(a){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(a),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),o}function o(a){return a===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(a):t(a)}}const Rn={name:\"lineEnding\",tokenize:ac};function ac(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const an={name:\"thematicBreak\",tokenize:sc};function sc(e,t,n){let r=0,i;return o;function o(l){return e.enter(\"thematicBreak\"),a(l)}function a(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 fe={continuation:{tokenize:fc},exit:hc,name:\"list\",tokenize:cc},lc={partial:!0,tokenize:pc},uc={partial:!0,tokenize:dc};function cc(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(c){const p=r.containerState.type||(c===42||c===43||c===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||c===r.containerState.marker:lr(c)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),c===42||c===45?e.check(an,n,l)(c):l(c);if(!r.interrupt||c===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(c)}return n(c)}function u(c){return lr(c)&&++a<10?(e.consume(c),u):(!r.interrupt||a<2)&&(r.containerState.marker?c===r.containerState.marker:c===41||c===46)?(e.exit(\"listItemValue\"),l(c)):n(c)}function l(c){return e.enter(\"listItemMarker\"),e.consume(c),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||c,e.check(In,r.interrupt?n:d,e.attempt(lc,h,f))}function d(c){return r.containerState.initialBlankLine=!0,o++,h(c)}function f(c){return L(c)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(c),e.exit(\"listItemPrefixWhitespace\"),h):n(c)}function h(c){return r.containerState.size=o+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(c)}}function fc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(In,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(uc,t,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(fe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function dc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type===\"listItemIndent\"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function hc(e){e.exit(this.containerState.type)}function pc(e,t,n){const r=this;return H(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!L(o)&&a&&a[1].type===\"listItemPrefixWhitespace\"?t(o):n(o)}}const $i={name:\"setextUnderline\",resolveTo:gc,tokenize:mc};function gc(e,t){let n=e.length,r,i,o;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),!o&&e[n][1].type===\"definition\"&&(o=n);const a={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",o?(e.splice(i,0,[\"enter\",a,t]),e.splice(o+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push([\"exit\",a,t]),e}function mc(e,t,n){const r=this;let i;return o;function o(l){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){f=r.events[d][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter(\"setextHeadingLine\"),i=l,a(l)):n(l)}function a(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 _c={tokenize:yc};function yc(e){const t=this,n=e.attempt(In,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Su,i)),\"linePrefix\")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEndingBlank\"),e.consume(o),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const bc={resolveAll:na()},vc=ta(\"string\"),wc=ta(\"text\");function ta(e){return{resolveAll:na(e===\"text\"?kc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,s);return a;function a(d){return l(d)?o(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),o(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const c=f[h];if(!c.previous||c.previous.call(r,r.previous))return!0}return!1}}}function na(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type===\"data\"&&(o=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function kc(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 o=i.length,a=-1,s=0,u;for(;o--;){const l=i[o];if(typeof l==\"string\"){for(a=l.length;l.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(l===-2)u=!0,s++;else if(l!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,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 Sc={42:fe,43:fe,45:fe,48:fe,49:fe,50:fe,51:fe,52:fe,53:fe,54:fe,55:fe,56:fe,57:fe,62:Go},xc={91:Au},Cc={[-2]:Fn,[-1]:Fn,32:Fn},Ic={35:zu,42:an,45:[$i,an],60:Mu,61:$i,95:an,96:Ni,126:Ni},Ec={38:Yo,92:Ko},Ac={[-5]:Rn,[-4]:Rn,[-3]:Rn,33:nc,38:Yo,42:ur,60:[iu,ju],91:ic,92:[Du,Ko],93:Nr,95:ur,96:_u},Pc={null:[ur,bc]},Tc={null:[42,95]},Nc={null:[]},Dc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Tc,contentInitial:xc,disable:Nc,document:Sc,flow:Ic,flowInitial:Cc,insideSpan:Pc,string:Ec,text:Ac},Symbol.toStringTag,{value:\"Module\"}));function $c(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={},o=[];let a=[],s=[];const u={attempt:P(C),check:P(_),consume:k,enter:x,exit:A,interrupt:P(_,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:c,write:f};let d=t.tokenize.call(l,u);return t.resolveAll&&o.push(t),l;function f(N){return a=ie(a,N),S(),a[a.length-1]!==null?[]:(T(t,0),l.events=Cn(o,l.events,l),l.events)}function h(N,$){return Fc(c(N),$)}function c(N){return zc(a,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 w(N){i[N.line]=N.column,b()}function S(){let N;for(;r._index<a.length;){const $=a[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)y($.charCodeAt(r._bufferIndex));else y($)}}function y(N){d=d(N)}function k(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,b()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=N}function x(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function C(N,$){T(N,$.from)}function _(N,$){$.restore()}function P(N,$){return B;function B(U,M,Z){let J,pe,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(ee){return wt;function wt(Le){const ut=Le!==null&&ee[Le],ct=Le!==null&&ee.null,Tn=[...Array.isArray(ut)?ut:ut?[ut]:[],...Array.isArray(ct)?ct:ct?[ct]:[]];return j(Tn)(Le)}}function j(ee){return J=ee,pe=0,ee.length===0?Z:g(ee[pe])}function g(ee){return wt;function wt(Le){return m=z(),ke=ee,ee.partial||(l.currentConstruct=ee),ee.name&&l.parser.constructs.disable.null.includes(ee.name)?le():ee.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,le)(Le)}}function q(ee){return N(ke,m),M}function le(ee){return m.restore(),++pe<J.length?g(J[pe]):Z}}}function T(N,$){N.resolveAll&&!o.includes(N)&&o.push(N),N.resolve&&_e(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function zc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const s=a[0];typeof s==\"string\"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function Fc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o==\"string\")a=o;else switch(o){case-5:{a=\"\\r\";break}case-4:{a=`\n`;break}case-3:{a=`\\r\n`;break}case-2:{a=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;a=\" \";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join(\"\")}function Rc(e){const r={constructs:Rl([Dc,...(e||{}).extensions||[]]),content:i(Jl),defined:[],document:i(Xl),flow:i(_c),lazy:{},string:i(vc),text:i(wc)};return r;function i(o){return a;function a(s){return $c(r,o,s)}}}function Oc(e){for(;!Jo(e););return e}const zi=/[\\0\\t\\n\\r]/g;function Mc(){let e=1,t=\"\",n=!0,r;return i;function i(o,a,s){const u=[];let l,d,f,h,c;for(o=t+(typeof o==\"string\"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t=\"\",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(zi.lastIndex=f,l=zi.exec(o),h=l&&l.index!==void 0?l.index:o.length,c=o.charCodeAt(h),!l){t=o.slice(f);break}if(c===10&&f===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<h&&(u.push(o.slice(f,h)),e+=h-f),c){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Lc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Yl(n)(Oc(Rc(n).document().write(Mc()(e,t,!0))))}const On={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Vc(){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=On[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=On[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,Bc)),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\"+On[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Bc(e,t){return t===\"|\"?t:e}class Hc{constructor(){this.map=[]}add(t,n,r){qc(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[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 o of i)t.push(o);i=r.pop()}this.map.length=0}}function qc(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 Uc(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 o=r.length-1;r[o]=r[o]===\"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 jc(){return{flow:{null:{name:\"table\",tokenize:Wc,resolveAll:Qc}}}}function Wc(e,t,n){const r=this;let i=0,o=0,a;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\"?_:u;return B===_&&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||(a=!0,o+=1),d(b)}function d(b){return b===null?n(b):R(b)?o>1?(o=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),c):n(b):L(b)?H(e,d,\"whitespace\")(b):(o+=1,a&&(a=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),a=!0,d):(e.enter(\"data\"),f(b)))}function f(b){return b===null||b===124||se(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?h:f)}function h(b){return b===92||b===124?(e.consume(b),f):f(b)}function c(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),a=!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?S(b):b===124?(a=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),w):C(b)}function w(b){return L(b)?H(e,S,\"whitespace\")(b):S(b)}function S(b){return b===58?(o+=1,a=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),y):b===45?(o+=1,y(b)):b===null||R(b)?A(b):C(b)}function y(b){return b===45?(e.enter(\"tableDelimiterFiller\"),k(b)):C(b)}function k(b){return b===45?(e.consume(b),k):b===58?(a=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(b))}function x(b){return L(b)?H(e,A,\"whitespace\")(b):A(b)}function A(b){return b===124?p(b):b===null||R(b)?!a||i!==o?C(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):C(b)}function C(b){return n(b)}function _(b){return e.enter(\"tableRow\"),P(b)}function P(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),P):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,P,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||se(b)?(e.exit(\"data\"),P(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Qc(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],a=[0,0,0,0],s=!1,u=0,l,d,f;const h=new Hc;for(;++n<e.length;){const c=e[n],p=c[1];c[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Fi(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,f=void 0,o=[0,0,0,0],a=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],f=Xt(h,t,o,i,void 0,f),o=[0,0,0,0]),a[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],f=Xt(h,t,o,i,void 0,f)),o=a,a=[o[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,o[1]!==0?(a[0]=a[1],f=Xt(h,t,o,i,n,f)):a[1]!==0&&(f=Xt(h,t,a,i,n,f)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(a[3]=n)}for(u!==0&&Fi(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const c=t.events[n];c[0]===\"enter\"&&c[1].type===\"table\"&&(c[1]._align=Uc(t.events,n))}return e}function Xt(e,t,n,r,i,o){const a=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(o.end=Object.assign({},ft(t.events,n[0])),e.add(n[0],0,[[\"exit\",o,t]]));const u=ft(t.events,n[1]);if(o={type:a,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",o,t]]),n[2]!==0){const l=ft(t.events,n[2]),d=ft(t.events,n[3]),f={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",f,t]]),r!==2){const h=t.events[n[2]],c=t.events[n[3]];if(h[1].end=Object.assign({},c[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",f,t]])}return i!==void 0&&(o.end=Object.assign({},ft(t.events,i)),e.add(i,0,[[\"exit\",o,t]]),o=void 0),o}function Fi(e,t,n,r,i){const o=[],a=ft(t.events,n);i&&(i.end=Object.assign({},a),o.push([\"exit\",i,t])),r.end=Object.assign({},a),o.push([\"exit\",r,t]),e.add(n+1,0,o)}function ft(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Gc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Kc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,s){let u=-1;for(;++u<a.length;)if(a[u][0]===\"enter\"&&a[u][1].type===\"strikethroughSequenceTemporary\"&&a[u][1]._close){let l=u;for(;l--;)if(a[l][0]===\"exit\"&&a[l][1].type===\"strikethroughSequenceTemporary\"&&a[l][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[l][1].end.offset-a[l][1].start.offset){a[u][1].type=\"strikethroughSequence\",a[l][1].type=\"strikethroughSequence\";const d={type:\"strikethrough\",start:Object.assign({},a[l][1].start),end:Object.assign({},a[u][1].end)},f={type:\"strikethroughText\",start:Object.assign({},a[l][1].end),end:Object.assign({},a[u][1].start)},h=[[\"enter\",d,s],[\"enter\",a[l][1],s],[\"exit\",a[l][1],s],[\"enter\",f,s]],c=s.parser.constructs.insideSpan.null;c&&_e(h,h.length,0,Cn(c,a.slice(l+1,u),s)),_e(h,h.length,0,[[\"exit\",f,s],[\"enter\",a[u][1],s],[\"exit\",a[u][1],s],[\"exit\",d,s]]),_e(a,l-1,u-l+3,h),u=l+h.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type===\"strikethroughSequenceTemporary\"&&(a[u][1].type=\"data\");return a}function o(a,s,u){const l=this.previous,d=this.events;let f=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(a.enter(\"strikethroughSequenceTemporary\"),c(p))}function c(p){const w=bn(l);if(p===126)return f>1?u(p):(a.consume(p),f++,c);if(f<2&&!n)return u(p);const S=a.exit(\"strikethroughSequenceTemporary\"),y=bn(p);return S._open=!y||y===2&&!!w,S._close=!w||w===2&&!!y,s(p)}}}function Yc(e){return Lc(e,{allowDangerousHtml:!0,extensions:[jc(),Kc(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[Vc(),Gc()]})}const Jc={update:()=>{},getValues:()=>({})},Ce=ot({}),Qt=ot(Jc),ce=ot(!1),cr=ot(null);function Zc(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const o of Array.from(r.querySelectorAll(\":scope > p\")))o.replaceWith(...Array.from(o.childNodes));const i=Array.from(r.childNodes).map((o,a)=>ra(o,a,t));return v(Y,{children:i})}function ra(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,o=r.getAttribute(\"data-tw\");if(o!=null)return n[parseInt(o,10)];const a={key:t};for(const u of Array.from(r.attributes))a[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>ra(u,l,n));return G(i,a,...s)}return null}function Xc({node:e}){const t=Ar(),n=K(ce),r=K(Ce),i={};for(const[o,a]of Object.entries(e.attributes))i[o]=t(a)??a;return G(e.tag,i,e.children.length>0?Ie(e.children,{nobr:n,locals:r}):void 0)}function ef(){const e=K(cr),t=K(ce),n=K(Ce);return!e||e.length===0?null:v(Y,{children:Ie(e,{nobr:t,locals:n})})}function tf(e,t){if(Fl(e.name))return null;const n=Nl(e.name);if(n)return v(Tl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=$l(e.name);return r?v(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):v(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function fr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?v(ef,{},t):v(_l,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return tf(e,t);case\"html\":return v(Xc,{node:e},t);default:return e}}function ia(e){return e.length===0?null:e.map((t,n)=>fr(t,n))}function nf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function rf(e,t){const n=I.getState(),r=e.name.split(\".\"),i=r[0];let o;e.scope===\"variable\"?o=n.variables[i]:e.scope===\"temporary\"?o=n.temporary[i]:o=t[i];for(let a=1;a<r.length;a++){if(o==null||typeof o!=\"object\")return\"\";o=o[r[a]]}return o==null?\"\":String(o)}function Ie(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>fr(s,u));const r=[];let i=\"\";const o=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value;else if(u.type===\"variable\"&&nf(i))i+=rf(u,o);else{const l=r.length;r.push(fr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const a=Yc(i);return Zc(a,r,t?.nobr)}function of(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||i.history.length===0||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function af(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||t.history.length===0||typeof t.historyIndex!=\"number\")}const sf=\"spindle\",lf=1;let en=null,Mn=null;function Ue(){return Mn||(Mn={saves:new Map,playthroughs:new Map,meta:new Map}),Mn}function uf(){return en||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(en=new Promise((e,t)=>{const n=indexedDB.open(sf,lf);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)}),en))}function je(e,t){return uf().then(n=>n.transaction(e,t).objectStore(e))}function We(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function En(e){try{const t=await je(\"saves\",\"readwrite\");await We(t.put(e))}catch{Ue().saves.set(e.meta.id,e)}}async function An(e){try{const t=await je(\"saves\",\"readonly\");return await We(t.get(e))??void 0}catch{return Ue().saves.get(e)}}async function cf(e){try{const t=await je(\"saves\",\"readwrite\");await We(t.delete(e))}catch{Ue().saves.delete(e)}}async function ff(e){try{const n=(await je(\"saves\",\"readonly\")).index(\"ifid\");return await We(n.getAll(e))??[]}catch{return[...Ue().saves.values()].filter(t=>t.meta.ifid===e)}}async function oa(e){try{const t=await je(\"playthroughs\",\"readwrite\");await We(t.put(e))}catch{Ue().playthroughs.set(e.id,e)}}async function Dr(e){try{const n=(await je(\"playthroughs\",\"readonly\")).index(\"ifid\");return await We(n.getAll(e))??[]}catch{return[...Ue().playthroughs.values()].filter(t=>t.ifid===e)}}async function $r(e){try{const t=await je(\"meta\",\"readonly\"),n=await We(t.get(e));return n?n.value:void 0}catch{return Ue().meta.get(e)}}async function aa(e,t){try{const n=await je(\"meta\",\"readwrite\");await We(n.put({key:e,value:t}))}catch{Ue().meta.set(e,t)}}const sa=new Map,Pn=new Map;function df(e,t){sa.set(e,t),Pn.set(t,e)}function hf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function re(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[u,l]of r)s.set(n(u),n(l));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const u of r)s.add(n(u));return s}const o=i.constructor;if(Pn.get(o)!==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(hf(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 Ye=\"__spindle_class__\",Je=\"__spindle_data__\";function Xe(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),{[Ye]:\"__Date__\",[Je]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[Ye]:\"__RegExp__\",[Je]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}if(r instanceof Map){const u=[...r].map(([l,d])=>[n(l),n(d)]);return t.delete(i),{[Ye]:\"__Map__\",[Je]:{entries:u}}}if(r instanceof Set){const u=[...r].map(l=>n(l));return t.delete(i),{[Ye]:\"__Set__\",[Je]:{entries:u}}}const o=i.constructor,a=Pn.get(o);if(a!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Ye]:a,[Je]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function et(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(a=>t(a));const r=n;if(Ye in r&&Je in r){const a=r[Ye],s=r[Je];if(a===\"__Date__\")return new Date(s.iso);if(a===\"__RegExp__\")return new RegExp(s.source,s.flags);if(a===\"__Map__\"){const d=s.entries;return new Map(d.map(([f,h])=>[t(f),t(h)]))}if(a===\"__Set__\"){const d=s.entries;return new Set(d.map(f=>t(f)))}const u=sa.get(a);if(!u){console.warn(`spindle: Class \"${a}\" not registered. Falling back to plain object.`);const d={};for(const f of Object.keys(s))d[f]=t(s[f]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(Pn.has(i))return n;const o={};for(const a of Object.keys(r))o[a]=t(r[a]);return o}return t(e)}let dr=null,hr=null,Ri=!1;function pf(e){dr=e}function gf(e){hr=e}function mf(e){if(hr)try{const i=new Function(\"passage\",\"variables\",hr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(dr)try{const r=dr(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 _f(){Ri||(Ri=!0)}async function Oi(e){const n=(await Dr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await oa(i),await aa(`currentPlaythroughId.${e}`,r),r}async function yf(e){return $r(`currentPlaythroughId.${e}`)}async function la(e,t,n,r={}){const i=new Date().toISOString(),o={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:mf(n),passage:n.passage,custom:r},a=re(n);a.variables=Xe(a.variables),a.history=a.history.map(u=>({...u,variables:Xe(u.variables)}));const s={meta:o,payload:a};return await En(s),s}async function ua(e,t){const n=await An(e);if(!n)return;const r=re(t);r.variables=Xe(r.variables),r.history=r.history.map(o=>({...o,variables:Xe(o.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await En(i),i}async function bf(e){const t=await An(e);if(!t)return;const n=t.payload;return n.variables=et(n.variables),n.history=n.history.map(r=>({...r,variables:et(r.variables)})),n}async function vf(e){await cf(e)}async function wf(e,t){const n=await An(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await En(r)}async function kf(e){const[t,n]=await Promise.all([ff(e),Dr(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 o=[],a=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of a){const u=i.get(s.id)??[];o.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||o.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return o}const ca=\"autosave.\";async function Sf(e,t,n){const r=`${ca}${e}`,i=await $r(r);if(i){const a=await ua(i,n);if(a)return a}const o=await la(e,t,n,{isAutosave:!0});return await aa(r,o.meta.id),o}async function xf(e){const t=`${ca}${e}`,n=await $r(t);if(n)return bf(n)}const zr=\"spindle.session.\";function Cf(e,t){try{sessionStorage.setItem(`${zr}${e}`,JSON.stringify(t))}catch{}}function If(e){try{const t=sessionStorage.getItem(`${zr}${e}`);if(!t)return;const n=JSON.parse(t);if(!af(n))return;const r=n;return r.variables=et(r.variables),r.history=r.history.map(i=>({...i,variables:et(i.variables)})),r}catch{return}}function Ef(e){try{sessionStorage.removeItem(`${zr}${e}`)}catch{}}async function Af(e){const t=await An(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Pf(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=re(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Dr(t)).some(o=>o.id===n.meta.playthroughId)){const o={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await oa(o)}return await En(n),n}function fa(){const e=I.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=yt(t.content),i=bt(r),o=document.createElement(\"div\");o.style.display=\"none\",document.body.appendChild(o),xe(G(()=>Ie(i),null),o)}const n=e.storyData.passages.get(\"SaveTitle\");n&&gf(n.content)}let da=0,ve=[],Ln=!1,st=[],Nt=null,Oe=null;function Fr(e){const t=I.getState();try{return!!xn(e,t.variables,t.temporary)}catch{return!1}}function ha(e,t){const n=da++,r=typeof t==\"function\",i=r?void 0:t,o=r?t:void 0,a={id:n,name:i?.name,condition:e,callback:o,options:i,lastResult:Fr(e),priority:i?.priority??0};return ve.push(a),ve.sort((s,u)=>u.priority-s.priority),()=>{ve=ve.filter(s=>s.id!==n)}}function pa(e){ve=ve.filter(t=>t.name!==e)}function Tf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=I.getState();Bo(n.run,r.variables,r.temporary)}n.dialog&&(st.push({passageName:n.dialog}),Nt?.()),n.goto&&I.getState().navigate(n.goto)}}const Nf=10;function Df(){if(!Ln){Ln=!0;try{for(let e=0;e<Nf;e++){let t=!1;const n=[...ve];for(const r of n){if(!ve.includes(r))continue;const i=Fr(r.condition),o=!r.lastResult;r.lastResult=i,i&&o&&(t=!0,r.options?.once&&(ve=ve.filter(a=>a.id!==r.id)),Tf(r))}if(!t)break}}finally{Ln=!1}}}function $f(){for(const e of ve)e.lastResult=Fr(e.condition)}function zf(){ve=[],st=[],da=0,Oe?.closeAll()}function Ff(e){return Nt=e,st.length>0&&e(),()=>{Nt===e&&(Nt=null)}}function Rf(){return st.shift()}function Of(){return st.length}function Mf(e){Oe?Oe.push(e):(st.push(e),Nt?.())}function Lf(){st=[]}function Vf(e){return Oe=e,()=>{Oe===e&&(Oe=null)}}function Bf(){Oe?.close()}function Hf(){Lf(),Oe?.closeAll()}function qf(){return Oe?.isOpen()??!1}nl();const Uf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ze={},ye=[],Ve={};function Mi(e){return e.map(t=>({...t,value:t.value!==void 0?re(t.value):void 0}))}function Li(e,t){const[,n,r]=il(e,i=>{const o=i;for(const a of Object.keys(o))a in t||delete o[a];for(const[a,s]of Object.entries(t))o[a]=s});return{forward:Mi(n),inverse:Mi(r)}}function jf(e){let t=Ze;for(let n=0;n<e;n++)t=dt(t,ye[n].forward);return t}let be=[];function Vn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:o,visitCounts:a,renderCounts:s}=e();if(t){if(be.length>i.length&&(be.length=i.length),be.length<i.length)if(i.length-be.length===1){const l=i.length-1;be[l]={passage:i[l].passage,variables:Xe(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ze;for(let d=0;d<i.length;d++)if(d>0&&(l=dt(l,ye[d-1].forward)),d>=be.length){const f=d===i.length-1?r:l;be[d]={passage:i[d].passage,variables:Xe(f),timestamp:i[d].timestamp,prng:i[d].prng}}}Cf(t.ifid,{passage:n,variables:Xe(r),history:be,historyIndex:o,visitCounts:a,renderCounts:s,prng:yn()})}}function Vi(e){Ze=e,ye=[],Ve=e,be=[]}function Bi(e){e?.prng?Oo(e.prng.seed,e.prng.pull):e&&or()}const I=Ls()(al((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 o=re(r);Vi(re(o)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=o,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}}),Ve=t().variables;const a=n.ifid;_f().then(async()=>{const s=await yf(a);if(s)e(u=>{u.playthroughId=s});else{const u=await Oi(a);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(Uf.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 o=Li(Ve,i);e(a=>{a.temporary={},a.currentPassage=n,a.history=a.history.slice(0,a.historyIndex+1),ye.length=a.historyIndex,ye.push(o),a.history.push({passage:n,timestamp:Date.now(),prng:yn()});const s=a.history.length-a.maxHistory;if(s>0){for(let u=0;u<s;u++)Ze=dt(Ze,ye[u].forward);a.history=a.history.slice(s),ye=ye.slice(s),be=be.slice(s)}a.historyIndex=a.history.length-1,a.visitCounts[n]=(a.visitCounts[n]??0)+1,a.renderCounts[n]=(a.renderCounts[n]??0)+1}),Ve=t().variables,Vn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=re(dt(r,ye[n-1].inverse));e(o=>{o.historyIndex--,o.currentPassage=o.history[o.historyIndex].passage,o.variables=i,o.temporary={}}),Ve=t().variables,Bi(t().history[t().historyIndex]),Vn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const o=re(dt(i,ye[n].forward));e(a=>{a.historyIndex++,a.currentPassage=a.history[a.historyIndex].passage,a.variables=o,a.temporary={}}),Ve=t().variables,Bi(t().history[t().historyIndex]),Vn(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;or(),zf();const o=re(r);Vi(re(o)),e(a=>{a.currentPassage=i.name,a.variables=o,a.temporary={},a.history=[{passage:i.name,timestamp:Date.now()}],a.historyIndex=0,a.visitCounts={[i.name]:1},a.renderCounts={[i.name]:1}}),Ve=t().variables,fa(),Ef(n.ifid),Oi(n.ifid).then(a=>{e(s=>{s.playthroughId=a})}).catch(a=>console.error(\"spindle: failed to start new playthrough\",a))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(o=>{o.saveError=null}),Sf(n.ifid,r,i).then(()=>{e(o=>{o.saveVersion++})}).catch(o=>{console.error(\"spindle: failed to quick save\",o),e(a=>{a.saveError=o instanceof Error?o.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),xf(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:o,visitCounts:a,renderCounts:s}=t(),u=[];let l=Ze;for(let d=0;d<i.length;d++)d>0&&(l=dt(l,ye[d-1].forward)),u.push({passage:i[d].passage,variables:re(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:re(r),history:u,historyIndex:o,visitCounts:{...a},renderCounts:{...s},prng:yn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=et(n.history[0]?.variables??{}),i=[];let o=r;for(let a=1;a<n.history.length;a++){const s=et(n.history[a].variables);i.push(Li(o,s)),o=s}Ze=re(r),ye=i,be=[],e(a=>{a.currentPassage=n.passage,a.variables=et(n.variables),a.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),a.historyIndex=Math.max(0,Math.min(n.historyIndex,a.history.length-1)),a.visitCounts=n.visitCounts??{},a.renderCounts=n.renderCounts??{},a.temporary={}}),Ve=t().variables,n.prng?Oo(n.prng.seed,n.prng.pull):or()},getHistoryVariables:n=>re(jf(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}}))),Wf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Qf(){const t=I(o=>o.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Wf,r=t?.tags.includes(\"nobr\")??!1,i=de(()=>{try{const o=yt(n),a=bt(o);return v(Y,{children:ia(a)})}catch(o){return v(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",o instanceof Error?o.message:String(o)]})}},[n]);return r?v(ce.Provider,{value:!0,children:i}):i}const ga=ot(null);function Rr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const o=ae(r);o.current=r;const a=he(()=>o.current(),[]),s=I(c=>c.storyData),l=(e?s?.passages.get(e):void 0)?.content??t,d=de(()=>{if(!l)return v(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=yt(l),p=bt(c);return Ie(p)}catch(c){return v(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[l]),f=c=>{c.target.classList.contains(\"dialog-overlay\")&&a()},h=n?`dialog-panel ${n}`:\"dialog-panel\";return v(ga.Provider,{value:a,children:v(\"div\",{class:\"dialog-overlay\",onClick:f,children:v(\"div\",{class:h,children:[i&&v(\"button\",{class:\"dialog-close\",onClick:a,children:\"✕\"}),v(\"div\",{class:\"dialog-body\",children:d})]})})})}function Gf(){const[e,t]=X([]),n=ae(e);n.current=e;const r=he(a=>{t(s=>[...s,a])},[]),i=he(()=>{t(a=>a.slice(0,-1))},[]),o=he(()=>{t([])},[]);return we(()=>Vf({close:i,closeAll:o,push:r,isOpen:()=>n.current.length>0}),[i,o,r]),we(()=>Ff(()=>{const a=[];for(;Of()>0;){const s=Rf();s&&a.push(s)}a.length>0&&t(s=>[...s,...a])}),[]),e.length===0?null:v(Y,{children:e.map((a,s)=>v(Rr,{passageName:a.passageName,panelClass:a.panelClass,onClose:i,showCloseButton:a.showCloseButton},`${a.passageName}-${s}`))})}function Kf(){const e=I(i=>i.storyData),t=I(i=>i.currentPassage),n=I(i=>i.nobr);if(we(()=>{const i=o=>{o.key===\"F6\"?(o.preventDefault(),I.getState().save()):o.key===\"F9\"&&(o.preventDefault(),I.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return v(\"div\",{class:\"loading\",children:\"Loading...\"});const r=v(Y,{children:[v(Qf,{}),v(Gf,{})]});return n?v(ce.Provider,{value:!0,children:r}):r}function Yf(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Jf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",o=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",d=new Map,f=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const c=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",w=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),S=Yf(h.innerHTML),y={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const A of h.attributes)k.has(A.name)||(y[A.name]=A.value);const x={pid:c,name:p,tags:w,metadata:y,content:S};d.set(p,x),f.set(c,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:o,passages:d,passagesById:f,userCSS:s,userScript:l}}const xt=new Map;let ue={},Hi=!1;function ma(){return`spindle.${I.getState().storyData?.ifid||\"unknown\"}.settings`}function Zf(){localStorage.setItem(ma(),JSON.stringify(ue))}function Bn(){if(!Hi){Hi=!0;try{const e=localStorage.getItem(ma());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ue={...ue,...t})}}catch{}}}const Mt={addToggle(e,t){xt.set(e,{type:\"toggle\",config:t}),e in ue||(ue[e]=t.default),Bn()},addList(e,t){xt.set(e,{type:\"list\",config:t}),e in ue||(ue[e]=t.default),Bn()},addRange(e,t){xt.set(e,{type:\"range\",config:t}),e in ue||(ue[e]=t.default),Bn()},get(e){return ue[e]},getToggle(e){const t=ue[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ue[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ue[e];return typeof t==\"number\"?t:0},set(e,t){ue[e]=t,Zf()},getAll(){return{...ue}},getDefinitions(){return xt},hasAny(){return xt.size>0}};function Xf(e,t,n){const r=I.getState(),i=re(r.variables),o=re(r.temporary),a={...t};Bo(e,i,o,a);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(o))o[s]!==r.temporary[s]&&r.setTemporary(s,o[s]);for(const s of Object.keys(a))a[s]!==t[s]&&n(s,a[s]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in o||r.deleteTemporary(s);for(const s of Object.keys(t))s in a||n(s,void 0)}const vn=new Map,pr=new Set,gr=new Map;function ed(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(gr.get(r)??0)+1;return gr.set(r,i),i===1?r:`${r}:${i}`}function td(e){return vn.set(e.id,e),Ui(),()=>{vn.delete(e.id),Ui()}}function qi(){return Array.from(vn.values())}function nd(e){return vn.get(e)}function rd(){gr.clear()}function id(e){return pr.add(e),()=>{pr.delete(e)}}function Ui(){for(const e of pr)e()}function od(e){const t=ae(\"\"),n=ae(e.perform);n.current=e.perform,t.current||(t.current=ed(e.type,e.key,e.authorId));const r=t.current;return at(()=>{const i={id:r,type:e.type,label:e.label,perform:(...o)=>n.current(...o)};return e.target!==void 0&&(i.target=e.target),e.variable!==void 0&&(i.variable=e.variable),e.options!==void 0&&(i.options=e.options),e.value!==void 0&&(i.value=e.value),e.disabled!==void 0&&(i.disabled=e.disabled),td(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function ad(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function _a(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Or(){const e=I.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?_a(t):\"\"}function sd(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 ld(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 ud(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const cd={useState:X,useRef:ae,useEffect:we,useLayoutEffect:at,useCallback:he,useMemo:de,useContext:K};function ji(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function fd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];(r[o]==null||typeof r[o]!=\"object\")&&(r[o]={}),r=r[o]}r[t[t.length-1]]=n}function V(e){function t(n){let r=n.className,i=n.id,o;e.interpolate&&(o=Ar(),r=o(r),i=o(i));const{update:a,getValues:s}=K(Qt),u=K(ce),l=K(Ce),f={collectText:ad,sourceLocation:Or,parseVarArgs:sd,extractOptions:ld,h:G,renderNodes:(h,c)=>Ie(h,{nobr:u,locals:l,...c}),renderInlineNodes:ia,hooks:cd,useAction:od,className:r,id:i,resolve:o,cls:ud(e.name,r),mutate:h=>Xf(h,s(),a),update:a,getValues:s,wrap:h=>r||i?G(\"span\",{id:i,class:r},h):G(Y,null,h)};if(e.merged){f.merged=Er();const h=f.merged;f.evaluate=c=>xn(c,h[0],h[1],h[2])}if(e.storeVar){const c=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),p=c.split(\".\");f.varName=c,f.value=I(w=>ji(w.variables,p)),f.getValue=()=>ji(I.getState().variables,p),f.setValue=w=>{I.setState(S=>{fd(S.variables,p,w)})}}return e.render(n,f)}if(Dl(e.name,t),e.subMacros)for(const n of e.subMacros)zl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&ir(e.name)}function dd(){return{get(e){return I.getState().variables[e]},set(e,t){const n=I.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){I.getState().navigate(e)},back(){I.getState().goBack()},forward(){I.getState().goForward()},restart(){I.getState().restart()},save(e){I.getState().save(e)},load(e){I.getState().load(e)},hasSave(e){return I.getState().hasSave(e)},visited(e){const t=I.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=I.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=I.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=I.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return I.getState().storyData?.name||\"\"},get passage(){return I.getState().currentPassage},settings:Mt,registerClass(e,t){df(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){pf(e)}},getActions(){return qi()},performAction(e,t){const n=nd(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=I.getState().currentPassage;return I.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return id(t);if(e===\"variableChanged\"){let n={...I.getState().variables};return I.subscribe(r=>{const i={};let o=!1;const a=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of a)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},o=!0);n={...r.variables},o&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(qi())})})})},watch(e,t){return ha(e,t)},unwatch(e){pa(e)},openDialog(e,t){Mf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Bf()},closeAllDialogs(){Hf()},isDialogOpen(){return qf()},setNobr(e){I.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){I.getState().setTransition(e)},setNextTransition(e){I.getState().setNextTransition(e)},random(){return Pr()},randomInt(e,t){return Mo(e,t)},config:{get maxHistory(){return I.getState().maxHistory},set maxHistory(e){I.getState().setMaxHistory(e)}},prng:{init(e,t){yl(e,t);const{historyIndex:n}=I.getState();I.setState(r=>{const i=r.history[n];i&&(i.prng=yn())})},isEnabled(){return bl()},get seed(){return vl()},get pull(){return wl()}}}}function hd(){window.Story=dd()}const pd=/^\\$(\\w+)\\s*=\\s*(.+)$/,Wi=/\\$(\\w+(?:\\.\\w+)*)/g,Qi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,gd=new Set([\"number\",\"string\",\"boolean\"]);function ya(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,ya(i));return{type:\"object\",fields:n}}const t=typeof e;if(!gd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function md(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(pd);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,o,a]=i;let s;try{s=new Function(\"return (\"+a+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${o} = ${a}\": ${l instanceof Error?l.message:l}`)}const u=ya(s);t.set(o,{...u,name:o,default:s})}return t}function _d(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 yd(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const o=t.get(i);if(!o)return`Undeclared variable: $${e}`;let a=o;for(let s=1;s<r.length;s++){const u=r[s];if(a.type===\"array\")return null;if(a.type!==\"object\"||!a.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${a.type})`;const l=a.fields.get(u);if(!l)return null;a=l}return null}function bd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const o=_d(i.content);let a;for(Wi.lastIndex=0;(a=Wi.exec(i.content))!==null;){const s=a[1],u=yd(s,t,o);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function vd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function sn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&sn(t.children))return!0;if(t.type===\"macro\"){if(sn(t.children))return!0;if(t.branches){for(const n of t.branches)if(sn(n.children))return!0}}}return!1}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function He({macro:e,error:t}){return v(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Or()}: ${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 v(He,{macro:\"print\",error:n})}}});function wd(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 o=t.slice(0,r).trim(),a=t.slice(r+1).trim();if(!o.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${o}\"`);return{target:o,expr:a}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function kd(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function Gi(e,t,n,r,i,o,a){let s;try{s=xn(e,r,i,o)}catch(l){console.error(`spindle: Error in {computed ${a}}${Or()}:`,l);return}const u=n?i[t]:r[t];if(!kd(u,s)){const l=I.getState();n?l.setTemporary(t,s):l.setVariable(t,s)}}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let o,a;try{({target:o,expr:a}=wd(e))}catch(d){return v(He,{macro:\"computed\",error:d})}const s=o.startsWith(\"_\"),u=o.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,Gi(a,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{Gi(a,u,s,n,r,i,e)},[n,r,i]),null}});function Sd(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 o=xd(r);if(o.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:o[0],maxExpr:o.slice(1).join(\" \"),labelMode:n}}function xd(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const o=e[i];if(o===\"(\"||o===\"[\")r++,n+=o;else if(o===\")\"||o===\"]\")r--,n+=o;else if(/\\s/.test(o)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=o}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}=Sd(e),o=Number(t.evaluate(n)),a=Number(t.evaluate(r)),s=a===0?0:Math.max(0,Math.min(100,o/a*100)),u=Cd(o,a,i),l=t.cls;return v(\"div\",{class:l,id:t.id,children:[v(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&v(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return v(He,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),o=t.resolve(r.className),a=t.resolve(r.id);return o||a?v(\"span\",{id:a,class:o,children:i}):v(Y,{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 v(He,{macro:\"if\",error:i})}}return null}});function Id(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()),o=i[0],a=i.length>1?i[1]:null;if(!o.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${o}\"`);if(a&&!a.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${a}\"`);return{itemVar:o.slice(1),indexVar:a?a.slice(1):null,listExpr:r}}function Ed({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,o]=X(()=>({...n})),a={...e,...t,...i},s=ae(a);s.current=a;const u=he(()=>s.current,[]),l=he((h,c)=>{o(p=>({...p,[h]:c}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]),f=K(ce);return v(Qt.Provider,{value:d,children:v(Ce.Provider,{value:a,children:Ie(r,{nobr:f,locals:a})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=K(Ce);let i;try{i=Id(e)}catch(d){return v(He,{macro:\"for\",error:d})}const{itemVar:o,indexVar:a,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return v(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return v(He,{macro:\"for\",error:d})}const l=u.map((d,f)=>{const h={[o]:d,...a?{[a]:f}:void 0};return v(Ed,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${f}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=K(ce),o=()=>{const a=document.createElement(\"div\"),s=G(ce.Provider,{value:i},G(Qt.Provider,{value:{update:n.update,getValues:n.getValues}},G(Ce.Provider,{value:n.getValues()},Ie(t))));xe(s,a),xe(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:o}),v(\"button\",{id:n.id,class:n.cls,onClick:o,children:r})}});function Ad(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 Ki(e,t,n,r){const i=document.createElement(\"div\"),o=G(ce.Provider,{value:r},G(Qt.Provider,{value:{update:n,getValues:t}},G(Ce.Provider,{value:t()},Ie(e))));xe(o,i),xe(null,i)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Ad(e),o=K(ce),a=s=>{s.preventDefault(),Ki(t,n.getValues,n.update,o),i&&I.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Ki(t,n.getValues,n.update,o),i&&I.getState().navigate(i)}}),v(\"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(o){return v(He,{macro:\"switch\",error:o})}let i=null;for(let o=1;o<t.length;o++){const a=t[o];if(a.rawArgs===\"\"){i=a;continue}try{const s=n.evaluate(a.rawArgs);if(r===s)return v(Y,{children:n.renderNodes(a.children)})}catch(s){return v(He,{macro:\"case\",error:s})}}return i?v(Y,{children:n.renderNodes(i.children)}):null}});function Mr(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,o=i(()=>e.map(c=>({delay:c.rawArgs?Mr(c.rawArgs):0,nodes:c.children,className:c.className,id:c.id})),[e]),[a,s]=n(-1);if(r(()=>{if(a>=o.length-1)return;const c=a+1,p=o[c].delay,w=setTimeout(()=>{s(c)},p);return()=>clearTimeout(w)},[a,o]),a<0)return t.wrap(null);const u=o[a],l=t.renderNodes(u.nodes),d=t.resolve(u.className),f=t.resolve(u.id),h=d||f?v(\"span\",{id:f,class:d,children:l}):l;return t.wrap(h)}});const ba=ot({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:o}=n.hooks,a=Mr(e),[s,u]=r(0),[l,d]=r(!1),f=o(()=>d(!0),[]);if(i(()=>{if(l)return;const c=setInterval(()=>{u(p=>p+1)},a);return()=>clearInterval(c)},[a,l]),s===0&&!l)return null;const h=v(ba.Provider,{value:{stop:f},children:v(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?v(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(ba);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:o}=n.hooks,a=Mr(e),s=o(null),[u,l]=r(0),[d,f]=r(0),h=o(0);h.current=d,i(()=>{if(s.current){const w=s.current.textContent||\"\";l(w.length)}},[]),i(()=>{if(u===0||h.current>=u)return;const w=setInterval(()=>{f(S=>S>=u?(clearInterval(w),S):S+1)},a);return()=>clearInterval(w)},[u,a]);const c=d>=u&&u>0,p=[\"macro-type\",c?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return v(\"span\",{id:n.id,class:p,ref:s,style:{clipPath:(u>0&&!c,void 0)},children:[v(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!c?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!c&&u>0&&v(\"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),o=JSON.stringify(t),a=i.join(\",\");return n.hooks.useLayoutEffect(()=>{qo(r,t,i)},[r,o,a]),null}});V({name:\"story-title\",render(e,t){const n=I(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return v(\"span\",{id:t.id,class:r,children:n})}});function lt(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=X(!1),o=e.setup?.()??{perform:()=>{}},{disabled:a}=o,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&o.perform()}:o.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:a,perform:e.dialog?()=>i(!0):o.perform}),v(Y,{children:[v(\"button\",{id:n.id,class:s,onClick:u,disabled:a,title:e.title,children:e.label}),e.dialog&&r&&v(Rr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}lt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:I(e=>e.goBack),disabled:!I(e=>e.historyIndex>0)})});lt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:I(e=>e.goForward),disabled:!I(e=>e.historyIndex<e.history.length-1)})});lt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:I(e=>e.save)})});lt({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=I(n=>n.load),t=I(n=>n.hasSave);return I(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});lt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:I(e=>e.restart)})});lt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});lt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Mt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),o=/\\bnoclose\\s*$/.test(e),a=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(a.replace(/^[\"']|[\"']$/g,\"\"))??a,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return v(Y,{children:[v(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&v(Rr,{passageName:u,onClose:()=>i(!1),showCloseButton:!o})]})}});function Td(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 o=Math.floor(i/24);return o<30?`${o}d ago`:new Date(e).toLocaleDateString()}function Nd(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Dd(){const[e,t]=X(\"load\"),[n,r]=X([]),[i,o]=X(!0),[a,s]=X(null),[u,l]=X(()=>new Set),[d,f]=X(null),[h,c]=X(\"\"),p=ae(null),w=ae(null),S=K(ga),y=I(D=>D.storyData),k=I(D=>D.playthroughId),x=I(D=>D.getSavePayload),A=I(D=>D.loadFromPayload),C=y?.ifid??\"\",_=he(async()=>{if(!C)return;const D=await kf(C);r(D),o(!1)},[C]);we(()=>{_()},[_]),we(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const P=ae(),T=(D,j=\"success\")=>{clearTimeout(P.current),s({text:D,type:j}),P.current=window.setTimeout(()=>s(null),3e3)};we(()=>()=>clearTimeout(P.current),[]);const z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},b=async()=>{if(!(!C||!k))try{const D=x();await la(C,k,D),T(\"Save created\"),await _()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=x();await ua(D,j),T(\"Save overwritten\"),await _()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{A(D.payload),T(\"Game loaded\"),S&&setTimeout(S,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await vf(D),T(\"Save deleted\"),await _()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{f(D.meta.id),c(D.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await wf(d,h.trim()),f(null),T(\"Save renamed\"),await _()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&f(null)},J=async D=>{try{const j=await Af(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),le=document.createElement(\"a\");le.href=q,le.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,le.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},pe=()=>{w.current?.click()},ke=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),le=JSON.parse(q);if(!of(le))throw new Error(\"Invalid save file format\");await Pf(le,C),T(\"Save imported\"),await _()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.saves.length,0);return v(\"div\",{class:\"save-manager\",children:[v(\"div\",{class:\"saves-header\",children:v(\"div\",{class:\"saves-header-left\",children:v(\"div\",{class:\"saves-mode-toggle\",children:[v(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),v(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),v(\"div\",{class:\"saves-toolbar\",children:[v(\"button\",{class:\"saves-toolbar-button\",onClick:pe,children:\"Import\"}),v(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),v(\"div\",{class:\"saves-body\",children:[i?v(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?v(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:v(\"div\",{class:\"playthrough-group\",children:[v(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[v(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),v(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),v(\"span\",{class:\"playthrough-date\",children:Nd(D.playthrough.createdAt)})]}),!j&&v(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>v(\"div\",{class:\"save-slot\",children:[v(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?v(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:le=>c(le.target.value),onKeyDown:Z,onBlur:M}):v(\"div\",{class:\"save-slot-title\",children:q.meta.title}),v(\"div\",{class:\"save-slot-meta\",children:[v(\"span\",{children:q.meta.passage}),v(\"span\",{children:Td(q.meta.updatedAt)})]})]}),v(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?v(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):v(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>J(q.meta.id),children:\"Export\"}),v(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===k)&&v(\"div\",{class:\"playthrough-group\",children:v(\"div\",{class:\"playthrough-saves\",children:v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),a&&v(\"div\",{class:`saves-status ${a.type===\"error\"?\"error\":\"\"}`,children:a.text})]})}V({name:\"save-manager\",render(){return v(Dd,{})}});function $d({name:e,def:t}){const[n,r]=X(()=>Mt.get(e)),i=o=>{r(o),Mt.set(e,o)};switch(t.type){case\"toggle\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:t.config.label}),v(\"input\",{type:\"checkbox\",checked:!!n,onChange:o=>i(o.target.checked)})]});case\"list\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:t.config.label}),v(\"select\",{value:String(n),onChange:o=>i(o.target.value),children:t.config.options.map(o=>v(\"option\",{value:o,children:o},o))})]});case\"range\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:[t.config.label,\": \",String(n)]}),v(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:o=>i(parseFloat(o.target.value))})]})}}function zd(){const e=Mt.getDefinitions();return v(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>v($d,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return v(zd,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=I(f=>f.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let o;try{const f=t.evaluate(i);o=String(f)}catch{o=i.replace(/^[\"']|[\"']$/g,\"\")}const a=n.passages.get(o);if(a&&I.getState().trackRender(o),!a)return v(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${o}\" not found}`});const s=a.tags.includes(\"nobr\"),u=yt(a.content),l=bt(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(ce.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(ce.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}I.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=I.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _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):\"\")}),v(\"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)}),v(\"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):\"\")}),v(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Fd(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Fd(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),v(\"label\",{id:t.id,class:t.cls,children:[v(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function Rd(e){const t=e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=Rd(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),v(\"label\",{id:t.id,class:t.cls,children:[v(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),v(\"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=>v(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),a=(n.indexOf(String(i))+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()}}),v(\"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 It(e){const t=yt(e.content),n=bt(t),r=e.tags.includes(\"nobr\");return Ie(n,r?{nobr:!0}:void 0)}const Od=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Md({passage:e,dataTransition:t}){const n=I(w=>w.storyData),r=Od.has(e.name),[i,o]=X(!1),a=de(()=>{try{return It(e)}catch(w){return v(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",_a(e),\":\",\" \",w instanceof Error?w.message:String(w)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=de(()=>{if(!s)return null;try{return It(s)}catch(w){return console.error(\"spindle: Error in PassageHeader:\",w),null}},[s?.content]),f=de(()=>{if(!u)return null;try{return It(u)}catch(w){return console.error(\"spindle: Error in PassageFooter:\",w),null}},[u?.content]);we(()=>(l&&o(!0),()=>o(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return It(l)}catch(w){return console.error(\"spindle: Error in PassageDone:\",w),null}},[i,l?.content]),c=e.tags.includes(\"nobr\"),p=v(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&v(\"div\",{class:\"passage-header\",children:d}),a,f&&v(\"div\",{class:\"passage-footer\",children:f}),h&&v(\"div\",{hidden:!0,children:h})]});return c?v(ce.Provider,{value:!0,children:p}):p}const Ld=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),mr={type:\"fade-through\",duration:300,pause:50};function Vd(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Ld.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const o=Number(i.slice(9));Number.isNaN(o)||(r.duration=o)}else if(i.startsWith(\"pause:\")){const o=Number(i.slice(6));Number.isNaN(o)||(r.pause=o)}return r}function Hn(e){return{type:e.type,duration:e.duration??mr.duration,pause:e.pause??mr.pause}}function Bd(e,t,n){const r=Vd(e);return r?Hn(r):t?Hn(t):n?Hn(n):{...mr}}function Yi(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let o=0;o<r.length;o++)r[o].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let o=0;o<i.length;o++){const a=i[o];a.pause?.(),a.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function qn(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 Un(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=I(c=>c.currentPassage),r=I(c=>c.storyData),[i,o]=X(n),a=ae(\"fade\"),s=ae(0),u=ae(null),l=ae([]),d=he(()=>{for(const c of l.current)clearTimeout(c);l.current=[],Un(u.current)},[]);we(()=>{const c=I.getState(),{history:p,historyIndex:w,transitionConfig:S}=c,y=c.consumeNextTransition(),k=s.current;s.current=p.length;const x=!i,A=p.length===1&&w===0&&k>1,C=p.length>1&&w===p.length-1&&k>1&&Math.abs(p.length-k)>1;if(n===i)return;d();const _=r?.passages.get(n);if(!_){a.current=\"none\",o(n);return}if(x||A||C){a.current=\"fade\",o(n);return}const P=Bd(_.tags,y,S);a.current=P.type;const T=u.current;if(P.type===\"none\"){o(n);return}if(P.type===\"fade\"){T&&qn(T,P),o(n);return}if(P.type===\"fade-through\"){if(!T){o(n);return}qn(T,P);const z=T.querySelector(\".passage\");if(!z){o(n);return}const b=Yi(z,P.type);T.appendChild(b),o(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{o(n)},N),B=N+P.duration,U=setTimeout(()=>{Un(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){o(n);return}qn(T,P);const z=T.querySelector(\".passage\");if(!z){o(n);return}const b=Yi(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),o(n);const N=setTimeout(()=>{Un(T)},P.duration);l.current=[N];return}o(n)},[n]);const f=i?r?.passages.get(i):null;if(!f&&i)return v(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return v(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&v(\"div\",{hidden:!0,children:It(h)},`ready-${n}`),v(\"div\",{class:\"passage-container\",ref:u,children:f&&v(Md,{passage:f,dataTransition:a.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 o=i[2],a=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(a))!==null;){const f=l[1]??l[5],h=l[2]??l[3]??l[4];if(f)switch(f){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,ha(o,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,pa(r)),null}});const Hd='*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}';function Ji(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const o of t){const a=document.createElement(\"li\");a.textContent=o,i.appendChild(a)}n.appendChild(i),e.appendChild(n)}function Zi(){const e=Jf(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Hd,document.head.appendChild(t),hd(),e.userCSS){const c=document.createElement(\"style\");c.textContent=e.userCSS,document.head.appendChild(c)}if(e.userScript)try{new Function(e.userScript)()}catch(c){console.error(\"spindle: Error in story JavaScript:\",c)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const c=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",p=document.getElementById(\"root\");throw p&&Ji(p,[c]),new Error(`spindle: ${c}`)}const i=md(r.content),o=bd(e.passages,i);if(o.length>0){const c=document.getElementById(\"root\");throw c&&Ji(c,o),new Error(`spindle: ${o.length} validation error(s):\n${o.join(`\n`)}`)}n=vd(i),I.getState().init(e,n),fa();const a=If(e.ifid);a&&I.getState().loadFromPayload(a);const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){let p;for(;(p=s.exec(c.content))!==null;){const w=p[1],S=p[2];/\\{@children\\}/.test(S)&&ir(w)}s.lastIndex=0}for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const p=yt(c.content),w=bt(p);for(const S of w)if(S.type===\"macro\"&&S.name===\"widget\"&&S.rawArgs){const y=S.rawArgs.trim().split(/\\s+/),k=y[0].replace(/[\"']/g,\"\"),x=y.slice(1).filter(_=>_.startsWith(\"$\")||_.startsWith(\"_\")||_.startsWith(\"@\")),A=S.children,C=sn(A);qo(k,A,x,C),C&&ir(k)}}let u=\"\";I.subscribe(c=>{c.currentPassage!==u&&(u=c.currentPassage,rd())});let l=I.getState().variables,d=I.getState().historyIndex;I.subscribe(c=>{c.variables!==l&&(c.historyIndex===d?Df():$f()),l=c.variables,d=c.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 h=document.getElementById(\"root\");if(!h)throw new Error('spindle: No <div id=\"root\"> element found.');xe(v(Kf,{}),h),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Zi):Zi();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.31.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 o of i)if(o.type===\"childList\")for(const a of o.addedNodes)a.tagName===\"LINK\"&&a.rel===\"modulepreload\"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?o.credentials=\"include\":i.crossOrigin===\"anonymous\"?o.credentials=\"omit\":o.credentials=\"same-origin\",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Lt,O,Xi,Ge,Qr,eo,to,no,_r,jn,Wn,ro,ln={},un=[],Qa=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Vt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function yr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function G(e,t,n){var r,i,o,a={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?Lt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return Et(e,a,r,i,null)}function Et(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Xi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(o),o}function Ga(){return{current:null}}function Y(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function ht(e,t){if(t==null)return e.__?ht(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\"?ht(e):null}function Ka(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=Te({},t);o.__v=t.__v+1,O.vnode&&O.vnode(o),br(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ht(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,so(r,o,i),t.__e=t.__=null,o.__e!=n&&io(o)}}function io(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}),io(e)}function Qn(e){(!e.__d&&(e.__d=!0)&&Ge.push(e)&&!cn.__r++||Qr!=O.debounceRendering)&&((Qr=O.debounceRendering)||eo)(cn)}function cn(){for(var e,t=1;Ge.length;)Ge.length>t&&Ge.sort(to),e=Ge.shift(),t=Ge.length,Ka(e);cn.__r=0}function oo(e,t,n,r,i,o,a,s,u,l,d){var f,h,c,p,w,S,y,k=r&&r.__k||un,x=t.length;for(u=Ya(n,t,k,u,x),f=0;f<x;f++)(c=n.__k[f])!=null&&(h=c.__i!=-1&&k[c.__i]||ln,c.__i=f,S=br(e,c,h,i,o,a,s,u,l,d),p=c.__e,c.ref&&h.ref!=c.ref&&(h.ref&&vr(h.ref,null,c),d.push(c.ref,c.__c||p,c)),w==null&&p!=null&&(w=p),(y=!!(4&c.__u))||h.__k===c.__k?u=ao(c,u,e,y):typeof c.type==\"function\"&&S!==void 0?u=S:p&&(u=p.nextSibling),c.__u&=-7);return n.__e=w,u}function Ya(e,t,n,r,i){var o,a,s,u,l,d=n.length,f=d,h=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!=\"boolean\"&&typeof a!=\"function\"?(typeof a==\"string\"||typeof a==\"number\"||typeof a==\"bigint\"||a.constructor==String?a=e.__k[o]=Et(null,a,null,null,null):Vt(a)?a=e.__k[o]=Et(Y,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=Et(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,u=o+h,a.__=e,a.__b=e.__b+1,s=null,(l=a.__i=Ja(a,n,u,f))!=-1&&(f--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof a.type!=\"function\"&&(a.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,a.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<d;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ht(s)),uo(s,s));return r}function ao(e,t,n,r){var i,o;if(typeof e.type==\"function\"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=ao(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ht(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Re(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Vt(e)?e.some(function(n){Re(n,t)}):t.push(e)),t}function Ja(e,t,n,r){var i,o,a,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((l=t[a=i>=0?i--:o++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return a}return-1}function Gr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Qa.test(t)?n:n+\"px\"}function Gt(e,t,n,r,i){var o,a;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||Gr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Gr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")o=t!=(t=t.replace(no,\"$1\")),a=t.toLowerCase(),t=a in e||t==\"onFocusOut\"||t==\"onFocusIn\"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=_r,e.addEventListener(t,o?Wn:jn,o)):e.removeEventListener(t,o?Wn:jn,o);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 Kr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=_r++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function br(e,t,n,r,i,o,a,s,u,l){var d,f,h,c,p,w,S,y,k,x,A,C,_,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),o=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(y=t.props,k=\"prototype\"in z&&z.prototype.render,x=(d=z.contextType)&&r[d.__c],A=d?x?x.props.value:d.__:r,n.__c?S=(f=t.__c=n.__c).__=f.__E:(k?t.__c=f=new z(y,A):(t.__c=f=new Ne(y,A),f.constructor=z,f.render=Xa),x&&x.sub(f),f.state||(f.state={}),f.__n=r,h=f.__d=!0,f.__h=[],f._sb=[]),k&&f.__s==null&&(f.__s=f.state),k&&z.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Te({},f.__s)),Te(f.__s,z.getDerivedStateFromProps(y,f.__s))),c=f.props,p=f.state,f.__v=t,h)k&&z.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),k&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(k&&z.getDerivedStateFromProps==null&&y!==c&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,A),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,A)===!1){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),un.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&a.push(f);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,A),k&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(c,p,w)})}if(f.context=A,f.props=y,f.__P=e,f.__e=!1,C=O.__r,_=0,k)f.state=f.__s,f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),un.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++_<25);f.state=f.__s,f.getChildContext!=null&&(r=Te(Te({},r),f.getChildContext())),k&&!h&&f.getSnapshotBeforeUpdate!=null&&(w=f.getSnapshotBeforeUpdate(c,p)),P=d!=null&&d.type===Y&&d.key==null?lo(d.props.children):d,s=oo(e,Vt(P)?P:[P],t,n,r,i,o,a,s,u,l),f.base=t.__e,t.__u&=-161,f.__h.length&&a.push(f),S&&(f.__E=f.__=null)}catch(b){if(t.__v=null,u||o!=null)if(b.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o[o.indexOf(s)]=null,t.__e=s}else{for(T=o.length;T--;)yr(o[T]);Gn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||Gn(t);O.__e(b,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Za(n.__e,t,n,r,i,o,a,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function Gn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Gn))}function so(e,t,n){for(var r=0;r<n.length;r++)vr(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(o){o.call(i)})}catch(o){O.__e(o,i.__v)}})}function lo(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Vt(e)?e.map(lo):Te({},e)}function Za(e,t,n,r,i,o,a,s,u){var l,d,f,h,c,p,w,S=n.props||ln,y=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),o!=null){for(l=0;l<o.length;l++)if((c=o[l])&&\"setAttribute\"in c==!!k&&(k?c.localName==k:c.nodeType==3)){e=c,o[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(y);e=document.createElementNS(i,k,y.is&&y),s&&(O.__m&&O.__m(t,o),s=!1),o=null}if(k==null)S===y||s&&e.data==y||(e.data=y);else{if(o=o&&Lt.call(e.childNodes),!s&&o!=null)for(S={},l=0;l<e.attributes.length;l++)S[(c=e.attributes[l]).name]=c.value;for(l in S)c=S[l],l==\"dangerouslySetInnerHTML\"?f=c:l==\"children\"||l in y||l==\"value\"&&\"defaultValue\"in y||l==\"checked\"&&\"defaultChecked\"in y||Gt(e,l,null,c,i);for(l in y)c=y[l],l==\"children\"?h=c:l==\"dangerouslySetInnerHTML\"?d=c:l==\"value\"?p=c:l==\"checked\"?w=c:s&&typeof c!=\"function\"||S[l]===c||Gt(e,l,c,S[l],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),oo(t.type==\"template\"?e.content:e,Vt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,o,a,o?o[0]:n.__k&&ht(n,0),s,u),o!=null)for(l=o.length;l--;)yr(o[l]);s||(l=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||k==\"progress\"&&!p||k==\"option\"&&p!=S[l])&&Gt(e,l,p,S[l],i),l=\"checked\",w!=null&&w!=e[l]&&Gt(e,l,w,S[l],i))}return e}function vr(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 uo(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||vr(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){O.__e(o,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&uo(r[i],t,n||typeof e.type!=\"function\");n||yr(e.__e),e.__c=e.__=e.__e=void 0}function Xa(e,t,n){return this.constructor(e,n)}function xe(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],a=[],br(t,e=(!r&&n||t).__k=G(Y,null,[e]),i||ln,ln,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Lt.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),so(o,e,a)}function co(e,t){xe(e,t,co)}function es(e,t,n){var r,i,o,a,s=Te({},e.props);for(o in e.type&&e.type.defaultProps&&(a=e.type.defaultProps),t)o==\"key\"?r=t[o]:o==\"ref\"?i=t[o]:s[o]=t[o]===void 0&&a!=null?a[o]:t[o];return arguments.length>2&&(s.children=arguments.length>3?Lt.call(arguments,2):n),Et(e.type,s,r||e.key,i||e.ref,null)}function ot(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(o){this.props.value!=o.value&&r.forEach(function(a){a.__e=!0,Qn(a)})},this.sub=function(o){r.add(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){r&&r.delete(o),a&&a.call(o)}}),n.children}return t.__c=\"__cC\"+ro++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Lt=un.slice,O={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},Xi=0,Ne.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof e==\"function\"&&(e=e(Te({},n),this.props)),e&&Te(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Qn(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Qn(this))},Ne.prototype.render=Y,Ge=[],eo=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,to=function(e,t){return e.__v.__b-t.__v.__b},cn.__r=0,no=/(PointerCapture)$|Capture$/i,_r=0,jn=Kr(!1),Wn=Kr(!0),ro=0;var ts=0;function v(e,t,n,r,i,o){t||(t={});var a,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?a=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ts,__i:-1,__u:0,__source:i,__self:o};if(typeof e==\"function\"&&(a=e.defaultProps))for(s in a)u[s]===void 0&&(u[s]=a[s]);return O.vnode&&O.vnode(l),l}var Be,W,Nn,Yr,pt=0,fo=[],Q=O,Jr=Q.__b,Zr=Q.__r,Xr=Q.diffed,ei=Q.__c,ti=Q.unmount,ni=Q.__;function _t(e,t){Q.__h&&Q.__h(W,e,pt||t),pt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return pt=1,wr(mo,e)}function wr(e,t,n){var r=_t(Be++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):mo(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!o||o.call(this,s,u,l);var f=r.__c.props!==s;return d.some(function(h){if(h.__N){var c=h.__[0];h.__=h.__N,h.__N=void 0,c!==h.__[0]&&(f=!0)}}),o&&o.call(this,s,u,l)||f};W.__f=!0;var o=W.shouldComponentUpdate,a=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var d=o;o=void 0,i(s,u,l),o=d}a&&a.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function we(e,t){var n=_t(Be++,3);!Q.__s&&kr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function at(e,t){var n=_t(Be++,4);!Q.__s&&kr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function ae(e){return pt=5,de(function(){return{current:e}},[])}function ho(e,t,n){pt=6,at(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=_t(Be++,7);return kr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function he(e,t){return pt=8,de(function(){return e},t)}function K(e){var t=W.context[e.__c],n=_t(Be++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function po(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function go(){var e=_t(Be++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function ns(){for(var e;e=fo.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(tn),t.__h.some(Kn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Jr&&Jr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ni&&ni(e,t)},Q.__r=function(e){Zr&&Zr(e),Be=0;var t=(W=e.__c).__H;t&&(Nn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(tn),t.__h.some(Kn),t.__h=[],Be=0)),Nn=W},Q.diffed=function(e){Xr&&Xr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fo.push(t)!==1&&Yr===Q.requestAnimationFrame||((Yr=Q.requestAnimationFrame)||rs)(ns)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Nn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(tn),n.__h=n.__h.filter(function(r){return!r.__||Kn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),ei&&ei(e,t)},Q.unmount=function(e){ti&&ti(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{tn(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ri=typeof requestAnimationFrame==\"function\";function rs(e){var t,n=function(){clearTimeout(r),ri&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ri&&(t=requestAnimationFrame(n))}function tn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Kn(e){var t=W;e.__c=e.__(),W=t}function kr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function mo(e,t){return typeof t==\"function\"?t(e):t}const ii=e=>{let t;const n=new Set,r=(l,d)=>{const f=typeof l==\"function\"?l(t):l;if(!Object.is(f,t)){const h=t;t=d??(typeof f!=\"object\"||f===null)?f:Object.assign({},t,f),n.forEach(c=>c(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},is=(e=>e?ii(e):ii);function _o(e,t){for(var n in t)e[n]=t[n];return e}function Yn(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 yo(e,t){var n=t(),r=X({t:{__:n,u:t}}),i=r[0].t,o=r[1];return at(function(){i.__=n,i.u=t,Dn(i)&&o({t:i})},[e,n,t]),we(function(){return Dn(i)&&o({t:i}),e(function(){Dn(i)&&o({t:i})})},[e]),n}function Dn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function bo(e){e()}function vo(e){return e}function wo(){return[!1,bo]}var ko=at;function Jn(e,t){this.props=e,this.context=t}function os(e,t){function n(i){var o=this.props.ref,a=o==i.ref;return!a&&o&&(o.call?o(null):o.current=null),t?!t(this.props,i)||!a:Yn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,G(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Jn.prototype=new Ne).isPureReactComponent=!0,Jn.prototype.shouldComponentUpdate=function(e,t){return Yn(this.props,e)||Yn(this.state,t)};var oi=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),oi&&oi(e)};var as=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ss(e){function t(n){var r=_o({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=as,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ai=function(e,t){return e==null?null:Re(Re(e).map(t))},ls={map:ai,forEach:ai,count:function(e){return e?Re(e).length:0},only:function(e){var t=Re(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Re},us=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,o=t;o=o.__;)if((i=o.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}us(e,t,n,r)};var si=O.unmount;function So(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=_o({},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 So(r,t,n)})),e}function xo(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return xo(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 nn(){this.__u=0,this.o=null,this.__b=null}function Co(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function cs(e){var t,n,r,i=null;function o(a){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?G(i,a):null}return o.displayName=\"Lazy\",o.__f=!0,o}function Ct(){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),si&&si(e)},(nn.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=Co(r.__v),o=!1,a=function(){o||r.__z||(o=!0,n.__R=null,i?i(u):u())};n.__R=a;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]=xo(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(a,a)},nn.prototype.componentWillUnmount=function(){this.o=[]},nn.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]=So(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&G(Y,null,e.fallback);return i&&(i.__u&=-33),[G(Y,null,t.__a?null:e.children),i]};var li=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function fs(e){return this.getChildContext=function(){return e.context},e.children}function ds(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){xe(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,o){this.childNodes.push(i),t.h.insertBefore(i,o)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}xe(G(fs,{context:t.context},e.__v),t.v)}function hs(e,t){var n=G(ds,{__v:e,h:t});return n.containerInfo=t,n}(Ct.prototype=new Ne).__a=function(e){var t=this,n=Co(t.__v),r=t.l.get(e);return r[0]++,function(i){var o=function(){t.props.revealOrder?(r.push(i),li(t,e,r)):i()};n?n(o):o()}},Ct.prototype.render=function(e){this.i=null,this.l=new Map;var t=Re(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Ct.prototype.componentDidUpdate=Ct.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){li(e,n,t)})};var Io=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ps=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,gs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ms=/[A-Z0-9]/g,_s=typeof document<\"u\",ys=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function bs(e,t,n){return t.__k==null&&(t.textContent=\"\"),xe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function vs(e,t,n){return co(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ne.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ne.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ui=O.event;function ws(){}function ks(){return this.cancelBubble}function Ss(){return this.defaultPrevented}O.event=function(e){return ui&&(e=ui(e)),e.persist=ws,e.isPropagationStopped=ks,e.isDefaultPrevented=Ss,e.nativeEvent=e};var Sr,xs={enumerable:!1,configurable:!0,get:function(){return this.class}},ci=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},o=r.indexOf(\"-\")===-1;for(var a in n){var s=n[a];if(!(a===\"value\"&&\"defaultValue\"in n&&s==null||_s&&a===\"children\"&&r===\"noscript\"||a===\"class\"||a===\"className\")){var u=a.toLowerCase();a===\"defaultValue\"&&\"value\"in n&&n.value==null?a=\"value\":a===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?a=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ys(n.type)?u===\"onfocus\"?a=\"onfocusin\":u===\"onblur\"?a=\"onfocusout\":gs.test(a)&&(a=u):u=a=\"oninput\":o&&ps.test(a)?a=a.replace(ms,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[a=u]&&(a=\"oninputCapture\"),i[a]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",xs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Io,ci&&ci(e)};var fi=O.__r;O.__r=function(e){fi&&fi(e),Sr=e.__c};var di=O.diffed;O.diffed=function(e){di&&di(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),Sr=null};var Cs={ReactCurrentDispatcher:{current:{readContext:function(e){return Sr.__n[e.__c].props.value},useCallback:he,useContext:K,useDebugValue:po,useDeferredValue:vo,useEffect:we,useId:go,useImperativeHandle:ho,useInsertionEffect:ko,useLayoutEffect:at,useMemo:de,useReducer:wr,useRef:ae,useState:X,useSyncExternalStore:yo,useTransition:wo}}};function Is(e){return G.bind(null,e)}function wn(e){return!!e&&e.$$typeof===Io}function Es(e){return wn(e)&&e.type===Y}function As(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ps(e){return wn(e)?es.apply(null,arguments):e}function Ts(e){return!!e.__k&&(xe(null,e),!0)}function Ns(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ds=function(e,t){return e(t)},$s=function(e,t){return e(t)},zs=Y,Fs=wn,Kt={useState:X,useId:go,useReducer:wr,useEffect:we,useLayoutEffect:at,useInsertionEffect:ko,useTransition:wo,useDeferredValue:vo,useSyncExternalStore:yo,startTransition:bo,useRef:ae,useImperativeHandle:ho,useMemo:de,useCallback:he,useContext:K,useDebugValue:po,version:\"18.3.1\",Children:ls,render:bs,hydrate:vs,unmountComponentAtNode:Ts,createPortal:hs,createElement:G,createContext:ot,createFactory:Is,cloneElement:Ps,createRef:Ga,Fragment:Y,isValidElement:wn,isElement:Fs,isFragment:Es,isMemo:As,findDOMNode:Ns,Component:Ne,PureComponent:Jn,memo:os,forwardRef:ss,flushSync:$s,unstable_batchedUpdates:Ds,StrictMode:zs,Suspense:nn,SuspenseList:Ct,lazy:cs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Cs};const Rs=e=>e;function Os(e,t=Rs){const n=Kt.useSyncExternalStore(e.subscribe,Kt.useCallback(()=>t(e.getState()),[e,t]),Kt.useCallback(()=>t(e.getInitialState()),[e,t]));return Kt.useDebugValue(n),n}const Ms=e=>{const t=is(e),n=r=>Os(t,r);return Object.assign(n,t),n},Ls=(e=>Ms);var xr=Symbol.for(\"immer-nothing\"),At=Symbol.for(\"immer-draftable\"),te=Symbol.for(\"immer-state\");function oe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ge=Object,tt=ge.getPrototypeOf,Dt=\"constructor\",Bt=\"prototype\",Zn=\"configurable\",fn=\"enumerable\",rn=\"writable\",$t=\"value\",Me=e=>!!e&&!!e[te];function De(e){return e?Eo(e)||qt(e)||!!e[At]||!!e[Dt]?.[At]||Ut(e)||jt(e):!1}var Vs=ge[Bt][Dt].toString(),hi=new WeakMap;function Eo(e){if(!e||!gt(e))return!1;const t=tt(e);if(t===null||t===ge[Bt])return!0;const n=ge.hasOwnProperty.call(t,Dt)&&t[Dt];if(n===Object)return!0;if(!Ke(n))return!1;let r=hi.get(n);return r===void 0&&(r=Function.toString.call(n),hi.set(n,r)),r===Vs}function Ht(e,t,n=!0){nt(e)===0?(n?Reflect.ownKeys(e):ge.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function nt(e){const t=e[te];return t?t.type_:qt(e)?1:Ut(e)?2:jt(e)?3:0}var Pt=(e,t,n=nt(e))=>n===2?e.has(t):ge[Bt].hasOwnProperty.call(e,t),ze=(e,t,n=nt(e))=>n===2?e.get(t):e[t],dn=(e,t,n,r=nt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Bs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var qt=Array.isArray,Ut=e=>e instanceof Map,jt=e=>e instanceof Set,gt=e=>typeof e==\"object\",Ke=e=>typeof e==\"function\",$n=e=>typeof e==\"boolean\";function Hs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var qs=e=>gt(e)?e?.[te]:null,Fe=e=>e.copy_||e.base_,Cr=e=>e.modified_?e.copy_:e.base_;function Xn(e,t){if(Ut(e))return new Map(e);if(jt(e))return new Set(e);if(qt(e))return Array[Bt].slice.call(e);const n=Eo(e);if(t===!0||t===\"class_only\"&&!n){const r=ge.getOwnPropertyDescriptors(e);delete r[te];let i=Reflect.ownKeys(r);for(let o=0;o<i.length;o++){const a=i[o],s=r[a];s[rn]===!1&&(s[rn]=!0,s[Zn]=!0),(s.get||s.set)&&(r[a]={[Zn]:!0,[rn]:!0,[fn]:s[fn],[$t]:e[a]})}return ge.create(tt(e),r)}else{const r=tt(e);if(r!==null&&n)return{...e};const i=ge.create(r);return ge.assign(i,e)}}function Ir(e,t=!1){return kn(e)||Me(e)||!De(e)||(nt(e)>1&&ge.defineProperties(e,{set:Yt,add:Yt,clear:Yt,delete:Yt}),ge.freeze(e),t&&Ht(e,(n,r)=>{Ir(r,!0)},!1)),e}function Us(){oe(2)}var Yt={[$t]:Us};function kn(e){return e===null||!gt(e)?!0:ge.isFrozen(e)}var hn=\"MapSet\",pn=\"Patches\",pi=\"ArrayMethods\",gn={};function rt(e){const t=gn[e];return t||oe(0,e),t}var gi=e=>!!gn[e];function js(e,t){gn[e]||(gn[e]=t)}var zt,Ao=()=>zt,Ws=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:gi(hn)?rt(hn):void 0,arrayMethodsPlugin_:gi(pi)?rt(pi):void 0});function mi(e,t){t&&(e.patchPlugin_=rt(pn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function er(e){tr(e),e.drafts_.forEach(Qs),e.drafts_=null}function tr(e){e===zt&&(zt=e.parent_)}var _i=e=>zt=Ws(zt,e);function Qs(e){const t=e[te];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function yi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[te].modified_&&(er(t),oe(4)),De(e)&&(e=bi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[te].base_,e,t)}else e=bi(t,n);return Gs(t,e,!0),er(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==xr?e:void 0}function bi(e,t){if(kn(t))return t;const n=t[te];if(!n)return mn(t,e.handledSet_,e);if(!Sn(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);No(n,e)}return n.copy_}function Gs(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ir(t,n)}function Po(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Sn=(e,t)=>e.scope_===t,Ks=[];function To(e,t,n,r){const i=Fe(e),o=e.type_;if(r!==void 0&&ze(i,r,o)===t){dn(i,r,n,o);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Ht(i,(u,l)=>{if(Me(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const a=e.draftLocations_.get(t)??Ks;for(const s of a)dn(i,s,n,o)}function Ys(e,t,n){e.callbacks_.push(function(i){const o=t;if(!o||!Sn(o,i))return;i.mapSetPlugin_?.fixSetContents(o);const a=Cr(o);To(e,o.draft_??o,a,n),No(o,i)})}function No(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)}Po(e)}}function Js(e,t,n){const{scope_:r}=e;if(Me(n)){const i=n[te];Sn(i,r)&&i.callbacks_.push(function(){on(e);const a=Cr(i);To(e,n,a,t)})}else De(n)&&e.callbacks_.push(function(){const o=Fe(e);e.type_===3?o.has(n)&&mn(n,r.handledSet_,r):ze(o,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&mn(ze(e.copy_,t,e.type_),r.handledSet_,r)})}function mn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Me(e)||t.has(e)||!De(e)||kn(e)||(t.add(e),Ht(e,(r,i)=>{if(Me(i)){const o=i[te];if(Sn(o,n)){const a=Cr(o);dn(e,r,a,e.type_),Po(o)}}else De(i)&&mn(i,t,n)})),e}function Zs(e,t){const n=qt(e),r={type_:n?1:0,scope_:t?t.scope_:Ao(),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,o=_n;n&&(i=[r],o=Ft);const{revoke:a,proxy:s}=Proxy.revocable(i,o);return r.draft_=s,r.revoke_=a,[s,r]}var _n={get(e,t){if(t===te)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Fe(e);if(!Pt(i,t,e.type_))return Xs(e,i,t);const o=i[t];if(e.finalized_||!De(o)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Hs(t))return o;if(o===zn(e.base_,t)){on(e);const a=e.type_===1?+t:t,s=rr(e.scope_,o,e,a);return e.copy_[a]=s}return o},has(e,t){return t in Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=Do(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=zn(Fe(e),t),o=i?.[te];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Bs(n,i)&&(n!==void 0||Pt(e.base_,t,e.type_)))return!0;on(e),nr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Js(e,t,n)),!0},deleteProperty(e,t){return on(e),zn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),nr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[rn]:!0,[Zn]:e.type_!==1||t!==\"length\",[fn]:r[fn],[$t]:n[t]}},defineProperty(){oe(11)},getPrototypeOf(e){return tt(e.base_)},setPrototypeOf(){oe(12)}},Ft={};for(let e in _n){let t=_n[e];Ft[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Ft.deleteProperty=function(e,t){return Ft.set.call(this,e,t,void 0)};Ft.set=function(e,t,n){return _n.set.call(this,e[0],t,n,e[0])};function zn(e,t){const n=e[te];return(n?Fe(n):e)[t]}function Xs(e,t,n){const r=Do(t,n);return r?$t in r?r[$t]:r.get?.call(e.draft_):void 0}function Do(e,t){if(!(t in e))return;let n=tt(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tt(n)}}function nr(e){e.modified_||(e.modified_=!0,e.parent_&&nr(e.parent_))}function on(e){e.copy_||(e.assigned_=new Map,e.copy_=Xn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var el=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ke(t)&&!Ke(n)){const o=n;n=t;const a=this;return function(u=o,...l){return a.produce(u,d=>n.call(this,d,...l))}}Ke(n)||oe(6),r!==void 0&&!Ke(r)&&oe(7);let i;if(De(t)){const o=_i(this),a=rr(o,t,void 0);let s=!0;try{i=n(a),s=!1}finally{s?er(o):tr(o)}return mi(o,r),yi(i,o)}else if(!t||!gt(t)){if(i=n(t),i===void 0&&(i=t),i===xr&&(i=void 0),this.autoFreeze_&&Ir(i,!0),r){const o=[],a=[];rt(pn).generateReplacementPatches_(t,i,{patches_:o,inversePatches_:a}),r(o,a)}return i}else oe(1,t)},this.produceWithPatches=(t,n)=>{if(Ke(t))return(a,...s)=>this.produceWithPatches(a,u=>t(u,...s));let r,i;return[this.produce(t,n,(a,s)=>{r=a,i=s}),r,i]},$n(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),$n(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),$n(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){De(e)||oe(8),Me(e)&&(e=tl(e));const t=_i(this),n=rr(t,e,void 0);return n[te].isManual_=!0,tr(t),n}finishDraft(e,t){const n=e&&e[te];(!n||!n.isManual_)&&oe(9);const{scope_:r}=n;return mi(r,t),yi(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=rt(pn).applyPatches_;return Me(e)?r(e,t):this.produce(e,i=>r(i,t))}};function rr(e,t,n,r){const[i,o]=Ut(t)?rt(hn).proxyMap_(t,n):jt(t)?rt(hn).proxySet_(t,n):Zs(t,n);return(n?.scope_??Ao()).drafts_.push(i),o.callbacks_=n?.callbacks_??[],o.key_=r,n&&r!==void 0?Ys(n,o,r):o.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(o);const{patchPlugin_:l}=u;o.modified_&&l&&l.generatePatches_(o,[],u)}),i}function tl(e){return Me(e)||oe(10,e),$o(e)}function $o(e){if(!De(e)||kn(e))return e;const t=e[te];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Xn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Xn(e,!0);return Ht(n,(i,o)=>{dn(n,i,$o(o))},r),t&&(t.finalized_=!1),n}function nl(){function t(p,w=[]){if(p.key_!==void 0){const S=p.parent_.copy_??p.parent_.base_,y=qs(ze(S,p.key_)),k=ze(S,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||y!=null&&y.base_!==p.base_)return null;const x=p.parent_.type_===3;let A;if(x){const C=p.parent_;A=Array.from(C.drafts_.keys()).indexOf(p.key_)}else A=p.key_;if(!(x&&S.size>A||Pt(S,A)))return null;w.push(A)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let S=p;for(let y=0;y<w.length-1;y++){const k=w[y];if(S=ze(S,k),!gt(S)||S===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return S}const r=\"replace\",i=\"add\",o=\"remove\";function a(p,w,S){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:y,inversePatches_:k}=S;switch(p.type_){case 0:case 2:return u(p,w,y,k);case 1:return s(p,w,y,k);case 3:return l(p,w,y,k)}}function s(p,w,S,y){let{base_:k,assigned_:x}=p,A=p.copy_;A.length<k.length&&([k,A]=[A,k],[S,y]=[y,S]);const C=p.allIndicesReassigned_===!0;for(let _=0;_<k.length;_++){const P=A[_],T=k[_];if((C||x?.get(_.toString()))&&P!==T){const b=P?.[te];if(b&&b.modified_)continue;const N=w.concat([_]);S.push({op:r,path:N,value:c(P)}),y.push({op:r,path:N,value:c(T)})}}for(let _=k.length;_<A.length;_++){const P=w.concat([_]);S.push({op:i,path:P,value:c(A[_])})}for(let _=A.length-1;k.length<=_;--_){const P=w.concat([_]);y.push({op:o,path:P})}}function u(p,w,S,y){const{base_:k,copy_:x,type_:A}=p;Ht(p.assigned_,(C,_)=>{const P=ze(k,C,A),T=ze(x,C,A),z=_?Pt(k,C)?r:i:o;if(P===T&&z===r)return;const b=w.concat(C);S.push(z===o?{op:z,path:b}:{op:z,path:b,value:c(T)}),y.push(z===i?{op:o,path:b}:z===o?{op:i,path:b,value:c(P)}:{op:r,path:b,value:c(P)})})}function l(p,w,S,y){let{base_:k,copy_:x}=p,A=0;k.forEach(C=>{if(!x.has(C)){const _=w.concat([A]);S.push({op:o,path:_,value:C}),y.unshift({op:i,path:_,value:C})}A++}),A=0,x.forEach(C=>{if(!k.has(C)){const _=w.concat([A]);S.push({op:i,path:_,value:C}),y.unshift({op:o,path:_,value:C})}A++})}function d(p,w,S){const{patches_:y,inversePatches_:k}=S;y.push({op:r,path:[],value:w===xr?void 0:w}),k.push({op:r,path:[],value:p})}function f(p,w){return w.forEach(S=>{const{path:y,op:k}=S;let x=p;for(let P=0;P<y.length-1;P++){const T=nt(x);let z=y[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===Dt)&&oe(19),Ke(x)&&z===Bt&&oe(19),x=ze(x,z),gt(x)||oe(18,y.join(\"/\"))}const A=nt(x),C=h(S.value),_=y[y.length-1];switch(k){case r:switch(A){case 2:return x.set(_,C);case 3:oe(16);default:return x[_]=C}case i:switch(A){case 1:return _===\"-\"?x.push(C):x.splice(_,0,C);case 2:return x.set(_,C);case 3:return x.add(C);default:return x[_]=C}case o:switch(A){case 1:return x.splice(_,1);case 2:return x.delete(_);case 3:return x.delete(S.value);default:return delete x[_]}default:oe(17,k)}}),p}function h(p){if(!De(p))return p;if(qt(p))return p.map(h);if(Ut(p))return new Map(Array.from(p.entries()).map(([S,y])=>[S,h(y)]));if(jt(p))return new Set(Array.from(p).map(h));const w=Object.create(tt(p));for(const S in p)w[S]=h(p[S]);return Pt(p,At)&&(w[At]=p[At]),w}function c(p){return Me(p)?h(p):p}js(pn,{applyPatches_:f,generatePatches_:a,generateReplacementPatches_:d,getPath:t})}var Rt=new el,rl=Rt.produce,il=Rt.produceWithPatches.bind(Rt),dt=Rt.applyPatches.bind(Rt);const ol=e=>(t,n,r)=>(r.setState=(i,o,...a)=>{const s=typeof i==\"function\"?rl(i):i;return t(s,o,...a)},e(r.setState,n,r)),al=ol,sl=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),ll=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function ul(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function vi(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 wi(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const o=e[i];i++;let a=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))a+=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++,a+=e.slice(s,i);else{i=s;break}}else break;a&&(o===\".\"?n.push(a):r=a)}return{className:n.join(\" \"),id:r,endIdx:i}}function cl(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const o=e[t];t++;const a=t;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===o&&s<=0)break;t++}n[i]=e.slice(a,t),t<e.length&&t++}else{const o=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(o,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function yt(e){const t=[];let n=0,r=0;function i(o){o>r&&t.push({type:\"text\",value:e.slice(r,o),start:r,end:o})}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 o=n;n+=2;let a,s;if(e[n]===\".\"||e[n]===\"#\"){const p=wi(e,n);a=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=o+2,r=o;continue}const d=e.slice(l,n);n+=2;const{display:f,target:h}=ul(d),c={type:\"link\",display:f,target:h,start:o,end:n};a&&(c.className=a),s&&(c.id=s),t.push(c),r=n;continue}if(e[n]===\"{\"){const o=n;let a=e[n+1],s,u;if(a===\".\"||a===\"#\"){i(n);const l=wi(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const f=e[d];if(f===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"variable\",start:o,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=o+1,r=o;continue}if(f===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"temporary\",start:o,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=o+1,r=o;continue}if(f===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const c=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:c,scope:\"local\",start:o,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=o+1,r=o;continue}if(f!==void 0&&/[a-zA-Z]/.test(f)){n=d;let h=1;const c=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=o+1,r=o;continue}const p=e.slice(c,n);n++;const{name:w,rawArgs:S,isClose:y}=vi(p),k={type:\"macro\",name:w,rawArgs:S,isClose:y,start:o,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),r=n;continue}n=o+1,r=o;continue}if(a===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"variable\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"temporary\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"local\",start:o,end:n}),r=n;continue}n=o+1,r=o;continue}if(a!==void 0&&(a===\"/\"||/[a-zA-Z]/.test(a))){i(n),n++;let l=1;const d=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=o+1,r=o;continue}const f=e.slice(d,n);n++;const{name:h,rawArgs:c,isClose:p}=vi(f);t.push({type:\"macro\",name:h,rawArgs:c,isClose:p,start:o,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const o=n;let a=n+1;const s=e[a]===\"/\";s&&a++;const u=a;for(;a<e.length&&/[a-zA-Z0-9]/.test(e[a]);)a++;const l=e.slice(u,a).toLowerCase();if(l&&sl.has(l))if(s){for(;a<e.length&&/\\s/.test(e[a]);)a++;if(e[a]===\">\"){a++,i(o),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:o,end:a}),r=a,n=a;continue}}else{const d=cl(e,a);a=d.endIdx;let f=ll.has(l);if(e[a]===\"/\"&&(f=!0,a++),e[a]===\">\"){a++,i(o),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:f,start:o,end:a}),r=a,n=a;continue}}n++;continue}n++}return i(e.length),t}const zo=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function ir(e){zo.add(e.toLowerCase())}const ki={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},fl=new Set([\"if\",\"switch\",\"timed\"]);function bt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const a={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"variable\":{const o={type:\"variable\",name:i.name,scope:i.scope};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);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 a=n[n.length-1];if(a.node.type!==\"html\"||a.node.tag!==i.tag){const s=a.node.type===\"html\"?`</${a.node.tag}>`:`{/${a.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(a.node);break}const o={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:o,start:i.start});break}case\"macro\":{const o=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==o){const s=a.node.type===\"macro\"?`{/${a.node.name}}`:`</${a.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(a.node);break}if(ki[o]){const a=ki[o],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==a)throw new Error(`{${i.name}} without matching {${a}} (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(zo.has(o)){const a={type:\"macro\",name:o,rawArgs:i.rawArgs,children:[]};if(fl.has(o)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),a.branches=[s]}else i.className&&(a.className=i.className),i.id&&(a.id=i.id);n.push({node:a,start:i.start});break}{const a={type:\"macro\",name:o,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const o=i;throw new Error(`Unknown token type: ${o.type}`)}}if(n.length>0){const i=n[n.length-1],o=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${o} (opened at character ${i.start})`)}return t}function Er(){const e=I(r=>r.variables),t=I(r=>r.temporary),n=K(Ce);return de(()=>[e,t,n],[e,t,n])}const dl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,hl=/\\{[\\$_@][\\w.]+\\}/;function pl(e){return hl.test(e)}function gl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function ml(e,t,n,r){return e.replace(dl,(i,o)=>{const a=o[0],u=o.slice(1).split(\".\"),l=u[0];let d;return a===\"$\"?d=t[l]:a===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=gl(d,u)),d==null?\"\":String(d)})}function Ar(){const[e,t,n]=Er();return he(r=>r===void 0||!pl(r)?r:ml(r,e,t,n),[e,t,n])}function _l({name:e,scope:t,className:n,id:r}){const i=Ar();n=i(n),r=i(r);const o=K(Ce),a=e.split(\".\"),s=a[0],u=I(f=>t===\"variable\"?f.variables[s]:t===\"temporary\"?f.temporary[s]:void 0);let l;t===\"local\"?l=s in o?o[s]:void 0:l=u;for(let f=1;f<a.length;f++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=a[f];l=l[h]}const d=l==null?\"\":String(l);return n||r?v(\"span\",{id:r,class:n,children:d}):v(Y,{children:d})}function Fo(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 Ro(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let vt=!1,Wt=\"\",it=0,mt=null;function yl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Wt=n,it=0,mt=Fo(Ro(n)),vt=!0}function Oo(e,t){Wt=e,it=0,mt=Fo(Ro(e)),vt=!0;for(let n=0;n<t;n++)mt();it=t}function or(){vt=!1,Wt=\"\",it=0,mt=null}function yn(){return vt?{seed:Wt,pull:it}:null}function Pr(){return!vt||!mt?Math.random():(it++,mt())}function Mo(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Pr()*(t-e+1))+e}function bl(){return vt}function vl(){return Wt}function wl(){return it}const kl=500,Qe=new Map,Sl=/\\$(\\w+)/g,xl=/(?<![.\\w])_(\\w+)/g,Cl=/@(\\w+)/g;function Il(e){return e.replace(Sl,'variables[\"$1\"]').replace(xl,'temporary[\"$1\"]').replace(Cl,'locals[\"$1\"]')}function Tr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Il(n),n=\"\")}for(;r<e.length;){const o=e.charAt(r);if(o==='\"'||o===\"'\"){i();const a=o;let s=a;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===a){s+=a,r++;break}else s+=u,r++}t+=s;continue}if(o===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const a=e.charAt(r);if(a===\"\\\\\"&&r+1<e.length)t+=a+e.charAt(r+1),r+=2;else if(a===\"$\"&&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 if(l===\"\\\\\"&&r+1<e.length)u+=l+e.charAt(r+1),r++;else if(l==='\"'||l===\"'\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===l){u+=d,r++;break}else u+=d,r++}continue}else if(l===\"`\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===\"$\"&&e.charAt(r+1)===\"{\"){u+=\"${\",r+=2;let f=1;for(;r<e.length&&f>0;){const h=e.charAt(r);h===\"{\"?f++:h===\"}\"&&f--,f>0&&(u+=h),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Tr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(a===\"`\"){t+=\"`\",r++;break}else t+=a,r++}continue}n+=o,r++}return i(),t}const El=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Lo(e,t){const n=Qe.get(e);if(n)return Qe.delete(e),Qe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",El+t);if(Qe.set(e,r),Qe.size>kl){const i=Qe.keys().next().value;i!==void 0&&Qe.delete(i)}return r}let Jt=null,Si=null,xi=null;function Vo(){const e=I.getState(),{visitCounts:t,renderCounts:n}=e;if(Jt&&Si===t&&xi===n)return Jt;const r=c=>t[c??I.getState().currentPassage]??0,i=c=>r(c)>0,o=(...c)=>c.some(p=>r(p)>0),a=(...c)=>c.every(p=>r(p)>0),s=c=>n[c??I.getState().currentPassage]??0;return Jt={currentPassage:()=>{const c=I.getState();return c.storyData?.passages.get(c.currentPassage)},previousPassage:()=>{const c=I.getState();if(c.historyIndex<=0)return;const p=c.history[c.historyIndex-1]?.passage;return p?c.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:o,hasVisitedAll:a,rendered:s,hasRendered:c=>s(c)>0,hasRenderedAny:(...c)=>c.some(p=>s(p)>0),hasRenderedAll:(...c)=>c.every(p=>s(p)>0),random:Pr,randomInt:Mo},Si=t,xi=n,Jt}function xn(e,t,n,r={}){const o=`return (${Tr(e)});`;return Lo(o,o)(t,n,r,Vo())}function Bo(e,t,n,r={}){const i=Tr(e);Lo(\"exec:\"+i,i)(t,n,r,Vo())}function Al(e){const t=[];let n=\"\",r=0,i=null;for(let a=0;a<e.length;a++){const s=e[a];if(i){n+=s,s===i&&e[a-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 o=n.trim();return o&&t.push(o),t}function Pl({body:e,parentValues:t,ownKeys:n}){const r=K(ce),[i,o]=X({}),a={...t,...n,...i},s=ae(a);s.current=a;const u=he(()=>s.current,[]),l=he((f,h)=>{o(c=>({...c,[f]:h}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]);return v(Qt.Provider,{value:d,children:v(Ce.Provider,{value:a,children:Ie(e,{nobr:r,locals:a})})})}function Tl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=K(Ce),o=K(ce),[a,s,u]=Er(),l=r?.length?r:null;if(t.length===0||!n)return v(cr.Provider,{value:l,children:Ie(e,{nobr:o,locals:i})});const d=Al(n),f={};for(let h=0;h<t.length;h++){const c=t[h],p=d[h];let w;if(p!==void 0)try{w=xn(p,a,s,u)}catch{w=void 0}f[c.startsWith(\"@\")?c.slice(1):c]=w}return v(cr.Provider,{value:l,children:v(Pl,{body:e,parentValues:i,ownKeys:f})})}const Ho=new Map;function qo(e,t,n,r=!1){const i=n.filter(o=>o!==\"@children\");Ho.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Nl(e){return Ho.get(e.toLowerCase())}const Uo=new Map;function Dl(e,t){Uo.set(e.toLowerCase(),t)}function $l(e){return Uo.get(e.toLowerCase())}const jo=new Set;function zl(e){jo.add(e.toLowerCase())}function Fl(e){return jo.has(e.toLowerCase())}const Ci=document.createElement(\"i\");function Wo(e){const t=\"&\"+e+\";\";Ci.innerHTML=t;const n=Ci.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function _e(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function ie(e,t){return e.length>0?(_e(e,e.length,0,t),e):t}const ar={}.hasOwnProperty;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=(ar.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){ar.call(i,a)||(i[a]=[]);const s=o[a];Ml(i[a],Array.isArray(s)?s:s?[s]:[])}}}function Ml(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);_e(e,0,0,r)}function Ll(e){const t={};let n=-1;for(;++n<e.length;)Vl(t,e[n]);return t}function Vl(e,t){let n;for(n in t){const i=(ar.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o)i[a]=o[a]}}function Bl(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 Hl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Qo(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Hl[n]+\";\"}}function Ot(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Pe=qe(/[A-Za-z]/),me=qe(/[\\dA-Za-z]/),ql=qe(/[#-'*+\\--9=?A-Z^-~]/);function sr(e){return e!==null&&(e<32||e===127)}const lr=qe(/\\d/),Ul=qe(/[\\dA-Fa-f]/),jl=qe(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function se(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Wl=qe(/\\p{P}|\\p{S}/u),Ql=qe(/\\s/);function qe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Zt(e,t){const n=Qo(Gl(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),o=n.indexOf(\"#\"),a=n.indexOf(\"/\");return r<0||a>-1&&r>a||i>-1&&r>i||o>-1&&r>o||t.test(n.slice(0,r))?n:\"\"}function Gl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a=\"\";if(o===37&&me(e.charCodeAt(n+1))&&me(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const s=e.charCodeAt(n+1);o<56320&&s>56319&&s<57344?(a=String.fromCharCode(o,s),i=1):a=\"�\"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const Ii={}.hasOwnProperty,Ei=/^(https?|ircs?|mailto|xmpp)$/i,Kl=/^https?$/i;function Yl(e){const t=e||{};let n=!0;const r={},i=[[]],o=[],a=[],u=Ll([{enter:{blockQuote:M,codeFenced:ke,codeFencedFenceInfo:S,codeFencedFenceMeta:S,codeIndented:j,codeText:La,content:Ea,definition:wa,definitionDestinationString:Sa,definitionLabelString:S,definitionTitleString:S,emphasis:Oa,htmlFlow:Ra,htmlText:Hr,image:q,label:S,link:le,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:J,reference:S,resource:ut,resourceDestinationString:ct,resourceTitleString:S,setextHeading:Pa,strong:Ma},exit:{atxHeading:Na,atxHeadingSequence:Aa,autolinkEmail:Wa,autolinkProtocol:ja,blockQuote:Z,characterEscapeValue:kt,characterReferenceMarkerHexadecimal:qr,characterReferenceMarkerNumeric:qr,characterReferenceValue:Ua,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Fa,codeIndented:g,codeText:Va,codeTextData:kt,data:kt,definition:Ia,definitionDestinationString:xa,definitionLabelString:ka,definitionTitleString:Ca,emphasis:Ba,hardBreakEscape:Vr,hardBreakTrailing:Vr,htmlFlow:Br,htmlFlowData:kt,htmlText:Br,htmlTextData:kt,image:Lr,label:wt,labelText:ee,lineEnding:za,link:Lr,listOrdered:$,listUnordered:B,paragraph:pe,reference:P,referenceString:Le,resource:P,resourceDestinationString:Tn,resourceTitleString:va,setextHeading:$a,setextHeadingLineSequence:Da,setextHeadingText:Ta,strong:Ha,thematicBreak:qa}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:a},d={buffer:S,encode:_,getData:w,lineEndingIfNeeded:C,options:t,raw:x,resume:y,setData:p,tag:k};let f=t.defaultLineEnding;return h;function h(E){let F=-1,ne=0;const Se=[];let Ee=[],$e=[];for(;++F<E.length;)!f&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(f=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?Se.push(F):c(E.slice(Se.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?($e=ie($e,E.slice(ne,F)),ne=F):(Ee=ie(Ee,E.slice(ne,F+1)),ne=F+1));Ee=ie(Ee,$e),Ee=ie(Ee,E.slice(ne)),F=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const Ur=u[Ae[F][0]],jr=Ae[F][1].type,Wr=Ur[jr];Ii.call(Ur,jr)&&Wr&&Wr.call({sliceSerialize:Ae[F][2].sliceSerialize,...d},Ae[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function c(E){const F=E.length;let ne=0,Se=0,Ee=!1,$e;for(;++ne<F;){const Ae=E[ne];if(Ae[1]._container)$e=void 0,Ae[0]===\"enter\"?Se++:Se--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Se&&($e?$e=void 0:Ee=!0);break}default:$e=void 0}}E[0][1]._loose=Ee}function p(E,F){l[E]=F}function w(E){return l[E]}function S(){i.push([])}function y(){return i.pop().join(\"\")}function k(E){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(E))}function x(E){p(\"lastWasTag\"),i[i.length-1].push(E)}function A(){x(f||`\n`)}function C(){const E=i[i.length-1],F=E[E.length-1],ne=F?F.charCodeAt(F.length-1):null;ne===10||ne===13||ne===null||A()}function _(E){return w(\"ignoreEncode\")?E:Qo(E)}function P(){y()}function T(E){a.push(!E._loose),C(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){a.push(!E._loose),C(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function b(E){if(w(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&k(' start=\"'+_(String(F))+'\"')}}function N(){w(\"expectFirstItem\")?k(\">\"):U(),C(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),a.pop(),A(),k(\"</ol>\")}function B(){U(),a.pop(),A(),k(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&C(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){a.push(!1),C(),k(\"<blockquote>\")}function Z(){a.pop(),C(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function J(){a[a.length-1]||(C(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function pe(){a[a.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function ke(){C(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=y();k(' class=\"language-'+E+'\"')}function D(){const E=w(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){C(),k(\"<pre><code>\")}function g(){const E=w(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&A(),w(\"flowCodeSeenData\")&&C(),k(\"</code></pre>\"),E!==void 0&&E<2&&C(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){o.push({image:!0}),n=void 0}function le(){o.push({})}function ee(E){o[o.length-1].labelId=this.sliceSerialize(E)}function wt(){o[o.length-1].label=y()}function Le(E){o[o.length-1].referenceId=this.sliceSerialize(E)}function ut(){S(),o[o.length-1].destination=\"\"}function ct(){S(),p(\"ignoreEncode\",!0)}function Tn(){o[o.length-1].destination=y(),p(\"ignoreEncode\")}function va(){o[o.length-1].title=y()}function Lr(){let E=o.length-1;const F=o[E],ne=F.referenceId||F.labelId,Se=F.destination===void 0?r[Ot(ne)]:F;for(n=!0;E--;)if(o[E].image){n=void 0;break}F.image?(k('<img src=\"'+Zt(Se.destination,t.allowDangerousProtocol?void 0:Kl)+'\" alt=\"'),x(F.label),k('\"')):k('<a href=\"'+Zt(Se.destination,t.allowDangerousProtocol?void 0:Ei)+'\"'),k(Se.title?' title=\"'+Se.title+'\"':\"\"),F.image?k(\" />\"):(k(\">\"),x(F.label),k(\"</a>\")),o.pop()}function wa(){S(),o.push({})}function ka(E){y(),o[o.length-1].labelId=this.sliceSerialize(E)}function Sa(){S(),p(\"ignoreEncode\",!0)}function xa(){o[o.length-1].destination=y(),p(\"ignoreEncode\")}function Ca(){o[o.length-1].title=y()}function Ia(){const E=o[o.length-1],F=Ot(E.labelId);y(),Ii.call(r,F)||(r[F]=o[o.length-1]),o.pop()}function Ea(){p(\"slurpAllLineEndings\",!0)}function Aa(E){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),C(),k(\"<h\"+w(\"headingRank\")+\">\"))}function Pa(){S(),p(\"slurpAllLineEndings\")}function Ta(){p(\"slurpAllLineEndings\",!0)}function Na(){k(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function Da(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function $a(){const E=y();C(),k(\"<h\"+w(\"headingRank\")+\">\"),x(E),k(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function kt(E){x(_(this.sliceSerialize(E)))}function za(E){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){x(\" \");return}x(_(this.sliceSerialize(E)))}}function Fa(E){x(_(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Vr(){k(\"<br />\")}function Ra(){C(),Hr()}function Br(){p(\"ignoreEncode\")}function Hr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Oa(){k(\"<em>\")}function Ma(){k(\"<strong>\")}function La(){p(\"inCodeText\",!0),k(\"<code>\")}function Va(){p(\"inCodeText\"),k(\"</code>\")}function Ba(){k(\"</em>\")}function Ha(){k(\"</strong>\")}function qa(){C(),k(\"<hr />\")}function qr(E){p(\"characterReferenceType\",E.type)}function Ua(E){const F=this.sliceSerialize(E),ne=w(\"characterReferenceType\")?Bl(F,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Wo(F);x(_(ne)),p(\"characterReferenceType\")}function ja(E){const F=this.sliceSerialize(E);k('<a href=\"'+Zt(F,t.allowDangerousProtocol?void 0:Ei)+'\">'),x(_(F)),k(\"</a>\")}function Wa(E){const F=this.sliceSerialize(E);k('<a href=\"'+Zt(\"mailto:\"+F)+'\">'),x(_(F)),k(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&o++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Jl={tokenize:Zl};function Zl(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\"),o(s)}function o(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,a(s)}function a(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),o):(e.consume(s),a)}}const Xl={tokenize:eu},Ai={tokenize:tu};function eu(e){const t=this,n=[];let r=0,i,o,a;return s;function s(x){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,l)(x)}return l(x)}function u(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let C=A,_;for(;C--;)if(t.events[C][0]===\"exit\"&&t.events[C][1].type===\"chunkFlow\"){_=t.events[C][1].end;break}y(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={..._},P++;return _e(t.events,C+1,0,t.events.slice(A)),t.events.length=P,l(x)}return s(x)}function l(x){if(r===n.length){if(!i)return h(x);if(i.currentConstruct&&i.currentConstruct.concrete)return p(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ai,d,f)(x)}function d(x){return i&&k(),y(r),h(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,p(x)}function h(x){return t.containerState={},e.attempt(Ai,c,p)(x)}function c(x){return r++,n.push([t.currentConstruct,t.containerState]),h(x)}function p(x){if(x===null){i&&k(),y(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:o}),w(x)}function w(x){if(x===null){S(e.exit(\"chunkFlow\"),!0),y(0),e.consume(x);return}return R(x)?(e.consume(x),S(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(x),w)}function S(x,A){const C=t.sliceStream(x);if(A&&C.push(null),x.previous=o,o&&(o.next=x),o=x,i.defineSkip(x.start),i.write(C),t.parser.lazy[x.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<a&&(!i.events[_][1].end||i.events[_][1].end.offset>a))return;const P=t.events.length;let T=P,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(y(r),_=P;_<t.events.length;)t.events[_][1].end={...b},_++;_e(t.events,T+1,0,t.events.slice(P)),t.events.length=_}}function y(x){let A=n.length;for(;A-- >x;){const C=n[A];t.containerState=C[1],C[0].exit.call(t,e)}n.length=x}function k(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tu(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 bn(e){if(e===null||se(e)||Ql(e))return 1;if(Wl(e))return 2}function Cn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const ur={name:\"attention\",resolveAll:nu,tokenize:ru};function nu(e,t){let n=-1,r,i,o,a,s,u,l,d;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};Pi(f,-u),Pi(h,u),a={type:u>1?\"strongSequence\":\"emphasisSequence\",start:f,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},o={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...a.start},end:{...s.end}},e[r][1].end={...a.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ie(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ie(l,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"enter\",o,t]]),l=ie(l,Cn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ie(l,[[\"exit\",o,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=ie(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,_e(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function ru(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=bn(r);let o;return a;function a(u){return o=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===o)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),d=bn(u),f=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(o===42?f:f&&(i||!h)),l._close=!!(o===42?h:h&&(d||!f)),t(u)}}function Pi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const iu={name:\"autolink\",tokenize:ou};function ou(e,t,n){let r=0;return i;function i(c){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),o}function o(c){return Pe(c)?(e.consume(c),a):c===64?n(c):l(c)}function a(c){return c===43||c===45||c===46||me(c)?(r=1,s(c)):l(c)}function s(c){return c===58?(e.consume(c),r=0,u):(c===43||c===45||c===46||me(c))&&r++<32?(e.consume(c),s):(r=0,l(c))}function u(c){return c===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):c===null||c===32||c===60||sr(c)?n(c):(e.consume(c),u)}function l(c){return c===64?(e.consume(c),d):ql(c)?(e.consume(c),l):n(c)}function d(c){return me(c)?f(c):n(c)}function f(c){return c===46?(e.consume(c),r=0,d):c===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(c),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(c)}function h(c){if((c===45||me(c))&&r++<63){const p=c===45?h:f;return e.consume(c),p}return n(c)}}const In={partial:!0,tokenize:au};function au(e,t,n){return r;function r(o){return L(o)?H(e,i,\"linePrefix\")(o):i(o)}function i(o){return o===null||R(o)?t(o):n(o)}}const Go={continuation:{tokenize:lu},exit:uu,name:\"blockQuote\",tokenize:su};function su(e,t,n){const r=this;return i;function i(a){if(a===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(a),e.exit(\"blockQuoteMarker\"),o}return n(a)}function o(a){return L(a)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(a),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(a))}}function lu(e,t,n){const r=this;return i;function i(a){return L(a)?H(e,o,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(a):o(a)}function o(a){return e.attempt(Go,t,n)(a)}}function uu(e){e.exit(\"blockQuote\")}const Ko={name:\"characterEscape\",tokenize:cu};function cu(e,t,n){return r;function r(o){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(o),e.exit(\"escapeMarker\"),i}function i(o){return jl(o)?(e.enter(\"characterEscapeValue\"),e.consume(o),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(o)}}const Yo={name:\"characterReference\",tokenize:fu};function fu(e,t,n){const r=this;let i=0,o,a;return s;function s(f){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),u}function u(f){return f===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(f),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),o=31,a=me,d(f))}function l(f){return f===88||f===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(f),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),o=6,a=Ul,d):(e.enter(\"characterReferenceValue\"),o=7,a=lr,d(f))}function d(f){if(f===59&&i){const h=e.exit(\"characterReferenceValue\");return a===me&&!Wo(r.sliceSerialize(h))?n(f):(e.enter(\"characterReferenceMarker\"),e.consume(f),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return a(f)&&i++<o?(e.consume(f),d):n(f)}}const Ti={partial:!0,tokenize:hu},Ni={concrete:!0,name:\"codeFenced\",tokenize:du};function du(e,t,n){const r=this,i={partial:!0,tokenize:C};let o=0,a=0,s;return u;function u(_){return l(_)}function l(_){const P=r.events[r.events.length-1];return o=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=_,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(_)}function d(_){return _===s?(a++,e.consume(_),d):a<3?n(_):(e.exit(\"codeFencedFenceSequence\"),L(_)?H(e,f,\"whitespace\")(_):f(_))}function f(_){return _===null||R(_)?(e.exit(\"codeFencedFence\"),r.interrupt?t(_):e.check(Ti,w,A)(_)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(_))}function h(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),f(_)):L(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,c,\"whitespace\")(_)):_===96&&_===s?n(_):(e.consume(_),h)}function c(_){return _===null||R(_)?f(_):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(_))}function p(_){return _===null||R(_)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),f(_)):_===96&&_===s?n(_):(e.consume(_),p)}function w(_){return e.attempt(i,A,S)(_)}function S(_){return e.enter(\"lineEnding\"),e.consume(_),e.exit(\"lineEnding\"),y}function y(_){return o>0&&L(_)?H(e,k,\"linePrefix\",o+1)(_):k(_)}function k(_){return _===null||R(_)?e.check(Ti,w,A)(_):(e.enter(\"codeFlowValue\"),x(_))}function x(_){return _===null||R(_)?(e.exit(\"codeFlowValue\"),k(_)):(e.consume(_),x)}function A(_){return e.exit(\"codeFenced\"),t(_)}function C(_,P,T){let z=0;return b;function b(M){return _.enter(\"lineEnding\"),_.consume(M),_.exit(\"lineEnding\"),N}function N(M){return _.enter(\"codeFencedFence\"),L(M)?H(_,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(_.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,_.consume(M),B):z>=a?(_.exit(\"codeFencedFenceSequence\"),L(M)?H(_,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(_.exit(\"codeFencedFence\"),P(M)):T(M)}}}function hu(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Fn={name:\"codeIndented\",tokenize:gu},pu={partial:!0,tokenize:mu};function gu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,o,\"linePrefix\",5)(l)}function o(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?a(l):n(l)}function a(l){return l===null?u(l):R(l)?e.attempt(pu,a,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),a(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function mu(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):R(a)?(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),i):H(e,o,\"linePrefix\",5)(a)}function o(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):R(a)?i(a):n(a)}}const _u={name:\"codeText\",previous:bu,resolve:yu,tokenize:vu};function yu(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 bu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function vu(e,t,n){let r=0,i,o;return a;function a(f){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(f)}function s(f){return f===96?(e.consume(f),r++,s):(e.exit(\"codeTextSequence\"),u(f))}function u(f){return f===null?n(f):f===32?(e.enter(\"space\"),e.consume(f),e.exit(\"space\"),u):f===96?(o=e.enter(\"codeTextSequence\"),i=0,d(f)):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(f))}function l(f){return f===null||f===32||f===96||R(f)?(e.exit(\"codeTextData\"),u(f)):(e.consume(f),l)}function d(f){return f===96?(e.consume(f),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(f)):(o.type=\"codeTextData\",l(f))}}class wu{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 o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&St(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),St(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),St(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);St(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);St(this.left,n.reverse())}}}function St(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Jo(e){const t={};let n=-1,r,i,o,a,s,u,l;const d=new wu(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type===\"lineEndingBlank\"&&(o+=2),o<u.length&&u[o][1].type===\"content\"))for(;++o<u.length&&u[o][1].type!==\"content\";)u[o][1].type===\"chunkText\"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,ku(d,n)),n=t[n],l=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=d.get(o),a[1].type===\"lineEnding\"||a[1].type===\"lineEndingBlank\")a[0]===\"enter\"&&(i&&(d.get(i)[1].type=\"lineEndingBlank\"),a[1].type=\"lineEnding\",i=o);else if(!(a[1].type===\"linePrefix\"||a[1].type===\"listItemIndent\"))break;i&&(r[1].end={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return _e(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function ku(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const s=a.events,u=[],l={};let d,f,h=-1,c=n,p=0,w=0;const S=[w];for(;c;){for(;e.get(++i)[1]!==c;);o.push(i),c._tokenizer||(d=r.sliceStream(c),c.next||d.push(null),f&&a.defineSkip(c.start),c._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),c._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=c,c=c.next}for(c=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&&(w=h+1,S.push(w),c._tokenizer=void 0,c.previous=void 0,c=c.next);for(a.events=[],c?(c._tokenizer=void 0,c.previous=void 0):S.pop(),h=S.length;h--;){const y=s.slice(S[h],S[h+1]),k=o.pop();u.push([k,k+y.length-1]),e.splice(k,2,y)}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 Su={resolve:Cu,tokenize:Iu},xu={partial:!0,tokenize:Eu};function Cu(e){return Jo(e),e}function Iu(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?o(s):R(s)?e.check(xu,a,o)(s):(e.consume(s),i)}function o(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function a(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Eu(e,t,n){const r=this;return i;function i(a){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),H(e,o,\"linePrefix\")}function o(a){if(a===null||R(a))return n(a);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(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Zo(e,t,n,r,i,o,a,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),h):y===null||y===32||y===41||sr(y)?n(y):(e.enter(r),e.enter(a),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(y))}function h(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),c(y))}function c(y){return y===62?(e.exit(\"chunkString\"),e.exit(s),h(y)):y===null||y===60||R(y)?n(y):(e.consume(y),y===92?p:c)}function p(y){return y===60||y===62||y===92?(e.consume(y),c):c(y)}function w(y){return!d&&(y===null||y===41||se(y))?(e.exit(\"chunkString\"),e.exit(s),e.exit(a),e.exit(r),t(y)):d<l&&y===40?(e.consume(y),d++,w):y===41?(e.consume(y),d--,w):y===null||y===32||y===40||sr(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function Xo(e,t,n,r,i,o){const a=this;let s=0,u;return l;function l(c){return e.enter(r),e.enter(i),e.consume(c),e.exit(i),e.enter(o),d}function d(c){return s>999||c===null||c===91||c===93&&!u||c===94&&!s&&\"_hiddenFootnoteSupport\"in a.parser.constructs?n(c):c===93?(e.exit(o),e.enter(i),e.consume(c),e.exit(i),e.exit(r),t):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),f(c))}function f(c){return c===null||c===91||c===93||R(c)||s++>999?(e.exit(\"chunkString\"),d(c)):(e.consume(c),u||(u=!L(c)),c===92?h:f)}function h(c){return c===91||c===92||c===93?(e.consume(c),s++,f):f(c)}}function ea(e,t,n,r,i,o){let a;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),a=h===40?41:h,u):n(h)}function u(h){return h===a?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(o),l(h))}function l(h){return h===a?(e.exit(o),u(a)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===a||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?f:d)}function f(h){return h===a||h===92?(e.consume(h),d):d(h)}}function Tt(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Au={name:\"definition\",tokenize:Tu},Pu={partial:!0,tokenize:Nu};function Tu(e,t,n){const r=this;let i;return o;function o(c){return e.enter(\"definition\"),a(c)}function a(c){return Xo.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(c)}function s(c){return i=Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),c===58?(e.enter(\"definitionMarker\"),e.consume(c),e.exit(\"definitionMarker\"),u):n(c)}function u(c){return se(c)?Tt(e,l)(c):l(c)}function l(c){return Zo(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(c)}function d(c){return e.attempt(Pu,f,f)(c)}function f(c){return L(c)?H(e,h,\"whitespace\")(c):h(c)}function h(c){return c===null||R(c)?(e.exit(\"definition\"),r.parser.defined.push(i),t(c)):n(c)}}function Nu(e,t,n){return r;function r(s){return se(s)?Tt(e,i)(s):n(s)}function i(s){return ea(e,o,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function o(s){return L(s)?H(e,a,\"whitespace\")(s):a(s)}function a(s){return s===null||R(s)?t(s):n(s)}}const Du={name:\"hardBreakEscape\",tokenize:$u};function $u(e,t,n){return r;function r(o){return e.enter(\"hardBreakEscape\"),e.consume(o),i}function i(o){return R(o)?(e.exit(\"hardBreakEscape\"),t(o)):n(o)}}const zu={name:\"headingAtx\",resolve:Fu,tokenize:Ru};function Fu(e,t){let n=e.length-2,r=3,i,o;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},o={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},_e(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]])),e}function Ru(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),o(d)}function o(d){return e.enter(\"atxHeadingSequence\"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||se(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||se(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Ou=[\"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\"],Di=[\"pre\",\"script\",\"style\",\"textarea\"],Mu={concrete:!0,name:\"htmlFlow\",resolveTo:Bu,tokenize:Hu},Lu={partial:!0,tokenize:Uu},Vu={partial:!0,tokenize:qu};function Bu(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 Hu(e,t,n){const r=this;let i,o,a,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),f}function f(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),o=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):Pe(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function h(g){return g===45?(e.consume(g),i=2,c):g===91?(e.consume(g),i=5,s=0,p):Pe(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function c(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:p):n(g)}function w(g){return Pe(g)?(e.consume(g),a=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||se(g)){const q=g===47,le=a.toLowerCase();return!q&&!o&&Di.includes(le)?(i=1,r.interrupt?t(g):$(g)):Ou.includes(a.toLowerCase())?(i=6,q?(e.consume(g),y):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):o?k(g):x(g))}return g===45||me(g)?(e.consume(g),a+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function k(g){return L(g)?(e.consume(g),k):b(g)}function x(g){return g===47?(e.consume(g),b):g===58||g===95||Pe(g)?(e.consume(g),A):L(g)?(e.consume(g),x):b(g)}function A(g){return g===45||g===46||g===58||g===95||me(g)?(e.consume(g),A):C(g)}function C(g){return g===61?(e.consume(g),_):L(g)?(e.consume(g),C):x(g)}function _(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),_):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||se(g)?C(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?x(g):n(g)}function b(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),J):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ke):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Lu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Vu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function Z(g){return g===45?(e.consume(g),m):$(g)}function J(g){return g===47?(e.consume(g),a=\"\",pe):$(g)}function pe(g){if(g===62){const q=a.toLowerCase();return Di.includes(q)?(e.consume(g),D):$(g)}return Pe(g)&&a.length<8?(e.consume(g),a+=String.fromCharCode(g),pe):$(g)}function ke(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function qu(e,t,n){const r=this;return i;function i(a){return R(a)?(e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function Uu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(In,t,n)}}const ju={name:\"htmlText\",tokenize:Wu};function Wu(e,t,n){const r=this;let i,o,a;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),C):m===63?(e.consume(m),x):Pe(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),o=0,p):Pe(m)?(e.consume(m),k):n(m)}function d(m){return m===45?(e.consume(m),c):n(m)}function f(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(a=f,J(m)):(e.consume(m),f)}function h(m){return m===45?(e.consume(m),c):f(m)}function c(m){return m===62?Z(m):m===45?h(m):f(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(o++)?(e.consume(m),o===D.length?w:p):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):R(m)?(a=w,J(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?Z(m):m===93?(e.consume(m),y):w(m)}function k(m){return m===null||m===62?Z(m):R(m)?(a=k,J(m)):(e.consume(m),k)}function x(m){return m===null?n(m):m===63?(e.consume(m),A):R(m)?(a=x,J(m)):(e.consume(m),x)}function A(m){return m===62?Z(m):x(m)}function C(m){return Pe(m)?(e.consume(m),_):n(m)}function _(m){return m===45||me(m)?(e.consume(m),_):P(m)}function P(m){return R(m)?(a=P,J(m)):L(m)?(e.consume(m),P):Z(m)}function T(m){return m===45||me(m)?(e.consume(m),T):m===47||m===62||se(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),Z):m===58||m===95||Pe(m)?(e.consume(m),b):R(m)?(a=z,J(m)):L(m)?(e.consume(m),z):Z(m)}function b(m){return m===45||m===46||m===58||m===95||me(m)?(e.consume(m),b):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(a=N,J(m)):L(m)?(e.consume(m),N):z(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,B):R(m)?(a=$,J(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(a=B,J(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||se(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||se(m)?z(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function J(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),pe}function pe(m){return L(m)?H(e,ke,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):ke(m)}function ke(m){return e.enter(\"htmlTextData\"),a(m)}}const Nr={name:\"labelEnd\",resolveAll:Yu,resolveTo:Ju,tokenize:Zu},Qu={tokenize:Xu},Gu={tokenize:ec},Ku={tokenize:tc};function Yu(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&_e(e,0,e.length,n),e}function Ju(e,t){let n=e.length,r=0,i,o,a,s;for(;n--;)if(i=e[n][1],o){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(a){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(o=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(a=n);const u={type:e[o][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[o][1].start},end:{...e[a][1].end}},d={type:\"labelText\",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ie(s,e.slice(o+1,o+r+3)),s=ie(s,[[\"enter\",d,t]]),s=ie(s,Cn(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),s=ie(s,[[\"exit\",d,t],e[a-2],e[a-1],[\"exit\",l,t]]),s=ie(s,e.slice(a+1)),s=ie(s,[[\"exit\",u,t]]),_e(e,o,e.length,s),e}function Zu(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return s;function s(h){return o?o._inactive?f(h):(a=r.parser.defined.includes(Ot(r.sliceSerialize({start:o.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(Qu,d,a?d:f)(h):h===91?e.attempt(Gu,d,a?l:f)(h):a?d(h):f(h)}function l(h){return e.attempt(Ku,d,f)(h)}function d(h){return t(h)}function f(h){return o._balanced=!0,n(h)}}function Xu(e,t,n){return r;function r(f){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),i}function i(f){return se(f)?Tt(e,o)(f):o(f)}function o(f){return f===41?d(f):Zo(e,a,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(f)}function a(f){return se(f)?Tt(e,u)(f):d(f)}function s(f){return n(f)}function u(f){return f===34||f===39||f===40?ea(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(f):d(f)}function l(f){return se(f)?Tt(e,d)(f):d(f)}function d(f){return f===41?(e.enter(\"resourceMarker\"),e.consume(f),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(f)}}function ec(e,t,n){const r=this;return i;function i(s){return Xo.call(r,e,o,a,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function o(s){return r.parser.defined.includes(Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function a(s){return n(s)}}function tc(e,t,n){return r;function r(o){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(o),e.exit(\"referenceMarker\"),i}function i(o){return o===93?(e.enter(\"referenceMarker\"),e.consume(o),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(o)}}const nc={name:\"labelStartImage\",resolveAll:Nr.resolveAll,tokenize:rc};function rc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),o}function o(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),a):n(s)}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const ic={name:\"labelStartLink\",resolveAll:Nr.resolveAll,tokenize:oc};function oc(e,t,n){const r=this;return i;function i(a){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(a),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),o}function o(a){return a===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(a):t(a)}}const Rn={name:\"lineEnding\",tokenize:ac};function ac(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const an={name:\"thematicBreak\",tokenize:sc};function sc(e,t,n){let r=0,i;return o;function o(l){return e.enter(\"thematicBreak\"),a(l)}function a(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 fe={continuation:{tokenize:fc},exit:hc,name:\"list\",tokenize:cc},lc={partial:!0,tokenize:pc},uc={partial:!0,tokenize:dc};function cc(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return s;function s(c){const p=r.containerState.type||(c===42||c===43||c===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||c===r.containerState.marker:lr(c)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),c===42||c===45?e.check(an,n,l)(c):l(c);if(!r.interrupt||c===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(c)}return n(c)}function u(c){return lr(c)&&++a<10?(e.consume(c),u):(!r.interrupt||a<2)&&(r.containerState.marker?c===r.containerState.marker:c===41||c===46)?(e.exit(\"listItemValue\"),l(c)):n(c)}function l(c){return e.enter(\"listItemMarker\"),e.consume(c),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||c,e.check(In,r.interrupt?n:d,e.attempt(lc,h,f))}function d(c){return r.containerState.initialBlankLine=!0,o++,h(c)}function f(c){return L(c)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(c),e.exit(\"listItemPrefixWhitespace\"),h):n(c)}function h(c){return r.containerState.size=o+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(c)}}function fc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(In,i,o);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function o(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(uc,t,a)(s))}function a(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(fe,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function dc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type===\"listItemIndent\"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function hc(e){e.exit(this.containerState.type)}function pc(e,t,n){const r=this;return H(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!L(o)&&a&&a[1].type===\"listItemPrefixWhitespace\"?t(o):n(o)}}const $i={name:\"setextUnderline\",resolveTo:gc,tokenize:mc};function gc(e,t){let n=e.length,r,i,o;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),!o&&e[n][1].type===\"definition\"&&(o=n);const a={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",o?(e.splice(i,0,[\"enter\",a,t]),e.splice(o+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push([\"exit\",a,t]),e}function mc(e,t,n){const r=this;let i;return o;function o(l){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){f=r.events[d][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter(\"setextHeadingLine\"),i=l,a(l)):n(l)}function a(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 _c={tokenize:yc};function yc(e){const t=this,n=e.attempt(In,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Su,i)),\"linePrefix\")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEndingBlank\"),e.consume(o),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const bc={resolveAll:na()},vc=ta(\"string\"),wc=ta(\"text\");function ta(e){return{resolveAll:na(e===\"text\"?kc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,s);return a;function a(d){return l(d)?o(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),o(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const f=i[d];let h=-1;if(f)for(;++h<f.length;){const c=f[h];if(!c.previous||c.previous.call(r,r.previous))return!0}return!1}}}function na(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type===\"data\"&&(o=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function kc(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 o=i.length,a=-1,s=0,u;for(;o--;){const l=i[o];if(typeof l==\"string\"){for(a=l.length;l.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(l===-2)u=!0,s++;else if(l!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,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 Sc={42:fe,43:fe,45:fe,48:fe,49:fe,50:fe,51:fe,52:fe,53:fe,54:fe,55:fe,56:fe,57:fe,62:Go},xc={91:Au},Cc={[-2]:Fn,[-1]:Fn,32:Fn},Ic={35:zu,42:an,45:[$i,an],60:Mu,61:$i,95:an,96:Ni,126:Ni},Ec={38:Yo,92:Ko},Ac={[-5]:Rn,[-4]:Rn,[-3]:Rn,33:nc,38:Yo,42:ur,60:[iu,ju],91:ic,92:[Du,Ko],93:Nr,95:ur,96:_u},Pc={null:[ur,bc]},Tc={null:[42,95]},Nc={null:[]},Dc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Tc,contentInitial:xc,disable:Nc,document:Sc,flow:Ic,flowInitial:Cc,insideSpan:Pc,string:Ec,text:Ac},Symbol.toStringTag,{value:\"Module\"}));function $c(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={},o=[];let a=[],s=[];const u={attempt:P(C),check:P(_),consume:k,enter:x,exit:A,interrupt:P(_,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:c,write:f};let d=t.tokenize.call(l,u);return t.resolveAll&&o.push(t),l;function f(N){return a=ie(a,N),S(),a[a.length-1]!==null?[]:(T(t,0),l.events=Cn(o,l.events,l),l.events)}function h(N,$){return Fc(c(N),$)}function c(N){return zc(a,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 w(N){i[N.line]=N.column,b()}function S(){let N;for(;r._index<a.length;){const $=a[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)y($.charCodeAt(r._bufferIndex));else y($)}}function y(N){d=d(N)}function k(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,b()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=N}function x(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function C(N,$){T(N,$.from)}function _(N,$){$.restore()}function P(N,$){return B;function B(U,M,Z){let J,pe,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(ee){return wt;function wt(Le){const ut=Le!==null&&ee[Le],ct=Le!==null&&ee.null,Tn=[...Array.isArray(ut)?ut:ut?[ut]:[],...Array.isArray(ct)?ct:ct?[ct]:[]];return j(Tn)(Le)}}function j(ee){return J=ee,pe=0,ee.length===0?Z:g(ee[pe])}function g(ee){return wt;function wt(Le){return m=z(),ke=ee,ee.partial||(l.currentConstruct=ee),ee.name&&l.parser.constructs.disable.null.includes(ee.name)?le():ee.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,le)(Le)}}function q(ee){return N(ke,m),M}function le(ee){return m.restore(),++pe<J.length?g(J[pe]):Z}}}function T(N,$){N.resolveAll&&!o.includes(N)&&o.push(N),N.resolve&&_e(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function zc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const s=a[0];typeof s==\"string\"?a[0]=s.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function Fc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o==\"string\")a=o;else switch(o){case-5:{a=\"\\r\";break}case-4:{a=`\n`;break}case-3:{a=`\\r\n`;break}case-2:{a=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;a=\" \";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join(\"\")}function Rc(e){const r={constructs:Rl([Dc,...(e||{}).extensions||[]]),content:i(Jl),defined:[],document:i(Xl),flow:i(_c),lazy:{},string:i(vc),text:i(wc)};return r;function i(o){return a;function a(s){return $c(r,o,s)}}}function Oc(e){for(;!Jo(e););return e}const zi=/[\\0\\t\\n\\r]/g;function Mc(){let e=1,t=\"\",n=!0,r;return i;function i(o,a,s){const u=[];let l,d,f,h,c;for(o=t+(typeof o==\"string\"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t=\"\",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(zi.lastIndex=f,l=zi.exec(o),h=l&&l.index!==void 0?l.index:o.length,c=o.charCodeAt(h),!l){t=o.slice(f);break}if(c===10&&f===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<h&&(u.push(o.slice(f,h)),e+=h-f),c){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Lc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Yl(n)(Oc(Rc(n).document().write(Mc()(e,t,!0))))}const On={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Vc(){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=On[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=On[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,Bc)),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\"+On[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Bc(e,t){return t===\"|\"?t:e}class Hc{constructor(){this.map=[]}add(t,n,r){qc(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[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 o of i)t.push(o);i=r.pop()}this.map.length=0}}function qc(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 Uc(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 o=r.length-1;r[o]=r[o]===\"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 jc(){return{flow:{null:{name:\"table\",tokenize:Wc,resolveAll:Qc}}}}function Wc(e,t,n){const r=this;let i=0,o=0,a;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\"?_:u;return B===_&&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||(a=!0,o+=1),d(b)}function d(b){return b===null?n(b):R(b)?o>1?(o=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),c):n(b):L(b)?H(e,d,\"whitespace\")(b):(o+=1,a&&(a=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),a=!0,d):(e.enter(\"data\"),f(b)))}function f(b){return b===null||b===124||se(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?h:f)}function h(b){return b===92||b===124?(e.consume(b),f):f(b)}function c(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),a=!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?S(b):b===124?(a=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),w):C(b)}function w(b){return L(b)?H(e,S,\"whitespace\")(b):S(b)}function S(b){return b===58?(o+=1,a=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),y):b===45?(o+=1,y(b)):b===null||R(b)?A(b):C(b)}function y(b){return b===45?(e.enter(\"tableDelimiterFiller\"),k(b)):C(b)}function k(b){return b===45?(e.consume(b),k):b===58?(a=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),x):(e.exit(\"tableDelimiterFiller\"),x(b))}function x(b){return L(b)?H(e,A,\"whitespace\")(b):A(b)}function A(b){return b===124?p(b):b===null||R(b)?!a||i!==o?C(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):C(b)}function C(b){return n(b)}function _(b){return e.enter(\"tableRow\"),P(b)}function P(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),P):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,P,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||se(b)?(e.exit(\"data\"),P(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Qc(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],a=[0,0,0,0],s=!1,u=0,l,d,f;const h=new Hc;for(;++n<e.length;){const c=e[n],p=c[1];c[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Fi(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,f=void 0,o=[0,0,0,0],a=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],f=Xt(h,t,o,i,void 0,f),o=[0,0,0,0]),a[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],f=Xt(h,t,o,i,void 0,f)),o=a,a=[o[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,o[1]!==0?(a[0]=a[1],f=Xt(h,t,o,i,n,f)):a[1]!==0&&(f=Xt(h,t,a,i,n,f)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(a[3]=n)}for(u!==0&&Fi(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const c=t.events[n];c[0]===\"enter\"&&c[1].type===\"table\"&&(c[1]._align=Uc(t.events,n))}return e}function Xt(e,t,n,r,i,o){const a=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(o.end=Object.assign({},ft(t.events,n[0])),e.add(n[0],0,[[\"exit\",o,t]]));const u=ft(t.events,n[1]);if(o={type:a,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",o,t]]),n[2]!==0){const l=ft(t.events,n[2]),d=ft(t.events,n[3]),f={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",f,t]]),r!==2){const h=t.events[n[2]],c=t.events[n[3]];if(h[1].end=Object.assign({},c[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",f,t]])}return i!==void 0&&(o.end=Object.assign({},ft(t.events,i)),e.add(i,0,[[\"exit\",o,t]]),o=void 0),o}function Fi(e,t,n,r,i){const o=[],a=ft(t.events,n);i&&(i.end=Object.assign({},a),o.push([\"exit\",i,t])),r.end=Object.assign({},a),o.push([\"exit\",r,t]),e.add(n+1,0,o)}function ft(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Gc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Kc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,s){let u=-1;for(;++u<a.length;)if(a[u][0]===\"enter\"&&a[u][1].type===\"strikethroughSequenceTemporary\"&&a[u][1]._close){let l=u;for(;l--;)if(a[l][0]===\"exit\"&&a[l][1].type===\"strikethroughSequenceTemporary\"&&a[l][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[l][1].end.offset-a[l][1].start.offset){a[u][1].type=\"strikethroughSequence\",a[l][1].type=\"strikethroughSequence\";const d={type:\"strikethrough\",start:Object.assign({},a[l][1].start),end:Object.assign({},a[u][1].end)},f={type:\"strikethroughText\",start:Object.assign({},a[l][1].end),end:Object.assign({},a[u][1].start)},h=[[\"enter\",d,s],[\"enter\",a[l][1],s],[\"exit\",a[l][1],s],[\"enter\",f,s]],c=s.parser.constructs.insideSpan.null;c&&_e(h,h.length,0,Cn(c,a.slice(l+1,u),s)),_e(h,h.length,0,[[\"exit\",f,s],[\"enter\",a[u][1],s],[\"exit\",a[u][1],s],[\"exit\",d,s]]),_e(a,l-1,u-l+3,h),u=l+h.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type===\"strikethroughSequenceTemporary\"&&(a[u][1].type=\"data\");return a}function o(a,s,u){const l=this.previous,d=this.events;let f=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(a.enter(\"strikethroughSequenceTemporary\"),c(p))}function c(p){const w=bn(l);if(p===126)return f>1?u(p):(a.consume(p),f++,c);if(f<2&&!n)return u(p);const S=a.exit(\"strikethroughSequenceTemporary\"),y=bn(p);return S._open=!y||y===2&&!!w,S._close=!w||w===2&&!!y,s(p)}}}function Yc(e){return Lc(e,{allowDangerousHtml:!0,extensions:[jc(),Kc(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[Vc(),Gc()]})}const Jc={update:()=>{},getValues:()=>({})},Ce=ot({}),Qt=ot(Jc),ce=ot(!1),cr=ot(null);function Zc(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const o of Array.from(r.querySelectorAll(\":scope > p\")))o.replaceWith(...Array.from(o.childNodes));const i=Array.from(r.childNodes).map((o,a)=>ra(o,a,t));return v(Y,{children:i})}function ra(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,o=r.getAttribute(\"data-tw\");if(o!=null)return n[parseInt(o,10)];const a={key:t};for(const u of Array.from(r.attributes))a[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>ra(u,l,n));return G(i,a,...s)}return null}function Xc({node:e}){const t=Ar(),n=K(ce),r=K(Ce),i={};for(const[o,a]of Object.entries(e.attributes))i[o]=t(a)??a;return G(e.tag,i,e.children.length>0?Ie(e.children,{nobr:n,locals:r}):void 0)}function ef(){const e=K(cr),t=K(ce),n=K(Ce);return!e||e.length===0?null:v(Y,{children:Ie(e,{nobr:t,locals:n})})}function tf(e,t){if(Fl(e.name))return null;const n=Nl(e.name);if(n)return v(Tl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=$l(e.name);return r?v(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):v(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function fr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?v(ef,{},t):v(_l,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return tf(e,t);case\"html\":return v(Xc,{node:e},t);default:return e}}function ia(e){return e.length===0?null:e.map((t,n)=>fr(t,n))}function nf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function rf(e,t){const n=I.getState(),r=e.name.split(\".\"),i=r[0];let o;e.scope===\"variable\"?o=n.variables[i]:e.scope===\"temporary\"?o=n.temporary[i]:o=t[i];for(let a=1;a<r.length;a++){if(o==null||typeof o!=\"object\")return\"\";o=o[r[a]]}return o==null?\"\":String(o)}function Ie(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>fr(s,u));const r=[];let i=\"\";const o=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value;else if(u.type===\"variable\"&&nf(i))i+=rf(u,o);else{const l=r.length;r.push(fr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const a=Yc(i);return Zc(a,r,t?.nobr)}function of(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||i.history.length===0||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function af(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||t.history.length===0||typeof t.historyIndex!=\"number\")}const sf=\"spindle\",lf=1;let en=null,Mn=null;function Ue(){return Mn||(Mn={saves:new Map,playthroughs:new Map,meta:new Map}),Mn}function uf(){return en||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(en=new Promise((e,t)=>{const n=indexedDB.open(sf,lf);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)}),en))}function je(e,t){return uf().then(n=>n.transaction(e,t).objectStore(e))}function We(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function En(e){try{const t=await je(\"saves\",\"readwrite\");await We(t.put(e))}catch{Ue().saves.set(e.meta.id,e)}}async function An(e){try{const t=await je(\"saves\",\"readonly\");return await We(t.get(e))??void 0}catch{return Ue().saves.get(e)}}async function cf(e){try{const t=await je(\"saves\",\"readwrite\");await We(t.delete(e))}catch{Ue().saves.delete(e)}}async function ff(e){try{const n=(await je(\"saves\",\"readonly\")).index(\"ifid\");return await We(n.getAll(e))??[]}catch{return[...Ue().saves.values()].filter(t=>t.meta.ifid===e)}}async function oa(e){try{const t=await je(\"playthroughs\",\"readwrite\");await We(t.put(e))}catch{Ue().playthroughs.set(e.id,e)}}async function Dr(e){try{const n=(await je(\"playthroughs\",\"readonly\")).index(\"ifid\");return await We(n.getAll(e))??[]}catch{return[...Ue().playthroughs.values()].filter(t=>t.ifid===e)}}async function $r(e){try{const t=await je(\"meta\",\"readonly\"),n=await We(t.get(e));return n?n.value:void 0}catch{return Ue().meta.get(e)}}async function aa(e,t){try{const n=await je(\"meta\",\"readwrite\");await We(n.put({key:e,value:t}))}catch{Ue().meta.set(e,t)}}const sa=new Map,Pn=new Map;function df(e,t){sa.set(e,t),Pn.set(t,e)}function hf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function re(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}if(r instanceof Map){const s=new Map;t.set(i,s);for(const[u,l]of r)s.set(n(u),n(l));return s}if(r instanceof Set){const s=new Set;t.set(i,s);for(const u of r)s.add(n(u));return s}const o=i.constructor;if(Pn.get(o)!==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(hf(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 Ye=\"__spindle_class__\",Je=\"__spindle_data__\";function Xe(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),{[Ye]:\"__Date__\",[Je]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[Ye]:\"__RegExp__\",[Je]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}if(r instanceof Map){const u=[...r].map(([l,d])=>[n(l),n(d)]);return t.delete(i),{[Ye]:\"__Map__\",[Je]:{entries:u}}}if(r instanceof Set){const u=[...r].map(l=>n(l));return t.delete(i),{[Ye]:\"__Set__\",[Je]:{entries:u}}}const o=i.constructor,a=Pn.get(o);if(a!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Ye]:a,[Je]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function et(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(a=>t(a));const r=n;if(Ye in r&&Je in r){const a=r[Ye],s=r[Je];if(a===\"__Date__\")return new Date(s.iso);if(a===\"__RegExp__\")return new RegExp(s.source,s.flags);if(a===\"__Map__\"){const d=s.entries;return new Map(d.map(([f,h])=>[t(f),t(h)]))}if(a===\"__Set__\"){const d=s.entries;return new Set(d.map(f=>t(f)))}const u=sa.get(a);if(!u){console.warn(`spindle: Class \"${a}\" not registered. Falling back to plain object.`);const d={};for(const f of Object.keys(s))d[f]=t(s[f]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(Pn.has(i))return n;const o={};for(const a of Object.keys(r))o[a]=t(r[a]);return o}return t(e)}let dr=null,hr=null,Ri=!1;function pf(e){dr=e}function gf(e){hr=e}function mf(e){if(hr)try{const i=new Function(\"passage\",\"variables\",hr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(dr)try{const r=dr(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 _f(){Ri||(Ri=!0)}async function Oi(e){const n=(await Dr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await oa(i),await aa(`currentPlaythroughId.${e}`,r),r}async function yf(e){return $r(`currentPlaythroughId.${e}`)}async function la(e,t,n,r={}){const i=new Date().toISOString(),o={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:mf(n),passage:n.passage,custom:r},a=re(n);a.variables=Xe(a.variables),a.history=a.history.map(u=>({...u,variables:Xe(u.variables)}));const s={meta:o,payload:a};return await En(s),s}async function ua(e,t){const n=await An(e);if(!n)return;const r=re(t);r.variables=Xe(r.variables),r.history=r.history.map(o=>({...o,variables:Xe(o.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await En(i),i}async function bf(e){const t=await An(e);if(!t)return;const n=t.payload;return n.variables=et(n.variables),n.history=n.history.map(r=>({...r,variables:et(r.variables)})),n}async function vf(e){await cf(e)}async function wf(e,t){const n=await An(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await En(r)}async function kf(e){const[t,n]=await Promise.all([ff(e),Dr(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 o=[],a=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of a){const u=i.get(s.id)??[];o.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||o.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return o}const ca=\"autosave.\";async function Sf(e,t,n){const r=`${ca}${e}`,i=await $r(r);if(i){const a=await ua(i,n);if(a)return a}const o=await la(e,t,n,{isAutosave:!0});return await aa(r,o.meta.id),o}async function xf(e){const t=`${ca}${e}`,n=await $r(t);if(n)return bf(n)}const zr=\"spindle.session.\";function Cf(e,t){try{sessionStorage.setItem(`${zr}${e}`,JSON.stringify(t))}catch{}}function If(e){try{const t=sessionStorage.getItem(`${zr}${e}`);if(!t)return;const n=JSON.parse(t);if(!af(n))return;const r=n;return r.variables=et(r.variables),r.history=r.history.map(i=>({...i,variables:et(i.variables)})),r}catch{return}}function Ef(e){try{sessionStorage.removeItem(`${zr}${e}`)}catch{}}async function Af(e){const t=await An(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Pf(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=re(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Dr(t)).some(o=>o.id===n.meta.playthroughId)){const o={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await oa(o)}return await En(n),n}function fa(){const e=I.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=yt(t.content),i=bt(r),o=document.createElement(\"div\");o.style.display=\"none\",document.body.appendChild(o),xe(G(()=>Ie(i),null),o)}const n=e.storyData.passages.get(\"SaveTitle\");n&&gf(n.content)}let da=0,ve=[],Ln=!1,st=[],Nt=null,Oe=null;function Fr(e){const t=I.getState();try{return!!xn(e,t.variables,t.temporary)}catch{return!1}}function ha(e,t){const n=da++,r=typeof t==\"function\",i=r?void 0:t,o=r?t:void 0,a={id:n,name:i?.name,condition:e,callback:o,options:i,lastResult:Fr(e),priority:i?.priority??0};return ve.push(a),ve.sort((s,u)=>u.priority-s.priority),()=>{ve=ve.filter(s=>s.id!==n)}}function pa(e){ve=ve.filter(t=>t.name!==e)}function Tf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=I.getState();Bo(n.run,r.variables,r.temporary)}n.dialog&&(st.push({passageName:n.dialog}),Nt?.()),n.goto&&I.getState().navigate(n.goto)}}const Nf=10;function Df(){if(!Ln){Ln=!0;try{for(let e=0;e<Nf;e++){let t=!1;const n=[...ve];for(const r of n){if(!ve.includes(r))continue;const i=Fr(r.condition),o=!r.lastResult;r.lastResult=i,i&&o&&(t=!0,r.options?.once&&(ve=ve.filter(a=>a.id!==r.id)),Tf(r))}if(!t)break}}finally{Ln=!1}}}function $f(){for(const e of ve)e.lastResult=Fr(e.condition)}function zf(){ve=[],st=[],da=0,Oe?.closeAll()}function Ff(e){return Nt=e,st.length>0&&e(),()=>{Nt===e&&(Nt=null)}}function Rf(){return st.shift()}function Of(){return st.length}function Mf(e){Oe?Oe.push(e):(st.push(e),Nt?.())}function Lf(){st=[]}function Vf(e){return Oe=e,()=>{Oe===e&&(Oe=null)}}function Bf(){Oe?.close()}function Hf(){Lf(),Oe?.closeAll()}function qf(){return Oe?.isOpen()??!1}nl();const Uf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ze={},ye=[],Ve={};function Mi(e){return e.map(t=>({...t,value:t.value!==void 0?re(t.value):void 0}))}function Li(e,t){const[,n,r]=il(e,i=>{const o=i;for(const a of Object.keys(o))a in t||delete o[a];for(const[a,s]of Object.entries(t))o[a]=s});return{forward:Mi(n),inverse:Mi(r)}}function jf(e){let t=Ze;for(let n=0;n<e;n++)t=dt(t,ye[n].forward);return t}let be=[];function Vn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:o,visitCounts:a,renderCounts:s}=e();if(t){if(be.length>i.length&&(be.length=i.length),be.length<i.length)if(i.length-be.length===1){const l=i.length-1;be[l]={passage:i[l].passage,variables:Xe(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ze;for(let d=0;d<i.length;d++)if(d>0&&(l=dt(l,ye[d-1].forward)),d>=be.length){const f=d===i.length-1?r:l;be[d]={passage:i[d].passage,variables:Xe(f),timestamp:i[d].timestamp,prng:i[d].prng}}}Cf(t.ifid,{passage:n,variables:Xe(r),history:be,historyIndex:o,visitCounts:a,renderCounts:s,prng:yn()})}}function Vi(e){Ze=e,ye=[],Ve=e,be=[]}function Bi(e){e?.prng?Oo(e.prng.seed,e.prng.pull):e&&or()}const I=Ls()(al((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 o=re(r);Vi(re(o)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=o,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}}),Ve=t().variables;const a=n.ifid;_f().then(async()=>{const s=await yf(a);if(s)e(u=>{u.playthroughId=s});else{const u=await Oi(a);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(Uf.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 o=Li(Ve,i);e(a=>{a.temporary={},a.currentPassage=n,a.history=a.history.slice(0,a.historyIndex+1),ye.length=a.historyIndex,ye.push(o),a.history.push({passage:n,timestamp:Date.now(),prng:yn()});const s=a.history.length-a.maxHistory;if(s>0){for(let u=0;u<s;u++)Ze=dt(Ze,ye[u].forward);a.history=a.history.slice(s),ye=ye.slice(s),be=be.slice(s)}a.historyIndex=a.history.length-1,a.visitCounts[n]=(a.visitCounts[n]??0)+1,a.renderCounts[n]=(a.renderCounts[n]??0)+1}),Ve=t().variables,Vn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=re(dt(r,ye[n-1].inverse));e(o=>{o.historyIndex--,o.currentPassage=o.history[o.historyIndex].passage,o.variables=i,o.temporary={}}),Ve=t().variables,Bi(t().history[t().historyIndex]),Vn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const o=re(dt(i,ye[n].forward));e(a=>{a.historyIndex++,a.currentPassage=a.history[a.historyIndex].passage,a.variables=o,a.temporary={}}),Ve=t().variables,Bi(t().history[t().historyIndex]),Vn(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;or(),zf();const o=re(r);Vi(re(o)),e(a=>{a.currentPassage=i.name,a.variables=o,a.temporary={},a.history=[{passage:i.name,timestamp:Date.now()}],a.historyIndex=0,a.visitCounts={[i.name]:1},a.renderCounts={[i.name]:1}}),Ve=t().variables,fa(),Ef(n.ifid),Oi(n.ifid).then(a=>{e(s=>{s.playthroughId=a})}).catch(a=>console.error(\"spindle: failed to start new playthrough\",a))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(o=>{o.saveError=null}),Sf(n.ifid,r,i).then(()=>{e(o=>{o.saveVersion++})}).catch(o=>{console.error(\"spindle: failed to quick save\",o),e(a=>{a.saveError=o instanceof Error?o.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),xf(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:o,visitCounts:a,renderCounts:s}=t(),u=[];let l=Ze;for(let d=0;d<i.length;d++)d>0&&(l=dt(l,ye[d-1].forward)),u.push({passage:i[d].passage,variables:re(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:re(r),history:u,historyIndex:o,visitCounts:{...a},renderCounts:{...s},prng:yn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=et(n.history[0]?.variables??{}),i=[];let o=r;for(let a=1;a<n.history.length;a++){const s=et(n.history[a].variables);i.push(Li(o,s)),o=s}Ze=re(r),ye=i,be=[],e(a=>{a.currentPassage=n.passage,a.variables=et(n.variables),a.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),a.historyIndex=Math.max(0,Math.min(n.historyIndex,a.history.length-1)),a.visitCounts=n.visitCounts??{},a.renderCounts=n.renderCounts??{},a.temporary={}}),Ve=t().variables,n.prng?Oo(n.prng.seed,n.prng.pull):or()},getHistoryVariables:n=>re(jf(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}}))),Wf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Qf(){const t=I(o=>o.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Wf,r=t?.tags.includes(\"nobr\")??!1,i=de(()=>{try{const o=yt(n),a=bt(o);return v(Y,{children:ia(a)})}catch(o){return v(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",o instanceof Error?o.message:String(o)]})}},[n]);return r?v(ce.Provider,{value:!0,children:i}):i}const ga=ot(null);function Rr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const o=ae(r);o.current=r;const a=he(()=>o.current(),[]),s=I(c=>c.storyData),l=(e?s?.passages.get(e):void 0)?.content??t,d=de(()=>{if(!l)return v(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=yt(l),p=bt(c);return Ie(p)}catch(c){return v(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[l]),f=c=>{c.target.classList.contains(\"dialog-overlay\")&&a()},h=n?`dialog-panel ${n}`:\"dialog-panel\";return v(ga.Provider,{value:a,children:v(\"div\",{class:\"dialog-overlay\",onClick:f,children:v(\"div\",{class:h,children:[i&&v(\"button\",{class:\"dialog-close\",onClick:a,children:\"✕\"}),v(\"div\",{class:\"dialog-body\",children:d})]})})})}function Gf(){const[e,t]=X([]),n=ae(e);n.current=e;const r=he(a=>{t(s=>[...s,a])},[]),i=he(()=>{t(a=>a.slice(0,-1))},[]),o=he(()=>{t([])},[]);return we(()=>Vf({close:i,closeAll:o,push:r,isOpen:()=>n.current.length>0}),[i,o,r]),we(()=>Ff(()=>{const a=[];for(;Of()>0;){const s=Rf();s&&a.push(s)}a.length>0&&t(s=>[...s,...a])}),[]),e.length===0?null:v(Y,{children:e.map((a,s)=>v(Rr,{passageName:a.passageName,panelClass:a.panelClass,onClose:i,showCloseButton:a.showCloseButton},`${a.passageName}-${s}`))})}function Kf(){const e=I(i=>i.storyData),t=I(i=>i.currentPassage),n=I(i=>i.nobr);if(we(()=>{const i=o=>{o.key===\"F6\"?(o.preventDefault(),I.getState().save()):o.key===\"F9\"&&(o.preventDefault(),I.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return v(\"div\",{class:\"loading\",children:\"Loading...\"});const r=v(Y,{children:[v(Qf,{}),v(Gf,{})]});return n?v(ce.Provider,{value:!0,children:r}):r}function Yf(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Jf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",o=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",d=new Map,f=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const c=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",w=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),S=Yf(h.innerHTML),y={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const A of h.attributes)k.has(A.name)||(y[A.name]=A.value);const x={pid:c,name:p,tags:w,metadata:y,content:S};d.set(p,x),f.set(c,x)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:o,passages:d,passagesById:f,userCSS:s,userScript:l}}const xt=new Map;let ue={},Hi=!1;function ma(){return`spindle.${I.getState().storyData?.ifid||\"unknown\"}.settings`}function Zf(){localStorage.setItem(ma(),JSON.stringify(ue))}function Bn(){if(!Hi){Hi=!0;try{const e=localStorage.getItem(ma());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ue={...ue,...t})}}catch{}}}const Mt={addToggle(e,t){xt.set(e,{type:\"toggle\",config:t}),e in ue||(ue[e]=t.default),Bn()},addList(e,t){xt.set(e,{type:\"list\",config:t}),e in ue||(ue[e]=t.default),Bn()},addRange(e,t){xt.set(e,{type:\"range\",config:t}),e in ue||(ue[e]=t.default),Bn()},get(e){return ue[e]},getToggle(e){const t=ue[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ue[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ue[e];return typeof t==\"number\"?t:0},set(e,t){ue[e]=t,Zf()},getAll(){return{...ue}},getDefinitions(){return xt},hasAny(){return xt.size>0}};function Xf(e,t,n){const r=I.getState(),i=re(r.variables),o=re(r.temporary),a={...t};Bo(e,i,o,a);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(o))o[s]!==r.temporary[s]&&r.setTemporary(s,o[s]);for(const s of Object.keys(a))a[s]!==t[s]&&n(s,a[s]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in o||r.deleteTemporary(s);for(const s of Object.keys(t))s in a||n(s,void 0)}const vn=new Map,pr=new Set,gr=new Map;function ed(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(gr.get(r)??0)+1;return gr.set(r,i),i===1?r:`${r}:${i}`}function td(e){return vn.set(e.id,e),Ui(),()=>{vn.delete(e.id),Ui()}}function qi(){return Array.from(vn.values())}function nd(e){return vn.get(e)}function rd(){gr.clear()}function id(e){return pr.add(e),()=>{pr.delete(e)}}function Ui(){for(const e of pr)e()}function od(e){const t=ae(\"\"),n=ae(e.perform);n.current=e.perform,t.current||(t.current=ed(e.type,e.key,e.authorId));const r=t.current;return at(()=>{const i={id:r,type:e.type,label:e.label,perform:(...o)=>n.current(...o)};return e.target!==void 0&&(i.target=e.target),e.variable!==void 0&&(i.variable=e.variable),e.options!==void 0&&(i.options=e.options),e.value!==void 0&&(i.value=e.value),e.disabled!==void 0&&(i.disabled=e.disabled),td(i)},[r,e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function ad(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function _a(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Or(){const e=I.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?_a(t):\"\"}function sd(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 ld(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 ud(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const cd={useState:X,useRef:ae,useEffect:we,useLayoutEffect:at,useCallback:he,useMemo:de,useContext:K};function ji(e,t){let n=e;for(const r of t){if(n==null||typeof n!=\"object\")return;n=n[r]}return n}function fd(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];(r[o]==null||typeof r[o]!=\"object\")&&(r[o]={}),r=r[o]}r[t[t.length-1]]=n}function V(e){function t(n){let r=n.className,i=n.id,o;e.interpolate&&(o=Ar(),r=o(r),i=o(i));const{update:a,getValues:s}=K(Qt),u=K(ce),l=K(Ce),f={collectText:ad,sourceLocation:Or,parseVarArgs:sd,extractOptions:ld,h:G,renderNodes:(h,c)=>Ie(h,{nobr:u,locals:l,...c}),renderInlineNodes:ia,hooks:cd,useAction:od,className:r,id:i,resolve:o,cls:ud(e.name,r),mutate:h=>Xf(h,s(),a),update:a,getValues:s,wrap:h=>r||i?G(\"span\",{id:i,class:r},h):G(Y,null,h)};if(e.merged){f.merged=Er();const h=f.merged;f.evaluate=c=>xn(c,h[0],h[1],h[2])}if(e.storeVar){const c=(n.rawArgs.trim().split(/\\s+/)[0]?.replace(/[\"']/g,\"\")??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\"),p=c.split(\".\");f.varName=c,f.value=I(w=>ji(w.variables,p)),f.getValue=()=>ji(I.getState().variables,p),f.setValue=w=>{I.setState(S=>{fd(S.variables,p,w)})}}return e.render(n,f)}if(Dl(e.name,t),e.subMacros)for(const n of e.subMacros)zl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&ir(e.name)}function dd(){return{get(e){return I.getState().variables[e]},set(e,t){const n=I.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){I.getState().navigate(e)},back(){I.getState().goBack()},forward(){I.getState().goForward()},restart(){I.getState().restart()},save(e){I.getState().save(e)},load(e){I.getState().load(e)},hasSave(e){return I.getState().hasSave(e)},visited(e){const t=I.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=I.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=I.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=I.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return I.getState().storyData?.name||\"\"},get passage(){return I.getState().currentPassage},settings:Mt,registerClass(e,t){df(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){pf(e)}},getActions(){return qi()},performAction(e,t){const n=nd(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=I.getState().currentPassage;return I.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return id(t);if(e===\"variableChanged\"){let n={...I.getState().variables};return I.subscribe(r=>{const i={};let o=!1;const a=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of a)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},o=!0);n={...r.variables},o&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(qi())})})})},watch(e,t){return ha(e,t)},unwatch(e){pa(e)},openDialog(e,t){Mf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Bf()},closeAllDialogs(){Hf()},isDialogOpen(){return qf()},setNobr(e){I.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){I.getState().setTransition(e)},setNextTransition(e){I.getState().setNextTransition(e)},random(){return Pr()},randomInt(e,t){return Mo(e,t)},config:{get maxHistory(){return I.getState().maxHistory},set maxHistory(e){I.getState().setMaxHistory(e)}},prng:{init(e,t){yl(e,t);const{historyIndex:n}=I.getState();I.setState(r=>{const i=r.history[n];i&&(i.prng=yn())})},isEnabled(){return bl()},get seed(){return vl()},get pull(){return wl()}}}}function hd(){window.Story=dd()}const pd=/^\\$(\\w+)\\s*=\\s*(.+)$/,Wi=/\\$(\\w+(?:\\.\\w+)*)/g,Qi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,gd=new Set([\"number\",\"string\",\"boolean\"]);function ya(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,ya(i));return{type:\"object\",fields:n}}const t=typeof e;if(!gd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function md(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(pd);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,o,a]=i;let s;try{s=new Function(\"return (\"+a+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${o} = ${a}\": ${l instanceof Error?l.message:l}`)}const u=ya(s);t.set(o,{...u,name:o,default:s})}return t}function _d(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 yd(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const o=t.get(i);if(!o)return`Undeclared variable: $${e}`;let a=o;for(let s=1;s<r.length;s++){const u=r[s];if(a.type===\"array\")return null;if(a.type!==\"object\"||!a.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${a.type})`;const l=a.fields.get(u);if(!l)return null;a=l}return null}function bd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const o=_d(i.content);let a;for(Wi.lastIndex=0;(a=Wi.exec(i.content))!==null;){const s=a[1],u=yd(s,t,o);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function vd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function sn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&sn(t.children))return!0;if(t.type===\"macro\"){if(sn(t.children))return!0;if(t.branches){for(const n of t.branches)if(sn(n.children))return!0}}}return!1}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function He({macro:e,error:t}){return v(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Or()}: ${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 v(He,{macro:\"print\",error:n})}}});function wd(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 o=t.slice(0,r).trim(),a=t.slice(r+1).trim();if(!o.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${o}\"`);return{target:o,expr:a}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function kd(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function Gi(e,t,n,r,i,o,a){let s;try{s=xn(e,r,i,o)}catch(l){console.error(`spindle: Error in {computed ${a}}${Or()}:`,l);return}const u=n?i[t]:r[t];if(!kd(u,s)){const l=I.getState();n?l.setTemporary(t,s):l.setVariable(t,s)}}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let o,a;try{({target:o,expr:a}=wd(e))}catch(d){return v(He,{macro:\"computed\",error:d})}const s=o.startsWith(\"_\"),u=o.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,Gi(a,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{Gi(a,u,s,n,r,i,e)},[n,r,i]),null}});function Sd(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 o=xd(r);if(o.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:o[0],maxExpr:o.slice(1).join(\" \"),labelMode:n}}function xd(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const o=e[i];if(o===\"(\"||o===\"[\")r++,n+=o;else if(o===\")\"||o===\"]\")r--,n+=o;else if(/\\s/.test(o)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=o}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}=Sd(e),o=Number(t.evaluate(n)),a=Number(t.evaluate(r)),s=a===0?0:Math.max(0,Math.min(100,o/a*100)),u=Cd(o,a,i),l=t.cls;return v(\"div\",{class:l,id:t.id,children:[v(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&v(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return v(He,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),o=t.resolve(r.className),a=t.resolve(r.id);return o||a?v(\"span\",{id:a,class:o,children:i}):v(Y,{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 v(He,{macro:\"if\",error:i})}}return null}});function Id(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()),o=i[0],a=i.length>1?i[1]:null;if(!o.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${o}\"`);if(a&&!a.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${a}\"`);return{itemVar:o.slice(1),indexVar:a?a.slice(1):null,listExpr:r}}function Ed({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,o]=X(()=>({...n})),a={...e,...t,...i},s=ae(a);s.current=a;const u=he(()=>s.current,[]),l=he((h,c)=>{o(p=>({...p,[h]:c}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]),f=K(ce);return v(Qt.Provider,{value:d,children:v(Ce.Provider,{value:a,children:Ie(r,{nobr:f,locals:a})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=K(Ce);let i;try{i=Id(e)}catch(d){return v(He,{macro:\"for\",error:d})}const{itemVar:o,indexVar:a,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return v(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return v(He,{macro:\"for\",error:d})}const l=u.map((d,f)=>{const h={[o]:d,...a?{[a]:f}:void 0};return v(Ed,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${f}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=K(ce),o=()=>{const a=document.createElement(\"div\"),s=G(ce.Provider,{value:i},G(Qt.Provider,{value:{update:n.update,getValues:n.getValues}},G(Ce.Provider,{value:n.getValues()},Ie(t))));xe(s,a),xe(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:o}),v(\"button\",{id:n.id,class:n.cls,onClick:o,children:r})}});function Ad(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 Ki(e,t,n,r){const i=document.createElement(\"div\"),o=G(ce.Provider,{value:r},G(Qt.Provider,{value:{update:n,getValues:t}},G(Ce.Provider,{value:t()},Ie(e))));xe(o,i),xe(null,i)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Ad(e),o=K(ce),a=s=>{s.preventDefault(),Ki(t,n.getValues,n.update,o),i&&I.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Ki(t,n.getValues,n.update,o),i&&I.getState().navigate(i)}}),v(\"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(o){return v(He,{macro:\"switch\",error:o})}let i=null;for(let o=1;o<t.length;o++){const a=t[o];if(a.rawArgs===\"\"){i=a;continue}try{const s=n.evaluate(a.rawArgs);if(r===s)return v(Y,{children:n.renderNodes(a.children)})}catch(s){return v(He,{macro:\"case\",error:s})}}return i?v(Y,{children:n.renderNodes(i.children)}):null}});function Mr(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,o=i(()=>e.map(c=>({delay:c.rawArgs?Mr(c.rawArgs):0,nodes:c.children,className:c.className,id:c.id})),[e]),[a,s]=n(-1);if(r(()=>{if(a>=o.length-1)return;const c=a+1,p=o[c].delay,w=setTimeout(()=>{s(c)},p);return()=>clearTimeout(w)},[a,o]),a<0)return t.wrap(null);const u=o[a],l=t.renderNodes(u.nodes),d=t.resolve(u.className),f=t.resolve(u.id),h=d||f?v(\"span\",{id:f,class:d,children:l}):l;return t.wrap(h)}});const ba=ot({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:o}=n.hooks,a=Mr(e),[s,u]=r(0),[l,d]=r(!1),f=o(()=>d(!0),[]);if(i(()=>{if(l)return;const c=setInterval(()=>{u(p=>p+1)},a);return()=>clearInterval(c)},[a,l]),s===0&&!l)return null;const h=v(ba.Provider,{value:{stop:f},children:v(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?v(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(ba);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:o}=n.hooks,a=Mr(e),s=o(null),[u,l]=r(0),[d,f]=r(0),h=o(0);h.current=d,i(()=>{if(s.current){const w=s.current.textContent||\"\";l(w.length)}},[]),i(()=>{if(u===0||h.current>=u)return;const w=setInterval(()=>{f(S=>S>=u?(clearInterval(w),S):S+1)},a);return()=>clearInterval(w)},[u,a]);const c=d>=u&&u>0,p=[\"macro-type\",c?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return v(\"span\",{id:n.id,class:p,ref:s,style:{clipPath:(u>0&&!c,void 0)},children:[v(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!c?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!c&&u>0&&v(\"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),o=JSON.stringify(t),a=i.join(\",\");return n.hooks.useLayoutEffect(()=>{qo(r,t,i)},[r,o,a]),null}});V({name:\"story-title\",render(e,t){const n=I(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return v(\"span\",{id:t.id,class:r,children:n})}});function lt(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=X(!1),o=e.setup?.()??{perform:()=>{}},{disabled:a}=o,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&o.perform()}:o.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:a,perform:e.dialog?()=>i(!0):o.perform}),v(Y,{children:[v(\"button\",{id:n.id,class:s,onClick:u,disabled:a,title:e.title,children:e.label}),e.dialog&&r&&v(Rr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}lt({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:I(e=>e.goBack),disabled:!I(e=>e.historyIndex>0)})});lt({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:I(e=>e.goForward),disabled:!I(e=>e.historyIndex<e.history.length-1)})});lt({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:I(e=>e.save)})});lt({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=I(n=>n.load),t=I(n=>n.hasSave);return I(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});lt({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:I(e=>e.restart)})});lt({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});lt({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Mt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),o=/\\bnoclose\\s*$/.test(e),a=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(a.replace(/^[\"']|[\"']$/g,\"\"))??a,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return v(Y,{children:[v(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&v(Rr,{passageName:u,onClose:()=>i(!1),showCloseButton:!o})]})}});function Td(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 o=Math.floor(i/24);return o<30?`${o}d ago`:new Date(e).toLocaleDateString()}function Nd(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Dd(){const[e,t]=X(\"load\"),[n,r]=X([]),[i,o]=X(!0),[a,s]=X(null),[u,l]=X(()=>new Set),[d,f]=X(null),[h,c]=X(\"\"),p=ae(null),w=ae(null),S=K(ga),y=I(D=>D.storyData),k=I(D=>D.playthroughId),x=I(D=>D.getSavePayload),A=I(D=>D.loadFromPayload),C=y?.ifid??\"\",_=he(async()=>{if(!C)return;const D=await kf(C);r(D),o(!1)},[C]);we(()=>{_()},[_]),we(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const P=ae(),T=(D,j=\"success\")=>{clearTimeout(P.current),s({text:D,type:j}),P.current=window.setTimeout(()=>s(null),3e3)};we(()=>()=>clearTimeout(P.current),[]);const z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},b=async()=>{if(!(!C||!k))try{const D=x();await la(C,k,D),T(\"Save created\"),await _()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=x();await ua(D,j),T(\"Save overwritten\"),await _()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{A(D.payload),T(\"Game loaded\"),S&&setTimeout(S,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await vf(D),T(\"Save deleted\"),await _()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{f(D.meta.id),c(D.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await wf(d,h.trim()),f(null),T(\"Save renamed\"),await _()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&f(null)},J=async D=>{try{const j=await Af(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),le=document.createElement(\"a\");le.href=q,le.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,le.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},pe=()=>{w.current?.click()},ke=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),le=JSON.parse(q);if(!of(le))throw new Error(\"Invalid save file format\");await Pf(le,C),T(\"Save imported\"),await _()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.saves.length,0);return v(\"div\",{class:\"save-manager\",children:[v(\"div\",{class:\"saves-header\",children:v(\"div\",{class:\"saves-header-left\",children:v(\"div\",{class:\"saves-mode-toggle\",children:[v(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),v(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),v(\"div\",{class:\"saves-toolbar\",children:[v(\"button\",{class:\"saves-toolbar-button\",onClick:pe,children:\"Import\"}),v(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),v(\"div\",{class:\"saves-body\",children:[i?v(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?v(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:v(\"div\",{class:\"playthrough-group\",children:[v(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[v(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),v(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),v(\"span\",{class:\"playthrough-date\",children:Nd(D.playthrough.createdAt)})]}),!j&&v(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>v(\"div\",{class:\"save-slot\",children:[v(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?v(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:le=>c(le.target.value),onKeyDown:Z,onBlur:M}):v(\"div\",{class:\"save-slot-title\",children:q.meta.title}),v(\"div\",{class:\"save-slot-meta\",children:[v(\"span\",{children:q.meta.passage}),v(\"span\",{children:Td(q.meta.updatedAt)})]})]}),v(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?v(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):v(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),v(\"button\",{class:\"save-slot-action\",onClick:()=>J(q.meta.id),children:\"Export\"}),v(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===k)&&v(\"div\",{class:\"playthrough-group\",children:v(\"div\",{class:\"playthrough-saves\",children:v(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),a&&v(\"div\",{class:`saves-status ${a.type===\"error\"?\"error\":\"\"}`,children:a.text})]})}V({name:\"save-manager\",render(){return v(Dd,{})}});function $d({name:e,def:t}){const[n,r]=X(()=>Mt.get(e)),i=o=>{r(o),Mt.set(e,o)};switch(t.type){case\"toggle\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:t.config.label}),v(\"input\",{type:\"checkbox\",checked:!!n,onChange:o=>i(o.target.checked)})]});case\"list\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:t.config.label}),v(\"select\",{value:String(n),onChange:o=>i(o.target.value),children:t.config.options.map(o=>v(\"option\",{value:o,children:o},o))})]});case\"range\":return v(\"label\",{class:\"settings-row\",children:[v(\"span\",{children:[t.config.label,\": \",String(n)]}),v(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:o=>i(parseFloat(o.target.value))})]})}}function zd(){const e=Mt.getDefinitions();return v(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>v($d,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return v(zd,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=I(f=>f.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let o;try{const f=t.evaluate(i);o=String(f)}catch{o=i.replace(/^[\"']|[\"']$/g,\"\")}const a=n.passages.get(o);if(a&&I.getState().trackRender(o),!a)return v(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${o}\" not found}`});const s=a.tags.includes(\"nobr\"),u=yt(a.content),l=bt(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(ce.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(ce.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}I.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=I.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):i.startsWith(\"@\")?t.update(i.slice(1),void 0):console.error(`spindle: {unset} expects a variable ($name, _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):\"\")}),v(\"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)}),v(\"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):\"\")}),v(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Fd(e){return e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Fd(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),v(\"label\",{id:t.id,class:t.cls,children:[v(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function Rd(e){const t=e.match(/^\\s*[\"']?\\$?[\\w.]+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=Rd(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),v(\"label\",{id:t.id,class:t.cls,children:[v(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),v(\"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=>v(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=t.getValue(),a=(n.indexOf(String(i))+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()}}),v(\"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 It(e){const t=yt(e.content),n=bt(t),r=e.tags.includes(\"nobr\");return Ie(n,r?{nobr:!0}:void 0)}const Od=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Md({passage:e,dataTransition:t}){const n=I(w=>w.storyData),r=Od.has(e.name),[i,o]=X(!1),a=de(()=>{try{return It(e)}catch(w){return v(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",_a(e),\":\",\" \",w instanceof Error?w.message:String(w)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=de(()=>{if(!s)return null;try{return It(s)}catch(w){return console.error(\"spindle: Error in PassageHeader:\",w),null}},[s?.content]),f=de(()=>{if(!u)return null;try{return It(u)}catch(w){return console.error(\"spindle: Error in PassageFooter:\",w),null}},[u?.content]);we(()=>(l&&o(!0),()=>o(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return It(l)}catch(w){return console.error(\"spindle: Error in PassageDone:\",w),null}},[i,l?.content]),c=e.tags.includes(\"nobr\"),p=v(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&v(\"div\",{class:\"passage-header\",children:d}),a,f&&v(\"div\",{class:\"passage-footer\",children:f}),h&&v(\"div\",{hidden:!0,children:h})]});return c?v(ce.Provider,{value:!0,children:p}):p}const Ld=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),mr={type:\"fade-through\",duration:300,pause:50};function Vd(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Ld.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const o=Number(i.slice(9));Number.isNaN(o)||(r.duration=o)}else if(i.startsWith(\"pause:\")){const o=Number(i.slice(6));Number.isNaN(o)||(r.pause=o)}return r}function Hn(e){return{type:e.type,duration:e.duration??mr.duration,pause:e.pause??mr.pause}}function Bd(e,t,n){const r=Vd(e);return r?Hn(r):t?Hn(t):n?Hn(n):{...mr}}function Yi(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let o=0;o<r.length;o++)r[o].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let o=0;o<i.length;o++){const a=i[o];a.pause?.(),a.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function qn(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 Un(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=I(c=>c.currentPassage),r=I(c=>c.storyData),[i,o]=X(n),a=ae(\"fade\"),s=ae(0),u=ae(null),l=ae([]),d=he(()=>{for(const c of l.current)clearTimeout(c);l.current=[],Un(u.current)},[]);we(()=>{const c=I.getState(),{history:p,historyIndex:w,transitionConfig:S}=c,y=c.consumeNextTransition(),k=s.current;s.current=p.length;const x=!i,A=p.length===1&&w===0&&k>1,C=p.length>1&&w===p.length-1&&k>1&&Math.abs(p.length-k)>1;if(n===i)return;d();const _=r?.passages.get(n);if(!_){a.current=\"none\",o(n);return}if(x||A||C){a.current=\"fade\",o(n);return}const P=Bd(_.tags,y,S);a.current=P.type;const T=u.current;if(P.type===\"none\"){o(n);return}if(P.type===\"fade\"){T&&qn(T,P),o(n);return}if(P.type===\"fade-through\"){if(!T){o(n);return}qn(T,P);const z=T.querySelector(\".passage\");if(!z){o(n);return}const b=Yi(z,P.type);T.appendChild(b),o(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{o(n)},N),B=N+P.duration,U=setTimeout(()=>{Un(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){o(n);return}qn(T,P);const z=T.querySelector(\".passage\");if(!z){o(n);return}const b=Yi(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),o(n);const N=setTimeout(()=>{Un(T)},P.duration);l.current=[N];return}o(n)},[n]);const f=i?r?.passages.get(i):null;if(!f&&i)return v(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return v(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&v(\"div\",{hidden:!0,children:It(h)},`ready-${n}`),v(\"div\",{class:\"passage-container\",ref:u,children:f&&v(Md,{passage:f,dataTransition:a.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 o=i[2],a=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(a))!==null;){const f=l[1]??l[5],h=l[2]??l[3]??l[4];if(f)switch(f){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,ha(o,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,pa(r)),null}});const Hd='*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}';function Ji(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const o of t){const a=document.createElement(\"li\");a.textContent=o,i.appendChild(a)}n.appendChild(i),e.appendChild(n)}function Zi(){const e=Jf(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Hd,document.head.appendChild(t),hd(),e.userCSS){const c=document.createElement(\"style\");c.textContent=e.userCSS,document.head.appendChild(c)}if(e.userScript)try{new Function(e.userScript)()}catch(c){console.error(\"spindle: Error in story JavaScript:\",c)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const c=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",p=document.getElementById(\"root\");throw p&&Ji(p,[c]),new Error(`spindle: ${c}`)}const i=md(r.content),o=bd(e.passages,i);if(o.length>0){const c=document.getElementById(\"root\");throw c&&Ji(c,o),new Error(`spindle: ${o.length} validation error(s):\n${o.join(`\n`)}`)}n=vd(i),I.getState().init(e,n),fa();const a=If(e.ifid);a&&I.getState().loadFromPayload(a);const s=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){let p;for(;(p=s.exec(c.content))!==null;){const w=p[1],S=p[2];/\\{@children\\}/.test(S)&&ir(w)}s.lastIndex=0}for(const[,c]of e.passages)if(c.tags.includes(\"widget\")){const p=yt(c.content),w=bt(p);for(const S of w)if(S.type===\"macro\"&&S.name===\"widget\"&&S.rawArgs){const y=S.rawArgs.trim().split(/\\s+/),k=y[0].replace(/[\"']/g,\"\"),x=y.slice(1).filter(_=>_.startsWith(\"$\")||_.startsWith(\"_\")||_.startsWith(\"@\")),A=S.children,C=sn(A);qo(k,A,x,C),C&&ir(k)}}let u=\"\";I.subscribe(c=>{c.currentPassage!==u&&(u=c.currentPassage,rd())});let l=I.getState().variables,d=I.getState().historyIndex;I.subscribe(c=>{c.variables!==l&&(c.historyIndex===d?Df():$f()),l=c.variables,d=c.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 h=document.getElementById(\"root\");if(!h)throw new Error('spindle: No <div id=\"root\"> element found.');xe(v(Kf,{}),h),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Zi):Zi();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
package/package.json
CHANGED
package/src/define-macro.ts
CHANGED
|
@@ -173,7 +173,8 @@ export function defineMacro(config: MacroDefinition): void {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if (config.storeVar) {
|
|
176
|
-
const firstToken =
|
|
176
|
+
const firstToken =
|
|
177
|
+
props.rawArgs.trim().split(/\s+/)[0]?.replace(/["']/g, '') ?? '';
|
|
177
178
|
const varExpr = firstToken.replace(/["']/g, '').replace(/^\$/, '');
|
|
178
179
|
const segments = varExpr.split('.');
|
|
179
180
|
ctx.varName = varExpr;
|