@rohal12/spindle 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- window.storyFormat({"name":"spindle","version":"0.2.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const s of a.addedNodes)s.tagName===\"LINK\"&&s.rel===\"modulepreload\"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var pt,O,yi,Oe,gr,bi,vi,xi,Qn,vn,xn,wi,zt={},Ft=[],ss=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,mt=Array.isArray;function xe(e,t){for(var n in t)e[n]=t[n];return e}function Gn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ge(e,t,n){var r,i,a,s={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?pt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return ot(e,s,r,i,null)}function ot(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++yi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function os(){return{current:null}}function Y(e){return e.children}function we(e,t){this.props=e,this.context=t}function Ge(e,t){if(t==null)return e.__?Ge(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\"?Ge(e):null}function ls(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=xe({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),Yn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ge(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Ii(r,a,i),t.__e=t.__=null,a.__e!=n&&Si(a)}}function Si(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}),Si(e)}function wn(e){(!e.__d&&(e.__d=!0)&&Oe.push(e)&&!Ot.__r++||gr!=O.debounceRendering)&&((gr=O.debounceRendering)||bi)(Ot)}function Ot(){for(var e,t=1;Oe.length;)Oe.length>t&&Oe.sort(vi),e=Oe.shift(),t=Oe.length,ls(e);Ot.__r=0}function ki(e,t,n,r,i,a,s,o,u,l,h){var c,d,f,_,C,I,b,x=r&&r.__k||Ft,S=t.length;for(u=us(n,t,x,u,S),c=0;c<S;c++)(f=n.__k[c])!=null&&(d=f.__i!=-1&&x[f.__i]||zt,f.__i=c,I=Yn(e,f,d,i,a,s,o,u,l,h),_=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&Kn(d.ref,null,f),h.push(f.ref,f.__c||_,f)),C==null&&_!=null&&(C=_),(b=!!(4&f.__u))||d.__k===f.__k?u=Ci(f,u,e,b):typeof f.type==\"function\"&&I!==void 0?u=I:_&&(u=_.nextSibling),f.__u&=-7);return n.__e=C,u}function us(e,t,n,r,i){var a,s,o,u,l,h=n.length,c=h,d=0;for(e.__k=new Array(i),a=0;a<i;a++)(s=t[a])!=null&&typeof s!=\"boolean\"&&typeof s!=\"function\"?(typeof s==\"string\"||typeof s==\"number\"||typeof s==\"bigint\"||s.constructor==String?s=e.__k[a]=ot(null,s,null,null,null):mt(s)?s=e.__k[a]=ot(Y,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[a]=ot(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[a]=s,u=a+d,s.__=e,s.__b=e.__b+1,o=null,(l=s.__i=cs(s,n,u,c))!=-1&&(c--,(o=n[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(i>h?d--:i<h&&d++),typeof s.type!=\"function\"&&(s.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,s.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<h;a++)(o=n[a])!=null&&(2&o.__u)==0&&(o.__e==r&&(r=Ge(o)),Ei(o,o));return r}function Ci(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Ci(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ge(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ie(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(mt(e)?e.some(function(n){Ie(n,t)}):t.push(e)),t}function cs(e,t,n,r){var i,a,s,o=e.key,u=e.type,l=t[n],h=l!=null&&(2&l.__u)==0;if(l===null&&o==null||h&&o==l.key&&u==l.type)return n;if(r>(h?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[s=i>=0?i--:a++])!=null&&(2&l.__u)==0&&o==l.key&&u==l.type)return s}return-1}function _r(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ss.test(t)?n:n+\"px\"}function vt(e,t,n,r,i){var a,s;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||_r(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||_r(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(xi,\"$1\")),s=t.toLowerCase(),t=s in e||t==\"onFocusOut\"||t==\"onFocusIn\"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=Qn,e.addEventListener(t,a?xn:vn,a)):e.removeEventListener(t,a?xn:vn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function yr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Qn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Yn(e,t,n,r,i,a,s,o,u,l){var h,c,d,f,_,C,I,b,x,S,D,E,v,F,z,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[o=t.__e=n.__e]),(h=O.__b)&&h(t);e:if(typeof M==\"function\")try{if(b=t.props,x=\"prototype\"in M&&M.prototype.render,S=(h=M.contextType)&&r[h.__c],D=h?S?S.props.value:h.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(x?t.__c=c=new M(b,D):(t.__c=c=new we(b,D),c.constructor=M,c.render=hs),S&&S.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),x&&c.__s==null&&(c.__s=c.state),x&&M.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=xe({},c.__s)),xe(c.__s,M.getDerivedStateFromProps(b,c.__s))),f=c.props,_=c.state,c.__v=t,d)x&&M.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),x&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(x&&M.getDerivedStateFromProps==null&&b!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,D),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,D)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),Ft.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,D),x&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,_,C)})}if(c.context=D,c.props=b,c.__P=e,c.__e=!1,E=O.__r,v=0,x)c.state=c.__s,c.__d=!1,E&&E(t),h=c.render(c.props,c.state,c.context),Ft.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),h=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++v<25);c.state=c.__s,c.getChildContext!=null&&(r=xe(xe({},r),c.getChildContext())),x&&!d&&c.getSnapshotBeforeUpdate!=null&&(C=c.getSnapshotBeforeUpdate(f,_)),F=h!=null&&h.type===Y&&h.key==null?Ai(h.props.children):h,o=ki(e,mt(F)?F:[F],t,n,r,i,a,s,o,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||a!=null)if(y.then){for(t.__u|=u?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(z=a.length;z--;)Gn(a[z]);Sn(t)}else t.__e=n.__e,t.__k=n.__k,y.then||Sn(t);O.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=fs(n.__e,t,n,r,i,a,s,u,l);return(h=O.diffed)&&h(t),128&t.__u?void 0:o}function Sn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Sn))}function Ii(e,t,n){for(var r=0;r<n.length;r++)Kn(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function Ai(e){return typeof e!=\"object\"||e==null||e.__b>0?e:mt(e)?e.map(Ai):xe({},e)}function fs(e,t,n,r,i,a,s,o,u){var l,h,c,d,f,_,C,I=n.props||zt,b=t.props,x=t.type;if(x==\"svg\"?i=\"http://www.w3.org/2000/svg\":x==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((f=a[l])&&\"setAttribute\"in f==!!x&&(x?f.localName==x:f.nodeType==3)){e=f,a[l]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),o&&(O.__m&&O.__m(t,a),o=!1),a=null}if(x==null)I===b||o&&e.data==b||(e.data=b);else{if(a=a&&pt.call(e.childNodes),!o&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(f=e.attributes[l]).name]=f.value;for(l in I)f=I[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||vt(e,l,null,f,i);for(l in b)f=b[l],l==\"children\"?d=f:l==\"dangerouslySetInnerHTML\"?h=f:l==\"value\"?_=f:l==\"checked\"?C=f:o&&typeof f!=\"function\"||I[l]===f||vt(e,l,f,I[l],i);if(h)o||c&&(h.__html==c.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ki(t.type==\"template\"?e.content:e,mt(d)?d:[d],t,n,r,x==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,s,a?a[0]:n.__k&&Ge(n,0),o,u),a!=null)for(l=a.length;l--;)Gn(a[l]);o||(l=\"value\",x==\"progress\"&&_==null?e.removeAttribute(\"value\"):_!=null&&(_!==e[l]||x==\"progress\"&&!_||x==\"option\"&&_!=I[l])&&vt(e,l,_,I[l],i),l=\"checked\",C!=null&&C!=e[l]&&vt(e,l,C,I[l],i))}return e}function Kn(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 Ei(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Kn(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ei(r[i],t,n||typeof e.type!=\"function\");n||Gn(e.__e),e.__c=e.__=e.__e=void 0}function hs(e,t,n){return this.constructor(e,n)}function Ye(e,t,n){var r,i,a,s;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],s=[],Yn(t,e=(!r&&n||t).__k=ge(Y,null,[e]),i||zt,zt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?pt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,s),Ii(a,e,s)}function Pi(e,t){Ye(e,t,Pi)}function ds(e,t,n){var r,i,a,s,o=xe({},e.props);for(a in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a]===void 0&&s!=null?s[a]:t[a];return arguments.length>2&&(o.children=arguments.length>3?pt.call(arguments,2):n),ot(e.type,o,r||e.key,i||e.ref,null)}function Zn(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(s){s.__e=!0,wn(s)})},this.sub=function(a){r.add(a);var s=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),s&&s.call(a)}}),n.children}return t.__c=\"__cC\"+wi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}pt=Ft.slice,O={__e:function(e,t,n,r){for(var i,a,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=i.__d),s)return i.__E=i}catch(o){e=o}throw e}},yi=0,we.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=xe({},this.state),typeof e==\"function\"&&(e=e(xe({},n),this.props)),e&&xe(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),wn(this))},we.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),wn(this))},we.prototype.render=Y,Oe=[],bi=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,vi=function(e,t){return e.__v.__b-t.__v.__b},Ot.__r=0,xi=/(PointerCapture)$|Capture$/i,Qn=0,vn=yr(!1),xn=yr(!0),wi=0;var ps=0;function g(e,t,n,r,i,a){t||(t={});var s,o,u=t;if(\"ref\"in u)for(o in u={},t)o==\"ref\"?s=t[o]:u[o]=t[o];var l={type:e,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ps,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(s=e.defaultProps))for(o in s)u[o]===void 0&&(u[o]=s[o]);return O.vnode&&O.vnode(l),l}var Pe,W,cn,br,Ke=0,$i=[],G=O,vr=G.__b,xr=G.__r,wr=G.diffed,Sr=G.__c,kr=G.unmount,Cr=G.__;function et(e,t){G.__h&&G.__h(W,e,Ke||t),Ke=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function J(e){return Ke=1,Jn(zi,e)}function Jn(e,t,n){var r=et(Pe++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):zi(void 0,t),function(o){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,o);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(o,u,l){if(!r.__c.__H)return!0;var h=r.__c.__H.__.filter(function(d){return d.__c});if(h.every(function(d){return!d.__N}))return!a||a.call(this,o,u,l);var c=r.__c.props!==o;return h.some(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(c=!0)}}),a&&a.call(this,o,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,s=W.componentWillUpdate;W.componentWillUpdate=function(o,u,l){if(this.__e){var h=a;a=void 0,i(o,u,l),a=h}s&&s.call(this,o,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Se(e,t){var n=et(Pe++,3);!G.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function he(e,t){var n=et(Pe++,4);!G.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function Re(e){return Ke=5,Ve(function(){return{current:e}},[])}function Ti(e,t,n){Ke=6,he(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 Ve(e,t){var n=et(Pe++,7);return Xn(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Gt(e,t){return Ke=8,Ve(function(){return e},t)}function He(e){var t=W.context[e.__c],n=et(Pe++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Ni(e,t){G.useDebugValue&&G.useDebugValue(t?t(e):e)}function Di(){var e=et(Pe++,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 ms(){for(var e;e=$i.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(At),t.__h.some(kn),t.__h=[]}catch(n){t.__h=[],G.__e(n,e.__v)}}}G.__b=function(e){W=null,vr&&vr(e)},G.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Cr&&Cr(e,t)},G.__r=function(e){xr&&xr(e),Pe=0;var t=(W=e.__c).__H;t&&(cn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(At),t.__h.some(kn),t.__h=[],Pe=0)),cn=W},G.diffed=function(e){wr&&wr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&($i.push(t)!==1&&br===G.requestAnimationFrame||((br=G.requestAnimationFrame)||gs)(ms)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),cn=W=null},G.__c=function(e,t){t.some(function(n){try{n.__h.some(At),n.__h=n.__h.filter(function(r){return!r.__||kn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],G.__e(r,n.__v)}}),Sr&&Sr(e,t)},G.unmount=function(e){kr&&kr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{At(r)}catch(i){t=i}}),n.__H=void 0,t&&G.__e(t,n.__v))};var Ir=typeof requestAnimationFrame==\"function\";function gs(e){var t,n=function(){clearTimeout(r),Ir&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ir&&(t=requestAnimationFrame(n))}function At(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 Xn(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function zi(e,t){return typeof t==\"function\"?t(e):t}const Ar=e=>{let t;const n=new Set,r=(l,h)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=h??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,d))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,o);return o},_s=(e=>e?Ar(e):Ar);function Fi(e,t){for(var n in t)e[n]=t[n];return e}function Cn(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 Oi(e,t){var n=t(),r=J({t:{__:n,u:t}}),i=r[0].t,a=r[1];return he(function(){i.__=n,i.u=t,fn(i)&&a({t:i})},[e,n,t]),Se(function(){return fn(i)&&a({t:i}),e(function(){fn(i)&&a({t:i})})},[e]),n}function fn(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 Ri(e){e()}function Li(e){return e}function Mi(){return[!1,Ri]}var Bi=he;function In(e,t){this.props=e,this.context=t}function ys(e,t){function n(i){var a=this.props.ref,s=a==i.ref;return!s&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!s:Cn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,ge(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(In.prototype=new we).isPureReactComponent=!0,In.prototype.shouldComponentUpdate=function(e,t){return Cn(this.props,e)||Cn(this.state,t)};var Er=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Er&&Er(e)};var bs=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function vs(e){function t(n){var r=Fi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=bs,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Pr=function(e,t){return e==null?null:Ie(Ie(e).map(t))},xs={map:Pr,forEach:Pr,count:function(e){return e?Ie(e).length:0},only:function(e){var t=Ie(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Ie},ws=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}ws(e,t,n,r)};var $r=O.unmount;function Vi(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=Fi({},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 Vi(r,t,n)})),e}function Hi(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Hi(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 Et(){this.__u=0,this.o=null,this.__b=null}function qi(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Ss(e){var t,n,r,i=null;function a(s){if(t||(t=e()).then(function(o){o&&(i=o.default||o),r=!0},function(o){n=o,r=!0}),n)throw n;if(!r)throw t;return i?ge(i,s):null}return a.displayName=\"Lazy\",a.__f=!0,a}function st(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),$r&&$r(e)},(Et.prototype=new we).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=qi(r.__v),a=!1,s=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=s;var o=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Hi(l,l.__c.__P,l.__c.__O)}var h;for(r.setState({__a:r.__b=null});h=r.o.pop();)h.__P=o,h.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(s,s)},Et.prototype.componentWillUnmount=function(){this.o=[]},Et.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]=Vi(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&ge(Y,null,e.fallback);return i&&(i.__u&=-33),[ge(Y,null,t.__a?null:e.children),i]};var Tr=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 ks(e){return this.getChildContext=function(){return e.context},e.children}function Cs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ye(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,a){this.childNodes.push(i),t.h.insertBefore(i,a)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}Ye(ge(ks,{context:t.context},e.__v),t.v)}function Is(e,t){var n=ge(Cs,{__v:e,h:t});return n.containerInfo=t,n}(st.prototype=new we).__a=function(e){var t=this,n=qi(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Tr(t,e,r)):i()};n?n(a):a()}},st.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ie(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},st.prototype.componentDidUpdate=st.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Tr(e,n,t)})};var Ui=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,As=/^(?: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]/,Es=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ps=/[A-Z0-9]/g,$s=typeof document<\"u\",Ts=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ns(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ye(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ds(e,t,n){return Pi(e,t),typeof n==\"function\"&&n(),e?e.__c:null}we.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(we.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Nr=O.event;function zs(){}function Fs(){return this.cancelBubble}function Os(){return this.defaultPrevented}O.event=function(e){return Nr&&(e=Nr(e)),e.persist=zs,e.isPropagationStopped=Fs,e.isDefaultPrevented=Os,e.nativeEvent=e};var er,Rs={enumerable:!1,configurable:!0,get:function(){return this.class}},Dr=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var s in n){var o=n[s];if(!(s===\"value\"&&\"defaultValue\"in n&&o==null||$s&&s===\"children\"&&r===\"noscript\"||s===\"class\"||s===\"className\")){var u=s.toLowerCase();s===\"defaultValue\"&&\"value\"in n&&n.value==null?s=\"value\":s===\"download\"&&o===!0?o=\"\":u===\"translate\"&&o===\"no\"?o=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?s=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Ts(n.type)?u===\"onfocus\"?s=\"onfocusin\":u===\"onblur\"?s=\"onfocusout\":Es.test(s)&&(s=u):u=s=\"oninput\":a&&As.test(s)?s=s.replace(Ps,\"-$&\").toLowerCase():o===null&&(o=void 0),u===\"oninput\"&&i[s=u]&&(s=\"oninputCapture\"),i[s]=o}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Ie(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Ie(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\",Rs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ui,Dr&&Dr(e)};var zr=O.__r;O.__r=function(e){zr&&zr(e),er=e.__c};var Fr=O.diffed;O.diffed=function(e){Fr&&Fr(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),er=null};var Ls={ReactCurrentDispatcher:{current:{readContext:function(e){return er.__n[e.__c].props.value},useCallback:Gt,useContext:He,useDebugValue:Ni,useDeferredValue:Li,useEffect:Se,useId:Di,useImperativeHandle:Ti,useInsertionEffect:Bi,useLayoutEffect:he,useMemo:Ve,useReducer:Jn,useRef:Re,useState:J,useSyncExternalStore:Oi,useTransition:Mi}}};function Ms(e){return ge.bind(null,e)}function Yt(e){return!!e&&e.$$typeof===Ui}function Bs(e){return Yt(e)&&e.type===Y}function Vs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Hs(e){return Yt(e)?ds.apply(null,arguments):e}function qs(e){return!!e.__k&&(Ye(null,e),!0)}function Us(e){return e&&(e.base||e.nodeType===1&&e)||null}var js=function(e,t){return e(t)},Ws=function(e,t){return e(t)},Qs=Y,Gs=Yt,xt={useState:J,useId:Di,useReducer:Jn,useEffect:Se,useLayoutEffect:he,useInsertionEffect:Bi,useTransition:Mi,useDeferredValue:Li,useSyncExternalStore:Oi,startTransition:Ri,useRef:Re,useImperativeHandle:Ti,useMemo:Ve,useCallback:Gt,useContext:He,useDebugValue:Ni,version:\"18.3.1\",Children:xs,render:Ns,hydrate:Ds,unmountComponentAtNode:qs,createPortal:Is,createElement:ge,createContext:Zn,createFactory:Ms,cloneElement:Hs,createRef:os,Fragment:Y,isValidElement:Yt,isElement:Gs,isFragment:Bs,isMemo:Vs,findDOMNode:Us,Component:we,PureComponent:In,memo:ys,forwardRef:vs,flushSync:Ws,unstable_batchedUpdates:js,StrictMode:Qs,Suspense:Et,SuspenseList:st,lazy:Ss,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ls};const Ys=e=>e;function Ks(e,t=Ys){const n=xt.useSyncExternalStore(e.subscribe,xt.useCallback(()=>t(e.getState()),[e,t]),xt.useCallback(()=>t(e.getInitialState()),[e,t]));return xt.useDebugValue(n),n}const Zs=e=>{const t=_s(e),n=r=>Ks(t,r);return Object.assign(n,t),n},Js=(e=>Zs);var ji=Symbol.for(\"immer-nothing\"),Or=Symbol.for(\"immer-draftable\"),re=Symbol.for(\"immer-state\");function me(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var le=Object,Ze=le.getPrototypeOf,Rt=\"constructor\",Kt=\"prototype\",An=\"configurable\",Lt=\"enumerable\",Pt=\"writable\",ut=\"value\",$e=e=>!!e&&!!e[re];function Ae(e){return e?Wi(e)||Jt(e)||!!e[Or]||!!e[Rt]?.[Or]||Xt(e)||en(e):!1}var Xs=le[Kt][Rt].toString(),Rr=new WeakMap;function Wi(e){if(!e||!tr(e))return!1;const t=Ze(e);if(t===null||t===le[Kt])return!0;const n=le.hasOwnProperty.call(t,Rt)&&t[Rt];if(n===Object)return!0;if(!We(n))return!1;let r=Rr.get(n);return r===void 0&&(r=Function.toString.call(n),Rr.set(n,r)),r===Xs}function Zt(e,t,n=!0){gt(e)===0?(n?Reflect.ownKeys(e):le.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function gt(e){const t=e[re];return t?t.type_:Jt(e)?1:Xt(e)?2:en(e)?3:0}var Lr=(e,t,n=gt(e))=>n===2?e.has(t):le[Kt].hasOwnProperty.call(e,t),En=(e,t,n=gt(e))=>n===2?e.get(t):e[t],Mt=(e,t,n,r=gt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function eo(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Jt=Array.isArray,Xt=e=>e instanceof Map,en=e=>e instanceof Set,tr=e=>typeof e==\"object\",We=e=>typeof e==\"function\",hn=e=>typeof e==\"boolean\";function to(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ce=e=>e.copy_||e.base_,nr=e=>e.modified_?e.copy_:e.base_;function Pn(e,t){if(Xt(e))return new Map(e);if(en(e))return new Set(e);if(Jt(e))return Array[Kt].slice.call(e);const n=Wi(e);if(t===!0||t===\"class_only\"&&!n){const r=le.getOwnPropertyDescriptors(e);delete r[re];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[Pt]===!1&&(o[Pt]=!0,o[An]=!0),(o.get||o.set)&&(r[s]={[An]:!0,[Pt]:!0,[Lt]:o[Lt],[ut]:e[s]})}return le.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=le.create(r);return le.assign(i,e)}}function rr(e,t=!1){return tn(e)||$e(e)||!Ae(e)||(gt(e)>1&&le.defineProperties(e,{set:wt,add:wt,clear:wt,delete:wt}),le.freeze(e),t&&Zt(e,(n,r)=>{rr(r,!0)},!1)),e}function no(){me(2)}var wt={[ut]:no};function tn(e){return e===null||!tr(e)?!0:le.isFrozen(e)}var Bt=\"MapSet\",$n=\"Patches\",Mr=\"ArrayMethods\",Qi={};function Le(e){const t=Qi[e];return t||me(0,e),t}var Br=e=>!!Qi[e],ct,Gi=()=>ct,ro=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Br(Bt)?Le(Bt):void 0,arrayMethodsPlugin_:Br(Mr)?Le(Mr):void 0});function Vr(e,t){t&&(e.patchPlugin_=Le($n),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Tn(e){Nn(e),e.drafts_.forEach(io),e.drafts_=null}function Nn(e){e===ct&&(ct=e.parent_)}var Hr=e=>ct=ro(ct,e);function io(e){const t=e[re];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function qr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[re].modified_&&(Tn(t),me(4)),Ae(e)&&(e=Ur(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[re].base_,e,t)}else e=Ur(t,n);return ao(t,e,!0),Tn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ji?e:void 0}function Ur(e,t){if(tn(t))return t;const n=t[re];if(!n)return Vt(t,e.handledSet_,e);if(!nn(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);Zi(n,e)}return n.copy_}function ao(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&rr(t,n)}function Yi(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var nn=(e,t)=>e.scope_===t,so=[];function Ki(e,t,n,r){const i=Ce(e),a=e.type_;if(r!==void 0&&En(i,r,a)===t){Mt(i,r,n,a);return}if(!e.draftLocations_){const o=e.draftLocations_=new Map;Zt(i,(u,l)=>{if($e(l)){const h=o.get(l)||[];h.push(u),o.set(l,h)}})}const s=e.draftLocations_.get(t)??so;for(const o of s)Mt(i,o,n,a)}function oo(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!nn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=nr(a);Ki(e,a.draft_??a,s,n),Zi(a,i)})}function Zi(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)}Yi(e)}}function lo(e,t,n){const{scope_:r}=e;if($e(n)){const i=n[re];nn(i,r)&&i.callbacks_.push(function(){$t(e);const s=nr(i);Ki(e,n,s,t)})}else Ae(n)&&e.callbacks_.push(function(){const a=Ce(e);e.type_===3?a.has(n)&&Vt(n,r.handledSet_,r):En(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Vt(En(e.copy_,t,e.type_),r.handledSet_,r)})}function Vt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||$e(e)||t.has(e)||!Ae(e)||tn(e)||(t.add(e),Zt(e,(r,i)=>{if($e(i)){const a=i[re];if(nn(a,n)){const s=nr(a);Mt(e,r,s,e.type_),Yi(a)}}else Ae(i)&&Vt(i,t,n)})),e}function uo(e,t){const n=Jt(e),r={type_:n?1:0,scope_:t?t.scope_:Gi(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=Ht;n&&(i=[r],a=ft);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var Ht={get(e,t){if(t===re)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=Ce(e);if(!Lr(i,t,e.type_))return co(e,i,t);const a=i[t];if(e.finalized_||!Ae(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&to(t))return a;if(a===dn(e.base_,t)){$t(e);const s=e.type_===1?+t:t,o=zn(e.scope_,a,e,s);return e.copy_[s]=o}return a},has(e,t){return t in Ce(e)},ownKeys(e){return Reflect.ownKeys(Ce(e))},set(e,t,n){const r=Ji(Ce(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=dn(Ce(e),t),a=i?.[re];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(eo(n,i)&&(n!==void 0||Lr(e.base_,t,e.type_)))return!0;$t(e),Dn(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),lo(e,t,n)),!0},deleteProperty(e,t){return $t(e),dn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Dn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ce(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[Pt]:!0,[An]:e.type_!==1||t!==\"length\",[Lt]:r[Lt],[ut]:n[t]}},defineProperty(){me(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){me(12)}},ft={};for(let e in Ht){let t=Ht[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 Ht.set.call(this,e[0],t,n,e[0])};function dn(e,t){const n=e[re];return(n?Ce(n):e)[t]}function co(e,t,n){const r=Ji(t,n);return r?ut in r?r[ut]:r.get?.call(e.draft_):void 0}function Ji(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function Dn(e){e.modified_||(e.modified_=!0,e.parent_&&Dn(e.parent_))}function $t(e){e.copy_||(e.assigned_=new Map,e.copy_=Pn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var fo=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(We(t)&&!We(n)){const a=n;n=t;const s=this;return function(u=a,...l){return s.produce(u,h=>n.call(this,h,...l))}}We(n)||me(6),r!==void 0&&!We(r)&&me(7);let i;if(Ae(t)){const a=Hr(this),s=zn(a,t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?Tn(a):Nn(a)}return Vr(a,r),qr(i,a)}else if(!t||!tr(t)){if(i=n(t),i===void 0&&(i=t),i===ji&&(i=void 0),this.autoFreeze_&&rr(i,!0),r){const a=[],s=[];Le($n).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:s}),r(a,s)}return i}else me(1,t)},this.produceWithPatches=(t,n)=>{if(We(t))return(s,...o)=>this.produceWithPatches(s,u=>t(u,...o));let r,i;return[this.produce(t,n,(s,o)=>{r=s,i=o}),r,i]},hn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),hn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),hn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ae(e)||me(8),$e(e)&&(e=ho(e));const t=Hr(this),n=zn(t,e,void 0);return n[re].isManual_=!0,Nn(t),n}finishDraft(e,t){const n=e&&e[re];(!n||!n.isManual_)&&me(9);const{scope_:r}=n;return Vr(r,t),qr(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Le($n).applyPatches_;return $e(e)?r(e,t):this.produce(e,i=>r(i,t))}};function zn(e,t,n,r){const[i,a]=Xt(t)?Le(Bt).proxyMap_(t,n):en(t)?Le(Bt).proxySet_(t,n):uo(t,n);return(n?.scope_??Gi()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?oo(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function ho(e){return $e(e)||me(10,e),Xi(e)}function Xi(e){if(!Ae(e)||tn(e))return e;const t=e[re];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Pn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Pn(e,!0);return Zt(n,(i,a)=>{Mt(n,i,Xi(a))},r),t&&(t.finalized_=!1),n}var po=new fo,mo=po.produce;const go=e=>(t,n,r)=>(r.setState=(i,a,...s)=>{const o=typeof i==\"function\"?mo(i):i;return t(o,a,...s)},e(r.setState,n,r)),_o=go,yo=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\"]),bo=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function vo(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 jr(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 Wr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;const s=i;for(;i<e.length&&/[a-zA-Z0-9_-]/.test(e[i]);)i++;if(i>s){const o=e.slice(s,i);a===\".\"?n.push(o):r=o}}return{className:n.join(\" \"),id:r,endIdx:i}}function xo(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const s=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(s,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function _t(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let s,o;if(e[n]===\".\"||e[n]===\"#\"){const _=Wr(e,n);s=_.className||void 0,o=_.id||void 0,n=_.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const h=e.slice(l,n);n+=2;const{display:c,target:d}=vo(h),f={type:\"link\",display:c,target:d,start:a,end:n};s&&(f.className=s),o&&(f.id=o),t.push(f),r=n;continue}if(e[n]===\"{\"){const a=n;let s=e[n+1],o,u;if(s===\".\"||s===\"#\"){i(n);const l=Wr(e,n+1);o=l.className||void 0,u=l.id||void 0;let h=l.endIdx;e[h]===\" \"&&h++;const c=e[h];if(c===\"$\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const _={type:\"variable\",name:f,scope:\"variable\",start:a,end:n};o&&(_.className=o),u&&(_.id=u),t.push(_),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=h+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(d,n);if(e[n]===\"}\"){n++;const _={type:\"variable\",name:f,scope:\"temporary\",start:a,end:n};o&&(_.className=o),u&&(_.id=u),t.push(_),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=h;let d=1;const f=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const _=e.slice(f,n);n++;const{name:C,rawArgs:I,isClose:b}=jr(_),x={type:\"macro\",name:C,rawArgs:I,isClose:b,start:a,end:n};o&&(x.className=o),u&&(x.id=u),t.push(x),r=n;continue}n=a+1,r=a;continue}if(s===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(s===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:h,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(s!==void 0&&(s===\"/\"||/[a-zA-Z]/.test(s))){i(n),n++;let l=1;const h=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(h,n);n++;const{name:d,rawArgs:f,isClose:_}=jr(c);t.push({type:\"macro\",name:d,rawArgs:f,isClose:_,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let s=n+1;const o=e[s]===\"/\";o&&s++;const u=s;for(;s<e.length&&/[a-zA-Z0-9]/.test(e[s]);)s++;const l=e.slice(u,s).toLowerCase();if(l&&yo.has(l))if(o){for(;s<e.length&&/\\s/.test(e[s]);)s++;if(e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:s}),r=s,n=s;continue}}else{const h=xo(e,s);s=h.endIdx;let c=bo.has(l);if(e[s]===\"/\"&&(c=!0,s++),e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:h.attributes,isClose:!1,isSelfClose:c,start:a,end:s}),r=s,n=s;continue}}n++;continue}n++}return i(e.length),t}const wo=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),Qr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},So=new Set([\"if\",\"switch\",\"timed\"]);function yt(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const a={type:\"link\",display:i.display,target:i.target};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const s=n[n.length-1];if(s.node.type!==\"html\"||s.node.tag!==i.tag){const o=s.node.type===\"html\"?`</${s.node.tag}>`:`{/${s.node.name}}`;throw new Error(`Expected ${o} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(s.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const 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(Qr[i.name]){const a=Qr[i.name],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 o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),s.branches.push(o);break}if(wo.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(So.has(i.name)){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:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function ea(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 ta(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let tt=!1,bt=\"\",Me=0,Je=null;function ko(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,bt=n,Me=0,Je=ea(ta(n)),tt=!0}function Fn(e,t){bt=e,Me=0,Je=ea(ta(e)),tt=!0;for(let n=0;n<t;n++)Je();Me=t}function Tt(){tt=!1,bt=\"\",Me=0,Je=null}function Nt(){return tt?{seed:bt,pull:Me}:null}function ir(){return!tt||!Je?Math.random():(Me++,Je())}function na(e,t){return e>t&&([e,t]=[t,e]),Math.floor(ir()*(t-e+1))+e}function Co(){return tt}function Io(){return bt}function Ao(){return Me}const Eo=500,Fe=new Map,Po=/\\$(\\w+)/g,$o=/\\b_(\\w+)/g;function ra(e){return e.replace(Po,'variables[\"$1\"]').replace($o,'temporary[\"$1\"]')}const To=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function ia(e,t){const n=Fe.get(e);if(n)return Fe.delete(e),Fe.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"__fns\",To+t);if(Fe.set(e,r),Fe.size>Eo){const i=Fe.keys().next().value;i!==void 0&&Fe.delete(i)}return r}let St=null,Gr=null,Yr=null;function aa(){const e=w.getState(),{visitCounts:t,renderCounts:n}=e;if(St&&Gr===t&&Yr===n)return St;const r=f=>t[f]??0,i=f=>r(f)>0,a=(...f)=>f.some(_=>r(_)>0),s=(...f)=>f.every(_=>r(_)>0),o=f=>n[f]??0;return St={currentPassage:()=>{const f=w.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=w.getState();if(f.historyIndex<=0)return;const _=f.history[f.historyIndex-1]?.passage;return _?f.storyData?.passages.get(_):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:s,rendered:o,hasRendered:f=>o(f)>0,hasRenderedAny:(...f)=>f.some(_=>o(_)>0),hasRenderedAll:(...f)=>f.every(_=>o(_)>0),random:ir,randomInt:na},Gr=t,Yr=n,St}function _e(e,t,n){const i=`return (${ra(e)});`;return ia(i,i)(t,n,aa())}function Be(e,t,n){const r=ra(e);ia(\"exec:\"+r,r)(t,n,aa())}const No=\"spindle\",Do=1;let kt=null,pn=null;function Te(){return pn||(pn={saves:new Map,playthroughs:new Map,meta:new Map}),pn}function zo(){return kt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(kt=new Promise((e,t)=>{const n=indexedDB.open(No,Do);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),kt))}function Ne(e,t){return zo().then(n=>n.transaction(e,t).objectStore(e))}function De(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function rn(e){try{const t=await Ne(\"saves\",\"readwrite\");await De(t.put(e))}catch{Te().saves.set(e.meta.id,e)}}async function an(e){try{const t=await Ne(\"saves\",\"readonly\");return await De(t.get(e))??void 0}catch{return Te().saves.get(e)}}async function Fo(e){try{const t=await Ne(\"saves\",\"readwrite\");await De(t.delete(e))}catch{Te().saves.delete(e)}}async function Oo(e){try{const n=(await Ne(\"saves\",\"readonly\")).index(\"ifid\");return await De(n.getAll(e))??[]}catch{return[...Te().saves.values()].filter(t=>t.meta.ifid===e)}}async function sa(e){try{const t=await Ne(\"playthroughs\",\"readwrite\");await De(t.put(e))}catch{Te().playthroughs.set(e.id,e)}}async function ar(e){try{const n=(await Ne(\"playthroughs\",\"readonly\")).index(\"ifid\");return await De(n.getAll(e))??[]}catch{return[...Te().playthroughs.values()].filter(t=>t.ifid===e)}}async function sr(e){try{const t=await Ne(\"meta\",\"readonly\"),n=await De(t.get(e));return n?n.value:void 0}catch{return Te().meta.get(e)}}async function oa(e,t){try{const n=await Ne(\"meta\",\"readwrite\");await De(n.put({key:e,value:t}))}catch{Te().meta.set(e,t)}}const la=new Map,sn=new Map;function Ro(e,t){la.set(e,t),sn.set(t,e)}function Lo(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Q(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 o=[];t.set(i,o);for(let u=0;u<r.length;u++)o[u]=n(r[u]);return o}const a=i.constructor;if(sn.get(a)!==void 0){const o=Object.create(Object.getPrototypeOf(i));t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}if(Lo(r)||typeof r==\"object\"){const o={};t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}return r}return n(e)}const On=\"__spindle_class__\",Rn=\"__spindle_data__\";function qt(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,s=sn.get(a);if(s!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[On]:s,[Rn]:u}}const o={};for(const u of Object.keys(i))o[u]=n(i[u]);return t.delete(i),o}return n(e)}function Ut(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(s=>t(s));const r=n;if(On in r&&Rn in r){const s=r[On],o=r[Rn],u=la.get(s);if(!u){console.warn(`spindle: Class \"${s}\" not registered. Falling back to plain object.`);const h={};for(const c of Object.keys(o))h[c]=t(o[c]);return h}const l=Object.create(u.prototype);for(const h of Object.keys(o))l[h]=t(o[h]);return l}const i=r.constructor;if(sn.has(i))return n;const a={};for(const s of Object.keys(r))a[s]=t(r[s]);return a}return t(e)}let Ln=null,Mn=null,Kr=!1;function Mo(e){Ln=e}function Bo(e){Mn=e}function Vo(e){if(Mn)try{const i=new Function(\"passage\",\"variables\",Mn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Ln)try{const r=Ln(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 Ho(){Kr||(Kr=!0)}async function Zr(e){const n=(await ar(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await sa(i),await oa(`currentPlaythroughId.${e}`,r),r}async function qo(e){return sr(`currentPlaythroughId.${e}`)}async function ua(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Vo(n),passage:n.passage,custom:r},s=Q(n);s.variables=qt(s.variables),s.history=s.history.map(u=>({...u,variables:qt(u.variables)}));const o={meta:a,payload:s};return await rn(o),o}async function ca(e,t){const n=await an(e);if(!n)return;const r=Q(t);r.variables=qt(r.variables),r.history=r.history.map(a=>({...a,variables:qt(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await rn(i),i}async function Uo(e){const t=await an(e);if(!t)return;const n=t.payload;return n.variables=Ut(n.variables),n.history=n.history.map(r=>({...r,variables:Ut(r.variables)})),n}async function jo(e){await Fo(e)}async function Wo(e,t){const n=await an(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await rn(r)}async function Qo(e){const[t,n]=await Promise.all([Oo(e),ar(e)]),r=new Map;for(const o of n)r.set(o.id,o);const i=new Map;for(const o of t){const u=o.meta.playthroughId,l=i.get(u);l?l.push(o):i.set(u,[o])}for(const o of i.values())o.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],s=[...r.values()].sort((o,u)=>new Date(u.createdAt).getTime()-new Date(o.createdAt).getTime());for(const o of s){const u=i.get(o.id)??[];a.push({playthrough:o,saves:u})}for(const[o,u]of i)r.has(o)||a.push({playthrough:{id:o,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const fa=\"autosave.\";async function Go(e,t,n){const r=`${fa}${e}`,i=await sr(r);if(i){const s=await ca(i,n);if(s)return s}const a=await ua(e,t,n,{isAutosave:!0});return await oa(r,a.meta.id),a}async function Yo(e){const t=`${fa}${e}`,n=await sr(t);if(n)return Uo(n)}async function Ko(e){const t=await an(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Zo(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=Q(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await ar(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await sa(a)}return await rn(n),n}function Jo(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")Be(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");Be(i,t,n)}}}function ha(){const e=w.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=_t(t.content),r=yt(n),i=Q(e.variables),a=Q(e.temporary);Jo(r,i,a);for(const o of Object.keys(i))i[o]!==e.variables[o]&&e.setVariable(o,i[o]);for(const o of Object.keys(a))a[o]!==e.temporary[o]&&e.setTemporary(o,a[o]);const s=e.storyData.passages.get(\"SaveTitle\");s&&Bo(s.content)}function Jr(e){e?.prng?Fn(e.prng.seed,e.prng.pull):e&&Tt()}const w=Js()(_o((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",saveError:null,loadError:null,init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=Q(r);e(o=>{o.storyData=n,o.currentPassage=i.name,o.variables=a,o.variableDefaults=r,o.temporary={},o.history=[{passage:i.name,variables:Q(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}});const s=n.ifid;Ho().then(async()=>{const o=await qo(s);if(o)e(u=>{u.playthroughId=o});else{const u=await Zr(s);e(l=>{l.playthroughId=u})}}).catch(o=>console.error(\"spindle: failed to init save system\",o))},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:Q(i.variables),timestamp:Date.now(),prng:Nt()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=Q(r.variables),n.temporary={}}),Jr(t().history[t().historyIndex])},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=Q(r.variables),n.temporary={}}),Jr(t().history[t().historyIndex])},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;Tt();const a=Q(r);e(s=>{s.currentPassage=i.name,s.variables=a,s.temporary={},s.history=[{passage:i.name,variables:Q(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),ha(),Zr(n.ifid).then(s=>{e(o=>{o.playthroughId=s})}).catch(s=>console.error(\"spindle: failed to start new playthrough\",s))},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:a,history:s,historyIndex:o,visitCounts:u,renderCounts:l}=t();if(!n)return;const h={passage:i,variables:Q(a),history:Q(s),historyIndex:o,visitCounts:{...u},renderCounts:{...l},prng:Nt()};e(c=>{c.saveError=null}),Go(n.ifid,r,h).then(()=>{e(c=>{c.saveVersion++})}).catch(c=>{console.error(\"spindle: failed to quick save\",c),e(d=>{d.saveError=c instanceof Error?c.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),Yo(n.ifid).then(r=>{r&&(e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}}),r.prng?Fn(r.prng.seed,r.prng.pull):Tt())}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:s,renderCounts:o}=t();return{passage:n,variables:Q(r),history:Q(i),historyIndex:a,visitCounts:{...s},renderCounts:{...o},prng:Nt()}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Ut(n.variables),r.history=n.history.map(i=>({...i,variables:Ut(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}}),n.prng?Fn(n.prng.seed,n.prng.pull):Tt()}}))),jt=new Map,Bn=new Set,Vn=new Map;function Xo(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Vn.get(r)??0)+1;return Vn.set(r,i),i===1?r:`${r}:${i}`}function el(e){return jt.set(e.id,e),ei(),()=>{jt.delete(e.id),ei()}}function Xr(){return Array.from(jt.values())}function tl(e){return jt.get(e)}function nl(){Vn.clear()}function rl(e){return Bn.add(e),()=>{Bn.delete(e)}}function ei(){for(const e of Bn)e()}function ie(e){const t=Re(\"\");t.current||(t.current=Xo(e.type,e.key,e.authorId));const n=t.current;return he(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),el(r)}),n}function il({target:e,className:t,id:n,children:r}){const i=w(o=>o.navigate),a=o=>{o.preventDefault(),i(e)};ie({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return g(\"a\",{href:\"#\",id:n,class:s,onClick:a,children:r})}function al({name:e,scope:t,className:n,id:r}){const i=He(Xe),a=e.split(\".\"),s=a[0],o=w(c=>t===\"variable\"?c.variables[s]:c.temporary[s]),u=t===\"variable\"?`$${s}`:`_${s}`;let l=u in i?i[u]:o;for(let c=1;c<a.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const d=a[c];l=l[d]}const h=l==null?\"\":String(l);return n||r?g(\"span\",{id:r,class:n,children:h}):g(Y,{children:h})}function sl({rawArgs:e}){return he(()=>{const t=w.getState(),n=Q(t.variables),r=Q(t.temporary);try{Be(e,n,r)}catch(i){console.error(`spindle: Error in {set ${e}}:`,i);return}for(const i of Object.keys(n))n[i]!==t.variables[i]&&t.setVariable(i,n[i]);for(const i of Object.keys(r))r[i]!==t.temporary[i]&&t.setTemporary(i,r[i])},[]),null}function qe(){const e=w(r=>r.variables),t=w(r=>r.temporary),n=He(Xe);return Ve(()=>{const r={...e},i={...t};for(const[a,s]of Object.entries(n))a.startsWith(\"$\")?r[a.slice(1)]=s:a.startsWith(\"_\")&&(i[a.slice(1)]=s);return[r,i]},[e,t,n])}function ol({rawArgs:e,className:t,id:n}){const[r,i]=qe();try{const a=_e(e,r,i),s=a==null?\"\":String(a);return t||n?g(\"span\",{id:n,class:t,children:s}):g(Y,{children:s})}catch(a){return g(\"span\",{class:\"error\",title:String(a),children:`{print error: ${a instanceof Error?a.message:String(a)}}`})}}function ll({branches:e}){const[t,n]=qe();function r(i){const a=fe(i.children);return i.className||i.id?g(\"span\",{id:i.id,class:i.className,children:a}):g(Y,{children:a})}for(const i of e){if(i.rawArgs===\"\")return r(i);try{if(_e(i.rawArgs,t,n))return r(i)}catch(a){return g(\"span\",{class:\"error\",title:String(a),children:`{if error: ${a instanceof Error?a.message:String(a)}}`})}}return null}function ul(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(o=>o.trim()),a=i[0],s=i.length>1?i[1]:null;return{itemVar:a,indexVar:s,listExpr:r}}function cl({rawArgs:e,children:t,className:n,id:r}){const i=He(Xe),[a,s]=qe();let o;try{o=ul(e)}catch(f){return g(\"span\",{class:\"error\",title:String(f),children:`{for error: ${f instanceof Error?f.message:String(f)}}`})}const{itemVar:u,indexVar:l,listExpr:h}=o;let c;try{const f=_e(h,a,s);if(!Array.isArray(f))return g(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});c=f}catch(f){return g(\"span\",{class:\"error\",title:String(f),children:`{for error: ${f instanceof Error?f.message:String(f)}}`})}const d=c.map((f,_)=>{const C={...i,[u]:f,...l?{[l]:_}:void 0};return g(Xe.Provider,{value:C,children:fe(t)},_)});return n||r?g(\"span\",{id:r,class:n,children:d}):g(Y,{children:d})}function fl(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function hl({children:e}){const t=fl(e);return he(()=>{const n=w.getState(),r=Q(n.variables),i=Q(n.temporary);try{Be(t,r,i)}catch(a){console.error(\"spindle: Error in {do}:\",a);return}for(const a of Object.keys(r))r[a]!==n.variables[a]&&n.setVariable(a,r[a]);for(const a of Object.keys(i))i[a]!==n.temporary[a]&&n.setTemporary(a,i[a])},[]),null}function da(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function dl({rawArgs:e,children:t,className:n,id:r}){const i=()=>{const s=w.getState(),o=Q(s.variables),u=Q(s.temporary);try{Be(e,o,u)}catch(l){console.error(`spindle: Error in {button ${e}}:`,l);return}for(const l of Object.keys(o))o[l]!==s.variables[l]&&s.setVariable(l,o[l]);for(const l of Object.keys(u))u[l]!==s.temporary[l]&&s.setTemporary(l,u[l])};ie({type:\"button\",key:e,authorId:r,label:da(t)||e,perform:i});const a=n?`macro-button ${n}`:\"macro-button\";return g(\"button\",{id:r,class:a,onClick:i,children:Ta(t)})}function pl({className:e,id:t}){const n=w(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return g(\"span\",{id:t,class:r,children:n})}function ml({className:e,id:t}){const n=w(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return ie({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),g(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}function gl({className:e,id:t}){const n=w(a=>a.goBack),r=w(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return ie({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function _l({className:e,id:t}){const n=w(a=>a.goForward),r=w(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return ie({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),g(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function yl({className:e,id:t}){const n=w(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return ie({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),g(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function bl({className:e,id:t}){const n=w(o=>o.load),r=w(o=>o.hasSave);w(o=>o.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r(),s=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return ie({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:a,perform:()=>n()}),g(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:s,children:\"QuickLoad\"})}const it=new Map;let ne={},ti=!1;function pa(){return`spindle.${w.getState().storyData?.ifid||\"unknown\"}.settings`}function vl(){localStorage.setItem(pa(),JSON.stringify(ne))}function mn(){if(!ti){ti=!0;try{const e=localStorage.getItem(pa());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ne={...ne,...t})}}catch{}}}const ht={addToggle(e,t){it.set(e,{type:\"toggle\",config:t}),e in ne||(ne[e]=t.default),mn()},addList(e,t){it.set(e,{type:\"list\",config:t}),e in ne||(ne[e]=t.default),mn()},addRange(e,t){it.set(e,{type:\"range\",config:t}),e in ne||(ne[e]=t.default),mn()},get(e){return ne[e]},getToggle(e){const t=ne[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ne[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ne[e];return typeof t==\"number\"?t:0},set(e,t){ne[e]=t,vl()},getAll(){return{...ne}},getDefinitions(){return it},hasAny(){return it.size>0}};function xl({name:e,def:t}){const[n,r]=J(()=>ht.get(e)),i=a=>{r(a),ht.set(e,a)};switch(t.type){case\"toggle\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:t.config.label}),g(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:t.config.label}),g(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>g(\"option\",{value:a,children:a},a))})]});case\"range\":return g(\"label\",{class:\"settings-row\",children:[g(\"span\",{children:[t.config.label,\": \",String(n)]}),g(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function wl({onClose:e}){const t=ht.getDefinitions();return g(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:g(\"div\",{class:\"settings-panel\",children:[g(\"div\",{class:\"settings-header\",children:[g(\"span\",{children:\"Settings\"}),g(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),g(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>g(xl,{name:r,def:i},r))})]})})}function Sl({className:e,id:t}){const[n,r]=J(!1);if(!ht.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return g(Y,{children:[g(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&g(wl,{onClose:()=>r(!1)})]})}function kl(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Cl(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function Il(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Al({onClose:e}){const[t,n]=J(\"load\"),[r,i]=J([]),[a,s]=J(!0),[o,u]=J(null),[l,h]=J(()=>new Set),[c,d]=J(null),[f,_]=J(\"\"),C=Re(null),I=Re(null),b=w(A=>A.storyData),x=w(A=>A.playthroughId),S=w(A=>A.getSavePayload),D=w(A=>A.loadFromPayload),E=b?.ifid??\"\",v=Gt(async()=>{if(!E)return;const A=await Qo(E);i(A),s(!1)},[E]);Se(()=>{v()},[v]),Se(()=>{c&&C.current&&(C.current.focus(),C.current.select())},[c]);const F=Re(),z=(A,p=\"success\")=>{clearTimeout(F.current),u({text:A,type:p}),F.current=window.setTimeout(()=>u(null),3e3)},M=A=>{h(p=>{const q=new Set(p);return q.has(A)?q.delete(A):q.add(A),q})},y=async()=>{if(!(!E||!x))try{const A=S();await ua(E,x,A),z(\"Save created\"),await v()}catch{z(\"Failed to create save\",\"error\")}},P=async A=>{try{const p=S();await ca(A,p),z(\"Save overwritten\"),await v()}catch{z(\"Failed to overwrite save\",\"error\")}},$=async A=>{try{D(A.payload),z(\"Game loaded\"),setTimeout(e,500)}catch{z(\"Failed to load save\",\"error\")}},V=async A=>{if(confirm(\"Delete this save?\"))try{await jo(A),z(\"Save deleted\"),await v()}catch{z(\"Failed to delete save\",\"error\")}},H=A=>{d(A.meta.id),_(A.meta.title)},R=async()=>{if(!(!c||!f.trim()))try{await Wo(c,f.trim()),d(null),z(\"Save renamed\"),await v()}catch{z(\"Failed to rename\",\"error\")}},Z=A=>{A.key===\"Enter\"?R():A.key===\"Escape\"&&d(null)},K=async A=>{try{const p=await Ko(A);if(!p)return;const q=new Blob([JSON.stringify(p,null,2)],{type:\"application/json\"}),j=URL.createObjectURL(q),U=document.createElement(\"a\");U.href=j,U.download=`save-${p.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,U.click(),URL.revokeObjectURL(j),z(\"Save exported\")}catch{z(\"Failed to export save\",\"error\")}},se=()=>{I.current?.click()},de=async A=>{const p=A.target,q=p.files?.[0];if(q){p.value=\"\";try{const j=await q.text(),U=JSON.parse(j);if(!kl(U))throw new Error(\"Invalid save file format\");await Zo(U,E),z(\"Save imported\"),await v()}catch(j){z(j instanceof Error?j.message:\"Failed to import save\",\"error\")}}},m=A=>{A.target.classList.contains(\"saves-overlay\")&&e()},oe=r.reduce((A,p)=>A+p.saves.length,0);return g(\"div\",{class:\"saves-overlay\",onClick:m,children:g(\"div\",{class:\"saves-panel\",children:[g(\"div\",{class:\"saves-header\",children:[g(\"div\",{class:\"saves-header-left\",children:g(\"div\",{class:\"saves-mode-toggle\",children:[g(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),g(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),g(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),g(\"div\",{class:\"saves-toolbar\",children:[g(\"button\",{class:\"saves-toolbar-button\",onClick:se,children:\"Import\"}),g(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:de})]}),g(\"div\",{class:\"saves-body\",children:[a?g(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):oe===0&&t===\"load\"?g(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(A=>{const p=l.has(A.playthrough.id),q=A.playthrough.id===x;return t===\"save\"&&!q||t===\"load\"&&A.saves.length===0&&!q?null:g(\"div\",{class:\"playthrough-group\",children:[g(\"div\",{class:\"playthrough-header\",onClick:()=>M(A.playthrough.id),children:[g(\"span\",{class:`playthrough-chevron ${p?\"\":\"open\"}`,children:\"▶\"}),g(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,q?\" (current)\":\"\"]}),g(\"span\",{class:\"playthrough-date\",children:Il(A.playthrough.createdAt)})]}),!p&&g(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(j=>g(\"div\",{class:\"save-slot\",children:[g(\"div\",{class:\"save-slot-info\",children:[c===j.meta.id?g(\"input\",{ref:C,class:\"save-rename-input\",value:f,onInput:U=>_(U.target.value),onKeyDown:Z,onBlur:R}):g(\"div\",{class:\"save-slot-title\",children:j.meta.title}),g(\"div\",{class:\"save-slot-meta\",children:[g(\"span\",{children:j.meta.passage}),g(\"span\",{children:Cl(j.meta.updatedAt)})]})]}),g(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?g(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(j.meta.id),children:\"Save Here\"}):g(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(j),children:\"Load\"}),g(\"button\",{class:\"save-slot-action\",onClick:()=>H(j),children:\"Rename\"}),g(\"button\",{class:\"save-slot-action\",onClick:()=>K(j.meta.id),children:\"Export\"}),g(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(j.meta.id),children:\"Delete\"})]})]},j.meta.id)),t===\"save\"&&q&&g(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})]})]},A.playthrough.id)}),t===\"save\"&&!a&&!r.some(A=>A.playthrough.id===x)&&g(\"div\",{class:\"playthrough-group\",children:g(\"div\",{class:\"playthrough-saves\",children:g(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})})})]}),o&&g(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})})}function El({className:e,id:t}){const[n,r]=J(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return g(Y,{children:[g(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&g(Al,{onClose:()=>r(!1)})]})}function Pl({rawArgs:e,className:t,id:n}){const r=w(c=>c.storyData),i=w(c=>c.variables),a=w(c=>c.temporary);if(!r)return null;let s;try{const c=_e(e,i,a);s=String(c)}catch{s=e.replace(/^[\"']|[\"']$/g,\"\")}const o=r.passages.get(s);if(o&&w.getState().trackRender(s),!o)return g(\"span\",{class:\"error\",children:`{include: passage \"${s}\" not found}`});const u=_t(o.content),l=yt(u),h=fe(l);return t||n?g(\"span\",{id:n,class:t,children:h}):g(Y,{children:h})}function $l({rawArgs:e}){return he(()=>{const t=w.getState();let n;try{const r=_e(e,t.variables,t.temporary);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}t.navigate(n)},[]),null}function Tl({rawArgs:e}){return he(()=>{const t=w.getState(),n=e.trim();n.startsWith(\"$\")?t.deleteVariable(n.slice(1)):n.startsWith(\"_\")?t.deleteTemporary(n.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${n}\"`)},[]),null}function Nl(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 Dl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Nl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"textbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return g(\"input\",{type:\"text\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function zl(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 Fl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=zl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"numberbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return g(\"input\",{type:\"number\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>{const h=l.target.value;o(a,h===\"\"?0:Number(h))}})}function Ol(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 Rl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Ol(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"textarea\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return g(\"textarea\",{id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function Ll(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}function Ml({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=Ll(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"checkbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:!!s,perform:l=>o(a,l!==void 0?!!l:!s)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return g(\"label\",{id:n,class:u,children:[g(\"input\",{type:\"checkbox\",checked:!!s,onChange:()=>o(a,!s)}),i?` ${i}`:null]})}function Bl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}function Vl({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=Bl(e),s=r.startsWith(\"$\")?r.slice(1):r,o=w(h=>h.variables[s]),u=w(h=>h.setVariable);ie({type:\"radiobutton\",key:`$${s}:${i}`,authorId:n,label:a||i,variable:s,value:o,perform:()=>u(s,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return g(\"label\",{id:n,class:l,children:[g(\"input\",{type:\"radio\",name:`radio-${s}`,checked:o===i,onChange:()=>u(s,i)}),a?` ${a}`:null]})}function ma(e){const t=[];for(const n of e)n.type===\"macro\"&&n.name===\"option\"&&t.push(n.rawArgs.trim());return t}function Hl({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=w(h=>h.variables[a]),o=w(h=>h.setVariable),u=ma(t);ie({type:\"listbox\",key:`$${a}`,authorId:r,label:a,variable:a,options:u,value:s,perform:h=>{h!==void 0&&o(a,String(h))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return g(\"select\",{id:r,class:l,value:s==null?\"\":String(s),onChange:h=>o(a,h.target.value),children:u.map(h=>g(\"option\",{value:h,children:h},h))})}function ql({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=w(c=>c.variables[a]),o=w(c=>c.setVariable),u=ma(t),l=()=>{if(u.length===0)return;const d=(u.indexOf(String(s))+1)%u.length;o(a,u[d])};ie({type:\"cycle\",key:`$${a}`,authorId:r,label:s==null?u[0]||\"\":String(s),variable:a,options:u,value:s,perform:c=>{c!==void 0?o(a,c):l()}});const h=n?`macro-cycle ${n}`:\"macro-cycle\";return g(\"button\",{id:r,class:h,onClick:l,children:s==null?u[0]||\"\":String(s)})}function Ul(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function ni(e){const t=w.getState(),n=Q(t.variables),r=Q(t.temporary);for(const i of e)if(i.type===\"macro\"){if(i.name===\"set\")try{Be(i.rawArgs,n,r)}catch(a){console.error(\"spindle: Error in {link} child {set}:\",a)}else if(i.name===\"do\"){const a=da(i.children);try{Be(a,n,r)}catch(s){console.error(\"spindle: Error in {link} child {do}:\",s)}}}for(const i of Object.keys(n))n[i]!==t.variables[i]&&t.setVariable(i,n[i]);for(const i of Object.keys(r))r[i]!==t.temporary[i]&&t.setTemporary(i,r[i])}function jl({rawArgs:e,children:t,className:n,id:r}){const{display:i,passage:a}=Ul(e),s=u=>{u.preventDefault(),ni(t),a&&w.getState().navigate(a)};ie({type:\"link\",key:a||i,authorId:r,label:i,target:a??void 0,perform:()=>{ni(t),a&&w.getState().navigate(a)}});const o=n?`macro-link ${n}`:\"macro-link\";return g(\"a\",{id:r,class:o,href:\"#\",onClick:s,children:i})}function Wl({rawArgs:e,branches:t}){const[n,r]=qe();let i;try{i=_e(e,n,r)}catch(s){return g(\"span\",{class:\"error\",title:String(s),children:`{switch error: ${s instanceof Error?s.message:String(s)}}`})}let a=null;for(const s of t){if(s.rawArgs===\"\"){a=s;continue}try{const o=_e(s.rawArgs,n,r);if(i===o)return g(Y,{children:fe(s.children)})}catch(o){return g(\"span\",{class:\"error\",title:String(o),children:`{case error: ${o instanceof Error?o.message:String(o)}}`})}}return a?g(Y,{children:fe(a.children)}):null}function Wt(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function Ql({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=Ve(()=>{const l=[];l.push({delay:Wt(e),nodes:t});for(const h of n){const c=h.rawArgs?Wt(h.rawArgs):0;l.push({delay:c,nodes:h.children})}return l},[e,t,n]),[s,o]=J(-1);if(Se(()=>{if(s>=a.length-1)return;const l=s+1,h=a[l].delay,c=setTimeout(()=>{o(l)},h);return()=>clearTimeout(c)},[s,a]),s<0)return null;const u=fe(a[s].nodes);return r||i?g(\"span\",{id:i,class:r,children:u}):g(Y,{children:u})}const ga=Zn({stop:()=>{}});function Gl({rawArgs:e,children:t,className:n,id:r}){const i=Wt(e),[a,s]=J(0),[o,u]=J(!1),l=Gt(()=>u(!0),[]);if(Se(()=>{if(o)return;const d=setInterval(()=>{s(f=>f+1)},i);return()=>clearInterval(d)},[i,o]),a===0&&!o)return null;const h=n?`macro-repeat ${n}`:void 0,c=g(ga.Provider,{value:{stop:l},children:fe(t)});return h||r?g(\"span\",{id:r,class:h,children:c}):c}function Yl(){const{stop:e}=He(ga);return he(()=>{e()},[e]),null}function Kl({rawArgs:e,children:t,className:n,id:r}){const i=Wt(e),a=Re(null),[s,o]=J(0),[u,l]=J(0);Se(()=>{if(a.current){const d=a.current.textContent||\"\";o(d.length)}},[]),Se(()=>{if(s===0||u>=s)return;const d=setInterval(()=>{l(f=>f>=s?(clearInterval(d),f):f+1)},i);return()=>clearInterval(d)},[s,i]);const h=u>=s&&s>0,c=[\"macro-type\",h?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return g(\"span\",{id:r,class:c,ref:a,style:{clipPath:(s>0&&!h,void 0)},children:[g(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!h?`inset(0 ${(s-u)/s*100}% 0 0)`:void 0},children:Ta(t)}),!h&&s>0&&g(\"span\",{class:\"macro-type-cursor\"})]})}const _a=new Map;function ya(e,t,n){_a.set(e.toLowerCase(),{body:t,params:n})}function Zl(e){return _a.get(e.toLowerCase())}function Jl(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"$\")||i.startsWith(\"_\"));return{name:n,params:r}}function Xl({rawArgs:e,children:t}){const{name:n,params:r}=Jl(e);return he(()=>{ya(n,t,r)},[]),null}function eu(e){const t=[];let n=\"\",r=0,i=null;for(let s=0;s<e.length;s++){const o=e[s];if(i){n+=o,o===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(o==='\"'||o===\"'\"||o===\"`\"){i=o,n+=o;continue}if(o===\"(\"||o===\"[\"||o===\"{\"){r++,n+=o;continue}if(o===\")\"||o===\"]\"||o===\"}\"){r--,n+=o;continue}if(o===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=o}const a=n.trim();return a&&t.push(a),t}function tu({body:e,params:t,rawArgs:n}){const r=He(Xe),[i,a]=qe();if(t.length===0||!n)return g(Y,{children:fe(e)});const s=eu(n),o={...r};for(let u=0;u<t.length;u++){const l=t[u],h=s[u];let c;if(h!==void 0)try{c=_e(h,i,a)}catch{c=void 0}o[l]=c}return g(Xe.Provider,{value:o,children:fe(e)})}function nu(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),s=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:s}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function ru(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 iu({rawArgs:e}){const[t,n]=qe();let r,i;try{({target:r,expr:i}=nu(e))}catch(o){return g(\"span\",{class:\"error\",title:String(o),children:`{computed error: ${o instanceof Error?o.message:String(o)}}`})}const a=r.startsWith(\"_\"),s=r.slice(1);return he(()=>{const o=w.getState();let u;try{u=_e(i,t,n)}catch(h){console.error(`spindle: Error in {computed ${e}}:`,h);return}const l=a?o.temporary[s]:o.variables[s];ru(l,u)||(a?o.setTemporary(s,u):o.setVariable(s,u))}),null}function au(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const a=su(r);if(a.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:a[0],maxExpr:a.slice(1).join(\" \"),labelMode:n}}function su(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const a=e[i];if(a===\"(\"||a===\"[\")r++,n+=a;else if(a===\")\"||a===\"]\")r--,n+=a;else if(/\\s/.test(a)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=a}return n.length>0&&t.push(n),t}function ou(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function lu({rawArgs:e,className:t,id:n}){const[r,i]=qe();try{const{currentExpr:a,maxExpr:s,labelMode:o}=au(e),u=Number(_e(a,r,i)),l=Number(_e(s,r,i)),h=l===0?0:Math.max(0,Math.min(100,u/l*100)),c=ou(u,l,o),d=[\"macro-meter\",t].filter(Boolean).join(\" \");return g(\"div\",{class:d,id:n,children:[g(\"div\",{class:\"macro-meter-fill\",style:`width: ${h}%`}),c!=null&&g(\"span\",{class:\"macro-meter-label\",children:c})]})}catch(a){return g(\"span\",{class:\"error\",title:String(a),children:`{meter error: ${a instanceof Error?a.message:String(a)}}`})}}function uu({passage:e}){const t=Ve(()=>{try{const n=_t(e.content),r=yt(n);return fe(r)}catch(n){return g(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”:\",\" \",n.message]})}},[e.content,e.name]);return g(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}function cu({className:e,id:t}){const n=w(a=>a.currentPassage),i=w(a=>a.storyData)?.passages.get(n);return i?g(\"div\",{id:t??\"story\",class:e??\"story\",children:g(uu,{passage:i},n)}):g(\"div\",{class:\"error\",children:[\"Error: Passage “\",n,\"” not found.\"]})}const fu=new Map;function hu(e){return fu.get(e.toLowerCase())}const ri=document.createElement(\"i\");function ba(e){const t=\"&\"+e+\";\";ri.innerHTML=t;const n=ri.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function ce(e,t,n,r){const i=e.length;let a=0,s;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);a<r.length;)s=r.slice(a,a+1e4),s.unshift(t,0),e.splice(...s),a+=1e4,t+=1e4}function ee(e,t){return e.length>0?(ce(e,e.length,0,t),e):t}const Hn={}.hasOwnProperty;function du(e){const t={};let n=-1;for(;++n<e.length;)pu(t,e[n]);return t}function pu(e,t){let n;for(n in t){const i=(Hn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Hn.call(i,s)||(i[s]=[]);const o=a[s];mu(i[s],Array.isArray(o)?o:o?[o]:[])}}}function mu(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);ce(e,0,0,r)}function gu(e){const t={};let n=-1;for(;++n<e.length;)_u(t,e[n]);return t}function _u(e,t){let n;for(n in t){const i=(Hn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a)i[s]=a[s]}}function yu(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 bu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function va(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+bu[n]+\";\"}}function dt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const ve=ze(/[A-Za-z]/),ue=ze(/[\\dA-Za-z]/),vu=ze(/[#-'*+\\--9=?A-Z^-~]/);function qn(e){return e!==null&&(e<32||e===127)}const Un=ze(/\\d/),xu=ze(/[\\dA-Fa-f]/),wu=ze(/[!-/:-@[-`{-~]/);function N(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Su=ze(/\\p{P}|\\p{S}/u),ku=ze(/\\s/);function ze(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ct(e,t){const n=va(Cu(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),s=n.indexOf(\"/\");return r<0||s>-1&&r>s||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Cu(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let s=\"\";if(a===37&&ue(e.charCodeAt(n+1))&&ue(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(s=String.fromCharCode(a));else if(a>55295&&a<57344){const o=e.charCodeAt(n+1);a<56320&&o>56319&&o<57344?(s=String.fromCharCode(a,o),i=1):s=\"�\"}else s=String.fromCharCode(a);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const ii={}.hasOwnProperty,ai=/^(https?|ircs?|mailto|xmpp)$/i,Iu=/^https?$/i;function Au(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],s=[],u=gu([{enter:{blockQuote:R,codeFenced:de,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:A,codeText:Ja,content:Ba,definition:za,definitionDestinationString:Oa,definitionLabelString:I,definitionTitleString:I,emphasis:Ka,htmlFlow:Ya,htmlText:fr,image:q,label:I,link:j,listItemMarker:P,listItemValue:y,listOrdered:z,listUnordered:M,paragraph:K,reference:I,resource:Ue,resourceDestinationString:je,resourceTitleString:I,setextHeading:Ha,strong:Za},exit:{atxHeading:Ua,atxHeadingSequence:Va,autolinkEmail:as,autolinkProtocol:is,blockQuote:Z,characterEscapeValue:rt,characterReferenceMarkerHexadecimal:hr,characterReferenceMarkerNumeric:hr,characterReferenceValue:rs,codeFenced:p,codeFencedFence:oe,codeFencedFenceInfo:m,codeFencedFenceMeta:F,codeFlowValue:Ga,codeIndented:p,codeText:Xa,codeTextData:rt,data:rt,definition:Ma,definitionDestinationString:Ra,definitionLabelString:Fa,definitionTitleString:La,emphasis:es,hardBreakEscape:ur,hardBreakTrailing:ur,htmlFlow:cr,htmlFlowData:rt,htmlText:cr,htmlTextData:rt,image:lr,label:nt,labelText:U,lineEnding:Qa,link:lr,listOrdered:$,listUnordered:V,paragraph:se,reference:F,referenceString:Ee,resource:F,resourceDestinationString:un,resourceTitleString:Da,setextHeading:Wa,setextHeadingLineSequence:ja,setextHeadingText:qa,strong:ts,thematicBreak:ns}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:s},h={buffer:I,encode:v,getData:C,lineEndingIfNeeded:E,options:t,raw:S,resume:b,setData:_,tag:x};let c=t.defaultLineEnding;return d;function d(k){let T=-1,X=0;const pe=[];let ye=[],ke=[];for(;++T<k.length;)!c&&(k[T][1].type===\"lineEnding\"||k[T][1].type===\"lineEndingBlank\")&&(c=k[T][2].sliceSerialize(k[T][1])),(k[T][1].type===\"listOrdered\"||k[T][1].type===\"listUnordered\")&&(k[T][0]===\"enter\"?pe.push(T):f(k.slice(pe.pop(),T))),k[T][1].type===\"definition\"&&(k[T][0]===\"enter\"?(ke=ee(ke,k.slice(X,T)),X=T):(ye=ee(ye,k.slice(X,T+1)),X=T+1));ye=ee(ye,ke),ye=ee(ye,k.slice(X)),T=-1;const be=ye;for(u.enter.null&&u.enter.null.call(h);++T<k.length;){const dr=u[be[T][0]],pr=be[T][1].type,mr=dr[pr];ii.call(dr,pr)&&mr&&mr.call({sliceSerialize:be[T][2].sliceSerialize,...h},be[T][1])}return u.exit.null&&u.exit.null.call(h),i[0].join(\"\")}function f(k){const T=k.length;let X=0,pe=0,ye=!1,ke;for(;++X<T;){const be=k[X];if(be[1]._container)ke=void 0,be[0]===\"enter\"?pe++:pe--;else switch(be[1].type){case\"listItemPrefix\":{be[0]===\"exit\"&&(ke=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{be[0]===\"enter\"&&!pe&&(ke?ke=void 0:ye=!0);break}default:ke=void 0}}k[0][1]._loose=ye}function _(k,T){l[k]=T}function C(k){return l[k]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function x(k){n&&(_(\"lastWasTag\",!0),i[i.length-1].push(k))}function S(k){_(\"lastWasTag\"),i[i.length-1].push(k)}function D(){S(c||`\n`)}function E(){const k=i[i.length-1],T=k[k.length-1],X=T?T.charCodeAt(T.length-1):null;X===10||X===13||X===null||D()}function v(k){return C(\"ignoreEncode\")?k:va(k)}function F(){b()}function z(k){s.push(!k._loose),E(),x(\"<ol\"),_(\"expectFirstItem\",!0)}function M(k){s.push(!k._loose),E(),x(\"<ul\"),_(\"expectFirstItem\",!0)}function y(k){if(C(\"expectFirstItem\")){const T=Number.parseInt(this.sliceSerialize(k),10);T!==1&&x(' start=\"'+v(String(T))+'\"')}}function P(){C(\"expectFirstItem\")?x(\">\"):H(),E(),x(\"<li>\"),_(\"expectFirstItem\"),_(\"lastWasTag\")}function $(){H(),s.pop(),D(),x(\"</ol>\")}function V(){H(),s.pop(),D(),x(\"</ul>\")}function H(){C(\"lastWasTag\")&&!C(\"slurpAllLineEndings\")&&E(),x(\"</li>\"),_(\"slurpAllLineEndings\")}function R(){s.push(!1),E(),x(\"<blockquote>\")}function Z(){s.pop(),E(),x(\"</blockquote>\"),_(\"slurpAllLineEndings\")}function K(){s[s.length-1]||(E(),x(\"<p>\")),_(\"slurpAllLineEndings\")}function se(){s[s.length-1]?_(\"slurpAllLineEndings\",!0):x(\"</p>\")}function de(){E(),x(\"<pre><code\"),_(\"fencesCount\",0)}function m(){const k=b();x(' class=\"language-'+k+'\"')}function oe(){const k=C(\"fencesCount\")||0;k||(x(\">\"),_(\"slurpOneLineEnding\",!0)),_(\"fencesCount\",k+1)}function A(){E(),x(\"<pre><code>\")}function p(){const k=C(\"fencesCount\");k!==void 0&&k<2&&l.tightStack.length>0&&!C(\"lastWasTag\")&&D(),C(\"flowCodeSeenData\")&&E(),x(\"</code></pre>\"),k!==void 0&&k<2&&E(),_(\"flowCodeSeenData\"),_(\"fencesCount\"),_(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function j(){a.push({})}function U(k){a[a.length-1].labelId=this.sliceSerialize(k)}function nt(){a[a.length-1].label=b()}function Ee(k){a[a.length-1].referenceId=this.sliceSerialize(k)}function Ue(){I(),a[a.length-1].destination=\"\"}function je(){I(),_(\"ignoreEncode\",!0)}function un(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function Da(){a[a.length-1].title=b()}function lr(){let k=a.length-1;const T=a[k],X=T.referenceId||T.labelId,pe=T.destination===void 0?r[dt(X)]:T;for(n=!0;k--;)if(a[k].image){n=void 0;break}T.image?(x('<img src=\"'+Ct(pe.destination,t.allowDangerousProtocol?void 0:Iu)+'\" alt=\"'),S(T.label),x('\"')):x('<a href=\"'+Ct(pe.destination,t.allowDangerousProtocol?void 0:ai)+'\"'),x(pe.title?' title=\"'+pe.title+'\"':\"\"),T.image?x(\" />\"):(x(\">\"),S(T.label),x(\"</a>\")),a.pop()}function za(){I(),a.push({})}function Fa(k){b(),a[a.length-1].labelId=this.sliceSerialize(k)}function Oa(){I(),_(\"ignoreEncode\",!0)}function Ra(){a[a.length-1].destination=b(),_(\"ignoreEncode\")}function La(){a[a.length-1].title=b()}function Ma(){const k=a[a.length-1],T=dt(k.labelId);b(),ii.call(r,T)||(r[T]=a[a.length-1]),a.pop()}function Ba(){_(\"slurpAllLineEndings\",!0)}function Va(k){C(\"headingRank\")||(_(\"headingRank\",this.sliceSerialize(k).length),E(),x(\"<h\"+C(\"headingRank\")+\">\"))}function Ha(){I(),_(\"slurpAllLineEndings\")}function qa(){_(\"slurpAllLineEndings\",!0)}function Ua(){x(\"</h\"+C(\"headingRank\")+\">\"),_(\"headingRank\")}function ja(k){_(\"headingRank\",this.sliceSerialize(k).charCodeAt(0)===61?1:2)}function Wa(){const k=b();E(),x(\"<h\"+C(\"headingRank\")+\">\"),S(k),x(\"</h\"+C(\"headingRank\")+\">\"),_(\"slurpAllLineEndings\"),_(\"headingRank\")}function rt(k){S(v(this.sliceSerialize(k)))}function Qa(k){if(!C(\"slurpAllLineEndings\")){if(C(\"slurpOneLineEnding\")){_(\"slurpOneLineEnding\");return}if(C(\"inCodeText\")){S(\" \");return}S(v(this.sliceSerialize(k)))}}function Ga(k){S(v(this.sliceSerialize(k))),_(\"flowCodeSeenData\",!0)}function ur(){x(\"<br />\")}function Ya(){E(),fr()}function cr(){_(\"ignoreEncode\")}function fr(){t.allowDangerousHtml&&_(\"ignoreEncode\",!0)}function Ka(){x(\"<em>\")}function Za(){x(\"<strong>\")}function Ja(){_(\"inCodeText\",!0),x(\"<code>\")}function Xa(){_(\"inCodeText\"),x(\"</code>\")}function es(){x(\"</em>\")}function ts(){x(\"</strong>\")}function ns(){E(),x(\"<hr />\")}function hr(k){_(\"characterReferenceType\",k.type)}function rs(k){const T=this.sliceSerialize(k),X=C(\"characterReferenceType\")?yu(T,C(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):ba(T);S(v(X)),_(\"characterReferenceType\")}function is(k){const T=this.sliceSerialize(k);x('<a href=\"'+Ct(T,t.allowDangerousProtocol?void 0:ai)+'\">'),S(v(T)),x(\"</a>\")}function as(k){const T=this.sliceSerialize(k);x('<a href=\"'+Ct(\"mailto:\"+T)+'\">'),S(v(T)),x(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return s;function s(u){return L(u)?(e.enter(n),o(u)):t(u)}function o(u){return L(u)&&a++<i?(e.consume(u),o):(e.exit(n),t(u))}}const Eu={tokenize:Pu};function Pu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(o){return e.enter(\"paragraph\"),a(o)}function a(o){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,s(o)}function s(o){if(o===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(o);return}return N(o)?(e.consume(o),e.exit(\"chunkText\"),a):(e.consume(o),s)}}const $u={tokenize:Tu},si={tokenize:Nu};function Tu(e){const t=this,n=[];let r=0,i,a,s;return o;function o(S){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,u,l)(S)}return l(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const D=t.events.length;let E=D,v;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){v=t.events[E][1].end;break}b(r);let F=D;for(;F<t.events.length;)t.events[F][1].end={...v},F++;return ce(t.events,E+1,0,t.events.slice(D)),t.events.length=F,l(S)}return o(S)}function l(S){if(r===n.length){if(!i)return d(S);if(i.currentConstruct&&i.currentConstruct.concrete)return _(S);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(si,h,c)(S)}function h(S){return i&&x(),b(r),d(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,_(S)}function d(S){return t.containerState={},e.attempt(si,f,_)(S)}function f(S){return r++,n.push([t.currentConstruct,t.containerState]),d(S)}function _(S){if(S===null){i&&x(),b(0),e.consume(S);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),C(S)}function C(S){if(S===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(S);return}return N(S)?(e.consume(S),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,o):(e.consume(S),C)}function I(S,D){const E=t.sliceStream(S);if(D&&E.push(null),S.previous=a,a&&(a.next=S),a=S,i.defineSkip(S.start),i.write(E),t.parser.lazy[S.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<s&&(!i.events[v][1].end||i.events[v][1].end.offset>s))return;const F=t.events.length;let z=F,M,y;for(;z--;)if(t.events[z][0]===\"exit\"&&t.events[z][1].type===\"chunkFlow\"){if(M){y=t.events[z][1].end;break}M=!0}for(b(r),v=F;v<t.events.length;)t.events[v][1].end={...y},v++;ce(t.events,z+1,0,t.events.slice(F)),t.events.length=v}}function b(S){let D=n.length;for(;D-- >S;){const E=n[D];t.containerState=E[1],E[0].exit.call(t,e)}n.length=S}function x(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Nu(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Qt(e){if(e===null||te(e)||ku(e))return 1;if(Su(e))return 2}function on(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const jn={name:\"attention\",resolveAll:Du,tokenize:zu};function Du(e,t){let n=-1,r,i,a,s,o,u,l,h;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};oi(c,-u),oi(d,u),s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...s.start},end:{...o.end}},e[r][1].end={...s.start},e[n][1].start={...o.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",s,t],[\"exit\",s,t],[\"enter\",a,t]]),l=ee(l,on(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(l,[[\"exit\",a,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,l=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):h=0,ce(e,r-1,n-r+3,l),n=r+l.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function zu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Qt(r);let a;return s;function s(u){return a=u,e.enter(\"attentionSequence\"),o(u)}function o(u){if(u===a)return e.consume(u),o;const l=e.exit(\"attentionSequence\"),h=Qt(u),c=!h||h===2&&i||n.includes(u),d=!i||i===2&&h||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(h||!c)),t(u)}}function oi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Fu={name:\"autolink\",tokenize:Ou};function Ou(e,t,n){let r=0;return i;function i(f){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(f){return ve(f)?(e.consume(f),s):f===64?n(f):l(f)}function s(f){return f===43||f===45||f===46||ue(f)?(r=1,o(f)):l(f)}function o(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||ue(f))&&r++<32?(e.consume(f),o):(r=0,l(f))}function u(f){return f===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):f===null||f===32||f===60||qn(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),h):vu(f)?(e.consume(f),l):n(f)}function h(f){return ue(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,h):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(f)}function d(f){if((f===45||ue(f))&&r++<63){const _=f===45?d:c;return e.consume(f),_}return n(f)}}const ln={partial:!0,tokenize:Ru};function Ru(e,t,n){return r;function r(a){return L(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||N(a)?t(a):n(a)}}const xa={continuation:{tokenize:Mu},exit:Bu,name:\"blockQuote\",tokenize:Lu};function Lu(e,t,n){const r=this;return i;function i(s){if(s===62){const o=r.containerState;return o.open||(e.enter(\"blockQuote\",{_container:!0}),o.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(s),e.exit(\"blockQuoteMarker\"),a}return n(s)}function a(s){return L(s)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(s),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(s))}}function Mu(e,t,n){const r=this;return i;function i(s){return L(s)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s):a(s)}function a(s){return e.attempt(xa,t,n)(s)}}function Bu(e){e.exit(\"blockQuote\")}const wa={name:\"characterEscape\",tokenize:Vu};function Vu(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return wu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Sa={name:\"characterReference\",tokenize:Hu};function Hu(e,t,n){const r=this;let i=0,a,s;return o;function o(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,s=ue,h(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,s=xu,h):(e.enter(\"characterReferenceValue\"),a=7,s=Un,h(c))}function h(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return s===ue&&!ba(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return s(c)&&i++<a?(e.consume(c),h):n(c)}}const li={partial:!0,tokenize:Uu},ui={concrete:!0,name:\"codeFenced\",tokenize:qu};function qu(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,s=0,o;return u;function u(v){return l(v)}function l(v){const F=r.events[r.events.length-1];return a=F&&F[1].type===\"linePrefix\"?F[2].sliceSerialize(F[1],!0).length:0,o=v,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),h(v)}function h(v){return v===o?(s++,e.consume(v),h):s<3?n(v):(e.exit(\"codeFencedFenceSequence\"),L(v)?B(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||N(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(li,C,D)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(v))}function d(v){return v===null||N(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):L(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,f,\"whitespace\")(v)):v===96&&v===o?n(v):(e.consume(v),d)}function f(v){return v===null||N(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),_(v))}function _(v){return v===null||N(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===o?n(v):(e.consume(v),_)}function C(v){return e.attempt(i,D,I)(v)}function I(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),b}function b(v){return a>0&&L(v)?B(e,x,\"linePrefix\",a+1)(v):x(v)}function x(v){return v===null||N(v)?e.check(li,C,D)(v):(e.enter(\"codeFlowValue\"),S(v))}function S(v){return v===null||N(v)?(e.exit(\"codeFlowValue\"),x(v)):(e.consume(v),S)}function D(v){return e.exit(\"codeFenced\"),t(v)}function E(v,F,z){let M=0;return y;function y(R){return v.enter(\"lineEnding\"),v.consume(R),v.exit(\"lineEnding\"),P}function P(R){return v.enter(\"codeFencedFence\"),L(R)?B(v,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):$(R)}function $(R){return R===o?(v.enter(\"codeFencedFenceSequence\"),V(R)):z(R)}function V(R){return R===o?(M++,v.consume(R),V):M>=s?(v.exit(\"codeFencedFenceSequence\"),L(R)?B(v,H,\"whitespace\")(R):H(R)):z(R)}function H(R){return R===null||N(R)?(v.exit(\"codeFencedFence\"),F(R)):z(R)}}}function Uu(e,t,n){const r=this;return i;function i(s){return s===null?n(s):(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}const gn={name:\"codeIndented\",tokenize:Wu},ju={partial:!0,tokenize:Qu};function Wu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(e,a,\"linePrefix\",5)(l)}function a(l){const h=r.events[r.events.length-1];return h&&h[1].type===\"linePrefix\"&&h[2].sliceSerialize(h[1],!0).length>=4?s(l):n(l)}function s(l){return l===null?u(l):N(l)?e.attempt(ju,s,u)(l):(e.enter(\"codeFlowValue\"),o(l))}function o(l){return l===null||N(l)?(e.exit(\"codeFlowValue\"),s(l)):(e.consume(l),o)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function Qu(e,t,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):N(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(s)}function a(s){const o=r.events[r.events.length-1];return o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):N(s)?i(s):n(s)}}const Gu={name:\"codeText\",previous:Ku,resolve:Yu,tokenize:Zu};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 Ku(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function Zu(e,t,n){let r=0,i,a;return s;function s(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),o(c)}function o(c){return c===96?(e.consume(c),r++,o):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,h(c)):N(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||N(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function h(c){return c===96?(e.consume(c),i++,h):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class Ju{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&at(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),at(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),at(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);at(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);at(this.left,n.reverse())}}}function at(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ka(e){const t={};let n=-1,r,i,a,s,o,u,l;const h=new Ju(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type===\"chunkFlow\"&&h.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,Xu(h,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(s=h.get(a),s[1].type===\"lineEnding\"||s[1].type===\"lineEndingBlank\")s[0]===\"enter\"&&(i&&(h.get(i)[1].type=\"lineEndingBlank\"),s[1].type=\"lineEnding\",i=a);else if(!(s[1].type===\"linePrefix\"||s[1].type===\"listItemIndent\"))break;i&&(r[1].end={...h.get(i)[1].start},o=h.slice(i,n),o.unshift(r),h.splice(i,n-i+1,o))}}return ce(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!l}function Xu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const o=s.events,u=[],l={};let h,c,d=-1,f=n,_=0,C=0;const I=[C];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(h=r.sliceStream(f),f.next||h.push(null),c&&s.defineSkip(f.start),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(h),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++d<o.length;)o[d][0]===\"exit\"&&o[d-1][0]===\"enter\"&&o[d][1].type===o[d-1][1].type&&o[d][1].start.line!==o[d][1].end.line&&(C=d+1,I.push(C),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(s.events=[],f?(f._tokenizer=void 0,f.previous=void 0):I.pop(),d=I.length;d--;){const b=o.slice(I[d],I[d+1]),x=a.pop();u.push([x,x+b.length-1]),e.splice(x,2,b)}for(u.reverse(),d=-1;++d<u.length;)l[_+u[d][0]]=_+u[d][1],_+=u[d][1]-u[d][0]-1;return l}const ec={resolve:nc,tokenize:rc},tc={partial:!0,tokenize:ic};function nc(e){return ka(e),e}function rc(e,t){let n;return r;function r(o){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(o)}function i(o){return o===null?a(o):N(o)?e.check(tc,s,a)(o):(e.consume(o),i)}function a(o){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(o)}function s(o){return e.consume(o),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function ic(e,t,n){const r=this;return i;function i(s){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(s){if(s===null||N(s))return n(s);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function Ca(e,t,n,r,i,a,s,o,u){const l=u||Number.POSITIVE_INFINITY;let h=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),d):b===null||b===32||b===41||qn(b)?n(b):(e.enter(r),e.enter(s),e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),C(b))}function d(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),f(b))}function f(b){return b===62?(e.exit(\"chunkString\"),e.exit(o),d(b)):b===null||b===60||N(b)?n(b):(e.consume(b),b===92?_:f)}function _(b){return b===60||b===62||b===92?(e.consume(b),f):f(b)}function C(b){return!h&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(o),e.exit(s),e.exit(r),t(b)):h<l&&b===40?(e.consume(b),h++,C):b===41?(e.consume(b),h--,C):b===null||b===32||b===40||qn(b)?n(b):(e.consume(b),b===92?I:C)}function I(b){return b===40||b===41||b===92?(e.consume(b),C):C(b)}}function Ia(e,t,n,r,i,a){const s=this;let o=0,u;return l;function l(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),h}function h(f){return o>999||f===null||f===91||f===93&&!u||f===94&&!o&&\"_hiddenFootnoteSupport\"in s.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):N(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),h):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||N(f)||o++>999?(e.exit(\"chunkString\"),h(f)):(e.consume(f),u||(u=!L(f)),f===92?d:c)}function d(f){return f===91||f===92||f===93?(e.consume(f),o++,c):c(f)}}function Aa(e,t,n,r,i,a){let s;return o;function o(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),s=d===40?41:d,u):n(d)}function u(d){return d===s?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===s?(e.exit(a),u(s)):d===null?n(d):N(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),h(d))}function h(d){return d===s||d===null||N(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:h)}function c(d){return d===s||d===92?(e.consume(d),h):h(d)}}function lt(e,t){let n;return r;function r(i){return N(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const ac={name:\"definition\",tokenize:oc},sc={partial:!0,tokenize:lc};function oc(e,t,n){const r=this;let i;return a;function a(f){return e.enter(\"definition\"),s(f)}function s(f){return Ia.call(r,e,o,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function o(f){return i=dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter(\"definitionMarker\"),e.consume(f),e.exit(\"definitionMarker\"),u):n(f)}function u(f){return te(f)?lt(e,l)(f):l(f)}function l(f){return Ca(e,h,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function h(f){return e.attempt(sc,c,c)(f)}function c(f){return L(f)?B(e,d,\"whitespace\")(f):d(f)}function d(f){return f===null||N(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function lc(e,t,n){return r;function r(o){return te(o)?lt(e,i)(o):n(o)}function i(o){return Aa(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(o)}function a(o){return L(o)?B(e,s,\"whitespace\")(o):s(o)}function s(o){return o===null||N(o)?t(o):n(o)}}const uc={name:\"hardBreakEscape\",tokenize:cc};function cc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return N(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const fc={name:\"headingAtx\",resolve:hc,tokenize:dc};function hc(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},ce(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function dc(e,t,n){let r=0;return i;function i(h){return e.enter(\"atxHeading\"),a(h)}function a(h){return e.enter(\"atxHeadingSequence\"),s(h)}function s(h){return h===35&&r++<6?(e.consume(h),s):h===null||te(h)?(e.exit(\"atxHeadingSequence\"),o(h)):n(h)}function o(h){return h===35?(e.enter(\"atxHeadingSequence\"),u(h)):h===null||N(h)?(e.exit(\"atxHeading\"),t(h)):L(h)?B(e,o,\"whitespace\")(h):(e.enter(\"atxHeadingText\"),l(h))}function u(h){return h===35?(e.consume(h),u):(e.exit(\"atxHeadingSequence\"),o(h))}function l(h){return h===null||h===35||te(h)?(e.exit(\"atxHeadingText\"),o(h)):(e.consume(h),l)}}const pc=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],ci=[\"pre\",\"script\",\"style\",\"textarea\"],mc={concrete:!0,name:\"htmlFlow\",resolveTo:yc,tokenize:bc},gc={partial:!0,tokenize:xc},_c={partial:!0,tokenize:vc};function yc(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 bc(e,t,n){const r=this;let i,a,s,o,u;return l;function l(p){return h(p)}function h(p){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(p),c}function c(p){return p===33?(e.consume(p),d):p===47?(e.consume(p),a=!0,C):p===63?(e.consume(p),i=3,r.interrupt?t:m):ve(p)?(e.consume(p),s=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,f):p===91?(e.consume(p),i=5,o=0,_):ve(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function f(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function _(p){const q=\"CDATA[\";return p===q.charCodeAt(o++)?(e.consume(p),o===q.length?r.interrupt?t:$:_):n(p)}function C(p){return ve(p)?(e.consume(p),s=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||te(p)){const q=p===47,j=s.toLowerCase();return!q&&!a&&ci.includes(j)?(i=1,r.interrupt?t(p):$(p)):pc.includes(s.toLowerCase())?(i=6,q?(e.consume(p),b):r.interrupt?t(p):$(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):a?x(p):S(p))}return p===45||ue(p)?(e.consume(p),s+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:$):n(p)}function x(p){return L(p)?(e.consume(p),x):y(p)}function S(p){return p===47?(e.consume(p),y):p===58||p===95||ve(p)?(e.consume(p),D):L(p)?(e.consume(p),S):y(p)}function D(p){return p===45||p===46||p===58||p===95||ue(p)?(e.consume(p),D):E(p)}function E(p){return p===61?(e.consume(p),v):L(p)?(e.consume(p),E):S(p)}function v(p){return p===null||p===60||p===61||p===62||p===96?n(p):p===34||p===39?(e.consume(p),u=p,F):L(p)?(e.consume(p),v):z(p)}function F(p){return p===u?(e.consume(p),u=null,M):p===null||N(p)?n(p):(e.consume(p),F)}function z(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||te(p)?E(p):(e.consume(p),z)}function M(p){return p===47||p===62||L(p)?S(p):n(p)}function y(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||N(p)?$(p):L(p)?(e.consume(p),P):n(p)}function $(p){return p===45&&i===2?(e.consume(p),Z):p===60&&i===1?(e.consume(p),K):p===62&&i===4?(e.consume(p),oe):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),de):N(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(gc,A,V)(p)):p===null||N(p)?(e.exit(\"htmlFlowData\"),V(p)):(e.consume(p),$)}function V(p){return e.check(_c,H,A)(p)}function H(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),R}function R(p){return p===null||N(p)?V(p):(e.enter(\"htmlFlowData\"),$(p))}function Z(p){return p===45?(e.consume(p),m):$(p)}function K(p){return p===47?(e.consume(p),s=\"\",se):$(p)}function se(p){if(p===62){const q=s.toLowerCase();return ci.includes(q)?(e.consume(p),oe):$(p)}return ve(p)&&s.length<8?(e.consume(p),s+=String.fromCharCode(p),se):$(p)}function de(p){return p===93?(e.consume(p),m):$(p)}function m(p){return p===62?(e.consume(p),oe):p===45&&i===2?(e.consume(p),m):$(p)}function oe(p){return p===null||N(p)?(e.exit(\"htmlFlowData\"),A(p)):(e.consume(p),oe)}function A(p){return e.exit(\"htmlFlow\"),t(p)}}function vc(e,t,n){const r=this;return i;function i(s){return N(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a):n(s)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function xc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(ln,t,n)}}const wc={name:\"htmlText\",tokenize:Sc};function Sc(e,t,n){const r=this;let i,a,s;return o;function o(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),E):m===63?(e.consume(m),S):ve(m)?(e.consume(m),z):n(m)}function l(m){return m===45?(e.consume(m),h):m===91?(e.consume(m),a=0,_):ve(m)?(e.consume(m),x):n(m)}function h(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):N(m)?(s=c,K(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?Z(m):m===45?d(m):c(m)}function _(m){const oe=\"CDATA[\";return m===oe.charCodeAt(a++)?(e.consume(m),a===oe.length?C:_):n(m)}function C(m){return m===null?n(m):m===93?(e.consume(m),I):N(m)?(s=C,K(m)):(e.consume(m),C)}function I(m){return m===93?(e.consume(m),b):C(m)}function b(m){return m===62?Z(m):m===93?(e.consume(m),b):C(m)}function x(m){return m===null||m===62?Z(m):N(m)?(s=x,K(m)):(e.consume(m),x)}function S(m){return m===null?n(m):m===63?(e.consume(m),D):N(m)?(s=S,K(m)):(e.consume(m),S)}function D(m){return m===62?Z(m):S(m)}function E(m){return ve(m)?(e.consume(m),v):n(m)}function v(m){return m===45||ue(m)?(e.consume(m),v):F(m)}function F(m){return N(m)?(s=F,K(m)):L(m)?(e.consume(m),F):Z(m)}function z(m){return m===45||ue(m)?(e.consume(m),z):m===47||m===62||te(m)?M(m):n(m)}function M(m){return m===47?(e.consume(m),Z):m===58||m===95||ve(m)?(e.consume(m),y):N(m)?(s=M,K(m)):L(m)?(e.consume(m),M):Z(m)}function y(m){return m===45||m===46||m===58||m===95||ue(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),$):N(m)?(s=P,K(m)):L(m)?(e.consume(m),P):M(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):N(m)?(s=$,K(m)):L(m)?(e.consume(m),$):(e.consume(m),H)}function V(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):N(m)?(s=V,K(m)):(e.consume(m),V)}function H(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?M(m):(e.consume(m),H)}function R(m){return m===47||m===62||te(m)?M(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function K(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),se}function se(m){return L(m)?B(e,de,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):de(m)}function de(m){return e.enter(\"htmlTextData\"),s(m)}}const or={name:\"labelEnd\",resolveAll:Ac,resolveTo:Ec,tokenize:Pc},kc={tokenize:$c},Cc={tokenize:Tc},Ic={tokenize:Nc};function Ac(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&&ce(e,0,e.length,n),e}function Ec(e,t){let n=e.length,r=0,i,a,s,o;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(s){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(s=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[s][1].end}},h={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[s-2][1].start}};return o=[[\"enter\",u,t],[\"enter\",l,t]],o=ee(o,e.slice(a+1,a+r+3)),o=ee(o,[[\"enter\",h,t]]),o=ee(o,on(t.parser.constructs.insideSpan.null,e.slice(a+r+4,s-3),t)),o=ee(o,[[\"exit\",h,t],e[s-2],e[s-1],[\"exit\",l,t]]),o=ee(o,e.slice(s+1)),o=ee(o,[[\"exit\",u,t]]),ce(e,a,e.length,o),e}function Pc(e,t,n){const r=this;let i=r.events.length,a,s;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return o;function o(d){return a?a._inactive?c(d):(s=r.parser.defined.includes(dt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(kc,h,s?h:c)(d):d===91?e.attempt(Cc,h,s?l:c)(d):s?h(d):c(d)}function l(d){return e.attempt(Ic,h,c)(d)}function h(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function $c(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return te(c)?lt(e,a)(c):a(c)}function a(c){return c===41?h(c):Ca(e,s,o,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function s(c){return te(c)?lt(e,u)(c):h(c)}function o(c){return n(c)}function u(c){return c===34||c===39||c===40?Aa(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):h(c)}function l(c){return te(c)?lt(e,h)(c):h(c)}function h(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Tc(e,t,n){const r=this;return i;function i(o){return Ia.call(r,e,a,s,\"reference\",\"referenceMarker\",\"referenceString\")(o)}function a(o){return r.parser.defined.includes(dt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function s(o){return n(o)}}function Nc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const Dc={name:\"labelStartImage\",resolveAll:or.resolveAll,tokenize:zc};function zc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(o),e.exit(\"labelImageMarker\"),a}function a(o){return o===91?(e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),s):n(o)}function s(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Fc={name:\"labelStartLink\",resolveAll:or.resolveAll,tokenize:Oc};function Oc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const _n={name:\"lineEnding\",tokenize:Rc};function Rc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Dt={name:\"thematicBreak\",tokenize:Lc};function Lc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),s(l)}function s(l){return i=l,o(l)}function o(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||N(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?B(e,o,\"whitespace\")(l):o(l))}}const ae={continuation:{tokenize:Hc},exit:Uc,name:\"list\",tokenize:Vc},Mc={partial:!0,tokenize:jc},Bc={partial:!0,tokenize:qc};function Vc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return o;function o(f){const _=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(_===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:Un(f)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(Dt,n,l)(f):l(f);if(!r.interrupt||f===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(f)}return n(f)}function u(f){return Un(f)&&++s<10?(e.consume(f),u):(!r.interrupt||s<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit(\"listItemValue\"),l(f)):n(f)}function l(f){return e.enter(\"listItemMarker\"),e.consume(f),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||f,e.check(ln,r.interrupt?n:h,e.attempt(Mc,d,c))}function h(f){return r.containerState.initialBlankLine=!0,a++,d(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),d):n(f)}function d(f){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function Hc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ln,i,a);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(o)}function a(o){return r.containerState.furtherBlankLines||!L(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Bc,t,s)(o))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(ae,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o)}}function qc(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"listItemIndent\"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(a):n(a)}}function Uc(e){e.exit(this.containerState.type)}function jc(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const s=r.events[r.events.length-1];return!L(a)&&s&&s[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const fi={name:\"setextUnderline\",resolveTo:Wc,tokenize:Qc};function Wc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const s={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",s,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=s,e.push([\"exit\",s,t]),e}function Qc(e,t,n){const r=this;let i;return a;function a(l){let h=r.events.length,c;for(;h--;)if(r.events[h][1].type!==\"lineEnding\"&&r.events[h][1].type!==\"linePrefix\"&&r.events[h][1].type!==\"content\"){c=r.events[h][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,s(l)):n(l)}function s(l){return e.enter(\"setextHeadingLineSequence\"),o(l)}function o(l){return l===i?(e.consume(l),o):(e.exit(\"setextHeadingLineSequence\"),L(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||N(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const Gc={tokenize:Yc};function Yc(e){const t=this,n=e.attempt(ln,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ec,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const Kc={resolveAll:Pa()},Zc=Ea(\"string\"),Jc=Ea(\"text\");function Ea(e){return{resolveAll:Pa(e===\"text\"?Xc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,s,o);return s;function s(h){return l(h)?a(h):o(h)}function o(h){if(h===null){n.consume(h);return}return n.enter(\"data\"),n.consume(h),u}function u(h){return l(h)?(n.exit(\"data\"),a(h)):(n.consume(h),u)}function l(h){if(h===null)return!0;const c=i[h];let d=-1;if(c)for(;++d<c.length;){const f=c[d];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Pa(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function Xc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,s=-1,o=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(s=l.length;l.charCodeAt(s-1)===32;)o++,s--;if(s)break;s=-1}else if(l===-2)u=!0,o++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const l={type:n===e.length||u||o<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?s:r.start._bufferIndex+s,_index:r.start._index+a,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},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 ef={42:ae,43:ae,45:ae,48:ae,49:ae,50:ae,51:ae,52:ae,53:ae,54:ae,55:ae,56:ae,57:ae,62:xa},tf={91:ac},nf={[-2]:gn,[-1]:gn,32:gn},rf={35:fc,42:Dt,45:[fi,Dt],60:mc,61:fi,95:Dt,96:ui,126:ui},af={38:Sa,92:wa},sf={[-5]:_n,[-4]:_n,[-3]:_n,33:Dc,38:Sa,42:jn,60:[Fu,wc],91:Fc,92:[uc,wa],93:or,95:jn,96:Gu},of={null:[jn,Kc]},lf={null:[42,95]},uf={null:[]},cf=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:lf,contentInitial:tf,disable:uf,document:ef,flow:rf,flowInitial:nf,insideSpan:of,string:af,text:sf},Symbol.toStringTag,{value:\"Module\"}));function ff(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let s=[],o=[];const u={attempt:F(E),check:F(v),consume:x,enter:S,exit:D,interrupt:F(v,{interrupt:!0})},l={code:null,containerState:{},defineSkip:C,events:[],now:_,parser:e,previous:null,sliceSerialize:d,sliceStream:f,write:c};let h=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(P){return s=ee(s,P),I(),s[s.length-1]!==null?[]:(z(t,0),l.events=on(a,l.events,l),l.events)}function d(P,$){return df(f(P),$)}function f(P){return hf(s,P)}function _(){const{_bufferIndex:P,_index:$,line:V,column:H,offset:R}=r;return{_bufferIndex:P,_index:$,line:V,column:H,offset:R}}function C(P){i[P.line]=P.column,y()}function I(){let P;for(;r._index<s.length;){const $=s[r._index];if(typeof $==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(P){h=h(P)}function x(P){N(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function S(P,$){const V=$||{};return V.type=P,V.start=_(),l.events.push([\"enter\",V,l]),o.push(V),V}function D(P){const $=o.pop();return $.end=_(),l.events.push([\"exit\",$,l]),$}function E(P,$){z(P,$.from)}function v(P,$){$.restore()}function F(P,$){return V;function V(H,R,Z){let K,se,de,m;return Array.isArray(H)?A(H):\"tokenize\"in H?A([H]):oe(H);function oe(U){return nt;function nt(Ee){const Ue=Ee!==null&&U[Ee],je=Ee!==null&&U.null,un=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(je)?je:je?[je]:[]];return A(un)(Ee)}}function A(U){return K=U,se=0,U.length===0?Z:p(U[se])}function p(U){return nt;function nt(Ee){return m=M(),de=U,U.partial||(l.currentConstruct=U),U.name&&l.parser.constructs.disable.null.includes(U.name)?j():U.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,j)(Ee)}}function q(U){return P(de,m),R}function j(U){return m.restore(),++se<K.length?p(K[se]):Z}}}function z(P,$){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&ce(l.events,$,l.events.length-$,P.resolve(l.events.slice($),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function M(){const P=_(),$=l.previous,V=l.currentConstruct,H=l.events.length,R=Array.from(o);return{from:H,restore:Z};function Z(){r=P,l.previous=$,l.currentConstruct=V,l.events.length=H,o=R,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function hf(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let s;if(n===i)s=[e[n].slice(r,a)];else{if(s=e.slice(n,i),r>-1){const o=s[0];typeof o==\"string\"?s[0]=o.slice(r):s.shift()}a>0&&s.push(e[i].slice(0,a))}return s}function df(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let s;if(typeof a==\"string\")s=a;else switch(a){case-5:{s=\"\\r\";break}case-4:{s=`\n`;break}case-3:{s=`\\r\n`;break}case-2:{s=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;s=\" \";break}default:s=String.fromCharCode(a)}i=a===-2,r.push(s)}return r.join(\"\")}function pf(e){const r={constructs:du([cf,...(e||{}).extensions||[]]),content:i(Eu),defined:[],document:i($u),flow:i(Gc),lazy:{},string:i(Zc),text:i(Jc)};return r;function i(a){return s;function s(o){return ff(r,a,o)}}}function mf(e){for(;!ka(e););return e}const hi=/[\\0\\t\\n\\r]/g;function gf(){let e=1,t=\"\",n=!0,r;return i;function i(a,s,o){const u=[];let l,h,c,d,f;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(s||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(hi.lastIndex=c,l=hi.exec(a),d=l&&l.index!==void 0?l.index:a.length,f=a.charCodeAt(d),!l){t=a.slice(c);break}if(f===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),f){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function _f(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Au(n)(mf(pf(n).document().write(gf()(e,t,!0))))}const yn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function yf(){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=yn[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=yn[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,bf)),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\"+yn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function bf(e,t){return t===\"|\"?t:e}class vf{constructor(){this.map=[]}add(t,n,r){xf(this,t,n,r)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function xf(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 wf(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function Sf(){return{flow:{null:{name:\"table\",tokenize:kf,resolveAll:Cf}}}}function kf(e,t,n){const r=this;let i=0,a=0,s;return o;function o(y){let P=r.events.length-1;for(;P>-1;){const H=r.events[P][1].type;if(H===\"lineEnding\"||H===\"linePrefix\")P--;else break}const $=P>-1?r.events[P][1].type:null,V=$===\"tableHead\"||$===\"tableRow\"?v:u;return V===v&&r.parser.lazy[r.now().line]?n(y):V(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(s=!0,a+=1),h(y)}function h(y){return y===null?n(y):N(y)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),f):n(y):L(y)?B(e,h,\"whitespace\")(y):(a+=1,s&&(s=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),s=!0,h):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||te(y)?(e.exit(\"data\"),h(y)):(e.consume(y),y===92?d:c)}function d(y){return y===92||y===124?(e.consume(y),c):c(y)}function f(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),s=!1,L(y)?B(e,_,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):_(y))}function _(y){return y===45||y===58?I(y):y===124?(s=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),C):E(y)}function C(y){return L(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(a+=1,s=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(a+=1,b(y)):y===null||N(y)?D(y):E(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),x(y)):E(y)}function x(y){return y===45?(e.consume(y),x):y===58?(s=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),S):(e.exit(\"tableDelimiterFiller\"),S(y))}function S(y){return L(y)?B(e,D,\"whitespace\")(y):D(y)}function D(y){return y===124?_(y):y===null||N(y)?!s||i!==a?E(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):E(y)}function E(y){return n(y)}function v(y){return e.enter(\"tableRow\"),F(y)}function F(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),F):y===null||N(y)?(e.exit(\"tableRow\"),t(y)):L(y)?B(e,F,\"whitespace\")(y):(e.enter(\"data\"),z(y))}function z(y){return y===null||y===124||te(y)?(e.exit(\"data\"),F(y)):(e.consume(y),y===92?M:z)}function M(y){return y===92||y===124?(e.consume(y),z):z(y)}}function Cf(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,u=0,l,h,c;const d=new vf;for(;++n<e.length;){const f=e[n],_=f[1];f[0]===\"enter\"?_.type===\"tableHead\"?(o=!1,u!==0&&(di(d,t,u,l,h),h=void 0,u=0),l={type:\"table\",start:Object.assign({},_.start),end:Object.assign({},_.end)},d.add(n,0,[[\"enter\",l,t]])):_.type===\"tableRow\"||_.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],s=[0,n+1,0,0],o&&(o=!1,h={type:\"tableBody\",start:Object.assign({},_.start),end:Object.assign({},_.end)},d.add(n,0,[[\"enter\",h,t]])),i=_.type===\"tableDelimiterRow\"?2:h?3:1):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],c=It(d,t,a,i,void 0,c),a=[0,0,0,0]),s[2]=n)):_.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],c=It(d,t,a,i,void 0,c)),a=s,s=[a[1],n,0,0])):_.type===\"tableHead\"?(o=!0,u=n):_.type===\"tableRow\"||_.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(s[0]=s[1],c=It(d,t,a,i,n,c)):s[1]!==0&&(c=It(d,t,s,i,n,c)),i=0):i&&(_.type===\"data\"||_.type===\"tableDelimiterMarker\"||_.type===\"tableDelimiterFiller\")&&(s[3]=n)}for(u!==0&&di(d,t,u,l,h),d.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=wf(t.events,n))}return e}function It(e,t,n,r,i,a){const s=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",o=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Qe(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Qe(t.events,n[1]);if(a={type:s,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=Qe(t.events,n[2]),h=Qe(t.events,n[3]),c={type:o,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],f=t.events[n[3]];if(d[1].end=Object.assign({},f[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const _=n[2]+1,C=n[3]-n[2]-1;e.add(_,C,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},Qe(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function di(e,t,n,r,i){const a=[],s=Qe(t.events,n);i&&(i.end=Object.assign({},s),a.push([\"exit\",i,t])),r.end=Object.assign({},s),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function Qe(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function If(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Af(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,o){let u=-1;for(;++u<s.length;)if(s[u][0]===\"enter\"&&s[u][1].type===\"strikethroughSequenceTemporary\"&&s[u][1]._close){let l=u;for(;l--;)if(s[l][0]===\"exit\"&&s[l][1].type===\"strikethroughSequenceTemporary\"&&s[l][1]._open&&s[u][1].end.offset-s[u][1].start.offset===s[l][1].end.offset-s[l][1].start.offset){s[u][1].type=\"strikethroughSequence\",s[l][1].type=\"strikethroughSequence\";const h={type:\"strikethrough\",start:Object.assign({},s[l][1].start),end:Object.assign({},s[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},s[l][1].end),end:Object.assign({},s[u][1].start)},d=[[\"enter\",h,o],[\"enter\",s[l][1],o],[\"exit\",s[l][1],o],[\"enter\",c,o]],f=o.parser.constructs.insideSpan.null;f&&ce(d,d.length,0,on(f,s.slice(l+1,u),o)),ce(d,d.length,0,[[\"exit\",c,o],[\"enter\",s[u][1],o],[\"exit\",s[u][1],o],[\"exit\",h,o]]),ce(s,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<s.length;)s[u][1].type===\"strikethroughSequenceTemporary\"&&(s[u][1].type=\"data\");return s}function a(s,o,u){const l=this.previous,h=this.events;let c=0;return d;function d(_){return l===126&&h[h.length-1][1].type!==\"characterEscape\"?u(_):(s.enter(\"strikethroughSequenceTemporary\"),f(_))}function f(_){const C=Qt(l);if(_===126)return c>1?u(_):(s.consume(_),c++,f);if(c<2&&!n)return u(_);const I=s.exit(\"strikethroughSequenceTemporary\"),b=Qt(_);return I._open=!b||b===2&&!!C,I._close=!C||C===2&&!!b,o(_)}}}function Ef(e){return _f(e,{allowDangerousHtml:!0,extensions:[Sf(),Af()],htmlExtensions:[yf(),If()]})}const Xe=Zn({}),bn=[];function Pf(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>$a(i,a,t));return g(Y,{children:r})}function $a(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const s={key:t};for(const u of Array.from(r.attributes))s[u.name]=u.value;const o=Array.from(r.childNodes).map((u,l)=>$a(u,l,n));return ge(i,s,...o)}return null}function $f(e,t){switch(e.name){case\"set\":return g(sl,{rawArgs:e.rawArgs},t);case\"computed\":return g(iu,{rawArgs:e.rawArgs},t);case\"print\":return g(ol,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return g(lu,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"passage\":return g(cu,{className:e.className,id:e.id},t);case\"if\":return g(ll,{branches:e.branches??bn},t);case\"for\":return g(cl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return g(hl,{children:e.children},t);case\"button\":return g(dl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return g(pl,{className:e.className,id:e.id},t);case\"back\":return g(gl,{className:e.className,id:e.id},t);case\"forward\":return g(_l,{className:e.className,id:e.id},t);case\"restart\":return g(ml,{className:e.className,id:e.id},t);case\"quicksave\":return g(yl,{className:e.className,id:e.id},t);case\"quickload\":return g(bl,{className:e.className,id:e.id},t);case\"settings\":return g(Sl,{className:e.className,id:e.id},t);case\"saves\":return g(El,{className:e.className,id:e.id},t);case\"include\":return g(Pl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return g($l,{rawArgs:e.rawArgs},t);case\"unset\":return g(Tl,{rawArgs:e.rawArgs},t);case\"textbox\":return g(Dl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return g(Fl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return g(Rl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return g(Ml,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return g(Vl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return g(Hl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return g(ql,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return g(jl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return g(Wl,{rawArgs:e.rawArgs,branches:e.branches??bn},t);case\"timed\":return g(Ql,{rawArgs:e.rawArgs,children:e.children,branches:e.branches??bn,className:e.className,id:e.id},t);case\"repeat\":return g(Gl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return g(Yl,{},t);case\"type\":return g(Kl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return g(Xl,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=Zl(e.name);if(n)return g(tu,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=hu(e.name);return r?g(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:fe(e.children)},t):g(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function Wn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return g(il,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return g(al,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return $f(e,t);case\"html\":return ge(e.tag,{key:t,...e.attributes},e.children.length>0?fe(e.children):void 0);default:return e}}function Ta(e){return e.length===0?null:e.map((t,n)=>Wn(t,n))}function fe(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,s)=>Wn(a,s));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const s=e[a];if(s.type===\"text\")r+=s.value;else{const o=n.length;n.push(Wn(s,a)),r+=`<span data-tw=\"${o}\"></span>`}}const i=Ef(r);return Pf(i,n)}const Tf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Nf(){const t=w(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Tf;try{const r=_t(n),i=yt(r);return g(Y,{children:fe(i)})}catch(r){return g(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function Df(){const e=w(n=>n.storyData),t=w(n=>n.currentPassage);return Se(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),w.getState().save()):r.key===\"F9\"&&(r.preventDefault(),w.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?g(\"div\",{class:\"loading\",children:\"Loading...\"}):g(Nf,{})}function zf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",o=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",h=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(d.getAttribute(\"pid\")||\"0\",10),_=d.getAttribute(\"name\")||\"\",C=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(D=>D.length>0),I=d.textContent||\"\",b={},x=new Set([\"pid\",\"name\",\"tags\"]);for(const D of d.attributes)x.has(D.name)||(b[D.name]=D.value);const S={pid:f,name:_,tags:C,metadata:b,content:I};h.set(_,S),c.set(f,S)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:h,passagesById:c,userCSS:o,userScript:l}}function Ff(){return{get(e){return w.getState().variables[e]},set(e,t){const n=w.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){w.getState().navigate(e)},back(){w.getState().goBack()},forward(){w.getState().goForward()},restart(){w.getState().restart()},save(e){w.getState().save(e)},load(e){w.getState().load(e)},hasSave(e){return w.getState().hasSave(e)},visited(e){return w.getState().visitCounts[e]??0},hasVisited(e){return(w.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=w.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=w.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return w.getState().renderCounts[e]??0},hasRendered(e){return(w.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=w.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=w.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=w.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=w.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 w.getState().storyData?.name||\"\"},get passage(){return w.getState().currentPassage},settings:ht,registerClass(e,t){Ro(e,t)},saves:{setTitleGenerator(e){Mo(e)}},getActions(){return Xr()},performAction(e,t){const n=tl(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=w.getState().currentPassage;return w.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return rl(t);if(e===\"variableChanged\"){let n={...w.getState().variables};return w.subscribe(r=>{const i={};let a=!1;const s=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const o of s)r.variables[o]!==n[o]&&(i[o]={from:n[o],to:r.variables[o]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Xr())})})})},random(){return ir()},randomInt(e,t){return na(e,t)},prng:{init(e,t){ko(e,t);const{historyIndex:n}=w.getState();w.setState(r=>{const i=r.history[n];i&&(i.prng=Nt())})},isEnabled(){return Co()},get seed(){return Io()},get pull(){return Ao()}}}}function Of(){window.Story=Ff()}const Rf=/^\\$(\\w+)\\s*=\\s*(.+)$/,pi=/\\$(\\w+(?:\\.\\w+)*)/g,mi=/\\{for\\s+(\\$\\w+)(?:\\s*,\\s*(\\$\\w+))?\\s+of\\b/g,Lf=new Set([\"number\",\"string\",\"boolean\"]);function Na(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,Na(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Lf.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Mf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Rf);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,s]=i;let o;try{o=new Function(\"return (\"+s+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${s}\": ${l instanceof Error?l.message:l}`)}const u=Na(o);t.set(a,{...u,name:a,default:o})}return t}function Bf(e){const t=new Set;let n;for(mi.lastIndex=0;(n=mi.exec(e))!==null;)t.add(n[1].slice(1)),n[2]&&t.add(n[2].slice(1));return t}function Vf(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let s=a;for(let o=1;o<r.length;o++){const u=r[o];if(s.type===\"array\")return null;if(s.type!==\"object\"||!s.fields)return`Cannot access field \"${u}\" on $${r.slice(0,o).join(\".\")} (type: ${s.type})`;const l=s.fields.get(u);if(!l)return null;s=l}return null}function Hf(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=Bf(i.content);let s;for(pi.lastIndex=0;(s=pi.exec(i.content))!==null;){const o=s[1],u=Vf(o,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function qf(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function gi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const s=document.createElement(\"li\");s.textContent=a,i.appendChild(s)}n.appendChild(i),e.appendChild(n)}function _i(){const e=zf();if(Of(),e.userCSS){const u=document.createElement(\"style\");u.textContent=e.userCSS,document.head.appendChild(u)}if(e.userScript)try{new Function(e.userScript)()}catch(u){console.error(\"spindle: Error in story JavaScript:\",u)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const u=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",l=document.getElementById(\"root\");throw l&&gi(l,[u]),new Error(`spindle: ${u}`)}const r=Mf(n.content),i=Hf(e.passages,r);if(i.length>0){const u=document.getElementById(\"root\");throw u&&gi(u,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=qf(r),w.getState().init(e,t),ha();for(const[,u]of e.passages)if(u.tags.includes(\"widget\")){const l=_t(u.content),h=yt(l);for(const c of h)if(c.type===\"macro\"&&c.name===\"widget\"&&c.rawArgs){const d=c.rawArgs.trim().split(/\\s+/),f=d[0].replace(/[\"']/g,\"\"),_=d.slice(1).filter(C=>C.startsWith(\"$\")||C.startsWith(\"_\"));ya(f,c.children,_)}}let a=\"\";w.subscribe(u=>{u.currentPassage!==a&&(a=u.currentPassage,nl())});const s=e.passages.get(\"StoryInterface\");s&&!s.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const o=document.getElementById(\"root\");if(!o)throw new Error('spindle: No <div id=\"root\"> element found.');Ye(g(Df,{}),o),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",_i):_i();</script>\n <style rel=\"stylesheet\" crossorigin>*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
1
+ window.storyFormat({"name":"spindle","version":"0.2.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const s of a.addedNodes)s.tagName===\"LINK\"&&s.rel===\"modulepreload\"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var mt,O,yi,Me,gr,bi,vi,xi,Qn,vn,xn,wi,zt={},Ot=[],ss=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,gt=Array.isArray;function Se(e,t){for(var n in t)e[n]=t[n];return e}function Gn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function _e(e,t,n){var r,i,a,s={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a];if(arguments.length>2&&(s.children=arguments.length>3?mt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)s[a]===void 0&&(s[a]=e.defaultProps[a]);return lt(e,s,r,i,null)}function lt(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++yi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function os(){return{current:null}}function K(e){return e.children}function ke(e,t){this.props=e,this.context=t}function Ke(e,t){if(t==null)return e.__?Ke(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\"?Ke(e):null}function ls(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Se({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),Kn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Ke(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Ii(r,a,i),t.__e=t.__=null,a.__e!=n&&Si(a)}}function Si(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}),Si(e)}function wn(e){(!e.__d&&(e.__d=!0)&&Me.push(e)&&!Rt.__r++||gr!=O.debounceRendering)&&((gr=O.debounceRendering)||bi)(Rt)}function Rt(){for(var e,t=1;Me.length;)Me.length>t&&Me.sort(vi),e=Me.shift(),t=Me.length,ls(e);Rt.__r=0}function ki(e,t,n,r,i,a,s,o,u,l,f){var c,d,h,g,k,I,b,x=r&&r.__k||Ot,S=t.length;for(u=us(n,t,x,u,S),c=0;c<S;c++)(h=n.__k[c])!=null&&(d=h.__i!=-1&&x[h.__i]||zt,h.__i=c,I=Kn(e,h,d,i,a,s,o,u,l,f),g=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&Yn(d.ref,null,h),f.push(h.ref,h.__c||g,h)),k==null&&g!=null&&(k=g),(b=!!(4&h.__u))||d.__k===h.__k?u=Ci(h,u,e,b):typeof h.type==\"function\"&&I!==void 0?u=I:g&&(u=g.nextSibling),h.__u&=-7);return n.__e=k,u}function us(e,t,n,r,i){var a,s,o,u,l,f=n.length,c=f,d=0;for(e.__k=new Array(i),a=0;a<i;a++)(s=t[a])!=null&&typeof s!=\"boolean\"&&typeof s!=\"function\"?(typeof s==\"string\"||typeof s==\"number\"||typeof s==\"bigint\"||s.constructor==String?s=e.__k[a]=lt(null,s,null,null,null):gt(s)?s=e.__k[a]=lt(K,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[a]=lt(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[a]=s,u=a+d,s.__=e,s.__b=e.__b+1,o=null,(l=s.__i=cs(s,n,u,c))!=-1&&(c--,(o=n[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(i>f?d--:i<f&&d++),typeof s.type!=\"function\"&&(s.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,s.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<f;a++)(o=n[a])!=null&&(2&o.__u)==0&&(o.__e==r&&(r=Ke(o)),Ei(o,o));return r}function Ci(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=Ci(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Ke(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Pe(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(gt(e)?e.some(function(n){Pe(n,t)}):t.push(e)),t}function cs(e,t,n,r){var i,a,s,o=e.key,u=e.type,l=t[n],f=l!=null&&(2&l.__u)==0;if(l===null&&o==null||f&&o==l.key&&u==l.type)return n;if(r>(f?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[s=i>=0?i--:a++])!=null&&(2&l.__u)==0&&o==l.key&&u==l.type)return s}return-1}function _r(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||ss.test(t)?n:n+\"px\"}function xt(e,t,n,r,i){var a,s;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||_r(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||_r(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(xi,\"$1\")),s=t.toLowerCase(),t=s in e||t==\"onFocusOut\"||t==\"onFocusIn\"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=Qn,e.addEventListener(t,a?xn:vn,a)):e.removeEventListener(t,a?xn:vn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function yr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Qn++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function Kn(e,t,n,r,i,a,s,o,u,l){var f,c,d,h,g,k,I,b,x,S,D,E,v,z,F,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[o=t.__e=n.__e]),(f=O.__b)&&f(t);e:if(typeof M==\"function\")try{if(b=t.props,x=\"prototype\"in M&&M.prototype.render,S=(f=M.contextType)&&r[f.__c],D=f?S?S.props.value:f.__:r,n.__c?I=(c=t.__c=n.__c).__=c.__E:(x?t.__c=c=new M(b,D):(t.__c=c=new ke(b,D),c.constructor=M,c.render=hs),S&&S.sub(c),c.state||(c.state={}),c.__n=r,d=c.__d=!0,c.__h=[],c._sb=[]),x&&c.__s==null&&(c.__s=c.state),x&&M.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Se({},c.__s)),Se(c.__s,M.getDerivedStateFromProps(b,c.__s))),h=c.props,g=c.state,c.__v=t,d)x&&M.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),x&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(x&&M.getDerivedStateFromProps==null&&b!==h&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,D),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,D)===!1){t.__v!=n.__v&&(c.props=b,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(y){y&&(y.__=t)}),Ot.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,D),x&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(h,g,k)})}if(c.context=D,c.props=b,c.__P=e,c.__e=!1,E=O.__r,v=0,x)c.state=c.__s,c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),Ot.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,E&&E(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++v<25);c.state=c.__s,c.getChildContext!=null&&(r=Se(Se({},r),c.getChildContext())),x&&!d&&c.getSnapshotBeforeUpdate!=null&&(k=c.getSnapshotBeforeUpdate(h,g)),z=f!=null&&f.type===K&&f.key==null?Ai(f.props.children):f,o=ki(e,gt(z)?z:[z],t,n,r,i,a,s,o,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__E=c.__=null)}catch(y){if(t.__v=null,u||a!=null)if(y.then){for(t.__u|=u?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(F=a.length;F--;)Gn(a[F]);Sn(t)}else t.__e=n.__e,t.__k=n.__k,y.then||Sn(t);O.__e(y,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):o=t.__e=fs(n.__e,t,n,r,i,a,s,u,l);return(f=O.diffed)&&f(t),128&t.__u?void 0:o}function Sn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Sn))}function Ii(e,t,n){for(var r=0;r<n.length;r++)Yn(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function Ai(e){return typeof e!=\"object\"||e==null||e.__b>0?e:gt(e)?e.map(Ai):Se({},e)}function fs(e,t,n,r,i,a,s,o,u){var l,f,c,d,h,g,k,I=n.props||zt,b=t.props,x=t.type;if(x==\"svg\"?i=\"http://www.w3.org/2000/svg\":x==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((h=a[l])&&\"setAttribute\"in h==!!x&&(x?h.localName==x:h.nodeType==3)){e=h,a[l]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(i,x,b.is&&b),o&&(O.__m&&O.__m(t,a),o=!1),a=null}if(x==null)I===b||o&&e.data==b||(e.data=b);else{if(a=a&&mt.call(e.childNodes),!o&&a!=null)for(I={},l=0;l<e.attributes.length;l++)I[(h=e.attributes[l]).name]=h.value;for(l in I)h=I[l],l==\"dangerouslySetInnerHTML\"?c=h:l==\"children\"||l in b||l==\"value\"&&\"defaultValue\"in b||l==\"checked\"&&\"defaultChecked\"in b||xt(e,l,null,h,i);for(l in b)h=b[l],l==\"children\"?d=h:l==\"dangerouslySetInnerHTML\"?f=h:l==\"value\"?g=h:l==\"checked\"?k=h:o&&typeof h!=\"function\"||I[l]===h||xt(e,l,h,I[l],i);if(f)o||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ki(t.type==\"template\"?e.content:e,gt(d)?d:[d],t,n,r,x==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,s,a?a[0]:n.__k&&Ke(n,0),o,u),a!=null)for(l=a.length;l--;)Gn(a[l]);o||(l=\"value\",x==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[l]||x==\"progress\"&&!g||x==\"option\"&&g!=I[l])&&xt(e,l,g,I[l],i),l=\"checked\",k!=null&&k!=e[l]&&xt(e,l,k,I[l],i))}return e}function Yn(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 Ei(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Yn(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ei(r[i],t,n||typeof e.type!=\"function\");n||Gn(e.__e),e.__c=e.__=e.__e=void 0}function hs(e,t,n){return this.constructor(e,n)}function Ye(e,t,n){var r,i,a,s;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],s=[],Kn(t,e=(!r&&n||t).__k=_e(K,null,[e]),i||zt,zt,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?mt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,s),Ii(a,e,s)}function Pi(e,t){Ye(e,t,Pi)}function ds(e,t,n){var r,i,a,s,o=Se({},e.props);for(a in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a]===void 0&&s!=null?s[a]:t[a];return arguments.length>2&&(o.children=arguments.length>3?mt.call(arguments,2):n),lt(e.type,o,r||e.key,i||e.ref,null)}function Zn(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(s){s.__e=!0,wn(s)})},this.sub=function(a){r.add(a);var s=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),s&&s.call(a)}}),n.children}return t.__c=\"__cC\"+wi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}mt=Ot.slice,O={__e:function(e,t,n,r){for(var i,a,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=i.__d),s)return i.__E=i}catch(o){e=o}throw e}},yi=0,ke.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Se({},this.state),typeof e==\"function\"&&(e=e(Se({},n),this.props)),e&&Se(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),wn(this))},ke.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),wn(this))},ke.prototype.render=K,Me=[],bi=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,vi=function(e,t){return e.__v.__b-t.__v.__b},Rt.__r=0,xi=/(PointerCapture)$|Capture$/i,Qn=0,vn=yr(!1),xn=yr(!0),wi=0;var ps=0;function _(e,t,n,r,i,a){t||(t={});var s,o,u=t;if(\"ref\"in u)for(o in u={},t)o==\"ref\"?s=t[o]:u[o]=t[o];var l={type:e,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ps,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(s=e.defaultProps))for(o in s)u[o]===void 0&&(u[o]=s[o]);return O.vnode&&O.vnode(l),l}var Ne,W,cn,br,Ze=0,$i=[],G=O,vr=G.__b,xr=G.__r,wr=G.diffed,Sr=G.__c,kr=G.unmount,Cr=G.__;function et(e,t){G.__h&&G.__h(W,e,Ze||t),Ze=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return Ze=1,Jn(Fi,e)}function Jn(e,t,n){var r=et(Ne++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Fi(void 0,t),function(o){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,o);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(o,u,l){if(!r.__c.__H)return!0;var f=r.__c.__H.__.filter(function(d){return d.__c});if(f.every(function(d){return!d.__N}))return!a||a.call(this,o,u,l);var c=r.__c.props!==o;return f.some(function(d){if(d.__N){var h=d.__[0];d.__=d.__N,d.__N=void 0,h!==d.__[0]&&(c=!0)}}),a&&a.call(this,o,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,s=W.componentWillUpdate;W.componentWillUpdate=function(o,u,l){if(this.__e){var f=a;a=void 0,i(o,u,l),a=f}s&&s.call(this,o,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Ce(e,t){var n=et(Ne++,3);!G.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function he(e,t){var n=et(Ne++,4);!G.__s&&Xn(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function Be(e){return Ze=5,qe(function(){return{current:e}},[])}function Ti(e,t,n){Ze=6,he(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 qe(e,t){var n=et(Ne++,7);return Xn(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function tt(e,t){return Ze=8,qe(function(){return e},t)}function be(e){var t=W.context[e.__c],n=et(Ne++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function Ni(e,t){G.useDebugValue&&G.useDebugValue(t?t(e):e)}function Di(){var e=et(Ne++,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 ms(){for(var e;e=$i.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Et),t.__h.some(kn),t.__h=[]}catch(n){t.__h=[],G.__e(n,e.__v)}}}G.__b=function(e){W=null,vr&&vr(e)},G.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Cr&&Cr(e,t)},G.__r=function(e){xr&&xr(e),Ne=0;var t=(W=e.__c).__H;t&&(cn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Et),t.__h.some(kn),t.__h=[],Ne=0)),cn=W},G.diffed=function(e){wr&&wr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&($i.push(t)!==1&&br===G.requestAnimationFrame||((br=G.requestAnimationFrame)||gs)(ms)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),cn=W=null},G.__c=function(e,t){t.some(function(n){try{n.__h.some(Et),n.__h=n.__h.filter(function(r){return!r.__||kn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],G.__e(r,n.__v)}}),Sr&&Sr(e,t)},G.unmount=function(e){kr&&kr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Et(r)}catch(i){t=i}}),n.__H=void 0,t&&G.__e(t,n.__v))};var Ir=typeof requestAnimationFrame==\"function\";function gs(e){var t,n=function(){clearTimeout(r),Ir&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ir&&(t=requestAnimationFrame(n))}function Et(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 Xn(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Fi(e,t){return typeof t==\"function\"?t(e):t}const Ar=e=>{let t;const n=new Set,r=(l,f)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const d=t;t=f??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(h=>h(t,d))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,o);return o},_s=(e=>e?Ar(e):Ar);function zi(e,t){for(var n in t)e[n]=t[n];return e}function Cn(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 Oi(e,t){var n=t(),r=Y({t:{__:n,u:t}}),i=r[0].t,a=r[1];return he(function(){i.__=n,i.u=t,fn(i)&&a({t:i})},[e,n,t]),Ce(function(){return fn(i)&&a({t:i}),e(function(){fn(i)&&a({t:i})})},[e]),n}function fn(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 Ri(e){e()}function Li(e){return e}function Mi(){return[!1,Ri]}var Bi=he;function In(e,t){this.props=e,this.context=t}function ys(e,t){function n(i){var a=this.props.ref,s=a==i.ref;return!s&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!s:Cn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,_e(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(In.prototype=new ke).isPureReactComponent=!0,In.prototype.shouldComponentUpdate=function(e,t){return Cn(this.props,e)||Cn(this.state,t)};var Er=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Er&&Er(e)};var bs=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function vs(e){function t(n){var r=zi({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=bs,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var Pr=function(e,t){return e==null?null:Pe(Pe(e).map(t))},xs={map:Pr,forEach:Pr,count:function(e){return e?Pe(e).length:0},only:function(e){var t=Pe(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Pe},ws=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}ws(e,t,n,r)};var $r=O.unmount;function Vi(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=zi({},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 Vi(r,t,n)})),e}function Hi(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Hi(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 Pt(){this.__u=0,this.o=null,this.__b=null}function ji(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Ss(e){var t,n,r,i=null;function a(s){if(t||(t=e()).then(function(o){o&&(i=o.default||o),r=!0},function(o){n=o,r=!0}),n)throw n;if(!r)throw t;return i?_e(i,s):null}return a.displayName=\"Lazy\",a.__f=!0,a}function ot(){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),$r&&$r(e)},(Pt.prototype=new ke).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ji(r.__v),a=!1,s=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=s;var o=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Hi(l,l.__c.__P,l.__c.__O)}var f;for(r.setState({__a:r.__b=null});f=r.o.pop();)f.__P=o,f.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(s,s)},Pt.prototype.componentWillUnmount=function(){this.o=[]},Pt.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]=Vi(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&_e(K,null,e.fallback);return i&&(i.__u&=-33),[_e(K,null,t.__a?null:e.children),i]};var Tr=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 ks(e){return this.getChildContext=function(){return e.context},e.children}function Cs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Ye(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,a){this.childNodes.push(i),t.h.insertBefore(i,a)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}Ye(_e(ks,{context:t.context},e.__v),t.v)}function Is(e,t){var n=_e(Cs,{__v:e,h:t});return n.containerInfo=t,n}(ot.prototype=new ke).__a=function(e){var t=this,n=ji(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Tr(t,e,r)):i()};n?n(a):a()}},ot.prototype.render=function(e){this.i=null,this.l=new Map;var t=Pe(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},ot.prototype.componentDidUpdate=ot.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Tr(e,n,t)})};var qi=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,As=/^(?: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]/,Es=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ps=/[A-Z0-9]/g,$s=typeof document<\"u\",Ts=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function Ns(e,t,n){return t.__k==null&&(t.textContent=\"\"),Ye(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function Ds(e,t,n){return Pi(e,t),typeof n==\"function\"&&n(),e?e.__c:null}ke.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(ke.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Nr=O.event;function Fs(){}function zs(){return this.cancelBubble}function Os(){return this.defaultPrevented}O.event=function(e){return Nr&&(e=Nr(e)),e.persist=Fs,e.isPropagationStopped=zs,e.isDefaultPrevented=Os,e.nativeEvent=e};var er,Rs={enumerable:!1,configurable:!0,get:function(){return this.class}},Dr=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var s in n){var o=n[s];if(!(s===\"value\"&&\"defaultValue\"in n&&o==null||$s&&s===\"children\"&&r===\"noscript\"||s===\"class\"||s===\"className\")){var u=s.toLowerCase();s===\"defaultValue\"&&\"value\"in n&&n.value==null?s=\"value\":s===\"download\"&&o===!0?o=\"\":u===\"translate\"&&o===\"no\"?o=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?s=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||Ts(n.type)?u===\"onfocus\"?s=\"onfocusin\":u===\"onblur\"?s=\"onfocusout\":Es.test(s)&&(s=u):u=s=\"oninput\":a&&As.test(s)?s=s.replace(Ps,\"-$&\").toLowerCase():o===null&&(o=void 0),u===\"oninput\"&&i[s=u]&&(s=\"oninputCapture\"),i[s]=o}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Pe(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Pe(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\",Rs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=qi,Dr&&Dr(e)};var Fr=O.__r;O.__r=function(e){Fr&&Fr(e),er=e.__c};var zr=O.diffed;O.diffed=function(e){zr&&zr(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),er=null};var Ls={ReactCurrentDispatcher:{current:{readContext:function(e){return er.__n[e.__c].props.value},useCallback:tt,useContext:be,useDebugValue:Ni,useDeferredValue:Li,useEffect:Ce,useId:Di,useImperativeHandle:Ti,useInsertionEffect:Bi,useLayoutEffect:he,useMemo:qe,useReducer:Jn,useRef:Be,useState:Y,useSyncExternalStore:Oi,useTransition:Mi}}};function Ms(e){return _e.bind(null,e)}function Kt(e){return!!e&&e.$$typeof===qi}function Bs(e){return Kt(e)&&e.type===K}function Vs(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Hs(e){return Kt(e)?ds.apply(null,arguments):e}function js(e){return!!e.__k&&(Ye(null,e),!0)}function qs(e){return e&&(e.base||e.nodeType===1&&e)||null}var Us=function(e,t){return e(t)},Ws=function(e,t){return e(t)},Qs=K,Gs=Kt,wt={useState:Y,useId:Di,useReducer:Jn,useEffect:Ce,useLayoutEffect:he,useInsertionEffect:Bi,useTransition:Mi,useDeferredValue:Li,useSyncExternalStore:Oi,startTransition:Ri,useRef:Be,useImperativeHandle:Ti,useMemo:qe,useCallback:tt,useContext:be,useDebugValue:Ni,version:\"18.3.1\",Children:xs,render:Ns,hydrate:Ds,unmountComponentAtNode:js,createPortal:Is,createElement:_e,createContext:Zn,createFactory:Ms,cloneElement:Hs,createRef:os,Fragment:K,isValidElement:Kt,isElement:Gs,isFragment:Bs,isMemo:Vs,findDOMNode:qs,Component:ke,PureComponent:In,memo:ys,forwardRef:vs,flushSync:Ws,unstable_batchedUpdates:Us,StrictMode:Qs,Suspense:Pt,SuspenseList:ot,lazy:Ss,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ls};const Ks=e=>e;function Ys(e,t=Ks){const n=wt.useSyncExternalStore(e.subscribe,wt.useCallback(()=>t(e.getState()),[e,t]),wt.useCallback(()=>t(e.getInitialState()),[e,t]));return wt.useDebugValue(n),n}const Zs=e=>{const t=_s(e),n=r=>Ys(t,r);return Object.assign(n,t),n},Js=(e=>Zs);var Ui=Symbol.for(\"immer-nothing\"),Or=Symbol.for(\"immer-draftable\"),re=Symbol.for(\"immer-state\");function ge(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var le=Object,Je=le.getPrototypeOf,Lt=\"constructor\",Yt=\"prototype\",An=\"configurable\",Mt=\"enumerable\",$t=\"writable\",ct=\"value\",De=e=>!!e&&!!e[re];function $e(e){return e?Wi(e)||Jt(e)||!!e[Or]||!!e[Lt]?.[Or]||Xt(e)||en(e):!1}var Xs=le[Yt][Lt].toString(),Rr=new WeakMap;function Wi(e){if(!e||!tr(e))return!1;const t=Je(e);if(t===null||t===le[Yt])return!0;const n=le.hasOwnProperty.call(t,Lt)&&t[Lt];if(n===Object)return!0;if(!Qe(n))return!1;let r=Rr.get(n);return r===void 0&&(r=Function.toString.call(n),Rr.set(n,r)),r===Xs}function Zt(e,t,n=!0){_t(e)===0?(n?Reflect.ownKeys(e):le.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function _t(e){const t=e[re];return t?t.type_:Jt(e)?1:Xt(e)?2:en(e)?3:0}var Lr=(e,t,n=_t(e))=>n===2?e.has(t):le[Yt].hasOwnProperty.call(e,t),En=(e,t,n=_t(e))=>n===2?e.get(t):e[t],Bt=(e,t,n,r=_t(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function eo(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Jt=Array.isArray,Xt=e=>e instanceof Map,en=e=>e instanceof Set,tr=e=>typeof e==\"object\",Qe=e=>typeof e==\"function\",hn=e=>typeof e==\"boolean\";function to(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Ee=e=>e.copy_||e.base_,nr=e=>e.modified_?e.copy_:e.base_;function Pn(e,t){if(Xt(e))return new Map(e);if(en(e))return new Set(e);if(Jt(e))return Array[Yt].slice.call(e);const n=Wi(e);if(t===!0||t===\"class_only\"&&!n){const r=le.getOwnPropertyDescriptors(e);delete r[re];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[$t]===!1&&(o[$t]=!0,o[An]=!0),(o.get||o.set)&&(r[s]={[An]:!0,[$t]:!0,[Mt]:o[Mt],[ct]:e[s]})}return le.create(Je(e),r)}else{const r=Je(e);if(r!==null&&n)return{...e};const i=le.create(r);return le.assign(i,e)}}function rr(e,t=!1){return tn(e)||De(e)||!$e(e)||(_t(e)>1&&le.defineProperties(e,{set:St,add:St,clear:St,delete:St}),le.freeze(e),t&&Zt(e,(n,r)=>{rr(r,!0)},!1)),e}function no(){ge(2)}var St={[ct]:no};function tn(e){return e===null||!tr(e)?!0:le.isFrozen(e)}var Vt=\"MapSet\",$n=\"Patches\",Mr=\"ArrayMethods\",Qi={};function Ve(e){const t=Qi[e];return t||ge(0,e),t}var Br=e=>!!Qi[e],ft,Gi=()=>ft,ro=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Br(Vt)?Ve(Vt):void 0,arrayMethodsPlugin_:Br(Mr)?Ve(Mr):void 0});function Vr(e,t){t&&(e.patchPlugin_=Ve($n),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Tn(e){Nn(e),e.drafts_.forEach(io),e.drafts_=null}function Nn(e){e===ft&&(ft=e.parent_)}var Hr=e=>ft=ro(ft,e);function io(e){const t=e[re];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function jr(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[re].modified_&&(Tn(t),ge(4)),$e(e)&&(e=qr(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[re].base_,e,t)}else e=qr(t,n);return ao(t,e,!0),Tn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ui?e:void 0}function qr(e,t){if(tn(t))return t;const n=t[re];if(!n)return Ht(t,e.handledSet_,e);if(!nn(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);Zi(n,e)}return n.copy_}function ao(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&rr(t,n)}function Ki(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var nn=(e,t)=>e.scope_===t,so=[];function Yi(e,t,n,r){const i=Ee(e),a=e.type_;if(r!==void 0&&En(i,r,a)===t){Bt(i,r,n,a);return}if(!e.draftLocations_){const o=e.draftLocations_=new Map;Zt(i,(u,l)=>{if(De(l)){const f=o.get(l)||[];f.push(u),o.set(l,f)}})}const s=e.draftLocations_.get(t)??so;for(const o of s)Bt(i,o,n,a)}function oo(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!nn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=nr(a);Yi(e,a.draft_??a,s,n),Zi(a,i)})}function Zi(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)}Ki(e)}}function lo(e,t,n){const{scope_:r}=e;if(De(n)){const i=n[re];nn(i,r)&&i.callbacks_.push(function(){Tt(e);const s=nr(i);Yi(e,n,s,t)})}else $e(n)&&e.callbacks_.push(function(){const a=Ee(e);e.type_===3?a.has(n)&&Ht(n,r.handledSet_,r):En(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Ht(En(e.copy_,t,e.type_),r.handledSet_,r)})}function Ht(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||De(e)||t.has(e)||!$e(e)||tn(e)||(t.add(e),Zt(e,(r,i)=>{if(De(i)){const a=i[re];if(nn(a,n)){const s=nr(a);Bt(e,r,s,e.type_),Ki(a)}}else $e(i)&&Ht(i,t,n)})),e}function uo(e,t){const n=Jt(e),r={type_:n?1:0,scope_:t?t.scope_:Gi(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=jt;n&&(i=[r],a=ht);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var jt={get(e,t){if(t===re)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=Ee(e);if(!Lr(i,t,e.type_))return co(e,i,t);const a=i[t];if(e.finalized_||!$e(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&to(t))return a;if(a===dn(e.base_,t)){Tt(e);const s=e.type_===1?+t:t,o=Fn(e.scope_,a,e,s);return e.copy_[s]=o}return a},has(e,t){return t in Ee(e)},ownKeys(e){return Reflect.ownKeys(Ee(e))},set(e,t,n){const r=Ji(Ee(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=dn(Ee(e),t),a=i?.[re];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(eo(n,i)&&(n!==void 0||Lr(e.base_,t,e.type_)))return!0;Tt(e),Dn(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),lo(e,t,n)),!0},deleteProperty(e,t){return Tt(e),dn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Dn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Ee(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[$t]:!0,[An]:e.type_!==1||t!==\"length\",[Mt]:r[Mt],[ct]:n[t]}},defineProperty(){ge(11)},getPrototypeOf(e){return Je(e.base_)},setPrototypeOf(){ge(12)}},ht={};for(let e in jt){let t=jt[e];ht[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}ht.deleteProperty=function(e,t){return ht.set.call(this,e,t,void 0)};ht.set=function(e,t,n){return jt.set.call(this,e[0],t,n,e[0])};function dn(e,t){const n=e[re];return(n?Ee(n):e)[t]}function co(e,t,n){const r=Ji(t,n);return r?ct in r?r[ct]:r.get?.call(e.draft_):void 0}function Ji(e,t){if(!(t in e))return;let n=Je(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Je(n)}}function Dn(e){e.modified_||(e.modified_=!0,e.parent_&&Dn(e.parent_))}function Tt(e){e.copy_||(e.assigned_=new Map,e.copy_=Pn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var fo=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Qe(t)&&!Qe(n)){const a=n;n=t;const s=this;return function(u=a,...l){return s.produce(u,f=>n.call(this,f,...l))}}Qe(n)||ge(6),r!==void 0&&!Qe(r)&&ge(7);let i;if($e(t)){const a=Hr(this),s=Fn(a,t,void 0);let o=!0;try{i=n(s),o=!1}finally{o?Tn(a):Nn(a)}return Vr(a,r),jr(i,a)}else if(!t||!tr(t)){if(i=n(t),i===void 0&&(i=t),i===Ui&&(i=void 0),this.autoFreeze_&&rr(i,!0),r){const a=[],s=[];Ve($n).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:s}),r(a,s)}return i}else ge(1,t)},this.produceWithPatches=(t,n)=>{if(Qe(t))return(s,...o)=>this.produceWithPatches(s,u=>t(u,...o));let r,i;return[this.produce(t,n,(s,o)=>{r=s,i=o}),r,i]},hn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),hn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),hn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){$e(e)||ge(8),De(e)&&(e=ho(e));const t=Hr(this),n=Fn(t,e,void 0);return n[re].isManual_=!0,Nn(t),n}finishDraft(e,t){const n=e&&e[re];(!n||!n.isManual_)&&ge(9);const{scope_:r}=n;return Vr(r,t),jr(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=Ve($n).applyPatches_;return De(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Fn(e,t,n,r){const[i,a]=Xt(t)?Ve(Vt).proxyMap_(t,n):en(t)?Ve(Vt).proxySet_(t,n):uo(t,n);return(n?.scope_??Gi()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?oo(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function ho(e){return De(e)||ge(10,e),Xi(e)}function Xi(e){if(!$e(e)||tn(e))return e;const t=e[re];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Pn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Pn(e,!0);return Zt(n,(i,a)=>{Bt(n,i,Xi(a))},r),t&&(t.finalized_=!1),n}var po=new fo,mo=po.produce;const go=e=>(t,n,r)=>(r.setState=(i,a,...s)=>{const o=typeof i==\"function\"?mo(i):i;return t(o,a,...s)},e(r.setState,n,r)),_o=go,yo=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\"]),bo=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function vo(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 Ur(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 Wr(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;const s=i;for(;i<e.length&&/[a-zA-Z0-9_-]/.test(e[i]);)i++;if(i>s){const o=e.slice(s,i);a===\".\"?n.push(o):r=o}}return{className:n.join(\" \"),id:r,endIdx:i}}function xo(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_-]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const s=t;for(;t<e.length&&e[t]!==a;)t++;n[i]=e.slice(s,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function yt(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let s,o;if(e[n]===\".\"||e[n]===\"#\"){const g=Wr(e,n);s=g.className||void 0,o=g.id||void 0,n=g.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const f=e.slice(l,n);n+=2;const{display:c,target:d}=vo(f),h={type:\"link\",display:c,target:d,start:a,end:n};s&&(h.className=s),o&&(h.id=o),t.push(h),r=n;continue}if(e[n]===\"{\"){const a=n;let s=e[n+1],o,u;if(s===\".\"||s===\"#\"){i(n);const l=Wr(e,n+1);o=l.className||void 0,u=l.id||void 0;let f=l.endIdx;e[f]===\" \"&&f++;const c=e[f];if(c===\"$\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:h,scope:\"variable\",start:a,end:n};o&&(g.className=o),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:h,scope:\"temporary\",start:a,end:n};o&&(g.className=o),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=f+1;const d=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const h=e.slice(d,n);if(e[n]===\"}\"){n++;const g={type:\"variable\",name:h,scope:\"local\",start:a,end:n};o&&(g.className=o),u&&(g.id=u),t.push(g),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=f;let d=1;const h=n;for(;n<e.length&&d>0;)e[n]===\"{\"?d++:e[n]===\"}\"&&d--,d>0&&n++;if(d!==0){n=a+1,r=a;continue}const g=e.slice(h,n);n++;const{name:k,rawArgs:I,isClose:b}=Ur(g),x={type:\"macro\",name:k,rawArgs:I,isClose:b,start:a,end:n};o&&(x.className=o),u&&(x.id=u),t.push(x),r=n;continue}n=a+1,r=a;continue}if(s===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(s===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(s===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:f,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(s!==void 0&&(s===\"/\"||/[a-zA-Z]/.test(s))){i(n),n++;let l=1;const f=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(f,n);n++;const{name:d,rawArgs:h,isClose:g}=Ur(c);t.push({type:\"macro\",name:d,rawArgs:h,isClose:g,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let s=n+1;const o=e[s]===\"/\";o&&s++;const u=s;for(;s<e.length&&/[a-zA-Z0-9]/.test(e[s]);)s++;const l=e.slice(u,s).toLowerCase();if(l&&yo.has(l))if(o){for(;s<e.length&&/\\s/.test(e[s]);)s++;if(e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:s}),r=s,n=s;continue}}else{const f=xo(e,s);s=f.endIdx;let c=bo.has(l);if(e[s]===\"/\"&&(c=!0,s++),e[s]===\">\"){s++,i(a),t.push({type:\"html\",tag:l,attributes:f.attributes,isClose:!1,isSelfClose:c,start:a,end:s}),r=s,n=s;continue}}n++;continue}n++}return i(e.length),t}const wo=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\"]),Qr={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},So=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:\"link\",display:i.display,target:i.target};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const s=n[n.length-1];if(s.node.type!==\"html\"||s.node.tag!==i.tag){const o=s.node.type===\"html\"?`</${s.node.tag}>`:`{/${s.node.name}}`;throw new Error(`Expected ${o} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(s.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const a=n[n.length-1];if(a.node.type!==\"macro\"||a.node.name!==i.name){const 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(Qr[i.name]){const a=Qr[i.name],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 o={rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),s.branches.push(o);break}if(wo.has(i.name)){const a={type:\"macro\",name:i.name,rawArgs:i.rawArgs,children:[]};if(So.has(i.name)){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:i.name,rawArgs:i.rawArgs,children:[]};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function ea(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 ta(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let nt=!1,vt=\"\",He=0,Xe=null;function ko(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,vt=n,He=0,Xe=ea(ta(n)),nt=!0}function zn(e,t){vt=e,He=0,Xe=ea(ta(e)),nt=!0;for(let n=0;n<t;n++)Xe();He=t}function Nt(){nt=!1,vt=\"\",He=0,Xe=null}function Dt(){return nt?{seed:vt,pull:He}:null}function ir(){return!nt||!Xe?Math.random():(He++,Xe())}function na(e,t){return e>t&&([e,t]=[t,e]),Math.floor(ir()*(t-e+1))+e}function Co(){return nt}function Io(){return vt}function Ao(){return He}const Eo=500,Le=new Map,Po=/\\$(\\w+)/g,$o=/\\b_(\\w+)/g,To=/@(\\w+)/g;function ra(e){return e.replace(Po,'variables[\"$1\"]').replace($o,'temporary[\"$1\"]').replace(To,'locals[\"$1\"]')}const No=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function ia(e,t){const n=Le.get(e);if(n)return Le.delete(e),Le.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",No+t);if(Le.set(e,r),Le.size>Eo){const i=Le.keys().next().value;i!==void 0&&Le.delete(i)}return r}let kt=null,Gr=null,Kr=null;function aa(){const e=w.getState(),{visitCounts:t,renderCounts:n}=e;if(kt&&Gr===t&&Kr===n)return kt;const r=h=>t[h]??0,i=h=>r(h)>0,a=(...h)=>h.some(g=>r(g)>0),s=(...h)=>h.every(g=>r(g)>0),o=h=>n[h]??0;return kt={currentPassage:()=>{const h=w.getState();return h.storyData?.passages.get(h.currentPassage)},previousPassage:()=>{const h=w.getState();if(h.historyIndex<=0)return;const g=h.history[h.historyIndex-1]?.passage;return g?h.storyData?.passages.get(g):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:s,rendered:o,hasRendered:h=>o(h)>0,hasRenderedAny:(...h)=>h.some(g=>o(g)>0),hasRenderedAll:(...h)=>h.every(g=>o(g)>0),random:ir,randomInt:na},Gr=t,Kr=n,kt}function ye(e,t,n,r={}){const a=`return (${ra(e)});`;return ia(a,a)(t,n,r,aa())}function je(e,t,n,r={}){const i=ra(e);ia(\"exec:\"+i,i)(t,n,r,aa())}const Do=\"spindle\",Fo=1;let Ct=null,pn=null;function Fe(){return pn||(pn={saves:new Map,playthroughs:new Map,meta:new Map}),pn}function zo(){return Ct||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Ct=new Promise((e,t)=>{const n=indexedDB.open(Do,Fo);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)}),Ct))}function ze(e,t){return zo().then(n=>n.transaction(e,t).objectStore(e))}function Oe(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function rn(e){try{const t=await ze(\"saves\",\"readwrite\");await Oe(t.put(e))}catch{Fe().saves.set(e.meta.id,e)}}async function an(e){try{const t=await ze(\"saves\",\"readonly\");return await Oe(t.get(e))??void 0}catch{return Fe().saves.get(e)}}async function Oo(e){try{const t=await ze(\"saves\",\"readwrite\");await Oe(t.delete(e))}catch{Fe().saves.delete(e)}}async function Ro(e){try{const n=(await ze(\"saves\",\"readonly\")).index(\"ifid\");return await Oe(n.getAll(e))??[]}catch{return[...Fe().saves.values()].filter(t=>t.meta.ifid===e)}}async function sa(e){try{const t=await ze(\"playthroughs\",\"readwrite\");await Oe(t.put(e))}catch{Fe().playthroughs.set(e.id,e)}}async function ar(e){try{const n=(await ze(\"playthroughs\",\"readonly\")).index(\"ifid\");return await Oe(n.getAll(e))??[]}catch{return[...Fe().playthroughs.values()].filter(t=>t.ifid===e)}}async function sr(e){try{const t=await ze(\"meta\",\"readonly\"),n=await Oe(t.get(e));return n?n.value:void 0}catch{return Fe().meta.get(e)}}async function oa(e,t){try{const n=await ze(\"meta\",\"readwrite\");await Oe(n.put({key:e,value:t}))}catch{Fe().meta.set(e,t)}}const la=new Map,sn=new Map;function Lo(e,t){la.set(e,t),sn.set(t,e)}function Mo(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Q(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 o=[];t.set(i,o);for(let u=0;u<r.length;u++)o[u]=n(r[u]);return o}const a=i.constructor;if(sn.get(a)!==void 0){const o=Object.create(Object.getPrototypeOf(i));t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}if(Mo(r)||typeof r==\"object\"){const o={};t.set(i,o);for(const u of Object.keys(i))o[u]=n(i[u]);return o}return r}return n(e)}const On=\"__spindle_class__\",Rn=\"__spindle_data__\";function qt(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,s=sn.get(a);if(s!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[On]:s,[Rn]:u}}const o={};for(const u of Object.keys(i))o[u]=n(i[u]);return t.delete(i),o}return n(e)}function Ut(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(s=>t(s));const r=n;if(On in r&&Rn in r){const s=r[On],o=r[Rn],u=la.get(s);if(!u){console.warn(`spindle: Class \"${s}\" not registered. Falling back to plain object.`);const f={};for(const c of Object.keys(o))f[c]=t(o[c]);return f}const l=Object.create(u.prototype);for(const f of Object.keys(o))l[f]=t(o[f]);return l}const i=r.constructor;if(sn.has(i))return n;const a={};for(const s of Object.keys(r))a[s]=t(r[s]);return a}return t(e)}let Ln=null,Mn=null,Yr=!1;function Bo(e){Ln=e}function Vo(e){Mn=e}function Ho(e){if(Mn)try{const i=new Function(\"passage\",\"variables\",Mn)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(Ln)try{const r=Ln(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 jo(){Yr||(Yr=!0)}async function Zr(e){const n=(await ar(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await sa(i),await oa(`currentPlaythroughId.${e}`,r),r}async function qo(e){return sr(`currentPlaythroughId.${e}`)}async function ua(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Ho(n),passage:n.passage,custom:r},s=Q(n);s.variables=qt(s.variables),s.history=s.history.map(u=>({...u,variables:qt(u.variables)}));const o={meta:a,payload:s};return await rn(o),o}async function ca(e,t){const n=await an(e);if(!n)return;const r=Q(t);r.variables=qt(r.variables),r.history=r.history.map(a=>({...a,variables:qt(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await rn(i),i}async function Uo(e){const t=await an(e);if(!t)return;const n=t.payload;return n.variables=Ut(n.variables),n.history=n.history.map(r=>({...r,variables:Ut(r.variables)})),n}async function Wo(e){await Oo(e)}async function Qo(e,t){const n=await an(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await rn(r)}async function Go(e){const[t,n]=await Promise.all([Ro(e),ar(e)]),r=new Map;for(const o of n)r.set(o.id,o);const i=new Map;for(const o of t){const u=o.meta.playthroughId,l=i.get(u);l?l.push(o):i.set(u,[o])}for(const o of i.values())o.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],s=[...r.values()].sort((o,u)=>new Date(u.createdAt).getTime()-new Date(o.createdAt).getTime());for(const o of s){const u=i.get(o.id)??[];a.push({playthrough:o,saves:u})}for(const[o,u]of i)r.has(o)||a.push({playthrough:{id:o,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const fa=\"autosave.\";async function Ko(e,t,n){const r=`${fa}${e}`,i=await sr(r);if(i){const s=await ca(i,n);if(s)return s}const a=await ua(e,t,n,{isAutosave:!0});return await oa(r,a.meta.id),a}async function Yo(e){const t=`${fa}${e}`,n=await sr(t);if(n)return Uo(n)}async function Zo(e){const t=await an(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Jo(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=Q(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await ar(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await sa(a)}return await rn(n),n}function Xo(e,t,n){for(const r of e)if(r.type===\"macro\"){if(r.name===\"set\")je(r.rawArgs,t,n);else if(r.name===\"do\"){const i=r.children.map(a=>a.type===\"text\"?a.value:\"\").join(\"\");je(i,t,n)}}}function ha(){const e=w.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(!t)return;const n=yt(t.content),r=bt(n),i=Q(e.variables),a=Q(e.temporary);Xo(r,i,a);for(const o of Object.keys(i))i[o]!==e.variables[o]&&e.setVariable(o,i[o]);for(const o of Object.keys(a))a[o]!==e.temporary[o]&&e.setTemporary(o,a[o]);const s=e.storyData.passages.get(\"SaveTitle\");s&&Vo(s.content)}function Jr(e){e?.prng?zn(e.prng.seed,e.prng.pull):e&&Nt()}const w=Js()(_o((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",saveError:null,loadError:null,init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=Q(r);e(o=>{o.storyData=n,o.currentPassage=i.name,o.variables=a,o.variableDefaults=r,o.temporary={},o.history=[{passage:i.name,variables:Q(a),timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}});const s=n.ifid;jo().then(async()=>{const o=await qo(s);if(o)e(u=>{u.playthroughId=o});else{const u=await Zr(s);e(l=>{l.playthroughId=u})}}).catch(o=>console.error(\"spindle: failed to init save system\",o))},navigate:n=>{const{storyData:r}=t();if(r){if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}e(i=>{i.temporary={},i.currentPassage=n,i.history=i.history.slice(0,i.historyIndex+1),i.history.push({passage:n,variables:Q(i.variables),timestamp:Date.now(),prng:Dt()}),i.historyIndex=i.history.length-1,i.visitCounts[n]=(i.visitCounts[n]??0)+1,i.renderCounts[n]=(i.renderCounts[n]??0)+1})}},goBack:()=>{e(n=>{if(n.historyIndex<=0)return;n.historyIndex--;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=Q(r.variables),n.temporary={}}),Jr(t().history[t().historyIndex])},goForward:()=>{e(n=>{if(n.historyIndex>=n.history.length-1)return;n.historyIndex++;const r=n.history[n.historyIndex];n.currentPassage=r.passage,n.variables=Q(r.variables),n.temporary={}}),Jr(t().history[t().historyIndex])},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;Nt();const a=Q(r);e(s=>{s.currentPassage=i.name,s.variables=a,s.temporary={},s.history=[{passage:i.name,variables:Q(a),timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),ha(),Zr(n.ifid).then(s=>{e(o=>{o.playthroughId=s})}).catch(s=>console.error(\"spindle: failed to start new playthrough\",s))},save:()=>{const{storyData:n,playthroughId:r,currentPassage:i,variables:a,history:s,historyIndex:o,visitCounts:u,renderCounts:l}=t();if(!n)return;const f={passage:i,variables:Q(a),history:Q(s),historyIndex:o,visitCounts:{...u},renderCounts:{...l},prng:Dt()};e(c=>{c.saveError=null}),Ko(n.ifid,r,f).then(()=>{e(c=>{c.saveVersion++})}).catch(c=>{console.error(\"spindle: failed to quick save\",c),e(d=>{d.saveError=c instanceof Error?c.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),Yo(n.ifid).then(r=>{r&&(e(i=>{i.currentPassage=r.passage,i.variables=r.variables,i.history=r.history,i.historyIndex=r.historyIndex,i.visitCounts=r.visitCounts??{},i.renderCounts=r.renderCounts??{},i.temporary={}}),r.prng?zn(r.prng.seed,r.prng.pull):Nt())}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:s,renderCounts:o}=t();return{passage:n,variables:Q(r),history:Q(i),historyIndex:a,visitCounts:{...s},renderCounts:{...o},prng:Dt()}},loadFromPayload:n=>{e(r=>{r.currentPassage=n.passage,r.variables=Ut(n.variables),r.history=n.history.map(i=>({...i,variables:Ut(i.variables)})),r.historyIndex=n.historyIndex,r.visitCounts=n.visitCounts??{},r.renderCounts=n.renderCounts??{},r.temporary={}}),n.prng?zn(n.prng.seed,n.prng.pull):Nt()}}))),Wt=new Map,Bn=new Set,Vn=new Map;function el(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(Vn.get(r)??0)+1;return Vn.set(r,i),i===1?r:`${r}:${i}`}function tl(e){return Wt.set(e.id,e),ei(),()=>{Wt.delete(e.id),ei()}}function Xr(){return Array.from(Wt.values())}function nl(e){return Wt.get(e)}function rl(){Vn.clear()}function il(e){return Bn.add(e),()=>{Bn.delete(e)}}function ei(){for(const e of Bn)e()}function ie(e){const t=Be(\"\");t.current||(t.current=el(e.type,e.key,e.authorId));const n=t.current;return he(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),tl(r)}),n}function al({target:e,className:t,id:n,children:r}){const i=w(o=>o.navigate),a=o=>{o.preventDefault(),i(e)};ie({type:\"link\",key:e,authorId:n,label:typeof r==\"string\"?r:e,target:e,perform:()=>i(e)});const s=t?`passage-link ${t}`:\"passage-link\";return _(\"a\",{href:\"#\",id:n,class:s,onClick:a,children:r})}function sl({name:e,scope:t,className:n,id:r}){const i=be(Ie),a=e.split(\".\"),s=a[0],o=w(f=>t===\"variable\"?f.variables[s]:t===\"temporary\"?f.temporary[s]:void 0);let u;if(t===\"local\"){const f=`@${s}`;u=f in i.values?i.values[f]:void 0}else u=o;for(let f=1;f<a.length;f++){if(u==null||typeof u!=\"object\"){u=void 0;break}const c=a[f];u=u[c]}const l=u==null?\"\":String(u);return n||r?_(\"span\",{id:r,class:n,children:l}):_(K,{children:l})}function de(){const e=w(r=>r.variables),t=w(r=>r.temporary),n=be(Ie);return qe(()=>{const r={};for(const[i,a]of Object.entries(n.values))i.startsWith(\"@\")&&(r[i.slice(1)]=a);return[e,t,r]},[e,t,n.values])}function ol({rawArgs:e}){const t=be(Ie),[,,n]=de();return he(()=>{const r=w.getState(),i=Q(r.variables),a=Q(r.temporary),s={...n};try{je(e,i,a,s)}catch(o){console.error(`spindle: Error in {set ${e}}:`,o);return}for(const o of Object.keys(i))i[o]!==r.variables[o]&&r.setVariable(o,i[o]);for(const o of Object.keys(a))a[o]!==r.temporary[o]&&r.setTemporary(o,a[o]);for(const o of Object.keys(s))s[o]!==n[o]&&t.update(`@${o}`,s[o])},[]),null}function ll({rawArgs:e,className:t,id:n}){const[r,i,a]=de();try{const s=ye(e,r,i,a),o=s==null?\"\":String(s);return t||n?_(\"span\",{id:n,class:t,children:o}):_(K,{children:o})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{print error: ${s instanceof Error?s.message:String(s)}}`})}}function ul({branches:e}){const[t,n,r]=de();function i(a){const s=fe(a.children);return a.className||a.id?_(\"span\",{id:a.id,class:a.className,children:s}):_(K,{children:s})}for(const a of e){if(a.rawArgs===\"\")return i(a);try{if(ye(a.rawArgs,t,n,r))return i(a)}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{if error: ${s instanceof Error?s.message:String(s)}}`})}}return null}function cl(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(o=>o.trim()),a=i[0],s=i.length>1?i[1]:null;if(!a.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(s&&!s.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${s}\"`);return{itemVar:a,indexVar:s,listExpr:r}}function fl({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=Y(()=>({...e,...t,...n})),s=tt((u,l)=>{a(f=>({...f,[u]:l}))},[]),o={values:i,update:s};return _(Ie.Provider,{value:o,children:fe(r)})}function hl({rawArgs:e,children:t,className:n,id:r}){const i=be(Ie),[a,s,o]=de();let u;try{u=cl(e)}catch(g){return _(\"span\",{class:\"error\",title:String(g),children:`{for error: ${g instanceof Error?g.message:String(g)}}`})}const{itemVar:l,indexVar:f,listExpr:c}=u;let d;try{const g=ye(c,a,s,o);if(!Array.isArray(g))return _(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});d=g}catch(g){return _(\"span\",{class:\"error\",title:String(g),children:`{for error: ${g instanceof Error?g.message:String(g)}}`})}const h=d.map((g,k)=>{const I={[l]:g,...f?{[f]:k}:void 0};return _(fl,{parentValues:i.values,ownKeys:I,initialValues:{},children:t},k)});return n||r?_(\"span\",{id:r,class:n,children:h}):_(K,{children:h})}function dl(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function pl({children:e}){const t=dl(e),n=be(Ie),[,,r]=de();return he(()=>{const i=w.getState(),a=Q(i.variables),s=Q(i.temporary),o={...r};try{je(t,a,s,o)}catch(u){console.error(\"spindle: Error in {do}:\",u);return}for(const u of Object.keys(a))a[u]!==i.variables[u]&&i.setVariable(u,a[u]);for(const u of Object.keys(s))s[u]!==i.temporary[u]&&i.setTemporary(u,s[u]);for(const u of Object.keys(o))o[u]!==r[u]&&n.update(`@${u}`,o[u])},[]),null}function da(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function ml({rawArgs:e,children:t,className:n,id:r}){const i=be(Ie),[,,a]=de(),s=()=>{const u=w.getState(),l=Q(u.variables),f=Q(u.temporary),c={...a};try{je(e,l,f,c)}catch(d){console.error(`spindle: Error in {button ${e}}:`,d);return}for(const d of Object.keys(l))l[d]!==u.variables[d]&&u.setVariable(d,l[d]);for(const d of Object.keys(f))f[d]!==u.temporary[d]&&u.setTemporary(d,f[d]);for(const d of Object.keys(c))c[d]!==a[d]&&i.update(`@${d}`,c[d])};ie({type:\"button\",key:e,authorId:r,label:da(t)||e,perform:s});const o=n?`macro-button ${n}`:\"macro-button\";return _(\"button\",{id:r,class:o,onClick:s,children:Ta(t)})}function gl({className:e,id:t}){const n=w(i=>i.storyData?.name||\"\"),r=e?`story-title ${e}`:\"story-title\";return _(\"span\",{id:t,class:r,children:n})}function _l({className:e,id:t}){const n=w(a=>a.restart),r=e?`menubar-button ${e}`:\"menubar-button\",i=()=>{confirm(\"Restart the story? All progress will be lost.\")&&n()};return ie({type:\"restart\",key:\"restart\",authorId:t,label:\"Restart\",perform:()=>n()}),_(\"button\",{id:t,class:r,onClick:i,children:\"↺ Restart\"})}function yl({className:e,id:t}){const n=w(a=>a.goBack),r=w(a=>a.historyIndex>0),i=e?`menubar-button ${e}`:\"menubar-button\";return ie({type:\"back\",key:\"back\",authorId:t,label:\"Back\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"← Back\"})}function bl({className:e,id:t}){const n=w(a=>a.goForward),r=w(a=>a.historyIndex<a.history.length-1),i=e?`menubar-button ${e}`:\"menubar-button\";return ie({type:\"forward\",key:\"forward\",authorId:t,label:\"Forward\",disabled:!r,perform:()=>n()}),_(\"button\",{id:t,class:i,onClick:n,disabled:!r,children:\"Forward →\"})}function vl({className:e,id:t}){const n=w(i=>i.save),r=e?`menubar-button ${e}`:\"menubar-button\";return ie({type:\"save\",key:\"quicksave\",authorId:t,label:\"QuickSave\",perform:()=>n()}),_(\"button\",{id:t,class:r,title:\"Quick Save (F6)\",onClick:()=>n(),children:\"QuickSave\"})}function xl({className:e,id:t}){const n=w(o=>o.load),r=w(o=>o.hasSave);w(o=>o.saveVersion);const i=e?`menubar-button ${e}`:\"menubar-button\",a=!r(),s=()=>{confirm(\"Load saved game? Current progress will be lost.\")&&n()};return ie({type:\"load\",key:\"quickload\",authorId:t,label:\"QuickLoad\",disabled:a,perform:()=>n()}),_(\"button\",{id:t,class:i,title:\"Quick Load (F9)\",disabled:a,onClick:s,children:\"QuickLoad\"})}const at=new Map;let ne={},ti=!1;function pa(){return`spindle.${w.getState().storyData?.ifid||\"unknown\"}.settings`}function wl(){localStorage.setItem(pa(),JSON.stringify(ne))}function mn(){if(!ti){ti=!0;try{const e=localStorage.getItem(pa());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(ne={...ne,...t})}}catch{}}}const dt={addToggle(e,t){at.set(e,{type:\"toggle\",config:t}),e in ne||(ne[e]=t.default),mn()},addList(e,t){at.set(e,{type:\"list\",config:t}),e in ne||(ne[e]=t.default),mn()},addRange(e,t){at.set(e,{type:\"range\",config:t}),e in ne||(ne[e]=t.default),mn()},get(e){return ne[e]},getToggle(e){const t=ne[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=ne[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=ne[e];return typeof t==\"number\"?t:0},set(e,t){ne[e]=t,wl()},getAll(){return{...ne}},getDefinitions(){return at},hasAny(){return at.size>0}};function Sl({name:e,def:t}){const[n,r]=Y(()=>dt.get(e)),i=a=>{r(a),dt.set(e,a)};switch(t.type){case\"toggle\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:t.config.label}),_(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>_(\"option\",{value:a,children:a},a))})]});case\"range\":return _(\"label\",{class:\"settings-row\",children:[_(\"span\",{children:[t.config.label,\": \",String(n)]}),_(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function kl({onClose:e}){const t=dt.getDefinitions();return _(\"div\",{class:\"settings-overlay\",onClick:r=>{r.target.classList.contains(\"settings-overlay\")&&e()},children:_(\"div\",{class:\"settings-panel\",children:[_(\"div\",{class:\"settings-header\",children:[_(\"span\",{children:\"Settings\"}),_(\"button\",{class:\"settings-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"settings-body\",children:Array.from(t.entries()).map(([r,i])=>_(Sl,{name:r,def:i},r))})]})})}function Cl({className:e,id:t}){const[n,r]=Y(!1);if(!dt.hasAny())return null;const i=e?`menubar-button ${e}`:\"menubar-button\";return _(K,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"⚙ Settings\"}),n&&_(kl,{onClose:()=>r(!1)})]})}function Il(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function Al(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function El(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Pl({onClose:e}){const[t,n]=Y(\"load\"),[r,i]=Y([]),[a,s]=Y(!0),[o,u]=Y(null),[l,f]=Y(()=>new Set),[c,d]=Y(null),[h,g]=Y(\"\"),k=Be(null),I=Be(null),b=w(A=>A.storyData),x=w(A=>A.playthroughId),S=w(A=>A.getSavePayload),D=w(A=>A.loadFromPayload),E=b?.ifid??\"\",v=tt(async()=>{if(!E)return;const A=await Go(E);i(A),s(!1)},[E]);Ce(()=>{v()},[v]),Ce(()=>{c&&k.current&&(k.current.focus(),k.current.select())},[c]);const z=Be(),F=(A,p=\"success\")=>{clearTimeout(z.current),u({text:A,type:p}),z.current=window.setTimeout(()=>u(null),3e3)},M=A=>{f(p=>{const j=new Set(p);return j.has(A)?j.delete(A):j.add(A),j})},y=async()=>{if(!(!E||!x))try{const A=S();await ua(E,x,A),F(\"Save created\"),await v()}catch{F(\"Failed to create save\",\"error\")}},P=async A=>{try{const p=S();await ca(A,p),F(\"Save overwritten\"),await v()}catch{F(\"Failed to overwrite save\",\"error\")}},$=async A=>{try{D(A.payload),F(\"Game loaded\"),setTimeout(e,500)}catch{F(\"Failed to load save\",\"error\")}},V=async A=>{if(confirm(\"Delete this save?\"))try{await Wo(A),F(\"Save deleted\"),await v()}catch{F(\"Failed to delete save\",\"error\")}},H=A=>{d(A.meta.id),g(A.meta.title)},R=async()=>{if(!(!c||!h.trim()))try{await Qo(c,h.trim()),d(null),F(\"Save renamed\"),await v()}catch{F(\"Failed to rename\",\"error\")}},J=A=>{A.key===\"Enter\"?R():A.key===\"Escape\"&&d(null)},Z=async A=>{try{const p=await Zo(A);if(!p)return;const j=new Blob([JSON.stringify(p,null,2)],{type:\"application/json\"}),U=URL.createObjectURL(j),q=document.createElement(\"a\");q.href=U,q.download=`save-${p.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,q.click(),URL.revokeObjectURL(U),F(\"Save exported\")}catch{F(\"Failed to export save\",\"error\")}},se=()=>{I.current?.click()},pe=async A=>{const p=A.target,j=p.files?.[0];if(j){p.value=\"\";try{const U=await j.text(),q=JSON.parse(U);if(!Il(q))throw new Error(\"Invalid save file format\");await Jo(q,E),F(\"Save imported\"),await v()}catch(U){F(U instanceof Error?U.message:\"Failed to import save\",\"error\")}}},m=A=>{A.target.classList.contains(\"saves-overlay\")&&e()},oe=r.reduce((A,p)=>A+p.saves.length,0);return _(\"div\",{class:\"saves-overlay\",onClick:m,children:_(\"div\",{class:\"saves-panel\",children:[_(\"div\",{class:\"saves-header\",children:[_(\"div\",{class:\"saves-header-left\",children:_(\"div\",{class:\"saves-mode-toggle\",children:[_(\"button\",{class:t===\"save\"?\"active\":\"\",onClick:()=>n(\"save\"),children:\"Save\"}),_(\"button\",{class:t===\"load\"?\"active\":\"\",onClick:()=>n(\"load\"),children:\"Load\"})]})}),_(\"button\",{class:\"saves-close\",onClick:e,children:\"✕\"})]}),_(\"div\",{class:\"saves-toolbar\",children:[_(\"button\",{class:\"saves-toolbar-button\",onClick:se,children:\"Import\"}),_(\"input\",{ref:I,type:\"file\",accept:\".json\",style:\"display:none\",onChange:pe})]}),_(\"div\",{class:\"saves-body\",children:[a?_(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):oe===0&&t===\"load\"?_(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):r.map(A=>{const p=l.has(A.playthrough.id),j=A.playthrough.id===x;return t===\"save\"&&!j||t===\"load\"&&A.saves.length===0&&!j?null:_(\"div\",{class:\"playthrough-group\",children:[_(\"div\",{class:\"playthrough-header\",onClick:()=>M(A.playthrough.id),children:[_(\"span\",{class:`playthrough-chevron ${p?\"\":\"open\"}`,children:\"▶\"}),_(\"span\",{class:\"playthrough-label\",children:[A.playthrough.label,j?\" (current)\":\"\"]}),_(\"span\",{class:\"playthrough-date\",children:El(A.playthrough.createdAt)})]}),!p&&_(\"div\",{class:\"playthrough-saves\",children:[A.saves.map(U=>_(\"div\",{class:\"save-slot\",children:[_(\"div\",{class:\"save-slot-info\",children:[c===U.meta.id?_(\"input\",{ref:k,class:\"save-rename-input\",value:h,onInput:q=>g(q.target.value),onKeyDown:J,onBlur:R}):_(\"div\",{class:\"save-slot-title\",children:U.meta.title}),_(\"div\",{class:\"save-slot-meta\",children:[_(\"span\",{children:U.meta.passage}),_(\"span\",{children:Al(U.meta.updatedAt)})]})]}),_(\"div\",{class:\"save-slot-actions\",children:[t===\"save\"?_(\"button\",{class:\"save-slot-action primary\",onClick:()=>P(U.meta.id),children:\"Save Here\"}):_(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(U),children:\"Load\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>H(U),children:\"Rename\"}),_(\"button\",{class:\"save-slot-action\",onClick:()=>Z(U.meta.id),children:\"Export\"}),_(\"button\",{class:\"save-slot-action danger\",onClick:()=>V(U.meta.id),children:\"Delete\"})]})]},U.meta.id)),t===\"save\"&&j&&_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})]})]},A.playthrough.id)}),t===\"save\"&&!a&&!r.some(A=>A.playthrough.id===x)&&_(\"div\",{class:\"playthrough-group\",children:_(\"div\",{class:\"playthrough-saves\",children:_(\"button\",{class:\"save-slot-new\",onClick:y,children:\"+ New Save\"})})})]}),o&&_(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})})}function $l({className:e,id:t}){const[n,r]=Y(!1),i=e?`menubar-button ${e}`:\"menubar-button\";return _(K,{children:[_(\"button\",{id:t,class:i,onClick:()=>r(!0),children:\"Saves\"}),n&&_(Pl,{onClose:()=>r(!1)})]})}function Tl({rawArgs:e,className:t,id:n}){const r=w(d=>d.storyData),[i,a,s]=de();if(!r)return null;let o;try{const d=ye(e,i,a,s);o=String(d)}catch{o=e.replace(/^[\"']|[\"']$/g,\"\")}const u=r.passages.get(o);if(u&&w.getState().trackRender(o),!u)return _(\"span\",{class:\"error\",children:`{include: passage \"${o}\" not found}`});const l=yt(u.content),f=bt(l),c=fe(f);return t||n?_(\"span\",{id:n,class:t,children:c}):_(K,{children:c})}function Nl({rawArgs:e}){const[t,n,r]=de();return he(()=>{let i;try{const a=ye(e,t,n,r);i=String(a)}catch{i=e.replace(/^[\"']|[\"']$/g,\"\")}w.getState().navigate(i)},[]),null}function Dl({rawArgs:e}){return he(()=>{const t=w.getState(),n=e.trim();n.startsWith(\"$\")?t.deleteVariable(n.slice(1)):n.startsWith(\"_\")?t.deleteTemporary(n.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${n}\"`)},[]),null}function Fl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function zl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Fl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"textbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textbox ${t}`:\"macro-textbox\";return _(\"input\",{type:\"text\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function Ol(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 Rl({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Ol(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"numberbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?Number(l):0)});const u=t?`macro-numberbox ${t}`:\"macro-numberbox\";return _(\"input\",{type:\"number\",id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>{const f=l.target.value;o(a,f===\"\"?0:Number(f))}})}function Ll(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 Ml({rawArgs:e,className:t,id:n}){const{varName:r,placeholder:i}=Ll(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"textarea\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:s,perform:l=>o(a,l!==void 0?String(l):\"\")});const u=t?`macro-textarea ${t}`:\"macro-textarea\";return _(\"textarea\",{id:n,class:u,value:s==null?\"\":String(s),placeholder:i,onInput:l=>o(a,l.target.value)})}function Bl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t)return{varName:e.trim(),label:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2];return{varName:n,label:r}}function Vl({rawArgs:e,className:t,id:n}){const{varName:r,label:i}=Bl(e),a=r.startsWith(\"$\")?r.slice(1):r,s=w(l=>l.variables[a]),o=w(l=>l.setVariable);ie({type:\"checkbox\",key:`$${a}`,authorId:n,label:i||a,variable:a,value:!!s,perform:l=>o(a,l!==void 0?!!l:!s)});const u=t?`macro-checkbox ${t}`:\"macro-checkbox\";return _(\"label\",{id:n,class:u,children:[_(\"input\",{type:\"checkbox\",checked:!!s,onChange:()=>o(a,!s)}),i?` ${i}`:null]})}function Hl(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/);return{varName:(n[0]??\"\").replace(/[\"']/g,\"\"),value:n[1]??\"\",label:n.slice(2).join(\" \")}}return{varName:t[1].replace(/[\"']/g,\"\"),value:t[2],label:t[3]}}function jl({rawArgs:e,className:t,id:n}){const{varName:r,value:i,label:a}=Hl(e),s=r.startsWith(\"$\")?r.slice(1):r,o=w(f=>f.variables[s]),u=w(f=>f.setVariable);ie({type:\"radiobutton\",key:`$${s}:${i}`,authorId:n,label:a||i,variable:s,value:o,perform:()=>u(s,i)});const l=t?`macro-radiobutton ${t}`:\"macro-radiobutton\";return _(\"label\",{id:n,class:l,children:[_(\"input\",{type:\"radio\",name:`radio-${s}`,checked:o===i,onChange:()=>u(s,i)}),a?` ${a}`:null]})}function ma(e){const t=[];for(const n of e)n.type===\"macro\"&&n.name===\"option\"&&t.push(n.rawArgs.trim());return t}function ql({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=w(f=>f.variables[a]),o=w(f=>f.setVariable),u=ma(t);ie({type:\"listbox\",key:`$${a}`,authorId:r,label:a,variable:a,options:u,value:s,perform:f=>{f!==void 0&&o(a,String(f))}});const l=n?`macro-listbox ${n}`:\"macro-listbox\";return _(\"select\",{id:r,class:l,value:s==null?\"\":String(s),onChange:f=>o(a,f.target.value),children:u.map(f=>_(\"option\",{value:f,children:f},f))})}function Ul({rawArgs:e,children:t,className:n,id:r}){const i=e.trim().replace(/[\"']/g,\"\"),a=i.startsWith(\"$\")?i.slice(1):i,s=w(c=>c.variables[a]),o=w(c=>c.setVariable),u=ma(t),l=()=>{if(u.length===0)return;const d=(u.indexOf(String(s))+1)%u.length;o(a,u[d])};ie({type:\"cycle\",key:`$${a}`,authorId:r,label:s==null?u[0]||\"\":String(s),variable:a,options:u,value:s,perform:c=>{c!==void 0?o(a,c):l()}});const f=n?`macro-cycle ${n}`:\"macro-cycle\";return _(\"button\",{id:r,class:f,onClick:l,children:s==null?u[0]||\"\":String(s)})}function Wl(e){const t=[],n=/[\"']([^\"']+)[\"']/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function ni(e,t,n){const r=w.getState(),i=Q(r.variables),a=Q(r.temporary),s={...t};for(const o of e)if(o.type===\"macro\"){if(o.name===\"set\")try{je(o.rawArgs,i,a,s)}catch(u){console.error(\"spindle: Error in {link} child {set}:\",u)}else if(o.name===\"do\"){const u=da(o.children);try{je(u,i,a,s)}catch(l){console.error(\"spindle: Error in {link} child {do}:\",l)}}}for(const o of Object.keys(i))i[o]!==r.variables[o]&&r.setVariable(o,i[o]);for(const o of Object.keys(a))a[o]!==r.temporary[o]&&r.setTemporary(o,a[o]);for(const o of Object.keys(s))s[o]!==t[o]&&n(`@${o}`,s[o])}function Ql({rawArgs:e,children:t,className:n,id:r}){const{display:i,passage:a}=Wl(e),s=be(Ie),[,,o]=de(),u=f=>{f.preventDefault(),ni(t,o,s.update),a&&w.getState().navigate(a)};ie({type:\"link\",key:a||i,authorId:r,label:i,target:a??void 0,perform:()=>{ni(t,o,s.update),a&&w.getState().navigate(a)}});const l=n?`macro-link ${n}`:\"macro-link\";return _(\"a\",{id:r,class:l,href:\"#\",onClick:u,children:i})}function Gl({rawArgs:e,branches:t}){const[n,r,i]=de();let a;try{a=ye(e,n,r,i)}catch(o){return _(\"span\",{class:\"error\",title:String(o),children:`{switch error: ${o instanceof Error?o.message:String(o)}}`})}let s=null;for(const o of t){if(o.rawArgs===\"\"){s=o;continue}try{const u=ye(o.rawArgs,n,r,i);if(a===u)return _(K,{children:fe(o.children)})}catch(u){return _(\"span\",{class:\"error\",title:String(u),children:`{case error: ${u instanceof Error?u.message:String(u)}}`})}}return s?_(K,{children:fe(s.children)}):null}function Qt(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function Kl({rawArgs:e,children:t,branches:n,className:r,id:i}){const a=qe(()=>{const l=[];l.push({delay:Qt(e),nodes:t});for(const f of n){const c=f.rawArgs?Qt(f.rawArgs):0;l.push({delay:c,nodes:f.children})}return l},[e,t,n]),[s,o]=Y(-1);if(Ce(()=>{if(s>=a.length-1)return;const l=s+1,f=a[l].delay,c=setTimeout(()=>{o(l)},f);return()=>clearTimeout(c)},[s,a]),s<0)return null;const u=fe(a[s].nodes);return r||i?_(\"span\",{id:i,class:r,children:u}):_(K,{children:u})}const ga=Zn({stop:()=>{}});function Yl({rawArgs:e,children:t,className:n,id:r}){const i=Qt(e),[a,s]=Y(0),[o,u]=Y(!1),l=tt(()=>u(!0),[]);if(Ce(()=>{if(o)return;const d=setInterval(()=>{s(h=>h+1)},i);return()=>clearInterval(d)},[i,o]),a===0&&!o)return null;const f=n?`macro-repeat ${n}`:void 0,c=_(ga.Provider,{value:{stop:l},children:fe(t)});return f||r?_(\"span\",{id:r,class:f,children:c}):c}function Zl(){const{stop:e}=be(ga);return he(()=>{e()},[e]),null}function Jl({rawArgs:e,children:t,className:n,id:r}){const i=Qt(e),a=Be(null),[s,o]=Y(0),[u,l]=Y(0);Ce(()=>{if(a.current){const d=a.current.textContent||\"\";o(d.length)}},[]),Ce(()=>{if(s===0||u>=s)return;const d=setInterval(()=>{l(h=>h>=s?(clearInterval(d),h):h+1)},i);return()=>clearInterval(d)},[s,i]);const f=u>=s&&s>0,c=[\"macro-type\",f?\"macro-type-done\":\"\",n||\"\"].filter(Boolean).join(\" \");return _(\"span\",{id:r,class:c,ref:a,style:{clipPath:(s>0&&!f,void 0)},children:[_(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:s===0?\"hidden\":\"visible\",clipPath:s>0&&!f?`inset(0 ${(s-u)/s*100}% 0 0)`:void 0},children:Ta(t)}),!f&&s>0&&_(\"span\",{class:\"macro-type-cursor\"})]})}const _a=new Map;function ya(e,t,n){_a.set(e.toLowerCase(),{body:t,params:n})}function Xl(e){return _a.get(e.toLowerCase())}function eu(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}function tu({rawArgs:e,children:t}){const{name:n,params:r}=eu(e);return he(()=>{ya(n,t,r)},[]),null}function nu(e){const t=[];let n=\"\",r=0,i=null;for(let s=0;s<e.length;s++){const o=e[s];if(i){n+=o,o===i&&e[s-1]!==\"\\\\\"&&(i=null);continue}if(o==='\"'||o===\"'\"||o===\"`\"){i=o,n+=o;continue}if(o===\"(\"||o===\"[\"||o===\"{\"){r++,n+=o;continue}if(o===\")\"||o===\"]\"||o===\"}\"){r--,n+=o;continue}if(o===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=o}const a=n.trim();return a&&t.push(a),t}function ru({body:e,parentValues:t,ownKeys:n}){const[r,i]=Y(()=>({...t,...n})),a=tt((o,u)=>{i(l=>({...l,[o]:u}))},[]),s={values:r,update:a};return _(Ie.Provider,{value:s,children:fe(e)})}function iu({body:e,params:t,rawArgs:n}){const r=be(Ie),[i,a,s]=de();if(t.length===0||!n)return _(K,{children:fe(e)});const o=nu(n),u={};for(let l=0;l<t.length;l++){const f=t[l],c=o[l];let d;if(c!==void 0)try{d=ye(c,i,a,s)}catch{d=void 0}u[f]=d}return _(ru,{body:e,parentValues:r.values,ownKeys:u})}function au(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),s=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:s}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function su(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 ou({rawArgs:e}){const[t,n,r]=de();let i,a;try{({target:i,expr:a}=au(e))}catch(u){return _(\"span\",{class:\"error\",title:String(u),children:`{computed error: ${u instanceof Error?u.message:String(u)}}`})}const s=i.startsWith(\"_\"),o=i.slice(1);return he(()=>{const u=w.getState();let l;try{l=ye(a,t,n,r)}catch(c){console.error(`spindle: Error in {computed ${e}}:`,c);return}const f=s?u.temporary[o]:u.variables[o];su(f,l)||(s?u.setTemporary(o,l):u.setVariable(o,l))}),null}function lu(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const a=uu(r);if(a.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:a[0],maxExpr:a.slice(1).join(\" \"),labelMode:n}}function uu(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const a=e[i];if(a===\"(\"||a===\"[\")r++,n+=a;else if(a===\")\"||a===\"]\")r--,n+=a;else if(/\\s/.test(a)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=a}return n.length>0&&t.push(n),t}function cu(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}function fu({rawArgs:e,className:t,id:n}){const[r,i,a]=de();try{const{currentExpr:s,maxExpr:o,labelMode:u}=lu(e),l=Number(ye(s,r,i,a)),f=Number(ye(o,r,i,a)),c=f===0?0:Math.max(0,Math.min(100,l/f*100)),d=cu(l,f,u),h=[\"macro-meter\",t].filter(Boolean).join(\" \");return _(\"div\",{class:h,id:n,children:[_(\"div\",{class:\"macro-meter-fill\",style:`width: ${c}%`}),d!=null&&_(\"span\",{class:\"macro-meter-label\",children:d})]})}catch(s){return _(\"span\",{class:\"error\",title:String(s),children:`{meter error: ${s instanceof Error?s.message:String(s)}}`})}}function hu({passage:e}){const t=qe(()=>{try{const n=yt(e.content),r=bt(n);return fe(r)}catch(n){return _(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”:\",\" \",n.message]})}},[e.content,e.name]);return _(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),children:t})}function du({className:e,id:t}){const n=w(a=>a.currentPassage),i=w(a=>a.storyData)?.passages.get(n);return i?_(\"div\",{id:t??\"story\",class:e??\"story\",children:_(hu,{passage:i},n)}):_(\"div\",{class:\"error\",children:[\"Error: Passage “\",n,\"” not found.\"]})}const pu=new Map;function mu(e){return pu.get(e.toLowerCase())}const ri=document.createElement(\"i\");function ba(e){const t=\"&\"+e+\";\";ri.innerHTML=t;const n=ri.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function ce(e,t,n,r){const i=e.length;let a=0,s;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);a<r.length;)s=r.slice(a,a+1e4),s.unshift(t,0),e.splice(...s),a+=1e4,t+=1e4}function ee(e,t){return e.length>0?(ce(e,e.length,0,t),e):t}const Hn={}.hasOwnProperty;function gu(e){const t={};let n=-1;for(;++n<e.length;)_u(t,e[n]);return t}function _u(e,t){let n;for(n in t){const i=(Hn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Hn.call(i,s)||(i[s]=[]);const o=a[s];yu(i[s],Array.isArray(o)?o:o?[o]:[])}}}function yu(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);ce(e,0,0,r)}function bu(e){const t={};let n=-1;for(;++n<e.length;)vu(t,e[n]);return t}function vu(e,t){let n;for(n in t){const i=(Hn.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a)i[s]=a[s]}}function xu(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 wu={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function va(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+wu[n]+\";\"}}function pt(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const we=Re(/[A-Za-z]/),ue=Re(/[\\dA-Za-z]/),Su=Re(/[#-'*+\\--9=?A-Z^-~]/);function jn(e){return e!==null&&(e<32||e===127)}const qn=Re(/\\d/),ku=Re(/[\\dA-Fa-f]/),Cu=Re(/[!-/:-@[-`{-~]/);function N(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Iu=Re(/\\p{P}|\\p{S}/u),Au=Re(/\\s/);function Re(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function It(e,t){const n=va(Eu(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),s=n.indexOf(\"/\");return r<0||s>-1&&r>s||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Eu(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let s=\"\";if(a===37&&ue(e.charCodeAt(n+1))&&ue(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(s=String.fromCharCode(a));else if(a>55295&&a<57344){const o=e.charCodeAt(n+1);a<56320&&o>56319&&o<57344?(s=String.fromCharCode(a,o),i=1):s=\"�\"}else s=String.fromCharCode(a);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const ii={}.hasOwnProperty,ai=/^(https?|ircs?|mailto|xmpp)$/i,Pu=/^https?$/i;function $u(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],s=[],u=bu([{enter:{blockQuote:R,codeFenced:pe,codeFencedFenceInfo:I,codeFencedFenceMeta:I,codeIndented:A,codeText:Ja,content:Ba,definition:Fa,definitionDestinationString:Oa,definitionLabelString:I,definitionTitleString:I,emphasis:Ya,htmlFlow:Ka,htmlText:fr,image:j,label:I,link:U,listItemMarker:P,listItemValue:y,listOrdered:F,listUnordered:M,paragraph:Z,reference:I,resource:Ue,resourceDestinationString:We,resourceTitleString:I,setextHeading:Ha,strong:Za},exit:{atxHeading:qa,atxHeadingSequence:Va,autolinkEmail:as,autolinkProtocol:is,blockQuote:J,characterEscapeValue:it,characterReferenceMarkerHexadecimal:hr,characterReferenceMarkerNumeric:hr,characterReferenceValue:rs,codeFenced:p,codeFencedFence:oe,codeFencedFenceInfo:m,codeFencedFenceMeta:z,codeFlowValue:Ga,codeIndented:p,codeText:Xa,codeTextData:it,data:it,definition:Ma,definitionDestinationString:Ra,definitionLabelString:za,definitionTitleString:La,emphasis:es,hardBreakEscape:ur,hardBreakTrailing:ur,htmlFlow:cr,htmlFlowData:it,htmlText:cr,htmlTextData:it,image:lr,label:rt,labelText:q,lineEnding:Qa,link:lr,listOrdered:$,listUnordered:V,paragraph:se,reference:z,referenceString:Te,resource:z,resourceDestinationString:un,resourceTitleString:Da,setextHeading:Wa,setextHeadingLineSequence:Ua,setextHeadingText:ja,strong:ts,thematicBreak:ns}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:s},f={buffer:I,encode:v,getData:k,lineEndingIfNeeded:E,options:t,raw:S,resume:b,setData:g,tag:x};let c=t.defaultLineEnding;return d;function d(C){let T=-1,X=0;const me=[];let ve=[],Ae=[];for(;++T<C.length;)!c&&(C[T][1].type===\"lineEnding\"||C[T][1].type===\"lineEndingBlank\")&&(c=C[T][2].sliceSerialize(C[T][1])),(C[T][1].type===\"listOrdered\"||C[T][1].type===\"listUnordered\")&&(C[T][0]===\"enter\"?me.push(T):h(C.slice(me.pop(),T))),C[T][1].type===\"definition\"&&(C[T][0]===\"enter\"?(Ae=ee(Ae,C.slice(X,T)),X=T):(ve=ee(ve,C.slice(X,T+1)),X=T+1));ve=ee(ve,Ae),ve=ee(ve,C.slice(X)),T=-1;const xe=ve;for(u.enter.null&&u.enter.null.call(f);++T<C.length;){const dr=u[xe[T][0]],pr=xe[T][1].type,mr=dr[pr];ii.call(dr,pr)&&mr&&mr.call({sliceSerialize:xe[T][2].sliceSerialize,...f},xe[T][1])}return u.exit.null&&u.exit.null.call(f),i[0].join(\"\")}function h(C){const T=C.length;let X=0,me=0,ve=!1,Ae;for(;++X<T;){const xe=C[X];if(xe[1]._container)Ae=void 0,xe[0]===\"enter\"?me++:me--;else switch(xe[1].type){case\"listItemPrefix\":{xe[0]===\"exit\"&&(Ae=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{xe[0]===\"enter\"&&!me&&(Ae?Ae=void 0:ve=!0);break}default:Ae=void 0}}C[0][1]._loose=ve}function g(C,T){l[C]=T}function k(C){return l[C]}function I(){i.push([])}function b(){return i.pop().join(\"\")}function x(C){n&&(g(\"lastWasTag\",!0),i[i.length-1].push(C))}function S(C){g(\"lastWasTag\"),i[i.length-1].push(C)}function D(){S(c||`\n`)}function E(){const C=i[i.length-1],T=C[C.length-1],X=T?T.charCodeAt(T.length-1):null;X===10||X===13||X===null||D()}function v(C){return k(\"ignoreEncode\")?C:va(C)}function z(){b()}function F(C){s.push(!C._loose),E(),x(\"<ol\"),g(\"expectFirstItem\",!0)}function M(C){s.push(!C._loose),E(),x(\"<ul\"),g(\"expectFirstItem\",!0)}function y(C){if(k(\"expectFirstItem\")){const T=Number.parseInt(this.sliceSerialize(C),10);T!==1&&x(' start=\"'+v(String(T))+'\"')}}function P(){k(\"expectFirstItem\")?x(\">\"):H(),E(),x(\"<li>\"),g(\"expectFirstItem\"),g(\"lastWasTag\")}function $(){H(),s.pop(),D(),x(\"</ol>\")}function V(){H(),s.pop(),D(),x(\"</ul>\")}function H(){k(\"lastWasTag\")&&!k(\"slurpAllLineEndings\")&&E(),x(\"</li>\"),g(\"slurpAllLineEndings\")}function R(){s.push(!1),E(),x(\"<blockquote>\")}function J(){s.pop(),E(),x(\"</blockquote>\"),g(\"slurpAllLineEndings\")}function Z(){s[s.length-1]||(E(),x(\"<p>\")),g(\"slurpAllLineEndings\")}function se(){s[s.length-1]?g(\"slurpAllLineEndings\",!0):x(\"</p>\")}function pe(){E(),x(\"<pre><code\"),g(\"fencesCount\",0)}function m(){const C=b();x(' class=\"language-'+C+'\"')}function oe(){const C=k(\"fencesCount\")||0;C||(x(\">\"),g(\"slurpOneLineEnding\",!0)),g(\"fencesCount\",C+1)}function A(){E(),x(\"<pre><code>\")}function p(){const C=k(\"fencesCount\");C!==void 0&&C<2&&l.tightStack.length>0&&!k(\"lastWasTag\")&&D(),k(\"flowCodeSeenData\")&&E(),x(\"</code></pre>\"),C!==void 0&&C<2&&E(),g(\"flowCodeSeenData\"),g(\"fencesCount\"),g(\"slurpOneLineEnding\")}function j(){a.push({image:!0}),n=void 0}function U(){a.push({})}function q(C){a[a.length-1].labelId=this.sliceSerialize(C)}function rt(){a[a.length-1].label=b()}function Te(C){a[a.length-1].referenceId=this.sliceSerialize(C)}function Ue(){I(),a[a.length-1].destination=\"\"}function We(){I(),g(\"ignoreEncode\",!0)}function un(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function Da(){a[a.length-1].title=b()}function lr(){let C=a.length-1;const T=a[C],X=T.referenceId||T.labelId,me=T.destination===void 0?r[pt(X)]:T;for(n=!0;C--;)if(a[C].image){n=void 0;break}T.image?(x('<img src=\"'+It(me.destination,t.allowDangerousProtocol?void 0:Pu)+'\" alt=\"'),S(T.label),x('\"')):x('<a href=\"'+It(me.destination,t.allowDangerousProtocol?void 0:ai)+'\"'),x(me.title?' title=\"'+me.title+'\"':\"\"),T.image?x(\" />\"):(x(\">\"),S(T.label),x(\"</a>\")),a.pop()}function Fa(){I(),a.push({})}function za(C){b(),a[a.length-1].labelId=this.sliceSerialize(C)}function Oa(){I(),g(\"ignoreEncode\",!0)}function Ra(){a[a.length-1].destination=b(),g(\"ignoreEncode\")}function La(){a[a.length-1].title=b()}function Ma(){const C=a[a.length-1],T=pt(C.labelId);b(),ii.call(r,T)||(r[T]=a[a.length-1]),a.pop()}function Ba(){g(\"slurpAllLineEndings\",!0)}function Va(C){k(\"headingRank\")||(g(\"headingRank\",this.sliceSerialize(C).length),E(),x(\"<h\"+k(\"headingRank\")+\">\"))}function Ha(){I(),g(\"slurpAllLineEndings\")}function ja(){g(\"slurpAllLineEndings\",!0)}function qa(){x(\"</h\"+k(\"headingRank\")+\">\"),g(\"headingRank\")}function Ua(C){g(\"headingRank\",this.sliceSerialize(C).charCodeAt(0)===61?1:2)}function Wa(){const C=b();E(),x(\"<h\"+k(\"headingRank\")+\">\"),S(C),x(\"</h\"+k(\"headingRank\")+\">\"),g(\"slurpAllLineEndings\"),g(\"headingRank\")}function it(C){S(v(this.sliceSerialize(C)))}function Qa(C){if(!k(\"slurpAllLineEndings\")){if(k(\"slurpOneLineEnding\")){g(\"slurpOneLineEnding\");return}if(k(\"inCodeText\")){S(\" \");return}S(v(this.sliceSerialize(C)))}}function Ga(C){S(v(this.sliceSerialize(C))),g(\"flowCodeSeenData\",!0)}function ur(){x(\"<br />\")}function Ka(){E(),fr()}function cr(){g(\"ignoreEncode\")}function fr(){t.allowDangerousHtml&&g(\"ignoreEncode\",!0)}function Ya(){x(\"<em>\")}function Za(){x(\"<strong>\")}function Ja(){g(\"inCodeText\",!0),x(\"<code>\")}function Xa(){g(\"inCodeText\"),x(\"</code>\")}function es(){x(\"</em>\")}function ts(){x(\"</strong>\")}function ns(){E(),x(\"<hr />\")}function hr(C){g(\"characterReferenceType\",C.type)}function rs(C){const T=this.sliceSerialize(C),X=k(\"characterReferenceType\")?xu(T,k(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):ba(T);S(v(X)),g(\"characterReferenceType\")}function is(C){const T=this.sliceSerialize(C);x('<a href=\"'+It(T,t.allowDangerousProtocol?void 0:ai)+'\">'),S(v(T)),x(\"</a>\")}function as(C){const T=this.sliceSerialize(C);x('<a href=\"'+It(\"mailto:\"+T)+'\">'),S(v(T)),x(\"</a>\")}}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return s;function s(u){return L(u)?(e.enter(n),o(u)):t(u)}function o(u){return L(u)&&a++<i?(e.consume(u),o):(e.exit(n),t(u))}}const Tu={tokenize:Nu};function Nu(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}function i(o){return e.enter(\"paragraph\"),a(o)}function a(o){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,s(o)}function s(o){if(o===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(o);return}return N(o)?(e.consume(o),e.exit(\"chunkText\"),a):(e.consume(o),s)}}const Du={tokenize:Fu},si={tokenize:zu};function Fu(e){const t=this,n=[];let r=0,i,a,s;return o;function o(S){if(r<n.length){const D=n[r];return t.containerState=D[1],e.attempt(D[0].continuation,u,l)(S)}return l(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const D=t.events.length;let E=D,v;for(;E--;)if(t.events[E][0]===\"exit\"&&t.events[E][1].type===\"chunkFlow\"){v=t.events[E][1].end;break}b(r);let z=D;for(;z<t.events.length;)t.events[z][1].end={...v},z++;return ce(t.events,E+1,0,t.events.slice(D)),t.events.length=z,l(S)}return o(S)}function l(S){if(r===n.length){if(!i)return d(S);if(i.currentConstruct&&i.currentConstruct.concrete)return g(S);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(si,f,c)(S)}function f(S){return i&&x(),b(r),d(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,g(S)}function d(S){return t.containerState={},e.attempt(si,h,g)(S)}function h(S){return r++,n.push([t.currentConstruct,t.containerState]),d(S)}function g(S){if(S===null){i&&x(),b(0),e.consume(S);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),k(S)}function k(S){if(S===null){I(e.exit(\"chunkFlow\"),!0),b(0),e.consume(S);return}return N(S)?(e.consume(S),I(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,o):(e.consume(S),k)}function I(S,D){const E=t.sliceStream(S);if(D&&E.push(null),S.previous=a,a&&(a.next=S),a=S,i.defineSkip(S.start),i.write(E),t.parser.lazy[S.start.line]){let v=i.events.length;for(;v--;)if(i.events[v][1].start.offset<s&&(!i.events[v][1].end||i.events[v][1].end.offset>s))return;const z=t.events.length;let F=z,M,y;for(;F--;)if(t.events[F][0]===\"exit\"&&t.events[F][1].type===\"chunkFlow\"){if(M){y=t.events[F][1].end;break}M=!0}for(b(r),v=z;v<t.events.length;)t.events[v][1].end={...y},v++;ce(t.events,F+1,0,t.events.slice(z)),t.events.length=v}}function b(S){let D=n.length;for(;D-- >S;){const E=n[D];t.containerState=E[1],E[0].exit.call(t,e)}n.length=S}function x(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function zu(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function Gt(e){if(e===null||te(e)||Au(e))return 1;if(Iu(e))return 2}function on(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Un={name:\"attention\",resolveAll:Ou,tokenize:Ru};function Ou(e,t){let n=-1,r,i,a,s,o,u,l,f;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},d={...e[n][1].start};oi(c,-u),oi(d,u),s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:d},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...s.start},end:{...o.end}},e[r][1].end={...s.start},e[n][1].start={...o.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ee(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ee(l,[[\"enter\",i,t],[\"enter\",s,t],[\"exit\",s,t],[\"enter\",a,t]]),l=ee(l,on(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ee(l,[[\"exit\",a,t],[\"enter\",o,t],[\"exit\",o,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,l=ee(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):f=0,ce(e,r-1,n-r+3,l),n=r+l.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function Ru(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Gt(r);let a;return s;function s(u){return a=u,e.enter(\"attentionSequence\"),o(u)}function o(u){if(u===a)return e.consume(u),o;const l=e.exit(\"attentionSequence\"),f=Gt(u),c=!f||f===2&&i||n.includes(u),d=!i||i===2&&f||n.includes(r);return l._open=!!(a===42?c:c&&(i||!d)),l._close=!!(a===42?d:d&&(f||!c)),t(u)}}function oi(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Lu={name:\"autolink\",tokenize:Mu};function Mu(e,t,n){let r=0;return i;function i(h){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(h){return we(h)?(e.consume(h),s):h===64?n(h):l(h)}function s(h){return h===43||h===45||h===46||ue(h)?(r=1,o(h)):l(h)}function o(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||ue(h))&&r++<32?(e.consume(h),o):(r=0,l(h))}function u(h){return h===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h===null||h===32||h===60||jn(h)?n(h):(e.consume(h),u)}function l(h){return h===64?(e.consume(h),f):Su(h)?(e.consume(h),l):n(h)}function f(h){return ue(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(h),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):d(h)}function d(h){if((h===45||ue(h))&&r++<63){const g=h===45?d:c;return e.consume(h),g}return n(h)}}const ln={partial:!0,tokenize:Bu};function Bu(e,t,n){return r;function r(a){return L(a)?B(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||N(a)?t(a):n(a)}}const xa={continuation:{tokenize:Hu},exit:ju,name:\"blockQuote\",tokenize:Vu};function Vu(e,t,n){const r=this;return i;function i(s){if(s===62){const o=r.containerState;return o.open||(e.enter(\"blockQuote\",{_container:!0}),o.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(s),e.exit(\"blockQuoteMarker\"),a}return n(s)}function a(s){return L(s)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(s),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(s))}}function Hu(e,t,n){const r=this;return i;function i(s){return L(s)?B(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s):a(s)}function a(s){return e.attempt(xa,t,n)(s)}}function ju(e){e.exit(\"blockQuote\")}const wa={name:\"characterEscape\",tokenize:qu};function qu(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return Cu(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Sa={name:\"characterReference\",tokenize:Uu};function Uu(e,t,n){const r=this;let i=0,a,s;return o;function o(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,s=ue,f(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,s=ku,f):(e.enter(\"characterReferenceValue\"),a=7,s=qn,f(c))}function f(c){if(c===59&&i){const d=e.exit(\"characterReferenceValue\");return s===ue&&!ba(r.sliceSerialize(d))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return s(c)&&i++<a?(e.consume(c),f):n(c)}}const li={partial:!0,tokenize:Qu},ui={concrete:!0,name:\"codeFenced\",tokenize:Wu};function Wu(e,t,n){const r=this,i={partial:!0,tokenize:E};let a=0,s=0,o;return u;function u(v){return l(v)}function l(v){const z=r.events[r.events.length-1];return a=z&&z[1].type===\"linePrefix\"?z[2].sliceSerialize(z[1],!0).length:0,o=v,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),f(v)}function f(v){return v===o?(s++,e.consume(v),f):s<3?n(v):(e.exit(\"codeFencedFenceSequence\"),L(v)?B(e,c,\"whitespace\")(v):c(v))}function c(v){return v===null||N(v)?(e.exit(\"codeFencedFence\"),r.interrupt?t(v):e.check(li,k,D)(v)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),d(v))}function d(v){return v===null||N(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(v)):L(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),B(e,h,\"whitespace\")(v)):v===96&&v===o?n(v):(e.consume(v),d)}function h(v){return v===null||N(v)?c(v):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),g(v))}function g(v){return v===null||N(v)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(v)):v===96&&v===o?n(v):(e.consume(v),g)}function k(v){return e.attempt(i,D,I)(v)}function I(v){return e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),b}function b(v){return a>0&&L(v)?B(e,x,\"linePrefix\",a+1)(v):x(v)}function x(v){return v===null||N(v)?e.check(li,k,D)(v):(e.enter(\"codeFlowValue\"),S(v))}function S(v){return v===null||N(v)?(e.exit(\"codeFlowValue\"),x(v)):(e.consume(v),S)}function D(v){return e.exit(\"codeFenced\"),t(v)}function E(v,z,F){let M=0;return y;function y(R){return v.enter(\"lineEnding\"),v.consume(R),v.exit(\"lineEnding\"),P}function P(R){return v.enter(\"codeFencedFence\"),L(R)?B(v,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(R):$(R)}function $(R){return R===o?(v.enter(\"codeFencedFenceSequence\"),V(R)):F(R)}function V(R){return R===o?(M++,v.consume(R),V):M>=s?(v.exit(\"codeFencedFenceSequence\"),L(R)?B(v,H,\"whitespace\")(R):H(R)):F(R)}function H(R){return R===null||N(R)?(v.exit(\"codeFencedFence\"),z(R)):F(R)}}}function Qu(e,t,n){const r=this;return i;function i(s){return s===null?n(s):(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}const gn={name:\"codeIndented\",tokenize:Ku},Gu={partial:!0,tokenize:Yu};function Ku(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),B(e,a,\"linePrefix\",5)(l)}function a(l){const f=r.events[r.events.length-1];return f&&f[1].type===\"linePrefix\"&&f[2].sliceSerialize(f[1],!0).length>=4?s(l):n(l)}function s(l){return l===null?u(l):N(l)?e.attempt(Gu,s,u)(l):(e.enter(\"codeFlowValue\"),o(l))}function o(l){return l===null||N(l)?(e.exit(\"codeFlowValue\"),s(l)):(e.consume(l),o)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function Yu(e,t,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):N(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),i):B(e,a,\"linePrefix\",5)(s)}function a(s){const o=r.events[r.events.length-1];return o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):N(s)?i(s):n(s)}}const Zu={name:\"codeText\",previous:Xu,resolve:Ju,tokenize:ec};function Ju(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 Xu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function ec(e,t,n){let r=0,i,a;return s;function s(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),o(c)}function o(c){return c===96?(e.consume(c),r++,o):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,f(c)):N(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||N(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class tc{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&st(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),st(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),st(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);st(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);st(this.left,n.reverse())}}}function st(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ka(e){const t={};let n=-1,r,i,a,s,o,u,l;const f=new tc(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type===\"chunkFlow\"&&f.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,nc(f,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(s=f.get(a),s[1].type===\"lineEnding\"||s[1].type===\"lineEndingBlank\")s[0]===\"enter\"&&(i&&(f.get(i)[1].type=\"lineEndingBlank\"),s[1].type=\"lineEnding\",i=a);else if(!(s[1].type===\"linePrefix\"||s[1].type===\"listItemIndent\"))break;i&&(r[1].end={...f.get(i)[1].start},o=f.slice(i,n),o.unshift(r),f.splice(i,n-i+1,o))}}return ce(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!l}function nc(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const o=s.events,u=[],l={};let f,c,d=-1,h=n,g=0,k=0;const I=[k];for(;h;){for(;e.get(++i)[1]!==h;);a.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(f),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++d<o.length;)o[d][0]===\"exit\"&&o[d-1][0]===\"enter\"&&o[d][1].type===o[d-1][1].type&&o[d][1].start.line!==o[d][1].end.line&&(k=d+1,I.push(k),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):I.pop(),d=I.length;d--;){const b=o.slice(I[d],I[d+1]),x=a.pop();u.push([x,x+b.length-1]),e.splice(x,2,b)}for(u.reverse(),d=-1;++d<u.length;)l[g+u[d][0]]=g+u[d][1],g+=u[d][1]-u[d][0]-1;return l}const rc={resolve:ac,tokenize:sc},ic={partial:!0,tokenize:oc};function ac(e){return ka(e),e}function sc(e,t){let n;return r;function r(o){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(o)}function i(o){return o===null?a(o):N(o)?e.check(ic,s,a)(o):(e.consume(o),i)}function a(o){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(o)}function s(o){return e.consume(o),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function oc(e,t,n){const r=this;return i;function i(s){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),B(e,a,\"linePrefix\")}function a(s){if(s===null||N(s))return n(s);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&o&&o[1].type===\"linePrefix\"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function Ca(e,t,n,r,i,a,s,o,u){const l=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),d):b===null||b===32||b===41||jn(b)?n(b):(e.enter(r),e.enter(s),e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),k(b))}function d(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(o),e.enter(\"chunkString\",{contentType:\"string\"}),h(b))}function h(b){return b===62?(e.exit(\"chunkString\"),e.exit(o),d(b)):b===null||b===60||N(b)?n(b):(e.consume(b),b===92?g:h)}function g(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function k(b){return!f&&(b===null||b===41||te(b))?(e.exit(\"chunkString\"),e.exit(o),e.exit(s),e.exit(r),t(b)):f<l&&b===40?(e.consume(b),f++,k):b===41?(e.consume(b),f--,k):b===null||b===32||b===40||jn(b)?n(b):(e.consume(b),b===92?I:k)}function I(b){return b===40||b===41||b===92?(e.consume(b),k):k(b)}}function Ia(e,t,n,r,i,a){const s=this;let o=0,u;return l;function l(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(a),f}function f(h){return o>999||h===null||h===91||h===93&&!u||h===94&&!o&&\"_hiddenFootnoteSupport\"in s.parser.constructs?n(h):h===93?(e.exit(a),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):N(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),f):(e.enter(\"chunkString\",{contentType:\"string\"}),c(h))}function c(h){return h===null||h===91||h===93||N(h)||o++>999?(e.exit(\"chunkString\"),f(h)):(e.consume(h),u||(u=!L(h)),h===92?d:c)}function d(h){return h===91||h===92||h===93?(e.consume(h),o++,c):c(h)}}function Aa(e,t,n,r,i,a){let s;return o;function o(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),s=d===40?41:d,u):n(d)}function u(d){return d===s?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(a),l(d))}function l(d){return d===s?(e.exit(a),u(s)):d===null?n(d):N(d)?(e.enter(\"lineEnding\"),e.consume(d),e.exit(\"lineEnding\"),B(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),f(d))}function f(d){return d===s||d===null||N(d)?(e.exit(\"chunkString\"),l(d)):(e.consume(d),d===92?c:f)}function c(d){return d===s||d===92?(e.consume(d),f):f(d)}}function ut(e,t){let n;return r;function r(i){return N(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?B(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const lc={name:\"definition\",tokenize:cc},uc={partial:!0,tokenize:fc};function cc(e,t,n){const r=this;let i;return a;function a(h){return e.enter(\"definition\"),s(h)}function s(h){return Ia.call(r,e,o,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(h)}function o(h){return i=pt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter(\"definitionMarker\"),e.consume(h),e.exit(\"definitionMarker\"),u):n(h)}function u(h){return te(h)?ut(e,l)(h):l(h)}function l(h){return Ca(e,f,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(h)}function f(h){return e.attempt(uc,c,c)(h)}function c(h){return L(h)?B(e,d,\"whitespace\")(h):d(h)}function d(h){return h===null||N(h)?(e.exit(\"definition\"),r.parser.defined.push(i),t(h)):n(h)}}function fc(e,t,n){return r;function r(o){return te(o)?ut(e,i)(o):n(o)}function i(o){return Aa(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(o)}function a(o){return L(o)?B(e,s,\"whitespace\")(o):s(o)}function s(o){return o===null||N(o)?t(o):n(o)}}const hc={name:\"hardBreakEscape\",tokenize:dc};function dc(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return N(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const pc={name:\"headingAtx\",resolve:mc,tokenize:gc};function mc(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},ce(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function gc(e,t,n){let r=0;return i;function i(f){return e.enter(\"atxHeading\"),a(f)}function a(f){return e.enter(\"atxHeadingSequence\"),s(f)}function s(f){return f===35&&r++<6?(e.consume(f),s):f===null||te(f)?(e.exit(\"atxHeadingSequence\"),o(f)):n(f)}function o(f){return f===35?(e.enter(\"atxHeadingSequence\"),u(f)):f===null||N(f)?(e.exit(\"atxHeading\"),t(f)):L(f)?B(e,o,\"whitespace\")(f):(e.enter(\"atxHeadingText\"),l(f))}function u(f){return f===35?(e.consume(f),u):(e.exit(\"atxHeadingSequence\"),o(f))}function l(f){return f===null||f===35||te(f)?(e.exit(\"atxHeadingText\"),o(f)):(e.consume(f),l)}}const _c=[\"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\"],ci=[\"pre\",\"script\",\"style\",\"textarea\"],yc={concrete:!0,name:\"htmlFlow\",resolveTo:xc,tokenize:wc},bc={partial:!0,tokenize:kc},vc={partial:!0,tokenize:Sc};function xc(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 wc(e,t,n){const r=this;let i,a,s,o,u;return l;function l(p){return f(p)}function f(p){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(p),c}function c(p){return p===33?(e.consume(p),d):p===47?(e.consume(p),a=!0,k):p===63?(e.consume(p),i=3,r.interrupt?t:m):we(p)?(e.consume(p),s=String.fromCharCode(p),I):n(p)}function d(p){return p===45?(e.consume(p),i=2,h):p===91?(e.consume(p),i=5,o=0,g):we(p)?(e.consume(p),i=4,r.interrupt?t:m):n(p)}function h(p){return p===45?(e.consume(p),r.interrupt?t:m):n(p)}function g(p){const j=\"CDATA[\";return p===j.charCodeAt(o++)?(e.consume(p),o===j.length?r.interrupt?t:$:g):n(p)}function k(p){return we(p)?(e.consume(p),s=String.fromCharCode(p),I):n(p)}function I(p){if(p===null||p===47||p===62||te(p)){const j=p===47,U=s.toLowerCase();return!j&&!a&&ci.includes(U)?(i=1,r.interrupt?t(p):$(p)):_c.includes(s.toLowerCase())?(i=6,j?(e.consume(p),b):r.interrupt?t(p):$(p)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(p):a?x(p):S(p))}return p===45||ue(p)?(e.consume(p),s+=String.fromCharCode(p),I):n(p)}function b(p){return p===62?(e.consume(p),r.interrupt?t:$):n(p)}function x(p){return L(p)?(e.consume(p),x):y(p)}function S(p){return p===47?(e.consume(p),y):p===58||p===95||we(p)?(e.consume(p),D):L(p)?(e.consume(p),S):y(p)}function D(p){return p===45||p===46||p===58||p===95||ue(p)?(e.consume(p),D):E(p)}function E(p){return p===61?(e.consume(p),v):L(p)?(e.consume(p),E):S(p)}function v(p){return p===null||p===60||p===61||p===62||p===96?n(p):p===34||p===39?(e.consume(p),u=p,z):L(p)?(e.consume(p),v):F(p)}function z(p){return p===u?(e.consume(p),u=null,M):p===null||N(p)?n(p):(e.consume(p),z)}function F(p){return p===null||p===34||p===39||p===47||p===60||p===61||p===62||p===96||te(p)?E(p):(e.consume(p),F)}function M(p){return p===47||p===62||L(p)?S(p):n(p)}function y(p){return p===62?(e.consume(p),P):n(p)}function P(p){return p===null||N(p)?$(p):L(p)?(e.consume(p),P):n(p)}function $(p){return p===45&&i===2?(e.consume(p),J):p===60&&i===1?(e.consume(p),Z):p===62&&i===4?(e.consume(p),oe):p===63&&i===3?(e.consume(p),m):p===93&&i===5?(e.consume(p),pe):N(p)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(bc,A,V)(p)):p===null||N(p)?(e.exit(\"htmlFlowData\"),V(p)):(e.consume(p),$)}function V(p){return e.check(vc,H,A)(p)}function H(p){return e.enter(\"lineEnding\"),e.consume(p),e.exit(\"lineEnding\"),R}function R(p){return p===null||N(p)?V(p):(e.enter(\"htmlFlowData\"),$(p))}function J(p){return p===45?(e.consume(p),m):$(p)}function Z(p){return p===47?(e.consume(p),s=\"\",se):$(p)}function se(p){if(p===62){const j=s.toLowerCase();return ci.includes(j)?(e.consume(p),oe):$(p)}return we(p)&&s.length<8?(e.consume(p),s+=String.fromCharCode(p),se):$(p)}function pe(p){return p===93?(e.consume(p),m):$(p)}function m(p){return p===62?(e.consume(p),oe):p===45&&i===2?(e.consume(p),m):$(p)}function oe(p){return p===null||N(p)?(e.exit(\"htmlFlowData\"),A(p)):(e.consume(p),oe)}function A(p){return e.exit(\"htmlFlow\"),t(p)}}function Sc(e,t,n){const r=this;return i;function i(s){return N(s)?(e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),a):n(s)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function kc(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(ln,t,n)}}const Cc={name:\"htmlText\",tokenize:Ic};function Ic(e,t,n){const r=this;let i,a,s;return o;function o(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),E):m===63?(e.consume(m),S):we(m)?(e.consume(m),F):n(m)}function l(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),a=0,g):we(m)?(e.consume(m),x):n(m)}function f(m){return m===45?(e.consume(m),h):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),d):N(m)?(s=c,Z(m)):(e.consume(m),c)}function d(m){return m===45?(e.consume(m),h):c(m)}function h(m){return m===62?J(m):m===45?d(m):c(m)}function g(m){const oe=\"CDATA[\";return m===oe.charCodeAt(a++)?(e.consume(m),a===oe.length?k:g):n(m)}function k(m){return m===null?n(m):m===93?(e.consume(m),I):N(m)?(s=k,Z(m)):(e.consume(m),k)}function I(m){return m===93?(e.consume(m),b):k(m)}function b(m){return m===62?J(m):m===93?(e.consume(m),b):k(m)}function x(m){return m===null||m===62?J(m):N(m)?(s=x,Z(m)):(e.consume(m),x)}function S(m){return m===null?n(m):m===63?(e.consume(m),D):N(m)?(s=S,Z(m)):(e.consume(m),S)}function D(m){return m===62?J(m):S(m)}function E(m){return we(m)?(e.consume(m),v):n(m)}function v(m){return m===45||ue(m)?(e.consume(m),v):z(m)}function z(m){return N(m)?(s=z,Z(m)):L(m)?(e.consume(m),z):J(m)}function F(m){return m===45||ue(m)?(e.consume(m),F):m===47||m===62||te(m)?M(m):n(m)}function M(m){return m===47?(e.consume(m),J):m===58||m===95||we(m)?(e.consume(m),y):N(m)?(s=M,Z(m)):L(m)?(e.consume(m),M):J(m)}function y(m){return m===45||m===46||m===58||m===95||ue(m)?(e.consume(m),y):P(m)}function P(m){return m===61?(e.consume(m),$):N(m)?(s=P,Z(m)):L(m)?(e.consume(m),P):M(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,V):N(m)?(s=$,Z(m)):L(m)?(e.consume(m),$):(e.consume(m),H)}function V(m){return m===i?(e.consume(m),i=void 0,R):m===null?n(m):N(m)?(s=V,Z(m)):(e.consume(m),V)}function H(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||te(m)?M(m):(e.consume(m),H)}function R(m){return m===47||m===62||te(m)?M(m):n(m)}function J(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function Z(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),se}function se(m){return L(m)?B(e,pe,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):pe(m)}function pe(m){return e.enter(\"htmlTextData\"),s(m)}}const or={name:\"labelEnd\",resolveAll:$c,resolveTo:Tc,tokenize:Nc},Ac={tokenize:Dc},Ec={tokenize:Fc},Pc={tokenize:zc};function $c(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&&ce(e,0,e.length,n),e}function Tc(e,t){let n=e.length,r=0,i,a,s,o;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(s){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(s=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[s][1].end}},f={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[s-2][1].start}};return o=[[\"enter\",u,t],[\"enter\",l,t]],o=ee(o,e.slice(a+1,a+r+3)),o=ee(o,[[\"enter\",f,t]]),o=ee(o,on(t.parser.constructs.insideSpan.null,e.slice(a+r+4,s-3),t)),o=ee(o,[[\"exit\",f,t],e[s-2],e[s-1],[\"exit\",l,t]]),o=ee(o,e.slice(s+1)),o=ee(o,[[\"exit\",u,t]]),ce(e,a,e.length,o),e}function Nc(e,t,n){const r=this;let i=r.events.length,a,s;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return o;function o(d){return a?a._inactive?c(d):(s=r.parser.defined.includes(pt(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(d),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(d)}function u(d){return d===40?e.attempt(Ac,f,s?f:c)(d):d===91?e.attempt(Ec,f,s?l:c)(d):s?f(d):c(d)}function l(d){return e.attempt(Pc,f,c)(d)}function f(d){return t(d)}function c(d){return a._balanced=!0,n(d)}}function Dc(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return te(c)?ut(e,a)(c):a(c)}function a(c){return c===41?f(c):Ca(e,s,o,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function s(c){return te(c)?ut(e,u)(c):f(c)}function o(c){return n(c)}function u(c){return c===34||c===39||c===40?Aa(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):f(c)}function l(c){return te(c)?ut(e,f)(c):f(c)}function f(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Fc(e,t,n){const r=this;return i;function i(o){return Ia.call(r,e,a,s,\"reference\",\"referenceMarker\",\"referenceString\")(o)}function a(o){return r.parser.defined.includes(pt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function s(o){return n(o)}}function zc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const Oc={name:\"labelStartImage\",resolveAll:or.resolveAll,tokenize:Rc};function Rc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(o),e.exit(\"labelImageMarker\"),a}function a(o){return o===91?(e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),s):n(o)}function s(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Lc={name:\"labelStartLink\",resolveAll:or.resolveAll,tokenize:Mc};function Mc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const _n={name:\"lineEnding\",tokenize:Bc};function Bc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),B(e,t,\"linePrefix\")}}const Ft={name:\"thematicBreak\",tokenize:Vc};function Vc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),s(l)}function s(l){return i=l,o(l)}function o(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||N(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?B(e,o,\"whitespace\")(l):o(l))}}const ae={continuation:{tokenize:Uc},exit:Qc,name:\"list\",tokenize:qc},Hc={partial:!0,tokenize:Gc},jc={partial:!0,tokenize:Wc};function qc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return o;function o(h){const g=r.containerState.type||(h===42||h===43||h===45?\"listUnordered\":\"listOrdered\");if(g===\"listUnordered\"?!r.containerState.marker||h===r.containerState.marker:qn(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g===\"listUnordered\")return e.enter(\"listItemPrefix\"),h===42||h===45?e.check(Ft,n,l)(h):l(h);if(!r.interrupt||h===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(h)}return n(h)}function u(h){return qn(h)&&++s<10?(e.consume(h),u):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit(\"listItemValue\"),l(h)):n(h)}function l(h){return e.enter(\"listItemMarker\"),e.consume(h),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||h,e.check(ln,r.interrupt?n:f,e.attempt(Hc,d,c))}function f(h){return r.containerState.initialBlankLine=!0,a++,d(h)}function c(h){return L(h)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(h),e.exit(\"listItemPrefixWhitespace\"),d):n(h)}function d(h){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(h)}}function Uc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ln,i,a);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,\"listItemIndent\",r.containerState.size+1)(o)}function a(o){return r.containerState.furtherBlankLines||!L(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(jc,t,s)(o))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(ae,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o)}}function Wc(e,t,n){const r=this;return B(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const s=r.events[r.events.length-1];return s&&s[1].type===\"listItemIndent\"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(a):n(a)}}function Qc(e){e.exit(this.containerState.type)}function Gc(e,t,n){const r=this;return B(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const s=r.events[r.events.length-1];return!L(a)&&s&&s[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const fi={name:\"setextUnderline\",resolveTo:Kc,tokenize:Yc};function Kc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const s={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",s,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=s,e.push([\"exit\",s,t]),e}function Yc(e,t,n){const r=this;let i;return a;function a(l){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!==\"lineEnding\"&&r.events[f][1].type!==\"linePrefix\"&&r.events[f][1].type!==\"content\"){c=r.events[f][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,s(l)):n(l)}function s(l){return e.enter(\"setextHeadingLineSequence\"),o(l)}function o(l){return l===i?(e.consume(l),o):(e.exit(\"setextHeadingLineSequence\"),L(l)?B(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||N(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const Zc={tokenize:Jc};function Jc(e){const t=this,n=e.attempt(ln,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(rc,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const Xc={resolveAll:Pa()},ef=Ea(\"string\"),tf=Ea(\"text\");function Ea(e){return{resolveAll:Pa(e===\"text\"?nf:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,s,o);return s;function s(f){return l(f)?a(f):o(f)}function o(f){if(f===null){n.consume(f);return}return n.enter(\"data\"),n.consume(f),u}function u(f){return l(f)?(n.exit(\"data\"),a(f)):(n.consume(f),u)}function l(f){if(f===null)return!0;const c=i[f];let d=-1;if(c)for(;++d<c.length;){const h=c[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Pa(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function nf(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,s=-1,o=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(s=l.length;l.charCodeAt(s-1)===32;)o++,s--;if(s)break;s=-1}else if(l===-2)u=!0,o++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const l={type:n===e.length||u||o<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?s:r.start._bufferIndex+s,_index:r.start._index+a,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},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 rf={42:ae,43:ae,45:ae,48:ae,49:ae,50:ae,51:ae,52:ae,53:ae,54:ae,55:ae,56:ae,57:ae,62:xa},af={91:lc},sf={[-2]:gn,[-1]:gn,32:gn},of={35:pc,42:Ft,45:[fi,Ft],60:yc,61:fi,95:Ft,96:ui,126:ui},lf={38:Sa,92:wa},uf={[-5]:_n,[-4]:_n,[-3]:_n,33:Oc,38:Sa,42:Un,60:[Lu,Cc],91:Lc,92:[hc,wa],93:or,95:Un,96:Zu},cf={null:[Un,Xc]},ff={null:[42,95]},hf={null:[]},df=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:ff,contentInitial:af,disable:hf,document:rf,flow:of,flowInitial:sf,insideSpan:cf,string:lf,text:uf},Symbol.toStringTag,{value:\"Module\"}));function pf(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let s=[],o=[];const u={attempt:z(E),check:z(v),consume:x,enter:S,exit:D,interrupt:z(v,{interrupt:!0})},l={code:null,containerState:{},defineSkip:k,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:c};let f=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(P){return s=ee(s,P),I(),s[s.length-1]!==null?[]:(F(t,0),l.events=on(a,l.events,l),l.events)}function d(P,$){return gf(h(P),$)}function h(P){return mf(s,P)}function g(){const{_bufferIndex:P,_index:$,line:V,column:H,offset:R}=r;return{_bufferIndex:P,_index:$,line:V,column:H,offset:R}}function k(P){i[P.line]=P.column,y()}function I(){let P;for(;r._index<s.length;){const $=s[r._index];if(typeof $==\"string\")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(P){f=f(P)}function x(P){N(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,y()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=P}function S(P,$){const V=$||{};return V.type=P,V.start=g(),l.events.push([\"enter\",V,l]),o.push(V),V}function D(P){const $=o.pop();return $.end=g(),l.events.push([\"exit\",$,l]),$}function E(P,$){F(P,$.from)}function v(P,$){$.restore()}function z(P,$){return V;function V(H,R,J){let Z,se,pe,m;return Array.isArray(H)?A(H):\"tokenize\"in H?A([H]):oe(H);function oe(q){return rt;function rt(Te){const Ue=Te!==null&&q[Te],We=Te!==null&&q.null,un=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(We)?We:We?[We]:[]];return A(un)(Te)}}function A(q){return Z=q,se=0,q.length===0?J:p(q[se])}function p(q){return rt;function rt(Te){return m=M(),pe=q,q.partial||(l.currentConstruct=q),q.name&&l.parser.constructs.disable.null.includes(q.name)?U():q.tokenize.call($?Object.assign(Object.create(l),$):l,u,j,U)(Te)}}function j(q){return P(pe,m),R}function U(q){return m.restore(),++se<Z.length?p(Z[se]):J}}}function F(P,$){P.resolveAll&&!a.includes(P)&&a.push(P),P.resolve&&ce(l.events,$,l.events.length-$,P.resolve(l.events.slice($),l)),P.resolveTo&&(l.events=P.resolveTo(l.events,l))}function M(){const P=g(),$=l.previous,V=l.currentConstruct,H=l.events.length,R=Array.from(o);return{from:H,restore:J};function J(){r=P,l.previous=$,l.currentConstruct=V,l.events.length=H,o=R,y()}}function y(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function mf(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let s;if(n===i)s=[e[n].slice(r,a)];else{if(s=e.slice(n,i),r>-1){const o=s[0];typeof o==\"string\"?s[0]=o.slice(r):s.shift()}a>0&&s.push(e[i].slice(0,a))}return s}function gf(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let s;if(typeof a==\"string\")s=a;else switch(a){case-5:{s=\"\\r\";break}case-4:{s=`\n`;break}case-3:{s=`\\r\n`;break}case-2:{s=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;s=\" \";break}default:s=String.fromCharCode(a)}i=a===-2,r.push(s)}return r.join(\"\")}function _f(e){const r={constructs:gu([df,...(e||{}).extensions||[]]),content:i(Tu),defined:[],document:i(Du),flow:i(Zc),lazy:{},string:i(ef),text:i(tf)};return r;function i(a){return s;function s(o){return pf(r,a,o)}}}function yf(e){for(;!ka(e););return e}const hi=/[\\0\\t\\n\\r]/g;function bf(){let e=1,t=\"\",n=!0,r;return i;function i(a,s,o){const u=[];let l,f,c,d,h;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(s||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(hi.lastIndex=c,l=hi.exec(a),d=l&&l.index!==void 0?l.index:a.length,h=a.charCodeAt(d),!l){t=a.slice(c);break}if(h===10&&c===d&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<d&&(u.push(a.slice(c,d)),e+=d-c),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=d+1}return o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function vf(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),$u(n)(yf(_f(n).document().write(bf()(e,t,!0))))}const yn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function xf(){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=yn[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=yn[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,wf)),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\"+yn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function wf(e,t){return t===\"|\"?t:e}class Sf{constructor(){this.map=[]}add(t,n,r){kf(this,t,n,r)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function kf(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 Cf(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function If(){return{flow:{null:{name:\"table\",tokenize:Af,resolveAll:Ef}}}}function Af(e,t,n){const r=this;let i=0,a=0,s;return o;function o(y){let P=r.events.length-1;for(;P>-1;){const H=r.events[P][1].type;if(H===\"lineEnding\"||H===\"linePrefix\")P--;else break}const $=P>-1?r.events[P][1].type:null,V=$===\"tableHead\"||$===\"tableRow\"?v:u;return V===v&&r.parser.lazy[r.now().line]?n(y):V(y)}function u(y){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(y)}function l(y){return y===124||(s=!0,a+=1),f(y)}function f(y){return y===null?n(y):N(y)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),h):n(y):L(y)?B(e,f,\"whitespace\")(y):(a+=1,s&&(s=!1,i+=1),y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),s=!0,f):(e.enter(\"data\"),c(y)))}function c(y){return y===null||y===124||te(y)?(e.exit(\"data\"),f(y)):(e.consume(y),y===92?d:c)}function d(y){return y===92||y===124?(e.consume(y),c):c(y)}function h(y){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(y):(e.enter(\"tableDelimiterRow\"),s=!1,L(y)?B(e,g,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(y):g(y))}function g(y){return y===45||y===58?I(y):y===124?(s=!0,e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),k):E(y)}function k(y){return L(y)?B(e,I,\"whitespace\")(y):I(y)}function I(y){return y===58?(a+=1,s=!0,e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),b):y===45?(a+=1,b(y)):y===null||N(y)?D(y):E(y)}function b(y){return y===45?(e.enter(\"tableDelimiterFiller\"),x(y)):E(y)}function x(y){return y===45?(e.consume(y),x):y===58?(s=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(y),e.exit(\"tableDelimiterMarker\"),S):(e.exit(\"tableDelimiterFiller\"),S(y))}function S(y){return L(y)?B(e,D,\"whitespace\")(y):D(y)}function D(y){return y===124?g(y):y===null||N(y)?!s||i!==a?E(y):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(y)):E(y)}function E(y){return n(y)}function v(y){return e.enter(\"tableRow\"),z(y)}function z(y){return y===124?(e.enter(\"tableCellDivider\"),e.consume(y),e.exit(\"tableCellDivider\"),z):y===null||N(y)?(e.exit(\"tableRow\"),t(y)):L(y)?B(e,z,\"whitespace\")(y):(e.enter(\"data\"),F(y))}function F(y){return y===null||y===124||te(y)?(e.exit(\"data\"),z(y)):(e.consume(y),y===92?M:F)}function M(y){return y===92||y===124?(e.consume(y),F):F(y)}}function Ef(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,u=0,l,f,c;const d=new Sf;for(;++n<e.length;){const h=e[n],g=h[1];h[0]===\"enter\"?g.type===\"tableHead\"?(o=!1,u!==0&&(di(d,t,u,l,f),f=void 0,u=0),l={type:\"table\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",l,t]])):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],s=[0,n+1,0,0],o&&(o=!1,f={type:\"tableBody\",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[[\"enter\",f,t]])),i=g.type===\"tableDelimiterRow\"?2:f?3:1):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],c=At(d,t,a,i,void 0,c),a=[0,0,0,0]),s[2]=n)):g.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],c=At(d,t,a,i,void 0,c)),a=s,s=[a[1],n,0,0])):g.type===\"tableHead\"?(o=!0,u=n):g.type===\"tableRow\"||g.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(s[0]=s[1],c=At(d,t,a,i,n,c)):s[1]!==0&&(c=At(d,t,s,i,n,c)),i=0):i&&(g.type===\"data\"||g.type===\"tableDelimiterMarker\"||g.type===\"tableDelimiterFiller\")&&(s[3]=n)}for(u!==0&&di(d,t,u,l,f),d.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]===\"enter\"&&h[1].type===\"table\"&&(h[1]._align=Cf(t.events,n))}return e}function At(e,t,n,r,i,a){const s=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",o=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},Ge(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=Ge(t.events,n[1]);if(a={type:s,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=Ge(t.events,n[2]),f=Ge(t.events,n[3]),c={type:o,start:Object.assign({},l),end:Object.assign({},f)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const d=t.events[n[2]],h=t.events[n[3]];if(d[1].end=Object.assign({},h[1].end),d[1].type=\"chunkText\",d[1].contentType=\"text\",n[3]>n[2]+1){const g=n[2]+1,k=n[3]-n[2]-1;e.add(g,k,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},Ge(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function di(e,t,n,r,i){const a=[],s=Ge(t.events,n);i&&(i.end=Object.assign({},s),a.push([\"exit\",i,t])),r.end=Object.assign({},s),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function Ge(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Pf(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function $f(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(s,o){let u=-1;for(;++u<s.length;)if(s[u][0]===\"enter\"&&s[u][1].type===\"strikethroughSequenceTemporary\"&&s[u][1]._close){let l=u;for(;l--;)if(s[l][0]===\"exit\"&&s[l][1].type===\"strikethroughSequenceTemporary\"&&s[l][1]._open&&s[u][1].end.offset-s[u][1].start.offset===s[l][1].end.offset-s[l][1].start.offset){s[u][1].type=\"strikethroughSequence\",s[l][1].type=\"strikethroughSequence\";const f={type:\"strikethrough\",start:Object.assign({},s[l][1].start),end:Object.assign({},s[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},s[l][1].end),end:Object.assign({},s[u][1].start)},d=[[\"enter\",f,o],[\"enter\",s[l][1],o],[\"exit\",s[l][1],o],[\"enter\",c,o]],h=o.parser.constructs.insideSpan.null;h&&ce(d,d.length,0,on(h,s.slice(l+1,u),o)),ce(d,d.length,0,[[\"exit\",c,o],[\"enter\",s[u][1],o],[\"exit\",s[u][1],o],[\"exit\",f,o]]),ce(s,l-1,u-l+3,d),u=l+d.length-2;break}}for(u=-1;++u<s.length;)s[u][1].type===\"strikethroughSequenceTemporary\"&&(s[u][1].type=\"data\");return s}function a(s,o,u){const l=this.previous,f=this.events;let c=0;return d;function d(g){return l===126&&f[f.length-1][1].type!==\"characterEscape\"?u(g):(s.enter(\"strikethroughSequenceTemporary\"),h(g))}function h(g){const k=Gt(l);if(g===126)return c>1?u(g):(s.consume(g),c++,h);if(c<2&&!n)return u(g);const I=s.exit(\"strikethroughSequenceTemporary\"),b=Gt(g);return I._open=!b||b===2&&!!k,I._close=!k||k===2&&!!b,o(g)}}}function Tf(e){return vf(e,{allowDangerousHtml:!0,extensions:[If(),$f()],htmlExtensions:[xf(),Pf()]})}const Nf={values:{},update:()=>{}},Ie=Zn(Nf),bn=[];function Df(e,t){const n=document.createElement(\"div\");n.innerHTML=e.trim();const r=Array.from(n.childNodes).map((i,a)=>$a(i,a,t));return _(K,{children:r})}function $a(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.tagName.toLowerCase(),a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const s={key:t};for(const u of Array.from(r.attributes))s[u.name]=u.value;const o=Array.from(r.childNodes).map((u,l)=>$a(u,l,n));return _e(i,s,...o)}return null}function Ff(e,t){switch(e.name){case\"set\":return _(ol,{rawArgs:e.rawArgs},t);case\"computed\":return _(ou,{rawArgs:e.rawArgs},t);case\"print\":return _(ll,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"meter\":return _(fu,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"passage\":return _(du,{className:e.className,id:e.id},t);case\"if\":return _(ul,{branches:e.branches??bn},t);case\"for\":return _(hl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"do\":return _(pl,{children:e.children},t);case\"button\":return _(ml,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"story-title\":return _(gl,{className:e.className,id:e.id},t);case\"back\":return _(yl,{className:e.className,id:e.id},t);case\"forward\":return _(bl,{className:e.className,id:e.id},t);case\"restart\":return _(_l,{className:e.className,id:e.id},t);case\"quicksave\":return _(vl,{className:e.className,id:e.id},t);case\"quickload\":return _(xl,{className:e.className,id:e.id},t);case\"settings\":return _(Cl,{className:e.className,id:e.id},t);case\"saves\":return _($l,{className:e.className,id:e.id},t);case\"include\":return _(Tl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"goto\":return _(Nl,{rawArgs:e.rawArgs},t);case\"unset\":return _(Dl,{rawArgs:e.rawArgs},t);case\"textbox\":return _(zl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"numberbox\":return _(Rl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"textarea\":return _(Ml,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"checkbox\":return _(Vl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"radiobutton\":return _(jl,{rawArgs:e.rawArgs,className:e.className,id:e.id},t);case\"listbox\":return _(ql,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"cycle\":return _(Ul,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"link\":return _(Ql,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"switch\":return _(Gl,{rawArgs:e.rawArgs,branches:e.branches??bn},t);case\"timed\":return _(Kl,{rawArgs:e.rawArgs,children:e.children,branches:e.branches??bn,className:e.className,id:e.id},t);case\"repeat\":return _(Yl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"stop\":return _(Zl,{},t);case\"type\":return _(Jl,{rawArgs:e.rawArgs,children:e.children,className:e.className,id:e.id},t);case\"widget\":return _(tu,{rawArgs:e.rawArgs,children:e.children},t);case\"option\":case\"case\":case\"default\":case\"next\":return null;default:{const n=Xl(e.name);if(n)return _(iu,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=mu(e.name);return r?_(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:fe(e.children)},t):_(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}}}function Wn(e,t){switch(e.type){case\"text\":return e.value;case\"link\":return _(al,{target:e.target,className:e.className,id:e.id,children:e.display},t);case\"variable\":return _(sl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Ff(e,t);case\"html\":return _e(e.tag,{key:t,...e.attributes},e.children.length>0?fe(e.children):void 0);default:return e}}function Ta(e){return e.length===0?null:e.map((t,n)=>Wn(t,n))}function fe(e){if(e.length===0)return null;if(!e.some(a=>a.type===\"text\"))return e.map((a,s)=>Wn(a,s));const n=[];let r=\"\";for(let a=0;a<e.length;a++){const s=e[a];if(s.type===\"text\")r+=s.value;else{const o=n.length;n.push(Wn(s,a)),r+=`<span data-tw=\"${o}\"></span>`}}const i=Tf(r);return Df(i,n)}const zf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Of(){const t=w(r=>r.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:zf;try{const r=yt(n),i=bt(r);return _(K,{children:fe(i)})}catch(r){return _(\"span\",{class:\"error\",children:[\"Error in StoryInterface: \",r.message]})}}function Rf(){const e=w(n=>n.storyData),t=w(n=>n.currentPassage);return Ce(()=>{const n=r=>{r.key===\"F6\"?(r.preventDefault(),w.getState().save()):r.key===\"F9\"&&(r.preventDefault(),w.getState().load())};return document.addEventListener(\"keydown\",n),()=>document.removeEventListener(\"keydown\",n)},[]),!e||!t?_(\"div\",{class:\"loading\",children:\"Loading...\"}):_(Of,{})}function Lf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",o=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",f=new Map,c=new Map;for(const d of e.querySelectorAll(\"tw-passagedata\")){const h=parseInt(d.getAttribute(\"pid\")||\"0\",10),g=d.getAttribute(\"name\")||\"\",k=(d.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(D=>D.length>0),I=d.textContent||\"\",b={},x=new Set([\"pid\",\"name\",\"tags\"]);for(const D of d.attributes)x.has(D.name)||(b[D.name]=D.value);const S={pid:h,name:g,tags:k,metadata:b,content:I};f.set(g,S),c.set(h,S)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:f,passagesById:c,userCSS:o,userScript:l}}function Mf(){return{get(e){return w.getState().variables[e]},set(e,t){const n=w.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){w.getState().navigate(e)},back(){w.getState().goBack()},forward(){w.getState().goForward()},restart(){w.getState().restart()},save(e){w.getState().save(e)},load(e){w.getState().load(e)},hasSave(e){return w.getState().hasSave(e)},visited(e){return w.getState().visitCounts[e]??0},hasVisited(e){return(w.getState().visitCounts[e]??0)>0},hasVisitedAny(...e){const{visitCounts:t}=w.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=w.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){return w.getState().renderCounts[e]??0},hasRendered(e){return(w.getState().renderCounts[e]??0)>0},hasRenderedAny(...e){const{renderCounts:t}=w.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=w.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=w.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=w.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 w.getState().storyData?.name||\"\"},get passage(){return w.getState().currentPassage},settings:dt,registerClass(e,t){Lo(e,t)},saves:{setTitleGenerator(e){Bo(e)}},getActions(){return Xr()},performAction(e,t){const n=nl(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=w.getState().currentPassage;return w.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return il(t);if(e===\"variableChanged\"){let n={...w.getState().variables};return w.subscribe(r=>{const i={};let a=!1;const s=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const o of s)r.variables[o]!==n[o]&&(i[o]={from:n[o],to:r.variables[o]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Xr())})})})},random(){return ir()},randomInt(e,t){return na(e,t)},prng:{init(e,t){ko(e,t);const{historyIndex:n}=w.getState();w.setState(r=>{const i=r.history[n];i&&(i.prng=Dt())})},isEnabled(){return Co()},get seed(){return Io()},get pull(){return Ao()}}}}function Bf(){window.Story=Mf()}const Vf=/^\\$(\\w+)\\s*=\\s*(.+)$/,pi=/\\$(\\w+(?:\\.\\w+)*)/g,mi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Hf=new Set([\"number\",\"string\",\"boolean\"]);function Na(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,Na(i));return{type:\"object\",fields:n}}const t=typeof e;if(!Hf.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function jf(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(Vf);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,s]=i;let o;try{o=new Function(\"return (\"+s+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${s}\": ${l instanceof Error?l.message:l}`)}const u=Na(o);t.set(a,{...u,name:a,default:o})}return t}function qf(e){const t=new Set;let n;for(mi.lastIndex=0;(n=mi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Uf(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let s=a;for(let o=1;o<r.length;o++){const u=r[o];if(s.type===\"array\")return null;if(s.type!==\"object\"||!s.fields)return`Cannot access field \"${u}\" on $${r.slice(0,o).join(\".\")} (type: ${s.type})`;const l=s.fields.get(u);if(!l)return null;s=l}return null}function Wf(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=qf(i.content);let s;for(pi.lastIndex=0;(s=pi.exec(i.content))!==null;){const o=s[1],u=Uf(o,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function Qf(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function gi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const s=document.createElement(\"li\");s.textContent=a,i.appendChild(s)}n.appendChild(i),e.appendChild(n)}function _i(){const e=Lf();if(Bf(),e.userCSS){const u=document.createElement(\"style\");u.textContent=e.userCSS,document.head.appendChild(u)}if(e.userScript)try{new Function(e.userScript)()}catch(u){console.error(\"spindle: Error in story JavaScript:\",u)}let t={};const n=e.passages.get(\"StoryVariables\");if(!n){const u=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",l=document.getElementById(\"root\");throw l&&gi(l,[u]),new Error(`spindle: ${u}`)}const r=jf(n.content),i=Wf(e.passages,r);if(i.length>0){const u=document.getElementById(\"root\");throw u&&gi(u,i),new Error(`spindle: ${i.length} validation error(s):\n${i.join(`\n`)}`)}t=Qf(r),w.getState().init(e,t),ha();for(const[,u]of e.passages)if(u.tags.includes(\"widget\")){const l=yt(u.content),f=bt(l);for(const c of f)if(c.type===\"macro\"&&c.name===\"widget\"&&c.rawArgs){const d=c.rawArgs.trim().split(/\\s+/),h=d[0].replace(/[\"']/g,\"\"),g=d.slice(1).filter(k=>k.startsWith(\"$\")||k.startsWith(\"_\"));ya(h,c.children,g)}}let a=\"\";w.subscribe(u=>{u.currentPassage!==a&&(a=u.currentPassage,rl())});const s=e.passages.get(\"StoryInterface\");s&&!s.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const o=document.getElementById(\"root\");if(!o)throw new Error('spindle: No <div id=\"root\"> element found.');Ye(_(Rf,{}),o),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",_i):_i();</script>\n <style rel=\"stylesheet\" crossorigin>*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage{animation:passage-fade-in .3s ease-in}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.passage-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.passage-link:hover{color:#90caf9;border-bottom-color:#90caf9}.passage-link:active{color:#42a5f5}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.settings-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.settings-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:400px;max-height:80vh;overflow-y:auto;color:#e0e0e0;font-family:system-ui,sans-serif}.settings-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600}.settings-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.settings-close:hover{color:#e0e0e0}.settings-body{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.saves-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.saves-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:550px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-close{background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.saves-close:hover{color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}</style>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})