@rohal12/spindle 0.55.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/dist/pkg/headless.js +84 -18
- package/dist/pkg/macro-registry.json +2 -1
- package/dist/pkg/story-variables.js +53 -11
- package/dist/pkg/tooling.js +2 -2
- package/package.json +1 -1
- package/src/code-check.ts +22 -4
- package/src/components/macros/MacroLink.tsx +30 -7
- package/src/components/macros/macro-args.ts +27 -3
- package/src/components/macros/option-utils.ts +11 -6
- package/src/define-macro.ts +22 -2
- package/src/markup/validate.ts +16 -2
- package/src/tooling.ts +12 -0
- package/src/types-drift-check.ts +2 -2
- package/types/tooling.d.ts +11 -0
package/dist/pkg/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.storyFormat({"name":"spindle","version":"0.55.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel=\"modulepreload\"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return x(e,s,i,a,null)}function x(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(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`?w(e):null}function T(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=v({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),ce(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??w(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,ue(i,o,a),t.__e=t.__=null,o.__e!=n&&E(o)}}function E(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}),E(e)}function ee(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!D.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(D)}function D(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,T(e)}finally{a.length=D.__r=0}}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=ne(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=ce(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&pe(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?c=re(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function ne(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=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]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=O(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),me(s,s));return r}function re(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=re(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=w(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ie(e,t){return t=t||[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){ie(e,t)}):t.push(e)),t}function O(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?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)&&s==l.key&&c==l.type)return o}return-1}function ae(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function oe(e,t,n,r,i){var a,o;n: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||ae(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ae(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(l,`$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=u,e.addEventListener(t,a?f:d,a)):e.removeEventListener(t,a?f:d,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 n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function se(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=u++;else if(t.t<n.u)return;return n(r.event?r.event(t):t)}}}function ce(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,w,T,E,ee,D,ne,re,ie,O=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof O==`function`)try{if(w=t.props,T=O.prototype&&O.prototype.render,E=(d=O.contextType)&&i[d.__c],ee=d?E?E.props.value:d.__:i,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new O(w,ee):(t.__c=f=new C(w,ee),f.constructor=O,f.render=he),E&&E.sub(f),f.state||(f.state={}),f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&O.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,O.getDerivedStateFromProps(w,f.__s))),m=f.props,g=f.state,f.__v=t,p)T&&O.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&O.getDerivedStateFromProps==null&&w!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(w,ee),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(w,f.__s,ee)){t.__v!=n.__v&&(f.props=w,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(w,f.__s,ee),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=ee,f.props=w,f.__P=e,f.__e=!1,D=r.__r,ne=0,T)f.state=f.__s,f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++ne<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),re=d!=null&&d.type===S&&d.key==null?de(d.props.children):d,c=te(e,_(re)?re:[re],t,n,i,a,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(ie=o.length;ie--;)y(o[ie]);le(t)}else t.__e=n.__e,t.__k=n.__k,e.then||le(t);r.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=fe(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function le(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(le))}function ue(e,t,n){for(var i=0;i<n.length;i++)pe(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function de(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(de):v({},e)}function fe(e,t,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(r.__m&&r.__m(t,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=s&&n.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||oe(e,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||oe(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),te(t.type==`template`?e.content:e,_(h)?h:[h],t,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l||(d=`value`,C==`progress`&&v==null?e.removeAttribute(`value`):v!=null&&(v!==e[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&oe(e,d,v,x[d],o),d=`checked`,b!=null&&b!=e[d]&&oe(e,d,b,x[d],o))}return e}function pe(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function me(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||pe(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&me(i[a],t,n||typeof e.type!=`function`);n||y(e.__e),e.__c=e.__=e.__e=void 0}function he(e,t,n){return this.constructor(e,n)}function ge(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],ce(t,e=(!a&&i||t).__k=b(S,null,[e]),o||m,m,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),ue(s,e,c)}function _e(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,ee(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+ p++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=h.slice,r={__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(t){e=t}throw e}},i=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),ee(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ee(this))},C.prototype.render=S,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},D.__r=0,l=/(PointerCapture)$|Capture$/i,u=0,d=se(!1),f=se(!0),p=0;var ve,k,ye,be,xe=0,Se=[],A=r,Ce=A.__b,we=A.__r,Te=A.diffed,Ee=A.__c,De=A.unmount,Oe=A.__;function ke(e,t){A.__h&&A.__h(k,e,xe||t),xe=0;var n=k.__H||(k.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ae(e){return xe=1,je(Ue,e)}function je(e,t,n){var r=ke(ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ue(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=k,!k.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};k.__f=!0;var a=k.shouldComponentUpdate,o=k.componentWillUpdate;k.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},k.shouldComponentUpdate=i}return r.__N||r.__}function Me(e,t){var n=ke(ve++,3);!A.__s&&He(n.__H,t)&&(n.__=e,n.u=t,k.__H.__h.push(n))}function Ne(e,t){var n=ke(ve++,4);!A.__s&&He(n.__H,t)&&(n.__=e,n.u=t,k.__h.push(n))}function j(e){return xe=5,Pe(function(){return{current:e}},[])}function Pe(e,t){var n=ke(ve++,7);return He(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Fe(e,t){return xe=8,Pe(function(){return e},t)}function Ie(e){var t=k.context[e.__c],n=ke(ve++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(k)),t.props.value):e.__}function Le(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Be),t.__h.some(Ve),t.__h=[]}catch(n){t.__h=[],A.__e(n,e.__v)}}}A.__b=function(e){k=null,Ce&&Ce(e)},A.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},A.__r=function(e){we&&we(e),ve=0;var t=(k=e.__c).__H;t&&(ye===k?(t.__h=[],k.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Be),t.__h.some(Ve),t.__h=[],ve=0)),ye=k},A.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&be===A.requestAnimationFrame||((be=A.requestAnimationFrame)||ze)(Le)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ye=k=null},A.__c=function(e,t){t.some(function(e){try{e.__h.some(Be),e.__h=e.__h.filter(function(e){return!e.__||Ve(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],A.__e(n,e.__v)}}),Ee&&Ee(e,t)},A.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Be(e)}catch(e){t=e}}),n.__H=void 0,t&&A.__e(t,n.__v))};var Re=typeof requestAnimationFrame==`function`;function ze(e){var t,n=function(){clearTimeout(r),Re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Re&&(t=requestAnimationFrame(n))}function Be(e){var t=k,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),k=t}function Ve(e){var t=k;e.__c=e.__(),k=t}function He(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ue(e,t){return typeof t==`function`?t(e):t}function We(e,t){for(var n in t)e[n]=t[n];return e}function Ge(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 Ke(e,t){var n=t(),r=Ae({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Ne(function(){i.__=n,i.u=t,qe(i)&&a({t:i})},[e,n,t]),Me(function(){return qe(i)&&a({t:i}),e(function(){qe(i)&&a({t:i})})},[e]),n}function qe(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 Je(e,t){this.props=e,this.context=t}(Je.prototype=new C).isPureReactComponent=!0,Je.prototype.shouldComponentUpdate=function(e,t){return Ge(this.props,e)||Ge(this.state,t)};var Ye=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ye&&Ye(e)},typeof Symbol<`u`&&Symbol.for;var Xe=r.__e;r.__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??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Xe(e,t,n,r)};var Ze=r.unmount;function Qe(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=We({},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(e){return Qe(e,t,n)})),e}function $e(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return $e(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function et(){this.__u=0,this.o=null,this.__b=null}function tt(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function nt(){this.i=null,this.l=null}r.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ze&&Ze(e)},(et.prototype=new C).__c=function(e,t){var n=t.__c,r=this;r.o??(r.o=[]),r.o.push(n);var i=tt(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=$e(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},et.prototype.componentWillUnmount=function(){this.o=[]},et.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Qe(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var rt=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]}};(nt.prototype=new C).__a=function(e){var t=this,n=tt(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),rt(t,e,r)):i()};n?n(a):a()}},nt.prototype.render=function(e){this.i=null,this.l=new Map;var t=ie(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},nt.prototype.componentDidUpdate=nt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){rt(e,n,t)})};var it=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,at=/^(?: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]/,ot=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,st=/[A-Z0-9]/g,ct=typeof document<`u`,lt=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(C.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ut=r.event;r.event=function(e){return ut&&(e=ut(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var dt={configurable:!0,get:function(){return this.class}},ft=r.vnode;r.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||ct&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||lt(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:ot.test(a)&&(a=s):s=a=`oninput`:i&&at.test(a)?a=a.replace(st,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=ie(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ie(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,dt)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=it,ft&&ft(e)};var pt=r.__r;r.__r=function(e){pt&&pt(e),e.__c};var mt=r.diffed;r.diffed=function(e){mt&&mt(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)};var ht=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},gt=(e=>e?ht(e):ht),_t=e=>e;function vt(e){function t(t=_t){let n=Fe(()=>t(e.getState()),[t]);return Ke(e.subscribe,n)}return Object.assign(t,e)}function yt(){return e=>vt(gt()(e))}var bt=Symbol.for(`immer-nothing`),xt=Symbol.for(`immer-draftable`),M=Symbol.for(`immer-state`);function St(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ct=Object,wt=Ct.getPrototypeOf,Tt=`constructor`,Et=`prototype`,Dt=`configurable`,Ot=`enumerable`,kt=`writable`,At=`value`,jt=e=>!!e&&!!e[M];function Mt(e){return e?Ft(e)||Ht(e)||!!e[xt]||!!e[Tt]?.[xt]||Ut(e)||Wt(e):!1}var Nt=Ct[Et][Tt].toString(),Pt=new WeakMap;function Ft(e){if(!e||!Gt(e))return!1;let t=wt(e);if(t===null||t===Ct[Et])return!0;let n=Ct.hasOwnProperty.call(t,Tt)&&t[Tt];if(n===Object)return!0;if(!Kt(n))return!1;let r=Pt.get(n);return r===void 0&&(r=Function.toString.call(n),Pt.set(n,r)),r===Nt}function It(e,t,n=!0){Lt(e)===0?(n?Reflect.ownKeys(e):Ct.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Lt(e){let t=e[M];return t?t.type_:Ht(e)?1:Ut(e)?2:Wt(e)?3:0}var Rt=(e,t,n=Lt(e))=>n===2?e.has(t):Ct[Et].hasOwnProperty.call(e,t),zt=(e,t,n=Lt(e))=>n===2?e.get(t):e[t],Bt=(e,t,n,r=Lt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Vt(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ht=Array.isArray,Ut=e=>e instanceof Map,Wt=e=>e instanceof Set,Gt=e=>typeof e==`object`,Kt=e=>typeof e==`function`,qt=e=>typeof e==`boolean`;function Jt(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Yt=e=>Gt(e)?e?.[M]:null,Xt=e=>e.copy_||e.base_,Zt=e=>{let t=Yt(e);return t?t.copy_??t.base_:e},Qt=e=>e.modified_?e.copy_:e.base_;function $t(e,t){if(Ut(e))return new Map(e);if(Wt(e))return new Set(e);if(Ht(e))return Array[Et].slice.call(e);let n=Ft(e);if(t===!0||t===`class_only`&&!n){let t=Ct.getOwnPropertyDescriptors(e);delete t[M];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[kt]===!1&&(a[kt]=!0,a[Dt]=!0),(a.get||a.set)&&(t[i]={[Dt]:!0,[kt]:!0,[Ot]:a[Ot],[At]:e[i]})}return Ct.create(wt(e),t)}else{let t=wt(e);if(t!==null&&n)return{...e};let r=Ct.create(t);return Ct.assign(r,e)}}function en(e,t=!1){return tn(e)||jt(e)||!Mt(e)?e:(Lt(e)>1&&Ct.defineProperties(e,{set:P,add:P,clear:P,delete:P}),Ct.freeze(e),t&&It(e,(e,t)=>{en(t,!0)},!1),e)}function N(){St(2)}var P={[At]:N};function tn(e){return e===null||!Gt(e)?!0:Ct.isFrozen(e)}var nn=`MapSet`,rn=`Patches`,F=`ArrayMethods`,an={};function on(e){let t=an[e];return t||St(0,e),t}var sn=e=>!!an[e];function cn(e,t){an[e]||(an[e]=t)}var ln,un=()=>ln,dn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:sn(nn)?on(nn):void 0,arrayMethodsPlugin_:sn(F)?on(F):void 0});function fn(e,t){t&&(e.patchPlugin_=on(rn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function pn(e){mn(e),e.drafts_.forEach(I),e.drafts_=null}function mn(e){e===ln&&(ln=e.parent_)}var hn=e=>ln=dn(ln,e);function I(e){let t=e[M];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function gn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[M].modified_&&(pn(t),St(4)),Mt(e)&&(e=_n(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[M].base_,e,t)}else e=_n(t,n);return vn(t,e,!0),pn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===bt?void 0:e}function _n(e,t){if(tn(t))return t;let n=t[M];if(!n)return En(t,e.handledSet_,e);if(!bn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);wn(n,e)}return n.copy_}function vn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&en(t,n)}function yn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var bn=(e,t)=>e.scope_===t,xn=[];function Sn(e,t,n,r){let i=Xt(e),a=e.type_;if(r!==void 0&&zt(i,r,a)===t){Bt(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;It(i,(e,n)=>{if(jt(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??xn;for(let e of o)Bt(i,e,n,a)}function Cn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!bn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Qt(i);Sn(e,i.draft_??i,a,n),wn(i,r)})}function wn(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}yn(e)}}function Tn(e,t,n){let{scope_:r}=e;if(jt(n)){let i=n[M];bn(i,r)&&i.callbacks_.push(function(){Pn(e),Sn(e,n,Qt(i),t)})}else Mt(n)&&e.callbacks_.push(function(){let i=Xt(e);e.type_===3?i.has(n)&&En(n,r.handledSet_,r):zt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&En(zt(e.copy_,t,e.type_),r.handledSet_,r)})}function En(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||jt(e)||t.has(e)||!Mt(e)||tn(e)?e:(t.add(e),It(e,(r,i)=>{if(jt(i)){let t=i[M];bn(t,n)&&(Bt(e,r,Qt(t),e.type_),yn(t))}else Mt(i)&&En(i,t,n)}),e)}function Dn(e,t){let n=Ht(e),r={type_:n?1:0,scope_:t?t.scope_:un(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=On;n&&(i=[r],a=kn);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var On={get(e,t){if(t===M)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Xt(e);if(!Rt(i,t,e.type_))return jn(e,i,t);let a=i[t];if(e.finalized_||!Mt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Jt(t))return a;if(a===An(e.base_,t)){Pn(e);let n=e.type_===1?+t:t,r=In(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Xt(e)},ownKeys(e){return Reflect.ownKeys(Xt(e))},set(e,t,n){let r=Mn(Xt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=An(Xt(e),t),i=r?.[M];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Vt(n,r)&&(n!==void 0||Rt(e.base_,t,e.type_)))return!0;Pn(e),Nn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Tn(e,t,n),!0)},deleteProperty(e,t){return Pn(e),An(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Nn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Xt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[kt]:!0,[Dt]:e.type_!==1||t!==`length`,[Ot]:r[Ot],[At]:n[t]}},defineProperty(){St(11)},getPrototypeOf(e){return wt(e.base_)},setPrototypeOf(){St(12)}},kn={};for(let e in On){let t=On[e];kn[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}kn.deleteProperty=function(e,t){return kn.set.call(this,e,t,void 0)},kn.set=function(e,t,n){return On.set.call(this,e[0],t,n,e[0])};function An(e,t){let n=e[M];return(n?Xt(n):e)[t]}function jn(e,t,n){let r=Mn(t,n);return r?At in r?r[At]:r.get?.call(e.draft_):void 0}function Mn(e,t){if(!(t in e))return;let n=wt(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=wt(n)}}function Nn(e){e.modified_||(e.modified_=!0,e.parent_&&Nn(e.parent_))}function Pn(e){e.copy_||(e.assigned_=new Map,e.copy_=$t(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Kt(e)&&!Kt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Kt(t)||St(6),n!==void 0&&!Kt(n)&&St(7);let r;if(Mt(e)){let i=hn(this),a=In(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?pn(i):mn(i)}return fn(i,n),gn(r,i)}else if(!e||!Gt(e)){if(r=t(e),r===void 0&&(r=e),r===bt&&(r=void 0),this.autoFreeze_&&en(r,!0),n){let t=[],i=[];on(rn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else St(1,e)},this.produceWithPatches=(e,t)=>{if(Kt(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},qt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),qt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),qt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Mt(e)||St(8),jt(e)&&(e=Ln(e));let t=hn(this),n=In(t,e,void 0);return n[M].isManual_=!0,mn(t),n}finishDraft(e,t){let n=e&&e[M];(!n||!n.isManual_)&&St(9);let{scope_:r}=n;return fn(r,t),gn(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--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=on(rn).applyPatches_;return jt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function In(e,t,n,r){let[i,a]=Ut(t)?on(nn).proxyMap_(t,n):Wt(t)?on(nn).proxySet_(t,n):Dn(t,n);return(n?.scope_??un()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Cn(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Ln(e){return jt(e)||St(10,e),Rn(e)}function Rn(e){if(!Mt(e)||tn(e))return e;let t=e[M],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=$t(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=$t(e,!0);return It(n,(e,t)=>{Bt(n,e,Rn(t))},r),t&&(t.finalized_=!1),n}function zn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=Yt(zt(e,n.key_)),i=zt(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||Rt(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=zt(n,r),!Gt(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[M];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;It(e.assigned_,(e,l)=>{let u=zt(o,e,c),f=zt(s,e,c),p=l?Rt(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===bt?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=Lt(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===Tt)&&St(19),Kt(o)&&n===Et&&St(19),o=zt(o,n),Gt(o)||St(18,i.join(`/`))}let s=Lt(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:St(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:St(17,a)}}),e}function u(e){if(!Mt(e))return e;if(Ht(e))return e.map(u);if(Ut(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Wt(e))return new Set(Array.from(e).map(u));let t=Object.create(wt(e));for(let n in e)t[n]=u(e[n]);return Rt(e,xt)&&(t[xt]=e[xt]),t}function d(e){return jt(e)?u(e):e}cn(rn,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}function Bn(){class e extends Map{constructor(e,t){super(),this[M]={type_:2,parent_:t,scope_:t?t.scope_:un(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return Xt(this[M]).size}has(e){return Xt(this[M]).has(e)}set(e,t){let r=this[M];return o(r),(!Xt(r).has(e)||Xt(r).get(e)!==t)&&(n(r),Nn(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),Tn(r,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return o(t),n(t),Nn(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[M];o(e),Xt(e).size&&(n(e),Nn(e),e.assigned_=new Map,It(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[M];Xt(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[M];o(t);let r=Xt(t).get(e);if(t.finalized_||!Mt(r)||r!==t.base_.get(e))return r;let i=In(t.scope_,r,t,e);return n(t),t.copy_.set(e,i),i}keys(){return Xt(this[M]).keys()}values(){let e=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}}entries(){let e=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}}[Symbol.iterator](){return this.entries()}}function t(t,n){let r=new e(t,n);return[r,r[M]]}function n(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}class r extends Set{constructor(e,t){super(),this[M]={type_:3,parent_:t,scope_:t?t.scope_:un(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){return Xt(this[M]).size}has(e){let t=this[M];return o(t),t.copy_?!!(t.copy_.has(e)||t.drafts_.has(e)&&t.copy_.has(t.drafts_.get(e))):t.base_.has(e)}add(e){let t=this[M];return o(t),this.has(e)||(a(t),Nn(t),t.copy_.add(e),Tn(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return o(t),a(t),Nn(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[M];o(e),Xt(e).size&&(a(e),Nn(e),e.copy_.clear())}values(){let e=this[M];return o(e),a(e),e.copy_.values()}entries(){let e=this[M];return o(e),a(e),e.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}}function i(e,t){let n=new r(e,t);return[n,n[M]]}function a(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(Mt(t)){let n=In(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function o(e){e.revoked_&&St(3,JSON.stringify(Xt(e)))}function s(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add(Zt(t))})}}cn(nn,{proxyMap_:t,proxySet_:i,fixSetContents:s})}var Vn=new Fn().produce,Hn=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?Vn(e):e,n,...r),e(r.setState,n,r)),Un=`{`,Wn=`}`,Gn={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},Kn=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),qn={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},Jn=new Set([`if`,`switch`,`timed`]),Yn=[[`|`,!1],[`->`,!1],[`<-`,!0]],Xn={};function Zn(e){for(let[t,n]of Yn){let r=e.indexOf(t);if(r===-1)continue;let i=e.slice(0,r).trim(),a=e.slice(r+t.length).trim();return n?{display:a,target:i}:{display:i,target:a}}let t=e.trim();return{display:t,target:t}}function Qn(e){return`\"`+e.replace(/[\\\\\"]/g,`\\\\$&`)+`\"`}function $n(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}function er(e){let t=[],n=``;for(let[r,i]of e)i&&(r===`.`?t.push(i):n=i);return $n({},{className:t.join(` `),id:n})}function tr(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Un+(e.isClose?`/`:``)+e.name+Wn}function nr(e){return e.lex===`html`?`</`+e.tag+`>`:Un+`/`+e.name+Wn}function rr(e){return`line `+e.start.line+`, column `+e.start.column}function ir(e,t){return e.lex===t.lex&&e.lower===t.lower}function ar(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function or(e){switch(e.lex){case`text`:return{type:`text`,value:e.value};case`link`:return $n({type:`macro`,name:`link`,rawArgs:Qn(e.display)+` `+Qn(e.target),children:[]},e);case`variable`:return $n({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return $n({type:`expression`,expression:e.expression},e);default:return e}}function sr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return{type:`text`,value:e.value,...t};case`link`:return $n({type:`link`,display:e.display,target:e.target,...t},e);case`variable`:return $n({type:`variable`,name:e.name,scope:e.scope,...t},e);case`expression`:return $n({type:`expression`,expression:e.expression,...t},e);case`macro`:return $n({type:`macro`,name:e.name,rawArgs:e.rawArgs,isClose:e.isClose,...t},e);case`html`:return{type:`html`,tag:e.tag,attributes:e.attributes,isClose:e.isClose,isSelfClose:e.isSelfClose,...t}}}function cr(e,t){let n=[],r=null,i=e=>{if(e!=null){if(Array.isArray(e))return e.forEach(i);if(e.lex===`text`&&!e.escape&&r&&r.lex===`text`&&!r.escape&&r.end===e.start){r.value+=e.value,r.end=e.end;return}n.push(e),r=e}};return i(e),t?n.map(t):n}var lr=class extends SyntaxError{constructor(e,t,n,r){super(e),this.expected=t,this.found=n,this.location=r,this.name=`SyntaxError`}format(e){let t=`Error: `+this.message;if(this.location){let n=null,r=e.find(e=>e.source===this.location.source);r&&(n=r.text.split(/\\r\\n|\\n|\\r/g));let i=this.location.start,a=this.location.source&&typeof this.location.source.offset==`function`?this.location.source.offset(i):i,o=this.location.source+`:`+a.line+`:`+a.column;if(n){let e=this.location.end,r=``.padEnd(a.line.toString().length,` `),s=n[i.line-1],c=(i.line===e.line?e.column:s.length+1)-i.column||1;t+=`\n --> `+o+`\n`+r+` |\n`+a.line+` | `+s+`\n`+r+` | `+``.padEnd(i.column-1,` `)+``.padEnd(c,`^`)}else t+=`\n at `+o}return t}static buildMessage(e,t){function n(e){return e.codePointAt(0).toString(16).toUpperCase()}let r=Object.prototype.hasOwnProperty.call(RegExp.prototype,`unicode`)?RegExp(`[\\\\p{C}\\\\p{Mn}\\\\p{Mc}]`,`gu`):null;function i(e){return r?e.replace(r,e=>`\\\\u{`+n(e)+`}`):e}function a(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\"/g,`\\\\\"`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}function o(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\\]/g,`\\\\]`).replace(/\\^/g,`\\\\^`).replace(/-/g,`\\\\-`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}let s={literal(e){return`\"`+a(e.text)+`\"`},class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+`-`+o(e[1]):o(e));return`[`+(e.inverted?`^`:``)+t.join(``)+`]`+(e.unicode?`u`:``)},any(){return`any character`},end(){return`end of input`},other(e){return e.description}};function c(e){return s[e.type](e)}function l(e){let t=e.map(c);if(t.sort(),t.length>0){let e=1;for(let n=1;n<t.length;n++)t[n-1]!==t[n]&&(t[e]=t[n],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+` or `+t[1];default:return t.slice(0,-1).join(`, `)+`, or `+t[t.length-1]}}function u(e){return e?`\"`+a(e)+`\"`:`end of input`}return`Expected `+l(e)+` but `+u(t)+` found.`}};function ur(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Markup:vn,Tokens:An},a=vn,o=/^[^\\\\{[<]/,s=/^[{}]/,c=/^[$_@%(!\\/a-zA-Z]/,l=/^[.#]/,u=/^[a-zA-Z0-9_\\-]/,d=/^[$_@%]/,f=/^[a-zA-Z0-9_.]/,p=/^[$_@%(!]/,m=/^[a-zA-Z]/,h=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF}]/,g=/^[\\t-\\r \\/>\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,_=/^[a-zA-Z0-9\\-]/,v=/^[\\t-\\r \"'\\/<->{}\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,y=/^[^\"]/,b=/^[^']/,x=/^[\"']/,S=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF>]/,C=/^[ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,w=fn(),T=dn([`\\\\`,`{`,`[`,`<`],!0,!1,!1),E=un(`\\\\`,!1),ee=dn([`{`,`}`],!1,!1,!1),D=un(`{`,!1),te=dn([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ne=un(`<`,!1),re=un(`[`,!1),ie=un(`[[`,!1),O=un(`]]`,!1),ae=un(` `,!1),oe=dn([`.`,`#`],!1,!1,!1),se=dn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),ce=dn([`$`,`_`,`@`,`%`],!1,!1,!1),le=dn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),ue=un(`}`,!1),de=dn([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),fe=un(`/`,!1),pe=dn([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),me=dn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),he=un(`>`,!1),ge=dn([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),_e=un(`</`,!1),ve=dn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),k=dn([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),ye=un(`=`,!1),be=un(`\"`,!1),xe=dn([`\"`],!0,!1,!1),Se=un(`'`,!1),A=dn([`'`],!0,!1,!1),Ce=dn([`\"`,`'`],!1,!1,!1),we=dn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),Te=dn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Ee(e){return e}function De(e){Er(tr(e)+` must be directly inside {`+qn[e.lower]+Wn,e.loc)}function Oe(e){Er(tr(e)+` closes nothing: no `+(e.lex===`html`?`<`+e.tag+`>`:Un+e.name+Wn)+` is open here`,e.loc)}function ke(e){return cr(e,or)}function Ae(e){return e.kind===`open`}function je(e){return wr=e.lower,xr.isRaw(wr)}function Me(e,t){return t}function Ne(e){return xr.isBlock(e.lower)}function j(e,t){return t}function Pe(e){return null}function Fe(e,t){return kr(e,t)}function Ie(){return!br}function Le(e){return!e.isSelfClose}function Re(e,t){return t}function ze(e,t){let n={type:`html`,tag:e.tag,attributes:e.attributes,children:[]};return t&&(Or(e,t),n.children=t.children),n}function Be(e,t,n){return{children:e,branches:t,end:n}}function Ve(e,t){return{tag:e,children:t}}function He(){return null}function Ue(e){return e.kind===`branch`}function We(e){return e}function Ge(e){return e.kind===`close`}function Ke(e){return e}function qe(){return!br}function Je(e){return e}function Ye(t){return Tr(xr.rawBodyEnd(e,t,wr))}function Xe(e){return Sr-on()}function Ze(e,t,n){return{children:t?[{type:`text`,value:t}]:[],branches:[],end:n}}function Qe(){return{children:[],branches:[],end:null}}function $e(e){return cr(e,sr)}function et(){return!br}function tt(e){return e}function nt(){return!br}function rt(e){return Kn.has(e.lower)?null:e}function it(e){return wr=e.lower,e.kind===`open`&&xr.isRaw(wr)}function at(e,t){return t}function ot(e,t){return t?[e,t]:e}function st(t){return Tr(xr.rawBodyEnd(e,t,wr))}function ct(e){return Sr-on()}function lt(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?ar(`text`,r,{value:t}):null,n]}function ut(){return on()}function dt(e){return ar(`text`,sn(),{value:e})}function ft(e){return e.length%2==1}function pt(e,t){return t}function mt(t,n){let r=sn(),i=e.charAt(r.end.offset);if(br){if(!n&&i!==Un&&i!==Wn)return ar(`text`,r,{value:t});let e=ar(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return ar(`text`,r,{value:t});let a=ar(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=ar(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function ht(){return ar(`text`,sn(),{value:Un})}function gt(){return!br}function _t(){return ar(`text`,sn(),{value:`<`})}function vt(){return ar(`text`,sn(),{value:`[`})}function yt(){return!br}function bt(e,t){return $n(ar(`link`,sn(),Zn(t)),e)}function xt(){return!br}function M(){Er(`Unclosed link: [[ without ]]`,sn())}function St(e){return er(e)}function Ct(){return Xn}function wt(e,t){return[e,t]}function Tt(e,t,n){return $n(ar(`variable`,sn(),{name:n,scope:Gn[t]}),e)}function Et(e,t){return $n(ar(`expression`,sn(),{expression:t}),e)}function Dt(){Er(`Unclosed `+Un+e.substr(sn().end.offset,1)+`…: no } ends it`,sn())}function Ot(t){return Tr(xr.closeBrace(e,t,t))}function kt(e){return Sr-on()}function At(e,t){return t}function jt(t,n,r,i,a){return Tr(xr.closeBrace(e,a,n))}function Mt(e,t,n,r,i){return Sr-on()}function Nt(e,t,n,r,i,a){return a}function Pt(e,t,n,r,i,a){let o=sn(),s=r.toLowerCase(),c=ar(`macro`,o,{name:r,lower:s,rawArgs:``,isClose:!!n});return a===null&&Er(`Unclosed `+Un+(n?`/`:``)+r+`…: no } ends the macro`,o),c.rawArgs=a.trim(),n?(e!==Xn&&Er(`A closing tag takes no selectors: `+tr(c),o),c.rawArgs&&Er(`A closing tag takes no arguments: `+Un+`/`+r+` `+c.rawArgs+Wn,o),c.kind=`close`):($n(c,e),c.kind=Object.prototype.hasOwnProperty.call(qn,s)?`branch`:`open`),c}function Ft(e){Er(`A closing tag starts with a letter after `+Un+`/`,sn())}function It(){return!br}function Lt(e){return Kn.has(e.lower)}function Rt(e){return null}function zt(e,t,n){let r=e.toLowerCase();return ar(`html`,sn(),{tag:e,lower:r,attributes:Dr(t),isClose:!1,isSelfClose:!!n||Kn.has(r)})}function Bt(t,n){let r=e.charAt(n);r||Er(`Unclosed tag <`+t+`: no > ends it (write < for a < that starts no tag)`,sn());let i={source:sn().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};Er(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i)}function Vt(e){return ar(`html`,sn(),{tag:e,lower:e.toLowerCase(),attributes:{},isClose:!0,isSelfClose:!1})}function Ht(e){return Cr=xr.isCodeAttribute(e),!0}function Ut(e,t){return t}function Wt(e,t){return[e,t??``]}function Gt(e){return e}function Kt(e){return e}function qt(e){Er(`Unclosed attribute value: the `+e+` here has no closing `+e,sn())}function Jt(){return!Cr}function Yt(e){return e.length%2==1}function Xt(){return!Cr}function Zt(t,n){return Tr(xr.closeBrace(e,n,t))}function Qt(e,t){return Sr-on()}function $t(){return!Cr}function en(){return Cr}let N=t.peg$currPos|0,P=N,tn=[{line:1,column:1}],nn=N,rn=t.peg$maxFailExpected||[],F=t.peg$silentFails|0,an;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function on(){return P}function sn(){return hn(P,N)}function cn(e,t){throw t=t===void 0?hn(P,N):t,gn(e,t)}function ln(t=N){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function un(e,t){return{type:`literal`,text:e,ignoreCase:t}}function dn(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function fn(){return{type:`any`}}function pn(){return{type:`end`}}function mn(t){let n=tn[t],r;if(n)return n;if(t>=tn.length)r=tn.length-1;else for(r=t;!tn[--r];);for(n=tn[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return tn[t]=n,n}function hn(e,t,n){let i=mn(e),a=mn(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function I(e){N<nn||(N>nn&&(nn=N,rn=[]),rn.push(e))}function gn(e,t){return new lr(e,null,null,t)}function _n(e,t,n){return new lr(lr.buildMessage(e,t),e,t,n)}function vn(){let e,t,r;return e=N,t=bn(),r=yn(),r===n?(N=e,e=n):(P=e,e=Ee(t)),e}function yn(){let t,r;return t=N,F++,e.length>N?(r=e.charAt(N),N++):(r=n,F===0&&I(w)),F--,r===n?t=void 0:(N=t,t=n),t===n&&(t=N,r=Dn(),r!==n&&(P=t,r=De(r)),t=r,t===n&&(t=N,r=On(),r!==n&&(P=t,r=Oe(r)),t=r)),t}function bn(){let e,t,r;for(e=N,t=[],r=xn();r!==n;)t.push(r),r=xn();return P=e,t=ke(t),e=t,e}function xn(){let e;return e=Pn(),e===n&&(e=Fn(),e===n&&(e=Ln(),e===n&&(e=Cn(),e===n&&(e=dr(),e===n&&(e=Hn(),e===n&&(e=Sn(),e===n&&(e=In()))))))),e}function Sn(){let e,t,r,i,a,o;return e=N,t=Qn(),t===n?(N=e,e=n):(P=N,r=Ae(t),r=r?void 0:n,r===n?(N=e,e=n):(i=N,P=N,a=je(t),a=a?void 0:n,a===n?(N=i,i=n):(o=kn(),o===n?(N=i,i=n):(P=i,i=Me(t,o))),i===n&&(i=N,P=N,a=Ne(t),a=a?void 0:n,a===n?(N=i,i=n):(o=wn(),o===n?(N=i,i=n):(P=i,i=j(t,o))),i===n&&(i=N,a=``,P=i,a=Pe(t),i=a)),i===n?(N=e,e=n):(P=e,e=Fe(t,i)))),e}function Cn(){let e,t,r,i,a,o;return e=N,P=N,t=Ie(),t=t?void 0:n,t===n?(N=e,e=n):(r=fr(),r===n?(N=e,e=n):(i=N,P=N,a=Le(r),a=a?void 0:n,a===n?(N=i,i=n):(o=wn(),o===n?(N=i,i=n):(P=i,i=Re(r,o))),i===n&&(i=null),P=e,e=ze(r,i))),e}function wn(){let e,t,r,i;if(e=N,t=bn(),t!==n){for(r=[],i=Tn();i!==n;)r.push(i),i=Tn();i=En(),i===n?(N=e,e=n):(P=e,e=Be(t,r,i))}else N=e,e=n;return e}function Tn(){let e,t,r;return e=N,t=Dn(),t===n?(N=e,e=n):(r=bn(),r===n?(N=e,e=n):(P=e,e=Ve(t,r))),e}function En(){let t,r,i;return t=On(),t===n&&(t=N,r=N,F++,e.length>N?(i=e.charAt(N),N++):(i=n,F===0&&I(w)),F--,i===n?r=void 0:(N=r,r=n),r!==n&&(P=t,r=He()),t=r),t}function Dn(){let e,t,r;return e=N,t=Qn(),t===n?(N=e,e=n):(P=N,r=Ue(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=We(t))),e}function On(){let e,t,r;return e=N,t=Qn(),t===n?(N=e,e=n):(P=N,r=Ge(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=Ke(t))),e===n&&(e=N,P=N,t=qe(),t=t?void 0:n,t===n?(N=e,e=n):(r=pr(),r===n?(N=e,e=n):(P=e,e=Je(r)))),e}function kn(){let t,r,i,a,o,s,c,l;if(t=N,r=Nn(),P=N,i=Ye(r),i=i?void 0:n,i!==n){for(a=N,o=Xe(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=On(),o===n?(N=t,t=n):(P=t,t=Ze(r,a,o)))}else N=t,t=n;return t===n&&(t=N,r=``,P=t,r=Qe(),t=r),t}function An(){let e,t,r;for(e=N,t=[],r=jn();r!==n;)t.push(r),r=jn();return P=e,t=$e(t),e=t,e}function jn(){let e,t,r,i,a;return e=Pn(),e===n&&(e=Fn(),e===n&&(e=Ln(),e===n&&(e=N,P=N,t=et(),t=t?void 0:n,t===n?(N=e,e=n):(r=fr(),r===n?(N=e,e=n):(P=e,e=tt(r))),e===n&&(e=N,P=N,t=nt(),t=t?void 0:n,t===n?(N=e,e=n):(r=pr(),r===n?(N=e,e=n):(P=e,e=rt(r))),e===n&&(e=Hn(),e===n&&(e=N,t=Qn(),t===n?(N=e,e=n):(r=N,P=N,i=it(t),i=i?void 0:n,i===n?(N=r,r=n):(a=Mn(),a===n?(N=r,r=n):(P=r,r=at(t,a))),r===n&&(r=null),P=e,e=ot(t,r)),e===n&&(e=In()))))))),e}function Mn(){let t,r,i,a,o,s,c,l;if(t=N,r=Nn(),P=N,i=st(r),i=i?void 0:n,i!==n){for(a=N,o=ct(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=On(),o===n?(N=t,t=n):(P=t,t=lt(r,a,o)))}else N=t,t=n;return t}function Nn(){let e,t;return e=N,t=``,P=e,t=ut(),e=t,e}function Pn(){let t,r,i,a;if(t=N,r=N,i=[],a=e.charAt(N),o.test(a)?N++:(a=n,F===0&&I(T)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(N),o.test(a)?N++:(a=n,F===0&&I(T));else i=n;return r=i===n?i:e.substring(r,N),r!==n&&(P=t,r=dt(r)),t=r,t}function Fn(){let t,r,i,a,o;if(t=N,r=N,i=[],e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,F===0&&I(E)),a!==n)for(;a!==n;)i.push(a),e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,F===0&&I(E));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(i=N,P=N,a=ft(r),a=a?void 0:n,a===n?(N=i,i=n):(o=e.charAt(N),s.test(o)?N++:(o=n,F===0&&I(ee)),o===n?(N=i,i=n):(P=i,i=pt(r,o))),i===n&&(i=null),P=t,t=mt(r,i)),t}function In(){let t,r,i,a,o,s;return t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=N,F++,a=N,o=zn(),o===n?(N=a,a=n):(s=e.charAt(N),c.test(s)?N++:(s=n,F===0&&I(te)),s===n?(N=a,a=n):(o=[o,s],a=o)),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=t,t=n):(P=t,t=ht())),t===n&&(t=N,r=N,F++,i=N,P=N,a=gt(),a=a?void 0:n,a===n?(N=i,i=n):(o=pr(),o===n?(N=i,i=n):(a=[a,o],i=a)),F--,i===n?r=void 0:(N=r,r=n),r===n?(N=t,t=n):(e.charCodeAt(N)===60?(i=`<`,N++):(i=n,F===0&&I(ne)),i===n?(N=t,t=n):(P=t,t=_t())),t===n&&(t=N,e.charCodeAt(N)===91?(r=`[`,N++):(r=n,F===0&&I(re)),r!==n&&(P=t,r=vt()),t=r)),t}function Ln(){let t,r,i,a,o,s;return t=N,P=N,r=yt(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,F===0&&I(ie)),i===n?(N=t,t=n):(a=zn(),a===n?(N=t,t=n):(o=N,s=Rn(),o=e.substring(o,N),e.substr(N,2)===`]]`?(s=`]]`,N+=2):(s=n,F===0&&I(O)),s===n?(N=t,t=n):(P=t,t=bt(a,o))))),t===n&&(t=N,P=N,r=xt(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,F===0&&I(ie)),i===n?(N=t,t=n):(P=t,t=M()))),t}function Rn(){let t,r,i,a;for(t=[],r=N,i=N,F++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,F===0&&I(O)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,F===0&&I(ie))),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,F===0&&I(w)),a===n?(N=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=N,i=N,F++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,F===0&&I(O)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,F===0&&I(ie))),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,F===0&&I(w)),a===n?(N=r,r=n):(i=[i,a],r=i));return t}function zn(){let t,r,i;if(t=N,r=[],i=Bn(),i!==n)for(;i!==n;)r.push(i),i=Bn();else r=n;return r===n?(N=t,t=n):(e.charCodeAt(N)===32?(i=` `,N++):(i=n,F===0&&I(ae)),i===n&&(i=null),P=t,t=St(r)),t===n&&(t=N,r=``,P=t,r=Ct(),t=r),t}function Bn(){let t,r,i,a,o;if(t=N,r=e.charAt(N),l.test(r)?N++:(r=n,F===0&&I(oe)),r!==n){for(i=N,a=[],o=Vn();o!==n;)a.push(o),o=Vn();i=e.substring(i,N),P=t,t=wt(r,i)}else N=t,t=n;return t}function Vn(){let t,r,i,a,o;if(t=e.charAt(N),u.test(t)?N++:(t=n,F===0&&I(se)),t===n)if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r!==n)if(i=e.charAt(N),d.test(i)?N++:(i=n,F===0&&I(ce)),i!==n){for(a=[],o=e.charAt(N),f.test(o)?N++:(o=n,F===0&&I(le));o!==n;)a.push(o),o=e.charAt(N),f.test(o)?N++:(o=n,F===0&&I(le));e.charCodeAt(N)===125?(o=`}`,N++):(o=n,F===0&&I(ue)),o===n?(N=t,t=n):(r=[r,i,a,o],t=r)}else N=t,t=n;else N=t,t=n;return t}function Hn(){let t,r,i,a,o,s,c;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r!==n)if(i=zn(),i!==n)if(a=e.charAt(N),d.test(a)?N++:(a=n,F===0&&I(ce)),a!==n){for(o=N,s=[],c=e.charAt(N),f.test(c)?N++:(c=n,F===0&&I(le));c!==n;)s.push(c),c=e.charAt(N),f.test(c)?N++:(c=n,F===0&&I(le));o=e.substring(o,N),e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(ue)),s===n?(N=t,t=n):(P=t,t=Tt(i,a,o))}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=zn(),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),p.test(o)?N++:(o=n,F===0&&I(de)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=Yn(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(ue)),s===n?(N=t,t=n):(P=t,t=Et(i,o)))))),t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=zn(),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),p.test(o)?N++:(o=n,F===0&&I(de)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(P=t,t=Dt()))))),t}function Yn(){let t,r,i,a,o,s,c,l;if(t=N,r=Nn(),P=N,i=Ot(r),i=i?void 0:n,i!==n){for(a=N,o=kt(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(P=t,t=At(r,a))}else N=t,t=n;return t}function Qn(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r!==n)if(i=zn(),i!==n)if(a=Nn(),e.charCodeAt(N)===47?(o=`/`,N++):(o=n,F===0&&I(fe)),o===n&&(o=null),s=ur(),s!==n){if(c=Nn(),l=N,P=N,u=jt(i,a,o,s,c),u=u?void 0:n,u!==n){for(d=N,f=Mt(i,a,o,s,c),p=N,m=[],m.length>=(f|0)?h=n:e.length>N?(h=e.charAt(N),N++):(h=n,F===0&&I(w));h!==n;)m.push(h),m.length>=(f|0)?h=n:e.length>N?(h=e.charAt(N),N++):(h=n,F===0&&I(w));m.length<(f|0)?(N=p,p=n):p=m,f=p,d=f===n?f:e.substring(d,N),d===n?(N=l,l=n):(e.charCodeAt(N)===125?(f=`}`,N++):(f=n,F===0&&I(ue)),f===n?(N=l,l=n):(P=l,l=Nt(i,a,o,s,c,d)))}else N=l,l=n;l===n&&(l=null),P=t,t=Pt(i,a,o,s,c,l)}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=zn(),i===n?(N=t,t=n):(e.charCodeAt(N)===47?(a=`/`,N++):(a=n,F===0&&I(fe)),a===n?(N=t,t=n):(P=t,t=Ft(i))))),t}function ur(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),m.test(i)?N++:(i=n,F===0&&I(pe)),i!==n){for(a=[],o=e.charAt(N),h.test(o)?N++:(o=n,F===0&&I(me));o!==n;)a.push(o),o=e.charAt(N),h.test(o)?N++:(o=n,F===0&&I(me));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function dr(){let e,t,r,i;return e=N,P=N,t=It(),t=t?void 0:n,t===n?(N=e,e=n):(r=pr(),r===n?(N=e,e=n):(P=N,i=Lt(r),i=i?void 0:n,i===n?(N=e,e=n):(P=e,e=Rt(r)))),e}function fr(){let t,r,i,a,o,s,c;if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,F===0&&I(ne)),r!==n)if(i=mr(),i!==n){for(a=[],o=hr();o!==n;)a.push(o),o=hr();o=vr(),e.charCodeAt(N)===47?(s=`/`,N++):(s=n,F===0&&I(fe)),s===n&&(s=null),e.charCodeAt(N)===62?(c=`>`,N++):(c=n,F===0&&I(he)),c===n?(N=t,t=n):(P=t,t=zt(i,a,s))}else N=t,t=n;else N=t,t=n;if(t===n)if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,F===0&&I(ne)),r!==n)if(i=mr(),i!==n)if(a=N,F++,o=e.charAt(N),g.test(o)?N++:(o=n,F===0&&I(ge)),o===n&&(o=N,F++,e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(w)),F--,s===n?o=void 0:(N=o,o=n)),F--,o===n?a=n:(N=a,a=void 0),a!==n){for(o=[],s=hr();s!==n;)o.push(s),s=hr();s=vr(),c=Nn(),P=t,t=Bt(i,c)}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t}function pr(){let t,r,i,a;return t=N,e.substr(N,2)===`</`?(r=`</`,N+=2):(r=n,F===0&&I(_e)),r===n?(N=t,t=n):(i=mr(),i===n?(N=t,t=n):(vr(),e.charCodeAt(N)===62?(a=`>`,N++):(a=n,F===0&&I(he)),a===n?(N=t,t=n):(P=t,t=Vt(i)))),t}function mr(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),m.test(i)?N++:(i=n,F===0&&I(pe)),i!==n){for(a=[],o=e.charAt(N),_.test(o)?N++:(o=n,F===0&&I(ve));o!==n;)a.push(o),o=e.charAt(N),_.test(o)?N++:(o=n,F===0&&I(ve));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function hr(){let t,r,i,a,o,s,c;if(t=N,vr(),r=N,i=[],a=N,o=N,F++,s=e.charAt(N),v.test(s)?N++:(s=n,F===0&&I(k)),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=a,a=n):(e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(w)),s===n?(N=a,a=n):(o=[o,s],a=o)),a!==n)for(;a!==n;)i.push(a),a=N,o=N,F++,s=e.charAt(N),v.test(s)?N++:(s=n,F===0&&I(k)),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=a,a=n):(e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(w)),s===n?(N=a,a=n):(o=[o,s],a=o));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(P=N,i=Ht(r),i=i?void 0:n,i===n?(N=t,t=n):(a=N,o=vr(),e.charCodeAt(N)===61?(s=`=`,N++):(s=n,F===0&&I(ye)),s===n?(N=a,a=n):(vr(),c=gr(),c===n?(N=a,a=n):(P=a,a=Ut(r,c))),a===n&&(a=null),P=t,t=Wt(r,a))),t}function gr(){let t,r,i,a,o;if(t=N,e.charCodeAt(N)===34?(r=`\"`,N++):(r=n,F===0&&I(be)),r!==n){for(i=N,a=[],o=_r(),o===n&&(o=e.charAt(N),y.test(o)?N++:(o=n,F===0&&I(xe)));o!==n;)a.push(o),o=_r(),o===n&&(o=e.charAt(N),y.test(o)?N++:(o=n,F===0&&I(xe)));i=e.substring(i,N),e.charCodeAt(N)===34?(a=`\"`,N++):(a=n,F===0&&I(be)),a===n?(N=t,t=n):(P=t,t=Gt(i))}else N=t,t=n;if(t===n){if(t=N,e.charCodeAt(N)===39?(r=`'`,N++):(r=n,F===0&&I(Se)),r!==n){for(i=N,a=[],o=_r(),o===n&&(o=e.charAt(N),b.test(o)?N++:(o=n,F===0&&I(A)));o!==n;)a.push(o),o=_r(),o===n&&(o=e.charAt(N),b.test(o)?N++:(o=n,F===0&&I(A)));i=e.substring(i,N),e.charCodeAt(N)===39?(a=`'`,N++):(a=n,F===0&&I(Se)),a===n?(N=t,t=n):(P=t,t=Kt(i))}else N=t,t=n;if(t===n&&(t=N,r=e.charAt(N),x.test(r)?N++:(r=n,F===0&&I(Ce)),r!==n&&(P=t,r=qt(r)),t=r,t===n)){for(t=N,r=[],i=e.charAt(N),S.test(i)?N++:(i=n,F===0&&I(we));i!==n;)r.push(i),i=e.charAt(N),S.test(i)?N++:(i=n,F===0&&I(we));t=e.substring(t,N)}}return t}function _r(){let t,r,i,a,o,c,l,u,f,p,h,g,_,v;if(t=N,P=N,r=Jt(),r=r?void 0:n,r!==n){if(i=N,a=[],e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,F===0&&I(E)),o!==n)for(;o!==n;)a.push(o),e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,F===0&&I(E));else a=n;i=a===n?a:e.substring(i,N),i===n?(N=t,t=n):(a=N,P=N,o=Yt(i),o=o?void 0:n,o===n?(N=a,a=n):(c=e.charAt(N),s.test(c)?N++:(c=n,F===0&&I(ee)),c===n?(N=a,a=n):(o=[o,c],a=o)),a===n&&(a=null),r=[r,i,a],t=r)}else N=t,t=n;if(t===n){if(t=N,P=N,r=Xt(),r=r?void 0:n,r!==n)if(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(D)),i!==n)if(a=zn(),a!==n)if(o=Nn(),e.charCodeAt(N)===47?(c=`/`,N++):(c=n,F===0&&I(fe)),c===n&&(c=null),l=ur(),l!==n)if(u=Nn(),P=N,f=Zt(o,u),f=f?void 0:n,f!==n){for(p=N,h=Qt(o,u),g=N,_=[],_.length>=(h|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,F===0&&I(w));v!==n;)_.push(v),_.length>=(h|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,F===0&&I(w));_.length<(h|0)?(N=g,g=n):g=_,h=g,p=h===n?h:e.substring(p,N),p===n?(N=t,t=n):(e.charCodeAt(N)===125?(h=`}`,N++):(h=n,F===0&&I(ue)),h===n?(N=t,t=n):(r=[r,i,a,o,c,l,u,f,p,h],t=r))}else N=t,t=n;else N=t,t=n;else N=t,t=n;else N=t,t=n;else N=t,t=n;t===n&&(t=N,P=N,r=$t(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(D)),i===n?(N=t,t=n):(a=zn(),a===n?(N=t,t=n):(o=N,F++,c=N,e.charCodeAt(N)===47?(l=`/`,N++):(l=n,F===0&&I(fe)),l===n&&(l=null),u=e.charAt(N),m.test(u)?N++:(u=n,F===0&&I(pe)),u===n?(N=c,c=n):(l=[l,u],c=l),F--,c===n?o=void 0:(N=o,o=n),o===n?(N=t,t=n):(c=Yn(),c===n?(N=t,t=n):(e.charCodeAt(N)===125?(l=`}`,N++):(l=n,F===0&&I(ue)),l===n?(N=t,t=n):(r=[r,i,a,o,c,l],t=r)))))),t===n&&(t=N,P=N,r=en(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(D)),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),d.test(o)?N++:(o=n,F===0&&I(ce)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=Yn(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(c=`}`,N++):(c=n,F===0&&I(ue)),c===n?(N=t,t=n):(r=[r,i,a,o,c],t=r)))))))}return t}function vr(){let e,t;for(e=[],t=yr();t!==n;)e.push(t),t=yr();return e}function yr(){let t;return t=e.charAt(N),C.test(t)?N++:(t=n,F===0&&I(Te)),t}let br=t.text===!0,xr=t.hooks,Sr=-1,Cr=!1,wr=``;function Tr(e){return Sr=e,e>=0}function Er(e,t){cn(e,t)}function Dr(e){let t={},n=new Set;for(let[r,i]of e){let e=r.toLowerCase();n.has(e)||(n.add(e),Object.defineProperty(t,r,{value:i,enumerable:!0,writable:!0,configurable:!0}))}return t}function Or(e,t){for(let n of t.branches){let t=qn[n.tag.lower];(e.lex!==`macro`||e.lower!==t)&&Er(tr(n.tag)+` must be directly inside {`+t+Wn+`, not inside `+tr(e),n.tag.loc)}t.end||Er(`Unclosed `+tr(e)+`: no `+nr(e)+` closes it`,e.loc),ir(e,t.end)||Er(tr(t.end)+` found where `+nr(e)+` should close the `+tr(e)+` opened at `+rr(e.loc),t.end.loc)}function kr(e,t){let n={type:`macro`,name:e.lower,rawArgs:e.rawArgs,children:[]};if(!t)return $n(n,e);if(Or(e,t),n.children=t.children,Jn.has(e.lower)){n.branches=[$n({rawArgs:e.rawArgs,children:t.children},e)];for(let e of t.branches)n.branches.push($n({rawArgs:e.tag.rawArgs,children:e.children},e.tag));n.children=[]}else $n(n,e);return n}an=a();let Ar=an!==n&&N===e.length;function jr(){throw an!==n&&N<e.length&&I(pn()),_n(rn,nn<e.length?ln(nn):null,nn<e.length?hn(nn,nn+1):hn(nn,nn))}if(t.peg$library)return{peg$result:an,peg$currPos:N,peg$FAILED:n,peg$maxFailExpected:rn,peg$maxFailPos:nn,peg$success:Ar,peg$throw:Ar?void 0:jr};if(Ar)return an;jr()}var dr=class extends Map{get(e){return super.get(e.toLowerCase())}set(e,t){return super.set(e.toLowerCase(),t)}has(e){return super.has(e.toLowerCase())}delete(e){return super.delete(e.toLowerCase())}},fr=class{constructor(e=[]){this.names=new dr;for(let t of e)this.add(t)}add(e){this.names.set(e,!0)}has(e){return this.names.has(e)}delete(e){this.names.delete(e)}},pr=new fr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]);function mr(e){return pr.has(e)}function hr(e){pr.add(e)}var gr={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},_r=Object.fromEntries(Object.entries(gr).map(([e,t])=>[t,e])),vr=new Set(Object.keys(gr));function yr(e){return e!==void 0&&vr.has(e)}var br=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],xr=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],Sr=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Cr=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ-ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,wr={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},Tr=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,Er={5:Tr,\"5module\":Tr+` export import`,6:Tr+` const class extends export import super`},Dr=/^in(stanceof)?$/,Or=RegExp(`[`+Cr+`]`),kr=RegExp(`[`+Cr+Sr+`]`);function Ar(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function jr(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Or.test(String.fromCharCode(e)):t===!1?!1:Ar(e,xr)}function Mr(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&kr.test(String.fromCharCode(e)):t===!1?!1:Ar(e,xr)||Ar(e,br)}var L=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function Nr(e,t){return new L(e,{beforeExpr:!0,binop:t})}var Pr={beforeExpr:!0},Fr={startsExpr:!0},Ir={};function R(e,t){return t===void 0&&(t={}),t.keyword=e,Ir[e]=new L(e,t)}var z={num:new L(`num`,Fr),regexp:new L(`regexp`,Fr),string:new L(`string`,Fr),name:new L(`name`,Fr),privateId:new L(`privateId`,Fr),eof:new L(`eof`),bracketL:new L(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new L(`]`),braceL:new L(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new L(`}`),parenL:new L(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new L(`)`),comma:new L(`,`,Pr),semi:new L(`;`,Pr),colon:new L(`:`,Pr),dot:new L(`.`),question:new L(`?`,Pr),questionDot:new L(`?.`),arrow:new L(`=>`,Pr),template:new L(`template`),invalidTemplate:new L(`invalidTemplate`),ellipsis:new L(`...`,Pr),backQuote:new L(\"`\",Fr),dollarBraceL:new L(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new L(`=`,{beforeExpr:!0,isAssign:!0}),assign:new L(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new L(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new L(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Nr(`||`,1),logicalAND:Nr(`&&`,2),bitwiseOR:Nr(`|`,3),bitwiseXOR:Nr(`^`,4),bitwiseAND:Nr(`&`,5),equality:Nr(`==/!=/===/!==`,6),relational:Nr(`</>/<=/>=`,7),bitShift:Nr(`<</>>/>>>`,8),plusMin:new L(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Nr(`%`,10),star:Nr(`*`,10),slash:Nr(`/`,10),starstar:new L(`**`,{beforeExpr:!0}),coalesce:Nr(`??`,1),_break:R(`break`),_case:R(`case`,Pr),_catch:R(`catch`),_continue:R(`continue`),_debugger:R(`debugger`),_default:R(`default`,Pr),_do:R(`do`,{isLoop:!0,beforeExpr:!0}),_else:R(`else`,Pr),_finally:R(`finally`),_for:R(`for`,{isLoop:!0}),_function:R(`function`,Fr),_if:R(`if`),_return:R(`return`,Pr),_switch:R(`switch`),_throw:R(`throw`,Pr),_try:R(`try`),_var:R(`var`),_const:R(`const`),_while:R(`while`,{isLoop:!0}),_with:R(`with`),_new:R(`new`,{beforeExpr:!0,startsExpr:!0}),_this:R(`this`,Fr),_super:R(`super`,Fr),_class:R(`class`,Fr),_extends:R(`extends`,Pr),_export:R(`export`),_import:R(`import`,Fr),_null:R(`null`,Fr),_true:R(`true`,Fr),_false:R(`false`,Fr),_in:R(`in`,{beforeExpr:!0,binop:7}),_instanceof:R(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:R(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:R(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:R(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Lr=/\\r\\n?|\\n|\\u2028|\\u2029/,Rr=new RegExp(Lr.source,`g`);function zr(e){return e===10||e===13||e===8232||e===8233}function Br(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(zr(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Vr=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,Hr=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,Ur=Object.prototype,Wr=Ur.hasOwnProperty,Gr=Ur.toString,Kr=Object.hasOwn||(function(e,t){return Wr.call(e,t)}),qr=Array.isArray||(function(e){return Gr.call(e)===`[object Array]`}),Jr=Object.create(null);function Yr(e){return Jr[e]||(Jr[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function Xr(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Zr=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,Qr=function(e,t){this.line=e,this.column=t};Qr.prototype.offset=function(e){return new Qr(this.line,this.column+e)};var $r=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ei(e,t){for(var n=1,r=0;;){var i=Br(e,r,t);if(i<0)return new Qr(n,t-r);++n,r=i}}var ti={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ni=!1;function ri(e){var t={};for(var n in ti)t[n]=e&&Kr(e,n)?e[n]:ti[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ni&&typeof console==`object`&&console.warn&&(ni=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),qr(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(qr(t.onComment)&&(t.onComment=ii(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function ii(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new $r(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var ai=1,oi=2,si=4,ci=8,li=16,ui=32,di=64,fi=128,pi=256,mi=512,hi=1024,gi=ai|oi|pi;function _i(e,t){return oi|(e?si:0)|(t?ci:0)}var vi=0,yi=1,bi=2,xi=3,Si=4,Ci=5,wi=function(e,t,n){this.options=e=ri(e),this.sourceFile=e.sourceFile,this.keywords=Yr(Er[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=wr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=Yr(r);var i=(r?r+` `:``)+wr.strict;this.reservedWordsStrict=Yr(i),this.reservedWordsStrictBind=Yr(i+` `+wr.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`\n`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(Lr).length)):this.lineStart=0,this.type=z.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?oi:ai),this.regexpState=null,this.privateNameStack=[]},Ti={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};wi.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Ti.inFunction.get=function(){return(this.currentVarScope().flags&oi)>0},Ti.inGenerator.get=function(){return(this.currentVarScope().flags&ci)>0},Ti.inAsync.get=function(){return(this.currentVarScope().flags&si)>0},Ti.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(pi|mi))return!1;if(t&oi)return(t&si)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ti.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&ai)},Ti.allowSuper.get=function(){return(this.currentThisScope().flags&di)>0||this.options.allowSuperOutsideMethod},Ti.allowDirectSuper.get=function(){return(this.currentThisScope().flags&fi)>0},Ti.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ti.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(pi|mi)||t&oi&&!(t&li))return!0}return!1},Ti.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&hi||!this.inModule&&e&ai)},Ti.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&pi)>0},wi.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},wi.parse=function(e,t){return new this(t,e).parse()},wi.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},wi.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(wi.prototype,Ti);var Ei=wi.prototype,Di=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;Ei.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){Hr.lastIndex=e,e+=Hr.exec(this.input)[0].length;var t=Di.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){Hr.lastIndex=e+t[0].length;var n=Hr.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Lr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Oi(this,r))}e+=t[0].length,Hr.lastIndex=e,e+=Hr.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Oi(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Mr(i,!0))break;n+=i<=65535?1:2}return n===t+2&&e.input.slice(t,n)===`in`||n===t+10&&e.input.slice(t,n)===`instanceof`}Ei.eat=function(e){return this.type===e?(this.next(),!0):!1},Ei.isContextual=function(e){return this.type===z.name&&this.value===e&&!this.containsEsc},Ei.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},Ei.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\\bstack\\b.*\\b(exceeded|overflow)\\b/i.test(e.message)||/\\btoo much recursion\\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},Ei.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Ei.canInsertSemicolon=function(){return this.type===z.eof||this.type===z.braceR||Lr.test(this.input.slice(this.lastTokEnd,this.start))},Ei.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ei.semicolon=function(){!this.eat(z.semi)&&!this.insertSemicolon()&&this.unexpected()},Ei.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Ei.expect=function(e){this.eat(e)||this.unexpected()},Ei.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var ki=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ei.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},Ei.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},Ei.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},Ei.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var B=wi.prototype;B.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==z.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Ai={kind:`loop`},ji={kind:`switch`};B.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;Hr.lastIndex=this.pos;var t=Hr.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(jr(r)){var i=n;do n+=r<=65535?1:2;while(Mr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Dr.test(a))return!0}return!1},B.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;Hr.lastIndex=this.pos;var e=Hr.exec(this.input),t=this.pos+e[0].length,n;return!Lr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Mr(n=this.fullCharCodeAt(t+8))||n===92))},B.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;Hr.lastIndex=this.pos;var n=Hr.exec(this.input),r=this.pos+n[0].length;if(Lr.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||Mr(a=this.fullCharCodeAt(i))||a===92)return!1;Hr.lastIndex=i;var o=Hr.exec(this.input);if(r=i+o[0].length,o&&Lr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!jr(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Mr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Dr.test(l))return!1;if(t&&!e&&l===`of`){Hr.lastIndex=r;var u=Hr.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},B.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},B.isUsing=function(e){return this.isUsingKeyword(!1,e)},B.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=z._var,a=`let`),r){case z._break:case z._continue:return this.parseBreakContinueStatement(i,r.keyword);case z._debugger:return this.parseDebuggerStatement(i);case z._do:return this.parseDoStatement(i);case z._for:return this.parseForStatement(i);case z._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case z._class:return e&&this.unexpected(),this.parseClass(i,!0);case z._if:return this.parseIfStatement(i);case z._return:return this.parseReturnStatement(i);case z._switch:return this.parseSwitchStatement(i);case z._throw:return this.parseThrowStatement(i);case z._try:return this.parseTryStatement(i);case z._const:case z._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case z._while:return this.parseWhileStatement(i);case z._with:return this.parseWithStatement(i);case z.braceL:return this.parseBlock(!0,i);case z.semi:return this.parseEmptyStatement(i);case z._export:case z._import:if(this.options.ecmaVersion>10&&r===z._import){Hr.lastIndex=this.pos;var o=Hr.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===z._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,\"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement\"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===z.name&&d.type===`Identifier`&&this.eat(z.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},B.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(z.semi)||this.insertSemicolon()?e.label=null:this.type===z.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},B.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},B.parseDoStatement=function(e){return this.next(),this.labels.push(Ai),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(z._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(z.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},B.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Ai),this.enterScope(0),this.expect(z.parenL),this.type===z.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===z._var||this.type===z._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new ki,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===z._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===z._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},B.parseForAfterInit=function(e,t,n){return(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===z._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},B.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ni|(n?0:Pi),!1,t)},B.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(z._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},B.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(z.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},B.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(z.braceL),this.labels.push(ji),this.enterScope(hi);for(var t,n=!1;this.type!==z.braceR;)if(this.type===z._case||this.type===z._default){var r=this.type===z._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(z.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},B.parseThrowStatement=function(e){return this.next(),Lr.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var Mi=[];B.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?ui:0),this.checkLValPattern(e,t?Si:bi),this.expect(z.parenR),e},B.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===z._catch){var t=this.startNode();this.next(),this.eat(z.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(z._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},B.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},B.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Ai),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},B.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},B.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},B.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===z._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},B.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},B.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(z.braceL),e&&this.enterScope(0);this.type!==z.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},B.parseFor=function(e,t){return e.init=t,this.expect(z.semi),e.test=this.type===z.semi?null:this.parseExpression(),this.expect(z.semi),e.update=this.type===z.parenR?null:this.parseExpression(),this.expect(z.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},B.parseForIn=function(e,t){var n=this.type===z._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(z.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},B.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(z.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==z._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===z._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(z.comma))break}return e},B.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?yi:bi,!1)};var Ni=1,Pi=2,Fi=4;B.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===z.star&&t&Pi&&this.unexpected(),e.generator=this.eat(z.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ni&&(e.id=t&Fi&&this.type!==z.name?null:this.parseIdent(),e.id&&!(t&Pi)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?yi:bi:xi));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(_i(e.async,e.generator)),t&Ni||(e.id=this.type===z.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Ni?`FunctionDeclaration`:`FunctionExpression`)},B.parseFunctionParams=function(e){this.expect(z.parenL),e.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},B.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(z.braceL);this.type!==z.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Ii(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},B.parseClassElement=function(e){if(this.eat(z.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(z.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===z.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===z.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(z.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===z.parenL||o!==`method`||i||a){var l=!n.static&&Li(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},B.isClassElementNameStart=function(){return this.type===z.name||this.type===z.privateId||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword},B.parseClassElementName=function(e){this.type===z.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},B.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Li(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},B.parseClassField=function(e){return Li(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Li(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(z.eq)?(this.enterScope(mi|di),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},B.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(pi|di);this.type!==z.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},B.parseClassId=function(e,t){this.type===z.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,bi,!1)):(t===!0&&this.unexpected(),e.id=null)},B.parseClassSuper=function(e){e.superClass=this.eat(z._extends)?this.parseExprSubscripts(null,!1):null},B.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},B.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];Kr(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Ii(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function Li(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}B.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==z.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},B.parseExport=function(e,t){if(this.next(),this.eat(z.star))return this.parseExportAllDeclaration(e,t);if(this.eat(z._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==z.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,\"A string literal cannot be used as an exported binding without `from`.\")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},B.parseExportDeclaration=function(e){return this.parseStatement(null)},B.parseExportDefaultDeclaration=function(){var e;if(this.type===z._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ni|Fi,!1,e)}else if(this.type===z._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},B.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Kr(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},B.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},B.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},B.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},B.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},B.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(z.braceL);!this.eat(z.braceR);){if(n)n=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;t.push(this.parseExportSpecifier(e))}return t},B.parseImport=function(e){return this.next(),this.type===z.string?(e.specifiers=Mi,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===z.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},B.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,bi),this.finishNode(e,`ImportSpecifier`)},B.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,bi),this.finishNode(e,`ImportDefaultSpecifier`)},B.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,bi),this.finishNode(e,`ImportNamespaceSpecifier`)},B.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===z.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(z.comma)))return e;if(this.type===z.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(z.braceL);!this.eat(z.braceR);){if(t)t=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;e.push(this.parseImportSpecifier())}return e},B.parseWithClause=function(){var e=[];if(!this.eat(z._with))return e;this.expect(z.braceL);for(var t={},n=!0;!this.eat(z.braceR);){if(n)n=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Kr(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},B.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(z.colon),this.type!==z.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},B.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===z.string){var e=this.parseLiteral(this.value);return Zr.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},B.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},B.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`\"`||this.input[e.start]===`'`)};var Ri=wi.prototype;Ri.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},Ri.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},Ri.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Ri.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==z.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Ri.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case z.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(z.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case z.braceL:return this.parseObj(!0)}return this.parseIdent()},Ri.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(z.comma),t&&this.type===z.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===z.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},Ri.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Ri.parseBindingListItem=function(e){return e},Ri.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(z.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Ri.checkLValSimple=function(e,t,n){t===void 0&&(t=vi);var r=t!==vi;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===bi&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Kr(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Ci&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},Ri.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=vi),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},Ri.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=vi),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var zi=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},V={b_stat:new zi(`{`,!1),b_expr:new zi(`{`,!0),b_tmpl:new zi(\"${\",!1),p_stat:new zi(`(`,!1),p_expr:new zi(`(`,!0),q_tmpl:new zi(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new zi(`function`,!1),f_expr:new zi(`function`,!0),f_expr_gen:new zi(`function`,!0,!1,null,!0),f_gen:new zi(`function`,!1,!1,null,!0)},Bi=wi.prototype;Bi.initialContext=function(){return[V.b_stat]},Bi.curContext=function(){return this.context[this.context.length-1]},Bi.braceIsBlock=function(e){var t=this.curContext();return t===V.f_expr||t===V.f_stat?!0:e===z.colon&&(t===V.b_stat||t===V.b_expr)?!t.isExpr:e===z._return||e===z.name&&this.exprAllowed?Lr.test(this.input.slice(this.lastTokEnd,this.start)):e===z._else||e===z.semi||e===z.eof||e===z.parenR||e===z.arrow?!0:e===z.braceL?t===V.b_stat:e===z._var||e===z._const||e===z.name?!1:!this.exprAllowed},Bi.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},Bi.updateContext=function(e){var t,n=this.type;n.keyword&&e===z.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Bi.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},z.parenR.updateContext=z.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===V.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},z.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?V.b_stat:V.b_expr),this.exprAllowed=!0},z.dollarBraceL.updateContext=function(){this.context.push(V.b_tmpl),this.exprAllowed=!0},z.parenL.updateContext=function(e){var t=e===z._if||e===z._for||e===z._with||e===z._while;this.context.push(t?V.p_stat:V.p_expr),this.exprAllowed=!0},z.incDec.updateContext=function(){},z._function.updateContext=z._class.updateContext=function(e){e.beforeExpr&&e!==z._else&&!(e===z.semi&&this.curContext()!==V.p_stat)&&!(e===z._return&&Lr.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===z.colon||e===z.braceL)&&this.curContext()===V.b_stat)?this.context.push(V.f_expr):this.context.push(V.f_stat),this.exprAllowed=!1},z.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},z.backQuote.updateContext=function(){this.curContext()===V.q_tmpl?this.context.pop():this.context.push(V.q_tmpl),this.exprAllowed=!1},z.star.updateContext=function(e){if(e===z._function){var t=this.context.length-1;this.context[t]===V.f_expr?this.context[t]=V.f_expr_gen:this.context[t]=V.f_gen}this.exprAllowed=!0},z.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==z.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var H=wi.prototype;H.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},H.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===z.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(z.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},H.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new ki,r=!0);var s=this.start,c=this.startLoc;(this.type===z.parenL||this.type===z.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===z.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===z.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},H.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(!(i.type===`ArrowFunctionExpression`&&i.start===n)&&this.eat(z.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(z.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},H.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},H.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==z._in)&&a>r){var o=this.type===z.logicalOR||this.type===z.logicalAND,s=this.type===z.coalesce;s&&(a=z.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===z.coalesce||s&&(this.type===z.logicalOR||this.type===z.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},H.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},H.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===z.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&Vi(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Hi(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===z.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==z._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&!(o.type===`ArrowFunctionExpression`&&o.start===i)&&this.eat(z.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function Vi(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Vi(e.expression)}function Hi(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Hi(e.expression)||e.type===`ParenthesizedExpression`&&Hi(e.expression)}H.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},H.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},H.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(z.arrow)},H.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},H.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(z.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(z.bracketL);if(l||c&&this.type!==z.parenL&&this.type!==z.backQuote||this.eat(z.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(z.bracketR)):this.type===z.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(z.parenL)){var d=new ki,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===z.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},H.parseExprAtom=function(e,t,n){this.type===z.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case z._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===z.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==z.dot&&this.type!==z.bracketL&&this.type!==z.parenL&&this.unexpected(),this.finishNode(r,`Super`);case z._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case z.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(z._function))return this.overrideContext(V.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(z.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===z.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(z.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case z.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case z.num:case z.string:return this.parseLiteral(this.value);case z._null:case z._true:case z._false:return r=this.startNode(),r.value=this.type===z._null?null:this.type===z._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case z.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case z.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(z.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case z.braceL:return this.overrideContext(V.b_expr),this.parseObj(!1,e);case z._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case z._class:return this.parseClass(this.startNode(),!1);case z._new:return this.parseNew();case z.backQuote:return this.parseTemplate();case z._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},H.parseExprAtomDefault=function(){this.unexpected()},H.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===z.parenL&&!e)return this.parseDynamicImport(t);if(this.type===z.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}else this.unexpected()},H.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(z.parenR)?e.options=null:(this.expect(z.comma),this.afterTrailingComma(z.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(z.parenR)||(this.expect(z.comma),this.afterTrailingComma(z.parenR)||this.unexpected())));else if(!this.eat(z.parenR)){var t=this.start;this.eat(z.comma)&&this.eat(z.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},H.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},H.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},H.parseParenExpression=function(){this.expect(z.parenL);var e=this.parseExpression();return this.expect(z.parenR),e},H.shouldParseArrow=function(e){return!this.canInsertSemicolon()},H.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new ki,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==z.parenR;)if(l?l=!1:this.expect(z.comma),a&&this.afterTrailingComma(z.parenR,!0)){u=!0;break}else if(this.type===z.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(z.parenR),e&&this.shouldParseArrow(c)&&this.eat(z.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}else return i},H.parseParenItem=function(e){return e},H.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Ui=[];H.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===z.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),this.eat(z.parenL)?e.arguments=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ui,this.finishNode(e,`NewExpression`)},H.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===z.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\\r\\n?/g,`\n`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\\r\\n?/g,`\n`),cooked:this.value},this.next(),n.tail=this.type===z.backQuote,this.finishNode(n,`TemplateElement`)},H.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===z.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(z.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(z.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},H.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===z.name||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===z.star)&&!Lr.test(this.input.slice(this.lastTokEnd,this.start))},H.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(z.braceR);){if(r)r=!1;else if(this.expect(z.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(z.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},H.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(z.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===z.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(z.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(z.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},H.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},H.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===z.colon&&this.unexpected(),this.eat(z.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===z.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==z.comma&&this.type!==z.braceR&&this.type!==z.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===z.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},H.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(z.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(z.bracketR),e.key;e.computed=!1}return e.key=this.type===z.num||this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},H.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},H.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(_i(t,r.generator)|di|(n?fi:0)),this.expect(z.parenL),r.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},H.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(_i(n,!1)|li),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},H.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==z.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Ci),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},H.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},H.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,yi,t?null:n)}},H.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(z.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===z.comma?o=null:this.type===z.ellipsis?(o=this.parseSpread(r),r&&this.type===z.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},H.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&gi)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},H.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},H.parseIdentNode=function(){var e=this.startNode();return this.type===z.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=z.name):this.unexpected(),e},H.parsePrivateIdent=function(){var e=this.startNode();return this.type===z.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},H.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===z.semi||this.canInsertSemicolon()||this.type!==z.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(z.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},H.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var Wi=wi.prototype;Wi.raise=function(e,t){var n=ei(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},Wi.raiseRecoverable=Wi.raise,Wi.curPosition=function(){if(this.options.locations)return new Qr(this.curLine,this.pos-this.lineStart)};var Gi=wi.prototype,Ki=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Gi.enterScope=function(e){this.scopeStack.push(new Ki(e))},Gi.exitScope=function(){this.scopeStack.pop()},Gi.treatFunctionsAsVarInScope=function(e){return e.flags&oi||!this.inModule&&e.flags&ai},Gi.declareName=function(e,t,n){var r=!1;if(t===bi){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&ai&&delete this.undefinedExports[e]}else if(t===Si)this.currentScope().lexical.push(e);else if(t===xi){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&ui&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&ai&&delete this.undefinedExports[e],s.flags&gi)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Gi.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Gi.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Gi.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(gi|mi|pi))return t}},Gi.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(gi|mi|pi)&&!(t.flags&li))return t}};var qi=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new $r(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ji=wi.prototype;Ji.startNode=function(){return new qi(this,this.start,this.startLoc)},Ji.startNodeAt=function(e,t){return new qi(this,e,t)};function Yi(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Ji.finishNode=function(e,t){return Yi.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Ji.finishNodeAt=function(e,t,n,r){return Yi.call(this,e,t,n,r)},Ji.copyNode=function(e){var t=new qi(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Xi=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,Zi=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,Qi=Zi+` Extended_Pictographic`,$i=Qi,ea=$i+` EBase EComp EMod EPres ExtPict`,ta=ea,na=ta,ra={9:Zi,10:Qi,11:$i,12:ea,13:ta,14:na},ia=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,aa={9:``,10:``,11:``,12:``,13:``,14:ia},oa=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,sa=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,ca=sa+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,la=ca+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,ua=la+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,da=ua+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,fa=da+` `+Xi,pa={9:sa,10:ca,11:la,12:ua,13:da,14:fa},ma={};function ha(e){var t=ma[e]={binary:Yr(ra[e]+` `+oa),binaryOfStrings:Yr(aa[e]),nonBinary:{General_Category:Yr(oa),Script:Yr(pa[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var ga=0,_a=[9,10,11,12,13,14];ga<_a.length;ga+=1){var va=_a[ga];ha(va)}var U=wi.prototype,ya=function(e,t){this.parent=e,this.base=t||this};ya.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},ya.prototype.sibling=function(){return new ya(this.parent,this.base)};var ba=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=ma[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ba.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},ba.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},ba.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},ba.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},ba.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},ba.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},ba.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},ba.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},ba.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},U.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function xa(e){for(var t in e)return!0;return!1}U.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&xa(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},U.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},U.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ya(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},U.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},U.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},U.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},U.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},U.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},U.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},U.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},U.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},U.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},U.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},U.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&Sa(n);)t+=Xr(n),e.advance();return t};function Sa(e){return e===105||e===109||e===115}U.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},U.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},U.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Ca(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ca(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}U.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Ca(n);)e.advance();return e.pos!==t},U.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},U.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},U.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},U.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Xr(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Xr(e.lastIntValue);return!0}return!1},U.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),wa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function wa(e){return jr(e,!0)||e===36||e===95}U.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Ta(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ta(e){return Mr(e,!0)||e===36||e===95||e===8204||e===8205}U.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},U.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},U.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},U.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},U.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},U.regexp_eatZero=function(e){return e.current()===48&&!La(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},U.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},U.regexp_eatControlLetter=function(e){var t=e.current();return Ea(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Ea(e){return e>=65&&e<=90||e>=97&&e<=122}U.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Da(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Da(e){return e>=0&&e<=1114111}U.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},U.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Oa=0,ka=1,Aa=2;U.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(ja(t))return e.lastIntValue=-1,e.advance(),ka;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Aa&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Oa};function ja(e){return e===100||e===68||e===115||e===83||e===119||e===87}U.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),ka}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Oa},U.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Kr(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},U.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return ka;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Aa;e.raise(`Invalid property name`)},U.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Ma(t=e.current());)e.lastStringValue+=Xr(t),e.advance();return e.lastStringValue!==``};function Ma(e){return Ea(e)||e===95}U.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Na(t=e.current());)e.lastStringValue+=Xr(t),e.advance();return e.lastStringValue!==``};function Na(e){return Ma(e)||La(e)}U.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},U.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Aa&&e.raise(`Negated character class may contain strings`),!0}return!1},U.regexp_classContents=function(e){return e.current()===93?ka:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),ka)},U.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},U.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Ba(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},U.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},U.regexp_classSetExpression=function(e){var t=ka,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Aa&&(t=Aa);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Aa&&(t=ka);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Aa&&(t=Aa)}},U.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},U.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?ka:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},U.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Aa&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},U.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},U.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Aa&&(t=Aa);return t},U.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?ka:Aa},U.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Pa(n)||Fa(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Pa(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Fa(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}U.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ia(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ia(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}U.regexp_eatClassControlLetter=function(e){var t=e.current();return La(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},U.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},U.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;La(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function La(e){return e>=48&&e<=57}U.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ra(n=e.current());)e.lastIntValue=16*e.lastIntValue+za(n),e.advance();return e.pos!==t};function Ra(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function za(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}U.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},U.regexp_eatOctalDigit=function(e){var t=e.current();return Ba(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ba(e){return e>=48&&e<=55}U.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Ra(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+za(i),e.advance()}return!0};var Va=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new $r(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},W=wi.prototype;W.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new Va(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},W.getToken=function(){return this.next(),new Va(this)},typeof Symbol<`u`&&(W[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===z.eof,value:t}}}}),W.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(z.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},W.readToken=function(e){return jr(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},W.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},W.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},W.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=Br(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},W.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!zr(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},W.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&Vr.test(String.fromCharCode(e)))++this.pos;else break loop}}},W.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},W.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(z.ellipsis)):(++this.pos,this.finishToken(z.dot))},W.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(z.assign,2):this.finishOp(z.slash,1)},W.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?z.star:z.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=z.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(z.assign,n+1):this.finishOp(r,n)},W.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(z.assign,3):this.finishOp(e===124?z.logicalOR:z.logicalAND,2):t===61?this.finishOp(z.assign,2):this.finishOp(e===124?z.bitwiseOR:z.bitwiseAND,1)},W.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(z.assign,2):this.finishOp(z.bitwiseXOR,1)},W.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Lr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(z.incDec,2):t===61?this.finishOp(z.assign,2):this.finishOp(z.plusMin,1)},W.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(z.assign,n+1):this.finishOp(z.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(z.relational,n))},W.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(z.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(z.arrow)):this.finishOp(e===61?z.eq:z.prefix,1)},W.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(z.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(z.assign,3):this.finishOp(z.coalesce,2)}return this.finishOp(z.question,1)},W.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),jr(t,!0)||t===92))return this.finishToken(z.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+Xr(t)+`'`)},W.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(z.parenL);case 41:return++this.pos,this.finishToken(z.parenR);case 59:return++this.pos,this.finishToken(z.semi);case 44:return++this.pos,this.finishToken(z.comma);case 91:return++this.pos,this.finishToken(z.bracketL);case 93:return++this.pos,this.finishToken(z.bracketR);case 123:return++this.pos,this.finishToken(z.braceL);case 125:return++this.pos,this.finishToken(z.braceR);case 58:return++this.pos,this.finishToken(z.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(z.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(z.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+Xr(e)+`'`)},W.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},W.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(Lr.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||(this.regexpState=new ba(this));s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(z.regexp,{pattern:i,flags:o,value:c})},W.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function Ha(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Ua(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}W.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ua(this.input.slice(t,this.pos)),++this.pos):jr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(z.num,n)},W.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=Ua(this.input.slice(t,this.pos));return++this.pos,jr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(z.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),jr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Ha(this.input.slice(t,this.pos),n);return this.finishToken(z.num,a)},W.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},W.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(zr(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(z.string,t)};var Wa={};W.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Wa)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},W.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Wa;this.raise(e,t)},W.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===z.template||this.type===z.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(z.dollarBraceL)):(++this.pos,this.finishToken(z.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(z.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(zr(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`\n`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},W.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case\"`\":return this.finishToken(z.invalidTemplate,this.input.slice(this.start,this.pos));case`\\r`:this.input[this.pos+1]===`\n`&&++this.pos;case`\n`:case`\\u2028`:case`\\u2029`:++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,`Unterminated template`)},W.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`\n`;case 114:return`\\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Xr(this.readCodePoint());case 116:return`\t`;case 98:return`\\b`;case 118:return`\\v`;case 102:return`\\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return zr(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},W.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},W.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Mr(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\\\uXXXX`),++this.pos;var o=this.readCodePoint();(t?jr:Mr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=Xr(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},W.readWord=function(){var e=this.readWord1(),t=z.name;return this.keywords.test(e)&&(t=Ir[e]),this.finishToken(t,e)},wi.acorn={Parser:wi,version:`8.19.0`,defaultOptions:ti,Position:Qr,SourceLocation:$r,getLineInfo:ei,Node:qi,TokenType:L,tokTypes:z,keywordTypes:Ir,TokContext:zi,tokContexts:V,isIdentifierChar:Mr,isIdentifierStart:jr,Token:Va,isNewLine:zr,lineBreak:Lr,lineBreakG:Rr,nonASCIIwhitespace:Vr};var Ga={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},Ka=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,qa=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Ja=/^[$_]\\w+$/,Ya=/[\\n\\r\\u2028\\u2029]/,Xa=/\\s*(?:[;},:)]|=(?![=>]))/y;function Za(e,t){return Xa.lastIndex=t,Xa.test(e)}var Qa=new Set([z.name,z.num,z.string,z.regexp,z.backQuote,z.bracketR,z.braceR,z.parenR,z.incDec,z._this,z._null,z._true,z._false]),$a=class extends wi{constructor(...e){super(...e),this.operandBeforeLast=!0,this.operandHere=!0,this.breakBeforeLast=!1,this.breakHere=!1,this.ternaries=[],this.colonEndsTernary=!1,this.closedBlock=!1,this.lookahead=!0}readToken(e){let t=this;if(t.lastTokEnd=t.end,this.operandBeforeLast=this.operandHere,this.operandHere=t.exprAllowed,this.breakBeforeLast=this.breakHere,this.breakHere=Ya.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?Ka:qa;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===z.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&eo(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(z.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===z.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===z.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===z.colon){let e=this.ternaries[r]??0;this.colonEndsTernary=e>0,e>0&&(this.ternaries[r]=e-1)}let i=this,a=i.type;this.prevValue=i.value;let o=e.keyword!==void 0&&(a===z.dot||a===z.questionDot)||(e===z._function||e===z._class)&&Za(i.input,i.pos);super.finishToken(o?z.name:e,t),e===z.name&&t===`of`&&(a===z._const||a===z._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===z.colon&&this.colonEndsTernary)return!1;if(e===z.braceR&&this.closedBlock||e===z.name&&this.prevValue===`static`)return!0;if(this.breakHere&&Qa.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function eo(e,t){if(!Ya.test(e.input.slice(e.end,e.pos)))return!1;let n=ro(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===z.eof)return!1;if(r>0)to.has(e)?r++:no.has(e)&&r--;else if(e===z.bracketL)r=1;else if(e===z.dot){if(n.nextToken(),n.type!==z.name&&!n.type.keyword)return!1}else return e===z.eq||e===z.assign}}catch{return!1}}var to=new Set([z.parenL,z.bracketL,z.braceL,z.dollarBraceL]),no=new Set([z.parenR,z.bracketR,z.braceR]);function ro(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new $a(r?{...Ga,onComment:r}:Ga,e,t);return n===`expression`&&(a.type=z.parenL),i&&(a.exprAllowed=!1),a}var io=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${so(t,n)}`+ao(r,e=>oo(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+ao(this.bracket,n=>{let{line:r,column:i}=ei(e,t+n);return`at line ${r}, column ${i+1}`})}};function ao(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function oo(e,t){let{line:n,column:r}=ei(e,t);return Ya.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function so(e,t){let{column:n}=ei(e,t),r=t-n,i=e.slice(r).search(Ya),a=i<0?e.length:r+i,o=Math.max(r,t-30),s=Math.min(a,t+30),c=(o>r?`…`:``)+e.slice(o,t)+`▶`+e.slice(t,s)+(s<a?`…`:``);return`${oo(e,t)}: ${c.trim()}`}var co=e=>e[e.length-1],lo={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function uo(e,t){if(!(t instanceof SyntaxError)||!(`pos`in t))throw t;let n=t.pos,r=t.message.replace(/ \\(\\d+:\\d+\\)$/,``),{open:i,token:a}=fo(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&lo[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:lo[i.text],pos:i.pos}:void 0;return new io(r,e,n,c)}function fo(e,t){let n=[];for(let r of Eo(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===z.eof)return{open:co(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in lo?n.push({text:i,pos:r.start}):n.length&&lo[co(n).text]===i&&n.pop()}return{open:co(n),token:e.charAt(t)}}function po(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=mo(e,t,n,r),a={refs:[],strings:[]};return yo(i,e,a,!1,!1),a.refs.sort((e,t)=>e.start-t.start),a}catch(t){let i=t.pos??-1;if(!(t instanceof SyntaxError)||n.has(i)||(qa.lastIndex=i+1,e.charAt(i)!==`%`||!qa.test(e)))throw t;n.set(i,!r.has(i))}}}function mo(e,t,n,r){try{let i=ro(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==z.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw uo(e,t)}}var ho=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,go={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function _o(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&Ja.test(n))?[r,n.slice(1)]:null}function vo(e,t){if(!ho(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new io(`\"${e.name}\" can't be a property name`,t,e.start)}function yo(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)yo(i,t,n,r,!1);return}if(!ho(e))return;let a=(e,r=!1,i=!1)=>yo(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=_o(e,t);if(!a)return;if(r)throw new io(`\"${e.name}\" is a ${go[a[0]]} variable and can't be declared`,t,e.start);n.refs.push({sigil:a[0],name:a[1],start:e.start,end:e.end,shorthand:i});return}case`Literal`:typeof e.value==`string`&&n.strings.push(t.slice(e.start+1,e.end-1));return;case`TemplateElement`:n.strings.push(e.value.raw);return;case`MemberExpression`:a(e.object),e.computed?a(e.property):vo(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||vo(e.key,t),e.shorthand){let t=e.value;t.type===`AssignmentPattern`?(a(t.left,r,!0),a(t.right)):a(t,r,!0)}else a(e.value,r);return;case`MethodDefinition`:case`PropertyDefinition`:e.computed?a(e.key):vo(e.key,t),a(e.value);return;case`LabeledStatement`:a(e.body);return;case`BreakStatement`:case`ContinueStatement`:case`MetaProperty`:case`PrivateIdentifier`:return;case`VariableDeclarator`:a(e.id,!0),a(e.init);return;case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:a(e.id,!0);for(let t of e.params)a(t,!0);a(e.body);return;case`ClassDeclaration`:case`ClassExpression`:a(e.id,!0),a(e.superClass),a(e.body);return;case`CatchClause`:a(e.param,!0),a(e.body);return;case`AssignmentPattern`:a(e.left,r),a(e.right);return;case`ObjectPattern`:case`ArrayPattern`:case`RestElement`:for(let t of[`properties`,`elements`,`argument`])a(e[t],r);return;default:for(let t in e){if(t===`type`||t===`start`||t===`end`)continue;let n=e[t];typeof n==`object`&&n&&a(n)}}}var bo=/[\\p{ID_Continue}$.]*/uy,xo=/[\\p{ID_Continue}$]*/uy,So=new Set([`of`,`get`,`set`,`static`,`async`]);function Co(e,t,{goal:n=`expression`,stop:r}={}){let i=To(e,t,n,r);return i<0&&!r?wo(e,t,n):i}function wo(e,t,n){let r=ro(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===z.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function To(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of Eo(e,s,n,{afterOperand:c})){if(`error`in u){let{message:n}=u.error,a=i.includes(\"${\");if(!/^Unterminated/.test(n)&&!a){if(t=Math.max(u.pos,s)+1,c=!1,t>=e.length)return-1;break}let o=i.lastIndexOf(\"${\");if(!/^Unterminated template/.test(n)||o<0||l||r)return-1;l=!0,i.length=o,t=u.pos,c=!0;break}if(u.restarted&&i.includes(\"${\"))return-1;let n=u.type;if(n===z.eof||n===z.string&&o&&u.start===a)return-1;if(o=n===z.name&&!So.has(u.value)||n===z.num,a=u.end,n===z.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===z.dollarBraceL)i.push(\"${\");else if(n===z.parenL)i.push(`(`);else if(n===z.bracketL)i.push(`[`);else if(n===z.parenR||n===z.bracketR)co(i)===(n===z.parenR?`(`:`[`)&&i.pop();else if(n===z.braceR){let e=Math.max(i.lastIndexOf(`{`),i.lastIndexOf(\"${\"));if(e>=0)i.length=e;else if(!r)return u.start}}s=t,o=!1}}function*Eo(e,t,n,r={}){let i=ro(e,t,n,r);for(;;){try{i.nextToken()}catch(t){let n=Math.min(t.pos??i.pos,e.length),a=t.message,o=(t,n,a)=>(i=ro(e,a,`statements`,{onComment:r.onComment,afterOperand:!0}),{type:t,start:n,end:a,value:void 0,restarted:!0}),s=e.charAt(i.start),c=/^Unterminated/.test(a);if(/^Unterminated string/.test(a)){let{end:t,closed:r}=Mo(e,n);if(r){yield o(z.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Mo(e,i.start);if(n){yield o(z.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=jo(e,i.start);if(t>0){yield o(z.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){bo.lastIndex=i.start,bo.test(e),yield o(z.num,i.start,bo.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===z.eof)return}}function Do(e,t,n=`expression`){return Oo(e,0,t,0,n,!1)}function Oo(e,t,n,r,i,a){let o=[],s=(e,t,n,r)=>{o.push([n,r])},c=(t,i)=>{for(let a=t;a<i;a++)n.code?.(e.charAt(a),a,r)},l=(t,i)=>{i>t&&n.literal?.(e.slice(t,i),t,r)},u=(e,t)=>{for(let[n,r]of o)r<=e||n>=t||(c(e,n),l(n,r),e=r);o.length=0,c(e,t)},d=[],f=0,p=Eo(e,t,i,{onComment:s}),m=t,h;for(;;){let t=p.next().value;if(`error`in t){let n=Math.max(m,t.pos);if(u(m,n),n>=e.length)return e.length;if(/^Unterminated/.test(t.error.message))return l(n,e.length),e.length;c(n,n+1),m=n+1,p=Eo(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===z.eof)return u(m,e.length),e.length;if(u(m,t.start),o===z.name){let i=ko(e,t.start,t.value),a=h===z.dot||h===z.questionDot||(i===`$`||i===`_`)&&Ao(e,t.end,h);i&&!a?n.variable?.(i,e.slice(t.start+1,t.end),t.start,r):c(t.start,t.end)}else if(o===z.string||o===z.regexp||o===z.template||o===z.invalidTemplate)l(t.start,t.end);else if(o===z.backQuote)if(l(t.start,t.end),h===z.template||h===z.invalidTemplate){if(f--,a&&f===0)return t.end}else f++;else o===z.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===z.braceR&&co(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===z.braceL||o===z.parenL||o===z.bracketL?d.push(e.charAt(t.start)):(o===z.braceR||o===z.parenR||o===z.bracketR)&&d.length&&co(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function ko(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&Ja.test(n)?r:null}function Ao(e,t,n){if(n!==z.braceL&&n!==z.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function jo(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(Ya.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return xo.lastIndex=r+1,xo.test(e),xo.lastIndex}return-1}function Mo(e,t){let n=e.charAt(t),r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`\\\\`)r+=2;else if(t===n)return{end:r+1,closed:!0};else r++}return{end:e.length,closed:!1}}var No=/[\\p{L}\\p{N}_\\\\]/u;function Po(e,t){let n=e[t],r=n===\"`\";for(let i=t+1;i<e.length;){let t=e[i];if(t===`\\\\`)i+=2;else if(t===n)return i+1;else if(!r&&t===`\n`)return-1;else if(r&&t===`$`&&e[i+1]===`{`){let t=Fo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Fo(e,t){Io!==e&&(Io=e,Lo.clear());let n=Lo.get(t);return n===void 0&&(n=Ro(e,t),Lo.set(t,n)),n}var Io=``,Lo=new Map;function Ro(e,t){let n=0;for(;t<e.length;){let r=e[t];if(r===`{`)n++,t++;else if(r===`}`){if(n===0)return t;n--,t++}else if(r===\"`\"||(r===`\"`||r===`'`)&&!(t>0&&No.test(e[t-1]))){let n=Po(e,t);t=n===-1?t+1:n}else t++}return-1}var zo={closeBrace(e,t,n){let r=Co(e,t);return r===-1?Fo(e,n):r},rawBodyEnd(e,t,n){let r=`\\\\{/${n}\\\\s*\\\\}`,i=new RegExp(r,`gi`);i.lastIndex=t;let a=i.exec(e)?.index??-1;if(a===-1)return-1;let o=new RegExp(r,`iy`),s=Co(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function Bo(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function Vo(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}n+=e.slice(r,i),r=i+1;let a=yr(e[r])?zo.closeBrace(e,r,r):-1;if(a===-1){n+=`{`;continue}n&&t.push({text:n}),n=``;let o=e.slice(r,a);t.push(/^.\\w/.test(o)?{expr:o}:{verbatim:`{${o}}`}),r=a+1}return n&&t.push({text:n}),t}var Ho=new Set([`do`]),Uo={...zo,isBlock:mr,isRaw:e=>Ho.has(e),isCodeAttribute:Bo},Wo=class extends Error{constructor(e,t,n,r){super(`${e} (line ${n}, column ${r})`),this.reason=e,this.offset=t,this.line=n,this.column=r,this.name=`MarkupError`}};function Go(e,t){let n=1,r=0;for(let i=e.indexOf(`\n`);i!==-1&&i<t;)n++,r=i+1,i=e.indexOf(`\n`,r);return{line:n,column:t-r+1}}function Ko(e,t,n){let r=n.hooks?{...Uo,...n.hooks}:Uo;try{return ur(e,{startRule:t,text:n.text===!0,hooks:r})}catch(t){let n=t.location;if(t instanceof Error&&t.name===`SyntaxError`&&n){let{offset:r}=n.start,{line:i,column:a}=Go(e,r);throw new Wo(t.message,r,i,a)}throw t}}function qo(e,t={}){return Ko(e,`Markup`,t)}function Jo(e,t={}){return Ko(e,`Tokens`,t)}var Yo=e=>Symbol.iterator in e,Xo=e=>`entries`in e,Zo=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Qo=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function $o(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Yo(e)&&Yo(t)?Xo(e)&&Xo(t)?Zo(e,t):Qo(e,t):Zo({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function es(...e){let t=j();return Q(n=>{let r={};for(let t of e)r[t]=n[t];return $o(t.current,r)?t.current:t.current=r})}function ts(){let{variables:e,temporary:t,transient:n}=es(`variables`,`temporary`,`transient`),r=Ie(Ef);return Pe(()=>[e,t,r,n],[e,t,r,n])}var ns=1831565813;function rs(e){let t=e|0;return()=>{t=t+ns|0;let e=Math.imul(t^t>>>15,t|1);return e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function is(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var as=!1,os=``,ss=0,cs=null,ls=0;function us(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,os=n,ss=0,cs=rs(is(n)),as=!0,ls++}function ds(e,t){ls++,fs(e,t)}function fs(e,t){os=e;let n=Math.imul(t%4294967296,ns);cs=rs(is(e)+n|0),as=!0,ss=t}function ps(){ls++,as=!1,os=``,ss=0,cs=null}function ms(e){let t={generation:ls,seed:os,pull:ss};try{return e()}finally{as&&ls===t.generation&&ss!==t.pull&&fs(t.seed,t.pull)}}function hs(){return as?{seed:os,pull:ss}:null}function gs(){return!as||!cs?Math.random():(ss++,cs())}function _s(e,t){return e>t&&([e,t]=[t,e]),Math.floor(gs()*(t-e+1))+e}function vs(){return as}function ys(){return os}function bs(){return ss}var xs=`__proto__`;function Ss(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${xs} is reserved)`:void 0}function Cs(e,t=e){let n=Ss(e,t);if(n)throw TypeError(`spindle: ${n}`)}var G=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ws=(e,t)=>e&&G(e,t)?e[t]:void 0;function Ts(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function Es(e,t=()=>!0){let n=Object.create(null);for(let r of e)if(r)for(let e of Object.keys(r)){let i=r[e];t(i)&&(n[e]=i)}return n}var K=(...e)=>Es(e),Ds=e=>Object.getPrototypeOf(e)===null,Os=e=>Ds(e)?e:K(e);function ks(e,t,n){let r=K(e);return r[t]=n,r}var As=Object.freeze(K());function js(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>ws(e,n)!==ws(t,n))}var Ms=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function Ns(e,t){let n=ws(e,t);return Ms(n)?n:0}function Ps(e,t){let n=Es([e],Ms);return t!==void 0&&(n[t]=Ns(e,t)+1),n}var Fs=500,Is=new Map,Ls={$:`variables`,_:`temporary`,\"@\":`locals`,\"%\":`transient`},Rs=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function zs(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=Bs.get(n);if(r!==void 0)return r;let{refs:i}=po(e,t),a=``,o=0;for(let t of i){let n=Ss(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:Rs.test(a.slice(-2))&&(a+=` `),a+=`${Ls[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),Bs.size>=Fs&&Bs.delete(Bs.keys().next().value),Bs.set(n,a),a}var Bs=new Map,Vs=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function Hs(e,t){let n=Is.get(e);if(n)return Is.delete(e),Is.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,Vs+t);if(Is.set(e,r),Is.size>Fs){let e=Is.keys().next().value;e!==void 0&&Is.delete(e)}return r}function Us(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function Ws(){let e=Q.getState();if(e.historyIndex<=0)return;let t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0}function Gs(e){let t=t=>Ns(e(),t??Q.getState().currentPassage);return{count:t,has:e=>t(e)>0,any:(...e)=>e.some(e=>t(e)>0),all:(...e)=>e.every(e=>t(e)>0)}}function Ks(e,t){let n=Gs(e),r=Gs(t);return{currentPassage:Us,previousPassage:Ws,visited:n.count,hasVisited:n.has,hasVisitedAny:n.any,hasVisitedAll:n.all,rendered:r.count,hasRendered:r.has,hasRenderedAny:r.any,hasRenderedAll:r.all}}var qs=null,Js=null,Ys=null;function Xs(){let{visitCounts:e,renderCounts:t}=Q.getState();return qs&&Js===e&&Ys===t?qs:(qs={...Ks(()=>e,()=>t),random:gs,randomInt:_s},Js=e,Ys=t,qs)}function Zs(e){return Ds(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):Os(e)}function Qs(e,...[t,n,r=As,i=As]){return e(Zs(t),Zs(n),Zs(r),Xs(),Zs(i))}function $s(e,...t){let n=`return (${zs(e)}\\n);`;return Qs(Hs(n,n),...t)}function ec(e,...t){let n=zs(e,`statements`);Qs(Hs(`exec:`+n,n),...t)}var tc=new dr;function nc(e,t){tc.set(e,t)}function rc(e){return tc.get(e)}var ic=new dr;function ac(e,t){t?ic.set(e,t):ic.delete(e)}function oc(e){return ic.get(e)}var sc=new fr;function cc(e){sc.add(e)}function lc(e){return sc.has(e)}var uc=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`];function dc(e,t){for(let n of t){let t=n.type;if(!uc.includes(t)){let r=t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`;throw Error(`spindle: The parameter \"${n.name}\" of the macro {${e}} ${r}. Give it one of the types ${uc.join(`, `)} (see docs/custom-macros.md#parameter-types), or declare no parameters and read props.rawArgs.`)}n.parameters&&dc(e,n.parameters)}}var fc=new dr;function pc(e,t){fc.set(e,t)}function mc(){return Array.from(fc.values())}var hc=new dr;function gc(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);for(let e of i)e.startsWith(`@`)&&Cs(e.slice(1),e);hc.set(e,{body:t,params:i,isBlock:r})}function _c(e){return hc.get(e)}function vc(e){return/\\s/.test(e)}function yc(e){return e===`(`||e===`[`||e===`{`}function bc(e){return e===`)`||e===`]`||e===`}`}function xc(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Sc(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=Mo(e,t);return i?{value:xc(e.slice(t+1,r-1)),end:r}:null}function Cc(e){let t=Sc(e,0);return t&&t.end===e.length?t.value:null}function wc(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var Tc=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function Ec(e){let t=-1;if(Do(e,{code(e,n,r){r===0&&!vc(e)&&(t=n+1)},literal(e,n,r){let i=e.startsWith(`//`)||e.startsWith(`/*`);r===0&&!i&&(t=-1)},variable(e,n,r,i){i===0&&(t=-1)}}),t<0)return!1;let n=e.slice(0,t);return/(?:\\+\\+|--)$/.test(n)?!1:Tc.test(n)}function Dc(e,t){let n=[],r=0;return Do(e,{code(e,i,a){a>0||(yc(e)?r++:bc(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function Oc(e,t){let n=[],r=0;for(let i of Dc(e,t))n.push(e.slice(r,i)),r=i+1;return n.push(e.slice(r)),n}function kc(e){return Ac(e)&&!Ec(e)}function Ac(e){let t=e[0];return!!(t===`\"`||t===`'`||t===\"`\"||/^[$_@]\\w|^%[A-Za-z_]/.test(e)||/\\d/.test(t)||(t===`-`||t===`+`)&&e.length>1&&/\\d/.test(e[1])||t===`(`||t===`[`||t===`{`||/^(?:true|false|null|undefined)(?![\\w$])/.test(e)||t===`!`&&e.length>1&&e[1]!==`=`)}function jc(e){let t=Oc(e,vc).filter(Boolean);if(t.length<2)return null;for(let e of t)if(!kc(e))return null;return t}function Mc(e){let t=Oc(e,e=>e===`,`).map(e=>e.trim()),n=t.length>1;if(t[t.length-1]===``&&t.pop(),!n&&t.length===1){let e=jc(t[0]);if(e)return e}return t}function Nc(e){return e==null?``:String(e)}function Pc(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Fc(e){return e.includes(`{`)||e.includes(`}`)}var Ic=new Map,Lc=2e3;function Rc(e){let t=Ic.get(e);if(t===void 0){try{t={nodes:qo(e,{text:!0})}}catch(e){t={error:e}}Ic.size>=Lc&&Ic.clear(),Ic.set(e,t)}return t}function zc(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:zc(e.children,t)};case`macro`:{let n={...e,children:zc(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:zc(e.children,t)}))),n}default:return e}})}var Bc=100;function Vc(e,t,n){let r=n.split(`.`),i=r[0];Cs(i,_r[t]+i);let a=ws(t===`variable`?e.variables:t===`temporary`?e.temporary:t===`transient`?e.transient:e.locals,i);for(let e=1;e<r.length;e++){if(a==null)return;a=a[r[e]]}return a}function Hc(e,t){return $s(e,t.variables,t.temporary,t.locals,t.transient)}var Uc=class{constructor(){this.errors=[]}nodes(e,t,n){let r=``;for(let i of e)r+=this.node(i,t,n);return r}node(e,t,n){switch(e.type){case`text`:return e.value;case`variable`:if(e.scope===`local`&&e.name===`children`){let e=t.widgetChildren;return e?this.nested(`children`,e,t,n,{widgetChildren:null}):``}return this.variable(e.scope,e.name,t);case`expression`:try{return Nc(Hc(e.expression,t))}catch(e){return this.errors.push({macro:`expression`,error:e}),``}case`html`:return this.nodes(e.children,t,n);case`macro`:return this.macro(e,t,n);default:return e}}variable(e,t,n){try{return Nc(Vc(n,e,t))}catch(n){return this.errors.push({macro:_r[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=Bc?(this.errors.push({macro:e,error:Error(`markup nested too deeply (a widget using itself?)`)}),``):this.nodes(t,{...n,...i},r+1)}macro(e,t,n){if(lc(e.name))return``;let r=_c(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?Mc(e.rawArgs):[];i=K(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=Hc(o,t)}catch{a=void 0}i[e.startsWith(`@`)?e.slice(1):e]=a})}return this.nested(e.name,r.body,t,n,{locals:i,widgetChildren:e.children.length>0?e.children:null})}let i=oc(e.name);if(!i){let t=rc(e.name)?`{${e.name}} has no text form, so it can't be used in an attribute value or label`:`unknown macro {${e.name}}`;return this.errors.push({macro:e.name,error:Error(t)}),``}let a={evaluate:e=>Hc(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Wc(t.locals,i)}:{})};try{return i({rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},a)}catch(t){return this.errors.push({macro:e.name,error:t}),``}}};function Wc(e,t){for(let e of Object.keys(t))Cs(e,`@${e}`);return K(e,t)}function Gc(e,t){let n=new Uc;return{text:n.nodes(e,t,0),errors:n.errors}}function Kc(e,t){if(!Fc(e))return{text:e,errors:[]};let n=Rc(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:Gc(n.nodes,t)}function qc(e,t,n){let r=[],i=``;for(let a of Vo(e))if(`text`in a)i+=n?n(a.text):a.text;else if(`verbatim`in a)i+=a.verbatim;else if(/^[$_@%][\\w.]+$/.test(a.expr)){let e=gr[a.expr[0]];try{i+=Nc(Vc(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=Nc(Hc(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function Jc(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function Yc(){let[e,t,n,r]=ts(),i=Ie(Pf);return Pe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function Xc(){let e=Yc();return Fe(t=>{if(t===void 0||!Fc(t))return t;let{text:n,errors:r}=Kc(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${Jc(n)}`);return n},[e])}var Zc=0;Array.isArray;function q(e,t,n,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Zc,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}var Qc={variable:`variables`,temporary:`temporary`,transient:`transient`};function $c({node:e}){let{name:t,scope:n}=e,r=Xc(),i=r(e.className),a=r(e.id),o=Ie(Ef),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:ws(e[Qc[n]],c)),u=_r[n],d=Ss(c,u+c);if(d)return q(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?ws(o,c):l;for(let e=1;e<s.length;e++){if(f==null){f=void 0;break}let t=s[e];f=f[t]}return Pc(i,a,Nc(f))}function el({node:e}){let{expression:t}=e,n=Xc(),r=n(e.className),i=n(e.id),[a,o,s,c]=ts(),l;try{l=Nc($s(t,a,o,s,c))}catch{l=`{error: ${t}}`}return Pc(r,i,l)}function tl(){return{nobr:Ie(Of),inline:Ie(kf),raw:Ie(Af),locals:Ie(Ef)}}function nl({body:e,parentValues:t,ownKeys:n}){let r=tl(),[i,a]=Ae({}),o=Pe(()=>K(t,n,i),[t,n,i]),s=j(o);s.current=o;let c=Fe(()=>s.current,[]),l=Fe((e,t)=>{Cs(e,`@${e}`),s.current=ks(s.current,e,t),a(n=>({...n,[e]:t}))},[]),u=Pe(()=>({update:l,getValues:c}),[l,c]);return q(Df.Provider,{value:u,children:q(Ef.Provider,{value:o,children:Cp(e,{...r,locals:o})})})}function rl({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=tl(),a=i.locals,[o,s,c,l]=ts(),u=r?.length?r:null;if(t.length===0)return q(Pf.Provider,{value:u,children:Cp(e,i)});let d=n?Mc(n):[],f=[];for(let e=0;e<t.length;e++){let t=d[e],n;if(t!==void 0)try{n=$s(t,o,s,c,l)}catch{n=void 0}f.push(n)}let p=Pe(()=>{let e=K();for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=f[n];return e},f);return q(Pf.Provider,{value:u,children:q(nl,{body:e,parentValues:a,ownKeys:p})})}var il=document.createElement(`i`);function al(e){let t=`&`+e+`;`;il.innerHTML=t;let n=il.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function ol(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+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 sl(e,t){return e.length>0?(ol(e,e.length,0,t),e):t}var cl={}.hasOwnProperty;function ll(e){let t={},n=-1;for(;++n<e.length;)ul(t,e[n]);return t}function ul(e,t){let n;for(n in t){let r=(cl.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){cl.call(r,a)||(r[a]=[]);let e=i[a];dl(r[a],Array.isArray(e)?e:e?[e]:[])}}}function dl(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);ol(e,0,0,r)}function fl(e){let t={},n=-1;for(;++n<e.length;)pl(t,e[n]);return t}function pl(e,t){let n;for(n in t){let r=(cl.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function ml(e,t){let 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)}var hl={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function gl(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+hl[e]+`;`}}function _l(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var vl=Ol(/[A-Za-z]/),yl=Ol(/[\\dA-Za-z]/),bl=Ol(/[#-'*+\\--9=?A-Z^-~]/);function xl(e){return e!==null&&(e<32||e===127)}var Sl=Ol(/\\d/),Cl=Ol(/[\\dA-Fa-f]/),wl=Ol(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Tl(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var El=Ol(/\\p{P}|\\p{S}/u),Dl=Ol(/\\s/);function Ol(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function kl(e,t){let n=gl(Al(e||``));if(!t)return n;let 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 Al(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&yl(e.charCodeAt(n+1))&&yl(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){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),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)}var jl={}.hasOwnProperty,Ml=/^(https?|ircs?|mailto|xmpp)$/i,Nl=/^https?$/i;function Pl(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=fl([{enter:{blockQuote:ne,codeFenced:ae,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:ce,codeText:ze,content:we,definition:ye,definitionDestinationString:xe,definitionLabelString:h,definitionTitleString:h,emphasis:Le,htmlFlow:Pe,htmlText:Ie,image:ue,label:h,link:de,listItemMarker:E,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:ie,reference:h,resource:he,resourceDestinationString:ge,resourceTitleString:h,setextHeading:Ee,strong:Re},exit:{atxHeading:Oe,atxHeadingSequence:Te,autolinkEmail:qe,autolinkProtocol:Ke,blockQuote:re,characterEscapeValue:je,characterReferenceMarkerHexadecimal:We,characterReferenceMarkerNumeric:We,characterReferenceValue:Ge,codeFenced:le,codeFencedFence:se,codeFencedFenceInfo:oe,codeFencedFenceMeta:S,codeFlowValue:Ne,codeIndented:le,codeText:Be,codeTextData:je,data:je,definition:Ce,definitionDestinationString:Se,definitionLabelString:be,definitionTitleString:A,emphasis:Ve,hardBreakEscape:j,hardBreakTrailing:j,htmlFlow:Fe,htmlFlowData:je,htmlText:Fe,htmlTextData:je,image:k,label:pe,labelText:fe,lineEnding:Me,link:k,listOrdered:ee,listUnordered:D,paragraph:O,reference:S,referenceString:me,resource:S,resourceDestinationString:_e,resourceTitleString:ve,setextHeading:Ae,setextHeadingLineSequence:ke,setextHeadingText:De,strong:He,thematicBreak:Ue}},...t.htmlExtensions||[]]),c={definitions:r,tightStack:o},l={buffer:h,encode:x,getData:m,lineEndingIfNeeded:b,options:t,raw:v,resume:g,setData:p,tag:_},u=t.defaultLineEnding;return d;function d(e){let t=-1,n=0,r=[],a=[],o=[];for(;++t<e.length;)!u&&(e[t][1].type===`lineEnding`||e[t][1].type===`lineEndingBlank`)&&(u=e[t][2].sliceSerialize(e[t][1])),(e[t][1].type===`listOrdered`||e[t][1].type===`listUnordered`)&&(e[t][0]===`enter`?r.push(t):f(e.slice(r.pop(),t))),e[t][1].type===`definition`&&(e[t][0]===`enter`?(o=sl(o,e.slice(n,t)),n=t):(a=sl(a,e.slice(n,t+1)),n=t+1));a=sl(a,o),a=sl(a,e.slice(n)),t=-1;let c=a;for(s.enter.null&&s.enter.null.call(l);++t<e.length;){let e=s[c[t][0]],n=c[t][1].type,r=e[n];jl.call(e,n)&&r&&r.call({sliceSerialize:c[t][2].sliceSerialize,...l},c[t][1])}return s.exit.null&&s.exit.null.call(l),i[0].join(``)}function f(e){let t=e.length,n=0,r=0,i=!1,a;for(;++n<t;){let t=e[n];if(t[1]._container)a=void 0,t[0]===`enter`?r++:r--;else switch(t[1].type){case`listItemPrefix`:t[0]===`exit`&&(a=!0);break;case`linePrefix`:break;case`lineEndingBlank`:t[0]===`enter`&&!r&&(a?a=void 0:i=!0);break;default:a=void 0}}e[0][1]._loose=i}function p(e,t){c[e]=t}function m(e){return c[e]}function h(){i.push([])}function g(){return i.pop().join(``)}function _(e){n&&(p(`lastWasTag`,!0),i[i.length-1].push(e))}function v(e){p(`lastWasTag`),i[i.length-1].push(e)}function y(){v(u||`\n`)}function b(){let e=i[i.length-1],t=e[e.length-1],n=t?t.charCodeAt(t.length-1):null;n===10||n===13||n===null||y()}function x(e){return m(`ignoreEncode`)?e:gl(e)}function S(){g()}function C(e){o.push(!e._loose),b(),_(`<ol`),p(`expectFirstItem`,!0)}function w(e){o.push(!e._loose),b(),_(`<ul`),p(`expectFirstItem`,!0)}function T(e){if(m(`expectFirstItem`)){let t=Number.parseInt(this.sliceSerialize(e),10);t!==1&&_(` start=\"`+x(String(t))+`\"`)}}function E(){m(`expectFirstItem`)?_(`>`):te(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function ee(){te(),o.pop(),y(),_(`</ol>`)}function D(){te(),o.pop(),y(),_(`</ul>`)}function te(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function ne(){o.push(!1),b(),_(`<blockquote>`)}function re(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function ie(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function O(){o[o.length-1]?p(`slurpAllLineEndings`,!0):_(`</p>`)}function ae(){b(),_(`<pre><code`),p(`fencesCount`,0)}function oe(){_(` class=\"language-`+g()+`\"`)}function se(){let e=m(`fencesCount`)||0;e||(_(`>`),p(`slurpOneLineEnding`,!0)),p(`fencesCount`,e+1)}function ce(){b(),_(`<pre><code>`)}function le(){let e=m(`fencesCount`);e!==void 0&&e<2&&c.tightStack.length>0&&!m(`lastWasTag`)&&y(),m(`flowCodeSeenData`)&&b(),_(`</code></pre>`),e!==void 0&&e<2&&b(),p(`flowCodeSeenData`),p(`fencesCount`),p(`slurpOneLineEnding`)}function ue(){a.push({image:!0}),n=void 0}function de(){a.push({})}function fe(e){a[a.length-1].labelId=this.sliceSerialize(e)}function pe(){a[a.length-1].label=g()}function me(e){a[a.length-1].referenceId=this.sliceSerialize(e)}function he(){h(),a[a.length-1].destination=``}function ge(){h(),p(`ignoreEncode`,!0)}function _e(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function ve(){a[a.length-1].title=g()}function k(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[_l(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+kl(s.destination,t.allowDangerousProtocol?void 0:Nl)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+kl(s.destination,t.allowDangerousProtocol?void 0:Ml)+`\"`),_(s.title?` title=\"`+s.title+`\"`:``),i.image?_(` />`):(_(`>`),v(i.label),_(`</a>`)),a.pop()}function ye(){h(),a.push({})}function be(e){g(),a[a.length-1].labelId=this.sliceSerialize(e)}function xe(){h(),p(`ignoreEncode`,!0)}function Se(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function A(){a[a.length-1].title=g()}function Ce(){let e=a[a.length-1],t=_l(e.labelId);g(),jl.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function we(){p(`slurpAllLineEndings`,!0)}function Te(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function Ee(){h(),p(`slurpAllLineEndings`)}function De(){p(`slurpAllLineEndings`,!0)}function Oe(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function ke(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function Ae(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function je(e){v(x(this.sliceSerialize(e)))}function Me(e){if(!m(`slurpAllLineEndings`)){if(m(`slurpOneLineEnding`)){p(`slurpOneLineEnding`);return}if(m(`inCodeText`)){v(` `);return}v(x(this.sliceSerialize(e)))}}function Ne(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function j(){_(`<br />`)}function Pe(){b(),Ie()}function Fe(){p(`ignoreEncode`)}function Ie(){t.allowDangerousHtml&&p(`ignoreEncode`,!0)}function Le(){_(`<em>`)}function Re(){_(`<strong>`)}function ze(){p(`inCodeText`,!0),_(`<code>`)}function Be(){p(`inCodeText`),_(`</code>`)}function Ve(){_(`</em>`)}function He(){_(`</strong>`)}function Ue(){b(),_(`<hr />`)}function We(e){p(`characterReferenceType`,e.type)}function Ge(e){let t=this.sliceSerialize(e);v(x(m(`characterReferenceType`)?ml(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):al(t))),p(`characterReferenceType`)}function Ke(e){let n=this.sliceSerialize(e);_(`<a href=\"`+kl(n,t.allowDangerousProtocol?void 0:Ml)+`\">`),v(x(n)),_(`</a>`)}function qe(e){let t=this.sliceSerialize(e);_(`<a href=\"`+kl(`mailto:`+t)+`\">`),v(x(t)),_(`</a>`)}}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Fl={tokenize:Il};function Il(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Ll={tokenize:zl},Rl={tokenize:Bl};function zl(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return ol(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Rl,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Rl,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i=i||t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;ol(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Bl(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Vl(e){if(e===null||Tl(e)||Dl(e))return 1;if(El(e))return 2}function Hl(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Ul={name:`attention`,resolveAll:Wl,tokenize:Gl};function Wl(e,t){let n=-1,r,i,a,o,s,c,l,u;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;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Kl(d,-c),Kl(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>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=sl(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=sl(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=sl(l,Hl(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=sl(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=sl(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ol(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Gl(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Vl(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Vl(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Kl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ql={name:`autolink`,tokenize:Jl};function Jl(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return vl(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||yl(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||yl(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||xl(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):bl(t)?(e.consume(t),l):n(t)}function u(e){return yl(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||yl(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Yl={partial:!0,tokenize:Xl};function Xl(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var Zl={continuation:{tokenize:$l},exit:eu,name:`blockQuote`,tokenize:Ql};function Ql(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function $l(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Zl,t,n)(r)}}function eu(e){e.exit(`blockQuote`)}var tu={name:`characterEscape`,tokenize:nu};function nu(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return wl(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var ru={name:`characterReference`,tokenize:iu};function iu(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=yl,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Cl,u):(e.enter(`characterReferenceValue`),a=7,o=Sl,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===yl&&!al(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var au={partial:!0,tokenize:cu},ou={concrete:!0,name:`codeFenced`,tokenize:su};function su(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(au,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(au,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function cu(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var lu={name:`codeIndented`,tokenize:du},uu={partial:!0,tokenize:fu};function du(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(uu,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function fu(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var pu={name:`codeText`,previous:hu,resolve:mu,tokenize:gu};function mu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function hu(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function gu(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var _u=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError(\"Cannot access index `\"+e+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&vu(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),vu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vu(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);vu(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);vu(this.left,t.reverse())}}};function vu(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 yu(e){let t={},n=-1,r,i,a,o,s,c,l,u=new _u(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,bu(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.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={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return ol(e,0,1/0,u.slice(0)),!l}function bu(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var xu={resolve:Cu,tokenize:wu},Su={partial:!0,tokenize:Tu};function Cu(e){return yu(e),e}function wu(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(Su,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Tu(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Eu(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||xl(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Tl(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||xl(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Du(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!Y(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Ou(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function ku(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Au={name:`definition`,tokenize:Mu},ju={partial:!0,tokenize:Nu};function Mu(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Du.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=_l(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Tl(t)?ku(e,l)(t):l(t)}function l(t){return Eu(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(ju,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Nu(e,t,n){return r;function r(t){return Tl(t)?ku(e,i)(t):n(t)}function i(t){return Ou(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var Pu={name:`hardBreakEscape`,tokenize:Fu};function Fu(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Iu={name:`headingAtx`,resolve:Lu,tokenize:Ru};function Lu(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`},ol(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Ru(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Tl(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Tl(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var zu=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Bu=[`pre`,`script`,`style`,`textarea`],Vu={concrete:!0,name:`htmlFlow`,resolveTo:Wu,tokenize:Gu},Hu={partial:!0,tokenize:qu},Uu={partial:!0,tokenize:Ku};function Wu(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 Gu(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:se):vl(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):vl(a)?(e.consume(a),i=4,r.interrupt?t:se):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:se):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return vl(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Tl(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Bu.includes(l)?(i=1,r.interrupt?t(s):D(s)):zu.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||yl(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return Y(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||vl(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||yl(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Tl(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),ee):n(t)}function ee(t){return t===null||J(t)?D(t):Y(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),ie):t===60&&i===1?(e.consume(t),O):t===62&&i===4?(e.consume(t),ce):t===63&&i===3?(e.consume(t),se):t===93&&i===5?(e.consume(t),oe):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Hu,le,te)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),D)}function te(t){return e.check(Uu,ne,le)(t)}function ne(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),re}function re(t){return t===null||J(t)?te(t):(e.enter(`htmlFlowData`),D(t))}function ie(t){return t===45?(e.consume(t),se):D(t)}function O(t){return t===47?(e.consume(t),o=``,ae):D(t)}function ae(t){if(t===62){let n=o.toLowerCase();return Bu.includes(n)?(e.consume(t),ce):D(t)}return vl(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ae):D(t)}function oe(t){return t===93?(e.consume(t),se):D(t)}function se(t){return t===62?(e.consume(t),ce):t===45&&i===2?(e.consume(t),se):D(t)}function ce(t){return t===null||J(t)?(e.exit(`htmlFlowData`),le(t)):(e.consume(t),ce)}function le(n){return e.exit(`htmlFlow`),t(n)}}function Ku(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function qu(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Yl,t,n)}}var Ju={name:`htmlText`,tokenize:Yu};function Yu(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):vl(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):vl(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,O(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ie(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):J(t)?(o=h,O(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ie(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ie(t):J(t)?(o=v,O(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,O(t)):(e.consume(t),y)}function b(e){return e===62?ie(e):y(e)}function x(t){return vl(t)?(e.consume(t),S):n(t)}function S(t){return t===45||yl(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,O(t)):Y(t)?(e.consume(t),C):ie(t)}function w(t){return t===45||yl(t)?(e.consume(t),w):t===47||t===62||Tl(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ie):t===58||t===95||vl(t)?(e.consume(t),E):J(t)?(o=T,O(t)):Y(t)?(e.consume(t),T):ie(t)}function E(t){return t===45||t===46||t===58||t===95||yl(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):J(t)?(o=ee,O(t)):Y(t)?(e.consume(t),ee):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,te):J(t)?(o=D,O(t)):Y(t)?(e.consume(t),D):(e.consume(t),ne)}function te(t){return t===i?(e.consume(t),i=void 0,re):t===null?n(t):J(t)?(o=te,O(t)):(e.consume(t),te)}function ne(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Tl(t)?T(t):(e.consume(t),ne)}function re(e){return e===47||e===62||Tl(e)?T(e):n(e)}function ie(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function O(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return Y(t)?X(e,oe,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):oe(t)}function oe(t){return e.enter(`htmlTextData`),o(t)}}var Xu={name:`labelEnd`,resolveAll:ed,resolveTo:td,tokenize:nd},Zu={tokenize:rd},Qu={tokenize:id},$u={tokenize:ad};function ed(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&ol(e,0,e.length,n),e}function td(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);let c={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}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=sl(s,e.slice(a+1,a+r+3)),s=sl(s,[[`enter`,u,t]]),s=sl(s,Hl(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=sl(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=sl(s,e.slice(o+1)),s=sl(s,[[`exit`,c,t]]),ol(e,a,e.length,s),e}function nd(e,t,n){let r=this,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(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(_l(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Zu,u,o?u:d)(t):t===91?e.attempt(Qu,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt($u,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function rd(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Tl(t)?ku(e,a)(t):a(t)}function a(t){return t===41?u(t):Eu(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Tl(t)?ku(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Ou(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Tl(t)?ku(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function id(e,t,n){let r=this;return i;function i(t){return Du.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(_l(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function ad(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var od={name:`labelStartImage`,resolveAll:Xu.resolveAll,tokenize:sd};function sd(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var cd={name:`labelStartLink`,resolveAll:Xu.resolveAll,tokenize:ld};function ld(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ud={name:`lineEnding`,tokenize:dd};function dd(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var fd={name:`thematicBreak`,tokenize:pd};function pd(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var md={continuation:{tokenize:vd},exit:bd,name:`list`,tokenize:_d},hd={partial:!0,tokenize:xd},gd={partial:!0,tokenize:yd};function _d(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Sl(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(fd,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Sl(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Yl,r.interrupt?n:u,e.attempt(hd,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function vd(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Yl,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(gd,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(md,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function yd(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function bd(e){e.exit(this.containerState.type)}function xd(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Sd={name:`setextUnderline`,resolveTo:Cd,tokenize:wd};function Cd(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);let 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 wd(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Td={tokenize:Ed};function Ed(e){let t=this,n=e.attempt(Yl,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xu,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Dd={resolveAll:jd()},Od=Ad(`string`),kd=Ad(`text`);function Ad(e){return{resolveAll:jd(e===`text`?Md:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function jd(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Md(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||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={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Nd=t({attentionMarkers:()=>Vd,contentInitial:()=>Fd,disable:()=>Hd,document:()=>Pd,flow:()=>Ld,flowInitial:()=>Id,insideSpan:()=>Bd,string:()=>Rd,text:()=>zd}),Pd={42:md,43:md,45:md,48:md,49:md,50:md,51:md,52:md,53:md,54:md,55:md,56:md,57:md,62:Zl},Fd={91:Au},Id={[-2]:lu,[-1]:lu,32:lu},Ld={35:Iu,42:fd,45:[Sd,fd],60:Vu,61:Sd,95:fd,96:ou,126:ou},Rd={38:ru,92:tu},zd={[-5]:ud,[-4]:ud,[-3]:ud,33:od,38:ru,42:Ul,60:[ql,Ju],91:cd,92:[Pu,tu],93:Xu,95:Ul,96:pu},Bd={null:[Ul,Dd]},Vd={null:[42,95]},Hd={null:[]};function Ud(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=sl(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Hl(a,l.events,l),l.events):[]}function f(e,t){return Gd(p(e),t)}function p(e){return Wd(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-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=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&ol(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Wd(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Gd(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],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 Kd(e){let t={constructs:ll([Nd,...(e||{}).extensions||[]]),content:n(Fl),defined:[],document:n(Ll),flow:n(Td),lazy:{},string:n(Od),text:n(kd)};return t;function n(e){return n;function n(n){return Ud(t,e,n)}}}function qd(e){for(;!yu(e););return e}var Jd=/[\\0\\t\\n\\r]/g;function Yd(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(Jd.lastIndex=u,c=Jd.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Xd(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Pl(n)(qd(Kd(n).document().write(Yd()(e,t,!0))))}var Zd={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function Qd(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=Zd[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];e===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(`<td`+e+`>`))},tableHead(){this.lineEndingIfNeeded(),this.tag(`<thead>`)},tableHeader(){let e=Zd[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];this.lineEndingIfNeeded(),this.tag(`<th`+e+`>`)},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,$d)),this.raw(this.encode(t))},table(){this.setData(`tableAlign`),this.setData(`slurpAllLineEndings`),this.lineEndingIfNeeded(),this.tag(`</table>`)},tableBody(){this.lineEndingIfNeeded(),this.tag(`</tbody>`)},tableData(){let 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(){let e=this.getData(`tableColumn`);this.tag(`</th>`),this.setData(`tableColumn`,e+1)},tableRow(){let e=this.getData(`tableAlign`),t=this.getData(`tableColumn`);for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(`<td`+Zd[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function $d(e,t){return t===`|`?t:e}var ef=class{constructor(){this.map=[]}add(e,t,n){tf(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function tf(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 nf(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 rf(){return{flow:{null:{name:`table`,tokenize:af,resolveAll:of}}}}function af(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Tl(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Tl(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function of(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new ef;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(cf(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=sf(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=sf(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=sf(f,t,o,i,n,d)):(o[0]=o[1],d=sf(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&cf(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=nf(t.events,n))}return e}function sf(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},lf(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=lf(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=lf(t.events,n[2]),a=lf(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},lf(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function cf(e,t,n,r,i){let a=[],o=lf(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 lf(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function uf(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function df(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&ol(o,o.length,0,Hl(s,e.slice(r+1,n),t)),ol(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ol(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Vl(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Vl(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function ff(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[rf(),df(),{disable:{null:t}}],htmlExtensions:[Qd(),uf()]}}function pf(e,t){let n=ff(t);return Xd(e,{...n,extensions:[...n.extensions??[],yf(e),hf]})}var mf=e=>{let t=e.length-2,n=e[t-1];return n&&n[0]===`exit`&&n[1].type===`data`&&(n[1].end=e[t][1].end,e.length=t),e},hf={text:{null:{name:`textData`,tokenize(e,t){let n=this,r=this.parser.constructs.text;function i(e){if(e===null)return!0;let t=r[e]??[];return(Array.isArray(t)?t:[t]).some(e=>!e.previous||e.previous.call(n,n.previous))}function a(n){return i(n)?(e.exit(`data`),t(n)):(e.consume(n),a)}return t=>(e.enter(`data`),e.consume(t),a)},resolveTo:mf}}},gf=/[#-'*+\\--9=?A-Z^-~]/,_f=/[0-9A-Za-z]/,vf=/[A-Za-z]/;function yf(e){let t=e.charCodeAt(0)===65279?1:0,n=e.lastIndexOf(`-->`),r=e.lastIndexOf(`?>`),i=e.lastIndexOf(`]]>`),a=e.lastIndexOf(`>`);function o(t){return e[t]===`<`?e.startsWith(`\\x3C!--`,t)?n<t+2:e.startsWith(`<![CDATA[`,t)?i<t+9:e[t+1]===`!`&&vf.test(e[t+2]??``)?a<t+3:e[t+1]===`?`?r<t+2&&!s(t):!1:!1}function s(t){let n=t+1;for(;gf.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!_f.test(t))return!1;i=`label`}else if(i===`label`){if(t===`>`)return!0;t===`.`?(n++,r=0,i=`atSignOrDot`):i=`value`}else{if(!((t===`-`||_f.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}let c={name:`unclosedHtml`,resolveTo:mf,tokenize(e,n,r){let i=this.now().offset+t;return t=>t!==60||!o(i)?r(t):(e.enter(`data`),e.consume(t),e.exit(`data`),n)}};return{text:{60:c}}}function bf(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function xf(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?bf(t):``}function Sf({macro:e,error:t}){return q(`span`,{class:`error`,title:String(t),children:`{${e} error${xf()}: ${Jc(t)}}`})}function Cf(e,t,n=xf()){console.error(`spindle: Error in {${e}}${n}:`,t)}function wf(e,t,n){let r=j();if(r.current===void 0){r.current=null;let i=xf();try{n()}catch(n){r.current={error:n},Cf(`${e} ${t}`,n,i)}}return r.current?q(Sf,{macro:e,error:r.current.error}):null}var Tf={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>As},Ef=_e(As),Df=_e(Tf),Of=_e(!1),kf=_e(!1),Af=_e(!1),jf=_e(!1),Mf=`http://www.w3.org/2000/svg`,Nf=new Set([`pre`,`textarea`]),Pf=_e(null);function Ff(e,t){return`<span data-tw=${e}:${t}></span>`}var If=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,Lf=``;function Rf(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(If))i[1]===t.nonce&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(parseInt(i[2],10)),r=i.index+i[0].length);return r<e.length&&n.push(e.slice(r)),n}function zf(e,t){return Rf(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function Bf({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=Yc(),o=[],{props:s,direct:c}=$f(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=Gc(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=ep(c);return Hf(o,b(e,l?{...s,ref:l}:s,...i))}function Vf({tag:e,props:t,direct:n,children:r}){let i=ep(n);return b(e,{...t,ref:i},...r)}function Hf(e,t){return e.length===0?t:q(S,{children:[e.map(([e,{macro:t,error:n}],r)=>q(Sf,{macro:t,error:Error(`in attribute \"${e}\": ${Jc(n)}`)},r)),t]})}function Uf(e,t){if(e==null||e.nodeType!==Node.ELEMENT_NODE)return-1;let n=e.getAttribute(`data-tw`),r=`${t.nonce}:`;return n==null||!n.startsWith(r)?-1:parseInt(n.slice(r.length),10)}function Wf(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function Gf(e,t,n=!1){let r=Wf(e.trim());if(n)for(let e of Array.from(r.childNodes))e.nodeType===Node.ELEMENT_NODE&&e.nodeName===`P`&&e.replaceWith(...Array.from(e.childNodes));return q(S,{children:Array.from(r.childNodes).map((e,n)=>Kf(e,n,t))})}function Kf(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${Lf}`)&&Uf(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=zf(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=Uf(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===Mf,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=Rf(t,n);r.every(e=>typeof e==`string`)||(c??(c={}),c[e]=r.map(e=>typeof e==`string`?{type:`text`,value:e}:n.nodes[e]))}let l=Array.from(r.childNodes).map((e,t)=>Kf(e,t,n));if(c)return q(Bf,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=$f(s,o);return d.length>0?q(Vf,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var qf=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.dfn.em.i.kbd.label.mark.meter.output.progress.q.rp.rt.ruby.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`)),Jf=new Set([`value`,`checked`,`selected`,`muted`]),Yf=new Set([`allowfullscreen`,`async`,`autofocus`,`autoplay`,`checked`,`controls`,`default`,`defer`,`disabled`,`formnovalidate`,`hidden`,`inert`,`ismap`,`itemscope`,`loop`,`multiple`,`muted`,`nomodule`,`novalidate`,`open`,`playsinline`,`readonly`,`required`,`reversed`,`selected`]),Xf=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),Zf=/^[A-Za-z_:][\\w:.-]*$/;function Qf(e,t,n){if(Zf.test(t)){e.setAttribute(t,n);return}let r=Wf(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function $f(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();Yf.has(e)&&o!==``&&a===``||(!t&&Jf.has(e)?n[e]=e!==`value`&&o===``?!0:a:!Zf.test(i)||e.startsWith(`on`)||e===`translate`||t&&(Xf.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function ep(e){let t=j(null);return Ne(()=>{let n=t.current;if(!(!n||e.length===0)){for(let[t,r]of e)Qf(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var tp=new Map;function np(e){if(!e.includes(`&`))return e;let t=tp.get(e);return t===void 0&&(t=Wf(`<i title=\"${e.replace(/\"/g,`"`)}\"></i>`).firstChild.getAttribute(`title`)??e,tp.set(e,t)),t}var rp=/\\{[$_@%]\\w/,ip=new Map,ap=2e3;function op(e){let t=ip.get(e);return t===void 0&&(t=Rc(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:zc(t.nodes,np)}),ip.size>=ap&&ip.clear(),ip.set(e,t)),t}function sp(e,t,n,r){if(Bo(e)){if(!t.includes(`&`)&&!rp.test(t))return t;let i=qc(t,n,np);for(let t of i.errors)r.push([e,t]);return i.text}if(!Fc(t))return np(t);let i=op(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),np(t);let a=Gc(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function cp({node:e}){let t=Yc(),{nobr:n,locals:r,raw:i,inline:a}=tl(),o=Ie(jf),s=e.tag.toLowerCase(),c=s===`svg`,l=!i&&(c||Nf.has(s)),u=[],{props:d,direct:f}=$f(Object.entries(e.attributes).map(([e,n])=>[e,sp(e,n,t,u),n]),o||c),p=ep(f);p&&(d.ref=p);let m=qf.has(s),h;e.children.length>0&&(i||l?h=hp(e.children):(h=Cp(e.children,{nobr:n,locals:r,inline:m}),m!==a&&(h=q(kf.Provider,{value:m,children:h}))));let g=b(e.tag,d,h);return c&&!o&&(g=q(jf.Provider,{value:!0,children:g})),Hf(u,l?q(Af.Provider,{value:!0,children:g}):g)}function lp(){let e=Ie(Pf),t=tl();return!e||e.length===0?null:q(S,{children:Cp(e,t)})}var up=new WeakMap,dp=0;function fp(e){let t=up.get(e);return t===void 0&&(t=`n${dp++}`,up.set(e,t)),t}function pp(e,t){if(lc(e.name))return null;let n=_c(e.name);if(n)return q(rl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);let r=rc(e.name);return r?q(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):q(`span`,{class:`error`,children:`{unknown macro: ${e.name}}`},t)}function mp(e){if(e.type===`text`)return e.value;let t=fp(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?q(lp,{},t):q($c,{node:e},t);case`expression`:return q(el,{node:e},t);case`macro`:return pp(e,t);case`html`:return q(cp,{node:e},t);default:return e}}function hp(e){return e.length===0?null:e.map(e=>mp(e))}var gp=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,_p=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,vp=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,yp=` \t\\r\n`;function bp(e,t,n,r){let i=t;if(n===1)for(;i<e.length&&r.includes(e[i]);)i++;else for(;i>0&&r.includes(e[i-1]);)i--;return i}function xp(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:bp(e,0,1,` \t`),i=t===n.length-1?e.length:bp(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function Sp(e,t,n){let r=zf(xp(e),t).filter(e=>e!==``);return n?q(S,{children:r}):b(`p`,null,...r)}function Cp(e,t){if(e.length===0)return null;if(t?.raw)return hp(e);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||_p.test(e.value))))return e.map(e=>mp(e));let n=[],r={nonce:Math.random().toString(36).slice(2,10)||`0`,components:n,nodes:[]},i=``;for(let t=0;t<e.length;t++){let a=e[t];if(a.type===`text`){i+=a.value;continue}let o=n.length;n.push(mp(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=Lf),i+=Ff(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,bp(i,0,1,yp)),s=o.length===i.length?``:i.slice(bp(i,i.length,-1,yp)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?q(S,{children:[o,e,s]}):e,u=i.replace(vp,``);return!gp.test(u)&&!_p.test(u)?l(Sp(c,r,a)):l(Gf(pf(i,{inline:t?.inline}),r,a))}var wp=2**32-1,Tp=wp-1,Ep=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Dp=Symbol();function Op(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Dp?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(Vp(i))}return n}var kp=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function Ap(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===kp}function jp(e){return Object.prototype.toString.call(e).slice(8,-1)}function Mp(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function Np(e){switch(e){case`\"`:return`\\\\\"`;case`<`:return`\\\\u003C`;case`\\\\`:return`\\\\\\\\`;case`\n`:return`\\\\n`;case`\\r`:return`\\\\r`;case`\t`:return`\\\\t`;case`\\b`:return`\\\\b`;case`\\f`:return`\\\\f`;case`\\u2028`:return`\\\\u2028`;case`\\u2029`:return`\\\\u2029`;default:return e<` `?`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}var Pp=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function Fp(e){if(!Pp.test(e)&&e.isWellFormed())return`\"${e}\"`;let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let a=e.charCodeAt(i);if(a>=55296&&a<=57343){if(a<=56319&&i+1<r&&(e.charCodeAt(i+1)&64512)==56320){i+=1;continue}t+=e.slice(n,i)+`\\\\u${a.toString(16)}`,n=i+1;continue}let o=Np(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var Ip=64,Lp=new Map;function Rp(e){if(e.length>Ip)return Fp(e);let t=Lp.get(e);return t===void 0&&(Lp.size>=1024&&Lp.clear(),t=Fp(e),Lp.set(e,t)),t}function zp(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var Bp=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Vp(e){return Bp.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Hp(e){return!(!Number.isInteger(e)||e<0||e>Tp)}function Up(e){return!(!Number.isInteger(e)||e<0||e>wp)}function Wp(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return Hp(+e)}function Gp(e){for(var t=e.length-1;t>=0&&!Wp(e[t]);t--);return t+1}function Kp(e){let t=Object.keys(e);return t.length=Gp(t),t}function qp(e){return new Uint8Array(e).toBase64()}function Jp(e){return Uint8Array.fromBase64(e).buffer}function Yp(e){return Buffer.from(e).toString(`base64`)}function Xp(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function Zp(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function Qp(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}var $p=typeof Uint8Array.fromBase64==`function`,em=typeof process==`object`&&process.versions?.node!==void 0,tm=$p?qp:em?Yp:Zp,nm=$p?Jp:em?Xp:Qp;function rm(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var im=Object.freeze({kind:`not-plain`}),am=Object.freeze({kind:`symbol-keys`}),om=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>jp(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>(Mp(e)&&(e=new Uint8Array(e)),{buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>Kp(e),shapeOf:e=>Ap(e)?zp(e).length>0?am:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:im,get:(e,t)=>e[t]}),sm=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,cm=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,lm=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{try{sm.call(t)}catch(e){if(!cm)throw e;cm.call(t)}let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[Tp]=void 0,delete t[Tp],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function um(){throw Error(`Invalid input`)}function dm(e,t,n){return fm(JSON.parse(e),t,n)}function fm(e,t,n){let r=rm(lm,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&um();let i=e,a=Array(i.length),o=null;function s(e){return(!Hp(e)||e>=i.length)&&um(),i[e]}function c(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if((n||typeof e!=`number`)&&um(),e in a)return a[e];e>=i.length&&um();let l=i[e];if(!l||typeof l!=`object`)a[e]=r.fromPrimitive(l);else if(Array.isArray(l))if(typeof l[0]==`string`){let n=l[0],u=t&&Object.hasOwn(t,n)?t[n]:void 0;if(u){let t=l[1];if(typeof t!=`number`&&(t=i.push(l[1])-1),Object.hasOwn(a,t))return a[e]=u(a[t]);if(o??(o=new Set),o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=u(c(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(l[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<l.length;e+=1)r.addValue(t,c(l[e]));break;case`Map`:let i=r.createMap();a[e]=i;for(let e=1;e<l.length;e+=2)r.addEntry(i,c(l[e]),c(l[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(l[1],l[2]);break;case`Object`:{let t=l[1];if(!(t===-3||t===-4||t===-5||t===-6)){let e=s(t),n=Array.isArray(e)&&e[0]===`BigInt`;(e===void 0||typeof e==`object`)&&!n&&um()}a[e]=r.box(c(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(l[1]));break;case`null`:let o=r.createNullPrototypeObject();a[e]=o;for(let e=1;e<l.length;e+=2){let t=l[e];if(typeof t!=`string`)throw Error(`Cannot parse an object with a non-string key`);if(t===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(o,t,c(l[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=l[1],i=s(t);(!Array.isArray(i)||i[0]!==`ArrayBuffer`)&&um();let o=c(t);a[e]=r.fromViewInfo(n,o,l[2],l[3]);break}case`ArrayBuffer`:{let t=l[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(nm(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,l[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(l[0]===-7){let t=l[1];Up(t)||um();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!Hp(i)||i>=t)&&um(),r.set(n,i,c(l[e+1]))}}else{let t=r.createArray(l.length);a[e]=t;for(let e=0;e<l.length;e+=1){let n=l[e];n!==-2&&r.set(t,e,c(n))}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(l)){if(e===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(t,e,c(l[e]))}}return a[e]}return c(0)}function pm(e,t,n){let r=mm(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function mm(e,t,n,r){let i=rm(om,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(e,n){throw new Ep(e,Op(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?hm(i.toPrimitive(e)):`...`}),n,t)}function d(t,n){let r=i.typeOf(t);if(r===`undefined`)return-1;let f;if(r===`number`){if(f=i.toPrimitive(t),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(t);if(o.has(p))return o.get(p);n??(n=l++),o.set(p,n);for(let{key:e,fn:r}of s){let i=r(t);if(i)return a[n]=`[\"${e}\",${d(i)}]`,n}r===`function`?u(`Cannot stringify a function`,t):r===`symbol`&&u(`Cannot stringify a Symbol primitive`,t);let m=``;if(r!==`object`)m=hm(r===`number`?f:i.toPrimitive(t));else if(i.isThenable(t)){e||u(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,t);let r=c.slice();m=i.toPromise(t).then(e=>{c=r;let t=d(e,n);t<0&&(a[n]=t)}),m.catch(()=>{})}else{let e=i.tagOf(t);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`[\"Object\",${d(i.unbox(t))}]`;break;case`Date`:m=`[\"Date\",\"${i.toISOString(t)}\"]`;break;case`URL`:m=`[\"URL\",${Fp(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${Fp(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${Fp(n)},\"${r}\"]`:`[\"RegExp\",${Fp(n)}]`;break;case`Array`:{let e=!1,n=i.lengthOf(t);m=`[`;for(let r=0;r<n;r+=1)if(r>0&&(m+=`,`),i.hasOwn(t,r))c.push(r),m+=d(i.get(t,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(t),a=r.length,o=String(n).length;if((n-a)*3>4+o+a*(o+1)){m=`[-7,`+n;for(let e=0;e<r.length;e++){let n=r[e];c.push(+n),m+=`,`+n+`,`+d(i.get(t,n)),c.pop()}break}else e=!0,m+=-2}m+=`]`;break}case`Set`:m=`[\"Set\"`;for(let e of i.valuesOf(t))m+=`,${d(e)}`;m+=`]`;break;case`Map`:m=`[\"Map\"`;for(let[e,n]of i.entriesOf(t))c.push(Dp,e),m+=`,${d(e)},${d(n)}`,c.pop(),c.pop();m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.length}`),m+=`]`;break}case`DataView`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`[\"ArrayBuffer\",\"${tm(i.toArrayBuffer(t))}\"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`[\"${e}\",${Fp(i.toStringValue(t))}]`;break;default:{let e=i.shapeOf(t);if(e.kind===`not-plain`&&u(`Cannot stringify arbitrary non-POJOs`,t),e.kind===`symbol-keys`&&u(`Cannot stringify POJOs with symbolic keys`,t),e.kind===`null-proto`){m=`[\"null\"`;for(let n of e.keys)n===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),c.push(n),m+=`,${Rp(n)},${d(i.get(t,n))}`,c.pop();m+=`]`}else{m=`{`;let n=!1;for(let r of e.keys)r===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),n&&(m+=`,`),n=!0,c.push(r),m+=`${Rp(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function hm(e){let t=typeof e;return t===`string`?Fp(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var gm=new Map,_m=new Map;function vm(e,t){gm.set(e,t),_m.set(t,e)}function ym(e){let t=Object.getPrototypeOf(e);return t===null?void 0:_m.get(t.constructor)}var bm=`c:`,xm=`E:`,Sm=`S`,Cm=`K`,wm=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),Tm=new Map([...wm].map(([e,t])=>[t,e.constructor])),Em=[`message`,`cause`,`errors`],Dm=e=>typeof e==`object`&&!!e,Om=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function km(e){let t={};if(e instanceof Error)for(let n of Em)G(e,n)&&Om(t,n,e[n]);for(let n of Object.keys(e))Om(t,n,e[n]);return t}function Am(e){for(let t of Em)G(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var jm=e=>e.length===1&&JSON.stringify(e).length>3;function Mm(){let e={};for(let[t,n]of gm)e[bm+t]=e=>Dm(e)&&Object.getPrototypeOf(e)===n.prototype&&km(e);for(let[t,n]of wm)e[xm+n]=e=>Dm(e)&&Object.getPrototypeOf(e)===t&&km(e);return e[Sm]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[Cm]=e=>{if(!Dm(e)||Object.getPrototypeOf(e)!==Object.prototype)return!1;let t=Object.keys(e);if(!t.some(jm))return!1;if(t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])},e}function Nm(e){return t=>{if(!Dm(t)||Object.getPrototypeOf(t)!==Object.prototype){if(Dm(t)&&ym(t)===e)return t;throw TypeError(`spindle: Malformed data for class \"${e}\"`)}let n=gm.get(e);if(!n)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&Am(t),t}}function Pm(e){let t=Tm.get(e);if(t)return n=>{if(Object.getPrototypeOf(n)===t.prototype)return n;if(!Dm(n)||Object.getPrototypeOf(n)!==Object.prototype)throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),Am(n),n}}var Fm=new WeakMap;function Im(e){if(!Array.isArray(e)||e.length%2!=0)throw TypeError(`spindle: Malformed object entries`);let t=Fm.get(e);t||Fm.set(e,t={});for(let n=0;n<e.length&&G(e,n);n+=2){let r=e[n];if(typeof r!=`string`||r===`__proto__`)throw TypeError(`spindle: Malformed object entries`);Om(t,r,G(e,n+1)?e[n+1]:void 0)}return t}var Lm=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=Rm(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>Rm(t)});function Rm(e){if(typeof e==`string`){if(e===Sm)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===Cm)return Im;if(e.startsWith(bm))return Nm(e.slice(2));if(e.startsWith(xm))return Pm(e.slice(2))}}function zm(e,t){if(!(e instanceof Error)||e.name!==`DevalueError`)return e instanceof Error?e:Error(String(e));let{path:n,value:r}=e,i=n?` (at ${n})`:``,a=e.message;return typeof r==`function`?a=`Cannot save a function`:Dm(r)&&/non-POJO/.test(e.message)?a=`Cannot save an instance of class \"${Object.getPrototypeOf(r)?.constructor?.name??`?`}\", which is not registered (see Story.registerClass)`:typeof r==`symbol`?a=`Cannot save a unique symbol (only Symbol.for() symbols)`:/symbolic keys/.test(e.message)?a=`Cannot save an object with symbol keys`:/__proto__/.test(e.message)&&(a=`Cannot save a property named \"__proto__\"`),TypeError(`spindle: ${a}${i}`)}function Bm(e){try{return pm(e,Mm())}catch(t){throw zm(t,e)}}function Vm(e){return dm(e,Lm)}var Hm=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},Um={};function Wm(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new Hm}function Gm(e,t){Wm(e);let n=t;for(let t=e;t<1;t++){let e=Um[t];if(!e)throw new Hm;n=e(n)}return n}var Km=e=>e&&new Map(Object.entries(e));function qm(e){if(!(e instanceof TypeError))return e;let t=e.message.replace(/\\(at \\.variables(?=[.[]|\\))/,`(at $`).replace(/\\(at \\.history\\[(\\d+)\\]\\.variables(.*)\\)$/,(e,t,n)=>`(at $${n} in history moment ${t})`).replace(/\\(at \\$\\.?/,`(at $`);return t===e.message?e:TypeError(t)}function Jm(e){try{return{formatVersion:1,data:Bm({...e,visitCounts:Km(e.visitCounts),renderCounts:Km(e.renderCounts)})}}catch(e){throw qm(e)}}var Ym=()=>Error(`Invalid save data`);function Xm(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Zm(e){return e==null?!0:Xm(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var Qm=e=>Xm(e)&&typeof e.passage==`string`&&Xm(e.variables)&&typeof e.timestamp==`number`&&Zm(e.prng),$m=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function eh(e){if(!Xm(e)||typeof e.passage!=`string`||!Xm(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(Qm)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:$m(e.visitCounts)&&$m(e.renderCounts)&&Zm(e.prng)}var th=e=>e instanceof Map?Ps(Object.fromEntries(e)):void 0;function nh(e){if(typeof e!=`object`||!e)throw Ym();let{formatVersion:t,data:n}=e;if(Wm(t),typeof n!=`string`)throw Ym();let r=Vm(Gm(t,n));if(!eh(r))throw Ym();let i={...r,visitCounts:th(r.visitCounts),renderCounts:th(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var rh=`Invalid save file format`;function ih(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ah=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function oh(e){let t=console.warn;console.warn=()=>{};try{nh(e)}finally{console.warn=t}}function sh(e){if(!ih(e))throw Error(rh);if(!G(e,`formatVersion`))throw e.version===1?new Hm:Error(rh);if(Wm(e.formatVersion),typeof e.ifid!=`string`)throw Error(rh);let t=e.save;if(!ih(t)||!ih(t.meta))throw Error(rh);let n=t.meta;if(ah.some(e=>typeof n[e]!=`string`))throw Error(rh);try{oh(t.payload)}catch(e){throw e instanceof Hm?e:Error(rh)}}function ch(e){try{return sh(e),!0}catch{return!1}}function lh(e){return JSON.stringify(e).length}function uh(e){return{saves:e(`saves`,{ifid:e=>e.meta.ifid,playthroughId:e=>e.meta.playthroughId}),playthroughs:e(`playthroughs`,{ifid:e=>e.ifid}),meta:e(`meta`,{})}}function dh(e,{saves:t,playthroughs:n,meta:r},i){async function a(e,t,n,r){let i=(await e.find(n,r)).map(t);for(let t of i)await e.delete(t);return i}async function o(e){for(let t of await r.keys())e(t)&&await r.delete(t)}let s=e=>e.meta.id,c=e=>e.id;return{type:e,putSave:e=>t.put(e.meta.id,e),getSave:e=>t.get(e),deleteSave:e=>t.delete(e),getSavesByIfid:e=>t.find(`ifid`,e),deleteSavesByIfid:async e=>{await a(t,s,`ifid`,e)},deleteSavesByPlaythrough:e=>a(t,s,`playthroughId`,e),putPlaythrough:e=>n.put(e.id,e),getPlaythroughsByIfid:e=>n.find(`ifid`,e),deletePlaythroughsByIfid:async e=>{await a(n,c,`ifid`,e)},deletePlaythroughById:e=>n.delete(e),getMeta:e=>r.get(e),setMeta:(e,t)=>r.put(e,t),deleteMeta:e=>r.delete(e),deleteMetaByPrefix:e=>o(t=>t.startsWith(e)),deleteMetaByIfid:e=>o(t=>t.includes(e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function fh(){let e=e=>structuredClone(e),t=[];function n(n,r){let i=new Map;return t.push(i),{get:async t=>e(i.get(t)),put:async(t,n)=>{i.set(t,e(n))},delete:async e=>{i.delete(e)},find:async(t,n)=>[...i.values()].filter(e=>r[t](e)===n).map(e),keys:async()=>[...i.keys()]}}return dh(`memory`,uh(n),async()=>{for(let e of t)e.clear()})}var ph={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},mh={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function hh(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function gh(e,t){localStorage.setItem(e,JSON.stringify(t))}function _h(e){localStorage.removeItem(e)}function vh(e){return hh(e)??[]}function yh(e,t){let n=vh(e);n.includes(t)||(n.push(t),gh(e,n))}function bh(e,t){let n=vh(e).filter(e=>e!==t);n.length>0?gh(e,n):_h(e)}var xh=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function Sh(){function e(e,t){let n=ph[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:mh[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>hh(`${n}${e}`),async put(e,t){let r=hh(`${n}${e}`),a=i(t);if(r!==void 0)for(let t of i(r))a.includes(t)||bh(t,e);gh(`${n}${e}`,t);for(let t of a)yh(t,e)},async delete(e){let t=hh(`${n}${e}`);if(t!==void 0)for(let n of i(t))bh(n,e);_h(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of vh(`${i.prefix}${t}`)){let t=hh(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>xh(n).map(e=>e.slice(n.length))}}return dh(`localstorage`,uh(e),async()=>{for(let e of xh(`spindle.`))_h(e)})}var Ch=`spindle`,wh=1,Th={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function Eh(){let e=null;function t(){return e||(e=new Promise((e,t)=>{let n=indexedDB.open(Ch,wh);n.onupgradeneeded=()=>{let e=n.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(Th)){if(e.objectStoreNames.contains(t))continue;let i=e.createObjectStore(t,{keyPath:n});for(let[e,t]of Object.entries(r))i.createIndex(e,t,{unique:!1})}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),e)}function n(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function r(e){let r=e===`meta`,i=async(r,i)=>n(i((await t()).transaction(e,r).objectStore(e)));return{async get(e){let t=await i(`readonly`,t=>t.get(e));return r?t?.value:t},async put(e,t){await i(`readwrite`,n=>n.put(r?{key:e,value:t}:t))},async delete(e){await i(`readwrite`,t=>t.delete(e))},async find(e,t){return await i(`readonly`,n=>n.index(e).getAll(t))??[]},keys:async()=>await i(`readonly`,e=>e.getAllKeys())}}return dh(`indexeddb`,uh(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(Ch);n.onsuccess=()=>e(),n.onerror=()=>t(n.error)})})}var Dh=null;async function Oh(){if(typeof indexedDB<`u`)try{return await new Promise((e,t)=>{let n=indexedDB.open(`__spindle_probe__`,1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(`__spindle_probe__`),e()},n.onerror=()=>t(n.error)}),Eh()}catch{}if(typeof localStorage<`u`)try{let e=`__spindle_probe__`;localStorage.setItem(e,`1`);let t=localStorage.getItem(e);if(localStorage.removeItem(e),t===`1`)return Sh()}catch{}return fh()}var kh=null;function Z(){if(Dh)return Promise.resolve(Dh);if(!kh){let e=Oh().then(t=>(kh===e&&(Dh=t),t));kh=e}return kh}function Ah(){Dh=null,kh=null}function jh(){return Dh?.type??`memory`}var Mh=e=>Object.prototype.toString.call(e).slice(8,-1),Nh=e=>Mh(e).startsWith(`Temporal.`),Ph=e=>e instanceof Number||e instanceof String||e instanceof Boolean||Mh(e)===`BigInt`;function Fh(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof URL||e instanceof URLSearchParams||e instanceof Error||Ph(e)||Nh(e)}function Ih(e){if(!Fh(e))return;let t=e instanceof Error?`Error`:Mh(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}function Lh(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||e in Object.prototype&&!G(n,e))return;n=n[e]}return n}var Rh=e=>e===`length`||/^(0|[1-9]\\d*)$/.test(e),zh=Ih;function Bh(e){let t=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));for(let n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],enumerable:!0,writable:!0,configurable:!0});return t}function Vh(e,t,n,r={}){let i=Gh(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function Hh(e,t){let n=t[t.length-1];Uh(t);let r=e;for(let e of t.slice(0,-1)){if(typeof r!=`object`||!r||!G(r,e))return;r=r[e]}if(typeof r!=`object`||!r||!G(r,n))return;let i=Gh(e,t,!1);if(Array.isArray(i)&&jt(i)&&t.length>1){let r=Ln(i).slice();delete r[Number(n)];let a=Gh(e,t.slice(0,-1),!1);a[t[t.length-2]]=r;return}delete i[n]}function Uh(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function Wh(e,t,n,r){let i=zh(e)??(Array.isArray(e)&&!Rh(t)?`an array`:``);if(i)throw TypeError(`spindle: Cannot set property \"${t}\" on ${i} (at \"${n.slice(0,r).join(`.`)}\")`)}function Gh(e,t,n){Uh(t);let r=jt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];Wh(i,a,t,e);let o=G(i,a)?i[a]:void 0;if(typeof o!=`object`||!o){if(!n)throw TypeError(`spindle: Cannot set property \"${t[e+1]}\" on ${o===null?`null`:typeof o} (at \"${t.slice(0,e+1).join(`.`)}\")`);o={},i[a]=o}else r&&!jt(o)&&!zh(o)&&(o=Bh(o),i[a]=o);i=o}return Wh(i,t[t.length-1],t,t.length-1),i}function Kh(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var qh=[`message`,`cause`,`errors`];function Jh(e,t={}){let n=new Map,r=(e,t)=>(n.set(e,t),t);function i(e,t){for(let n of Object.keys(e))Ts(t,n,o(e[n]));return t}function a(e){if(e instanceof Date)return r(e,new Date(e.getTime()));if(e instanceof RegExp)return r(e,new RegExp(e.source,e.flags));if(e instanceof ArrayBuffer)return r(e,e.slice(0));if(ArrayBuffer.isView(e)){let t=o(e.buffer);if(e instanceof DataView)return r(e,new DataView(t,e.byteOffset,e.byteLength));let n=e.constructor,i=e.length;return r(e,new n(t,e.byteOffset,i))}if(e instanceof URL)return r(e,new URL(e.href));if(e instanceof URLSearchParams)return r(e,new URLSearchParams(e));if(Ph(e))return r(e,Object(e.valueOf()));if(Nh(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...qh,`stack`])G(e,n)&&Object.defineProperty(t,n,{value:o(e[n]),writable:!0,configurable:!0});return i(e,t)}}function o(e){if(typeof e!=`object`||!e)return e;let s=e;if(n.has(s))return n.get(s);if(Array.isArray(e)){let t=r(s,Array(e.length));for(let n=0;n<e.length;n++)n in e&&(t[n]=o(e[n]));return t}if(e instanceof Map){let t=r(s,new Map);for(let[n,r]of e)t.set(o(n),o(r));return t}if(e instanceof Set){let t=r(s,new Set);for(let n of e)t.add(o(n));return t}let c=a(s);if(c!==void 0)return c;let l=ym(s)!==void 0||Kh(e);return!l&&t.keepUnregistered?e:i(s,r(s,l?Object.create(Object.getPrototypeOf(s)):{}))}return o(e)}function Yh(e,t){return ig(e,t,Xh())}function Xh(){let e=new Map;return(t,n)=>{let r=e.get(t);if(r?.has(n))return!0;r?r.add(n):e.set(t,new Set([n]))}}function Zh(){let e=new Map,t=new Map,n=(n,r)=>{let i=e.get(n);if(i!==void 0)return i===r;if(t.has(r))return!1;e.set(n,r),t.set(r,n)};return n.strict=!0,n}function Qh(e,t){return ig(e,t,Zh())}function $h(e,t){let n=new Map;function r(e,t){if(e===t||!eg(t)||!eg(e))return t;if(n.has(t))return n.get(t);if(Qh(e,t))return n.set(t,e),e;if(t instanceof Map&&e instanceof Map){let i=new Map;n.set(t,i);for(let[n,a]of t)i.set(n,e.has(n)?r(e.get(n),a):a);return i}if(Array.isArray(t)&&Array.isArray(e)){let i=Array(t.length);n.set(t,i);for(let n=0;n<t.length;n++)n in t&&(i[n]=n<e.length?r(e[n],t[n]):t[n]);return i}if(og(e,t,!1)){let i=Object.create(Object.getPrototypeOf(t));n.set(t,i);let a=t;for(let t of Object.keys(a))Ts(i,t,G(e,t)?r(e[t],a[t]):a[t]);return i}return n.set(t,t),t}return r(e,t)}var eg=e=>typeof e==`object`&&!!e;function tg(e,t){let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function ng(e,t,n){if(e instanceof Date)return Object.is(e.getTime(),t.getTime());if(e instanceof RegExp)return String(e)===String(t);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return tg(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(Ph(e))return Object.is(e.valueOf(),t.valueOf());if(Nh(e))return String(e)===String(t);if(e instanceof Error)return qh.every(r=>G(e,r)===G(t,r)&&ig(e[r],t[r],n))&&rg(e,t,n)}function rg(e,t,n){let r=e,i=t,a=Object.keys(r);if(a.length!==Object.keys(i).length)return!1;for(let e of a)if(!G(i,e)||!ig(r[e],i[e],n))return!1;return!0}function ig(e,t,n){if(Object.is(e,t)&&!(n.strict&&eg(e)))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=n(e,t);if(r!==void 0)return r;if(e instanceof Map||e instanceof Set){let r=t;if(e.size!==r.size)return!1;let i=e.entries(),a=r.entries();for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!ig(e.value,t.value,n))return!1;return!0}let i=ng(e,t,n);if(i!==void 0)return i;if(Array.isArray(e)){let r=t;if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(t in e!=t in r||!ig(e[t],r[t],n))return!1;return!0}return rg(e,t,n)}function ag(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Fh(e)}function og(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t):ag(e)&&ag(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function sg(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(og(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):Yh(t,i)||r.push({key:e,kind:`changed`,after:i}))};if(Array.isArray(t)){let n=e,a=t;for(let e=0;e<Math.min(n.length,a.length);e++)i(String(e),n[e],a[e]);for(let e=n.length;e<a.length;e++)r.push({key:String(e),kind:`added`,after:a[e]});for(let e=a.length;e<n.length;e++)r.push({key:String(e),kind:`deleted`});return r}for(let n of Object.keys(t))G(e,n)?i(n,e[n],t[n]):r.push({key:n,kind:`added`,after:t[n]});for(let n of Object.keys(e))G(t,n)||r.push({key:n,kind:`deleted`});return r}function cg(e,t){let n=[],r=new Set;return(function e(t,i,a){if(!r.has(i)){r.add(i);for(let r of sg(t,i,!1)){let t=[...a,r.key];r.kind===`nested`?e(r.before,r.after,t):n.push(r.kind===`deleted`?{path:t,deleted:!0}:{path:t,deleted:!1,value:r.after})}r.delete(i)}})(e,t,[]),n}function lg(e,t){let n=Lh(e,t.path.slice(0,-1));if(typeof n!=`object`||!n)return t.deleted;let r=t.path[t.path.length-1];return G(n,r)?!t.deleted&&Yh(n[r],t.value):t.deleted}function ug(e,t){t.deleted?Hh(e,t.path):Vh(e,t.path,t.value)}function dg(e,t,n,r){let i=Array.isArray(e)?e:void 0;for(let a of sg(t,n,!0)){let{key:t}=a;if(a.kind===`deleted`)i?i.length=Math.min(i.length,Number(t)):delete e[t];else if(i&&a.kind===`added`)i.push(Jh(a.after));else if(i&&Number(t)>=i.length)continue;else (a.kind!==`nested`||!(r?.(t,a.before,a.after)||Yh(a.before,a.after)))&&(e[t]=Jh(a.after))}}var fg=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),pg=new Map;function mg(e,t){if(!fg.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=pg.get(e);return n||(n=new Set,pg.set(e,n)),n.add(t),()=>{n.delete(t)}}function hg(e,t){let n=pg.get(e);if(n)for(let e of[...n])t(e)}function gg(e,...t){hg(e,e=>e(...t))}function _g(e,...t){hg(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var vg=null,yg=null;function bg(e){vg=e}function xg(e){yg=e}function Sg(e){if(yg)try{let t=Function(`passage`,`variables`,yg)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(vg)try{let t=vg(e);if(typeof t==`string`&&t.trim())return t.trim()}catch{}let t=new Date().toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return`${e.passage} - ${t}`}var Cg=Promise.resolve();function wg(e){let t=Cg.then(e);return Cg=t.catch(()=>{}),t}function Tg(e){return(...t)=>wg(()=>e(...t))}var Eg=e=>Tg(async t=>e(await(await Z()).getSave(t))),Dg=e=>Tg(async(t,n)=>e(await i_(t,n))),Og=Tg(kg);async function kg(e,t=crypto.randomUUID()){let n=await Z(),r=await Mg(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};return await n.putPlaythrough(i),await n.setMeta(jg(e),r),await n.setMeta(Ng(e),t),t}var Ag=/^Playthrough (\\d+)$/;function jg(e){return`playthroughCount.${e}`}async function Mg(e){let t=await Z(),n=await t.getMeta(jg(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Ag.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function Ng(e){return`currentPlaythroughId.${e}`}var Pg=Tg(Fg);async function Fg(e,t){let n=await Z();await Ig(e,t,new Date().toISOString());let r=Ng(e);await n.getMeta(r)!==t&&await n.setMeta(r,t)}async function Ig(e,t,n){let r=await Z();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function Lg(e){return wg(async()=>({id:await(await Z()).getMeta(Ng(e))??await kg(e),knownSaves:await m_(e)}))}function Rg(e,t,n,r){try{let i=n();return ms(()=>gg(`beforesave`,e,t)),r(i()).then(t=>(ms(()=>gg(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function zg(e,t){let n=Jm(t);return{meta:{...e,estimatedBytes:lh(n)},payload:n}}var Bg=Tg(Vg);async function Vg(e,t,n,r={}){let i=new Date().toISOString(),a=zg({id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Sg(n),passage:n.passage,custom:r},n);return await(await Z()).putSave(a),a}var Hg=Tg(Ug);async function Ug(e,t,n,r){let i=await Z(),a=await i.getSave(e);if(!a)return;let o=zg({...a.meta,...r?{playthroughId:r}:{},updatedAt:new Date().toISOString(),title:a.meta.userTitle===!0?a.meta.title:Sg(t),passage:t.passage,...n==null?{}:{custom:{...a.meta.custom,...n}}},t);return await i.putSave(o),o}var Wg=e=>e&&nh(e.payload),Gg=e=>nh(e);Eg(Wg);function Kg(e){return wg(async()=>{let t=await Z(),n=await t.getSave(e);await t.deleteSave(e),n&&await s_(n.meta.ifid,t=>t===e)})}function qg(e,t){return wg(async()=>{let n=await Z(),r=await n.getSave(e);if(!r)return;let i={...r,meta:{...r.meta,title:t,userTitle:!0,updatedAt:new Date().toISOString()}};await n.putSave(i)})}var Jg=Tg(async function(e){let t=await Z(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(let e of r)i.set(e.id,e);let a=new Map;for(let e of n){let t=e.meta.playthroughId,n=a.get(t);n?n.push(e):a.set(t,[e])}for(let e of a.values())e.sort((e,t)=>new Date(t.meta.updatedAt).getTime()-new Date(e.meta.updatedAt).getTime());let o=[],s=[...i.values()].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());for(let e of s){let t=a.get(e.id)??[];o.push({playthrough:e,saves:t})}for(let[t,n]of a)i.has(t)||o.push({playthrough:{id:t,ifid:e,createdAt:n[0]?.meta.createdAt??new Date().toISOString(),label:`Unknown Playthrough`},saves:n});return o}),Yg=`autosave.`,Xg=`slot.`,Zg=`slotIndex.`;function Qg(e){return e!=null&&e!==``}function $g(e,t){return Qg(t)?`${Xg}${t}.${e}`:`${Yg}${e}`}var e_=e=>`${Zg}${e}`;async function t_(e,t){let n=await Z(),r=await n.getMeta(e_(e))??[],i=t(r);i!==r&&await n.setMeta(e_(e),i)}async function n_(e){return[void 0,...(await(await Z()).getMeta(e_(e))??[]).filter(Qg)]}async function r_(e,t){return(await Z()).getMeta($g(e,t))}async function i_(e,t){let n=await r_(e,t);return n?(await Z()).getSave(n):void 0}async function a_(e,t,n){await(await Z()).setMeta($g(e,t),n),Qg(t)&&await t_(e,e=>e.includes(t)?e:[...e,t])}async function o_(e,t){await(await Z()).deleteMeta($g(e,t)),Qg(t)&&await t_(e,e=>e.filter(e=>e!==t))}async function s_(e,t){for(let n of await n_(e)){let r=await r_(e,n);r&&t(r)&&await o_(e,n)}}var c_=e=>({isAutosave:!Qg(e),...Qg(e)?{slot:e}:{}});function l_(e,t){return{slot:Qg(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function u_(e,t,n,r,i){return wg(async()=>{let a=await t,o=await r_(e,r);if(o){let e=await Ug(o,n,i,a);if(e)return e}let s=await Vg(e,a,n,{...c_(r),...i});return await a_(e,r,s.meta.id),s})}async function d_(e,t){return await i_(e,t)!==void 0}Dg(Wg);function f_(e,t){return wg(async()=>{let n=await i_(e,t);if(!n)return;let r=nh(n.payload),{playthroughId:i}=n.meta;return i&&await Fg(e,i),{payload:r,playthroughId:i}})}var p_=Tg(m_);async function m_(e){let t=Object.create(null);for(let n of await n_(e))await d_(e,n)&&(t[n??``]=!0);return t}var h_=Tg(g_);async function g_(e,t){let n=await i_(e,t);return n?l_(n,t):null}var __=Tg(async e=>{let t=[];for(let n of await n_(e)){let r=await g_(e,n);r&&t.push(r)}return t}),v_=Tg(async(e,t)=>{let n=await r_(e,t);n&&(await(await Z()).deleteSave(n),await o_(e,t))}),y_=`spindle.session.`;function b_(e,t){let n=JSON.stringify(Jm(t));try{sessionStorage.setItem(`${y_}${e}`,n)}catch{}}function x_(e){try{let t=sessionStorage.getItem(`${y_}${e}`);return t?nh(JSON.parse(t)):void 0}catch(t){t instanceof Hm&&(console.warn(`spindle: ${t.message}; the session was not restored.`),S_(e));return}}function S_(e){try{sessionStorage.removeItem(`${y_}${e}`)}catch{}}function C_(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var w_=Eg(C_);async function T_(e,t){if(sh(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=Jh(e.save);return n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await Ig(t,n.meta.playthroughId,n.meta.createdAt),n}function E_(e,t){return wg(async()=>{let n=await T_(e,t);return await(await Z()).putSave(n),n})}var D_=Dg(C_);function O_(e,t,n){return wg(async()=>{let r=await T_(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...c_(n)};let o=await Z(),s=await r_(t,n);return await o.putSave(r),await a_(t,n,r.meta.id),s&&await o.deleteSave(s),l_(r,n)})}var k_=Tg(async function(e){let t=await Z(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e),i=0;for(let e of n)if(e.meta.estimatedBytes!=null)i+=e.meta.estimatedBytes;else{let n=lh(e.payload);e.meta.estimatedBytes=n,await t.putSave(e),i+=n}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}});function A_(e){return wg(async()=>{let t=await Z();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),S_(e)})}var j_=Tg(M_);async function M_(){if(await(await Z()).destroy(),Ah(),typeof sessionStorage<`u`){let e=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n?.startsWith(`spindle.session.`)&&e.push(n)}for(let t of e)sessionStorage.removeItem(t)}}function N_(e,t,n){return wg(async()=>{let r=await Z(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await s_(e,e=>a.has(e)),n&&await n.current===t)return await kg(e,n.id),!0;let o=Ng(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var P_=null;function F_(){P_&&(ge(null,P_),P_.remove(),P_=null)}function I_(){F_();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=qo(t.content),n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),P_=n,ge(b(()=>Cp(e),null),n),fy()}let n=e.storyData.passages.get(`SaveTitle`);n&&xg(n.content)}function L_(e){I_(),e&&Q.getState().loadFromPayload(e),gg(`storyinit`),e||fy()}var R_=[`variables`,`temporary`,`transient`],z_=[];function B_(){return z_[z_.length-1]?.work}function V_(){let e=Q.getState(),t=B_();return t?{...e,...t}:e}var H_=e=>Jh(e,{keepUnregistered:!0});function U_(e){return en(H_(e),!0)}function W_(e,t,n,r=z_){let i=n.path[0];for(let a of r)for(let r of[a.work[t],a.base[t]])try{ug(r,n.deleted?n:{...n,value:H_(n.value)})}catch{let n=e[t][i];G(e[t],i)?r[i]=H_(jt(n)?Ln(n):n):delete r[i]}}var G_=new Set(R_),K_=new Fn({autoFreeze:!1}),q_=!1;function J_(e,t){let n=[],r=e;for(let e of t){if(!ag(r))break;let t=String(e);n.push(t),r=G(r,t)?r[t]:void 0}return n}function Y_(e,t){let n=Lh(e,t.slice(0,-1)),r=t[t.length-1];return ag(n)&&G(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function X_(e,t,n){if(n.some(e=>e.path.length===1))return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!G(e,n)||e[n]!==t[n]).map(e=>Y_(t,[e]));let r=new Set,i=[];for(let e of n){let n=J_(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(Y_(t,n)))}return i}function Z_(e){if(q_){q_=!1;return}if(z_.length===0)return;$_(ev());let t=z_[z_.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=K_.produceWithPatches(n,e),a=R_.map(e=>{let t=i.filter(t=>t.path[0]===e);return[e,t.length?X_(n[e],r[e],t):[]]}),o=e=>e.deleted?e:{...e,value:H_(e.value)};for(let[e,n]of a)for(let r of n)ug(t.work[e],o(r));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!G_.has(e)&&t!==n[e]&&(i[e]=t)}let s=e;for(let[e,n]of a)for(let r of n){let n=r.path[0];try{ug(s[e],o(r))}catch{G(t.work[e],n)?s[e][n]=H_(t.work[e][n]):delete s[e][n]}W_(s,e,r)}}}var Q_=e=>({variables:Jh(e.variables),temporary:Jh(e.temporary),transient:Jh(e.transient)});function $_(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:R_.map(t=>[t,cg(e.base[t],e.work[t])])})),n=t.filter(({changes:e})=>e.some(([,e])=>e.length>0));if(n.length===0)return;for(let{scope:e,keepRunning:t}of n)t&&(e.base=Q_(e.work));q_=!0;try{Q.getState().updateVariables(r)}finally{q_=!1}function r(e){t.forEach(({scope:n,keepRunning:r,changes:i},a)=>{let o=e=>r?H_(e):e;for(let[r,s]of i){let i=new Set;for(let t of s){let a=t.path[0];if(!(i.has(a)||lg(e[r],t)))try{ug(e[r],t.deleted?t:{...t,value:o(t.value)})}catch{e[r][a]=o(n.work[r][a]),i.add(a)}}let c=t.slice(0,a).map(e=>e.scope);for(let t of s)W_(e,r,t,c)}})}}var ev=()=>z_.map(e=>({scope:e,keepRunning:!0}));function tv(e){let t=Q.getState();for(let n of R_)dg(e.work[n],e.work[n],t[n]);e.base=Q_(t)}function nv(e){if(z_.length===0)return e();$_(ev());let t=z_.splice(0);try{return e()}finally{z_.push(...t);for(let e of t)tv(e)}}function rv(e,t,n){let r=B_()??Q.getState(),i={work:Q_(r),base:Q_(r)},a=Os(Jh(t,{keepUnregistered:!0}));z_.push(i);try{ec(e,i.work.variables,i.work.temporary,a,i.work.transient)}finally{z_.pop()}$_([...ev(),{scope:i,keepRunning:!1}]);for(let e of Object.keys(a))Yh(a[e],t[e])||n(e,a[e]);for(let e of Object.keys(t))G(a,e)||n(e,void 0)}var iv=[],av=!1,ov=[],sv=null,cv=null;function lv(e){let t=V_();try{return!!$s(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function uv(e,t,n){let r=typeof t==`function`,i=r?void 0:t,a=r?t:void 0,o={name:i?.name,condition:e,callback:a,options:i,lastResult:lv(e),priority:i?.priority??0,macroKey:n};return iv.push(o),iv.sort((e,t)=>t.priority-e.priority),()=>{iv=iv.filter(e=>e!==o)}}function dv(e,t){return uv(e,t)}function fv(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);iv.some(e=>e.macroKey===r)||uv(e,t,r)}function pv(e){iv=iv.filter(t=>t.name!==e)}function mv(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run)try{rv(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&(ov.push({passageName:n.dialog}),sv?.()),n.goto&&Q.getState().navigate(n.goto)}}var hv=10;function gv(){for(let e=0;e<hv;e++){let e=!1,t=[...iv];for(let n of t){if(!iv.includes(n))continue;let t=lv(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(iv=iv.filter(e=>e!==n)),mv(n))}if(!e)break}}function _v(){if(!av){av=!0;try{gv()}finally{av=!1}}}var vv=0;function yv(){if(vv===0)return;let e=av;av=!0;try{gv()}finally{av=e}}function bv(){let e=Q.getState();vv++;let t=Q.subscribe(t=>{let n=e;e=t,t.navigationId===n.navigationId&&(t.variables===n.variables&&t.temporary===n.temporary&&t.transient===n.transient||_v())}),n=!0;return()=>{n&&(n=!1,vv--,t())}}function xv(){for(let e of iv)e.lastResult=lv(e.condition)}function Sv(){iv=[],ov=[],cv?.closeAll()}function Cv(e){return sv=e,ov.length>0&&e(),()=>{sv===e&&(sv=null)}}function wv(){return ov.shift()}function Tv(){return ov.length}function Ev(e){cv?cv.push(e):(ov.push(e),sv?.())}function Dv(){ov=[]}function Ov(e){return cv=e,()=>{cv===e&&(cv=null)}}function kv(){cv?.close()}function Av(){Dv(),cv?.closeAll()}function jv(){return cv?.isOpen()??!1}var Mv=[],Nv=1,Pv=new Set;function Fv(e){Mv=e;for(let e of Pv)e()}function Iv(e,t){let n=Jc(t).replace(/^spindle: /,``),r=Mv.find(t=>t.context===e&&t.message===n);Fv(r?Mv.map(e=>e===r?{...e,count:e.count+1}:e):[...Mv,{id:Nv++,context:e,message:n,count:1}])}function Lv(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function Rv(e){Fv(Mv.filter(t=>t.id!==e))}function zv(){return Mv}function Bv(e){return Pv.add(e),()=>{Pv.delete(e)}}zn(),Bn();var Vv=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),Hv=K(),Uv=[],Wv=K();function Gv(e,t){let n=[];for(let r of Object.keys(e))G(t,r)||n.push({key:r,deleted:!0});for(let r of Object.keys(t))(!G(e,r)||!Object.is(e[r],t[r]))&&n.push({key:r,deleted:!1,value:Jh(t[r],{keepUnregistered:!0})});return{forward:n}}function Kv(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))Ts(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:Ts(n,e.key,e.value);return n}function qv(e){let t=Uv.length-1;t<0?Hv=e:Uv[t]=Gv(Xv(t),e)}function Jv(e,t){let n=Hv;for(let r=0;r<e;r++)r>0&&(n=Kv(n,Uv[r-1].forward)),t(n,r)}function Yv(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function Xv(e){let t=Hv;for(let n=0;n<e;n++)t=Kv(t,Uv[n].forward);return t}var Zv=[];function Qv(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(Zv.length>i.length&&(Zv.length=i.length),Zv.length<i.length)if(i.length-Zv.length===1){let e=i.length-1;Zv[e]=Yv(i[e],r)}else Jv(i.length,(e,t)=>{t>=Zv.length&&(Zv[t]=Yv(i[t],e))});b_(t.ifid,{passage:n,variables:r,history:Zv,historyIndex:a,visitCounts:o,renderCounts:s,prng:hs()})}}var $v=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,ey=`The story could not go to another passage:`;function ty(e,t){let n;try{Qv(e)}catch(e){n={error:e},Iv($v,e)}try{t?.()}finally{if(n)throw n.error}}function ny(e){let t=e.history.length-e.maxHistory;if(t<=0)return!1;let n=Math.min(e.historyIndex,t),r=n+e.maxHistory;for(let e=0;e<n;e++)Hv=Kv(Hv,Uv[e].forward);return e.history=e.history.slice(n,r),Uv=Uv.slice(n,r-1),Zv=Zv.slice(n,r),e.historyIndex-=n,!0}var ry=!1,iy=[],ay=null;function oy(e,t){let n=ay;if(ay=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&qv(e().variables),Wv=e().variables;let r=hs(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var sy=e=>({...e});function cy(e){Hv=e,Uv=[],Wv=e,Zv=[]}function ly(e){let t=K(Jh(e));return cy(Jh(t)),t}function uy(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=K(Jh(r)),e.temporary=K(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function dy(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;oy(e,t);let o=e().currentPassage,s=i[a].passage;gg(`beforenavigate`,s);let c=Jh(Xv(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=K()}),xv(),Wv=e().variables,Ly(e().history[e().historyIndex]),ty(e,()=>gg(`afternavigate`,s,o))}function fy(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;cy(n);let r=hs();Q.setState(e=>{e.history[0].prng=r})}var py=Promise.resolve(``),my=0,hy=!1;function gy(){return hy?``:Q.getState().playthroughId}function _y(){let e=gy();return py.then(t=>e||t)}function vy(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function yy(e){let t=++my;return hy=!0,py=e.then(e=>(t===my&&(hy=!1,vy(e)),e)),py}function by(e,t){++my,hy=!1,py=t.then(()=>e,()=>e),vy(e)}function xy(e){let t=crypto.randomUUID();by(t,Og(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function Sy(e,t){gy()!==t&&by(t,Pg(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var Cy=0,wy=0,Ty=null;function Ey(){wy=++Cy}var Dy=[],Oy=!1;function ky(e){Oy&&Dy.push(e)}function Ay(){Oy=!0}function jy(){for(let e of Dy)e();Dy=[],Oy=!1}function My(e){return typeof e==`string`&&e!==``?e:null}function Ny(e){let{history:t,historyIndex:n}=e;if(!Number.isInteger(n))return;let r=t[n];if(!(!r||r.passage!==e.passage)&&!(typeof r.variables!=`object`||r.variables===null))return r}function Py(e,t,n){let r=e.history[e.historyIndex];r&&Fy(r.variables,t,n,new Set)}function Fy(e,t,n,r){r.add(n),dg(e,t,n,(t,n,i)=>{if(!G(e,t)||!og(i,e[t],!0)||r.has(i))return!1;let a=Bh(e[t]);return e[t]=a,Fy(a,n,i,r),!0}),r.delete(n)}function Iy(e){e?ds(e.seed,e.pull):ps()}function Ly(e){e&&Iy(e.prng)}var Ry=[`variables`,`temporary`,`transient`];function zy(e){for(let t of Ry){let n=e[t];Ds(n)||(e[t]=K(jt(n)?Ln(n):n))}}var By=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function Vy(e){return(t,n,r)=>{let i=((e,n)=>{if(n){t(e,!0);return}let r=typeof e==`function`?e:t=>{Object.assign(t,e)},i=Z_(r);t(e=>{(i??r)(e),zy(e)})});r.setState=i;let a=e(i,n,r);for(let e of By){let t=a[e];a[e]=(...e)=>nv(()=>t(...e))}return a}}var Hy=e=>Hn(Vy(e));function Uy(e){return e.catch(()=>{}),e}function Wy(e,t,n){return Uy(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function Gy(e,t,n){e(e=>{let r=t??``;if(n)e.knownSaves={...e.knownSaves,[r]:!0};else{let{[r]:t,...n}=e.knownSaves;e.knownSaves=n}})}function Ky(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),Wy(i,r)}var Q=yt()(Hy((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:K(),variableDefaults:{},transient:K(),transientDefaults:{},temporary:K(),history:[],historyIndex:-1,visitCounts:Ps(),renderCounts:Ps(),knownSaves:{},playthroughId:``,maxHistory:40,quickSaveKey:`F6`,quickLoadKey:`F9`,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{let r=!1;e(e=>{e.maxHistory=Math.max(1,Math.round(n)),r=ny(e)}),r&&ty(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=My(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=My(t)})},init:(n,r={},i={})=>{let a=n.passagesById.get(n.startNode);if(!a)throw Error(`spindle: Start passage (pid=${n.startNode}) not found.`);let o=ly(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,uy(e,a.name,o,i),e.visitCounts=Ps(null,a.name),e.renderCounts=Ps(null,a.name)}),Wv=t().variables,Ey(),yy(Lg(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``)))},navigate:n=>{if(ry){iy.push(n);return}let{storyData:r}=t();if(!r)return;if(Vv.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Lv(n,t().currentPassage);console.error(`spindle: ${e.message}`),Iv(ey,e);return}let i=t().currentPassage;gg(`beforenavigate`,n);let a=Gv(Wv,t().variables);e(e=>{e.temporary=K(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),Uv.length=e.historyIndex,Zv.length>e.historyIndex+1&&(Zv.length=e.historyIndex+1),Uv.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:hs()}),e.historyIndex=e.history.length-1,ny(e),e.visitCounts=Ps(e.visitCounts,n),e.renderCounts=Ps(e.renderCounts,n)}),ay={navigationId:t().navigationId,variables:t().variables},ry=!0;try{yv()}finally{ry=!1}let o=iy;iy=[],oy(t,e),ty(t,()=>{gg(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>dy(t,e,-1),goForward:()=>dy(t,e,1),setVariable:(t,n)=>{e(e=>{Cs(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{Cs(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{Cs(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{Cs(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{Cs(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{Cs(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=Ps(e.renderCounts,t)})},restart:()=>{let{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;let a=n.passagesById.get(n.startNode);if(!a)return;e(e=>{e.renderDeferred=!1}),gg(`beforerestart`),xy(n.ifid),Ey();let o=t().renderDeferred;jy(),ps(),Sv();let s=ly(r);e(e=>{uy(e,a.name,s,i),e.visitCounts=Ps(null,a.name),e.renderCounts=Ps(null,a.name),o||(e.renderDeferred=!1)}),Wv=t().variables,Ay(),I_(),S_(n.ifid),gg(`storyinit`),fy()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=_y();return Wy(Rg(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await u_(i.ifid,a,t,n,r),Gy(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=Jc(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=_y(),a=f_(r.ifid,n),o=yy(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++Cy;return Wy(a.then(async e=>{await o,e&&(wy>s||(Ty=s,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=Jc(t,`Failed to load`)}))},hasSave:e=>{let{storyData:n,knownSaves:r}=t();return n?G(r,e??``):!1},getSaveInfo:async e=>{let{storyData:n}=t();return n?h_(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?__(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?Wy(v_(r.ifid,n).then(()=>Gy(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await D_(n.ifid,e)??null:null},importSave:async(n,r)=>{let{storyData:i}=t();if(!i)throw Error(`spindle: Story is not initialized.`);let a=await O_(n,i.ifid,r);return Gy(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?Ky(t,e,A_(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>Ky(t,e,j_(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=gy(),o=py,s=crypto.randomUUID(),c=N_(i,n,{current:a||o,id:s});return n!==``&&n===a?by(s,c):a===``&&yy(c.then(e=>e?s:o,()=>o)),Wy(c.then(async()=>{let t=await p_(r.ifid);e(e=>{e.knownSaves=t})}),`spindle: failed to delete playthrough`)},getSavePayload:()=>{let{currentPassage:e,variables:n,history:r,historyIndex:i,visitCounts:a,renderCounts:o}=t(),s=[];return Jv(r.length,(e,t)=>{let n=sy(e);s.push(Yv(r[t],t===0?n:$h(s[t-1].variables,n)))}),{passage:e,variables:$h(s[i]?.variables,sy(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:hs()}},beginSave:()=>{let e=t().variables;return()=>{let n=t().getSavePayload();return Py(n,e,t().variables),n}},loadFromPayload:(n,r,i)=>{let a=Ty??++Cy;if(Ty=null,n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}wy=a,gg(`beforeload`,r);let o=t().storyData?.ifid;i&&o&&Sy(o,i);let s=Ny(n),c=Jh(n.history.map(e=>e.variables)).map(e=>K(e));Hv=Jh(c[0]),Uv=c.slice(1).map((e,t)=>Gv(c[t],e)),Zv=n.history.map((e,t)=>Yv(e,c[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=K(Jh(s?.variables??n.variables)),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),ny(e),e.visitCounts=Ps(n.visitCounts),e.renderCounts=Ps(n.renderCounts),e.temporary=K(),e.transient=K(Jh(t().transientDefaults))}),xv(),Wv=Xv(t().historyIndex),Iy(s?.prng===void 0?n.prng:s.prng),ty(t,()=>ms(()=>gg(`afterload`,r)))},getHistoryVariables:e=>Jh(Xv(e)),setTransition:t=>{e(e=>{e.transitionConfig=t})},setNextTransition:t=>{e(e=>{e.nextTransition=t})},consumeNextTransition:()=>{let n=t().nextTransition;return n!==null&&e(e=>{e.nextTransition=null}),n},deferRender:()=>{e(e=>{e.renderDeferred=!0})},clearDeferredRender:()=>{e(e=>{e.renderDeferred=!1})}}))),qy=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Jy(){let{storyData:e}=es(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?qy:t.content,r=t?.tags.includes(`nobr`)??!1,i=Pe(()=>{try{return q(S,{children:hp(qo(n))})}catch(e){return q(`span`,{class:`error`,children:[`Error in StoryInterface: `,Jc(e)]})}},[n]);return r?q(Of.Provider,{value:!0,children:i}):i}var Yy=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled]):not([type=\"hidden\"])`,`select:not([disabled])`,`textarea:not([disabled])`,`iframe`,`[contenteditable=\"true\"]`,`[tabindex]:not([tabindex=\"-1\"])`].join(`,`);function Xy(e){return Array.from(e.querySelectorAll(Yy)).filter(e=>!e.hidden&&!e.closest(`[hidden], [inert]`))}var Zy=[];function Qy(e,t,n,r){Ne(()=>{let n=e.current;if(!n)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i={panel:n};Zy.push(i);let a=n.querySelector(t)??n;return(n.querySelector(`[autofocus]`)??Xy(a)[0]??n).focus(),()=>{let e=Zy.indexOf(i);e!==-1&&Zy.splice(e,1);let t=document.activeElement;(!t||t===document.body||n.contains(t))&&r?.isConnected&&r.focus()}},[]),Ne(()=>{let t=e.current;if(!t)return;let i=e=>{if(Zy[Zy.length-1]?.panel!==t)return;if(e.key===`Escape`){if(!n)return;e.preventDefault(),e.stopPropagation(),r();return}if(e.key!==`Tab`)return;let i=Xy(t),a=i[0],o=i[i.length-1],s=document.activeElement,c=s!==t&&t.contains(s);!a||!o?(e.preventDefault(),t.focus()):e.shiftKey&&(s===a||!c)?(e.preventDefault(),o.focus()):!e.shiftKey&&(s===o||!c)&&(e.preventDefault(),a.focus())};return document.addEventListener(`keydown`,i),()=>document.removeEventListener(`keydown`,i)},[n,r])}var $y=_e(null);function eb({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,dismissible:i=!0,showCloseButton:a=i}){let o=j(r);o.current=r;let s=Fe(()=>o.current(),[]),{storyData:c}=es(`storyData`),l=e?c?.passages.get(e):void 0,u=l?.content??t,d=l?.tags.includes(`nobr`)??!1,f=Pe(()=>{if(!u)return q(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=Cp(qo(u),d?{nobr:!0}:void 0);return d?q(Of.Provider,{value:!0,children:e}):e}catch(e){return q(`div`,{class:`error`,children:[`Error in dialog: `,Jc(e)]})}},[u,d]),p=j(null);Qy(p,`.dialog-body`,i,s),Ne(()=>{p.current&&_g(`dialogrender`,e??``,p.current)},[]);let m=e=>{i&&e.target.classList.contains(`dialog-overlay`)&&s()},h=n?`dialog-panel ${n}`:`dialog-panel`;return q($y.Provider,{value:s,children:q(`div`,{class:`dialog-overlay`,onClick:m,children:q(`div`,{ref:p,class:h,role:`dialog`,\"aria-modal\":`true`,tabIndex:-1,children:[a&&q(`button`,{class:`dialog-close`,\"aria-label\":`Close`,onClick:s,children:`✕`}),q(`div`,{class:`dialog-body`,children:f})]})})})}function tb(){let[e,t]=Ae([]),n=j(e);n.current=e;let r=Fe(e=>{t(t=>[...t,e])},[]),i=Fe(()=>{t(e=>e.slice(0,-1))},[]),a=Fe(()=>{t([])},[]);return Me(()=>Ov({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Me(()=>Cv(()=>{let e=[];for(;Tv()>0;){let t=wv();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:q(S,{children:e.map((e,t)=>q(eb,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function nb(){let[e,t]=Ae(zv);return Me(()=>(t(zv()),Bv(()=>t(zv()))),[]),e.length===0?null:q(`div`,{class:`spindle-error-banners`,children:e.map(e=>q(`div`,{class:`spindle-error-banner`,role:`alert`,children:[q(`span`,{class:`spindle-error-banner-context`,children:e.context}),` `,q(`span`,{class:`spindle-error-banner-message`,children:e.message}),e.count>1&&q(`span`,{class:`spindle-error-banner-count`,children:` (×${e.count})`}),q(`button`,{type:`button`,class:`spindle-error-banner-dismiss`,\"aria-label\":`Dismiss`,onClick:()=>Rv(e.id),children:`✕`})]},e.id))})}function rb(){let{storyData:e,currentPassage:t,nobr:n}=es(`storyData`,`currentPassage`,`nobr`);if(Me(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n,save:r,load:i}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),r()):n!==null&&e.key===n&&(e.preventDefault(),i())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return q(`div`,{class:`loading`,children:`Loading...`});let r=q(S,{children:[q(Jy,{}),q(tb,{}),q(nb,{})]});return n?q(Of.Provider,{value:!0,children:r}):r}var ib=`http://www.w3.org/1999/xhtml`,ab=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function ob(e){let t=``;for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t+=n.data:n.nodeType===Node.COMMENT_NODE?t+=`\\x3C!--${n.data}-->`:n.nodeType===Node.ELEMENT_NODE&&(t+=sb(n));return t}function sb(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${cb(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===ib&&ab.has(t))return n;let r=t===`template`?e.content:e;return`${n}${ob(r)}</${t}>`}function cb(e,t){let n=Bo(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=Jo(`<i ${r}=${e}>`)}catch(e){if(e instanceof Wo)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${lb(t,n)}\"`}function lb(e,t){let n=e=>e.replace(/\"/g,`"`);if(t)return Vo(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=Jo(e,{text:!0})}catch(t){if(t instanceof Wo)return n(e);throw t}return r.map(t=>{let r=e.slice(t.start,t.end);return t.type===`text`?n(r):r}).join(``)}function ub(){let e=document.querySelector(`tw-storydata`);if(!e)throw Error(`spindle: No <tw-storydata> element found in the document.`);let t=e.getAttribute(`name`)||`Untitled`,n=parseInt(e.getAttribute(`startnode`)||`1`,10),r=e.getAttribute(`ifid`)||``,i=e.getAttribute(`format`)||``,a=e.getAttribute(`format-version`)||``,o=e.querySelector(`[type=\"text/twine-css\"]`)?.textContent||``,s=e.querySelector(`[type=\"text/twine-javascript\"]`)?.textContent||``,c=new Map,l=new Map;for(let t of e.querySelectorAll(`tw-passagedata`)){let e=parseInt(t.getAttribute(`pid`)||`0`,10),n=t.getAttribute(`name`)||``,r=(t.getAttribute(`tags`)||``).split(/\\s+/).filter(e=>e.length>0),i=ob(t),a={},o=new Set([`pid`,`name`,`tags`]);for(let e of t.attributes)o.has(e.name)||(a[e.name]=e.value);let s={pid:e,name:n,tags:r,metadata:a,content:i};c.set(n,s),l.set(e,s)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:c,passagesById:l,userCSS:o,userScript:s}}var db=new Map,fb=K(),pb=!1,mb=null;function hb(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function gb(){localStorage.setItem(hb(),JSON.stringify(fb))}function _b(){if(!pb){if(!Q.getState().storyData?.ifid){mb||(mb=Q.subscribe(e=>{e.storyData?.ifid&&(mb?.(),mb=null,_b())}));return}pb=!0;try{let e=localStorage.getItem(hb());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(fb=K(fb,t))}}catch{}}}function vb(e,t){db.set(e,t),G(fb,e)||(fb[e]=t.config.default),_b()}function yb(e,t){let n=ws(fb,e);return typeof n==typeof t?n:t}var bb={addToggle(e,t){vb(e,{type:`toggle`,config:t})},addList(e,t){vb(e,{type:`list`,config:t})},addRange(e,t){vb(e,{type:`range`,config:t})},get(e){return ws(fb,e)},getToggle(e){return yb(e,!1)},getList(e){return yb(e,``)},getRange(e){return yb(e,0)},set(e,t){fb[e]=t,gb()},getAll(){return{...fb}},getDefinitions(){return db},hasAny(){return db.size>0}},xb=[`target`,`variable`,`options`,`value`,`disabled`],Sb=new Map,Cb=new Map;function wb(e,t,n){if(n)return n;let r=`${e}:${t}`,i=Cb.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(Sb.has(a));return Cb.set(r,i),a}function Tb(e){let t=e.id,n={action:e},r=Sb.get(t);return r?(console.warn(`spindle: two mounted controls share the action ID \"${t}\"; Story.getActions() lists only the newer one.`),r.push(n)):Sb.set(t,[n]),Ab(),{update(e){let r=Sb.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&Ab())},unregister(){let e=Sb.get(t),r=e?e.indexOf(n):-1;!e||r===-1||(e.splice(r,1),e.length===0&&Sb.delete(t),r===e.length&&Ab())}}}function Eb(){return Array.from(Sb.values(),Ob)}function Db(e){let t=Sb.get(e);return t&&Ob(t)}function Ob(e){return e[e.length-1].action}function kb(){Cb.clear()}function Ab(){gg(`actionsChanged`)}function jb(e){let t=j(``),n=j(e.perform);n.current=e.perform,t.current||(t.current=wb(e.type,e.key,e.authorId));let r=t.current,i=()=>{let t={id:r,type:e.type,label:e.label,perform:(...e)=>n.current(...e)};for(let n of xb)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=j(null);Ne(()=>{let e=Tb(i());return a.current=e,()=>e.unregister()},[r]);let o=j(!1);return Ne(()=>{if(!o.current){o.current=!0;return}a.current?.update(i())},[e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Mb(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function Nb(e){let t=e.trim();return t.endsWith(`ms`)?parseFloat(t.slice(0,-2)):t.endsWith(`s`)?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function Pb(e){let t=[],n=0;for(let r of[...Dc(e,vc),e.length])r>n&&t.push([n,r]),n=r+1;return t}var Fb=(e,[t,n])=>e.slice(t,n);function Ib(e){return Cc(e)??wc(e)}function Lb(e,t){switch(e.type){case`string`:return Cc(t)??void 0;case`text`:return Ib(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return Nb(t);case`number`:return Number(t);case`options`:return Hb(e.parameters??[],t);default:return t}}function Rb(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var zb=/\\w+/y,Bb=/\\d+/y;function Vb(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function Hb(e,t){let n={},r=0;for(;r<t.length;){let i=Vb(zb,t,r);if(!i){r=Sc(t,r)?.end??r+1;continue}r+=i.length;let a,o=r;for(;o<t.length&&vc(t[o]);)o++;if(o>r){let e=Sc(t,o),n=e?null:Vb(Bb,t,o);e?(a=e.value,r=e.end):n&&(a=n,r=o+n.length)}let s=e.find(e=>e.name===i);s?.type===`flag`?n[i]=!0:s?.type===`number`?n[i]=Number(a??0):s&&(n[i]=a)}return n}var Ub=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function Wb(e,t){let n=Pb(e);if(n.length<2)return null;if(Fb(e,n[n.length-1])===t){let t=e.slice(0,n[n.length-2][1]);if(!Ec(t))return t}if(Fb(e,n[0])===t){let t=e.slice(n[1][0]);if(!Ub.test(t))return t}return null}function Gb(e,t){if(t===`=`){let t=Dc(e,e=>e===`=`);for(let n=0;n<t.length;n++){let r=t[n];if(e[r+1]===`=`){n++;continue}if(e[r-1]!==`!`)return[r,r+1]}return null}let n=Pb(e);for(let r=1;r<n.length-1;r++)if(Fb(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var Kb=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function qb(e,t,n){let r=t?.trim()??``;for(let i of e.filter(e=>e.type===`flag`)){let e=t===null?null:Wb(r,i.name);n[i.name]=e!==null,r=e??r}let i=e.filter(e=>e.type!==`flag`);if(i.length===0)return;let a=i.findIndex((e,t)=>Kb(e)&&!i.slice(t+1).some(Kb)),o=a<0?i.length-1:a,s=(e,t)=>t===``?Rb(e):Lb(e,t);if(i.length===1){n[i[0].name]=s(i[0],r);return}let c=Pb(r),l=0,u=c.length;for(let e of i.slice(0,o))n[e.name]=l<u?s(e,Fb(r,c[l++])):Rb(e);for(let e of i.slice(o+1).reverse()){let t=l<u&&!Ec(r.slice(0,c[u-1][0]))?s(e,Fb(r,c[u-1])):void 0;n[e.name]=t??Rb(e),t!==void 0&&u--}let d=i[o];n[d.name]=l<u?s(d,r.slice(c[l][0],c[u-1][1])):Rb(d)}var Jb={name:`delay`,type:`delay`,required:!0};function Yb(e,t){let n={},r=e.trim(),i=0;return t.forEach((e,a)=>{if(e.type!==`separator`)return;let o=r===null?null:Gb(r,e.name);n[e.name]=o!==null;let s=o?r.slice(0,o[0]):r;qb(t.slice(i,a),s,n),r=o?r.slice(o[1]):null,i=a+1}),qb(t.slice(i),r,n),n}function Xb(e,t,{storyData:n,currentPassage:r}){let i=String(t(e??``));if(n&&!n.passages.has(i))throw Lv(i,r);return i}function Zb(e){let t=e.trim(),n=Pb(t)[0];return n?Fb(t,n):``}function Qb(e){let{variable:t=``,placeholder:n=``}=Yb(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var $b=[{name:`value`,type:`string`}];function ex(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=Yb(n.rawArgs,$b);t.push(e??n.rawArgs.trim().replace(/^([\"'])(.+)\\1$/s,`$2`))}return t}function tx(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var nx={useState:Ae,useRef:j,useEffect:Me,useLayoutEffect:Ne,useCallback:Fe,useMemo:Pe,useContext:Ie};function $(e,t=`builtin`){let n=e.parameters??[];dc(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=Xc(),r=a(r),i=a(i));let{update:o,getValues:s}=Ie(Df),c=tl(),l={args:Yb(t.rawArgs,n),collectText:Mb,sourceLocation:xf,parseVarArgs:Qb,extractOptions:ex,h:b,renderNodes:(e,t)=>Cp(e,{...c,...t}),renderInlineNodes:hp,hooks:nx,useAction:jb,className:r,id:i,resolve:a,cls:tx(e.name,r),mutate:e=>rv(e,s(),o),update:o,getValues:s,wrap:e=>Pc(r,i,e)};if(e.merged){l.merged=ts();let e=l.merged;l.evaluate=t=>$s(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=Zb(t.rawArgs).replace(/[\"']/g,``);if(n.startsWith(`%`))return b(`span`,{class:`error`},`{${e.name}}: transient variables (%${n.slice(1)}) cannot be bound to input macros`);let r=n.replace(/[\"']/g,``).replace(/^\\$/,``),i=r.split(`.`);if(i.includes(`__proto__`))return b(`span`,{class:`error`},`{${e.name}}: \"$${r}\" cannot be bound: ${xs} is reserved`);l.varName=r,l.value=Q(e=>Lh(e.variables,i)),l.getValue=()=>Lh(V_().variables,i),l.setValue=e=>{Q.setState(t=>{Vh(t.variables,i,e,{createMissing:!0})})}}return e.render(t,l)}nc(e.name,r);let i=e.text;ac(e.name,i&&((e,t)=>i(e,{...t,args:Yb(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(pc(e.name,{name:e.name,block:a,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters&&[...e.parameters],source:t}),e.subMacros)for(let t of e.subMacros)cc(t);a&&hr(e.name)}var rx=null;function ix(e){rx=e}function ax(){return rx}var ox=null,sx=null;function cx(){return sx}var lx=!1;function ux(){if(lx)return;lx=!0;let e=Q.getState().variables,t=Q.getState().transient;Q.subscribe(n=>{let r={},i=(e,t,n)=>{for(let i of js(e,t))r[n+i]={from:ws(e,i),to:ws(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&gg(`variableChanged`,r)})}var dx=null,fx=null,px=new Set;function mx(e,t=[]){dx=new Set(e),fx=new Set(t),px.clear()}function hx(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return Cs(n.split(`.`)[0],e),{isTransient:t,key:n}}function gx(e,t){let n=e?fx:dx;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;px.has(i)||(px.add(i),console.warn(`spindle: Story.set() wrote ${i}, which is not declared in ${e?`StoryTransients`:`StoryVariables`}. Passages cannot reference it; check the name or declare it.`))}function _x(e,t,n){let{isTransient:r,key:i}=hx(t),a=r?e.transient:e.variables;i.includes(`.`)?Vh(a,i.split(`.`),n):a[i]=n}function vx(e){return((...t)=>Q.getState()[e](...t))}function yx(){return{get(e){let{isTransient:t,key:n}=hx(e),r=B_(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?Lh(a,n.split(`.`)):ws(a,n);return r?U_(o):o},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=hx(e);gx(t,n)}Q.getState().updateVariables(e=>{for(let[t,r]of n)_x(e,t,r)})},goto:vx(`navigate`),back:vx(`goBack`),forward:vx(`goForward`),restart:vx(`restart`),save:vx(`save`),load:vx(`load`),hasSave:vx(`hasSave`),getSaveInfo:vx(`getSaveInfo`),listSaves:vx(`listSaves`),deleteSave:vx(`deleteSave`),exportSave:vx(`exportSave`),importSave:vx(`importSave`),...Ks(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:bb,registerClass(e,t){vm(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return mc()},saves:{setTitleGenerator(e){bg(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?k_(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:jh()}},async getQuota(){if(typeof navigator<`u`&&navigator.storage?.estimate)try{let e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},clearGameData:vx(`clearGameData`),clearAllData:vx(`clearAllData`),deletePlaythrough:vx(`deletePlaythrough`),get backend(){return jh()}},getActions(){return Eb()},performAction(e,t){let n=Db(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){e===`variableChanged`&&ux();let n=mg(e,t);return ky(n),n},async waitForActions(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>ax()===Q.getState().navigationId;return ax()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=mg(`passagerender`,()=>{e()&&(n(),t())})}),Eb()},watch(e,t){return dv(e,t)},unwatch(e){pv(e)},openDialog(e,t){Ev({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){kv()},closeAllDialogs(){Av()},isDialogOpen(){return jv()},setNobr(e){Q.setState({nobr:e})},setCSS(e){let t=document.getElementById(`spindle-styles`);t&&(t.disabled=!e)},setTransition(e){Q.getState().setTransition(e)},setNextTransition(e){Q.getState().setNextTransition(e)},deferRender(){Q.getState().deferRender(),sx=new Promise(e=>{ox=e})},ready(){ox&&(Q.getState().clearDeferredRender(),ox(),ox=null,sx=null)},random(){return gs()},randomInt(e,t){return _s(e,t)},config:{get maxHistory(){return Q.getState().maxHistory},set maxHistory(e){Q.getState().setMaxHistory(e)},get quickSaveKey(){return Q.getState().quickSaveKey},set quickSaveKey(e){Q.getState().setQuickSaveKey(e)},get quickLoadKey(){return Q.getState().quickLoadKey},set quickLoadKey(e){Q.getState().setQuickLoadKey(e)}},prng:{init(e,t){us(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=hs())})},isEnabled(){return vs()},get seed(){return ys()},get pull(){return bs()}}}}function bx(){window.Story=yx()}var xx=null;function Sx(e){let t=xx;xx=new Map;try{return e()}finally{xx=t}}function Cx(e,t){let n=t[0]+e,r=xx?.get(n);if(r)return r;try{r=po(e,t)}catch(e){if(!(e instanceof io))throw e;r=e}return xx?.set(n,r),r}var wx=new Set([`if`,`elseif`,`case`]),Tx={watch:{condition:`expression`,run:`statements`}},Ex={link:[`passage`],watch:[`goto`,`dialog`]},Dx=new Set([`dialog`]);function Ox(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function*kx(e,t,n){let r=(e,n)=>t.findIndex((t,r)=>r>e&&t.type===`macro`&&t.isClose&&t.name.toLowerCase()===n);for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`link`)yield{kind:`passage`,name:a.target,offset:jx(e,a.target,a.start),label:e.slice(a.start,a.end)};else if(a.type===`expression`)yield{kind:`code`,code:a.expression,offset:a.end-1-a.expression.length,goal:`expression`,label:`{${a.expression}}`};else if(a.type===`html`)for(let[t,n]of Object.entries(a.attributes)){let r=jx(e,n,a.start);if(!Bo(t)){yield{kind:`text`,text:n,offset:r,where:`In the ${t} attribute of <${a.tag}>: `};continue}let i=0;for(let e of Vo(n)){if(!(`expr`in e))continue;let o=jx(n,e.expr,i);i=o+e.expr.length,yield{kind:`code`,code:e.expr,offset:r+o,goal:`expression`,label:`{${e.expr}} in the ${t} attribute of <${a.tag}>`}}}else if(a.type===`macro`&&!a.isClose){let o=a.name.toLowerCase();if(o===`do`){let n=r(i,o);if(n<0)continue;yield{kind:`code`,code:e.slice(a.end,t[n].start),offset:a.end,goal:`statements`,label:`{do}`},i=n;continue}let s=a.rawArgs;if(Dx.has(o)){let n=r(i,o),s=t.slice(i+1,n);if(n>i+1&&s.every(e=>e.type===`text`)){let r=e.slice(a.end,t[n].start).trim().replace(/^[\"']|[\"']$/g,``);yield{kind:`passage`,name:r,offset:jx(e,r,a.end),label:e.slice(a.start,a.end)}}}if(!s)continue;let c=`{${a.name} ${s}}`,l=jx(e,s,a.start+1);if(wx.has(o)){yield{kind:`code`,code:s,offset:l,goal:`expression`,label:c};continue}let u=n(o);u&&(yield*Ax(s,l,u,a.name,c))}}}function*Ax(e,t,n,r,i){let a=Yb(e,n),o=Tx[r.toLowerCase()]??{},s=Ex[r.toLowerCase()]??[],c=0;function*l(n,a){for(let u of n){let n=a[u.name];if(u.type===`options`&&u.parameters){yield*l(u.parameters,n??{});continue}if(typeof n!=`string`||!n.trim())continue;let d=jx(e,n,c);d>=c&&(c=d+n.length);let f=Ox(u)??o[u.name];if(f){let e={kind:`code`,code:n,offset:t+d,goal:f,label:i};u.type===`passage`&&(e.passage=!0),yield e}let p=u.type===`passage`?Cc(n.trim()):s.includes(u.name)?n:null;p!==null&&(yield{kind:`passage`,name:p,offset:t+d,label:i}),!f&&(u.type===`text`||u.type===`string`)&&(yield{kind:`text`,text:n,offset:t+d,where:`In the ${u.name} of {${r}}: `})}}yield*l(n,a)}function jx(e,t,n){let r=e.indexOf(t,n);if(r>=0)return r;let i=e.indexOf(t);return i>=0?i:n}function Mx(e,t){try{return Jo(e,{text:t})}catch(e){if(e instanceof Wo)return[];throw e}}function Nx(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var Px=/\\$(\\w+(?:\\.\\w+)*)/y,Fx=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,Ix=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,Lx=new Set([`number`,`string`,`boolean`]),Rx={string:Object(``),number:Object(0),boolean:Object(!1)};function zx(e){if(Array.isArray(e))return{type:`array`};if(typeof e==`object`&&e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,zx(r));return{type:`object`,fields:t}}let t=typeof e;if(!Lx.has(t))throw Error(`Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Bx(e,t=`$`){let n=new Map,r=Nx(t),i=t===`%`?`StoryTransients`:`StoryVariables`;for(let a of e.split(`\n`)){let e=a.trim();if(!e)continue;let o=e.match(r);if(!o)throw Error(`${i}: Invalid declaration: \"${e}\". Expected: ${t}name = value`);let[,s,c]=o,l=Ss(s,t+s);if(l)throw Error(`${i}: ${l}`);let u;try{u=Function(`return (`+c+`)`)()}catch(e){throw Error(`${i}: Failed to evaluate \"${t}${s} = ${c}\": ${Jc(e)}`)}let d;try{d=zx(u)}catch(e){throw Error(`${i}: ${Jc(e)}`)}n.set(s,{...d,name:s,default:u})}return n}function Vx(e){let t=new Set,n;for(Ix.lastIndex=0;(n=Ix.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Hx(e,t,n){let r=e.split(`.`),i=r[0],a=Ss(i,`$`+i);if(a)return a;if(n.has(i))return null;let o=t.get(i);if(!o)return`Undeclared variable: $${e}`;let s=o;for(let e=1;e<r.length;e++){let t=r[e];if(s.type===`array`)return null;let n=Rx[s.type];if(n&&t in n){let e=typeof n[t];if(!Lx.has(e))return null;s={type:e};continue}if(s.type!==`object`||!s.fields)return`Cannot access field \"${t}\" on $${r.slice(0,e).join(`.`)} (type: ${s.type})`;let i=s.fields.get(t);if(!i)return null;s=i}return null}var Ux=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],Wx=new Set;function Gx(e,t){for(let n of Vo(e))`expr`in n&&qx(n.expr,t)}function Kx(e,t,n=Wx){e.includes(`{`)&&Xx(e,Mx(e,!0),n,t)}function qx(e,t,n=`expression`){let r=Cx(e,n);if(r instanceof io){Jx(e,t,n);return}for(let n of r.refs)n.sigil===`$`&&(Px.lastIndex=n.start,t(Px.exec(e)[1]));for(let e of r.strings)Kx(e,t)}function Jx(e,t,n){let r=[];Do(e,{variable(n,r,i){n===`$`&&(Px.lastIndex=i,t(Px.exec(e)[1]))},literal(e,n,i){let a=r[r.length-1];if(a?.nesting===i)a.text===null?a.text=``:e===\"`\"||e===\"${\"?(Kx(a.text,t),e===\"`\"?r.pop():a.text=null):a.text+=e;else if(e===\"`\")r.push({nesting:i,text:``});else if(e[0]===`\"`||e[0]===`'`){let{closed:n}=Mo(e,0);Kx(e.slice(1,n?-1:void 0),t)}}},n);for(let e of r)e.text&&Kx(e.text,t)}function Yx(e,t,n){Sx(()=>Xx(e,Mx(e,!1),t,n))}function Xx(e,t,n,r){for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`variable`)a.scope===`variable`&&a.name&&r(a.name);else if(a.type===`expression`)qx(a.expression,r);else if(a.type===`html`)for(let[e,t]of Object.entries(a.attributes))Bo(e)?Gx(t,r):Kx(t,r,n);else if(a.type===`macro`&&!a.isClose){if(qx(a.rawArgs,r),n.has(a.name.toLowerCase())){let e=a.rawArgs.trim().split(/\\s+/)[0]??``,t=Fx.exec(e);t&&r(t[1])}if(a.name===`do`){let n=i+1;for(;n<t.length;){let e=t[n];if(e.type===`macro`&&e.isClose&&e.name===`do`)break;n++}n<t.length&&(qx(e.slice(a.end,t[n].start),r,`statements`),i=n)}}}}function Zx(e,t,n=Ux){let r=[],i=new Set(Array.from(n,e=>e.toLowerCase()));for(let[n,a]of e){if(n===`StoryVariables`||n===`StoryTransients`)continue;let e=Vx(a.content);Yx(a.content,i,i=>{let a=Hx(i,t,e);a&&r.push(`Passage \"${n}\": ${a}`)})}return r}function Qx(e){let t=K();for(let[n,r]of e)t[n]=r.default;return t}var $x=[{name:`name`,type:`text`,required:!0},{name:`parameters`,type:`text`}];function eS({name:e=``,parameters:t=``}){return{name:e,params:t.split(/\\s+/).filter(e=>e.startsWith(`@`))}}function tS(e){return eS(Yb(e,$x))}var nS=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;function rS(e){let t=[];for(let n of e)if(!(n.name!==`StoryInit`&&!n.tags?.includes(`widget`)))for(let e of n.content.matchAll(nS))/\\{@children\\}/.test(e[2])&&t.push(e[1]);return t}var iS=new Set([`StoryVariables`,`StoryTransients`]),aS=[`script`,`stylesheet`],oS=new Set([`elseif`,`else`,`case`,`default`,`next`]);function sS(e){let t=e.file?` (${e.file}${e.fileLine?`:${e.fileLine}`:``})`:``;return`Passage \"${e.passage}\", line ${e.line}, column ${e.column}${t}: ${e.message}`}function cS(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++)i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+(e[r-1]===t[a-1]?0:1));n=i}return n[t.length]}function lS(e,t,n){let r=e.toLowerCase(),i=``,a=Math.max(2,Math.floor(r.length/3))+1;for(let e of t){let t=cS(r,e.toLowerCase());t<a&&(i=e,a=t)}return i?` Did you mean ${n(i)}?`:``}var uS=` (a passage name is a quoted string or an expression)`,dS=/^[A-Za-z][\\w$]*$/;function fS(e){try{return tS(e).name.toLowerCase()||void 0}catch{return}}function pS(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r)=>{let{line:i,column:a}=Go(e.content,t),o={passage:e.name,line:i,column:a,message:r},s=e.metadata?.[`data-source-file`];if(s){o.file=s;let t=Number(e.metadata?.[`data-source-line`]);t&&(o.fileLine=t+i)}n.push(o)},a=[],o=new Set,s=new Set;for(let n of e){if(s.add(n.name),iS.has(n.name)||n.tags?.some(e=>aS.includes(e)))continue;let e=!t.only||t.only(n);try{let t=Jo(n.content);for(let e of t){if(e.type!==`macro`||e.isClose||e.name.toLowerCase()!==`widget`)continue;let t=fS(e.rawArgs);t&&o.add(t)}if(!e)continue;qo(n.content,{hooks:r}),a.push([n,t])}catch(t){if(!(t instanceof Wo))throw t;e&&i(n,t.offset,t.reason)}}let c=[...t.macroNames??[],...o],l=(e,n,r,a)=>{for(let s of n){if(s.type!==`macro`||s.isClose)continue;let n=s.name.toLowerCase();oS.has(n)||o.has(n)||t.isKnownMacro(n)||i(e,r+s.start,`${a}Unknown macro {${s.name}}.${lS(s.name,c,e=>`{${e}}`)}`)}},u=t.parametersOf??(()=>void 0),d=(e,t,n,a,o)=>{l(e,n,a,o);for(let c of kx(t,n,u)){let t=a+c.offset;if(c.kind===`passage`){if(!s.has(c.name)){let n=lS(c.name,s,JSON.stringify);i(e,t,`${o}No passage named ${JSON.stringify(c.name)} in ${c.label}.${n}`)}continue}if(c.kind===`code`){let n=Cx(c.code,c.goal),r=c.code.trim();if(n instanceof io){let r=n.reasonIn(e.content,t);i(e,t+n.pos,`${o}${r} in ${c.label}`+(c.passage?uS:``))}else c.passage&&dS.test(r)&&i(e,t,`${o}Unquoted passage name in ${c.label}: write ${JSON.stringify(r)}${uS}`);continue}if(c.text.includes(`{`))try{qo(c.text,{text:!0,hooks:r});let n=Jo(c.text,{text:!0});d(e,c.text,n,t,c.where)}catch(n){if(!(n instanceof Wo))throw n;i(e,t+n.offset,c.where+n.reason)}}};for(let[e,t]of a)Sx(()=>d(e,e.content,t,0,``));return n}function mS(e){for(let t of e){if(t.type===`variable`&&t.scope===`local`&&t.name===`children`||t.type===`html`&&mS(t.children))return!0;if(t.type===`macro`){if(mS(t.children))return!0;if(t.branches){for(let e of t.branches)if(mS(e.children))return!0}}}return!1}function hS({name:e,params:t},n){let r=mS(n);gc(e,n,t,r),r&&hr(e)}$({name:`widget`,block:!0,parameters:$x,render({children:e=[]},t){let n,r;try{let e=eS(t.args);for(let t of e.params)Cs(t.slice(1),t);n=e}catch(e){r=e}let{name:i,params:a}=n??{name:``,params:[]},o=JSON.stringify(e),s=a.join(`,`);return t.hooks.useLayoutEffect(()=>{n&&hS(n,e)},[i,o,s]),r?q(Sf,{macro:`widget`,error:r}):null}}),$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return wf(`set`,e,()=>t.mutate(e))}}),$({name:`print`,parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e},t){try{return t.wrap(Nc(t.evaluate(e)))}catch(e){return q(Sf,{macro:`print`,error:e})}},text({rawArgs:e},t){return Nc(t.evaluate(e))}});var gS=Symbol(`unset`);function _S(e,t){if(!t[`=`])throw Error(`{computed}: expected \"target = expression\", got \"${e}\"`);let{target:n=``,expression:r=``}=t;if(!n.match(/^[$_@]\\w+$/))throw Error(`{computed}: target must be $name, _name, or @name, got \"${n}\"`);return Cs(n.slice(1),n),{target:n,expr:r}}function vS(e,t,n,r,i,a,o,s){let c=xf(),l;try{let{variables:t,temporary:n,transient:r}=V_();l=$s(e,t,n,i(),r)}catch(e){Cf(`computed ${a}`,e,c);return}if(!Yh(o.current,l))if(o.current=l,r)try{s(t,l)}catch(e){Cf(`computed ${a}`,e,c)}else{let e=Q.getState();n?e.setTemporary(t,l):e.setVariable(t,l)}}$({name:`computed`,merged:!0,parameters:[{name:`target`,type:`variable`,required:!0},{name:`=`,type:`separator`},{name:`expression`,type:`expression`,required:!0}],render({rawArgs:e},t){let[n,r,i,a]=t.merged,o,s;try{({target:o,expr:s}=_S(e,t.args))}catch(e){return q(Sf,{macro:`computed`,error:e})}let c=o.startsWith(`@`),l=o.startsWith(`_`),u=o.slice(1),d=c?t.update:null,f=t.hooks.useRef(gS),p=()=>vS(s,u,l,c,t.getValues,e,f,d),m=t.hooks.useRef(!1);return m.current||(m.current=!0,p()),t.hooks.useLayoutEffect(p,[n,r,i,a]),null}});function yS(e){if(e.current===void 0||e.max===void 0)throw Error(`meter requires two arguments: {meter currentExpr maxExpr}`);return{currentExpr:e.current,maxExpr:e.max,labelMode:e.label??``}}function bS(e,t,n){return n===`none`?null:n===`%`?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}$({name:`meter`,interpolate:!0,merged:!0,parameters:[{name:`current`,type:`expression`,required:!0},{name:`max`,type:`expression`,required:!0},{name:`label`,type:`string`}],render(e,t){try{let{currentExpr:e,maxExpr:n,labelMode:r}=yS(t.args),i=Number(t.evaluate(e)),a=Number(t.evaluate(n)),o=a===0?0:Math.max(0,Math.min(100,i/a*100)),s=bS(i,a,r),c=t.cls;return q(`div`,{class:c,id:t.id,children:[q(`div`,{class:`macro-meter-fill`,style:`width: ${o}%`}),s!=null&&q(`span`,{class:`macro-meter-label`,children:s})]})}catch(e){return q(Sf,{macro:`meter`,error:e})}}});function xS(e,t){let n=null;for(let r of e)if(r.rawArgs===``)n=r;else if(t(r.rawArgs))return r;return n}function SS(e,t){let n=e.findIndex(e=>e.rawArgs===``);return xS(n<0?e:e.slice(0,n+1),e=>!!t(e))}$({name:`if`,block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){let n;try{n=SS(e,t.evaluate)}catch(e){return q(Sf,{macro:`if`,error:e})}return n?Pc(t.resolve(n.className),t.resolve(n.id),t.renderNodes(n.children)):null},text({branches:e=[]},t){let n=SS(e,t.evaluate);return n?t.renderText(n.children):``}});function CS(e){try{return wS(e,[])}catch{return`<unkeyable>`}}function wS(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`number`:return Number.isFinite(e)?JSON.stringify(e):String(e);case`boolean`:return String(e);case`bigint`:return`${e}n`;case`undefined`:return`undefined`;case`symbol`:return e.description===void 0?`Symbol()`:`Symbol(${JSON.stringify(e.description)})`;case`function`:return`<function ${JSON.stringify(e.name)}>`}if(e===null)return`null`;let n=e,r=t.indexOf(n);if(r!==-1)return`<cycle ${t.length-r}>`;if(e instanceof Date)return`Date(${e.getTime()})`;if(e instanceof RegExp)return`RegExp(${String(e)})`;t.push(n);try{if(Array.isArray(e))return`[${Array.from(e,e=>wS(e,t)).join(`,`)}]`;if(e instanceof Map)return`Map[${[...e].map(([e,n])=>`[${wS(e,t)},${wS(n,t)}]`).join(`,`)}]`;if(e instanceof Set)return`Set[${[...e].map(e=>wS(e,t)).join(`,`)}]`;let r=n,i=Object.keys(r).map(e=>`${JSON.stringify(e)}:${wS(r[e],t)}`).join(`,`),a=ym(n);return a===void 0?`{${i}}`:`Class(${JSON.stringify(a)}){${i}}`}finally{t.pop()}}function TS(e,t){if(!t.of)throw Error(`{for} requires \"of\" keyword: {for ${e}}`);let[n=``,r=null]=t.variables??[],i=t.list??``;if(!n.startsWith(`@`))throw Error(`{for} loop variable must use @ prefix: got \"${n}\"`);if(r&&!r.startsWith(`@`))throw Error(`{for} index variable must use @ prefix: got \"${r}\"`);return Cs(n.slice(1),n),r&&Cs(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function ES({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){return q(nl,{body:a,parentValues:e,ownKeys:Pe(()=>({[t]:n,...r?{[r]:i}:void 0}),[t,n,r,i])})}$({name:`for`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`variables`,type:`names`,required:!0},{name:`of`,type:`separator`},{name:`list`,type:`expression`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=Ie(Ef),i,a;try{i=TS(e,n.args);let t=n.evaluate(i.listExpr);if(!Array.isArray(t))return q(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});a=t}catch(e){return q(Sf,{macro:`for`,error:e})}let{itemVar:o,indexVar:s}=i,c=a.map((e,n)=>q(ES,{parentValues:r,itemVar:o,itemValue:e,indexVar:s,indexValue:n,children:t},`${n}-${CS(e)}`));return n.wrap(c)},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=TS(e,n.args),o=n.evaluate(a);if(!Array.isArray(o))throw Error(`expression did not evaluate to an array`);return o.map((e,a)=>n.renderText(t,{[r]:e,...i?{[i]:a}:void 0})).join(``)}}),$({name:`do`,block:!0,render({children:e=[]},t){let n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{let e=t.sourceLocation();try{t.mutate(n)}catch(t){Cf(`do`,t,e)}},[]),null}});function DS(e){return new Proxy(K(),{get:(t,n)=>typeof n==`string`?ws(e(),n):void 0,has:(t,n)=>typeof n==`string`&&G(e(),n),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>{let r=Object.getOwnPropertyDescriptor(e(),n);return r?{...r,configurable:!0}:void 0}})}var OS=_e({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[Jb],render({children:e=[]},t){let{useState:n,useEffect:r,useCallback:i}=t.hooks,a=t.args.delay??0,[o,s]=n(0),[c,l]=n(!1),u=i(()=>l(!0),[]);if(r(()=>{if(c)return;let e=setInterval(()=>{s(e=>e+1)},a);return()=>clearInterval(e)},[a,c]),o===0&&!c)return null;let d=q(OS.Provider,{value:{stop:u},children:q(`span`,{children:t.renderNodes(e)},o)});return t.className||t.id?q(`span`,{id:t.id,class:t.cls,children:d}):d}});function kS(){let e=Ie(Df),{nobr:t,inline:n}=tl(),r=Ie(Pf),i=Ie(OS),a=Ie($y),o=o=>{let s=DS(e.getValues),c=document.createElement(`div`);ge(q(Df.Provider,{value:e,children:q(Ef.Provider,{value:s,children:q(Of.Provider,{value:t,children:q(kf.Provider,{value:n,children:q(Pf.Provider,{value:r,children:q(OS.Provider,{value:i,children:q($y.Provider,{value:a,children:Cp(o,{nobr:t,inline:n,locals:s})})})})})})})}),c),ge(null,c)};return e=>nv(()=>o(e))}$({name:`button`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(n.args.label??``)??e,i=kS(),a=()=>i(t);return n.useAction({type:`button`,key:e,authorId:n.id,label:r,perform:a}),q(`button`,{id:n.id,class:n.cls,onClick:a,children:r})}}),$({name:`link`,block:!0,interpolate:!0,parameters:[{name:`text`,type:`string`,required:!0},{name:`passage`,type:`string`}],render({rawArgs:e,children:t=[]},n){let{text:r}=n.args,i=r??e.trim(),a=r===void 0?null:n.args.passage??null,o=kS(),s=()=>{o(t),a&&Q.getState().navigate(a)};return n.useAction({type:`link`,key:a||i,authorId:n.id,label:i,target:a??void 0,perform:s}),q(`a`,{id:n.id,class:n.cls,href:`#`,onClick:e=>{e.preventDefault(),s()},children:i})}});function AS(e,t,n){return xS(t.slice(1),t=>e===n(t))}$({name:`switch`,subMacros:[`case`,`default`],parameters:[{name:`expression`,type:`expression`,required:!0}],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(e){return q(Sf,{macro:`switch`,error:e})}let i;try{i=AS(r,t,n.evaluate)}catch(e){return q(Sf,{macro:`case`,error:e})}return i&&q(S,{children:n.renderNodes(i.children)})},text({rawArgs:e,branches:t=[]},n){let r=AS(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var jS=[Jb];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:jS,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(e=>({delay:Yb(e.rawArgs,jS).delay??0,nodes:e.children,className:e.className,id:e.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;let e=o+1,t=a[e].delay,n=setTimeout(()=>{s(e)},t);return()=>clearTimeout(n)},[o,a]),o<0)return t.wrap(null);let c=a[o];return t.wrap(Pc(t.resolve(c.className),t.resolve(c.id),t.renderNodes(c.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(OS);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}}),$({name:`type`,block:!0,interpolate:!0,parameters:[Jb],render({children:e=[]},t){let{useState:n,useEffect:r,useRef:i}=t.hooks,a=t.args.delay??0,o=i(null),[s,c]=n(0),[l,u]=n(0),d=i(0);d.current=l,r(()=>{o.current&&c((o.current.textContent||``).length)},[]),r(()=>{if(s===0||d.current>=s)return;let e=setInterval(()=>{u(t=>t>=s?(clearInterval(e),t):t+1)},a);return()=>clearInterval(e)},[s,a]);let f=l>=s&&s>0,p=[`macro-type`,f?`macro-type-done`:``,t.className||``].filter(Boolean).join(` `);return q(`span`,{id:t.id,class:p,ref:o,style:{clipPath:void 0},children:[q(`span`,{class:`macro-type-inner`,style:{display:`inline`,visibility:s===0?`hidden`:`visible`,clipPath:s>0&&!f?`inset(0 ${(s-l)/s*100}% 0 0)`:void 0},children:t.renderInlineNodes(e)}),!f&&s>0&&q(`span`,{class:`macro-type-cursor`})]})}}),$({name:`story-title`,render(e,t){let n=Q(e=>e.storyData?.name||``),r=t.className?`story-title ${t.className}`:`story-title`;return q(`span`,{id:t.id,class:r,children:n})},text:()=>Q.getState().storyData?.name||``});function MS(e,t){return t?`${e} (${t})`:e}function NS(e){$({name:e.name,render(t,n){if(e.hidden?.())return null;let[r,i]=Ae(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o,title:s=e.title}=a,c=n.className?`menubar-button ${n.className}`:`menubar-button`,l=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}),q(S,{children:[q(`button`,{id:n.id,class:c,onClick:l,disabled:o,title:s,children:e.label}),e.dialog&&r&&q(eb,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}NS({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),NS({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),NS({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{save:e,quickSaveKey:t}=es(`save`,`quickSaveKey`);return{perform:e,title:MS(`Quick Save`,t)}}}),NS({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{load:e,hasSave:t,quickLoadKey:n}=es(`load`,`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:()=>e(),disabled:!t(),title:MS(`Quick Load`,n)}}}),NS({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),NS({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),NS({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!bb.hasAny(),dialog:{passageName:`Settings`,fallbackMarkup:`{settings-controls}`,panelClass:`dialog-settings`}}),$({name:`dialog`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,required:!0},{name:`noclose`,type:`flag`}],render({children:e=[]},t){let[n,r]=t.hooks.useState(!1),{noclose:i}=t.args,a=t.resolve(t.args.label??``),o=t.collectText(e).trim().replace(/^[\"']|[\"']$/g,``);return q(S,{children:[q(`button`,{id:t.id,class:t.cls,onClick:()=>r(!0),children:a}),n&&q(eb,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function PS(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function FS(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function IS(){let[e,t]=Ae(`load`),[n,r]=Ae([]),[i,a]=Ae(!0),[o,s]=Ae(null),[c,l]=Ae(()=>new Set),[u,d]=Ae(null),[f,p]=Ae(``),m=j(null),h=j(null),g=Ie($y),{storyData:_,playthroughId:v,beginSave:y,loadFromPayload:b}=es(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),x=_?.ifid??``,S=Fe(async()=>{x&&(r(await Jg(x)),a(!1))},[x]);Me(()=>{S()},[S]),Me(()=>{u&&m.current&&(m.current.focus(),m.current.select())},[u]);let C=j(!0),w=j(),T=j(),E=(e,t=`success`)=>{C.current&&(clearTimeout(w.current),s({text:e,type:t}),w.current=window.setTimeout(()=>s(null),3e3))};Me(()=>(C.current=!0,()=>{C.current=!1,clearTimeout(w.current),clearTimeout(T.current)}),[]);let ee=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=async()=>{if(!x)return;let e=_y();try{await Rg(void 0,void 0,y,async t=>{let n=await e;if(!n)throw Error(`No playthrough`);return Bg(x,n,t)}),E(`Save created`),await S()}catch{E(`Failed to create save`,`error`)}},te=async e=>{let t=_y();try{await Rg(void 0,void 0,y,async n=>{if(!await Hg(e,n,void 0,await t||void 0))throw Error(`Save not found`)}),E(`Save overwritten`),await S()}catch{E(`Failed to overwrite save`,`error`)}},ne=async e=>{try{b(Gg(e.payload),void 0,e.meta.playthroughId),E(`Game loaded`),g&&(T.current=window.setTimeout(g,500)),await S()}catch{E(`Failed to load save`,`error`)}},re=async e=>{if(confirm(`Delete this save?`))try{await Kg(e);let t=await p_(x);Q.setState(e=>{e.knownSaves=t}),E(`Save deleted`),await S()}catch{E(`Failed to delete save`,`error`)}},ie=e=>{d(e.meta.id),p(e.meta.title)},O=async()=>{if(!(!u||!f.trim()))try{await qg(u,f.trim()),d(null),E(`Save renamed`),await S()}catch{E(`Failed to rename`,`error`)}},ae=e=>{e.key===`Enter`?O():e.key===`Escape`&&d(null)},oe=async e=>{try{let t=await w_(e);if(!t)return;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`save-${t.save.meta.title.replace(/[^a-z0-9]/gi,`_`)}.json`,i.click(),URL.revokeObjectURL(r),E(`Save exported`)}catch{E(`Failed to export save`,`error`)}},se=()=>{h.current?.click()},ce=async e=>{let t=e.target,n=t.files?.[0];if(n){t.value=``;try{let e=await n.text(),t=JSON.parse(e);if(!ch(t))throw Error(`Invalid save file format`);await E_(t,x),E(`Save imported`),await S()}catch(e){E(Jc(e,`Failed to import save`),`error`)}}},le=n.reduce((e,t)=>e+t.saves.length,0);return q(`div`,{class:`save-manager`,children:[q(`div`,{class:`saves-header`,children:q(`div`,{class:`saves-header-left`,children:q(`div`,{class:`saves-mode-toggle`,children:[q(`button`,{class:e===`save`?`active`:``,onClick:()=>t(`save`),children:`Save`}),q(`button`,{class:e===`load`?`active`:``,onClick:()=>t(`load`),children:`Load`})]})})}),q(`div`,{class:`saves-toolbar`,children:[q(`button`,{class:`saves-toolbar-button`,onClick:se,children:`Import`}),q(`input`,{ref:h,type:`file`,accept:`.json`,style:`display:none`,onChange:ce})]}),q(`div`,{class:`saves-body`,children:[i?q(`div`,{class:`saves-empty`,children:`Loading...`}):le===0&&e===`load`?q(`div`,{class:`saves-empty`,children:`No saves yet`}):n.map(t=>{let n=c.has(t.playthrough.id),r=t.playthrough.id===v;return e===`save`&&!r||e===`load`&&t.saves.length===0&&!r?null:q(`div`,{class:`playthrough-group`,children:[q(`div`,{class:`playthrough-header`,onClick:()=>ee(t.playthrough.id),children:[q(`span`,{class:`playthrough-chevron ${n?``:`open`}`,children:`▶`}),q(`span`,{class:`playthrough-label`,children:[t.playthrough.label,r?` (current)`:``]}),q(`span`,{class:`playthrough-date`,children:FS(t.playthrough.createdAt)})]}),!n&&q(`div`,{class:`playthrough-saves`,children:[t.saves.map(t=>q(`div`,{class:`save-slot`,children:[q(`div`,{class:`save-slot-info`,children:[u===t.meta.id?q(`input`,{ref:m,class:`save-rename-input`,value:f,onInput:e=>p(e.target.value),onKeyDown:ae,onBlur:O}):q(`div`,{class:`save-slot-title`,children:t.meta.title}),q(`div`,{class:`save-slot-meta`,children:[q(`span`,{children:t.meta.passage}),q(`span`,{children:PS(t.meta.updatedAt)})]})]}),q(`div`,{class:`save-slot-actions`,children:[e===`save`?q(`button`,{class:`save-slot-action primary`,onClick:()=>te(t.meta.id),children:`Save Here`}):q(`button`,{class:`save-slot-action primary`,onClick:()=>ne(t),children:`Load`}),q(`button`,{class:`save-slot-action`,onClick:()=>ie(t),children:`Rename`}),q(`button`,{class:`save-slot-action`,onClick:()=>oe(t.meta.id),children:`Export`}),q(`button`,{class:`save-slot-action danger`,onClick:()=>re(t.meta.id),children:`Delete`})]})]},t.meta.id)),e===`save`&&r&&q(`button`,{class:`save-slot-new`,onClick:D,children:`+ New Save`})]})]},t.playthrough.id)}),e===`save`&&!i&&!n.some(e=>e.playthrough.id===v)&&q(`div`,{class:`playthrough-group`,children:q(`div`,{class:`playthrough-saves`,children:q(`button`,{class:`save-slot-new`,onClick:D,children:`+ New Save`})})})]}),o&&q(`div`,{class:`saves-status ${o.type===`error`?`error`:``}`,children:o.text})]})}$({name:`save-manager`,render(){return q(IS,{})}});function LS({name:e,def:t}){let[n,r]=Ae(()=>bb.get(e)),i=t=>{r(t),bb.set(e,t)};switch(t.type){case`toggle`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`input`,{type:`checkbox`,checked:!!n,onChange:e=>i(e.target.checked)})]});case`list`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`select`,{value:String(n),onChange:e=>i(e.target.value),children:t.config.options.map(e=>q(`option`,{value:e,children:e},e))})]});case`range`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:[t.config.label,`: `,String(n)]}),q(`input`,{type:`range`,min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:e=>i(parseFloat(e.target.value))})]})}}function RS(){let e=bb.getDefinitions();return q(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>q(LS,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return q(RS,{})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=es(`storyData`),{inline:r}=t.args,i=``,a;try{i=Xb(t.args.passage,t.evaluate,Q.getState())}catch(e){a={error:e}}let o=n?.passages.get(i),s=t.hooks.useMemo(()=>o?qo(o.content):null,[o]);if(!n)return null;if(a)return q(Sf,{macro:`include`,error:a.error});if(!o||!s)return null;Q.getState().trackRender(i);let c=o.tags.includes(`nobr`),l=r?t.renderInlineNodes(s):t.renderNodes(s,c?{nobr:!0}:void 0);return c?t.wrap(t.h(Of.Provider,{value:!0},l)):t.wrap(l)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(Of.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`goto`,merged:!0,parameters:[{name:`passage`,type:`passage`,required:!0}],render(e,t){let[n,r]=t.hooks.useState();return t.hooks.useLayoutEffect(()=>{let e=t.sourceLocation();try{let e=Q.getState();e.navigate(Xb(t.args.passage,t.evaluate,e))}catch(t){Cf(`goto`,t,e),r({error:t})}},[]),n?q(Sf,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return wf(`unset`,e,()=>{let e=Q.getState(),n=t.args.variable??``;if(n.startsWith(`$`))e.deleteVariable(n.slice(1));else if(n.startsWith(`_`))e.deleteTemporary(n.slice(1));else if(n.startsWith(`%`))e.deleteTransient(n.slice(1));else if(n.startsWith(`@`))t.update(n.slice(1),void 0);else throw Error(`{unset} expects a variable ($name, _name, %name, or @name), got \"${n}\"`)})}});var zS={name:`variable`,type:`variable`,required:!0};function BS(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function VS(e,t,n=e=>e===void 0?``:String(e)){$({name:e,storeVar:!0,parameters:[zS,{name:`placeholder`,type:`string`}],render(r,i){let a=i.args.placeholder??``;return BS(i,{type:e,label:a||i.varName,perform:e=>i.setValue(n(e))}),b(t?`input`:`textarea`,{type:t,id:i.id,class:i.cls,value:Nc(i.value),placeholder:a,onInput:e=>i.setValue(n(e.target.value))})}})}VS(`textbox`,`text`),VS(`numberbox`,`number`,e=>e===void 0?0:Number(e)),VS(`textarea`),$({name:`checkbox`,storeVar:!0,parameters:[zS,{name:`label`,type:`text`}],render(e,t){let n=t.args.label??``;return BS(t,{type:`checkbox`,label:n||t.varName||``,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.value:!!e)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`checkbox`,checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}}),$({name:`radiobutton`,storeVar:!0,parameters:[zS,{name:`value`,type:`text`,required:!0},{name:`label`,type:`text`}],render(e,t){let n=t.args.value??``,r=t.args.label??``;return BS(t,{type:`radiobutton`,key:`$${t.varName}:${n}`,label:r||n,perform:()=>t.setValue(n)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`radio`,name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}}),$({name:`listbox`,subMacros:[`option`],storeVar:!0,parameters:[zS],render({children:e=[]},t){let n=t.extractOptions(e);return BS(t,{type:`listbox`,label:t.varName,options:n,perform:e=>{e!==void 0&&t.setValue(String(e))}}),q(`select`,{id:t.id,class:t.cls,value:Nc(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>q(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,storeVar:!0,parameters:[zS],render({children:e=[]},t){let n=t.extractOptions(e),r=()=>{if(n.length===0)return;let e=t.getValue(),r=(n.indexOf(String(e))+1)%n.length;t.setValue(n[r])};return BS(t,{type:`cycle`,label:t.value==null?n[0]||``:String(t.value),options:n,perform:e=>{e===void 0?r():t.setValue(e)}}),q(`button`,{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||``:String(t.value)})}}),$({name:`span`,block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))},text:({children:e=[]},t)=>t.renderText(e)});var HS=new WeakMap;function US(e){let t=HS.get(e);if(t&&t.content===e.content)return t.ast;let n=qo(e.content);return HS.set(e,{content:e.content,ast:n}),n}function WS(e){return Cp(US(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function GS(e){if(!e)return null;try{return WS(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var KS=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function qS({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=es(`storyData`),i=KS.has(e.name),[a,o]=Ae(!1),s=Pe(()=>{try{return WS(e)}catch(t){return q(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,bf(e),`: `,Jc(t)]})}},[e.content,e.name]),c=e=>i?void 0:r?.passages.get(e),l=c(`PassageHeader`),u=c(`PassageFooter`),d=c(`PassageDone`),f=Pe(()=>GS(l),[l?.content]),p=Pe(()=>GS(u),[u?.content]);Me(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Pe(()=>a?GS(d):null,[a,d?.content]),h=j(null);Ne(()=>{n!==void 0&&ix(n),h.current&&_g(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=q(`div`,{ref:h,class:`passage`,\"data-passage\":e.name,\"data-tags\":e.tags.join(` `),\"data-transition\":t,children:[f&&q(`div`,{class:`passage-header`,children:f}),s,p&&q(`div`,{class:`passage-footer`,children:p}),m&&q(`div`,{hidden:!0,children:m})]});return g?q(Of.Provider,{value:!0,children:_}):_}var JS=new Set([`none`,`fade`,`fade-through`,`crossfade`]),YS={type:`fade-through`,duration:300,pause:50};function XS(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!JS.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;let r={type:n};for(let t of e)if(t.startsWith(`duration:`)){let e=Number(t.slice(9));Number.isNaN(e)||(r.duration=e)}else if(t.startsWith(`pause:`)){let e=Number(t.slice(6));Number.isNaN(e)||(r.pause=e)}return r}function ZS(e){return{type:e.type,duration:e.duration??YS.duration,pause:e.pause??YS.pause}}function QS(e,t,n){let r=XS(e);return r?ZS(r):t?ZS(t):n?ZS(n):{...YS}}function $S(e,t){let n=e.cloneNode(!0);n.removeAttribute(`id`);let r=n.querySelectorAll(`[id]`);for(let e=0;e<r.length;e++)r[e].removeAttribute(`id`);n.style.pointerEvents=`none`,n.style.userSelect=`none`;let i=n.querySelectorAll(`audio, video`);for(let e=0;e<i.length;e++){let t=i[e];t.pause?.(),t.muted=!0}return n.classList.remove(`passage`),n.classList.add(`passage-snapshot`),n.setAttribute(`data-transition`,t),n}function eC(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 tC(e,t){if(!e)return null;eC(e,t);let n=e.querySelector(`.passage`);return n?$S(n,t.type):null}function nC(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}$({name:`passage`,interpolate:!0,render(e,t){let{currentPassage:n,navigationId:r,storyData:i,renderDeferred:a}=es(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=Ae({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=j(`fade`),d=j(0),f=j(null),p=j([]),m=Fe(()=>{for(let e of p.current)clearTimeout(e);p.current=[],nC(f.current)},[]);Me(()=>m,[m]),Me(()=>{let e=Q.getState(),{history:t,historyIndex:a,transitionConfig:s}=e,h=e.consumeNextTransition(),g=d.current;d.current=t.length;let _=!c,v=t.length===1&&a===0&&g>1,y=t.length>1&&a===t.length-1&&g>1&&Math.abs(t.length-g)>1;if(r===o.id)return;m();let b=i?.passages.get(n);if(!b){u.current=`none`,l(n);return}if(_||v||y){u.current=`fade`,l(n);return}let x=QS(b.tags,h,s);u.current=x.type;let S=f.current;if(x.type===`none`){l(n);return}if(x.type===`fade`){S&&eC(S,x),l(n);return}let C=x.type===`fade-through`||x.type===`crossfade`?tC(S,x):null;if(!S||!C){l(n);return}if(x.type===`fade-through`){S.appendChild(C),l(``);let e=x.duration+x.pause,t=setTimeout(()=>{l(n)},e),r=e+x.duration;p.current=[t,setTimeout(()=>{nC(S)},r)];return}S.classList.add(`passage-container--crossfading`),S.appendChild(C),l(n),p.current=[setTimeout(()=>{nC(S)},x.duration)]},[r]);let h=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!h&&c&&!a)return q(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let g=i?.passages.get(`PassageReady`);return q(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&g&&q(`div`,{hidden:!0,children:WS(g)},`ready-${r}`),q(`div`,{class:`passage-container`,ref:f,children:h&&q(qS,{passage:h,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`)})]})}}),$({name:`watch`,parameters:[{name:`condition`,type:`string`,required:!0},{name:`options`,type:`options`,parameters:[{name:`goto`,type:`string`},{name:`dialog`,type:`string`},{name:`run`,type:`string`},{name:`name`,type:`string`},{name:`priority`,type:`number`},{name:`once`,type:`flag`}]}],render(e,t){let{hooks:n}=t,{condition:r,options:i}=t.args;if(r===void 0)return null;let a=n.useRef(!1);return a.current||(a.current=!0,fv(r,i)),null}}),$({name:`unwatch`,parameters:[{name:`name`,type:`text`,required:!0}],render(e,t){let n=t.args.name??``,r=t.hooks.useRef(!1);return r.current||(r.current=!0,pv(n)),null}});var rC=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}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;-webkit-user-select: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:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.spindle-error-banners{z-index:300;flex-direction:column;gap:.5em;width:min(42em,100% - 1.5em);display:flex;position:fixed;top:.75em;left:50%;transform:translate(-50%)}.spindle-error-banner{color:#ffcdd2;background:#2b1a1e;border:1px solid #ef5350;border-radius:4px;padding:.75em 2.75em .75em 1em;font-size:.9em;line-height:1.5;position:relative;box-shadow:0 2px 12px #00000080}.spindle-error-banner-message{color:#ef9a9a;font-family:monospace}.spindle-error-banner-dismiss{color:inherit;cursor:pointer;background:0 0;border:none;font-size:1em;position:absolute;top:.5em;right:.5em}.spindle-error-banner-dismiss:hover{color:#fff}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;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:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-panel:focus{outline:none}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;align-items:center;gap:.5em;padding:.4em 0;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.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{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.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{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.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{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.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 #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.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:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function iC(e,t){e.innerHTML=``;let n=document.createElement(`div`);n.style.cssText=`font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto`;let r=document.createElement(`h1`);r.style.color=`#c00`,r.textContent=`Story Validation Errors`,n.appendChild(r);let i=document.createElement(`ul`);i.style.cssText=`line-height:1.6`;for(let e of t){let t=document.createElement(`li`);t.textContent=e,i.appendChild(t)}n.appendChild(i),e.appendChild(n)}function aC(e){let t=document.getElementById(`root`);throw t&&iC(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function oC(e,t){let n=mc(),r=new Map(n.map(e=>[e.name.toLowerCase(),e.parameters]));return pS(e.passages.values(),{isKnownMacro:e=>!!rc(e)||lc(e)||!!_c(e),macroNames:n.map(e=>e.name),parametersOf:e=>r.get(e),only:t}).map(sS)}function sC(){let e=ub(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=rC,document.head.appendChild(t),bx(),e.userCSS){let t=document.createElement(`style`);t.textContent=e.userCSS,document.head.appendChild(t)}if(e.userScript)try{Function(e.userScript)()}catch(e){console.error(`spindle: Error in story JavaScript:`,e)}document.dispatchEvent(new CustomEvent(`:storystartup`));let n={},r=e.passages.get(`StoryVariables`);if(!r){let e=`Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.`,t=document.getElementById(`root`);throw t&&iC(t,[e]),Error(`spindle: ${e}`)}let i=Bx(r.content),a=mc().filter(e=>e.storeVar).map(e=>e.name);for(let t of rS(e.passages.values()))hr(t);let o=Zx(e.passages,i,a);o.push(...oC(e,e=>e.name===`StoryInit`));let s={},c=e.passages.get(`StoryTransients`);if(c){let e=Bx(c.content,`%`);for(let t of e.keys())i.has(t)&&o.push(`StoryTransients: Variable \"${t}\" is already declared in StoryVariables. Names must be unique across scopes.`);s=Qx(e)}o.length>0&&aC(o),n=Qx(i),mx(Object.keys(n),Object.keys(s)),Q.getState().init(e,n,s),Ay(),L_(x_(e.ifid));let l=oC(e,e=>e.name!==`StoryInit`);l.length>0&&aC(l);for(let[,t]of e.passages)if(t.tags.includes(`widget`)){let e=qo(t.content);for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=tS(n.rawArgs);try{hS(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t.name}\" was not registered: ${Jc(n)}`)}}}let u=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==u&&(u=e.navigationId,kb())}),bv();let 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.`);let f=document.getElementById(`root`);if(!f)throw Error(`spindle: No <div id=\"root\"> element found.`);ge(q(rb,{}),f);let p=cx();p?p.then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,sC):sC();</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.57.0","author":"Rohal12","description":"A Preact-based story format for Twine 2.","image":"","url":"","license":"Unlicense","proofing":false,"source":"<!doctype html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\n />\n <title>{{STORY_NAME}}</title>\n <link\n id=\"favicon\"\n rel=\"icon\"\n type=\"image/svg+xml\"\n href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='sg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23c4b5fd'/%3E%3Cstop offset='50%25' stop-color='%238b5cf6'/%3E%3Cstop offset='100%25' stop-color='%235b21b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%237c3aed' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(55,16,16)'/%3E%3Cellipse cx='16' cy='16' rx='13' ry='5' stroke='%238b5cf6' stroke-width='1.8' fill='none' opacity='.85' transform='rotate(-55,16,16)'/%3E%3Cpath d='M16 3Q19.5 9 20.5 16 19.5 23 16 29 12.5 23 11.5 16 12.5 9 16 3Z' fill='url(%23sg)'/%3E%3C/svg%3E\"\n />\n <script type=\"module\" crossorigin>var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel=\"modulepreload\"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return x(e,s,i,a,null)}function x(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(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`?w(e):null}function T(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=v({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),ce(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??w(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,ue(i,o,a),t.__e=t.__=null,o.__e!=n&&E(o)}}function E(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}),E(e)}function ee(e){(!e.__d&&(e.__d=!0)&&a.push(e)&&!D.__r++||o!=r.debounceRendering)&&((o=r.debounceRendering)||s)(D)}function D(){try{for(var e,t=1;a.length;)a.length>t&&a.sort(c),e=a.shift(),t=a.length,T(e)}finally{a.length=D.__r=0}}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=ne(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=ce(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&pe(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?c=re(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function ne(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=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]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=O(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),me(s,s));return r}function re(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=re(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=w(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ie(e,t){return t=t||[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){ie(e,t)}):t.push(e)),t}function O(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?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)&&s==l.key&&c==l.type)return o}return-1}function ae(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function oe(e,t,n,r,i){var a,o;n: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||ae(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ae(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(l,`$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=u,e.addEventListener(t,a?f:d,a)):e.removeEventListener(t,a?f:d,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 n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function se(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=u++;else if(t.t<n.u)return;return n(r.event?r.event(t):t)}}}function ce(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,w,T,E,ee,D,ne,re,ie,O=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof O==`function`)try{if(w=t.props,T=O.prototype&&O.prototype.render,E=(d=O.contextType)&&i[d.__c],ee=d?E?E.props.value:d.__:i,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new O(w,ee):(t.__c=f=new C(w,ee),f.constructor=O,f.render=he),E&&E.sub(f),f.state||(f.state={}),f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&O.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,O.getDerivedStateFromProps(w,f.__s))),m=f.props,g=f.state,f.__v=t,p)T&&O.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&O.getDerivedStateFromProps==null&&w!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(w,ee),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(w,f.__s,ee)){t.__v!=n.__v&&(f.props=w,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(w,f.__s,ee),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=ee,f.props=w,f.__P=e,f.__e=!1,D=r.__r,ne=0,T)f.state=f.__s,f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,D&&D(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++ne<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),re=d!=null&&d.type===S&&d.key==null?de(d.props.children):d,c=te(e,_(re)?re:[re],t,n,i,a,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(ie=o.length;ie--;)y(o[ie]);le(t)}else t.__e=n.__e,t.__k=n.__k,e.then||le(t);r.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=fe(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function le(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(le))}function ue(e,t,n){for(var i=0;i<n.length;i++)pe(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function de(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(de):v({},e)}function fe(e,t,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||(o=`http://www.w3.org/1999/xhtml`),s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&(r.__m&&r.__m(t,s),l=!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s=s&&n.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||oe(e,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||oe(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),te(t.type==`template`?e.content:e,_(h)?h:[h],t,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l||(d=`value`,C==`progress`&&v==null?e.removeAttribute(`value`):v!=null&&(v!==e[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&oe(e,d,v,x[d],o),d=`checked`,b!=null&&b!=e[d]&&oe(e,d,b,x[d],o))}return e}function pe(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function me(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||pe(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&me(i[a],t,n||typeof e.type!=`function`);n||y(e.__e),e.__c=e.__=e.__e=void 0}function he(e,t,n){return this.constructor(e,n)}function ge(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],ce(t,e=(!a&&i||t).__k=b(S,null,[e]),o||m,m,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),ue(s,e,c)}function _e(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,ee(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+ p++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=h.slice,r={__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(t){e=t}throw e}},i=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),ee(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ee(this))},C.prototype.render=S,a=[],s=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,c=function(e,t){return e.__v.__b-t.__v.__b},D.__r=0,l=/(PointerCapture)$|Capture$/i,u=0,d=se(!1),f=se(!0),p=0;var ve,k,ye,be,xe=0,Se=[],A=r,Ce=A.__b,we=A.__r,Te=A.diffed,Ee=A.__c,De=A.unmount,Oe=A.__;function ke(e,t){A.__h&&A.__h(k,e,xe||t),xe=0;var n=k.__H||(k.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function Ae(e){return xe=1,je(Ue,e)}function je(e,t,n){var r=ke(ve++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ue(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=k,!k.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};k.__f=!0;var a=k.shouldComponentUpdate,o=k.componentWillUpdate;k.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},k.shouldComponentUpdate=i}return r.__N||r.__}function Me(e,t){var n=ke(ve++,3);!A.__s&&He(n.__H,t)&&(n.__=e,n.u=t,k.__H.__h.push(n))}function Ne(e,t){var n=ke(ve++,4);!A.__s&&He(n.__H,t)&&(n.__=e,n.u=t,k.__h.push(n))}function j(e){return xe=5,Pe(function(){return{current:e}},[])}function Pe(e,t){var n=ke(ve++,7);return He(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Fe(e,t){return xe=8,Pe(function(){return e},t)}function Ie(e){var t=k.context[e.__c],n=ke(ve++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(k)),t.props.value):e.__}function Le(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Be),t.__h.some(Ve),t.__h=[]}catch(n){t.__h=[],A.__e(n,e.__v)}}}A.__b=function(e){k=null,Ce&&Ce(e)},A.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},A.__r=function(e){we&&we(e),ve=0;var t=(k=e.__c).__H;t&&(ye===k?(t.__h=[],k.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Be),t.__h.some(Ve),t.__h=[],ve=0)),ye=k},A.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&be===A.requestAnimationFrame||((be=A.requestAnimationFrame)||ze)(Le)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),ye=k=null},A.__c=function(e,t){t.some(function(e){try{e.__h.some(Be),e.__h=e.__h.filter(function(e){return!e.__||Ve(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],A.__e(n,e.__v)}}),Ee&&Ee(e,t)},A.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Be(e)}catch(e){t=e}}),n.__H=void 0,t&&A.__e(t,n.__v))};var Re=typeof requestAnimationFrame==`function`;function ze(e){var t,n=function(){clearTimeout(r),Re&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Re&&(t=requestAnimationFrame(n))}function Be(e){var t=k,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),k=t}function Ve(e){var t=k;e.__c=e.__(),k=t}function He(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ue(e,t){return typeof t==`function`?t(e):t}function We(e,t){for(var n in t)e[n]=t[n];return e}function Ge(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 Ke(e,t){var n=t(),r=Ae({t:{__:n,u:t}}),i=r[0].t,a=r[1];return Ne(function(){i.__=n,i.u=t,qe(i)&&a({t:i})},[e,n,t]),Me(function(){return qe(i)&&a({t:i}),e(function(){qe(i)&&a({t:i})})},[e]),n}function qe(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 Je(e,t){this.props=e,this.context=t}(Je.prototype=new C).isPureReactComponent=!0,Je.prototype.shouldComponentUpdate=function(e,t){return Ge(this.props,e)||Ge(this.state,t)};var Ye=r.__b;r.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ye&&Ye(e)},typeof Symbol<`u`&&Symbol.for;var Xe=r.__e;r.__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??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Xe(e,t,n,r)};var Ze=r.unmount;function Qe(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=We({},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(e){return Qe(e,t,n)})),e}function $e(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return $e(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function et(){this.__u=0,this.o=null,this.__b=null}function tt(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function nt(){this.i=null,this.l=null}r.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ze&&Ze(e)},(et.prototype=new C).__c=function(e,t){var n=t.__c,r=this;r.o??(r.o=[]),r.o.push(n);var i=tt(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=$e(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},et.prototype.componentWillUnmount=function(){this.o=[]},et.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Qe(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var rt=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]}};(nt.prototype=new C).__a=function(e){var t=this,n=tt(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),rt(t,e,r)):i()};n?n(a):a()}},nt.prototype.render=function(e){this.i=null,this.l=new Map;var t=ie(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},nt.prototype.componentDidUpdate=nt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){rt(e,n,t)})};var it=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,at=/^(?: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]/,ot=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,st=/[A-Z0-9]/g,ct=typeof document<`u`,lt=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(C.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ut=r.event;r.event=function(e){return ut&&(e=ut(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var dt={configurable:!0,get:function(){return this.class}},ft=r.vnode;r.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||ct&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||lt(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:ot.test(a)&&(a=s):s=a=`oninput`:i&&at.test(a)?a=a.replace(st,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=ie(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=ie(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,dt)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=it,ft&&ft(e)};var pt=r.__r;r.__r=function(e){pt&&pt(e),e.__c};var mt=r.diffed;r.diffed=function(e){mt&&mt(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)};var ht=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},gt=(e=>e?ht(e):ht),_t=e=>e;function vt(e){function t(t=_t){let n=Fe(()=>t(e.getState()),[t]);return Ke(e.subscribe,n)}return Object.assign(t,e)}function yt(){return e=>vt(gt()(e))}var bt=Symbol.for(`immer-nothing`),xt=Symbol.for(`immer-draftable`),M=Symbol.for(`immer-state`);function St(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Ct=Object,wt=Ct.getPrototypeOf,Tt=`constructor`,Et=`prototype`,Dt=`configurable`,Ot=`enumerable`,kt=`writable`,At=`value`,jt=e=>!!e&&!!e[M];function Mt(e){return e?Ft(e)||Ht(e)||!!e[xt]||!!e[Tt]?.[xt]||Ut(e)||Wt(e):!1}var Nt=Ct[Et][Tt].toString(),Pt=new WeakMap;function Ft(e){if(!e||!Gt(e))return!1;let t=wt(e);if(t===null||t===Ct[Et])return!0;let n=Ct.hasOwnProperty.call(t,Tt)&&t[Tt];if(n===Object)return!0;if(!Kt(n))return!1;let r=Pt.get(n);return r===void 0&&(r=Function.toString.call(n),Pt.set(n,r)),r===Nt}function It(e,t,n=!0){Lt(e)===0?(n?Reflect.ownKeys(e):Ct.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Lt(e){let t=e[M];return t?t.type_:Ht(e)?1:Ut(e)?2:Wt(e)?3:0}var Rt=(e,t,n=Lt(e))=>n===2?e.has(t):Ct[Et].hasOwnProperty.call(e,t),zt=(e,t,n=Lt(e))=>n===2?e.get(t):e[t],Bt=(e,t,n,r=Lt(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Vt(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Ht=Array.isArray,Ut=e=>e instanceof Map,Wt=e=>e instanceof Set,Gt=e=>typeof e==`object`,Kt=e=>typeof e==`function`,qt=e=>typeof e==`boolean`;function Jt(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Yt=e=>Gt(e)?e?.[M]:null,Xt=e=>e.copy_||e.base_,Zt=e=>{let t=Yt(e);return t?t.copy_??t.base_:e},Qt=e=>e.modified_?e.copy_:e.base_;function $t(e,t){if(Ut(e))return new Map(e);if(Wt(e))return new Set(e);if(Ht(e))return Array[Et].slice.call(e);let n=Ft(e);if(t===!0||t===`class_only`&&!n){let t=Ct.getOwnPropertyDescriptors(e);delete t[M];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[kt]===!1&&(a[kt]=!0,a[Dt]=!0),(a.get||a.set)&&(t[i]={[Dt]:!0,[kt]:!0,[Ot]:a[Ot],[At]:e[i]})}return Ct.create(wt(e),t)}else{let t=wt(e);if(t!==null&&n)return{...e};let r=Ct.create(t);return Ct.assign(r,e)}}function en(e,t=!1){return tn(e)||jt(e)||!Mt(e)?e:(Lt(e)>1&&Ct.defineProperties(e,{set:P,add:P,clear:P,delete:P}),Ct.freeze(e),t&&It(e,(e,t)=>{en(t,!0)},!1),e)}function N(){St(2)}var P={[At]:N};function tn(e){return e===null||!Gt(e)?!0:Ct.isFrozen(e)}var nn=`MapSet`,rn=`Patches`,F=`ArrayMethods`,an={};function on(e){let t=an[e];return t||St(0,e),t}var sn=e=>!!an[e];function cn(e,t){an[e]||(an[e]=t)}var ln,un=()=>ln,dn=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:sn(nn)?on(nn):void 0,arrayMethodsPlugin_:sn(F)?on(F):void 0});function fn(e,t){t&&(e.patchPlugin_=on(rn),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function pn(e){mn(e),e.drafts_.forEach(I),e.drafts_=null}function mn(e){e===ln&&(ln=e.parent_)}var hn=e=>ln=dn(ln,e);function I(e){let t=e[M];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function gn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[M].modified_&&(pn(t),St(4)),Mt(e)&&(e=_n(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[M].base_,e,t)}else e=_n(t,n);return vn(t,e,!0),pn(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===bt?void 0:e}function _n(e,t){if(tn(t))return t;let n=t[M];if(!n)return En(t,e.handledSet_,e);if(!bn(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);wn(n,e)}return n.copy_}function vn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&en(t,n)}function yn(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var bn=(e,t)=>e.scope_===t,xn=[];function Sn(e,t,n,r){let i=Xt(e),a=e.type_;if(r!==void 0&&zt(i,r,a)===t){Bt(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;It(i,(e,n)=>{if(jt(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??xn;for(let e of o)Bt(i,e,n,a)}function Cn(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!bn(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Qt(i);Sn(e,i.draft_??i,a,n),wn(i,r)})}function wn(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}yn(e)}}function Tn(e,t,n){let{scope_:r}=e;if(jt(n)){let i=n[M];bn(i,r)&&i.callbacks_.push(function(){Pn(e),Sn(e,n,Qt(i),t)})}else Mt(n)&&e.callbacks_.push(function(){let i=Xt(e);e.type_===3?i.has(n)&&En(n,r.handledSet_,r):zt(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&En(zt(e.copy_,t,e.type_),r.handledSet_,r)})}function En(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||jt(e)||t.has(e)||!Mt(e)||tn(e)?e:(t.add(e),It(e,(r,i)=>{if(jt(i)){let t=i[M];bn(t,n)&&(Bt(e,r,Qt(t),e.type_),yn(t))}else Mt(i)&&En(i,t,n)}),e)}function Dn(e,t){let n=Ht(e),r={type_:n?1:0,scope_:t?t.scope_:un(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=On;n&&(i=[r],a=kn);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var On={get(e,t){if(t===M)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Xt(e);if(!Rt(i,t,e.type_))return jn(e,i,t);let a=i[t];if(e.finalized_||!Mt(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Jt(t))return a;if(a===An(e.base_,t)){Pn(e);let n=e.type_===1?+t:t,r=In(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Xt(e)},ownKeys(e){return Reflect.ownKeys(Xt(e))},set(e,t,n){let r=Mn(Xt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=An(Xt(e),t),i=r?.[M];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Vt(n,r)&&(n!==void 0||Rt(e.base_,t,e.type_)))return!0;Pn(e),Nn(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Tn(e,t,n),!0)},deleteProperty(e,t){return Pn(e),An(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Nn(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Xt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[kt]:!0,[Dt]:e.type_!==1||t!==`length`,[Ot]:r[Ot],[At]:n[t]}},defineProperty(){St(11)},getPrototypeOf(e){return wt(e.base_)},setPrototypeOf(){St(12)}},kn={};for(let e in On){let t=On[e];kn[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}kn.deleteProperty=function(e,t){return kn.set.call(this,e,t,void 0)},kn.set=function(e,t,n){return On.set.call(this,e[0],t,n,e[0])};function An(e,t){let n=e[M];return(n?Xt(n):e)[t]}function jn(e,t,n){let r=Mn(t,n);return r?At in r?r[At]:r.get?.call(e.draft_):void 0}function Mn(e,t){if(!(t in e))return;let n=wt(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=wt(n)}}function Nn(e){e.modified_||(e.modified_=!0,e.parent_&&Nn(e.parent_))}function Pn(e){e.copy_||(e.assigned_=new Map,e.copy_=$t(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Kt(e)&&!Kt(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Kt(t)||St(6),n!==void 0&&!Kt(n)&&St(7);let r;if(Mt(e)){let i=hn(this),a=In(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?pn(i):mn(i)}return fn(i,n),gn(r,i)}else if(!e||!Gt(e)){if(r=t(e),r===void 0&&(r=e),r===bt&&(r=void 0),this.autoFreeze_&&en(r,!0),n){let t=[],i=[];on(rn).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else St(1,e)},this.produceWithPatches=(e,t)=>{if(Kt(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},qt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),qt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),qt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Mt(e)||St(8),jt(e)&&(e=Ln(e));let t=hn(this),n=In(t,e,void 0);return n[M].isManual_=!0,mn(t),n}finishDraft(e,t){let n=e&&e[M];(!n||!n.isManual_)&&St(9);let{scope_:r}=n;return fn(r,t),gn(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--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=on(rn).applyPatches_;return jt(e)?r(e,t):this.produce(e,e=>r(e,t))}};function In(e,t,n,r){let[i,a]=Ut(t)?on(nn).proxyMap_(t,n):Wt(t)?on(nn).proxySet_(t,n):Dn(t,n);return(n?.scope_??un()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Cn(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function Ln(e){return jt(e)||St(10,e),Rn(e)}function Rn(e){if(!Mt(e)||tn(e))return e;let t=e[M],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=$t(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=$t(e,!0);return It(n,(e,t)=>{Bt(n,e,Rn(t))},r),t&&(t.finalized_=!1),n}function zn(){function e(n,r=[]){if(n.key_!==void 0){let e=n.parent_.copy_??n.parent_.base_,t=Yt(zt(e,n.key_)),i=zt(e,n.key_);if(i===void 0||i!==n.draft_&&i!==n.base_&&i!==n.copy_||t!=null&&t.base_!==n.base_)return null;let a=n.parent_.type_===3,o;if(a){let e=n.parent_;o=Array.from(e.drafts_.keys()).indexOf(n.key_)}else o=n.key_;if(!(a&&e.size>o||Rt(e,o)))return null;r.push(o)}if(n.parent_)return e(n.parent_,r);r.reverse();try{t(n.copy_,r)}catch{return null}return r}function t(e,t){let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(n=zt(n,r),!Gt(n)||n===null)throw Error(`Cannot resolve path at '${t.join(`/`)}'`)}return n}let n=`replace`,r=`remove`;function i(e,t,n){if(e.scope_.processedForPatches_.has(e))return;e.scope_.processedForPatches_.add(e);let{patches_:r,inversePatches_:i}=n;switch(e.type_){case 0:case 2:return o(e,t,r,i);case 1:return a(e,t,r,i);case 3:return s(e,t,r,i)}}function a(e,t,i,a){let{base_:o,assigned_:s}=e,c=e.copy_;c.length<o.length&&([o,c]=[c,o],[i,a]=[a,i]);let l=e.allIndicesReassigned_===!0;for(let e=0;e<o.length;e++){let r=c[e],u=o[e];if((l||s?.get(e.toString()))&&r!==u){let o=r?.[M];if(o&&o.modified_)continue;let s=t.concat([e]);i.push({op:n,path:s,value:d(r)}),a.push({op:n,path:s,value:d(u)})}}for(let e=o.length;e<c.length;e++){let n=t.concat([e]);i.push({op:`add`,path:n,value:d(c[e])})}for(let e=c.length-1;o.length<=e;--e){let n=t.concat([e]);a.push({op:r,path:n})}}function o(e,t,i,a){let{base_:o,copy_:s,type_:c}=e;It(e.assigned_,(e,l)=>{let u=zt(o,e,c),f=zt(s,e,c),p=l?Rt(o,e)?n:`add`:r;if(u===f&&p===n)return;let m=t.concat(e);i.push(p===r?{op:p,path:m}:{op:p,path:m,value:d(f)}),a.push(p===`add`?{op:r,path:m}:p===r?{op:`add`,path:m,value:d(u)}:{op:n,path:m,value:d(u)})})}function s(e,t,n,i){let{base_:a,copy_:o}=e,s=0;a.forEach(e=>{if(!o.has(e)){let a=t.concat([s]);n.push({op:r,path:a,value:e}),i.unshift({op:`add`,path:a,value:e})}s++}),s=0,o.forEach(e=>{if(!a.has(e)){let a=t.concat([s]);n.push({op:`add`,path:a,value:e}),i.unshift({op:r,path:a,value:e})}s++})}function c(e,t,r){let{patches_:i,inversePatches_:a}=r;i.push({op:n,path:[],value:t===bt?void 0:t}),a.push({op:n,path:[],value:e})}function l(e,t){return t.forEach(t=>{let{path:i,op:a}=t,o=e;for(let e=0;e<i.length-1;e++){let t=Lt(o),n=i[e];typeof n!=`string`&&typeof n!=`number`&&(n=``+n),(t===0||t===1)&&(n===`__proto__`||n===Tt)&&St(19),Kt(o)&&n===Et&&St(19),o=zt(o,n),Gt(o)||St(18,i.join(`/`))}let s=Lt(o),c=u(t.value),l=i[i.length-1];switch(a){case n:switch(s){case 2:return o.set(l,c);case 3:St(16);default:return o[l]=c}case`add`:switch(s){case 1:return l===`-`?o.push(c):o.splice(l,0,c);case 2:return o.set(l,c);case 3:return o.add(c);default:return o[l]=c}case r:switch(s){case 1:return o.splice(l,1);case 2:return o.delete(l);case 3:return o.delete(t.value);default:return delete o[l]}default:St(17,a)}}),e}function u(e){if(!Mt(e))return e;if(Ht(e))return e.map(u);if(Ut(e))return new Map(Array.from(e.entries()).map(([e,t])=>[e,u(t)]));if(Wt(e))return new Set(Array.from(e).map(u));let t=Object.create(wt(e));for(let n in e)t[n]=u(e[n]);return Rt(e,xt)&&(t[xt]=e[xt]),t}function d(e){return jt(e)?u(e):e}cn(rn,{applyPatches_:l,generatePatches_:i,generateReplacementPatches_:c,getPath:e})}function Bn(){class e extends Map{constructor(e,t){super(),this[M]={type_:2,parent_:t,scope_:t?t.scope_:un(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:e,draft_:this,isManual_:!1,revoked_:!1,callbacks_:[]}}get size(){return Xt(this[M]).size}has(e){return Xt(this[M]).has(e)}set(e,t){let r=this[M];return o(r),(!Xt(r).has(e)||Xt(r).get(e)!==t)&&(n(r),Nn(r),r.assigned_.set(e,!0),r.copy_.set(e,t),r.assigned_.set(e,!0),Tn(r,e,t)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return o(t),n(t),Nn(t),t.base_.has(e)?t.assigned_.set(e,!1):t.assigned_.delete(e),t.copy_.delete(e),!0}clear(){let e=this[M];o(e),Xt(e).size&&(n(e),Nn(e),e.assigned_=new Map,It(e.base_,t=>{e.assigned_.set(t,!1)}),e.copy_.clear())}forEach(e,t){let n=this[M];Xt(n).forEach((n,r,i)=>{e.call(t,this.get(r),r,this)})}get(e){let t=this[M];o(t);let r=Xt(t).get(e);if(t.finalized_||!Mt(r)||r!==t.base_.get(e))return r;let i=In(t.scope_,r,t,e);return n(t),t.copy_.set(e,i),i}keys(){return Xt(this[M]).keys()}values(){let e=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}}entries(){let e=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let t=e.next();if(t.done)return t;let n=this.get(t.value);return{done:!1,value:[t.value,n]}}}}[Symbol.iterator](){return this.entries()}}function t(t,n){let r=new e(t,n);return[r,r[M]]}function n(e){e.copy_||(e.assigned_=new Map,e.copy_=new Map(e.base_))}class r extends Set{constructor(e,t){super(),this[M]={type_:3,parent_:t,scope_:t?t.scope_:un(),modified_:!1,finalized_:!1,copy_:void 0,base_:e,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1,assigned_:void 0,callbacks_:[]}}get size(){return Xt(this[M]).size}has(e){let t=this[M];return o(t),t.copy_?!!(t.copy_.has(e)||t.drafts_.has(e)&&t.copy_.has(t.drafts_.get(e))):t.base_.has(e)}add(e){let t=this[M];return o(t),this.has(e)||(a(t),Nn(t),t.copy_.add(e),Tn(t,e,e)),this}delete(e){if(!this.has(e))return!1;let t=this[M];return o(t),a(t),Nn(t),t.copy_.delete(e)||(t.drafts_.has(e)?t.copy_.delete(t.drafts_.get(e)):!1)}clear(){let e=this[M];o(e),Xt(e).size&&(a(e),Nn(e),e.copy_.clear())}values(){let e=this[M];return o(e),a(e),e.copy_.values()}entries(){let e=this[M];return o(e),a(e),e.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(e,t){let n=this.values(),r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}}function i(e,t){let n=new r(e,t);return[n,n[M]]}function a(e){e.copy_||(e.copy_=new Set,e.base_.forEach(t=>{if(Mt(t)){let n=In(e.scope_,t,e,t);e.drafts_.set(t,n),e.copy_.add(n)}else e.copy_.add(t)}))}function o(e){e.revoked_&&St(3,JSON.stringify(Xt(e)))}function s(e){if(e.type_===3&&e.copy_){let t=new Set(e.copy_);e.copy_.clear(),t.forEach(t=>{e.copy_.add(Zt(t))})}}cn(nn,{proxyMap_:t,proxySet_:i,fixSetContents:s})}var Vn=new Fn().produce,Hn=e=>(t,n,r)=>(r.setState=(e,n,...r)=>t(typeof e==`function`?Vn(e):e,n,...r),e(r.setState,n,r)),Un=`{`,Wn=`}`,Gn={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},Kn=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),qn={elseif:`if`,else:`if`,case:`switch`,default:`switch`,next:`timed`},Jn=new Set([`if`,`switch`,`timed`]),Yn=[[`|`,!1],[`->`,!1],[`<-`,!0]],Xn={};function Zn(e){for(let[t,n]of Yn){let r=e.indexOf(t);if(r===-1)continue;let i=e.slice(0,r).trim(),a=e.slice(r+t.length).trim();return n?{display:a,target:i}:{display:i,target:a}}let t=e.trim();return{display:t,target:t}}function Qn(e){return`\"`+e.replace(/[\\\\\"]/g,`\\\\$&`)+`\"`}function $n(e,t){return t.className&&(e.className=t.className),t.id&&(e.id=t.id),e}function er(e){let t=[],n=``;for(let[r,i]of e)i&&(r===`.`?t.push(i):n=i);return $n({},{className:t.join(` `),id:n})}function tr(e){return e.lex===`html`?(e.isClose?`</`:`<`)+e.tag+`>`:Un+(e.isClose?`/`:``)+e.name+Wn}function nr(e){return e.lex===`html`?`</`+e.tag+`>`:Un+`/`+e.name+Wn}function rr(e){return`line `+e.start.line+`, column `+e.start.column}function ir(e,t){return e.lex===t.lex&&e.lower===t.lower}function ar(e,t,n){return n.lex=e,n.start=t.start.offset,n.end=t.end.offset,n.loc=t,n}function or(e){switch(e.lex){case`text`:return{type:`text`,value:e.value};case`link`:return $n({type:`macro`,name:`link`,rawArgs:Qn(e.display)+` `+Qn(e.target),children:[]},e);case`variable`:return $n({type:`variable`,name:e.name,scope:e.scope},e);case`expression`:return $n({type:`expression`,expression:e.expression},e);default:return e}}function sr(e){let t={start:e.start,end:e.end};switch(e.lex){case`text`:return{type:`text`,value:e.value,...t};case`link`:return $n({type:`link`,display:e.display,target:e.target,...t},e);case`variable`:return $n({type:`variable`,name:e.name,scope:e.scope,...t},e);case`expression`:return $n({type:`expression`,expression:e.expression,...t},e);case`macro`:return $n({type:`macro`,name:e.name,rawArgs:e.rawArgs,isClose:e.isClose,...t},e);case`html`:return{type:`html`,tag:e.tag,attributes:e.attributes,isClose:e.isClose,isSelfClose:e.isSelfClose,...t}}}function cr(e,t){let n=[],r=null,i=e=>{if(e!=null){if(Array.isArray(e))return e.forEach(i);if(e.lex===`text`&&!e.escape&&r&&r.lex===`text`&&!r.escape&&r.end===e.start){r.value+=e.value,r.end=e.end;return}n.push(e),r=e}};return i(e),t?n.map(t):n}var lr=class extends SyntaxError{constructor(e,t,n,r){super(e),this.expected=t,this.found=n,this.location=r,this.name=`SyntaxError`}format(e){let t=`Error: `+this.message;if(this.location){let n=null,r=e.find(e=>e.source===this.location.source);r&&(n=r.text.split(/\\r\\n|\\n|\\r/g));let i=this.location.start,a=this.location.source&&typeof this.location.source.offset==`function`?this.location.source.offset(i):i,o=this.location.source+`:`+a.line+`:`+a.column;if(n){let e=this.location.end,r=``.padEnd(a.line.toString().length,` `),s=n[i.line-1],c=(i.line===e.line?e.column:s.length+1)-i.column||1;t+=`\n --> `+o+`\n`+r+` |\n`+a.line+` | `+s+`\n`+r+` | `+``.padEnd(i.column-1,` `)+``.padEnd(c,`^`)}else t+=`\n at `+o}return t}static buildMessage(e,t){function n(e){return e.codePointAt(0).toString(16).toUpperCase()}let r=Object.prototype.hasOwnProperty.call(RegExp.prototype,`unicode`)?RegExp(`[\\\\p{C}\\\\p{Mn}\\\\p{Mc}]`,`gu`):null;function i(e){return r?e.replace(r,e=>`\\\\u{`+n(e)+`}`):e}function a(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\"/g,`\\\\\"`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}function o(e){return i(e.replace(/\\\\/g,`\\\\\\\\`).replace(/\\]/g,`\\\\]`).replace(/\\^/g,`\\\\^`).replace(/-/g,`\\\\-`).replace(/\\0/g,`\\\\0`).replace(/\\t/g,`\\\\t`).replace(/\\n/g,`\\\\n`).replace(/\\r/g,`\\\\r`).replace(/[\\x00-\\x0F]/g,e=>`\\\\x0`+n(e)).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g,e=>`\\\\x`+n(e)))}let s={literal(e){return`\"`+a(e.text)+`\"`},class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+`-`+o(e[1]):o(e));return`[`+(e.inverted?`^`:``)+t.join(``)+`]`+(e.unicode?`u`:``)},any(){return`any character`},end(){return`end of input`},other(e){return e.description}};function c(e){return s[e.type](e)}function l(e){let t=e.map(c);if(t.sort(),t.length>0){let e=1;for(let n=1;n<t.length;n++)t[n-1]!==t[n]&&(t[e]=t[n],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+` or `+t[1];default:return t.slice(0,-1).join(`, `)+`, or `+t[t.length-1]}}function u(e){return e?`\"`+a(e)+`\"`:`end of input`}return`Expected `+l(e)+` but `+u(t)+` found.`}};function ur(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Markup:vn,Tokens:An},a=vn,o=/^[^\\\\{[<]/,s=/^[{}]/,c=/^[$_@%(!\\/a-zA-Z]/,l=/^[.#]/,u=/^[a-zA-Z0-9_\\-]/,d=/^[$_@%]/,f=/^[a-zA-Z0-9_.]/,p=/^[$_@%(!]/,m=/^[a-zA-Z]/,h=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF}]/,g=/^[\\t-\\r \\/>\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,_=/^[a-zA-Z0-9\\-]/,v=/^[\\t-\\r \"'\\/<->{}\\xA0\\u1680\\u2000-\\u200A\\u2028-\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,y=/^[^\"]/,b=/^[^']/,x=/^[\"']/,S=/^[^ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF>]/,C=/^[ \\t\\n\\r\\v\\f\\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]/,w=fn(),T=dn([`\\\\`,`{`,`[`,`<`],!0,!1,!1),E=un(`\\\\`,!1),ee=dn([`{`,`}`],!1,!1,!1),D=un(`{`,!1),te=dn([`$`,`_`,`@`,`%`,`(`,`!`,`/`,[`a`,`z`],[`A`,`Z`]],!1,!1,!1),ne=un(`<`,!1),re=un(`[`,!1),ie=un(`[[`,!1),O=un(`]]`,!1),ae=un(` `,!1),oe=dn([`.`,`#`],!1,!1,!1),se=dn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`-`],!1,!1,!1),ce=dn([`$`,`_`,`@`,`%`],!1,!1,!1),le=dn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`_`,`.`],!1,!1,!1),ue=un(`}`,!1),de=dn([`$`,`_`,`@`,`%`,`(`,`!`],!1,!1,!1),fe=un(`/`,!1),pe=dn([[`a`,`z`],[`A`,`Z`]],!1,!1,!1),me=dn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`}`],!0,!1,!1),he=un(`>`,!1),ge=dn([[`\t`,`\\r`],` `,`/`,`>`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),_e=un(`</`,!1),ve=dn([[`a`,`z`],[`A`,`Z`],[`0`,`9`],`-`],!1,!1,!1),k=dn([[`\t`,`\\r`],` `,`\"`,`'`,`/`,[`<`,`>`],`{`,`}`,`\\xA0`,` `,[` `,` `],[`\\u2028`,`\\u2029`],` `,` `,` `,``],!1,!1,!1),ye=un(`=`,!1),be=un(`\"`,!1),xe=dn([`\"`],!0,!1,!1),Se=un(`'`,!1),A=dn([`'`],!0,!1,!1),Ce=dn([`\"`,`'`],!1,!1,!1),we=dn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``,`>`],!0,!1,!1),Te=dn([` `,`\t`,`\n`,`\\r`,`\\v`,`\\f`,`\\xA0`,` `,[` `,` `],`\\u2028`,`\\u2029`,` `,` `,` `,``],!1,!1,!1);function Ee(e){return e}function De(e){Er(tr(e)+` must be directly inside {`+qn[e.lower]+Wn,e.loc)}function Oe(e){Er(tr(e)+` closes nothing: no `+(e.lex===`html`?`<`+e.tag+`>`:Un+e.name+Wn)+` is open here`,e.loc)}function ke(e){return cr(e,or)}function Ae(e){return e.kind===`open`}function je(e){return wr=e.lower,xr.isRaw(wr)}function Me(e,t){return t}function Ne(e){return xr.isBlock(e.lower)}function j(e,t){return t}function Pe(e){return null}function Fe(e,t){return kr(e,t)}function Ie(){return!br}function Le(e){return!e.isSelfClose}function Re(e,t){return t}function ze(e,t){let n={type:`html`,tag:e.tag,attributes:e.attributes,children:[]};return t&&(Or(e,t),n.children=t.children),n}function Be(e,t,n){return{children:e,branches:t,end:n}}function Ve(e,t){return{tag:e,children:t}}function He(){return null}function Ue(e){return e.kind===`branch`}function We(e){return e}function Ge(e){return e.kind===`close`}function Ke(e){return e}function qe(){return!br}function Je(e){return e}function Ye(t){return Tr(xr.rawBodyEnd(e,t,wr))}function Xe(e){return Sr-on()}function Ze(e,t,n){return{children:t?[{type:`text`,value:t}]:[],branches:[],end:n}}function Qe(){return{children:[],branches:[],end:null}}function $e(e){return cr(e,sr)}function et(){return!br}function tt(e){return e}function nt(){return!br}function rt(e){return Kn.has(e.lower)?null:e}function it(e){return wr=e.lower,e.kind===`open`&&xr.isRaw(wr)}function at(e,t){return t}function ot(e,t){return t?[e,t]:e}function st(t){return Tr(xr.rawBodyEnd(e,t,wr))}function ct(e){return Sr-on()}function lt(e,t,n){let r={start:{offset:e},end:{offset:e+t.length}};return[t?ar(`text`,r,{value:t}):null,n]}function ut(){return on()}function dt(e){return ar(`text`,sn(),{value:e})}function ft(e){return e.length%2==1}function pt(e,t){return t}function mt(t,n){let r=sn(),i=e.charAt(r.end.offset);if(br){if(!n&&i!==Un&&i!==Wn)return ar(`text`,r,{value:t});let e=ar(`text`,r,{value:`\\\\`.repeat(t.length>>1)+(n||``)});return e.escape=!0,e}if(!n)return ar(`text`,r,{value:t});let a=ar(`text`,r,{value:t.slice(1)});a.end=r.end.offset-2;let o=ar(`text`,r,{value:n});return o.start=r.end.offset-2,o.escape=!0,t.length>1?[a,o]:o}function ht(){return ar(`text`,sn(),{value:Un})}function gt(){return!br}function _t(){return ar(`text`,sn(),{value:`<`})}function vt(){return ar(`text`,sn(),{value:`[`})}function yt(){return!br}function bt(e,t){return $n(ar(`link`,sn(),Zn(t)),e)}function xt(){return!br}function M(){Er(`Unclosed link: [[ without ]]`,sn())}function St(e){return er(e)}function Ct(){return Xn}function wt(e,t){return[e,t]}function Tt(e,t,n){return $n(ar(`variable`,sn(),{name:n,scope:Gn[t]}),e)}function Et(e,t){return $n(ar(`expression`,sn(),{expression:t}),e)}function Dt(){Er(`Unclosed `+Un+e.substr(sn().end.offset,1)+`…: no } ends it`,sn())}function Ot(t){return Tr(xr.closeBrace(e,t,t))}function kt(e){return Sr-on()}function At(e,t){return t}function jt(t,n,r,i,a){return Tr(xr.closeBrace(e,a,n))}function Mt(e,t,n,r,i){return Sr-on()}function Nt(e,t,n,r,i,a){return a}function Pt(e,t,n,r,i,a){let o=sn(),s=r.toLowerCase(),c=ar(`macro`,o,{name:r,lower:s,rawArgs:``,isClose:!!n});return a===null&&Er(`Unclosed `+Un+(n?`/`:``)+r+`…: no } ends the macro`,o),c.rawArgs=a.trim(),n?(e!==Xn&&Er(`A closing tag takes no selectors: `+tr(c),o),c.rawArgs&&Er(`A closing tag takes no arguments: `+Un+`/`+r+` `+c.rawArgs+Wn,o),c.kind=`close`):($n(c,e),c.kind=Object.prototype.hasOwnProperty.call(qn,s)?`branch`:`open`),c}function Ft(e){Er(`A closing tag starts with a letter after `+Un+`/`,sn())}function It(){return!br}function Lt(e){return Kn.has(e.lower)}function Rt(e){return null}function zt(e,t,n){let r=e.toLowerCase();return ar(`html`,sn(),{tag:e,lower:r,attributes:Dr(t),isClose:!1,isSelfClose:!!n||Kn.has(r)})}function Bt(t,n){let r=e.charAt(n);r||Er(`Unclosed tag <`+t+`: no > ends it (write < for a < that starts no tag)`,sn());let i={source:sn().source,start:{offset:n,line:0,column:0},end:{offset:n+1,line:0,column:0}};Er(`Unexpected `+JSON.stringify(r)+` in the tag <`+t+`>: expected an attribute, or > to end the tag`,i)}function Vt(e){return ar(`html`,sn(),{tag:e,lower:e.toLowerCase(),attributes:{},isClose:!0,isSelfClose:!1})}function Ht(e){return Cr=xr.isCodeAttribute(e),!0}function Ut(e,t){return t}function Wt(e,t){return[e,t??``]}function Gt(e){return e}function Kt(e){return e}function qt(e){Er(`Unclosed attribute value: the `+e+` here has no closing `+e,sn())}function Jt(){return!Cr}function Yt(e){return e.length%2==1}function Xt(){return!Cr}function Zt(t,n){return Tr(xr.closeBrace(e,n,t))}function Qt(e,t){return Sr-on()}function $t(){return!Cr}function en(){return Cr}let N=t.peg$currPos|0,P=N,tn=[{line:1,column:1}],nn=N,rn=t.peg$maxFailExpected||[],F=t.peg$silentFails|0,an;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule \"`+t.startRule+`\".`);a=i[t.startRule]}function on(){return P}function sn(){return hn(P,N)}function cn(e,t){throw t=t===void 0?hn(P,N):t,gn(e,t)}function ln(t=N){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function un(e,t){return{type:`literal`,text:e,ignoreCase:t}}function dn(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function fn(){return{type:`any`}}function pn(){return{type:`end`}}function mn(t){let n=tn[t],r;if(n)return n;if(t>=tn.length)r=tn.length-1;else for(r=t;!tn[--r];);for(n=tn[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return tn[t]=n,n}function hn(e,t,n){let i=mn(e),a=mn(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function I(e){N<nn||(N>nn&&(nn=N,rn=[]),rn.push(e))}function gn(e,t){return new lr(e,null,null,t)}function _n(e,t,n){return new lr(lr.buildMessage(e,t),e,t,n)}function vn(){let e,t,r;return e=N,t=bn(),r=yn(),r===n?(N=e,e=n):(P=e,e=Ee(t)),e}function yn(){let t,r;return t=N,F++,e.length>N?(r=e.charAt(N),N++):(r=n,F===0&&I(w)),F--,r===n?t=void 0:(N=t,t=n),t===n&&(t=N,r=Dn(),r!==n&&(P=t,r=De(r)),t=r,t===n&&(t=N,r=On(),r!==n&&(P=t,r=Oe(r)),t=r)),t}function bn(){let e,t,r;for(e=N,t=[],r=xn();r!==n;)t.push(r),r=xn();return P=e,t=ke(t),e=t,e}function xn(){let e;return e=Pn(),e===n&&(e=Fn(),e===n&&(e=Ln(),e===n&&(e=Cn(),e===n&&(e=dr(),e===n&&(e=Hn(),e===n&&(e=Sn(),e===n&&(e=In()))))))),e}function Sn(){let e,t,r,i,a,o;return e=N,t=Qn(),t===n?(N=e,e=n):(P=N,r=Ae(t),r=r?void 0:n,r===n?(N=e,e=n):(i=N,P=N,a=je(t),a=a?void 0:n,a===n?(N=i,i=n):(o=kn(),o===n?(N=i,i=n):(P=i,i=Me(t,o))),i===n&&(i=N,P=N,a=Ne(t),a=a?void 0:n,a===n?(N=i,i=n):(o=wn(),o===n?(N=i,i=n):(P=i,i=j(t,o))),i===n&&(i=N,a=``,P=i,a=Pe(t),i=a)),i===n?(N=e,e=n):(P=e,e=Fe(t,i)))),e}function Cn(){let e,t,r,i,a,o;return e=N,P=N,t=Ie(),t=t?void 0:n,t===n?(N=e,e=n):(r=fr(),r===n?(N=e,e=n):(i=N,P=N,a=Le(r),a=a?void 0:n,a===n?(N=i,i=n):(o=wn(),o===n?(N=i,i=n):(P=i,i=Re(r,o))),i===n&&(i=null),P=e,e=ze(r,i))),e}function wn(){let e,t,r,i;if(e=N,t=bn(),t!==n){for(r=[],i=Tn();i!==n;)r.push(i),i=Tn();i=En(),i===n?(N=e,e=n):(P=e,e=Be(t,r,i))}else N=e,e=n;return e}function Tn(){let e,t,r;return e=N,t=Dn(),t===n?(N=e,e=n):(r=bn(),r===n?(N=e,e=n):(P=e,e=Ve(t,r))),e}function En(){let t,r,i;return t=On(),t===n&&(t=N,r=N,F++,e.length>N?(i=e.charAt(N),N++):(i=n,F===0&&I(w)),F--,i===n?r=void 0:(N=r,r=n),r!==n&&(P=t,r=He()),t=r),t}function Dn(){let e,t,r;return e=N,t=Qn(),t===n?(N=e,e=n):(P=N,r=Ue(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=We(t))),e}function On(){let e,t,r;return e=N,t=Qn(),t===n?(N=e,e=n):(P=N,r=Ge(t),r=r?void 0:n,r===n?(N=e,e=n):(P=e,e=Ke(t))),e===n&&(e=N,P=N,t=qe(),t=t?void 0:n,t===n?(N=e,e=n):(r=pr(),r===n?(N=e,e=n):(P=e,e=Je(r)))),e}function kn(){let t,r,i,a,o,s,c,l;if(t=N,r=Nn(),P=N,i=Ye(r),i=i?void 0:n,i!==n){for(a=N,o=Xe(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=On(),o===n?(N=t,t=n):(P=t,t=Ze(r,a,o)))}else N=t,t=n;return t===n&&(t=N,r=``,P=t,r=Qe(),t=r),t}function An(){let e,t,r;for(e=N,t=[],r=jn();r!==n;)t.push(r),r=jn();return P=e,t=$e(t),e=t,e}function jn(){let e,t,r,i,a;return e=Pn(),e===n&&(e=Fn(),e===n&&(e=Ln(),e===n&&(e=N,P=N,t=et(),t=t?void 0:n,t===n?(N=e,e=n):(r=fr(),r===n?(N=e,e=n):(P=e,e=tt(r))),e===n&&(e=N,P=N,t=nt(),t=t?void 0:n,t===n?(N=e,e=n):(r=pr(),r===n?(N=e,e=n):(P=e,e=rt(r))),e===n&&(e=Hn(),e===n&&(e=N,t=Qn(),t===n?(N=e,e=n):(r=N,P=N,i=it(t),i=i?void 0:n,i===n?(N=r,r=n):(a=Mn(),a===n?(N=r,r=n):(P=r,r=at(t,a))),r===n&&(r=null),P=e,e=ot(t,r)),e===n&&(e=In()))))))),e}function Mn(){let t,r,i,a,o,s,c,l;if(t=N,r=Nn(),P=N,i=st(r),i=i?void 0:n,i!==n){for(a=N,o=ct(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(o=On(),o===n?(N=t,t=n):(P=t,t=lt(r,a,o)))}else N=t,t=n;return t}function Nn(){let e,t;return e=N,t=``,P=e,t=ut(),e=t,e}function Pn(){let t,r,i,a;if(t=N,r=N,i=[],a=e.charAt(N),o.test(a)?N++:(a=n,F===0&&I(T)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(N),o.test(a)?N++:(a=n,F===0&&I(T));else i=n;return r=i===n?i:e.substring(r,N),r!==n&&(P=t,r=dt(r)),t=r,t}function Fn(){let t,r,i,a,o;if(t=N,r=N,i=[],e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,F===0&&I(E)),a!==n)for(;a!==n;)i.push(a),e.charCodeAt(N)===92?(a=`\\\\`,N++):(a=n,F===0&&I(E));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(i=N,P=N,a=ft(r),a=a?void 0:n,a===n?(N=i,i=n):(o=e.charAt(N),s.test(o)?N++:(o=n,F===0&&I(ee)),o===n?(N=i,i=n):(P=i,i=pt(r,o))),i===n&&(i=null),P=t,t=mt(r,i)),t}function In(){let t,r,i,a,o,s;return t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=N,F++,a=N,o=zn(),o===n?(N=a,a=n):(s=e.charAt(N),c.test(s)?N++:(s=n,F===0&&I(te)),s===n?(N=a,a=n):(o=[o,s],a=o)),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=t,t=n):(P=t,t=ht())),t===n&&(t=N,r=N,F++,i=N,P=N,a=gt(),a=a?void 0:n,a===n?(N=i,i=n):(o=pr(),o===n?(N=i,i=n):(a=[a,o],i=a)),F--,i===n?r=void 0:(N=r,r=n),r===n?(N=t,t=n):(e.charCodeAt(N)===60?(i=`<`,N++):(i=n,F===0&&I(ne)),i===n?(N=t,t=n):(P=t,t=_t())),t===n&&(t=N,e.charCodeAt(N)===91?(r=`[`,N++):(r=n,F===0&&I(re)),r!==n&&(P=t,r=vt()),t=r)),t}function Ln(){let t,r,i,a,o,s;return t=N,P=N,r=yt(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,F===0&&I(ie)),i===n?(N=t,t=n):(a=zn(),a===n?(N=t,t=n):(o=N,s=Rn(),o=e.substring(o,N),e.substr(N,2)===`]]`?(s=`]]`,N+=2):(s=n,F===0&&I(O)),s===n?(N=t,t=n):(P=t,t=bt(a,o))))),t===n&&(t=N,P=N,r=xt(),r=r?void 0:n,r===n?(N=t,t=n):(e.substr(N,2)===`[[`?(i=`[[`,N+=2):(i=n,F===0&&I(ie)),i===n?(N=t,t=n):(P=t,t=M()))),t}function Rn(){let t,r,i,a;for(t=[],r=N,i=N,F++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,F===0&&I(O)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,F===0&&I(ie))),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,F===0&&I(w)),a===n?(N=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=N,i=N,F++,e.substr(N,2)===`]]`?(a=`]]`,N+=2):(a=n,F===0&&I(O)),a===n&&(e.substr(N,2)===`[[`?(a=`[[`,N+=2):(a=n,F===0&&I(ie))),F--,a===n?i=void 0:(N=i,i=n),i===n?(N=r,r=n):(e.length>N?(a=e.charAt(N),N++):(a=n,F===0&&I(w)),a===n?(N=r,r=n):(i=[i,a],r=i));return t}function zn(){let t,r,i;if(t=N,r=[],i=Bn(),i!==n)for(;i!==n;)r.push(i),i=Bn();else r=n;return r===n?(N=t,t=n):(e.charCodeAt(N)===32?(i=` `,N++):(i=n,F===0&&I(ae)),i===n&&(i=null),P=t,t=St(r)),t===n&&(t=N,r=``,P=t,r=Ct(),t=r),t}function Bn(){let t,r,i,a,o;if(t=N,r=e.charAt(N),l.test(r)?N++:(r=n,F===0&&I(oe)),r!==n){for(i=N,a=[],o=Vn();o!==n;)a.push(o),o=Vn();i=e.substring(i,N),P=t,t=wt(r,i)}else N=t,t=n;return t}function Vn(){let t,r,i,a,o;if(t=e.charAt(N),u.test(t)?N++:(t=n,F===0&&I(se)),t===n)if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r!==n)if(i=e.charAt(N),d.test(i)?N++:(i=n,F===0&&I(ce)),i!==n){for(a=[],o=e.charAt(N),f.test(o)?N++:(o=n,F===0&&I(le));o!==n;)a.push(o),o=e.charAt(N),f.test(o)?N++:(o=n,F===0&&I(le));e.charCodeAt(N)===125?(o=`}`,N++):(o=n,F===0&&I(ue)),o===n?(N=t,t=n):(r=[r,i,a,o],t=r)}else N=t,t=n;else N=t,t=n;return t}function Hn(){let t,r,i,a,o,s,c;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r!==n)if(i=zn(),i!==n)if(a=e.charAt(N),d.test(a)?N++:(a=n,F===0&&I(ce)),a!==n){for(o=N,s=[],c=e.charAt(N),f.test(c)?N++:(c=n,F===0&&I(le));c!==n;)s.push(c),c=e.charAt(N),f.test(c)?N++:(c=n,F===0&&I(le));o=e.substring(o,N),e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(ue)),s===n?(N=t,t=n):(P=t,t=Tt(i,a,o))}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=zn(),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),p.test(o)?N++:(o=n,F===0&&I(de)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=Yn(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(s=`}`,N++):(s=n,F===0&&I(ue)),s===n?(N=t,t=n):(P=t,t=Et(i,o)))))),t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=zn(),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),p.test(o)?N++:(o=n,F===0&&I(de)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(P=t,t=Dt()))))),t}function Yn(){let t,r,i,a,o,s,c,l;if(t=N,r=Nn(),P=N,i=Ot(r),i=i?void 0:n,i!==n){for(a=N,o=kt(r),s=N,c=[],c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));l!==n;)c.push(l),c.length>=(o|0)?l=n:e.length>N?(l=e.charAt(N),N++):(l=n,F===0&&I(w));c.length<(o|0)?(N=s,s=n):s=c,o=s,a=o===n?o:e.substring(a,N),a===n?(N=t,t=n):(P=t,t=At(r,a))}else N=t,t=n;return t}function Qn(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h;if(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r!==n)if(i=zn(),i!==n)if(a=Nn(),e.charCodeAt(N)===47?(o=`/`,N++):(o=n,F===0&&I(fe)),o===n&&(o=null),s=ur(),s!==n){if(c=Nn(),l=N,P=N,u=jt(i,a,o,s,c),u=u?void 0:n,u!==n){for(d=N,f=Mt(i,a,o,s,c),p=N,m=[],m.length>=(f|0)?h=n:e.length>N?(h=e.charAt(N),N++):(h=n,F===0&&I(w));h!==n;)m.push(h),m.length>=(f|0)?h=n:e.length>N?(h=e.charAt(N),N++):(h=n,F===0&&I(w));m.length<(f|0)?(N=p,p=n):p=m,f=p,d=f===n?f:e.substring(d,N),d===n?(N=l,l=n):(e.charCodeAt(N)===125?(f=`}`,N++):(f=n,F===0&&I(ue)),f===n?(N=l,l=n):(P=l,l=Nt(i,a,o,s,c,d)))}else N=l,l=n;l===n&&(l=null),P=t,t=Pt(i,a,o,s,c,l)}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t===n&&(t=N,e.charCodeAt(N)===123?(r=`{`,N++):(r=n,F===0&&I(D)),r===n?(N=t,t=n):(i=zn(),i===n?(N=t,t=n):(e.charCodeAt(N)===47?(a=`/`,N++):(a=n,F===0&&I(fe)),a===n?(N=t,t=n):(P=t,t=Ft(i))))),t}function ur(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),m.test(i)?N++:(i=n,F===0&&I(pe)),i!==n){for(a=[],o=e.charAt(N),h.test(o)?N++:(o=n,F===0&&I(me));o!==n;)a.push(o),o=e.charAt(N),h.test(o)?N++:(o=n,F===0&&I(me));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function dr(){let e,t,r,i;return e=N,P=N,t=It(),t=t?void 0:n,t===n?(N=e,e=n):(r=pr(),r===n?(N=e,e=n):(P=N,i=Lt(r),i=i?void 0:n,i===n?(N=e,e=n):(P=e,e=Rt(r)))),e}function fr(){let t,r,i,a,o,s,c;if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,F===0&&I(ne)),r!==n)if(i=mr(),i!==n){for(a=[],o=hr();o!==n;)a.push(o),o=hr();o=vr(),e.charCodeAt(N)===47?(s=`/`,N++):(s=n,F===0&&I(fe)),s===n&&(s=null),e.charCodeAt(N)===62?(c=`>`,N++):(c=n,F===0&&I(he)),c===n?(N=t,t=n):(P=t,t=zt(i,a,s))}else N=t,t=n;else N=t,t=n;if(t===n)if(t=N,e.charCodeAt(N)===60?(r=`<`,N++):(r=n,F===0&&I(ne)),r!==n)if(i=mr(),i!==n)if(a=N,F++,o=e.charAt(N),g.test(o)?N++:(o=n,F===0&&I(ge)),o===n&&(o=N,F++,e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(w)),F--,s===n?o=void 0:(N=o,o=n)),F--,o===n?a=n:(N=a,a=void 0),a!==n){for(o=[],s=hr();s!==n;)o.push(s),s=hr();s=vr(),c=Nn(),P=t,t=Bt(i,c)}else N=t,t=n;else N=t,t=n;else N=t,t=n;return t}function pr(){let t,r,i,a;return t=N,e.substr(N,2)===`</`?(r=`</`,N+=2):(r=n,F===0&&I(_e)),r===n?(N=t,t=n):(i=mr(),i===n?(N=t,t=n):(vr(),e.charCodeAt(N)===62?(a=`>`,N++):(a=n,F===0&&I(he)),a===n?(N=t,t=n):(P=t,t=Vt(i)))),t}function mr(){let t,r,i,a,o;if(t=N,r=N,i=e.charAt(N),m.test(i)?N++:(i=n,F===0&&I(pe)),i!==n){for(a=[],o=e.charAt(N),_.test(o)?N++:(o=n,F===0&&I(ve));o!==n;)a.push(o),o=e.charAt(N),_.test(o)?N++:(o=n,F===0&&I(ve));i=[i,a],r=i}else N=r,r=n;return t=r===n?r:e.substring(t,N),t}function hr(){let t,r,i,a,o,s,c;if(t=N,vr(),r=N,i=[],a=N,o=N,F++,s=e.charAt(N),v.test(s)?N++:(s=n,F===0&&I(k)),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=a,a=n):(e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(w)),s===n?(N=a,a=n):(o=[o,s],a=o)),a!==n)for(;a!==n;)i.push(a),a=N,o=N,F++,s=e.charAt(N),v.test(s)?N++:(s=n,F===0&&I(k)),F--,s===n?o=void 0:(N=o,o=n),o===n?(N=a,a=n):(e.length>N?(s=e.charAt(N),N++):(s=n,F===0&&I(w)),s===n?(N=a,a=n):(o=[o,s],a=o));else i=n;return r=i===n?i:e.substring(r,N),r===n?(N=t,t=n):(P=N,i=Ht(r),i=i?void 0:n,i===n?(N=t,t=n):(a=N,o=vr(),e.charCodeAt(N)===61?(s=`=`,N++):(s=n,F===0&&I(ye)),s===n?(N=a,a=n):(vr(),c=gr(),c===n?(N=a,a=n):(P=a,a=Ut(r,c))),a===n&&(a=null),P=t,t=Wt(r,a))),t}function gr(){let t,r,i,a,o;if(t=N,e.charCodeAt(N)===34?(r=`\"`,N++):(r=n,F===0&&I(be)),r!==n){for(i=N,a=[],o=_r(),o===n&&(o=e.charAt(N),y.test(o)?N++:(o=n,F===0&&I(xe)));o!==n;)a.push(o),o=_r(),o===n&&(o=e.charAt(N),y.test(o)?N++:(o=n,F===0&&I(xe)));i=e.substring(i,N),e.charCodeAt(N)===34?(a=`\"`,N++):(a=n,F===0&&I(be)),a===n?(N=t,t=n):(P=t,t=Gt(i))}else N=t,t=n;if(t===n){if(t=N,e.charCodeAt(N)===39?(r=`'`,N++):(r=n,F===0&&I(Se)),r!==n){for(i=N,a=[],o=_r(),o===n&&(o=e.charAt(N),b.test(o)?N++:(o=n,F===0&&I(A)));o!==n;)a.push(o),o=_r(),o===n&&(o=e.charAt(N),b.test(o)?N++:(o=n,F===0&&I(A)));i=e.substring(i,N),e.charCodeAt(N)===39?(a=`'`,N++):(a=n,F===0&&I(Se)),a===n?(N=t,t=n):(P=t,t=Kt(i))}else N=t,t=n;if(t===n&&(t=N,r=e.charAt(N),x.test(r)?N++:(r=n,F===0&&I(Ce)),r!==n&&(P=t,r=qt(r)),t=r,t===n)){for(t=N,r=[],i=e.charAt(N),S.test(i)?N++:(i=n,F===0&&I(we));i!==n;)r.push(i),i=e.charAt(N),S.test(i)?N++:(i=n,F===0&&I(we));t=e.substring(t,N)}}return t}function _r(){let t,r,i,a,o,c,l,u,f,p,h,g,_,v;if(t=N,P=N,r=Jt(),r=r?void 0:n,r!==n){if(i=N,a=[],e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,F===0&&I(E)),o!==n)for(;o!==n;)a.push(o),e.charCodeAt(N)===92?(o=`\\\\`,N++):(o=n,F===0&&I(E));else a=n;i=a===n?a:e.substring(i,N),i===n?(N=t,t=n):(a=N,P=N,o=Yt(i),o=o?void 0:n,o===n?(N=a,a=n):(c=e.charAt(N),s.test(c)?N++:(c=n,F===0&&I(ee)),c===n?(N=a,a=n):(o=[o,c],a=o)),a===n&&(a=null),r=[r,i,a],t=r)}else N=t,t=n;if(t===n){if(t=N,P=N,r=Xt(),r=r?void 0:n,r!==n)if(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(D)),i!==n)if(a=zn(),a!==n)if(o=Nn(),e.charCodeAt(N)===47?(c=`/`,N++):(c=n,F===0&&I(fe)),c===n&&(c=null),l=ur(),l!==n)if(u=Nn(),P=N,f=Zt(o,u),f=f?void 0:n,f!==n){for(p=N,h=Qt(o,u),g=N,_=[],_.length>=(h|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,F===0&&I(w));v!==n;)_.push(v),_.length>=(h|0)?v=n:e.length>N?(v=e.charAt(N),N++):(v=n,F===0&&I(w));_.length<(h|0)?(N=g,g=n):g=_,h=g,p=h===n?h:e.substring(p,N),p===n?(N=t,t=n):(e.charCodeAt(N)===125?(h=`}`,N++):(h=n,F===0&&I(ue)),h===n?(N=t,t=n):(r=[r,i,a,o,c,l,u,f,p,h],t=r))}else N=t,t=n;else N=t,t=n;else N=t,t=n;else N=t,t=n;else N=t,t=n;t===n&&(t=N,P=N,r=$t(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(D)),i===n?(N=t,t=n):(a=zn(),a===n?(N=t,t=n):(o=N,F++,c=N,e.charCodeAt(N)===47?(l=`/`,N++):(l=n,F===0&&I(fe)),l===n&&(l=null),u=e.charAt(N),m.test(u)?N++:(u=n,F===0&&I(pe)),u===n?(N=c,c=n):(l=[l,u],c=l),F--,c===n?o=void 0:(N=o,o=n),o===n?(N=t,t=n):(c=Yn(),c===n?(N=t,t=n):(e.charCodeAt(N)===125?(l=`}`,N++):(l=n,F===0&&I(ue)),l===n?(N=t,t=n):(r=[r,i,a,o,c,l],t=r)))))),t===n&&(t=N,P=N,r=en(),r=r?void 0:n,r===n?(N=t,t=n):(e.charCodeAt(N)===123?(i=`{`,N++):(i=n,F===0&&I(D)),i===n?(N=t,t=n):(a=N,F++,o=e.charAt(N),d.test(o)?N++:(o=n,F===0&&I(ce)),F--,o===n?a=n:(N=a,a=void 0),a===n?(N=t,t=n):(o=Yn(),o===n?(N=t,t=n):(e.charCodeAt(N)===125?(c=`}`,N++):(c=n,F===0&&I(ue)),c===n?(N=t,t=n):(r=[r,i,a,o,c],t=r)))))))}return t}function vr(){let e,t;for(e=[],t=yr();t!==n;)e.push(t),t=yr();return e}function yr(){let t;return t=e.charAt(N),C.test(t)?N++:(t=n,F===0&&I(Te)),t}let br=t.text===!0,xr=t.hooks,Sr=-1,Cr=!1,wr=``;function Tr(e){return Sr=e,e>=0}function Er(e,t){cn(e,t)}function Dr(e){let t={},n=new Set;for(let[r,i]of e){let e=r.toLowerCase();n.has(e)||(n.add(e),Object.defineProperty(t,r,{value:i,enumerable:!0,writable:!0,configurable:!0}))}return t}function Or(e,t){for(let n of t.branches){let t=qn[n.tag.lower];(e.lex!==`macro`||e.lower!==t)&&Er(tr(n.tag)+` must be directly inside {`+t+Wn+`, not inside `+tr(e),n.tag.loc)}t.end||Er(`Unclosed `+tr(e)+`: no `+nr(e)+` closes it`,e.loc),ir(e,t.end)||Er(tr(t.end)+` found where `+nr(e)+` should close the `+tr(e)+` opened at `+rr(e.loc),t.end.loc)}function kr(e,t){let n={type:`macro`,name:e.lower,rawArgs:e.rawArgs,children:[]};if(!t)return $n(n,e);if(Or(e,t),n.children=t.children,Jn.has(e.lower)){n.branches=[$n({rawArgs:e.rawArgs,children:t.children},e)];for(let e of t.branches)n.branches.push($n({rawArgs:e.tag.rawArgs,children:e.children},e.tag));n.children=[]}else $n(n,e);return n}an=a();let Ar=an!==n&&N===e.length;function jr(){throw an!==n&&N<e.length&&I(pn()),_n(rn,nn<e.length?ln(nn):null,nn<e.length?hn(nn,nn+1):hn(nn,nn))}if(t.peg$library)return{peg$result:an,peg$currPos:N,peg$FAILED:n,peg$maxFailExpected:rn,peg$maxFailPos:nn,peg$success:Ar,peg$throw:Ar?void 0:jr};if(Ar)return an;jr()}var dr=class extends Map{get(e){return super.get(e.toLowerCase())}set(e,t){return super.set(e.toLowerCase(),t)}has(e){return super.has(e.toLowerCase())}delete(e){return super.delete(e.toLowerCase())}},fr=class{constructor(e=[]){this.names=new dr;for(let t of e)this.add(t)}add(e){this.names.set(e,!0)}has(e){return this.names.has(e)}delete(e){this.names.delete(e)}},pr=new fr([`if`,`for`,`do`,`button`,`link`,`listbox`,`cycle`,`switch`,`timed`,`repeat`,`type`,`widget`,`span`,`nobr`]);function mr(e){return pr.has(e)}function hr(e){pr.add(e)}var gr={$:`variable`,_:`temporary`,\"@\":`local`,\"%\":`transient`},_r=Object.fromEntries(Object.entries(gr).map(([e,t])=>[t,e])),vr=new Set(Object.keys(gr));function yr(e){return e!==void 0&&vr.has(e)}var br=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],xr=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],Sr=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,Cr=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ-ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,wr={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},Tr=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,Er={5:Tr,\"5module\":Tr+` export import`,6:Tr+` const class extends export import super`},Dr=/^in(stanceof)?$/,Or=RegExp(`[`+Cr+`]`),kr=RegExp(`[`+Cr+Sr+`]`);function Ar(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function jr(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&Or.test(String.fromCharCode(e)):t===!1?!1:Ar(e,xr)}function Mr(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&kr.test(String.fromCharCode(e)):t===!1?!1:Ar(e,xr)||Ar(e,br)}var L=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function Nr(e,t){return new L(e,{beforeExpr:!0,binop:t})}var Pr={beforeExpr:!0},Fr={startsExpr:!0},Ir={};function R(e,t){return t===void 0&&(t={}),t.keyword=e,Ir[e]=new L(e,t)}var z={num:new L(`num`,Fr),regexp:new L(`regexp`,Fr),string:new L(`string`,Fr),name:new L(`name`,Fr),privateId:new L(`privateId`,Fr),eof:new L(`eof`),bracketL:new L(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new L(`]`),braceL:new L(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new L(`}`),parenL:new L(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new L(`)`),comma:new L(`,`,Pr),semi:new L(`;`,Pr),colon:new L(`:`,Pr),dot:new L(`.`),question:new L(`?`,Pr),questionDot:new L(`?.`),arrow:new L(`=>`,Pr),template:new L(`template`),invalidTemplate:new L(`invalidTemplate`),ellipsis:new L(`...`,Pr),backQuote:new L(\"`\",Fr),dollarBraceL:new L(\"${\",{beforeExpr:!0,startsExpr:!0}),eq:new L(`=`,{beforeExpr:!0,isAssign:!0}),assign:new L(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new L(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new L(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Nr(`||`,1),logicalAND:Nr(`&&`,2),bitwiseOR:Nr(`|`,3),bitwiseXOR:Nr(`^`,4),bitwiseAND:Nr(`&`,5),equality:Nr(`==/!=/===/!==`,6),relational:Nr(`</>/<=/>=`,7),bitShift:Nr(`<</>>/>>>`,8),plusMin:new L(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Nr(`%`,10),star:Nr(`*`,10),slash:Nr(`/`,10),starstar:new L(`**`,{beforeExpr:!0}),coalesce:Nr(`??`,1),_break:R(`break`),_case:R(`case`,Pr),_catch:R(`catch`),_continue:R(`continue`),_debugger:R(`debugger`),_default:R(`default`,Pr),_do:R(`do`,{isLoop:!0,beforeExpr:!0}),_else:R(`else`,Pr),_finally:R(`finally`),_for:R(`for`,{isLoop:!0}),_function:R(`function`,Fr),_if:R(`if`),_return:R(`return`,Pr),_switch:R(`switch`),_throw:R(`throw`,Pr),_try:R(`try`),_var:R(`var`),_const:R(`const`),_while:R(`while`,{isLoop:!0}),_with:R(`with`),_new:R(`new`,{beforeExpr:!0,startsExpr:!0}),_this:R(`this`,Fr),_super:R(`super`,Fr),_class:R(`class`,Fr),_extends:R(`extends`,Pr),_export:R(`export`),_import:R(`import`,Fr),_null:R(`null`,Fr),_true:R(`true`,Fr),_false:R(`false`,Fr),_in:R(`in`,{beforeExpr:!0,binop:7}),_instanceof:R(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:R(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:R(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:R(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Lr=/\\r\\n?|\\n|\\u2028|\\u2029/,Rr=new RegExp(Lr.source,`g`);function zr(e){return e===10||e===13||e===8232||e===8233}function Br(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(zr(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var Vr=/[\\u1680\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/,Hr=/(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g,Ur=Object.prototype,Wr=Ur.hasOwnProperty,Gr=Ur.toString,Kr=Object.hasOwn||(function(e,t){return Wr.call(e,t)}),qr=Array.isArray||(function(e){return Gr.call(e)===`[object Array]`}),Jr=Object.create(null);function Yr(e){return Jr[e]||(Jr[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function Xr(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Zr=/(?:[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])/,Qr=function(e,t){this.line=e,this.column=t};Qr.prototype.offset=function(e){return new Qr(this.line,this.column+e)};var $r=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ei(e,t){for(var n=1,r=0;;){var i=Br(e,r,t);if(i<0)return new Qr(n,t-r);++n,r=i}}var ti={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},ni=!1;function ri(e){var t={};for(var n in ti)t[n]=e&&Kr(e,n)?e[n]:ti[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!ni&&typeof console==`object`&&console.warn&&(ni=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),qr(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(qr(t.onComment)&&(t.onComment=ii(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function ii(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new $r(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var ai=1,oi=2,si=4,ci=8,li=16,ui=32,di=64,fi=128,pi=256,mi=512,hi=1024,gi=ai|oi|pi;function _i(e,t){return oi|(e?si:0)|(t?ci:0)}var vi=0,yi=1,bi=2,xi=3,Si=4,Ci=5,wi=function(e,t,n){this.options=e=ri(e),this.sourceFile=e.sourceFile,this.keywords=Yr(Er[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=wr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=Yr(r);var i=(r?r+` `:``)+wr.strict;this.reservedWordsStrict=Yr(i),this.reservedWordsStrictBind=Yr(i+` `+wr.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`\n`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(Lr).length)):this.lineStart=0,this.type=z.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?oi:ai),this.regexpState=null,this.privateNameStack=[]},Ti={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};wi.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},Ti.inFunction.get=function(){return(this.currentVarScope().flags&oi)>0},Ti.inGenerator.get=function(){return(this.currentVarScope().flags&ci)>0},Ti.inAsync.get=function(){return(this.currentVarScope().flags&si)>0},Ti.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(pi|mi))return!1;if(t&oi)return(t&si)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ti.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&ai)},Ti.allowSuper.get=function(){return(this.currentThisScope().flags&di)>0||this.options.allowSuperOutsideMethod},Ti.allowDirectSuper.get=function(){return(this.currentThisScope().flags&fi)>0},Ti.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ti.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(pi|mi)||t&oi&&!(t&li))return!0}return!1},Ti.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&hi||!this.inModule&&e&ai)},Ti.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&pi)>0},wi.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},wi.parse=function(e,t){return new this(t,e).parse()},wi.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},wi.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(wi.prototype,Ti);var Ei=wi.prototype,Di=/^(?:'((?:\\\\[^]|[^'\\\\])*?)'|\"((?:\\\\[^]|[^\"\\\\])*?)\")/;Ei.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){Hr.lastIndex=e,e+=Hr.exec(this.input)[0].length;var t=Di.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){Hr.lastIndex=e+t[0].length;var n=Hr.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||Lr.test(n[0])&&!(/[(`.[+\\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Oi(this,r))}e+=t[0].length,Hr.lastIndex=e,e+=Hr.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Oi(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!Mr(i,!0))break;n+=i<=65535?1:2}return n===t+2&&e.input.slice(t,n)===`in`||n===t+10&&e.input.slice(t,n)===`instanceof`}Ei.eat=function(e){return this.type===e?(this.next(),!0):!1},Ei.isContextual=function(e){return this.type===z.name&&this.value===e&&!this.containsEsc},Ei.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},Ei.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\\bstack\\b.*\\b(exceeded|overflow)\\b/i.test(e.message)||/\\btoo much recursion\\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},Ei.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},Ei.canInsertSemicolon=function(){return this.type===z.eof||this.type===z.braceR||Lr.test(this.input.slice(this.lastTokEnd,this.start))},Ei.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ei.semicolon=function(){!this.eat(z.semi)&&!this.insertSemicolon()&&this.unexpected()},Ei.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},Ei.expect=function(e){this.eat(e)||this.unexpected()},Ei.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var ki=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ei.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},Ei.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},Ei.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},Ei.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var B=wi.prototype;B.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==z.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Ai={kind:`loop`},ji={kind:`switch`};B.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;Hr.lastIndex=this.pos;var t=Hr.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(jr(r)){var i=n;do n+=r<=65535?1:2;while(Mr(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!Dr.test(a))return!0}return!1},B.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;Hr.lastIndex=this.pos;var e=Hr.exec(this.input),t=this.pos+e[0].length,n;return!Lr.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(Mr(n=this.fullCharCodeAt(t+8))||n===92))},B.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;Hr.lastIndex=this.pos;var n=Hr.exec(this.input),r=this.pos+n[0].length;if(Lr.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||Mr(a=this.fullCharCodeAt(i))||a===92)return!1;Hr.lastIndex=i;var o=Hr.exec(this.input);if(r=i+o[0].length,o&&Lr.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!jr(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(Mr(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(Dr.test(l))return!1;if(t&&!e&&l===`of`){Hr.lastIndex=r;var u=Hr.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},B.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},B.isUsing=function(e){return this.isUsingKeyword(!1,e)},B.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=z._var,a=`let`),r){case z._break:case z._continue:return this.parseBreakContinueStatement(i,r.keyword);case z._debugger:return this.parseDebuggerStatement(i);case z._do:return this.parseDoStatement(i);case z._for:return this.parseForStatement(i);case z._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case z._class:return e&&this.unexpected(),this.parseClass(i,!0);case z._if:return this.parseIfStatement(i);case z._return:return this.parseReturnStatement(i);case z._switch:return this.parseSwitchStatement(i);case z._throw:return this.parseThrowStatement(i);case z._try:return this.parseTryStatement(i);case z._const:case z._var:return a=a||this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case z._while:return this.parseWhileStatement(i);case z._with:return this.parseWithStatement(i);case z.braceL:return this.parseBlock(!0,i);case z.semi:return this.parseEmptyStatement(i);case z._export:case z._import:if(this.options.ecmaVersion>10&&r===z._import){Hr.lastIndex=this.pos;var o=Hr.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===z._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,\"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement\"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===z.name&&d.type===`Identifier`&&this.eat(z.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},B.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(z.semi)||this.insertSemicolon()?e.label=null:this.type===z.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},B.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},B.parseDoStatement=function(e){return this.next(),this.labels.push(Ai),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(z._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(z.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},B.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Ai),this.enterScope(0),this.expect(z.parenL),this.type===z.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===z._var||this.type===z._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new ki,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===z._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===z._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},B.parseForAfterInit=function(e,t,n){return(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===z._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},B.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,Ni|(n?0:Pi),!1,t)},B.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(z._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},B.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(z.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},B.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(z.braceL),this.labels.push(ji),this.enterScope(hi);for(var t,n=!1;this.type!==z.braceR;)if(this.type===z._case||this.type===z._default){var r=this.type===z._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(z.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},B.parseThrowStatement=function(e){return this.next(),Lr.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var Mi=[];B.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?ui:0),this.checkLValPattern(e,t?Si:bi),this.expect(z.parenR),e},B.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===z._catch){var t=this.startNode();this.next(),this.eat(z.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(z._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},B.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},B.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Ai),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},B.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},B.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},B.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===z._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},B.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},B.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(z.braceL),e&&this.enterScope(0);this.type!==z.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},B.parseFor=function(e,t){return e.init=t,this.expect(z.semi),e.test=this.type===z.semi?null:this.parseExpression(),this.expect(z.semi),e.update=this.type===z.parenR?null:this.parseExpression(),this.expect(z.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},B.parseForIn=function(e,t){var n=this.type===z._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(z.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},B.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(z.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==z._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===z._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(z.comma))break}return e},B.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?yi:bi,!1)};var Ni=1,Pi=2,Fi=4;B.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===z.star&&t&Pi&&this.unexpected(),e.generator=this.eat(z.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&Ni&&(e.id=t&Fi&&this.type!==z.name?null:this.parseIdent(),e.id&&!(t&Pi)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?yi:bi:xi));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(_i(e.async,e.generator)),t&Ni||(e.id=this.type===z.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&Ni?`FunctionDeclaration`:`FunctionExpression`)},B.parseFunctionParams=function(e){this.expect(z.parenL),e.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},B.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(z.braceL);this.type!==z.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Ii(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},B.parseClassElement=function(e){if(this.eat(z.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(z.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===z.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===z.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(z.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===z.parenL||o!==`method`||i||a){var l=!n.static&&Li(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},B.isClassElementNameStart=function(){return this.type===z.name||this.type===z.privateId||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword},B.parseClassElementName=function(e){this.type===z.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},B.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&Li(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},B.parseClassField=function(e){return Li(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&Li(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(z.eq)?(this.enterScope(mi|di),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},B.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(pi|di);this.type!==z.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},B.parseClassId=function(e,t){this.type===z.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,bi,!1)):(t===!0&&this.unexpected(),e.id=null)},B.parseClassSuper=function(e){e.superClass=this.eat(z._extends)?this.parseExprSubscripts(null,!1):null},B.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},B.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];Kr(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Ii(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function Li(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}B.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==z.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},B.parseExport=function(e,t){if(this.next(),this.eat(z.star))return this.parseExportAllDeclaration(e,t);if(this.eat(z._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==z.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,\"A string literal cannot be used as an exported binding without `from`.\")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},B.parseExportDeclaration=function(e){return this.parseStatement(null)},B.parseExportDefaultDeclaration=function(){var e;if(this.type===z._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,Ni|Fi,!1,e)}else if(this.type===z._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},B.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Kr(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},B.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},B.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},B.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},B.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},B.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(z.braceL);!this.eat(z.braceR);){if(n)n=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;t.push(this.parseExportSpecifier(e))}return t},B.parseImport=function(e){return this.next(),this.type===z.string?(e.specifiers=Mi,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===z.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},B.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,bi),this.finishNode(e,`ImportSpecifier`)},B.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,bi),this.finishNode(e,`ImportDefaultSpecifier`)},B.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,bi),this.finishNode(e,`ImportNamespaceSpecifier`)},B.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===z.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(z.comma)))return e;if(this.type===z.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(z.braceL);!this.eat(z.braceR);){if(t)t=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;e.push(this.parseImportSpecifier())}return e},B.parseWithClause=function(){var e=[];if(!this.eat(z._with))return e;this.expect(z.braceL);for(var t={},n=!0;!this.eat(z.braceR);){if(n)n=!1;else if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Kr(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},B.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(z.colon),this.type!==z.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},B.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===z.string){var e=this.parseLiteral(this.value);return Zr.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},B.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},B.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`\"`||this.input[e.start]===`'`)};var Ri=wi.prototype;Ri.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},Ri.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},Ri.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},Ri.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==z.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},Ri.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case z.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(z.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case z.braceL:return this.parseObj(!0)}return this.parseIdent()},Ri.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(z.comma),t&&this.type===z.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===z.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},Ri.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Ri.parseBindingListItem=function(e){return e},Ri.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(z.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},Ri.checkLValSimple=function(e,t,n){t===void 0&&(t=vi);var r=t!==vi;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===bi&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Kr(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Ci&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},Ri.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=vi),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},Ri.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=vi),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var zi=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},V={b_stat:new zi(`{`,!1),b_expr:new zi(`{`,!0),b_tmpl:new zi(\"${\",!1),p_stat:new zi(`(`,!1),p_expr:new zi(`(`,!0),q_tmpl:new zi(\"`\",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new zi(`function`,!1),f_expr:new zi(`function`,!0),f_expr_gen:new zi(`function`,!0,!1,null,!0),f_gen:new zi(`function`,!1,!1,null,!0)},Bi=wi.prototype;Bi.initialContext=function(){return[V.b_stat]},Bi.curContext=function(){return this.context[this.context.length-1]},Bi.braceIsBlock=function(e){var t=this.curContext();return t===V.f_expr||t===V.f_stat?!0:e===z.colon&&(t===V.b_stat||t===V.b_expr)?!t.isExpr:e===z._return||e===z.name&&this.exprAllowed?Lr.test(this.input.slice(this.lastTokEnd,this.start)):e===z._else||e===z.semi||e===z.eof||e===z.parenR||e===z.arrow?!0:e===z.braceL?t===V.b_stat:e===z._var||e===z._const||e===z.name?!1:!this.exprAllowed},Bi.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},Bi.updateContext=function(e){var t,n=this.type;n.keyword&&e===z.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Bi.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},z.parenR.updateContext=z.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===V.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},z.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?V.b_stat:V.b_expr),this.exprAllowed=!0},z.dollarBraceL.updateContext=function(){this.context.push(V.b_tmpl),this.exprAllowed=!0},z.parenL.updateContext=function(e){var t=e===z._if||e===z._for||e===z._with||e===z._while;this.context.push(t?V.p_stat:V.p_expr),this.exprAllowed=!0},z.incDec.updateContext=function(){},z._function.updateContext=z._class.updateContext=function(e){e.beforeExpr&&e!==z._else&&!(e===z.semi&&this.curContext()!==V.p_stat)&&!(e===z._return&&Lr.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===z.colon||e===z.braceL)&&this.curContext()===V.b_stat)?this.context.push(V.f_expr):this.context.push(V.f_stat),this.exprAllowed=!1},z.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},z.backQuote.updateContext=function(){this.curContext()===V.q_tmpl?this.context.pop():this.context.push(V.q_tmpl),this.exprAllowed=!1},z.star.updateContext=function(e){if(e===z._function){var t=this.context.length-1;this.context[t]===V.f_expr?this.context[t]=V.f_expr_gen:this.context[t]=V.f_gen}this.exprAllowed=!0},z.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==z.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var H=wi.prototype;H.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},H.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===z.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(z.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},H.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new ki,r=!0);var s=this.start,c=this.startLoc;(this.type===z.parenL||this.type===z.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===z.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===z.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},H.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(!(i.type===`ArrowFunctionExpression`&&i.start===n)&&this.eat(z.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(z.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},H.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},H.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==z._in)&&a>r){var o=this.type===z.logicalOR||this.type===z.logicalAND,s=this.type===z.coalesce;s&&(a=z.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===z.coalesce||s&&(this.type===z.logicalOR||this.type===z.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},H.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},H.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===z.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&Vi(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Hi(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===z.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==z._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&!(o.type===`ArrowFunctionExpression`&&o.start===i)&&this.eat(z.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function Vi(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Vi(e.expression)}function Hi(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Hi(e.expression)||e.type===`ParenthesizedExpression`&&Hi(e.expression)}H.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},H.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},H.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(z.arrow)},H.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},H.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(z.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(z.bracketL);if(l||c&&this.type!==z.parenL&&this.type!==z.backQuote||this.eat(z.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(z.bracketR)):this.type===z.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(z.parenL)){var d=new ki,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===z.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},H.parseExprAtom=function(e,t,n){this.type===z.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case z._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===z.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==z.dot&&this.type!==z.bracketL&&this.type!==z.parenL&&this.unexpected(),this.finishNode(r,`Super`);case z._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case z.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(z._function))return this.overrideContext(V.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(z.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===z.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(z.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case z.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case z.num:case z.string:return this.parseLiteral(this.value);case z._null:case z._true:case z._false:return r=this.startNode(),r.value=this.type===z._null?null:this.type===z._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case z.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case z.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(z.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case z.braceL:return this.overrideContext(V.b_expr),this.parseObj(!1,e);case z._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case z._class:return this.parseClass(this.startNode(),!1);case z._new:return this.parseNew();case z.backQuote:return this.parseTemplate();case z._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},H.parseExprAtomDefault=function(){this.unexpected()},H.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===z.parenL&&!e)return this.parseDynamicImport(t);if(this.type===z.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}else this.unexpected()},H.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(z.parenR)?e.options=null:(this.expect(z.comma),this.afterTrailingComma(z.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(z.parenR)||(this.expect(z.comma),this.afterTrailingComma(z.parenR)||this.unexpected())));else if(!this.eat(z.parenR)){var t=this.start;this.eat(z.comma)&&this.eat(z.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},H.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},H.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},H.parseParenExpression=function(){this.expect(z.parenL);var e=this.parseExpression();return this.expect(z.parenR),e},H.shouldParseArrow=function(e){return!this.canInsertSemicolon()},H.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new ki,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==z.parenR;)if(l?l=!1:this.expect(z.comma),a&&this.afterTrailingComma(z.parenR,!0)){u=!0;break}else if(this.type===z.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(z.parenR),e&&this.shouldParseArrow(c)&&this.eat(z.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}else return i},H.parseParenItem=function(e){return e},H.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Ui=[];H.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===z.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),this.eat(z.parenL)?e.arguments=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ui,this.finishNode(e,`NewExpression`)},H.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===z.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\\r\\n?/g,`\n`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\\r\\n?/g,`\n`),cooked:this.value},this.next(),n.tail=this.type===z.backQuote,this.finishNode(n,`TemplateElement`)},H.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===z.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(z.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(z.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},H.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===z.name||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===z.star)&&!Lr.test(this.input.slice(this.lastTokEnd,this.start))},H.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(z.braceR);){if(r)r=!1;else if(this.expect(z.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(z.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},H.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(z.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===z.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===z.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(z.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(z.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},H.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},H.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===z.colon&&this.unexpected(),this.eat(z.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===z.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==z.comma&&this.type!==z.braceR&&this.type!==z.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===z.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},H.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(z.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(z.bracketR),e.key;e.computed=!1}return e.key=this.type===z.num||this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},H.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},H.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(_i(t,r.generator)|di|(n?fi:0)),this.expect(z.parenL),r.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},H.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(_i(n,!1)|li),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},H.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==z.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Ci),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},H.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},H.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,yi,t?null:n)}},H.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(z.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===z.comma?o=null:this.type===z.ellipsis?(o=this.parseSpread(r),r&&this.type===z.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},H.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&gi)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},H.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},H.parseIdentNode=function(){var e=this.startNode();return this.type===z.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=z.name):this.unexpected(),e},H.parsePrivateIdent=function(){var e=this.startNode();return this.type===z.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},H.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===z.semi||this.canInsertSemicolon()||this.type!==z.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(z.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},H.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var Wi=wi.prototype;Wi.raise=function(e,t){var n=ei(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},Wi.raiseRecoverable=Wi.raise,Wi.curPosition=function(){if(this.options.locations)return new Qr(this.curLine,this.pos-this.lineStart)};var Gi=wi.prototype,Ki=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Gi.enterScope=function(e){this.scopeStack.push(new Ki(e))},Gi.exitScope=function(){this.scopeStack.pop()},Gi.treatFunctionsAsVarInScope=function(e){return e.flags&oi||!this.inModule&&e.flags&ai},Gi.declareName=function(e,t,n){var r=!1;if(t===bi){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&ai&&delete this.undefinedExports[e]}else if(t===Si)this.currentScope().lexical.push(e);else if(t===xi){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&ui&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&ai&&delete this.undefinedExports[e],s.flags&gi)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},Gi.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Gi.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Gi.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(gi|mi|pi))return t}},Gi.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(gi|mi|pi)&&!(t.flags&li))return t}};var qi=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new $r(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ji=wi.prototype;Ji.startNode=function(){return new qi(this,this.start,this.startLoc)},Ji.startNodeAt=function(e,t){return new qi(this,e,t)};function Yi(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}Ji.finishNode=function(e,t){return Yi.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Ji.finishNodeAt=function(e,t,n,r){return Yi.call(this,e,t,n,r)},Ji.copyNode=function(e){var t=new qi(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Xi=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,Zi=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,Qi=Zi+` Extended_Pictographic`,$i=Qi,ea=$i+` EBase EComp EMod EPres ExtPict`,ta=ea,na=ta,ra={9:Zi,10:Qi,11:$i,12:ea,13:ta,14:na},ia=`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`,aa={9:``,10:``,11:``,12:``,13:``,14:ia},oa=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,sa=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,ca=sa+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,la=ca+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,ua=la+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,da=ua+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,fa=da+` `+Xi,pa={9:sa,10:ca,11:la,12:ua,13:da,14:fa},ma={};function ha(e){var t=ma[e]={binary:Yr(ra[e]+` `+oa),binaryOfStrings:Yr(aa[e]),nonBinary:{General_Category:Yr(oa),Script:Yr(pa[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var ga=0,_a=[9,10,11,12,13,14];ga<_a.length;ga+=1){var va=_a[ga];ha(va)}var U=wi.prototype,ya=function(e,t){this.parent=e,this.base=t||this};ya.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},ya.prototype.sibling=function(){return new ya(this.parent,this.base)};var ba=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=ma[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ba.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},ba.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},ba.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},ba.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},ba.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},ba.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},ba.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},ba.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},ba.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},U.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function xa(e){for(var t in e)return!0;return!1}U.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&xa(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},U.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},U.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ya(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},U.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},U.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},U.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},U.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},U.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},U.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},U.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},U.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},U.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},U.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},U.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&Sa(n);)t+=Xr(n),e.advance();return t};function Sa(e){return e===105||e===109||e===115}U.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},U.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},U.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Ca(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ca(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}U.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Ca(n);)e.advance();return e.pos!==t},U.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},U.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},U.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},U.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=Xr(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=Xr(e.lastIntValue);return!0}return!1},U.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),wa(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function wa(e){return jr(e,!0)||e===36||e===95}U.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Ta(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Ta(e){return Mr(e,!0)||e===36||e===95||e===8204||e===8205}U.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},U.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},U.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},U.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},U.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},U.regexp_eatZero=function(e){return e.current()===48&&!La(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},U.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},U.regexp_eatControlLetter=function(e){var t=e.current();return Ea(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Ea(e){return e>=65&&e<=90||e>=97&&e<=122}U.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Da(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Da(e){return e>=0&&e<=1114111}U.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},U.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Oa=0,ka=1,Aa=2;U.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(ja(t))return e.lastIntValue=-1,e.advance(),ka;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Aa&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Oa};function ja(e){return e===100||e===68||e===115||e===83||e===119||e===87}U.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),ka}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Oa},U.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Kr(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},U.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return ka;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Aa;e.raise(`Invalid property name`)},U.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Ma(t=e.current());)e.lastStringValue+=Xr(t),e.advance();return e.lastStringValue!==``};function Ma(e){return Ea(e)||e===95}U.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Na(t=e.current());)e.lastStringValue+=Xr(t),e.advance();return e.lastStringValue!==``};function Na(e){return Ma(e)||La(e)}U.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},U.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Aa&&e.raise(`Negated character class may contain strings`),!0}return!1},U.regexp_classContents=function(e){return e.current()===93?ka:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),ka)},U.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},U.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Ba(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},U.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},U.regexp_classSetExpression=function(e){var t=ka,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===Aa&&(t=Aa);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==Aa&&(t=ka);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Aa&&(t=Aa)}},U.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},U.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?ka:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},U.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Aa&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},U.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},U.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Aa&&(t=Aa);return t},U.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?ka:Aa},U.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Pa(n)||Fa(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Pa(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Fa(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}U.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Ia(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Ia(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}U.regexp_eatClassControlLetter=function(e){var t=e.current();return La(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},U.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},U.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;La(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function La(e){return e>=48&&e<=57}U.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ra(n=e.current());)e.lastIntValue=16*e.lastIntValue+za(n),e.advance();return e.pos!==t};function Ra(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function za(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}U.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},U.regexp_eatOctalDigit=function(e){var t=e.current();return Ba(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Ba(e){return e>=48&&e<=55}U.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Ra(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+za(i),e.advance()}return!0};var Va=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new $r(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},W=wi.prototype;W.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new Va(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},W.getToken=function(){return this.next(),new Va(this)},typeof Symbol<`u`&&(W[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===z.eof,value:t}}}}),W.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(z.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},W.readToken=function(e){return jr(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},W.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},W.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},W.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=Br(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},W.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!zr(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},W.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&Vr.test(String.fromCharCode(e)))++this.pos;else break loop}}},W.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},W.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(z.ellipsis)):(++this.pos,this.finishToken(z.dot))},W.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(z.assign,2):this.finishOp(z.slash,1)},W.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?z.star:z.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=z.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(z.assign,n+1):this.finishOp(r,n)},W.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(z.assign,3):this.finishOp(e===124?z.logicalOR:z.logicalAND,2):t===61?this.finishOp(z.assign,2):this.finishOp(e===124?z.bitwiseOR:z.bitwiseAND,1)},W.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(z.assign,2):this.finishOp(z.bitwiseXOR,1)},W.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Lr.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(z.incDec,2):t===61?this.finishOp(z.assign,2):this.finishOp(z.plusMin,1)},W.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(z.assign,n+1):this.finishOp(z.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(z.relational,n))},W.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(z.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(z.arrow)):this.finishOp(e===61?z.eq:z.prefix,1)},W.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(z.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(z.assign,3):this.finishOp(z.coalesce,2)}return this.finishOp(z.question,1)},W.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),jr(t,!0)||t===92))return this.finishToken(z.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+Xr(t)+`'`)},W.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(z.parenL);case 41:return++this.pos,this.finishToken(z.parenR);case 59:return++this.pos,this.finishToken(z.semi);case 44:return++this.pos,this.finishToken(z.comma);case 91:return++this.pos,this.finishToken(z.bracketL);case 93:return++this.pos,this.finishToken(z.bracketR);case 123:return++this.pos,this.finishToken(z.braceL);case 125:return++this.pos,this.finishToken(z.braceR);case 58:return++this.pos,this.finishToken(z.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(z.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(z.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+Xr(e)+`'`)},W.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},W.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(Lr.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||(this.regexpState=new ba(this));s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(z.regexp,{pattern:i,flags:o,value:c})},W.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function Ha(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function Ua(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}W.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ua(this.input.slice(t,this.pos)),++this.pos):jr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(z.num,n)},W.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=Ua(this.input.slice(t,this.pos));return++this.pos,jr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(z.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),jr(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Ha(this.input.slice(t,this.pos),n);return this.finishToken(z.num,a)},W.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},W.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(zr(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(z.string,t)};var Wa={};W.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===Wa)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},W.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Wa;this.raise(e,t)},W.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===z.template||this.type===z.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(z.dollarBraceL)):(++this.pos,this.finishToken(z.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(z.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(zr(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`\n`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else ++this.pos}},W.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case\"`\":return this.finishToken(z.invalidTemplate,this.input.slice(this.start,this.pos));case`\\r`:this.input[this.pos+1]===`\n`&&++this.pos;case`\n`:case`\\u2028`:case`\\u2029`:++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,`Unterminated template`)},W.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`\n`;case 114:return`\\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Xr(this.readCodePoint());case 116:return`\t`;case 98:return`\\b`;case 118:return`\\v`;case 102:return`\\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return zr(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},W.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},W.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Mr(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\\\uXXXX`),++this.pos;var o=this.readCodePoint();(t?jr:Mr)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=Xr(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},W.readWord=function(){var e=this.readWord1(),t=z.name;return this.keywords.test(e)&&(t=Ir[e]),this.finishToken(t,e)},wi.acorn={Parser:wi,version:`8.19.0`,defaultOptions:ti,Position:Qr,SourceLocation:$r,getLineInfo:ei,Node:qi,TokenType:L,tokTypes:z,keywordTypes:Ir,TokContext:zi,tokContexts:V,isIdentifierChar:Mr,isIdentifierStart:jr,Token:Va,isNewLine:zr,lineBreak:Lr,lineBreakG:Rr,nonASCIIwhitespace:Vr};var Ga={ecmaVersion:`latest`,sourceType:`script`,allowReturnOutsideFunction:!0},Ka=/\\w+(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,qa=/[A-Za-z_]\\w*(?![\\p{ID_Continue}$\\u200c\\u200d])/uy,Ja=/^[$_]\\w+$/,Ya=/[\\n\\r\\u2028\\u2029]/,Xa=/\\s*(?:[;},:)]|=(?![=>]))/y;function Za(e,t){return Xa.lastIndex=t,Xa.test(e)}var Qa=new Set([z.name,z.num,z.string,z.regexp,z.backQuote,z.bracketR,z.braceR,z.parenR,z.incDec,z._this,z._null,z._true,z._false]),$a=class extends wi{constructor(...e){super(...e),this.operandBeforeLast=!0,this.operandHere=!0,this.breakBeforeLast=!1,this.breakHere=!1,this.ternaries=[],this.colonEndsTernary=!1,this.closedBlock=!1,this.lookahead=!0}readToken(e){let t=this;if(t.lastTokEnd=t.end,this.operandBeforeLast=this.operandHere,this.operandHere=t.exprAllowed,this.breakBeforeLast=this.breakHere,this.breakHere=Ya.test(t.input.slice(t.end,t.pos)),e===64||e===37){let n=t.pos,r=e===64?Ka:qa;r.lastIndex=n+1;let i=r.exec(t.input)?.[0];if(i){let r=n+1+i.length,a=t.type===z.incDec&&(this.operandBeforeLast||this.breakBeforeLast),o=e===37?this.percentAt?.get(n):void 0;if(e===64||(o??(t.exprAllowed||a||this.lookahead&&eo(t,r)))){e===37&&this.transientsRead?.add(n),t.pos=r,t.finishToken(z.name,t.input.charAt(n)+i);return}}}super.readToken(e)}finishToken(e,t){let{context:n}=this,r=n.length;if(e===z.braceR){let e=n[r-1];this.closedBlock=e.token===`{`&&!e.isExpr}else if(e===z.question)this.ternaries[r]=(this.ternaries[r]??0)+1;else if(e===z.colon){let e=this.ternaries[r]??0;this.colonEndsTernary=e>0,e>0&&(this.ternaries[r]=e-1)}let i=this,a=i.type;this.prevValue=i.value;let o=e.keyword!==void 0&&(a===z.dot||a===z.questionDot)||(e===z._function||e===z._class)&&Za(i.input,i.pos);super.finishToken(o?z.name:e,t),e===z.name&&t===`of`&&(a===z._const||a===z._var||this.prevValue===`let`)&&(i.exprAllowed=!1)}braceIsBlock(e){if(e===z.colon&&this.colonEndsTernary)return!1;if(e===z.braceR&&this.closedBlock||e===z.name&&this.prevValue===`static`)return!0;if(this.breakHere&&Qa.has(e)){let{context:e}=this,t=e[e.length-1];if(t.token===`{`&&!t.isExpr)return!0}return super.braceIsBlock(e)}};function eo(e,t){if(!Ya.test(e.input.slice(e.end,e.pos)))return!1;let n=ro(e.input,t,`statements`,{afterOperand:!0});n.lookahead=!1;let r=0;try{for(;;){n.nextToken();let e=n.type;if(e===z.eof)return!1;if(r>0)to.has(e)?r++:no.has(e)&&r--;else if(e===z.bracketL)r=1;else if(e===z.dot){if(n.nextToken(),n.type!==z.name&&!n.type.keyword)return!1}else return e===z.eq||e===z.assign}}catch{return!1}}var to=new Set([z.parenL,z.bracketL,z.braceL,z.dollarBraceL]),no=new Set([z.parenR,z.bracketR,z.braceR]);function ro(e,t,n,{onComment:r,afterOperand:i=!1}={}){let a=new $a(r?{...Ga,onComment:r}:Ga,e,t);return n===`expression`&&(a.type=z.parenL),i&&(a.exprAllowed=!1),a}var io=class extends SyntaxError{constructor(e,t,n,r){super(`${e} ${so(t,n)}`+ao(r,e=>oo(t,e))),this.reason=e,this.source=t,this.pos=n,this.bracket=r,this.name=`SyntaxError`}reasonIn(e,t){return this.reason+ao(this.bracket,n=>{let{line:r,column:i}=ei(e,t+n);return`at line ${r}, column ${i+1}`})}};function ao(e,t){return e?` (missing \"${e.closer}\" for the \"${e.open}\" ${t(e.pos)})`:``}function oo(e,t){let{line:n,column:r}=ei(e,t);return Ya.test(e)?`at line ${n}, column ${r+1}`:`at column ${r+1}`}function so(e,t){let{column:n}=ei(e,t),r=t-n,i=e.slice(r).search(Ya),a=i<0?e.length:r+i,o=Math.max(r,t-30),s=Math.min(a,t+30),c=(o>r?`…`:``)+e.slice(o,t)+`▶`+e.slice(t,s)+(s<a?`…`:``);return`${oo(e,t)}: ${c.trim()}`}var co=e=>e[e.length-1],lo={\"(\":`)`,\"[\":`]`,\"{\":`}`,\"${\":`}`};function uo(e,t){if(!(t instanceof SyntaxError)||!(`pos`in t))throw t;let n=t.pos,r=t.message.replace(/ \\(\\d+:\\d+\\)$/,``),{open:i,token:a}=fo(e,n),o=n>=e.length||a===``,s=!1;r===`Unexpected token`?(r=o?`Unexpected end of code`:`Unexpected \"${a}\"`,s=!!i&&lo[i.text]!==a&&(o||[`)`,`]`,`}`,`;`,`{`].includes(a))):r.startsWith(`Unterminated template`)&&(s=i?.text===\"${\");let c=s&&i?{open:i.text,closer:lo[i.text],pos:i.pos}:void 0;return new io(r,e,n,c)}function fo(e,t){let n=[];for(let r of Eo(e,0,`statements`)){if(`error`in r)break;if(r.start>=t||r.type===z.eof)return{open:co(n),token:e.slice(r.start,r.end)};let i=e.slice(r.start,r.end);i in lo?n.push({text:i,pos:r.start}):n.length&&lo[co(n).text]===i&&n.pop()}return{open:co(n),token:e.charAt(t)}}function po(e,t=`expression`){let n=new Map;for(;;){let r=new Set;try{let i=mo(e,t,n,r),a={refs:[],strings:[]};return yo(i,e,a,!1,!1),a.refs.sort((e,t)=>e.start-t.start),a}catch(t){let i=t.pos??-1;if(!(t instanceof SyntaxError)||n.has(i)||(qa.lastIndex=i+1,e.charAt(i)!==`%`||!qa.test(e)))throw t;n.set(i,!r.has(i))}}}function mo(e,t,n,r){try{let i=ro(e,0,t);if(i.percentAt=n,i.transientsRead=r,t===`statements`)return i.parse();i.nextToken();let a=i.parseExpression();if(i.type!==z.eof)throw Object.assign(SyntaxError(`Unexpected token`),{pos:i.start});return a}catch(t){throw uo(e,t)}}var ho=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,go={$:`story`,_:`temporary`,\"@\":`local`,\"%\":`transient`};function _o(e,t){let n=e.name,r=t.charAt(e.start);return r===n.charAt(0)&&(r===`@`||r===`%`||(r===`$`||r===`_`)&&Ja.test(n))?[r,n.slice(1)]:null}function vo(e,t){if(!ho(e)||e.type!==`Identifier`)return;let n=t.charAt(e.start);if(n===`@`||n===`%`)throw new io(`\"${e.name}\" can't be a property name`,t,e.start)}function yo(e,t,n,r,i){if(Array.isArray(e)){for(let i of e)yo(i,t,n,r,!1);return}if(!ho(e))return;let a=(e,r=!1,i=!1)=>yo(e,t,n,r,i);switch(e.type){case`Identifier`:{let a=_o(e,t);if(!a)return;if(r)throw new io(`\"${e.name}\" is a ${go[a[0]]} variable and can't be declared`,t,e.start);n.refs.push({sigil:a[0],name:a[1],start:e.start,end:e.end,shorthand:i});return}case`Literal`:typeof e.value==`string`&&n.strings.push(t.slice(e.start+1,e.end-1));return;case`TemplateElement`:n.strings.push(e.value.raw);return;case`MemberExpression`:a(e.object),e.computed?a(e.property):vo(e.property,t);return;case`Property`:if(e.computed?a(e.key):e.shorthand||vo(e.key,t),e.shorthand){let t=e.value;t.type===`AssignmentPattern`?(a(t.left,r,!0),a(t.right)):a(t,r,!0)}else a(e.value,r);return;case`MethodDefinition`:case`PropertyDefinition`:e.computed?a(e.key):vo(e.key,t),a(e.value);return;case`LabeledStatement`:a(e.body);return;case`BreakStatement`:case`ContinueStatement`:case`MetaProperty`:case`PrivateIdentifier`:return;case`VariableDeclarator`:a(e.id,!0),a(e.init);return;case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:a(e.id,!0);for(let t of e.params)a(t,!0);a(e.body);return;case`ClassDeclaration`:case`ClassExpression`:a(e.id,!0),a(e.superClass),a(e.body);return;case`CatchClause`:a(e.param,!0),a(e.body);return;case`AssignmentPattern`:a(e.left,r),a(e.right);return;case`ObjectPattern`:case`ArrayPattern`:case`RestElement`:for(let t of[`properties`,`elements`,`argument`])a(e[t],r);return;default:for(let t in e){if(t===`type`||t===`start`||t===`end`)continue;let n=e[t];typeof n==`object`&&n&&a(n)}}}var bo=/[\\p{ID_Continue}$.]*/uy,xo=/[\\p{ID_Continue}$]*/uy,So=new Set([`of`,`get`,`set`,`static`,`async`]);function Co(e,t,{goal:n=`expression`,stop:r}={}){let i=To(e,t,n,r);return i<0&&!r?wo(e,t,n):i}function wo(e,t,n){let r=ro(e,t,n);try{if(n===`statements`)r.parse();else if(r.nextToken(),r.parseExpression(),r.type===z.braceR)return r.start}catch(t){let n=t.pos??-1;if(e.charAt(n)===`}`)return n}return-1}function To(e,t,n,r){let i=[],a=-1,o=!1,s=t,c=!1,l=!1;for(;;){let t=-1;for(let u of Eo(e,s,n,{afterOperand:c})){if(`error`in u){let{message:n}=u.error,a=i.includes(\"${\");if(!/^Unterminated/.test(n)&&!a){if(t=Math.max(u.pos,s)+1,c=!1,t>=e.length)return-1;break}let o=i.lastIndexOf(\"${\");if(!/^Unterminated template/.test(n)||o<0||l||r)return-1;l=!0,i.length=o,t=u.pos,c=!0;break}if(u.restarted&&i.includes(\"${\"))return-1;let n=u.type;if(n===z.eof||n===z.string&&o&&u.start===a)return-1;if(o=n===z.name&&!So.has(u.value)||n===z.num,a=u.end,n===z.braceL){if(r?.(u.start))return u.start;i.push(`{`)}else if(n===z.dollarBraceL)i.push(\"${\");else if(n===z.parenL)i.push(`(`);else if(n===z.bracketL)i.push(`[`);else if(n===z.parenR||n===z.bracketR)co(i)===(n===z.parenR?`(`:`[`)&&i.pop();else if(n===z.braceR){let e=Math.max(i.lastIndexOf(`{`),i.lastIndexOf(\"${\"));if(e>=0)i.length=e;else if(!r)return u.start}}s=t,o=!1}}function*Eo(e,t,n,r={}){let i=ro(e,t,n,r);for(;;){try{i.nextToken()}catch(t){let n=Math.min(t.pos??i.pos,e.length),a=t.message,o=(t,n,a)=>(i=ro(e,a,`statements`,{onComment:r.onComment,afterOperand:!0}),{type:t,start:n,end:a,value:void 0,restarted:!0}),s=e.charAt(i.start),c=/^Unterminated/.test(a);if(/^Unterminated string/.test(a)){let{end:t,closed:r}=Mo(e,n);if(r){yield o(z.string,n,t);continue}}else if(!c&&i.start<=n&&(s===`\"`||s===`'`)){let{end:t,closed:n}=Mo(e,i.start);if(n){yield o(z.string,i.start,t);continue}}else if(!c&&i.start<=n&&s===`/`){let t=jo(e,i.start);if(t>0){yield o(z.regexp,i.start,t);continue}}else if(!c&&i.start<=n&&/[\\d.]/.test(s)&&/\\d/.test(e.slice(i.start,i.start+2))){bo.lastIndex=i.start,bo.test(e),yield o(z.num,i.start,bo.lastIndex);continue}yield{error:t,pos:n};return}if(yield{type:i.type,start:i.start,end:i.end,value:i.value},i.type===z.eof)return}}function Do(e,t,n=`expression`){return Oo(e,0,t,0,n,!1)}function Oo(e,t,n,r,i,a){let o=[],s=(e,t,n,r)=>{o.push([n,r])},c=(t,i)=>{for(let a=t;a<i;a++)n.code?.(e.charAt(a),a,r)},l=(t,i)=>{i>t&&n.literal?.(e.slice(t,i),t,r)},u=(e,t)=>{for(let[n,r]of o)r<=e||n>=t||(c(e,n),l(n,r),e=r);o.length=0,c(e,t)},d=[],f=0,p=Eo(e,t,i,{onComment:s}),m=t,h;for(;;){let t=p.next().value;if(`error`in t){let n=Math.max(m,t.pos);if(u(m,n),n>=e.length)return e.length;if(/^Unterminated/.test(t.error.message))return l(n,e.length),e.length;c(n,n+1),m=n+1,p=Eo(e,m,i,{onComment:s}),h=void 0;continue}let o=t.type;if(o===z.eof)return u(m,e.length),e.length;if(u(m,t.start),o===z.name){let i=ko(e,t.start,t.value),a=h===z.dot||h===z.questionDot||(i===`$`||i===`_`)&&Ao(e,t.end,h);i&&!a?n.variable?.(i,e.slice(t.start+1,t.end),t.start,r):c(t.start,t.end)}else if(o===z.string||o===z.regexp||o===z.template||o===z.invalidTemplate)l(t.start,t.end);else if(o===z.backQuote)if(l(t.start,t.end),h===z.template||h===z.invalidTemplate){if(f--,a&&f===0)return t.end}else f++;else o===z.dollarBraceL?(l(t.start,t.end),d.push(\"${\"),r++):o===z.braceR&&co(d)===\"${\"?(d.pop(),r--,l(t.start,t.end)):(o===z.braceL||o===z.parenL||o===z.bracketL?d.push(e.charAt(t.start)):(o===z.braceR||o===z.parenR||o===z.bracketR)&&d.length&&co(d)!==\"${\"&&d.pop(),c(t.start,t.end));h=o,m=t.end}}function ko(e,t,n){let r=e.charAt(t);return(r===`@`||r===`%`)&&n.charAt(0)===r||(r===`$`||r===`_`)&&Ja.test(n)?r:null}function Ao(e,t,n){if(n!==z.braceL&&n!==z.comma)return!1;let r=/\\S/g;r.lastIndex=t;let i=r.exec(e)?.[0];return i===`:`||i===`(`}function jo(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charAt(r);if(Ya.test(t))return-1;if(t===`\\\\`)r++;else if(t===`[`)n=!0;else if(t===`]`)n=!1;else if(t===`/`&&!n)return xo.lastIndex=r+1,xo.test(e),xo.lastIndex}return-1}function Mo(e,t){let n=e.charAt(t),r=t+1;for(;r<e.length;){let t=e.charAt(r);if(t===`\\\\`)r+=2;else if(t===n)return{end:r+1,closed:!0};else r++}return{end:e.length,closed:!1}}var No=/[\\p{L}\\p{N}_\\\\]/u;function Po(e,t){let n=e[t],r=n===\"`\";for(let i=t+1;i<e.length;){let t=e[i];if(t===`\\\\`)i+=2;else if(t===n)return i+1;else if(!r&&t===`\n`)return-1;else if(r&&t===`$`&&e[i+1]===`{`){let t=Fo(e,i+2);if(t===-1)return-1;i=t+1}else i++}return-1}function Fo(e,t){Io!==e&&(Io=e,Lo.clear());let n=Lo.get(t);return n===void 0&&(n=Ro(e,t),Lo.set(t,n)),n}var Io=``,Lo=new Map;function Ro(e,t){let n=0;for(;t<e.length;){let r=e[t];if(r===`{`)n++,t++;else if(r===`}`){if(n===0)return t;n--,t++}else if(r===\"`\"||(r===`\"`||r===`'`)&&!(t>0&&No.test(e[t-1]))){let n=Po(e,t);t=n===-1?t+1:n}else t++}return-1}var zo={closeBrace(e,t,n){let r=Co(e,t);return r===-1?Fo(e,n):r},rawBodyEnd(e,t,n){let r=`\\\\{/${n}\\\\s*\\\\}`,i=new RegExp(r,`gi`);i.lastIndex=t;let a=i.exec(e)?.index??-1;if(a===-1)return-1;let o=new RegExp(r,`iy`),s=Co(e,t,{goal:`statements`,stop:t=>(o.lastIndex=t,o.test(e))});return s===-1?a:s}};function Bo(e){let t=e.toLowerCase();return t.startsWith(`on`)||t===`pattern`||t===`srcdoc`}function Vo(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`{`,r);if(i===-1){n+=e.slice(r);break}n+=e.slice(r,i),r=i+1;let a=yr(e[r])?zo.closeBrace(e,r,r):-1;if(a===-1){n+=`{`;continue}n&&t.push({text:n}),n=``;let o=e.slice(r,a);t.push(/^.\\w/.test(o)?{expr:o}:{verbatim:`{${o}}`}),r=a+1}return n&&t.push({text:n}),t}var Ho=new Set([`do`]),Uo={...zo,isBlock:mr,isRaw:e=>Ho.has(e),isCodeAttribute:Bo},Wo=class extends Error{constructor(e,t,n,r){super(`${e} (line ${n}, column ${r})`),this.reason=e,this.offset=t,this.line=n,this.column=r,this.name=`MarkupError`}};function Go(e,t){let n=1,r=0;for(let i=e.indexOf(`\n`);i!==-1&&i<t;)n++,r=i+1,i=e.indexOf(`\n`,r);return{line:n,column:t-r+1}}function Ko(e,t,n){let r=n.hooks?{...Uo,...n.hooks}:Uo;try{return ur(e,{startRule:t,text:n.text===!0,hooks:r})}catch(t){let n=t.location;if(t instanceof Error&&t.name===`SyntaxError`&&n){let{offset:r}=n.start,{line:i,column:a}=Go(e,r);throw new Wo(t.message,r,i,a)}throw t}}function qo(e,t={}){return Ko(e,`Markup`,t)}function Jo(e,t={}){return Ko(e,`Tokens`,t)}var Yo=e=>Symbol.iterator in e,Xo=e=>`entries`in e,Zo=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Qo=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function $o(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Yo(e)&&Yo(t)?Xo(e)&&Xo(t)?Zo(e,t):Qo(e,t):Zo({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function es(...e){let t=j();return Q(n=>{let r={};for(let t of e)r[t]=n[t];return $o(t.current,r)?t.current:t.current=r})}function ts(){let{variables:e,temporary:t,transient:n}=es(`variables`,`temporary`,`transient`),r=Ie(Ef);return Pe(()=>[e,t,r,n],[e,t,r,n])}var ns=1831565813;function rs(e){let t=e|0;return()=>{t=t+ns|0;let e=Math.imul(t^t>>>15,t|1);return e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function is(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t}var as=!1,os=``,ss=0,cs=null,ls=0;function us(e,t=!0){let n;n=e===void 0?String(Date.now())+String(Math.random()):t?e+`|`+Date.now()+`|`+Math.random():e,os=n,ss=0,cs=rs(is(n)),as=!0,ls++}function ds(e,t){ls++,fs(e,t)}function fs(e,t){os=e;let n=Math.imul(t%4294967296,ns);cs=rs(is(e)+n|0),as=!0,ss=t}function ps(){ls++,as=!1,os=``,ss=0,cs=null}function ms(e){let t={generation:ls,seed:os,pull:ss};try{return e()}finally{as&&ls===t.generation&&ss!==t.pull&&fs(t.seed,t.pull)}}function hs(){return as?{seed:os,pull:ss}:null}function gs(){return!as||!cs?Math.random():(ss++,cs())}function _s(e,t){return e>t&&([e,t]=[t,e]),Math.floor(gs()*(t-e+1))+e}function vs(){return as}function ys(){return os}function bs(){return ss}var xs=`__proto__`;function Ss(e,t=e){return e===`__proto__`?`\"${t}\" cannot be used as a variable name (${xs} is reserved)`:void 0}function Cs(e,t=e){let n=Ss(e,t);if(n)throw TypeError(`spindle: ${n}`)}var G=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ws=(e,t)=>e&&G(e,t)?e[t]:void 0;function Ts(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function Es(e,t=()=>!0){let n=Object.create(null);for(let r of e)if(r)for(let e of Object.keys(r)){let i=r[e];t(i)&&(n[e]=i)}return n}var K=(...e)=>Es(e),Ds=e=>Object.getPrototypeOf(e)===null,Os=e=>Ds(e)?e:K(e);function ks(e,t,n){let r=K(e);return r[t]=n,r}var As=Object.freeze(K());function js(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>ws(e,n)!==ws(t,n))}var Ms=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function Ns(e,t){let n=ws(e,t);return Ms(n)?n:0}function Ps(e,t){let n=Es([e],Ms);return t!==void 0&&(n[t]=Ns(e,t)+1),n}var Fs=500,Is=new Map,Ls={$:`variables`,_:`temporary`,\"@\":`locals`,\"%\":`transient`},Rs=/[\\p{ID_Continue}$\\u200c\\u200d]$/u;function zs(e,t=`expression`){let n=t===`statements`?`s`+e:`e`+e,r=Bs.get(n);if(r!==void 0)return r;let{refs:i}=po(e,t),a=``,o=0;for(let t of i){let n=Ss(t.name,t.sigil+t.name);if(n)throw SyntaxError(`spindle: ${n}`);a+=e.slice(o,t.start),t.shorthand?a+=`${t.name}: `:Rs.test(a.slice(-2))&&(a+=` `),a+=`${Ls[t.sigil]}[\"${t.name}\"]`,o=t.end}return a+=e.slice(o),Bs.size>=Fs&&Bs.delete(Bs.keys().next().value),Bs.set(n,a),a}var Bs=new Map,Vs=`const {currentPassage,previousPassage,visited,hasVisited,hasVisitedAny,hasVisitedAll,rendered,hasRendered,hasRenderedAny,hasRenderedAll,random,randomInt}=__fns;`;function Hs(e,t){let n=Is.get(e);if(n)return Is.delete(e),Is.set(e,n),n;let r=Function(`variables`,`temporary`,`locals`,`__fns`,`transient`,Vs+t);if(Is.set(e,r),Is.size>Fs){let e=Is.keys().next().value;e!==void 0&&Is.delete(e)}return r}function Us(){let e=Q.getState();return e.storyData?.passages.get(e.currentPassage)}function Ws(){let e=Q.getState();if(e.historyIndex<=0)return;let t=e.history[e.historyIndex-1]?.passage;return t?e.storyData?.passages.get(t):void 0}function Gs(e){let t=t=>Ns(e(),t??Q.getState().currentPassage);return{count:t,has:e=>t(e)>0,any:(...e)=>e.some(e=>t(e)>0),all:(...e)=>e.every(e=>t(e)>0)}}function Ks(e,t){let n=Gs(e),r=Gs(t);return{currentPassage:Us,previousPassage:Ws,visited:n.count,hasVisited:n.has,hasVisitedAny:n.any,hasVisitedAll:n.all,rendered:r.count,hasRendered:r.has,hasRenderedAny:r.any,hasRenderedAll:r.all}}var qs=null,Js=null,Ys=null;function Xs(){let{visitCounts:e,renderCounts:t}=Q.getState();return qs&&Js===e&&Ys===t?qs:(qs={...Ks(()=>e,()=>t),random:gs,randomInt:_s},Js=e,Ys=t,qs)}function Zs(e){return Ds(e)?e:Object.isExtensible(e)?(Object.setPrototypeOf(e,null),e):Os(e)}function Qs(e,...[t,n,r=As,i=As]){return e(Zs(t),Zs(n),Zs(r),Xs(),Zs(i))}function $s(e,...t){let n=`return (${zs(e)}\\n);`;return Qs(Hs(n,n),...t)}function ec(e,...t){let n=zs(e,`statements`);Qs(Hs(`exec:`+n,n),...t)}var tc=new dr;function nc(e,t){tc.set(e,t)}function rc(e){return tc.get(e)}var ic=new dr;function ac(e,t){t?ic.set(e,t):ic.delete(e)}function oc(e){return ic.get(e)}var sc=new fr;function cc(e){sc.add(e)}function lc(e){return sc.has(e)}var uc=[`expression`,`statements`,`passage`,`variable`,`string`,`text`,`names`,`delay`,`number`,`flag`,`separator`,`options`];function dc(e,t){for(let n of t){let t=n.type;if(!uc.includes(t)){let r=t===void 0?`has no type`:`has the unknown type ${JSON.stringify(t)}`;throw Error(`spindle: The parameter \"${n.name}\" of the macro {${e}} ${r}. Give it one of the types ${uc.join(`, `)} (see docs/custom-macros.md#parameter-types), or declare no parameters and read props.rawArgs.`)}n.parameters&&dc(e,n.parameters)}}var fc=new dr;function pc(e,t){fc.set(e,t)}function mc(){return Array.from(fc.values())}var hc=new dr;function gc(e,t,n,r=!1){let i=n.filter(e=>e!==`@children`);for(let e of i)e.startsWith(`@`)&&Cs(e.slice(1),e);hc.set(e,{body:t,params:i,isBlock:r})}function _c(e){return hc.get(e)}function vc(e){return/\\s/.test(e)}function yc(e){return e===`(`||e===`[`||e===`{`}function bc(e){return e===`)`||e===`]`||e===`}`}function xc(e){return e.replace(/\\\\([\"'\\\\])/g,`$1`)}function Sc(e,t){let n=e[t];if(n!==`\"`&&n!==`'`)return null;let{end:r,closed:i}=Mo(e,t);return i?{value:xc(e.slice(t+1,r-1)),end:r}:null}function Cc(e){let t=Sc(e,0);return t&&t.end===e.length?t.value:null}function wc(e){return/^[\"']?(.+?)[\"']?$/s.exec(e)?.[1]??e}var Tc=/(?:[-+*/%&|^!~=<>?:,.]|(?:^|[^\\w$@.])(?:typeof|void|new|delete|in|instanceof|await|yield))$/;function Ec(e){let t=-1;if(Do(e,{code(e,n,r){r===0&&!vc(e)&&(t=n+1)},literal(e,n,r){let i=e.startsWith(`//`)||e.startsWith(`/*`);r===0&&!i&&(t=-1)},variable(e,n,r,i){i===0&&(t=-1)}}),t<0)return!1;let n=e.slice(0,t);return/(?:\\+\\+|--)$/.test(n)?!1:Tc.test(n)}function Dc(e,t){let n=[],r=0;return Do(e,{code(e,i,a){a>0||(yc(e)?r++:bc(e)?r--:r===0&&t(e)&&n.push(i))}}),n}function Oc(e,t){let n=[],r=0;for(let i of Dc(e,t))n.push(e.slice(r,i)),r=i+1;return n.push(e.slice(r)),n}function kc(e){return Ac(e)&&!Ec(e)}function Ac(e){let t=e[0];return!!(t===`\"`||t===`'`||t===\"`\"||/^[$_@]\\w|^%[A-Za-z_]/.test(e)||/\\d/.test(t)||(t===`-`||t===`+`)&&e.length>1&&/\\d/.test(e[1])||t===`(`||t===`[`||t===`{`||/^(?:true|false|null|undefined)(?![\\w$])/.test(e)||t===`!`&&e.length>1&&e[1]!==`=`)}function jc(e){let t=Oc(e,vc).filter(Boolean);if(t.length<2)return null;for(let e of t)if(!kc(e))return null;return t}function Mc(e){let t=Oc(e,e=>e===`,`).map(e=>e.trim()),n=t.length>1;if(t[t.length-1]===``&&t.pop(),!n&&t.length===1){let e=jc(t[0]);if(e)return e}return t}function Nc(e){return e==null?``:String(e)}function Pc(e,t,n){return e||t?b(`span`,{id:t,class:e},n):b(S,null,n)}function Fc(e){return e.includes(`{`)||e.includes(`}`)}var Ic=new Map,Lc=2e3;function Rc(e){let t=Ic.get(e);if(t===void 0){try{t={nodes:qo(e,{text:!0})}}catch(e){t={error:e}}Ic.size>=Lc&&Ic.clear(),Ic.set(e,t)}return t}function zc(e,t){return e.map(e=>{switch(e.type){case`text`:return{type:`text`,value:t(e.value)};case`html`:return{...e,children:zc(e.children,t)};case`macro`:{let n={...e,children:zc(e.children,t)};return e.branches&&(n.branches=e.branches.map(e=>({...e,children:zc(e.children,t)}))),n}default:return e}})}var Bc=100;function Vc(e,t,n){let r=n.split(`.`),i=r[0];Cs(i,_r[t]+i);let a=ws(t===`variable`?e.variables:t===`temporary`?e.temporary:t===`transient`?e.transient:e.locals,i);for(let e=1;e<r.length;e++){if(a==null)return;a=a[r[e]]}return a}function Hc(e,t){return $s(e,t.variables,t.temporary,t.locals,t.transient)}var Uc=class{constructor(){this.errors=[]}nodes(e,t,n){let r=``;for(let i of e)r+=this.node(i,t,n);return r}node(e,t,n){switch(e.type){case`text`:return e.value;case`variable`:if(e.scope===`local`&&e.name===`children`){let e=t.widgetChildren;return e?this.nested(`children`,e,t,n,{widgetChildren:null}):``}return this.variable(e.scope,e.name,t);case`expression`:try{return Nc(Hc(e.expression,t))}catch(e){return this.errors.push({macro:`expression`,error:e}),``}case`html`:return this.nodes(e.children,t,n);case`macro`:return this.macro(e,t,n);default:return e}}variable(e,t,n){try{return Nc(Vc(n,e,t))}catch(n){return this.errors.push({macro:_r[e]+t,error:n}),``}}nested(e,t,n,r,i={}){return r>=Bc?(this.errors.push({macro:e,error:Error(`markup nested too deeply (a widget using itself?)`)}),``):this.nodes(t,{...n,...i},r+1)}macro(e,t,n){if(lc(e.name))return``;let r=_c(e.name);if(r){let i=t.locals;if(r.params.length>0){let n=e.rawArgs?Mc(e.rawArgs):[];i=K(t.locals),r.params.forEach((e,r)=>{let a,o=n[r];if(o!==void 0)try{a=Hc(o,t)}catch{a=void 0}i[e.startsWith(`@`)?e.slice(1):e]=a})}return this.nested(e.name,r.body,t,n,{locals:i,widgetChildren:e.children.length>0?e.children:null})}let i=oc(e.name);if(!i){let t=rc(e.name)?`{${e.name}} has no text form, so it can't be used in an attribute value or label`:`unknown macro {${e.name}}`;return this.errors.push({macro:e.name,error:Error(t)}),``}let a={evaluate:e=>Hc(e,t),renderText:(r,i)=>this.nested(e.name,r,t,n,i?{locals:Wc(t.locals,i)}:{})};try{return i({rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},a)}catch(t){return this.errors.push({macro:e.name,error:t}),``}}};function Wc(e,t){for(let e of Object.keys(t))Cs(e,`@${e}`);return K(e,t)}function Gc(e,t){let n=new Uc;return{text:n.nodes(e,t,0),errors:n.errors}}function Kc(e,t){if(!Fc(e))return{text:e,errors:[]};let n=Rc(e);return`error`in n?{text:e,errors:[{macro:`markup`,error:n.error}]}:Gc(n.nodes,t)}function qc(e,t,n){let r=[],i=``;for(let a of Vo(e))if(`text`in a)i+=n?n(a.text):a.text;else if(`verbatim`in a)i+=a.verbatim;else if(/^[$_@%][\\w.]+$/.test(a.expr)){let e=gr[a.expr[0]];try{i+=Nc(Vc(t,e,a.expr.slice(1)))}catch(e){r.push({macro:a.expr,error:e})}}else try{i+=Nc(Hc(a.expr,t))}catch(e){r.push({macro:`expression`,error:e})}return{text:i,errors:r}}function Jc(e,t){return e instanceof Error?e.message||t||String(e):typeof e==`string`&&e!==``?e:t??String(e)}function Yc(){let[e,t,n,r]=ts(),i=Ie(Pf);return Pe(()=>({variables:e,temporary:t,locals:n,transient:r,widgetChildren:i}),[e,t,n,r,i])}function Xc(){let e=Yc();return Fe(t=>{if(t===void 0||!Fc(t))return t;let{text:n,errors:r}=Kc(t,e);for(let{macro:e,error:n}of r)console.error(`spindle: {${e}} error in \"${t}\": ${Jc(n)}`);return n},[e])}var Zc=0;Array.isArray;function q(e,t,n,i,a,o){t||(t={});var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Zc,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}var Qc={variable:`variables`,temporary:`temporary`,transient:`transient`};function $c({node:e}){let{name:t,scope:n}=e,r=Xc(),i=r(e.className),a=r(e.id),o=Ie(Ef),s=t.split(`.`),c=s[0],l=Q(e=>n===`local`?void 0:ws(e[Qc[n]],c)),u=_r[n],d=Ss(c,u+c);if(d)return q(`span`,{class:`error`,children:`{${u}${t} error: ${d}}`});let f;f=n===`local`?ws(o,c):l;for(let e=1;e<s.length;e++){if(f==null){f=void 0;break}let t=s[e];f=f[t]}return Pc(i,a,Nc(f))}function el({node:e}){let{expression:t}=e,n=Xc(),r=n(e.className),i=n(e.id),[a,o,s,c]=ts(),l;try{l=Nc($s(t,a,o,s,c))}catch{l=`{error: ${t}}`}return Pc(r,i,l)}function tl(){return{nobr:Ie(Of),inline:Ie(kf),raw:Ie(Af),locals:Ie(Ef)}}function nl({body:e,parentValues:t,ownKeys:n}){let r=tl(),[i,a]=Ae({}),o=Pe(()=>K(t,n,i),[t,n,i]),s=j(o);s.current=o;let c=Fe(()=>s.current,[]),l=Fe((e,t)=>{Cs(e,`@${e}`),s.current=ks(s.current,e,t),a(n=>({...n,[e]:t}))},[]),u=Pe(()=>({update:l,getValues:c}),[l,c]);return q(Df.Provider,{value:u,children:q(Ef.Provider,{value:o,children:Cp(e,{...r,locals:o})})})}function rl({body:e,params:t,rawArgs:n,invocationChildren:r}){let i=tl(),a=i.locals,[o,s,c,l]=ts(),u=r?.length?r:null;if(t.length===0)return q(Pf.Provider,{value:u,children:Cp(e,i)});let d=n?Mc(n):[],f=[];for(let e=0;e<t.length;e++){let t=d[e],n;if(t!==void 0)try{n=$s(t,o,s,c,l)}catch{n=void 0}f.push(n)}let p=Pe(()=>{let e=K();for(let n=0;n<t.length;n++)e[t[n].startsWith(`@`)?t[n].slice(1):t[n]]=f[n];return e},f);return q(Pf.Provider,{value:u,children:q(nl,{body:e,parentValues:a,ownKeys:p})})}var il=document.createElement(`i`);function al(e){let t=`&`+e+`;`;il.innerHTML=t;let n=il.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function ol(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+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 sl(e,t){return e.length>0?(ol(e,e.length,0,t),e):t}var cl={}.hasOwnProperty;function ll(e){let t={},n=-1;for(;++n<e.length;)ul(t,e[n]);return t}function ul(e,t){let n;for(n in t){let r=(cl.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){cl.call(r,a)||(r[a]=[]);let e=i[a];dl(r[a],Array.isArray(e)?e:e?[e]:[])}}}function dl(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);ol(e,0,0,r)}function fl(e){let t={},n=-1;for(;++n<e.length;)pl(t,e[n]);return t}function pl(e,t){let n;for(n in t){let r=(cl.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i)r[a]=i[a]}}function ml(e,t){let 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)}var hl={'\"':`quot`,\"&\":`amp`,\"<\":`lt`,\">\":`gt`};function gl(e){return e.replace(/[\"&<>]/g,t);function t(e){return`&`+hl[e]+`;`}}function _l(e){return e.replace(/[\\t\\n\\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var vl=Ol(/[A-Za-z]/),yl=Ol(/[\\dA-Za-z]/),bl=Ol(/[#-'*+\\--9=?A-Z^-~]/);function xl(e){return e!==null&&(e<32||e===127)}var Sl=Ol(/\\d/),Cl=Ol(/[\\dA-Fa-f]/),wl=Ol(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function Tl(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var El=Ol(/\\p{P}|\\p{S}/u),Dl=Ol(/\\s/);function Ol(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function kl(e,t){let n=gl(Al(e||``));if(!t)return n;let 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 Al(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&yl(e.charCodeAt(n+1))&&yl(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){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),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)}var jl={}.hasOwnProperty,Ml=/^(https?|ircs?|mailto|xmpp)$/i,Nl=/^https?$/i;function Pl(e){let t=e||{},n=!0,r={},i=[[]],a=[],o=[],s=fl([{enter:{blockQuote:ne,codeFenced:ae,codeFencedFenceInfo:h,codeFencedFenceMeta:h,codeIndented:ce,codeText:ze,content:we,definition:ye,definitionDestinationString:xe,definitionLabelString:h,definitionTitleString:h,emphasis:Le,htmlFlow:Pe,htmlText:Ie,image:ue,label:h,link:de,listItemMarker:E,listItemValue:T,listOrdered:C,listUnordered:w,paragraph:ie,reference:h,resource:he,resourceDestinationString:ge,resourceTitleString:h,setextHeading:Ee,strong:Re},exit:{atxHeading:Oe,atxHeadingSequence:Te,autolinkEmail:qe,autolinkProtocol:Ke,blockQuote:re,characterEscapeValue:je,characterReferenceMarkerHexadecimal:We,characterReferenceMarkerNumeric:We,characterReferenceValue:Ge,codeFenced:le,codeFencedFence:se,codeFencedFenceInfo:oe,codeFencedFenceMeta:S,codeFlowValue:Ne,codeIndented:le,codeText:Be,codeTextData:je,data:je,definition:Ce,definitionDestinationString:Se,definitionLabelString:be,definitionTitleString:A,emphasis:Ve,hardBreakEscape:j,hardBreakTrailing:j,htmlFlow:Fe,htmlFlowData:je,htmlText:Fe,htmlTextData:je,image:k,label:pe,labelText:fe,lineEnding:Me,link:k,listOrdered:ee,listUnordered:D,paragraph:O,reference:S,referenceString:me,resource:S,resourceDestinationString:_e,resourceTitleString:ve,setextHeading:Ae,setextHeadingLineSequence:ke,setextHeadingText:De,strong:He,thematicBreak:Ue}},...t.htmlExtensions||[]]),c={definitions:r,tightStack:o},l={buffer:h,encode:x,getData:m,lineEndingIfNeeded:b,options:t,raw:v,resume:g,setData:p,tag:_},u=t.defaultLineEnding;return d;function d(e){let t=-1,n=0,r=[],a=[],o=[];for(;++t<e.length;)!u&&(e[t][1].type===`lineEnding`||e[t][1].type===`lineEndingBlank`)&&(u=e[t][2].sliceSerialize(e[t][1])),(e[t][1].type===`listOrdered`||e[t][1].type===`listUnordered`)&&(e[t][0]===`enter`?r.push(t):f(e.slice(r.pop(),t))),e[t][1].type===`definition`&&(e[t][0]===`enter`?(o=sl(o,e.slice(n,t)),n=t):(a=sl(a,e.slice(n,t+1)),n=t+1));a=sl(a,o),a=sl(a,e.slice(n)),t=-1;let c=a;for(s.enter.null&&s.enter.null.call(l);++t<e.length;){let e=s[c[t][0]],n=c[t][1].type,r=e[n];jl.call(e,n)&&r&&r.call({sliceSerialize:c[t][2].sliceSerialize,...l},c[t][1])}return s.exit.null&&s.exit.null.call(l),i[0].join(``)}function f(e){let t=e.length,n=0,r=0,i=!1,a;for(;++n<t;){let t=e[n];if(t[1]._container)a=void 0,t[0]===`enter`?r++:r--;else switch(t[1].type){case`listItemPrefix`:t[0]===`exit`&&(a=!0);break;case`linePrefix`:break;case`lineEndingBlank`:t[0]===`enter`&&!r&&(a?a=void 0:i=!0);break;default:a=void 0}}e[0][1]._loose=i}function p(e,t){c[e]=t}function m(e){return c[e]}function h(){i.push([])}function g(){return i.pop().join(``)}function _(e){n&&(p(`lastWasTag`,!0),i[i.length-1].push(e))}function v(e){p(`lastWasTag`),i[i.length-1].push(e)}function y(){v(u||`\n`)}function b(){let e=i[i.length-1],t=e[e.length-1],n=t?t.charCodeAt(t.length-1):null;n===10||n===13||n===null||y()}function x(e){return m(`ignoreEncode`)?e:gl(e)}function S(){g()}function C(e){o.push(!e._loose),b(),_(`<ol`),p(`expectFirstItem`,!0)}function w(e){o.push(!e._loose),b(),_(`<ul`),p(`expectFirstItem`,!0)}function T(e){if(m(`expectFirstItem`)){let t=Number.parseInt(this.sliceSerialize(e),10);t!==1&&_(` start=\"`+x(String(t))+`\"`)}}function E(){m(`expectFirstItem`)?_(`>`):te(),b(),_(`<li>`),p(`expectFirstItem`),p(`lastWasTag`)}function ee(){te(),o.pop(),y(),_(`</ol>`)}function D(){te(),o.pop(),y(),_(`</ul>`)}function te(){m(`lastWasTag`)&&!m(`slurpAllLineEndings`)&&b(),_(`</li>`),p(`slurpAllLineEndings`)}function ne(){o.push(!1),b(),_(`<blockquote>`)}function re(){o.pop(),b(),_(`</blockquote>`),p(`slurpAllLineEndings`)}function ie(){o[o.length-1]||(b(),_(`<p>`)),p(`slurpAllLineEndings`)}function O(){o[o.length-1]?p(`slurpAllLineEndings`,!0):_(`</p>`)}function ae(){b(),_(`<pre><code`),p(`fencesCount`,0)}function oe(){_(` class=\"language-`+g()+`\"`)}function se(){let e=m(`fencesCount`)||0;e||(_(`>`),p(`slurpOneLineEnding`,!0)),p(`fencesCount`,e+1)}function ce(){b(),_(`<pre><code>`)}function le(){let e=m(`fencesCount`);e!==void 0&&e<2&&c.tightStack.length>0&&!m(`lastWasTag`)&&y(),m(`flowCodeSeenData`)&&b(),_(`</code></pre>`),e!==void 0&&e<2&&b(),p(`flowCodeSeenData`),p(`fencesCount`),p(`slurpOneLineEnding`)}function ue(){a.push({image:!0}),n=void 0}function de(){a.push({})}function fe(e){a[a.length-1].labelId=this.sliceSerialize(e)}function pe(){a[a.length-1].label=g()}function me(e){a[a.length-1].referenceId=this.sliceSerialize(e)}function he(){h(),a[a.length-1].destination=``}function ge(){h(),p(`ignoreEncode`,!0)}function _e(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function ve(){a[a.length-1].title=g()}function k(){let e=a.length-1,i=a[e],o=i.referenceId||i.labelId,s=i.destination===void 0?r[_l(o)]:i;for(n=!0;e--;)if(a[e].image){n=void 0;break}i.image?(_(`<img src=\"`+kl(s.destination,t.allowDangerousProtocol?void 0:Nl)+`\" alt=\"`),v(i.label),_(`\"`)):_(`<a href=\"`+kl(s.destination,t.allowDangerousProtocol?void 0:Ml)+`\"`),_(s.title?` title=\"`+s.title+`\"`:``),i.image?_(` />`):(_(`>`),v(i.label),_(`</a>`)),a.pop()}function ye(){h(),a.push({})}function be(e){g(),a[a.length-1].labelId=this.sliceSerialize(e)}function xe(){h(),p(`ignoreEncode`,!0)}function Se(){a[a.length-1].destination=g(),p(`ignoreEncode`)}function A(){a[a.length-1].title=g()}function Ce(){let e=a[a.length-1],t=_l(e.labelId);g(),jl.call(r,t)||(r[t]=a[a.length-1]),a.pop()}function we(){p(`slurpAllLineEndings`,!0)}function Te(e){m(`headingRank`)||(p(`headingRank`,this.sliceSerialize(e).length),b(),_(`<h`+m(`headingRank`)+`>`))}function Ee(){h(),p(`slurpAllLineEndings`)}function De(){p(`slurpAllLineEndings`,!0)}function Oe(){_(`</h`+m(`headingRank`)+`>`),p(`headingRank`)}function ke(e){p(`headingRank`,this.sliceSerialize(e).charCodeAt(0)===61?1:2)}function Ae(){let e=g();b(),_(`<h`+m(`headingRank`)+`>`),v(e),_(`</h`+m(`headingRank`)+`>`),p(`slurpAllLineEndings`),p(`headingRank`)}function je(e){v(x(this.sliceSerialize(e)))}function Me(e){if(!m(`slurpAllLineEndings`)){if(m(`slurpOneLineEnding`)){p(`slurpOneLineEnding`);return}if(m(`inCodeText`)){v(` `);return}v(x(this.sliceSerialize(e)))}}function Ne(e){v(x(this.sliceSerialize(e))),p(`flowCodeSeenData`,!0)}function j(){_(`<br />`)}function Pe(){b(),Ie()}function Fe(){p(`ignoreEncode`)}function Ie(){t.allowDangerousHtml&&p(`ignoreEncode`,!0)}function Le(){_(`<em>`)}function Re(){_(`<strong>`)}function ze(){p(`inCodeText`,!0),_(`<code>`)}function Be(){p(`inCodeText`),_(`</code>`)}function Ve(){_(`</em>`)}function He(){_(`</strong>`)}function Ue(){b(),_(`<hr />`)}function We(e){p(`characterReferenceType`,e.type)}function Ge(e){let t=this.sliceSerialize(e);v(x(m(`characterReferenceType`)?ml(t,m(`characterReferenceType`)===`characterReferenceMarkerNumeric`?10:16):al(t))),p(`characterReferenceType`)}function Ke(e){let n=this.sliceSerialize(e);_(`<a href=\"`+kl(n,t.allowDangerousProtocol?void 0:Ml)+`\">`),v(x(n)),_(`</a>`)}function qe(e){let t=this.sliceSerialize(e);_(`<a href=\"`+kl(`mailto:`+t)+`\">`),v(x(t)),_(`</a>`)}}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Fl={tokenize:Il};function Il(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Ll={tokenize:zl},Rl={tokenize:Bl};function zl(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return ol(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Rl,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Rl,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i=i||t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;ol(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Bl(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Vl(e){if(e===null||Tl(e)||Dl(e))return 1;if(El(e))return 2}function Hl(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Ul={name:`attention`,resolveAll:Wl,tokenize:Gl};function Wl(e,t){let n=-1,r,i,a,o,s,c,l,u;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;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Kl(d,-c),Kl(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>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=sl(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=sl(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=sl(l,Hl(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=sl(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=sl(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ol(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Gl(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Vl(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Vl(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Kl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ql={name:`autolink`,tokenize:Jl};function Jl(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return vl(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||yl(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||yl(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||xl(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):bl(t)?(e.consume(t),l):n(t)}function u(e){return yl(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||yl(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Yl={partial:!0,tokenize:Xl};function Xl(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var Zl={continuation:{tokenize:$l},exit:eu,name:`blockQuote`,tokenize:Ql};function Ql(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||(e.enter(`blockQuote`,{_container:!0}),n.open=!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function $l(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Zl,t,n)(r)}}function eu(e){e.exit(`blockQuote`)}var tu={name:`characterEscape`,tokenize:nu};function nu(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return wl(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var ru={name:`characterReference`,tokenize:iu};function iu(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=yl,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Cl,u):(e.enter(`characterReferenceValue`),a=7,o=Sl,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===yl&&!al(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var au={partial:!0,tokenize:cu},ou={concrete:!0,name:`codeFenced`,tokenize:su};function su(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(au,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(au,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function cu(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var lu={name:`codeIndented`,tokenize:du},uu={partial:!0,tokenize:fu};function du(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(uu,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function fu(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var pu={name:`codeText`,previous:hu,resolve:mu,tokenize:gu};function mu(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function hu(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function gu(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var _u=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError(\"Cannot access index `\"+e+\"` in a splice buffer of size `\"+(this.left.length+this.right.length)+\"`\");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&vu(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),vu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vu(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);vu(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);vu(this.left,t.reverse())}}};function vu(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 yu(e){let t={},n=-1,r,i,a,o,s,c,l,u=new _u(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,bu(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.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={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return ol(e,0,1/0,u.slice(0)),!l}function bu(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var xu={resolve:Cu,tokenize:wu},Su={partial:!0,tokenize:Tu};function Cu(e){return yu(e),e}function wu(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(Su,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Tu(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Eu(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||xl(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Tl(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||xl(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Du(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||(c=!Y(t)),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Ou(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function ku(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Au={name:`definition`,tokenize:Mu},ju={partial:!0,tokenize:Nu};function Mu(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Du.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=_l(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Tl(t)?ku(e,l)(t):l(t)}function l(t){return Eu(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(ju,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Nu(e,t,n){return r;function r(t){return Tl(t)?ku(e,i)(t):n(t)}function i(t){return Ou(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var Pu={name:`hardBreakEscape`,tokenize:Fu};function Fu(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Iu={name:`headingAtx`,resolve:Lu,tokenize:Ru};function Lu(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`},ol(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Ru(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Tl(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Tl(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var zu=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Bu=[`pre`,`script`,`style`,`textarea`],Vu={concrete:!0,name:`htmlFlow`,resolveTo:Wu,tokenize:Gu},Hu={partial:!0,tokenize:qu},Uu={partial:!0,tokenize:Ku};function Wu(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 Gu(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:se):vl(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):vl(a)?(e.consume(a),i=4,r.interrupt?t:se):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:se):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return vl(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Tl(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Bu.includes(l)?(i=1,r.interrupt?t(s):D(s)):zu.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||yl(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return Y(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||vl(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||yl(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Tl(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),ee):n(t)}function ee(t){return t===null||J(t)?D(t):Y(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),ie):t===60&&i===1?(e.consume(t),O):t===62&&i===4?(e.consume(t),ce):t===63&&i===3?(e.consume(t),se):t===93&&i===5?(e.consume(t),oe):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Hu,le,te)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),D)}function te(t){return e.check(Uu,ne,le)(t)}function ne(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),re}function re(t){return t===null||J(t)?te(t):(e.enter(`htmlFlowData`),D(t))}function ie(t){return t===45?(e.consume(t),se):D(t)}function O(t){return t===47?(e.consume(t),o=``,ae):D(t)}function ae(t){if(t===62){let n=o.toLowerCase();return Bu.includes(n)?(e.consume(t),ce):D(t)}return vl(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ae):D(t)}function oe(t){return t===93?(e.consume(t),se):D(t)}function se(t){return t===62?(e.consume(t),ce):t===45&&i===2?(e.consume(t),se):D(t)}function ce(t){return t===null||J(t)?(e.exit(`htmlFlowData`),le(t)):(e.consume(t),ce)}function le(n){return e.exit(`htmlFlow`),t(n)}}function Ku(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function qu(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Yl,t,n)}}var Ju={name:`htmlText`,tokenize:Yu};function Yu(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):vl(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):vl(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,O(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ie(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):J(t)?(o=h,O(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ie(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ie(t):J(t)?(o=v,O(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,O(t)):(e.consume(t),y)}function b(e){return e===62?ie(e):y(e)}function x(t){return vl(t)?(e.consume(t),S):n(t)}function S(t){return t===45||yl(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,O(t)):Y(t)?(e.consume(t),C):ie(t)}function w(t){return t===45||yl(t)?(e.consume(t),w):t===47||t===62||Tl(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ie):t===58||t===95||vl(t)?(e.consume(t),E):J(t)?(o=T,O(t)):Y(t)?(e.consume(t),T):ie(t)}function E(t){return t===45||t===46||t===58||t===95||yl(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):J(t)?(o=ee,O(t)):Y(t)?(e.consume(t),ee):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,te):J(t)?(o=D,O(t)):Y(t)?(e.consume(t),D):(e.consume(t),ne)}function te(t){return t===i?(e.consume(t),i=void 0,re):t===null?n(t):J(t)?(o=te,O(t)):(e.consume(t),te)}function ne(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Tl(t)?T(t):(e.consume(t),ne)}function re(e){return e===47||e===62||Tl(e)?T(e):n(e)}function ie(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function O(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ae}function ae(t){return Y(t)?X(e,oe,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):oe(t)}function oe(t){return e.enter(`htmlTextData`),o(t)}}var Xu={name:`labelEnd`,resolveAll:ed,resolveTo:td,tokenize:nd},Zu={tokenize:rd},Qu={tokenize:id},$u={tokenize:ad};function ed(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&ol(e,0,e.length,n),e}function td(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);let c={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}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=sl(s,e.slice(a+1,a+r+3)),s=sl(s,[[`enter`,u,t]]),s=sl(s,Hl(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=sl(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=sl(s,e.slice(o+1)),s=sl(s,[[`exit`,c,t]]),ol(e,a,e.length,s),e}function nd(e,t,n){let r=this,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(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(_l(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Zu,u,o?u:d)(t):t===91?e.attempt(Qu,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt($u,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function rd(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Tl(t)?ku(e,a)(t):a(t)}function a(t){return t===41?u(t):Eu(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Tl(t)?ku(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Ou(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Tl(t)?ku(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function id(e,t,n){let r=this;return i;function i(t){return Du.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(_l(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function ad(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var od={name:`labelStartImage`,resolveAll:Xu.resolveAll,tokenize:sd};function sd(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var cd={name:`labelStartLink`,resolveAll:Xu.resolveAll,tokenize:ld};function ld(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ud={name:`lineEnding`,tokenize:dd};function dd(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var fd={name:`thematicBreak`,tokenize:pd};function pd(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var md={continuation:{tokenize:vd},exit:bd,name:`list`,tokenize:_d},hd={partial:!0,tokenize:xd},gd={partial:!0,tokenize:yd};function _d(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Sl(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(fd,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Sl(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Yl,r.interrupt?n:u,e.attempt(hd,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function vd(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Yl,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(gd,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(md,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function yd(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function bd(e){e.exit(this.containerState.type)}function xd(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Sd={name:`setextUnderline`,resolveTo:Cd,tokenize:wd};function Cd(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);let 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 wd(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Td={tokenize:Ed};function Ed(e){let t=this,n=e.attempt(Yl,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xu,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Dd={resolveAll:jd()},Od=Ad(`string`),kd=Ad(`text`);function Ad(e){return{resolveAll:jd(e===`text`?Md:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function jd(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Md(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||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={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Nd=t({attentionMarkers:()=>Vd,contentInitial:()=>Fd,disable:()=>Hd,document:()=>Pd,flow:()=>Ld,flowInitial:()=>Id,insideSpan:()=>Bd,string:()=>Rd,text:()=>zd}),Pd={42:md,43:md,45:md,48:md,49:md,50:md,51:md,52:md,53:md,54:md,55:md,56:md,57:md,62:Zl},Fd={91:Au},Id={[-2]:lu,[-1]:lu,32:lu},Ld={35:Iu,42:fd,45:[Sd,fd],60:Vu,61:Sd,95:fd,96:ou,126:ou},Rd={38:ru,92:tu},zd={[-5]:ud,[-4]:ud,[-3]:ud,33:od,38:ru,42:Ul,60:[ql,Ju],91:cd,92:[Pu,tu],93:Xu,95:Ul,96:pu},Bd={null:[Ul,Dd]},Vd={null:[42,95]},Hd={null:[]};function Ud(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=sl(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Hl(a,l.events,l),l.events):[]}function f(e,t){return Gd(p(e),t)}function p(e){return Wd(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-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=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&ol(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Wd(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Gd(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],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 Kd(e){let t={constructs:ll([Nd,...(e||{}).extensions||[]]),content:n(Fl),defined:[],document:n(Ll),flow:n(Td),lazy:{},string:n(Od),text:n(kd)};return t;function n(e){return n;function n(n){return Ud(t,e,n)}}}function qd(e){for(;!yu(e););return e}var Jd=/[\\0\\t\\n\\r]/g;function Yd(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(Jd.lastIndex=u,c=Jd.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&(s.push(-5),r=void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}function Xd(e,t,n){return typeof t!=`string`&&(n=t,t=void 0),Pl(n)(qd(Kd(n).document().write(Yd()(e,t,!0))))}var Zd={none:``,left:` align=\"left\"`,right:` align=\"right\"`,center:` align=\"center\"`};function Qd(){return{enter:{table(e){let t=e._align;this.lineEndingIfNeeded(),this.tag(`<table>`),this.setData(`tableAlign`,t)},tableBody(){this.tag(`<tbody>`)},tableData(){let e=Zd[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];e===void 0?this.buffer():(this.lineEndingIfNeeded(),this.tag(`<td`+e+`>`))},tableHead(){this.lineEndingIfNeeded(),this.tag(`<thead>`)},tableHeader(){let e=Zd[this.getData(`tableAlign`)[this.getData(`tableColumn`)]];this.lineEndingIfNeeded(),this.tag(`<th`+e+`>`)},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,$d)),this.raw(this.encode(t))},table(){this.setData(`tableAlign`),this.setData(`slurpAllLineEndings`),this.lineEndingIfNeeded(),this.tag(`</table>`)},tableBody(){this.lineEndingIfNeeded(),this.tag(`</tbody>`)},tableData(){let 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(){let e=this.getData(`tableColumn`);this.tag(`</th>`),this.setData(`tableColumn`,e+1)},tableRow(){let e=this.getData(`tableAlign`),t=this.getData(`tableColumn`);for(;t<e.length;)this.lineEndingIfNeeded(),this.tag(`<td`+Zd[e[t]]+`></td>`),t++;this.setData(`tableColumn`,t),this.lineEndingIfNeeded(),this.tag(`</tr>`)}}}}function $d(e,t){return t===`|`?t:e}var ef=class{constructor(){this.map=[]}add(e,t,n){tf(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function tf(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 nf(e,t){let n=!1,r=[];for(;t<e.length;){let 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`){let e=r.length-1;r[e]=r[e]===`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 rf(){return{flow:{null:{name:`table`,tokenize:af,resolveAll:of}}}}function af(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Tl(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Tl(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function of(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new ef;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(cf(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=sf(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=sf(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=sf(f,t,o,i,n,d)):(o[0]=o[1],d=sf(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&cf(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=nf(t.events,n))}return e}function sf(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},lf(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=lf(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=lf(t.events,n[2]),a=lf(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},lf(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function cf(e,t,n,r,i){let a=[],o=lf(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 lf(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}function uf(){return{enter:{strikethrough(){this.tag(`<del>`)}},exit:{strikethrough(){this.tag(`</del>`)}}}}function df(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&ol(o,o.length,0,Hl(s,e.slice(r+1,n),t)),ol(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ol(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Vl(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Vl(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}function ff(e){let t=[`codeIndented`];return e?.inline&&t.push(`list`,`headingAtx`,`setextUnderline`,`thematicBreak`,`blockQuote`,`codeFenced`,`table`),{allowDangerousHtml:!0,extensions:[rf(),df(),{disable:{null:t}}],htmlExtensions:[Qd(),uf()]}}function pf(e,t){let n=ff(t);return Xd(e,{...n,extensions:[...n.extensions??[],yf(e),hf]})}var mf=e=>{let t=e.length-2,n=e[t-1];return n&&n[0]===`exit`&&n[1].type===`data`&&(n[1].end=e[t][1].end,e.length=t),e},hf={text:{null:{name:`textData`,tokenize(e,t){let n=this,r=this.parser.constructs.text;function i(e){if(e===null)return!0;let t=r[e]??[];return(Array.isArray(t)?t:[t]).some(e=>!e.previous||e.previous.call(n,n.previous))}function a(n){return i(n)?(e.exit(`data`),t(n)):(e.consume(n),a)}return t=>(e.enter(`data`),e.consume(t),a)},resolveTo:mf}}},gf=/[#-'*+\\--9=?A-Z^-~]/,_f=/[0-9A-Za-z]/,vf=/[A-Za-z]/;function yf(e){let t=e.charCodeAt(0)===65279?1:0,n=e.lastIndexOf(`-->`),r=e.lastIndexOf(`?>`),i=e.lastIndexOf(`]]>`),a=e.lastIndexOf(`>`);function o(t){return e[t]===`<`?e.startsWith(`\\x3C!--`,t)?n<t+2:e.startsWith(`<![CDATA[`,t)?i<t+9:e[t+1]===`!`&&vf.test(e[t+2]??``)?a<t+3:e[t+1]===`?`?r<t+2&&!s(t):!1:!1}function s(t){let n=t+1;for(;gf.test(e[n]??``);)n++;if(e[n]!==`@`)return!1;n++;let r=0,i=`atSignOrDot`;for(;;){let t=e[n]??``;if(i===`atSignOrDot`){if(!_f.test(t))return!1;i=`label`}else if(i===`label`){if(t===`>`)return!0;t===`.`?(n++,r=0,i=`atSignOrDot`):i=`value`}else{if(!((t===`-`||_f.test(t))&&r++<63))return!1;n++,i=t===`-`?`value`:`label`}}}let c={name:`unclosedHtml`,resolveTo:mf,tokenize(e,n,r){let i=this.now().offset+t;return t=>t!==60||!o(i)?r(t):(e.enter(`data`),e.consume(t),e.exit(`data`),n)}};return{text:{60:c}}}function bf(e){let t=e.metadata[`data-source-file`],n=e.metadata[`data-source-line`];return t?n?` (${t}:${n})`:` (${t})`:``}function xf(){let e=Q.getState();if(!e.storyData)return``;let t=e.storyData.passages.get(e.currentPassage);return t?bf(t):``}function Sf({macro:e,error:t}){return q(`span`,{class:`error`,title:String(t),children:`{${e} error${xf()}: ${Jc(t)}}`})}function Cf(e,t,n=xf()){console.error(`spindle: Error in {${e}}${n}:`,t)}function wf(e,t,n){let r=j();if(r.current===void 0){r.current=null;let i=xf();try{n()}catch(n){r.current={error:n},Cf(`${e} ${t}`,n,i)}}return r.current?q(Sf,{macro:e,error:r.current.error}):null}var Tf={update:e=>{throw Error(`Cannot set @${e} — local variables require a {for}, widget, {link}, or {button} scope`)},getValues:()=>As},Ef=_e(As),Df=_e(Tf),Of=_e(!1),kf=_e(!1),Af=_e(!1),jf=_e(!1),Mf=`http://www.w3.org/2000/svg`,Nf=new Set([`pre`,`textarea`]),Pf=_e(null);function Ff(e,t){return`<span data-tw=${e}:${t}></span>`}var If=/(?:(?<=\\\\)\\uE000)?<span data-tw=([0-9a-z]+):(\\d+)><\\/span>/g,Lf=``;function Rf(e,t){if(!e.includes(`<span data-tw=`))return[e];let n=[],r=0;for(let i of e.matchAll(If))i[1]===t.nonce&&(i.index>r&&n.push(e.slice(r,i.index)),n.push(parseInt(i[2],10)),r=i.index+i[0].length);return r<e.length&&n.push(e.slice(r)),n}function zf(e,t){return Rf(e,t).map(e=>typeof e==`number`?t.components[e]:e)}function Bf({tag:e,attributes:t,placeholders:n,svg:r,children:i}){let a=Yc(),o=[],{props:s,direct:c}=$f(t.map(([e,t,r])=>{let i=n[e];if(!i)return[e,t,r];let s=Gc(i,a);for(let t of s.errors)o.push([e,t]);return[e,s.text,r]}),r),l=ep(c);return Hf(o,b(e,l?{...s,ref:l}:s,...i))}function Vf({tag:e,props:t,direct:n,children:r}){let i=ep(n);return b(e,{...t,ref:i},...r)}function Hf(e,t){return e.length===0?t:q(S,{children:[e.map(([e,{macro:t,error:n}],r)=>q(Sf,{macro:t,error:Error(`in attribute \"${e}\": ${Jc(n)}`)},r)),t]})}function Uf(e,t){if(e==null||e.nodeType!==Node.ELEMENT_NODE)return-1;let n=e.getAttribute(`data-tw`),r=`${t.nonce}:`;return n==null||!n.startsWith(r)?-1:parseInt(n.slice(r.length),10)}function Wf(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content}function Gf(e,t,n=!1){let r=Wf(e.trim());if(n)for(let e of Array.from(r.childNodes))e.nodeType===Node.ELEMENT_NODE&&e.nodeName===`P`&&e.replaceWith(...Array.from(e.childNodes));return q(S,{children:Array.from(r.childNodes).map((e,n)=>Kf(e,n,t))})}function Kf(e,t,n){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??``;t.endsWith(`\\\\${Lf}`)&&Uf(e.nextSibling,n)!==-1&&(t=t.slice(0,-1));let r=zf(t,n);return r.length===1?r[0]:r}if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.localName,a=Uf(r,n);if(a!==-1)return n.components[a];let o=r.namespaceURI===Mf,s=[],c;for(let{name:e,value:t}of Array.from(r.attributes)){s.push([e,t,t]);let r=Rf(t,n);r.every(e=>typeof e==`string`)||(c??(c={}),c[e]=r.map(e=>typeof e==`string`?{type:`text`,value:e}:n.nodes[e]))}let l=Array.from(r.childNodes).map((e,t)=>Kf(e,t,n));if(c)return q(Bf,{tag:i,attributes:s,placeholders:c,svg:o,children:l},t);let{props:u,direct:d}=$f(s,o);return d.length>0?q(Vf,{tag:i,props:u,direct:d,children:l},t):b(i,{...u,key:t},...l)}return null}var qf=new Set(`a.abbr.b.bdi.bdo.br.cite.code.data.dfn.em.i.kbd.label.mark.meter.output.progress.q.rp.rt.ruby.s.samp.small.span.strong.sub.sup.time.u.var.wbr`.split(`.`)),Jf=new Set([`value`,`checked`,`selected`,`muted`]),Yf=new Set([`allowfullscreen`,`async`,`autofocus`,`autoplay`,`checked`,`controls`,`default`,`defer`,`disabled`,`formnovalidate`,`hidden`,`inert`,`ismap`,`itemscope`,`loop`,`multiple`,`muted`,`nomodule`,`novalidate`,`open`,`playsinline`,`readonly`,`required`,`reversed`,`selected`]),Xf=new Set([...new Set([`key`,`ref`,`children`,`dangerouslySetInnerHTML`]),`class`,`className`]),Zf=/^[A-Za-z_:][\\w:.-]*$/;function Qf(e,t,n){if(Zf.test(t)){e.setAttribute(t,n);return}let r=Wf(`<i ${t}=\"\"></i>`).firstChild.attributes[0];if(!r)return;let i=r.cloneNode();i.value=n,e.setAttributeNode(i)}function $f(e,t){let n={},r=[];for(let[i,a,o]of e){let e=i.toLowerCase();Yf.has(e)&&o!==``&&a===``||(!t&&Jf.has(e)?n[e]=e!==`value`&&o===``?!0:a:!Zf.test(i)||e.startsWith(`on`)||e===`translate`||t&&(Xf.has(i)||i===`__proto__`)?r.push([i,a]):n[t?i:i.toUpperCase()]=a)}return{props:n,direct:r}}function ep(e){let t=j(null);return Ne(()=>{let n=t.current;if(!(!n||e.length===0)){for(let[t,r]of e)Qf(n,t,r);return()=>{for(let[t]of e)n.removeAttribute(t)}}},[JSON.stringify(e)]),e.length>0?t:void 0}var tp=new Map;function np(e){if(!e.includes(`&`))return e;let t=tp.get(e);return t===void 0&&(t=Wf(`<i title=\"${e.replace(/\"/g,`"`)}\"></i>`).firstChild.getAttribute(`title`)??e,tp.set(e,t)),t}var rp=/\\{[$_@%]\\w/,ip=new Map,ap=2e3;function op(e){let t=ip.get(e);return t===void 0&&(t=Rc(e),`nodes`in t&&e.includes(`&`)&&(t={nodes:zc(t.nodes,np)}),ip.size>=ap&&ip.clear(),ip.set(e,t)),t}function sp(e,t,n,r){if(Bo(e)){if(!t.includes(`&`)&&!rp.test(t))return t;let i=qc(t,n,np);for(let t of i.errors)r.push([e,t]);return i.text}if(!Fc(t))return np(t);let i=op(t);if(`error`in i)return r.push([e,{macro:`markup`,error:i.error}]),np(t);let a=Gc(i.nodes,n);for(let t of a.errors)r.push([e,t]);return a.text}function cp({node:e}){let t=Yc(),{nobr:n,locals:r,raw:i,inline:a}=tl(),o=Ie(jf),s=e.tag.toLowerCase(),c=s===`svg`,l=!i&&(c||Nf.has(s)),u=[],{props:d,direct:f}=$f(Object.entries(e.attributes).map(([e,n])=>[e,sp(e,n,t,u),n]),o||c),p=ep(f);p&&(d.ref=p);let m=qf.has(s),h;e.children.length>0&&(i||l?h=hp(e.children):(h=Cp(e.children,{nobr:n,locals:r,inline:m}),m!==a&&(h=q(kf.Provider,{value:m,children:h}))));let g=b(e.tag,d,h);return c&&!o&&(g=q(jf.Provider,{value:!0,children:g})),Hf(u,l?q(Af.Provider,{value:!0,children:g}):g)}function lp(){let e=Ie(Pf),t=tl();return!e||e.length===0?null:q(S,{children:Cp(e,t)})}var up=new WeakMap,dp=0;function fp(e){let t=up.get(e);return t===void 0&&(t=`n${dp++}`,up.set(e,t)),t}function pp(e,t){if(lc(e.name))return null;let n=_c(e.name);if(n)return q(rl,{body:n.body,params:n.params,rawArgs:e.rawArgs,invocationChildren:e.children},t);let r=rc(e.name);return r?q(r,{rawArgs:e.rawArgs,className:e.className,id:e.id,children:e.children,branches:e.branches},t):q(`span`,{class:`error`,children:`{unknown macro: ${e.name}}`},t)}function mp(e){if(e.type===`text`)return e.value;let t=fp(e);switch(e.type){case`variable`:return e.scope===`local`&&e.name===`children`?q(lp,{},t):q($c,{node:e},t);case`expression`:return q(el,{node:e},t);case`macro`:return pp(e,t);case`html`:return q(cp,{node:e},t);default:return e}}function hp(e){return e.length===0?null:e.map(e=>mp(e))}var gp=/[*_`#|~\\[>\\\\\\-+=\\r]|!\\[|\\d+[.)]|&#?[a-zA-Z0-9]+;| {2}\\n|<[!?]/,_p=/(?:\\r\\n|\\r(?!\\n)|\\n)\\s*[\\r\\n]/,vp=/<span data-tw=[0-9a-z]+:\\d+><\\/span>/g,yp=` \t\\r\n`;function bp(e,t,n,r){let i=t;if(n===1)for(;i<e.length&&r.includes(e[i]);)i++;else for(;i>0&&r.includes(e[i-1]);)i--;return i}function xp(e){return e.includes(`\n`)?e.split(`\n`).map((e,t,n)=>{let r=t===0?0:bp(e,0,1,` \t`),i=t===n.length-1?e.length:bp(e,e.length,-1,` \t`);return e.slice(r,Math.max(r,i))}).join(`\n`):e}function Sp(e,t,n){let r=zf(xp(e),t).filter(e=>e!==``);return n?q(S,{children:r}):b(`p`,null,...r)}function Cp(e,t){if(e.length===0)return null;if(t?.raw)return hp(e);if(!e.some(e=>e.type===`text`&&(e.value.trim()!==``||_p.test(e.value))))return e.map(e=>mp(e));let n=[],r={nonce:Math.random().toString(36).slice(2,10)||`0`,components:n,nodes:[]},i=``;for(let t=0;t<e.length;t++){let a=e[t];if(a.type===`text`){i+=a.value;continue}let o=n.length;n.push(mp(a)),r.nodes.push(a),i.endsWith(`\\\\`)&&(i+=Lf),i+=Ff(r.nonce,o)}let a=!!(t?.nobr||t?.inline),o=i.slice(0,bp(i,0,1,yp)),s=o.length===i.length?``:i.slice(bp(i,i.length,-1,yp)),c=i.slice(o.length,i.length-s.length),l=e=>a&&(o||s)?q(S,{children:[o,e,s]}):e,u=i.replace(vp,``);return!gp.test(u)&&!_p.test(u)?l(Sp(c,r,a)):l(Gf(pf(i,{inline:t?.inline}),r,a))}var wp=2**32-1,Tp=wp-1,Ep=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}},Dp=Symbol();function Op(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i===Dp?n.push(`.get(${t(e[++r])})`):typeof i==`number`?n.push(`[${i}]`):n.push(Vp(i))}return n}var kp=Object.getOwnPropertyNames(Object.prototype).sort().join(`\\0`);function Ap(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\\0`)===kp}function jp(e){return Object.prototype.toString.call(e).slice(8,-1)}function Mp(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}function Np(e){switch(e){case`\"`:return`\\\\\"`;case`<`:return`\\\\u003C`;case`\\\\`:return`\\\\\\\\`;case`\n`:return`\\\\n`;case`\\r`:return`\\\\r`;case`\t`:return`\\\\t`;case`\\b`:return`\\\\b`;case`\\f`:return`\\\\f`;case`\\u2028`:return`\\\\u2028`;case`\\u2029`:return`\\\\u2029`;default:return e<` `?`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}var Pp=/[\"<\\\\\\u0000-\\u001f\\u2028\\u2029]/;function Fp(e){if(!Pp.test(e)&&e.isWellFormed())return`\"${e}\"`;let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let a=e.charCodeAt(i);if(a>=55296&&a<=57343){if(a<=56319&&i+1<r&&(e.charCodeAt(i+1)&64512)==56320){i+=1;continue}t+=e.slice(n,i)+`\\\\u${a.toString(16)}`,n=i+1;continue}let o=Np(e[i]);o&&(t+=e.slice(n,i)+o,n=i+1)}return`\"${n===0?e:t+e.slice(n)}\"`}var Ip=64,Lp=new Map;function Rp(e){if(e.length>Ip)return Fp(e);let t=Lp.get(e);return t===void 0&&(Lp.size>=1024&&Lp.clear(),t=Fp(e),Lp.set(e,t)),t}function zp(e){let t=Object.getOwnPropertySymbols(e);return t.length===0?t:t.filter(t=>Object.getOwnPropertyDescriptor(e,t)?.enumerable)}var Bp=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Vp(e){return Bp.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function Hp(e){return!(!Number.isInteger(e)||e<0||e>Tp)}function Up(e){return!(!Number.isInteger(e)||e<0||e>wp)}function Wp(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return Hp(+e)}function Gp(e){for(var t=e.length-1;t>=0&&!Wp(e[t]);t--);return t+1}function Kp(e){let t=Object.keys(e);return t.length=Gp(t),t}function qp(e){return new Uint8Array(e).toBase64()}function Jp(e){return Uint8Array.fromBase64(e).buffer}function Yp(e){return Buffer.from(e).toString(`base64`)}function Xp(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function Zp(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function Qp(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}var $p=typeof Uint8Array.fromBase64==`function`,em=typeof process==`object`&&process.versions?.node!==void 0,tm=$p?qp:em?Yp:Zp,nm=$p?Jp:em?Xp:Qp;function rm(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}var im=Object.freeze({kind:`not-plain`}),am=Object.freeze({kind:`symbol-keys`}),om=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>jp(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>(Mp(e)&&(e=new Uint8Array(e)),{buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>Kp(e),shapeOf:e=>Ap(e)?zp(e).length>0?am:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:im,get:(e,t)=>e[t]}),sm=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,`byteLength`)?.get,cm=typeof SharedArrayBuffer>`u`?void 0:Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype,`byteLength`)?.get,lm=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{try{sm.call(t)}catch(e){if(!cm)throw e;cm.call(t)}let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[Tp]=void 0,delete t[Tp],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function um(){throw Error(`Invalid input`)}function dm(e,t,n){return fm(JSON.parse(e),t,n)}function fm(e,t,n){let r=rm(lm,n?.operations);if(typeof e==`number`)return c(e,!0);(!Array.isArray(e)||e.length===0)&&um();let i=e,a=Array(i.length),o=null;function s(e){return(!Hp(e)||e>=i.length)&&um(),i[e]}function c(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if((n||typeof e!=`number`)&&um(),e in a)return a[e];e>=i.length&&um();let l=i[e];if(!l||typeof l!=`object`)a[e]=r.fromPrimitive(l);else if(Array.isArray(l))if(typeof l[0]==`string`){let n=l[0],u=t&&Object.hasOwn(t,n)?t[n]:void 0;if(u){let t=l[1];if(typeof t!=`number`&&(t=i.push(l[1])-1),Object.hasOwn(a,t))return a[e]=u(a[t]);if(o??(o=new Set),o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=u(c(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(l[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<l.length;e+=1)r.addValue(t,c(l[e]));break;case`Map`:let i=r.createMap();a[e]=i;for(let e=1;e<l.length;e+=2)r.addEntry(i,c(l[e]),c(l[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(l[1],l[2]);break;case`Object`:{let t=l[1];if(!(t===-3||t===-4||t===-5||t===-6)){let e=s(t),n=Array.isArray(e)&&e[0]===`BigInt`;(e===void 0||typeof e==`object`)&&!n&&um()}a[e]=r.box(c(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(l[1]));break;case`null`:let o=r.createNullPrototypeObject();a[e]=o;for(let e=1;e<l.length;e+=2){let t=l[e];if(typeof t!=`string`)throw Error(`Cannot parse an object with a non-string key`);if(t===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(o,t,c(l[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=l[1],i=s(t);(!Array.isArray(i)||i[0]!==`ArrayBuffer`)&&um();let o=c(t);a[e]=r.fromViewInfo(n,o,l[2],l[3]);break}case`ArrayBuffer`:{let t=l[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(nm(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,l[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(l[0]===-7){let t=l[1];Up(t)||um();let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<l.length;e+=2){let i=l[e];(!Hp(i)||i>=t)&&um(),r.set(n,i,c(l[e+1]))}}else{let t=r.createArray(l.length);a[e]=t;for(let e=0;e<l.length;e+=1){let n=l[e];n!==-2&&r.set(t,e,c(n))}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(l)){if(e===`__proto__`)throw Error(\"Cannot parse an object with a `__proto__` property\");r.set(t,e,c(l[e]))}}return a[e]}return c(0)}function pm(e,t,n){let r=mm(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function mm(e,t,n,r){let i=rm(om,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(e,n){throw new Ep(e,Op(c,e=>{let t=i.typeOf(e);return t!==`object`&&t!==`function`&&t!==`symbol`?hm(i.toPrimitive(e)):`...`}),n,t)}function d(t,n){let r=i.typeOf(t);if(r===`undefined`)return-1;let f;if(r===`number`){if(f=i.toPrimitive(t),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(t);if(o.has(p))return o.get(p);n??(n=l++),o.set(p,n);for(let{key:e,fn:r}of s){let i=r(t);if(i)return a[n]=`[\"${e}\",${d(i)}]`,n}r===`function`?u(`Cannot stringify a function`,t):r===`symbol`&&u(`Cannot stringify a Symbol primitive`,t);let m=``;if(r!==`object`)m=hm(r===`number`?f:i.toPrimitive(t));else if(i.isThenable(t)){e||u(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,t);let r=c.slice();m=i.toPromise(t).then(e=>{c=r;let t=d(e,n);t<0&&(a[n]=t)}),m.catch(()=>{})}else{let e=i.tagOf(t);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`[\"Object\",${d(i.unbox(t))}]`;break;case`Date`:m=`[\"Date\",\"${i.toISOString(t)}\"]`;break;case`URL`:m=`[\"URL\",${Fp(i.toStringValue(t))}]`;break;case`URLSearchParams`:m=`[\"URLSearchParams\",${Fp(i.toStringValue(t))}]`;break;case`RegExp`:let{source:n,flags:r}=i.regExpInfo(t);m=r?`[\"RegExp\",${Fp(n)},\"${r}\"]`:`[\"RegExp\",${Fp(n)}]`;break;case`Array`:{let e=!1,n=i.lengthOf(t);m=`[`;for(let r=0;r<n;r+=1)if(r>0&&(m+=`,`),i.hasOwn(t,r))c.push(r),m+=d(i.get(t,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(t),a=r.length,o=String(n).length;if((n-a)*3>4+o+a*(o+1)){m=`[-7,`+n;for(let e=0;e<r.length;e++){let n=r[e];c.push(+n),m+=`,`+n+`,`+d(i.get(t,n)),c.pop()}break}else e=!0,m+=-2}m+=`]`;break}case`Set`:m=`[\"Set\"`;for(let e of i.valuesOf(t))m+=`,${d(e)}`;m+=`]`;break;case`Map`:m=`[\"Map\"`;for(let[e,n]of i.entriesOf(t))c.push(Dp,e),m+=`,${d(e)},${d(n)}`,c.pop(),c.pop();m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.length}`),m+=`]`;break}case`DataView`:{let n=i.viewInfo(t);m=`[\"`+e+`\",`+d(n.buffer),n.byteLength!==n.bufferByteLength&&(m+=`,${n.byteOffset},${n.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`[\"ArrayBuffer\",\"${tm(i.toArrayBuffer(t))}\"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`[\"${e}\",${Fp(i.toStringValue(t))}]`;break;default:{let e=i.shapeOf(t);if(e.kind===`not-plain`&&u(`Cannot stringify arbitrary non-POJOs`,t),e.kind===`symbol-keys`&&u(`Cannot stringify POJOs with symbolic keys`,t),e.kind===`null-proto`){m=`[\"null\"`;for(let n of e.keys)n===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),c.push(n),m+=`,${Rp(n)},${d(i.get(t,n))}`,c.pop();m+=`]`}else{m=`{`;let n=!1;for(let r of e.keys)r===`__proto__`&&u(`Cannot stringify objects with __proto__ keys`,t),n&&(m+=`,`),n=!0,c.push(r),m+=`${Rp(r)}:${d(i.get(t,r))}`,c.pop();m+=`}`}}}}return a[n]=m,n}let f=d(t);return f<0?`${f}`:a}function hm(e){let t=typeof e;return t===`string`?Fp(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`[\"BigInt\",\"${e}\"]`:String(e)}var gm=new Map,_m=new Map;function vm(e,t){gm.set(e,t),_m.set(t,e)}function ym(e){let t=Object.getPrototypeOf(e);return t===null?void 0:_m.get(t.constructor)}var bm=`c:`,xm=`E:`,Sm=`S`,Cm=`K`,wm=new Map([Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,globalThis.AggregateError].map(e=>[e.prototype,e.name])),Tm=new Map([...wm].map(([e,t])=>[t,e.constructor])),Em=[`message`,`cause`,`errors`],Dm=e=>typeof e==`object`&&!!e,Om=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})};function km(e){let t={};if(e instanceof Error)for(let n of Em)G(e,n)&&Om(t,n,e[n]);for(let n of Object.keys(e))Om(t,n,e[n]);return t}function Am(e){for(let t of Em)G(e,t)&&Object.defineProperty(e,t,{enumerable:!1})}var jm=e=>e.length===1&&JSON.stringify(e).length>3;function Mm(){let e={};for(let[t,n]of gm)e[bm+t]=e=>Dm(e)&&Object.getPrototypeOf(e)===n.prototype&&km(e);for(let[t,n]of wm)e[xm+n]=e=>Dm(e)&&Object.getPrototypeOf(e)===t&&km(e);return e[Sm]=e=>{if(typeof e!=`symbol`)return!1;let t=Symbol.keyFor(e);return t!==void 0&&[t]},e[Cm]=e=>{if(!Dm(e)||Object.getPrototypeOf(e)!==Object.prototype)return!1;let t=Object.keys(e);if(!t.some(jm))return!1;if(t.includes(`__proto__`))throw TypeError(`spindle: Cannot save a property named \"__proto__\"`);return t.flatMap(t=>[t,e[t]])},e}function Nm(e){return t=>{if(!Dm(t)||Object.getPrototypeOf(t)!==Object.prototype){if(Dm(t)&&ym(t)===e)return t;throw TypeError(`spindle: Malformed data for class \"${e}\"`)}let n=gm.get(e);if(!n)throw TypeError(`spindle: The save holds an instance of class \"${e}\", which is not registered`);return Object.setPrototypeOf(t,n.prototype),t instanceof Error&&Am(t),t}}function Pm(e){let t=Tm.get(e);if(t)return n=>{if(Object.getPrototypeOf(n)===t.prototype)return n;if(!Dm(n)||Object.getPrototypeOf(n)!==Object.prototype)throw TypeError(`spindle: Malformed data for \"${e}\"`);return Object.setPrototypeOf(n,t.prototype),Am(n),n}}var Fm=new WeakMap;function Im(e){if(!Array.isArray(e)||e.length%2!=0)throw TypeError(`spindle: Malformed object entries`);let t=Fm.get(e);t||Fm.set(e,t={});for(let n=0;n<e.length&&G(e,n);n+=2){let r=e[n];if(typeof r!=`string`||r===`__proto__`)throw TypeError(`spindle: Malformed object entries`);Om(t,r,G(e,n+1)?e[n+1]:void 0)}return t}var Lm=new Proxy({},{getOwnPropertyDescriptor(e,t){let n=Rm(t);return n&&{value:n,enumerable:!0,configurable:!0}},get:(e,t)=>Rm(t)});function Rm(e){if(typeof e==`string`){if(e===Sm)return e=>{if(!Array.isArray(e)||typeof e[0]!=`string`)throw TypeError(`spindle: Malformed symbol`);return Symbol.for(e[0])};if(e===Cm)return Im;if(e.startsWith(bm))return Nm(e.slice(2));if(e.startsWith(xm))return Pm(e.slice(2))}}function zm(e,t){if(!(e instanceof Error)||e.name!==`DevalueError`)return e instanceof Error?e:Error(String(e));let{path:n,value:r}=e,i=n?` (at ${n})`:``,a=e.message;return typeof r==`function`?a=`Cannot save a function`:Dm(r)&&/non-POJO/.test(e.message)?a=`Cannot save an instance of class \"${Object.getPrototypeOf(r)?.constructor?.name??`?`}\", which is not registered (see Story.registerClass)`:typeof r==`symbol`?a=`Cannot save a unique symbol (only Symbol.for() symbols)`:/symbolic keys/.test(e.message)?a=`Cannot save an object with symbol keys`:/__proto__/.test(e.message)&&(a=`Cannot save a property named \"__proto__\"`),TypeError(`spindle: ${a}${i}`)}function Bm(e){try{return pm(e,Mm())}catch(t){throw zm(t,e)}}function Vm(e){return dm(e,Lm)}var Hm=class extends Error{constructor(){super(`This save was made by an incompatible version of Spindle`),this.name=`IncompatibleSaveError`}},Um={};function Wm(e){if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>1)throw new Hm}function Gm(e,t){Wm(e);let n=t;for(let t=e;t<1;t++){let e=Um[t];if(!e)throw new Hm;n=e(n)}return n}var Km=e=>e&&new Map(Object.entries(e));function qm(e){if(!(e instanceof TypeError))return e;let t=e.message.replace(/\\(at \\.variables(?=[.[]|\\))/,`(at $`).replace(/\\(at \\.history\\[(\\d+)\\]\\.variables(.*)\\)$/,(e,t,n)=>`(at $${n} in history moment ${t})`).replace(/\\(at \\$\\.?/,`(at $`);return t===e.message?e:TypeError(t)}function Jm(e){try{return{formatVersion:1,data:Bm({...e,visitCounts:Km(e.visitCounts),renderCounts:Km(e.renderCounts)})}}catch(e){throw qm(e)}}var Ym=()=>Error(`Invalid save data`);function Xm(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Zm(e){return e==null?!0:Xm(e)&&typeof e.seed==`string`&&typeof e.pull==`number`&&Number.isInteger(e.pull)&&e.pull>=0}var Qm=e=>Xm(e)&&typeof e.passage==`string`&&Xm(e.variables)&&typeof e.timestamp==`number`&&Zm(e.prng),$m=e=>e===void 0||e instanceof Map&&[...e.keys()].every(e=>typeof e==`string`);function eh(e){if(!Xm(e)||typeof e.passage!=`string`||!Xm(e.variables))return!1;let{history:t,historyIndex:n}=e;return!Array.isArray(t)||t.length===0||!Array.from(t).every(Qm)||typeof n!=`number`||!Number.isInteger(n)||n<0||n>=t.length||t[n].passage!==e.passage?!1:$m(e.visitCounts)&&$m(e.renderCounts)&&Zm(e.prng)}var th=e=>e instanceof Map?Ps(Object.fromEntries(e)):void 0;function nh(e){if(typeof e!=`object`||!e)throw Ym();let{formatVersion:t,data:n}=e;if(Wm(t),typeof n!=`string`)throw Ym();let r=Vm(Gm(t,n));if(!eh(r))throw Ym();let i={...r,visitCounts:th(r.visitCounts),renderCounts:th(r.renderCounts)};return i.visitCounts===void 0&&delete i.visitCounts,i.renderCounts===void 0&&delete i.renderCounts,i}var rh=`Invalid save file format`;function ih(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ah=[`id`,`passage`,`ifid`,`playthroughId`,`createdAt`,`updatedAt`,`title`];function oh(e){let t=console.warn;console.warn=()=>{};try{nh(e)}finally{console.warn=t}}function sh(e){if(!ih(e))throw Error(rh);if(!G(e,`formatVersion`))throw e.version===1?new Hm:Error(rh);if(Wm(e.formatVersion),typeof e.ifid!=`string`)throw Error(rh);let t=e.save;if(!ih(t)||!ih(t.meta))throw Error(rh);let n=t.meta;if(ah.some(e=>typeof n[e]!=`string`))throw Error(rh);try{oh(t.payload)}catch(e){throw e instanceof Hm?e:Error(rh)}}function ch(e){try{return sh(e),!0}catch{return!1}}function lh(e){return JSON.stringify(e).length}function uh(e){return{saves:e(`saves`,{ifid:e=>e.meta.ifid,playthroughId:e=>e.meta.playthroughId}),playthroughs:e(`playthroughs`,{ifid:e=>e.ifid}),meta:e(`meta`,{})}}function dh(e,{saves:t,playthroughs:n,meta:r},i){async function a(e,t,n,r){let i=(await e.find(n,r)).map(t);for(let t of i)await e.delete(t);return i}async function o(e){for(let t of await r.keys())e(t)&&await r.delete(t)}let s=e=>e.meta.id,c=e=>e.id;return{type:e,putSave:e=>t.put(e.meta.id,e),getSave:e=>t.get(e),deleteSave:e=>t.delete(e),getSavesByIfid:e=>t.find(`ifid`,e),deleteSavesByIfid:async e=>{await a(t,s,`ifid`,e)},deleteSavesByPlaythrough:e=>a(t,s,`playthroughId`,e),putPlaythrough:e=>n.put(e.id,e),getPlaythroughsByIfid:e=>n.find(`ifid`,e),deletePlaythroughsByIfid:async e=>{await a(n,c,`ifid`,e)},deletePlaythroughById:e=>n.delete(e),getMeta:e=>r.get(e),setMeta:(e,t)=>r.put(e,t),deleteMeta:e=>r.delete(e),deleteMetaByPrefix:e=>o(t=>t.startsWith(e)),deleteMetaByIfid:e=>o(t=>t.includes(e)),getAllMetaKeys:()=>r.keys(),destroy:i}}function fh(){let e=e=>structuredClone(e),t=[];function n(n,r){let i=new Map;return t.push(i),{get:async t=>e(i.get(t)),put:async(t,n)=>{i.set(t,e(n))},delete:async e=>{i.delete(e)},find:async(t,n)=>[...i.values()].filter(e=>r[t](e)===n).map(e),keys:async()=>[...i.keys()]}}return dh(`memory`,uh(n),async()=>{for(let e of t)e.clear()})}var ph={saves:`spindle.save.`,playthroughs:`spindle.pt.`,meta:`spindle.meta.`},mh={\"saves.ifid\":`spindle.idx.saves.`,\"saves.playthroughId\":`spindle.idx.saves-pt.`,\"playthroughs.ifid\":`spindle.idx.pt.`};function hh(e){let t=localStorage.getItem(e);if(t!==null)try{return JSON.parse(t)}catch{return}}function gh(e,t){localStorage.setItem(e,JSON.stringify(t))}function _h(e){localStorage.removeItem(e)}function vh(e){return hh(e)??[]}function yh(e,t){let n=vh(e);n.includes(t)||(n.push(t),gh(e,n))}function bh(e,t){let n=vh(e).filter(e=>e!==t);n.length>0?gh(e,n):_h(e)}var xh=e=>Object.keys(localStorage).filter(t=>t.startsWith(e));function Sh(){function e(e,t){let n=ph[e],r=Object.entries(t).map(([t,n])=>({field:t,read:n,prefix:mh[`${e}.${t}`]})),i=e=>r.map(t=>`${t.prefix}${t.read(e)}`);return{get:async e=>hh(`${n}${e}`),async put(e,t){let r=hh(`${n}${e}`),a=i(t);if(r!==void 0)for(let t of i(r))a.includes(t)||bh(t,e);gh(`${n}${e}`,t);for(let t of a)yh(t,e)},async delete(e){let t=hh(`${n}${e}`);if(t!==void 0)for(let n of i(t))bh(n,e);_h(`${n}${e}`)},async find(e,t){let i=r.find(t=>t.field===e),a=[];for(let e of vh(`${i.prefix}${t}`)){let t=hh(`${n}${e}`);t!==void 0&&a.push(t)}return a},keys:async()=>xh(n).map(e=>e.slice(n.length))}}return dh(`localstorage`,uh(e),async()=>{for(let e of xh(`spindle.`))_h(e)})}var Ch=`spindle`,wh=1,Th={saves:{keyPath:`meta.id`,indexes:{ifid:`meta.ifid`,playthroughId:`meta.playthroughId`}},playthroughs:{keyPath:`id`,indexes:{ifid:`ifid`}},meta:{keyPath:`key`,indexes:{}}};function Eh(){let e=null;function t(){return e||(e=new Promise((e,t)=>{let n=indexedDB.open(Ch,wh);n.onupgradeneeded=()=>{let e=n.result;for(let[t,{keyPath:n,indexes:r}]of Object.entries(Th)){if(e.objectStoreNames.contains(t))continue;let i=e.createObjectStore(t,{keyPath:n});for(let[e,t]of Object.entries(r))i.createIndex(e,t,{unique:!1})}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}),e)}function n(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function r(e){let r=e===`meta`,i=async(r,i)=>n(i((await t()).transaction(e,r).objectStore(e)));return{async get(e){let t=await i(`readonly`,t=>t.get(e));return r?t?.value:t},async put(e,t){await i(`readwrite`,n=>n.put(r?{key:e,value:t}:t))},async delete(e){await i(`readwrite`,t=>t.delete(e))},async find(e,t){return await i(`readonly`,n=>n.index(e).getAll(t))??[]},keys:async()=>await i(`readonly`,e=>e.getAllKeys())}}return dh(`indexeddb`,uh(r),async()=>{(await t()).close(),e=null,await new Promise((e,t)=>{let n=indexedDB.deleteDatabase(Ch);n.onsuccess=()=>e(),n.onerror=()=>t(n.error)})})}var Dh=null;async function Oh(){if(typeof indexedDB<`u`)try{return await new Promise((e,t)=>{let n=indexedDB.open(`__spindle_probe__`,1);n.onsuccess=()=>{n.result.close(),indexedDB.deleteDatabase(`__spindle_probe__`),e()},n.onerror=()=>t(n.error)}),Eh()}catch{}if(typeof localStorage<`u`)try{let e=`__spindle_probe__`;localStorage.setItem(e,`1`);let t=localStorage.getItem(e);if(localStorage.removeItem(e),t===`1`)return Sh()}catch{}return fh()}var kh=null;function Z(){if(Dh)return Promise.resolve(Dh);if(!kh){let e=Oh().then(t=>(kh===e&&(Dh=t),t));kh=e}return kh}function Ah(){Dh=null,kh=null}function jh(){return Dh?.type??`memory`}var Mh=e=>Object.prototype.toString.call(e).slice(8,-1),Nh=e=>Mh(e).startsWith(`Temporal.`),Ph=e=>e instanceof Number||e instanceof String||e instanceof Boolean||Mh(e)===`BigInt`;function Fh(e){return e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof URL||e instanceof URLSearchParams||e instanceof Error||Ph(e)||Nh(e)}function Ih(e){if(!Fh(e))return;let t=e instanceof Error?`Error`:Mh(e);return`${/^[AEIOU]/.test(t)?`an`:`a`} ${t}`}function Lh(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n||e in Object.prototype&&!G(n,e))return;n=n[e]}return n}var Rh=e=>e===`length`||/^(0|[1-9]\\d*)$/.test(e),zh=Ih;function Bh(e){let t=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));for(let n of Object.keys(e))Object.defineProperty(t,n,{value:e[n],enumerable:!0,writable:!0,configurable:!0});return t}function Vh(e,t,n,r={}){let i=Gh(e,t,r.createMissing??!1);i[t[t.length-1]]=n}function Hh(e,t){let n=t[t.length-1];Uh(t);let r=e;for(let e of t.slice(0,-1)){if(typeof r!=`object`||!r||!G(r,e))return;r=r[e]}if(typeof r!=`object`||!r||!G(r,n))return;let i=Gh(e,t,!1);if(Array.isArray(i)&&jt(i)&&t.length>1){let r=Ln(i).slice();delete r[Number(n)];let a=Gh(e,t.slice(0,-1),!1);a[t[t.length-2]]=r;return}delete i[n]}function Uh(e){if(e.includes(`__proto__`))throw TypeError(`spindle: Cannot use \"__proto__\" in a variable path (\"${e.join(`.`)}\")`)}function Wh(e,t,n,r){let i=zh(e)??(Array.isArray(e)&&!Rh(t)?`an array`:``);if(i)throw TypeError(`spindle: Cannot set property \"${t}\" on ${i} (at \"${n.slice(0,r).join(`.`)}\")`)}function Gh(e,t,n){Uh(t);let r=jt(e),i=e;for(let e=0;e<t.length-1;e++){let a=t[e];Wh(i,a,t,e);let o=G(i,a)?i[a]:void 0;if(typeof o!=`object`||!o){if(!n)throw TypeError(`spindle: Cannot set property \"${t[e+1]}\" on ${o===null?`null`:typeof o} (at \"${t.slice(0,e+1).join(`.`)}\")`);o={},i[a]=o}else r&&!jt(o)&&!zh(o)&&(o=Bh(o),i[a]=o);i=o}return Wh(i,t[t.length-1],t,t.length-1),i}function Kh(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var qh=[`message`,`cause`,`errors`];function Jh(e,t={}){let n=new Map,r=(e,t)=>(n.set(e,t),t);function i(e,t){for(let n of Object.keys(e))Ts(t,n,o(e[n]));return t}function a(e){if(e instanceof Date)return r(e,new Date(e.getTime()));if(e instanceof RegExp)return r(e,new RegExp(e.source,e.flags));if(e instanceof ArrayBuffer)return r(e,e.slice(0));if(ArrayBuffer.isView(e)){let t=o(e.buffer);if(e instanceof DataView)return r(e,new DataView(t,e.byteOffset,e.byteLength));let n=e.constructor,i=e.length;return r(e,new n(t,e.byteOffset,i))}if(e instanceof URL)return r(e,new URL(e.href));if(e instanceof URLSearchParams)return r(e,new URLSearchParams(e));if(Ph(e))return r(e,Object(e.valueOf()));if(Nh(e))return e;if(e instanceof Error){let t=r(e,Object.create(Object.getPrototypeOf(e)));for(let n of[...qh,`stack`])G(e,n)&&Object.defineProperty(t,n,{value:o(e[n]),writable:!0,configurable:!0});return i(e,t)}}function o(e){if(typeof e!=`object`||!e)return e;let s=e;if(n.has(s))return n.get(s);if(Array.isArray(e)){let t=r(s,Array(e.length));for(let n=0;n<e.length;n++)n in e&&(t[n]=o(e[n]));return t}if(e instanceof Map){let t=r(s,new Map);for(let[n,r]of e)t.set(o(n),o(r));return t}if(e instanceof Set){let t=r(s,new Set);for(let n of e)t.add(o(n));return t}let c=a(s);if(c!==void 0)return c;let l=ym(s)!==void 0||Kh(e);return!l&&t.keepUnregistered?e:i(s,r(s,l?Object.create(Object.getPrototypeOf(s)):{}))}return o(e)}function Yh(e,t){return ig(e,t,Xh())}function Xh(){let e=new Map;return(t,n)=>{let r=e.get(t);if(r?.has(n))return!0;r?r.add(n):e.set(t,new Set([n]))}}function Zh(){let e=new Map,t=new Map,n=(n,r)=>{let i=e.get(n);if(i!==void 0)return i===r;if(t.has(r))return!1;e.set(n,r),t.set(r,n)};return n.strict=!0,n}function Qh(e,t){return ig(e,t,Zh())}function $h(e,t){let n=new Map;function r(e,t){if(e===t||!eg(t)||!eg(e))return t;if(n.has(t))return n.get(t);if(Qh(e,t))return n.set(t,e),e;if(t instanceof Map&&e instanceof Map){let i=new Map;n.set(t,i);for(let[n,a]of t)i.set(n,e.has(n)?r(e.get(n),a):a);return i}if(Array.isArray(t)&&Array.isArray(e)){let i=Array(t.length);n.set(t,i);for(let n=0;n<t.length;n++)n in t&&(i[n]=n<e.length?r(e[n],t[n]):t[n]);return i}if(og(e,t,!1)){let i=Object.create(Object.getPrototypeOf(t));n.set(t,i);let a=t;for(let t of Object.keys(a))Ts(i,t,G(e,t)?r(e[t],a[t]):a[t]);return i}return n.set(t,t),t}return r(e,t)}var eg=e=>typeof e==`object`&&!!e;function tg(e,t){let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function ng(e,t,n){if(e instanceof Date)return Object.is(e.getTime(),t.getTime());if(e instanceof RegExp)return String(e)===String(t);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return tg(e,t);if(e instanceof URL||e instanceof URLSearchParams)return String(e)===String(t);if(Ph(e))return Object.is(e.valueOf(),t.valueOf());if(Nh(e))return String(e)===String(t);if(e instanceof Error)return qh.every(r=>G(e,r)===G(t,r)&&ig(e[r],t[r],n))&&rg(e,t,n)}function rg(e,t,n){let r=e,i=t,a=Object.keys(r);if(a.length!==Object.keys(i).length)return!1;for(let e of a)if(!G(i,e)||!ig(r[e],i[e],n))return!1;return!0}function ig(e,t,n){if(Object.is(e,t)&&!(n.strict&&eg(e)))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=n(e,t);if(r!==void 0)return r;if(e instanceof Map||e instanceof Set){let r=t;if(e.size!==r.size)return!1;let i=e.entries(),a=r.entries();for(let e=i.next(),t=a.next();!e.done;e=i.next(),t=a.next())if(!ig(e.value,t.value,n))return!1;return!0}let i=ng(e,t,n);if(i!==void 0)return i;if(Array.isArray(e)){let r=t;if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(t in e!=t in r||!ig(e[t],r[t],n))return!1;return!0}return rg(e,t,n)}function ag(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!Fh(e)}function og(e,t,n){return n&&(Array.isArray(e)||Array.isArray(t))?Array.isArray(e)&&Array.isArray(t):ag(e)&&ag(t)&&Object.getPrototypeOf(e)===Object.getPrototypeOf(t)}function sg(e,t,n){let r=[],i=(e,t,i)=>{Object.is(t,i)||(og(t,i,n)?r.push({key:e,kind:`nested`,before:t,after:i}):Yh(t,i)||r.push({key:e,kind:`changed`,after:i}))};if(Array.isArray(t)){let n=e,a=t;for(let e=0;e<Math.min(n.length,a.length);e++)i(String(e),n[e],a[e]);for(let e=n.length;e<a.length;e++)r.push({key:String(e),kind:`added`,after:a[e]});for(let e=a.length;e<n.length;e++)r.push({key:String(e),kind:`deleted`});return r}for(let n of Object.keys(t))G(e,n)?i(n,e[n],t[n]):r.push({key:n,kind:`added`,after:t[n]});for(let n of Object.keys(e))G(t,n)||r.push({key:n,kind:`deleted`});return r}function cg(e,t){let n=[],r=new Set;return(function e(t,i,a){if(!r.has(i)){r.add(i);for(let r of sg(t,i,!1)){let t=[...a,r.key];r.kind===`nested`?e(r.before,r.after,t):n.push(r.kind===`deleted`?{path:t,deleted:!0}:{path:t,deleted:!1,value:r.after})}r.delete(i)}})(e,t,[]),n}function lg(e,t){let n=Lh(e,t.path.slice(0,-1));if(typeof n!=`object`||!n)return t.deleted;let r=t.path[t.path.length-1];return G(n,r)?!t.deleted&&Yh(n[r],t.value):t.deleted}function ug(e,t){t.deleted?Hh(e,t.path):Vh(e,t.path,t.value)}function dg(e,t,n,r){let i=Array.isArray(e)?e:void 0;for(let a of sg(t,n,!0)){let{key:t}=a;if(a.kind===`deleted`)i?i.length=Math.min(i.length,Number(t)):delete e[t];else if(i&&a.kind===`added`)i.push(Jh(a.after));else if(i&&Number(t)>=i.length)continue;else (a.kind!==`nested`||!(r?.(t,a.before,a.after)||Yh(a.before,a.after)))&&(e[t]=Jh(a.after))}}var fg=new Set([`storyinit`,`beforerestart`,`actionsChanged`,`variableChanged`,`beforesave`,`aftersave`,`beforeload`,`afterload`,`beforenavigate`,`afternavigate`,`passagerender`,`dialogrender`]),pg=new Map;function mg(e,t){if(!fg.has(e))throw Error(`spindle: Unknown event \"${e}\".`);let n=pg.get(e);return n||(n=new Set,pg.set(e,n)),n.add(t),()=>{n.delete(t)}}function hg(e,t){let n=pg.get(e);if(n)for(let e of[...n])t(e)}function gg(e,...t){hg(e,e=>e(...t))}function _g(e,...t){hg(e,n=>{try{n(...t)}catch(t){console.error(`spindle: Error in ${e} handler:`,t)}})}var vg=null,yg=null;function bg(e){vg=e}function xg(e){yg=e}function Sg(e){if(yg)try{let t=Function(`passage`,`variables`,yg)(e.passage,e.variables);if(typeof t==`string`&&t.trim())return t.trim()}catch{}if(vg)try{let t=vg(e);if(typeof t==`string`&&t.trim())return t.trim()}catch{}let t=new Date().toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return`${e.passage} - ${t}`}var Cg=Promise.resolve();function wg(e){let t=Cg.then(e);return Cg=t.catch(()=>{}),t}function Tg(e){return(...t)=>wg(()=>e(...t))}var Eg=e=>Tg(async t=>e(await(await Z()).getSave(t))),Dg=e=>Tg(async(t,n)=>e(await i_(t,n))),Og=Tg(kg);async function kg(e,t=crypto.randomUUID()){let n=await Z(),r=await Mg(e),i={id:t,ifid:e,createdAt:new Date().toISOString(),label:`Playthrough ${r}`};return await n.putPlaythrough(i),await n.setMeta(jg(e),r),await n.setMeta(Ng(e),t),t}var Ag=/^Playthrough (\\d+)$/;function jg(e){return`playthroughCount.${e}`}async function Mg(e){let t=await Z(),n=await t.getMeta(jg(e))??0;for(let r of await t.getPlaythroughsByIfid(e)){let e=Ag.exec(r.label);e&&(n=Math.max(n,Number(e[1])))}return n+1}function Ng(e){return`currentPlaythroughId.${e}`}var Pg=Tg(Fg);async function Fg(e,t){let n=await Z();await Ig(e,t,new Date().toISOString());let r=Ng(e);await n.getMeta(r)!==t&&await n.setMeta(r,t)}async function Ig(e,t,n){let r=await Z();(await r.getPlaythroughsByIfid(e)).some(e=>e.id===t)||await r.putPlaythrough({id:t,ifid:e,createdAt:n,label:`Imported`})}function Lg(e){return wg(async()=>({id:await(await Z()).getMeta(Ng(e))??await kg(e),knownSaves:await m_(e)}))}function Rg(e,t,n,r){try{let i=n();return ms(()=>gg(`beforesave`,e,t)),r(i()).then(t=>(ms(()=>gg(`aftersave`,e)),t))}catch(e){return Promise.reject(e)}}function zg(e,t){let n=Jm(t);return{meta:{...e,estimatedBytes:lh(n)},payload:n}}var Bg=Tg(Vg);async function Vg(e,t,n,r={}){let i=new Date().toISOString(),a=zg({id:crypto.randomUUID(),ifid:e,playthroughId:t,createdAt:i,updatedAt:i,title:Sg(n),passage:n.passage,custom:r},n);return await(await Z()).putSave(a),a}var Hg=Tg(Ug);async function Ug(e,t,n,r){let i=await Z(),a=await i.getSave(e);if(!a)return;let o=zg({...a.meta,...r?{playthroughId:r}:{},updatedAt:new Date().toISOString(),title:a.meta.userTitle===!0?a.meta.title:Sg(t),passage:t.passage,...n==null?{}:{custom:{...a.meta.custom,...n}}},t);return await i.putSave(o),o}var Wg=e=>e&&nh(e.payload),Gg=e=>nh(e);Eg(Wg);function Kg(e){return wg(async()=>{let t=await Z(),n=await t.getSave(e);await t.deleteSave(e),n&&await s_(n.meta.ifid,t=>t===e)})}function qg(e,t){return wg(async()=>{let n=await Z(),r=await n.getSave(e);if(!r)return;let i={...r,meta:{...r.meta,title:t,userTitle:!0,updatedAt:new Date().toISOString()}};await n.putSave(i)})}var Jg=Tg(async function(e){let t=await Z(),[n,r]=await Promise.all([t.getSavesByIfid(e),t.getPlaythroughsByIfid(e)]),i=new Map;for(let e of r)i.set(e.id,e);let a=new Map;for(let e of n){let t=e.meta.playthroughId,n=a.get(t);n?n.push(e):a.set(t,[e])}for(let e of a.values())e.sort((e,t)=>new Date(t.meta.updatedAt).getTime()-new Date(e.meta.updatedAt).getTime());let o=[],s=[...i.values()].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());for(let e of s){let t=a.get(e.id)??[];o.push({playthrough:e,saves:t})}for(let[t,n]of a)i.has(t)||o.push({playthrough:{id:t,ifid:e,createdAt:n[0]?.meta.createdAt??new Date().toISOString(),label:`Unknown Playthrough`},saves:n});return o}),Yg=`autosave.`,Xg=`slot.`,Zg=`slotIndex.`;function Qg(e){return e!=null&&e!==``}function $g(e,t){return Qg(t)?`${Xg}${t}.${e}`:`${Yg}${e}`}var e_=e=>`${Zg}${e}`;async function t_(e,t){let n=await Z(),r=await n.getMeta(e_(e))??[],i=t(r);i!==r&&await n.setMeta(e_(e),i)}async function n_(e){return[void 0,...(await(await Z()).getMeta(e_(e))??[]).filter(Qg)]}async function r_(e,t){return(await Z()).getMeta($g(e,t))}async function i_(e,t){let n=await r_(e,t);return n?(await Z()).getSave(n):void 0}async function a_(e,t,n){await(await Z()).setMeta($g(e,t),n),Qg(t)&&await t_(e,e=>e.includes(t)?e:[...e,t])}async function o_(e,t){await(await Z()).deleteMeta($g(e,t)),Qg(t)&&await t_(e,e=>e.filter(e=>e!==t))}async function s_(e,t){for(let n of await n_(e)){let r=await r_(e,n);r&&t(r)&&await o_(e,n)}}var c_=e=>({isAutosave:!Qg(e),...Qg(e)?{slot:e}:{}});function l_(e,t){return{slot:Qg(t)?t:``,title:e.meta.title,passage:e.meta.passage,createdAt:e.meta.createdAt,updatedAt:e.meta.updatedAt,custom:e.meta.custom??{}}}function u_(e,t,n,r,i){return wg(async()=>{let a=await t,o=await r_(e,r);if(o){let e=await Ug(o,n,i,a);if(e)return e}let s=await Vg(e,a,n,{...c_(r),...i});return await a_(e,r,s.meta.id),s})}async function d_(e,t){return await i_(e,t)!==void 0}Dg(Wg);function f_(e,t){return wg(async()=>{let n=await i_(e,t);if(!n)return;let r=nh(n.payload),{playthroughId:i}=n.meta;return i&&await Fg(e,i),{payload:r,playthroughId:i}})}var p_=Tg(m_);async function m_(e){let t=Object.create(null);for(let n of await n_(e))await d_(e,n)&&(t[n??``]=!0);return t}var h_=Tg(g_);async function g_(e,t){let n=await i_(e,t);return n?l_(n,t):null}var __=Tg(async e=>{let t=[];for(let n of await n_(e)){let r=await g_(e,n);r&&t.push(r)}return t}),v_=Tg(async(e,t)=>{let n=await r_(e,t);n&&(await(await Z()).deleteSave(n),await o_(e,t))}),y_=`spindle.session.`;function b_(e,t){let n=JSON.stringify(Jm(t));try{sessionStorage.setItem(`${y_}${e}`,n)}catch{}}function x_(e){try{let t=sessionStorage.getItem(`${y_}${e}`);return t?nh(JSON.parse(t)):void 0}catch(t){t instanceof Hm&&(console.warn(`spindle: ${t.message}; the session was not restored.`),S_(e));return}}function S_(e){try{sessionStorage.removeItem(`${y_}${e}`)}catch{}}function C_(e){if(e)return{formatVersion:1,ifid:e.meta.ifid,exportedAt:new Date().toISOString(),save:e}}var w_=Eg(C_);async function T_(e,t){if(sh(e),e.ifid!==t)throw Error(`Save is from a different story (expected IFID ${t}, got ${e.ifid})`);let n=Jh(e.save);return n.meta.id=crypto.randomUUID(),n.meta.updatedAt=new Date().toISOString(),n.meta.ifid=t,await Ig(t,n.meta.playthroughId,n.meta.createdAt),n}function E_(e,t){return wg(async()=>{let n=await T_(e,t);return await(await Z()).putSave(n),n})}var D_=Dg(C_);function O_(e,t,n){return wg(async()=>{let r=await T_(e,t),{slot:i,...a}=r.meta.custom??{};r.meta.custom={...a,...c_(n)};let o=await Z(),s=await r_(t,n);return await o.putSave(r),await a_(t,n,r.meta.id),s&&await o.deleteSave(s),l_(r,n)})}var k_=Tg(async function(e){let t=await Z(),n=await t.getSavesByIfid(e),r=await t.getPlaythroughsByIfid(e),i=0;for(let e of n)if(e.meta.estimatedBytes!=null)i+=e.meta.estimatedBytes;else{let n=lh(e.payload);e.meta.estimatedBytes=n,await t.putSave(e),i+=n}return{saveCount:n.length,playthroughCount:r.length,totalBytes:i,backend:t.type}});function A_(e){return wg(async()=>{let t=await Z();await t.deleteSavesByIfid(e),await t.deletePlaythroughsByIfid(e),await t.deleteMetaByIfid(e),S_(e)})}var j_=Tg(M_);async function M_(){if(await(await Z()).destroy(),Ah(),typeof sessionStorage<`u`){let e=[];for(let t=0;t<sessionStorage.length;t++){let n=sessionStorage.key(t);n?.startsWith(`spindle.session.`)&&e.push(n)}for(let t of e)sessionStorage.removeItem(t)}}function N_(e,t,n){return wg(async()=>{let r=await Z(),i=await r.deleteSavesByPlaythrough(t);await r.deletePlaythroughById(t);let a=new Set(i);if(await s_(e,e=>a.has(e)),n&&await n.current===t)return await kg(e,n.id),!0;let o=Ng(e);return await r.getMeta(o)===t&&await r.deleteMeta(o),!1})}var P_=null;function F_(){P_&&(ge(null,P_),P_.remove(),P_=null)}function I_(){F_();let e=Q.getState();if(!e.storyData)return;let t=e.storyData.passages.get(`StoryInit`);if(t){let e=qo(t.content),n=document.createElement(`div`);n.style.display=`none`,document.body.appendChild(n),P_=n,ge(b(()=>Cp(e),null),n),fy()}let n=e.storyData.passages.get(`SaveTitle`);n&&xg(n.content)}function L_(e){I_(),e&&Q.getState().loadFromPayload(e),gg(`storyinit`),e||fy()}var R_=[`variables`,`temporary`,`transient`],z_=[];function B_(){return z_[z_.length-1]?.work}function V_(){let e=Q.getState(),t=B_();return t?{...e,...t}:e}var H_=e=>Jh(e,{keepUnregistered:!0});function U_(e){return en(H_(e),!0)}function W_(e,t,n,r=z_){let i=n.path[0];for(let a of r)for(let r of[a.work[t],a.base[t]])try{ug(r,n.deleted?n:{...n,value:H_(n.value)})}catch{let n=e[t][i];G(e[t],i)?r[i]=H_(jt(n)?Ln(n):n):delete r[i]}}var G_=new Set(R_),K_=new Fn({autoFreeze:!1}),q_=!1;function J_(e,t){let n=[],r=e;for(let e of t){if(!ag(r))break;let t=String(e);n.push(t),r=G(r,t)?r[t]:void 0}return n}function Y_(e,t){let n=Lh(e,t.slice(0,-1)),r=t[t.length-1];return ag(n)&&G(n,r)?{path:t,deleted:!1,value:n[r]}:{path:t,deleted:!0}}function X_(e,t,n){if(n.some(e=>e.path.length===1))return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>!G(e,n)||e[n]!==t[n]).map(e=>Y_(t,[e]));let r=new Set,i=[];for(let e of n){let n=J_(t,e.path.slice(1)),a=JSON.stringify(n);r.has(a)||(r.add(a),i.push(Y_(t,n)))}return i}function Z_(e){if(q_){q_=!1;return}if(z_.length===0)return;$_(ev());let t=z_[z_.length-1],n={...Q.getState(),variables:t.work.variables,temporary:t.work.temporary,transient:t.work.transient},[r,i]=K_.produceWithPatches(n,e),a=R_.map(e=>{let t=i.filter(t=>t.path[0]===e);return[e,t.length?X_(n[e],r[e],t):[]]}),o=e=>e.deleted?e:{...e,value:H_(e.value)};for(let[e,n]of a)for(let r of n)ug(t.work[e],o(r));return e=>{let i=e;for(let e of Object.keys(r)){let t=r[e];!G_.has(e)&&t!==n[e]&&(i[e]=t)}let s=e;for(let[e,n]of a)for(let r of n){let n=r.path[0];try{ug(s[e],o(r))}catch{G(t.work[e],n)?s[e][n]=H_(t.work[e][n]):delete s[e][n]}W_(s,e,r)}}}var Q_=e=>({variables:Jh(e.variables),temporary:Jh(e.temporary),transient:Jh(e.transient)});function $_(e){let t=e.map(({scope:e,keepRunning:t})=>({scope:e,keepRunning:t,changes:R_.map(t=>[t,cg(e.base[t],e.work[t])])})),n=t.filter(({changes:e})=>e.some(([,e])=>e.length>0));if(n.length===0)return;for(let{scope:e,keepRunning:t}of n)t&&(e.base=Q_(e.work));q_=!0;try{Q.getState().updateVariables(r)}finally{q_=!1}function r(e){t.forEach(({scope:n,keepRunning:r,changes:i},a)=>{let o=e=>r?H_(e):e;for(let[r,s]of i){let i=new Set;for(let t of s){let a=t.path[0];if(!(i.has(a)||lg(e[r],t)))try{ug(e[r],t.deleted?t:{...t,value:o(t.value)})}catch{e[r][a]=o(n.work[r][a]),i.add(a)}}let c=t.slice(0,a).map(e=>e.scope);for(let t of s)W_(e,r,t,c)}})}}var ev=()=>z_.map(e=>({scope:e,keepRunning:!0}));function tv(e){let t=Q.getState();for(let n of R_)dg(e.work[n],e.work[n],t[n]);e.base=Q_(t)}function nv(e){if(z_.length===0)return e();$_(ev());let t=z_.splice(0);try{return e()}finally{z_.push(...t);for(let e of t)tv(e)}}function rv(e,t,n){let r=B_()??Q.getState(),i={work:Q_(r),base:Q_(r)},a=Os(Jh(t,{keepUnregistered:!0}));z_.push(i);try{ec(e,i.work.variables,i.work.temporary,a,i.work.transient)}finally{z_.pop()}$_([...ev(),{scope:i,keepRunning:!1}]);for(let e of Object.keys(a))Yh(a[e],t[e])||n(e,a[e]);for(let e of Object.keys(t))G(a,e)||n(e,void 0)}var iv=[],av=!1,ov=[],sv=null,cv=null;function lv(e){let t=V_();try{return!!$s(e,t.variables,t.temporary,{},t.transient)}catch{return!1}}function uv(e,t,n){let r=typeof t==`function`,i=r?void 0:t,a=r?t:void 0,o={name:i?.name,condition:e,callback:a,options:i,lastResult:lv(e),priority:i?.priority??0,macroKey:n};return iv.push(o),iv.sort((e,t)=>t.priority-e.priority),()=>{iv=iv.filter(e=>e!==o)}}function dv(e,t){return uv(e,t)}function fv(e,t){let n=Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:1)),r=JSON.stringify([e,n]);iv.some(e=>e.macroKey===r)||uv(e,t,r)}function pv(e){iv=iv.filter(t=>t.name!==e)}function mv(e){let{callback:t,options:n}=e;if(t){t();return}if(n){if(n.run)try{rv(n.run,{},()=>{})}catch(t){console.error(`spindle: Error in watch run action for \"${e.condition}\":`,t)}n.dialog&&(ov.push({passageName:n.dialog}),sv?.()),n.goto&&Q.getState().navigate(n.goto)}}var hv=10;function gv(){for(let e=0;e<hv;e++){let e=!1,t=[...iv];for(let n of t){if(!iv.includes(n))continue;let t=lv(n.condition),r=!n.lastResult;n.lastResult=t,t&&r&&(e=!0,n.options?.once&&(iv=iv.filter(e=>e!==n)),mv(n))}if(!e)break}}function _v(){if(!av){av=!0;try{gv()}finally{av=!1}}}var vv=0;function yv(){if(vv===0)return;let e=av;av=!0;try{gv()}finally{av=e}}function bv(){let e=Q.getState();vv++;let t=Q.subscribe(t=>{let n=e;e=t,t.navigationId===n.navigationId&&(t.variables===n.variables&&t.temporary===n.temporary&&t.transient===n.transient||_v())}),n=!0;return()=>{n&&(n=!1,vv--,t())}}function xv(){for(let e of iv)e.lastResult=lv(e.condition)}function Sv(){iv=[],ov=[],cv?.closeAll()}function Cv(e){return sv=e,ov.length>0&&e(),()=>{sv===e&&(sv=null)}}function wv(){return ov.shift()}function Tv(){return ov.length}function Ev(e){cv?cv.push(e):(ov.push(e),sv?.())}function Dv(){ov=[]}function Ov(e){return cv=e,()=>{cv===e&&(cv=null)}}function kv(){cv?.close()}function Av(){Dv(),cv?.closeAll()}function jv(){return cv?.isOpen()??!1}var Mv=[],Nv=1,Pv=new Set;function Fv(e){Mv=e;for(let e of Pv)e()}function Iv(e,t){let n=Jc(t).replace(/^spindle: /,``),r=Mv.find(t=>t.context===e&&t.message===n);Fv(r?Mv.map(e=>e===r?{...e,count:e.count+1}:e):[...Mv,{id:Nv++,context:e,message:n,count:1}])}function Lv(e,t){return Error(`No passage named ${JSON.stringify(e)} (in passage ${JSON.stringify(t)})`)}function Rv(e){Fv(Mv.filter(t=>t.id!==e))}function zv(){return Mv}function Bv(e){return Pv.add(e),()=>{Pv.delete(e)}}zn(),Bn();var Vv=new Set([`StoryInit`,`StoryInterface`,`StoryVariables`,`StoryTransients`,`StoryLoading`,`SaveTitle`,`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]),Hv=K(),Uv=[],Wv=K();function Gv(e,t){let n=[];for(let r of Object.keys(e))G(t,r)||n.push({key:r,deleted:!0});for(let r of Object.keys(t))(!G(e,r)||!Object.is(e[r],t[r]))&&n.push({key:r,deleted:!1,value:Jh(t[r],{keepUnregistered:!0})});return{forward:n}}function Kv(e,t){let n=Object.create(Object.getPrototypeOf(e));for(let t of Object.keys(e))Ts(n,t,e[t]);for(let e of t)e.deleted?delete n[e.key]:Ts(n,e.key,e.value);return n}function qv(e){let t=Uv.length-1;t<0?Hv=e:Uv[t]=Gv(Xv(t),e)}function Jv(e,t){let n=Hv;for(let r=0;r<e;r++)r>0&&(n=Kv(n,Uv[r-1].forward)),t(n,r)}function Yv(e,t){return{passage:e.passage,variables:t,timestamp:e.timestamp,prng:e.prng}}function Xv(e){let t=Hv;for(let n=0;n<e;n++)t=Kv(t,Uv[n].forward);return t}var Zv=[];function Qv(e){let{storyData:t,currentPassage:n,variables:r,history:i,historyIndex:a,visitCounts:o,renderCounts:s}=e();if(t){if(Zv.length>i.length&&(Zv.length=i.length),Zv.length<i.length)if(i.length-Zv.length===1){let e=i.length-1;Zv[e]=Yv(i[e],r)}else Jv(i.length,(e,t)=>{t>=Zv.length&&(Zv[t]=Yv(i[t],e))});b_(t.ifid,{passage:n,variables:r,history:Zv,historyIndex:a,visitCounts:o,renderCounts:s,prng:hs()})}}var $v=`The game could not be saved for a page reload; a reload goes back to the last passage it could save:`,ey=`The story could not go to another passage:`;function ty(e,t){let n;try{Qv(e)}catch(e){n={error:e},Iv($v,e)}try{t?.()}finally{if(n)throw n.error}}function ny(e){let t=e.history.length-e.maxHistory;if(t<=0)return!1;let n=Math.min(e.historyIndex,t),r=n+e.maxHistory;for(let e=0;e<n;e++)Hv=Kv(Hv,Uv[e].forward);return e.history=e.history.slice(n,r),Uv=Uv.slice(n,r-1),Zv=Zv.slice(n,r),e.historyIndex-=n,!0}var ry=!1,iy=[],ay=null;function oy(e,t){let n=ay;if(ay=null,!n||e().navigationId!==n.navigationId)return;e().variables!==n.variables&&qv(e().variables),Wv=e().variables;let r=hs(),i=e().history[e().historyIndex].prng;(r?.seed!==i?.seed||r?.pull!==i?.pull)&&t(e=>{e.history[e.historyIndex].prng=r})}var sy=e=>({...e});function cy(e){Hv=e,Uv=[],Wv=e,Zv=[]}function ly(e){let t=K(Jh(e));return cy(Jh(t)),t}function uy(e,t,n,r){e.currentPassage=t,e.navigationId++,e.variables=n,e.transient=K(Jh(r)),e.temporary=K(),e.history=[{passage:t,timestamp:Date.now()}],e.historyIndex=0}function dy(e,t,n){let{historyIndex:r,history:i}=e(),a=r+n;if(a<0||a>=i.length)return;oy(e,t);let o=e().currentPassage,s=i[a].passage;gg(`beforenavigate`,s);let c=Jh(Xv(a));t(e=>{e.historyIndex+=n,e.currentPassage=e.history[e.historyIndex].passage,e.navigationId++,e.variables=c,e.temporary=K()}),xv(),Wv=e().variables,Ly(e().history[e().historyIndex]),ty(e,()=>gg(`afternavigate`,s,o))}function fy(){let{history:e,historyIndex:t,variables:n}=Q.getState();if(e.length!==1||t!==0)return;cy(n);let r=hs();Q.setState(e=>{e.history[0].prng=r})}var py=Promise.resolve(``),my=0,hy=!1;function gy(){return hy?``:Q.getState().playthroughId}function _y(){let e=gy();return py.then(t=>e||t)}function vy(e){Q.getState().playthroughId!==e&&Q.setState(t=>{t.playthroughId=e})}function yy(e){let t=++my;return hy=!0,py=e.then(e=>(t===my&&(hy=!1,vy(e)),e)),py}function by(e,t){++my,hy=!1,py=t.then(()=>e,()=>e),vy(e)}function xy(e){let t=crypto.randomUUID();by(t,Og(e,t).catch(e=>{console.error(`spindle: failed to start new playthrough`,e)}))}function Sy(e,t){gy()!==t&&by(t,Pg(e,t).catch(e=>{console.error(`spindle: failed to switch to the loaded playthrough`,e)}))}var Cy=0,wy=0,Ty=null;function Ey(){wy=++Cy}var Dy=[],Oy=!1;function ky(e){Oy&&Dy.push(e)}function Ay(){Oy=!0}function jy(){for(let e of Dy)e();Dy=[],Oy=!1}function My(e){return typeof e==`string`&&e!==``?e:null}function Ny(e){let{history:t,historyIndex:n}=e;if(!Number.isInteger(n))return;let r=t[n];if(!(!r||r.passage!==e.passage)&&!(typeof r.variables!=`object`||r.variables===null))return r}function Py(e,t,n){let r=e.history[e.historyIndex];r&&Fy(r.variables,t,n,new Set)}function Fy(e,t,n,r){r.add(n),dg(e,t,n,(t,n,i)=>{if(!G(e,t)||!og(i,e[t],!0)||r.has(i))return!1;let a=Bh(e[t]);return e[t]=a,Fy(a,n,i,r),!0}),r.delete(n)}function Iy(e){e?ds(e.seed,e.pull):ps()}function Ly(e){e&&Iy(e.prng)}var Ry=[`variables`,`temporary`,`transient`];function zy(e){for(let t of Ry){let n=e[t];Ds(n)||(e[t]=K(jt(n)?Ln(n):n))}}var By=[`navigate`,`goBack`,`goForward`,`restart`,`save`,`load`,`getSavePayload`,`loadFromPayload`];function Vy(e){return(t,n,r)=>{let i=((e,n)=>{if(n){t(e,!0);return}let r=typeof e==`function`?e:t=>{Object.assign(t,e)},i=Z_(r);t(e=>{(i??r)(e),zy(e)})});r.setState=i;let a=e(i,n,r);for(let e of By){let t=a[e];a[e]=(...e)=>nv(()=>t(...e))}return a}}var Hy=e=>Hn(Vy(e));function Uy(e){return e.catch(()=>{}),e}function Wy(e,t,n){return Uy(e.catch(e=>{throw console.error(t,e),n?.(e),e}))}function Gy(e,t,n){e(e=>{let r=t??``;if(n)e.knownSaves={...e.knownSaves,[r]:!0};else{let{[r]:t,...n}=e.knownSaves;e.knownSaves=n}})}function Ky(e,t,n,r){let i=n.then(()=>{t(e=>{e.knownSaves={}})});return e().restart(),Wy(i,r)}var Q=yt()(Hy((e,t)=>({storyData:null,currentPassage:``,navigationId:0,variables:K(),variableDefaults:{},transient:K(),transientDefaults:{},temporary:K(),history:[],historyIndex:-1,visitCounts:Ps(),renderCounts:Ps(),knownSaves:{},playthroughId:``,maxHistory:40,quickSaveKey:`F6`,quickLoadKey:`F9`,saveError:null,loadError:null,transitionConfig:null,nextTransition:null,nobr:!1,renderDeferred:!1,setMaxHistory:n=>{let r=!1;e(e=>{e.maxHistory=Math.max(1,Math.round(n)),r=ny(e)}),r&&ty(t)},setQuickSaveKey:t=>{e(e=>{e.quickSaveKey=My(t)})},setQuickLoadKey:t=>{e(e=>{e.quickLoadKey=My(t)})},init:(n,r={},i={})=>{let a=n.passagesById.get(n.startNode);if(!a)throw Error(`spindle: Start passage (pid=${n.startNode}) not found.`);let o=ly(r);e(e=>{e.storyData=n,e.playthroughId=``,e.variableDefaults=r,e.transientDefaults=i,uy(e,a.name,o,i),e.visitCounts=Ps(null,a.name),e.renderCounts=Ps(null,a.name)}),Wv=t().variables,Ey(),yy(Lg(n.ifid).then(({id:t,knownSaves:n})=>(e(e=>{e.knownSaves=n}),t)).catch(e=>(console.error(`spindle: failed to init save system`,e),``)))},navigate:n=>{if(ry){iy.push(n);return}let{storyData:r}=t();if(!r)return;if(Vv.has(n)){console.error(`spindle: Cannot navigate to special passage \"${n}\".`);return}if(!r.passages.has(n)){let e=Lv(n,t().currentPassage);console.error(`spindle: ${e.message}`),Iv(ey,e);return}let i=t().currentPassage;gg(`beforenavigate`,n);let a=Gv(Wv,t().variables);e(e=>{e.temporary=K(),e.currentPassage=n,e.navigationId++,e.history=e.history.slice(0,e.historyIndex+1),Uv.length=e.historyIndex,Zv.length>e.historyIndex+1&&(Zv.length=e.historyIndex+1),Uv.push(a),e.history.push({passage:n,timestamp:Date.now(),prng:hs()}),e.historyIndex=e.history.length-1,ny(e),e.visitCounts=Ps(e.visitCounts,n),e.renderCounts=Ps(e.renderCounts,n)}),ay={navigationId:t().navigationId,variables:t().variables},ry=!0;try{yv()}finally{ry=!1}let o=iy;iy=[],oy(t,e),ty(t,()=>{gg(`afternavigate`,n,i);for(let e of o)t().navigate(e)})},goBack:()=>dy(t,e,-1),goForward:()=>dy(t,e,1),setVariable:(t,n)=>{e(e=>{Cs(t,`$${t}`),e.variables[t]=n})},setTemporary:(t,n)=>{e(e=>{Cs(t,`_${t}`),e.temporary[t]=n})},deleteVariable:t=>{e(e=>{Cs(t,`$${t}`),delete e.variables[t]})},deleteTemporary:t=>{e(e=>{Cs(t,`_${t}`),delete e.temporary[t]})},setTransient:(t,n)=>{e(e=>{Cs(t,`%${t}`),e.transient[t]=n})},deleteTransient:t=>{e(e=>{Cs(t,`%${t}`),delete e.transient[t]})},updateVariables:t=>{e(e=>{t(e)})},trackRender:t=>{e(e=>{e.renderCounts=Ps(e.renderCounts,t)})},restart:()=>{let{storyData:n,variableDefaults:r,transientDefaults:i}=t();if(!n)return;let a=n.passagesById.get(n.startNode);if(!a)return;e(e=>{e.renderDeferred=!1}),gg(`beforerestart`),xy(n.ifid),Ey();let o=t().renderDeferred;jy(),ps(),Sv();let s=ly(r);e(e=>{uy(e,a.name,s,i),e.visitCounts=Ps(null,a.name),e.renderCounts=Ps(null,a.name),o||(e.renderDeferred=!1)}),Wv=t().variables,Ay(),I_(),S_(n.ifid),gg(`storyinit`),fy()},save:(n,r)=>{let{storyData:i}=t();if(!i)return Promise.resolve();let a=_y();return Wy(Rg(n,r,t().beginSave,async t=>{e(e=>{e.saveError=null}),await u_(i.ifid,a,t,n,r),Gy(e,n,!0)}),`spindle: failed to save`,t=>e(e=>{e.saveError=Jc(t,`Failed to save`)}))},load:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();e(e=>{e.loadError=null});let i=_y(),a=f_(r.ifid,n),o=yy(Promise.all([i,a.catch(()=>void 0)]).then(([e,t])=>t?.playthroughId||e)),s=++Cy;return Wy(a.then(async e=>{await o,e&&(wy>s||(Ty=s,t().loadFromPayload(e.payload,n)))}),`spindle: failed to load save`,t=>e(e=>{e.loadError=Jc(t,`Failed to load`)}))},hasSave:e=>{let{storyData:n,knownSaves:r}=t();return n?G(r,e??``):!1},getSaveInfo:async e=>{let{storyData:n}=t();return n?h_(n.ifid,e):null},listSaves:async()=>{let{storyData:e}=t();return e?__(e.ifid):[]},deleteSave:n=>{let{storyData:r}=t();return r?Wy(v_(r.ifid,n).then(()=>Gy(e,n,!1)),`spindle: failed to delete save`):Promise.resolve()},exportSave:async e=>{let{storyData:n}=t();return n?await D_(n.ifid,e)??null:null},importSave:async(n,r)=>{let{storyData:i}=t();if(!i)throw Error(`spindle: Story is not initialized.`);let a=await O_(n,i.ifid,r);return Gy(e,r,!0),a},clearGameData:()=>{let{storyData:n}=t();return n?Ky(t,e,A_(n.ifid),`spindle: failed to clear game data`):Promise.resolve()},clearAllData:()=>Ky(t,e,j_(),`spindle: failed to clear all data`),deletePlaythrough:n=>{let{storyData:r}=t();if(!r)return Promise.resolve();let i=r.ifid,a=gy(),o=py,s=crypto.randomUUID(),c=N_(i,n,{current:a||o,id:s});return n!==``&&n===a?by(s,c):a===``&&yy(c.then(e=>e?s:o,()=>o)),Wy(c.then(async()=>{let t=await p_(r.ifid);e(e=>{e.knownSaves=t})}),`spindle: failed to delete playthrough`)},getSavePayload:()=>{let{currentPassage:e,variables:n,history:r,historyIndex:i,visitCounts:a,renderCounts:o}=t(),s=[];return Jv(r.length,(e,t)=>{let n=sy(e);s.push(Yv(r[t],t===0?n:$h(s[t-1].variables,n)))}),{passage:e,variables:$h(s[i]?.variables,sy(n)),history:s,historyIndex:i,visitCounts:{...a},renderCounts:{...o},prng:hs()}},beginSave:()=>{let e=t().variables;return()=>{let n=t().getSavePayload();return Py(n,e,t().variables),n}},loadFromPayload:(n,r,i)=>{let a=Ty??++Cy;if(Ty=null,n.history.length===0){console.warn(`loadFromPayload: rejecting payload with empty history`);return}wy=a,gg(`beforeload`,r);let o=t().storyData?.ifid;i&&o&&Sy(o,i);let s=Ny(n),c=Jh(n.history.map(e=>e.variables)).map(e=>K(e));Hv=Jh(c[0]),Uv=c.slice(1).map((e,t)=>Gv(c[t],e)),Zv=n.history.map((e,t)=>Yv(e,c[t])),e(e=>{e.currentPassage=n.passage,e.navigationId++,e.variables=K(Jh(s?.variables??n.variables)),e.history=n.history.map(e=>({passage:e.passage,timestamp:e.timestamp,prng:e.prng})),e.historyIndex=Math.max(0,Math.min(n.historyIndex,e.history.length-1)),ny(e),e.visitCounts=Ps(n.visitCounts),e.renderCounts=Ps(n.renderCounts),e.temporary=K(),e.transient=K(Jh(t().transientDefaults))}),xv(),Wv=Xv(t().historyIndex),Iy(s?.prng===void 0?n.prng:s.prng),ty(t,()=>ms(()=>gg(`afterload`,r)))},getHistoryVariables:e=>Jh(Xv(e)),setTransition:t=>{e(e=>{e.transitionConfig=t})},setNextTransition:t=>{e(e=>{e.nextTransition=t})},consumeNextTransition:()=>{let n=t().nextTransition;return n!==null&&e(e=>{e.nextTransition=null}),n},deferRender:()=>{e(e=>{e.renderDeferred=!0})},clearDeferredRender:()=>{e(e=>{e.renderDeferred=!1})}}))),qy=`<header class=\"story-menubar\">{story-title}{back}{forward}{restart}{quicksave}{quickload}{saves}{settings}</header>\n{passage}`;function Jy(){let{storyData:e}=es(`storyData`),t=e?.passages.get(`StoryInterface`),n=t===void 0?qy:t.content,r=t?.tags.includes(`nobr`)??!1,i=Pe(()=>{try{return q(S,{children:hp(qo(n))})}catch(e){return q(`span`,{class:`error`,children:[`Error in StoryInterface: `,Jc(e)]})}},[n]);return r?q(Of.Provider,{value:!0,children:i}):i}var Yy=[`a[href]`,`area[href]`,`button:not([disabled])`,`input:not([disabled]):not([type=\"hidden\"])`,`select:not([disabled])`,`textarea:not([disabled])`,`iframe`,`[contenteditable=\"true\"]`,`[tabindex]:not([tabindex=\"-1\"])`].join(`,`);function Xy(e){return Array.from(e.querySelectorAll(Yy)).filter(e=>!e.hidden&&!e.closest(`[hidden], [inert]`))}var Zy=[];function Qy(e,t,n,r){Ne(()=>{let n=e.current;if(!n)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i={panel:n};Zy.push(i);let a=n.querySelector(t)??n;return(n.querySelector(`[autofocus]`)??Xy(a)[0]??n).focus(),()=>{let e=Zy.indexOf(i);e!==-1&&Zy.splice(e,1);let t=document.activeElement;(!t||t===document.body||n.contains(t))&&r?.isConnected&&r.focus()}},[]),Ne(()=>{let t=e.current;if(!t)return;let i=e=>{if(Zy[Zy.length-1]?.panel!==t)return;if(e.key===`Escape`){if(!n)return;e.preventDefault(),e.stopPropagation(),r();return}if(e.key!==`Tab`)return;let i=Xy(t),a=i[0],o=i[i.length-1],s=document.activeElement,c=s!==t&&t.contains(s);!a||!o?(e.preventDefault(),t.focus()):e.shiftKey&&(s===a||!c)?(e.preventDefault(),o.focus()):!e.shiftKey&&(s===o||!c)&&(e.preventDefault(),a.focus())};return document.addEventListener(`keydown`,i),()=>document.removeEventListener(`keydown`,i)},[n,r])}var $y=_e(null);function eb({passageName:e,fallbackMarkup:t,panelClass:n,onClose:r,dismissible:i=!0,showCloseButton:a=i}){let o=j(r);o.current=r;let s=Fe(()=>o.current(),[]),{storyData:c}=es(`storyData`),l=e?c?.passages.get(e):void 0,u=l?.content??t,d=l?.tags.includes(`nobr`)??!1,f=Pe(()=>{if(!u)return q(`div`,{class:`error`,children:`Dialog: no content available`});try{let e=Cp(qo(u),d?{nobr:!0}:void 0);return d?q(Of.Provider,{value:!0,children:e}):e}catch(e){return q(`div`,{class:`error`,children:[`Error in dialog: `,Jc(e)]})}},[u,d]),p=j(null);Qy(p,`.dialog-body`,i,s),Ne(()=>{p.current&&_g(`dialogrender`,e??``,p.current)},[]);let m=e=>{i&&e.target.classList.contains(`dialog-overlay`)&&s()},h=n?`dialog-panel ${n}`:`dialog-panel`;return q($y.Provider,{value:s,children:q(`div`,{class:`dialog-overlay`,onClick:m,children:q(`div`,{ref:p,class:h,role:`dialog`,\"aria-modal\":`true`,tabIndex:-1,children:[a&&q(`button`,{class:`dialog-close`,\"aria-label\":`Close`,onClick:s,children:`✕`}),q(`div`,{class:`dialog-body`,children:f})]})})})}function tb(){let[e,t]=Ae([]),n=j(e);n.current=e;let r=Fe(e=>{t(t=>[...t,e])},[]),i=Fe(()=>{t(e=>e.slice(0,-1))},[]),a=Fe(()=>{t([])},[]);return Me(()=>Ov({close:i,closeAll:a,push:r,isOpen:()=>n.current.length>0}),[i,a,r]),Me(()=>Cv(()=>{let e=[];for(;Tv()>0;){let t=wv();t&&e.push(t)}e.length>0&&t(t=>[...t,...e])}),[]),e.length===0?null:q(S,{children:e.map((e,t)=>q(eb,{passageName:e.passageName,panelClass:e.panelClass,onClose:i,showCloseButton:e.showCloseButton,dismissible:e.dismissible},`${e.passageName}-${t}`))})}function nb(){let[e,t]=Ae(zv);return Me(()=>(t(zv()),Bv(()=>t(zv()))),[]),e.length===0?null:q(`div`,{class:`spindle-error-banners`,children:e.map(e=>q(`div`,{class:`spindle-error-banner`,role:`alert`,children:[q(`span`,{class:`spindle-error-banner-context`,children:e.context}),` `,q(`span`,{class:`spindle-error-banner-message`,children:e.message}),e.count>1&&q(`span`,{class:`spindle-error-banner-count`,children:` (×${e.count})`}),q(`button`,{type:`button`,class:`spindle-error-banner-dismiss`,\"aria-label\":`Dismiss`,onClick:()=>Rv(e.id),children:`✕`})]},e.id))})}function rb(){let{storyData:e,currentPassage:t,nobr:n}=es(`storyData`,`currentPassage`,`nobr`);if(Me(()=>{let e=e=>{let{quickSaveKey:t,quickLoadKey:n,save:r,load:i}=Q.getState();t!==null&&e.key===t?(e.preventDefault(),r()):n!==null&&e.key===n&&(e.preventDefault(),i())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!e||!t)return q(`div`,{class:`loading`,children:`Loading...`});let r=q(S,{children:[q(Jy,{}),q(tb,{}),q(nb,{})]});return n?q(Of.Provider,{value:!0,children:r}):r}var ib=`http://www.w3.org/1999/xhtml`,ab=new Set([`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function ob(e){let t=``;for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t+=n.data:n.nodeType===Node.COMMENT_NODE?t+=`\\x3C!--${n.data}-->`:n.nodeType===Node.ELEMENT_NODE&&(t+=sb(n));return t}function sb(e){let t=e.localName,n=`<${t}`;for(let t of Array.from(e.attributes))n+=` ${t.name}=${cb(t.name,t.value)}`;if(n+=`>`,e.namespaceURI===ib&&ab.has(t))return n;let r=t===`template`?e.content:e;return`${n}${ob(r)}</${t}>`}function cb(e,t){let n=Bo(e),r=n?`on`:`a`;return[`\"${t}\"`,`'${t}'`].find(e=>{let t;try{t=Jo(`<i ${r}=${e}>`)}catch(e){if(e instanceof Wo)return!1;throw e}let n=t[0];return t.length===1&&n?.type===`html`&&n.attributes[r]===e.slice(1,-1)})??`\"${lb(t,n)}\"`}function lb(e,t){let n=e=>e.replace(/\"/g,`"`);if(t)return Vo(e).map(e=>`text`in e?n(e.text):`expr`in e?`{${e.expr}}`:e.verbatim).join(``);let r;try{r=Jo(e,{text:!0})}catch(t){if(t instanceof Wo)return n(e);throw t}return r.map(t=>{let r=e.slice(t.start,t.end);return t.type===`text`?n(r):r}).join(``)}function ub(){let e=document.querySelector(`tw-storydata`);if(!e)throw Error(`spindle: No <tw-storydata> element found in the document.`);let t=e.getAttribute(`name`)||`Untitled`,n=parseInt(e.getAttribute(`startnode`)||`1`,10),r=e.getAttribute(`ifid`)||``,i=e.getAttribute(`format`)||``,a=e.getAttribute(`format-version`)||``,o=e.querySelector(`[type=\"text/twine-css\"]`)?.textContent||``,s=e.querySelector(`[type=\"text/twine-javascript\"]`)?.textContent||``,c=new Map,l=new Map;for(let t of e.querySelectorAll(`tw-passagedata`)){let e=parseInt(t.getAttribute(`pid`)||`0`,10),n=t.getAttribute(`name`)||``,r=(t.getAttribute(`tags`)||``).split(/\\s+/).filter(e=>e.length>0),i=ob(t),a={},o=new Set([`pid`,`name`,`tags`]);for(let e of t.attributes)o.has(e.name)||(a[e.name]=e.value);let s={pid:e,name:n,tags:r,metadata:a,content:i};c.set(n,s),l.set(e,s)}return{name:t,startNode:n,ifid:r,format:i,formatVersion:a,passages:c,passagesById:l,userCSS:o,userScript:s}}var db=new Map,fb=K(),pb=!1,mb=null;function hb(){return`spindle.${Q.getState().storyData?.ifid||`unknown`}.settings`}function gb(){localStorage.setItem(hb(),JSON.stringify(fb))}function _b(){if(!pb){if(!Q.getState().storyData?.ifid){mb||(mb=Q.subscribe(e=>{e.storyData?.ifid&&(mb?.(),mb=null,_b())}));return}pb=!0;try{let e=localStorage.getItem(hb());if(e){let t=JSON.parse(e);typeof t==`object`&&t&&!Array.isArray(t)&&(fb=K(fb,t))}}catch{}}}function vb(e,t){db.set(e,t),G(fb,e)||(fb[e]=t.config.default),_b()}function yb(e,t){let n=ws(fb,e);return typeof n==typeof t?n:t}var bb={addToggle(e,t){vb(e,{type:`toggle`,config:t})},addList(e,t){vb(e,{type:`list`,config:t})},addRange(e,t){vb(e,{type:`range`,config:t})},get(e){return ws(fb,e)},getToggle(e){return yb(e,!1)},getList(e){return yb(e,``)},getRange(e){return yb(e,0)},set(e,t){fb[e]=t,gb()},getAll(){return{...fb}},getDefinitions(){return db},hasAny(){return db.size>0}},xb=[`target`,`variable`,`options`,`value`,`disabled`],Sb=new Map,Cb=new Map;function wb(e,t,n){if(n)return n;let r=`${e}:${t}`,i=Cb.get(r)??0,a;do i++,a=i===1?r:`${r}:${i}`;while(Sb.has(a));return Cb.set(r,i),a}function Tb(e){let t=e.id,n={action:e},r=Sb.get(t);return r?(console.warn(`spindle: two mounted controls share the action ID \"${t}\"; Story.getActions() lists only the newer one.`),r.push(n)):Sb.set(t,[n]),Ab(),{update(e){let r=Sb.get(t);r?.includes(n)&&(n.action=e,r[r.length-1]===n&&Ab())},unregister(){let e=Sb.get(t),r=e?e.indexOf(n):-1;!e||r===-1||(e.splice(r,1),e.length===0&&Sb.delete(t),r===e.length&&Ab())}}}function Eb(){return Array.from(Sb.values(),Ob)}function Db(e){let t=Sb.get(e);return t&&Ob(t)}function Ob(e){return e[e.length-1].action}function kb(){Cb.clear()}function Ab(){gg(`actionsChanged`)}function jb(e){let t=j(``),n=j(e.perform);n.current=e.perform,t.current||(t.current=wb(e.type,e.key,e.authorId));let r=t.current,i=()=>{let t={id:r,type:e.type,label:e.label,perform:(...e)=>n.current(...e)};for(let n of xb)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t},a=j(null);Ne(()=>{let e=Tb(i());return a.current=e,()=>e.unregister()},[r]);let o=j(!1);return Ne(()=>{if(!o.current){o.current=!0;return}a.current?.update(i())},[e.type,e.label,e.target,e.variable,e.disabled,e.value,JSON.stringify(e.options)]),r}function Mb(e){return e.map(e=>e.type===`text`?e.value:``).join(``)}function Nb(e){let t=e.trim();return t.endsWith(`ms`)?parseFloat(t.slice(0,-2)):t.endsWith(`s`)?parseFloat(t.slice(0,-1))*1e3:parseFloat(t)}function Pb(e){let t=[],n=0;for(let r of[...Dc(e,vc),e.length])r>n&&t.push([n,r]),n=r+1;return t}var Fb=(e,[t,n])=>e.slice(t,n);function Ib(e){return Cc(e)??wc(e)}var Lb=class extends Error{constructor(e,t){super(`The ${e.name} must be a quoted string (\"…\" or '…'), not ${t}`),this.name=`MacroArgumentError`}};function Rb(e,t){switch(e.type){case`string`:{let n=Cc(t);if(n===null)throw new Lb(e,t);return n}case`text`:return Ib(t);case`names`:return t.split(`,`).map(e=>e.trim());case`delay`:return Nb(t);case`number`:return Number(t);case`options`:return Ub(e.parameters??[],t);default:return t}}function zb(e){return e.type===`flag`||e.type===`separator`?!1:e.type===`options`?{}:void 0}var Bb=/\\w+/y,Vb=/\\d+/y;function Hb(e,t,n){return e.lastIndex=n,e.exec(t)?.[0]??null}function Ub(e,t){let n={},r=0;for(;r<t.length;){let i=Hb(Bb,t,r);if(!i){r=Sc(t,r)?.end??r+1;continue}r+=i.length;let a,o=r;for(;o<t.length&&vc(t[o]);)o++;if(o>r){let e=Sc(t,o),n=e?null:Hb(Vb,t,o);e?(a=e.value,r=e.end):n&&(a=n,r=o+n.length)}let s=e.find(e=>e.name===i);s?.type===`flag`?n[i]=!0:s?.type===`number`?n[i]=Number(a??0):s&&(n[i]=a)}return n}var Wb=/^(?:[-+*/&|^=<>?:,.]|%(?![A-Za-z_]))/;function Gb(e,t){let n=Pb(e);if(n.length<2)return null;if(Fb(e,n[n.length-1])===t){let t=e.slice(0,n[n.length-2][1]);if(!Ec(t))return t}if(Fb(e,n[0])===t){let t=e.slice(n[1][0]);if(!Wb.test(t))return t}return null}function Kb(e,t){if(t===`=`){let t=Dc(e,e=>e===`=`);for(let n=0;n<t.length;n++){let r=t[n];if(e[r+1]===`=`){n++;continue}if(e[r-1]!==`!`)return[r,r+1]}return null}let n=Pb(e);for(let r=1;r<n.length-1;r++)if(Fb(e,n[r])===t)return[n[r-1][1],n[r+1][0]];return null}var qb=e=>e.type===`expression`||e.type===`statements`||e.type===`passage`||e.type===`text`;function Jb(e,t,n){let r=t?.trim()??``;for(let i of e.filter(e=>e.type===`flag`)){let e=t===null?null:Gb(r,i.name);n[i.name]=e!==null,r=e??r}let i=e.filter(e=>e.type!==`flag`);if(i.length===0)return;let a=i.findIndex((e,t)=>qb(e)&&!i.slice(t+1).some(qb)),o=a<0?i.length-1:a,s=(e,t)=>t===``?zb(e):Rb(e,t);if(i.length===1){n[i[0].name]=s(i[0],r);return}let c=Pb(r),l=0,u=c.length;for(let e of i.slice(0,o))n[e.name]=l<u?s(e,Fb(r,c[l++])):zb(e);let d=(e,t)=>{try{return s(e,t)}catch(e){if(e instanceof Lb)return;throw e}};for(let e of i.slice(o+1).reverse()){let t=l<u&&!Ec(r.slice(0,c[u-1][0]))?d(e,Fb(r,c[u-1])):void 0;n[e.name]=t??zb(e),t!==void 0&&u--}let f=i[o];n[f.name]=l<u?s(f,r.slice(c[l][0],c[u-1][1])):zb(f)}var Yb={name:`delay`,type:`delay`,required:!0};function Xb(e,t){let n={},r=e.trim(),i=0;return t.forEach((e,a)=>{if(e.type!==`separator`)return;let o=r===null?null:Kb(r,e.name);n[e.name]=o!==null;let s=o?r.slice(0,o[0]):r;Jb(t.slice(i,a),s,n),r=o?r.slice(o[1]):null,i=a+1}),Jb(t.slice(i),r,n),n}function Zb(e,t,{storyData:n,currentPassage:r}){let i=String(t(e??``));if(n&&!n.passages.has(i))throw Lv(i,r);return i}function Qb(e){let t=e.trim(),n=Pb(t)[0];return n?Fb(t,n):``}function $b(e){let{variable:t=``,placeholder:n=``}=Xb(e,[{name:`variable`,type:`variable`},{name:`placeholder`,type:`string`}]);return{varName:t.replace(/[\"']/g,``),placeholder:n}}var ex=[{name:`value`,type:`string`,required:!0}],tx={option:ex};function nx(e){let t=[];for(let n of e)if(n.type===`macro`&&n.name===`option`){let{value:e}=Xb(n.rawArgs,ex);t.push(e??``)}return t}function rx(e,t){let n=`macro-${e}`;return t?`${n} ${t}`:n}var ix={useState:Ae,useRef:j,useEffect:Me,useLayoutEffect:Ne,useCallback:Fe,useMemo:Pe,useContext:Ie};function $(e,t=`builtin`){let n=e.parameters??[];dc(e.name,n);function r(t){let r=t.className,i=t.id,a;e.interpolate&&(a=Xc(),r=a(r),i=a(i));let{update:o,getValues:s}=Ie(Df),c=tl(),l=(e,t)=>Cp(e,{...c,...t}),u;try{u=Xb(t.rawArgs,n)}catch(t){if(t instanceof Lb)return b(Sf,{macro:e.name,error:t});throw t}let d={args:u,collectText:Mb,sourceLocation:xf,parseVarArgs:$b,extractOptions:nx,h:b,renderNodes:l,renderInlineNodes:hp,hooks:ix,useAction:jb,className:r,id:i,resolve:a,cls:rx(e.name,r),mutate:e=>rv(e,s(),o),update:o,getValues:s,wrap:e=>Pc(r,i,e)};if(e.merged){d.merged=ts();let e=d.merged;d.evaluate=t=>$s(t,e[0],e[1],e[2],e[3])}if(e.storeVar){let n=Qb(t.rawArgs).replace(/[\"']/g,``);if(n.startsWith(`%`))return b(`span`,{class:`error`},`{${e.name}}: transient variables (%${n.slice(1)}) cannot be bound to input macros`);let r=n.replace(/[\"']/g,``).replace(/^\\$/,``),i=r.split(`.`);if(i.includes(`__proto__`))return b(`span`,{class:`error`},`{${e.name}}: \"$${r}\" cannot be bound: ${xs} is reserved`);d.varName=r,d.value=Q(e=>Lh(e.variables,i)),d.getValue=()=>Lh(V_().variables,i),d.setValue=e=>{Q.setState(t=>{Vh(t.variables,i,e,{createMissing:!0})})}}try{return e.render(t,d)}catch(t){if(t instanceof Lb)return b(Sf,{macro:e.name,error:t});throw t}}nc(e.name,r);let i=e.text;ac(e.name,i&&((e,t)=>i(e,{...t,args:Xb(e.rawArgs,n)})));let a=e.block===!0||e.block!==!1&&(e.subMacros?.length??0)>0;if(pc(e.name,{name:e.name,block:a,subMacros:e.subMacros??[],storeVar:e.storeVar,interpolate:e.interpolate,merged:e.merged,description:e.description,parameters:e.parameters&&[...e.parameters],source:t}),e.subMacros)for(let t of e.subMacros)cc(t);a&&hr(e.name)}var ax=null;function ox(e){ax=e}function sx(){return ax}var cx=null,lx=null;function ux(){return lx}var dx=!1;function fx(){if(dx)return;dx=!0;let e=Q.getState().variables,t=Q.getState().transient;Q.subscribe(n=>{let r={},i=(e,t,n)=>{for(let i of js(e,t))r[n+i]={from:ws(e,i),to:ws(t,i)}};i(e,n.variables,``),i(t,n.transient,`%`),e=n.variables,t=n.transient,Object.keys(r).length>0&&gg(`variableChanged`,r)})}var px=null,mx=null,hx=new Set;function gx(e,t=[]){px=new Set(e),mx=new Set(t),hx.clear()}function _x(e){let t=e.startsWith(`%`),n=t||e.startsWith(`$`)?e.slice(1):e;return Cs(n.split(`.`)[0],e),{isTransient:t,key:n}}function vx(e,t){let n=e?mx:px;if(!n)return;let r=t.split(`.`)[0];if(n.has(r))return;let i=(e?`%`:`$`)+r;hx.has(i)||(hx.add(i),console.warn(`spindle: Story.set() wrote ${i}, which is not declared in ${e?`StoryTransients`:`StoryVariables`}. Passages cannot reference it; check the name or declare it.`))}function yx(e,t,n){let{isTransient:r,key:i}=_x(t),a=r?e.transient:e.variables;i.includes(`.`)?Vh(a,i.split(`.`),n):a[i]=n}function bx(e){return((...t)=>Q.getState()[e](...t))}function xx(){return{get(e){let{isTransient:t,key:n}=_x(e),r=B_(),i=r??Q.getState(),a=t?i.transient:i.variables,o=n.includes(`.`)?Lh(a,n.split(`.`)):ws(a,n);return r?U_(o):o},set(e,t){let n=typeof e==`string`?[[e,t]]:Object.entries(e);for(let[e]of n){let{isTransient:t,key:n}=_x(e);vx(t,n)}Q.getState().updateVariables(e=>{for(let[t,r]of n)yx(e,t,r)})},goto:bx(`navigate`),back:bx(`goBack`),forward:bx(`goForward`),restart:bx(`restart`),save:bx(`save`),load:bx(`load`),hasSave:bx(`hasSave`),getSaveInfo:bx(`getSaveInfo`),listSaves:bx(`listSaves`),deleteSave:bx(`deleteSave`),exportSave:bx(`exportSave`),importSave:bx(`importSave`),...Ks(()=>Q.getState().visitCounts,()=>Q.getState().renderCounts),get title(){return Q.getState().storyData?.name||``},get passage(){return Q.getState().currentPassage},settings:bb,registerClass(e,t){vm(e,t)},defineMacro(e){$(e,`user`)},getMacroRegistry(){return mc()},saves:{setTitleGenerator(e){bg(e)}},storage:{async getInfo(){let e=Q.getState().storyData?.ifid;return e?k_(e):{saveCount:0,playthroughCount:0,totalBytes:0,backend:jh()}},async getQuota(){if(typeof navigator<`u`&&navigator.storage?.estimate)try{let e=await navigator.storage.estimate();return{usage:e.usage??0,quota:e.quota??0,estimateSupported:!0}}catch{}return{usage:0,quota:0,estimateSupported:!1}},clearGameData:bx(`clearGameData`),clearAllData:bx(`clearAllData`),deletePlaythrough:bx(`deletePlaythrough`),get backend(){return jh()}},getActions(){return Eb()},performAction(e,t){let n=Db(e);if(!n)throw Error(`spindle: Action \"${e}\" not found.`);if(n.disabled)throw Error(`spindle: Action \"${e}\" is disabled.`);n.perform(t)},on(e,t){e===`variableChanged`&&fx();let n=mg(e,t);return ky(n),n},async waitForActions(){await new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))});let e=()=>sx()===Q.getState().navigationId;return sx()!==null&&!e()&&!Q.getState().renderDeferred&&await new Promise(t=>{let n=mg(`passagerender`,()=>{e()&&(n(),t())})}),Eb()},watch(e,t){return dv(e,t)},unwatch(e){pv(e)},openDialog(e,t){Ev({passageName:e,panelClass:t?.panelClass,showCloseButton:t?.showCloseButton,dismissible:t?.dismissible})},closeDialog(){kv()},closeAllDialogs(){Av()},isDialogOpen(){return jv()},setNobr(e){Q.setState({nobr:e})},setCSS(e){let t=document.getElementById(`spindle-styles`);t&&(t.disabled=!e)},setTransition(e){Q.getState().setTransition(e)},setNextTransition(e){Q.getState().setNextTransition(e)},deferRender(){Q.getState().deferRender(),lx=new Promise(e=>{cx=e})},ready(){cx&&(Q.getState().clearDeferredRender(),cx(),cx=null,lx=null)},random(){return gs()},randomInt(e,t){return _s(e,t)},config:{get maxHistory(){return Q.getState().maxHistory},set maxHistory(e){Q.getState().setMaxHistory(e)},get quickSaveKey(){return Q.getState().quickSaveKey},set quickSaveKey(e){Q.getState().setQuickSaveKey(e)},get quickLoadKey(){return Q.getState().quickLoadKey},set quickLoadKey(e){Q.getState().setQuickLoadKey(e)}},prng:{init(e,t){us(e,t);let{historyIndex:n}=Q.getState();Q.setState(e=>{let t=e.history[n];t&&(t.prng=hs())})},isEnabled(){return vs()},get seed(){return ys()},get pull(){return bs()}}}}function Sx(){window.Story=xx()}var Cx=null;function wx(e){let t=Cx;Cx=new Map;try{return e()}finally{Cx=t}}function Tx(e,t){let n=t[0]+e,r=Cx?.get(n);if(r)return r;try{r=po(e,t)}catch(e){if(!(e instanceof io))throw e;r=e}return Cx?.set(n,r),r}var Ex=new Set([`if`,`elseif`,`case`]),Dx={watch:{condition:`expression`,run:`statements`}},Ox={watch:[`goto`,`dialog`]},kx=new Set([`dialog`]);function Ax(e){if(e.type===`expression`||e.type===`passage`)return`expression`;if(e.type===`statements`)return`statements`}function*jx(e,t,n){let r=(e,n)=>t.findIndex((t,r)=>r>e&&t.type===`macro`&&t.isClose&&t.name.toLowerCase()===n);for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`link`)yield{kind:`passage`,name:a.target,offset:Nx(e,a.target,a.start),label:e.slice(a.start,a.end)};else if(a.type===`expression`)yield{kind:`code`,code:a.expression,offset:a.end-1-a.expression.length,goal:`expression`,label:`{${a.expression}}`};else if(a.type===`html`)for(let[t,n]of Object.entries(a.attributes)){let r=Nx(e,n,a.start);if(!Bo(t)){yield{kind:`text`,text:n,offset:r,where:`In the ${t} attribute of <${a.tag}>: `};continue}let i=0;for(let e of Vo(n)){if(!(`expr`in e))continue;let o=Nx(n,e.expr,i);i=o+e.expr.length,yield{kind:`code`,code:e.expr,offset:r+o,goal:`expression`,label:`{${e.expr}} in the ${t} attribute of <${a.tag}>`}}}else if(a.type===`macro`&&!a.isClose){let o=a.name.toLowerCase();if(o===`do`){let n=r(i,o);if(n<0)continue;yield{kind:`code`,code:e.slice(a.end,t[n].start),offset:a.end,goal:`statements`,label:`{do}`},i=n;continue}let s=a.rawArgs;if(kx.has(o)){let n=r(i,o),s=t.slice(i+1,n);if(n>i+1&&s.every(e=>e.type===`text`)){let r=e.slice(a.end,t[n].start).trim().replace(/^[\"']|[\"']$/g,``);yield{kind:`passage`,name:r,offset:Nx(e,r,a.end),label:e.slice(a.start,a.end)}}}if(!s)continue;let c=`{${a.name} ${s}}`,l=Nx(e,s,a.start+1);if(Ex.has(o)){yield{kind:`code`,code:s,offset:l,goal:`expression`,label:c};continue}let u=n(o);u&&(yield*Mx(s,l,u,a.name,c))}}}function*Mx(e,t,n,r,i){let a;try{a=Xb(e,n)}catch(e){if(!(e instanceof Lb))throw e;yield{kind:`argument-error`,message:e.message,offset:t,label:i};return}let o=Dx[r.toLowerCase()]??{},s=Ox[r.toLowerCase()]??[],c=0;function*l(n,a){for(let u of n){let n=a[u.name];if(u.type===`options`&&u.parameters){yield*l(u.parameters,n??{});continue}if(typeof n!=`string`||!n.trim())continue;let d=Nx(e,n,c);d>=c&&(c=d+n.length);let f=Ax(u)??o[u.name];if(f){let e={kind:`code`,code:n,offset:t+d,goal:f,label:i};u.type===`passage`&&(e.passage=!0),yield e}let p=u.type===`passage`?Cc(n.trim()):s.includes(u.name)?n:null;p!==null&&(yield{kind:`passage`,name:p,offset:t+d,label:i}),!f&&(u.type===`text`||u.type===`string`)&&(yield{kind:`text`,text:n,offset:t+d,where:`In the ${u.name} of {${r}}: `})}}yield*l(n,a)}function Nx(e,t,n){let r=e.indexOf(t,n);if(r>=0)return r;let i=e.indexOf(t);return i>=0?i:n}function Px(e,t){try{return Jo(e,{text:t})}catch(e){if(e instanceof Wo)return[];throw e}}function Fx(e){let t=e.replace(/[.*+?^${}()|[\\]\\\\]/g,`\\\\$&`);return RegExp(`^${t}(\\\\w+)\\\\s*=\\\\s*(.+)$`)}var Ix=/\\$(\\w+(?:\\.\\w+)*)/y,Lx=/^[\"']\\$(\\w+(?:\\.\\w+)*)[\"']?$/,Rx=/\\{for\\s+@(\\w+)(?:\\s*,\\s*@(\\w+))?\\s+of\\b/g,zx=new Set([`number`,`string`,`boolean`]),Bx={string:Object(``),number:Object(0),boolean:Object(!1)};function Vx(e){if(Array.isArray(e))return{type:`array`};if(typeof e==`object`&&e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,Vx(r));return{type:`object`,fields:t}}let t=typeof e;if(!zx.has(t))throw Error(`Unsupported type \"${t}\" for value ${String(e)}. Expected number, string, boolean, array, or object.`);return{type:t}}function Hx(e,t=`$`){let n=new Map,r=Fx(t),i=t===`%`?`StoryTransients`:`StoryVariables`;for(let a of e.split(`\n`)){let e=a.trim();if(!e)continue;let o=e.match(r);if(!o)throw Error(`${i}: Invalid declaration: \"${e}\". Expected: ${t}name = value`);let[,s,c]=o,l=Ss(s,t+s);if(l)throw Error(`${i}: ${l}`);let u;try{u=Function(`return (`+c+`)`)()}catch(e){throw Error(`${i}: Failed to evaluate \"${t}${s} = ${c}\": ${Jc(e)}`)}let d;try{d=Vx(u)}catch(e){throw Error(`${i}: ${Jc(e)}`)}n.set(s,{...d,name:s,default:u})}return n}function Ux(e){let t=new Set,n;for(Rx.lastIndex=0;(n=Rx.exec(e))!==null;)t.add(n[1]),n[2]&&t.add(n[2]);return t}function Wx(e,t,n){let r=e.split(`.`),i=r[0],a=Ss(i,`$`+i);if(a)return a;if(n.has(i))return null;let o=t.get(i);if(!o)return`Undeclared variable: $${e}`;let s=o;for(let e=1;e<r.length;e++){let t=r[e];if(s.type===`array`)return null;let n=Bx[s.type];if(n&&t in n){let e=typeof n[t];if(!zx.has(e))return null;s={type:e};continue}if(s.type!==`object`||!s.fields)return`Cannot access field \"${t}\" on $${r.slice(0,e).join(`.`)} (type: ${s.type})`;let i=s.fields.get(t);if(!i)return null;s=i}return null}var Gx=[`checkbox`,`cycle`,`listbox`,`numberbox`,`radiobutton`,`textarea`,`textbox`],Kx=new Set;function qx(e,t){for(let n of Vo(e))`expr`in n&&Yx(n.expr,t)}function Jx(e,t,n=Kx){e.includes(`{`)&&Qx(e,Px(e,!0),n,t)}function Yx(e,t,n=`expression`){let r=Tx(e,n);if(r instanceof io){Xx(e,t,n);return}for(let n of r.refs)n.sigil===`$`&&(Ix.lastIndex=n.start,t(Ix.exec(e)[1]));for(let e of r.strings)Jx(e,t)}function Xx(e,t,n){let r=[];Do(e,{variable(n,r,i){n===`$`&&(Ix.lastIndex=i,t(Ix.exec(e)[1]))},literal(e,n,i){let a=r[r.length-1];if(a?.nesting===i)a.text===null?a.text=``:e===\"`\"||e===\"${\"?(Jx(a.text,t),e===\"`\"?r.pop():a.text=null):a.text+=e;else if(e===\"`\")r.push({nesting:i,text:``});else if(e[0]===`\"`||e[0]===`'`){let{closed:n}=Mo(e,0);Jx(e.slice(1,n?-1:void 0),t)}}},n);for(let e of r)e.text&&Jx(e.text,t)}function Zx(e,t,n){wx(()=>Qx(e,Px(e,!1),t,n))}function Qx(e,t,n,r){for(let i=0;i<t.length;i++){let a=t[i];if(a.type===`variable`)a.scope===`variable`&&a.name&&r(a.name);else if(a.type===`expression`)Yx(a.expression,r);else if(a.type===`html`)for(let[e,t]of Object.entries(a.attributes))Bo(e)?qx(t,r):Jx(t,r,n);else if(a.type===`macro`&&!a.isClose){if(Yx(a.rawArgs,r),n.has(a.name.toLowerCase())){let e=a.rawArgs.trim().split(/\\s+/)[0]??``,t=Lx.exec(e);t&&r(t[1])}if(a.name===`do`){let n=i+1;for(;n<t.length;){let e=t[n];if(e.type===`macro`&&e.isClose&&e.name===`do`)break;n++}n<t.length&&(Yx(e.slice(a.end,t[n].start),r,`statements`),i=n)}}}}function $x(e,t,n=Gx){let r=[],i=new Set(Array.from(n,e=>e.toLowerCase()));for(let[n,a]of e){if(n===`StoryVariables`||n===`StoryTransients`)continue;let e=Ux(a.content);Zx(a.content,i,i=>{let a=Wx(i,t,e);a&&r.push(`Passage \"${n}\": ${a}`)})}return r}function eS(e){let t=K();for(let[n,r]of e)t[n]=r.default;return t}var tS=[{name:`name`,type:`text`,required:!0},{name:`parameters`,type:`text`}];function nS({name:e=``,parameters:t=``}){return{name:e,params:t.split(/\\s+/).filter(e=>e.startsWith(`@`))}}function rS(e){return nS(Xb(e,tS))}var iS=/\\{widget\\s+[\"']?(\\w+)[\"']?[^}]*\\}([\\s\\S]*?)\\{\\/widget\\}/g;function aS(e){let t=[];for(let n of e)if(!(n.name!==`StoryInit`&&!n.tags?.includes(`widget`)))for(let e of n.content.matchAll(iS))/\\{@children\\}/.test(e[2])&&t.push(e[1]);return t}var oS=new Set([`StoryVariables`,`StoryTransients`]),sS=[`script`,`stylesheet`],cS=new Set([`elseif`,`else`,`case`,`default`,`next`]);function lS(e){let t=e.file?` (${e.file}${e.fileLine?`:${e.fileLine}`:``})`:``;return`Passage \"${e.passage}\", line ${e.line}, column ${e.column}${t}: ${e.message}`}function uS(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++)i[a]=Math.min(n[a]+1,i[a-1]+1,n[a-1]+(e[r-1]===t[a-1]?0:1));n=i}return n[t.length]}function dS(e,t,n){let r=e.toLowerCase(),i=``,a=Math.max(2,Math.floor(r.length/3))+1;for(let e of t){let t=uS(r,e.toLowerCase());t<a&&(i=e,a=t)}return i?` Did you mean ${n(i)}?`:``}var fS=` (a passage name is a quoted string or an expression)`,pS=/^[A-Za-z][\\w$]*$/;function mS(e){try{return rS(e).name.toLowerCase()||void 0}catch{return}}function hS(e,t){let n=[],r=t.isBlockMacro?{isBlock:t.isBlockMacro}:void 0,i=(e,t,r)=>{let{line:i,column:a}=Go(e.content,t),o={passage:e.name,line:i,column:a,message:r},s=e.metadata?.[`data-source-file`];if(s){o.file=s;let t=Number(e.metadata?.[`data-source-line`]);t&&(o.fileLine=t+i)}n.push(o)},a=[],o=new Set,s=new Set;for(let n of e){if(s.add(n.name),oS.has(n.name)||n.tags?.some(e=>sS.includes(e)))continue;let e=!t.only||t.only(n);try{let t=Jo(n.content);for(let e of t){if(e.type!==`macro`||e.isClose||e.name.toLowerCase()!==`widget`)continue;let t=mS(e.rawArgs);t&&o.add(t)}if(!e)continue;qo(n.content,{hooks:r}),a.push([n,t])}catch(t){if(!(t instanceof Wo))throw t;e&&i(n,t.offset,t.reason)}}let c=[...t.macroNames??[],...o],l=(e,n,r,a)=>{for(let s of n){if(s.type!==`macro`||s.isClose)continue;let n=s.name.toLowerCase();cS.has(n)||o.has(n)||t.isKnownMacro(n)||i(e,r+s.start,`${a}Unknown macro {${s.name}}.${dS(s.name,c,e=>`{${e}}`)}`)}},u=e=>t.parametersOf?.(e)??tx[e.toLowerCase()],d=(e,n,a,o,c)=>{l(e,a,o,c);for(let l of jx(n,a,u)){let n=o+l.offset;if(l.kind===`argument-error`){i(e,n,`${c}${l.message} in ${l.label}`);continue}if(l.kind===`passage`){if(t.checkPassageNames!==!1&&!s.has(l.name)){let t=dS(l.name,s,JSON.stringify);i(e,n,`${c}No passage named ${JSON.stringify(l.name)} in ${l.label}.${t}`)}continue}if(l.kind===`code`){let t=Tx(l.code,l.goal),r=l.code.trim();if(t instanceof io){let r=t.reasonIn(e.content,n);i(e,n+t.pos,`${c}${r} in ${l.label}`+(l.passage?fS:``))}else l.passage&&pS.test(r)&&i(e,n,`${c}Unquoted passage name in ${l.label}: write ${JSON.stringify(r)}${fS}`);continue}if(l.text.includes(`{`))try{qo(l.text,{text:!0,hooks:r});let t=Jo(l.text,{text:!0});d(e,l.text,t,n,l.where)}catch(t){if(!(t instanceof Wo))throw t;i(e,n+t.offset,l.where+t.reason)}}};for(let[e,t]of a)wx(()=>d(e,e.content,t,0,``));return n}function gS(e){for(let t of e){if(t.type===`variable`&&t.scope===`local`&&t.name===`children`||t.type===`html`&&gS(t.children))return!0;if(t.type===`macro`){if(gS(t.children))return!0;if(t.branches){for(let e of t.branches)if(gS(e.children))return!0}}}return!1}function _S({name:e,params:t},n){let r=gS(n);gc(e,n,t,r),r&&hr(e)}$({name:`widget`,block:!0,parameters:tS,render({children:e=[]},t){let n,r;try{let e=nS(t.args);for(let t of e.params)Cs(t.slice(1),t);n=e}catch(e){r=e}let{name:i,params:a}=n??{name:``,params:[]},o=JSON.stringify(e),s=a.join(`,`);return t.hooks.useLayoutEffect(()=>{n&&_S(n,e)},[i,o,s]),r?q(Sf,{macro:`widget`,error:r}):null}}),$({name:`set`,parameters:[{name:`code`,type:`statements`,required:!0}],render({rawArgs:e},t){return wf(`set`,e,()=>t.mutate(e))}}),$({name:`print`,parameters:[{name:`expression`,type:`expression`,required:!0}],interpolate:!0,merged:!0,render({rawArgs:e},t){try{return t.wrap(Nc(t.evaluate(e)))}catch(e){return q(Sf,{macro:`print`,error:e})}},text({rawArgs:e},t){return Nc(t.evaluate(e))}});var vS=Symbol(`unset`);function yS(e,t){if(!t[`=`])throw Error(`{computed}: expected \"target = expression\", got \"${e}\"`);let{target:n=``,expression:r=``}=t;if(!n.match(/^[$_@]\\w+$/))throw Error(`{computed}: target must be $name, _name, or @name, got \"${n}\"`);return Cs(n.slice(1),n),{target:n,expr:r}}function bS(e,t,n,r,i,a,o,s){let c=xf(),l;try{let{variables:t,temporary:n,transient:r}=V_();l=$s(e,t,n,i(),r)}catch(e){Cf(`computed ${a}`,e,c);return}if(!Yh(o.current,l))if(o.current=l,r)try{s(t,l)}catch(e){Cf(`computed ${a}`,e,c)}else{let e=Q.getState();n?e.setTemporary(t,l):e.setVariable(t,l)}}$({name:`computed`,merged:!0,parameters:[{name:`target`,type:`variable`,required:!0},{name:`=`,type:`separator`},{name:`expression`,type:`expression`,required:!0}],render({rawArgs:e},t){let[n,r,i,a]=t.merged,o,s;try{({target:o,expr:s}=yS(e,t.args))}catch(e){return q(Sf,{macro:`computed`,error:e})}let c=o.startsWith(`@`),l=o.startsWith(`_`),u=o.slice(1),d=c?t.update:null,f=t.hooks.useRef(vS),p=()=>bS(s,u,l,c,t.getValues,e,f,d),m=t.hooks.useRef(!1);return m.current||(m.current=!0,p()),t.hooks.useLayoutEffect(p,[n,r,i,a]),null}});function xS(e){if(e.current===void 0||e.max===void 0)throw Error(`meter requires two arguments: {meter currentExpr maxExpr}`);return{currentExpr:e.current,maxExpr:e.max,labelMode:e.label??``}}function SS(e,t,n){return n===`none`?null:n===`%`?`${t===0?0:Math.round(e/t*100)}%`:n?`${e} ${n} / ${t} ${n}`:`${e} / ${t}`}$({name:`meter`,interpolate:!0,merged:!0,parameters:[{name:`current`,type:`expression`,required:!0},{name:`max`,type:`expression`,required:!0},{name:`label`,type:`string`}],render(e,t){try{let{currentExpr:e,maxExpr:n,labelMode:r}=xS(t.args),i=Number(t.evaluate(e)),a=Number(t.evaluate(n)),o=a===0?0:Math.max(0,Math.min(100,i/a*100)),s=SS(i,a,r),c=t.cls;return q(`div`,{class:c,id:t.id,children:[q(`div`,{class:`macro-meter-fill`,style:`width: ${o}%`}),s!=null&&q(`span`,{class:`macro-meter-label`,children:s})]})}catch(e){return q(Sf,{macro:`meter`,error:e})}}});function CS(e,t){let n=null;for(let r of e)if(r.rawArgs===``)n=r;else if(t(r.rawArgs))return r;return n}function wS(e,t){let n=e.findIndex(e=>e.rawArgs===``);return CS(n<0?e:e.slice(0,n+1),e=>!!t(e))}$({name:`if`,block:!0,interpolate:!0,merged:!0,render({branches:e=[]},t){let n;try{n=wS(e,t.evaluate)}catch(e){return q(Sf,{macro:`if`,error:e})}return n?Pc(t.resolve(n.className),t.resolve(n.id),t.renderNodes(n.children)):null},text({branches:e=[]},t){let n=wS(e,t.evaluate);return n?t.renderText(n.children):``}});function TS(e){try{return ES(e,[])}catch{return`<unkeyable>`}}function ES(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`number`:return Number.isFinite(e)?JSON.stringify(e):String(e);case`boolean`:return String(e);case`bigint`:return`${e}n`;case`undefined`:return`undefined`;case`symbol`:return e.description===void 0?`Symbol()`:`Symbol(${JSON.stringify(e.description)})`;case`function`:return`<function ${JSON.stringify(e.name)}>`}if(e===null)return`null`;let n=e,r=t.indexOf(n);if(r!==-1)return`<cycle ${t.length-r}>`;if(e instanceof Date)return`Date(${e.getTime()})`;if(e instanceof RegExp)return`RegExp(${String(e)})`;t.push(n);try{if(Array.isArray(e))return`[${Array.from(e,e=>ES(e,t)).join(`,`)}]`;if(e instanceof Map)return`Map[${[...e].map(([e,n])=>`[${ES(e,t)},${ES(n,t)}]`).join(`,`)}]`;if(e instanceof Set)return`Set[${[...e].map(e=>ES(e,t)).join(`,`)}]`;let r=n,i=Object.keys(r).map(e=>`${JSON.stringify(e)}:${ES(r[e],t)}`).join(`,`),a=ym(n);return a===void 0?`{${i}}`:`Class(${JSON.stringify(a)}){${i}}`}finally{t.pop()}}function DS(e,t){if(!t.of)throw Error(`{for} requires \"of\" keyword: {for ${e}}`);let[n=``,r=null]=t.variables??[],i=t.list??``;if(!n.startsWith(`@`))throw Error(`{for} loop variable must use @ prefix: got \"${n}\"`);if(r&&!r.startsWith(`@`))throw Error(`{for} index variable must use @ prefix: got \"${r}\"`);return Cs(n.slice(1),n),r&&Cs(r.slice(1),r),{itemVar:n.slice(1),indexVar:r?r.slice(1):null,listExpr:i}}function OS({parentValues:e,itemVar:t,itemValue:n,indexVar:r,indexValue:i,children:a}){return q(nl,{body:a,parentValues:e,ownKeys:Pe(()=>({[t]:n,...r?{[r]:i}:void 0}),[t,n,r,i])})}$({name:`for`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`variables`,type:`names`,required:!0},{name:`of`,type:`separator`},{name:`list`,type:`expression`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=Ie(Ef),i,a;try{i=DS(e,n.args);let t=n.evaluate(i.listExpr);if(!Array.isArray(t))return q(`span`,{class:`error`,children:`{for error: expression did not evaluate to an array}`});a=t}catch(e){return q(Sf,{macro:`for`,error:e})}let{itemVar:o,indexVar:s}=i,c=a.map((e,n)=>q(OS,{parentValues:r,itemVar:o,itemValue:e,indexVar:s,indexValue:n,children:t},`${n}-${TS(e)}`));return n.wrap(c)},text({rawArgs:e,children:t=[]},n){let{itemVar:r,indexVar:i,listExpr:a}=DS(e,n.args),o=n.evaluate(a);if(!Array.isArray(o))throw Error(`expression did not evaluate to an array`);return o.map((e,a)=>n.renderText(t,{[r]:e,...i?{[i]:a}:void 0})).join(``)}}),$({name:`do`,block:!0,render({children:e=[]},t){let n=t.collectText(e);return t.hooks.useLayoutEffect(()=>{let e=t.sourceLocation();try{t.mutate(n)}catch(t){Cf(`do`,t,e)}},[]),null}});function kS(e){return new Proxy(K(),{get:(t,n)=>typeof n==`string`?ws(e(),n):void 0,has:(t,n)=>typeof n==`string`&&G(e(),n),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>{let r=Object.getOwnPropertyDescriptor(e(),n);return r?{...r,configurable:!0}:void 0}})}var AS=_e({stop:()=>{}});$({name:`repeat`,block:!0,interpolate:!0,parameters:[Yb],render({children:e=[]},t){let{useState:n,useEffect:r,useCallback:i}=t.hooks,a=t.args.delay??0,[o,s]=n(0),[c,l]=n(!1),u=i(()=>l(!0),[]);if(r(()=>{if(c)return;let e=setInterval(()=>{s(e=>e+1)},a);return()=>clearInterval(e)},[a,c]),o===0&&!c)return null;let d=q(AS.Provider,{value:{stop:u},children:q(`span`,{children:t.renderNodes(e)},o)});return t.className||t.id?q(`span`,{id:t.id,class:t.cls,children:d}):d}});function jS(){let e=Ie(Df),{nobr:t,inline:n}=tl(),r=Ie(Pf),i=Ie(AS),a=Ie($y),o=o=>{let s=kS(e.getValues),c=document.createElement(`div`);ge(q(Df.Provider,{value:e,children:q(Ef.Provider,{value:s,children:q(Of.Provider,{value:t,children:q(kf.Provider,{value:n,children:q(Pf.Provider,{value:r,children:q(AS.Provider,{value:i,children:q($y.Provider,{value:a,children:Cp(o,{nobr:t,inline:n,locals:s})})})})})})})}),c),ge(null,c)};return e=>nv(()=>o(e))}$({name:`button`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,required:!0}],render({rawArgs:e,children:t=[]},n){let r=n.resolve?.(n.args.label??``)??e,i=jS(),a=()=>i(t);return n.useAction({type:`button`,key:e,authorId:n.id,label:r,perform:a}),q(`button`,{id:n.id,class:n.cls,onClick:a,children:r})}}),$({name:`link`,block:!0,interpolate:!0,merged:!0,parameters:[{name:`text`,type:`string`,required:!0},{name:`passage`,type:`passage`}],render({children:e=[]},t){let n=t.args.text??``,r=null,i;if(t.args.passage!==void 0)try{r=Zb(t.args.passage,t.evaluate,Q.getState())}catch(e){i={error:e}}let a=jS(),o=()=>{a(e),r&&Q.getState().navigate(r)};return t.useAction({type:`link`,key:r||n,authorId:t.id,label:n,target:r??void 0,perform:o}),i?q(Sf,{macro:`link`,error:i.error}):q(`a`,{id:t.id,class:t.cls,href:`#`,onClick:e=>{e.preventDefault(),o()},children:n})}});function MS(e,t,n){return CS(t.slice(1),t=>e===n(t))}$({name:`switch`,subMacros:[`case`,`default`],parameters:[{name:`expression`,type:`expression`,required:!0}],merged:!0,render({rawArgs:e,branches:t=[]},n){let r;try{r=n.evaluate(e)}catch(e){return q(Sf,{macro:`switch`,error:e})}let i;try{i=MS(r,t,n.evaluate)}catch(e){return q(Sf,{macro:`case`,error:e})}return i&&q(S,{children:n.renderNodes(i.children)})},text({rawArgs:e,branches:t=[]},n){let r=MS(n.evaluate(e),t,n.evaluate);return r?n.renderText(r.children):``}});var NS=[Yb];$({name:`timed`,subMacros:[`next`],interpolate:!0,parameters:NS,render({branches:e=[]},t){let{useState:n,useEffect:r,useMemo:i}=t.hooks,a=i(()=>e.map(e=>({delay:Xb(e.rawArgs,NS).delay??0,nodes:e.children,className:e.className,id:e.id})),[e]),[o,s]=n(-1);if(r(()=>{if(o>=a.length-1)return;let e=o+1,t=a[e].delay,n=setTimeout(()=>{s(e)},t);return()=>clearTimeout(n)},[o,a]),o<0)return t.wrap(null);let c=a[o];return t.wrap(Pc(t.resolve(c.className),t.resolve(c.id),t.renderNodes(c.nodes)))}}),$({name:`stop`,render(e,t){let{stop:n}=t.hooks.useContext(AS);return t.hooks.useLayoutEffect(()=>{n()},[n]),null}}),$({name:`type`,block:!0,interpolate:!0,parameters:[Yb],render({children:e=[]},t){let{useState:n,useEffect:r,useRef:i}=t.hooks,a=t.args.delay??0,o=i(null),[s,c]=n(0),[l,u]=n(0),d=i(0);d.current=l,r(()=>{o.current&&c((o.current.textContent||``).length)},[]),r(()=>{if(s===0||d.current>=s)return;let e=setInterval(()=>{u(t=>t>=s?(clearInterval(e),t):t+1)},a);return()=>clearInterval(e)},[s,a]);let f=l>=s&&s>0,p=[`macro-type`,f?`macro-type-done`:``,t.className||``].filter(Boolean).join(` `);return q(`span`,{id:t.id,class:p,ref:o,style:{clipPath:void 0},children:[q(`span`,{class:`macro-type-inner`,style:{display:`inline`,visibility:s===0?`hidden`:`visible`,clipPath:s>0&&!f?`inset(0 ${(s-l)/s*100}% 0 0)`:void 0},children:t.renderInlineNodes(e)}),!f&&s>0&&q(`span`,{class:`macro-type-cursor`})]})}}),$({name:`story-title`,render(e,t){let n=Q(e=>e.storyData?.name||``),r=t.className?`story-title ${t.className}`:`story-title`;return q(`span`,{id:t.id,class:r,children:n})},text:()=>Q.getState().storyData?.name||``});function PS(e,t){return t?`${e} (${t})`:e}function FS(e){$({name:e.name,render(t,n){if(e.hidden?.())return null;let[r,i]=Ae(!1),a=e.setup?.()??{perform:()=>{}},{disabled:o,title:s=e.title}=a,c=n.className?`menubar-button ${n.className}`:`menubar-button`,l=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}),q(S,{children:[q(`button`,{id:n.id,class:c,onClick:l,disabled:o,title:s,children:e.label}),e.dialog&&r&&q(eb,{passageName:e.dialog.passageName,fallbackMarkup:e.dialog.fallbackMarkup,panelClass:e.dialog.panelClass,onClose:()=>i(!1),showCloseButton:e.dialog.showCloseButton})]})}})}FS({name:`back`,label:`← Back`,actionType:`back`,setup:()=>({perform:Q(e=>e.goBack),disabled:!Q(e=>e.historyIndex>0)})}),FS({name:`forward`,label:`Forward →`,actionType:`forward`,setup:()=>({perform:Q(e=>e.goForward),disabled:!Q(e=>e.historyIndex<e.history.length-1)})}),FS({name:`quicksave`,label:`QuickSave`,actionType:`save`,setup:()=>{let{save:e,quickSaveKey:t}=es(`save`,`quickSaveKey`);return{perform:e,title:PS(`Quick Save`,t)}}}),FS({name:`quickload`,label:`QuickLoad`,actionType:`load`,confirm:`Load saved game? Current progress will be lost.`,setup:()=>{let{load:e,hasSave:t,quickLoadKey:n}=es(`load`,`hasSave`,`quickLoadKey`,`knownSaves`);return{perform:()=>e(),disabled:!t(),title:PS(`Quick Load`,n)}}}),FS({name:`restart`,label:`↺ Restart`,actionType:`restart`,confirm:`Restart the story? All progress will be lost.`,setup:()=>({perform:Q(e=>e.restart)})}),FS({name:`saves`,label:`Saves`,actionType:`dialog`,dialog:{passageName:`SaveLoad`,fallbackMarkup:`{save-manager}`,panelClass:`dialog-saves`}}),FS({name:`settings`,label:`Settings`,actionType:`dialog`,hidden:()=>!bb.hasAny(),dialog:{passageName:`Settings`,fallbackMarkup:`{settings-controls}`,panelClass:`dialog-settings`}}),$({name:`dialog`,block:!0,interpolate:!0,parameters:[{name:`label`,type:`text`,required:!0},{name:`noclose`,type:`flag`}],render({children:e=[]},t){let[n,r]=t.hooks.useState(!1),{noclose:i}=t.args,a=t.resolve(t.args.label??``),o=t.collectText(e).trim().replace(/^[\"']|[\"']$/g,``);return q(S,{children:[q(`button`,{id:t.id,class:t.cls,onClick:()=>r(!0),children:a}),n&&q(eb,{passageName:o,onClose:()=>r(!1),showCloseButton:!i})]})}});function IS(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:new Date(e).toLocaleDateString()}function LS(e){return new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function RS(){let[e,t]=Ae(`load`),[n,r]=Ae([]),[i,a]=Ae(!0),[o,s]=Ae(null),[c,l]=Ae(()=>new Set),[u,d]=Ae(null),[f,p]=Ae(``),m=j(null),h=j(null),g=Ie($y),{storyData:_,playthroughId:v,beginSave:y,loadFromPayload:b}=es(`storyData`,`playthroughId`,`beginSave`,`loadFromPayload`),x=_?.ifid??``,S=Fe(async()=>{x&&(r(await Jg(x)),a(!1))},[x]);Me(()=>{S()},[S]),Me(()=>{u&&m.current&&(m.current.focus(),m.current.select())},[u]);let C=j(!0),w=j(),T=j(),E=(e,t=`success`)=>{C.current&&(clearTimeout(w.current),s({text:e,type:t}),w.current=window.setTimeout(()=>s(null),3e3))};Me(()=>(C.current=!0,()=>{C.current=!1,clearTimeout(w.current),clearTimeout(T.current)}),[]);let ee=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},D=async()=>{if(!x)return;let e=_y();try{await Rg(void 0,void 0,y,async t=>{let n=await e;if(!n)throw Error(`No playthrough`);return Bg(x,n,t)}),E(`Save created`),await S()}catch{E(`Failed to create save`,`error`)}},te=async e=>{let t=_y();try{await Rg(void 0,void 0,y,async n=>{if(!await Hg(e,n,void 0,await t||void 0))throw Error(`Save not found`)}),E(`Save overwritten`),await S()}catch{E(`Failed to overwrite save`,`error`)}},ne=async e=>{try{b(Gg(e.payload),void 0,e.meta.playthroughId),E(`Game loaded`),g&&(T.current=window.setTimeout(g,500)),await S()}catch{E(`Failed to load save`,`error`)}},re=async e=>{if(confirm(`Delete this save?`))try{await Kg(e);let t=await p_(x);Q.setState(e=>{e.knownSaves=t}),E(`Save deleted`),await S()}catch{E(`Failed to delete save`,`error`)}},ie=e=>{d(e.meta.id),p(e.meta.title)},O=async()=>{if(!(!u||!f.trim()))try{await qg(u,f.trim()),d(null),E(`Save renamed`),await S()}catch{E(`Failed to rename`,`error`)}},ae=e=>{e.key===`Enter`?O():e.key===`Escape`&&d(null)},oe=async e=>{try{let t=await w_(e);if(!t)return;let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`save-${t.save.meta.title.replace(/[^a-z0-9]/gi,`_`)}.json`,i.click(),URL.revokeObjectURL(r),E(`Save exported`)}catch{E(`Failed to export save`,`error`)}},se=()=>{h.current?.click()},ce=async e=>{let t=e.target,n=t.files?.[0];if(n){t.value=``;try{let e=await n.text(),t=JSON.parse(e);if(!ch(t))throw Error(`Invalid save file format`);await E_(t,x),E(`Save imported`),await S()}catch(e){E(Jc(e,`Failed to import save`),`error`)}}},le=n.reduce((e,t)=>e+t.saves.length,0);return q(`div`,{class:`save-manager`,children:[q(`div`,{class:`saves-header`,children:q(`div`,{class:`saves-header-left`,children:q(`div`,{class:`saves-mode-toggle`,children:[q(`button`,{class:e===`save`?`active`:``,onClick:()=>t(`save`),children:`Save`}),q(`button`,{class:e===`load`?`active`:``,onClick:()=>t(`load`),children:`Load`})]})})}),q(`div`,{class:`saves-toolbar`,children:[q(`button`,{class:`saves-toolbar-button`,onClick:se,children:`Import`}),q(`input`,{ref:h,type:`file`,accept:`.json`,style:`display:none`,onChange:ce})]}),q(`div`,{class:`saves-body`,children:[i?q(`div`,{class:`saves-empty`,children:`Loading...`}):le===0&&e===`load`?q(`div`,{class:`saves-empty`,children:`No saves yet`}):n.map(t=>{let n=c.has(t.playthrough.id),r=t.playthrough.id===v;return e===`save`&&!r||e===`load`&&t.saves.length===0&&!r?null:q(`div`,{class:`playthrough-group`,children:[q(`div`,{class:`playthrough-header`,onClick:()=>ee(t.playthrough.id),children:[q(`span`,{class:`playthrough-chevron ${n?``:`open`}`,children:`▶`}),q(`span`,{class:`playthrough-label`,children:[t.playthrough.label,r?` (current)`:``]}),q(`span`,{class:`playthrough-date`,children:LS(t.playthrough.createdAt)})]}),!n&&q(`div`,{class:`playthrough-saves`,children:[t.saves.map(t=>q(`div`,{class:`save-slot`,children:[q(`div`,{class:`save-slot-info`,children:[u===t.meta.id?q(`input`,{ref:m,class:`save-rename-input`,value:f,onInput:e=>p(e.target.value),onKeyDown:ae,onBlur:O}):q(`div`,{class:`save-slot-title`,children:t.meta.title}),q(`div`,{class:`save-slot-meta`,children:[q(`span`,{children:t.meta.passage}),q(`span`,{children:IS(t.meta.updatedAt)})]})]}),q(`div`,{class:`save-slot-actions`,children:[e===`save`?q(`button`,{class:`save-slot-action primary`,onClick:()=>te(t.meta.id),children:`Save Here`}):q(`button`,{class:`save-slot-action primary`,onClick:()=>ne(t),children:`Load`}),q(`button`,{class:`save-slot-action`,onClick:()=>ie(t),children:`Rename`}),q(`button`,{class:`save-slot-action`,onClick:()=>oe(t.meta.id),children:`Export`}),q(`button`,{class:`save-slot-action danger`,onClick:()=>re(t.meta.id),children:`Delete`})]})]},t.meta.id)),e===`save`&&r&&q(`button`,{class:`save-slot-new`,onClick:D,children:`+ New Save`})]})]},t.playthrough.id)}),e===`save`&&!i&&!n.some(e=>e.playthrough.id===v)&&q(`div`,{class:`playthrough-group`,children:q(`div`,{class:`playthrough-saves`,children:q(`button`,{class:`save-slot-new`,onClick:D,children:`+ New Save`})})})]}),o&&q(`div`,{class:`saves-status ${o.type===`error`?`error`:``}`,children:o.text})]})}$({name:`save-manager`,render(){return q(RS,{})}});function zS({name:e,def:t}){let[n,r]=Ae(()=>bb.get(e)),i=t=>{r(t),bb.set(e,t)};switch(t.type){case`toggle`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`input`,{type:`checkbox`,checked:!!n,onChange:e=>i(e.target.checked)})]});case`list`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:t.config.label}),q(`select`,{value:String(n),onChange:e=>i(e.target.value),children:t.config.options.map(e=>q(`option`,{value:e,children:e},e))})]});case`range`:return q(`label`,{class:`settings-row`,children:[q(`span`,{children:[t.config.label,`: `,String(n)]}),q(`input`,{type:`range`,min:t.config.min,max:t.config.max,step:t.config.step,value:Number(n),onInput:e=>i(parseFloat(e.target.value))})]})}}function BS(){let e=bb.getDefinitions();return q(`div`,{class:`settings-controls`,children:Array.from(e.entries()).map(([e,t])=>q(zS,{name:e,def:t},e))})}$({name:`settings-controls`,render(){return q(BS,{})}}),$({name:`include`,interpolate:!0,merged:!0,parameters:[{name:`inline`,type:`flag`},{name:`passage`,type:`passage`,required:!0}],render(e,t){let{storyData:n}=es(`storyData`),{inline:r}=t.args,i=``,a;try{i=Zb(t.args.passage,t.evaluate,Q.getState())}catch(e){a={error:e}}let o=n?.passages.get(i),s=t.hooks.useMemo(()=>o?qo(o.content):null,[o]);if(!n)return null;if(a)return q(Sf,{macro:`include`,error:a.error});if(!o||!s)return null;Q.getState().trackRender(i);let c=o.tags.includes(`nobr`),l=r?t.renderInlineNodes(s):t.renderNodes(s,c?{nobr:!0}:void 0);return c?t.wrap(t.h(Of.Provider,{value:!0},l)):t.wrap(l)}}),$({name:`nobr`,block:!0,render({children:e=[]},t){return t.wrap(t.h(Of.Provider,{value:!0},t.renderNodes(e,{nobr:!0})))},text:({children:e=[]},t)=>t.renderText(e)}),$({name:`goto`,merged:!0,parameters:[{name:`passage`,type:`passage`,required:!0}],render(e,t){let[n,r]=t.hooks.useState();return t.hooks.useLayoutEffect(()=>{let e=t.sourceLocation();try{let e=Q.getState();e.navigate(Zb(t.args.passage,t.evaluate,e))}catch(t){Cf(`goto`,t,e),r({error:t})}},[]),n?q(Sf,{macro:`goto`,error:n.error}):null}}),$({name:`unset`,parameters:[{name:`variable`,type:`variable`,required:!0}],render({rawArgs:e},t){return wf(`unset`,e,()=>{let e=Q.getState(),n=t.args.variable??``;if(n.startsWith(`$`))e.deleteVariable(n.slice(1));else if(n.startsWith(`_`))e.deleteTemporary(n.slice(1));else if(n.startsWith(`%`))e.deleteTransient(n.slice(1));else if(n.startsWith(`@`))t.update(n.slice(1),void 0);else throw Error(`{unset} expects a variable ($name, _name, %name, or @name), got \"${n}\"`)})}});var VS={name:`variable`,type:`variable`,required:!0};function HS(e,t){return e.useAction({key:`$${e.varName}`,authorId:e.id,variable:e.varName,value:e.value,...t})}function US(e,t,n=e=>e===void 0?``:String(e)){$({name:e,storeVar:!0,parameters:[VS,{name:`placeholder`,type:`string`}],render(r,i){let a=i.args.placeholder??``;return HS(i,{type:e,label:a||i.varName,perform:e=>i.setValue(n(e))}),b(t?`input`:`textarea`,{type:t,id:i.id,class:i.cls,value:Nc(i.value),placeholder:a,onInput:e=>i.setValue(n(e.target.value))})}})}US(`textbox`,`text`),US(`numberbox`,`number`,e=>e===void 0?0:Number(e)),US(`textarea`),$({name:`checkbox`,storeVar:!0,parameters:[VS,{name:`label`,type:`text`}],render(e,t){let n=t.args.label??``;return HS(t,{type:`checkbox`,label:n||t.varName||``,value:!!t.value,perform:e=>t.setValue(e===void 0?!t.value:!!e)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`checkbox`,checked:!!t.value,onChange:()=>t.setValue(!t.value)}),n?` ${n}`:null]})}}),$({name:`radiobutton`,storeVar:!0,parameters:[VS,{name:`value`,type:`text`,required:!0},{name:`label`,type:`text`}],render(e,t){let n=t.args.value??``,r=t.args.label??``;return HS(t,{type:`radiobutton`,key:`$${t.varName}:${n}`,label:r||n,perform:()=>t.setValue(n)}),q(`label`,{id:t.id,class:t.cls,children:[q(`input`,{type:`radio`,name:`radio-${t.varName}`,checked:t.value===n,onChange:()=>t.setValue(n)}),r?` ${r}`:null]})}}),$({name:`listbox`,subMacros:[`option`],storeVar:!0,parameters:[VS],render({children:e=[]},t){let n=t.extractOptions(e);return HS(t,{type:`listbox`,label:t.varName,options:n,perform:e=>{e!==void 0&&t.setValue(String(e))}}),q(`select`,{id:t.id,class:t.cls,value:Nc(t.value),onChange:e=>t.setValue(e.target.value),children:n.map(e=>q(`option`,{value:e,children:e},e))})}}),$({name:`cycle`,block:!0,storeVar:!0,parameters:[VS],render({children:e=[]},t){let n=t.extractOptions(e),r=()=>{if(n.length===0)return;let e=t.getValue(),r=(n.indexOf(String(e))+1)%n.length;t.setValue(n[r])};return HS(t,{type:`cycle`,label:t.value==null?n[0]||``:String(t.value),options:n,perform:e=>{e===void 0?r():t.setValue(e)}}),q(`button`,{id:t.id,class:t.cls,onClick:r,children:t.value==null?n[0]||``:String(t.value)})}}),$({name:`span`,block:!0,render({children:e=[]},t){return t.wrap(t.renderNodes(e))},text:({children:e=[]},t)=>t.renderText(e)});var WS=new WeakMap;function GS(e){let t=WS.get(e);if(t&&t.content===e.content)return t.ast;let n=qo(e.content);return WS.set(e,{content:e.content,ast:n}),n}function KS(e){return Cp(GS(e),e.tags.includes(`nobr`)?{nobr:!0}:void 0)}function qS(e){if(!e)return null;try{return KS(e)}catch(t){return console.error(`spindle: Error in ${e.name}:`,t),null}}var JS=new Set([`PassageReady`,`PassageHeader`,`PassageFooter`,`PassageDone`]);function YS({passage:e,dataTransition:t,navigationId:n}){let{storyData:r}=es(`storyData`),i=JS.has(e.name),[a,o]=Ae(!1),s=Pe(()=>{try{return KS(e)}catch(t){return q(`div`,{class:`error`,children:[`Error parsing passage “`,e.name,`”`,bf(e),`: `,Jc(t)]})}},[e.content,e.name]),c=e=>i?void 0:r?.passages.get(e),l=c(`PassageHeader`),u=c(`PassageFooter`),d=c(`PassageDone`),f=Pe(()=>qS(l),[l?.content]),p=Pe(()=>qS(u),[u?.content]);Me(()=>(d&&o(!0),()=>o(!1)),[e.name]);let m=Pe(()=>a?qS(d):null,[a,d?.content]),h=j(null);Ne(()=>{n!==void 0&&ox(n),h.current&&_g(`passagerender`,e.name,h.current)},[e.name,n]);let g=e.tags.includes(`nobr`),_=q(`div`,{ref:h,class:`passage`,\"data-passage\":e.name,\"data-tags\":e.tags.join(` `),\"data-transition\":t,children:[f&&q(`div`,{class:`passage-header`,children:f}),s,p&&q(`div`,{class:`passage-footer`,children:p}),m&&q(`div`,{hidden:!0,children:m})]});return g?q(Of.Provider,{value:!0,children:_}):_}var XS=new Set([`none`,`fade`,`fade-through`,`crossfade`]),ZS={type:`fade-through`,duration:300,pause:50};function QS(e){let t=e.find(e=>e.startsWith(`transition:`));if(!t)return null;let n=t.slice(11);if(!XS.has(n))return console.warn(`Unknown transition type: \"${n}\"`),null;let r={type:n};for(let t of e)if(t.startsWith(`duration:`)){let e=Number(t.slice(9));Number.isNaN(e)||(r.duration=e)}else if(t.startsWith(`pause:`)){let e=Number(t.slice(6));Number.isNaN(e)||(r.pause=e)}return r}function $S(e){return{type:e.type,duration:e.duration??ZS.duration,pause:e.pause??ZS.pause}}function eC(e,t,n){let r=QS(e);return r?$S(r):t?$S(t):n?$S(n):{...ZS}}function tC(e,t){let n=e.cloneNode(!0);n.removeAttribute(`id`);let r=n.querySelectorAll(`[id]`);for(let e=0;e<r.length;e++)r[e].removeAttribute(`id`);n.style.pointerEvents=`none`,n.style.userSelect=`none`;let i=n.querySelectorAll(`audio, video`);for(let e=0;e<i.length;e++){let t=i[e];t.pause?.(),t.muted=!0}return n.classList.remove(`passage`),n.classList.add(`passage-snapshot`),n.setAttribute(`data-transition`,t),n}function nC(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 rC(e,t){if(!e)return null;nC(e,t);let n=e.querySelector(`.passage`);return n?tC(n,t.type):null}function iC(e){if(!e)return;e.classList.remove(`passage-container--crossfading`);let t=e.querySelectorAll(`.passage-snapshot`);for(let e=0;e<t.length;e++)t[e].remove()}$({name:`passage`,interpolate:!0,render(e,t){let{currentPassage:n,navigationId:r,storyData:i,renderDeferred:a}=es(`currentPassage`,`navigationId`,`storyData`,`renderDeferred`),[o,s]=Ae({passage:n,id:r}),c=o.passage,l=e=>s({passage:e,id:r}),u=j(`fade`),d=j(0),f=j(null),p=j([]),m=Fe(()=>{for(let e of p.current)clearTimeout(e);p.current=[],iC(f.current)},[]);Me(()=>m,[m]),Me(()=>{let e=Q.getState(),{history:t,historyIndex:a,transitionConfig:s}=e,h=e.consumeNextTransition(),g=d.current;d.current=t.length;let _=!c,v=t.length===1&&a===0&&g>1,y=t.length>1&&a===t.length-1&&g>1&&Math.abs(t.length-g)>1;if(r===o.id)return;m();let b=i?.passages.get(n);if(!b){u.current=`none`,l(n);return}if(_||v||y){u.current=`fade`,l(n);return}let x=eC(b.tags,h,s);u.current=x.type;let S=f.current;if(x.type===`none`){l(n);return}if(x.type===`fade`){S&&nC(S,x),l(n);return}let C=x.type===`fade-through`||x.type===`crossfade`?rC(S,x):null;if(!S||!C){l(n);return}if(x.type===`fade-through`){S.appendChild(C),l(``);let e=x.duration+x.pause,t=setTimeout(()=>{l(n)},e),r=e+x.duration;p.current=[t,setTimeout(()=>{iC(S)},r)];return}S.classList.add(`passage-container--crossfading`),S.appendChild(C),l(n),p.current=[setTimeout(()=>{iC(S)},x.duration)]},[r]);let h=a?i?.passages.get(`StoryLoading`)??null:c?i?.passages.get(c):null;if(!h&&c&&!a)return q(`div`,{class:`error`,children:[`Error: Passage “`,c,`” not found.`]});let g=i?.passages.get(`PassageReady`);return q(`div`,{id:t.id??`story`,class:t.className??`story`,children:[!a&&g&&q(`div`,{hidden:!0,children:KS(g)},`ready-${r}`),q(`div`,{class:`passage-container`,ref:f,children:h&&q(YS,{passage:h,dataTransition:a?`none`:u.current,navigationId:a?void 0:o.id},a?`loading`:`nav-${o.id}`)})]})}}),$({name:`watch`,parameters:[{name:`condition`,type:`string`,required:!0},{name:`options`,type:`options`,parameters:[{name:`goto`,type:`string`},{name:`dialog`,type:`string`},{name:`run`,type:`string`},{name:`name`,type:`string`},{name:`priority`,type:`number`},{name:`once`,type:`flag`}]}],render(e,t){let{hooks:n}=t,{condition:r,options:i}=t.args;if(r===void 0)return null;let a=n.useRef(!1);return a.current||(a.current=!0,fv(r,i)),null}}),$({name:`unwatch`,parameters:[{name:`name`,type:`text`,required:!0}],render(e,t){let n=t.args.name??``,r=t.hooks.useRef(!1);return r.current||(r.current=!0,pv(n)),null}});var aC=`*,:before,:after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;font-size:16px}body{color:#e0e0e0;background-color:#1a1a2e;min-height:100vh;margin:0;padding:0;font-family:Georgia,Times New Roman,serif;line-height:1.75}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;-webkit-user-select: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:10ms!important}}.macro-button{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;font-size:.95em;transition:background .2s,border-color .2s}.macro-button:hover{background:#64b5f640;border-color:#90caf9}.macro-button:active{background:#64b5f659}.error{color:#ef5350;background:#ef53501a;border:1px solid #ef5350;border-radius:4px;padding:1em;font-family:monospace}.spindle-error-banners{z-index:300;flex-direction:column;gap:.5em;width:min(42em,100% - 1.5em);display:flex;position:fixed;top:.75em;left:50%;transform:translate(-50%)}.spindle-error-banner{color:#ffcdd2;background:#2b1a1e;border:1px solid #ef5350;border-radius:4px;padding:.75em 2.75em .75em 1em;font-size:.9em;line-height:1.5;position:relative;box-shadow:0 2px 12px #00000080}.spindle-error-banner-message{color:#ef9a9a;font-family:monospace}.spindle-error-banner-dismiss{color:inherit;cursor:pointer;background:0 0;border:none;font-size:1em;position:absolute;top:.5em;right:.5em}.spindle-error-banner-dismiss:hover{color:#fff}.loading{text-align:center;opacity:.6;padding:2em}.story-menubar{z-index:100;background:#16213e;border-bottom:1px solid #ffffff14;align-items:center;gap:.5em;padding:.5em 1.5em;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:.9em;display:flex;position:sticky;top:0}.story-title{color:#e0e0e0;white-space:nowrap;text-overflow:ellipsis;flex:1;font-weight:600;overflow:hidden}.menubar-button{color:#9e9e9e;cursor:pointer;font:inherit;background:0 0;border:1px solid #0000;border-radius:4px;padding:.35em .7em;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:0 0}.dialog-overlay{z-index:200;background:#0009;justify-content:center;align-items:center;display:flex;position:fixed;top:0;bottom:0;left:0;right:0}.dialog-panel{color:#e0e0e0;background:#16213e;border:1px solid #ffffff1a;border-radius:8px;flex-direction:column;width:90%;max-width:500px;max-height:80vh;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;display:flex;position:relative}.dialog-panel:focus{outline:none}.dialog-saves{max-width:550px}.dialog-settings{max-width:400px}.dialog-close{z-index:1;color:#9e9e9e;cursor:pointer;background:0 0;border:none;padding:.25em;font-size:1.1em;line-height:1;position:absolute;top:.75em;right:.75em}.dialog-close:hover{color:#e0e0e0}.dialog-body{flex:1;min-height:0;overflow-y:auto}.settings-controls{flex-direction:column;gap:1em;padding:1em 1.25em;display:flex}.settings-row{justify-content:space-between;align-items:center;gap:1em;display:flex}.settings-row select,.settings-row input[type=range]{accent-color:#64b5f6}.settings-row select{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.settings-row input[type=checkbox]{accent-color:#64b5f6;width:1.1em;height:1.1em}.save-manager{flex-direction:column;flex:1;min-height:0;display:flex}.saves-header{border-bottom:1px solid #ffffff14;flex-shrink:0;justify-content:space-between;align-items:center;padding:1em 3em 1em 1.25em;font-weight:600;display:flex}.saves-header-left{align-items:center;gap:.75em;display:flex}.saves-mode-toggle{border:1px solid #ffffff26;border-radius:4px;gap:0;display:flex;overflow:hidden}.saves-mode-toggle button{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:none;padding:.3em .8em;font-size:.85em;font-weight:600;transition:background .2s,color .2s}.saves-mode-toggle button.active{color:#64b5f6;background:#64b5f633}.saves-mode-toggle button:hover:not(.active){color:#e0e0e0}.saves-body{flex:1;min-height:0;padding:.75em 1.25em;overflow-y:auto}.saves-empty{text-align:center;opacity:.5;padding:2em 1em;font-size:.9em}.saves-toolbar{border-bottom:1px solid #ffffff14;flex-shrink:0;gap:.5em;padding:.5em 1.25em;display:flex}.saves-toolbar-button{color:#9e9e9e;font:inherit;cursor:pointer;background:#ffffff0d;border:1px solid #ffffff1a;border-radius:4px;padding:.3em .7em;font-size:.8em;transition:background .2s,color .2s}.saves-toolbar-button:hover{color:#e0e0e0;background:#ffffff1a}.playthrough-group{margin-bottom:.75em}.playthrough-header{cursor:pointer;-webkit-user-select:none;user-select:none;color:#9e9e9e;align-items:center;gap:.5em;padding:.4em 0;font-size:.85em;transition:color .2s;display:flex}.playthrough-header:hover{color:#e0e0e0}.playthrough-chevron{font-size:.7em;transition:transform .2s;display:inline-block}.playthrough-chevron.open{transform:rotate(90deg)}.playthrough-label{font-weight:600}.playthrough-date{opacity:.6;font-size:.9em}.playthrough-saves{flex-direction:column;gap:.4em;padding-left:.25em;display:flex}.save-slot{background:#ffffff08;border:1px solid #ffffff0f;border-radius:6px;align-items:center;gap:.75em;padding:.5em .6em;transition:background .15s;display:flex}.save-slot:hover{background:#ffffff0f}.save-slot-info{flex:1;min-width:0}.save-slot-title{white-space:nowrap;text-overflow:ellipsis;font-size:.9em;font-weight:500;overflow:hidden}.save-slot-meta{color:#9e9e9e;gap:.75em;font-size:.75em;display:flex}.save-slot-actions{flex-shrink:0;gap:.3em;display:flex}.save-slot-action{color:#9e9e9e;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:1px solid #0000;border-radius:3px;padding:.2em .5em;font-size:.75em;transition:color .2s,background .2s}.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{color:#9e9e9e;font:inherit;cursor:pointer;background:0 0;border:1px dashed #ffffff1f;border-radius:6px;justify-content:center;align-items:center;width:100%;margin-top:.25em;padding:.5em;font-size:.8em;transition:color .2s,border-color .2s,background .2s;display:flex}.save-slot-new:hover{color:#64b5f6;background:#64b5f60d;border-color:#64b5f64d}.saves-status{color:#81c784;text-align:center;border-top:1px solid #ffffff14;flex-shrink:0;padding:.5em 1.25em;font-size:.8em}.saves-status.error{color:#ef5350;background:0 0;border:none;border-radius:0;padding:.5em 1.25em;font-family:inherit}.save-rename-input{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #64b5f666;border-radius:3px;width:100%;padding:.15em .4em;font-size:.9em}.save-rename-input:focus{border-color:#64b5f6;outline:none}.macro-link{color:#64b5f6;cursor:pointer;border-bottom:1px solid #64b5f64d;text-decoration:none;transition:color .2s,border-color .2s}.macro-link:hover{color:#90caf9;border-bottom-color:#90caf9}.macro-link:active{color:#42a5f5}.macro-textbox,.macro-numberbox,.macro-textarea{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-textbox:focus,.macro-numberbox:focus,.macro-textarea:focus{border-color:#64b5f6;outline:none}.macro-textarea{resize:vertical;min-height:3em}.macro-checkbox,.macro-radiobutton{cursor:pointer;align-items:center;gap:.3em;display:inline-flex}.macro-checkbox input,.macro-radiobutton input{accent-color:#64b5f6}.macro-listbox{color:#e0e0e0;font:inherit;background:#1a1a2e;border:1px solid #ffffff26;border-radius:4px;padding:.3em .5em}.macro-cycle{color:#64b5f6;font:inherit;cursor:pointer;background:#64b5f626;border:1px solid #64b5f666;border-radius:4px;padding:.25em .75em;transition:background .2s,border-color .2s}.macro-cycle:hover{background:#64b5f640;border-color:#90caf9}.macro-meter{background:#2a2a3e;border:1px solid #444;border-radius:.3em;width:100%;height:1.4em;position:relative;overflow:hidden}.macro-meter-fill{background:#64b5f6;height:100%;transition:width .3s}.macro-meter-label{color:#e0e0e0;text-shadow:0 1px 2px #000c;pointer-events:none;justify-content:center;align-items:center;font-size:.85em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}.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{color:#f0f0f0;margin:1em 0 .4em;line-height:1.3}.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{opacity:.8;font-size:.9em}.passage code{background:#ffffff14;border-radius:3px;padding:.15em .35em;font-family:Fira Code,Cascadia Code,Consolas,monospace;font-size:.9em}.passage pre{background:#0000004d;border:1px solid #ffffff14;border-radius:6px;margin:.8em 0;padding:1em;overflow-x:auto}.passage pre code{background:0 0;border-radius:0;padding:0;font-size:.85em}.passage blockquote{color:#b0b0b0;border-left:3px solid #64b5f680;margin:.8em 0;padding:.4em 1em}.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 #ffffff1f;margin:1.2em 0}.passage table{border-collapse:collapse;width:100%;margin:.8em 0}.passage th,.passage td{text-align:left;border:1px solid #ffffff1f;padding:.5em .75em}.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:\"█\";color:#64b5f6;animation:.7s step-end infinite type-blink}.macro-type-done .macro-type-cursor:after{display:none}@keyframes type-blink{50%{opacity:0}}`;function oC(e,t){e.innerHTML=``;let n=document.createElement(`div`);n.style.cssText=`font-family:monospace;padding:2rem;max-width:60rem;margin:0 auto`;let r=document.createElement(`h1`);r.style.color=`#c00`,r.textContent=`Story Validation Errors`,n.appendChild(r);let i=document.createElement(`ul`);i.style.cssText=`line-height:1.6`;for(let e of t){let t=document.createElement(`li`);t.textContent=e,i.appendChild(t)}n.appendChild(i),e.appendChild(n)}function sC(e){let t=document.getElementById(`root`);throw t&&oC(t,e),Error(`spindle: ${e.length} validation error(s):\\n${e.join(`\n`)}`)}function cC(e,t){let n=mc(),r=new Map(n.map(e=>[e.name.toLowerCase(),e.parameters]));return hS(e.passages.values(),{isKnownMacro:e=>!!rc(e)||lc(e)||!!_c(e),macroNames:n.map(e=>e.name),parametersOf:e=>r.get(e),only:t}).map(lS)}function lC(){let e=ub(),t=document.createElement(`style`);if(t.id=`spindle-styles`,t.textContent=aC,document.head.appendChild(t),Sx(),e.userCSS){let t=document.createElement(`style`);t.textContent=e.userCSS,document.head.appendChild(t)}if(e.userScript)try{Function(e.userScript)()}catch(e){console.error(`spindle: Error in story JavaScript:`,e)}document.dispatchEvent(new CustomEvent(`:storystartup`));let n={},r=e.passages.get(`StoryVariables`);if(!r){let e=`Missing StoryVariables passage. Add a :: StoryVariables passage to declare your variables.`,t=document.getElementById(`root`);throw t&&oC(t,[e]),Error(`spindle: ${e}`)}let i=Hx(r.content),a=mc().filter(e=>e.storeVar).map(e=>e.name);for(let t of aS(e.passages.values()))hr(t);let o=$x(e.passages,i,a);o.push(...cC(e,e=>e.name===`StoryInit`));let s={},c=e.passages.get(`StoryTransients`);if(c){let e=Hx(c.content,`%`);for(let t of e.keys())i.has(t)&&o.push(`StoryTransients: Variable \"${t}\" is already declared in StoryVariables. Names must be unique across scopes.`);s=eS(e)}o.length>0&&sC(o),n=eS(i),gx(Object.keys(n),Object.keys(s)),Q.getState().init(e,n,s),Ay(),L_(x_(e.ifid));let l=cC(e,e=>e.name!==`StoryInit`);l.length>0&&sC(l);for(let[,t]of e.passages)if(t.tags.includes(`widget`)){let e=qo(t.content);for(let n of e)if(n.type===`macro`&&n.name===`widget`&&n.rawArgs){let e=rS(n.rawArgs);try{_S(e,n.children)}catch(n){console.error(`spindle: widget \"${e.name}\" in passage \"${t.name}\" was not registered: ${Jc(n)}`)}}}let u=Q.getState().navigationId;Q.subscribe(e=>{e.navigationId!==u&&(u=e.navigationId,kb())}),bv();let 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.`);let f=document.getElementById(`root`);if(!f)throw Error(`spindle: No <div id=\"root\"> element found.`);ge(q(rb,{}),f);let p=ux();p?p.then(()=>{document.dispatchEvent(new CustomEvent(`:storyready`))}):document.dispatchEvent(new CustomEvent(`:storyready`))}document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,lC):lC();</script>\n </head>\n <body>\n <div id=\"root\"></div>\n {{STORY_DATA}}\n </body>\n</html>\n"})
|