@rohal12/spindle 0.28.4 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/package.json +1 -1
- package/src/class-registry.ts +17 -2
- package/src/components/Passage.tsx +2 -1
- package/src/components/PassageDialog.tsx +5 -1
- package/src/components/macros/Button.tsx +12 -5
- package/src/components/macros/Computed.tsx +4 -5
- package/src/components/macros/For.tsx +7 -6
- package/src/components/macros/MacroLink.tsx +15 -7
- package/src/components/macros/SaveManager.tsx +4 -0
- package/src/components/macros/Type.tsx +3 -1
- package/src/components/macros/Widget.tsx +4 -1
- package/src/components/macros/WidgetInvocation.tsx +17 -6
- package/src/expression.ts +51 -0
- package/src/index.tsx +8 -2
- package/src/markup/markdown.ts +5 -1
- package/src/markup/render.tsx +14 -1
- package/src/saves/types.ts +3 -2
- package/src/store.ts +4 -0
- package/src/story-init.ts +5 -1
- package/src/widgets/ast-scanner.ts +29 -0
- package/src/widgets/widget-registry.ts +12 -1
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.28.4","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Ot,O,Ji,Qe,Ur,Zi,Xi,ea,pr,Hn,qn,ta,an={},on=[],jo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Mt=Array.isArray;function Ee(e,t){for(var n in t)e[n]=t[n];return e}function gr(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function K(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Ot.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Ct(e,o,r,i,null)}function Ct(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ji,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Wo(){return{current:null}}function G(e){return e.children}function Ae(e,t){this.props=e,this.context=t}function ct(e,t){if(t==null)return e.__?ct(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?ct(e):null}function Qo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ee({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),mr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ct(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,aa(r,a,i),t.__e=t.__=null,a.__e!=n&&na(a)}}function na(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),na(e)}function Un(e){(!e.__d&&(e.__d=!0)&&Qe.push(e)&&!sn.__r++||Ur!=O.debounceRendering)&&((Ur=O.debounceRendering)||Zi)(sn)}function sn(){for(var e,t=1;Qe.length;)Qe.length>t&&Qe.sort(Xi),e=Qe.shift(),t=Qe.length,Qo(e);sn.__r=0}function ra(e,t,n,r,i,a,o,s,u,l,d){var c,h,f,p,w,x,_,v=r&&r.__k||on,S=t.length;for(u=Go(n,t,v,u,S),c=0;c<S;c++)(f=n.__k[c])!=null&&(h=f.__i!=-1&&v[f.__i]||an,f.__i=c,x=mr(e,f,h,i,a,o,s,u,l,d),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&_r(h.ref,null,f),d.push(f.ref,f.__c||p,f)),w==null&&p!=null&&(w=p),(_=!!(4&f.__u))||h.__k===f.__k?u=ia(f,u,e,_):typeof f.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),f.__u&=-7);return n.__e=w,u}function Go(e,t,n,r,i){var a,o,s,u,l,d=n.length,c=d,h=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=Ct(null,o,null,null,null):Mt(o)?o=e.__k[a]=Ct(G,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Ct(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+h,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Yo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<d;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ct(s)),sa(s,s));return r}function ia(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=ia(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ct(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Re(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Mt(e)?e.some(function(n){Re(n,t)}):t.push(e)),t}function Yo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function jr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||jo.test(t)?n:n+\"px\"}function Wt(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||jr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||jr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(ea,\"$1\")),o=t.toLowerCase(),t=o in e||t==\"onFocusOut\"||t==\"onFocusIn\"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=pr,e.addEventListener(t,a?qn:Hn,a)):e.removeEventListener(t,a?qn:Hn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Wr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=pr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function mr(e,t,n,r,i,a,o,s,u,l){var d,c,h,f,p,w,x,_,v,S,A,I,y,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(_=t.props,v=\"prototype\"in z&&z.prototype.render,S=(d=z.contextType)&&r[d.__c],A=d?S?S.props.value:d.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(v?t.__c=c=new z(_,A):(t.__c=c=new Ae(_,A),c.constructor=z,c.render=Jo),S&&S.sub(c),c.state||(c.state={}),c.__n=r,h=c.__d=!0,c.__h=[],c._sb=[]),v&&c.__s==null&&(c.__s=c.state),v&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Ee({},c.__s)),Ee(c.__s,z.getDerivedStateFromProps(_,c.__s))),f=c.props,p=c.state,c.__v=t,h)v&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),v&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(v&&z.getDerivedStateFromProps==null&&_!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,A),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,A)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(b){b&&(b.__=t)}),on.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,A),v&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,p,w)})}if(c.context=A,c.props=_,c.__P=e,c.__e=!1,I=O.__r,y=0,v)c.state=c.__s,c.__d=!1,I&&I(t),d=c.render(c.props,c.state,c.context),on.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,I&&I(t),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Ee(Ee({},r),c.getChildContext())),v&&!h&&c.getSnapshotBeforeUpdate!=null&&(w=c.getSnapshotBeforeUpdate(f,p)),P=d!=null&&d.type===G&&d.key==null?oa(d.props.children):d,s=ra(e,Mt(P)?P:[P],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(b){if(t.__v=null,u||a!=null)if(b.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(T=a.length;T--;)gr(a[T]);jn(t)}else t.__e=n.__e,t.__k=n.__k,b.then||jn(t);O.__e(b,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Ko(n.__e,t,n,r,i,a,o,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function jn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(jn))}function aa(e,t,n){for(var r=0;r<n.length;r++)_r(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function oa(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Mt(e)?e.map(oa):Ee({},e)}function Ko(e,t,n,r,i,a,o,s,u){var l,d,c,h,f,p,w,x=n.props||an,_=t.props,v=t.type;if(v==\"svg\"?i=\"http://www.w3.org/2000/svg\":v==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((f=a[l])&&\"setAttribute\"in f==!!v&&(v?f.localName==v:f.nodeType==3)){e=f,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(v==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Ot.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(f=e.attributes[l]).name]=f.value;for(l in x)f=x[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||Wt(e,l,null,f,i);for(l in _)f=_[l],l==\"children\"?h=f:l==\"dangerouslySetInnerHTML\"?d=f:l==\"value\"?p=f:l==\"checked\"?w=f:s&&typeof f!=\"function\"||x[l]===f||Wt(e,l,f,x[l],i);if(d)s||c&&(d.__html==c.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),ra(t.type==\"template\"?e.content:e,Mt(h)?h:[h],t,n,r,v==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&ct(n,0),s,u),a!=null)for(l=a.length;l--;)gr(a[l]);s||(l=\"value\",v==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||v==\"progress\"&&!p||v==\"option\"&&p!=x[l])&&Wt(e,l,p,x[l],i),l=\"checked\",w!=null&&w!=e[l]&&Wt(e,l,w,x[l],i))}return e}function _r(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){O.__e(i,n)}}function sa(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||_r(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&sa(r[i],t,n||typeof e.type!=\"function\");n||gr(e.__e),e.__c=e.__=e.__e=void 0}function Jo(e,t,n){return this.constructor(e,n)}function be(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],mr(t,e=(!r&&n||t).__k=K(G,null,[e]),i||an,an,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Ot.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),aa(a,e,o)}function la(e,t){be(e,t,la)}function Zo(e,t,n){var r,i,a,o,s=Ee({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?Ot.call(arguments,2):n),Ct(e.type,s,r||e.key,i||e.ref,null)}function pt(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,Un(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+ta++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Ot=on.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},Ji=0,Ae.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ee({},this.state),typeof e==\"function\"&&(e=e(Ee({},n),this.props)),e&&Ee(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Un(this))},Ae.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Un(this))},Ae.prototype.render=G,Qe=[],Zi=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Xi=function(e,t){return e.__v.__b-t.__v.__b},sn.__r=0,ea=/(PointerCapture)$|Capture$/i,pr=0,Hn=Wr(!1),qn=Wr(!0),ta=0;var Xo=0;function k(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xo,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var Ve,W,An,Qr,ft=0,ua=[],Q=O,Gr=Q.__b,Yr=Q.__r,Kr=Q.diffed,Jr=Q.__c,Zr=Q.unmount,Xr=Q.__;function gt(e,t){Q.__h&&Q.__h(W,e,ft||t),ft=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Z(e){return ft=1,yr(ha,e)}function yr(e,t,n){var r=gt(Ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ha(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return d.some(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var d=a;a=void 0,i(s,u,l),a=d}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function Se(e,t){var n=gt(Ve++,3);!Q.__s&&br(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function nt(e,t){var n=gt(Ve++,4);!Q.__s&&br(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function ce(e){return ft=5,fe(function(){return{current:e}},[])}function ca(e,t,n){ft=6,nt(function(){if(typeof e==\"function\"){var r=e(t());return function(){e(null),r&&typeof r==\"function\"&&r()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function fe(e,t){var n=gt(Ve++,7);return br(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return ft=8,fe(function(){return e},t)}function ae(e){var t=W.context[e.__c],n=gt(Ve++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function fa(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function da(){var e=gt(Ve++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function es(){for(var e;e=ua.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Xt),t.__h.some(Wn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Gr&&Gr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Xr&&Xr(e,t)},Q.__r=function(e){Yr&&Yr(e),Ve=0;var t=(W=e.__c).__H;t&&(An===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Xt),t.__h.some(Wn),t.__h=[],Ve=0)),An=W},Q.diffed=function(e){Kr&&Kr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ua.push(t)!==1&&Qr===Q.requestAnimationFrame||((Qr=Q.requestAnimationFrame)||ts)(es)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),An=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(Xt),n.__h=n.__h.filter(function(r){return!r.__||Wn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Jr&&Jr(e,t)},Q.unmount=function(e){Zr&&Zr(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Xt(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ei=typeof requestAnimationFrame==\"function\";function ts(e){var t,n=function(){clearTimeout(r),ei&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ei&&(t=requestAnimationFrame(n))}function Xt(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Wn(e){var t=W;e.__c=e.__(),W=t}function br(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ha(e,t){return typeof t==\"function\"?t(e):t}const ti=e=>{let t;const n=new Set,r=(l,d)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const h=t;t=d??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},ns=(e=>e?ti(e):ti);function pa(e,t){for(var n in t)e[n]=t[n];return e}function Qn(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function ga(e,t){var n=t(),r=Z({t:{__:n,u:t}}),i=r[0].t,a=r[1];return nt(function(){i.__=n,i.u=t,Pn(i)&&a({t:i})},[e,n,t]),Se(function(){return Pn(i)&&a({t:i}),e(function(){Pn(i)&&a({t:i})})},[e]),n}function Pn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function ma(e){e()}function _a(e){return e}function ya(){return[!1,ma]}var ba=nt;function Gn(e,t){this.props=e,this.context=t}function rs(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:Qn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,K(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Gn.prototype=new Ae).isPureReactComponent=!0,Gn.prototype.shouldComponentUpdate=function(e,t){return Qn(this.props,e)||Qn(this.state,t)};var ni=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ni&&ni(e)};var is=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function as(e){function t(n){var r=pa({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=is,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ri=function(e,t){return e==null?null:Re(Re(e).map(t))},os={map:ri,forEach:ri,count:function(e){return e?Re(e).length:0},only:function(e){var t=Re(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Re},ss=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}ss(e,t,n,r)};var ii=O.unmount;function va(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c==\"function\"&&r.__c()}),e.__c.__H=null),(e=pa({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return va(r,t,n)})),e}function wa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return wa(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function en(){this.__u=0,this.o=null,this.__b=null}function ka(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ls(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?K(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function St(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ii&&ii(e)},(en.prototype=new Ae).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=ka(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=wa(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},en.prototype.componentWillUnmount=function(){this.o=[]},en.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=va(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&K(G,null,e.fallback);return i&&(i.__u&=-33),[K(G,null,t.__a?null:e.children),i]};var ai=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function us(e){return this.getChildContext=function(){return e.context},e.children}function cs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){be(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,a){this.childNodes.push(i),t.h.insertBefore(i,a)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}be(K(us,{context:t.context},e.__v),t.v)}function fs(e,t){var n=K(cs,{__v:e,h:t});return n.containerInfo=t,n}(St.prototype=new Ae).__a=function(e){var t=this,n=ka(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),ai(t,e,r)):i()};n?n(a):a()}},St.prototype.render=function(e){this.i=null,this.l=new Map;var t=Re(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},St.prototype.componentDidUpdate=St.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){ai(e,n,t)})};var Sa=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,ds=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,hs=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ps=/[A-Z0-9]/g,gs=typeof document<\"u\",ms=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function _s(e,t,n){return t.__k==null&&(t.textContent=\"\"),be(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ys(e,t,n){return la(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ae.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ae.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var oi=O.event;function bs(){}function vs(){return this.cancelBubble}function ws(){return this.defaultPrevented}O.event=function(e){return oi&&(e=oi(e)),e.persist=bs,e.isPropagationStopped=vs,e.isDefaultPrevented=ws,e.nativeEvent=e};var vr,ks={enumerable:!1,configurable:!0,get:function(){return this.class}},si=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||gs&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||ms(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":hs.test(o)&&(o=u):u=o=\"oninput\":a&&ds.test(o)?o=o.replace(ps,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",ks)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Sa,si&&si(e)};var li=O.__r;O.__r=function(e){li&&li(e),vr=e.__c};var ui=O.diffed;O.diffed=function(e){ui&&ui(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),vr=null};var Ss={ReactCurrentDispatcher:{current:{readContext:function(e){return vr.__n[e.__c].props.value},useCallback:ve,useContext:ae,useDebugValue:fa,useDeferredValue:_a,useEffect:Se,useId:da,useImperativeHandle:ca,useInsertionEffect:ba,useLayoutEffect:nt,useMemo:fe,useReducer:yr,useRef:ce,useState:Z,useSyncExternalStore:ga,useTransition:ya}}};function xs(e){return K.bind(null,e)}function yn(e){return!!e&&e.$$typeof===Sa}function Cs(e){return yn(e)&&e.type===G}function Is(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Es(e){return yn(e)?Zo.apply(null,arguments):e}function As(e){return!!e.__k&&(be(null,e),!0)}function Ps(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ts=function(e,t){return e(t)},Ns=function(e,t){return e(t)},Ds=G,$s=yn,Qt={useState:Z,useId:da,useReducer:yr,useEffect:Se,useLayoutEffect:nt,useInsertionEffect:ba,useTransition:ya,useDeferredValue:_a,useSyncExternalStore:ga,startTransition:ma,useRef:ce,useImperativeHandle:ca,useMemo:fe,useCallback:ve,useContext:ae,useDebugValue:fa,version:\"18.3.1\",Children:os,render:_s,hydrate:ys,unmountComponentAtNode:As,createPortal:fs,createElement:K,createContext:pt,createFactory:xs,cloneElement:Es,createRef:Wo,Fragment:G,isValidElement:yn,isElement:$s,isFragment:Cs,isMemo:Is,findDOMNode:Ps,Component:Ae,PureComponent:Gn,memo:rs,forwardRef:as,flushSync:Ns,unstable_batchedUpdates:Ts,StrictMode:Ds,Suspense:en,SuspenseList:St,lazy:ls,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Ss};const zs=e=>e;function Fs(e,t=zs){const n=Qt.useSyncExternalStore(e.subscribe,Qt.useCallback(()=>t(e.getState()),[e,t]),Qt.useCallback(()=>t(e.getInitialState()),[e,t]));return Qt.useDebugValue(n),n}const Rs=e=>{const t=ns(e),n=r=>Fs(t,r);return Object.assign(n,t),n},Os=(e=>Rs);var wr=Symbol.for(\"immer-nothing\"),It=Symbol.for(\"immer-draftable\"),ee=Symbol.for(\"immer-state\");function ie(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var he=Object,Ze=he.getPrototypeOf,Tt=\"constructor\",Lt=\"prototype\",Yn=\"configurable\",ln=\"enumerable\",tn=\"writable\",Nt=\"value\",Oe=e=>!!e&&!!e[ee];function Pe(e){return e?xa(e)||Bt(e)||!!e[It]||!!e[Tt]?.[It]||Ht(e)||qt(e):!1}var Ms=he[Lt][Tt].toString(),ci=new WeakMap;function xa(e){if(!e||!dt(e))return!1;const t=Ze(e);if(t===null||t===he[Lt])return!0;const n=he.hasOwnProperty.call(t,Tt)&&t[Tt];if(n===Object)return!0;if(!Ge(n))return!1;let r=ci.get(n);return r===void 0&&(r=Function.toString.call(n),ci.set(n,r)),r===Ms}function Vt(e,t,n=!0){Xe(e)===0?(n?Reflect.ownKeys(e):he.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Xe(e){const t=e[ee];return t?t.type_:Bt(e)?1:Ht(e)?2:qt(e)?3:0}var Et=(e,t,n=Xe(e))=>n===2?e.has(t):he[Lt].hasOwnProperty.call(e,t),ze=(e,t,n=Xe(e))=>n===2?e.get(t):e[t],un=(e,t,n,r=Xe(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ls(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Bt=Array.isArray,Ht=e=>e instanceof Map,qt=e=>e instanceof Set,dt=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",Tn=e=>typeof e==\"boolean\";function Vs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Bs=e=>dt(e)?e?.[ee]:null,Fe=e=>e.copy_||e.base_,kr=e=>e.modified_?e.copy_:e.base_;function Kn(e,t){if(Ht(e))return new Map(e);if(qt(e))return new Set(e);if(Bt(e))return Array[Lt].slice.call(e);const n=xa(e);if(t===!0||t===\"class_only\"&&!n){const r=he.getOwnPropertyDescriptors(e);delete r[ee];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[tn]===!1&&(s[tn]=!0,s[Yn]=!0),(s.get||s.set)&&(r[o]={[Yn]:!0,[tn]:!0,[ln]:s[ln],[Nt]:e[o]})}return he.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=he.create(r);return he.assign(i,e)}}function Sr(e,t=!1){return bn(e)||Oe(e)||!Pe(e)||(Xe(e)>1&&he.defineProperties(e,{set:Gt,add:Gt,clear:Gt,delete:Gt}),he.freeze(e),t&&Vt(e,(n,r)=>{Sr(r,!0)},!1)),e}function Hs(){ie(2)}var Gt={[Nt]:Hs};function bn(e){return e===null||!dt(e)?!0:he.isFrozen(e)}var cn=\"MapSet\",fn=\"Patches\",fi=\"ArrayMethods\",dn={};function et(e){const t=dn[e];return t||ie(0,e),t}var di=e=>!!dn[e];function qs(e,t){dn[e]||(dn[e]=t)}var Dt,Ca=()=>Dt,Us=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:di(cn)?et(cn):void 0,arrayMethodsPlugin_:di(fi)?et(fi):void 0});function hi(e,t){t&&(e.patchPlugin_=et(fn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Jn(e){Zn(e),e.drafts_.forEach(js),e.drafts_=null}function Zn(e){e===Dt&&(Dt=e.parent_)}var pi=e=>Dt=Us(Dt,e);function js(e){const t=e[ee];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function gi(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[ee].modified_&&(Jn(t),ie(4)),Pe(e)&&(e=mi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[ee].base_,e,t)}else e=mi(t,n);return Ws(t,e,!0),Jn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==wr?e:void 0}function mi(e,t){if(bn(t))return t;const n=t[ee];if(!n)return hn(t,e.handledSet_,e);if(!vn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);Aa(n,e)}return n.copy_}function Ws(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Sr(t,n)}function Ia(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var vn=(e,t)=>e.scope_===t,Qs=[];function Ea(e,t,n,r){const i=Fe(e),a=e.type_;if(r!==void 0&&ze(i,r,a)===t){un(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Vt(i,(u,l)=>{if(Oe(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const o=e.draftLocations_.get(t)??Qs;for(const s of o)un(i,s,n,a)}function Gs(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!vn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=kr(a);Ea(e,a.draft_??a,o,n),Aa(a,i)})}function Aa(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}Ia(e)}}function Ys(e,t,n){const{scope_:r}=e;if(Oe(n)){const i=n[ee];vn(i,r)&&i.callbacks_.push(function(){nn(e);const o=kr(i);Ea(e,n,o,t)})}else Pe(n)&&e.callbacks_.push(function(){const a=Fe(e);e.type_===3?a.has(n)&&hn(n,r.handledSet_,r):ze(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&hn(ze(e.copy_,t,e.type_),r.handledSet_,r)})}function hn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Oe(e)||t.has(e)||!Pe(e)||bn(e)||(t.add(e),Vt(e,(r,i)=>{if(Oe(i)){const a=i[ee];if(vn(a,n)){const o=kr(a);un(e,r,o,e.type_),Ia(a)}}else Pe(i)&&hn(i,t,n)})),e}function Ks(e,t){const n=Bt(e),r={type_:n?1:0,scope_:t?t.scope_:Ca(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=pn;n&&(i=[r],a=$t);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var pn={get(e,t){if(t===ee)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Fe(e);if(!Et(i,t,e.type_))return Js(e,i,t);const a=i[t];if(e.finalized_||!Pe(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Vs(t))return a;if(a===Nn(e.base_,t)){nn(e);const o=e.type_===1?+t:t,s=er(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=Pa(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=Nn(Fe(e),t),a=i?.[ee];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ls(n,i)&&(n!==void 0||Et(e.base_,t,e.type_)))return!0;nn(e),Xn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Ys(e,t,n)),!0},deleteProperty(e,t){return nn(e),Nn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Xn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[tn]:!0,[Yn]:e.type_!==1||t!==\"length\",[ln]:r[ln],[Nt]:n[t]}},defineProperty(){ie(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ie(12)}},$t={};for(let e in pn){let t=pn[e];$t[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}$t.deleteProperty=function(e,t){return $t.set.call(this,e,t,void 0)};$t.set=function(e,t,n){return pn.set.call(this,e[0],t,n,e[0])};function Nn(e,t){const n=e[ee];return(n?Fe(n):e)[t]}function Js(e,t,n){const r=Pa(t,n);return r?Nt in r?r[Nt]:r.get?.call(e.draft_):void 0}function Pa(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function Xn(e){e.modified_||(e.modified_=!0,e.parent_&&Xn(e.parent_))}function nn(e){e.copy_||(e.assigned_=new Map,e.copy_=Kn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Zs=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ge(t)&&!Ge(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,d=>n.call(this,d,...l))}}Ge(n)||ie(6),r!==void 0&&!Ge(r)&&ie(7);let i;if(Pe(t)){const a=pi(this),o=er(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?Jn(a):Zn(a)}return hi(a,r),gi(i,a)}else if(!t||!dt(t)){if(i=n(t),i===void 0&&(i=t),i===wr&&(i=void 0),this.autoFreeze_&&Sr(i,!0),r){const a=[],o=[];et(fn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ie(1,t)},this.produceWithPatches=(t,n)=>{if(Ge(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},Tn(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Tn(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Tn(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Pe(e)||ie(8),Oe(e)&&(e=Xs(e));const t=pi(this),n=er(t,e,void 0);return n[ee].isManual_=!0,Zn(t),n}finishDraft(e,t){const n=e&&e[ee];(!n||!n.isManual_)&&ie(9);const{scope_:r}=n;return hi(r,t),gi(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=et(fn).applyPatches_;return Oe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function er(e,t,n,r){const[i,a]=Ht(t)?et(cn).proxyMap_(t,n):qt(t)?et(cn).proxySet_(t,n):Ks(t,n);return(n?.scope_??Ca()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Gs(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function Xs(e){return Oe(e)||ie(10,e),Ta(e)}function Ta(e){if(!Pe(e)||bn(e))return e;const t=e[ee];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Kn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Kn(e,!0);return Vt(n,(i,a)=>{un(n,i,Ta(a))},r),t&&(t.finalized_=!1),n}function el(){function t(p,w=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Bs(ze(x,p.key_)),v=ze(x,p.key_);if(v===void 0||v!==p.draft_&&v!==p.base_&&v!==p.copy_||_!=null&&_.base_!==p.base_)return null;const S=p.parent_.type_===3;let A;if(S){const I=p.parent_;A=Array.from(I.drafts_.keys()).indexOf(p.key_)}else A=p.key_;if(!(S&&x.size>A||Et(x,A)))return null;w.push(A)}if(p.parent_)return t(p.parent_,w);w.reverse();try{n(p.copy_,w)}catch{return null}return w}function n(p,w){let x=p;for(let _=0;_<w.length-1;_++){const v=w[_];if(x=ze(x,v),!dt(x)||x===null)throw new Error(`Cannot resolve path at '${w.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,w,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:v}=x;switch(p.type_){case 0:case 2:return u(p,w,_,v);case 1:return s(p,w,_,v);case 3:return l(p,w,_,v)}}function s(p,w,x,_){let{base_:v,assigned_:S}=p,A=p.copy_;A.length<v.length&&([v,A]=[A,v],[x,_]=[_,x]);const I=p.allIndicesReassigned_===!0;for(let y=0;y<v.length;y++){const P=A[y],T=v[y];if((I||S?.get(y.toString()))&&P!==T){const b=P?.[ee];if(b&&b.modified_)continue;const N=w.concat([y]);x.push({op:r,path:N,value:f(P)}),_.push({op:r,path:N,value:f(T)})}}for(let y=v.length;y<A.length;y++){const P=w.concat([y]);x.push({op:i,path:P,value:f(A[y])})}for(let y=A.length-1;v.length<=y;--y){const P=w.concat([y]);_.push({op:a,path:P})}}function u(p,w,x,_){const{base_:v,copy_:S,type_:A}=p;Vt(p.assigned_,(I,y)=>{const P=ze(v,I,A),T=ze(S,I,A),z=y?Et(v,I)?r:i:a;if(P===T&&z===r)return;const b=w.concat(I);x.push(z===a?{op:z,path:b}:{op:z,path:b,value:f(T)}),_.push(z===i?{op:a,path:b}:z===a?{op:i,path:b,value:f(P)}:{op:r,path:b,value:f(P)})})}function l(p,w,x,_){let{base_:v,copy_:S}=p,A=0;v.forEach(I=>{if(!S.has(I)){const y=w.concat([A]);x.push({op:a,path:y,value:I}),_.unshift({op:i,path:y,value:I})}A++}),A=0,S.forEach(I=>{if(!v.has(I)){const y=w.concat([A]);x.push({op:i,path:y,value:I}),_.unshift({op:a,path:y,value:I})}A++})}function d(p,w,x){const{patches_:_,inversePatches_:v}=x;_.push({op:r,path:[],value:w===wr?void 0:w}),v.push({op:r,path:[],value:p})}function c(p,w){return w.forEach(x=>{const{path:_,op:v}=x;let S=p;for(let P=0;P<_.length-1;P++){const T=Xe(S);let z=_[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===Tt)&&ie(19),Ge(S)&&z===Lt&&ie(19),S=ze(S,z),dt(S)||ie(18,_.join(\"/\"))}const A=Xe(S),I=h(x.value),y=_[_.length-1];switch(v){case r:switch(A){case 2:return S.set(y,I);case 3:ie(16);default:return S[y]=I}case i:switch(A){case 1:return y===\"-\"?S.push(I):S.splice(y,0,I);case 2:return S.set(y,I);case 3:return S.add(I);default:return S[y]=I}case a:switch(A){case 1:return S.splice(y,1);case 2:return S.delete(y);case 3:return S.delete(x.value);default:return delete S[y]}default:ie(17,v)}}),p}function h(p){if(!Pe(p))return p;if(Bt(p))return p.map(h);if(Ht(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,h(_)]));if(qt(p))return new Set(Array.from(p).map(h));const w=Object.create(Ze(p));for(const x in p)w[x]=h(p[x]);return Et(p,It)&&(w[It]=p[It]),w}function f(p){return Oe(p)?h(p):p}qs(fn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var zt=new Zs,tl=zt.produce,nl=zt.produceWithPatches.bind(zt),lt=zt.applyPatches.bind(zt);const rl=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?tl(i):i;return t(s,a,...o)},e(r.setState,n,r)),il=rl,al=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),ol=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function sl(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function _i(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function yi(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function ll(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;t++}n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function mt(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const p=yi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const d=e.slice(l,n);n+=2;const{display:c,target:h}=sl(d),f={type:\"link\",display:c,target:h,start:a,end:n};o&&(f.className=o),s&&(f.id=s),t.push(f),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=yi(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const c=e[d];if(c===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=d;let h=1;const f=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=a+1,r=a;continue}const p=e.slice(f,n);n++;const{name:w,rawArgs:x,isClose:_}=_i(p),v={type:\"macro\",name:w,rawArgs:x,isClose:_,start:a,end:n};s&&(v.className=s),u&&(v.id=u),t.push(v),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const d=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(d,n);n++;const{name:h,rawArgs:f,isClose:p}=_i(c);t.push({type:\"macro\",name:h,rawArgs:f,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&al.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const d=ll(e,o);o=d.endIdx;let c=ol.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const Na=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function ul(e){Na.add(e.toLowerCase())}const bi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},cl=new Set([\"if\",\"switch\",\"timed\"]);function _t(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{const a=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(bi[a]){const o=bi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const u={rawArgs:i.rawArgs,children:[]};i.className&&(u.className=i.className),i.id&&(u.id=i.id),s.branches.push(u);break}if(Na.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(cl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function xr(){const e=C(r=>r.variables),t=C(r=>r.temporary),n=ae(Te);return fe(()=>[e,t,n],[e,t,n])}const fl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,dl=/\\{[\\$_@][\\w.]+\\}/;function hl(e){return dl.test(e)}function pl(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function gl(e,t,n,r){return e.replace(fl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let d;return o===\"$\"?d=t[l]:o===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=pl(d,u)),d==null?\"\":String(d)})}function Cr(){const[e,t,n]=xr();return ve(r=>r===void 0||!hl(r)?r:gl(r,e,t,n),[e,t,n])}function ml({name:e,scope:t,className:n,id:r}){const i=Cr();n=i(n),r=i(r);const a=ae(Te),o=e.split(\".\"),s=o[0],u=C(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=o[c];l=l[h]}const d=l==null?\"\":String(l);return n||r?k(\"span\",{id:r,class:n,children:d}):k(G,{children:d})}function Da(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function $a(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let yt=!1,Ut=\"\",tt=0,ht=null;function _l(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Ut=n,tt=0,ht=Da($a(n)),yt=!0}function za(e,t){Ut=e,tt=0,ht=Da($a(e)),yt=!0;for(let n=0;n<t;n++)ht();tt=t}function tr(){yt=!1,Ut=\"\",tt=0,ht=null}function gn(){return yt?{seed:Ut,pull:tt}:null}function Ir(){return!yt||!ht?Math.random():(tt++,ht())}function Fa(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Ir()*(t-e+1))+e}function yl(){return yt}function bl(){return Ut}function vl(){return tt}const wl=500,We=new Map,kl=/\\$(\\w+)/g,Sl=/(?<![.\\w])_(\\w+)/g,xl=/@(\\w+)/g;function Cl(e){return e.replace(kl,'variables[\"$1\"]').replace(Sl,'temporary[\"$1\"]').replace(xl,'locals[\"$1\"]')}function Er(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=Cl(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else l===\"\\\\\"&&r+1<e.length?(u+=l+e.charAt(r+1),r++):u+=l;r++}t+=Er(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Il=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function Ra(e,t){const n=We.get(e);if(n)return We.delete(e),We.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Il+t);if(We.set(e,r),We.size>wl){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let Yt=null,vi=null,wi=null;function Oa(){const e=C.getState(),{visitCounts:t,renderCounts:n}=e;if(Yt&&vi===t&&wi===n)return Yt;const r=f=>t[f??C.getState().currentPassage]??0,i=f=>r(f)>0,a=(...f)=>f.some(p=>r(p)>0),o=(...f)=>f.every(p=>r(p)>0),s=f=>n[f??C.getState().currentPassage]??0;return Yt={currentPassage:()=>{const f=C.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=C.getState();if(f.historyIndex<=0)return;const p=f.history[f.historyIndex-1]?.passage;return p?f.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:f=>s(f)>0,hasRenderedAny:(...f)=>f.some(p=>s(p)>0),hasRenderedAll:(...f)=>f.every(p=>s(p)>0),random:Ir,randomInt:Fa},vi=t,wi=n,Yt}function wn(e,t,n,r={}){const a=`return (${Er(e)});`;return Ra(a,a)(t,n,r,Oa())}function Ma(e,t,n,r={}){const i=Er(e);Ra(\"exec:\"+i,i)(t,n,r,Oa())}function El(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function Al({body:e,parentValues:t,ownKeys:n}){const r=ae(Ne),[i,a]=Z({}),o={...t,...n,...i},s=ce(o);s.current=o;const u=ve(()=>s.current,[]),l=ve((c,h)=>{a(f=>({...f,[c]:h}))},[]),d=fe(()=>({update:l,getValues:u}),[l,u]);return k(jt.Provider,{value:d,children:k(Te.Provider,{value:o,children:De(e,{nobr:r,locals:o})})})}function Pl({body:e,params:t,rawArgs:n}){const r=ae(Te),i=ae(Ne),[a,o,s]=xr();if(t.length===0||!n)return k(G,{children:De(e,{nobr:i,locals:r})});const u=El(n),l={};for(let d=0;d<t.length;d++){const c=t[d],h=u[d];let f;if(h!==void 0)try{f=wn(h,a,o,s)}catch{f=void 0}l[c.startsWith(\"@\")?c.slice(1):c]=f}return k(Al,{body:e,parentValues:r,ownKeys:l})}const La=new Map;function Va(e,t,n){La.set(e.toLowerCase(),{body:t,params:n})}function Tl(e){return La.get(e.toLowerCase())}const Ba=new Map;function Nl(e,t){Ba.set(e.toLowerCase(),t)}function Dl(e){return Ba.get(e.toLowerCase())}const Ha=new Set;function $l(e){Ha.add(e.toLowerCase())}function zl(e){return Ha.has(e.toLowerCase())}const ki=document.createElement(\"i\");function qa(e){const t=\"&\"+e+\";\";ki.innerHTML=t;const n=ki.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function ge(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function re(e,t){return e.length>0?(ge(e,e.length,0,t),e):t}const nr={}.hasOwnProperty;function Fl(e){const t={};let n=-1;for(;++n<e.length;)Rl(t,e[n]);return t}function Rl(e,t){let n;for(n in t){const i=(nr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){nr.call(i,o)||(i[o]=[]);const s=a[o];Ol(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Ol(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);ge(e,0,0,r)}function Ml(e){const t={};let n=-1;for(;++n<e.length;)Ll(t,e[n]);return t}function Ll(e,t){let n;for(n in t){const i=(nr.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function Vl(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const Bl={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Ua(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+Bl[n]+\";\"}}function Ft(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Ie=He(/[A-Za-z]/),pe=He(/[\\dA-Za-z]/),Hl=He(/[#-'*+\\--9=?A-Z^-~]/);function rr(e){return e!==null&&(e<32||e===127)}const ir=He(/\\d/),ql=He(/[\\dA-Fa-f]/),Ul=He(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function oe(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const jl=He(/\\p{P}|\\p{S}/u),Wl=He(/\\s/);function He(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Kt(e,t){const n=Ua(Ql(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),o=n.indexOf(\"/\");return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Ql(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&pe(e.charCodeAt(n+1))&&pe(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o=\"�\"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const Si={}.hasOwnProperty,xi=/^(https?|ircs?|mailto|xmpp)$/i,Gl=/^https?$/i;function Yl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Ml([{enter:{blockQuote:M,codeFenced:we,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:Oo,content:Co,definition:bo,definitionDestinationString:wo,definitionLabelString:x,definitionTitleString:x,emphasis:Fo,htmlFlow:zo,htmlText:Lr,image:q,label:x,link:se,listItemMarker:N,listItemValue:b,listOrdered:T,listUnordered:z,paragraph:Y,reference:x,resource:at,resourceDestinationString:ot,resourceTitleString:x,setextHeading:Eo,strong:Ro},exit:{atxHeading:Po,atxHeadingSequence:Io,autolinkEmail:Uo,autolinkProtocol:qo,blockQuote:J,characterEscapeValue:vt,characterReferenceMarkerHexadecimal:Vr,characterReferenceMarkerNumeric:Vr,characterReferenceValue:Ho,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:$o,codeIndented:g,codeText:Mo,codeTextData:vt,data:vt,definition:xo,definitionDestinationString:ko,definitionLabelString:vo,definitionTitleString:So,emphasis:Lo,hardBreakEscape:Or,hardBreakTrailing:Or,htmlFlow:Mr,htmlFlowData:vt,htmlText:Mr,htmlTextData:vt,image:Rr,label:bt,labelText:X,lineEnding:Do,link:Rr,listOrdered:$,listUnordered:B,paragraph:de,reference:P,referenceString:Me,resource:P,resourceDestinationString:En,resourceTitleString:yo,setextHeading:No,setextHeadingLineSequence:To,setextHeadingText:Ao,strong:Vo,thematicBreak:Bo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:x,encode:y,getData:w,lineEndingIfNeeded:I,options:t,raw:S,resume:_,setData:p,tag:v};let c=t.defaultLineEnding;return h;function h(E){let F=-1,te=0;const ke=[];let xe=[],$e=[];for(;++F<E.length;)!c&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(c=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?ke.push(F):f(E.slice(ke.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?($e=re($e,E.slice(te,F)),te=F):(xe=re(xe,E.slice(te,F+1)),te=F+1));xe=re(xe,$e),xe=re(xe,E.slice(te)),F=-1;const Ce=xe;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const Br=u[Ce[F][0]],Hr=Ce[F][1].type,qr=Br[Hr];Si.call(Br,Hr)&&qr&&qr.call({sliceSerialize:Ce[F][2].sliceSerialize,...d},Ce[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function f(E){const F=E.length;let te=0,ke=0,xe=!1,$e;for(;++te<F;){const Ce=E[te];if(Ce[1]._container)$e=void 0,Ce[0]===\"enter\"?ke++:ke--;else switch(Ce[1].type){case\"listItemPrefix\":{Ce[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ce[0]===\"enter\"&&!ke&&($e?$e=void 0:xe=!0);break}default:$e=void 0}}E[0][1]._loose=xe}function p(E,F){l[E]=F}function w(E){return l[E]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function v(E){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(E))}function S(E){p(\"lastWasTag\"),i[i.length-1].push(E)}function A(){S(c||`\n`)}function I(){const E=i[i.length-1],F=E[E.length-1],te=F?F.charCodeAt(F.length-1):null;te===10||te===13||te===null||A()}function y(E){return w(\"ignoreEncode\")?E:Ua(E)}function P(){_()}function T(E){o.push(!E._loose),I(),v(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){o.push(!E._loose),I(),v(\"<ul\"),p(\"expectFirstItem\",!0)}function b(E){if(w(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&v(' start=\"'+y(String(F))+'\"')}}function N(){w(\"expectFirstItem\")?v(\">\"):U(),I(),v(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),A(),v(\"</ol>\")}function B(){U(),o.pop(),A(),v(\"</ul>\")}function U(){w(\"lastWasTag\")&&!w(\"slurpAllLineEndings\")&&I(),v(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),I(),v(\"<blockquote>\")}function J(){o.pop(),I(),v(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function Y(){o[o.length-1]||(I(),v(\"<p>\")),p(\"slurpAllLineEndings\")}function de(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):v(\"</p>\")}function we(){I(),v(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=_();v(' class=\"language-'+E+'\"')}function D(){const E=w(\"fencesCount\")||0;E||(v(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){I(),v(\"<pre><code>\")}function g(){const E=w(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!w(\"lastWasTag\")&&A(),w(\"flowCodeSeenData\")&&I(),v(\"</code></pre>\"),E!==void 0&&E<2&&I(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function se(){a.push({})}function X(E){a[a.length-1].labelId=this.sliceSerialize(E)}function bt(){a[a.length-1].label=_()}function Me(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function at(){x(),a[a.length-1].destination=\"\"}function ot(){x(),p(\"ignoreEncode\",!0)}function En(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function yo(){a[a.length-1].title=_()}function Rr(){let E=a.length-1;const F=a[E],te=F.referenceId||F.labelId,ke=F.destination===void 0?r[Ft(te)]:F;for(n=!0;E--;)if(a[E].image){n=void 0;break}F.image?(v('<img src=\"'+Kt(ke.destination,t.allowDangerousProtocol?void 0:Gl)+'\" alt=\"'),S(F.label),v('\"')):v('<a href=\"'+Kt(ke.destination,t.allowDangerousProtocol?void 0:xi)+'\"'),v(ke.title?' title=\"'+ke.title+'\"':\"\"),F.image?v(\" />\"):(v(\">\"),S(F.label),v(\"</a>\")),a.pop()}function bo(){x(),a.push({})}function vo(E){_(),a[a.length-1].labelId=this.sliceSerialize(E)}function wo(){x(),p(\"ignoreEncode\",!0)}function ko(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function So(){a[a.length-1].title=_()}function xo(){const E=a[a.length-1],F=Ft(E.labelId);_(),Si.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Co(){p(\"slurpAllLineEndings\",!0)}function Io(E){w(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),I(),v(\"<h\"+w(\"headingRank\")+\">\"))}function Eo(){x(),p(\"slurpAllLineEndings\")}function Ao(){p(\"slurpAllLineEndings\",!0)}function Po(){v(\"</h\"+w(\"headingRank\")+\">\"),p(\"headingRank\")}function To(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function No(){const E=_();I(),v(\"<h\"+w(\"headingRank\")+\">\"),S(E),v(\"</h\"+w(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function vt(E){S(y(this.sliceSerialize(E)))}function Do(E){if(!w(\"slurpAllLineEndings\")){if(w(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(w(\"inCodeText\")){S(\" \");return}S(y(this.sliceSerialize(E)))}}function $o(E){S(y(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Or(){v(\"<br />\")}function zo(){I(),Lr()}function Mr(){p(\"ignoreEncode\")}function Lr(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Fo(){v(\"<em>\")}function Ro(){v(\"<strong>\")}function Oo(){p(\"inCodeText\",!0),v(\"<code>\")}function Mo(){p(\"inCodeText\"),v(\"</code>\")}function Lo(){v(\"</em>\")}function Vo(){v(\"</strong>\")}function Bo(){I(),v(\"<hr />\")}function Vr(E){p(\"characterReferenceType\",E.type)}function Ho(E){const F=this.sliceSerialize(E),te=w(\"characterReferenceType\")?Vl(F,w(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):qa(F);S(y(te)),p(\"characterReferenceType\")}function qo(E){const F=this.sliceSerialize(E);v('<a href=\"'+Kt(F,t.allowDangerousProtocol?void 0:xi)+'\">'),S(y(F)),v(\"</a>\")}function Uo(E){const F=this.sliceSerialize(E);v('<a href=\"'+Kt(\"mailto:\"+F)+'\">'),S(y(F)),v(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Kl={tokenize:Jl};function Jl(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const Zl={tokenize:Xl},Ci={tokenize:eu};function Xl(e){const t=this,n=[];let r=0,i,a,o;return s;function s(S){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,l)(S)}return l(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();const A=t.events.length;let I=A,y;for(;I--;)if(t.events[I][0]===\"exit\"&&t.events[I][1].type===\"chunkFlow\"){y=t.events[I][1].end;break}_(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={...y},P++;return ge(t.events,I+1,0,t.events.slice(A)),t.events.length=P,l(S)}return s(S)}function l(S){if(r===n.length){if(!i)return h(S);if(i.currentConstruct&&i.currentConstruct.concrete)return p(S);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ci,d,c)(S)}function d(S){return i&&v(),_(r),h(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(S)}function h(S){return t.containerState={},e.attempt(Ci,f,p)(S)}function f(S){return r++,n.push([t.currentConstruct,t.containerState]),h(S)}function p(S){if(S===null){i&&v(),_(0),e.consume(S);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),w(S)}function w(S){if(S===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(S);return}return R(S)?(e.consume(S),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(S),w)}function x(S,A){const I=t.sliceStream(S);if(A&&I.push(null),S.previous=a,a&&(a.next=S),a=S,i.defineSkip(S.start),i.write(I),t.parser.lazy[S.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const P=t.events.length;let T=P,z,b;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){b=t.events[T][1].end;break}z=!0}for(_(r),y=P;y<t.events.length;)t.events[y][1].end={...b},y++;ge(t.events,T+1,0,t.events.slice(P)),t.events.length=y}}function _(S){let A=n.length;for(;A-- >S;){const I=n[A];t.containerState=I[1],I[0].exit.call(t,e)}n.length=S}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function eu(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function mn(e){if(e===null||oe(e)||Wl(e))return 1;if(jl(e))return 2}function kn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const ar={name:\"attention\",resolveAll:tu,tokenize:nu};function tu(e,t){let n=-1,r,i,a,o,s,u,l,d;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},h={...e[n][1].start};Ii(c,-u),Ii(h,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=re(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=re(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=re(l,kn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=re(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=re(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,ge(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function nu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=mn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),d=mn(u),c=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?c:c&&(i||!h)),l._close=!!(a===42?h:h&&(d||!c)),t(u)}}function Ii(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ru={name:\"autolink\",tokenize:iu};function iu(e,t,n){let r=0;return i;function i(f){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(f){return Ie(f)?(e.consume(f),o):f===64?n(f):l(f)}function o(f){return f===43||f===45||f===46||pe(f)?(r=1,s(f)):l(f)}function s(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||pe(f))&&r++<32?(e.consume(f),s):(r=0,l(f))}function u(f){return f===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):f===null||f===32||f===60||rr(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),d):Hl(f)?(e.consume(f),l):n(f)}function d(f){return pe(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,d):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(f)}function h(f){if((f===45||pe(f))&&r++<63){const p=f===45?h:c;return e.consume(f),p}return n(f)}}const Sn={partial:!0,tokenize:au};function au(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const ja={continuation:{tokenize:su},exit:lu,name:\"blockQuote\",tokenize:ou};function ou(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function su(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(ja,t,n)(o)}}function lu(e){e.exit(\"blockQuote\")}const Wa={name:\"characterEscape\",tokenize:uu};function uu(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return Ul(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Qa={name:\"characterReference\",tokenize:cu};function cu(e,t,n){const r=this;let i=0,a,o;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=pe,d(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=ql,d):(e.enter(\"characterReferenceValue\"),a=7,o=ir,d(c))}function d(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===pe&&!qa(r.sliceSerialize(h))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),d):n(c)}}const Ei={partial:!0,tokenize:du},Ai={concrete:!0,name:\"codeFenced\",tokenize:fu};function fu(e,t,n){const r=this,i={partial:!0,tokenize:I};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(y)}function d(y){return y===s?(o++,e.consume(y),d):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),L(y)?H(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||R(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(Ei,w,A)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(y))}function h(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):L(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,f,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),h)}function f(y){return y===null||R(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function w(y){return e.attempt(i,A,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&L(y)?H(e,v,\"linePrefix\",a+1)(y):v(y)}function v(y){return y===null||R(y)?e.check(Ei,w,A)(y):(e.enter(\"codeFlowValue\"),S(y))}function S(y){return y===null||R(y)?(e.exit(\"codeFlowValue\"),v(y)):(e.consume(y),S)}function A(y){return e.exit(\"codeFenced\"),t(y)}function I(y,P,T){let z=0;return b;function b(M){return y.enter(\"lineEnding\"),y.consume(M),y.exit(\"lineEnding\"),N}function N(M){return y.enter(\"codeFencedFence\"),L(M)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(y.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,y.consume(M),B):z>=o?(y.exit(\"codeFencedFenceSequence\"),L(M)?H(y,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(y.exit(\"codeFencedFence\"),P(M)):T(M)}}}function du(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Dn={name:\"codeIndented\",tokenize:pu},hu={partial:!0,tokenize:gu};function pu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(hu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function gu(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):R(o)?i(o):n(o)}}const mu={name:\"codeText\",previous:yu,resolve:_u,tokenize:bu};function _u(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function bu(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,d(c)):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||R(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function d(c){return c===96?(e.consume(c),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class vu{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&wt(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),wt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);wt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wt(this.left,n.reverse())}}}function wt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ga(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new vu(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,wu(d,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=d.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(d.get(i)[1].type=\"lineEndingBlank\"),o[1].type=\"lineEnding\",i=a);else if(!(o[1].type===\"linePrefix\"||o[1].type===\"listItemIndent\"))break;i&&(r[1].end={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return ge(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function wu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let d,c,h=-1,f=n,p=0,w=0;const x=[w];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),c&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++h<s.length;)s[h][0]===\"exit\"&&s[h-1][0]===\"enter\"&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(w=h+1,x.push(w),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),h=x.length;h--;){const _=s.slice(x[h],x[h+1]),v=a.pop();u.push([v,v+_.length-1]),e.splice(v,2,_)}for(u.reverse(),h=-1;++h<u.length;)l[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return l}const ku={resolve:xu,tokenize:Cu},Su={partial:!0,tokenize:Iu};function xu(e){return Ga(e),e}function Cu(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):R(s)?e.check(Su,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Iu(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||R(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Ya(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),h):_===null||_===32||_===41||rr(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),w(_))}function h(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),f(_))}function f(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),h(_)):_===null||_===60||R(_)?n(_):(e.consume(_),_===92?p:f)}function p(_){return _===60||_===62||_===92?(e.consume(_),f):f(_)}function w(_){return!d&&(_===null||_===41||oe(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):d<l&&_===40?(e.consume(_),d++,w):_===41?(e.consume(_),d--,w):_===null||_===32||_===40||rr(_)?n(_):(e.consume(_),_===92?x:w)}function x(_){return _===40||_===41||_===92?(e.consume(_),w):w(_)}}function Ka(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),d}function d(f){return s>999||f===null||f===91||f===93&&!u||f===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||R(f)||s++>999?(e.exit(\"chunkString\"),d(f)):(e.consume(f),u||(u=!L(f)),f===92?h:c)}function h(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function Ja(e,t,n,r,i,a){let o;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,u):n(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),l(h))}function l(h){return h===o?(e.exit(a),u(o)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===o||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?c:d)}function c(h){return h===o||h===92?(e.consume(h),d):d(h)}}function At(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Eu={name:\"definition\",tokenize:Pu},Au={partial:!0,tokenize:Tu};function Pu(e,t,n){const r=this;let i;return a;function a(f){return e.enter(\"definition\"),o(f)}function o(f){return Ka.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function s(f){return i=Ft(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter(\"definitionMarker\"),e.consume(f),e.exit(\"definitionMarker\"),u):n(f)}function u(f){return oe(f)?At(e,l)(f):l(f)}function l(f){return Ya(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function d(f){return e.attempt(Au,c,c)(f)}function c(f){return L(f)?H(e,h,\"whitespace\")(f):h(f)}function h(f){return f===null||R(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function Tu(e,t,n){return r;function r(s){return oe(s)?At(e,i)(s):n(s)}function i(s){return Ja(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||R(s)?t(s):n(s)}}const Nu={name:\"hardBreakEscape\",tokenize:Du};function Du(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const $u={name:\"headingAtx\",resolve:zu,tokenize:Fu};function zu(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},ge(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Fu(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),a(d)}function a(d){return e.enter(\"atxHeadingSequence\"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||oe(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||oe(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Ru=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],Pi=[\"pre\",\"script\",\"style\",\"textarea\"],Ou={concrete:!0,name:\"htmlFlow\",resolveTo:Vu,tokenize:Bu},Mu={partial:!0,tokenize:qu},Lu={partial:!0,tokenize:Hu};function Vu(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Bu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):Ie(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function h(g){return g===45?(e.consume(g),i=2,f):g===91?(e.consume(g),i=5,s=0,p):Ie(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function f(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:p):n(g)}function w(g){return Ie(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function x(g){if(g===null||g===47||g===62||oe(g)){const q=g===47,se=o.toLowerCase();return!q&&!a&&Pi.includes(se)?(i=1,r.interrupt?t(g):$(g)):Ru.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?v(g):S(g))}return g===45||pe(g)?(e.consume(g),o+=String.fromCharCode(g),x):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function v(g){return L(g)?(e.consume(g),v):b(g)}function S(g){return g===47?(e.consume(g),b):g===58||g===95||Ie(g)?(e.consume(g),A):L(g)?(e.consume(g),S):b(g)}function A(g){return g===45||g===46||g===58||g===95||pe(g)?(e.consume(g),A):I(g)}function I(g){return g===61?(e.consume(g),y):L(g)?(e.consume(g),I):S(g)}function y(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),y):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||oe(g)?I(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?S(g):n(g)}function b(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),J):g===60&&i===1?(e.consume(g),Y):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),we):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Mu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Lu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function J(g){return g===45?(e.consume(g),m):$(g)}function Y(g){return g===47?(e.consume(g),o=\"\",de):$(g)}function de(g){if(g===62){const q=o.toLowerCase();return Pi.includes(q)?(e.consume(g),D):$(g)}return Ie(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),de):$(g)}function we(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function Hu(e,t,n){const r=this;return i;function i(o){return R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function qu(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(Sn,t,n)}}const Uu={name:\"htmlText\",tokenize:ju};function ju(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),I):m===63?(e.consume(m),S):Ie(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),a=0,p):Ie(m)?(e.consume(m),v):n(m)}function d(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(o=c,Y(m)):(e.consume(m),c)}function h(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?J(m):m===45?h(m):c(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(a++)?(e.consume(m),a===D.length?w:p):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),x):R(m)?(o=w,Y(m)):(e.consume(m),w)}function x(m){return m===93?(e.consume(m),_):w(m)}function _(m){return m===62?J(m):m===93?(e.consume(m),_):w(m)}function v(m){return m===null||m===62?J(m):R(m)?(o=v,Y(m)):(e.consume(m),v)}function S(m){return m===null?n(m):m===63?(e.consume(m),A):R(m)?(o=S,Y(m)):(e.consume(m),S)}function A(m){return m===62?J(m):S(m)}function I(m){return Ie(m)?(e.consume(m),y):n(m)}function y(m){return m===45||pe(m)?(e.consume(m),y):P(m)}function P(m){return R(m)?(o=P,Y(m)):L(m)?(e.consume(m),P):J(m)}function T(m){return m===45||pe(m)?(e.consume(m),T):m===47||m===62||oe(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),J):m===58||m===95||Ie(m)?(e.consume(m),b):R(m)?(o=z,Y(m)):L(m)?(e.consume(m),z):J(m)}function b(m){return m===45||m===46||m===58||m===95||pe(m)?(e.consume(m),b):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(o=N,Y(m)):L(m)?(e.consume(m),N):z(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,B):R(m)?(o=$,Y(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(o=B,Y(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||oe(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||oe(m)?z(m):n(m)}function J(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function Y(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),de}function de(m){return L(m)?H(e,we,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):we(m)}function we(m){return e.enter(\"htmlTextData\"),o(m)}}const Ar={name:\"labelEnd\",resolveAll:Yu,resolveTo:Ku,tokenize:Ju},Wu={tokenize:Zu},Qu={tokenize:Xu},Gu={tokenize:ec};function Yu(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&ge(e,0,e.length,n),e}function Ku(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},d={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=re(s,e.slice(a+1,a+r+3)),s=re(s,[[\"enter\",d,t]]),s=re(s,kn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=re(s,[[\"exit\",d,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=re(s,e.slice(o+1)),s=re(s,[[\"exit\",u,t]]),ge(e,a,e.length,s),e}function Ju(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(h){return a?a._inactive?c(h):(o=r.parser.defined.includes(Ft(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(h)}function u(h){return h===40?e.attempt(Wu,d,o?d:c)(h):h===91?e.attempt(Qu,d,o?l:c)(h):o?d(h):c(h)}function l(h){return e.attempt(Gu,d,c)(h)}function d(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function Zu(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return oe(c)?At(e,a)(c):a(c)}function a(c){return c===41?d(c):Ya(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return oe(c)?At(e,u)(c):d(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?Ja(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):d(c)}function l(c){return oe(c)?At(e,d)(c):d(c)}function d(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function Xu(e,t,n){const r=this;return i;function i(s){return Ka.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Ft(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function ec(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const tc={name:\"labelStartImage\",resolveAll:Ar.resolveAll,tokenize:nc};function nc(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),a}function a(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),o):n(s)}function o(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const rc={name:\"labelStartLink\",resolveAll:Ar.resolveAll,tokenize:ic};function ic(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const $n={name:\"lineEnding\",tokenize:ac};function ac(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const rn={name:\"thematicBreak\",tokenize:oc};function oc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?H(e,s,\"whitespace\")(l):s(l))}}const ue={continuation:{tokenize:cc},exit:dc,name:\"list\",tokenize:uc},sc={partial:!0,tokenize:hc},lc={partial:!0,tokenize:fc};function uc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(f){const p=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:ir(f)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(rn,n,l)(f):l(f);if(!r.interrupt||f===49)return e.enter(\"listItemPrefix\"),e.enter(\"listItemValue\"),u(f)}return n(f)}function u(f){return ir(f)&&++o<10?(e.consume(f),u):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit(\"listItemValue\"),l(f)):n(f)}function l(f){return e.enter(\"listItemMarker\"),e.consume(f),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||f,e.check(Sn,r.interrupt?n:d,e.attempt(sc,h,c))}function d(f){return r.containerState.initialBlankLine=!0,a++,h(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),h):n(f)}function h(f){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function cc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Sn,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(lc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(ue,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function fc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function dc(e){e.exit(this.containerState.type)}function hc(e,t,n){const r=this;return H(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Ti={name:\"setextUnderline\",resolveTo:pc,tokenize:gc};function pc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function gc(e,t,n){const r=this;let i;return a;function a(l){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){c=r.events[d][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const mc={tokenize:_c};function _c(e){const t=this,n=e.attempt(Sn,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ku,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const yc={resolveAll:Xa()},bc=Za(\"string\"),vc=Za(\"text\");function Za(e){return{resolveAll:Xa(e===\"text\"?wc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(d){return l(d)?a(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),a(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const c=i[d];let h=-1;if(c)for(;++h<c.length;){const f=c[h];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function Xa(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function wc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const kc={42:ue,43:ue,45:ue,48:ue,49:ue,50:ue,51:ue,52:ue,53:ue,54:ue,55:ue,56:ue,57:ue,62:ja},Sc={91:Eu},xc={[-2]:Dn,[-1]:Dn,32:Dn},Cc={35:$u,42:rn,45:[Ti,rn],60:Ou,61:Ti,95:rn,96:Ai,126:Ai},Ic={38:Qa,92:Wa},Ec={[-5]:$n,[-4]:$n,[-3]:$n,33:tc,38:Qa,42:ar,60:[ru,Uu],91:rc,92:[Nu,Wa],93:Ar,95:ar,96:mu},Ac={null:[ar,yc]},Pc={null:[42,95]},Tc={null:[]},Nc=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Pc,contentInitial:Sc,disable:Tc,document:kc,flow:Cc,flowInitial:xc,insideSpan:Ac,string:Ic,text:Ec},Symbol.toStringTag,{value:\"Module\"}));function Dc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(I),check:P(y),consume:v,enter:S,exit:A,interrupt:P(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:w,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:f,write:c};let d=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(N){return o=re(o,N),x(),o[o.length-1]!==null?[]:(T(t,0),l.events=kn(a,l.events,l),l.events)}function h(N,$){return zc(f(N),$)}function f(N){return $c(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:M}}function w(N){i[N.line]=N.column,b()}function x(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(N){d=d(N)}function v(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,b()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=N}function S(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function I(N,$){T(N,$.from)}function y(N,$){$.restore()}function P(N,$){return B;function B(U,M,J){let Y,de,we,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(X){return bt;function bt(Me){const at=Me!==null&&X[Me],ot=Me!==null&&X.null,En=[...Array.isArray(at)?at:at?[at]:[],...Array.isArray(ot)?ot:ot?[ot]:[]];return j(En)(Me)}}function j(X){return Y=X,de=0,X.length===0?J:g(X[de])}function g(X){return bt;function bt(Me){return m=z(),we=X,X.partial||(l.currentConstruct=X),X.name&&l.parser.constructs.disable.null.includes(X.name)?se():X.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,se)(Me)}}function q(X){return N(we,m),M}function se(X){return m.restore(),++de<Y.length?g(Y[de]):J}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&ge(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:J};function J(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,b()}}function b(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function $c(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s==\"string\"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function zc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a==\"string\")o=a;else switch(a){case-5:{o=\"\\r\";break}case-4:{o=`\n`;break}case-3:{o=`\\r\n`;break}case-2:{o=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;o=\" \";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(\"\")}function Fc(e){const r={constructs:Fl([Nc,...(e||{}).extensions||[]]),content:i(Kl),defined:[],document:i(Zl),flow:i(mc),lazy:{},string:i(bc),text:i(vc)};return r;function i(a){return o;function o(s){return Dc(r,a,s)}}}function Rc(e){for(;!Ga(e););return e}const Ni=/[\\0\\t\\n\\r]/g;function Oc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,c,h,f;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if(Ni.lastIndex=c,l=Ni.exec(a),h=l&&l.index!==void 0?l.index:a.length,f=a.charCodeAt(h),!l){t=a.slice(c);break}if(f===10&&c===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<h&&(u.push(a.slice(c,h)),e+=h-c),f){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Mc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Yl(n)(Rc(Fc(n).document().write(Oc()(e,t,!0))))}const zn={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Lc(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=zn[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=zn[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,Vc)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+zn[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Vc(e,t){return t===\"|\"?t:e}class Bc{constructor(){this.map=[]}add(t,n,r){Hc(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function Hc(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function qc(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function Uc(){return{flow:{null:{name:\"table\",tokenize:jc,resolveAll:Wc}}}}function jc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(b){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?y:u;return B===y&&r.parser.lazy[r.now().line]?n(b):B(b)}function u(b){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(b)}function l(b){return b===124||(o=!0,a+=1),d(b)}function d(b){return b===null?n(b):R(b)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(b),e.exit(\"lineEnding\"),f):n(b):L(b)?H(e,d,\"whitespace\")(b):(a+=1,o&&(o=!1,i+=1),b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),o=!0,d):(e.enter(\"data\"),c(b)))}function c(b){return b===null||b===124||oe(b)?(e.exit(\"data\"),d(b)):(e.consume(b),b===92?h:c)}function h(b){return b===92||b===124?(e.consume(b),c):c(b)}function f(b){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(b):(e.enter(\"tableDelimiterRow\"),o=!1,L(b)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(b):p(b))}function p(b){return b===45||b===58?x(b):b===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),w):I(b)}function w(b){return L(b)?H(e,x,\"whitespace\")(b):x(b)}function x(b){return b===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),_):b===45?(a+=1,_(b)):b===null||R(b)?A(b):I(b)}function _(b){return b===45?(e.enter(\"tableDelimiterFiller\"),v(b)):I(b)}function v(b){return b===45?(e.consume(b),v):b===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(b),e.exit(\"tableDelimiterMarker\"),S):(e.exit(\"tableDelimiterFiller\"),S(b))}function S(b){return L(b)?H(e,A,\"whitespace\")(b):A(b)}function A(b){return b===124?p(b):b===null||R(b)?!o||i!==a?I(b):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(b)):I(b)}function I(b){return n(b)}function y(b){return e.enter(\"tableRow\"),P(b)}function P(b){return b===124?(e.enter(\"tableCellDivider\"),e.consume(b),e.exit(\"tableCellDivider\"),P):b===null||R(b)?(e.exit(\"tableRow\"),t(b)):L(b)?H(e,P,\"whitespace\")(b):(e.enter(\"data\"),T(b))}function T(b){return b===null||b===124||oe(b)?(e.exit(\"data\"),P(b)):(e.consume(b),b===92?z:T)}function z(b){return b===92||b===124?(e.consume(b),T):T(b)}}function Wc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,d,c;const h=new Bc;for(;++n<e.length;){const f=e[n],p=f[1];f[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(Di(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Jt(h,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Jt(h,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Jt(h,t,a,i,n,c)):o[1]!==0&&(c=Jt(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&Di(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=qc(t.events,n))}return e}function Jt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},st(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=st(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=st(t.events,n[2]),d=st(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const h=t.events[n[2]],f=t.events[n[3]];if(h[1].end=Object.assign({},f[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,w=n[3]-n[2]-1;e.add(p,w,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},st(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function Di(e,t,n,r,i){const a=[],o=st(t.events,n);i&&(i.end=Object.assign({},o),a.push([\"exit\",i,t])),r.end=Object.assign({},o),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function st(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Qc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Gc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const d={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},h=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],f=s.parser.constructs.insideSpan.null;f&&ge(h,h.length,0,kn(f,o.slice(l+1,u),s)),ge(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",d,s]]),ge(o,l-1,u-l+3,h),u=l+h.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,d=this.events;let c=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),f(p))}function f(p){const w=mn(l);if(p===126)return c>1?u(p):(o.consume(p),c++,f);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=mn(p);return x._open=!_||_===2&&!!w,x._close=!w||w===2&&!!_,s(p)}}}function Yc(e){return Mc(e,{allowDangerousHtml:!0,extensions:[Uc(),Gc()],htmlExtensions:[Lc(),Qc()]})}const Kc={update:()=>{},getValues:()=>({})},Te=pt({}),jt=pt(Kc),Ne=pt(!1);function Jc(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>eo(a,o,t));return k(G,{children:i})}function eo(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>eo(u,l,n));return K(i,o,...s)}return null}function Zc({node:e}){const t=Cr(),n=ae(Ne),r=ae(Te),i={};for(const[a,o]of Object.entries(e.attributes))i[a]=t(o)??o;return K(e.tag,i,e.children.length>0?De(e.children,{nobr:n,locals:r}):void 0)}function Xc(e,t){if(zl(e.name))return null;const n=Tl(e.name);if(n)return k(Pl,{body:n.body,params:n.params,rawArgs:e.rawArgs},t);const r=Dl(e.name);return r?k(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):k(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function or(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return k(ml,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return Xc(e,t);case\"html\":return k(Zc,{node:e},t);default:return e}}function to(e){return e.length===0?null:e.map((t,n)=>or(t,n))}function ef(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function tf(e,t){const n=C.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function De(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>or(s,u));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value.replace(/^[ \\t]{4,}/gm,\" \");else if(u.type===\"variable\"&&ef(i))i+=tf(u,a);else{const l=r.length;r.push(or(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=Yc(i);return Jc(o,r,t?.nobr)}function nf(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 rf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||typeof t.historyIndex!=\"number\")}const af=\"spindle\",of=1;let Zt=null,Fn=null;function qe(){return Fn||(Fn={saves:new Map,playthroughs:new Map,meta:new Map}),Fn}function sf(){return Zt||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(Zt=new Promise((e,t)=>{const n=indexedDB.open(af,of);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),Zt))}function Ue(e,t){return sf().then(n=>n.transaction(e,t).objectStore(e))}function je(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function xn(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.put(e))}catch{qe().saves.set(e.meta.id,e)}}async function Cn(e){try{const t=await Ue(\"saves\",\"readonly\");return await je(t.get(e))??void 0}catch{return qe().saves.get(e)}}async function lf(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.delete(e))}catch{qe().saves.delete(e)}}async function uf(e){try{const n=(await Ue(\"saves\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().saves.values()].filter(t=>t.meta.ifid===e)}}async function no(e){try{const t=await Ue(\"playthroughs\",\"readwrite\");await je(t.put(e))}catch{qe().playthroughs.set(e.id,e)}}async function Pr(e){try{const n=(await Ue(\"playthroughs\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().playthroughs.values()].filter(t=>t.ifid===e)}}async function Tr(e){try{const t=await Ue(\"meta\",\"readonly\"),n=await je(t.get(e));return n?n.value:void 0}catch{return qe().meta.get(e)}}async function ro(e,t){try{const n=await Ue(\"meta\",\"readwrite\");await je(n.put({key:e,value:t}))}catch{qe().meta.set(e,t)}}const io=new Map,In=new Map;function cf(e,t){io.set(e,t),In.set(t,e)}function ff(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ne(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(In.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(ff(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const sr=\"__spindle_class__\",lr=\"__spindle_data__\";function Ke(e){const t=new Set;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))throw new Error(\"spindle: Cannot serialize circular references\");if(t.add(i),r instanceof Date)return t.delete(i),r.toISOString();if(r instanceof RegExp)return t.delete(i),r.toString();if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=In.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[sr]:o,[lr]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Je(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(o=>t(o));const r=n;if(sr in r&&lr in r){const o=r[sr],s=r[lr],u=io.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const d={};for(const c of Object.keys(s))d[c]=t(s[c]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(In.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let ur=null,cr=null,$i=!1;function df(e){ur=e}function hf(e){cr=e}function pf(e){if(cr)try{const i=new Function(\"passage\",\"variables\",cr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(ur)try{const r=ur(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function gf(){$i||($i=!0)}async function zi(e){const n=(await Pr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await no(i),await ro(`currentPlaythroughId.${e}`,r),r}async function mf(e){return Tr(`currentPlaythroughId.${e}`)}async function ao(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:pf(n),passage:n.passage,custom:r},o=ne(n);o.variables=Ke(o.variables),o.history=o.history.map(u=>({...u,variables:Ke(u.variables)}));const s={meta:a,payload:o};return await xn(s),s}async function oo(e,t){const n=await Cn(e);if(!n)return;const r=ne(t);r.variables=Ke(r.variables),r.history=r.history.map(a=>({...a,variables:Ke(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await xn(i),i}async function _f(e){const t=await Cn(e);if(!t)return;const n=t.payload;return n.variables=Je(n.variables),n.history=n.history.map(r=>({...r,variables:Je(r.variables)})),n}async function yf(e){await lf(e)}async function bf(e,t){const n=await Cn(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await xn(r)}async function vf(e){const[t,n]=await Promise.all([uf(e),Pr(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const so=\"autosave.\";async function wf(e,t,n){const r=`${so}${e}`,i=await Tr(r);if(i){const o=await oo(i,n);if(o)return o}const a=await ao(e,t,n,{isAutosave:!0});return await ro(r,a.meta.id),a}async function kf(e){const t=`${so}${e}`,n=await Tr(t);if(n)return _f(n)}const Nr=\"spindle.session.\";function Sf(e,t){try{sessionStorage.setItem(`${Nr}${e}`,JSON.stringify(t))}catch{}}function xf(e){try{const t=sessionStorage.getItem(`${Nr}${e}`);if(!t)return;const n=JSON.parse(t);if(!rf(n))return;const r=n;return r.variables=Je(r.variables),r.history=r.history.map(i=>({...i,variables:Je(i.variables)})),r}catch{return}}function Cf(e){try{sessionStorage.removeItem(`${Nr}${e}`)}catch{}}async function If(e){const t=await Cn(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Ef(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=ne(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Pr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await no(a)}return await xn(n),n}function lo(){const e=C.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=mt(t.content),i=_t(r),a=document.createElement(\"div\");be(K(()=>De(i),null),a),be(null,a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&hf(n.content)}let uo=0,ye=[],Rn=!1,rt=[],Pt=null,ut=null;function Dr(e){const t=C.getState();try{return!!wn(e,t.variables,t.temporary)}catch{return!1}}function co(e,t){const n=uo++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:Dr(e),priority:i?.priority??0};return ye.push(o),ye.sort((s,u)=>u.priority-s.priority),()=>{ye=ye.filter(s=>s.id!==n)}}function fo(e){ye=ye.filter(t=>t.name!==e)}function Af(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=C.getState();Ma(n.run,r.variables,r.temporary)}n.dialog&&(rt.push({passageName:n.dialog}),Pt?.()),n.goto&&C.getState().navigate(n.goto)}}const Pf=10;function Tf(){if(!Rn){Rn=!0;try{for(let e=0;e<Pf;e++){let t=!1;const n=[...ye];for(const r of n){if(!ye.includes(r))continue;const i=Dr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(ye=ye.filter(o=>o.id!==r.id)),Af(r))}if(!t)break}}finally{Rn=!1}}}function Nf(){for(const e of ye)e.lastResult=Dr(e.condition)}function Df(){ye=[],rt=[],uo=0,ut?.close()}function $f(e){return Pt=e,rt.length>0&&e(),()=>{Pt===e&&(Pt=null)}}function Fi(){return rt.shift()}function zf(){return rt.length}function Ff(e){rt.push(e),Pt?.()}function Rf(){rt=[]}function Of(e){return ut=e,()=>{ut===e&&(ut=null)}}function Ri(){ut?.close()}function Mf(){return ut?.isOpen()??!1}el();const Lf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ye={},me=[],Le={};function Oi(e){return e.map(t=>({...t,value:t.value!==void 0?ne(t.value):void 0}))}function Mi(e,t){const[,n,r]=nl(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:Oi(n),inverse:Oi(r)}}function Vf(e){let t=Ye;for(let n=0;n<e;n++)t=lt(t,me[n].forward);return t}let _e=[];function On(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(_e.length>i.length&&(_e.length=i.length),_e.length<i.length)if(i.length-_e.length===1){const l=i.length-1;_e[l]={passage:i[l].passage,variables:Ke(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ye;for(let d=0;d<i.length;d++)if(d>0&&(l=lt(l,me[d-1].forward)),d>=_e.length){const c=d===i.length-1?r:l;_e[d]={passage:i[d].passage,variables:Ke(c),timestamp:i[d].timestamp,prng:i[d].prng}}}Sf(t.ifid,{passage:n,variables:Ke(r),history:_e,historyIndex:a,visitCounts:o,renderCounts:s,prng:gn()})}}function Li(e){Ye=e,me=[],Le=e,_e=[]}function Vi(e){e?.prng?za(e.prng.seed,e.prng.pull):e&&tr()}const C=Os()(il((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=ne(r);Li(ne(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Le=t().variables;const o=n.ifid;gf().then(async()=>{const s=await mf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await zi(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Lf.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=Mi(Le,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),me.length=o.historyIndex,me.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:gn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ye=lt(Ye,me[u].forward);o.history=o.history.slice(s),me=me.slice(s),_e=_e.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Le=t().variables,On(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=ne(lt(r,me[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Le=t().variables,Vi(t().history[t().historyIndex]),On(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=ne(lt(i,me[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Le=t().variables,Vi(t().history[t().historyIndex]),On(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;tr(),Df();const a=ne(r);Li(ne(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Le=t().variables,lo(),Cf(n.ifid),zi(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),wf(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),kf(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=Ye;for(let d=0;d<i.length;d++)d>0&&(l=lt(l,me[d-1].forward)),u.push({passage:i[d].passage,variables:ne(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:ne(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:gn()}},loadFromPayload:n=>{const r=Je(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=Je(n.history[o].variables);i.push(Mi(a,s)),a=s}Ye=ne(r),me=i,_e=[],e(o=>{o.currentPassage=n.passage,o.variables=Je(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=Math.max(0,Math.min(n.historyIndex,o.history.length-1)),o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),Le=t().variables,n.prng?za(n.prng.seed,n.prng.pull):tr()},getHistoryVariables:n=>ne(Vf(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n}}))),Bf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Hf(){const t=C(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Bf,r=t?.tags.includes(\"nobr\")??!1,i=fe(()=>{try{const a=mt(n),o=_t(a);return k(G,{children:to(o)})}catch(a){return k(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?k(Ne.Provider,{value:!0,children:i}):i}const ho=pt(null);function $r({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=C(c=>c.storyData),s=(e?a?.passages.get(e):void 0)?.content??t,u=fe(()=>{if(!s)return k(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=mt(s),h=_t(c);return De(h)}catch(c){return k(\"div\",{class:\"error\",children:[\"Error in dialog: \",c.message]})}},[s]),l=c=>{c.target.classList.contains(\"dialog-overlay\")&&r()},d=n?`dialog-panel ${n}`:\"dialog-panel\";return k(ho.Provider,{value:r,children:k(\"div\",{class:\"dialog-overlay\",onClick:l,children:k(\"div\",{class:d,children:[i&&k(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),k(\"div\",{class:\"dialog-body\",children:u})]})})})}function qf(){const[e,t]=Z(null),n=ce(e);n.current=e;const r=ve(()=>{const a=Fi();t(a??null)},[]),i=ve(()=>{t(null),zf()>0&&requestAnimationFrame(r)},[r]);return Se(()=>Of({close:i,isOpen:()=>n.current!==null}),[i]),Se(()=>$f(()=>{t(a=>a!==null?a:Fi()??null)}),[]),e?k($r,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton}):null}function Uf(){const e=C(i=>i.storyData),t=C(i=>i.currentPassage),n=C(i=>i.nobr);if(Se(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),C.getState().save()):a.key===\"F9\"&&(a.preventDefault(),C.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return k(\"div\",{class:\"loading\",children:\"Loading...\"});const r=k(G,{children:[k(Hf,{}),k(qf,{})]});return n?k(Ne.Provider,{value:!0,children:r}):r}function jf(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Wf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",d=new Map,c=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",w=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),x=jf(h.innerHTML),_={},v=new Set([\"pid\",\"name\",\"tags\"]);for(const A of h.attributes)v.has(A.name)||(_[A.name]=A.value);const S={pid:f,name:p,tags:w,metadata:_,content:x};d.set(p,S),c.set(f,S)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:d,passagesById:c,userCSS:s,userScript:l}}const kt=new Map;let le={},Bi=!1;function po(){return`spindle.${C.getState().storyData?.ifid||\"unknown\"}.settings`}function Qf(){localStorage.setItem(po(),JSON.stringify(le))}function Mn(){if(!Bi){Bi=!0;try{const e=localStorage.getItem(po());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(le={...le,...t})}}catch{}}}const Rt={addToggle(e,t){kt.set(e,{type:\"toggle\",config:t}),e in le||(le[e]=t.default),Mn()},addList(e,t){kt.set(e,{type:\"list\",config:t}),e in le||(le[e]=t.default),Mn()},addRange(e,t){kt.set(e,{type:\"range\",config:t}),e in le||(le[e]=t.default),Mn()},get(e){return le[e]},getToggle(e){const t=le[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=le[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=le[e];return typeof t==\"number\"?t:0},set(e,t){le[e]=t,Qf()},getAll(){return{...le}},getDefinitions(){return kt},hasAny(){return kt.size>0}};function Gf(e,t,n){const r=C.getState(),i=ne(r.variables),a=ne(r.temporary),o={...t};Ma(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(s,o[s]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in a||r.deleteTemporary(s);for(const s of Object.keys(t))s in o||n(s,void 0)}const _n=new Map,fr=new Set,dr=new Map;function Yf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(dr.get(r)??0)+1;return dr.set(r,i),i===1?r:`${r}:${i}`}function Kf(e){return _n.set(e.id,e),qi(),()=>{_n.delete(e.id),qi()}}function Hi(){return Array.from(_n.values())}function Jf(e){return _n.get(e)}function Zf(){dr.clear()}function Xf(e){return fr.add(e),()=>{fr.delete(e)}}function qi(){for(const e of fr)e()}function ed(e){const t=ce(\"\");t.current||(t.current=Yf(e.type,e.key,e.authorId));const n=t.current;return nt(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),Kf(r)}),n}function td(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function go(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function zr(){const e=C.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?go(t):\"\"}function nd(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 rd(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function id(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const ad={useState:Z,useRef:ce,useEffect:Se,useLayoutEffect:nt,useCallback:ve,useMemo:fe,useContext:ae};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=Cr(),r=a(r),i=a(i));const{update:o,getValues:s}=ae(jt),u=ae(Ne),l=ae(Te),c={collectText:td,sourceLocation:zr,parseVarArgs:nd,extractOptions:rd,h:K,renderNodes:(h,f)=>De(h,{nobr:u,locals:l,...f}),renderInlineNodes:to,hooks:ad,useAction:ed,className:r,id:i,resolve:a,cls:id(e.name,r),mutate:h=>Gf(h,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){c.merged=xr();const h=c.merged;c.evaluate=f=>wn(f,h[0],h[1],h[2])}if(e.storeVar){const f=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");c.varName=f,c.value=C(w=>w.variables[f]);const p=C(w=>w.setVariable);c.setValue=w=>p(f,w)}return c.wrap=h=>c.className||c.id?K(\"span\",{id:c.id,class:c.className},h):K(G,null,h),e.render(n,c)}if(Nl(e.name,t),e.subMacros)for(const n of e.subMacros)$l(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&ul(e.name)}function od(){return{get(e){return C.getState().variables[e]},set(e,t){const n=C.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){C.getState().navigate(e)},back(){C.getState().goBack()},forward(){C.getState().goForward()},restart(){C.getState().restart()},save(e){C.getState().save(e)},load(e){C.getState().load(e)},hasSave(e){return C.getState().hasSave(e)},visited(e){const t=C.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=C.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=C.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=C.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=C.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=C.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return C.getState().storyData?.name||\"\"},get passage(){return C.getState().currentPassage},settings:Rt,registerClass(e,t){cf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){df(e)}},getActions(){return Hi()},performAction(e,t){const n=Jf(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=C.getState().currentPassage;return C.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return Xf(t);if(e===\"variableChanged\"){let n={...C.getState().variables};return C.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Hi())})})})},watch(e,t){return co(e,t)},unwatch(e){fo(e)},openDialog(e,t){Ff({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Ri()},closeAllDialogs(){Rf(),Ri()},isDialogOpen(){return Mf()},setNobr(e){C.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){C.getState().setTransition(e)},setNextTransition(e){C.getState().setNextTransition(e)},random(){return Ir()},randomInt(e,t){return Fa(e,t)},config:{get maxHistory(){return C.getState().maxHistory},set maxHistory(e){C.getState().setMaxHistory(e)}},prng:{init(e,t){_l(e,t);const{historyIndex:n}=C.getState();C.setState(r=>{const i=r.history[n];i&&(i.prng=gn())})},isEnabled(){return yl()},get seed(){return bl()},get pull(){return vl()}}}}function sd(){window.Story=od()}const ld=/^\\$(\\w+)\\s*=\\s*(.+)$/,Ui=/\\$(\\w+(?:\\.\\w+)*)/g,ji=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,ud=new Set([\"number\",\"string\",\"boolean\"]);function mo(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,mo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!ud.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function cd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(ld);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=mo(s);t.set(a,{...u,name:a,default:s})}return t}function fd(e){const t=new Set;let n;for(ji.lastIndex=0;(n=ji.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function dd(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function hd(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=fd(i.content);let o;for(Ui.lastIndex=0;(o=Ui.exec(i.content))!==null;){const s=o[1],u=dd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function pd(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Be({macro:e,error:t}){return k(\"span\",{class:\"error\",title:String(t),children:`{${e} error${zr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return k(Be,{macro:\"print\",error:n})}}});function gd(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function md(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function Wi(e,t,n,r,i,a,o){const s=C.getState();let u;try{u=wn(e,r,i,a)}catch(d){console.error(`spindle: Error in {computed ${o}}${zr()}:`,d);return}const l=n?s.temporary[t]:s.variables[t];md(l,u)||(n?s.setTemporary(t,u):s.setVariable(t,u))}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=gd(e))}catch(d){return k(Be,{macro:\"computed\",error:d})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);if(!l.current){l.current=!0;const d=C.getState();Wi(o,u,s,d.variables,d.temporary,i,e)}return t.hooks.useLayoutEffect(()=>{Wi(o,u,s,n,r,i,e)},[n,r,i]),null}});function _d(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=yd(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 yd(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 bd(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=_d(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=bd(a,o,i),l=t.cls;return k(\"div\",{class:l,id:t.id,children:[k(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&k(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return k(Be,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?k(\"span\",{id:o,class:a,children:i}):k(G,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return k(Be,{macro:\"if\",error:i})}}return null}});function vd(e){const t=e.indexOf(\" of \");if(t===-1)throw new Error(`{for} requires \"of\" keyword: {for ${e}}`);const n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(\",\").map(s=>s.trim()),a=i[0],o=i.length>1?i[1]:null;if(!a.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(o&&!o.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${o}\"`);return{itemVar:a.slice(1),indexVar:o?o.slice(1):null,listExpr:r}}function wd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=Z(()=>({...e,...t,...n})),o=ce(i);o.current=i;const s=ve(()=>o.current,[]),u=ve((c,h)=>{a(f=>({...f,[c]:h}))},[]),l=fe(()=>({update:u,getValues:s}),[u,s]),d=ae(Ne);return k(jt.Provider,{value:l,children:k(Te.Provider,{value:i,children:De(r,{nobr:d,locals:i})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=ae(Te);let i;try{i=vd(e)}catch(d){return k(Be,{macro:\"for\",error:d})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return k(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return k(Be,{macro:\"for\",error:d})}const l=u.map((d,c)=>{const h={[a]:d,...o?{[o]:c}:void 0};return k(wd,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${c}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=()=>{const a=document.createElement(\"div\"),o=K(jt.Provider,{value:{update:n.update,getValues:n.getValues}},K(Te.Provider,{value:n.getValues()},De(t)));be(o,a),be(null,a)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:i}),k(\"button\",{id:n.id,class:n.cls,onClick:i,children:r})}});function kd(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Qi(e,t,n){const r=document.createElement(\"div\"),i=K(jt.Provider,{value:{update:n,getValues:t}},K(Te.Provider,{value:t()},De(e)));be(i,r),be(null,r)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=kd(e),a=o=>{o.preventDefault(),Qi(t,n.getValues,n.update),i&&C.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Qi(t,n.getValues,n.update),i&&C.getState().navigate(i)}}),k(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:a,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return k(Be,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return k(G,{children:n.renderNodes(o.children)})}catch(s){return k(Be,{macro:\"case\",error:s})}}return i?k(G,{children:n.renderNodes(i.children)}):null}});function Fr(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(f=>({delay:f.rawArgs?Fr(f.rawArgs):0,nodes:f.children,className:f.className,id:f.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const f=o+1,p=a[f].delay,w=setTimeout(()=>{s(f)},p);return()=>clearTimeout(w)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),d=t.resolve(u.className),c=t.resolve(u.id),h=d||c?k(\"span\",{id:c,class:d,children:l}):l;return t.wrap(h)}});const _o=pt({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Fr(e),[s,u]=r(0),[l,d]=r(!1),c=a(()=>d(!0),[]);if(i(()=>{if(l)return;const f=setInterval(()=>{u(p=>p+1)},o);return()=>clearInterval(f)},[o,l]),s===0&&!l)return null;const h=k(_o.Provider,{value:{stop:c},children:k(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?k(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(_o);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Fr(e),s=a(null),[u,l]=r(0),[d,c]=r(0);i(()=>{if(s.current){const p=s.current.textContent||\"\";l(p.length)}},[]),i(()=>{if(u===0||d>=u)return;const p=setInterval(()=>{c(w=>w>=u?(clearInterval(p),w):w+1)},o);return()=>clearInterval(p)},[u,o]);const h=d>=u&&u>0,f=[\"macro-type\",h?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return k(\"span\",{id:n.id,class:f,ref:s,style:{clipPath:(u>0&&!h,void 0)},children:[k(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!h?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!h&&u>0&&k(\"span\",{class:\"macro-type-cursor\"})]})}});function Sd(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=Sd(e);return n.hooks.useLayoutEffect(()=>{Va(r,t,i)},[]),null}});V({name:\"story-title\",render(e,t){const n=C(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return k(\"span\",{id:t.id,class:r,children:n})}});function it(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=Z(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),k(G,{children:[k(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&k($r,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}it({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:C(e=>e.goBack),disabled:!C(e=>e.historyIndex>0)})});it({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:C(e=>e.goForward),disabled:!C(e=>e.historyIndex<e.history.length-1)})});it({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:C(e=>e.save)})});it({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=C(n=>n.load),t=C(n=>n.hasSave);return C(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});it({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:C(e=>e.restart)})});it({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});it({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Rt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return k(G,{children:[k(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&k($r,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function xd(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 Cd(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Id(){const[e,t]=Z(\"load\"),[n,r]=Z([]),[i,a]=Z(!0),[o,s]=Z(null),[u,l]=Z(()=>new Set),[d,c]=Z(null),[h,f]=Z(\"\"),p=ce(null),w=ce(null),x=ae(ho),_=C(D=>D.storyData),v=C(D=>D.playthroughId),S=C(D=>D.getSavePayload),A=C(D=>D.loadFromPayload),I=_?.ifid??\"\",y=ve(async()=>{if(!I)return;const D=await vf(I);r(D),a(!1)},[I]);Se(()=>{y()},[y]),Se(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const P=ce(),T=(D,j=\"success\")=>{clearTimeout(P.current),s({text:D,type:j}),P.current=window.setTimeout(()=>s(null),3e3)},z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},b=async()=>{if(!(!I||!v))try{const D=S();await ao(I,v,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=S();await oo(D,j),T(\"Save overwritten\"),await y()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{A(D.payload),T(\"Game loaded\"),x&&setTimeout(x,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await yf(D),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{c(D.meta.id),f(D.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await bf(d,h.trim()),c(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},J=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&c(null)},Y=async D=>{try{const j=await If(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),se=document.createElement(\"a\");se.href=q,se.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,se.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},de=()=>{w.current?.click()},we=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),se=JSON.parse(q);if(!nf(se))throw new Error(\"Invalid save file format\");await Ef(se,I),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.saves.length,0);return k(\"div\",{class:\"save-manager\",children:[k(\"div\",{class:\"saves-header\",children:k(\"div\",{class:\"saves-header-left\",children:k(\"div\",{class:\"saves-mode-toggle\",children:[k(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),k(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),k(\"div\",{class:\"saves-toolbar\",children:[k(\"button\",{class:\"saves-toolbar-button\",onClick:de,children:\"Import\"}),k(\"input\",{ref:w,type:\"file\",accept:\".json\",style:\"display:none\",onChange:we})]}),k(\"div\",{class:\"saves-body\",children:[i?k(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?k(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===v;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:k(\"div\",{class:\"playthrough-group\",children:[k(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[k(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),k(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),k(\"span\",{class:\"playthrough-date\",children:Cd(D.playthrough.createdAt)})]}),!j&&k(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>k(\"div\",{class:\"save-slot\",children:[k(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?k(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:se=>f(se.target.value),onKeyDown:J,onBlur:M}):k(\"div\",{class:\"save-slot-title\",children:q.meta.title}),k(\"div\",{class:\"save-slot-meta\",children:[k(\"span\",{children:q.meta.passage}),k(\"span\",{children:xd(q.meta.updatedAt)})]})]}),k(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?k(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):k(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),k(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),k(\"button\",{class:\"save-slot-action\",onClick:()=>Y(q.meta.id),children:\"Export\"}),k(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&k(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===v)&&k(\"div\",{class:\"playthrough-group\",children:k(\"div\",{class:\"playthrough-saves\",children:k(\"button\",{class:\"save-slot-new\",onClick:b,children:\"+ New Save\"})})})]}),o&&k(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return k(Id,{})}});function Ed({name:e,def:t}){const[n,r]=Z(()=>Rt.get(e)),i=a=>{r(a),Rt.set(e,a)};switch(t.type){case\"toggle\":return k(\"label\",{class:\"settings-row\",children:[k(\"span\",{children:t.config.label}),k(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return k(\"label\",{class:\"settings-row\",children:[k(\"span\",{children:t.config.label}),k(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>k(\"option\",{value:a,children:a},a))})]});case\"range\":return k(\"label\",{class:\"settings-row\",children:[k(\"span\",{children:[t.config.label,\": \",String(n)]}),k(\"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 Ad(){const e=Rt.getDefinitions();return k(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>k(Ed,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return k(Ad,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=C(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&C.getState().trackRender(a),!o)return k(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=mt(o.content),l=_t(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(Ne.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(Ne.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}C.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=C.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),k(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),k(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),k(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Pd(e){return e.match(/^\\s*[\"']?\\$?\\w+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Pd(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),k(\"label\",{id:t.id,class:t.cls,children:[k(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function Td(e){const t=e.match(/^\\s*[\"']?\\$?\\w+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=Td(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),k(\"label\",{id:t.id,class:t.cls,children:[k(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),k(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>k(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=C.getState().variables[t.varName],o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),k(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function xt(e){const t=mt(e.content),n=_t(t),r=e.tags.includes(\"nobr\");return De(n,r?{nobr:!0}:void 0)}const Nd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Dd({passage:e,dataTransition:t}){const n=C(w=>w.storyData),r=Nd.has(e.name),[i,a]=Z(!1),o=fe(()=>{try{return xt(e)}catch(w){return k(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",go(e),\": \",w.message]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=fe(()=>{if(!s)return null;try{return xt(s)}catch(w){return console.error(\"spindle: Error in PassageHeader:\",w),null}},[s?.content]),c=fe(()=>{if(!u)return null;try{return xt(u)}catch(w){return console.error(\"spindle: Error in PassageFooter:\",w),null}},[u?.content]);Se(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=fe(()=>{if(!i||!l)return null;try{return xt(l)}catch(w){return console.error(\"spindle: Error in PassageDone:\",w),null}},[i,l?.content]),f=e.tags.includes(\"nobr\"),p=k(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&k(\"div\",{class:\"passage-header\",children:d}),o,c&&k(\"div\",{class:\"passage-footer\",children:c}),h&&k(\"div\",{hidden:!0,children:h})]});return f?k(Ne.Provider,{value:!0,children:p}):p}const $d=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),hr={type:\"fade-through\",duration:300,pause:50};function zd(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!$d.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function Ln(e){return{type:e.type,duration:e.duration??hr.duration,pause:e.pause??hr.pause}}function Fd(e,t,n){const r=zd(e);return r?Ln(r):t?Ln(t):n?Ln(n):{...hr}}function Gi(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function Vn(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function Bn(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=C(f=>f.currentPassage),r=C(f=>f.storyData),[i,a]=Z(n),o=ce(\"fade\"),s=ce(0),u=ce(null),l=ce([]),d=ve(()=>{for(const f of l.current)clearTimeout(f);l.current=[],Bn(u.current)},[]);Se(()=>{const f=C.getState(),{history:p,historyIndex:w,transitionConfig:x}=f,_=f.consumeNextTransition(),v=s.current;s.current=p.length;const S=!i,A=p.length===1&&w===0&&v>1,I=p.length>1&&w===p.length-1&&v>1&&Math.abs(p.length-v)>1;if(n===i)return;d();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(S||A||I){o.current=\"fade\",a(n);return}const P=Fd(y.tags,_,x);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&Vn(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}Vn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Gi(z,P.type);T.appendChild(b),a(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{a(n)},N),B=N+P.duration,U=setTimeout(()=>{Bn(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}Vn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const b=Gi(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(b),a(n);const N=setTimeout(()=>{Bn(T)},P.duration);l.current=[N];return}a(n)},[n]);const c=i?r?.passages.get(i):null;if(!c&&i)return k(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return k(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&k(\"div\",{hidden:!0,children:xt(h)},`ready-${n}`),k(\"div\",{class:\"passage-container\",ref:u,children:c&&k(Dd,{passage:c,dataTransition:o.current},i)})]})}});V({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const c=l[1]??l[5],h=l[2]??l[3]??l[4];if(c)switch(c){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,co(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,fo(r)),null}});const Rd='*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}';function Yi(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const o=document.createElement(\"li\");o.textContent=a,i.appendChild(o)}n.appendChild(i),e.appendChild(n)}function Ki(){const e=Wf(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Rd,document.head.appendChild(t),sd(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",f=document.getElementById(\"root\");throw f&&Yi(f,[h]),new Error(`spindle: ${h}`)}const i=cd(r.content),a=hd(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&Yi(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=pd(i),C.getState().init(e,n),lo();const o=xf(e.ifid);o&&C.getState().loadFromPayload(o);for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const f=mt(h.content),p=_t(f);for(const w of p)if(w.type===\"macro\"&&w.name===\"widget\"&&w.rawArgs){const x=w.rawArgs.trim().split(/\\s+/),_=x[0].replace(/[\"']/g,\"\"),v=x.slice(1).filter(S=>S.startsWith(\"$\")||S.startsWith(\"_\")||S.startsWith(\"@\"));Va(_,w.children,v)}}let s=\"\";C.subscribe(h=>{h.currentPassage!==s&&(s=h.currentPassage,Zf())});let u=C.getState().variables,l=C.getState().historyIndex;C.subscribe(h=>{h.variables!==u&&(h.historyIndex===l?Tf():Nf()),u=h.variables,l=h.historyIndex});const d=e.passages.get(\"StoryInterface\");d&&!d.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const c=document.getElementById(\"root\");if(!c)throw new Error('spindle: No <div id=\"root\"> element found.');be(k(Uf,{}),c),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Ki):Ki();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|
|
1
|
+
window.storyFormat({"name":"spindle","version":"0.29.1","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>(function(){const t=document.createElement(\"link\").relList;if(t&&t.supports&&t.supports(\"modulepreload\"))return;for(const i of document.querySelectorAll('link[rel=\"modulepreload\"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type===\"childList\")for(const o of a.addedNodes)o.tagName===\"LINK\"&&o.rel===\"modulepreload\"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin===\"use-credentials\"?a.credentials=\"include\":i.crossOrigin===\"anonymous\"?a.credentials=\"omit\":a.credentials=\"same-origin\",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Lt,O,Xi,Qe,Wr,ea,ta,na,mr,jn,Wn,ra,ln={},un=[],Go=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Vt=Array.isArray;function Te(e,t){for(var n in t)e[n]=t[n];return e}function _r(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function G(e,t,n){var r,i,a,o={};for(a in t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?Lt.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return Ct(e,o,r,i,null)}function Ct(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Xi,__i:-1,__u:0};return i==null&&O.vnode!=null&&O.vnode(a),a}function Ko(){return{current:null}}function Y(e){return e.children}function Ne(e,t){this.props=e,this.context=t}function ft(e,t){if(t==null)return e.__?ft(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?ft(e):null}function Yo(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Te({},t);a.__v=t.__v+1,O.vnode&&O.vnode(a),yr(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??ft(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,sa(r,a,i),t.__e=t.__=null,a.__e!=n&&ia(a)}}function ia(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ia(e)}function Qn(e){(!e.__d&&(e.__d=!0)&&Qe.push(e)&&!cn.__r++||Wr!=O.debounceRendering)&&((Wr=O.debounceRendering)||ea)(cn)}function cn(){for(var e,t=1;Qe.length;)Qe.length>t&&Qe.sort(ta),e=Qe.shift(),t=Qe.length,Yo(e);cn.__r=0}function aa(e,t,n,r,i,a,o,s,u,l,d){var c,h,f,p,b,x,_,k=r&&r.__k||un,S=t.length;for(u=Jo(n,t,k,u,S),c=0;c<S;c++)(f=n.__k[c])!=null&&(h=f.__i!=-1&&k[f.__i]||ln,f.__i=c,x=yr(e,f,h,i,a,o,s,u,l,d),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&br(h.ref,null,f),d.push(f.ref,f.__c||p,f)),b==null&&p!=null&&(b=p),(_=!!(4&f.__u))||h.__k===f.__k?u=oa(f,u,e,_):typeof f.type==\"function\"&&x!==void 0?u=x:p&&(u=p.nextSibling),f.__u&=-7);return n.__e=b,u}function Jo(e,t,n,r,i){var a,o,s,u,l,d=n.length,c=d,h=0;for(e.__k=new Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=\"boolean\"&&typeof o!=\"function\"?(typeof o==\"string\"||typeof o==\"number\"||typeof o==\"bigint\"||o.constructor==String?o=e.__k[a]=Ct(null,o,null,null,null):Vt(o)?o=e.__k[a]=Ct(Y,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=Ct(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,u=a+h,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Zo(o,n,u,c))!=-1&&(c--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>d?h--:i<d&&h++),typeof o.type!=\"function\"&&(o.__u|=4)):l!=u&&(l==u-1?h--:l==u+1?h++:(l>u?h--:h++,o.__u|=4))):e.__k[a]=null;if(c)for(a=0;a<d;a++)(s=n[a])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=ft(s)),ua(s,s));return r}function oa(e,t,n,r){var i,a;if(typeof e.type==\"function\"){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=oa(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=ft(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Re(e,t){return t=t||[],e==null||typeof e==\"boolean\"||(Vt(e)?e.some(function(n){Re(n,t)}):t.push(e)),t}function Zo(e,t,n,r){var i,a,o,s=e.key,u=e.type,l=t[n],d=l!=null&&(2&l.__u)==0;if(l===null&&s==null||d&&s==l.key&&u==l.type)return n;if(r>(d?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&(2&l.__u)==0&&s==l.key&&u==l.type)return o}return-1}function Qr(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Go.test(t)?n:n+\"px\"}function Gt(e,t,n,r,i){var a,o;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||Qr(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Qr(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")a=t!=(t=t.replace(na,\"$1\")),o=t.toLowerCase(),t=o in e||t==\"onFocusOut\"||t==\"onFocusIn\"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+a]=n,n?r?n.u=r.u:(n.u=mr,e.addEventListener(t,a?Wn:jn,a)):e.removeEventListener(t,a?Wn:jn,a);else{if(i==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Gr(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=mr++;else if(t.t<n.u)return;return n(O.event?O.event(t):t)}}}function yr(e,t,n,r,i,a,o,s,u,l){var d,c,h,f,p,b,x,_,k,S,A,C,y,P,T,z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),a=[s=t.__e=n.__e]),(d=O.__b)&&d(t);e:if(typeof z==\"function\")try{if(_=t.props,k=\"prototype\"in z&&z.prototype.render,S=(d=z.contextType)&&r[d.__c],A=d?S?S.props.value:d.__:r,n.__c?x=(c=t.__c=n.__c).__=c.__E:(k?t.__c=c=new z(_,A):(t.__c=c=new Ne(_,A),c.constructor=z,c.render=es),S&&S.sub(c),c.state||(c.state={}),c.__n=r,h=c.__d=!0,c.__h=[],c._sb=[]),k&&c.__s==null&&(c.__s=c.state),k&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Te({},c.__s)),Te(c.__s,z.getDerivedStateFromProps(_,c.__s))),f=c.props,p=c.state,c.__v=t,h)k&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),k&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(k&&z.getDerivedStateFromProps==null&&_!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(_,A),t.__v==n.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(_,c.__s,A)===!1){t.__v!=n.__v&&(c.props=_,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(v){v&&(v.__=t)}),un.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(_,c.__s,A),k&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,p,b)})}if(c.context=A,c.props=_,c.__P=e,c.__e=!1,C=O.__r,y=0,k)c.state=c.__s,c.__d=!1,C&&C(t),d=c.render(c.props,c.state,c.context),un.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,C&&C(t),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++y<25);c.state=c.__s,c.getChildContext!=null&&(r=Te(Te({},r),c.getChildContext())),k&&!h&&c.getSnapshotBeforeUpdate!=null&&(b=c.getSnapshotBeforeUpdate(f,p)),P=d!=null&&d.type===Y&&d.key==null?la(d.props.children):d,s=aa(e,Vt(P)?P:[P],t,n,r,i,a,o,s,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),x&&(c.__E=c.__=null)}catch(v){if(t.__v=null,u||a!=null)if(v.then){for(t.__u|=u?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(T=a.length;T--;)_r(a[T]);Gn(t)}else t.__e=n.__e,t.__k=n.__k,v.then||Gn(t);O.__e(v,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Xo(n.__e,t,n,r,i,a,o,u,l);return(d=O.diffed)&&d(t),128&t.__u?void 0:s}function Gn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Gn))}function sa(e,t,n){for(var r=0;r<n.length;r++)br(n[r],n[++r],n[++r]);O.__c&&O.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){O.__e(a,i.__v)}})}function la(e){return typeof e!=\"object\"||e==null||e.__b>0?e:Vt(e)?e.map(la):Te({},e)}function Xo(e,t,n,r,i,a,o,s,u){var l,d,c,h,f,p,b,x=n.props||ln,_=t.props,k=t.type;if(k==\"svg\"?i=\"http://www.w3.org/2000/svg\":k==\"math\"?i=\"http://www.w3.org/1998/Math/MathML\":i||(i=\"http://www.w3.org/1999/xhtml\"),a!=null){for(l=0;l<a.length;l++)if((f=a[l])&&\"setAttribute\"in f==!!k&&(k?f.localName==k:f.nodeType==3)){e=f,a[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(_);e=document.createElementNS(i,k,_.is&&_),s&&(O.__m&&O.__m(t,a),s=!1),a=null}if(k==null)x===_||s&&e.data==_||(e.data=_);else{if(a=a&&Lt.call(e.childNodes),!s&&a!=null)for(x={},l=0;l<e.attributes.length;l++)x[(f=e.attributes[l]).name]=f.value;for(l in x)f=x[l],l==\"dangerouslySetInnerHTML\"?c=f:l==\"children\"||l in _||l==\"value\"&&\"defaultValue\"in _||l==\"checked\"&&\"defaultChecked\"in _||Gt(e,l,null,f,i);for(l in _)f=_[l],l==\"children\"?h=f:l==\"dangerouslySetInnerHTML\"?d=f:l==\"value\"?p=f:l==\"checked\"?b=f:s&&typeof f!=\"function\"||x[l]===f||Gt(e,l,f,x[l],i);if(d)s||c&&(d.__html==c.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(c&&(e.innerHTML=\"\"),aa(t.type==\"template\"?e.content:e,Vt(h)?h:[h],t,n,r,k==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":i,a,o,a?a[0]:n.__k&&ft(n,0),s,u),a!=null)for(l=a.length;l--;)_r(a[l]);s||(l=\"value\",k==\"progress\"&&p==null?e.removeAttribute(\"value\"):p!=null&&(p!==e[l]||k==\"progress\"&&!p||k==\"option\"&&p!=x[l])&&Gt(e,l,p,x[l],i),l=\"checked\",b!=null&&b!=e[l]&&Gt(e,l,b,x[l],i))}return e}function br(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){O.__e(i,n)}}function ua(e,t,n){var r,i;if(O.unmount&&O.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||br(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){O.__e(a,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&ua(r[i],t,n||typeof e.type!=\"function\");n||_r(e.__e),e.__c=e.__=e.__e=void 0}function es(e,t,n){return this.constructor(e,n)}function xe(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),i=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,a=[],o=[],yr(t,e=(!r&&n||t).__k=G(Y,null,[e]),i||ln,ln,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Lt.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),sa(a,e,o)}function ca(e,t){xe(e,t,ca)}function ts(e,t,n){var r,i,a,o,s=Te({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==\"key\"?r=t[a]:a==\"ref\"?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?Lt.call(arguments,2):n),Ct(e.type,s,r||e.key,i||e.ref,null)}function nt(e){function t(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(o){o.__e=!0,Qn(o)})},this.sub=function(a){r.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),o&&o.call(a)}}),n.children}return t.__c=\"__cC\"+ra++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,r){return n.children(r)}).contextType=t,t}Lt=un.slice,O={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(s){e=s}throw e}},Xi=0,Ne.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof e==\"function\"&&(e=e(Te({},n),this.props)),e&&Te(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Qn(this))},Ne.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Qn(this))},Ne.prototype.render=Y,Qe=[],ea=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ta=function(e,t){return e.__v.__b-t.__v.__b},cn.__r=0,na=/(PointerCapture)$|Capture$/i,mr=0,jn=Gr(!1),Wn=Gr(!0),ra=0;var ns=0;function w(e,t,n,r,i,a){t||(t={});var o,s,u=t;if(\"ref\"in u)for(s in u={},t)s==\"ref\"?o=t[s]:u[s]=t[s];var l={type:e,props:u,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ns,__i:-1,__u:0,__source:i,__self:a};if(typeof e==\"function\"&&(o=e.defaultProps))for(s in o)u[s]===void 0&&(u[s]=o[s]);return O.vnode&&O.vnode(l),l}var Ve,W,Nn,Kr,dt=0,fa=[],Q=O,Yr=Q.__b,Jr=Q.__r,Zr=Q.diffed,Xr=Q.__c,ei=Q.unmount,ti=Q.__;function gt(e,t){Q.__h&&Q.__h(W,e,dt||t),dt=0;var n=W.__H||(W.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return dt=1,vr(ga,e)}function vr(e,t,n){var r=gt(Ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ga(void 0,t),function(s){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,s);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(s,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(h){return h.__c});if(d.every(function(h){return!h.__N}))return!a||a.call(this,s,u,l);var c=r.__c.props!==s;return d.some(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(c=!0)}}),a&&a.call(this,s,u,l)||c};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(s,u,l){if(this.__e){var d=a;a=void 0,i(s,u,l),a=d}o&&o.call(this,s,u,l)},W.shouldComponentUpdate=i}return r.__N||r.__}function ve(e,t){var n=gt(Ve++,3);!Q.__s&&wr(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function rt(e,t){var n=gt(Ve++,4);!Q.__s&&wr(n.__H,t)&&(n.__=e,n.u=t,W.__h.push(n))}function fe(e){return dt=5,de(function(){return{current:e}},[])}function da(e,t,n){dt=6,rt(function(){if(typeof e==\"function\"){var r=e(t());return function(){e(null),r&&typeof r==\"function\"&&r()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function de(e,t){var n=gt(Ve++,7);return wr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function we(e,t){return dt=8,de(function(){return e},t)}function K(e){var t=W.context[e.__c],n=gt(Ve++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(W)),t.props.value):e.__}function ha(e,t){Q.useDebugValue&&Q.useDebugValue(t?t(e):e)}function pa(){var e=gt(Ve++,11);if(!e.__){for(var t=W.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=\"P\"+n[0]+\"-\"+n[1]++}return e.__}function rs(){for(var e;e=fa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(tn),t.__h.some(Kn),t.__h=[]}catch(n){t.__h=[],Q.__e(n,e.__v)}}}Q.__b=function(e){W=null,Yr&&Yr(e)},Q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ti&&ti(e,t)},Q.__r=function(e){Jr&&Jr(e),Ve=0;var t=(W=e.__c).__H;t&&(Nn===W?(t.__h=[],W.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(tn),t.__h.some(Kn),t.__h=[],Ve=0)),Nn=W},Q.diffed=function(e){Zr&&Zr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(fa.push(t)!==1&&Kr===Q.requestAnimationFrame||((Kr=Q.requestAnimationFrame)||is)(rs)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Nn=W=null},Q.__c=function(e,t){t.some(function(n){try{n.__h.some(tn),n.__h=n.__h.filter(function(r){return!r.__||Kn(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Q.__e(r,n.__v)}}),Xr&&Xr(e,t)},Q.unmount=function(e){ei&&ei(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{tn(r)}catch(i){t=i}}),n.__H=void 0,t&&Q.__e(t,n.__v))};var ni=typeof requestAnimationFrame==\"function\";function is(e){var t,n=function(){clearTimeout(r),ni&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ni&&(t=requestAnimationFrame(n))}function tn(e){var t=W,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),W=t}function Kn(e){var t=W;e.__c=e.__(),W=t}function wr(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ga(e,t){return typeof t==\"function\"?t(e):t}const ri=e=>{let t;const n=new Set,r=(l,d)=>{const c=typeof l==\"function\"?l(t):l;if(!Object.is(c,t)){const h=t;t=d??(typeof c!=\"object\"||c===null)?c:Object.assign({},t,c),n.forEach(f=>f(t,h))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>u,subscribe:l=>(n.add(l),()=>n.delete(l))},u=t=e(r,i,s);return s},as=(e=>e?ri(e):ri);function ma(e,t){for(var n in t)e[n]=t[n];return e}function Yn(e,t){for(var n in e)if(n!==\"__source\"&&!(n in t))return!0;for(var r in t)if(r!==\"__source\"&&e[r]!==t[r])return!0;return!1}function _a(e,t){var n=t(),r=X({t:{__:n,u:t}}),i=r[0].t,a=r[1];return rt(function(){i.__=n,i.u=t,Dn(i)&&a({t:i})},[e,n,t]),ve(function(){return Dn(i)&&a({t:i}),e(function(){Dn(i)&&a({t:i})})},[e]),n}function Dn(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function ya(e){e()}function ba(e){return e}function va(){return[!1,ya]}var wa=rt;function Jn(e,t){this.props=e,this.context=t}function os(e,t){function n(i){var a=this.props.ref,o=a==i.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,i)||!o:Yn(this.props,i)}function r(i){return this.shouldComponentUpdate=n,G(e,i)}return r.displayName=\"Memo(\"+(e.displayName||e.name)+\")\",r.prototype.isReactComponent=!0,r.__f=!0,r.type=e,r}(Jn.prototype=new Ne).isPureReactComponent=!0,Jn.prototype.shouldComponentUpdate=function(e,t){return Yn(this.props,e)||Yn(this.state,t)};var ii=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ii&&ii(e)};var ss=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.forward_ref\")||3911;function ls(e){function t(n){var r=ma({},n);return delete r.ref,e(r,n.ref||null)}return t.$$typeof=ss,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName=\"ForwardRef(\"+(e.displayName||e.name)+\")\",t}var ai=function(e,t){return e==null?null:Re(Re(e).map(t))},us={map:ai,forEach:ai,count:function(e){return e?Re(e).length:0},only:function(e){var t=Re(e);if(t.length!==1)throw\"Children.only\";return t[0]},toArray:Re},cs=O.__e;O.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}cs(e,t,n,r)};var oi=O.unmount;function ka(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c==\"function\"&&r.__c()}),e.__c.__H=null),(e=ma({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return ka(r,t,n)})),e}function Sa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Sa(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function nn(){this.__u=0,this.o=null,this.__b=null}function xa(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function fs(e){var t,n,r,i=null;function a(o){if(t||(t=e()).then(function(s){s&&(i=s.default||s),r=!0},function(s){n=s,r=!0}),n)throw n;if(!r)throw t;return i?G(i,o):null}return a.displayName=\"Lazy\",a.__f=!0,a}function St(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),oi&&oi(e)},(nn.prototype=new Ne).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var i=xa(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(u):u())};n.__R=o;var s=n.__P;n.__P=null;var u=function(){if(!--r.__u){if(r.state.__a){var l=r.state.__a;r.__v.__k[0]=Sa(l,l.__c.__P,l.__c.__O)}var d;for(r.setState({__a:r.__b=null});d=r.o.pop();)d.__P=s,d.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},nn.prototype.componentWillUnmount=function(){this.o=[]},nn.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(\"div\"),r=this.__v.__k[0].__c;this.__v.__k[0]=ka(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&G(Y,null,e.fallback);return i&&(i.__u&=-33),[G(Y,null,t.__a?null:e.children),i]};var si=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==\"t\"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function ds(e){return this.getChildContext=function(){return e.context},e.children}function hs(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){xe(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var r=t.__v;r!==null&&!r.__m&&r.__!==null;)r=r.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:r.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(i,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)}}}xe(G(ds,{context:t.context},e.__v),t.v)}function ps(e,t){var n=G(hs,{__v:e,h:t});return n.containerInfo=t,n}(St.prototype=new Ne).__a=function(e){var t=this,n=xa(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),si(t,e,r)):i()};n?n(a):a()}},St.prototype.render=function(e){this.i=null,this.l=new Map;var t=Re(e.children);e.revealOrder&&e.revealOrder[0]===\"b\"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},St.prototype.componentDidUpdate=St.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){si(e,n,t)})};var Ca=typeof Symbol<\"u\"&&Symbol.for&&Symbol.for(\"react.element\")||60103,gs=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,ms=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,_s=/[A-Z0-9]/g,ys=typeof document<\"u\",bs=function(e){return(typeof Symbol<\"u\"&&typeof Symbol()==\"symbol\"?/fil|che|rad/:/fil|che|ra/).test(e)};function vs(e,t,n){return t.__k==null&&(t.textContent=\"\"),xe(e,t),typeof n==\"function\"&&n(),e?e.__c:null}function ws(e,t,n){return ca(e,t),typeof n==\"function\"&&n(),e?e.__c:null}Ne.prototype.isReactComponent={},[\"componentWillMount\",\"componentWillReceiveProps\",\"componentWillUpdate\"].forEach(function(e){Object.defineProperty(Ne.prototype,e,{configurable:!0,get:function(){return this[\"UNSAFE_\"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var li=O.event;function ks(){}function Ss(){return this.cancelBubble}function xs(){return this.defaultPrevented}O.event=function(e){return li&&(e=li(e)),e.persist=ks,e.isPropagationStopped=Ss,e.isDefaultPrevented=xs,e.nativeEvent=e};var kr,Cs={enumerable:!1,configurable:!0,get:function(){return this.class}},ui=O.vnode;O.vnode=function(e){typeof e.type==\"string\"&&(function(t){var n=t.props,r=t.type,i={},a=r.indexOf(\"-\")===-1;for(var o in n){var s=n[o];if(!(o===\"value\"&&\"defaultValue\"in n&&s==null||ys&&o===\"children\"&&r===\"noscript\"||o===\"class\"||o===\"className\")){var u=o.toLowerCase();o===\"defaultValue\"&&\"value\"in n&&n.value==null?o=\"value\":o===\"download\"&&s===!0?s=\"\":u===\"translate\"&&s===\"no\"?s=!1:u[0]===\"o\"&&u[1]===\"n\"?u===\"ondoubleclick\"?o=\"ondblclick\":u!==\"onchange\"||r!==\"input\"&&r!==\"textarea\"||bs(n.type)?u===\"onfocus\"?o=\"onfocusin\":u===\"onblur\"?o=\"onfocusout\":ms.test(o)&&(o=u):u=o=\"oninput\":a&&gs.test(o)?o=o.replace(_s,\"-$&\").toLowerCase():s===null&&(s=void 0),u===\"oninput\"&&i[o=u]&&(o=\"oninputCapture\"),i[o]=s}}r==\"select\"&&i.multiple&&Array.isArray(i.value)&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),r==\"select\"&&i.defaultValue!=null&&(i.value=Re(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value})),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,\"className\",Cs)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=Ca,ui&&ui(e)};var ci=O.__r;O.__r=function(e){ci&&ci(e),kr=e.__c};var fi=O.diffed;O.diffed=function(e){fi&&fi(e);var t=e.props,n=e.__e;n!=null&&e.type===\"textarea\"&&\"value\"in t&&t.value!==n.value&&(n.value=t.value==null?\"\":t.value),kr=null};var Is={ReactCurrentDispatcher:{current:{readContext:function(e){return kr.__n[e.__c].props.value},useCallback:we,useContext:K,useDebugValue:ha,useDeferredValue:ba,useEffect:ve,useId:pa,useImperativeHandle:da,useInsertionEffect:wa,useLayoutEffect:rt,useMemo:de,useReducer:vr,useRef:fe,useState:X,useSyncExternalStore:_a,useTransition:va}}};function Es(e){return G.bind(null,e)}function wn(e){return!!e&&e.$$typeof===Ca}function As(e){return wn(e)&&e.type===Y}function Ps(e){return!!e&&typeof e.displayName==\"string\"&&e.displayName.startsWith(\"Memo(\")}function Ts(e){return wn(e)?ts.apply(null,arguments):e}function Ns(e){return!!e.__k&&(xe(null,e),!0)}function Ds(e){return e&&(e.base||e.nodeType===1&&e)||null}var $s=function(e,t){return e(t)},zs=function(e,t){return e(t)},Fs=Y,Rs=wn,Kt={useState:X,useId:pa,useReducer:vr,useEffect:ve,useLayoutEffect:rt,useInsertionEffect:wa,useTransition:va,useDeferredValue:ba,useSyncExternalStore:_a,startTransition:ya,useRef:fe,useImperativeHandle:da,useMemo:de,useCallback:we,useContext:K,useDebugValue:ha,version:\"18.3.1\",Children:us,render:vs,hydrate:ws,unmountComponentAtNode:Ns,createPortal:ps,createElement:G,createContext:nt,createFactory:Es,cloneElement:Ts,createRef:Ko,Fragment:Y,isValidElement:wn,isElement:Rs,isFragment:As,isMemo:Ps,findDOMNode:Ds,Component:Ne,PureComponent:Jn,memo:os,forwardRef:ls,flushSync:zs,unstable_batchedUpdates:$s,StrictMode:Fs,Suspense:nn,SuspenseList:St,lazy:fs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Is};const Os=e=>e;function Ms(e,t=Os){const n=Kt.useSyncExternalStore(e.subscribe,Kt.useCallback(()=>t(e.getState()),[e,t]),Kt.useCallback(()=>t(e.getInitialState()),[e,t]));return Kt.useDebugValue(n),n}const Ls=e=>{const t=as(e),n=r=>Ms(t,r);return Object.assign(n,t),n},Vs=(e=>Ls);var Sr=Symbol.for(\"immer-nothing\"),It=Symbol.for(\"immer-draftable\"),te=Symbol.for(\"immer-state\");function ae(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var pe=Object,Ze=pe.getPrototypeOf,Dt=\"constructor\",Bt=\"prototype\",Zn=\"configurable\",fn=\"enumerable\",rn=\"writable\",$t=\"value\",Oe=e=>!!e&&!!e[te];function De(e){return e?Ia(e)||qt(e)||!!e[It]||!!e[Dt]?.[It]||Ut(e)||jt(e):!1}var Bs=pe[Bt][Dt].toString(),di=new WeakMap;function Ia(e){if(!e||!ht(e))return!1;const t=Ze(e);if(t===null||t===pe[Bt])return!0;const n=pe.hasOwnProperty.call(t,Dt)&&t[Dt];if(n===Object)return!0;if(!Ge(n))return!1;let r=di.get(n);return r===void 0&&(r=Function.toString.call(n),di.set(n,r)),r===Bs}function Ht(e,t,n=!0){Xe(e)===0?(n?Reflect.ownKeys(e):pe.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function Xe(e){const t=e[te];return t?t.type_:qt(e)?1:Ut(e)?2:jt(e)?3:0}var Et=(e,t,n=Xe(e))=>n===2?e.has(t):pe[Bt].hasOwnProperty.call(e,t),ze=(e,t,n=Xe(e))=>n===2?e.get(t):e[t],dn=(e,t,n,r=Xe(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Hs(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var qt=Array.isArray,Ut=e=>e instanceof Map,jt=e=>e instanceof Set,ht=e=>typeof e==\"object\",Ge=e=>typeof e==\"function\",$n=e=>typeof e==\"boolean\";function qs(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var Us=e=>ht(e)?e?.[te]:null,Fe=e=>e.copy_||e.base_,xr=e=>e.modified_?e.copy_:e.base_;function Xn(e,t){if(Ut(e))return new Map(e);if(jt(e))return new Set(e);if(qt(e))return Array[Bt].slice.call(e);const n=Ia(e);if(t===!0||t===\"class_only\"&&!n){const r=pe.getOwnPropertyDescriptors(e);delete r[te];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],s=r[o];s[rn]===!1&&(s[rn]=!0,s[Zn]=!0),(s.get||s.set)&&(r[o]={[Zn]:!0,[rn]:!0,[fn]:s[fn],[$t]:e[o]})}return pe.create(Ze(e),r)}else{const r=Ze(e);if(r!==null&&n)return{...e};const i=pe.create(r);return pe.assign(i,e)}}function Cr(e,t=!1){return kn(e)||Oe(e)||!De(e)||(Xe(e)>1&&pe.defineProperties(e,{set:Yt,add:Yt,clear:Yt,delete:Yt}),pe.freeze(e),t&&Ht(e,(n,r)=>{Cr(r,!0)},!1)),e}function js(){ae(2)}var Yt={[$t]:js};function kn(e){return e===null||!ht(e)?!0:pe.isFrozen(e)}var hn=\"MapSet\",pn=\"Patches\",hi=\"ArrayMethods\",gn={};function et(e){const t=gn[e];return t||ae(0,e),t}var pi=e=>!!gn[e];function Ws(e,t){gn[e]||(gn[e]=t)}var zt,Ea=()=>zt,Qs=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:pi(hn)?et(hn):void 0,arrayMethodsPlugin_:pi(hi)?et(hi):void 0});function gi(e,t){t&&(e.patchPlugin_=et(pn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function er(e){tr(e),e.drafts_.forEach(Gs),e.drafts_=null}function tr(e){e===zt&&(zt=e.parent_)}var mi=e=>zt=Qs(zt,e);function Gs(e){const t=e[te];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _i(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(e!==void 0&&e!==n){n[te].modified_&&(er(t),ae(4)),De(e)&&(e=yi(t,e));const{patchPlugin_:i}=t;i&&i.generateReplacementPatches_(n[te].base_,e,t)}else e=yi(t,n);return Ks(t,e,!0),er(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Sr?e:void 0}function yi(e,t){if(kn(t))return t;const n=t[te];if(!n)return mn(t,e.handledSet_,e);if(!Sn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(e);Ta(n,e)}return n.copy_}function Ks(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Cr(t,n)}function Aa(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Sn=(e,t)=>e.scope_===t,Ys=[];function Pa(e,t,n,r){const i=Fe(e),a=e.type_;if(r!==void 0&&ze(i,r,a)===t){dn(i,r,n,a);return}if(!e.draftLocations_){const s=e.draftLocations_=new Map;Ht(i,(u,l)=>{if(Oe(l)){const d=s.get(l)||[];d.push(u),s.set(l,d)}})}const o=e.draftLocations_.get(t)??Ys;for(const s of o)dn(i,s,n,a)}function Js(e,t,n){e.callbacks_.push(function(i){const a=t;if(!a||!Sn(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=xr(a);Pa(e,a.draft_??a,o,n),Ta(a,i)})}function Ta(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:r}=t;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,t)}Aa(e)}}function Zs(e,t,n){const{scope_:r}=e;if(Oe(n)){const i=n[te];Sn(i,r)&&i.callbacks_.push(function(){an(e);const o=xr(i);Pa(e,n,o,t)})}else De(n)&&e.callbacks_.push(function(){const a=Fe(e);e.type_===3?a.has(n)&&mn(n,r.handledSet_,r):ze(a,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&mn(ze(e.copy_,t,e.type_),r.handledSet_,r)})}function mn(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Oe(e)||t.has(e)||!De(e)||kn(e)||(t.add(e),Ht(e,(r,i)=>{if(Oe(i)){const a=i[te];if(Sn(a,n)){const o=xr(a);dn(e,r,o,e.type_),Aa(a)}}else De(i)&&mn(i,t,n)})),e}function Xs(e,t){const n=qt(e),r={type_:n?1:0,scope_:t?t.scope_:Ea(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=_n;n&&(i=[r],a=Ft);const{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var _n={get(e,t){if(t===te)return e;let n=e.scope_.arrayMethodsPlugin_;const r=e.type_===1&&typeof t==\"string\";if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const i=Fe(e);if(!Et(i,t,e.type_))return el(e,i,t);const a=i[t];if(e.finalized_||!De(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&qs(t))return a;if(a===zn(e.base_,t)){an(e);const o=e.type_===1?+t:t,s=rr(e.scope_,a,e,o);return e.copy_[o]=s}return a},has(e,t){return t in Fe(e)},ownKeys(e){return Reflect.ownKeys(Fe(e))},set(e,t,n){const r=Na(Fe(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=zn(Fe(e),t),a=i?.[te];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Hs(n,i)&&(n!==void 0||Et(e.base_,t,e.type_)))return!0;an(e),nr(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Zs(e,t,n)),!0},deleteProperty(e,t){return an(e),zn(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),nr(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Fe(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[rn]:!0,[Zn]:e.type_!==1||t!==\"length\",[fn]:r[fn],[$t]:n[t]}},defineProperty(){ae(11)},getPrototypeOf(e){return Ze(e.base_)},setPrototypeOf(){ae(12)}},Ft={};for(let e in _n){let t=_n[e];Ft[e]=function(){const n=arguments;return n[0]=n[0][0],t.apply(this,n)}}Ft.deleteProperty=function(e,t){return Ft.set.call(this,e,t,void 0)};Ft.set=function(e,t,n){return _n.set.call(this,e[0],t,n,e[0])};function zn(e,t){const n=e[te];return(n?Fe(n):e)[t]}function el(e,t,n){const r=Na(t,n);return r?$t in r?r[$t]:r.get?.call(e.draft_):void 0}function Na(e,t){if(!(t in e))return;let n=Ze(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Ze(n)}}function nr(e){e.modified_||(e.modified_=!0,e.parent_&&nr(e.parent_))}function an(e){e.copy_||(e.assigned_=new Map,e.copy_=Xn(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var tl=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,n,r)=>{if(Ge(t)&&!Ge(n)){const a=n;n=t;const o=this;return function(u=a,...l){return o.produce(u,d=>n.call(this,d,...l))}}Ge(n)||ae(6),r!==void 0&&!Ge(r)&&ae(7);let i;if(De(t)){const a=mi(this),o=rr(a,t,void 0);let s=!0;try{i=n(o),s=!1}finally{s?er(a):tr(a)}return gi(a,r),_i(i,a)}else if(!t||!ht(t)){if(i=n(t),i===void 0&&(i=t),i===Sr&&(i=void 0),this.autoFreeze_&&Cr(i,!0),r){const a=[],o=[];et(pn).generateReplacementPatches_(t,i,{patches_:a,inversePatches_:o}),r(a,o)}return i}else ae(1,t)},this.produceWithPatches=(t,n)=>{if(Ge(t))return(o,...s)=>this.produceWithPatches(o,u=>t(u,...s));let r,i;return[this.produce(t,n,(o,s)=>{r=o,i=s}),r,i]},$n(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),$n(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),$n(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){De(e)||ae(8),Oe(e)&&(e=nl(e));const t=mi(this),n=rr(t,e,void 0);return n[te].isManual_=!0,tr(t),n}finishDraft(e,t){const n=e&&e[te];(!n||!n.isManual_)&&ae(9);const{scope_:r}=n;return gi(r,t),_i(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op===\"replace\"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=et(pn).applyPatches_;return Oe(e)?r(e,t):this.produce(e,i=>r(i,t))}};function rr(e,t,n,r){const[i,a]=Ut(t)?et(hn).proxyMap_(t,n):jt(t)?et(hn).proxySet_(t,n):Xs(t,n);return(n?.scope_??Ea()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Js(n,a,r):a.callbacks_.push(function(u){u.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:l}=u;a.modified_&&l&&l.generatePatches_(a,[],u)}),i}function nl(e){return Oe(e)||ae(10,e),Da(e)}function Da(e){if(!De(e)||kn(e))return e;const t=e[te];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Xn(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Xn(e,!0);return Ht(n,(i,a)=>{dn(n,i,Da(a))},r),t&&(t.finalized_=!1),n}function rl(){function t(p,b=[]){if(p.key_!==void 0){const x=p.parent_.copy_??p.parent_.base_,_=Us(ze(x,p.key_)),k=ze(x,p.key_);if(k===void 0||k!==p.draft_&&k!==p.base_&&k!==p.copy_||_!=null&&_.base_!==p.base_)return null;const S=p.parent_.type_===3;let A;if(S){const C=p.parent_;A=Array.from(C.drafts_.keys()).indexOf(p.key_)}else A=p.key_;if(!(S&&x.size>A||Et(x,A)))return null;b.push(A)}if(p.parent_)return t(p.parent_,b);b.reverse();try{n(p.copy_,b)}catch{return null}return b}function n(p,b){let x=p;for(let _=0;_<b.length-1;_++){const k=b[_];if(x=ze(x,k),!ht(x)||x===null)throw new Error(`Cannot resolve path at '${b.join(\"/\")}'`)}return x}const r=\"replace\",i=\"add\",a=\"remove\";function o(p,b,x){if(p.scope_.processedForPatches_.has(p))return;p.scope_.processedForPatches_.add(p);const{patches_:_,inversePatches_:k}=x;switch(p.type_){case 0:case 2:return u(p,b,_,k);case 1:return s(p,b,_,k);case 3:return l(p,b,_,k)}}function s(p,b,x,_){let{base_:k,assigned_:S}=p,A=p.copy_;A.length<k.length&&([k,A]=[A,k],[x,_]=[_,x]);const C=p.allIndicesReassigned_===!0;for(let y=0;y<k.length;y++){const P=A[y],T=k[y];if((C||S?.get(y.toString()))&&P!==T){const v=P?.[te];if(v&&v.modified_)continue;const N=b.concat([y]);x.push({op:r,path:N,value:f(P)}),_.push({op:r,path:N,value:f(T)})}}for(let y=k.length;y<A.length;y++){const P=b.concat([y]);x.push({op:i,path:P,value:f(A[y])})}for(let y=A.length-1;k.length<=y;--y){const P=b.concat([y]);_.push({op:a,path:P})}}function u(p,b,x,_){const{base_:k,copy_:S,type_:A}=p;Ht(p.assigned_,(C,y)=>{const P=ze(k,C,A),T=ze(S,C,A),z=y?Et(k,C)?r:i:a;if(P===T&&z===r)return;const v=b.concat(C);x.push(z===a?{op:z,path:v}:{op:z,path:v,value:f(T)}),_.push(z===i?{op:a,path:v}:z===a?{op:i,path:v,value:f(P)}:{op:r,path:v,value:f(P)})})}function l(p,b,x,_){let{base_:k,copy_:S}=p,A=0;k.forEach(C=>{if(!S.has(C)){const y=b.concat([A]);x.push({op:a,path:y,value:C}),_.unshift({op:i,path:y,value:C})}A++}),A=0,S.forEach(C=>{if(!k.has(C)){const y=b.concat([A]);x.push({op:i,path:y,value:C}),_.unshift({op:a,path:y,value:C})}A++})}function d(p,b,x){const{patches_:_,inversePatches_:k}=x;_.push({op:r,path:[],value:b===Sr?void 0:b}),k.push({op:r,path:[],value:p})}function c(p,b){return b.forEach(x=>{const{path:_,op:k}=x;let S=p;for(let P=0;P<_.length-1;P++){const T=Xe(S);let z=_[P];typeof z!=\"string\"&&typeof z!=\"number\"&&(z=\"\"+z),(T===0||T===1)&&(z===\"__proto__\"||z===Dt)&&ae(19),Ge(S)&&z===Bt&&ae(19),S=ze(S,z),ht(S)||ae(18,_.join(\"/\"))}const A=Xe(S),C=h(x.value),y=_[_.length-1];switch(k){case r:switch(A){case 2:return S.set(y,C);case 3:ae(16);default:return S[y]=C}case i:switch(A){case 1:return y===\"-\"?S.push(C):S.splice(y,0,C);case 2:return S.set(y,C);case 3:return S.add(C);default:return S[y]=C}case a:switch(A){case 1:return S.splice(y,1);case 2:return S.delete(y);case 3:return S.delete(x.value);default:return delete S[y]}default:ae(17,k)}}),p}function h(p){if(!De(p))return p;if(qt(p))return p.map(h);if(Ut(p))return new Map(Array.from(p.entries()).map(([x,_])=>[x,h(_)]));if(jt(p))return new Set(Array.from(p).map(h));const b=Object.create(Ze(p));for(const x in p)b[x]=h(p[x]);return Et(p,It)&&(b[It]=p[It]),b}function f(p){return Oe(p)?h(p):p}Ws(pn,{applyPatches_:c,generatePatches_:o,generateReplacementPatches_:d,getPath:t})}var Rt=new tl,il=Rt.produce,al=Rt.produceWithPatches.bind(Rt),ut=Rt.applyPatches.bind(Rt);const ol=e=>(t,n,r)=>(r.setState=(i,a,...o)=>{const s=typeof i==\"function\"?il(i):i;return t(s,a,...o)},e(r.setState,n,r)),sl=ol,ll=new Set([\"a\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"code\",\"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\"u\",\"ul\",\"wbr\"]),ul=new Set([\"br\",\"col\",\"hr\",\"img\",\"wbr\"]);function cl(e){const t=e.indexOf(\"|\");if(t!==-1)return{display:e.slice(0,t).trim(),target:e.slice(t+1).trim()};const n=e.indexOf(\"->\");if(n!==-1)return{display:e.slice(0,n).trim(),target:e.slice(n+2).trim()};const r=e.indexOf(\"<-\");if(r!==-1)return{target:e.slice(0,r).trim(),display:e.slice(r+2).trim()};const i=e.trim();return{display:i,target:i}}function bi(e){const t=e.trim(),n=t.startsWith(\"/\"),r=n?t.slice(1):t,i=r.search(/\\s/);return i===-1?{name:r,rawArgs:\"\",isClose:n}:{name:r.slice(0,i),rawArgs:r.slice(i+1).trim(),isClose:n}}function vi(e,t){const n=[];let r=\"\",i=t;for(;i<e.length&&(e[i]===\".\"||e[i]===\"#\");){const a=e[i];i++;let o=\"\";for(;i<e.length;)if(/[a-zA-Z0-9_-]/.test(e[i]))o+=e[i],i++;else if(e[i]===\"{\"&&(e[i+1]===\"$\"||e[i+1]===\"_\"||e[i+1]===\"@\")){const s=i;for(i+=2;i<e.length&&/[\\w.]/.test(e[i]);)i++;if(i<e.length&&e[i]===\"}\")i++,o+=e.slice(s,i);else{i=s;break}}else break;o&&(a===\".\"?n.push(o):r=o)}return{className:n.join(\" \"),id:r,endIdx:i}}function fl(e,t){const n={};for(;t<e.length;){for(;t<e.length&&/\\s/.test(e[t]);)t++;if(t>=e.length||e[t]===\">\"||e[t]===\"/\"&&e[t+1]===\">\")break;const r=t;for(;t<e.length&&/[a-zA-Z0-9_\\-:@]/.test(e[t]);)t++;const i=e.slice(r,t);if(!i)break;if(e[t]===\"=\")if(t++,e[t]==='\"'||e[t]===\"'\"){const a=e[t];t++;const o=t;let s=0;for(;t<e.length;){if(e[t]===\"{\")s++;else if(e[t]===\"}\")s--;else if(e[t]===a&&s<=0)break;t++}n[i]=e.slice(o,t),t<e.length&&t++}else{const a=t;for(;t<e.length&&/[^\\s>]/.test(e[t]);)t++;n[i]=e.slice(a,t)}else n[i]=\"\"}return{attributes:n,endIdx:t}}function mt(e){const t=[];let n=0,r=0;function i(a){a>r&&t.push({type:\"text\",value:e.slice(r,a),start:r,end:a})}for(;n<e.length;){if(e[n]===\"\\\\\"&&(e[n+1]===\"{\"||e[n+1]===\"}\")){i(n),t.push({type:\"text\",value:e[n+1],start:n,end:n+2}),n+=2,r=n;continue}if(e[n]===\"[\"&&e[n+1]===\"[\"){i(n);const a=n;n+=2;let o,s;if(e[n]===\".\"||e[n]===\"#\"){const p=vi(e,n);o=p.className||void 0,s=p.id||void 0,n=p.endIdx,e[n]===\" \"&&n++}let u=1;const l=n;for(;n<e.length&&u>0;)if(e[n]===\"[\"&&e[n+1]===\"[\")u++,n+=2;else if(e[n]===\"]\"&&e[n+1]===\"]\"){if(u--,u===0)break;n+=2}else n++;if(u!==0){n=a+2,r=a;continue}const d=e.slice(l,n);n+=2;const{display:c,target:h}=cl(d),f={type:\"link\",display:c,target:h,start:a,end:n};o&&(f.className=o),s&&(f.id=s),t.push(f),r=n;continue}if(e[n]===\"{\"){const a=n;let o=e[n+1],s,u;if(o===\".\"||o===\"#\"){i(n);const l=vi(e,n+1);s=l.className||void 0,u=l.id||void 0;let d=l.endIdx;e[d]===\" \"&&d++;const c=e[d];if(c===\"$\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"variable\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"_\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"temporary\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c===\"@\"){n=d+1;const h=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const f=e.slice(h,n);if(e[n]===\"}\"){n++;const p={type:\"variable\",name:f,scope:\"local\",start:a,end:n};s&&(p.className=s),u&&(p.id=u),t.push(p),r=n;continue}n=a+1,r=a;continue}if(c!==void 0&&/[a-zA-Z]/.test(c)){n=d;let h=1;const f=n;for(;n<e.length&&h>0;)e[n]===\"{\"?h++:e[n]===\"}\"&&h--,h>0&&n++;if(h!==0){n=a+1,r=a;continue}const p=e.slice(f,n);n++;const{name:b,rawArgs:x,isClose:_}=bi(p),k={type:\"macro\",name:b,rawArgs:x,isClose:_,start:a,end:n};s&&(k.className=s),u&&(k.id=u),t.push(k),r=n;continue}n=a+1,r=a;continue}if(o===\"$\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"variable\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"_\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"temporary\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o===\"@\"){i(n),n+=2;const l=n;for(;n<e.length&&/[\\w.]/.test(e[n]);)n++;const d=e.slice(l,n);if(e[n]===\"}\"){n++,t.push({type:\"variable\",name:d,scope:\"local\",start:a,end:n}),r=n;continue}n=a+1,r=a;continue}if(o!==void 0&&(o===\"/\"||/[a-zA-Z]/.test(o))){i(n),n++;let l=1;const d=n;for(;n<e.length&&l>0;)e[n]===\"{\"?l++:e[n]===\"}\"&&l--,l>0&&n++;if(l!==0){n=a+1,r=a;continue}const c=e.slice(d,n);n++;const{name:h,rawArgs:f,isClose:p}=bi(c);t.push({type:\"macro\",name:h,rawArgs:f,isClose:p,start:a,end:n}),r=n;continue}n++;continue}if(e[n]===\"<\"){const a=n;let o=n+1;const s=e[o]===\"/\";s&&o++;const u=o;for(;o<e.length&&/[a-zA-Z0-9]/.test(e[o]);)o++;const l=e.slice(u,o).toLowerCase();if(l&&ll.has(l))if(s){for(;o<e.length&&/\\s/.test(e[o]);)o++;if(e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:{},isClose:!0,isSelfClose:!1,start:a,end:o}),r=o,n=o;continue}}else{const d=fl(e,o);o=d.endIdx;let c=ul.has(l);if(e[o]===\"/\"&&(c=!0,o++),e[o]===\">\"){o++,i(a),t.push({type:\"html\",tag:l,attributes:d.attributes,isClose:!1,isSelfClose:c,start:a,end:o}),r=o,n=o;continue}}n++;continue}n++}return i(e.length),t}const $a=new Set([\"if\",\"for\",\"do\",\"button\",\"link\",\"listbox\",\"cycle\",\"switch\",\"timed\",\"repeat\",\"type\",\"widget\",\"span\",\"nobr\"]);function za(e){$a.add(e.toLowerCase())}const wi={elseif:\"if\",else:\"if\",case:\"switch\",default:\"switch\",next:\"timed\"},dl=new Set([\"if\",\"switch\",\"timed\"]);function _t(e){const t=[],n=[];function r(){if(n.length===0)return t;const i=n[n.length-1].node;return i.type===\"macro\"&&i.branches&&i.branches.length>0?i.branches[i.branches.length-1].children:i.children}for(const i of e)switch(i.type){case\"text\":r().push({type:\"text\",value:i.value});break;case\"link\":{const o={type:\"macro\",name:\"link\",rawArgs:`\"${i.display}\" \"${i.target}\"`,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o);break}case\"variable\":{const a={type:\"variable\",name:i.name,scope:i.scope};i.className&&(a.className=i.className),i.id&&(a.id=i.id),r().push(a);break}case\"html\":{if(i.isSelfClose){r().push({type:\"html\",tag:i.tag,attributes:i.attributes,children:[]});break}if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing </${i.tag}> (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"html\"||o.node.tag!==i.tag){const s=o.node.type===\"html\"?`</${o.node.tag}>`:`{/${o.node.name}}`;throw new Error(`Expected ${s} but found </${i.tag}> (at character ${i.start})`)}n.pop(),r().push(o.node);break}const a={type:\"html\",tag:i.tag,attributes:i.attributes,children:[]};n.push({node:a,start:i.start});break}case\"macro\":{const a=i.name.toLowerCase();if(i.isClose){if(n.length===0)throw new Error(`Unexpected closing {/${i.name}} (at character ${i.start})`);const o=n[n.length-1];if(o.node.type!==\"macro\"||o.node.name!==a){const s=o.node.type===\"macro\"?`{/${o.node.name}}`:`</${o.node.tag}>`;throw new Error(`Expected ${s} but found {/${i.name}} (at character ${i.start})`)}n.pop(),r().push(o.node);break}if(wi[a]){const o=wi[a],s=n.length>0?n[n.length-1].node:null;if(!s||s.type!==\"macro\"||s.name!==o)throw new Error(`{${i.name}} without matching {${o}} (at character ${i.start})`);const u={rawArgs:i.rawArgs,children:[]};i.className&&(u.className=i.className),i.id&&(u.id=i.id),s.branches.push(u);break}if($a.has(a)){const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};if(dl.has(a)){const s={rawArgs:i.rawArgs,children:[]};i.className&&(s.className=i.className),i.id&&(s.id=i.id),o.branches=[s]}else i.className&&(o.className=i.className),i.id&&(o.id=i.id);n.push({node:o,start:i.start});break}{const o={type:\"macro\",name:a,rawArgs:i.rawArgs,children:[]};i.className&&(o.className=i.className),i.id&&(o.id=i.id),r().push(o)}break}default:{const a=i;throw new Error(`Unknown token type: ${a.type}`)}}if(n.length>0){const i=n[n.length-1],a=i.node.type===\"html\"?`<${i.node.tag}>`:`{${i.node.name}} macro`;throw new Error(`Unclosed ${a} (opened at character ${i.start})`)}return t}function Ir(){const e=I(r=>r.variables),t=I(r=>r.temporary),n=K(Ce);return de(()=>[e,t,n],[e,t,n])}const hl=/\\{(\\$[\\w.]+|_[\\w.]+|@[\\w.]+)\\}/g,pl=/\\{[\\$_@][\\w.]+\\}/;function gl(e){return pl.test(e)}function ml(e,t){let n=e;for(let r=1;r<t.length;r++){if(n==null||typeof n!=\"object\")return;n=n[t[r]]}return n}function _l(e,t,n,r){return e.replace(hl,(i,a)=>{const o=a[0],u=a.slice(1).split(\".\"),l=u[0];let d;return o===\"$\"?d=t[l]:o===\"_\"?d=n[l]:d=r[l],u.length>1&&(d=ml(d,u)),d==null?\"\":String(d)})}function Er(){const[e,t,n]=Ir();return we(r=>r===void 0||!gl(r)?r:_l(r,e,t,n),[e,t,n])}function yl({name:e,scope:t,className:n,id:r}){const i=Er();n=i(n),r=i(r);const a=K(Ce),o=e.split(\".\"),s=o[0],u=I(c=>t===\"variable\"?c.variables[s]:t===\"temporary\"?c.temporary[s]:void 0);let l;t===\"local\"?l=s in a?a[s]:void 0:l=u;for(let c=1;c<o.length;c++){if(l==null||typeof l!=\"object\"){l=void 0;break}const h=o[c];l=l[h]}const d=l==null?\"\":String(l);return n||r?w(\"span\",{id:r,class:n,children:d}):w(Y,{children:d})}function Fa(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,t|1);return n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function Ra(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}let yt=!1,Wt=\"\",tt=0,pt=null;function bl(e,t=!0){let n;e===void 0?n=String(Date.now())+String(Math.random()):t?n=e+\"|\"+Date.now()+\"|\"+Math.random():n=e,Wt=n,tt=0,pt=Fa(Ra(n)),yt=!0}function Oa(e,t){Wt=e,tt=0,pt=Fa(Ra(e)),yt=!0;for(let n=0;n<t;n++)pt();tt=t}function ir(){yt=!1,Wt=\"\",tt=0,pt=null}function yn(){return yt?{seed:Wt,pull:tt}:null}function Ar(){return!yt||!pt?Math.random():(tt++,pt())}function Ma(e,t){return e>t&&([e,t]=[t,e]),Math.floor(Ar()*(t-e+1))+e}function vl(){return yt}function wl(){return Wt}function kl(){return tt}const Sl=500,We=new Map,xl=/\\$(\\w+)/g,Cl=/(?<![.\\w])_(\\w+)/g,Il=/@(\\w+)/g;function El(e){return e.replace(xl,'variables[\"$1\"]').replace(Cl,'temporary[\"$1\"]').replace(Il,'locals[\"$1\"]')}function Pr(e){let t=\"\",n=\"\",r=0;function i(){n&&(t+=El(n),n=\"\")}for(;r<e.length;){const a=e.charAt(r);if(a==='\"'||a===\"'\"){i();const o=a;let s=o;for(r++;r<e.length;){const u=e.charAt(r);if(u===\"\\\\\"&&r+1<e.length)s+=u+e.charAt(r+1),r+=2;else if(u===o){s+=o,r++;break}else s+=u,r++}t+=s;continue}if(a===\"`\"){for(i(),t+=\"`\",r++;r<e.length;){const o=e.charAt(r);if(o===\"\\\\\"&&r+1<e.length)t+=o+e.charAt(r+1),r+=2;else if(o===\"$\"&&e.charAt(r+1)===\"{\"){t+=\"${\",r+=2;let s=1,u=\"\";for(;r<e.length&&s>0;){const l=e.charAt(r);if(l===\"{\")s++,u+=l;else if(l===\"}\"){if(s--,s===0)break;u+=l}else if(l===\"\\\\\"&&r+1<e.length)u+=l+e.charAt(r+1),r++;else if(l==='\"'||l===\"'\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===l){u+=d,r++;break}else u+=d,r++}continue}else if(l===\"`\"){for(u+=l,r++;r<e.length;){const d=e.charAt(r);if(d===\"\\\\\"&&r+1<e.length)u+=d+e.charAt(r+1),r+=2;else if(d===\"$\"&&e.charAt(r+1)===\"{\"){u+=\"${\",r+=2;let c=1;for(;r<e.length&&c>0;){const h=e.charAt(r);h===\"{\"?c++:h===\"}\"&&c--,c>0&&(u+=h),r++}u+=\"}\"}else if(d===\"`\"){u+=d,r++;break}else u+=d,r++}continue}else u+=l;r++}t+=Pr(u),r<e.length&&e.charAt(r)===\"}\"&&(t+=\"}\",r++)}else if(o===\"`\"){t+=\"`\",r++;break}else t+=o,r++}continue}n+=a,r++}return i(),t}const Al=\"const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;\";function La(e,t){const n=We.get(e);if(n)return We.delete(e),We.set(e,n),n;const r=new Function(\"variables\",\"temporary\",\"locals\",\"__fns\",Al+t);if(We.set(e,r),We.size>Sl){const i=We.keys().next().value;i!==void 0&&We.delete(i)}return r}let Jt=null,ki=null,Si=null;function Va(){const e=I.getState(),{visitCounts:t,renderCounts:n}=e;if(Jt&&ki===t&&Si===n)return Jt;const r=f=>t[f??I.getState().currentPassage]??0,i=f=>r(f)>0,a=(...f)=>f.some(p=>r(p)>0),o=(...f)=>f.every(p=>r(p)>0),s=f=>n[f??I.getState().currentPassage]??0;return Jt={currentPassage:()=>{const f=I.getState();return f.storyData?.passages.get(f.currentPassage)},previousPassage:()=>{const f=I.getState();if(f.historyIndex<=0)return;const p=f.history[f.historyIndex-1]?.passage;return p?f.storyData?.passages.get(p):void 0},visited:r,hasVisited:i,hasVisitedAny:a,hasVisitedAll:o,rendered:s,hasRendered:f=>s(f)>0,hasRenderedAny:(...f)=>f.some(p=>s(p)>0),hasRenderedAll:(...f)=>f.every(p=>s(p)>0),random:Ar,randomInt:Ma},ki=t,Si=n,Jt}function xn(e,t,n,r={}){const a=`return (${Pr(e)});`;return La(a,a)(t,n,r,Va())}function Ba(e,t,n,r={}){const i=Pr(e);La(\"exec:\"+i,i)(t,n,r,Va())}function Pl(e){const t=[];let n=\"\",r=0,i=null;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s,s===i&&e[o-1]!==\"\\\\\"&&(i=null);continue}if(s==='\"'||s===\"'\"||s===\"`\"){i=s,n+=s;continue}if(s===\"(\"||s===\"[\"||s===\"{\"){r++,n+=s;continue}if(s===\")\"||s===\"]\"||s===\"}\"){r--,n+=s;continue}if(s===\",\"&&r===0){t.push(n.trim()),n=\"\";continue}n+=s}const a=n.trim();return a&&t.push(a),t}function Tl({body:e,parentValues:t,ownKeys:n}){const r=K(ue),[i,a]=X({}),o={...t,...n,...i},s=fe(o);s.current=o;const u=we(()=>s.current,[]),l=we((c,h)=>{a(f=>({...f,[c]:h}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]);return w(Qt.Provider,{value:d,children:w(Ce.Provider,{value:o,children:Ie(e,{nobr:r,locals:o})})})}function Nl({body:e,params:t,rawArgs:n,invocationChildren:r}){const i=K(Ce),a=K(ue),[o,s,u]=Ir(),l=r?.length?r:null;if(t.length===0||!n)return w(ur.Provider,{value:l,children:Ie(e,{nobr:a,locals:i})});const d=Pl(n),c={};for(let h=0;h<t.length;h++){const f=t[h],p=d[h];let b;if(p!==void 0)try{b=xn(p,o,s,u)}catch{b=void 0}c[f.startsWith(\"@\")?f.slice(1):f]=b}return w(ur.Provider,{value:l,children:w(Tl,{body:e,parentValues:i,ownKeys:c})})}const Ha=new Map;function qa(e,t,n,r=!1){const i=n.filter(a=>a!==\"@children\");Ha.set(e.toLowerCase(),{body:t,params:i,isBlock:r})}function Dl(e){return Ha.get(e.toLowerCase())}const Ua=new Map;function $l(e,t){Ua.set(e.toLowerCase(),t)}function zl(e){return Ua.get(e.toLowerCase())}const ja=new Set;function Fl(e){ja.add(e.toLowerCase())}function Rl(e){return ja.has(e.toLowerCase())}const xi=document.createElement(\"i\");function Wa(e){const t=\"&\"+e+\";\";xi.innerHTML=t;const n=xi.textContent;return n.charCodeAt(n.length-1)===59&&e!==\"semi\"||n===t?!1:n}function me(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ie(e,t){return e.length>0?(me(e,e.length,0,t),e):t}const ar={}.hasOwnProperty;function Ol(e){const t={};let n=-1;for(;++n<e.length;)Ml(t,e[n]);return t}function Ml(e,t){let n;for(n in t){const i=(ar.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){ar.call(i,o)||(i[o]=[]);const s=a[o];Ll(i[o],Array.isArray(s)?s:s?[s]:[])}}}function Ll(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add===\"after\"?e:r).push(t[n]);me(e,0,0,r)}function Vl(e){const t={};let n=-1;for(;++n<e.length;)Bl(t,e[n]);return t}function Bl(e,t){let n;for(n in t){const i=(ar.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a)i[o]=a[o]}}function Hl(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?\"�\":String.fromCodePoint(n)}const ql={'\"':\"quot\",\"&\":\"amp\",\"<\":\"lt\",\">\":\"gt\"};function Qa(e){return e.replace(/[\"&<>]/g,t);function t(n){return\"&\"+ql[n]+\";\"}}function Ot(e){return e.replace(/[\\t\\n\\r ]+/g,\" \").replace(/^ | $/g,\"\").toLowerCase().toUpperCase()}const Pe=He(/[A-Za-z]/),ge=He(/[\\dA-Za-z]/),Ul=He(/[#-'*+\\--9=?A-Z^-~]/);function or(e){return e!==null&&(e<32||e===127)}const sr=He(/\\d/),jl=He(/[\\dA-Fa-f]/),Wl=He(/[!-/:-@[-`{-~]/);function R(e){return e!==null&&e<-2}function oe(e){return e!==null&&(e<0||e===32)}function L(e){return e===-2||e===-1||e===32}const Ql=He(/\\p{P}|\\p{S}/u),Gl=He(/\\s/);function He(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Zt(e,t){const n=Qa(Kl(e||\"\"));if(!t)return n;const r=n.indexOf(\":\"),i=n.indexOf(\"?\"),a=n.indexOf(\"#\"),o=n.indexOf(\"/\");return r<0||o>-1&&r>o||i>-1&&r>i||a>-1&&r>a||t.test(n.slice(0,r))?n:\"\"}function Kl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o=\"\";if(a===37&&ge(e.charCodeAt(n+1))&&ge(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o=\"�\"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=\"\"),i&&(n+=i,i=0)}return t.join(\"\")+e.slice(r)}const Ci={}.hasOwnProperty,Ii=/^(https?|ircs?|mailto|xmpp)$/i,Yl=/^https?$/i;function Jl(e){const t=e||{};let n=!0;const r={},i=[[]],a=[],o=[],u=Vl([{enter:{blockQuote:M,codeFenced:ke,codeFencedFenceInfo:x,codeFencedFenceMeta:x,codeIndented:j,codeText:Vo,content:Ao,definition:ko,definitionDestinationString:xo,definitionLabelString:x,definitionTitleString:x,emphasis:Mo,htmlFlow:Oo,htmlText:Br,image:q,label:x,link:se,listItemMarker:N,listItemValue:v,listOrdered:T,listUnordered:z,paragraph:J,reference:x,resource:ot,resourceDestinationString:st,resourceTitleString:x,setextHeading:To,strong:Lo},exit:{atxHeading:Do,atxHeadingSequence:Po,autolinkEmail:Qo,autolinkProtocol:Wo,blockQuote:Z,characterEscapeValue:vt,characterReferenceMarkerHexadecimal:Hr,characterReferenceMarkerNumeric:Hr,characterReferenceValue:jo,codeFenced:g,codeFencedFence:D,codeFencedFenceInfo:m,codeFencedFenceMeta:P,codeFlowValue:Ro,codeIndented:g,codeText:Bo,codeTextData:vt,data:vt,definition:Eo,definitionDestinationString:Co,definitionLabelString:So,definitionTitleString:Io,emphasis:Ho,hardBreakEscape:Lr,hardBreakTrailing:Lr,htmlFlow:Vr,htmlFlowData:vt,htmlText:Vr,htmlTextData:vt,image:Mr,label:bt,labelText:ee,lineEnding:Fo,link:Mr,listOrdered:$,listUnordered:B,paragraph:he,reference:P,referenceString:Me,resource:P,resourceDestinationString:Tn,resourceTitleString:wo,setextHeading:zo,setextHeadingLineSequence:$o,setextHeadingText:No,strong:qo,thematicBreak:Uo}},...t.htmlExtensions||[]]),l={definitions:r,tightStack:o},d={buffer:x,encode:y,getData:b,lineEndingIfNeeded:C,options:t,raw:S,resume:_,setData:p,tag:k};let c=t.defaultLineEnding;return h;function h(E){let F=-1,ne=0;const Se=[];let Ee=[],$e=[];for(;++F<E.length;)!c&&(E[F][1].type===\"lineEnding\"||E[F][1].type===\"lineEndingBlank\")&&(c=E[F][2].sliceSerialize(E[F][1])),(E[F][1].type===\"listOrdered\"||E[F][1].type===\"listUnordered\")&&(E[F][0]===\"enter\"?Se.push(F):f(E.slice(Se.pop(),F))),E[F][1].type===\"definition\"&&(E[F][0]===\"enter\"?($e=ie($e,E.slice(ne,F)),ne=F):(Ee=ie(Ee,E.slice(ne,F+1)),ne=F+1));Ee=ie(Ee,$e),Ee=ie(Ee,E.slice(ne)),F=-1;const Ae=Ee;for(u.enter.null&&u.enter.null.call(d);++F<E.length;){const qr=u[Ae[F][0]],Ur=Ae[F][1].type,jr=qr[Ur];Ci.call(qr,Ur)&&jr&&jr.call({sliceSerialize:Ae[F][2].sliceSerialize,...d},Ae[F][1])}return u.exit.null&&u.exit.null.call(d),i[0].join(\"\")}function f(E){const F=E.length;let ne=0,Se=0,Ee=!1,$e;for(;++ne<F;){const Ae=E[ne];if(Ae[1]._container)$e=void 0,Ae[0]===\"enter\"?Se++:Se--;else switch(Ae[1].type){case\"listItemPrefix\":{Ae[0]===\"exit\"&&($e=!0);break}case\"linePrefix\":break;case\"lineEndingBlank\":{Ae[0]===\"enter\"&&!Se&&($e?$e=void 0:Ee=!0);break}default:$e=void 0}}E[0][1]._loose=Ee}function p(E,F){l[E]=F}function b(E){return l[E]}function x(){i.push([])}function _(){return i.pop().join(\"\")}function k(E){n&&(p(\"lastWasTag\",!0),i[i.length-1].push(E))}function S(E){p(\"lastWasTag\"),i[i.length-1].push(E)}function A(){S(c||`\n`)}function C(){const E=i[i.length-1],F=E[E.length-1],ne=F?F.charCodeAt(F.length-1):null;ne===10||ne===13||ne===null||A()}function y(E){return b(\"ignoreEncode\")?E:Qa(E)}function P(){_()}function T(E){o.push(!E._loose),C(),k(\"<ol\"),p(\"expectFirstItem\",!0)}function z(E){o.push(!E._loose),C(),k(\"<ul\"),p(\"expectFirstItem\",!0)}function v(E){if(b(\"expectFirstItem\")){const F=Number.parseInt(this.sliceSerialize(E),10);F!==1&&k(' start=\"'+y(String(F))+'\"')}}function N(){b(\"expectFirstItem\")?k(\">\"):U(),C(),k(\"<li>\"),p(\"expectFirstItem\"),p(\"lastWasTag\")}function $(){U(),o.pop(),A(),k(\"</ol>\")}function B(){U(),o.pop(),A(),k(\"</ul>\")}function U(){b(\"lastWasTag\")&&!b(\"slurpAllLineEndings\")&&C(),k(\"</li>\"),p(\"slurpAllLineEndings\")}function M(){o.push(!1),C(),k(\"<blockquote>\")}function Z(){o.pop(),C(),k(\"</blockquote>\"),p(\"slurpAllLineEndings\")}function J(){o[o.length-1]||(C(),k(\"<p>\")),p(\"slurpAllLineEndings\")}function he(){o[o.length-1]?p(\"slurpAllLineEndings\",!0):k(\"</p>\")}function ke(){C(),k(\"<pre><code\"),p(\"fencesCount\",0)}function m(){const E=_();k(' class=\"language-'+E+'\"')}function D(){const E=b(\"fencesCount\")||0;E||(k(\">\"),p(\"slurpOneLineEnding\",!0)),p(\"fencesCount\",E+1)}function j(){C(),k(\"<pre><code>\")}function g(){const E=b(\"fencesCount\");E!==void 0&&E<2&&l.tightStack.length>0&&!b(\"lastWasTag\")&&A(),b(\"flowCodeSeenData\")&&C(),k(\"</code></pre>\"),E!==void 0&&E<2&&C(),p(\"flowCodeSeenData\"),p(\"fencesCount\"),p(\"slurpOneLineEnding\")}function q(){a.push({image:!0}),n=void 0}function se(){a.push({})}function ee(E){a[a.length-1].labelId=this.sliceSerialize(E)}function bt(){a[a.length-1].label=_()}function Me(E){a[a.length-1].referenceId=this.sliceSerialize(E)}function ot(){x(),a[a.length-1].destination=\"\"}function st(){x(),p(\"ignoreEncode\",!0)}function Tn(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function wo(){a[a.length-1].title=_()}function Mr(){let E=a.length-1;const F=a[E],ne=F.referenceId||F.labelId,Se=F.destination===void 0?r[Ot(ne)]:F;for(n=!0;E--;)if(a[E].image){n=void 0;break}F.image?(k('<img src=\"'+Zt(Se.destination,t.allowDangerousProtocol?void 0:Yl)+'\" alt=\"'),S(F.label),k('\"')):k('<a href=\"'+Zt(Se.destination,t.allowDangerousProtocol?void 0:Ii)+'\"'),k(Se.title?' title=\"'+Se.title+'\"':\"\"),F.image?k(\" />\"):(k(\">\"),S(F.label),k(\"</a>\")),a.pop()}function ko(){x(),a.push({})}function So(E){_(),a[a.length-1].labelId=this.sliceSerialize(E)}function xo(){x(),p(\"ignoreEncode\",!0)}function Co(){a[a.length-1].destination=_(),p(\"ignoreEncode\")}function Io(){a[a.length-1].title=_()}function Eo(){const E=a[a.length-1],F=Ot(E.labelId);_(),Ci.call(r,F)||(r[F]=a[a.length-1]),a.pop()}function Ao(){p(\"slurpAllLineEndings\",!0)}function Po(E){b(\"headingRank\")||(p(\"headingRank\",this.sliceSerialize(E).length),C(),k(\"<h\"+b(\"headingRank\")+\">\"))}function To(){x(),p(\"slurpAllLineEndings\")}function No(){p(\"slurpAllLineEndings\",!0)}function Do(){k(\"</h\"+b(\"headingRank\")+\">\"),p(\"headingRank\")}function $o(E){p(\"headingRank\",this.sliceSerialize(E).charCodeAt(0)===61?1:2)}function zo(){const E=_();C(),k(\"<h\"+b(\"headingRank\")+\">\"),S(E),k(\"</h\"+b(\"headingRank\")+\">\"),p(\"slurpAllLineEndings\"),p(\"headingRank\")}function vt(E){S(y(this.sliceSerialize(E)))}function Fo(E){if(!b(\"slurpAllLineEndings\")){if(b(\"slurpOneLineEnding\")){p(\"slurpOneLineEnding\");return}if(b(\"inCodeText\")){S(\" \");return}S(y(this.sliceSerialize(E)))}}function Ro(E){S(y(this.sliceSerialize(E))),p(\"flowCodeSeenData\",!0)}function Lr(){k(\"<br />\")}function Oo(){C(),Br()}function Vr(){p(\"ignoreEncode\")}function Br(){t.allowDangerousHtml&&p(\"ignoreEncode\",!0)}function Mo(){k(\"<em>\")}function Lo(){k(\"<strong>\")}function Vo(){p(\"inCodeText\",!0),k(\"<code>\")}function Bo(){p(\"inCodeText\"),k(\"</code>\")}function Ho(){k(\"</em>\")}function qo(){k(\"</strong>\")}function Uo(){C(),k(\"<hr />\")}function Hr(E){p(\"characterReferenceType\",E.type)}function jo(E){const F=this.sliceSerialize(E),ne=b(\"characterReferenceType\")?Hl(F,b(\"characterReferenceType\")===\"characterReferenceMarkerNumeric\"?10:16):Wa(F);S(y(ne)),p(\"characterReferenceType\")}function Wo(E){const F=this.sliceSerialize(E);k('<a href=\"'+Zt(F,t.allowDangerousProtocol?void 0:Ii)+'\">'),S(y(F)),k(\"</a>\")}function Qo(E){const F=this.sliceSerialize(E);k('<a href=\"'+Zt(\"mailto:\"+F)+'\">'),S(y(F)),k(\"</a>\")}}function H(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(u){return L(u)?(e.enter(n),s(u)):t(u)}function s(u){return L(u)&&a++<i?(e.consume(u),s):(e.exit(n),t(u))}}const Zl={tokenize:Xl};function Xl(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter(\"lineEnding\"),e.consume(s),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}function i(s){return e.enter(\"paragraph\"),a(s)}function a(s){const u=e.enter(\"chunkText\",{contentType:\"text\",previous:n});return n&&(n.next=u),n=u,o(s)}function o(s){if(s===null){e.exit(\"chunkText\"),e.exit(\"paragraph\"),e.consume(s);return}return R(s)?(e.consume(s),e.exit(\"chunkText\"),a):(e.consume(s),o)}}const eu={tokenize:tu},Ei={tokenize:nu};function tu(e){const t=this,n=[];let r=0,i,a,o;return s;function s(S){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,l)(S)}return l(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let C=A,y;for(;C--;)if(t.events[C][0]===\"exit\"&&t.events[C][1].type===\"chunkFlow\"){y=t.events[C][1].end;break}_(r);let P=A;for(;P<t.events.length;)t.events[P][1].end={...y},P++;return me(t.events,C+1,0,t.events.slice(A)),t.events.length=P,l(S)}return s(S)}function l(S){if(r===n.length){if(!i)return h(S);if(i.currentConstruct&&i.currentConstruct.concrete)return p(S);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ei,d,c)(S)}function d(S){return i&&k(),_(r),h(S)}function c(S){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,p(S)}function h(S){return t.containerState={},e.attempt(Ei,f,p)(S)}function f(S){return r++,n.push([t.currentConstruct,t.containerState]),h(S)}function p(S){if(S===null){i&&k(),_(0),e.consume(S);return}return i=i||t.parser.flow(t.now()),e.enter(\"chunkFlow\",{_tokenizer:i,contentType:\"flow\",previous:a}),b(S)}function b(S){if(S===null){x(e.exit(\"chunkFlow\"),!0),_(0),e.consume(S);return}return R(S)?(e.consume(S),x(e.exit(\"chunkFlow\")),r=0,t.interrupt=void 0,s):(e.consume(S),b)}function x(S,A){const C=t.sliceStream(S);if(A&&C.push(null),S.previous=a,a&&(a.next=S),a=S,i.defineSkip(S.start),i.write(C),t.parser.lazy[S.start.line]){let y=i.events.length;for(;y--;)if(i.events[y][1].start.offset<o&&(!i.events[y][1].end||i.events[y][1].end.offset>o))return;const P=t.events.length;let T=P,z,v;for(;T--;)if(t.events[T][0]===\"exit\"&&t.events[T][1].type===\"chunkFlow\"){if(z){v=t.events[T][1].end;break}z=!0}for(_(r),y=P;y<t.events.length;)t.events[y][1].end={...v},y++;me(t.events,T+1,0,t.events.slice(P)),t.events.length=y}}function _(S){let A=n.length;for(;A-- >S;){const C=n[A];t.containerState=C[1],C[0].exit.call(t,e)}n.length=S}function k(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function nu(e,t,n){return H(e,e.attempt(this.parser.constructs.document,t,n),\"linePrefix\",this.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)}function bn(e){if(e===null||oe(e)||Gl(e))return 1;if(Ql(e))return 2}function Cn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const lr={name:\"attention\",resolveAll:ru,tokenize:iu};function ru(e,t){let n=-1,r,i,a,o,s,u,l,d;for(;++n<e.length;)if(e[n][0]===\"enter\"&&e[n][1].type===\"attentionSequence\"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===\"exit\"&&e[r][1].type===\"attentionSequence\"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},h={...e[n][1].start};Ai(c,-u),Ai(h,u),o={type:u>1?\"strongSequence\":\"emphasisSequence\",start:c,end:{...e[r][1].end}},s={type:u>1?\"strongSequence\":\"emphasisSequence\",start:{...e[n][1].start},end:h},a={type:u>1?\"strongText\":\"emphasisText\",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?\"strong\":\"emphasis\",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ie(l,[[\"enter\",e[r][1],t],[\"exit\",e[r][1],t]])),l=ie(l,[[\"enter\",i,t],[\"enter\",o,t],[\"exit\",o,t],[\"enter\",a,t]]),l=ie(l,Cn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ie(l,[[\"exit\",a,t],[\"enter\",s,t],[\"exit\",s,t],[\"exit\",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,l=ie(l,[[\"enter\",e[n][1],t],[\"exit\",e[n][1],t]])):d=0,me(e,r-1,n-r+3,l),n=r+l.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type===\"attentionSequence\"&&(e[n][1].type=\"data\");return e}function iu(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=bn(r);let a;return o;function o(u){return a=u,e.enter(\"attentionSequence\"),s(u)}function s(u){if(u===a)return e.consume(u),s;const l=e.exit(\"attentionSequence\"),d=bn(u),c=!d||d===2&&i||n.includes(u),h=!i||i===2&&d||n.includes(r);return l._open=!!(a===42?c:c&&(i||!h)),l._close=!!(a===42?h:h&&(d||!c)),t(u)}}function Ai(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const au={name:\"autolink\",tokenize:ou};function ou(e,t,n){let r=0;return i;function i(f){return e.enter(\"autolink\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.enter(\"autolinkProtocol\"),a}function a(f){return Pe(f)?(e.consume(f),o):f===64?n(f):l(f)}function o(f){return f===43||f===45||f===46||ge(f)?(r=1,s(f)):l(f)}function s(f){return f===58?(e.consume(f),r=0,u):(f===43||f===45||f===46||ge(f))&&r++<32?(e.consume(f),s):(r=0,l(f))}function u(f){return f===62?(e.exit(\"autolinkProtocol\"),e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):f===null||f===32||f===60||or(f)?n(f):(e.consume(f),u)}function l(f){return f===64?(e.consume(f),d):Ul(f)?(e.consume(f),l):n(f)}function d(f){return ge(f)?c(f):n(f)}function c(f){return f===46?(e.consume(f),r=0,d):f===62?(e.exit(\"autolinkProtocol\").type=\"autolinkEmail\",e.enter(\"autolinkMarker\"),e.consume(f),e.exit(\"autolinkMarker\"),e.exit(\"autolink\"),t):h(f)}function h(f){if((f===45||ge(f))&&r++<63){const p=f===45?h:c;return e.consume(f),p}return n(f)}}const In={partial:!0,tokenize:su};function su(e,t,n){return r;function r(a){return L(a)?H(e,i,\"linePrefix\")(a):i(a)}function i(a){return a===null||R(a)?t(a):n(a)}}const Ga={continuation:{tokenize:uu},exit:cu,name:\"blockQuote\",tokenize:lu};function lu(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter(\"blockQuote\",{_container:!0}),s.open=!0),e.enter(\"blockQuotePrefix\"),e.enter(\"blockQuoteMarker\"),e.consume(o),e.exit(\"blockQuoteMarker\"),a}return n(o)}function a(o){return L(o)?(e.enter(\"blockQuotePrefixWhitespace\"),e.consume(o),e.exit(\"blockQuotePrefixWhitespace\"),e.exit(\"blockQuotePrefix\"),t):(e.exit(\"blockQuotePrefix\"),t(o))}}function uu(e,t,n){const r=this;return i;function i(o){return L(o)?H(e,a,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(o):a(o)}function a(o){return e.attempt(Ga,t,n)(o)}}function cu(e){e.exit(\"blockQuote\")}const Ka={name:\"characterEscape\",tokenize:fu};function fu(e,t,n){return r;function r(a){return e.enter(\"characterEscape\"),e.enter(\"escapeMarker\"),e.consume(a),e.exit(\"escapeMarker\"),i}function i(a){return Wl(a)?(e.enter(\"characterEscapeValue\"),e.consume(a),e.exit(\"characterEscapeValue\"),e.exit(\"characterEscape\"),t):n(a)}}const Ya={name:\"characterReference\",tokenize:du};function du(e,t,n){const r=this;let i=0,a,o;return s;function s(c){return e.enter(\"characterReference\"),e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),u}function u(c){return c===35?(e.enter(\"characterReferenceMarkerNumeric\"),e.consume(c),e.exit(\"characterReferenceMarkerNumeric\"),l):(e.enter(\"characterReferenceValue\"),a=31,o=ge,d(c))}function l(c){return c===88||c===120?(e.enter(\"characterReferenceMarkerHexadecimal\"),e.consume(c),e.exit(\"characterReferenceMarkerHexadecimal\"),e.enter(\"characterReferenceValue\"),a=6,o=jl,d):(e.enter(\"characterReferenceValue\"),a=7,o=sr,d(c))}function d(c){if(c===59&&i){const h=e.exit(\"characterReferenceValue\");return o===ge&&!Wa(r.sliceSerialize(h))?n(c):(e.enter(\"characterReferenceMarker\"),e.consume(c),e.exit(\"characterReferenceMarker\"),e.exit(\"characterReference\"),t)}return o(c)&&i++<a?(e.consume(c),d):n(c)}}const Pi={partial:!0,tokenize:pu},Ti={concrete:!0,name:\"codeFenced\",tokenize:hu};function hu(e,t,n){const r=this,i={partial:!0,tokenize:C};let a=0,o=0,s;return u;function u(y){return l(y)}function l(y){const P=r.events[r.events.length-1];return a=P&&P[1].type===\"linePrefix\"?P[2].sliceSerialize(P[1],!0).length:0,s=y,e.enter(\"codeFenced\"),e.enter(\"codeFencedFence\"),e.enter(\"codeFencedFenceSequence\"),d(y)}function d(y){return y===s?(o++,e.consume(y),d):o<3?n(y):(e.exit(\"codeFencedFenceSequence\"),L(y)?H(e,c,\"whitespace\")(y):c(y))}function c(y){return y===null||R(y)?(e.exit(\"codeFencedFence\"),r.interrupt?t(y):e.check(Pi,b,A)(y)):(e.enter(\"codeFencedFenceInfo\"),e.enter(\"chunkString\",{contentType:\"string\"}),h(y))}function h(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),c(y)):L(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceInfo\"),H(e,f,\"whitespace\")(y)):y===96&&y===s?n(y):(e.consume(y),h)}function f(y){return y===null||R(y)?c(y):(e.enter(\"codeFencedFenceMeta\"),e.enter(\"chunkString\",{contentType:\"string\"}),p(y))}function p(y){return y===null||R(y)?(e.exit(\"chunkString\"),e.exit(\"codeFencedFenceMeta\"),c(y)):y===96&&y===s?n(y):(e.consume(y),p)}function b(y){return e.attempt(i,A,x)(y)}function x(y){return e.enter(\"lineEnding\"),e.consume(y),e.exit(\"lineEnding\"),_}function _(y){return a>0&&L(y)?H(e,k,\"linePrefix\",a+1)(y):k(y)}function k(y){return y===null||R(y)?e.check(Pi,b,A)(y):(e.enter(\"codeFlowValue\"),S(y))}function S(y){return y===null||R(y)?(e.exit(\"codeFlowValue\"),k(y)):(e.consume(y),S)}function A(y){return e.exit(\"codeFenced\"),t(y)}function C(y,P,T){let z=0;return v;function v(M){return y.enter(\"lineEnding\"),y.consume(M),y.exit(\"lineEnding\"),N}function N(M){return y.enter(\"codeFencedFence\"),L(M)?H(y,$,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(M):$(M)}function $(M){return M===s?(y.enter(\"codeFencedFenceSequence\"),B(M)):T(M)}function B(M){return M===s?(z++,y.consume(M),B):z>=o?(y.exit(\"codeFencedFenceSequence\"),L(M)?H(y,U,\"whitespace\")(M):U(M)):T(M)}function U(M){return M===null||R(M)?(y.exit(\"codeFencedFence\"),P(M)):T(M)}}}function pu(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Fn={name:\"codeIndented\",tokenize:mu},gu={partial:!0,tokenize:_u};function mu(e,t,n){const r=this;return i;function i(l){return e.enter(\"codeIndented\"),H(e,a,\"linePrefix\",5)(l)}function a(l){const d=r.events[r.events.length-1];return d&&d[1].type===\"linePrefix\"&&d[2].sliceSerialize(d[1],!0).length>=4?o(l):n(l)}function o(l){return l===null?u(l):R(l)?e.attempt(gu,o,u)(l):(e.enter(\"codeFlowValue\"),s(l))}function s(l){return l===null||R(l)?(e.exit(\"codeFlowValue\"),o(l)):(e.consume(l),s)}function u(l){return e.exit(\"codeIndented\"),t(l)}}function _u(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),i):H(e,a,\"linePrefix\",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):R(o)?i(o):n(o)}}const yu={name:\"codeText\",previous:vu,resolve:bu,tokenize:wu};function bu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===\"lineEnding\"||e[n][1].type===\"space\")&&(e[t][1].type===\"lineEnding\"||e[t][1].type===\"space\")){for(r=n;++r<t;)if(e[r][1].type===\"codeTextData\"){e[n][1].type=\"codeTextPadding\",e[t][1].type=\"codeTextPadding\",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==\"lineEnding\"&&(i=r):(r===t||e[r][1].type===\"lineEnding\")&&(e[i][1].type=\"codeTextData\",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function vu(e){return e!==96||this.events[this.events.length-1][1].type===\"characterEscape\"}function wu(e,t,n){let r=0,i,a;return o;function o(c){return e.enter(\"codeText\"),e.enter(\"codeTextSequence\"),s(c)}function s(c){return c===96?(e.consume(c),r++,s):(e.exit(\"codeTextSequence\"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter(\"space\"),e.consume(c),e.exit(\"space\"),u):c===96?(a=e.enter(\"codeTextSequence\"),i=0,d(c)):R(c)?(e.enter(\"lineEnding\"),e.consume(c),e.exit(\"lineEnding\"),u):(e.enter(\"codeTextData\"),l(c))}function l(c){return c===null||c===32||c===96||R(c)?(e.exit(\"codeTextData\"),u(c)):(e.consume(c),l)}function d(c){return c===96?(e.consume(c),i++,d):i===r?(e.exit(\"codeTextSequence\"),e.exit(\"codeText\"),t(c)):(a.type=\"codeTextData\",l(c))}}class ku{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError(\"Cannot access index `\"+t+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&wt(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),wt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);wt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wt(this.left,n.reverse())}}}function wt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ja(e){const t={};let n=-1,r,i,a,o,s,u,l;const d=new ku(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type===\"chunkFlow\"&&d.get(n-1)[1].type===\"listItemPrefix\"&&(u=r[1]._tokenizer.events,a=0,a<u.length&&u[a][1].type===\"lineEndingBlank\"&&(a+=2),a<u.length&&u[a][1].type===\"content\"))for(;++a<u.length&&u[a][1].type!==\"content\";)u[a][1].type===\"chunkText\"&&(u[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===\"enter\")r[1].contentType&&(Object.assign(t,Su(d,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=d.get(a),o[1].type===\"lineEnding\"||o[1].type===\"lineEndingBlank\")o[0]===\"enter\"&&(i&&(d.get(i)[1].type=\"lineEndingBlank\"),o[1].type=\"lineEnding\",i=a);else if(!(o[1].type===\"linePrefix\"||o[1].type===\"listItemIndent\"))break;i&&(r[1].end={...d.get(i)[1].start},s=d.slice(i,n),s.unshift(r),d.splice(i,n-i+1,s))}}return me(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function Su(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,u=[],l={};let d,c,h=-1,f=n,p=0,b=0;const x=[b];for(;f;){for(;e.get(++i)[1]!==f;);a.push(i),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),c&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),c=f,f=f.next}for(f=n;++h<s.length;)s[h][0]===\"exit\"&&s[h-1][0]===\"enter\"&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(b=h+1,x.push(b),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):x.pop(),h=x.length;h--;){const _=s.slice(x[h],x[h+1]),k=a.pop();u.push([k,k+_.length-1]),e.splice(k,2,_)}for(u.reverse(),h=-1;++h<u.length;)l[p+u[h][0]]=p+u[h][1],p+=u[h][1]-u[h][0]-1;return l}const xu={resolve:Iu,tokenize:Eu},Cu={partial:!0,tokenize:Au};function Iu(e){return Ja(e),e}function Eu(e,t){let n;return r;function r(s){return e.enter(\"content\"),n=e.enter(\"chunkContent\",{contentType:\"content\"}),i(s)}function i(s){return s===null?a(s):R(s)?e.check(Cu,o,a)(s):(e.consume(s),i)}function a(s){return e.exit(\"chunkContent\"),e.exit(\"content\"),t(s)}function o(s){return e.consume(s),e.exit(\"chunkContent\"),n.next=e.enter(\"chunkContent\",{contentType:\"content\",previous:n}),n=n.next,i}}function Au(e,t,n){const r=this;return i;function i(o){return e.exit(\"chunkContent\"),e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),H(e,a,\"linePrefix\")}function a(o){if(o===null||R(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(\"codeIndented\")&&s&&s[1].type===\"linePrefix\"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Za(e,t,n,r,i,a,o,s,u){const l=u||Number.POSITIVE_INFINITY;let d=0;return c;function c(_){return _===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(_),e.exit(a),h):_===null||_===32||_===41||or(_)?n(_):(e.enter(r),e.enter(o),e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),b(_))}function h(_){return _===62?(e.enter(a),e.consume(_),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(\"chunkString\",{contentType:\"string\"}),f(_))}function f(_){return _===62?(e.exit(\"chunkString\"),e.exit(s),h(_)):_===null||_===60||R(_)?n(_):(e.consume(_),_===92?p:f)}function p(_){return _===60||_===62||_===92?(e.consume(_),f):f(_)}function b(_){return!d&&(_===null||_===41||oe(_))?(e.exit(\"chunkString\"),e.exit(s),e.exit(o),e.exit(r),t(_)):d<l&&_===40?(e.consume(_),d++,b):_===41?(e.consume(_),d--,b):_===null||_===32||_===40||or(_)?n(_):(e.consume(_),_===92?x:b)}function x(_){return _===40||_===41||_===92?(e.consume(_),b):b(_)}}function Xa(e,t,n,r,i,a){const o=this;let s=0,u;return l;function l(f){return e.enter(r),e.enter(i),e.consume(f),e.exit(i),e.enter(a),d}function d(f){return s>999||f===null||f===91||f===93&&!u||f===94&&!s&&\"_hiddenFootnoteSupport\"in o.parser.constructs?n(f):f===93?(e.exit(a),e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):R(f)?(e.enter(\"lineEnding\"),e.consume(f),e.exit(\"lineEnding\"),d):(e.enter(\"chunkString\",{contentType:\"string\"}),c(f))}function c(f){return f===null||f===91||f===93||R(f)||s++>999?(e.exit(\"chunkString\"),d(f)):(e.consume(f),u||(u=!L(f)),f===92?h:c)}function h(f){return f===91||f===92||f===93?(e.consume(f),s++,c):c(f)}}function eo(e,t,n,r,i,a){let o;return s;function s(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,u):n(h)}function u(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(a),l(h))}function l(h){return h===o?(e.exit(a),u(o)):h===null?n(h):R(h)?(e.enter(\"lineEnding\"),e.consume(h),e.exit(\"lineEnding\"),H(e,l,\"linePrefix\")):(e.enter(\"chunkString\",{contentType:\"string\"}),d(h))}function d(h){return h===o||h===null||R(h)?(e.exit(\"chunkString\"),l(h)):(e.consume(h),h===92?c:d)}function c(h){return h===o||h===92?(e.consume(h),d):d(h)}}function At(e,t){let n;return r;function r(i){return R(i)?(e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),n=!0,r):L(i)?H(e,r,n?\"linePrefix\":\"lineSuffix\")(i):t(i)}}const Pu={name:\"definition\",tokenize:Nu},Tu={partial:!0,tokenize:Du};function Nu(e,t,n){const r=this;let i;return a;function a(f){return e.enter(\"definition\"),o(f)}function o(f){return Xa.call(r,e,s,n,\"definitionLabel\",\"definitionLabelMarker\",\"definitionLabelString\")(f)}function s(f){return i=Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),f===58?(e.enter(\"definitionMarker\"),e.consume(f),e.exit(\"definitionMarker\"),u):n(f)}function u(f){return oe(f)?At(e,l)(f):l(f)}function l(f){return Za(e,d,n,\"definitionDestination\",\"definitionDestinationLiteral\",\"definitionDestinationLiteralMarker\",\"definitionDestinationRaw\",\"definitionDestinationString\")(f)}function d(f){return e.attempt(Tu,c,c)(f)}function c(f){return L(f)?H(e,h,\"whitespace\")(f):h(f)}function h(f){return f===null||R(f)?(e.exit(\"definition\"),r.parser.defined.push(i),t(f)):n(f)}}function Du(e,t,n){return r;function r(s){return oe(s)?At(e,i)(s):n(s)}function i(s){return eo(e,a,n,\"definitionTitle\",\"definitionTitleMarker\",\"definitionTitleString\")(s)}function a(s){return L(s)?H(e,o,\"whitespace\")(s):o(s)}function o(s){return s===null||R(s)?t(s):n(s)}}const $u={name:\"hardBreakEscape\",tokenize:zu};function zu(e,t,n){return r;function r(a){return e.enter(\"hardBreakEscape\"),e.consume(a),i}function i(a){return R(a)?(e.exit(\"hardBreakEscape\"),t(a)):n(a)}}const Fu={name:\"headingAtx\",resolve:Ru,tokenize:Ou};function Ru(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===\"whitespace\"&&(r+=2),n-2>r&&e[n][1].type===\"whitespace\"&&(n-=2),e[n][1].type===\"atxHeadingSequence\"&&(r===n-1||n-4>r&&e[n-2][1].type===\"whitespace\")&&(n-=r+1===n?2:4),n>r&&(i={type:\"atxHeadingText\",start:e[r][1].start,end:e[n][1].end},a={type:\"chunkText\",start:e[r][1].start,end:e[n][1].end,contentType:\"text\"},me(e,r,n-r+1,[[\"enter\",i,t],[\"enter\",a,t],[\"exit\",a,t],[\"exit\",i,t]])),e}function Ou(e,t,n){let r=0;return i;function i(d){return e.enter(\"atxHeading\"),a(d)}function a(d){return e.enter(\"atxHeadingSequence\"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||oe(d)?(e.exit(\"atxHeadingSequence\"),s(d)):n(d)}function s(d){return d===35?(e.enter(\"atxHeadingSequence\"),u(d)):d===null||R(d)?(e.exit(\"atxHeading\"),t(d)):L(d)?H(e,s,\"whitespace\")(d):(e.enter(\"atxHeadingText\"),l(d))}function u(d){return d===35?(e.consume(d),u):(e.exit(\"atxHeadingSequence\"),s(d))}function l(d){return d===null||d===35||oe(d)?(e.exit(\"atxHeadingText\"),s(d)):(e.consume(d),l)}}const Mu=[\"address\",\"article\",\"aside\",\"base\",\"basefont\",\"blockquote\",\"body\",\"caption\",\"center\",\"col\",\"colgroup\",\"dd\",\"details\",\"dialog\",\"dir\",\"div\",\"dl\",\"dt\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"frame\",\"frameset\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"head\",\"header\",\"hr\",\"html\",\"iframe\",\"legend\",\"li\",\"link\",\"main\",\"menu\",\"menuitem\",\"nav\",\"noframes\",\"ol\",\"optgroup\",\"option\",\"p\",\"param\",\"search\",\"section\",\"summary\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"title\",\"tr\",\"track\",\"ul\"],Ni=[\"pre\",\"script\",\"style\",\"textarea\"],Lu={concrete:!0,name:\"htmlFlow\",resolveTo:Hu,tokenize:qu},Vu={partial:!0,tokenize:ju},Bu={partial:!0,tokenize:Uu};function Hu(e){let t=e.length;for(;t--&&!(e[t][0]===\"enter\"&&e[t][1].type===\"htmlFlow\"););return t>1&&e[t-2][1].type===\"linePrefix\"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function qu(e,t,n){const r=this;let i,a,o,s,u;return l;function l(g){return d(g)}function d(g){return e.enter(\"htmlFlow\"),e.enter(\"htmlFlowData\"),e.consume(g),c}function c(g){return g===33?(e.consume(g),h):g===47?(e.consume(g),a=!0,b):g===63?(e.consume(g),i=3,r.interrupt?t:m):Pe(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function h(g){return g===45?(e.consume(g),i=2,f):g===91?(e.consume(g),i=5,s=0,p):Pe(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function f(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function p(g){const q=\"CDATA[\";return g===q.charCodeAt(s++)?(e.consume(g),s===q.length?r.interrupt?t:$:p):n(g)}function b(g){return Pe(g)?(e.consume(g),o=String.fromCharCode(g),x):n(g)}function x(g){if(g===null||g===47||g===62||oe(g)){const q=g===47,se=o.toLowerCase();return!q&&!a&&Ni.includes(se)?(i=1,r.interrupt?t(g):$(g)):Mu.includes(o.toLowerCase())?(i=6,q?(e.consume(g),_):r.interrupt?t(g):$(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):a?k(g):S(g))}return g===45||ge(g)?(e.consume(g),o+=String.fromCharCode(g),x):n(g)}function _(g){return g===62?(e.consume(g),r.interrupt?t:$):n(g)}function k(g){return L(g)?(e.consume(g),k):v(g)}function S(g){return g===47?(e.consume(g),v):g===58||g===95||Pe(g)?(e.consume(g),A):L(g)?(e.consume(g),S):v(g)}function A(g){return g===45||g===46||g===58||g===95||ge(g)?(e.consume(g),A):C(g)}function C(g){return g===61?(e.consume(g),y):L(g)?(e.consume(g),C):S(g)}function y(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,P):L(g)?(e.consume(g),y):T(g)}function P(g){return g===u?(e.consume(g),u=null,z):g===null||R(g)?n(g):(e.consume(g),P)}function T(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||oe(g)?C(g):(e.consume(g),T)}function z(g){return g===47||g===62||L(g)?S(g):n(g)}function v(g){return g===62?(e.consume(g),N):n(g)}function N(g){return g===null||R(g)?$(g):L(g)?(e.consume(g),N):n(g)}function $(g){return g===45&&i===2?(e.consume(g),Z):g===60&&i===1?(e.consume(g),J):g===62&&i===4?(e.consume(g),D):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),ke):R(g)&&(i===6||i===7)?(e.exit(\"htmlFlowData\"),e.check(Vu,j,B)(g)):g===null||R(g)?(e.exit(\"htmlFlowData\"),B(g)):(e.consume(g),$)}function B(g){return e.check(Bu,U,j)(g)}function U(g){return e.enter(\"lineEnding\"),e.consume(g),e.exit(\"lineEnding\"),M}function M(g){return g===null||R(g)?B(g):(e.enter(\"htmlFlowData\"),$(g))}function Z(g){return g===45?(e.consume(g),m):$(g)}function J(g){return g===47?(e.consume(g),o=\"\",he):$(g)}function he(g){if(g===62){const q=o.toLowerCase();return Ni.includes(q)?(e.consume(g),D):$(g)}return Pe(g)&&o.length<8?(e.consume(g),o+=String.fromCharCode(g),he):$(g)}function ke(g){return g===93?(e.consume(g),m):$(g)}function m(g){return g===62?(e.consume(g),D):g===45&&i===2?(e.consume(g),m):$(g)}function D(g){return g===null||R(g)?(e.exit(\"htmlFlowData\"),j(g)):(e.consume(g),D)}function j(g){return e.exit(\"htmlFlow\"),t(g)}}function Uu(e,t,n){const r=this;return i;function i(o){return R(o)?(e.enter(\"lineEnding\"),e.consume(o),e.exit(\"lineEnding\"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function ju(e,t,n){return r;function r(i){return e.enter(\"lineEnding\"),e.consume(i),e.exit(\"lineEnding\"),e.attempt(In,t,n)}}const Wu={name:\"htmlText\",tokenize:Qu};function Qu(e,t,n){const r=this;let i,a,o;return s;function s(m){return e.enter(\"htmlText\"),e.enter(\"htmlTextData\"),e.consume(m),u}function u(m){return m===33?(e.consume(m),l):m===47?(e.consume(m),C):m===63?(e.consume(m),S):Pe(m)?(e.consume(m),T):n(m)}function l(m){return m===45?(e.consume(m),d):m===91?(e.consume(m),a=0,p):Pe(m)?(e.consume(m),k):n(m)}function d(m){return m===45?(e.consume(m),f):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),h):R(m)?(o=c,J(m)):(e.consume(m),c)}function h(m){return m===45?(e.consume(m),f):c(m)}function f(m){return m===62?Z(m):m===45?h(m):c(m)}function p(m){const D=\"CDATA[\";return m===D.charCodeAt(a++)?(e.consume(m),a===D.length?b:p):n(m)}function b(m){return m===null?n(m):m===93?(e.consume(m),x):R(m)?(o=b,J(m)):(e.consume(m),b)}function x(m){return m===93?(e.consume(m),_):b(m)}function _(m){return m===62?Z(m):m===93?(e.consume(m),_):b(m)}function k(m){return m===null||m===62?Z(m):R(m)?(o=k,J(m)):(e.consume(m),k)}function S(m){return m===null?n(m):m===63?(e.consume(m),A):R(m)?(o=S,J(m)):(e.consume(m),S)}function A(m){return m===62?Z(m):S(m)}function C(m){return Pe(m)?(e.consume(m),y):n(m)}function y(m){return m===45||ge(m)?(e.consume(m),y):P(m)}function P(m){return R(m)?(o=P,J(m)):L(m)?(e.consume(m),P):Z(m)}function T(m){return m===45||ge(m)?(e.consume(m),T):m===47||m===62||oe(m)?z(m):n(m)}function z(m){return m===47?(e.consume(m),Z):m===58||m===95||Pe(m)?(e.consume(m),v):R(m)?(o=z,J(m)):L(m)?(e.consume(m),z):Z(m)}function v(m){return m===45||m===46||m===58||m===95||ge(m)?(e.consume(m),v):N(m)}function N(m){return m===61?(e.consume(m),$):R(m)?(o=N,J(m)):L(m)?(e.consume(m),N):z(m)}function $(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,B):R(m)?(o=$,J(m)):L(m)?(e.consume(m),$):(e.consume(m),U)}function B(m){return m===i?(e.consume(m),i=void 0,M):m===null?n(m):R(m)?(o=B,J(m)):(e.consume(m),B)}function U(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||oe(m)?z(m):(e.consume(m),U)}function M(m){return m===47||m===62||oe(m)?z(m):n(m)}function Z(m){return m===62?(e.consume(m),e.exit(\"htmlTextData\"),e.exit(\"htmlText\"),t):n(m)}function J(m){return e.exit(\"htmlTextData\"),e.enter(\"lineEnding\"),e.consume(m),e.exit(\"lineEnding\"),he}function he(m){return L(m)?H(e,ke,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(m):ke(m)}function ke(m){return e.enter(\"htmlTextData\"),o(m)}}const Tr={name:\"labelEnd\",resolveAll:Ju,resolveTo:Zu,tokenize:Xu},Gu={tokenize:ec},Ku={tokenize:tc},Yu={tokenize:nc};function Ju(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type===\"labelImage\"||r.type===\"labelLink\"||r.type===\"labelEnd\"){const i=r.type===\"labelImage\"?4:2;r.type=\"data\",t+=i}}return e.length!==n.length&&me(e,0,e.length,n),e}function Zu(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===\"link\"||i.type===\"labelLink\"&&i._inactive)break;e[n][0]===\"enter\"&&i.type===\"labelLink\"&&(i._inactive=!0)}else if(o){if(e[n][0]===\"enter\"&&(i.type===\"labelImage\"||i.type===\"labelLink\")&&!i._balanced&&(a=n,i.type!==\"labelLink\")){r=2;break}}else i.type===\"labelEnd\"&&(o=n);const u={type:e[a][1].type===\"labelLink\"?\"link\":\"image\",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:\"label\",start:{...e[a][1].start},end:{...e[o][1].end}},d={type:\"labelText\",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[\"enter\",u,t],[\"enter\",l,t]],s=ie(s,e.slice(a+1,a+r+3)),s=ie(s,[[\"enter\",d,t]]),s=ie(s,Cn(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ie(s,[[\"exit\",d,t],e[o-2],e[o-1],[\"exit\",l,t]]),s=ie(s,e.slice(o+1)),s=ie(s,[[\"exit\",u,t]]),me(e,a,e.length,s),e}function Xu(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===\"labelImage\"||r.events[i][1].type===\"labelLink\")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(h){return a?a._inactive?c(h):(o=r.parser.defined.includes(Ot(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(\"labelEnd\"),e.enter(\"labelMarker\"),e.consume(h),e.exit(\"labelMarker\"),e.exit(\"labelEnd\"),u):n(h)}function u(h){return h===40?e.attempt(Gu,d,o?d:c)(h):h===91?e.attempt(Ku,d,o?l:c)(h):o?d(h):c(h)}function l(h){return e.attempt(Yu,d,c)(h)}function d(h){return t(h)}function c(h){return a._balanced=!0,n(h)}}function ec(e,t,n){return r;function r(c){return e.enter(\"resource\"),e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),i}function i(c){return oe(c)?At(e,a)(c):a(c)}function a(c){return c===41?d(c):Za(e,o,s,\"resourceDestination\",\"resourceDestinationLiteral\",\"resourceDestinationLiteralMarker\",\"resourceDestinationRaw\",\"resourceDestinationString\",32)(c)}function o(c){return oe(c)?At(e,u)(c):d(c)}function s(c){return n(c)}function u(c){return c===34||c===39||c===40?eo(e,l,n,\"resourceTitle\",\"resourceTitleMarker\",\"resourceTitleString\")(c):d(c)}function l(c){return oe(c)?At(e,d)(c):d(c)}function d(c){return c===41?(e.enter(\"resourceMarker\"),e.consume(c),e.exit(\"resourceMarker\"),e.exit(\"resource\"),t):n(c)}}function tc(e,t,n){const r=this;return i;function i(s){return Xa.call(r,e,a,o,\"reference\",\"referenceMarker\",\"referenceString\")(s)}function a(s){return r.parser.defined.includes(Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function nc(e,t,n){return r;function r(a){return e.enter(\"reference\"),e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),i}function i(a){return a===93?(e.enter(\"referenceMarker\"),e.consume(a),e.exit(\"referenceMarker\"),e.exit(\"reference\"),t):n(a)}}const rc={name:\"labelStartImage\",resolveAll:Tr.resolveAll,tokenize:ic};function ic(e,t,n){const r=this;return i;function i(s){return e.enter(\"labelImage\"),e.enter(\"labelImageMarker\"),e.consume(s),e.exit(\"labelImageMarker\"),a}function a(s){return s===91?(e.enter(\"labelMarker\"),e.consume(s),e.exit(\"labelMarker\"),e.exit(\"labelImage\"),o):n(s)}function o(s){return s===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(s):t(s)}}const ac={name:\"labelStartLink\",resolveAll:Tr.resolveAll,tokenize:oc};function oc(e,t,n){const r=this;return i;function i(o){return e.enter(\"labelLink\"),e.enter(\"labelMarker\"),e.consume(o),e.exit(\"labelMarker\"),e.exit(\"labelLink\"),a}function a(o){return o===94&&\"_hiddenFootnoteSupport\"in r.parser.constructs?n(o):t(o)}}const Rn={name:\"lineEnding\",tokenize:sc};function sc(e,t){return n;function n(r){return e.enter(\"lineEnding\"),e.consume(r),e.exit(\"lineEnding\"),H(e,t,\"linePrefix\")}}const on={name:\"thematicBreak\",tokenize:lc};function lc(e,t,n){let r=0,i;return a;function a(l){return e.enter(\"thematicBreak\"),o(l)}function o(l){return i=l,s(l)}function s(l){return l===i?(e.enter(\"thematicBreakSequence\"),u(l)):r>=3&&(l===null||R(l))?(e.exit(\"thematicBreak\"),t(l)):n(l)}function u(l){return l===i?(e.consume(l),r++,u):(e.exit(\"thematicBreakSequence\"),L(l)?H(e,s,\"whitespace\")(l):s(l))}}const ce={continuation:{tokenize:dc},exit:pc,name:\"list\",tokenize:fc},uc={partial:!0,tokenize:gc},cc={partial:!0,tokenize:hc};function fc(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type===\"linePrefix\"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(f){const p=r.containerState.type||(f===42||f===43||f===45?\"listUnordered\":\"listOrdered\");if(p===\"listUnordered\"?!r.containerState.marker||f===r.containerState.marker:sr(f)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p===\"listUnordered\")return e.enter(\"listItemPrefix\"),f===42||f===45?e.check(on,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 sr(f)&&++o<10?(e.consume(f),u):(!r.interrupt||o<2)&&(r.containerState.marker?f===r.containerState.marker:f===41||f===46)?(e.exit(\"listItemValue\"),l(f)):n(f)}function l(f){return e.enter(\"listItemMarker\"),e.consume(f),e.exit(\"listItemMarker\"),r.containerState.marker=r.containerState.marker||f,e.check(In,r.interrupt?n:d,e.attempt(uc,h,c))}function d(f){return r.containerState.initialBlankLine=!0,a++,h(f)}function c(f){return L(f)?(e.enter(\"listItemPrefixWhitespace\"),e.consume(f),e.exit(\"listItemPrefixWhitespace\"),h):n(f)}function h(f){return r.containerState.size=a+r.sliceSerialize(e.exit(\"listItemPrefix\"),!0).length,t(f)}}function dc(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(In,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,H(e,t,\"listItemIndent\",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!L(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(cc,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,H(e,e.attempt(ce,t,n),\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(s)}}function hc(e,t,n){const r=this;return H(e,i,\"listItemIndent\",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type===\"listItemIndent\"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function pc(e){e.exit(this.containerState.type)}function gc(e,t,n){const r=this;return H(e,i,\"listItemPrefixWhitespace\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!L(a)&&o&&o[1].type===\"listItemPrefixWhitespace\"?t(a):n(a)}}const Di={name:\"setextUnderline\",resolveTo:mc,tokenize:_c};function mc(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===\"enter\"){if(e[n][1].type===\"content\"){r=n;break}e[n][1].type===\"paragraph\"&&(i=n)}else e[n][1].type===\"content\"&&e.splice(n,1),!a&&e[n][1].type===\"definition\"&&(a=n);const o={type:\"setextHeading\",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=\"setextHeadingText\",a?(e.splice(i,0,[\"enter\",o,t]),e.splice(a+1,0,[\"exit\",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([\"exit\",o,t]),e}function _c(e,t,n){const r=this;let i;return a;function a(l){let d=r.events.length,c;for(;d--;)if(r.events[d][1].type!==\"lineEnding\"&&r.events[d][1].type!==\"linePrefix\"&&r.events[d][1].type!==\"content\"){c=r.events[d][1].type===\"paragraph\";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter(\"setextHeadingLine\"),i=l,o(l)):n(l)}function o(l){return e.enter(\"setextHeadingLineSequence\"),s(l)}function s(l){return l===i?(e.consume(l),s):(e.exit(\"setextHeadingLineSequence\"),L(l)?H(e,u,\"lineSuffix\")(l):u(l))}function u(l){return l===null||R(l)?(e.exit(\"setextHeadingLine\"),t(l)):n(l)}}const yc={tokenize:bc};function bc(e){const t=this,n=e.attempt(In,r,e.attempt(this.parser.constructs.flowInitial,i,H(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xu,i)),\"linePrefix\")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter(\"lineEndingBlank\"),e.consume(a),e.exit(\"lineEndingBlank\"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter(\"lineEnding\"),e.consume(a),e.exit(\"lineEnding\"),t.currentConstruct=void 0,n}}const vc={resolveAll:no()},wc=to(\"string\"),kc=to(\"text\");function to(e){return{resolveAll:no(e===\"text\"?Sc:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(d){return l(d)?a(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter(\"data\"),n.consume(d),u}function u(d){return l(d)?(n.exit(\"data\"),a(d)):(n.consume(d),u)}function l(d){if(d===null)return!0;const c=i[d];let h=-1;if(c)for(;++h<c.length;){const f=c[h];if(!f.previous||f.previous.call(r,r.previous))return!0}return!1}}}function no(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type===\"data\"&&(a=i,i++):(!n[i]||n[i][1].type!==\"data\")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function Sc(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===\"lineEnding\")&&e[n-1][1].type===\"data\"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,u;for(;a--;){const l=i[a];if(typeof l==\"string\"){for(o=l.length;l.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(l===-2)u=!0,s++;else if(l!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const l={type:n===e.length||u||s<2?\"lineSuffix\":\"hardBreakTrailing\",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,[\"enter\",l,t],[\"exit\",l,t]),n+=2)}n++}return e}const xc={42:ce,43:ce,45:ce,48:ce,49:ce,50:ce,51:ce,52:ce,53:ce,54:ce,55:ce,56:ce,57:ce,62:Ga},Cc={91:Pu},Ic={[-2]:Fn,[-1]:Fn,32:Fn},Ec={35:Fu,42:on,45:[Di,on],60:Lu,61:Di,95:on,96:Ti,126:Ti},Ac={38:Ya,92:Ka},Pc={[-5]:Rn,[-4]:Rn,[-3]:Rn,33:rc,38:Ya,42:lr,60:[au,Wu],91:ac,92:[$u,Ka],93:Tr,95:lr,96:yu},Tc={null:[lr,vc]},Nc={null:[42,95]},Dc={null:[]},$c=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Nc,contentInitial:Cc,disable:Dc,document:xc,flow:Ec,flowInitial:Ic,insideSpan:Tc,string:Ac,text:Pc},Symbol.toStringTag,{value:\"Module\"}));function zc(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let o=[],s=[];const u={attempt:P(C),check:P(y),consume:k,enter:S,exit:A,interrupt:P(y,{interrupt:!0})},l={code:null,containerState:{},defineSkip:b,events:[],now:p,parser:e,previous:null,sliceSerialize:h,sliceStream:f,write:c};let d=t.tokenize.call(l,u);return t.resolveAll&&a.push(t),l;function c(N){return o=ie(o,N),x(),o[o.length-1]!==null?[]:(T(t,0),l.events=Cn(a,l.events,l),l.events)}function h(N,$){return Rc(f(N),$)}function f(N){return Fc(o,N)}function p(){const{_bufferIndex:N,_index:$,line:B,column:U,offset:M}=r;return{_bufferIndex:N,_index:$,line:B,column:U,offset:M}}function b(N){i[N.line]=N.column,v()}function x(){let N;for(;r._index<o.length;){const $=o[r._index];if(typeof $==\"string\")for(N=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===N&&r._bufferIndex<$.length;)_($.charCodeAt(r._bufferIndex));else _($)}}function _(N){d=d(N)}function k(N){R(N)?(r.line++,r.column=1,r.offset+=N===-3?2:1,v()):N!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=N}function S(N,$){const B=$||{};return B.type=N,B.start=p(),l.events.push([\"enter\",B,l]),s.push(B),B}function A(N){const $=s.pop();return $.end=p(),l.events.push([\"exit\",$,l]),$}function C(N,$){T(N,$.from)}function y(N,$){$.restore()}function P(N,$){return B;function B(U,M,Z){let J,he,ke,m;return Array.isArray(U)?j(U):\"tokenize\"in U?j([U]):D(U);function D(ee){return bt;function bt(Me){const ot=Me!==null&&ee[Me],st=Me!==null&&ee.null,Tn=[...Array.isArray(ot)?ot:ot?[ot]:[],...Array.isArray(st)?st:st?[st]:[]];return j(Tn)(Me)}}function j(ee){return J=ee,he=0,ee.length===0?Z:g(ee[he])}function g(ee){return bt;function bt(Me){return m=z(),ke=ee,ee.partial||(l.currentConstruct=ee),ee.name&&l.parser.constructs.disable.null.includes(ee.name)?se():ee.tokenize.call($?Object.assign(Object.create(l),$):l,u,q,se)(Me)}}function q(ee){return N(ke,m),M}function se(ee){return m.restore(),++he<J.length?g(J[he]):Z}}}function T(N,$){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&me(l.events,$,l.events.length-$,N.resolve(l.events.slice($),l)),N.resolveTo&&(l.events=N.resolveTo(l.events,l))}function z(){const N=p(),$=l.previous,B=l.currentConstruct,U=l.events.length,M=Array.from(s);return{from:U,restore:Z};function Z(){r=N,l.previous=$,l.currentConstruct=B,l.events.length=U,s=M,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Fc(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s==\"string\"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Rc(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a==\"string\")o=a;else switch(a){case-5:{o=\"\\r\";break}case-4:{o=`\n`;break}case-3:{o=`\\r\n`;break}case-2:{o=t?\" \":\"\t\";break}case-1:{if(!t&&i)continue;o=\" \";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(\"\")}function Oc(e){const r={constructs:Ol([$c,...(e||{}).extensions||[]]),content:i(Zl),defined:[],document:i(eu),flow:i(yc),lazy:{},string:i(wc),text:i(kc)};return r;function i(a){return o;function o(s){return zc(r,a,s)}}}function Mc(e){for(;!Ja(e););return e}const $i=/[\\0\\t\\n\\r]/g;function Lc(){let e=1,t=\"\",n=!0,r;return i;function i(a,o,s){const u=[];let l,d,c,h,f;for(a=t+(typeof a==\"string\"?a.toString():new TextDecoder(o||void 0).decode(a)),c=0,t=\"\",n&&(a.charCodeAt(0)===65279&&c++,n=void 0);c<a.length;){if($i.lastIndex=c,l=$i.exec(a),h=l&&l.index!==void 0?l.index:a.length,f=a.charCodeAt(h),!l){t=a.slice(c);break}if(f===10&&c===h&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<h&&(u.push(a.slice(c,h)),e+=h-c),f){case 0:{u.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,u.push(-2);e++<d;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=h+1}return s&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}function Vc(e,t,n){return typeof t!=\"string\"&&(n=t,t=void 0),Jl(n)(Mc(Oc(n).document().write(Lc()(e,t,!0))))}const On={none:\"\",left:' align=\"left\"',right:' align=\"right\"',center:' align=\"center\"'};function Bc(){return{enter:{table(e){const t=e._align;this.lineEndingIfNeeded(),this.tag(\"<table>\"),this.setData(\"tableAlign\",t)},tableBody(){this.tag(\"<tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=On[e[t]];n===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(\"<td\"+n+\">\"))},tableHead(){this.lineEndingIfNeeded(),this.tag(\"<thead>\")},tableHeader(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\"),n=On[e[t]];this.lineEndingIfNeeded(),this.tag(\"<th\"+n+\">\")},tableRow(){this.setData(\"tableColumn\",0),this.lineEndingIfNeeded(),this.tag(\"<tr>\")}},exit:{codeTextData(e){let t=this.sliceSerialize(e);this.getData(\"tableAlign\")&&(t=t.replace(/\\\\([\\\\|])/g,Hc)),this.raw(this.encode(t))},table(){this.setData(\"tableAlign\"),this.setData(\"slurpAllLineEndings\"),this.lineEndingIfNeeded(),this.tag(\"</table>\")},tableBody(){this.lineEndingIfNeeded(),this.tag(\"</tbody>\")},tableData(){const e=this.getData(\"tableAlign\"),t=this.getData(\"tableColumn\");t in e?(this.tag(\"</td>\"),this.setData(\"tableColumn\",t+1)):this.resume()},tableHead(){this.lineEndingIfNeeded(),this.tag(\"</thead>\")},tableHeader(){const e=this.getData(\"tableColumn\");this.tag(\"</th>\"),this.setData(\"tableColumn\",e+1)},tableRow(){const e=this.getData(\"tableAlign\");let t=this.getData(\"tableColumn\");for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(\"<td\"+On[e[t]]+\"></td>\"),t++;this.setData(\"tableColumn\",t),this.lineEndingIfNeeded(),this.tag(\"</tr>\")}}}}function Hc(e,t){return t===\"|\"?t:e}class qc{constructor(){this.map=[]}add(t,n,r){Uc(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function Uc(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function jc(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]===\"enter\")i[1].type===\"tableContent\"&&r.push(e[t+1][1].type===\"tableDelimiterMarker\"?\"left\":\"none\");else if(i[1].type===\"tableContent\"){if(e[t-1][1].type===\"tableDelimiterMarker\"){const a=r.length-1;r[a]=r[a]===\"left\"?\"center\":\"right\"}}else if(i[1].type===\"tableDelimiterRow\")break}else i[0]===\"enter\"&&i[1].type===\"tableDelimiterRow\"&&(n=!0);t+=1}return r}function Wc(){return{flow:{null:{name:\"table\",tokenize:Qc,resolveAll:Gc}}}}function Qc(e,t,n){const r=this;let i=0,a=0,o;return s;function s(v){let N=r.events.length-1;for(;N>-1;){const U=r.events[N][1].type;if(U===\"lineEnding\"||U===\"linePrefix\")N--;else break}const $=N>-1?r.events[N][1].type:null,B=$===\"tableHead\"||$===\"tableRow\"?y:u;return B===y&&r.parser.lazy[r.now().line]?n(v):B(v)}function u(v){return e.enter(\"tableHead\"),e.enter(\"tableRow\"),l(v)}function l(v){return v===124||(o=!0,a+=1),d(v)}function d(v){return v===null?n(v):R(v)?a>1?(a=0,r.interrupt=!0,e.exit(\"tableRow\"),e.enter(\"lineEnding\"),e.consume(v),e.exit(\"lineEnding\"),f):n(v):L(v)?H(e,d,\"whitespace\")(v):(a+=1,o&&(o=!1,i+=1),v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),o=!0,d):(e.enter(\"data\"),c(v)))}function c(v){return v===null||v===124||oe(v)?(e.exit(\"data\"),d(v)):(e.consume(v),v===92?h:c)}function h(v){return v===92||v===124?(e.consume(v),c):c(v)}function f(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter(\"tableDelimiterRow\"),o=!1,L(v)?H(e,p,\"linePrefix\",r.parser.constructs.disable.null.includes(\"codeIndented\")?void 0:4)(v):p(v))}function p(v){return v===45||v===58?x(v):v===124?(o=!0,e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),b):C(v)}function b(v){return L(v)?H(e,x,\"whitespace\")(v):x(v)}function x(v){return v===58?(a+=1,o=!0,e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),_):v===45?(a+=1,_(v)):v===null||R(v)?A(v):C(v)}function _(v){return v===45?(e.enter(\"tableDelimiterFiller\"),k(v)):C(v)}function k(v){return v===45?(e.consume(v),k):v===58?(o=!0,e.exit(\"tableDelimiterFiller\"),e.enter(\"tableDelimiterMarker\"),e.consume(v),e.exit(\"tableDelimiterMarker\"),S):(e.exit(\"tableDelimiterFiller\"),S(v))}function S(v){return L(v)?H(e,A,\"whitespace\")(v):A(v)}function A(v){return v===124?p(v):v===null||R(v)?!o||i!==a?C(v):(e.exit(\"tableDelimiterRow\"),e.exit(\"tableHead\"),t(v)):C(v)}function C(v){return n(v)}function y(v){return e.enter(\"tableRow\"),P(v)}function P(v){return v===124?(e.enter(\"tableCellDivider\"),e.consume(v),e.exit(\"tableCellDivider\"),P):v===null||R(v)?(e.exit(\"tableRow\"),t(v)):L(v)?H(e,P,\"whitespace\")(v):(e.enter(\"data\"),T(v))}function T(v){return v===null||v===124||oe(v)?(e.exit(\"data\"),P(v)):(e.consume(v),v===92?z:T)}function z(v){return v===92||v===124?(e.consume(v),T):T(v)}}function Gc(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,u=0,l,d,c;const h=new qc;for(;++n<e.length;){const f=e[n],p=f[1];f[0]===\"enter\"?p.type===\"tableHead\"?(s=!1,u!==0&&(zi(h,t,u,l,d),d=void 0,u=0),l={type:\"table\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",l,t]])):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(r=!0,c=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,d={type:\"tableBody\",start:Object.assign({},p.start),end:Object.assign({},p.end)},h.add(n,0,[[\"enter\",d,t]])),i=p.type===\"tableDelimiterRow\"?2:d?3:1):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],c=Xt(h,t,a,i,void 0,c),a=[0,0,0,0]),o[2]=n)):p.type===\"tableCellDivider\"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],c=Xt(h,t,a,i,void 0,c)),a=o,o=[a[1],n,0,0])):p.type===\"tableHead\"?(s=!0,u=n):p.type===\"tableRow\"||p.type===\"tableDelimiterRow\"?(u=n,a[1]!==0?(o[0]=o[1],c=Xt(h,t,a,i,n,c)):o[1]!==0&&(c=Xt(h,t,o,i,n,c)),i=0):i&&(p.type===\"data\"||p.type===\"tableDelimiterMarker\"||p.type===\"tableDelimiterFiller\")&&(o[3]=n)}for(u!==0&&zi(h,t,u,l,d),h.consume(t.events),n=-1;++n<t.events.length;){const f=t.events[n];f[0]===\"enter\"&&f[1].type===\"table\"&&(f[1]._align=jc(t.events,n))}return e}function Xt(e,t,n,r,i,a){const o=r===1?\"tableHeader\":r===2?\"tableDelimiter\":\"tableData\",s=\"tableContent\";n[0]!==0&&(a.end=Object.assign({},lt(t.events,n[0])),e.add(n[0],0,[[\"exit\",a,t]]));const u=lt(t.events,n[1]);if(a={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[[\"enter\",a,t]]),n[2]!==0){const l=lt(t.events,n[2]),d=lt(t.events,n[3]),c={type:s,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[[\"enter\",c,t]]),r!==2){const h=t.events[n[2]],f=t.events[n[3]];if(h[1].end=Object.assign({},f[1].end),h[1].type=\"chunkText\",h[1].contentType=\"text\",n[3]>n[2]+1){const p=n[2]+1,b=n[3]-n[2]-1;e.add(p,b,[])}}e.add(n[3]+1,0,[[\"exit\",c,t]])}return i!==void 0&&(a.end=Object.assign({},lt(t.events,i)),e.add(i,0,[[\"exit\",a,t]]),a=void 0),a}function zi(e,t,n,r,i){const a=[],o=lt(t.events,n);i&&(i.end=Object.assign({},o),a.push([\"exit\",i,t])),r.end=Object.assign({},o),a.push([\"exit\",r,t]),e.add(n+1,0,a)}function lt(e,t){const n=e[t],r=n[0]===\"enter\"?\"start\":\"end\";return n[1][r]}function Kc(){return{enter:{strikethrough(){this.tag(\"<del>\")}},exit:{strikethrough(){this.tag(\"</del>\")}}}}function Yc(e){let n={}.singleTilde;const r={name:\"strikethrough\",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let u=-1;for(;++u<o.length;)if(o[u][0]===\"enter\"&&o[u][1].type===\"strikethroughSequenceTemporary\"&&o[u][1]._close){let l=u;for(;l--;)if(o[l][0]===\"exit\"&&o[l][1].type===\"strikethroughSequenceTemporary\"&&o[l][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[l][1].end.offset-o[l][1].start.offset){o[u][1].type=\"strikethroughSequence\",o[l][1].type=\"strikethroughSequence\";const d={type:\"strikethrough\",start:Object.assign({},o[l][1].start),end:Object.assign({},o[u][1].end)},c={type:\"strikethroughText\",start:Object.assign({},o[l][1].end),end:Object.assign({},o[u][1].start)},h=[[\"enter\",d,s],[\"enter\",o[l][1],s],[\"exit\",o[l][1],s],[\"enter\",c,s]],f=s.parser.constructs.insideSpan.null;f&&me(h,h.length,0,Cn(f,o.slice(l+1,u),s)),me(h,h.length,0,[[\"exit\",c,s],[\"enter\",o[u][1],s],[\"exit\",o[u][1],s],[\"exit\",d,s]]),me(o,l-1,u-l+3,h),u=l+h.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type===\"strikethroughSequenceTemporary\"&&(o[u][1].type=\"data\");return o}function a(o,s,u){const l=this.previous,d=this.events;let c=0;return h;function h(p){return l===126&&d[d.length-1][1].type!==\"characterEscape\"?u(p):(o.enter(\"strikethroughSequenceTemporary\"),f(p))}function f(p){const b=bn(l);if(p===126)return c>1?u(p):(o.consume(p),c++,f);if(c<2&&!n)return u(p);const x=o.exit(\"strikethroughSequenceTemporary\"),_=bn(p);return x._open=!_||_===2&&!!b,x._close=!b||b===2&&!!_,s(p)}}}function Jc(e){return Vc(e,{allowDangerousHtml:!0,extensions:[Wc(),Yc(),{disable:{null:[\"codeIndented\"]}}],htmlExtensions:[Bc(),Kc()]})}const Zc={update:()=>{},getValues:()=>({})},Ce=nt({}),Qt=nt(Zc),ue=nt(!1),ur=nt(null);function Xc(e,t,n=!1){const r=document.createElement(\"div\");if(r.innerHTML=e.trim(),n)for(const a of Array.from(r.querySelectorAll(\":scope > p\")))a.replaceWith(...Array.from(a.childNodes));const i=Array.from(r.childNodes).map((a,o)=>ro(a,o,t));return w(Y,{children:i})}function ro(e,t,n){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType===Node.ELEMENT_NODE){const r=e,i=r.localName,a=r.getAttribute(\"data-tw\");if(a!=null)return n[parseInt(a,10)];const o={key:t};for(const u of Array.from(r.attributes))o[u.name]=u.value;const s=Array.from(r.childNodes).map((u,l)=>ro(u,l,n));return G(i,o,...s)}return null}function ef({node:e}){const t=Er(),n=K(ue),r=K(Ce),i={};for(const[a,o]of Object.entries(e.attributes))i[a]=t(o)??o;return G(e.tag,i,e.children.length>0?Ie(e.children,{nobr:n,locals:r}):void 0)}function tf(){const e=K(ur),t=K(ue),n=K(Ce);return!e||e.length===0?null:w(Y,{children:Ie(e,{nobr:t,locals:n})})}function nf(e,t){if(Rl(e.name))return null;const n=Dl(e.name);if(n)return w(Nl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);const r=zl(e.name);return r?w(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):w(\"span\",{class:\"error\",children:`{unknown macro: ${e.name}}`},t)}function cr(e,t){switch(e.type){case\"text\":return e.value;case\"variable\":return e.scope===\"local\"&&e.name===\"children\"?w(tf,{},t):w(yl,{name:e.name,scope:e.scope,className:e.className,id:e.id},t);case\"macro\":return nf(e,t);case\"html\":return w(ef,{node:e},t);default:return e}}function io(e){return e.length===0?null:e.map((t,n)=>cr(t,n))}function rf(e){let t=0;for(let n=0;n<e.length;n++)e[n]===\"`\"&&t++;return t%2===1}function af(e,t){const n=I.getState(),r=e.name.split(\".\"),i=r[0];let a;e.scope===\"variable\"?a=n.variables[i]:e.scope===\"temporary\"?a=n.temporary[i]:a=t[i];for(let o=1;o<r.length;o++){if(a==null||typeof a!=\"object\")return\"\";a=a[r[o]]}return a==null?\"\":String(a)}function Ie(e,t){if(e.length===0)return null;if(!e.some(s=>s.type===\"text\"))return e.map((s,u)=>cr(s,u));const r=[];let i=\"\";const a=t?.locals??{};for(let s=0;s<e.length;s++){const u=e[s];if(u.type===\"text\")i+=u.value;else if(u.type===\"variable\"&&rf(i))i+=af(u,a);else{const l=r.length;r.push(cr(u,s)),i+=`<span data-tw=\"${l}\"></span>`}}const o=Jc(i);return Xc(o,r,t?.nobr)}function of(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;if(t.version!==1||typeof t.ifid!=\"string\"||typeof t.save!=\"object\"||t.save===null)return!1;const n=t.save;if(typeof n.meta!=\"object\"||n.meta===null||typeof n.payload!=\"object\"||n.payload===null)return!1;const r=n.meta;if(typeof r.id!=\"string\"||typeof r.passage!=\"string\"||typeof r.ifid!=\"string\"||typeof r.playthroughId!=\"string\"||typeof r.createdAt!=\"string\"||typeof r.updatedAt!=\"string\"||typeof r.title!=\"string\")return!1;const i=n.payload;return!(typeof i.passage!=\"string\"||!Array.isArray(i.history)||i.history.length===0||typeof i.historyIndex!=\"number\"||typeof i.variables!=\"object\"||i.variables===null)}function sf(e){if(typeof e!=\"object\"||e===null)return!1;const t=e;return!(typeof t.passage!=\"string\"||typeof t.variables!=\"object\"||t.variables===null||!Array.isArray(t.history)||t.history.length===0||typeof t.historyIndex!=\"number\")}const lf=\"spindle\",uf=1;let en=null,Mn=null;function qe(){return Mn||(Mn={saves:new Map,playthroughs:new Map,meta:new Map}),Mn}function cf(){return en||(typeof indexedDB>\"u\"?Promise.reject(new Error(\"IndexedDB unavailable\")):(en=new Promise((e,t)=>{const n=indexedDB.open(lf,uf);n.onupgradeneeded=()=>{const r=n.result;if(!r.objectStoreNames.contains(\"saves\")){const i=r.createObjectStore(\"saves\",{keyPath:\"meta.id\"});i.createIndex(\"ifid\",\"meta.ifid\",{unique:!1}),i.createIndex(\"playthroughId\",\"meta.playthroughId\",{unique:!1})}r.objectStoreNames.contains(\"playthroughs\")||r.createObjectStore(\"playthroughs\",{keyPath:\"id\"}).createIndex(\"ifid\",\"ifid\",{unique:!1}),r.objectStoreNames.contains(\"meta\")||r.createObjectStore(\"meta\",{keyPath:\"key\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),en))}function Ue(e,t){return cf().then(n=>n.transaction(e,t).objectStore(e))}function je(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function En(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.put(e))}catch{qe().saves.set(e.meta.id,e)}}async function An(e){try{const t=await Ue(\"saves\",\"readonly\");return await je(t.get(e))??void 0}catch{return qe().saves.get(e)}}async function ff(e){try{const t=await Ue(\"saves\",\"readwrite\");await je(t.delete(e))}catch{qe().saves.delete(e)}}async function df(e){try{const n=(await Ue(\"saves\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().saves.values()].filter(t=>t.meta.ifid===e)}}async function ao(e){try{const t=await Ue(\"playthroughs\",\"readwrite\");await je(t.put(e))}catch{qe().playthroughs.set(e.id,e)}}async function Nr(e){try{const n=(await Ue(\"playthroughs\",\"readonly\")).index(\"ifid\");return await je(n.getAll(e))??[]}catch{return[...qe().playthroughs.values()].filter(t=>t.ifid===e)}}async function Dr(e){try{const t=await Ue(\"meta\",\"readonly\"),n=await je(t.get(e));return n?n.value:void 0}catch{return qe().meta.get(e)}}async function oo(e,t){try{const n=await Ue(\"meta\",\"readwrite\");await je(n.put({key:e,value:t}))}catch{qe().meta.set(e,t)}}const so=new Map,Pn=new Map;function hf(e,t){so.set(e,t),Pn.set(t,e)}function pf(e){if(typeof e!=\"object\"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function re(e){const t=new Map;function n(r){if(r===null||typeof r!=\"object\")return r;const i=r;if(t.has(i))return t.get(i);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const s=[];t.set(i,s);for(let u=0;u<r.length;u++)s[u]=n(r[u]);return s}const a=i.constructor;if(Pn.get(a)!==void 0){const s=Object.create(Object.getPrototypeOf(i));t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}if(pf(r)||typeof r==\"object\"){const s={};t.set(i,s);for(const u of Object.keys(i))s[u]=n(i[u]);return s}return r}return n(e)}const Pt=\"__spindle_class__\",Tt=\"__spindle_data__\";function Ye(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),{[Pt]:\"__Date__\",[Tt]:{iso:r.toISOString()}};if(r instanceof RegExp)return t.delete(i),{[Pt]:\"__RegExp__\",[Tt]:{source:r.source,flags:r.flags}};if(Array.isArray(r)){const u=r.map(l=>n(l));return t.delete(i),u}const a=i.constructor,o=Pn.get(a);if(o!==void 0){const u={};for(const l of Object.keys(i))u[l]=n(i[l]);return t.delete(i),{[Pt]:o,[Tt]:u}}const s={};for(const u of Object.keys(i))s[u]=n(i[u]);return t.delete(i),s}return n(e)}function Je(e){function t(n){if(n===null||typeof n!=\"object\")return n;if(Array.isArray(n))return n.map(o=>t(o));const r=n;if(Pt in r&&Tt in r){const o=r[Pt],s=r[Tt];if(o===\"__Date__\")return new Date(s.iso);if(o===\"__RegExp__\")return new RegExp(s.source,s.flags);const u=so.get(o);if(!u){console.warn(`spindle: Class \"${o}\" not registered. Falling back to plain object.`);const d={};for(const c of Object.keys(s))d[c]=t(s[c]);return d}const l=Object.create(u.prototype);for(const d of Object.keys(s))l[d]=t(s[d]);return l}const i=r.constructor;if(Pn.has(i))return n;const a={};for(const o of Object.keys(r))a[o]=t(r[o]);return a}return t(e)}let fr=null,dr=null,Fi=!1;function gf(e){fr=e}function mf(e){dr=e}function _f(e){if(dr)try{const i=new Function(\"passage\",\"variables\",dr)(e.passage,e.variables);if(typeof i==\"string\"&&i.trim())return i.trim()}catch{}if(fr)try{const r=fr(e);if(typeof r==\"string\"&&r.trim())return r.trim()}catch{}const n=new Date().toLocaleTimeString(void 0,{hour:\"2-digit\",minute:\"2-digit\"});return`${e.passage} - ${n}`}async function yf(){Fi||(Fi=!0)}async function Ri(e){const n=(await Nr(e)).length+1,r=crypto.randomUUID(),i={id:r,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${n}`};return await ao(i),await oo(`currentPlaythroughId.${e}`,r),r}async function bf(e){return Dr(`currentPlaythroughId.${e}`)}async function lo(e,t,n,r={}){const i=new Date().toISOString(),a={id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:_f(n),passage:n.passage,custom:r},o=re(n);o.variables=Ye(o.variables),o.history=o.history.map(u=>({...u,variables:Ye(u.variables)}));const s={meta:a,payload:o};return await En(s),s}async function uo(e,t){const n=await An(e);if(!n)return;const r=re(t);r.variables=Ye(r.variables),r.history=r.history.map(a=>({...a,variables:Ye(a.variables)}));const i={meta:{...n.meta,updatedAt:new Date().toISOString(),passage:t.passage},payload:r};return await En(i),i}async function vf(e){const t=await An(e);if(!t)return;const n=t.payload;return n.variables=Je(n.variables),n.history=n.history.map(r=>({...r,variables:Je(r.variables)})),n}async function wf(e){await ff(e)}async function kf(e,t){const n=await An(e);if(!n)return;const r={...n,meta:{...n.meta,title:t,updatedAt:new Date().toISOString()}};await En(r)}async function Sf(e){const[t,n]=await Promise.all([df(e),Nr(e)]),r=new Map;for(const s of n)r.set(s.id,s);const i=new Map;for(const s of t){const u=s.meta.playthroughId,l=i.get(u);l?l.push(s):i.set(u,[s])}for(const s of i.values())s.sort((u,l)=>new Date(l.meta.updatedAt).getTime()-new Date(u.meta.updatedAt).getTime());const a=[],o=[...r.values()].sort((s,u)=>new Date(u.createdAt).getTime()-new Date(s.createdAt).getTime());for(const s of o){const u=i.get(s.id)??[];a.push({playthrough:s,saves:u})}for(const[s,u]of i)r.has(s)||a.push({playthrough:{id:s,ifid:e,createdAt:u[0]?.meta.createdAt??new Date().toISOString(),label:\"Unknown Playthrough\"},saves:u});return a}const co=\"autosave.\";async function xf(e,t,n){const r=`${co}${e}`,i=await Dr(r);if(i){const o=await uo(i,n);if(o)return o}const a=await lo(e,t,n,{isAutosave:!0});return await oo(r,a.meta.id),a}async function Cf(e){const t=`${co}${e}`,n=await Dr(t);if(n)return vf(n)}const $r=\"spindle.session.\";function If(e,t){try{sessionStorage.setItem(`${$r}${e}`,JSON.stringify(t))}catch{}}function Ef(e){try{const t=sessionStorage.getItem(`${$r}${e}`);if(!t)return;const n=JSON.parse(t);if(!sf(n))return;const r=n;return r.variables=Je(r.variables),r.history=r.history.map(i=>({...i,variables:Je(i.variables)})),r}catch{return}}function Af(e){try{sessionStorage.removeItem(`${$r}${e}`)}catch{}}async function Pf(e){const t=await An(e);if(t)return{version:1,ifid:t.meta.ifid,exportedAt:new Date().toISOString(),save:t}}async function Tf(e,t){if(e.version!==1)throw new Error(`Unsupported save version: ${e.version}`);if(e.ifid!==t)throw new Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);const n=re(e.save);if(n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),!(await Nr(t)).some(a=>a.id===n.meta.playthroughId)){const a={id:n.meta.playthroughId,ifid:t,createdAt:n.meta.createdAt,label:\"Imported\"};await ao(a)}return await En(n),n}function fo(){const e=I.getState();if(!e.storyData)return;const t=e.storyData.passages.get(\"StoryInit\");if(t){const r=mt(t.content),i=_t(r),a=document.createElement(\"div\");a.style.display=\"none\",document.body.appendChild(a),xe(G(()=>Ie(i),null),a)}const n=e.storyData.passages.get(\"SaveTitle\");n&&mf(n.content)}let ho=0,be=[],Ln=!1,it=[],Nt=null,ct=null;function zr(e){const t=I.getState();try{return!!xn(e,t.variables,t.temporary)}catch{return!1}}function po(e,t){const n=ho++,r=typeof t==\"function\",i=r?void 0:t,a=r?t:void 0,o={id:n,name:i?.name,condition:e,callback:a,options:i,lastResult:zr(e),priority:i?.priority??0};return be.push(o),be.sort((s,u)=>u.priority-s.priority),()=>{be=be.filter(s=>s.id!==n)}}function go(e){be=be.filter(t=>t.name!==e)}function Nf(e){const{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run){const r=I.getState();Ba(n.run,r.variables,r.temporary)}n.dialog&&(it.push({passageName:n.dialog}),Nt?.()),n.goto&&I.getState().navigate(n.goto)}}const Df=10;function $f(){if(!Ln){Ln=!0;try{for(let e=0;e<Df;e++){let t=!1;const n=[...be];for(const r of n){if(!be.includes(r))continue;const i=zr(r.condition),a=!r.lastResult;r.lastResult=i,i&&a&&(t=!0,r.options?.once&&(be=be.filter(o=>o.id!==r.id)),Nf(r))}if(!t)break}}finally{Ln=!1}}}function zf(){for(const e of be)e.lastResult=zr(e.condition)}function Ff(){be=[],it=[],ho=0,ct?.close()}function Rf(e){return Nt=e,it.length>0&&e(),()=>{Nt===e&&(Nt=null)}}function Oi(){return it.shift()}function Of(){return it.length}function Mf(e){it.push(e),Nt?.()}function Lf(){it=[]}function Vf(e){return ct=e,()=>{ct===e&&(ct=null)}}function Mi(){ct?.close()}function Bf(){return ct?.isOpen()??!1}rl();const Hf=new Set([\"StoryInit\",\"StoryInterface\",\"StoryVariables\",\"SaveTitle\",\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);let Ke={},_e=[],Le={};function Li(e){return e.map(t=>({...t,value:t.value!==void 0?re(t.value):void 0}))}function Vi(e,t){const[,n,r]=al(e,i=>{const a=i;for(const o of Object.keys(a))o in t||delete a[o];for(const[o,s]of Object.entries(t))a[o]=s});return{forward:Li(n),inverse:Li(r)}}function qf(e){let t=Ke;for(let n=0;n<e;n++)t=ut(t,_e[n].forward);return t}let ye=[];function Vn(e){const{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(ye.length>i.length&&(ye.length=i.length),ye.length<i.length)if(i.length-ye.length===1){const l=i.length-1;ye[l]={passage:i[l].passage,variables:Ye(r),timestamp:i[l].timestamp,prng:i[l].prng}}else{let l=Ke;for(let d=0;d<i.length;d++)if(d>0&&(l=ut(l,_e[d-1].forward)),d>=ye.length){const c=d===i.length-1?r:l;ye[d]={passage:i[d].passage,variables:Ye(c),timestamp:i[d].timestamp,prng:i[d].prng}}}If(t.ifid,{passage:n,variables:Ye(r),history:ye,historyIndex:a,visitCounts:o,renderCounts:s,prng:yn()})}}function Bi(e){Ke=e,_e=[],Le=e,ye=[]}function Hi(e){e?.prng?Oa(e.prng.seed,e.prng.pull):e&&ir()}const I=Vs()(sl((e,t)=>({storyData:null,currentPassage:\"\",variables:{},variableDefaults:{},temporary:{},history:[],historyIndex:-1,visitCounts:{},renderCounts:{},saveVersion:0,playthroughId:\"\",maxHistory:40,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,setMaxHistory:n=>{e(r=>{r.maxHistory=Math.max(1,Math.round(n))})},init:(n,r={})=>{const i=n.passagesById.get(n.startNode);if(!i)throw new Error(`spindle: Start passage (pid=${n.startNode}) not found.`);const a=re(r);Bi(re(a)),e(s=>{s.storyData=n,s.currentPassage=i.name,s.variables=a,s.variableDefaults=r,s.temporary={},s.history=[{passage:i.name,timestamp:Date.now()}],s.historyIndex=0,s.visitCounts={[i.name]:1},s.renderCounts={[i.name]:1}}),Le=t().variables;const o=n.ifid;yf().then(async()=>{const s=await bf(o);if(s)e(u=>{u.playthroughId=s});else{const u=await Ri(o);e(l=>{l.playthroughId=u})}}).catch(s=>console.error(\"spindle: failed to init save system\",s))},navigate:n=>{const{storyData:r,variables:i}=t();if(!r)return;if(Hf.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){console.error(`spindle: Passage \"${n}\" not found.`);return}const a=Vi(Le,i);e(o=>{o.temporary={},o.currentPassage=n,o.history=o.history.slice(0,o.historyIndex+1),_e.length=o.historyIndex,_e.push(a),o.history.push({passage:n,timestamp:Date.now(),prng:yn()});const s=o.history.length-o.maxHistory;if(s>0){for(let u=0;u<s;u++)Ke=ut(Ke,_e[u].forward);o.history=o.history.slice(s),_e=_e.slice(s),ye=ye.slice(s)}o.historyIndex=o.history.length-1,o.visitCounts[n]=(o.visitCounts[n]??0)+1,o.renderCounts[n]=(o.renderCounts[n]??0)+1}),Le=t().variables,Vn(t)},goBack:()=>{const{historyIndex:n,variables:r}=t();if(n<=0)return;const i=re(ut(r,_e[n-1].inverse));e(a=>{a.historyIndex--,a.currentPassage=a.history[a.historyIndex].passage,a.variables=i,a.temporary={}}),Le=t().variables,Hi(t().history[t().historyIndex]),Vn(t)},goForward:()=>{const{historyIndex:n,history:r,variables:i}=t();if(n>=r.length-1)return;const a=re(ut(i,_e[n].forward));e(o=>{o.historyIndex++,o.currentPassage=o.history[o.historyIndex].passage,o.variables=a,o.temporary={}}),Le=t().variables,Hi(t().history[t().historyIndex]),Vn(t)},setVariable:(n,r)=>{e(i=>{i.variables[n]=r})},setTemporary:(n,r)=>{e(i=>{i.temporary[n]=r})},deleteVariable:n=>{e(r=>{delete r.variables[n]})},deleteTemporary:n=>{e(r=>{delete r.temporary[n]})},trackRender:n=>{e(r=>{r.renderCounts[n]=(r.renderCounts[n]??0)+1})},restart:()=>{const{storyData:n,variableDefaults:r}=t();if(!n)return;const i=n.passagesById.get(n.startNode);if(!i)return;ir(),Ff();const a=re(r);Bi(re(a)),e(o=>{o.currentPassage=i.name,o.variables=a,o.temporary={},o.history=[{passage:i.name,timestamp:Date.now()}],o.historyIndex=0,o.visitCounts={[i.name]:1},o.renderCounts={[i.name]:1}}),Le=t().variables,fo(),Af(n.ifid),Ri(n.ifid).then(o=>{e(s=>{s.playthroughId=o})}).catch(o=>console.error(\"spindle: failed to start new playthrough\",o))},save:()=>{const{storyData:n,playthroughId:r}=t();if(!n)return;const i=t().getSavePayload();e(a=>{a.saveError=null}),xf(n.ifid,r,i).then(()=>{e(a=>{a.saveVersion++})}).catch(a=>{console.error(\"spindle: failed to quick save\",a),e(o=>{o.saveError=a instanceof Error?a.message:\"Failed to save\"})})},load:()=>{const{storyData:n}=t();n&&(e(r=>{r.loadError=null}),Cf(n.ifid).then(r=>{r&&t().loadFromPayload(r)}).catch(r=>{console.error(\"spindle: failed to load quick save\",r),e(i=>{i.loadError=r instanceof Error?r.message:\"Failed to load\"})}))},hasSave:()=>{const{storyData:n,saveVersion:r}=t();return n?r>0:!1},getSavePayload:()=>{const{currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=t(),u=[];let l=Ke;for(let d=0;d<i.length;d++)d>0&&(l=ut(l,_e[d-1].forward)),u.push({passage:i[d].passage,variables:re(l),timestamp:i[d].timestamp,prng:i[d].prng});return{passage:n,variables:re(r),history:u,historyIndex:a,visitCounts:{...o},renderCounts:{...s},prng:yn()}},loadFromPayload:n=>{if(n.history.length===0){console.warn(\"loadFromPayload: rejecting payload with empty history\");return}const r=Je(n.history[0]?.variables??{}),i=[];let a=r;for(let o=1;o<n.history.length;o++){const s=Je(n.history[o].variables);i.push(Vi(a,s)),a=s}Ke=re(r),_e=i,ye=[],e(o=>{o.currentPassage=n.passage,o.variables=Je(n.variables),o.history=n.history.map(s=>({passage:s.passage,timestamp:s.timestamp,prng:s.prng})),o.historyIndex=Math.max(0,Math.min(n.historyIndex,o.history.length-1)),o.visitCounts=n.visitCounts??{},o.renderCounts=n.renderCounts??{},o.temporary={}}),Le=t().variables,n.prng?Oa(n.prng.seed,n.prng.pull):ir()},getHistoryVariables:n=>re(qf(n)),setTransition:n=>{e(r=>{r.transitionConfig=n})},setNextTransition:n=>{e(r=>{r.nextTransition=n})},consumeNextTransition:()=>{const n=t().nextTransition;return n!==null&&e(r=>{r.nextTransition=null}),n}}))),Uf=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function jf(){const t=I(a=>a.storyData)?.passages.get(\"StoryInterface\"),n=t!==void 0?t.content:Uf,r=t?.tags.includes(\"nobr\")??!1,i=de(()=>{try{const a=mt(n),o=_t(a);return w(Y,{children:io(o)})}catch(a){return w(\"span\",{class:\"error\",children:[\"Error in StoryInterface:\",\" \",a instanceof Error?a.message:String(a)]})}},[n]);return r?w(ue.Provider,{value:!0,children:i}):i}const mo=nt(null);function Fr({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,showCloseButton:i=!0}){const a=I(c=>c.storyData),s=(e?a?.passages.get(e):void 0)?.content??t,u=de(()=>{if(!s)return w(\"div\",{class:\"error\",children:\"Dialog: no content available\"});try{const c=mt(s),h=_t(c);return Ie(h)}catch(c){return w(\"div\",{class:\"error\",children:[\"Error in dialog: \",c instanceof Error?c.message:String(c)]})}},[s]),l=c=>{c.target.classList.contains(\"dialog-overlay\")&&r()},d=n?`dialog-panel ${n}`:\"dialog-panel\";return w(mo.Provider,{value:r,children:w(\"div\",{class:\"dialog-overlay\",onClick:l,children:w(\"div\",{class:d,children:[i&&w(\"button\",{class:\"dialog-close\",onClick:r,children:\"✕\"}),w(\"div\",{class:\"dialog-body\",children:u})]})})})}function Wf(){const[e,t]=X(null),n=fe(e);n.current=e;const r=we(()=>{const a=Oi();t(a??null)},[]),i=we(()=>{t(null),Of()>0&&requestAnimationFrame(r)},[r]);return ve(()=>Vf({close:i,isOpen:()=>n.current!==null}),[i]),ve(()=>Rf(()=>{t(a=>a!==null?a:Oi()??null)}),[]),e?w(Fr,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton}):null}function Qf(){const e=I(i=>i.storyData),t=I(i=>i.currentPassage),n=I(i=>i.nobr);if(ve(()=>{const i=a=>{a.key===\"F6\"?(a.preventDefault(),I.getState().save()):a.key===\"F9\"&&(a.preventDefault(),I.getState().load())};return document.addEventListener(\"keydown\",i),()=>document.removeEventListener(\"keydown\",i)},[]),!e||!t)return w(\"div\",{class:\"loading\",children:\"Loading...\"});const r=w(Y,{children:[w(jf,{}),w(Wf,{})]});return n?w(ue.Provider,{value:!0,children:r}):r}function Gf(e){return e.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&/g,\"&\")}function Kf(){const e=document.querySelector(\"tw-storydata\");if(!e)throw new Error(\"spindle: No <tw-storydata> element found in the document.\");const t=e.getAttribute(\"name\")||\"Untitled\",n=parseInt(e.getAttribute(\"startnode\")||\"1\",10),r=e.getAttribute(\"ifid\")||\"\",i=e.getAttribute(\"format\")||\"\",a=e.getAttribute(\"format-version\")||\"\",s=e.querySelector('[type=\"text/twine-css\"]')?.textContent||\"\",l=e.querySelector('[type=\"text/twine-javascript\"]')?.textContent||\"\",d=new Map,c=new Map;for(const h of e.querySelectorAll(\"tw-passagedata\")){const f=parseInt(h.getAttribute(\"pid\")||\"0\",10),p=h.getAttribute(\"name\")||\"\",b=(h.getAttribute(\"tags\")||\"\").split(/\\s+/).filter(A=>A.length>0),x=Gf(h.innerHTML),_={},k=new Set([\"pid\",\"name\",\"tags\"]);for(const A of h.attributes)k.has(A.name)||(_[A.name]=A.value);const S={pid:f,name:p,tags:b,metadata:_,content:x};d.set(p,S),c.set(f,S)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:d,passagesById:c,userCSS:s,userScript:l}}const kt=new Map;let le={},qi=!1;function _o(){return`spindle.${I.getState().storyData?.ifid||\"unknown\"}.settings`}function Yf(){localStorage.setItem(_o(),JSON.stringify(le))}function Bn(){if(!qi){qi=!0;try{const e=localStorage.getItem(_o());if(e){const t=JSON.parse(e);typeof t==\"object\"&&t!==null&&!Array.isArray(t)&&(le={...le,...t})}}catch{}}}const Mt={addToggle(e,t){kt.set(e,{type:\"toggle\",config:t}),e in le||(le[e]=t.default),Bn()},addList(e,t){kt.set(e,{type:\"list\",config:t}),e in le||(le[e]=t.default),Bn()},addRange(e,t){kt.set(e,{type:\"range\",config:t}),e in le||(le[e]=t.default),Bn()},get(e){return le[e]},getToggle(e){const t=le[e];return typeof t==\"boolean\"?t:!1},getList(e){const t=le[e];return typeof t==\"string\"?t:\"\"},getRange(e){const t=le[e];return typeof t==\"number\"?t:0},set(e,t){le[e]=t,Yf()},getAll(){return{...le}},getDefinitions(){return kt},hasAny(){return kt.size>0}};function Jf(e,t,n){const r=I.getState(),i=re(r.variables),a=re(r.temporary),o={...t};Ba(e,i,a,o);for(const s of Object.keys(i))i[s]!==r.variables[s]&&r.setVariable(s,i[s]);for(const s of Object.keys(a))a[s]!==r.temporary[s]&&r.setTemporary(s,a[s]);for(const s of Object.keys(o))o[s]!==t[s]&&n(s,o[s]);for(const s of Object.keys(r.variables))s in i||r.deleteVariable(s);for(const s of Object.keys(r.temporary))s in a||r.deleteTemporary(s);for(const s of Object.keys(t))s in o||n(s,void 0)}const vn=new Map,hr=new Set,pr=new Map;function Zf(e,t,n){if(n)return n;const r=`${e}:${t}`,i=(pr.get(r)??0)+1;return pr.set(r,i),i===1?r:`${r}:${i}`}function Xf(e){return vn.set(e.id,e),ji(),()=>{vn.delete(e.id),ji()}}function Ui(){return Array.from(vn.values())}function ed(e){return vn.get(e)}function td(){pr.clear()}function nd(e){return hr.add(e),()=>{hr.delete(e)}}function ji(){for(const e of hr)e()}function rd(e){const t=fe(\"\");t.current||(t.current=Zf(e.type,e.key,e.authorId));const n=t.current;return rt(()=>{const r={id:n,type:e.type,label:e.label,perform:e.perform};return e.target!==void 0&&(r.target=e.target),e.variable!==void 0&&(r.variable=e.variable),e.options!==void 0&&(r.options=e.options),e.value!==void 0&&(r.value=e.value),e.disabled!==void 0&&(r.disabled=e.disabled),Xf(r)}),n}function id(e){return e.map(t=>t.type===\"text\"?t.value:\"\").join(\"\")}function yo(e){const t=e.metadata[\"data-source-file\"],n=e.metadata[\"data-source-line\"];return t?n?` (${t}:${n})`:` (${t})`:\"\"}function Rr(){const e=I.getState();if(!e.storyData)return\"\";const t=e.storyData.passages.get(e.currentPassage);return t?yo(t):\"\"}function ad(e){const t=e.match(/^\\s*([\"']?\\$\\w+[\"']?)\\s*(?:[\"'](.*)[\"'])?\\s*$/);if(!t)return{varName:e.trim(),placeholder:\"\"};const n=t[1].replace(/[\"']/g,\"\"),r=t[2]||\"\";return{varName:n,placeholder:r}}function od(e){const t=[];for(const n of e)if(n.type===\"macro\"&&n.name===\"option\"){const i=n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/,\"$2\");t.push(i)}return t}function sd(e,t){const n=`macro-${e}`;return t?`${n} ${t}`:n}const ld={useState:X,useRef:fe,useEffect:ve,useLayoutEffect:rt,useCallback:we,useMemo:de,useContext:K};function V(e){function t(n){let r=n.className,i=n.id,a;e.interpolate&&(a=Er(),r=a(r),i=a(i));const{update:o,getValues:s}=K(Qt),u=K(ue),l=K(Ce),c={collectText:id,sourceLocation:Rr,parseVarArgs:ad,extractOptions:od,h:G,renderNodes:(h,f)=>Ie(h,{nobr:u,locals:l,...f}),renderInlineNodes:io,hooks:ld,useAction:rd,className:r,id:i,resolve:a,cls:sd(e.name,r),mutate:h=>Jf(h,s(),o),update:o,getValues:s,wrap:void 0};if(e.merged){c.merged=Ir();const h=c.merged;c.evaluate=f=>xn(f,h[0],h[1],h[2])}if(e.storeVar){const f=(n.rawArgs.trim().split(/[\\s\"']+/)[0]??\"\").replace(/[\"']/g,\"\").replace(/^\\$/,\"\");c.varName=f,c.value=I(b=>b.variables[f]);const p=I(b=>b.setVariable);c.setValue=b=>p(f,b)}return c.wrap=h=>c.className||c.id?G(\"span\",{id:c.id,class:c.className},h):G(Y,null,h),e.render(n,c)}if($l(e.name,t),e.subMacros)for(const n of e.subMacros)Fl(n);(e.block===!0||e.block!==!1&&e.subMacros&&e.subMacros.length>0)&&za(e.name)}function ud(){return{get(e){return I.getState().variables[e]},set(e,t){const n=I.getState();if(typeof e==\"string\")n.setVariable(e,t);else for(const[r,i]of Object.entries(e))n.setVariable(r,i)},goto(e){I.getState().navigate(e)},back(){I.getState().goBack()},forward(){I.getState().goForward()},restart(){I.getState().restart()},save(e){I.getState().save(e)},load(e){I.getState().load(e)},hasSave(e){return I.getState().hasSave(e)},visited(e){const t=I.getState();return t.visitCounts[e??t.currentPassage]??0},hasVisited(e){return this.visited(e)>0},hasVisitedAny(...e){const{visitCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasVisitedAll(...e){const{visitCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},rendered(e){const t=I.getState();return t.renderCounts[e??t.currentPassage]??0},hasRendered(e){return this.rendered(e)>0},hasRenderedAny(...e){const{renderCounts:t}=I.getState();return e.some(n=>(t[n]??0)>0)},hasRenderedAll(...e){const{renderCounts:t}=I.getState();return e.every(n=>(t[n]??0)>0)},currentPassage(){const e=I.getState();return e.storyData?.passages.get(e.currentPassage)},previousPassage(){const e=I.getState();if(e.historyIndex<=0)return;const t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0},get title(){return I.getState().storyData?.name||\"\"},get passage(){return I.getState().currentPassage},settings:Mt,registerClass(e,t){hf(e,t)},defineMacro(e){V(e)},saves:{setTitleGenerator(e){gf(e)}},getActions(){return Ui()},performAction(e,t){const n=ed(e);if(!n)throw new Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw new Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){if(e===\"navigate\"){let n=I.getState().currentPassage;return I.subscribe(r=>{if(r.currentPassage!==n){const i=n;n=r.currentPassage,t(r.currentPassage,i)}})}if(e===\"actionsChanged\")return nd(t);if(e===\"variableChanged\"){let n={...I.getState().variables};return I.subscribe(r=>{const i={};let a=!1;const o=new Set([...Object.keys(n),...Object.keys(r.variables)]);for(const s of o)r.variables[s]!==n[s]&&(i[s]={from:n[s],to:r.variables[s]},a=!0);n={...r.variables},a&&t(i)})}throw new Error(`spindle: Unknown event \"${e}\".`)},waitForActions(){return new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{e(Ui())})})})},watch(e,t){return po(e,t)},unwatch(e){go(e)},openDialog(e,t){Mf({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton})},closeDialog(){Mi()},closeAllDialogs(){Lf(),Mi()},isDialogOpen(){return Bf()},setNobr(e){I.setState({nobr:e})},setCSS(e){const t=document.getElementById(\"spindle-styles\");t&&(t.disabled=!e)},setTransition(e){I.getState().setTransition(e)},setNextTransition(e){I.getState().setNextTransition(e)},random(){return Ar()},randomInt(e,t){return Ma(e,t)},config:{get maxHistory(){return I.getState().maxHistory},set maxHistory(e){I.getState().setMaxHistory(e)}},prng:{init(e,t){bl(e,t);const{historyIndex:n}=I.getState();I.setState(r=>{const i=r.history[n];i&&(i.prng=yn())})},isEnabled(){return vl()},get seed(){return wl()},get pull(){return kl()}}}}function cd(){window.Story=ud()}const fd=/^\\$(\\w+)\\s*=\\s*(.+)$/,Wi=/\\$(\\w+(?:\\.\\w+)*)/g,Qi=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,dd=new Set([\"number\",\"string\",\"boolean\"]);function bo(e){if(Array.isArray(e))return{type:\"array\"};if(e!==null&&typeof e==\"object\"){const n=new Map;for(const[r,i]of Object.entries(e))n.set(r,bo(i));return{type:\"object\",fields:n}}const t=typeof e;if(!dd.has(t))throw new Error(`StoryVariables: Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function hd(e){const t=new Map;for(const n of e.split(`\n`)){const r=n.trim();if(!r)continue;const i=r.match(fd);if(!i)throw new Error(`StoryVariables: Invalid declaration: \"${r}\". Expected: $name = value`);const[,a,o]=i;let s;try{s=new Function(\"return (\"+o+\")\")()}catch(l){throw new Error(`StoryVariables: Failed to evaluate \"$${a} = ${o}\": ${l instanceof Error?l.message:l}`)}const u=bo(s);t.set(a,{...u,name:a,default:s})}return t}function pd(e){const t=new Set;let n;for(Qi.lastIndex=0;(n=Qi.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function gd(e,t,n){const r=e.split(\".\"),i=r[0];if(n.has(i))return null;const a=t.get(i);if(!a)return`Undeclared variable: $${e}`;let o=a;for(let s=1;s<r.length;s++){const u=r[s];if(o.type===\"array\")return null;if(o.type!==\"object\"||!o.fields)return`Cannot access field \"${u}\" on $${r.slice(0,s).join(\".\")} (type: ${o.type})`;const l=o.fields.get(u);if(!l)return null;o=l}return null}function md(e,t){const n=[];for(const[r,i]of e){if(r===\"StoryVariables\")continue;const a=pd(i.content);let o;for(Wi.lastIndex=0;(o=Wi.exec(i.content))!==null;){const s=o[1],u=gd(s,t,a);u&&n.push(`Passage \"${r}\": ${u}`)}}return n}function _d(e){const t={};for(const[n,r]of e)t[n]=r.default;return t}function sn(e){for(const t of e){if(t.type===\"variable\"&&t.scope===\"local\"&&t.name===\"children\"||t.type===\"html\"&&sn(t.children))return!0;if(t.type===\"macro\"){if(sn(t.children))return!0;if(t.branches){for(const n of t.branches)if(sn(n.children))return!0}}}return!1}V({name:\"set\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;try{t.mutate(e)}catch(r){return console.error(`spindle: Error in {set ${e}}${t.sourceLocation()}:`,r),null}}return null}});function Be({macro:e,error:t}){return w(\"span\",{class:\"error\",title:String(t),children:`{${e} error${Rr()}: ${t instanceof Error?t.message:String(t)}}`})}V({name:\"print\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const n=t.evaluate(e),r=n==null?\"\":String(n);return t.wrap(r)}catch(n){return w(Be,{macro:\"print\",error:n})}}});function yd(e){const t=e.trim();let n=0;for(let r=0;r<t.length;r++){const i=t[r];if(i===\"(\"||i===\"[\"||i===\"{\")n++;else if(i===\")\"||i===\"]\"||i===\"}\")n--;else if(i===\"=\"&&n===0){if(t[r+1]===\"=\"){r++;continue}if(r>0&&t[r-1]===\"!\")continue;const a=t.slice(0,r).trim(),o=t.slice(r+1).trim();if(!a.match(/^[$_]\\w+$/))throw new Error(`{computed}: target must be $name or _name, got \"${a}\"`);return{target:a,expr:o}}}throw new Error(`{computed}: expected \"target = expression\", got \"${e}\"`)}function bd(e,t){if(Object.is(e,t))return!0;if(typeof e==\"object\"&&e!==null&&typeof t==\"object\"&&t!==null)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1}function Gi(e,t,n,r,i,a,o){let s;try{s=xn(e,r,i,a)}catch(l){console.error(`spindle: Error in {computed ${o}}${Rr()}:`,l);return}const u=n?i[t]:r[t];if(!bd(u,s)){const l=I.getState();n?l.setTemporary(t,s):l.setVariable(t,s)}}V({name:\"computed\",merged:!0,render({rawArgs:e},t){const[n,r,i]=t.merged;let a,o;try{({target:a,expr:o}=yd(e))}catch(d){return w(Be,{macro:\"computed\",error:d})}const s=a.startsWith(\"_\"),u=a.slice(1),l=t.hooks.useRef(!1);return l.current||(l.current=!0,Gi(o,u,s,n,r,i,e)),t.hooks.useLayoutEffect(()=>{Gi(o,u,s,n,r,i,e)},[n,r,i]),null}});function vd(e){const t=e.trim();let n=\"\",r=t;const i=r.match(/\\s+(?:\"([^\"]*)\"|'([^']*)')$/);i&&(n=i[1]??i[2]??\"\",r=r.slice(0,i.index??r.length).trim());const a=wd(r);if(a.length<2)throw new Error(\"meter requires two arguments: {meter currentExpr maxExpr}\");return{currentExpr:a[0],maxExpr:a.slice(1).join(\" \"),labelMode:n}}function wd(e){const t=[];let n=\"\",r=0;for(let i=0;i<e.length;i++){const a=e[i];if(a===\"(\"||a===\"[\")r++,n+=a;else if(a===\")\"||a===\"]\")r--,n+=a;else if(/\\s/.test(a)&&r===0&&n.length>0)for(t.push(n),n=\"\";i+1<e.length&&/\\s/.test(e[i+1]);)i++;else n+=a}return n.length>0&&t.push(n),t}function kd(e,t,n){return n===\"none\"?null:n===\"%\"?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}V({name:\"meter\",interpolate:!0,merged:!0,render({rawArgs:e},t){try{const{currentExpr:n,maxExpr:r,labelMode:i}=vd(e),a=Number(t.evaluate(n)),o=Number(t.evaluate(r)),s=o===0?0:Math.max(0,Math.min(100,a/o*100)),u=kd(a,o,i),l=t.cls;return w(\"div\",{class:l,id:t.id,children:[w(\"div\",{class:\"macro-meter-fill\",style:`width: ${s}%`}),u!=null&&w(\"span\",{class:\"macro-meter-label\",children:u})]})}catch(n){return w(Be,{macro:\"meter\",error:n})}}});V({name:\"if\",interpolate:!0,merged:!0,render({branches:e=[]},t){function n(r){const i=t.renderNodes(r.children),a=t.resolve(r.className),o=t.resolve(r.id);return a||o?w(\"span\",{id:o,class:a,children:i}):w(Y,{children:i})}for(const r of e){if(r.rawArgs===\"\")return n(r);try{if(t.evaluate(r.rawArgs))return n(r)}catch(i){return w(Be,{macro:\"if\",error:i})}}return null}});function Sd(e){const t=e.indexOf(\" of \");if(t===-1)throw new Error(`{for} requires \"of\" keyword: {for ${e}}`);const n=e.slice(0,t).trim(),r=e.slice(t+4).trim(),i=n.split(\",\").map(s=>s.trim()),a=i[0],o=i.length>1?i[1]:null;if(!a.startsWith(\"@\"))throw new Error(`{for} loop variable must use @ prefix: got \"${a}\"`);if(o&&!o.startsWith(\"@\"))throw new Error(`{for} index variable must use @ prefix: got \"${o}\"`);return{itemVar:a.slice(1),indexVar:o?o.slice(1):null,listExpr:r}}function xd({parentValues:e,ownKeys:t,initialValues:n,children:r}){const[i,a]=X(()=>({...n})),o={...e,...t,...i},s=fe(o);s.current=o;const u=we(()=>s.current,[]),l=we((h,f)=>{a(p=>({...p,[h]:f}))},[]),d=de(()=>({update:l,getValues:u}),[l,u]),c=K(ue);return w(Qt.Provider,{value:d,children:w(Ce.Provider,{value:o,children:Ie(r,{nobr:c,locals:o})})})}V({name:\"for\",interpolate:!0,merged:!0,render({rawArgs:e,children:t=[]},n){const r=K(Ce);let i;try{i=Sd(e)}catch(d){return w(Be,{macro:\"for\",error:d})}const{itemVar:a,indexVar:o,listExpr:s}=i;let u;try{const d=n.evaluate(s);if(!Array.isArray(d))return w(\"span\",{class:\"error\",children:\"{for error: expression did not evaluate to an array}\"});u=d}catch(d){return w(Be,{macro:\"for\",error:d})}const l=u.map((d,c)=>{const h={[a]:d,...o?{[o]:c}:void 0};return w(xd,{parentValues:r,ownKeys:h,initialValues:{},children:t},`${c}-${JSON.stringify(d)}`)});return n.wrap(l)}});V({name:\"do\",render({children:e=[]},t){const n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{try{t.mutate(n)}catch(r){console.error(`spindle: Error in {do}${t.sourceLocation()}:`,r)}},[]),null}});V({name:\"button\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const r=n.resolve?.(e.replace(/^[\"']|[\"']$/g,\"\"))??e,i=K(ue),a=()=>{const o=document.createElement(\"div\"),s=G(ue.Provider,{value:i},G(Qt.Provider,{value:{update:n.update,getValues:n.getValues}},G(Ce.Provider,{value:n.getValues()},Ie(t))));xe(s,o),xe(null,o)};return n.useAction({type:\"button\",key:e,authorId:n.id,label:r,perform:a}),w(\"button\",{id:n.id,class:n.cls,onClick:a,children:r})}});function Cd(e){const t=[],n=/([\"'])(.*?)\\1/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[2]);return t.length>=2?{display:t[0],passage:t[1]}:t.length===1?{display:t[0],passage:null}:{display:e.trim(),passage:null}}function Ki(e,t,n,r){const i=document.createElement(\"div\"),a=G(ue.Provider,{value:r},G(Qt.Provider,{value:{update:n,getValues:t}},G(Ce.Provider,{value:t()},Ie(e))));xe(a,i),xe(null,i)}V({name:\"link\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{display:r,passage:i}=Cd(e),a=K(ue),o=s=>{s.preventDefault(),Ki(t,n.getValues,n.update,a),i&&I.getState().navigate(i)};return n.useAction({type:\"link\",key:i||r,authorId:n.id,label:r,target:i??void 0,perform:()=>{Ki(t,n.getValues,n.update,a),i&&I.getState().navigate(i)}}),w(\"a\",{id:n.id,class:n.cls,href:\"#\",onClick:o,children:r})}});V({name:\"switch\",subMacros:[\"case\",\"default\"],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(a){return w(Be,{macro:\"switch\",error:a})}let i=null;for(let a=1;a<t.length;a++){const o=t[a];if(o.rawArgs===\"\"){i=o;continue}try{const s=n.evaluate(o.rawArgs);if(r===s)return w(Y,{children:n.renderNodes(o.children)})}catch(s){return w(Be,{macro:\"case\",error:s})}}return i?w(Y,{children:n.renderNodes(i.children)}):null}});function Or(e){const t=e.trim();return t.endsWith(\"ms\")?parseFloat(t.slice(0,-2)):t.endsWith(\"s\")?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}V({name:\"timed\",subMacros:[\"next\"],interpolate:!0,render({branches:e=[]},t){const{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(f=>({delay:f.rawArgs?Or(f.rawArgs):0,nodes:f.children,className:f.className,id:f.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;const f=o+1,p=a[f].delay,b=setTimeout(()=>{s(f)},p);return()=>clearTimeout(b)},[o,a]),o<0)return t.wrap(null);const u=a[o],l=t.renderNodes(u.nodes),d=t.resolve(u.className),c=t.resolve(u.id),h=d||c?w(\"span\",{id:c,class:d,children:l}):l;return t.wrap(h)}});const vo=nt({stop:()=>{}});V({name:\"repeat\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useCallback:a}=n.hooks,o=Or(e),[s,u]=r(0),[l,d]=r(!1),c=a(()=>d(!0),[]);if(i(()=>{if(l)return;const f=setInterval(()=>{u(p=>p+1)},o);return()=>clearInterval(f)},[o,l]),s===0&&!l)return null;const h=w(vo.Provider,{value:{stop:c},children:w(\"span\",{children:n.renderNodes(t)},s)});return n.className||n.id?w(\"span\",{id:n.id,class:n.cls,children:h}):h}});V({name:\"stop\",render(e,t){const{stop:n}=t.hooks.useContext(vo);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}});V({name:\"type\",interpolate:!0,render({rawArgs:e,children:t=[]},n){const{useState:r,useEffect:i,useRef:a}=n.hooks,o=Or(e),s=a(null),[u,l]=r(0),[d,c]=r(0),h=a(0);h.current=d,i(()=>{if(s.current){const b=s.current.textContent||\"\";l(b.length)}},[]),i(()=>{if(u===0||h.current>=u)return;const b=setInterval(()=>{c(x=>x>=u?(clearInterval(b),x):x+1)},o);return()=>clearInterval(b)},[u,o]);const f=d>=u&&u>0,p=[\"macro-type\",f?\"macro-type-done\":\"\",n.className||\"\"].filter(Boolean).join(\" \");return w(\"span\",{id:n.id,class:p,ref:s,style:{clipPath:(u>0&&!f,void 0)},children:[w(\"span\",{class:\"macro-type-inner\",style:{display:\"inline\",visibility:u===0?\"hidden\":\"visible\",clipPath:u>0&&!f?`inset(0 ${(u-d)/u*100}% 0 0)`:void 0},children:n.renderInlineNodes(t)}),!f&&u>0&&w(\"span\",{class:\"macro-type-cursor\"})]})}});function Id(e){const t=e.trim().split(/\\s+/),n=t[0].replace(/[\"']/g,\"\"),r=t.slice(1).filter(i=>i.startsWith(\"@\"));return{name:n,params:r}}V({name:\"widget\",render({rawArgs:e,children:t=[]},n){const{name:r,params:i}=Id(e),a=JSON.stringify(t),o=i.join(\",\");return n.hooks.useLayoutEffect(()=>{qa(r,t,i)},[r,a,o]),null}});V({name:\"story-title\",render(e,t){const n=I(i=>i.storyData?.name||\"\"),r=t.className?`story-title ${t.className}`:\"story-title\";return w(\"span\",{id:t.id,class:r,children:n})}});function at(e){V({name:e.name,render(t,n){if(e.hidden?.())return null;const[r,i]=X(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o}=a,s=n.className?`menubar-button ${n.className}`:\"menubar-button\",u=e.dialog?()=>i(!0):e.confirm?()=>{confirm(e.confirm)&&a.perform()}:a.perform;return n.useAction({type:e.actionType,key:e.name,authorId:n.id,label:typeof e.label==\"string\"?e.label:e.name,disabled:o,perform:e.dialog?()=>i(!0):a.perform}),w(Y,{children:[w(\"button\",{id:n.id,class:s,onClick:u,disabled:o,title:e.title,children:e.label}),e.dialog&&r&&w(Fr,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}at({name:\"back\",label:\"← Back\",actionType:\"back\",setup:()=>({perform:I(e=>e.goBack),disabled:!I(e=>e.historyIndex>0)})});at({name:\"forward\",label:\"Forward →\",actionType:\"forward\",setup:()=>({perform:I(e=>e.goForward),disabled:!I(e=>e.historyIndex<e.history.length-1)})});at({name:\"quicksave\",label:\"QuickSave\",actionType:\"save\",title:\"Quick Save (F6)\",setup:()=>({perform:I(e=>e.save)})});at({name:\"quickload\",label:\"QuickLoad\",actionType:\"load\",title:\"Quick Load (F9)\",confirm:\"Load saved game? Current progress will be lost.\",setup:()=>{const e=I(n=>n.load),t=I(n=>n.hasSave);return I(n=>n.saveVersion),{perform:()=>e(),disabled:!t()}}});at({name:\"restart\",label:\"↺ Restart\",actionType:\"restart\",confirm:\"Restart the story? All progress will be lost.\",setup:()=>({perform:I(e=>e.restart)})});at({name:\"saves\",label:\"Saves\",actionType:\"dialog\",dialog:{passageName:\"SaveLoad\",fallbackMarkup:\"{save-manager}\",panelClass:\"dialog-saves\"}});at({name:\"settings\",label:\"Settings\",actionType:\"dialog\",hidden:()=>!Mt.hasAny(),dialog:{passageName:\"Settings\",fallbackMarkup:\"{settings-controls}\",panelClass:\"dialog-settings\"}});V({name:\"dialog\",block:!0,interpolate:!0,render({rawArgs:e,children:t=[]},n){const[r,i]=n.hooks.useState(!1),a=/\\bnoclose\\s*$/.test(e),o=e.replace(/\\bnoclose\\s*$/,\"\").trim(),s=n.resolve?.(o.replace(/^[\"']|[\"']$/g,\"\"))??o,u=n.collectText(t).trim().replace(/^[\"']|[\"']$/g,\"\");return w(Y,{children:[w(\"button\",{id:n.id,class:n.cls,onClick:()=>i(!0),children:s}),r&&w(Fr,{passageName:u,onClose:()=>i(!1),showCloseButton:!a})]})}});function Ed(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return\"just now\";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function Ad(e){return new Date(e).toLocaleDateString(void 0,{month:\"short\",day:\"numeric\",year:\"numeric\"})}function Pd(){const[e,t]=X(\"load\"),[n,r]=X([]),[i,a]=X(!0),[o,s]=X(null),[u,l]=X(()=>new Set),[d,c]=X(null),[h,f]=X(\"\"),p=fe(null),b=fe(null),x=K(mo),_=I(D=>D.storyData),k=I(D=>D.playthroughId),S=I(D=>D.getSavePayload),A=I(D=>D.loadFromPayload),C=_?.ifid??\"\",y=we(async()=>{if(!C)return;const D=await Sf(C);r(D),a(!1)},[C]);ve(()=>{y()},[y]),ve(()=>{d&&p.current&&(p.current.focus(),p.current.select())},[d]);const P=fe(),T=(D,j=\"success\")=>{clearTimeout(P.current),s({text:D,type:j}),P.current=window.setTimeout(()=>s(null),3e3)};ve(()=>()=>clearTimeout(P.current),[]);const z=D=>{l(j=>{const g=new Set(j);return g.has(D)?g.delete(D):g.add(D),g})},v=async()=>{if(!(!C||!k))try{const D=S();await lo(C,k,D),T(\"Save created\"),await y()}catch{T(\"Failed to create save\",\"error\")}},N=async D=>{try{const j=S();await uo(D,j),T(\"Save overwritten\"),await y()}catch{T(\"Failed to overwrite save\",\"error\")}},$=async D=>{try{A(D.payload),T(\"Game loaded\"),x&&setTimeout(x,500)}catch{T(\"Failed to load save\",\"error\")}},B=async D=>{if(confirm(\"Delete this save?\"))try{await wf(D),T(\"Save deleted\"),await y()}catch{T(\"Failed to delete save\",\"error\")}},U=D=>{c(D.meta.id),f(D.meta.title)},M=async()=>{if(!(!d||!h.trim()))try{await kf(d,h.trim()),c(null),T(\"Save renamed\"),await y()}catch{T(\"Failed to rename\",\"error\")}},Z=D=>{D.key===\"Enter\"?M():D.key===\"Escape\"&&c(null)},J=async D=>{try{const j=await Pf(D);if(!j)return;const g=new Blob([JSON.stringify(j,null,2)],{type:\"application/json\"}),q=URL.createObjectURL(g),se=document.createElement(\"a\");se.href=q,se.download=`save-${j.save.meta.title.replace(/[^a-z0-9]/gi,\"_\")}.json`,se.click(),URL.revokeObjectURL(q),T(\"Save exported\")}catch{T(\"Failed to export save\",\"error\")}},he=()=>{b.current?.click()},ke=async D=>{const j=D.target,g=j.files?.[0];if(g){j.value=\"\";try{const q=await g.text(),se=JSON.parse(q);if(!of(se))throw new Error(\"Invalid save file format\");await Tf(se,C),T(\"Save imported\"),await y()}catch(q){T(q instanceof Error?q.message:\"Failed to import save\",\"error\")}}},m=n.reduce((D,j)=>D+j.saves.length,0);return w(\"div\",{class:\"save-manager\",children:[w(\"div\",{class:\"saves-header\",children:w(\"div\",{class:\"saves-header-left\",children:w(\"div\",{class:\"saves-mode-toggle\",children:[w(\"button\",{class:e===\"save\"?\"active\":\"\",onClick:()=>t(\"save\"),children:\"Save\"}),w(\"button\",{class:e===\"load\"?\"active\":\"\",onClick:()=>t(\"load\"),children:\"Load\"})]})})}),w(\"div\",{class:\"saves-toolbar\",children:[w(\"button\",{class:\"saves-toolbar-button\",onClick:he,children:\"Import\"}),w(\"input\",{ref:b,type:\"file\",accept:\".json\",style:\"display:none\",onChange:ke})]}),w(\"div\",{class:\"saves-body\",children:[i?w(\"div\",{class:\"saves-empty\",children:\"Loading...\"}):m===0&&e===\"load\"?w(\"div\",{class:\"saves-empty\",children:\"No saves yet\"}):n.map(D=>{const j=u.has(D.playthrough.id),g=D.playthrough.id===k;return e===\"save\"&&!g||e===\"load\"&&D.saves.length===0&&!g?null:w(\"div\",{class:\"playthrough-group\",children:[w(\"div\",{class:\"playthrough-header\",onClick:()=>z(D.playthrough.id),children:[w(\"span\",{class:`playthrough-chevron ${j?\"\":\"open\"}`,children:\"▶\"}),w(\"span\",{class:\"playthrough-label\",children:[D.playthrough.label,g?\" (current)\":\"\"]}),w(\"span\",{class:\"playthrough-date\",children:Ad(D.playthrough.createdAt)})]}),!j&&w(\"div\",{class:\"playthrough-saves\",children:[D.saves.map(q=>w(\"div\",{class:\"save-slot\",children:[w(\"div\",{class:\"save-slot-info\",children:[d===q.meta.id?w(\"input\",{ref:p,class:\"save-rename-input\",value:h,onInput:se=>f(se.target.value),onKeyDown:Z,onBlur:M}):w(\"div\",{class:\"save-slot-title\",children:q.meta.title}),w(\"div\",{class:\"save-slot-meta\",children:[w(\"span\",{children:q.meta.passage}),w(\"span\",{children:Ed(q.meta.updatedAt)})]})]}),w(\"div\",{class:\"save-slot-actions\",children:[e===\"save\"?w(\"button\",{class:\"save-slot-action primary\",onClick:()=>N(q.meta.id),children:\"Save Here\"}):w(\"button\",{class:\"save-slot-action primary\",onClick:()=>$(q),children:\"Load\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>U(q),children:\"Rename\"}),w(\"button\",{class:\"save-slot-action\",onClick:()=>J(q.meta.id),children:\"Export\"}),w(\"button\",{class:\"save-slot-action danger\",onClick:()=>B(q.meta.id),children:\"Delete\"})]})]},q.meta.id)),e===\"save\"&&g&&w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})]})]},D.playthrough.id)}),e===\"save\"&&!i&&!n.some(D=>D.playthrough.id===k)&&w(\"div\",{class:\"playthrough-group\",children:w(\"div\",{class:\"playthrough-saves\",children:w(\"button\",{class:\"save-slot-new\",onClick:v,children:\"+ New Save\"})})})]}),o&&w(\"div\",{class:`saves-status ${o.type===\"error\"?\"error\":\"\"}`,children:o.text})]})}V({name:\"save-manager\",render(){return w(Pd,{})}});function Td({name:e,def:t}){const[n,r]=X(()=>Mt.get(e)),i=a=>{r(a),Mt.set(e,a)};switch(t.type){case\"toggle\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"input\",{type:\"checkbox\",checked:!!n,onChange:a=>i(a.target.checked)})]});case\"list\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:t.config.label}),w(\"select\",{value:String(n),onChange:a=>i(a.target.value),children:t.config.options.map(a=>w(\"option\",{value:a,children:a},a))})]});case\"range\":return w(\"label\",{class:\"settings-row\",children:[w(\"span\",{children:[t.config.label,\": \",String(n)]}),w(\"input\",{type:\"range\",min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:a=>i(parseFloat(a.target.value))})]})}}function Nd(){const e=Mt.getDefinitions();return w(\"div\",{class:\"settings-controls\",children:Array.from(e.entries()).map(([t,n])=>w(Td,{name:t,def:n},t))})}V({name:\"settings-controls\",render(){return w(Nd,{})}});V({name:\"include\",interpolate:!0,merged:!0,render({rawArgs:e},t){const n=I(c=>c.storyData);if(!n)return null;const r=/\\binline\\b/.test(e),i=e.replace(/\\binline\\b/,\"\").trim();let a;try{const c=t.evaluate(i);a=String(c)}catch{a=i.replace(/^[\"']|[\"']$/g,\"\")}const o=n.passages.get(a);if(o&&I.getState().trackRender(a),!o)return w(\"span\",{class:\"error\",children:`{include${t.sourceLocation()}: passage \"${a}\" not found}`});const s=o.tags.includes(\"nobr\"),u=mt(o.content),l=_t(u),d=r?t.renderInlineNodes(l):t.renderNodes(l,s?{nobr:!0}:void 0);return s?t.wrap(t.h(ue.Provider,{value:!0},d)):t.wrap(d)}});V({name:\"nobr\",render({children:e=[]},t){return t.wrap(t.h(ue.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))}});V({name:\"goto\",merged:!0,render({rawArgs:e},t){return t.hooks.useLayoutEffect(()=>{let n;try{const r=t.evaluate(e);n=String(r)}catch{n=e.replace(/^[\"']|[\"']$/g,\"\")}I.getState().navigate(n)},[]),null}});V({name:\"unset\",render({rawArgs:e},t){const n=t.hooks.useRef(!1);if(!n.current){n.current=!0;const r=I.getState(),i=e.trim();i.startsWith(\"$\")?r.deleteVariable(i.slice(1)):i.startsWith(\"_\")?r.deleteTemporary(i.slice(1)):console.error(`spindle: {unset} expects a variable ($name or _name), got \"${i}\"`)}return null}});V({name:\"textbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"input\",{type:\"text\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});V({name:\"numberbox\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"numberbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?Number(r):0)}),w(\"input\",{type:\"number\",id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>{const i=r.target.value;t.setValue(i===\"\"?0:Number(i))}})}});V({name:\"textarea\",storeVar:!0,render({rawArgs:e},t){const{placeholder:n}=t.parseVarArgs(e);return t.useAction({type:\"textarea\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName,variable:t.varName,value:t.value,perform:r=>t.setValue(r!==void 0?String(r):\"\")}),w(\"textarea\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),placeholder:n,onInput:r=>t.setValue(r.target.value)})}});function Dd(e){return e.match(/^\\s*[\"']?\\$?\\w+[\"']?\\s+[\"']?(.+?)[\"']?\\s*$/)?.[1]??\"\"}V({name:\"checkbox\",storeVar:!0,render({rawArgs:e},t){const n=Dd(e);return t.useAction({type:\"checkbox\",key:`$${t.varName}`,authorId:t.id,label:n||t.varName||\"\",variable:t.varName,value:!!t.value,perform:r=>t.setValue(r!==void 0?!!r:!t.value)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"checkbox\",checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}});function $d(e){const t=e.match(/^\\s*[\"']?\\$?\\w+[\"']?\\s+[\"'](.+?)[\"']\\s+[\"']?(.+?)[\"']?\\s*$/);if(!t){const n=e.trim().split(/\\s+/).slice(1);return{value:n[0]??\"\",label:n.slice(1).join(\" \")}}return{value:t[1],label:t[2]}}V({name:\"radiobutton\",storeVar:!0,render({rawArgs:e},t){const{value:n,label:r}=$d(e);return t.useAction({type:\"radiobutton\",key:`$${t.varName}:${n}`,authorId:t.id,label:r||n,variable:t.varName,value:t.value,perform:()=>t.setValue(n)}),w(\"label\",{id:t.id,class:t.cls,children:[w(\"input\",{type:\"radio\",name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}});V({name:\"listbox\",subMacros:[\"option\"],storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e);return t.useAction({type:\"listbox\",key:`$${t.varName}`,authorId:t.id,label:t.varName,variable:t.varName,options:n,value:t.value,perform:r=>{r!==void 0&&t.setValue(String(r))}}),w(\"select\",{id:t.id,class:t.cls,value:t.value==null?\"\":String(t.value),onChange:r=>t.setValue(r.target.value),children:n.map(r=>w(\"option\",{value:r,children:r},r))})}});V({name:\"cycle\",storeVar:!0,render({children:e=[]},t){const n=t.extractOptions(e),r=()=>{if(n.length===0)return;const i=I.getState().variables[t.varName],o=(n.indexOf(String(i))+1)%n.length;t.setValue(n[o])};return t.useAction({type:\"cycle\",key:`$${t.varName}`,authorId:t.id,label:t.value==null?n[0]||\"\":String(t.value),variable:t.varName,options:n,value:t.value,perform:i=>{i!==void 0?t.setValue(i):r()}}),w(\"button\",{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||\"\":String(t.value)})}});V({name:\"span\",render({children:e=[]},t){return t.wrap(t.renderNodes(e))}});function xt(e){const t=mt(e.content),n=_t(t),r=e.tags.includes(\"nobr\");return Ie(n,r?{nobr:!0}:void 0)}const zd=new Set([\"PassageReady\",\"PassageHeader\",\"PassageFooter\",\"PassageDone\"]);function Fd({passage:e,dataTransition:t}){const n=I(b=>b.storyData),r=zd.has(e.name),[i,a]=X(!1),o=de(()=>{try{return xt(e)}catch(b){return w(\"div\",{class:\"error\",children:[\"Error parsing passage “\",e.name,\"”\",yo(e),\":\",\" \",b instanceof Error?b.message:String(b)]})}},[e.content,e.name]),s=r?void 0:n?.passages.get(\"PassageHeader\"),u=r?void 0:n?.passages.get(\"PassageFooter\"),l=r?void 0:n?.passages.get(\"PassageDone\"),d=de(()=>{if(!s)return null;try{return xt(s)}catch(b){return console.error(\"spindle: Error in PassageHeader:\",b),null}},[s?.content]),c=de(()=>{if(!u)return null;try{return xt(u)}catch(b){return console.error(\"spindle: Error in PassageFooter:\",b),null}},[u?.content]);ve(()=>(l&&a(!0),()=>a(!1)),[e.name]);const h=de(()=>{if(!i||!l)return null;try{return xt(l)}catch(b){return console.error(\"spindle: Error in PassageDone:\",b),null}},[i,l?.content]),f=e.tags.includes(\"nobr\"),p=w(\"div\",{class:\"passage\",\"data-passage\":e.name,\"data-tags\":e.tags.join(\" \"),\"data-transition\":t,children:[d&&w(\"div\",{class:\"passage-header\",children:d}),o,c&&w(\"div\",{class:\"passage-footer\",children:c}),h&&w(\"div\",{hidden:!0,children:h})]});return f?w(ue.Provider,{value:!0,children:p}):p}const Rd=new Set([\"none\",\"fade\",\"fade-through\",\"crossfade\"]),gr={type:\"fade-through\",duration:300,pause:50};function Od(e){const t=e.find(i=>i.startsWith(\"transition:\"));if(!t)return null;const n=t.slice(11);if(!Rd.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;const r={type:n};for(const i of e)if(i.startsWith(\"duration:\")){const a=Number(i.slice(9));Number.isNaN(a)||(r.duration=a)}else if(i.startsWith(\"pause:\")){const a=Number(i.slice(6));Number.isNaN(a)||(r.pause=a)}return r}function Hn(e){return{type:e.type,duration:e.duration??gr.duration,pause:e.pause??gr.pause}}function Md(e,t,n){const r=Od(e);return r?Hn(r):t?Hn(t):n?Hn(n):{...gr}}function Yi(e,t){const n=e.cloneNode(!0);n.removeAttribute(\"id\");const r=n.querySelectorAll(\"[id]\");for(let a=0;a<r.length;a++)r[a].removeAttribute(\"id\");n.style.pointerEvents=\"none\",n.style.userSelect=\"none\";const i=n.querySelectorAll(\"audio, video\");for(let a=0;a<i.length;a++){const o=i[a];o.pause?.(),o.muted=!0}return n.classList.remove(\"passage\"),n.classList.add(\"passage-snapshot\"),n.setAttribute(\"data-transition\",t),n}function qn(e,t){e.style.setProperty(\"--passage-in-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-out-duration\",`${t.duration/1e3}s`),e.style.setProperty(\"--passage-pause\",`${t.pause/1e3}s`)}function Un(e){if(!e)return;e.classList.remove(\"passage-container--crossfading\");const t=e.querySelectorAll(\".passage-snapshot\");for(let n=0;n<t.length;n++)t[n].remove()}V({name:\"passage\",interpolate:!0,render(e,t){const n=I(f=>f.currentPassage),r=I(f=>f.storyData),[i,a]=X(n),o=fe(\"fade\"),s=fe(0),u=fe(null),l=fe([]),d=we(()=>{for(const f of l.current)clearTimeout(f);l.current=[],Un(u.current)},[]);ve(()=>{const f=I.getState(),{history:p,historyIndex:b,transitionConfig:x}=f,_=f.consumeNextTransition(),k=s.current;s.current=p.length;const S=!i,A=p.length===1&&b===0&&k>1,C=p.length>1&&b===p.length-1&&k>1&&Math.abs(p.length-k)>1;if(n===i)return;d();const y=r?.passages.get(n);if(!y){o.current=\"none\",a(n);return}if(S||A||C){o.current=\"fade\",a(n);return}const P=Md(y.tags,_,x);o.current=P.type;const T=u.current;if(P.type===\"none\"){a(n);return}if(P.type===\"fade\"){T&&qn(T,P),a(n);return}if(P.type===\"fade-through\"){if(!T){a(n);return}qn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const v=Yi(z,P.type);T.appendChild(v),a(\"\");const N=P.duration+P.pause,$=setTimeout(()=>{a(n)},N),B=N+P.duration,U=setTimeout(()=>{Un(T)},B);l.current=[$,U];return}if(P.type===\"crossfade\"){if(!T){a(n);return}qn(T,P);const z=T.querySelector(\".passage\");if(!z){a(n);return}const v=Yi(z,P.type);T.classList.add(\"passage-container--crossfading\"),T.appendChild(v),a(n);const N=setTimeout(()=>{Un(T)},P.duration);l.current=[N];return}a(n)},[n]);const c=i?r?.passages.get(i):null;if(!c&&i)return w(\"div\",{class:\"error\",children:[\"Error: Passage “\",i,\"” not found.\"]});const h=r?.passages.get(\"PassageReady\");return w(\"div\",{id:t.id??\"story\",class:t.className??\"story\",children:[h&&w(\"div\",{hidden:!0,children:xt(h)},`ready-${n}`),w(\"div\",{class:\"passage-container\",ref:u,children:c&&w(Fd,{passage:c,dataTransition:o.current},i)})]})}});V({name:\"watch\",render(e,t){const{hooks:n}=t,r=e.rawArgs.trim(),i=r.match(/^(['\"])(.*?)\\1\\s*/);if(!i)return null;const a=i[2],o=r.slice(i[0].length),s={},u=/(\\w+)\\s+(?:\"([^\"]*?)\"|'([^']*?)'|(\\d+))|(\\w+)/g;let l;for(;(l=u.exec(o))!==null;){const c=l[1]??l[5],h=l[2]??l[3]??l[4];if(c)switch(c){case\"goto\":s.goto=h;break;case\"dialog\":s.dialog=h;break;case\"run\":s.run=h;break;case\"name\":s.name=h;break;case\"priority\":s.priority=h?Number(h):0;break;case\"once\":s.once=!0;break}}const d=n.useRef(!1);return d.current||(d.current=!0,po(a,s)),null}});V({name:\"unwatch\",render(e,t){const r=e.rawArgs.trim().replace(/^['\"]|['\"]$/g,\"\"),i=t.hooks.useRef(!1);return i.current||(i.current=!0,go(r)),null}});const Ld='*,*:before,*:after{box-sizing:border-box}html{font-size:16px;-webkit-text-size-adjust:100%}body{margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75;color:#e0e0e0;background-color:#1a1a2e;min-height:100vh}tw-storydata{display:none!important}#story{max-width:42em;margin:0 auto;padding:2em 1.5em}.passage-container{position:relative}.passage-container--crossfading{display:grid}.passage-container--crossfading>*{grid-area:1 / 1}.passage{animation:passage-fade-in var(--passage-in-duration, .3s) ease}.passage[data-transition=none]{animation:none}.passage-snapshot{animation:passage-fade-out var(--passage-out-duration, .3s) ease forwards;pointer-events:none;user-select:none}@keyframes passage-fade-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes passage-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}@media(prefers-reduced-motion:reduce){.passage,.passage-snapshot{animation-duration:.01s!important}}.macro-button{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;font-size:.95em;cursor:pointer;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;font-family:monospace;padding:1em;border:1px solid #ef5350;border-radius:4px;background:#ef53501a}.loading{text-align:center;padding:2em;opacity:.6}.story-menubar{position:sticky;top:0;z-index:100;display:flex;align-items:center;gap:.5em;padding:.5em 1.5em;background:#16213e;border-bottom:1px solid rgba(255,255,255,.08);font-family:system-ui,sans-serif;font-size:.9em}.story-title{flex:1;font-weight:600;color:#e0e0e0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.menubar-button{background:transparent;color:#9e9e9e;border:1px solid transparent;padding:.35em .7em;border-radius:4px;cursor:pointer;font:inherit;transition:color .2s,background .2s}.menubar-button:hover{color:#e0e0e0;background:#ffffff14}.menubar-button:disabled{opacity:.4;cursor:default}.menubar-button:disabled:hover{color:#9e9e9e;background:transparent}.dialog-overlay{position:fixed;inset:0;z-index:200;display:flex;align-items:center;justify-content:center;background:#0009}.dialog-panel{background:#16213e;border:1px solid rgba(255,255,255,.1);border-radius:8px;width:90%;max-width:500px;max-height:80vh;display:flex;flex-direction:column;color:#e0e0e0;font-family:system-ui,sans-serif;position:relative}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{position:absolute;top:.75em;right:.75em;z-index:1;background:transparent;border:none;color:#9e9e9e;font-size:1.1em;cursor:pointer;padding:.25em;line-height:1}.dialog-close:hover{color:#e0e0e0}.dialog-body{overflow-y:auto;flex:1;min-height:0}.settings-controls{padding:1em 1.25em;display:flex;flex-direction:column;gap:1em}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:1em}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{display:flex;flex-direction:column;flex:1;min-height:0}.saves-header{display:flex;align-items:center;justify-content:space-between;padding:1em 3em 1em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);font-weight:600;flex-shrink:0}.saves-header-left{display:flex;align-items:center;gap:.75em}.saves-mode-toggle{display:flex;gap:0;border:1px solid rgba(255,255,255,.15);border-radius:4px;overflow:hidden}.saves-mode-toggle button{background:transparent;color:#9e9e9e;border:none;padding:.3em .8em;font:inherit;font-size:.85em;font-weight:600;cursor:pointer;transition:background .2s,color .2s}.saves-mode-toggle button.active{background:#64b5f633;color:#64b5f6}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{padding:.75em 1.25em;overflow-y:auto;flex:1;min-height:0}.saves-empty{text-align:center;padding:2em 1em;opacity:.5;font-size:.9em}.saves-toolbar{display:flex;gap:.5em;padding:.5em 1.25em;border-bottom:1px solid rgba(255,255,255,.08);flex-shrink:0}.saves-toolbar-button{background:#ffffff0d;color:#9e9e9e;border:1px solid rgba(255,255,255,.1);border-radius:4px;padding:.3em .7em;font:inherit;font-size:.8em;cursor:pointer;transition:background .2s,color .2s}.saves-toolbar-button:hover{background:#ffffff1a;color:#e0e0e0}.playthrough-group{margin-bottom:.75em}.playthrough-header{display:flex;align-items:center;gap:.5em;padding:.4em 0;cursor:pointer;user-select:none;font-size:.85em;color:#9e9e9e;transition:color .2s}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{display:inline-block;font-size:.7em;transition:transform .2s}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{display:flex;flex-direction:column;gap:.4em;padding-left:.25em}.save-slot{display:flex;align-items:center;gap:.75em;padding:.5em .6em;background:#ffffff08;border:1px solid rgba(255,255,255,.06);border-radius:6px;transition:background .15s}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{font-weight:500;font-size:.9em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.save-slot-meta{font-size:.75em;color:#9e9e9e;display:flex;gap:.75em}.save-slot-actions{display:flex;gap:.3em;flex-shrink:0}.save-slot-action{background:transparent;color:#9e9e9e;border:1px solid transparent;border-radius:3px;padding:.2em .5em;font:inherit;font-size:.75em;cursor:pointer;transition:color .2s,background .2s;white-space:nowrap}.save-slot-action:hover{color:#e0e0e0;background:#ffffff14}.save-slot-action.primary{color:#64b5f6;border-color:#64b5f64d}.save-slot-action.primary:hover{background:#64b5f626}.save-slot-action.danger:hover{color:#ef5350;background:#ef53501a}.save-slot-new{display:flex;align-items:center;justify-content:center;padding:.5em;margin-top:.25em;border:1px dashed rgba(255,255,255,.12);border-radius:6px;color:#9e9e9e;font:inherit;font-size:.8em;background:transparent;cursor:pointer;width:100%;transition:color .2s,border-color .2s,background .2s}.save-slot-new:hover{color:#64b5f6;border-color:#64b5f64d;background:#64b5f60d}.saves-status{padding:.5em 1.25em;font-size:.8em;color:#81c784;border-top:1px solid rgba(255,255,255,.08);flex-shrink:0;text-align:center}.saves-status.error{color:#ef5350;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit;background:transparent}.save-rename-input{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(100,181,246,.4);border-radius:3px;padding:.15em .4em;font:inherit;font-size:.9em;width:100%}.save-rename-input:focus{outline:none;border-color:#64b5f6}.macro-link{color:#64b5f6;text-decoration:none;border-bottom:1px solid rgba(100,181,246,.3);transition:color .2s,border-color .2s;cursor:pointer}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{outline:none;border-color:#64b5f6}.macro-textarea{min-height:3em;resize:vertical}.macro-checkbox,.macro-radiobutton{cursor:pointer;display:inline-flex;align-items:center;gap:.3em}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{background:#1a1a2e;color:#e0e0e0;border:1px solid rgba(255,255,255,.15);border-radius:4px;padding:.3em .5em;font:inherit}.macro-cycle{background:#64b5f626;color:#64b5f6;border:1px solid rgba(100,181,246,.4);border-radius:4px;padding:.25em .75em;font:inherit;cursor:pointer;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{position:relative;width:100%;height:1.4em;background:#2a2a3e;border-radius:.3em;overflow:hidden;border:1px solid #444}.macro-meter-fill{height:100%;background:#64b5f6;transition:width .3s ease}.macro-meter-label{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:.85em;color:#e0e0e0;text-shadow:0 1px 2px rgba(0,0,0,.8);pointer-events:none}.md{display:contents}.passage p{margin:.6em 0}.passage p:first-child{margin-top:0}.passage p:last-child{margin-bottom:0}.passage h1,.passage h2,.passage h3,.passage h4,.passage h5,.passage h6{margin:1em 0 .4em;line-height:1.3;color:#f0f0f0}.passage h1{font-size:1.8em}.passage h2{font-size:1.5em}.passage h3{font-size:1.25em}.passage h4{font-size:1.1em}.passage h5{font-size:1em}.passage h6{font-size:.9em;opacity:.8}.passage code{font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em;background:#ffffff14;padding:.15em .35em;border-radius:3px}.passage pre{background:#0000004d;border:1px solid rgba(255,255,255,.08);border-radius:6px;padding:1em;overflow-x:auto;margin:.8em 0}.passage pre code{background:none;padding:0;border-radius:0;font-size:.85em}.passage blockquote{border-left:3px solid rgba(100,181,246,.5);margin:.8em 0;padding:.4em 1em;color:#b0b0b0}.passage blockquote p{margin:.3em 0}.passage ul,.passage ol{margin:.6em 0;padding-left:1.8em}.passage li{margin:.2em 0}.passage hr{border:none;border-top:1px solid rgba(255,255,255,.12);margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{border:1px solid rgba(255,255,255,.12);padding:.5em .75em;text-align:left}.passage th{background:#ffffff0f;font-weight:600}.passage tr:nth-child(2n){background:#ffffff05}.passage del{opacity:.5}.passage strong{color:#f0f0f0}.macro-type-cursor:after{content:\"█\";animation:type-blink .7s step-end infinite;color:#64b5f6}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}';function Ji(e,t){e.innerHTML=\"\";const n=document.createElement(\"div\");n.style.cssText=\"font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto\";const r=document.createElement(\"h1\");r.style.color=\"#c00\",r.textContent=\"Story Validation Errors\",n.appendChild(r);const i=document.createElement(\"ul\");i.style.cssText=\"line-height:1.6\";for(const a of t){const o=document.createElement(\"li\");o.textContent=a,i.appendChild(o)}n.appendChild(i),e.appendChild(n)}function Zi(){const e=Kf(),t=document.createElement(\"style\");if(t.id=\"spindle-styles\",t.textContent=Ld,document.head.appendChild(t),cd(),e.userCSS){const h=document.createElement(\"style\");h.textContent=e.userCSS,document.head.appendChild(h)}if(e.userScript)try{new Function(e.userScript)()}catch(h){console.error(\"spindle: Error in story JavaScript:\",h)}document.dispatchEvent(new CustomEvent(\":storystartup\"));let n={};const r=e.passages.get(\"StoryVariables\");if(!r){const h=\"Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.\",f=document.getElementById(\"root\");throw f&&Ji(f,[h]),new Error(`spindle: ${h}`)}const i=hd(r.content),a=md(e.passages,i);if(a.length>0){const h=document.getElementById(\"root\");throw h&&Ji(h,a),new Error(`spindle: ${a.length} validation error(s):\n${a.join(`\n`)}`)}n=_d(i),I.getState().init(e,n),fo();const o=Ef(e.ifid);o&&I.getState().loadFromPayload(o);for(const[,h]of e.passages)if(h.tags.includes(\"widget\")){const f=mt(h.content),p=_t(f);for(const b of p)if(b.type===\"macro\"&&b.name===\"widget\"&&b.rawArgs){const x=b.rawArgs.trim().split(/\\s+/),_=x[0].replace(/[\"']/g,\"\"),k=x.slice(1).filter(C=>C.startsWith(\"$\")||C.startsWith(\"_\")||C.startsWith(\"@\")),S=b.children,A=sn(S);qa(_,S,k,A),A&&za(_)}}let s=\"\";I.subscribe(h=>{h.currentPassage!==s&&(s=h.currentPassage,td())});let u=I.getState().variables,l=I.getState().historyIndex;I.subscribe(h=>{h.variables!==u&&(h.historyIndex===l?$f():zf()),u=h.variables,l=h.historyIndex});const d=e.passages.get(\"StoryInterface\");d&&!d.content.includes(\"{passage}\")&&console.warn(\"spindle: StoryInterface passage does not contain {passage}. The current passage will not be displayed.\");const c=document.getElementById(\"root\");if(!c)throw new Error('spindle: No <div id=\"root\"> element found.');xe(w(Qf,{}),c),document.dispatchEvent(new CustomEvent(\":storyready\"))}document.readyState===\"loading\"?document.addEventListener(\"DOMContentLoaded\",Zi):Zi();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|