/**
 * Copyright Croquet Corporation 2024
 * Bundle of @croquet/croquet
 * Date: 2024-03-20
 * Version: 1.1.0
 */

var Croquet=function(t){"use strict";if(void 0===globalThis.TextEncoder){globalThis.TextEncoder=function(){},TextEncoder.prototype.encode=function(t){for(var e=t.length,s=-1,i="undefined"==typeof Uint8Array?new Array(1.5*e):new Uint8Array(3*e),n=0,o=0,r=0;r!==e;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===e){i[s+=1]=239,i[s+=1]=191,i[s+=1]=189;break}if(!((o=t.charCodeAt(r))>=56320&&o<=57343)){i[s+=1]=239,i[s+=1]=191,i[s+=1]=189;continue}if(r+=1,(n=1024*(n-55296)+o-56320+65536)>65535){i[s+=1]=240|n>>>18,i[s+=1]=128|n>>>12&63,i[s+=1]=128|n>>>6&63,i[s+=1]=128|63&n;continue}}n<=127?i[s+=1]=0|n:n<=2047?(i[s+=1]=192|n>>>6,i[s+=1]=128|63&n):(i[s+=1]=224|n>>>12,i[s+=1]=128|n>>>6&63,i[s+=1]=128|63&n)}return"undefined"!=typeof Uint8Array?i.subarray(0,s+1):(i.length=s+1,i)},TextEncoder.prototype.toString=function(){return"[object TextEncoder]"};try{Object.defineProperty(TextEncoder.prototype,"encoding",{get:function(){if(TextEncoder.prototype.isPrototypeOf(this))return"utf-8";throw TypeError("Illegal invocation")}})}catch(t){TextEncoder.prototype.encoding="utf-8"}"undefined"!=typeof Symbol&&(TextEncoder.prototype[Symbol.toStringTag]="TextEncoder")}var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){var e=function(t){var e,s=Object.prototype,i=s.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",r=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function l(t,e,s){return Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,s){return t[e]=s}}function c(t,e,s,i){var n=e&&e.prototype instanceof b?e:b,o=Object.create(n.prototype),r=new W(i||[]);return o._invoke=function(t,e,s){var i=h;return function(n,o){if(i===m)throw new Error("Generator is already running");if(i===p){if("throw"===n)throw o;return C()}for(s.method=n,s.arg=o;;){var r=s.delegate;if(r){var a=S(r,s);if(a){if(a===f)continue;return a}}if("next"===s.method)s.sent=s._sent=s.arg;else if("throw"===s.method){if(i===h)throw i=p,s.arg;s.dispatchException(s.arg)}else"return"===s.method&&s.abrupt("return",s.arg);i=m;var l=d(t,e,s);if("normal"===l.type){if(i=s.done?p:u,l.arg===f)continue;return{value:l.arg,done:s.done}}"throw"===l.type&&(i=p,s.method="throw",s.arg=l.arg)}}}(t,s,r),o}function d(t,e,s){try{return{type:"normal",arg:t.call(e,s)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h="suspendedStart",u="suspendedYield",m="executing",p="completed",f={};function b(){}function y(){}function g(){}var w={};l(w,o,(function(){return this}));var Z=Object.getPrototypeOf,v=Z&&Z(Z(T([])));v&&v!==s&&i.call(v,o)&&(w=v);var X=g.prototype=b.prototype=Object.create(w);function L(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function s(n,o,r,a){var l=d(t[n],t,o);if("throw"!==l.type){var c=l.arg,h=c.value;return h&&"object"==typeof h&&i.call(h,"__await")?e.resolve(h.__await).then((function(t){s("next",t,r,a)}),(function(t){s("throw",t,r,a)})):e.resolve(h).then((function(t){c.value=t,r(c)}),(function(t){return s("throw",t,r,a)}))}a(l.arg)}var n;this._invoke=function(t,i){function o(){return new e((function(e,n){s(t,i,e,n)}))}return n=n?n.then(o,o):o()}}function S(t,s){var i=t.iterator[s.method];if(i===e){if(s.delegate=null,"throw"===s.method){if(t.iterator.return&&(s.method="return",s.arg=e,S(t,s),"throw"===s.method))return f;s.method="throw",s.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=d(i,t.iterator,s.arg);if("throw"===n.type)return s.method="throw",s.arg=n.arg,s.delegate=null,f;var o=n.arg;return o?o.done?(s[t.resultName]=o.value,s.next=t.nextLoc,"return"!==s.method&&(s.method="next",s.arg=e),s.delegate=null,f):o:(s.method="throw",s.arg=new TypeError("iterator result is not an object"),s.delegate=null,f)}function G(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function W(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(G,this),this.reset(!0)}function T(t){if(t){var s=t[o];if(s)return s.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function s(){for(;++n<t.length;)if(i.call(t,n))return s.value=t[n],s.done=!1,s;return s.value=e,s.done=!0,s};return r.next=r}}return{next:C}}function C(){return{value:e,done:!0}}return y.prototype=g,l(X,"constructor",g),l(g,"constructor",y),y.displayName=l(g,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,l(t,a,"GeneratorFunction")),t.prototype=Object.create(X),t},t.awrap=function(t){return{__await:t}},L(x.prototype),l(x.prototype,r,(function(){return this})),t.AsyncIterator=x,t.async=function(e,s,i,n,o){void 0===o&&(o=Promise);var r=new x(c(e,s,i,n),o);return t.isGeneratorFunction(s)?r:r.next().then((function(t){return t.done?t.value:r.next()}))},L(X),l(X,a,"Generator"),l(X,o,(function(){return this})),l(X,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var s in t)e.push(s);return e.reverse(),function s(){for(;e.length;){var i=e.pop();if(i in t)return s.value=i,s.done=!1,s}return s.done=!0,s}},t.values=T,W.prototype={constructor:W,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var s in this)"t"===s.charAt(0)&&i.call(this,s)&&!isNaN(+s.slice(1))&&(this[s]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var s=this;function n(i,n){return a.type="throw",a.arg=t,s.next=i,n&&(s.method="next",s.arg=e),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var r=this.tryEntries[o],a=r.completion;if("root"===r.tryLoc)return n("end");if(r.tryLoc<=this.prev){var l=i.call(r,"catchLoc"),c=i.call(r,"finallyLoc");if(l&&c){if(this.prev<r.catchLoc)return n(r.catchLoc,!0);if(this.prev<r.finallyLoc)return n(r.finallyLoc)}else if(l){if(this.prev<r.catchLoc)return n(r.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return n(r.finallyLoc)}}}},abrupt:function(t,e){for(var s=this.tryEntries.length-1;s>=0;--s){var n=this.tryEntries[s];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=t,r.arg=e,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(r)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var s=this.tryEntries[e];if(s.finallyLoc===t)return this.complete(s.completion,s.afterLoc),k(s),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var s=this.tryEntries[e];if(s.tryLoc===t){var i=s.completion;if("throw"===i.type){var n=i.arg;k(s)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,s,i){return this.delegate={iterator:T(t),resultName:s,nextLoc:i},"next"===this.method&&(this.arg=e),f}},t}(t.exports);try{globalThis.regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}({exports:{}});const s={CROQUET_VERSION:"1.1.0"},i=window.location.hostname.endsWith("croquet.studio");let n="",o="";function r(t,e){if(e)for(const s of e.split("&")){const e=s.split("="),i=e[0];let n=!0;if(e.length>1&&(n=decodeURIComponent(e.slice(1).join("=")),n.match(/^(true|false|null|[0-9.]*|["[{].*)$/)))try{n=JSON.parse(n)}catch(t){"["===n[0]&&(n=n.slice(1,-1).split(","))}t[i]=n}}const a=new class{constructor(){this.getSession(),r(this,window.location.search.slice(1)),r(this,i?window.location.hash.slice(1):o),window.location.pathname.indexOf("/ar.html")>=0&&(this.ar=!0)}has(t,e,s){"boolean"!=typeof s&&(s=this.isHost(s));const i=this[t];if("string"!=typeof i)return s;const n=i.split(",");return!0===s&&(e=`no${e}`),e.endsWith("s")&&(e=e.slice(0,-1)),n.includes(e)||n.includes(`${e}s`)?!s:s}getSession(){if(i){const t=/^\/([^/]+)\/(.*)$/,e=window.location.pathname.match(t);if(e)return n=e[1],e[2]}else{const t=/^#([^&]+)&?(.*)$/,e=window.location.hash.match(t);if(e)return e[1].includes("=")?(o=`${e[1]}&${e[2]}`,""):(o=e[2],e[1])}return"string"==typeof this.session?(o=window.location.hash.slice(1),this.session):""}setSession(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null==i&&this.getSession();const{search:s,hash:r}=window.location,a=i?`/${n}/${t}${s}${r}`:`#${t}${o?"&"+o:""}`;e?window.history.replaceState({},"",a):window.history.pushState({},"",a)}isHost(t){const e=window.location.hostname;if(e===t)return!0;if("localhost"!==t)return!1;if(e.endsWith(".ngrok.io"))return!0;if(e.endsWith("croquet.dev"))return!0;if("croquet.io"===e){if(window.location.pathname.match(/^\/(dev|files)\//))return!0}return"file:"===window.location.protocol||["127.0.0.1","[::1]"].includes(e)}isLocalhost(){return this.isHost("localhost")}};var l,c,d,h={exports:{}};c=e,d=function(t){var e=function(t){return new e.lib.init(t)};function s(t,e){return e.offset[t]?isNaN(e.offset[t])?e.offset[t]:e.offset[t]+"px":"0px"}function i(t,e){return!(!t||"string"!=typeof e||!(t.className&&t.className.trim().split(/\s+/gi).indexOf(e)>-1))}return e.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,style:{background:""}},e.lib=e.prototype={toastify:"1.11.2",constructor:e,init:function(t){return t||(t={}),this.options={},this.toastElement=null,this.options.text=t.text||e.defaults.text,this.options.node=t.node||e.defaults.node,this.options.duration=0===t.duration?0:t.duration||e.defaults.duration,this.options.selector=t.selector||e.defaults.selector,this.options.callback=t.callback||e.defaults.callback,this.options.destination=t.destination||e.defaults.destination,this.options.newWindow=t.newWindow||e.defaults.newWindow,this.options.close=t.close||e.defaults.close,this.options.gravity="bottom"===t.gravity?"toastify-bottom":e.defaults.gravity,this.options.positionLeft=t.positionLeft||e.defaults.positionLeft,this.options.position=t.position||e.defaults.position,this.options.backgroundColor=t.backgroundColor||e.defaults.backgroundColor,this.options.avatar=t.avatar||e.defaults.avatar,this.options.className=t.className||e.defaults.className,this.options.stopOnFocus=void 0===t.stopOnFocus?e.defaults.stopOnFocus:t.stopOnFocus,this.options.onClick=t.onClick||e.defaults.onClick,this.options.offset=t.offset||e.defaults.offset,this.options.escapeMarkup=void 0!==t.escapeMarkup?t.escapeMarkup:e.defaults.escapeMarkup,this.options.style=t.style||e.defaults.style,t.backgroundColor&&(this.options.style.background=t.backgroundColor),this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var t=document.createElement("div");for(var e in t.className="toastify on "+this.options.className,this.options.position?t.className+=" toastify-"+this.options.position:!0===this.options.positionLeft?(t.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):t.className+=" toastify-right",t.className+=" "+this.options.gravity,this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.'),this.options.style)t.style[e]=this.options.style[e];if(this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)t.appendChild(this.options.node);else if(this.options.escapeMarkup?t.innerText=this.options.text:t.innerHTML=this.options.text,""!==this.options.avatar){var i=document.createElement("img");i.src=this.options.avatar,i.className="toastify-avatar","left"==this.options.position||!0===this.options.positionLeft?t.appendChild(i):t.insertAdjacentElement("afterbegin",i)}if(!0===this.options.close){var n=document.createElement("span");n.innerHTML="&#10006;",n.className="toast-close",n.addEventListener("click",function(t){t.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}.bind(this));var o=window.innerWidth>0?window.innerWidth:screen.width;("left"==this.options.position||!0===this.options.positionLeft)&&o>360?t.insertAdjacentElement("afterbegin",n):t.appendChild(n)}if(this.options.stopOnFocus&&this.options.duration>0){var r=this;t.addEventListener("mouseover",(function(e){window.clearTimeout(t.timeOutValue)})),t.addEventListener("mouseleave",(function(){t.timeOutValue=window.setTimeout((function(){r.removeElement(t)}),r.options.duration)}))}if(void 0!==this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination}.bind(this)),"function"==typeof this.options.onClick&&void 0===this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),this.options.onClick()}.bind(this)),"object"==typeof this.options.offset){var a=s("x",this.options),l=s("y",this.options),c="left"==this.options.position?a:"-"+a,d="toastify-top"==this.options.gravity?l:"-"+l;t.style.transform="translate("+c+","+d+")"}return t},showToast:function(){var t;if(this.toastElement=this.buildToast(),!(t="string"==typeof this.options.selector?document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||"undefined"!=typeof ShadowRoot&&this.options.selector instanceof ShadowRoot?this.options.selector:document.body))throw"Root element is not defined";var s=e.defaults.oldestFirst?t.firstChild:t.lastChild;return t.insertBefore(this.toastElement,s),e.reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout(function(){this.removeElement(this.toastElement)}.bind(this),this.options.duration)),this},hideToast:function(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this.removeElement(this.toastElement)},removeElement:function(t){t.className=t.className.replace(" on",""),window.setTimeout(function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),t.parentNode&&t.parentNode.removeChild(t),this.options.callback.call(t),e.reposition()}.bind(this),400)}},e.reposition=function(){for(var t,e={top:15,bottom:15},s={top:15,bottom:15},n={top:15,bottom:15},o=document.getElementsByClassName("toastify"),r=0;r<o.length;r++){t=!0===i(o[r],"toastify-top")?"toastify-top":"toastify-bottom";var a=o[r].offsetHeight;t=t.substr(9,t.length-1),(window.innerWidth>0?window.innerWidth:screen.width)<=360?(o[r].style[t]=n[t]+"px",n[t]+=a+15):!0===i(o[r],"toastify-left")?(o[r].style[t]=e[t]+"px",e[t]+=a+15):(o[r].style[t]=s[t]+"px",s[t]+=a+15)}return this},e.lib.init.prototype=e.lib,e},(l=h).exports?l.exports=d():c.Toastify=d();var u=h.exports,m={exports:{}};!function(t){!function(e,s,i){var n,o=256,r=i.pow(o,6),a=i.pow(2,52),l=2*a,c=255;function d(t,c,d){var b=[],y=p(m((c=1==c?{entropy:!0}:c||{}).entropy?[t,f(s)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(o):(t=new Uint8Array(o),(e.crypto||e.msCrypto).getRandomValues(t)),f(t)}catch(t){var i=e.navigator,r=i&&i.plugins;return[+new Date,e,r,e.screen,f(s)]}}():t,3),b),g=new h(b),w=function(){for(var t=g.g(6),e=r,s=0;t<a;)t=(t+s)*o,e*=o,s=g.g(1);for(;t>=l;)t/=2,e/=2,s>>>=1;return(t+s)/e};return w.int32=function(){return 0|g.g(4)},w.quick=function(){return g.g(4)/4294967296},w.double=w,p(f(g.S),s),(c.pass||d||function(t,e,s,n){return n&&(n.S&&u(n,g),t.state=function(){return u(g,{})}),s?(i.random=t,e):t})(w,y,"global"in c?c.global:this==i,c.state)}function h(t){var e,s=t.length,i=this,n=0,r=i.i=i.j=0,a=i.S=[];for(s||(t=[s++]);n<o;)a[n]=n++;for(n=0;n<o;n++)a[n]=a[r=c&r+t[n%s]+(e=a[n])],a[r]=e;(i.g=function(t){for(var e,s=0,n=i.i,r=i.j,a=i.S;t--;)e=a[n=c&n+1],s=s*o+a[c&(a[n]=a[r=c&r+e])+(a[r]=e)];return i.i=n,i.j=r,s})(o)}function u(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function m(t,e){var s,i=[],n=typeof t;if(e&&"object"==n)for(s in t)try{i.push(m(t[s],e-1))}catch(t){}return i.length?i:"string"==n?t:t+"\0"}function p(t,e){for(var s,i=t+"",n=0;n<i.length;)e[c&n]=c&(s^=19*e[c&n])+i.charCodeAt(n++);return f(e)}function f(t){return String.fromCharCode.apply(0,t)}if(p(i.random(),s),t.exports){t.exports=d;try{n=undefined}catch(t){}}else i.seedrandom=d}("undefined"!=typeof self?self:e,[],Math)}(m);var p,f=m.exports;!function(){function t(t){this.mode=s.MODE_8BIT_BYTE,this.data=t,this.parsedData=[];for(var e=0,i=this.data.length;e<i;e++){var n=[],o=this.data.charCodeAt(e);o>65536?(n[0]=240|(1835008&o)>>>18,n[1]=128|(258048&o)>>>12,n[2]=128|(4032&o)>>>6,n[3]=128|63&o):o>2048?(n[0]=224|(61440&o)>>>12,n[1]=128|(4032&o)>>>6,n[2]=128|63&o):o>128?(n[0]=192|(1984&o)>>>6,n[1]=128|63&o):n[0]=o,this.parsedData.push(n)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function e(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}t.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,s=this.parsedData.length;e<s;e++)t.put(this.parsedData[e],8)}},e.prototype={addData:function(e){var s=new t(e);this.dataList.push(s),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,s){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var i=0;i<this.moduleCount;i++){this.modules[i]=new Array(this.moduleCount);for(var n=0;n<this.moduleCount;n++)this.modules[i][n]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,s),this.typeNumber>=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=e.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,s)},setupPositionProbePattern:function(t,e){for(var s=-1;s<=7;s++)if(!(t+s<=-1||this.moduleCount<=t+s))for(var i=-1;i<=7;i++)e+i<=-1||this.moduleCount<=e+i||(this.modules[t+s][e+i]=0<=s&&s<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==s||6==s)||2<=s&&s<=4&&2<=i&&i<=4)},getBestMaskPattern:function(){for(var t=0,e=0,s=0;s<8;s++){this.makeImpl(!0,s);var i=u.getLostPoint(this);(0==s||t>i)&&(t=i,e=s)}return e},createMovieClip:function(t,e,s){var i=t.createEmptyMovieClip(e,s);this.make();for(var n=0;n<this.modules.length;n++)for(var o=1*n,r=0;r<this.modules[n].length;r++){var a=1*r;this.modules[n][r]&&(i.beginFill(0,100),i.moveTo(a,o),i.lineTo(a+1,o),i.lineTo(a+1,o+1),i.lineTo(a,o+1),i.endFill())}return i},setupTimingPattern:function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e]&&(this.modules[6][e]=e%2==0)},setupPositionAdjustPattern:function(){for(var t=u.getPatternPosition(this.typeNumber),e=0;e<t.length;e++)for(var s=0;s<t.length;s++){var i=t[e],n=t[s];if(null==this.modules[i][n])for(var o=-2;o<=2;o++)for(var r=-2;r<=2;r++)this.modules[i+o][n+r]=-2==o||2==o||-2==r||2==r||0==o&&0==r}},setupTypeNumber:function(t){for(var e=u.getBCHTypeNumber(this.typeNumber),s=0;s<18;s++){var i=!t&&1==(e>>s&1);this.modules[Math.floor(s/3)][s%3+this.moduleCount-8-3]=i}for(s=0;s<18;s++){i=!t&&1==(e>>s&1);this.modules[s%3+this.moduleCount-8-3][Math.floor(s/3)]=i}},setupTypeInfo:function(t,e){for(var s=this.errorCorrectLevel<<3|e,i=u.getBCHTypeInfo(s),n=0;n<15;n++){var o=!t&&1==(i>>n&1);n<6?this.modules[n][8]=o:n<8?this.modules[n+1][8]=o:this.modules[this.moduleCount-15+n][8]=o}for(n=0;n<15;n++){o=!t&&1==(i>>n&1);n<8?this.modules[8][this.moduleCount-n-1]=o:n<9?this.modules[8][15-n-1+1]=o:this.modules[8][15-n-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var s=-1,i=this.moduleCount-1,n=7,o=0,r=this.moduleCount-1;r>0;r-=2)for(6==r&&r--;;){for(var a=0;a<2;a++)if(null==this.modules[i][r-a]){var l=!1;o<t.length&&(l=1==(t[o]>>>n&1)),u.getMask(e,i,r-a)&&(l=!l),this.modules[i][r-a]=l,-1==--n&&(o++,n=7)}if((i+=s)<0||this.moduleCount<=i){i-=s,s=-s;break}}}},e.PAD0=236,e.PAD1=17,e.createData=function(t,s,i){for(var n=y.getRSBlocks(t,s),o=new g,r=0;r<i.length;r++){var a=i[r];o.put(a.mode,4),o.put(a.getLength(),u.getLengthInBits(a.mode,t)),a.write(o)}var l=0;for(r=0;r<n.length;r++)l+=n[r].dataCount;if(o.getLengthInBits()>8*l)throw new Error("code length overflow. ("+o.getLengthInBits()+">"+8*l+")");for(o.getLengthInBits()+4<=8*l&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(!1);for(;!(o.getLengthInBits()>=8*l||(o.put(e.PAD0,8),o.getLengthInBits()>=8*l));)o.put(e.PAD1,8);return e.createBytes(o,n)},e.createBytes=function(t,e){for(var s=0,i=0,n=0,o=new Array(e.length),r=new Array(e.length),a=0;a<e.length;a++){var l=e[a].dataCount,c=e[a].totalCount-l;i=Math.max(i,l),n=Math.max(n,c),o[a]=new Array(l);for(var d=0;d<o[a].length;d++)o[a][d]=255&t.buffer[d+s];s+=l;var h=u.getErrorCorrectPolynomial(c),m=new b(o[a],h.getLength()-1).mod(h);r[a]=new Array(h.getLength()-1);for(d=0;d<r[a].length;d++){var p=d+m.getLength()-r[a].length;r[a][d]=p>=0?m.get(p):0}}var f=0;for(d=0;d<e.length;d++)f+=e[d].totalCount;var y=new Array(f),g=0;for(d=0;d<i;d++)for(a=0;a<e.length;a++)d<o[a].length&&(y[g++]=o[a][d]);for(d=0;d<n;d++)for(a=0;a<e.length;a++)d<r[a].length&&(y[g++]=r[a][d]);return y};for(var s={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},i={L:1,M:0,Q:3,H:2},n=0,o=1,r=2,a=3,l=4,c=5,d=6,h=7,u={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;u.getBCHDigit(e)-u.getBCHDigit(u.G15)>=0;)e^=u.G15<<u.getBCHDigit(e)-u.getBCHDigit(u.G15);return(t<<10|e)^u.G15_MASK},getBCHTypeNumber:function(t){for(var e=t<<12;u.getBCHDigit(e)-u.getBCHDigit(u.G18)>=0;)e^=u.G18<<u.getBCHDigit(e)-u.getBCHDigit(u.G18);return t<<12|e},getBCHDigit:function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},getPatternPosition:function(t){return u.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,s){switch(t){case n:return(e+s)%2==0;case o:return e%2==0;case r:return s%3==0;case a:return(e+s)%3==0;case l:return(Math.floor(e/2)+Math.floor(s/3))%2==0;case c:return e*s%2+e*s%3==0;case d:return(e*s%2+e*s%3)%2==0;case h:return(e*s%3+(e+s)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new b([1],0),s=0;s<t;s++)e=e.multiply(new b([1,m.gexp(s)],0));return e},getLengthInBits:function(t,e){if(1<=e&&e<10)switch(t){case s.MODE_NUMBER:return 10;case s.MODE_ALPHA_NUM:return 9;case s.MODE_8BIT_BYTE:case s.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case s.MODE_NUMBER:return 12;case s.MODE_ALPHA_NUM:return 11;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case s.MODE_NUMBER:return 14;case s.MODE_ALPHA_NUM:return 13;case s.MODE_8BIT_BYTE:return 16;case s.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},getLostPoint:function(t){for(var e=t.getModuleCount(),s=0,i=0;i<e;i++)for(var n=0;n<e;n++){for(var o=0,r=t.isDark(i,n),a=-1;a<=1;a++)if(!(i+a<0||e<=i+a))for(var l=-1;l<=1;l++)n+l<0||e<=n+l||0==a&&0==l||r==t.isDark(i+a,n+l)&&o++;o>5&&(s+=3+o-5)}for(i=0;i<e-1;i++)for(n=0;n<e-1;n++){var c=0;t.isDark(i,n)&&c++,t.isDark(i+1,n)&&c++,t.isDark(i,n+1)&&c++,t.isDark(i+1,n+1)&&c++,0!=c&&4!=c||(s+=3)}for(i=0;i<e;i++)for(n=0;n<e-6;n++)t.isDark(i,n)&&!t.isDark(i,n+1)&&t.isDark(i,n+2)&&t.isDark(i,n+3)&&t.isDark(i,n+4)&&!t.isDark(i,n+5)&&t.isDark(i,n+6)&&(s+=40);for(n=0;n<e;n++)for(i=0;i<e-6;i++)t.isDark(i,n)&&!t.isDark(i+1,n)&&t.isDark(i+2,n)&&t.isDark(i+3,n)&&t.isDark(i+4,n)&&!t.isDark(i+5,n)&&t.isDark(i+6,n)&&(s+=40);var d=0;for(n=0;n<e;n++)for(i=0;i<e;i++)t.isDark(i,n)&&d++;return s+=10*(Math.abs(100*d/e/e-50)/5)}},m={glog:function(t){if(t<1)throw new Error("glog("+t+")");return m.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return m.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},f=0;f<8;f++)m.EXP_TABLE[f]=1<<f;for(f=8;f<256;f++)m.EXP_TABLE[f]=m.EXP_TABLE[f-4]^m.EXP_TABLE[f-5]^m.EXP_TABLE[f-6]^m.EXP_TABLE[f-8];for(f=0;f<255;f++)m.LOG_TABLE[m.EXP_TABLE[f]]=f;function b(t,e){if(null==t.length)throw new Error(t.length+"/"+e);for(var s=0;s<t.length&&0==t[s];)s++;this.num=new Array(t.length-s+e);for(var i=0;i<t.length-s;i++)this.num[i]=t[i+s]}function y(t,e){this.totalCount=t,this.dataCount=e}function g(){this.buffer=[],this.length=0}b.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),s=0;s<this.getLength();s++)for(var i=0;i<t.getLength();i++)e[s+i]^=m.gexp(m.glog(this.get(s))+m.glog(t.get(i)));return new b(e,0)},mod:function(t){if(this.getLength()-t.getLength()<0)return this;for(var e=m.glog(this.get(0))-m.glog(t.get(0)),s=new Array(this.getLength()),i=0;i<this.getLength();i++)s[i]=this.get(i);for(i=0;i<t.getLength();i++)s[i]^=m.gexp(m.glog(t.get(i))+e);return new b(s,0).mod(t)}},y.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],y.getRSBlocks=function(t,e){var s=y.getRsBlockTable(t,e);if(null==s)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+e);for(var i=s.length/3,n=[],o=0;o<i;o++)for(var r=s[3*o+0],a=s[3*o+1],l=s[3*o+2],c=0;c<r;c++)n.push(new y(a,l));return n},y.getRsBlockTable=function(t,e){switch(e){case i.L:return y.RS_BLOCK_TABLE[4*(t-1)+0];case i.M:return y.RS_BLOCK_TABLE[4*(t-1)+1];case i.Q:return y.RS_BLOCK_TABLE[4*(t-1)+2];case i.H:return y.RS_BLOCK_TABLE[4*(t-1)+3];default:return}},g.prototype={get:function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(var s=0;s<e;s++)this.putBit(1==(t>>>e-s-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var w=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],Z=function(){var t=function(t,e){this._bIsPainted=!1,this._htOption=e,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=e.width,this._elCanvas.height=e.height,t.appendChild(this._elCanvas),this._el=t,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._bSupportDataURI=null};return t.prototype.draw=function(t){var e=this._oContext,s=this._htOption,i=t.getModuleCount(),n=s.width/i,o=s.height/i,r=Math.round(n),a=Math.round(o);this.clear();for(var l=0;l<i;l++)for(var c=0;c<i;c++){var d=t.isDark(l,c),h=c*n,u=l*o;e.strokeStyle=d?s.colorDark:s.colorLight,e.lineWidth=1,e.fillStyle=d?s.colorDark:s.colorLight,e.fillRect(h,u,n,o),e.strokeRect(Math.floor(h)+.5,Math.floor(u)+.5,r,a),e.strokeRect(Math.ceil(h)-.5,Math.ceil(u)-.5,r,a)}this._bIsPainted=!0},t.prototype.isPainted=function(){return this._bIsPainted},t.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},t.prototype.round=function(t){return t?Math.floor(1e3*t)/1e3:t},t}();function v(t,e){for(var s=1,n=function(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=t?3:0)}(t),o=0,r=w.length;o<=r;o++){var a=0;switch(e){case i.L:a=w[o][0];break;case i.M:a=w[o][1];break;case i.Q:a=w[o][2];break;case i.H:a=w[o][3]}if(n<=a)break;s++}if(s>w.length)throw new Error("Too long data");return s}p=function(t,e){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:i.H},"string"==typeof e&&(e={text:e}),e)for(var s in e)this._htOption[s]=e[s];"string"==typeof t&&(t=document.getElementById(t)),this._htOption.useSVG&&(Z=svgDrawer),this._el=t,this._oQRCode=null,this._oDrawing=new Z(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},p.prototype.makeCode=function(t){this._oQRCode=new e(v(t,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(t),this._oQRCode.make(),this._oDrawing.draw(this._oQRCode)},p.prototype.clear=function(){this._oDrawing.clear()},p.prototype.getCanvas=function(){for(let t=0;t<this._el.children.length;t++){const e=this._el.children[t];if("CANVAS"===e.tagName)return e}return null},p.CorrectLevel=i}();var b=p,y=function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var s,i="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(s=e.cmp,function(t){return function(e,i){var n={key:e,value:t[e]},o={key:i,value:t[i]};return s(n,o)}}),o=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return JSON.stringify(e);var s,r;if(Array.isArray(e)){for(r="[",s=0;s<e.length;s++)s&&(r+=","),r+=t(e[s])||"null";return r+"]"}if(null===e)return"null";if(-1!==o.indexOf(e)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(e)-1,l=Object.keys(e).sort(n&&n(e));for(r="",s=0;s<l.length;s++){var c=l[s],d=t(e[c]);d&&(r&&(r+=","),r+=JSON.stringify(c)+":"+d)}return o.splice(a,1),"{"+r+"}"}}(t)},g={exports:{}},w={exports:{}};!function(t,s){var i;t.exports=(i=i||function(t,s){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(i=globalThis.crypto),!i&&"undefined"!=typeof window&&window.msCrypto&&(i=window.msCrypto),!i&&void 0!==e&&e.crypto&&(i=e.crypto),!i)try{i=require("crypto")}catch(t){}var n=function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(e){var s;return t.prototype=e,s=new t,t.prototype=null,s}}(),r={},a=r.lib={},l=a.Base={extend:function(t){var e=o(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=l.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=s?e:4*t.length},toString:function(t){return(t||h).stringify(this)},concat:function(t){var e=this.words,s=t.words,i=this.sigBytes,n=t.sigBytes;if(this.clamp(),i%4)for(var o=0;o<n;o++){var r=s[o>>>2]>>>24-o%4*8&255;e[i+o>>>2]|=r<<24-(i+o)%4*8}else for(var a=0;a<n;a+=4)e[i+a>>>2]=s[a>>>2];return this.sigBytes+=n,this},clamp:function(){var e=this.words,s=this.sigBytes;e[s>>>2]&=4294967295<<32-s%4*8,e.length=t.ceil(s/4)},clone:function(){var t=l.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],s=0;s<t;s+=4)e.push(n());return new c.init(e,t)}}),d=r.enc={},h=d.Hex={stringify:function(t){for(var e=t.words,s=t.sigBytes,i=[],n=0;n<s;n++){var o=e[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,s=[],i=0;i<e;i+=2)s[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new c.init(s,e/2)}},u=d.Latin1={stringify:function(t){for(var e=t.words,s=t.sigBytes,i=[],n=0;n<s;n++){var o=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,s=[],i=0;i<e;i++)s[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new c.init(s,e)}},m=d.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},p=a.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=m.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var s,i=this._data,n=i.words,o=i.sigBytes,r=this.blockSize,a=o/(4*r),l=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*r,d=t.min(4*l,o);if(l){for(var h=0;h<l;h+=r)this._doProcessBlock(n,h);s=n.splice(0,l),i.sigBytes-=d}return new c.init(s,d)},clone:function(){var t=l.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});a.Hasher=p.extend({cfg:l.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,s){return new t.init(s).finalize(e)}},_createHmacHelper:function(t){return function(e,s){return new f.HMAC.init(t,s).finalize(e)}}});var f=r.algo={};return r}(Math),i)}(w),function(t,e){var s;t.exports=(s=w.exports,function(){if("function"==typeof ArrayBuffer){var t=s.lib.WordArray,e=t.init,i=t.init=function(t){if(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),(t instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),t instanceof Uint8Array){for(var s=t.byteLength,i=[],n=0;n<s;n++)i[n>>>2]|=t[n]<<24-n%4*8;e.call(this,i,s)}else e.apply(this,arguments)};i.prototype=t}}(),s.lib.WordArray)}(g);var Z=g.exports,v={exports:{}};!function(t,e){var s;t.exports=(s=w.exports,function(t){var e=s,i=e.lib,n=i.WordArray,o=i.Hasher,r=e.algo,a=[],l=[];!function(){function e(e){for(var s=t.sqrt(e),i=2;i<=s;i++)if(!(e%i))return!1;return!0}function s(t){return 4294967296*(t-(0|t))|0}for(var i=2,n=0;n<64;)e(i)&&(n<8&&(a[n]=s(t.pow(i,.5))),l[n]=s(t.pow(i,1/3)),n++),i++}();var c=[],d=r.SHA256=o.extend({_doReset:function(){this._hash=new n.init(a.slice(0))},_doProcessBlock:function(t,e){for(var s=this._hash.words,i=s[0],n=s[1],o=s[2],r=s[3],a=s[4],d=s[5],h=s[6],u=s[7],m=0;m<64;m++){if(m<16)c[m]=0|t[e+m];else{var p=c[m-15],f=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,b=c[m-2],y=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;c[m]=f+c[m-7]+y+c[m-16]}var g=i&n^i&o^n&o,w=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),Z=u+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&d^~a&h)+l[m]+c[m];u=h,h=d,d=a,a=r+Z|0,r=o,o=n,n=i,i=Z+(w+g)|0}s[0]=s[0]+i|0,s[1]=s[1]+n|0,s[2]=s[2]+o|0,s[3]=s[3]+r|0,s[4]=s[4]+a|0,s[5]=s[5]+d|0,s[6]=s[6]+h|0,s[7]=s[7]+u|0},_doFinalize:function(){var e=this._data,s=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return s[n>>>5]|=128<<24-n%32,s[14+(n+64>>>9<<4)]=t.floor(i/4294967296),s[15+(n+64>>>9<<4)]=i,e.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=o._createHelper(d),e.HmacSHA256=o._createHmacHelper(d)}(Math),s.SHA256)}(v);var X=v.exports;const L="node"===s.CROQUET_PLATFORM;let x;function S(t){const e=t.sigBytes,s=t.words,i=new Uint8Array(e);let n=0,o=0;for(;n<e;){const t=s[o++];if(i[n++]=(4278190080&t)>>>24,n===e)break;if(i[n++]=(16711680&t)>>>16,n===e)break;if(i[n++]=(65280&t)>>>8,n===e)break;i[n++]=255&t}return i}function G(t){function e(t){const e=t.indexOf("{"),s=t.lastIndexOf("}");if(-1===e||-1===s||s<e)return t;const i=t.slice(0,e).replace(/\s+/g," ").replace(/\s\(/,"("),n=t.slice(e+1,s);return`${i.trim()}{${n.trim()}}`}let s=e(""+t);if(!s.startsWith("class")){const i=t.prototype;i&&(s+=Object.getOwnPropertyNames(i).map((t=>`${t}:${e(""+i[t])}`)).join(""))}return s}function k(t){return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function W(){return a.has("debug","hashing",!1)}x=globalThis.crypto&&globalThis.crypto.subtle&&"function"==typeof globalThis.crypto.subtle.digest?globalThis.crypto.subtle.digest.bind(globalThis.crypto.subtle):(t,e)=>{if("SHA-256"!==t)throw Error("Croquet: only SHA-256 available");const s=Z.create(e);return S(X(s)).buffer};let T={};const C=new TextEncoder;async function P(t){const e=C.encode(t),s=await async function(t){return 0===t.length?"47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU":k(await x("SHA-256",t))}(e);return T[s]={string:t,buffer:e},s}const V=[],R={};const Y=new Set;const M=Date.now();"undefined"==typeof performance&&(window.performance={now:()=>Date.now()-M});const I=["simulate","update","render","snapshot"],H={total:"black",update:"blue",render:"magenta",simulate:"yellow",snapshot:"green",backlog:"red",network:"lightgray"};let K,z,N=null,F=null,_=null,j=0,Q=null,E=null;function J(t){for(N=t;t.firstChild;)t.removeChild(t.firstChild);t.style.background="#faf0dc",Q=document.createElement("canvas"),E=Q.getContext("2d"),Q.id="text_stats",Q.width=Math.min(140,window.innerWidth),Q.height=36,Q.style.width=Q.width,Q.style.height=Q.height,E.font="9.5pt sans-serif",t.appendChild(Q),t.title=Object.entries(H).map((t=>{let[e,s]=t;return`${s}: ${e}`})).join("\n"),F=document.createElement("canvas"),F.width=Math.min(125,window.innerWidth),F.height=125,F.style.width="100%";const e=document.createElement("div");e.id="innerDiv",t.appendChild(e),e.appendChild(F),_=F.getContext("2d")}const U=[];let D=0,O=!1,B=tt(0);const A=1e3/60;function $(t){return 20*(1-t/A)+60}function q(t){K=function(t){const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.style.width="100%",e.style.position="absolute",e.style.left="0px",N.querySelector("#innerDiv").appendChild(e),e}(t),z=K.getContext("2d"),z.strokeStyle="rgba(255, 255, 255, 0.5)";for(let t=0;t<60;t+=A){const e=$(t);z.moveTo(0,e),z.lineTo(K.width,e),z.stroke()}}function tt(t){return{start:t,total:0,items:{},users:0,backlog:0,network:0,latency:0,activity:1e3,connected:O}}function et(t){B.total=t-B.start;const e=Math.min(120,window.innerWidth);if(U.length>=e&&U.splice(0,U.length-e+1),U.push(B),U.length<=1)return;if(!N)return;if(0===N.offsetHeight)return;const s=U.slice(1).filter((t=>t.total)),i=s.map((t=>t.total)).reduce(((t,e)=>t+e),0)/s.length,n=Math.max(...s.map((t=>t.total)));Math.max(...s.map((t=>Math.max(t.backlog,t.network)))),D=1e3,function(t,e){E.globalCompositeOperation="copy",E.fillStyle="rgb(255, 255, 255, 0)",E.fillRect(0,0,Q.width,Q.height),E.fillStyle="rgb(0, 0, 0, 1)",E.globalCompositeOperation="source-over";let s=`${B.users} users, ${Math.round(1e3/t)} fps`;e>70&&(s+=` ${Math.ceil(e).toLocaleString()}ms`),E.fillText(s,2,15),s=B.backlog<100&&B.activity<1e3?`latency: ${B.latency} ms`:`backlog: ${B.backlog<100?"0.0":(B.backlog/1e3).toFixed(1)} s`,E.fillText(s,2,33)}(i,n),K||q(F),j===F.width?(_.globalCompositeOperation="copy",_.drawImage(F,1,0,F.width-1,F.height,0,0,F.width-1,F.height),_.globalCompositeOperation="source-over",_.fillStyle="transparent",_.fillRect(F.width-1,0,1,F.height)):j++;const o=t=>$(t/D*-2*A)+5;{const t=U[U.length-1],e=j-.5;let s=$(0);_.beginPath(),_.moveTo(e,s),_.lineTo(e,$(t.total)),_.strokeStyle=H[t.connected?"total":"network"],_.stroke(),_.beginPath(),_.moveTo(e,s),s=$(t.total);let i=0;for(const n of I)t.items[n]&&(i+=t.items[n],s=$(i),_.lineTo(e,s),_.strokeStyle=H[n],_.stroke(),_.beginPath(),_.moveTo(e,s));t.network&&(_.beginPath(),_.moveTo(e,o(0)),_.lineTo(e,o(t.network)),_.strokeStyle=H.network,_.stroke())}}const st=[],it={};let nt={};const ot={frames:U,animationFrame(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};et(t),B=tt(t);for(const[t,s]of Object.entries(e))this[t](s)},begin(t){const e=performance.now();B.items[t]=(B.items[t]||0)-e;const s=st[st.length-1];return s&&(B.items[s]+=e),st.push(t),e},end(t){const e=performance.now();B.items[t]+=e;const s=st.pop();if(s!==t)throw Error(`Unmatched stats calls: expected end("${s}"), got end("${t}")`);const i=st[st.length-1];return i&&(B.items[i]-=e),e},backlog(t){B.backlog=Math.max(t,B.backlog)},network(t){B.network=t},starvation(t){B.network=t},latency(t){B.latency=t},activity(t){B.activity=t},users(t){B.users=t},connected(t){const e=O;B.connected=O=t,e&&!O&&K&&(K.remove(),z=null)},networkTraffic:it,addNetworkTraffic(t,e){it[t]=(it[t]||0)+e},perSecondTally(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(window.logMessageStats)for(const[e,s]of Object.entries(t))nt[e]=(nt[e]||0)+s},stepSession(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const s=Math.floor(Date.now()/1e3);if(!window.logMessageStats)return nt={second:s},null;let i=null;if(s!==nt.second){if(nt.second&&e&&(nt.requestedMessages||nt.sentMessagesTotal)){i={...nt};const t=s-nt.second;1!==t&&(i.sampleSeconds=t),i.sentBundles&&(i.averageDelay=Math.round(10*i.sendDelay/i.sentMessagesTotal)/10,i.averageBundlePayload=Math.round(i.sentBundlePayload/i.sentBundles)),delete i.second,delete i.sendDelay,delete i.sentBundlePayload}nt={second:s}}return i}};globalThis.CROQUETSTATS=ot;const rt="ontouchstart"in document.documentElement,at=window.parent!==window,lt=rt?20:12,ct=rt?0:15;let dt=!1;function ht(){if(dt)return;dt=!0;const t=`\n        #croquet_dock { position: fixed; z-index: 2; border: 3px solid white; bottom: 6px; left: 6px; width: 36px; height: 36px; box-sizing: border-box; background: white; opacity: 0.4; transition: all 0.3s ease; }\n        #croquet_dock.active { opacity: 0.95; border-radius: 12px; }\n        #croquet_dock.debug { width: 84px; }\n        #croquet_dock_bar { position: absolute; border: 3px solid white; width: 100%; height: 30px; box-sizing: border-box; background: white; }\n\n        #croquet_badge { position: absolute; width: 72px; height: 24px; top: 50%; transform: translate(0px, -50%); cursor: none; }\n        #croquet_dock.active #croquet_badge { left: 2%; }\n        #croquet_dock:not(.debug) #croquet_badge { display: none; }\n\n        .croquet_dock_button { position: absolute; width: ${lt}%; height: 90%; top: 50%; transform: translate(0px, -50%); border-radius: 20%; }\n        .croquet_dock_button:focus { outline: 0; }\n        .croquet_dock_button canvas { position: absolute; width: 100%; height: 100%; top: 0px; left: 0px; }\n        #croquet_dock:not(.active) .croquet_dock_button { display: none; }\n        #croquet_dock_left { right: ${2+ct+lt+2}% }\n        #croquet_dock:not(.debug) #croquet_dock_left { display: none; }\n        #croquet_dock_right { right: ${2+ct}%; }\n        #croquet_dock:not(.debug) #croquet_dock_right { display: none; }\n        #croquet_dock_pin { right: 2%; }\n        #croquet_dock_pin.pinned { background: #cce6ff; }\n\n        #croquet_dock_content { position: absolute; left: 2px; top: 2px; right: 2px; bottom: 2px; background: white; overflow: hidden; }\n        #croquet_dock.debug:not(.active) #croquet_dock_content { display: none; }\n        #croquet_dock.debug:not(.active) #croquet_dock_content div { display: none; }\n\n        #croquet_qrcode { position: absolute; width: 100%; height: 100%;box-sizing: border-box; cursor: crosshair; }\n        #croquet_dock.active #croquet_qrcode { border: 6px solid white; }\n        #croquet_dock.debug #croquet_qrcode:not(.active) { display: none; }\n        #croquet_qrcode canvas { image-rendering: pixelated; }\n\n        #croquet_stats { position: absolute; width: 70%; height: 90%; left: 15%; top: 5%; opacity: 0.8; font-family: sans-serif; }\n        #croquet_stats:not(.active) { display: none; }\n`,e=document.createElement("style");e.innerHTML=t,document.head.insertBefore(e,document.head.getElementsByTagName("style")[0])}let ut=!1;let mt,pt=!1;function ft(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t&&Vt.showMessage(t,{...e,level:"warning"})}function bt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t&&Vt.showMessage(t,{...e,level:"status"})}function yt(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";console.error(`Error during ${t}`,e);const i=(e.stack||"").split("\n").filter((t=>!t.match(/croquet-.*\.min.js/))).join("\n");Vt.showMessage(`Error during ${t}: ${e.message}\n\n${i}`,{level:s,duration:"error"===s?1e4:void 0,stopOnFocus:!0})}function gt(t,e){const s=Tt(Vt.root,(()=>document.body));if(!1===s)return null;!function(){if(pt)return;pt=!0;let t="/*!\n        * Toastify js 1.5.0\n        * https://github.com/apvarun/toastify-js\n        * @license MIT licensed\n        *\n        * Copyright (C) 2018 Varun A P\n        */\n        .toastify {\n            padding: 12px 20px;\n            color: #ffffff;\n            display: inline-block;\n            box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n            background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n            background: linear-gradient(135deg, #73a5ff, #5477f5);\n            position: fixed;\n            opacity: 0;\n            transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n            border-radius: 2px;\n            cursor: pointer;\n            text-decoration: none;\n            max-width: calc(50% - 20px);\n            z-index: 2147483647;\n        }\n        .toastify.on {\n            opacity: 1;\n        }\n        .toast-close {\n            opacity: 0.4;\n            padding: 0 5px;\n        }\n        .toastify-right {\n            right: 15px;\n        }\n        .toastify-left {\n            left: 15px;\n        }\n        .toastify-top {\n            top: -150px;\n        }\n        .toastify-bottom {\n            bottom: -150px;\n        }\n        .toastify-rounded {\n            border-radius: 25px;\n        }\n        .toastify-avatar {\n            width: 1.5em;\n            height: 1.5em;\n            margin: 0 5px;\n            border-radius: 2px;\n        }\n        @media only screen and (max-width: 360px) {\n            .toastify-right, .toastify-left {\n                margin-left: auto;\n                margin-right: auto;\n                left: 0;\n                right: 0;\n                max-width: fit-content;\n            }\n        }\n";t+="\n        .toastify {\n            font-family: sans-serif;\n            border-radius: 8px;\n        }\n\n        .toastify-center {\n            margin-left: auto;\n            margin-right: auto;\n            left: 0;\n            right: 0;\n            max-width: fit-content;\n            max-width: -moz-fit-content;\n        }\n";const e=document.createElement("style");e.innerHTML="/*!\n        * Toastify js 1.5.0\n        * https://github.com/apvarun/toastify-js\n        * @license MIT licensed\n        *\n        * Copyright (C) 2018 Varun A P\n        */\n        .toastify {\n            padding: 12px 20px;\n            color: #ffffff;\n            display: inline-block;\n            box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n            background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n            background: linear-gradient(135deg, #73a5ff, #5477f5);\n            position: fixed;\n            opacity: 0;\n            transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n            border-radius: 2px;\n            cursor: pointer;\n            text-decoration: none;\n            max-width: calc(50% - 20px);\n            z-index: 2147483647;\n        }\n        .toastify.on {\n            opacity: 1;\n        }\n        .toast-close {\n            opacity: 0.4;\n            padding: 0 5px;\n        }\n        .toastify-right {\n            right: 15px;\n        }\n        .toastify-left {\n            left: 15px;\n        }\n        .toastify-top {\n            top: -150px;\n        }\n        .toastify-bottom {\n            bottom: -150px;\n        }\n        .toastify-rounded {\n            border-radius: 25px;\n        }\n        .toastify-avatar {\n            width: 1.5em;\n            height: 1.5em;\n            margin: 0 5px;\n            border-radius: 2px;\n        }\n        @media only screen and (max-width: 360px) {\n            .toastify-right, .toastify-left {\n                margin-left: auto;\n                margin-right: auto;\n                left: 0;\n                right: 0;\n                max-width: fit-content;\n            }\n        }\n\n        .toastify {\n            font-family: sans-serif;\n            border-radius: 8px;\n        }\n\n        .toastify-center {\n            margin-left: auto;\n            margin-right: auto;\n            left: 0;\n            right: 0;\n            max-width: fit-content;\n            max-width: -moz-fit-content;\n        }\n",document.head.insertBefore(e,document.head.getElementsByTagName("style")[0])}();const i={text:t,duration:3e3,gravity:"bottom",position:"right",stopOnFocus:!0,...e};let n;return s instanceof Element&&s!==document.body?(n=s.id,n||(s.id=n="_croquetToastParent")):"string"==typeof s&&(n=s),n&&(i.selector=n),u(i).showToast()}try{if(mt=window.localStorage,mt["croquet-debug-persist-allowed"]="true","true"!==mt["croquet-debug-persist-allowed"])throw Error("localStorage not persisted");delete mt["croquet-debug-persist-allowed"]}catch(ar){console.warn("localStorage not allowed"),mt={}}const wt={get pinned(){return"true"===mt[window.location.pathname+"/croquet-debug-ui-pinned"]},set pinned(t){mt[window.location.pathname+"/croquet-debug-ui-pinned"]=!!t},get activePage(){return mt[window.location.pathname+"/croquet-debug-ui-activePage"]},set activePage(t){mt[window.location.pathname+"/croquet-debug-ui-activePage"]=t}},Zt=t=>{t.preventDefault(),t.stopPropagation()};function vt(t,e,s){const i=document.createElement("canvas"),n=i.width=40*lt/12,o=i.height=60,r=i.getContext("2d");r.font="36px Arial",r.textAlign="center",r.textBaseline="middle",r.fillStyle="black",r.fillText(t,n/2,.55*o);const a=document.createElement("button");a.id=e,a.className="croquet_dock_button";const l=t=>{t.preventDefault(),t.stopPropagation(),s()};return rt?(a.ontouchstart=l,a.ontouchend=Zt,a.onpointerdown=Zt,a.onpointerup=Zt):(a.onclick=l,a.onpointerdown=Zt,a.onpointerup=Zt),a.appendChild(i),a}function Xt(t,e){if(!1===Vt.badge)return;const s=function(t){const e=new f(t),s=["bcdfghjklmnpqrstvwxyz","aeiou"];let i="";for(let t=0;t<5;t++)i+=s[t%2][e.quick()*s[t%2].length|0];return i}(e);for(document.title=document.title.replace(/:.*/,""),document.title+=":"+s;t.firstChild;)t.removeChild(t.firstChild);const i=document.createElement("canvas"),n=i.width=120,o=i.height=40;i.style.width="100%",t.appendChild(i);const r=i.getContext("2d"),a=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const s=new f(t),i=[];for(let t=0;t<e;t++)i.push(`hsl(${360*s.quick()}, 50%, 70%)`);return i}(e,2);r.fillStyle=a[0],r.beginPath(),r.moveTo(0,0),r.lineTo(0,o),r.lineTo(n,0),r.closePath(),r.fill(),r.fillStyle=a[1],r.beginPath(),r.moveTo(n,o),r.lineTo(n,0),r.lineTo(0,o),r.closePath(),r.fill(),r.font="30px Arial",r.textAlign="center",r.textBaseline="middle",r.fillStyle="black",r.fillText(s,n/2,o/2)}function Lt(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(;t.firstChild;)t.removeChild(t.firstChild);return new b(t,{text:e,width:128,height:128,colorDark:"#000000",colorLight:"#ffffff",correctLevel:b.CorrectLevel.L,...s})}function xt(){if(!1===Vt.root||!1===Vt.qrcode)return;if(a.noqr)return;const t=Vt.sessionURL;if(!t)return void console.warn("App.sessionURL is not set");const e=Tt(Vt.qrcode);if(!e)return;rt||(e.onclick=e=>{e.preventDefault(),e.stopPropagation(),e.shiftKey?function(){const t=document.getElementById("croquet_dock");t&&t.classList.toggle("debug")}():window.open(t)});Lt(e,t).getCanvas().style.width="100%"}let St,Gt,kt=0;function Wt(){!function(){if(ut)return;ut=!0;const t=`\n        ${at?"body { min-height: 100vh }":""}\n        #croquet_spinnerOverlay {\n            z-index: 1000;\n            position: fixed;\n            left: 0;\n            top: 0;\n            width: 100%;\n            height: 100%;\n            background-color:#333;\n            opacity:0.9;\n            display:flex;\n            align-items:center;\n            justify-content:center;\n            transition: opacity 1.0s ease-out;\n        }\n        /* https://github.com/lukehaas/css-loaders */\n        @keyframes croquet_dots {\n            0%, 80%, 100% { box-shadow: 0 2.5em 0 -1.3em; }\n            40% { box-shadow: 0 2.5em 0 0; }\n        }\n        #croquet_loader,\n        #croquet_loader::before,\n        #croquet_loader::after {\n          border-radius: 50%;\n          width: 2.5em;\n          height: 2.5em;\n          animation: croquet_dots 1.8s infinite ease-in-out;\n        }\n        #croquet_loader {\n          color: #fff;\n          font-size: 10px;\n          margin: 80px auto;\n          position: relative;\n          text-indent: -9999em;\n          animation-delay: -0.16s;\n        }\n        #croquet_loader::before,\n        #croquet_loader::after {\n          content: '';\n          position: absolute;\n          top: 0;\n        }\n        #croquet_loader::before { left: -3.5em; animation-delay: -0.32s; }\n        #croquet_loader::after { left: 3.5em; }\n        #croquet_spinnerOverlay.croquet_error>*,\n        #croquet_spinnerOverlay.croquet_error>*::before,\n        #croquet_spinnerOverlay.croquet_error>*::after {\n            color: #f00;\n        }\n        #croquet_spinnerOverlay.croquet_fatal>*,\n        #croquet_spinnerOverlay.croquet_fatal>*::before,\n        #croquet_spinnerOverlay.croquet_fatal>*::after {\n            color: #f00;\n            box-shadow: 0 2.5em 0 0 !important;\n            animation: none !important;\n        }\n`,e=document.createElement("style");e.innerHTML=t,document.head.insertBefore(e,document.head.getElementsByTagName("style")[0])}();const t=document.createElement("div");t.id="croquet_spinnerOverlay";const e=document.createElement("div");return e.id="croquet_loader",e.innerText="Catching up...",t.appendChild(e),t}function Tt(t,e){if(!1===t)return!1;if(t instanceof Element)return t;if("string"==typeof t){const e=document.getElementById(t);if(e)return e}return e?e():null}const Ct=new Set;let Pt=function(){let t=null;const e=document.getElementsByTagName("link");for(const s of e)if("canonical"===s.getAttribute("rel")){t=s.getAttribute("href");break}return t||window.location.href}();const Vt={get sessionURL(){return Pt},set sessionURL(t){Pt=t,xt()},root:null,sync:!0,messages:!1,badge:!1,stats:!1,qrcode:!1,makeWidgetDock:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a.nodock)return;const e=t.debug||a.debug,s=document.getElementById("croquet_dock");s&&s.parentElement.removeChild(s);const i=Tt(Vt.root,(()=>document.body));if(!i)return;ht();const n=document.createElement("div");n.id="croquet_dock",e&&n.classList.add("debug"),at&&!t.iframe&&(n.style.display="none"),i.appendChild(n);const o=document.createElement("div");let r;o.id="croquet_dock_bar",n.appendChild(o),!1!==t.badge&&(r=document.createElement("div"),r.id="croquet_badge",o.appendChild(r),Vt.badge=r);const l=document.createElement("div");l.id="croquet_dock_content",n.appendChild(l);const c=[];let d,h;if(!1!==t.qrcode){Vt.sessionURL&&(d=document.createElement("div"),d.id="croquet_qrcode",l.appendChild(d),c.push(d.id),Vt.qrcode=d,e||(wt.activePage=d.id))}if(!1!==t.stats&&(h=document.createElement("div"),h.id="croquet_stats",l.appendChild(h),c.push(h.id),Vt.stats=h),c.length){function v(t){const e=c.length;let s,i=0;if(wt.activePage){const t=c.indexOf(wt.activePage);t>=0?(i=t,s=document.getElementById(wt.activePage)):wt.activePage=null}const n=c[(i+e+t)%e];let o;n===wt.activePage?o=s:(s&&s.classList.remove("active"),o=document.getElementById(n)),o&&o.classList.add("active"),wt.activePage=n}c.length>1&&(o.appendChild(vt("<","croquet_dock_left",(()=>v(-1)))),o.appendChild(vt(">","croquet_dock_right",(()=>v(1))))),v(0)}if(!rt&&!t.alwaysPinned){const X=vt("📌","croquet_dock_pin",(()=>{wt.pinned=!wt.pinned,L()})),L=()=>{wt.pinned?X.classList.add("pinned"):X.classList.remove("pinned")};L(),o.appendChild(X)}const u=200,m=166,p=8,f=t=>{n.style.width=`${t}px`;const e=1.18*t;n.style.height=`${e}px`;const s=18*t/100;o.style.height=`${s}px`,l.style.top=`${s+2}px`,r&&(r.style.height=.9*s+"px",r.style.width=.9*s*3+"px"),d&&(d.style.border=p*t/u+"px solid white")},b=()=>{n.style.width=n.style.height="",o.style.height="",l.style.top="",r&&(r.style.height=r.style.width=""),d&&(d.style.border="")};let y=t.fixedSize||u;const g=()=>n.classList.contains("active"),w=()=>{n.classList.add("active"),f(y),setTimeout((()=>n.style.transition="none"),300)},Z=()=>{n.style.transition="",n.classList.remove("active"),b()};if(rt)Z(),n.ontouchstart=t=>{t.preventDefault(),t.stopPropagation(),g()?Z():w()},n.ontouchend=Zt,n.onpointerdown=Zt,n.onpointerup=Zt;else if(t.alwaysPinned?w():(wt.pinned?w():Z(),n.onmouseenter=w,n.onmouseleave=()=>{wt.pinned||Z()}),!t.fixedSize){let x=0;n.addEventListener("wheel",(t=>{t.stopPropagation();const e=Date.now();if(e-x<100)return;x=e;let{deltaY:s}=t;s=Math.sign(s)*Math.min(5,Math.abs(s));const i=.8*Math.min(window.innerWidth,window.innerHeight);y=Math.max(m,Math.min(i,n.offsetWidth/1.05**s)),f(y)}),{passive:!0})}},makeSessionWidgets:function(t){!function(t){if(!t||!1===Vt.root)return;const e=Tt(Vt.badge);e&&Xt(e,t)}(t),xt(),function(){if(!1===Vt.root)return;if(a.nostats)return;const t=Tt(Vt.stats);t&&J(t)}()},makeQRCanvas(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Vt.sessionURL)return null;const e=Lt(document.createElement("div"),Vt.sessionURL,t);return e&&e.getCanvas()},clearSessionMoniker:function(){!1!==Vt.badge&&(document.title=document.title.replace(/:.*/,""))},showSyncWait(t){!1===Vt.root?t=!1:St||(St=Wt()),function(t){if(Gt!==t&&("string"!=typeof Gt||!0!==t))if(!1===Vt.sync&&(t=!1),Gt=t,t)clearTimeout(kt),kt=setTimeout((()=>{Gt&&(Tt(Vt.root,(()=>document.body)).appendChild(St),St.style.opacity=.9,St.className="error"===Gt?"croquet_error":"fatal"===Gt?"croquet_fatal":"")}),500);else{if(!St)return;clearTimeout(kt),St.style.opacity=0,St.className="",kt=setTimeout((()=>{Gt||St.parentElement&&St.parentElement.removeChild(St)}),500)}}(t)},messageFunction:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e.level;let i;return"error"===s?(i="orangered,red",console.error(t)):"warning"===s?(i="gold,orange",console.warn(t)):i="silver,gray",gt(t,{style:{background:`linear-gradient(90deg,${i})`},...e})},showMessage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("once"===e.only){if(Ct.has(t))return null;Ct.add(t)}return"fatal"===e.level&&(e.level="error",e.showSyncWait="fatal"),e.showSyncWait&&("fatal"!==e.showSyncWait||e.duration||(e.duration=-1),Vt.showSyncWait(e.showSyncWait)),a.nomessages||!1===Vt.root||!1===Vt.messages||!Vt.messageFunction?("warning"===e.level&&console.warn(t),"error"===e.level&&console.error(t),null):Vt.messageFunction(t,e)},isCroquetHost:t=>t.endsWith("croquet.io")||["localhost","127.0.0.1","[::1]"].includes(t)||t.endsWith("ngrok.io"),referrerURL(){const t=new URL(Vt.sessionURL),e=this.isCroquetHost(t.hostname);return`${t.protocol}//${t.host}${t.pathname}${e?t.search:""}`},autoSession(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{key:"q"};"string"==typeof t&&(t={key:t}),t||(t={});const e=t.key||"q",s=new URL(Vt.sessionURL);let i="";const n=s.search.slice(1).split("&"),o=n.find((t=>t.split("=")[0]===e));if(o?i=o.replace(/[^=]*=/,""):(i=n.find((t=>!t.includes("="))),i||(i=s.hash.slice(1),i&&(s.hash="",s.search?s.searchParams.set(e,i):s.search=i))),i)try{i=decodeURIComponent(i)}catch(t){}else i=Math.floor(Math.random()*36**10).toString(36),s.searchParams.set(e,i);const r=s.toString("");window.location.href!==r&&(window.history.replaceState({},"",r),Vt.sessionURL=r),a.has("debug","session")&&console.log(`Croquet.App.autoSession: "${i}"`);const l=Promise.resolve(i);return l[Symbol.toPrimitive]=()=>(console.warn("Deprecated: Croquet.App.autoSession() return value used directly. It returns a promise now!"),i),l},autoPassword(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{key:"pw",scrub:!1,keyless:!1};const e=t.key||"pw",s=t.scrub&&!a.has("debug","password"),i=t.keyless,n=new URL(Vt.sessionURL);let o="";const r=n.hash.slice(1);if(r){const t=r.split("&"),a=t.find((t=>t.split("=")[0]===e));a?(o=a.replace(/[^=]*=/,""),o&&s&&(n.hash=t.filter((t=>t.split("=")[0]!==e)).join("&"))):i&&(o=t.find((t=>!t.includes("="))),o&&s&&(n.hash=t.filter((t=>t!==o)).join("&")))}if(!o){const t=new Uint8Array(16);window.crypto.getRandomValues(t),o=k(t.buffer),n.hash=r?`${r}&${e}=${o}`:i?o:`${e}=${o}`,Vt.sessionURL=n.href,s&&(n.hash=r)}if(a.has("debug","session")&&console.log(`Croquet.App.sessionUrl: ${Vt.sessionURL}`),window.location.href!==n.href&&window.history.replaceState({},"",n.href),o)try{o=decodeURIComponent(o)}catch(t){}a.has("debug","session")&&console.log(`Croquet.App.autoPassword: "${o}"`);const l=Promise.resolve(o);return l[Symbol.toPrimitive]=()=>(console.warn("Deprecated: Croquet.App.autoPassword() return value used directly. It returns a promise now!"),o),l}},Rt="#__vote";function Yt(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i="none";for(const n of["immediate","queued","oncePerFrame","oncePerFrameWhileSynced"])for(const o of t[n])o.for===e?null===s||o.unbound===s?t[n].delete(o):i="subscriber":"none"===i&&(i="others");return i}const Mt=globalThis.CROQUETVD=new class{constructor(){this.subscriptions={},this.subscribers=new Map,this.queuedEvents=[],this.perFrameEvents=new Map,this.perSyncedFrameEvents=new Map,this.subscriberIds=0}register(t){return"V"+ ++this.subscriberIds}deregister(t){}addSubscription(t,e,s,i,n){if("vote"===n)return void this.addSubscription(t,e+Rt,s,i,"immediate");const o=t+":"+e,r=i;r.for=s;let a=this.subscriptions[o];if(a||(a=this.subscriptions[o]={immediate:new Set,queued:new Set,oncePerFrame:new Set,oncePerFrameWhileSynced:new Set}),!a[n])throw Error(`Unknown subscribe() option: handling="${n}"`);a[n].add(r);let l=this.subscribers.get(s);l||this.subscribers.set(s,l=new Set),l.add(o)}removeSubscription(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const n=t+":"+e,o=this.subscriptions[n];if(o){const t=Yt(o,s,i);if("none"===t&&delete this.subscriptions[n],"subscriber"!==t){const t=this.subscribers.get(s);t.delete(n),0===t.size&&this.subscribers.delete(s)}}e.endsWith(Rt)||this.removeSubscription(t,e+Rt,s)}removeAllSubscriptionsFor(t){const e=this.subscribers.get(t);if(e){for(const s of e){const e=this.subscriptions[s];if(e){"none"===Yt(e,t)&&delete this.subscriptions[s]}else console.error(`Croquet: topic ${s} not found in subscriptions table for ${t} during removeAllSubscriptionsFor()`)}this.subscribers.delete(t)}}handleEvent(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t=>t();const i=this.subscriptions[t];i&&(i.queued.size>0&&this.queuedEvents.push({topic:t,data:e}),i.oncePerFrame.size>0&&this.perFrameEvents.set(t,e),i.oncePerFrameWhileSynced.size>0&&this.perSyncedFrameEvents.set(t,e),i.immediate.size>0&&s((()=>{for(const s of i.immediate)try{s(e)}catch(e){console.error(e),console.warn(`Croquet: error "${e.message}" in "immediate" subscription ${t}`)}})))}processFrameEvents(t,e){let s=0;const i=(t,e,i)=>{const n=this.subscriptions[e];if(n)for(const o of n[t]){try{o(i)}catch(s){console.error(s),console.warn(`Croquet: error "${s.message}" in "${t}" subscription ${e}`)}s++}};for(const{topic:t,data:e}of this.queuedEvents)i("queued",t,e);if(this.queuedEvents.length=0,t){for(const[t,e]of this.perFrameEvents)i("oncePerFrame",t,e);if(this.perFrameEvents.clear(),e){for(const[t,e]of this.perSyncedFrameEvents)i("oncePerFrameWhileSynced",t,e);this.perSyncedFrameEvents.clear()}for(const{topic:t,data:e}of this.queuedEvents)i("queued",t,e);this.queuedEvents.length=0}return s}};let It={get subscribe(){return It={subscribe:a.has("debug","subscribe",!1)},It.subscribe}};class Ht{constructor(t){this.vm=t}register(t){return this.vm.registerModel(t)}deregister(t){this.vm.deregisterModel(t.id)}publish(t,e,s){this.vm.publishFromModel(s,t,e)}subscribe(t,e,s,i){return It.subscribe&&console.log(`Model.subscribe("${e}:${s}", ${t} ${(""+i).replace(/\([\s\S]*/,"")})`),this.vm.addSubscription(t,e,s,i)}unsubscribe(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"*";It.subscribe&&console.log(`Model.unsubscribe(${e}:${s}", ${t} ${(""+i).replace(/\([\s\S]*/,"")})`),this.vm.removeSubscription(t,e,s,i)}unsubscribeAll(t){It.subscribe&&console.log(`Model.unsubscribeAll(${t} ${t.id})`),this.vm.removeAllSubscriptionsFor(t)}future(t,e,s,i){if(zt&&zt.equal(this))return this.vm.future(t,e,s,i);throw Error(`Model.future() called from outside: ${t}`)}cancelFuture(t,e){if(zt&&zt.equal(this))return this.vm.cancelFuture(t,e);throw Error(`Model.cancelFuture() called from outside: ${t}`)}random(){return this.vm.random()}now(){return this.vm.time}equal(t){return t instanceof Ht&&t.vm===this.vm}isViewRealm(){return!1}}class Kt{constructor(t){this.vd=Mt,this.vm=t,this.controller=t.controller}valid(){return this.vm===this.controller.vm}register(t){return Mt.register(t)}deregister(t){Mt.deregister(t)}publish(t,e,s){this.vm.publishFromView(s,t,e)}subscribe(t,e,s,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"queued";It.subscribe&&console.log(`View.subscribe("${i}:${t}", ${e} ${s?s.name||(""+s).replace(/\([\s\S]*/,""):""+s} [${n}])`),Mt.addSubscription(i,t,e,s,n)}unsubscribe(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3?arguments[3]:void 0;It.subscribe&&console.log(`View.unsubscribe("${i}:${t}", ${e} ${s?s.name||(""+s).replace(/\([\s\S]*/,""):"*"})`),Mt.removeSubscription(i,t,e,s)}unsubscribeAll(t){It.subscribe&&console.log(`View.unsubscribeAll(${t})`),Mt.removeAllSubscriptionsFor(t)}future(t,e){const s=this.vm;return new Proxy(t,{get(i,n){if("function"==typeof t[n]){return new Proxy(t[n],{apply(i,o,r){setTimeout((()=>{t.id&&_t(s,(()=>t[n](...r)),!0)}),e)}})}throw Error("Tried to call "+n+"() on future of "+Object.getPrototypeOf(t).constructor.name+" which is not a function")}})}random(){return Math.random()}now(){return this.vm.time}externalNow(){return this.controller.reflectorTime}extrapolatedNow(){return this.controller.extrapolatedTime}isSynced(){return!!this.controller.synced}equal(t){return t instanceof Kt&&t.vm===this.vm}isViewRealm(){return!0}}let zt=null;function Nt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Tried to execute code that requires realm outside of realm.";if(!zt&&t)throw Error(t);return zt}function Ft(t,e){if(null!==zt)throw Error("Can't switch realms from inside realm");try{return zt=new Ht(t),e()}finally{zt=null}}function _t(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(null!==zt&&!s)throw Error("Can't switch realms from inside realm");const i=zt;try{return zt=new Kt(t),e()}finally{zt=i}}var jt=function(t){return t!=t},Qt=Math.sqrt,Et=.7853981633974483;var Jt=function(t){var e,s;return 0===t?.16666666666666713:((t<0?-t:t)<=1?(e=t*(19.562619833175948+t*(t*(5.444622390564711+t*(.004253011369004428*t-.6019598008014124))-16.262479672107002))-8.198089802484825,s=t*(139.51056146574857+t*(t*(70.49610280856842+t*(1*t-14.740913729888538))-147.1791292232726))-49.18853881490881):(e=.004253011369004428+(t=1/t)*(t*(5.444622390564711+t*(t*(19.562619833175948+-8.198089802484825*t)-16.262479672107002))-.6019598008014124),s=1+t*(t*(70.49610280856842+t*(t*(139.51056146574857+-49.18853881490881*t)-147.1791292232726))-14.740913729888538)),e/s)};var Ut=function(t){var e,s;return 0===t?.08333333333333809:((t<0?-t:t)<=1?(e=28.536655482610616+t*(t*(6.968710824104713+t*(.002967721961301243*t-.5634242780008963))-25.56901049652825),s=342.43986579130785+t*(t*(147.0656354026815+t*(1*t-21.947795316429207))-383.8770957603691)):(e=.002967721961301243+(t=1/t)*(t*(6.968710824104713+t*(28.536655482610616*t-25.56901049652825))-.5634242780008963),s=1+t*(t*(147.0656354026815+t*(342.43986579130785*t-383.8770957603691))-21.947795316429207)),e/s)};var Dt=function(t){var e,s,i,n,o;if(jt(t))return NaN;if(t>0?i=t:(e=!0,i=-t),i>1)return NaN;if(i>.625)n=(s=1-i)*Ut(s),s=Qt(s+s),o=Et-s,o-=s=s*n-6123233995736766e-32,o+=Et;else{if(i<1e-8)return t;o=i*(o=(s=i*i)*Jt(s))+i}return e?-o:o};var Ot=function(t){var e;return jt(t)||t<-1||t>1?NaN:t>.5?2*Dt(Qt(.5-.5*t)):(e=Et-Dt(t),e+=6123233995736766e-32,e+=Et)};var Bt=function(){return"function"==typeof Symbol&&"symbol"==typeof Symbol("foo")}();var At=function(){return Bt&&"symbol"==typeof Symbol.toStringTag},$t=Object.prototype.toString;var qt=function(t){return $t.call(t)},te=Object.prototype.hasOwnProperty;var ee=function(t,e){return null!=t&&te.call(t,e)},se="function"==typeof Symbol?Symbol.toStringTag:"";var ie=function(t){var e,s,i;if(null==t)return $t.call(t);s=t[se],e=ee(t,se);try{t[se]=void 0}catch(e){return $t.call(t)}return i=$t.call(t),e?t[se]=s:delete t[se],i},ne=At()?ie:qt,oe="function"==typeof Uint32Array;var re=function(t){return oe&&t instanceof Uint32Array||"[object Uint32Array]"===ne(t)},ae=4294967295,le="function"==typeof Uint32Array?Uint32Array:null;var ce=function(){var t,e;if("function"!=typeof le)return!1;try{e=new le(e=[1,3.14,-3.14,ae+1,ae+2]),t=re(e)&&1===e[0]&&3===e[1]&&e[2]===ae-2&&0===e[3]&&1===e[4]}catch(e){t=!1}return t},de="function"==typeof Uint32Array?Uint32Array:null;var he=function(){throw new Error("not implemented")},ue=ce()?de:he,me="function"==typeof Float64Array;var pe=function(t){return me&&t instanceof Float64Array||"[object Float64Array]"===ne(t)},fe="function"==typeof Float64Array?Float64Array:null;var be=function(){var t,e;if("function"!=typeof fe)return!1;try{e=new fe([1,3.14,-3.14,NaN]),t=pe(e)&&1===e[0]&&3.14===e[1]&&-3.14===e[2]&&e[3]!=e[3]}catch(e){t=!1}return t},ye="function"==typeof Float64Array?Float64Array:null;var ge=function(){throw new Error("not implemented")},we=be()?ye:ge,Ze="function"==typeof Uint8Array;var ve=function(t){return Ze&&t instanceof Uint8Array||"[object Uint8Array]"===ne(t)},Xe="function"==typeof Uint8Array?Uint8Array:null;var Le=function(){var t,e;if("function"!=typeof Xe)return!1;try{e=new Xe(e=[1,3.14,-3.14,256,257]),t=ve(e)&&1===e[0]&&3===e[1]&&253===e[2]&&0===e[3]&&1===e[4]}catch(e){t=!1}return t},xe="function"==typeof Uint8Array?Uint8Array:null;var Se=function(){throw new Error("not implemented")},Ge=Le()?xe:Se,ke="function"==typeof Uint16Array;var We=function(t){return ke&&t instanceof Uint16Array||"[object Uint16Array]"===ne(t)},Te="function"==typeof Uint16Array?Uint16Array:null;var Ce=function(){var t,e;if("function"!=typeof Te)return!1;try{e=new Te(e=[1,3.14,-3.14,65536,65537]),t=We(e)&&1===e[0]&&3===e[1]&&65533===e[2]&&0===e[3]&&1===e[4]}catch(e){t=!1}return t},Pe="function"==typeof Uint16Array?Uint16Array:null;var Ve,Re=function(){throw new Error("not implemented")},Ye={uint16:Ce()?Pe:Re,uint8:Ge};(Ve=new Ye.uint16(1))[0]=4660;var Me=52===new Ye.uint8(Ve.buffer)[0],Ie=!0===Me?1:0,He=new we(1),Ke=new ue(He.buffer);var ze=function(t){return He[0]=t,Ke[Ie]},Ne=!0===Me?1:0,Fe=new we(1),_e=new ue(Fe.buffer);var je=function(t,e){return Fe[0]=t,_e[Ne]=e>>>0,Fe[0]},Qe=je,Ee=Number.POSITIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ue=1023;var De=function(t){return 0===t?.6666666666666735:.6666666666666735+t*(.3999999999940942+t*(.2857142874366239+t*(.22222198432149784+t*(.1818357216161805+t*(.15313837699209373+.14798198605116586*t)))))},Oe=.6931471803691238,Be=1.9082149292705877e-10;var Ae=function(t){var e,s,i,n,o,r,a,l,c,d;if(t<-1||jt(t))return NaN;if(-1===t)return Je;if(t===Ee)return t;if(0===t)return t;if(d=1,(i=t<0?-t:t)<.41421356237309503){if(i<1.862645149230957e-9)return i<5551115123125783e-32?t:t-t*t*.5;t>-.2928932188134525&&(d=0,n=t,s=1)}return 0!==d&&(i<9007199254740992?(o=(d=((s=ze(c=1+t))>>20)-Ue)>0?1-(c-t):t-(c-1),o/=c):(d=((s=ze(c=t))>>20)-Ue,o=0),(s&=1048575)<434334?c=Qe(c,1072693248|s):(d+=1,c=Qe(c,1071644672|s),s=1048576-s>>2),n=c-1),e=.5*n*n,0===s?0===n?d*Oe+(o+=d*Be):d*Oe-((l=e*(1-.6666666666666666*n))-(d*Be+o)-n):(l=(a=(r=n/(2+n))*r)*De(a),0===d?n-(e-r*(e+l)):d*Oe-(e-(r*(e+l)+(d*Be+o))-n))},$e=.6931471805599453;var qe=function(t){return 0===t?.3999999999940942:.3999999999940942+t*(.22222198432149784+.15313837699209373*t)};var ts=function(t){return 0===t?.6666666666666735:.6666666666666735+t*(.2857142874366239+t*(.1818357216161805+.14798198605116586*t))},es=.6931471803691238,ss=1.9082149292705877e-10,is=1048575;var ns=function(t){var e,s,i,n,o,r,a,l,c,d,h;return 0===t?Je:jt(t)||t<0?NaN:(n=0,(s=ze(t))<1048576&&(n-=54,s=ze(t*=0x40000000000000)),s>=2146435072?t+t:(n+=(s>>20)-Ue|0,n+=(a=(s&=is)+614244&1048576|0)>>20|0,r=(t=Qe(t,s|1072693248^a))-1,(is&2+s)<3?0===r?0===n?0:n*es+n*ss:(o=r*r*(.5-.3333333333333333*r),0===n?r-o:n*es-(o-n*ss-r)):(a=s-398458|0,l=440401-s|0,i=(d=(h=(c=r/(2+r))*c)*h)*qe(d),o=h*ts(d)+i,(a|=l)>0?(e=.5*r*r,0===n?r-(e-c*(e+o)):n*es-(e-(c*(e+o)+n*ss)-r)):0===n?r-c*(r-o):n*es-(c*(r-o)-n*ss-r))))};var os=function(t){var e;return jt(t)||t<1?NaN:1===t?0:t>=268435456?ns(t)+$e:t>2?ns(2*t-1/(t+Qt(t*t-1))):Ae((e=t-1)+Qt(2*e+e*e))};var rs=function(t){return t===Ee||t===Je};var as=function(t){var e,s,i;return jt(t)||rs(t)?t:(t<0&&(t=-t,e=!0),i=t<3.725290298461914e-9?t:t>268435456?ns(t)+$e:t>2?ns(2*t+1/(Qt(t*t+1)+t)):Ae(t+(s=t*t)/(1+Qt(1+s))),e?-i:i)},ls=1.5707963267948966;var cs=function(t){return 0===t?-64.85021904942025:t*(t*(t*(-.8750608600031904*t-16.157537187333652)-75.00855792314705)-122.88666844901361)-64.85021904942025};var ds=function(t){return 0===t?194.5506571482614:194.5506571482614+t*(485.3903996359137+t*(432.88106049129027+t*(165.02700983169885+t*(24.858464901423062+1*t))))},hs=6123233995736766e-32;var us=function(t){var e,s,i,n;return jt(t)||0===t?t:t===Ee?ls:t===Je?-ls:(t<0&&(s=!0,t=-t),e=0,t>2.414213562373095?(i=ls,e=1,t=-1/t):t<=.66?i=0:(i=Et,e=2,t=(t-1)/(t+1)),n=t*(n=(n=t*t)*cs(n)/ds(n))+t,2===e?n+=.5*hs:1===e&&(n+=hs),i+=n,s?-i:i)};var ms,ps,fs=function(t){var e,s;return jt(t)||t<-1||t>1?NaN:1===t?Ee:-1===t?Je:(t<0&&(e=!0,t=-t),t<3.725290298461914e-9?e?-t:t:(s=t<.5?.5*Ae((s=t+t)+s*t/(1-t)):.5*Ae((t+t)/(1-t)),e?-s:s))};!0===Me?(ms=1,ps=0):(ms=0,ps=1);var bs={HIGH:ms,LOW:ps},ys=new we(1),gs=new ue(ys.buffer),ws=bs.HIGH,Zs=bs.LOW;var vs=function(t,e){return ys[0]=e,t[0]=gs[ws],t[1]=gs[Zs],t};var Xs,Ls,xs=function(t,e){return 1===arguments.length?vs([0,0],t):vs(t,e)},Ss=xs;!0===Me?(Xs=1,Ls=0):(Xs=0,Ls=1);var Gs={HIGH:Xs,LOW:Ls},ks=new we(1),Ws=new ue(ks.buffer),Ts=Gs.HIGH,Cs=Gs.LOW;var Ps=function(t,e){return Ws[Ts]=t,Ws[Cs]=e,ks[0]},Vs=Ps,Rs=[0,0];var Ys=function(t,e){var s,i;return Ss(Rs,t),s=Rs[0],s&=2147483647,i=ze(e),Vs(s|=i&=2147483648,Rs[1])};var Ms=function(t){return!!(ze(t)>>>31)},Is=3.141592653589793;var Hs=function(t,e){var s;return jt(e)||jt(t)?NaN:rs(e)?e===Ee?rs(t)?Ys(Is/4,t):Ys(0,t):rs(t)?Ys(3*Is/4,t):Ys(Is,t):rs(t)?Ys(Is/2,t):0===t?e>=0&&!Ms(e)?Ys(0,t):Ys(Is,t):0===e?Ys(Is/2,t):(s=us(t/e),e<0?s<=0?s+Is:s-Is:s)},Ks=22250738585072014e-324;var zs=function(t){return 0===t?1.87595182427177:1.87595182427177+t*(t*(1.6214297201053545+t*(.14599619288661245*t-.758397934778766))-1.8849797954337717)},Ns=2147483647;var Fs=function(t){var e,s,i,n,o;return jt(t)||rs(t)||0===t?t:(s=-2147483648&(i=ze(t)),i&=Ns,o=0,t<Ks?(o=0x40000000000000,e=ze(o*=t),o=Vs(s|(e=(e&Ns)/3+696219795),0)):o=Qe(o,s|(e=i/3+715094163)),o*=zs(n=o*o*(o/t)),e=ze(o),o=Vs(e+1,0),o+=o*(n=((n=t/(o*o))-o)/(o+o+n)))},_s=Fs;var js=function(t){return 0===t?.0416666666666666:.0416666666666666+t*(2480158728947673e-20*t-.001388888888887411)};var Qs=function(t){return 0===t?-2.7557314351390663e-7:t*(2.087572321298175e-9+-11359647557788195e-27*t)-2.7557314351390663e-7};var Es=function(t,e){var s,i,n,o;return n=(o=t*t)*o,i=o*js(o),i+=n*n*Qs(o),(n=1-(s=.5*o))+(1-n-s+(o*i-t*e))},Js=-.16666666666666632;var Us=function(t,e){var s,i,n;return s=.00833333333332249+(n=t*t)*(27557313707070068e-22*n-.0001984126982985795)+n*(n*n)*(1.58969099521155e-10*n-2.5050760253406863e-8),i=n*t,0===e?t+i*(Js+n*s):t-(n*(.5*e-i*s)-e-i*Js)},Ds=!0===Me?0:1,Os=new we(1),Bs=new ue(Os.buffer);var As=function(t){return Os[0]=t,Bs[Ds]},$s=Math.floor;var qs=function(t){return t<0?-t:0===t?0:t};var ti=function(t,e){return jt(e)||rs(e)?(t[0]=e,t[1]=0,t):0!==e&&qs(e)<Ks?(t[0]=4503599627370496*e,t[1]=-52,t):(t[0]=e,t[1]=0,t)};var ei=function(t,e){return 1===arguments.length?ti([0,0],t):ti(t,e)},si=ei;var ii=function(t){var e=ze(t);return(e=(2146435072&e)>>>20)-Ue|0},ni=ii,oi=[0,0],ri=[0,0];var ai=function(t,e){var s,i;return 0===t||jt(t)||rs(t)?t:(si(oi,t),e+=oi[1],(e+=ni(t=oi[0]))<-1074?Ys(0,t):e>1023?t<0?Je:Ee:(e<=-1023?(e+=52,i=2220446049250313e-31):i=1,Ss(ri,t),s=ri[0],s&=2148532223,i*Vs(s|=e+Ue<<20,ri[1])))},li=ai,ci=[10680707,7228996,1387004,2578385,16069853,12639074,9804092,4427841,16666979,11263675,12935607,2387514,4345298,14681673,3074569,13734428,16653803,1880361,10960616,8533493,3062596,8710556,7349940,6258241,3772886,3769171,3798172,8675211,12450088,3874808,9961438,366607,15675153,9132554,7151469,3571407,2607881,12013382,4155038,6285869,7677882,13102053,15825725,473591,9065106,15363067,6271263,9264392,5636912,4652155,7056368,13614112,10155062,1944035,9527646,15080200,6658437,6231200,6832269,16767104,5075751,3212806,1398474,7579849,6349435,12618859],di=[1.570796251296997,7.549789415861596e-8,5390302529957765e-30,3282003415807913e-37,1270655753080676e-44,12293330898111133e-52,27337005381646456e-60,21674168387780482e-67],hi=16777216,ui=5.960464477539063e-8,mi=yi(new Array(20)),pi=yi(new Array(20)),fi=yi(new Array(20)),bi=yi(new Array(20));function yi(t){var e,s=t.length;for(e=0;e<s;e++)t[e]=0;return t}function gi(t,e,s,i,n,o,r,a,l){var c,d,h,u,m,p,f,b,y;for(u=o,y=i[s],b=s,m=0;b>0;m++)d=ui*y|0,bi[m]=y-hi*d|0,y=i[b-1]+d,b-=1;if(y=li(y,n),y-=8*$s(.125*y),y-=f=0|y,h=0,n>0?(f+=m=bi[s-1]>>24-n,bi[s-1]-=m<<24-n,h=bi[s-1]>>23-n):0===n?h=bi[s-1]>>23:y>=.5&&(h=2),h>0){for(f+=1,c=0,m=0;m<s;m++)b=bi[m],0===c?0!==b&&(c=1,bi[m]=16777216-b):bi[m]=16777215-b;if(n>0)switch(n){case 1:bi[s-1]&=8388607;break;case 2:bi[s-1]&=4194303}2===h&&(y=1-y,0!==c&&(y-=li(1,n)))}if(0===y){for(b=0,m=s-1;m>=o;m--)b|=bi[m];if(0===b){for(p=1;0===bi[o-p];p++);for(m=s+1;m<=s+p;m++){for(l[a+m]=ci[r+m],d=0,b=0;b<=a;b++)d+=t[b]*l[a+(m-b)];i[m]=d}return gi(t,e,s+=p,i,n,o,r,a,l)}}if(0===y)for(s-=1,n-=24;0===bi[s];)s-=1,n-=24;else(y=li(y,-n))>=hi?(d=ui*y|0,bi[s]=y-hi*d|0,n+=24,bi[s+=1]=d):bi[s]=0|y;for(d=li(1,n),m=s;m>=0;m--)i[m]=d*bi[m],d*=ui;for(m=s;m>=0;m--){for(d=0,p=0;p<=u&&p<=s-m;p++)d+=di[p]*i[m+p];fi[s-m]=d}for(d=0,m=s;m>=0;m--)d+=fi[m];for(e[0]=0===h?d:-d,d=fi[0]-d,m=1;m<=s;m++)d+=fi[m];return e[1]=0===h?d:-d,7&f}var wi=function(t,e,s,i){var n,o,r,a,l,c,d;for(4,(o=(s-3)/24|0)<0&&(o=0),a=s-24*(o+1),c=o-(r=i-1),d=r+4,l=0;l<=d;l++)mi[l]=c<0?0:ci[c],c+=1;for(l=0;l<=4;l++){for(n=0,c=0;c<=r;c++)n+=t[c]*mi[r+(l-c)];pi[l]=n}return 4,gi(t,e,4,pi,a,4,o,r,mi)},Zi=Math.round;var vi=function(t,e,s){var i,n,o,r,a;return o=t-1.5707963267341256*(i=Zi(.6366197723675814*t)),r=6077100506506192e-26*i,a=e>>20|0,s[0]=o-r,a-(ze(s[0])>>20&2047)>16&&(r=20222662487959506e-37*i-((n=o)-(o=n-(r=6077100506303966e-26*i))-r),s[0]=o-r,a-(ze(s[0])>>20&2047)>49&&(r=84784276603689e-45*i-((n=o)-(o=n-(r=20222662487111665e-37*i))-r),s[0]=o-r)),s[1]=o-s[0]-r,i},Xi=1.5707963267341256,Li=6077100506506192e-26,xi=2*Li,Si=3*Li,Gi=4*Li,ki=new Array(3),Wi=new Array(2);var Ti=function(t,e){var s,i,n,o,r,a,l;if((n=2147483647&ze(t)|0)<=1072243195)return e[0]=t,e[1]=0,0;if(n<=1074752122)return 598523==(1048575&n)?vi(t,n,e):n<=1073928572?t>0?(l=t-Xi,e[0]=l-Li,e[1]=l-e[0]-Li,1):(l=t+Xi,e[0]=l+Li,e[1]=l-e[0]+Li,-1):t>0?(l=t-2*Xi,e[0]=l-xi,e[1]=l-e[0]-xi,2):(l=t+2*Xi,e[0]=l+xi,e[1]=l-e[0]+xi,-2);if(n<=1075594811)return n<=1075183036?1074977148===n?vi(t,n,e):t>0?(l=t-3*Xi,e[0]=l-Si,e[1]=l-e[0]-Si,3):(l=t+3*Xi,e[0]=l+Si,e[1]=l-e[0]+Si,-3):1075388923===n?vi(t,n,e):t>0?(l=t-4*Xi,e[0]=l-Gi,e[1]=l-e[0]-Gi,4):(l=t+4*Xi,e[0]=l+Gi,e[1]=l-e[0]+Gi,-4);if(n<1094263291)return vi(t,n,e);if(n>=2146435072)return e[0]=NaN,e[1]=NaN,0;for(s=As(t),l=Vs(n-((i=(n>>20)-1046)<<20|0),s),r=0;r<2;r++)ki[r]=0|l,l=16777216*(l-ki[r]);for(ki[2]=l,o=3;0===ki[o-1];)o-=1;return a=wi(ki,Wi,i,o),t<0?(e[0]=-Wi[0],e[1]=-Wi[1],-a):(e[0]=Wi[0],e[1]=Wi[1],a)},Ci=Ti,Pi=[0,0];var Vi=function(t){var e;if(e=ze(t),(e&=2147483647)<=1072243195)return e<1044381696?1:Es(t,0);if(e>=2146435072)return NaN;switch(3&Ci(t,Pi)){case 0:return Es(Pi[0],Pi[1]);case 1:return-Us(Pi[0],Pi[1]);case 2:return-Es(Pi[0],Pi[1]);default:return Us(Pi[0],Pi[1])}},Ri=Math.ceil;var Yi=function(t){return t<0?Ri(t):$s(t)};var Mi=function(t){return 0===t?.16666666666666602:.16666666666666602+t*(t*(6613756321437934e-20+t*(4.1381367970572385e-8*t-16533902205465252e-22))-.0027777777777015593)};var Ii=function(t,e,s){var i,n,o;return o=(i=t-e)-(n=i*i)*Mi(n),li(1-(e-i*o/(2-o)-t),s)},Hi=1.4426950408889634,Ki=1/(1<<28);var zi=function(t){var e;return jt(t)||t===Ee?t:t===Je?0:t>709.782712893384?Ee:t<-745.1332191019411?0:t>-3.725290298461914e-9&&t<Ki?1+t:(e=Yi(t<0?Hi*t-.5:Hi*t+.5),Ii(t-.6931471803691238*e,1.9082149292705877e-10*e,e))};var Ni=function(t){return jt(t)?t:(t<0&&(t=-t),t>21?zi(t)/2:(zi(t)+zi(-t))/2)};var Fi=function(t){return 0===t?-.03333333333333313:t*(.0015873015872548146+t*(t*(4008217827329362e-21+-2.0109921818362437e-7*t)-793650757867488e-19))-.03333333333333313},_i=.6931471803691238,ji=1.9082149292705877e-10,Qi=1.4426950408889634;var Ei=function(t){var e,s,i,n,o,r,a,l,c,d,h,u;if(t===Ee||jt(t))return t;if(t===Je)return-1;if(0===t)return t;if(t<0?(s=!0,a=-t):(s=!1,a=t),a>=38.816242111356935){if(s)return-1;if(a>=709.782712893384)return Ee}if(o=0|ze(a),a>.34657359027997264)a<1.0397207708399179?s?(i=t+_i,n=-ji,u=-1):(i=t-_i,n=ji,u=1):(u=s?Qi*t-.5:Qi*t+.5,i=t-(d=u|=0)*_i,n=d*ji),c=i-(t=i-n)-n;else{if(o<1016070144)return t;u=0}return h=(l=t*(e=.5*t))*(((r=1+l*Fi(l))-(d=3-r*e))/(6-t*d)),0===u?t-(t*h-l):(h=t*(h-c)-c,h-=l,-1===u?.5*(t-h)-.5:1===u?t<-.25?-2*(h-(t+.5)):1+2*(t-h):u<=-2||u>56?(i=ze(a=1-(h-t))+(u<<20)|0,(a=Qe(a,i))-1):(d=1,u<20?a=(d=Qe(d,i=1072693248-(2097152>>u)|0))-(h-t):(a=t-(h+(d=Qe(d,i=Ue-u<<20|0))),a+=1),i=ze(a)+(u<<20)|0,Qe(a,i)))},Ji=!0===Me?0:1,Ui=new we(1),Di=new ue(Ui.buffer);var Oi=function(t,e){return Ui[0]=t,Di[Ji]=e>>>0,Ui[0]},Bi=Oi;var Ai=function(t){return 0===t?.3999999999940942:.3999999999940942+t*(.22222198432149784+.15313837699209373*t)};var $i=function(t){return 0===t?.6666666666666735:.6666666666666735+t*(.2857142874366239+t*(.1818357216161805+.14798198605116586*t))},qi=1048575;var tn=function(t){var e,s,i,n,o,r,a,l,c,d;return i=ze(t),n=t-1,(qi&2+i)<3?0===n?0:n*n*(.3333333333333333*n-.5):(c=(i&=qi)-398458|0,d=440401-i|0,s=(l=(r=(o=n/(2+n))*o)*r)*Ai(l),a=r*$i(l)+s,(c|=d)>0?o*((e=.5*n*n)+a)-e:o*(a-n))},en=.4342944818781689;var sn=function(t){var e,s,i,n,o,r,a;return jt(t)||t<0?NaN:0===t?Je:(o=0,(s=ze(t))<1048576&&(o-=54,s=ze(t*=0x40000000000000)),s>=2146435072?t+t:(o+=(s>>20)-Ue|0,t=Qe(t,(s&=1048575)|1072693248^(n=s+614244&1048576|0)),r=o+=n>>20|0,i=tn(t),a=3694239077158931e-28*r+25082946711645275e-27*((t-=1)+i),(a+=(t-(e=Bi(t,0))+i)*en+e*en)+.30102999566361177*r))};var nn=function(t){return 0===t?.3999999999940942:.3999999999940942+t*(.22222198432149784+.15313837699209373*t)};var on=function(t){return 0===t?.6666666666666735:.6666666666666735+t*(.2857142874366239+t*(.1818357216161805+.14798198605116586*t))},rn=1048575;var an=function(t){var e,s,i,n,o,r,a,l,c,d;return i=ze(t),n=t-1,(rn&2+i)<3?0===n?0:n*n*(.3333333333333333*n-.5):(c=(i&=rn)-398458|0,d=440401-i|0,s=(l=(r=(o=n/(2+n))*o)*r)*nn(l),a=r*on(l)+s,(c|=d)>0?o*((e=.5*n*n)+a)-e:o*(a-n))},ln=1.4426950407214463,cn=[0,0];var dn=function(t){var e,s,i,n,o;if(jt(t)||t<0)return NaN;if(Ss(cn,t),o=0,(s=cn[0])<1048576){if(0==(2147483647&s|cn[1]))return Je;o-=54,s=ze(t*=0x40000000000000)}return s>=2146435072?t+t:(o+=(s>>20)-Ue|0,t=Qe(t,(s&=1048575)|1072693248^(n=s+614244&1048576|0)),o+=n>>20|0,i=an(t),1.6751713164886512e-10*((t-=1)+i)+(t-(e=Bi(t,0))+i)*ln+e*ln+o)},hn=[0,0];var un=function(t){var e;if(e=ze(t),(e&=2147483647)<=1072243195)return e<1045430272?t:Us(t,0);if(e>=2146435072)return NaN;switch(3&Ci(t,hn)){case 0:return Us(hn[0],hn[1]);case 1:return Es(hn[0],hn[1]);case 2:return-Us(hn[0],hn[1]);default:return-Es(hn[0],hn[1])}};var mn=function(t){var e,s;return 0===t?.16666666666666666:((t<0?-t:t)<=1?(e=t*(t*(-.789474443963537*t-163.72585752598383)-11561.443576500522)-351754.9648081514,s=t*(36157.827983443196+t*(1*t-277.7110814206028))-2110529.7888489086):(e=(t=1/t)*(t*(-351754.9648081514*t-11561.443576500522)-163.72585752598383)-.789474443963537,s=1+t*(t*(36157.827983443196+-2110529.7888489086*t)-277.7110814206028)),e/s)};var pn=function(t){var e;return 0===t?t:(e=qs(t),t>710.4758600739439||t<-709.089565712824?t>0?Ee:Je:e>1?e>=709.0895657128241?(e=zi(.5*e),e*=.5*e,t<0&&(e=-e),e):(e=.5*(e=zi(e))-.5/e,t<0&&(e=-e),e):t+t*(e*=e)*mn(e))};var fn=function(t){return 0===t?.13333333333320124:.13333333333320124+t*(.021869488294859542+t*(.0035920791075913124+t*(.0005880412408202641+t*(7817944429395571e-20+-18558637485527546e-21*t))))};var bn=function(t){return 0===t?.05396825397622605:.05396825397622605+t*(.0088632398235993+t*(.0014562094543252903+t*(.0002464631348184699+t*(7140724913826082e-20+2590730518636337e-20*t))))};var yn=function(t,e,s){var i,n,o,r,a,l,c,d,h;return(n=2147483647&(i=ze(t))|0)>=1072010280&&(t<0&&(t=-t,e=-e),t=(h=.7853981633974483-t)+(d=3061616997868383e-32-e),e=0),r=e+(h=t*t)*((a=h*t)*((r=fn(d=h*h))+(c=h*bn(d)))+e),d=t+(r+=.3333333333333341*a),n>=1072010280?(1-(i>>30&2))*((c=s)-2*(t-(d*d/(d+c)-r))):1===s?d:(Bi(h=d,0),c=r-(h-t),Bi(l=o=-1/d,0),l+o*((a=1+l*h)+l*c))},gn=[0,0];var wn=function(t){var e,s;return e=ze(t),(e&=2147483647)<=1072243195?e<1044381696?t:yn(t,0,1):e>=2146435072?NaN:(s=Ci(t,gn),yn(gn[0],gn[1],1-((1&s)<<1)))};var Zn=function(t){var e,s;return 0===t?-.3333333333333332:((t<0?-t:t)<=1?(e=t*(t*(0*t-.9643991794250523)-99.28772310019185)-1614.6876844170845,s=4844.063053251255+t*(2235.4883906010045+t*(112.81167849163293+1*t))):(e=0+(t=1/t)*(t*(-1614.6876844170845*t-99.28772310019185)-.9643991794250523),s=1+t*(112.81167849163293+t*(2235.4883906010045+4844.063053251255*t))),e/s)};var vn=function(t){var e,s;if((s=qs(t))>44.014845965556525)return t<0?-1:1;if(s>=.625)s=1-2/((e=zi(2*s))+1),t<0&&(s=-s);else{if(0===t)return t;s=t+t*(e=t*t)*Zn(e)}return s};void 0===globalThis.CroquetMath&&(globalThis.CroquetMath={}),Object.assign(globalThis.CroquetMath,{acos:Ot,acosh:os,asin:Dt,asinh:as,atan:us,atanh:fs,atan2:Hs,cbrt:_s,cos:Vi,cosh:Ni,exp:zi,expm1:Ei,log:ns,log1p:Ae,log10:sn,log2:dn,sin:un,sinh:pn,tan:wn,tanh:vn});const Xn=Math.pow;function Ln(t){return t===1/0||t===-1/0}globalThis.CroquetMath.pow=(t,e)=>{if(isNaN(t)||isNaN(e))return NaN;if(Ln(t)||Ln(e))return Xn(t,e);if(0===t||0===e)return Xn(t,e);if(t<0&&!function(t){return Number.isInteger(t)}(e))return NaN;if(1===e)return t;if(2===e)return t*t;if(3===e)return t*t*t;if(4===e)return t*t*t*t;let s=1;t<0&&(t*=-1,s=Xn(-1,e));return globalThis.CroquetMath.exp(globalThis.CroquetMath.log(t)*e)*s};var xn=function(t,e){return t<e};function Sn(t){if(!(this instanceof Sn))return new Sn(t);this.array=[],this.size=0,this.compare=t||xn}Sn.prototype.clone=function(){var t=new Sn(this.compare);return t.size=this.size,t.array=this.array.slice(0,this.size),t},Sn.prototype.add=function(t){var e,s,i=this.size;for(this.array[this.size]=t,this.size+=1;i>0&&(e=i-1>>1,s=this.array[e],this.compare(t,s));)this.array[i]=s,i=e;this.array[i]=t},Sn.prototype.heapify=function(t){var e;for(this.array=t,this.size=t.length,e=this.size>>1;e>=0;e--)this._percolateDown(e)},Sn.prototype._percolateUp=function(t,e){for(var s,i,n=this.array[t];t>0&&(s=t-1>>1,i=this.array[s],e||this.compare(n,i));)this.array[t]=i,t=s;this.array[t]=n},Sn.prototype._percolateDown=function(t){for(var e,s,i,n=this.size,o=this.size>>>1,r=this.array[t];t<o&&(s=(e=1+(t<<1))+1,i=this.array[e],s<n&&this.compare(this.array[s],i)&&(e=s,i=this.array[s]),this.compare(i,r));)this.array[t]=i,t=e;this.array[t]=r},Sn.prototype._removeAt=function(t){if(!(t>this.size-1||t<0))return this._percolateUp(t,!0),this.poll()},Sn.prototype.remove=function(t){for(var e=0;e<this.size;e++)if(!this.compare(this.array[e],t)&&!this.compare(t,this.array[e]))return this._removeAt(e),!0;return!1},Sn.prototype.removeOne=function(t){if("function"==typeof t)for(var e=0;e<this.size;e++)if(t(this.array[e]))return this._removeAt(e)},Sn.prototype.removeMany=function(t,e){if("function"!=typeof t||this.size<1)return[];e=e?Math.min(e,this.size):this.size;for(var s=0,i=new Array(e),n=0,o=new Array(this.size);s<e&&!this.isEmpty();){var r=this.poll();t(r)?i[s++]=r:o[n++]=r}i.length=s;for(var a=0;a<n;)this.add(o[a++]);return i},Sn.prototype.peek=function(){if(0!=this.size)return this.array[0]},Sn.prototype.poll=function(){if(0!=this.size){var t=this.array[0];return this.size>1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,t}},Sn.prototype.replaceTop=function(t){if(0!=this.size){var e=this.array[0];return this.array[0]=t,this._percolateDown(0),e}},Sn.prototype.trim=function(){this.array=this.array.slice(0,this.size)},Sn.prototype.isEmpty=function(){return 0===this.size},Sn.prototype.forEach=function(t){if(!this.isEmpty()&&"function"==typeof t)for(var e=0,s=this.clone();!s.isEmpty();)t(s.poll(),e++)},Sn.prototype.kSmallest=function(t){if(0==this.size)return[];t=Math.min(this.size,t);var e=new Sn(this.compare);const s=Math.min((t>0?Math.pow(2,t-1):0)+1,this.size);e.size=s,e.array=this.array.slice(0,s);for(var i=new Array(t),n=0;n<t;n++)i[n]=e.poll();return i};var Gn=Sn;class kn extends Gn{poll(){const t=super.poll();return this.array[this.size]=null,t}asArray(){const t=[];return this.forEach((e=>t.push(e))),t}asUnsortedArray(){return this.array.slice(0,this.size)}}var Wn={exports:{}};!function(t,e){var s;t.exports=(s=w.exports,function(){var t=s,e=t.lib.WordArray;function i(t,s,i){for(var n=[],o=0,r=0;r<s;r++)if(r%4){var a=i[t.charCodeAt(r-1)]<<r%4*2|i[t.charCodeAt(r)]>>>6-r%4*2;n[o>>>2]|=a<<24-o%4*8,o++}return e.create(n,o)}t.enc.Base64={stringify:function(t){var e=t.words,s=t.sigBytes,i=this._map;t.clamp();for(var n=[],o=0;o<s;o+=3)for(var r=(e[o>>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a<s;a++)n.push(i.charAt(r>>>6*(3-a)&63));var l=i.charAt(64);if(l)for(;n.length%4;)n.push(l);return n.join("")},parse:function(t){var e=t.length,s=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var o=0;o<s.length;o++)n[s.charCodeAt(o)]=o}var r=s.charAt(64);if(r){var a=t.indexOf(r);-1!==a&&(e=a)}return i(t,e,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),s.enc.Base64)}(Wn);var Tn=Wn.exports,Cn={exports:{}};!function(t,e){t.exports=w.exports.enc.Utf8}(Cn);var Pn=Cn.exports,Vn={exports:{}},Rn={exports:{}};!function(t,e){var s;t.exports=(s=w.exports,function(){var t=s,e=t.lib,i=e.WordArray,n=e.Hasher,o=t.algo,r=[],a=o.SHA1=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var s=this._hash.words,i=s[0],n=s[1],o=s[2],a=s[3],l=s[4],c=0;c<80;c++){if(c<16)r[c]=0|t[e+c];else{var d=r[c-3]^r[c-8]^r[c-14]^r[c-16];r[c]=d<<1|d>>>31}var h=(i<<5|i>>>27)+l+r[c];h+=c<20?1518500249+(n&o|~n&a):c<40?1859775393+(n^o^a):c<60?(n&o|n&a|o&a)-1894007588:(n^o^a)-899497514,l=a,a=o,o=n<<30|n>>>2,n=i,i=h}s[0]=s[0]+i|0,s[1]=s[1]+n|0,s[2]=s[2]+o|0,s[3]=s[3]+a|0,s[4]=s[4]+l|0},_doFinalize:function(){var t=this._data,e=t.words,s=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(s/4294967296),e[15+(i+64>>>9<<4)]=s,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=n._createHelper(a),t.HmacSHA1=n._createHmacHelper(a)}(),s.SHA1)}(Rn);var Yn={exports:{}};!function(t,e){var s;t.exports=(s=w.exports,void function(){var t=s,e=t.lib.Base,i=t.enc.Utf8;t.algo.HMAC=e.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=i.parse(e));var s=t.blockSize,n=4*s;e.sigBytes>n&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),r=this._iKey=e.clone(),a=o.words,l=r.words,c=0;c<s;c++)a[c]^=1549556828,l[c]^=909522486;o.sigBytes=r.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,s=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(s))}})}())}(Yn),function(t,e){var s;t.exports=(s=w.exports,function(){var t=s,e=t.lib,i=e.Base,n=e.WordArray,o=t.algo,r=o.SHA1,a=o.HMAC,l=o.PBKDF2=i.extend({cfg:i.extend({keySize:4,hasher:r,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var s=this.cfg,i=a.create(s.hasher,t),o=n.create(),r=n.create([1]),l=o.words,c=r.words,d=s.keySize,h=s.iterations;l.length<d;){var u=i.update(e).finalize(r);i.reset();for(var m=u.words,p=m.length,f=u,b=1;b<h;b++){f=i.finalize(f),i.reset();for(var y=f.words,g=0;g<p;g++)m[g]^=y[g]}o.concat(u),c[0]++}return o.sigBytes=4*d,o}});t.PBKDF2=function(t,e,s){return l.create(s).compute(t,e)}}(),s.PBKDF2)}(Vn);var Mn=Vn.exports,In={exports:{}},Hn={exports:{}};!function(t,e){var s;t.exports=(s=w.exports,function(t){var e=s,i=e.lib,n=i.WordArray,o=i.Hasher,r=e.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var l=r.MD5=o.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var s=0;s<16;s++){var i=e+s,n=t[i];t[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,r=t[e+0],l=t[e+1],m=t[e+2],p=t[e+3],f=t[e+4],b=t[e+5],y=t[e+6],g=t[e+7],w=t[e+8],Z=t[e+9],v=t[e+10],X=t[e+11],L=t[e+12],x=t[e+13],S=t[e+14],G=t[e+15],k=o[0],W=o[1],T=o[2],C=o[3];k=c(k,W,T,C,r,7,a[0]),C=c(C,k,W,T,l,12,a[1]),T=c(T,C,k,W,m,17,a[2]),W=c(W,T,C,k,p,22,a[3]),k=c(k,W,T,C,f,7,a[4]),C=c(C,k,W,T,b,12,a[5]),T=c(T,C,k,W,y,17,a[6]),W=c(W,T,C,k,g,22,a[7]),k=c(k,W,T,C,w,7,a[8]),C=c(C,k,W,T,Z,12,a[9]),T=c(T,C,k,W,v,17,a[10]),W=c(W,T,C,k,X,22,a[11]),k=c(k,W,T,C,L,7,a[12]),C=c(C,k,W,T,x,12,a[13]),T=c(T,C,k,W,S,17,a[14]),k=d(k,W=c(W,T,C,k,G,22,a[15]),T,C,l,5,a[16]),C=d(C,k,W,T,y,9,a[17]),T=d(T,C,k,W,X,14,a[18]),W=d(W,T,C,k,r,20,a[19]),k=d(k,W,T,C,b,5,a[20]),C=d(C,k,W,T,v,9,a[21]),T=d(T,C,k,W,G,14,a[22]),W=d(W,T,C,k,f,20,a[23]),k=d(k,W,T,C,Z,5,a[24]),C=d(C,k,W,T,S,9,a[25]),T=d(T,C,k,W,p,14,a[26]),W=d(W,T,C,k,w,20,a[27]),k=d(k,W,T,C,x,5,a[28]),C=d(C,k,W,T,m,9,a[29]),T=d(T,C,k,W,g,14,a[30]),k=h(k,W=d(W,T,C,k,L,20,a[31]),T,C,b,4,a[32]),C=h(C,k,W,T,w,11,a[33]),T=h(T,C,k,W,X,16,a[34]),W=h(W,T,C,k,S,23,a[35]),k=h(k,W,T,C,l,4,a[36]),C=h(C,k,W,T,f,11,a[37]),T=h(T,C,k,W,g,16,a[38]),W=h(W,T,C,k,v,23,a[39]),k=h(k,W,T,C,x,4,a[40]),C=h(C,k,W,T,r,11,a[41]),T=h(T,C,k,W,p,16,a[42]),W=h(W,T,C,k,y,23,a[43]),k=h(k,W,T,C,Z,4,a[44]),C=h(C,k,W,T,L,11,a[45]),T=h(T,C,k,W,G,16,a[46]),k=u(k,W=h(W,T,C,k,m,23,a[47]),T,C,r,6,a[48]),C=u(C,k,W,T,g,10,a[49]),T=u(T,C,k,W,S,15,a[50]),W=u(W,T,C,k,b,21,a[51]),k=u(k,W,T,C,L,6,a[52]),C=u(C,k,W,T,p,10,a[53]),T=u(T,C,k,W,v,15,a[54]),W=u(W,T,C,k,l,21,a[55]),k=u(k,W,T,C,w,6,a[56]),C=u(C,k,W,T,G,10,a[57]),T=u(T,C,k,W,y,15,a[58]),W=u(W,T,C,k,x,21,a[59]),k=u(k,W,T,C,f,6,a[60]),C=u(C,k,W,T,X,10,a[61]),T=u(T,C,k,W,m,15,a[62]),W=u(W,T,C,k,Z,21,a[63]),o[0]=o[0]+k|0,o[1]=o[1]+W|0,o[2]=o[2]+T|0,o[3]=o[3]+C|0},_doFinalize:function(){var e=this._data,s=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;s[n>>>5]|=128<<24-n%32;var o=t.floor(i/4294967296),r=i;s[15+(n+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(s.length+1),this._process();for(var a=this._hash,l=a.words,c=0;c<4;c++){var d=l[c];l[c]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,s,i,n,o,r){var a=t+(e&s|~e&i)+n+r;return(a<<o|a>>>32-o)+e}function d(t,e,s,i,n,o,r){var a=t+(e&i|s&~i)+n+r;return(a<<o|a>>>32-o)+e}function h(t,e,s,i,n,o,r){var a=t+(e^s^i)+n+r;return(a<<o|a>>>32-o)+e}function u(t,e,s,i,n,o,r){var a=t+(s^(e|~i))+n+r;return(a<<o|a>>>32-o)+e}e.MD5=o._createHelper(l),e.HmacMD5=o._createHmacHelper(l)}(Math),s.MD5)}(Hn);var Kn={exports:{}};!function(t,e){var s;t.exports=(s=w.exports,function(){var t=s,e=t.lib,i=e.Base,n=e.WordArray,o=t.algo,r=o.MD5,a=o.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:r,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var s,i=this.cfg,o=i.hasher.create(),r=n.create(),a=r.words,l=i.keySize,c=i.iterations;a.length<l;){s&&o.update(s),s=o.update(t).finalize(e),o.reset();for(var d=1;d<c;d++)s=o.finalize(s),o.reset();r.concat(s)}return r.sigBytes=4*l,r}});t.EvpKDF=function(t,e,s){return a.create(s).compute(t,e)}}(),s.EvpKDF)}(Kn);var zn={exports:{}};!function(t,e){var s;t.exports=void((s=w.exports).lib.Cipher||function(t){var e=s,i=e.lib,n=i.Base,o=i.WordArray,r=i.BufferedBlockAlgorithm,a=e.enc;a.Utf8;var l=a.Base64,c=e.algo.EvpKDF,d=i.Cipher=r.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,s){this.cfg=this.cfg.extend(s),this._xformMode=t,this._key=e,this.reset()},reset:function(){r.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?w:y}return function(e){return{encrypt:function(s,i,n){return t(i).encrypt(e,s,i,n)},decrypt:function(s,i,n){return t(i).decrypt(e,s,i,n)}}}}()});i.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var h=e.mode={},u=i.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),m=h.CBC=function(){var e=u.extend();function s(e,s,i){var n,o=this._iv;o?(n=o,this._iv=t):n=this._prevBlock;for(var r=0;r<i;r++)e[s+r]^=n[r]}return e.Encryptor=e.extend({processBlock:function(t,e){var i=this._cipher,n=i.blockSize;s.call(this,t,e,n),i.encryptBlock(t,e),this._prevBlock=t.slice(e,e+n)}}),e.Decryptor=e.extend({processBlock:function(t,e){var i=this._cipher,n=i.blockSize,o=t.slice(e,e+n);i.decryptBlock(t,e),s.call(this,t,e,n),this._prevBlock=o}}),e}(),p=(e.pad={}).Pkcs7={pad:function(t,e){for(var s=4*e,i=s-t.sigBytes%s,n=i<<24|i<<16|i<<8|i,r=[],a=0;a<i;a+=4)r.push(n);var l=o.create(r,i);t.concat(l)},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}};i.BlockCipher=d.extend({cfg:d.cfg.extend({mode:m,padding:p}),reset:function(){var t;d.reset.call(this);var e=this.cfg,s=e.iv,i=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=i.createEncryptor:(t=i.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,s&&s.words):(this._mode=t.call(i,this,s&&s.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4});var f=i.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),b=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,s=t.salt;return(s?o.create([1398893684,1701076831]).concat(s).concat(e):e).toString(l)},parse:function(t){var e,s=l.parse(t),i=s.words;return 1398893684==i[0]&&1701076831==i[1]&&(e=o.create(i.slice(2,4)),i.splice(0,4),s.sigBytes-=16),f.create({ciphertext:s,salt:e})}},y=i.SerializableCipher=n.extend({cfg:n.extend({format:b}),encrypt:function(t,e,s,i){i=this.cfg.extend(i);var n=t.createEncryptor(s,i),o=n.finalize(e),r=n.cfg;return f.create({ciphertext:o,key:s,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,s,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(s,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,s,i){i||(i=o.random(8));var n=c.create({keySize:e+s}).compute(t,i),r=o.create(n.words.slice(e),4*s);return n.sigBytes=4*e,f.create({key:n,iv:r,salt:i})}},w=i.PasswordBasedCipher=y.extend({cfg:y.cfg.extend({kdf:g}),encrypt:function(t,e,s,i){var n=(i=this.cfg.extend(i)).kdf.execute(s,t.keySize,t.ivSize);i.iv=n.iv;var o=y.encrypt.call(this,t,e,n.key,i);return o.mixIn(n),o},decrypt:function(t,e,s,i){i=this.cfg.extend(i),e=this._parse(e,i.format);var n=i.kdf.execute(s,t.keySize,t.ivSize,e.salt);return i.iv=n.iv,y.decrypt.call(this,t,e,n.key,i)}})}())}(zn),function(t,e){var s;t.exports=(s=w.exports,function(){var t=s,e=t.lib.BlockCipher,i=t.algo,n=[],o=[],r=[],a=[],l=[],c=[],d=[],h=[],u=[],m=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var s=0,i=0;for(e=0;e<256;e++){var p=i^i<<1^i<<2^i<<3^i<<4;p=p>>>8^255&p^99,n[s]=p,o[p]=s;var f=t[s],b=t[f],y=t[b],g=257*t[p]^16843008*p;r[s]=g<<24|g>>>8,a[s]=g<<16|g>>>16,l[s]=g<<8|g>>>24,c[s]=g,g=16843009*y^65537*b^257*f^16843008*s,d[p]=g<<24|g>>>8,h[p]=g<<16|g>>>16,u[p]=g<<8|g>>>24,m[p]=g,s?(s=f^t[t[t[y^f]]],i^=t[t[i]]):s=i=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],f=i.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,s=t.sigBytes/4,i=4*((this._nRounds=s+6)+1),o=this._keySchedule=[],r=0;r<i;r++)r<s?o[r]=e[r]:(c=o[r-1],r%s?s>6&&r%s==4&&(c=n[c>>>24]<<24|n[c>>>16&255]<<16|n[c>>>8&255]<<8|n[255&c]):(c=n[(c=c<<8|c>>>24)>>>24]<<24|n[c>>>16&255]<<16|n[c>>>8&255]<<8|n[255&c],c^=p[r/s|0]<<24),o[r]=o[r-s]^c);for(var a=this._invKeySchedule=[],l=0;l<i;l++){if(r=i-l,l%4)var c=o[r];else c=o[r-4];a[l]=l<4||r<=4?c:d[n[c>>>24]]^h[n[c>>>16&255]]^u[n[c>>>8&255]]^m[n[255&c]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,r,a,l,c,n)},decryptBlock:function(t,e){var s=t[e+1];t[e+1]=t[e+3],t[e+3]=s,this._doCryptBlock(t,e,this._invKeySchedule,d,h,u,m,o),s=t[e+1],t[e+1]=t[e+3],t[e+3]=s},_doCryptBlock:function(t,e,s,i,n,o,r,a){for(var l=this._nRounds,c=t[e]^s[0],d=t[e+1]^s[1],h=t[e+2]^s[2],u=t[e+3]^s[3],m=4,p=1;p<l;p++){var f=i[c>>>24]^n[d>>>16&255]^o[h>>>8&255]^r[255&u]^s[m++],b=i[d>>>24]^n[h>>>16&255]^o[u>>>8&255]^r[255&c]^s[m++],y=i[h>>>24]^n[u>>>16&255]^o[c>>>8&255]^r[255&d]^s[m++],g=i[u>>>24]^n[c>>>16&255]^o[d>>>8&255]^r[255&h]^s[m++];c=f,d=b,h=y,u=g}f=(a[c>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^s[m++],b=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^s[m++],y=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&d])^s[m++],g=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^s[m++],t[e]=f,t[e+1]=b,t[e+2]=y,t[e+3]=g},keySize:8});t.AES=e._createHelper(f)}(),s.AES)}(In);var Nn=In.exports,Fn={exports:{}};!function(t,e){t.exports=w.exports.HmacSHA256}(Fn);var _n=Fn.exports;function jn(t){let e=t.length;for(;--e>=0;)t[e]=0}const Qn=256,En=286,Jn=30,Un=15,Dn=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),On=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Bn=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),An=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$n=new Array(576);jn($n);const qn=new Array(60);jn(qn);const to=new Array(512);jn(to);const eo=new Array(256);jn(eo);const so=new Array(29);jn(so);const io=new Array(Jn);function no(t,e,s,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=s,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let oo,ro,ao;function lo(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}jn(io);const co=t=>t<256?to[t]:to[256+(t>>>7)],ho=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},uo=(t,e,s)=>{t.bi_valid>16-s?(t.bi_buf|=e<<t.bi_valid&65535,ho(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=s-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=s)},mo=(t,e,s)=>{uo(t,s[2*e],s[2*e+1])},po=(t,e)=>{let s=0;do{s|=1&t,t>>>=1,s<<=1}while(--e>0);return s>>>1},fo=(t,e,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=Un;n++)i[n]=r=r+s[n-1]<<1;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=po(i[e]++,e))}},bo=t=>{let e;for(e=0;e<En;e++)t.dyn_ltree[2*e]=0;for(e=0;e<Jn;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},yo=t=>{t.bi_valid>8?ho(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},go=(t,e,s,i)=>{const n=2*e,o=2*s;return t[n]<t[o]||t[n]===t[o]&&i[e]<=i[s]},wo=(t,e,s)=>{const i=t.heap[s];let n=s<<1;for(;n<=t.heap_len&&(n<t.heap_len&&go(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!go(e,i,t.heap[n],t.depth));)t.heap[s]=t.heap[n],s=n,n<<=1;t.heap[s]=i},Zo=(t,e,s)=>{let i,n,o,r,a=0;if(0!==t.last_lit)do{i=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],n=t.pending_buf[t.l_buf+a],a++,0===i?mo(t,n,e):(o=eo[n],mo(t,o+Qn+1,e),r=Dn[o],0!==r&&(n-=so[o],uo(t,n,r)),i--,o=co(i),mo(t,o,s),r=On[o],0!==r&&(i-=io[o],uo(t,i,r)))}while(a<t.last_lit);mo(t,256,e)},vo=(t,e)=>{const s=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,o=e.stat_desc.elems;let r,a,l,c=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<o;r++)0!==s[2*r]?(t.heap[++t.heap_len]=c=r,t.depth[r]=0):s[2*r+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,s[2*l]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=i[2*l+1]);for(e.max_code=c,r=t.heap_len>>1;r>=1;r--)wo(t,s,r);l=o;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],wo(t,s,1),a=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=a,s[2*l]=s[2*r]+s[2*a],t.depth[l]=(t.depth[r]>=t.depth[a]?t.depth[r]:t.depth[a])+1,s[2*r+1]=s[2*a+1]=l,t.heap[1]=l++,wo(t,s,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const s=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,o=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let c,d,h,u,m,p,f=0;for(u=0;u<=Un;u++)t.bl_count[u]=0;for(s[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)d=t.heap[c],u=s[2*s[2*d+1]+1]+1,u>l&&(u=l,f++),s[2*d+1]=u,d>i||(t.bl_count[u]++,m=0,d>=a&&(m=r[d-a]),p=s[2*d],t.opt_len+=p*(u+m),o&&(t.static_len+=p*(n[2*d+1]+m)));if(0!==f){do{for(u=l-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,f-=2}while(f>0);for(u=l;0!==u;u--)for(d=t.bl_count[u];0!==d;)h=t.heap[--c],h>i||(s[2*h+1]!==u&&(t.opt_len+=(u-s[2*h+1])*s[2*h],s[2*h+1]=u),d--)}})(t,e),fo(s,c,t.bl_count)},Xo=(t,e,s)=>{let i,n,o=-1,r=e[1],a=0,l=7,c=4;for(0===r&&(l=138,c=3),e[2*(s+1)+1]=65535,i=0;i<=s;i++)n=r,r=e[2*(i+1)+1],++a<l&&n===r||(a<c?t.bl_tree[2*n]+=a:0!==n?(n!==o&&t.bl_tree[2*n]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=n,0===r?(l=138,c=3):n===r?(l=6,c=3):(l=7,c=4))},Lo=(t,e,s)=>{let i,n,o=-1,r=e[1],a=0,l=7,c=4;for(0===r&&(l=138,c=3),i=0;i<=s;i++)if(n=r,r=e[2*(i+1)+1],!(++a<l&&n===r)){if(a<c)do{mo(t,n,t.bl_tree)}while(0!=--a);else 0!==n?(n!==o&&(mo(t,n,t.bl_tree),a--),mo(t,16,t.bl_tree),uo(t,a-3,2)):a<=10?(mo(t,17,t.bl_tree),uo(t,a-3,3)):(mo(t,18,t.bl_tree),uo(t,a-11,7));a=0,o=n,0===r?(l=138,c=3):n===r?(l=6,c=3):(l=7,c=4)}};let xo=!1;const So=(t,e,s,i)=>{uo(t,0+(i?1:0),3),((t,e,s,i)=>{yo(t),i&&(ho(t,s),ho(t,~s)),t.pending_buf.set(t.window.subarray(e,e+s),t.pending),t.pending+=s})(t,e,s,!0)};var Go=(t,e,s,i)=>{let n,o,r=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,s=4093624447;for(e=0;e<=31;e++,s>>>=1)if(1&s&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Qn;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),vo(t,t.l_desc),vo(t,t.d_desc),r=(t=>{let e;for(Xo(t,t.dyn_ltree,t.l_desc.max_code),Xo(t,t.dyn_dtree,t.d_desc.max_code),vo(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*An[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),n=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=n&&(n=o)):n=o=s+5,s+4<=n&&-1!==e?So(t,e,s,i):4===t.strategy||o===n?(uo(t,2+(i?1:0),3),Zo(t,$n,qn)):(uo(t,4+(i?1:0),3),((t,e,s,i)=>{let n;for(uo(t,e-257,5),uo(t,s-1,5),uo(t,i-4,4),n=0;n<i;n++)uo(t,t.bl_tree[2*An[n]+1],3);Lo(t,t.dyn_ltree,e-1),Lo(t,t.dyn_dtree,s-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,r+1),Zo(t,t.dyn_ltree,t.dyn_dtree)),bo(t),i&&yo(t)},ko={_tr_init:t=>{xo||((()=>{let t,e,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(so[i]=s,t=0;t<1<<Dn[i];t++)eo[s++]=i;for(eo[s-1]=i,n=0,i=0;i<16;i++)for(io[i]=n,t=0;t<1<<On[i];t++)to[n++]=i;for(n>>=7;i<Jn;i++)for(io[i]=n<<7,t=0;t<1<<On[i]-7;t++)to[256+n++]=i;for(e=0;e<=Un;e++)o[e]=0;for(t=0;t<=143;)$n[2*t+1]=8,t++,o[8]++;for(;t<=255;)$n[2*t+1]=9,t++,o[9]++;for(;t<=279;)$n[2*t+1]=7,t++,o[7]++;for(;t<=287;)$n[2*t+1]=8,t++,o[8]++;for(fo($n,287,o),t=0;t<Jn;t++)qn[2*t+1]=5,qn[2*t]=po(t,5);oo=new no($n,Dn,257,En,Un),ro=new no(qn,On,0,Jn,Un),ao=new no(new Array(0),Bn,0,19,7)})(),xo=!0),t.l_desc=new lo(t.dyn_ltree,oo),t.d_desc=new lo(t.dyn_dtree,ro),t.bl_desc=new lo(t.bl_tree,ao),t.bi_buf=0,t.bi_valid=0,bo(t)},_tr_stored_block:So,_tr_flush_block:Go,_tr_tally:(t,e,s)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&s,t.last_lit++,0===e?t.dyn_ltree[2*s]++:(t.matches++,e--,t.dyn_ltree[2*(eo[s]+Qn+1)]++,t.dyn_dtree[2*co(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{uo(t,2,3),mo(t,256,$n),(t=>{16===t.bi_valid?(ho(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var Wo=(t,e,s,i)=>{let n=65535&t|0,o=t>>>16&65535|0,r=0;for(;0!==s;){r=s>2e3?2e3:s,s-=r;do{n=n+e[i++]|0,o=o+n|0}while(--r);n%=65521,o%=65521}return n|o<<16|0};const To=new Uint32Array((()=>{let t,e=[];for(var s=0;s<256;s++){t=s;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[s]=t}return e})());var Co=(t,e,s,i)=>{const n=To,o=i+s;t^=-1;for(let s=i;s<o;s++)t=t>>>8^n[255&(t^e[s])];return-1^t},Po={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Vo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ro,_tr_stored_block:Yo,_tr_flush_block:Mo,_tr_tally:Io,_tr_align:Ho}=ko,{Z_NO_FLUSH:Ko,Z_PARTIAL_FLUSH:zo,Z_FULL_FLUSH:No,Z_FINISH:Fo,Z_BLOCK:_o,Z_OK:jo,Z_STREAM_END:Qo,Z_STREAM_ERROR:Eo,Z_DATA_ERROR:Jo,Z_BUF_ERROR:Uo,Z_DEFAULT_COMPRESSION:Do,Z_FILTERED:Oo,Z_HUFFMAN_ONLY:Bo,Z_RLE:Ao,Z_FIXED:$o,Z_DEFAULT_STRATEGY:qo,Z_UNKNOWN:tr,Z_DEFLATED:er}=Vo,sr=258,ir=262,nr=103,or=113,rr=666,ar=(t,e)=>(t.msg=Po[e],e),lr=t=>(t<<1)-(t>4?9:0),cr=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let dr=(t,e,s)=>(e<<t.hash_shift^s)&t.hash_mask;const hr=t=>{const e=t.state;let s=e.pending;s>t.avail_out&&(s=t.avail_out),0!==s&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+s),t.next_out),t.next_out+=s,e.pending_out+=s,t.total_out+=s,t.avail_out-=s,e.pending-=s,0===e.pending&&(e.pending_out=0))},ur=(t,e)=>{Mo(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,hr(t.strm)},mr=(t,e)=>{t.pending_buf[t.pending++]=e},pr=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},fr=(t,e,s,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),s),1===t.state.wrap?t.adler=Wo(t.adler,e,n,s):2===t.state.wrap&&(t.adler=Co(t.adler,e,n,s)),t.next_in+=n,t.total_in+=n,n)},br=(t,e)=>{let s,i,n=t.max_chain_length,o=t.strstart,r=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-ir?t.strstart-(t.w_size-ir):0,c=t.window,d=t.w_mask,h=t.prev,u=t.strstart+sr;let m=c[o+r-1],p=c[o+r];t.prev_length>=t.good_match&&(n>>=2),a>t.lookahead&&(a=t.lookahead);do{if(s=e,c[s+r]===p&&c[s+r-1]===m&&c[s]===c[o]&&c[++s]===c[o+1]){o+=2,s++;do{}while(c[++o]===c[++s]&&c[++o]===c[++s]&&c[++o]===c[++s]&&c[++o]===c[++s]&&c[++o]===c[++s]&&c[++o]===c[++s]&&c[++o]===c[++s]&&c[++o]===c[++s]&&o<u);if(i=sr-(u-o),o=u-sr,i>r){if(t.match_start=e,r=i,i>=a)break;m=c[o+r-1],p=c[o+r]}}}while((e=h[e&d])>l&&0!=--n);return r<=t.lookahead?r:t.lookahead},yr=t=>{const e=t.w_size;let s,i,n,o,r;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ir)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,s=i;do{n=t.head[--s],t.head[s]=n>=e?n-e:0}while(--i);i=e,s=i;do{n=t.prev[--s],t.prev[s]=n>=e?n-e:0}while(--i);o+=e}if(0===t.strm.avail_in)break;if(i=fr(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=i,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=dr(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=dr(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<ir&&0!==t.strm.avail_in)},gr=(t,e)=>{let s,i;for(;;){if(t.lookahead<ir){if(yr(t),t.lookahead<ir&&e===Ko)return 1;if(0===t.lookahead)break}if(s=0,t.lookahead>=3&&(t.ins_h=dr(t,t.ins_h,t.window[t.strstart+3-1]),s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==s&&t.strstart-s<=t.w_size-ir&&(t.match_length=br(t,s)),t.match_length>=3)if(i=Io(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=dr(t,t.ins_h,t.window[t.strstart+3-1]),s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=dr(t,t.ins_h,t.window[t.strstart+1]);else i=Io(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ur(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Fo?(ur(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ur(t,!1),0===t.strm.avail_out)?1:2},wr=(t,e)=>{let s,i,n;for(;;){if(t.lookahead<ir){if(yr(t),t.lookahead<ir&&e===Ko)return 1;if(0===t.lookahead)break}if(s=0,t.lookahead>=3&&(t.ins_h=dr(t,t.ins_h,t.window[t.strstart+3-1]),s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==s&&t.prev_length<t.max_lazy_match&&t.strstart-s<=t.w_size-ir&&(t.match_length=br(t,s),t.match_length<=5&&(t.strategy===Oo||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=Io(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=dr(t,t.ins_h,t.window[t.strstart+3-1]),s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(ur(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=Io(t,0,t.window[t.strstart-1]),i&&ur(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=Io(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Fo?(ur(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ur(t,!1),0===t.strm.avail_out)?1:2};function Zr(t,e,s,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=s,this.max_chain=i,this.func=n}const vr=[new Zr(0,0,0,0,((t,e)=>{let s=65535;for(s>t.pending_buf_size-5&&(s=t.pending_buf_size-5);;){if(t.lookahead<=1){if(yr(t),0===t.lookahead&&e===Ko)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const i=t.block_start+s;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,ur(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-ir&&(ur(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Fo?(ur(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(ur(t,!1),t.strm.avail_out),1)})),new Zr(4,4,8,4,gr),new Zr(4,5,16,8,gr),new Zr(4,6,32,32,gr),new Zr(4,4,16,16,wr),new Zr(8,16,32,32,wr),new Zr(8,16,128,128,wr),new Zr(8,32,128,256,wr),new Zr(32,128,258,1024,wr),new Zr(32,258,258,4096,wr)];function Xr(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=er,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),cr(this.dyn_ltree),cr(this.dyn_dtree),cr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),cr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),cr(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Lr=t=>{if(!t||!t.state)return ar(t,Eo);t.total_in=t.total_out=0,t.data_type=tr;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:or,t.adler=2===e.wrap?0:1,e.last_flush=Ko,Ro(e),jo},xr=t=>{const e=Lr(t);var s;return e===jo&&((s=t.state).window_size=2*s.w_size,cr(s.head),s.max_lazy_match=vr[s.level].max_lazy,s.good_match=vr[s.level].good_length,s.nice_match=vr[s.level].nice_length,s.max_chain_length=vr[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=2,s.match_available=0,s.ins_h=0),e},Sr=(t,e,s,i,n,o)=>{if(!t)return Eo;let r=1;if(e===Do&&(e=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==er||i<8||i>15||e<0||e>9||o<0||o>$o)return ar(t,Eo);8===i&&(i=9);const a=new Xr;return t.state=a,a.strm=t,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=o,a.method=s,xr(t)};var Gr={deflateInit:(t,e)=>Sr(t,e,er,15,8,qo),deflateInit2:Sr,deflateReset:xr,deflateResetKeep:Lr,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Eo:(t.state.gzhead=e,jo):Eo,deflate:(t,e)=>{let s,i;if(!t||!t.state||e>_o||e<0)return t?ar(t,Eo):Eo;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||n.status===rr&&e!==Fo)return ar(t,0===t.avail_out?Uo:Eo);n.strm=t;const o=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,mr(n,31),mr(n,139),mr(n,8),n.gzhead?(mr(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),mr(n,255&n.gzhead.time),mr(n,n.gzhead.time>>8&255),mr(n,n.gzhead.time>>16&255),mr(n,n.gzhead.time>>24&255),mr(n,9===n.level?2:n.strategy>=Bo||n.level<2?4:0),mr(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(mr(n,255&n.gzhead.extra.length),mr(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=Co(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(mr(n,0),mr(n,0),mr(n,0),mr(n,0),mr(n,0),mr(n,9===n.level?2:n.strategy>=Bo||n.level<2?4:0),mr(n,3),n.status=or);else{let e=er+(n.w_bits-8<<4)<<8,s=-1;s=n.strategy>=Bo||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=s<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=or,pr(n,e),0!==n.strstart&&(pr(n,t.adler>>>16),pr(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(s=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>s&&(t.adler=Co(t.adler,n.pending_buf,n.pending-s,s)),hr(t),s=n.pending,n.pending!==n.pending_buf_size));)mr(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>s&&(t.adler=Co(t.adler,n.pending_buf,n.pending-s,s)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){s=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>s&&(t.adler=Co(t.adler,n.pending_buf,n.pending-s,s)),hr(t),s=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,mr(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>s&&(t.adler=Co(t.adler,n.pending_buf,n.pending-s,s)),0===i&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){s=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>s&&(t.adler=Co(t.adler,n.pending_buf,n.pending-s,s)),hr(t),s=n.pending,n.pending===n.pending_buf_size)){i=1;break}i=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,mr(n,i)}while(0!==i);n.gzhead.hcrc&&n.pending>s&&(t.adler=Co(t.adler,n.pending_buf,n.pending-s,s)),0===i&&(n.status=nr)}else n.status=nr;if(n.status===nr&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&hr(t),n.pending+2<=n.pending_buf_size&&(mr(n,255&t.adler),mr(n,t.adler>>8&255),t.adler=0,n.status=or)):n.status=or),0!==n.pending){if(hr(t),0===t.avail_out)return n.last_flush=-1,jo}else if(0===t.avail_in&&lr(e)<=lr(o)&&e!==Fo)return ar(t,Uo);if(n.status===rr&&0!==t.avail_in)return ar(t,Uo);if(0!==t.avail_in||0!==n.lookahead||e!==Ko&&n.status!==rr){let s=n.strategy===Bo?((t,e)=>{let s;for(;;){if(0===t.lookahead&&(yr(t),0===t.lookahead)){if(e===Ko)return 1;break}if(t.match_length=0,s=Io(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,s&&(ur(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Fo?(ur(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ur(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===Ao?((t,e)=>{let s,i,n,o;const r=t.window;for(;;){if(t.lookahead<=sr){if(yr(t),t.lookahead<=sr&&e===Ko)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){o=t.strstart+sr;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&n<o);t.match_length=sr-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(s=Io(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(s=Io(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),s&&(ur(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Fo?(ur(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ur(t,!1),0===t.strm.avail_out)?1:2})(n,e):vr[n.level].func(n,e);if(3!==s&&4!==s||(n.status=rr),1===s||3===s)return 0===t.avail_out&&(n.last_flush=-1),jo;if(2===s&&(e===zo?Ho(n):e!==_o&&(Yo(n,0,0,!1),e===No&&(cr(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),hr(t),0===t.avail_out))return n.last_flush=-1,jo}return e!==Fo?jo:n.wrap<=0?Qo:(2===n.wrap?(mr(n,255&t.adler),mr(n,t.adler>>8&255),mr(n,t.adler>>16&255),mr(n,t.adler>>24&255),mr(n,255&t.total_in),mr(n,t.total_in>>8&255),mr(n,t.total_in>>16&255),mr(n,t.total_in>>24&255)):(pr(n,t.adler>>>16),pr(n,65535&t.adler)),hr(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?jo:Qo)},deflateEnd:t=>{if(!t||!t.state)return Eo;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==nr&&e!==or&&e!==rr?ar(t,Eo):(t.state=null,e===or?ar(t,Jo):jo)},deflateSetDictionary:(t,e)=>{let s=e.length;if(!t||!t.state)return Eo;const i=t.state,n=i.wrap;if(2===n||1===n&&42!==i.status||i.lookahead)return Eo;if(1===n&&(t.adler=Wo(t.adler,e,s,0)),i.wrap=0,s>=i.w_size){0===n&&(cr(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(s-i.w_size,s),0),e=t,s=i.w_size}const o=t.avail_in,r=t.next_in,a=t.input;for(t.avail_in=s,t.next_in=0,t.input=e,yr(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=dr(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,yr(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=r,t.input=a,t.avail_in=o,i.wrap=n,jo},deflateInfo:"pako deflate (from Nodeca project)"};const kr=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Wr=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const s=e.shift();if(s){if("object"!=typeof s)throw new TypeError(s+"must be non-object");for(const e in s)kr(s,e)&&(t[e]=s[e])}}return t},Tr=t=>{let e=0;for(let s=0,i=t.length;s<i;s++)e+=t[s].length;const s=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];s.set(n,i),i+=n.length}return s};let Cr=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Cr=!1}const Pr=new Uint8Array(256);for(let t=0;t<256;t++)Pr[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Pr[254]=Pr[254]=1;var Vr=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,s,i,n,o,r=t.length,a=0;for(n=0;n<r;n++)s=t.charCodeAt(n),55296==(64512&s)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(s=65536+(s-55296<<10)+(i-56320),n++)),a+=s<128?1:s<2048?2:s<65536?3:4;for(e=new Uint8Array(a),o=0,n=0;o<a;n++)s=t.charCodeAt(n),55296==(64512&s)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(s=65536+(s-55296<<10)+(i-56320),n++)),s<128?e[o++]=s:s<2048?(e[o++]=192|s>>>6,e[o++]=128|63&s):s<65536?(e[o++]=224|s>>>12,e[o++]=128|s>>>6&63,e[o++]=128|63&s):(e[o++]=240|s>>>18,e[o++]=128|s>>>12&63,e[o++]=128|s>>>6&63,e[o++]=128|63&s);return e},Rr=(t,e)=>{const s=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const o=new Array(2*s);for(n=0,i=0;i<s;){let e=t[i++];if(e<128){o[n++]=e;continue}let r=Pr[e];if(r>4)o[n++]=65533,i+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&i<s;)e=e<<6|63&t[i++],r--;r>1?o[n++]=65533:e<65536?o[n++]=e:(e-=65536,o[n++]=55296|e>>10&1023,o[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Cr)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let s="";for(let i=0;i<e;i++)s+=String.fromCharCode(t[i]);return s})(o,n)},Yr=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let s=e-1;for(;s>=0&&128==(192&t[s]);)s--;return s<0||0===s?e:s+Pr[t[s]]>e?s:e};var Mr=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ir=Object.prototype.toString,{Z_NO_FLUSH:Hr,Z_SYNC_FLUSH:Kr,Z_FULL_FLUSH:zr,Z_FINISH:Nr,Z_OK:Fr,Z_STREAM_END:_r,Z_DEFAULT_COMPRESSION:jr,Z_DEFAULT_STRATEGY:Qr,Z_DEFLATED:Er}=Vo;function Jr(t){this.options=Wr({level:jr,method:Er,chunkSize:16384,windowBits:15,memLevel:8,strategy:Qr},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mr,this.strm.avail_out=0;let s=Gr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(s!==Fr)throw new Error(Po[s]);if(e.header&&Gr.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Vr(e.dictionary):"[object ArrayBuffer]"===Ir.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,s=Gr.deflateSetDictionary(this.strm,t),s!==Fr)throw new Error(Po[s]);this._dict_set=!0}}function Ur(t,e){const s=new Jr(e);if(s.push(t,!0),s.err)throw s.msg||Po[s.err];return s.result}Jr.prototype.push=function(t,e){const s=this.strm,i=this.options.chunkSize;let n,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Nr:Hr,"string"==typeof t?s.input=Vr(t):"[object ArrayBuffer]"===Ir.call(t)?s.input=new Uint8Array(t):s.input=t,s.next_in=0,s.avail_in=s.input.length;;)if(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),(o===Kr||o===zr)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=Gr.deflate(s,o),n===_r)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=Gr.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Fr;if(0!==s.avail_out){if(o>0&&s.next_out>0)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else if(0===s.avail_in)break}else this.onData(s.output)}return!0},Jr.prototype.onData=function(t){this.chunks.push(t)},Jr.prototype.onEnd=function(t){t===Fr&&(this.result=Tr(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Dr={Deflate:Jr,deflate:Ur,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Ur(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Ur(t,e)},constants:Vo};var Or=function(t,e){let s,i,n,o,r,a,l,c,d,h,u,m,p,f,b,y,g,w,Z,v,X,L,x,S;const G=t.state;s=t.next_in,x=t.input,i=s+(t.avail_in-5),n=t.next_out,S=t.output,o=n-(e-t.avail_out),r=n+(t.avail_out-257),a=G.dmax,l=G.wsize,c=G.whave,d=G.wnext,h=G.window,u=G.hold,m=G.bits,p=G.lencode,f=G.distcode,b=(1<<G.lenbits)-1,y=(1<<G.distbits)-1;t:do{m<15&&(u+=x[s++]<<m,m+=8,u+=x[s++]<<m,m+=8),g=p[u&b];e:for(;;){if(w=g>>>24,u>>>=w,m-=w,w=g>>>16&255,0===w)S[n++]=65535&g;else{if(!(16&w)){if(0==(64&w)){g=p[(65535&g)+(u&(1<<w)-1)];continue e}if(32&w){G.mode=12;break t}t.msg="invalid literal/length code",G.mode=30;break t}Z=65535&g,w&=15,w&&(m<w&&(u+=x[s++]<<m,m+=8),Z+=u&(1<<w)-1,u>>>=w,m-=w),m<15&&(u+=x[s++]<<m,m+=8,u+=x[s++]<<m,m+=8),g=f[u&y];s:for(;;){if(w=g>>>24,u>>>=w,m-=w,w=g>>>16&255,!(16&w)){if(0==(64&w)){g=f[(65535&g)+(u&(1<<w)-1)];continue s}t.msg="invalid distance code",G.mode=30;break t}if(v=65535&g,w&=15,m<w&&(u+=x[s++]<<m,m+=8,m<w&&(u+=x[s++]<<m,m+=8)),v+=u&(1<<w)-1,v>a){t.msg="invalid distance too far back",G.mode=30;break t}if(u>>>=w,m-=w,w=n-o,v>w){if(w=v-w,w>c&&G.sane){t.msg="invalid distance too far back",G.mode=30;break t}if(X=0,L=h,0===d){if(X+=l-w,w<Z){Z-=w;do{S[n++]=h[X++]}while(--w);X=n-v,L=S}}else if(d<w){if(X+=l+d-w,w-=d,w<Z){Z-=w;do{S[n++]=h[X++]}while(--w);if(X=0,d<Z){w=d,Z-=w;do{S[n++]=h[X++]}while(--w);X=n-v,L=S}}}else if(X+=d-w,w<Z){Z-=w;do{S[n++]=h[X++]}while(--w);X=n-v,L=S}for(;Z>2;)S[n++]=L[X++],S[n++]=L[X++],S[n++]=L[X++],Z-=3;Z&&(S[n++]=L[X++],Z>1&&(S[n++]=L[X++]))}else{X=n-v;do{S[n++]=S[X++],S[n++]=S[X++],S[n++]=S[X++],Z-=3}while(Z>2);Z&&(S[n++]=S[X++],Z>1&&(S[n++]=S[X++]))}break}}break}}while(s<i&&n<r);Z=m>>3,s-=Z,m-=Z<<3,u&=(1<<m)-1,t.next_in=s,t.next_out=n,t.avail_in=s<i?i-s+5:5-(s-i),t.avail_out=n<r?r-n+257:257-(n-r),G.hold=u,G.bits=m};const Br=15,Ar=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),$r=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),qr=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ta=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ea=(t,e,s,i,n,o,r,a)=>{const l=a.bits;let c,d,h,u,m,p,f=0,b=0,y=0,g=0,w=0,Z=0,v=0,X=0,L=0,x=0,S=null,G=0;const k=new Uint16Array(16),W=new Uint16Array(16);let T,C,P,V=null,R=0;for(f=0;f<=Br;f++)k[f]=0;for(b=0;b<i;b++)k[e[s+b]]++;for(w=l,g=Br;g>=1&&0===k[g];g--);if(w>g&&(w=g),0===g)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(y=1;y<g&&0===k[y];y++);for(w<y&&(w=y),X=1,f=1;f<=Br;f++)if(X<<=1,X-=k[f],X<0)return-1;if(X>0&&(0===t||1!==g))return-1;for(W[1]=0,f=1;f<Br;f++)W[f+1]=W[f]+k[f];for(b=0;b<i;b++)0!==e[s+b]&&(r[W[e[s+b]]++]=b);if(0===t?(S=V=r,p=19):1===t?(S=Ar,G-=257,V=$r,R-=257,p=256):(S=qr,V=ta,p=-1),x=0,b=0,f=y,m=o,Z=w,v=0,h=-1,L=1<<w,u=L-1,1===t&&L>852||2===t&&L>592)return 1;for(;;){T=f-v,r[b]<p?(C=0,P=r[b]):r[b]>p?(C=V[R+r[b]],P=S[G+r[b]]):(C=96,P=0),c=1<<f-v,d=1<<Z,y=d;do{d-=c,n[m+(x>>v)+d]=T<<24|C<<16|P|0}while(0!==d);for(c=1<<f-1;x&c;)c>>=1;if(0!==c?(x&=c-1,x+=c):x=0,b++,0==--k[f]){if(f===g)break;f=e[s+r[b]]}if(f>w&&(x&u)!==h){for(0===v&&(v=w),m+=y,Z=f-v,X=1<<Z;Z+v<g&&(X-=k[Z+v],!(X<=0));)Z++,X<<=1;if(L+=1<<Z,1===t&&L>852||2===t&&L>592)return 1;h=x&u,n[h]=w<<24|Z<<16|m-o|0}}return 0!==x&&(n[m+x]=f-v<<24|64<<16|0),a.bits=w,0};const{Z_FINISH:sa,Z_BLOCK:ia,Z_TREES:na,Z_OK:oa,Z_STREAM_END:ra,Z_NEED_DICT:aa,Z_STREAM_ERROR:la,Z_DATA_ERROR:ca,Z_MEM_ERROR:da,Z_BUF_ERROR:ha,Z_DEFLATED:ua}=Vo,ma=12,pa=30,fa=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ba(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ya=t=>{if(!t||!t.state)return la;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,oa},ga=t=>{if(!t||!t.state)return la;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,ya(t)},wa=(t,e)=>{let s;if(!t||!t.state)return la;const i=t.state;return e<0?(s=0,e=-e):(s=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?la:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=s,i.wbits=e,ga(t))},Za=(t,e)=>{if(!t)return la;const s=new ba;t.state=s,s.window=null;const i=wa(t,e);return i!==oa&&(t.state=null),i};let va,Xa,La=!0;const xa=t=>{if(La){va=new Int32Array(512),Xa=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ea(1,t.lens,0,288,va,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ea(2,t.lens,0,32,Xa,0,t.work,{bits:5}),La=!1}t.lencode=va,t.lenbits=9,t.distcode=Xa,t.distbits=5},Sa=(t,e,s,i)=>{let n;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),i>=o.wsize?(o.window.set(e.subarray(s-o.wsize,s),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(e.subarray(s-i,s-i+n),o.wnext),(i-=n)?(o.window.set(e.subarray(s-i,s),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0};var Ga=(t,e)=>{let s,i,n,o,r,a,l,c,d,h,u,m,p,f,b,y,g,w,Z,v,X,L,x=0;const S=new Uint8Array(4);let G,k;const W=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return la;s=t.state,s.mode===ma&&(s.mode=13),r=t.next_out,n=t.output,l=t.avail_out,o=t.next_in,i=t.input,a=t.avail_in,c=s.hold,d=s.bits,h=a,u=l,L=oa;t:for(;;)switch(s.mode){case 1:if(0===s.wrap){s.mode=13;break}for(;d<16;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(2&s.wrap&&35615===c){s.check=0,S[0]=255&c,S[1]=c>>>8&255,s.check=Co(s.check,S,2,0),c=0,d=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",s.mode=pa;break}if((15&c)!==ua){t.msg="unknown compression method",s.mode=pa;break}if(c>>>=4,d-=4,X=8+(15&c),0===s.wbits)s.wbits=X;else if(X>s.wbits){t.msg="invalid window size",s.mode=pa;break}s.dmax=1<<s.wbits,t.adler=s.check=1,s.mode=512&c?10:ma,c=0,d=0;break;case 2:for(;d<16;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(s.flags=c,(255&s.flags)!==ua){t.msg="unknown compression method",s.mode=pa;break}if(57344&s.flags){t.msg="unknown header flags set",s.mode=pa;break}s.head&&(s.head.text=c>>8&1),512&s.flags&&(S[0]=255&c,S[1]=c>>>8&255,s.check=Co(s.check,S,2,0)),c=0,d=0,s.mode=3;case 3:for(;d<32;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}s.head&&(s.head.time=c),512&s.flags&&(S[0]=255&c,S[1]=c>>>8&255,S[2]=c>>>16&255,S[3]=c>>>24&255,s.check=Co(s.check,S,4,0)),c=0,d=0,s.mode=4;case 4:for(;d<16;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}s.head&&(s.head.xflags=255&c,s.head.os=c>>8),512&s.flags&&(S[0]=255&c,S[1]=c>>>8&255,s.check=Co(s.check,S,2,0)),c=0,d=0,s.mode=5;case 5:if(1024&s.flags){for(;d<16;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}s.length=c,s.head&&(s.head.extra_len=c),512&s.flags&&(S[0]=255&c,S[1]=c>>>8&255,s.check=Co(s.check,S,2,0)),c=0,d=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(m=s.length,m>a&&(m=a),m&&(s.head&&(X=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(i.subarray(o,o+m),X)),512&s.flags&&(s.check=Co(s.check,i,m,o)),a-=m,o+=m,s.length-=m),s.length))break t;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break t;m=0;do{X=i[o+m++],s.head&&X&&s.length<65536&&(s.head.name+=String.fromCharCode(X))}while(X&&m<a);if(512&s.flags&&(s.check=Co(s.check,i,m,o)),a-=m,o+=m,X)break t}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===a)break t;m=0;do{X=i[o+m++],s.head&&X&&s.length<65536&&(s.head.comment+=String.fromCharCode(X))}while(X&&m<a);if(512&s.flags&&(s.check=Co(s.check,i,m,o)),a-=m,o+=m,X)break t}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;d<16;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(c!==(65535&s.check)){t.msg="header crc mismatch",s.mode=pa;break}c=0,d=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),t.adler=s.check=0,s.mode=ma;break;case 10:for(;d<32;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}t.adler=s.check=fa(c),c=0,d=0,s.mode=11;case 11:if(0===s.havedict)return t.next_out=r,t.avail_out=l,t.next_in=o,t.avail_in=a,s.hold=c,s.bits=d,aa;t.adler=s.check=1,s.mode=ma;case ma:if(e===ia||e===na)break t;case 13:if(s.last){c>>>=7&d,d-=7&d,s.mode=27;break}for(;d<3;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}switch(s.last=1&c,c>>>=1,d-=1,3&c){case 0:s.mode=14;break;case 1:if(xa(s),s.mode=20,e===na){c>>>=2,d-=2;break t}break;case 2:s.mode=17;break;case 3:t.msg="invalid block type",s.mode=pa}c>>>=2,d-=2;break;case 14:for(c>>>=7&d,d-=7&d;d<32;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",s.mode=pa;break}if(s.length=65535&c,c=0,d=0,s.mode=15,e===na)break t;case 15:s.mode=16;case 16:if(m=s.length,m){if(m>a&&(m=a),m>l&&(m=l),0===m)break t;n.set(i.subarray(o,o+m),r),a-=m,o+=m,l-=m,r+=m,s.length-=m;break}s.mode=ma;break;case 17:for(;d<14;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(s.nlen=257+(31&c),c>>>=5,d-=5,s.ndist=1+(31&c),c>>>=5,d-=5,s.ncode=4+(15&c),c>>>=4,d-=4,s.nlen>286||s.ndist>30){t.msg="too many length or distance symbols",s.mode=pa;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;d<3;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}s.lens[W[s.have++]]=7&c,c>>>=3,d-=3}for(;s.have<19;)s.lens[W[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,G={bits:s.lenbits},L=ea(0,s.lens,0,19,s.lencode,0,s.work,G),s.lenbits=G.bits,L){t.msg="invalid code lengths set",s.mode=pa;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;x=s.lencode[c&(1<<s.lenbits)-1],b=x>>>24,y=x>>>16&255,g=65535&x,!(b<=d);){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(g<16)c>>>=b,d-=b,s.lens[s.have++]=g;else{if(16===g){for(k=b+2;d<k;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(c>>>=b,d-=b,0===s.have){t.msg="invalid bit length repeat",s.mode=pa;break}X=s.lens[s.have-1],m=3+(3&c),c>>>=2,d-=2}else if(17===g){for(k=b+3;d<k;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}c>>>=b,d-=b,X=0,m=3+(7&c),c>>>=3,d-=3}else{for(k=b+7;d<k;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}c>>>=b,d-=b,X=0,m=11+(127&c),c>>>=7,d-=7}if(s.have+m>s.nlen+s.ndist){t.msg="invalid bit length repeat",s.mode=pa;break}for(;m--;)s.lens[s.have++]=X}}if(s.mode===pa)break;if(0===s.lens[256]){t.msg="invalid code -- missing end-of-block",s.mode=pa;break}if(s.lenbits=9,G={bits:s.lenbits},L=ea(1,s.lens,0,s.nlen,s.lencode,0,s.work,G),s.lenbits=G.bits,L){t.msg="invalid literal/lengths set",s.mode=pa;break}if(s.distbits=6,s.distcode=s.distdyn,G={bits:s.distbits},L=ea(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,G),s.distbits=G.bits,L){t.msg="invalid distances set",s.mode=pa;break}if(s.mode=20,e===na)break t;case 20:s.mode=21;case 21:if(a>=6&&l>=258){t.next_out=r,t.avail_out=l,t.next_in=o,t.avail_in=a,s.hold=c,s.bits=d,Or(t,u),r=t.next_out,n=t.output,l=t.avail_out,o=t.next_in,i=t.input,a=t.avail_in,c=s.hold,d=s.bits,s.mode===ma&&(s.back=-1);break}for(s.back=0;x=s.lencode[c&(1<<s.lenbits)-1],b=x>>>24,y=x>>>16&255,g=65535&x,!(b<=d);){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(y&&0==(240&y)){for(w=b,Z=y,v=g;x=s.lencode[v+((c&(1<<w+Z)-1)>>w)],b=x>>>24,y=x>>>16&255,g=65535&x,!(w+b<=d);){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}c>>>=w,d-=w,s.back+=w}if(c>>>=b,d-=b,s.back+=b,s.length=g,0===y){s.mode=26;break}if(32&y){s.back=-1,s.mode=ma;break}if(64&y){t.msg="invalid literal/length code",s.mode=pa;break}s.extra=15&y,s.mode=22;case 22:if(s.extra){for(k=s.extra;d<k;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,d-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;x=s.distcode[c&(1<<s.distbits)-1],b=x>>>24,y=x>>>16&255,g=65535&x,!(b<=d);){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(0==(240&y)){for(w=b,Z=y,v=g;x=s.distcode[v+((c&(1<<w+Z)-1)>>w)],b=x>>>24,y=x>>>16&255,g=65535&x,!(w+b<=d);){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}c>>>=w,d-=w,s.back+=w}if(c>>>=b,d-=b,s.back+=b,64&y){t.msg="invalid distance code",s.mode=pa;break}s.offset=g,s.extra=15&y,s.mode=24;case 24:if(s.extra){for(k=s.extra;d<k;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,d-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg="invalid distance too far back",s.mode=pa;break}s.mode=25;case 25:if(0===l)break t;if(m=u-l,s.offset>m){if(m=s.offset-m,m>s.whave&&s.sane){t.msg="invalid distance too far back",s.mode=pa;break}m>s.wnext?(m-=s.wnext,p=s.wsize-m):p=s.wnext-m,m>s.length&&(m=s.length),f=s.window}else f=n,p=r-s.offset,m=s.length;m>l&&(m=l),l-=m,s.length-=m;do{n[r++]=f[p++]}while(--m);0===s.length&&(s.mode=21);break;case 26:if(0===l)break t;n[r++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;d<32;){if(0===a)break t;a--,c|=i[o++]<<d,d+=8}if(u-=l,t.total_out+=u,s.total+=u,u&&(t.adler=s.check=s.flags?Co(s.check,n,u,r-u):Wo(s.check,n,u,r-u)),u=l,(s.flags?c:fa(c))!==s.check){t.msg="incorrect data check",s.mode=pa;break}c=0,d=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;d<32;){if(0===a)break t;a--,c+=i[o++]<<d,d+=8}if(c!==(4294967295&s.total)){t.msg="incorrect length check",s.mode=pa;break}c=0,d=0}s.mode=29;case 29:L=ra;break t;case pa:L=ca;break t;case 31:return da;default:return la}return t.next_out=r,t.avail_out=l,t.next_in=o,t.avail_in=a,s.hold=c,s.bits=d,(s.wsize||u!==t.avail_out&&s.mode<pa&&(s.mode<27||e!==sa))&&Sa(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,s.total+=u,s.wrap&&u&&(t.adler=s.check=s.flags?Co(s.check,n,u,t.next_out-u):Wo(s.check,n,u,t.next_out-u)),t.data_type=s.bits+(s.last?64:0)+(s.mode===ma?128:0)+(20===s.mode||15===s.mode?256:0),(0===h&&0===u||e===sa)&&L===oa&&(L=ha),L},ka={inflateReset:ga,inflateReset2:wa,inflateResetKeep:ya,inflateInit:t=>Za(t,15),inflateInit2:Za,inflate:Ga,inflateEnd:t=>{if(!t||!t.state)return la;let e=t.state;return e.window&&(e.window=null),t.state=null,oa},inflateGetHeader:(t,e)=>{if(!t||!t.state)return la;const s=t.state;return 0==(2&s.wrap)?la:(s.head=e,e.done=!1,oa)},inflateSetDictionary:(t,e)=>{const s=e.length;let i,n,o;return t&&t.state?(i=t.state,0!==i.wrap&&11!==i.mode?la:11===i.mode&&(n=1,n=Wo(n,e,s,0),n!==i.check)?ca:(o=Sa(t,e,s,s),o?(i.mode=31,da):(i.havedict=1,oa))):la},inflateInfo:"pako inflate (from Nodeca project)"};var Wa=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ta=Object.prototype.toString,{Z_NO_FLUSH:Ca,Z_FINISH:Pa,Z_OK:Va,Z_STREAM_END:Ra,Z_NEED_DICT:Ya,Z_STREAM_ERROR:Ma,Z_DATA_ERROR:Ia,Z_MEM_ERROR:Ha}=Vo;function Ka(t){this.options=Wr({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mr,this.strm.avail_out=0;let s=ka.inflateInit2(this.strm,e.windowBits);if(s!==Va)throw new Error(Po[s]);if(this.header=new Wa,ka.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Vr(e.dictionary):"[object ArrayBuffer]"===Ta.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(s=ka.inflateSetDictionary(this.strm,e.dictionary),s!==Va)))throw new Error(Po[s])}function za(t,e){const s=new Ka(e);if(s.push(t),s.err)throw s.msg||Po[s.err];return s.result}Ka.prototype.push=function(t,e){const s=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let o,r,a;if(this.ended)return!1;for(r=e===~~e?e:!0===e?Pa:Ca,"[object ArrayBuffer]"===Ta.call(t)?s.input=new Uint8Array(t):s.input=t,s.next_in=0,s.avail_in=s.input.length;;){for(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),o=ka.inflate(s,r),o===Ya&&n&&(o=ka.inflateSetDictionary(s,n),o===Va?o=ka.inflate(s,r):o===Ia&&(o=Ya));s.avail_in>0&&o===Ra&&s.state.wrap>0&&0!==t[s.next_in];)ka.inflateReset(s),o=ka.inflate(s,r);switch(o){case Ma:case Ia:case Ya:case Ha:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===Ra))if("string"===this.options.to){let t=Yr(s.output,s.next_out),e=s.next_out-t,n=Rr(s.output,t);s.next_out=e,s.avail_out=i-e,e&&s.output.set(s.output.subarray(t,t+e),0),this.onData(n)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(o!==Va||0!==a){if(o===Ra)return o=ka.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},Ka.prototype.onData=function(t){this.chunks.push(t)},Ka.prototype.onEnd=function(t){t===Va&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Tr(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Na={Inflate:Ka,inflate:za,inflateRaw:function(t,e){return(e=e||{}).raw=!0,za(t,e)},ungzip:za,constants:Vo};const{Deflate:Fa,deflate:_a,deflateRaw:ja,gzip:Qa}=Dr,{Inflate:Ea,inflate:Ja,inflateRaw:Ua,ungzip:Da}=Na;var Oa={Deflate:Fa,deflate:_a,deflateRaw:ja,gzip:Qa,Inflate:Ea,inflate:Ja,inflateRaw:Ua,ungzip:Da,constants:Vo};class Ba{constructor(){this.url="(offline)",this.readyState=WebSocket.CONNECTING,this.bufferedAmount=0,setTimeout((()=>{this.readyState=WebSocket.OPEN,this.onopen&&this.onopen()}),50),this.start=Date.now()}send(t){const{id:e,action:s,args:i}=JSON.parse(t);switch(s){case"JOIN":return this.id=e,this.ticks=i.ticks.tick,this.seq=-16>>>0,this.reply("SYNC",{messages:[],time:this.time,seq:this.seq,tove:i.tove,reflector:"offline"}),this.reply("RECV",[this.time,++this.seq,{what:"users",joined:[i.user],active:1,total:1}]),void this.tick();case"SEND":{const t=[...i];return t[0]=this.time,t[1]=++this.seq,void this.reply("RECV",t)}case"PULSE":return;default:throw Error("Offline unhandled "+s)}}close(t,e){this.readyState=WebSocket.CLOSING,setTimeout((()=>{this.readyState=WebSocket.CLOSED,this.onclose&&this.onclose({code:t,reason:e})}),50)}get time(){return Date.now()-this.start}tick(){clearInterval(this.ticker),this.ticker=setInterval((()=>{this.reply("TICK",{time:this.time})}),this.ticks)}reply(t,e){setTimeout((()=>{this.onmessage&&this.onmessage({data:JSON.stringify({id:this.id,action:t,args:e})})}),50)}}function Aa(t,e,s){var i=void 0===e?null:e,n=function(t,e){var s=atob(t);if(e){for(var i=new Uint8Array(s.length),n=0,o=s.length;n<o;++n)i[n]=s.charCodeAt(n);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return s}(t,void 0!==s&&s),o=n.indexOf("\n",10)+1,r=n.substring(o)+(i?"\/\/# sourceMappingURL="+i:""),a=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(a)}var $a,qa,tl,el,sl=($a="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwovKioKICogQ29weXJpZ2h0IENyb3F1ZXQgQ29ycG9yYXRpb24gMjAyNAogKiBCdW5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ZmZsaW5lIGNyZWF0ZWQifX1mdW5jdGlvbiBPKHQpe2NvbnN0IGU9eC5nZXQodCk7aWYoIWUpcmV0dXJuIGsmJmNvbnNvbGUuZXJyb3IoYCR7dX0gZmlsZSBub3QgZm91bmQgJHt0fWApLHZvaWQgYih7am9iOnIsb2s6ITEsc3RhdHVzOi0xLHN0YXR1c1RleHQ6Ik9mZmxpbmUgZmlsZSBub3QgZm91bmQifSk7ayYmY29uc29sZS5sb2codSxgcmV0cmlldmVkICR7dH1gKSxiKHtqb2I6cixvazohMCxzdGF0dXM6MjAwLHN0YXR1c1RleHQ6Ik9mZmxpbmUgZmlsZSBmb3VuZCIsYm9keTplLGJ5dGVzOmUuYnl0ZUxlbmd0aH0pfX0sbT1mZXRjaCxiPXBvc3RNZXNzYWdlO2NvbnN0IHg9bmV3IE1hcH0oKTsKCg==",qa=null,tl=!1,function(t){return el=el||Aa($a,qa,tl),new Worker(el,t)});const il=s.CROQUET_VERSION,nl="node"===s.CROQUET_PLATFORM;nl||window.location.hostname.match(/co?de?pe?n\.io/)?console.log("Croquet "+il):console.log("%cCroquet%c %c"+il,"color:#F0493E","color:inherit","color:"+(il.includes("+")?"#909":"inherit"));const ol=!nl&&!!window.location.hostname.match(/^(.*\.)?croquet\.io$/i)&&window.location.pathname.startsWith("/dev/"),rl=!nl&&!!window.location.hostname.match(/^(.*\.)?croquet\.dev$/i),al="https://croquet.io/files/v1",ll="https://files.croquet.io",cl=ll;let dl=null;function hl(t){var e;const s=t.lastIndexOf(":"),i=-1===s?t:t.slice(s+1),n=-1===s?"":t.slice(0,s);let o=a.backend||n;const r=null===(e=a.reflector)||void 0===e?void 0:e.includes("/");if("none"===o||dl.offline)return{apiKey:i,signServer:"none",reflector:"overridden"};if(!o&&!nl)switch(window.location.hostname){case"croquet.dev":o="dev";break;case"staging.croquet.io":o="staging"}let l;switch(o){case"":case"prod":l="croquet.io";break;case"staging":l="staging.croquet.io";break;case"dev":l="croquet.dev";break;default:l=`${o}.croquet.dev`}return{apiKey:i,signServer:`https://api.${l}/sign`,reflector:r?"overridden":`wss://api.${l}/reflector/v1`}}const ul=a.nocheat,ml=200,pl=[0],fl=4096;let bl;const yl=new sl;yl.onerror=t=>console.error(`UploadWorker error: ${t.message}`);let gl=0;const wl=new Set;function Zl(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=null;for(const s of wl)if(e||(e=s),s.id===t){e=s;break}if(e){const{appId:t,persistentId:s}=e.sessionSpec;return{appId:t,persistentId:s,key:e.key,uploadEncrypted:t=>e.uploadEncrypted(t),downloadEncrypted:t=>e.downloadEncrypted(t)}}return{}}Object.defineProperty(Mt,"controller",{get(){return this.controllers.values().next().value}}),Mt.controllers=wl;class vl{constructor(){!function(){const t=a.dev||!1!==a.dev&&"localhost",e=a.dev||!1!==a.dev&&(ol||rl);dl={messages:a.has("debug","messages",!1),sends:a.has("debug","sends",!1),ticks:a.has("debug","ticks",!1),pong:a.has("debug","pong",!1),snapshot:a.has("debug","snapshot",!1),session:a.has("debug","session",!1),initsnapshot:a.has("debug","initsnapshot",t),reflector:a.has("debug","reflector",e),offline:a.has("debug","offline",a.offline)},dl.offline&&Vt.showMessage("Croquet: offline mode enabled, no multiuser",{level:"warning"})}(),this.reset()}reset(){globalThis.CROQUETVM===this.vm&&delete globalThis.CROQUETVM,this.vm=null,this.session=null,this.connection=this.connection||new Xl(this),this.networkQueue=[],this.reflectorTime=0,this.msPerTick=this.msPerTick||0,this.tickMultiplier=this.tickMultiplier||1,this.extrapolatedTimeBase=Date.now(),this.key=this.key||null,this.tove=this.tove||null,this.viewId=this.viewId||Math.floor(Math.random()*36**10).toString(36),this.timeline="",this.rejoinTimeout&&clearTimeout(this.rejoinTimeout),this.rejoinTimeout=0,this.sendBuffer=[],this.users=0,this.usersTotal=0,this.cpuTime=0,this.triggeringCpuTime=null,this.synced=null,this.latency=0,this.latencyHistory&&(this.latencyHistory=[]),this.localTicker&&(globalThis.clearInterval(this.localTicker),delete this.localTicker),this.syncTimer&&(globalThis.clearTimeout(this.syncTimer),delete this.syncTimer),this.tuttiHistory=[],this.lastAnimationEnd=0,this.animationGapCheck=[],this.rateLimitedSendTimes=[],this.rateLimitBuffer=[],this.rateLimitSoftWarned=!1,this.rateLimitBufferWarned=!1,this.rateLimitLastLogged=0,this.payloadSizeWarned=!1,Mt.removeAllSubscriptionsFor(this.viewId),Mt.addSubscription(this.viewId,"__peers__",this.viewId,(t=>bt(`users now ${t.count}`)),"oncePerFrameWhileSynced"),this.leaving||Vt.showSyncWait(!0)}get id(){return this.vm?this.vm.id:this.sessionSpec.id}get persistentId(){return this.sessionSpec.persistentId}get versionId(){return this.sessionSpec.codeHash}get extrapolatedTime(){return Date.now()-this.extrapolatedTimeBase}get viewOnly(){return this.sessionSpec.viewOnly}get backlog(){return this.vm?this.reflectorTime-this.vm.time:0}get starvation(){return Date.now()-this.lastReceived}get lag(){return this.vm?Math.max(0,this.extrapolatedTime-this.vm.time-this.msPerTick):0}get activity(){return Date.now()-this.lastSent}get viewed(){return!(!this.session||!this.session.view)}get connected(){return this.connection.connected}get shouldLeaveWhenDisconnected(){return this.leaving||!this.canRejoinSeamlessly||0===this.sessionSpec.rejoinLimit}get canRejoinSeamlessly(){return!!this.timeline}checkForConnection(t){this.connection.checkForConnection(t)}dormantDisconnect(){this.connected&&this.connection.dormantDisconnect()}async initFromSessionSpec(t){const{name:e,optionsFromUrl:s,password:i,appId:n,apiKey:o,viewIdDebugSuffix:r}=t,l=n?`${n}/${e}`:e;r&&(this.viewId=this.viewId.replace(/_.*$/,"")+"_"+encodeURIComponent((""+r).slice(0,16)).replace(/[^a-z0-9]/gi,(t=>`_${"%"===t?"":t.charCodeAt(0).toString(16).toUpperCase()}`)));const c={...t.options};if(s)for(const t of s)t in a&&(c[t]=a[t]);const d={};for(const e of["hashOverride"])e in a?d[e]=a[e]:e in t&&(d[e]=t[e]);this.key=Mn(i,"",{keySize:8});const h=await async function(t,e){return P(t+y(e))}(l,c),{developerId:u,token:m}=await this.verifyApiKey(o,n,h),{id:p,codeHash:f,computedCodeHash:b}=await async function(t,e,s,i){let n,o;const r=R[t];let a="";r?(n=r.codeHashes,o=r.computedCodeHash,a=" (code hashing from cache)"):(n=await Promise.all(V),o=await P([i,...n].join("|")),R[t]={codeHashes:n,computedCodeHash:o});const{hashOverride:l,...c}=s,d=l||o,h=await P(t+"|"+e+y(c)+d);if(W()&&!Y.has(h)){(L?"utf-8":[...document.getElementsByTagName("meta")].find((t=>t.getAttribute("charset"))))||console.warn('Croquet: Missing <meta charset="..."> declaration. Croquet model code hashing might differ between browsers.'),T[o].what="Version ID",T[t].what="Persistent ID",T[h].what="Session ID",d!==o&&(n.push(o),T[o].what="Computed Version ID (replaced by overrideHash)",T[d]={what:"Version ID (as specified by overrideHash)"});const e=[...n,d,t,h].map((t=>({hash:t,...T[t]})));console.log(`Croquet: Debug Hashing for session ${h}${a}`,e),Y.add(h)}return W()||(T={}),{id:h,persistentId:t,codeHash:d,computedCodeHash:o}}(h,u,d,il);this.tove=await this.encrypt(p),dl.session&&console.log(`Croquet session "${l}":\n        sessionId=${p}${n?`\n        persistentId=${h}`:""}\n        versionId=${f===b?f:`${f} (specified in hashOverride)\n        versionId=${b} (computed)`}\n        viewId=${this.viewId}`),this.eventRateLimit=t.eventRateLimit,this.eventHistoryLimit=this.eventRateLimit,this.eventMaxBundles=this.eventRateLimit,this.sessionSpec={...t,options:c,name:l,id:p,persistentId:h,developerId:u,token:m,codeHash:f,computedCodeHash:b};const{msPerTick:g,multiplier:w}=this.getTickAndMultiplier();this.msPerTick=g,this.tickMultiplier=w,this.setUpActivityChecks()}async establishSession(){const{id:t,persistentId:e,codeHash:s}=this.sessionSpec;this.sessionSpec.snapshot={id:t,time:0,meta:{id:t,persistentId:e,codeHash:s,created:(new Date).toISOString()}};const i=new Promise((t=>this.sessionSpec.sessionJoined=t));this.checkForConnection(!1),dl.session&&console.log(t,"waiting for SYNC"),await i}async verifyApiKey(t,e,s){const{signServer:i,apiKey:n}=hl(t);if("none"===i)return{developerId:"unknown_dev_id"};try{const t=await fetch(`${i}/join?meta=login`,{method:"GET",mode:"cors",headers:{"X-Croquet-Auth":n,"X-Croquet-App":e,"X-Croquet-Id":s,"X-Croquet-Version":il,"X-Croquet-Path":new URL(Vt.referrerURL()).pathname},referrer:Vt.referrerURL(),referrerPolicy:"no-referrer-when-downgrade"}),{error:o,developerId:r,token:a}=await t.json();if(o)throw Error(o);return dl.session&&console.log("Croquet: verified API key"),{developerId:r,token:a}}catch(e){throw Error(`Croquet API key validation failed for "${t}": ${e.message}`)}}lastKnownTime(t){return Math.max(t.time,t.externalTime)}takeSnapshot(){const t=this.vm.snapshot(),e=this.lastKnownTime(t),s=t.externalSeq;return t.meta={...this.sessionSpec.snapshot.meta,options:this.sessionSpec.options,time:e,seq:s,date:(new globalThis.CroquetViewDate).toISOString(),host:nl?"localhost":window.location.hostname,sdk:il},delete t.meta.hash,t}takeSnapshotHandleErrors(){let t,e,s;try{t=ot.begin("snapshot"),s=this.takeSnapshot()}catch(t){return yt("snapshot",t),null}finally{e=ot.end("snapshot")-t}return dl.snapshot&&console.log(this.id,`snapshot taken in ${Math.ceil(e)} ms`),s}scheduleSnapshot(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.connected||!this.vm||this.viewOnly)return;const e=this.vm.time,s=e-this.vm.lastSnapshotPoll;if(s<5e3&&!t)return void(dl.snapshot&&console.log(`not requesting snapshot poll (${s}ms since poll scheduled)`));if(t){const t=Object.keys(this.vm.views);if(t.sort(),t[0]!==this.viewId&&t[1]!==this.viewId&&t[2]!==this.viewId)return void(dl.snapshot&&console.log("not forcing snapshot poll (not one of the three)"));dl.snapshot&&console.log("forcing snapshot poll")}const i=new tc(e,0,"_","handlePollForSnapshot",[]);this.sendTagged(i,{debounce:5e3,msgID:"pollForSnapshot"}),dl.snapshot&&console.log(this.id,"requesting snapshot poll via reflector")}handlePollForSnapshot(t){if(!0!==this.synced||this.viewOnly)return void(this.triggeringCpuTime=null);const e=this.triggeringCpuTime||this.cpuTime;let s,i,n;this.triggeringCpuTime=null,this.cpuTime=0;try{s=ot.begin("snapshot"),i={cpuTime:e,hash:this.vm.getSummaryHash(),viewId:this.viewId}}catch(t){return void yt("snapshot",t)}finally{n=ot.end("snapshot")-s,this.cpuTime-=n}dl.snapshot&&console.log(this.id,`Summary hashing took ${Math.ceil(n)}ms`),Promise.resolve().then((()=>this.pollForSnapshot(t,i)))}pollForSnapshot(t,e){e.cpuTime+=Math.random(),dl.snapshot&&console.log(this.id,"sending snapshot vote",e),this.sendTutti({time:t,topic:"snapshot",data:e,tallyTarget:["handleSnapshotVote"]})}handleSnapshotVote(t){const{tally:e}=t;dl.snapshot&&console.log(this.id,"received snapshot votes",e);const{numberOfGroups:s,shouldUpload:i,dissidentFlag:n}=this.analyzeTally(e,"cpuTime");if(s>1){this.diverged=!0;const t=this.vm.diverged?this.vm.diverged.size:0;console.error(this.id,`Session diverged (#${t})! Snapshots fall into ${s} groups`)}if(!0===this.synced){if(i){const t=this.takeSnapshotHandleErrors();t&&Promise.resolve().then((()=>this.uploadSnapshot(t,n)))}}else dl.snapshot&&console.log(this.id,"Ignoring snapshot vote during sync")}analyzeTally(t,e){let s=!1,i=null;const n=[],o={};let r=null;Object.keys(t).forEach(((t,e)=>{const s=JSON.parse(t);n.push(s);const{hash:i,viewId:a}=s;a===this.viewId&&(r=e),o[i]||(o[i]=[]),o[i].push(e)}));const a=Object.keys(o),l=a.length;let c=0;l>1&&(a.sort(((t,e)=>o[e].length-o[t].length)),o[a[0]].length===o[a[1]].length&&(dl.snapshot&&console.log(this.id,"Deciding consensus by tie-break"),a[1]<a[0]&&(c=1)));const d=a[c];if(null!==r){const t=n[r].hash,a=o[t];a.length>1&&a.sort(((t,s)=>n[t][e]-n[s][e])),a[0]===r&&(s=!0,t!==d&&(i={groupVotes:a.length,allVotes:n.length}))}return{numberOfGroups:l,shouldUpload:s,dissidentFlag:i}}snapshotPath(t,e,s){const i=Math.ceil(t).toString().padStart(10,"0"),{appId:n,persistentId:o,codeHash:r,apiKey:a}=this.sessionSpec;return a?`apps/${n}/snap/${r}/${o}.${this.id}/${i}_${e}.${s}`:`snapshots/${this.id}/${i}_${e}-${s}.snap`}hashSnapshot(t){return t.meta.hash?t.meta.hash:(t.meta.hashPromise||(t.meta.hashPromise=new Promise((e=>{const s={...t};delete s.meta,P(JSON.stringify(s)).then((s=>{t.meta.hash=s,delete t.meta.hashPromise,e(s)}))}))),t.meta.hashPromise)}uploadServer(t){if("string"==typeof a.files){let t=new URL(a.files,window.location).href;return t.endsWith("/")&&(t=t.slice(0,-1)),{url:t,apiKey:null}}const{apiKey:e,signServer:s}=hl(t);if("none"===s&&!dl.offline)throw Error("no file server configured");return{url:s,apiKey:e}}async uploadSnapshot(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;await this.hashSnapshot(t);const s=ot.begin("snapshot"),i=JSON.stringify(t),n=ot.end("snapshot")-s;dl.snapshot&&console.log(this.id,`snapshot stringified (${i.length} bytes) in ${Math.ceil(n)}ms`);const{time:o,seq:r,hash:a}=t.meta,l=this.connection.socket;try{const t=await this.uploadEncrypted({content:i,path:this.snapshotPath(o,r,a),key:this.key,gzip:!0,debug:dl.snapshot,what:"snapshot"});return this.connection.socket!==l?(console.warn(this.id,"Controller was reset while trying to upload snapshot"),!1):(this.announceSnapshotUrl(o,r,a,t,e),!0)}catch(t){return console.error(this.id,"Failed to upload snapshot"),!1}}announceSnapshotUrl(t,e,s,i,n){if(dl.snapshot){let o=`time: ${t}, seq: ${e}, hash: ${s}`;n&&(o+=", as dissident; "+JSON.stringify(n)),console.log(this.id,`sending snapshot url to reflector (${o}): ${i}`)}try{this.connection.send(JSON.stringify({id:this.id,action:"SNAP",args:{time:t,seq:e,hash:s,url:i,dissident:n}}))}catch(t){console.error("ERROR while sending",t)}this.diverged&&this.vm.publishFromView("__VM__","__diverged__",{key:`@${t}#${e}`,url:i,dissident:n})}async diffDivergedSnapshots(t){const e=await Promise.all(t.map((t=>this.downloadEncrypted({url:t,gzip:!0,key:this.key,debug:dl.snapshot,json:!0,what:"diverged snapshot"}))));for(const t of e)delete t.meta;let s=0;!function t(e,i,n){if(typeof e!=typeof i)console.log(`${n} diverged (${typeof e} vs ${typeof i}):`,e,i),s++;else if(Array.isArray(e)!==Array.isArray(i))console.log(`${n} diverged (array vs object):`,e,i),s++;else if("object"==typeof e){const o=e?Object.keys(e):[],r=i?Object.keys(i):[],a=o.filter((t=>!r.includes(t))),l=r.filter((t=>!o.includes(t)));(a.length||l.length)&&(console.log(`${n} diverged (keys mismatch):`,a,l),s++);for(const s of o)r.includes(s)&&t(e[s],i[s],`${n}${zl(e,s)}`)}else e!==i&&(console.log(`${n} diverged (value mismatch):`,e,i),s++)}(e[0],e[1],"CROQUETVM"),s?console.log(`Total ${s} differences between diverged snapshots:`,e.slice(0,2)):console.log("... but diverged snapshots are identical?!")}async downloadEncrypted(t){let{url:e,gzip:s,key:i,debug:n,json:o,what:r}=t;e.startsWith(al)&&(e=e.replace(al,ll));const a=e.startsWith("offline:");let l=Date.now();const c=await(a?this.fetchOffline(e,r,n):fetch(e,{method:"GET",mode:"cors",headers:{"X-Croquet-App":this.sessionSpec.appId,"X-Croquet-Id":this.sessionSpec.persistentId,"X-Croquet-Session":this.sessionSpec.id,"X-Croquet-Version":il},referrer:Vt.referrerURL()})),d=await c.arrayBuffer();n&&console.log(this.id,`${r} fetched (${d.byteLength} bytes) in ${-l+(l=Date.now())}ms`),ot.addNetworkTraffic(`${r}_in`,d.byteLength);const h=this.decryptBinary(d,i);n&&console.log(this.id,`${r} decrypted (${h.length} bytes) in ${-l+(l=Date.now())}ms`);const u=s?Oa.inflate(h):h;return n&&s&&console.log(this.id,`${r} inflated (${u.length} bytes) in ${-l+(l=Date.now())}ms`),o?JSON.parse((new TextDecoder).decode(u)):u}async fetchOffline(t,e,s){const i=++gl;return new Promise(((n,o)=>{const r=nl?"addListener":"addEventListener",a=nl?"removeListener":"removeEventListener";yl.postMessage({job:i,cmd:"getOfflineFile",url:t,id:this.id,what:e,debug:s,offline:dl.offline});const l=t=>{if(i!==t.data.job)return;const{ok:s,status:r,statusText:c,body:d,bytes:h}=t.data;ot.addNetworkTraffic(`${e}_out`,h),yl[a]("message",l),s?n({arrayBuffer:()=>d}):o(Error(`${r}: ${c}`))};try{yl[r]("message",l)}catch(t){console.log("failed to add listener",t)}}))}async uploadEncrypted(t){let{content:e,path:s,key:i,gzip:n,keep:o,debug:r,what:a}=t;const l="string"==typeof e?(new TextEncoder).encode(e).buffer:e,c=o?void 0:[l],d="string"==typeof i?i:Tn.stringify(i),{apiKey:h,appId:u,persistentId:m}=this.sessionSpec,p=++gl;return new Promise(((t,e)=>{const i=nl?"addListener":"addEventListener",o=nl?"removeListener":"removeEventListener";yl.postMessage({job:p,cmd:"uploadEncrypted",server:this.uploadServer(h),path:s,buffer:l,keyBase64:d,gzip:n,referrer:Vt.referrerURL(),id:this.id,appId:u,persistentId:m,CROQUET_VERSION:il,debug:r,what:a,offline:dl.offline},c);const f=s=>{if(p!==s.data.job)return;const{url:i,ok:n,status:r,statusText:l,bytes:c}=s.data;ot.addNetworkTraffic(`${a}_out`,c),yl[o]("message",f),n?t(i):e(Error(`${r}: ${l}`))};try{yl[i]("message",f)}catch(t){console.log("failed to add listener",t)}}))}persistentPath(t){const{appId:e,persistentId:s}=this.sessionSpec;return`apps/${e}/${s}/save/${t}`}pollForPersist(t,e,s,i,n){if(!this.synced)return;if(!this.sessionSpec.appId)throw Error("Persistence API requires appId");if(dl.offline)return;const o={viewId:this.viewId,hash:i,ms:n+.001*Math.random()},r={persistTime:e,persistentHash:i,persistentString:s};dl.snapshot&&console.log(this.id,`sending persistence vote for time @${e}`,o),this.sendTutti({time:t,topic:"persist",data:o,localContext:r,tallyTarget:["handlePersistVote"]})}async handlePersistVote(t){const{tally:e,localContext:s}=t;if(dl.snapshot){const t=!!s?`for time @${s.persistTime}`:"that we didn't participate in";console.log(this.id,`received persistence vote ${t}`,e)}const{numberOfGroups:i,shouldUpload:n,dissidentFlag:o}=this.analyzeTally(e,"ms");if(i>1&&console.warn(this.id,`Persistence records fall into ${i} groups`),!n||!s)return;const{persistTime:r,persistentHash:a,persistentString:l}=s,c=await this.uploadEncrypted({path:this.persistentPath(a),content:l,key:this.key,gzip:!0,debug:dl.snapshot,what:"persistence"});if(dl.snapshot){const t=o?` (as dissident; ${JSON.stringify(o)})`:"";console.log(this.id,`sending persistent data url to reflector${t}: ${c}`)}try{this.connection.send(JSON.stringify({id:this.id,action:"SAVE",args:{persistTime:r,url:c,dissident:o}}))}catch(t){console.error("ERROR while sending",t)}}convertReflectorMessage(t){let e="noop",s=[];switch(t[2].what){case"users":{const{joined:i,left:n,active:o,total:r}=t[2];this.users=o,this.usersTotal=r;const a="__peers__",l={entered:i||[],exited:n||[],count:o};e="publishFromModelOnly",s=["__VM__",a,l],Mt.handleEvent(this.viewId+":"+a,l);break}case"tally":{const{tuttiSeq:i,tuttiKey:n,tally:o,tallyTarget:r,missingClients:a}=t[2];(dl.messages||dl.snapshot)&&a&&console.log(`${a} ${1===a?"client":"clients"} failed to participate in tally ${n||i}`),e="handleTuttiResult",s=[{tuttiSeq:i,tuttiKey:n,tally:o,tallyTarget:r}];break}}const i=new tc(0,0,"_",e,s);t[2]=i.asState()[2]}handleTuttiResult(t){const{tuttiSeq:e,tuttiKey:s,tally:i,tallyTarget:n}=t,o=s?t=>t.tuttiKey===s:t=>t.dummyTuttiSeq===e,r=this.tuttiHistory.findIndex(o),a=-1!==r&&this.tuttiHistory.splice(r,1)[0];let l=null,c=null;if(a&&(l=a.payload,c=a.localContext),n){const[t,...e]=n,s=[...e,{tally:i,localPayload:l,localContext:c}],o=new tc(0,0,"_",t,s);this.vm.verifyExternal(o),o.executeOn(this.vm,!0)}}async receive(t,e){const s=this.lastReceived;switch(this.lastReceived=this.connection.lastReceived,t){case"SYNC":{this.syncReceived=!0,this.clearSyncReceiptTimeout(),wl.add(this);const{progressReporter:t}=this.sessionSpec,s=t||(()=>{}),{messages:i,url:n,persisted:o,time:r,seq:a,snapshotSeq:l,tove:c,reflector:d,flags:h}=e;if(c&&c!==this.tove)try{if(this.decrypt(c)!==this.id)throw Error("wrong sessionId in tove?!")}catch(t){return this.connection.closeConnectionWithError("SYNC",Error(`session password check: ${t.message}`),4200),void s(-1)}const u=e.timeline||e.reflectorSession;this.flags=h||{};const m=o?"persistence":"snapshot";dl.session&&console.log(this.id,`received SYNC from ${d} reflector: time ${r}, ${i.length} messages, ${m} ${n||"<none>"}`);let p=!!this.vm;if(p){this.networkQueue.length=0;const t=!!u&&u===this.timeline,e=i[0],s=a,n=void 0!==l?l:e?e[1]:s;dl.messages&&console.log(this.id,`rejoin: we have #${this.vm.seq} SYNC has #${n}-#${s}`);let o=t&&ql(n,this.vm.seq)&&ql(this.vm.seq,s)&&r>=this.reflectorTime;if(o){let t=0;e&&ql(e[1],this.vm.seq)&&(t=this.vm.seq-e[1]+1>>>0);for(let e=t;o&&e<i.length;e++){const t=i[e][2];"string"!=typeof t&&"users"===t.what&&t.left&&t.left.includes(this.viewId)&&(dl.session&&console.log(this.id,"reflector reports that this view has left"),o=!1)}o&&t&&(dl.messages&&console.log(this.id,`rejoin: discarding ${t} messages #${e[1]}-#${this.vm.seq}`),i.splice(0,t))}if(o){if(this.sendBuffer.length>0){const t=this.sendBuffer;this.sendBuffer=[],dl.session&&console.log(this.id,`rejoin: sending ${t.length} messages buffered while disconnected`);for(const e of t)e()}}else dl.session&&console.log(this.id,"cannot rejoin seamlessly; rebooting model/view"),this.leave(!0),p=!1}const f=this.networkQueue;this.networkQueue=[];for(const t of i){if("string"!=typeof t[2])this.convertReflectorMessage(t);else try{t[2]=this.decryptPayload(t[2])[0]}catch(t){return this.connection.closeConnectionWithError("SYNC",Error(`session password decrypt: ${t.message}`),4200),void s(-1)}dl.messages&&console.log(this.id,"received in SYNC "+JSON.stringify(t)),this.networkQueue.push(t)}if(this.networkQueue.push(...f),r>this.reflectorTime&&this.timeFromReflector(r,"reflector"),p)return dl.session&&console.log(this.id,"seamless rejoin successful"),void this.sessionSpec.sessionJoined();let b;if(this.timeline=u||"",dl.snapshot&&n&&console.log(this.id,`fetching ${m} ${n}`),n)try{b=await this.downloadEncrypted({url:n,gzip:!0,key:this.key,debug:dl.snapshot,json:!0,what:m})}catch(t){return this.connection.closeConnectionWithError("SYNC",Error(`failed to fetch ${m}: ${t.message}`),4200),void s(-1)}if(!this.connected)return console.log(this.id,"disconnected during SYNC"),void s(-1);o?this.install(b):(b&&(this.sessionSpec.snapshot=b),this.install()),dl.session&&console.log(this.id,`fast-forwarding from ${Math.round(this.vm.time)} to at least ${r}`);const y=this.vm.time,g=await new Promise((t=>{const{port1:e,port2:i}=new MessageChannel;e.onmessage=()=>{let e=!0;if(this.vm.time===this.reflectorTime)this.viewId in this.vm.views&&(s(1),t(!0),e=!1);else{const t=(this.vm.time-y)/(this.reflectorTime-y);s(t)}e&&this.stepSession("fastForward",{budget:ml})};this.fastForwardHandler=e=>{this.connected&&this.vm?"error"===e?(s(-1),t(!1)):i.postMessage("tick"):(console.log(this.id,"disconnected during SYNC fast-forwarding"),s(-1),t(!1))},Promise.resolve().then((()=>this.stepSession("fastForward",{budget:ml})))}));return delete this.fastForwardHandler,g&&dl.session&&console.log(this.id,`fast-forwarded to ${Math.round(this.vm.time)}`),g&&this.vm.diverged&&Vt.showMessage("Croquet: session had diverged",{level:"warning",only:"once"}),void(g&&this.sessionSpec.sessionJoined())}case"RECV":{const t=e;if(t[1]>>>=0,"string"!=typeof t[2])dl.messages&&console.log(this.id,"received META "+JSON.stringify(t)),this.convertReflectorMessage(t),dl.messages&&console.log(this.id,"converted to "+JSON.stringify(t));else try{const[e,s,i]=this.decryptPayload(t[2]);t[2]=e,s===this.viewId&&this.addToStatistics(i,this.lastReceived),dl.messages&&console.log(this.id,"received "+JSON.stringify(t))}catch(t){return void this.connection.closeConnectionWithError("RECV",Error(`session password decrypt: ${t.message}`),4200)}let s;return this.networkQueue.push(t),this.flags.rawtime&&(s=t[t.length-1]),this.timeFromReflector(t[0],"reflector",s),void(this.simulateIfNeeded&&Promise.resolve().then((()=>this.simulateIfNeeded())))}case"TICK":{if(!this.vm)return;const t="number"==typeof e?e:e.time;if(dl.ticks){const e=s&&this.lastReceived-s-this.msPerTick*this.tickMultiplier|0;console.log(this.id,`Controller received TICK ${t} ${Math.abs(e)<5?"on time":e<0?"early":"late"} (${e} ms)`)}return this.timeFromReflector(t,"reflector"),this.tickMultiplier>1&&this.multiplyTick(t),void(this.simulateIfNeeded&&Promise.resolve().then((()=>this.simulateIfNeeded())))}case"INFO":{const{msg:t,options:s}=e;return void Vt.showMessage("Croquet Reflector: "+t,s)}case"REQU":return dl.snapshot&&console.log("received REQU (snapshot request) from reflector"),void(this.reflectorNeedsSnapshot=!0);default:console.warn("Unknown action:",t,e)}}install(t){const e=Date.now(),{snapshot:s,initFn:i,options:n}=this.sessionSpec,[o,r]=s.modelsById?["deserializ","snapshot"]:["initializ","root model"];dl.session&&console.log(this.id,`${o}ing ${r}`);let a=new Al(s,(()=>{try{return i(n,t)}catch(t){throw yt("init",t,"fatal"),t}}));if((dl.session||dl.snapshot&&s.modelsById)&&console.log(this.id,`${r} ${o}ed in ${Date.now()-e}ms`),dl.initsnapshot&&!s.modelsById){dl.snapshot&&console.log(this.id,"exercising snapshot and restore after init()");let t=null;try{t=JSON.stringify(a.snapshot())}catch(t){throw yt("initial snapshot",t,"fatal"),t}try{a=new Al(JSON.parse(t),(()=>i(n)))}catch(t){throw yt("initial snapshot resume",t,"fatal"),t}}const l=this.lastKnownTime(a);this.reflectorTime=Math.max(this.reflectorTime,l),this.setVM(a)}setVM(t){this.vm=t,this.vm.controller=this}sendJoin(){this.syncReceived=!1,delete this.fastForwardHandler,this.rejoinTimeout&&(clearTimeout(this.rejoinTimeout),this.rejoinTimeout=0),dl.session&&console.log(this.id,"Controller sending JOIN");const{tick:t,delay:e}=this.getTickAndMultiplier(),{name:s,codeHash:i,appId:n,apiKey:o,persistentId:r,developerId:a,heraldUrl:l,rejoinLimit:c,autoSleep:d,computedCodeHash:h,location:u,flags:m}=this.sessionSpec,{apiKey:p}=hl(o),f=u?[this.viewId]:this.viewId,b={name:s,apiKey:p,appId:n,persistentId:r,url:Vt.referrerURL(),sdk:il,developerId:a,version:1,user:f,location:u,ticks:{tick:t,delay:e},dormantDelay:d,tove:this.tove,codeHash:i};l&&Object.assign(b,{heraldUrl:l}),c&&Object.assign(b,{leaveDelay:c+250}),h!==i&&Object.assign(b,{computedCodeHash:h}),m&&Object.assign(b,{flags:m}),this.connection.send(JSON.stringify({id:this.id,action:"JOIN",args:b})),this.syncReceiptTimeout=setTimeout((()=>{delete this.syncReceiptTimeout,this.syncReceived||this.connection.closeConnectionWithError("JOIN",Error("Initial reflector connection timed out"))}),5e3)}clearSyncReceiptTimeout(){this.syncReceiptTimeout&&(clearTimeout(this.syncReceiptTimeout),delete this.syncReceiptTimeout)}connectionInterrupted(){this.syncReceived&&(this.shouldLeaveWhenDisconnected?this.leave():this.rejoinTimeout||(this.rejoinTimeout=setTimeout((()=>{dl.session&&console.log(this.id,"rejoin timed out"),this.rejoinTimeout=0,this.leave()}),this.sessionSpec.rejoinLimit)))}leave(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{rebootModelView:e}=this.sessionSpec;if(this.reset(),dl.session&&console.log(this.id,`resetting ${t?"(but keeping)":"and discarding"} controller`),t||wl.delete(this),!this.sessionSpec)throw Error("do not discard sessionSpec!");e()}async encrypt(t){const e=Z.random(16),s=Nn.encrypt(t,this.key,{iv:e}),i=_n(t,this.key);return`${Tn.stringify(e)}${Tn.stringify(i)}${s}`}get deprecatedDefaultKey(){return bl||(bl=Mn("THIS SHOULDN'T BE IN LOGS","",{keySize:8})),bl}decrypt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.key;const s=Tn.parse(t.slice(0,24)),i=Tn.parse(t.slice(24,68)),n=t.slice(68),o=Nn.decrypt(n,e,{iv:s});let r="";try{r=Pn.stringify(o)}catch(t){}const a=_n(r,this.key);if(this.compareHmacs(i.words,a.words))return r;if(e!==this.deprecatedDefaultKey)return this.decrypt(t,this.deprecatedDefaultKey);throw Error("Decryption error")}decryptBinary(t,e){const s=(new TextDecoder).decode(new Uint8Array(t,0,4));let i,n,o,r,a;switch("string"==typeof e&&(e=Tn.parse(e)),s){case"CRQ0":i=(new TextDecoder).decode(t),n=Tn.parse(i.slice(4,28)),o=Tn.parse(i.slice(28,72)),r=i.slice(72),a=Nn.decrypt(r,e,{iv:n});break;case"CRQ1":i=new Uint8Array(t),n=Z.create(i.subarray(4,20)),o=Z.create(i.subarray(20,52)),r=Z.create(i.subarray(52)),a=Nn.decrypt({ciphertext:r},e,{iv:n});break;default:throw Error(`${this.id} unknown encryption version ${s}`)}a.clamp();const l=_n(a,e);if(this.compareHmacs(o.words,l.words))return S(a);if(e!==this.deprecatedDefaultKey)return this.decryptBinary(t,this.deprecatedDefaultKey);throw Error("Decryption error")}async encryptMessage(t,e,s){const[i,n,o]=t.asState();return[i,n,await this.encryptPayload([o,e,s])]}async encryptPayload(t){return this.encrypt(JSON.stringify(t))}decryptPayload(t){return JSON.parse(this.decrypt(t))}compareHmacs(t,e){let s=t.length===e.length;for(let i=0;i<t.length;i++)t[i]!==e[i]&&(s=!1);return s}sendMessage(t){if(this.viewOnly||!this.vm)return;const e=t.asState()[2].length;if(e>16384)return void console.warn(this.id,`Message with payload of ${e} bytes exceeds maximum 16384 and will not be sent to reflector.`);!this.payloadSizeWarned&&e>fl&&(console.log(this.id,`Message with payload of ${e} bytes being sent to reflector. Maximum recommended is 4096.`),this.payloadSizeWarned=!0);const s=Date.now(),i=this.rateLimitedSendTimes,n=this.rateLimitBuffer;if(ot.perSecondTally({requestedMessages:1}),n.length)return void this.addToRateLimitBuffer(t);let o=0;if(i.length&&this.synced){const t=i[i.length-1],e=1e3/this.eventRateLimit-(s-t);e>1&&(o=Math.ceil(e))}o?(this.addToRateLimitBuffer(t),setTimeout((()=>this.serviceRateLimitBuffer()),o)):(this.recordRateLimitedSend(s),this.socketSendMessage(t),ot.perSecondTally({sentSingleMessages:1,sentMessagesTotal:1,sentPayloadTotal:e}))}recordRateLimitedSend(t){const e=this.rateLimitedSendTimes;!this.synced&&e.length&&e[e.length-1]===t||(e.push(t),e.length>this.eventHistoryLimit&&e.shift()),!this.rateLimitSoftWarned&&e.length===this.eventHistoryLimit&&t-e[0]<1010&&(console.warn(this.id,`Sends to reflector are at or above recommended limit of ${this.eventHistoryLimit} within one second. Events will be bundled as necessary to keep to the limit.`),this.rateLimitSoftWarned=!0)}addToRateLimitBuffer(t){ot.perSecondTally({bundledMessages:1});const e=Date.now(),s=t.asState(),i=s[2].length,n=this.rateLimitBuffer;if(n.length){const t=n[n.length-1],{msgStates:o,totalPayload:r}=t;if(r<fl)return o.push({msgState:s,bufferTime:e}),void(t.totalPayload+=i)}ot.perSecondTally({newBundles:1}),n.push({msgStates:[{msgState:s,bufferTime:e}],totalPayload:i});const o=n.length;dl.session&&o%5==0&&o!==this.rateLimitLastLogged&&(console.log(this.id,`SEND rate-limit buffer grew to ${o} event bundles (max ${this.eventMaxBundles})`),this.rateLimitLastLogged=o),o>this.eventMaxBundles?(console.error(this.id,"Disconnecting after overflow of SEND rate-limit buffer."),this.connection.closeConnectionWithError("SEND",Error("Send rate exceeded"),4200)):!this.rateLimitBufferWarned&&o>this.eventMaxBundles/2&&(console.warn(this.id,"SEND rate-limit buffer is 50% full. If send rate does not drop, the app will be disconnected."),this.rateLimitBufferWarned=!0)}serviceRateLimitBuffer(){if(!this.connected)return;const t=this.rateLimitBuffer;if(!t.length)return;const e=Date.now(),s=1e3/this.eventRateLimit,i=this.rateLimitedSendTimes;if(i.length){const t=i[i.length-1];if(s-(e-t)>0)return}const n=t.shift(),{msgStates:o,totalPayload:r}=n,a=[];let l=0;if(o.forEach((t=>{a.push(t.msgState),l+=e-t.bufferTime})),1===a.length){const t=tc.fromState(a[0],this.vm);this.socketSendMessage(t)}else{const t=new tc(this.vm.time,0,"_","handleBundledEvents",[a]);this.socketSendMessage(t)}if(this.recordRateLimitedSend(e),ot.perSecondTally({sentBundles:1,sentMessagesTotal:o.length,sendDelay:l,sentBundlePayload:r,sentPayloadTotal:r}),dl.session&&this.connected){const e=t.length;e&&e%5==0&&e!==this.rateLimitLastLogged&&(console.log(this.id,`SEND rate-limit buffer dropped to ${e} event bundles`),this.rateLimitLastLogged=e)}t.length&&setTimeout((()=>this.serviceRateLimitBuffer()),s)}async socketSendMessage(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=await this.encryptMessage(t,this.viewId,Date.now()),i=dl.sends&&(e?`tagged SEND ${t.asState()} with tags ${JSON.stringify(e)}`:`SEND ${t.asState()}`);if(!this.connected)return void(this.vm&&(dl.sends&&console.log(this.id,`buffering ${i}`),this.sendBuffer.push((()=>this.socketSendMessage(t,e)))));dl.sends&&console.log(this.id,`sending ${i}`);const n={id:this.id,action:"SEND",args:[...s,this.latency]};e&&(n.tags=e),this.lastSent=Date.now(),this.connection.send(JSON.stringify(n))}async sendTagged(t,e){this.viewOnly||this.socketSendMessage(t,e)}async sendTutti(t){let{time:e,topic:s,data:i,localContext:n=null,firstMessage:o=null,wantsVote:r=!0,tallyTarget:a=null}=t;if(this.viewOnly)return;const l=o&&await this.encryptMessage(o,this.viewId,Date.now()),c=y(i);if(!this.connected)return void(this.vm&&(dl.sends&&console.log(this.id,`buffering "${s}" TUTTI ${c} ${o&&o.asState()}`),this.sendBuffer.push((()=>this.sendTutti({time:e,topic:s,data:i,localContext:n,firstMessage:o,wantsVote:r,tallyTarget:a})))));dl.sends&&console.log(this.id,`sending "${s}" TUTTI ${c} ${o&&o.asState()}`),this.lastSent=Date.now();const d=`${s}@${e}`;this.connection.send(JSON.stringify({id:this.id,action:"TUTTI",args:[e,0,c,l,r,a,d]})),this.tuttiHistory.length>100&&this.tuttiHistory.shift(),this.tuttiHistory.push({time:e,tuttiKey:d,dummyTuttiSeq:0,payload:c,localContext:n})}sendLog(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];this.connected?(dl.sends&&console.log(this.id,"sending LOG"),e.length<2&&(e=e[0]),this.connection.send(JSON.stringify({action:"LOG",args:e}))):this.vm&&(dl.sends&&console.log(this.id,"buffering LOG"),this.sendBuffer.push((()=>this.sendLog(...e))))}addToStatistics(t,e){this.latency=e-t,this.latencyHistory&&(this.latencyHistory.length>=100&&this.latencyHistory.shift(),this.latencyHistory.push({time:e,ms:this.latency}))}get latencies(){return this.latencyHistory||(this.latencyHistory=[]),this.latencyHistory}getTickAndMultiplier(){const t=this.sessionSpec.options,e=["number","string"].includes(typeof t.tps)?t.tps:["number","string"].includes(typeof this.sessionSpec.tps)?this.sessionSpec.tps:20,[s,i]=(e+"x").split("x").map((t=>Number.parseFloat("0"+t))),n=1e3/Math.max(1/30,Math.min(60,s)),o=Math.max(1,i);let r=n,a=0;return o>1&&!ul&&(r=n/o,a=Math.ceil(r*(o-1))),{msPerTick:r,multiplier:o,tick:n,delay:a}}simulate(t){if(!this.vm)return!0;try{let e=!0;if(this.networkQueue.length+this.vm.messages.size===0)e=this.vm.advanceTo(this.reflectorTime,t);else{const s=ot.begin("simulate");for(;e;){const s=this.networkQueue[0];if(!s)break;if(e=this.vm.advanceTo(s[0],t),!e)break;this.networkQueue.shift();const i=this.vm.scheduleExternalMessage(s);e=this.vm.advanceTo(i.time,t),this.cpuTime+=5}e&&(e=this.vm.advanceTo(this.reflectorTime,t)),this.cpuTime+=Math.max(.01,ot.end("simulate")-s)}ot.backlog(this.backlog);const s=this.lag,i=Math.max(200,.1*this.msPerTick),n=Math.max(2e3,.2*this.msPerTick);if("boolean"==typeof this.synced&&this.viewed&&(this.synced&&s>n||!this.synced&&s<i)){!this.synced?this.syncTimer||(this.syncTimer=setTimeout((()=>{delete this.syncTimer,this.connected&&this.lag<i&&this.applySyncChange(!0)}),200)):this.applySyncChange(!1)}return dl.offline||(this.synced&&e&&this.cpuTime>5e3?(this.triggeringCpuTime=this.cpuTime,this.cpuTime=0,this.isBeingAnimated()?setTimeout((()=>this.scheduleSnapshot()),Math.floor(2e3*Math.random())):this.scheduleSnapshot()):this.reflectorNeedsSnapshot&&(this.triggeringCpuTime=this.synced?this.cpuTime:12345,this.scheduleSnapshot(!0),this.reflectorNeedsSnapshot=!1)),e}catch(t){return yt("simulate",t),this.connection.closeConnectionWithError("simulate",t),"error"}}stepSession(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=ot.stepSession(e.frameTime,!0);s&&console.log(s);const{backlog:i,latency:n,starvation:o,activity:r}=this;if("animation"===t){ot.animationFrame(e.frameTime,{backlog:i,starvation:o,latency:n,activity:r,users:this.users});const t=Date.now();if(this.lastAnimationEnd){const e=t-this.lastAnimationEnd;if(!0===this.animationGapCheck&&e>200&&(this.animationGapCheck=[],dl.session&&console.log(this.id,"animation has stopped (too long between steps)")),!0!==this.animationGapCheck){const t=this.animationGapCheck;t.push(e),t.length>4&&t.shift(),4===t.length&&t.reduce(((t,e)=>t+e),0)<=400&&(this.animationGapCheck=!0,dl.session&&console.log(this.id,"animation has started"))}}this.lastAnimationEnd=t}if(!this.connected)return void(this.isInBackground()||this.checkForConnection(!0));if(!this.vm)return;let a;switch(t){case"animation":{const t=e.expectedSimFPS,s=Date.now(),i=pl.reduce(((t,e)=>t+e),0)/pl.length;if(a=this.simulate(s+Math.min(i,ml)),!1===a){const e=0===t?0:1e3/t*4;this.backlog>e&&(a=this.simulate(s+ml-i))}"error"!==a&&(pl.push(Date.now()-s),pl.length>4&&pl.shift());break}case"fastForward":case"background":a=this.simulate(Date.now()+e.budget);break;default:console.warn(t)}this.fastForwardHandler&&this.fastForwardHandler(a),"error"!==a&&(ot.begin("update"),this.processModelViewEvents("animation"===t),ot.end("update"),this.serviceRateLimitBuffer(),"animation"===t&&(e.view&&(ot.begin("render"),this.inViewRealm((()=>e.view.update(e.frameTime))),ot.end("render")),this.lastAnimationEnd=Date.now()))}applySyncChange(t){dl.session&&console.log(this.id,`synced=${t}`),this.synced=t,Vt.showSyncWait(!t),this.vm.publishFromView(this.viewId,"synced",t)}inViewRealm(t){return _t(this.vm,(()=>t(this.vm)))}processModelViewEvents(t){return this.vm?this.vm.processModelViewEvents(t):0}timeFromReflector(t,e,s){t<this.reflectorTime?("controller"!==e||dl.ticks)&&console.warn(`time is ${this.reflectorTime}, ignoring time ${t} from ${e}`):("boolean"!=typeof this.synced&&(this.synced=!1),this.reflectorTime=t,this.extrapolatedTimeBase=Date.now()-t,this.vm&&ot.backlog(this.backlog),this.tickHook&&this.tickHook(t,s))}multiplyTick(t){this.localTicker&&globalThis.clearInterval(this.localTicker);const e=this.msPerTick,s=this.tickMultiplier;let i=1;this.localTicker=globalThis.setInterval((()=>{this.timeFromReflector(Math.round(t+i*e),"controller"),dl.ticks&&console.log(this.id,"Controller generate TICK "+this.reflectorTime,i),++i>=s&&(globalThis.clearInterval(this.localTicker),this.localTicker=0)}),e)}startStepping(t){const e=s=>{this.leaving||(this.isOutOfSight()||t(s),window.requestAnimationFrame(e))};window.requestAnimationFrame(e)}setUpActivityChecks(){let t=null;if(this.isOutOfSight=()=>!(nl||"hidden"!==document.visibilityState&&t),this.isBeingAnimated=()=>{const t=!0===this.animationGapCheck,e=Date.now()-this.lastAnimationEnd<200;return t&&!e&&(this.animationGapCheck=[],dl.session&&console.log(this.id,"animation has stopped (too long since last step)")),t&&e},this.isInBackground=()=>this.isOutOfSight()||!this.isBeingAnimated(),!nl){new IntersectionObserver(((e,s)=>t=e[0].isIntersecting)).observe(document.body)}const e=this.sessionSpec.autoSleep;let s;if(e){const t=1e3*e;let i=0,n=0;s=()=>{const e=Date.now();e-i<980||(i=e,this.isOutOfSight()?n?e-n>t&&(this.dormantDisconnect(),n=0):n=e:n=0)}}const i=()=>{this.leaving?n&&(clearInterval(n),n=null):this.connected&&this.vm&&(s&&s(),this.isBeingAnimated()||this.connection.keepAlive(Date.now()))};let n=setInterval(i,1e3);this.simulateIfNeeded=()=>{if(!this.isBeingAnimated()&&(i(),!this.fastForwardHandler&&this.connected)){let t=.9*this.msPerTick;e&&(t=Math.min(t,ml));const s=this.synced?"background":"fastForward";this.stepSession(s,{budget:t})}}}toString(){return`Controller[${this.id}]`}[Symbol.toPrimitive](){return this.toString()}}class Xl{constructor(t){this.controller=t,this.socketLastSent=0,this.connectBlocked=!1,this.connectRestricted=!1,this.connectHasBeenCalled=!1,this.reconnectDelay=0,this.missingTickThreshold=1/0}get id(){return this.controller.id}setTick(t){this.missingTickThreshold=Math.min(3*t,45e3)}get connected(){return!(!this.socket||this.socket.readyState!==WebSocket.OPEN)}checkForConnection(t){this.socket||this.connectHasBeenCalled||this.connectBlocked||this.connectRestricted&&!t||this.connectToReflector()}connectToReflector(){if(this.socket||this.connectHasBeenCalled)return;let t;if(this.connectHasBeenCalled=!0,this.connectBlocked=!1,this.connectRestricted=!1,dl.offline)t=new Ba;else{let e=hl(this.controller.sessionSpec.apiKey).reflector;const s=nl?void 0:window.location.href,i={},n=this.controller.sessionSpec.token;if(n&&(i.token=n),a.reflector){const t=a.reflector.toUpperCase();"CF"===t||t.match(/^[A-Z]{3}$/)?(e=dl.reflector?"wss://croquet.network/reflector/dev/":"wss://croquet.network/reflector/",3===t.length&&(i.colo=t)):a.reflector.match(/^[-a-z0-9]+$/i)?i.region=a.reflector:e=new URL(a.reflector,s).href.replace(/^http/,"ws")}if(!e.match(/^wss?:/))throw Error("Cannot interpret reflector address "+e);e.endsWith("/")||(e+="/");const o=new URL(e+this.id,s);for(const[t,e]of Object.entries(i))o.searchParams.append(t,e);t=new WebSocket(o)}t.onopen=e=>{const s=this.socket;s&&(s.onopen=s.onmessage=s.onerror=s.onclose=null),this.socket=t,this.connectHasBeenCalled=!1,dl.session&&console.log(this.id,this.socket.constructor.name,"connected to",this.socket.url),this.reconnectDelay=0,ot.connected(!0),this.controller.sendJoin()},t.onmessage=e=>{ot.addNetworkTraffic("reflector_in",e.data.length),t===this.socket&&this.receive(e.data)},t.onerror=e=>{dl.session&&console.log(this.id,t.constructor.name,"connection error"),this.connectHasBeenCalled=!1,this.controller.clearSyncReceiptTimeout()},t.onclose=t=>{this.socketClosed(t.code,t.reason)}}socketClosed(t,e){this.controller.clearSyncReceiptTimeout();const s=1e3!==t&&t<4100,i=4110===t;i||1e3===t||this.reconnectDelay||setTimeout((()=>{this.connected||Vt.showMessage(`Connection closed: ${t} ${e}`,{level:s?"error":"fatal"})}),500),dl.session&&console.log(this.id,`${this.socket?this.socket.constructor.name+" closed":"closed before opening,"} with code: ${t} ${e}`),ot.connected(!1),i?this.connectRestricted=!0:this.connectBlocked=!0,this.disconnected(),s&&(dl.session&&console.log(this.id,`reconnecting in ${this.reconnectDelay} ms`),this.reconnectTimeout=globalThis.setTimeout((()=>{delete this.reconnectTimeout,this.connectToReflector()}),this.reconnectDelay),this.reconnectDelay=Math.min(3e4,Math.round((this.reconnectDelay+100)*(1+Math.random()))))}disconnected(){this.socket&&(this.socket=null,this.lastReceived=0,this.socketLastSent=0,this.stalledSince=0,this.connectHasBeenCalled=!1,this.controller.connectionInterrupted())}send(t){this.socketLastSent=Date.now(),this.socket.send(t),ot.addNetworkTraffic("reflector_out",t.length)}receive(t){this.lastReceived=Date.now();const{id:e,action:s,args:i}=JSON.parse(t);if(e)try{this.controller.receive(s,i)}catch(t){this.closeConnectionWithError("receive",t)}else if("PONG"===s){if(dl.pong&&console.log("PONG after",Date.now()-i,"ms"),this.pongHook)try{this.pongHook(i)}catch(t){console.error(t)}}else console.warn("Unknown action",s)}dormantDisconnect(){this.connected&&(dl.session&&console.log(this.id,"dormant; disconnecting from reflector"),this.closeConnection(4110,"Going dormant"))}closeConnectionWithError(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4e3;console.error(e),console.warn("closing socket"),s>=4100&&4110!==s&&(this.controller.leaving=()=>{}),this.closeConnection(s,`Error in ${t}: ${e.message||e}`)}closeConnection(t,e){this.socket&&(this.socket.onclose=null,this.socket.close(t,e),this.socketClosed(t,e))}PULSE(t){this.connected&&(0===this.socket.bufferedAmount?(this.send(JSON.stringify({action:"PULSE"})),this.stalledSince=0):this.stalledSince&&t-this.stalledSince>500?console.log(this.id,`Reflector connection stalled: ${this.socket.bufferedAmount} bytes unsent for ${t-this.stalledSince} ms`):this.stalledSince=Date.now())}keepAlive(t){0!==this.lastReceived&&(t-this.socketLastSent>25e3?this.PULSE(t):t-this.lastReceived>5e4?this.closeConnectionWithError("connection",Error("Reflector has gone away")):t-this.lastReceived>this.missingTickThreshold&&this.PULSE(t))}PING(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now();this.connected&&this.send(JSON.stringify({action:"PING",args:t}))}}globalThis.setInterval((()=>{for(const t of wl)t.connected&&t.vm&&t.connection.keepAlive(Date.now())}),100);const Ll=Symbol("hash"),xl=Symbol("key"),Sl=Symbol("url"),Gl=new Map;let kl=0;function Wl(t){return a.has("debug",t,!1)}function Tl(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function Cl(t){return t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+3&-4,"=")}function Pl(t,e){return t||(t="*"),e.replace(/[\s\S]/g,(e=>String.fromCharCode(e.charCodeAt(0)^t.charCodeAt(0))))}class Vl{async store(){throw Error("Data.store() needs to be called from session.data")}async fetch(){throw Error("Data.fetch() needs to be called from session.data")}static async store(t,e,s){if(Al.hasCurrent())throw Error("Croquet.Data.store() called from Model code");let i,n,o;if("string"==typeof t?(i=t,t=e,n=!0,o=s):(i=e&&e.sessionId,n=e&&e.shareable,o=e&&e.keep),!(t instanceof ArrayBuffer))throw Error("Croquet.Data.store() called with non-ArrayBuffer data");const{appId:r,persistentId:a,key:l,uploadEncrypted:c}=Zl(i),d=n?Z.random(32).toString(Tn):Tn.stringify(l),h=`apps/${r}/${a}/data/%HASH%`,u="data#"+ ++kl;Wl("data")&&console.log(`Croquet.Data: storing ${u} ${t.byteLength} bytes`);const m=await c({path:h,content:t,key:d,keep:o,debug:Wl("data"),what:u}),p=function(t){return t.replace(/.*\//,"")}(m),f=new Rl(p,n&&d,m);return Wl("data")&&console.log(`Croquet.Data: stored ${u} as ${this.toId(f)}`),f}static async fetch(t,e){let s;if(e&&e[Sl]?(s=t,t=e):s=e&&e.sessionId,Al.hasCurrent())throw Error("Croquet.Data.fetch() called from Model code");const{downloadEncrypted:i,key:n}=Zl(s),o=t&&t[Ll],r=t&&t[xl]||Tn.stringify(n),a=t&&t[Sl];if("string"!=typeof o||"string"!=typeof r||"string"!=typeof a)throw Error("Croquet.Data.fetch() called with invalid handle");const l="data#"+ ++kl;return Wl("data")&&console.log(`Croquet.Data: fetching ${l} ${this.toId(t)}`),i({url:a,key:r,debug:Wl("data"),what:l})}static hash(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"base64url";"function"==typeof t&&(t=Function.prototype.toString.call(t)),"string"==typeof t?t=(new TextEncoder).encode(t):t&&t.constructor===DataView?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t&&t.constructor===ArrayBuffer?t=new Uint8Array(t):ArrayBuffer.isView(t)||(t=(new TextEncoder).encode(y(t)));const s=X(Z.create(t));switch(e){case"hex":return s.toString();case"base64":return s.toString(Tn);case"base64url":return Tl(s.toString(Tn));default:throw Error(`Croquet.Data: unknown hash output "${e}", expected "hex"/"base64"/"base64url"`)}}static fromId(t){const e=t.slice(0,1);let s,i,n,o;switch(e){case"0":s=t.slice(1,44),i=t.slice(44),n=`${cl}/sessiondata/${s}`;break;case"1":s=t.slice(1,44),i=t.slice(44,87)+"=",o=t.slice(87),n=`${cl}/apps/${o}/data/${s}`;break;case"2":s=t.slice(1,44),i=Cl(t.slice(44,87)),o=Pl(i,atob(Cl(t.slice(87)))),n=`${cl}/apps/${o}/data/${s}`;break;case"3":i=Cl(t.slice(1,44)),n=Pl(i,atob(Cl(t.slice(44)))),s=n.slice(-43);break;case"4":i=null,n=Pl(i,atob(Cl(t.slice(1)))),s=n.slice(-43);break;default:throw Error(`Croquet.Data expected handle v0-v4 got v${e}`)}return new this(s,i,n)}static toId(t){if(!t)return"";const e=t[Ll],s=t[xl],i=t[Sl];if(i.slice(-43)!==e)throw Error("Croquet Data: malformed URL");const n=s&&Tl(s),o=Tl(btoa(Pl(s,i)));return s?`3${n}${o}`:`4${o}`}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2?arguments[2]:void 0;const i=Gl.get(t);if(i)return i;if(s.slice(-43)!==t)throw Error("Croquet Data: malformed URL");Object.defineProperty(this,Ll,{value:t}),e&&Object.defineProperty(this,xl,{value:e}),Object.defineProperty(this,Sl,{value:s}),Gl.set(t,this)}}class Rl extends Vl{}const Yl={cls:Rl,write:t=>Rl.toId(t),read:t=>Rl.fromId(t)};let Ml=null,Il=null;const Hl=Symbol("DEBUG_WRITE_TARGET");let Kl=null;function zl(t,e){return Array.isArray(t)||"string"!=typeof e?`[${e}]`:e.match(/^[a-z_$][a-z0-9_$]*$/i)?`.${e}`:`["${e}"]`}class Nl extends Error{}function Fl(){if(!globalThis.CroquetViewMath){globalThis.CroquetMath.random=()=>Ml.random(),globalThis.CroquetViewMath={};for(const[t,e]of Object.entries(Object.getOwnPropertyDescriptors(Math)))globalThis.CroquetViewMath[t]=e.value;for(const[s,i]of Object.entries(globalThis.CroquetMath)){const n=Math[s];Math[s]=1===i.length?t=>Ml?i(t):n(t):(t,e)=>Ml?i(t,e):n(t,e)}}if(!globalThis.CroquetViewDate){const o=globalThis.Date;let r=!1;function a(t,e){return r||(r=!0,console.warn(new Nl(`${t} used in Model code`))),e}function l(t,e,s,i,n,r,c){const d=this instanceof l,h=[t,e,s,i,n,r,c];if(h.length=arguments.length,Ml)switch(a(d?"new Date()":"Date()"),arguments.length){case 0:h.push(Ml.time);break;case 1:break;default:h[0]=o.UTC(...h),h.length=1}const u=new o(...h);return d?u:""+u}l.prototype=o.prototype,l.UTC=o.UTC,l.now=()=>Ml?a("Date.now()",Ml.time):o.now(),l.parse=function(){return Ml?a("Date.parse()",0):o.parse(...arguments)},globalThis.CroquetViewDate=o,globalThis.Date=l}}Object.defineProperty(Nl.prototype,"name",{value:"CroquetWarning"});const _l={};function jl(t,e){const{qPara:s,qArgs:i,qFn:n}=JSON.parse(atob(t.slice(1,-1))),o=JSON.stringify(s),r=_l[o]||(_l[o]=new Function(...s));return"number"==typeof n&&(i[n]=r),r.call(e,...i).bind(e)}function Ql(t,e){if(Ml)throw Error("VirtualMachine confusion");if(!(t instanceof Al))throw Error("not a VM: "+t);const s=Ml;try{Ml=t,globalThis.CROQUETVM=t,e()}finally{Ml=s}}const El="#reflected",Jl=["handleModelEventInModel","handleBundledEvents","publishFromModelOnly","handlePollForSnapshot","handleTuttiResult","handleTuttiDivergence","handleSnapshotVote","handlePersistVote","handleModelEventInView","noop"],Ul={};for(let t=0;t<Jl.length;t++)Ul[Jl[t]]=t;const Dl=new WeakMap;function Ol(t){Dl.set(t,null)}class Bl{random(){throw Error("Math.random() cannot be used in Model.evaluate()")}}class Al{static current(){return Ml||console.warn("VirtualMachine.current() called from outside the vm!"),Ml}static hasCurrent(){return!!Ml}static evaluate(t){if(Ml)return t();Fl();const e=Ml;try{return Ml=new Bl,t()}finally{Ml=e}}constructor(t,e){Fl(),Il={snapshot:a.has("debug","snapshot",!1),session:a.has("debug","session",!1),write:a.has("debug","write",!1)},Ol(this),Ql(this,(()=>{Ft(this,(()=>{if(this.modelsById={},this.modelsByName={},this.messages=new kn(((t,e)=>t.before(e))),this.subscriptions={},this.subscribers=new Map,this.views={},this._random=()=>{throw Error("You must not use random when applying state!")},this.id=t.id,this.time=0,this.seq=4294967280,this.externalTime=0,this.externalSeq=this.seq,this.futureSeq=0,this.lastSnapshotPoll=0,this.lastPersistencePoll=0,this.inPersistenceCoolOff=!1,this.persisted="",this.modelsId=0,this.diverged=null,this.controller=null,t.modelsById){const e=oc.newOrRecycled(this).readVM(t,"vm");let s=[];for(const t of Object.keys(e))t in this||"meta"===t?"_random"===t?this[t]=new f(null,{state:e[t]}):"messages"===t?s=e.messages:this[t]=e[t]:console.warn(`Ignoring property snapshot.${t}`);for(const t of s)this.messages.add(t);for(const[t,e]of Object.entries(this.subscriptions))for(const s of e){const[e]=s.split(".");let i=this.subscribers.get(e);i||this.subscribers.set(e,i=new Set),i.add(t)}}else this._random=new f(t.id,{state:!0}),this.addSubscription(this,"__VM__","__peers__",this.generateJoinExit),this.addSubscription(this,"__VM__","__diverged__",this.handleSessionDiverged),e(this)}))}))}registerModel(t,e){if(Ml!==this)throw Error("You can only create models from model code!");return e||(e="M"+ ++this.modelsId),this.modelsById[e]=t,e}deregisterModel(t){if(Ml!==this)throw Error("You can only destroy models from model code!");const e=this.modelsById;delete this.modelsById[t];for(const[t,s]of Object.entries(this.modelsByName))e===s&&delete this.modelsByName[t];this.messages.removeMany((e=>e.hasReceiver(t)))}lookUpModel(t){if("_"===t)return this;let e=this.modelsById[t];if(e)return e;const[s,i,n]=t.match(/^([^#]+)#(.*)$/)||[];return e=this.modelsById[i],e&&e.lookUp(n)}get(t){const e=this.modelsByName[t];return Ml!==this&&Il.write&&e?this.debugWriteProxy(this,e,e.id):e}set(t,e){if(Ml!==this)throw Error("You can only make a model well-known from model code!");this.modelsByName[t]=e}debugWriteProxy(t,e,s){if("object"!=typeof e||null===e||e[Hl])return e;if(e instanceof mc&&(s=e.id),!this.$debugWriteProxyHandler){function n(t,e,s){s&&(t+=` ${s} of`);const i=Kl.get(e).path;if(console.warn(`write-debug: non-model code is ${t} ${i}:`,e),s&&"$"!==s[0])throw Error("write-debug: Attempt to modify Croquet model state from outside!")}Kl||(Kl=new WeakMap),this.$debugWriteProxyHandler={set(e,s,i){Ml!==t?n("assigning",e,s):console.warn("Croquet debug write protection inside model - this should not happen!"),e[s]=i},deleteProperty(e,s){Ml!==t?n("deleting",e,s):console.warn("Croquet debug write protection inside model - this should not happen!"),delete e[s]},get(e,s){if(s===Hl)return e;const i=e[s];if(i&&i[Hl])return i;if(Ml!==t){if("object"==typeof i&&null!==i){const o=Kl.get(e).path;if(i instanceof Map){const e=new Map([...i.entries()].map(((e,s)=>{let[i,n]=e;return[t.debugWriteProxy(t,i,`${o}.key#${s}`),t.debugWriteProxy(t,n,`${o}.value#${s}`)]})));return e[Hl]=i,e.set=()=>n("setting an item in",i),e.delete=()=>n("deleting from",i),e.clear=()=>n("clearing",i),Kl.set(i,{proxy:e,path:o+zl(i,s)}),e}if(i instanceof Set){const e=new Set([...i.values()].map(((e,s)=>t.debugWriteProxy(t,e,`${o}.item#${s}`))));return e[Hl]=i,e.add=()=>n("adding to",i),e.delete=()=>n("deleting from",i),e.clear=()=>n("clearing",i),Kl.set(i,{proxy:e,path:o+zl(i,s)}),e}return t.debugWriteProxy(t,i,o+zl(i,s))}}else console.warn("Croquet debug write protection inside model - this should not happen!");return i}}}let i=Kl.get(e);return i||(i={proxy:new Proxy(e,this.$debugWriteProxyHandler),path:s},Kl.set(e,i)),i.proxy}noop(){}generateJoinExit(t){let{entered:e,exited:s,count:i}=t;const n={};for(const t of e){if(!Array.isArray(t))continue;const e=t[1]||{};e.region&&(e.country=e.region.slice(0,2),e.region=e.region.slice(2)),n[t[0]]={loc:e}}if(e=e.map((t=>Array.isArray(t)?t[0]:t)),s=s.map((t=>Array.isArray(t)?t[0]:t)),e.length===i){s=Object.keys(this.views);for(const t of s)this.views[t].extraConnections=0}if(0!==e.length&&0!==s.length){const t=e.filter((t=>s.includes(t)));if(0!==t.length&&(e=e.filter((e=>!t.includes(e))),s=s.filter((e=>!t.includes(e))),0===e.length&&0===s.length))return}for(const t of s)if(this.views[t]){if(this.views[t].extraConnections){this.views[t].extraConnections--,Il.session&&console.log(this.id,`@${this.time}#${this.seq} view ${t} closed extra connection`);continue}delete this.views[t],this.publishFromModelOnly(this.id,"view-exit",t)}else{const{time:e,seq:s}=this;console.error(`${this.id} @${e}#${s} view ${t} exited without being present - this should not happen`),Promise.resolve().then((()=>{this.controller.sendLog(`view-exit-mismatch @${e}#${s} ${t} left without being present`)}))}for(const t of e)this.views[t]?(Il.session&&console.log(this.id,`@${this.time}#${this.seq} view ${t} opened another connection`),this.views[t].extraConnections=(this.views[t].extraConnections||0)+1):(this.views[t]=n[t]||{},this.publishFromModelOnly(this.id,"view-join",t));const o=Object.values(this.views).reduce(((t,e)=>t+1+(e.extraConnections||0)),0);if(i!==o){const{time:t,seq:e}=this;console.error(`@${t}#${e} view count mismatch (model: ${o}, reflector: ${i}) - this should not happen`),Promise.resolve().then((()=>{this.controller.sendLog(`view-exit-mismatch @${t}#${e} connections model: ${o} reflector: ${i}`)}))}}scheduleExternalMessage(t){const e=tc.fromState(t,this);if(e.time<this.time)throw Error("past message from reflector "+t);const s=this.externalSeq+1>>>0;if(e.seq!==s)throw Error(`External message error. Expected message #${s} got #${e.seq}`);return this.externalTime=e.time,this.externalSeq=e.seq,e.seq=2*e.seq+1,this.verifyExternal(e),this.messages.add(e),e}verifyExternal(t){if("_"!==t.receiver)throw Error(`invalid receiver in external message: ${t}`);if(!(t.selector in Ul))throw Error(`unexpected external message: ${t.selector}`)}futureSend(t,e,s,i){if(t.every)return this.futureRepeat(t.every,e,s,i);if(t<0)throw Error("attempt to send future message into the past");this.futureSeq=this.futureSeq+1>>>0;const n=new tc(this.time+t,2*this.futureSeq,e,s,i);return this.messages.add(n),{time:n.time,seq:n.seq}}cancelFuture(t,e){const s=this.messages;let i;if("number"==typeof e.time){const{time:t,seq:n}=e;i=s.removeOne((e=>e.time===t&&e.seq===n))}else{if("*"===e)return i=s.removeMany((e=>e.receiver===t.id)),i.length>0;{const n=this.asQFunc(t,e,"cancelFuture message"),o=t.id;i=s.removeOne((t=>t.receiver===o&&t.selector===n||"_"===t.receiver&&"futureExecAndRepeat"===t.selector&&t.args[1]===o&&t.args[2]===n))}}return void 0!==i}futureRepeat(t,e,s,i){this.futureSend(t,"_","futureExecAndRepeat",[t,e,s,i])}futureExecAndRepeat(t,e,s,i){const n=this.lookUpModel(e);if(n){if("function"==typeof n[s])try{n[s](...i)}catch(t){yt(`future message ${n}.${s}`,t)}else{const t=jl(s,n);try{t(...i)}catch(e){yt(`future message ${n} ${t}`,e)}}this.futureRepeat(t,e,s,i)}}future(t,e,s,i){if(!this.lookUpModel(t.id))throw Error(`future send to unregistered model ${t}`);if(void 0===s){const s=this;return new Proxy(t,{get:(i,n)=>function(){for(var i=arguments.length,o=new Array(i),r=0;r<i;r++)o[r]=arguments[r];return s.future(t,e,n,o)}})}const n=this.asQFunc(t,s,"future message");if("string"!=typeof n)throw Error(`future message to ${t} ${n} is not a string`);if("function"!=typeof t[n]&&n.indexOf(".")<0&&"{"!==n[0])throw Error(`future send to ${t} with unknown method ${n}()`);return this.futureSend(e,t.id,n,i)}advanceTo(t,e){if(Ml)throw Error("cannot advance time from model code");let s;for(;(s=this.messages.peek())&&s.time<=t;){const{time:t,seq:i}=s;if(t<this.time)throw Error("past message encountered: "+s);if(1&i&&(this.seq=this.seq+1>>>0,i/2>>>0!==this.seq))throw Error(`Sequence error: expected ${this.seq} got ${i/2>>>0} in ${s}`);if(this.messages.poll(),this.time=s.time,s.executeOn(this),globalThis.CroquetViewDate.now()>=e)return!1}return this.time=t,!0}asQFunc(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"subscription handler";if("string"==typeof e)return e;if("function"==typeof e){if(t[e.name]===e)return e.name;let i=t;for(;null!==i;){for(const[t,s]of Object.entries(Object.getOwnPropertyDescriptors(i)))if(s.value===e)return t;i=Object.getPrototypeOf(i)}ft(`${s} is not a method of ${t}: ${e}\n`,{only:"once"});const n=/^\(?([a-z][a-z0-9]*)?\)? *=> *this\.([a-z][a-z0-9]*) *\( *([a-z][a-z0-9]*)? *\) *$/i,o=e.toString().match(n);return!o||o[3]&&o[3]!==o[1]?function(t,e){"function"==typeof t&&(e=t,t={});const s=Object.keys(t).concat(["return "+e]),i=Object.values(t),n={qPara:s,qArgs:i},o=i.indexOf(e);return o>=0&&(i[o]=s[o],n.qFn=o),`{${btoa(JSON.stringify(n))}}`}(e):o[2]}return null}addSubscription(t,e,s,i){if(Ml!==this)throw Error("Cannot add a model subscription from outside model code");const n=this.asQFunc(t,i);if("string"!=typeof n)throw Error(`Subscription handler for "${s}" must be a method name`);if(n.indexOf(".")<0&&"function"!=typeof t[n]&&"{"!==n[0])throw Error(`Subscriber method for "${s}" not found: ${t}.${n}()`);const o=e+":"+s,r=t===this?"_":t.id,a=r+"."+n;if(this.subscriptions[o]){if(-1!==this.subscriptions[o].indexOf(a))throw Error(`${t}.${n} already subscribed to ${s}`)}else this.subscriptions[o]=[];this.subscriptions[o].push(a);let l=this.subscribers.get(r);l||this.subscribers.set(r,l=new Set),l.add(o)}removeSubscription(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"*";if(Ml!==this)throw Error("Cannot remove a model subscription from outside model code");const n=e+":"+s,o=this.subscriptions[n];if(o){const e=t.id+".";if("*"===i){for(let t=o.length-1;t>=0;t--)o[t].startsWith(e)&&o.splice(t,1);0===o.length&&delete this.subscriptions[n]}else{const r=this.asQFunc(t,i);if("string"!=typeof r)throw Error(`Invalid unsubscribe args for "${s}" in ${t}: ${i}`);const a=e+r,l=o.indexOf(a);if(-1!==l&&(o.splice(l,1),0===o.length&&delete this.subscriptions[n]),o.find((t=>t.startsWith(e))))return}const r=this.subscribers.get(t.id);r.delete(n),0===r.size&&this.subscribers.delete(t.id)}}removeAllSubscriptionsFor(t){const e=this.subscribers.get(t.id);if(e){const s=t.id+".";for(const t of e){const e=this.subscriptions[t];for(let t=e.length-1;t>=0;t--)e[t].startsWith(s)&&e.splice(t,1);0===e.length&&delete this.subscriptions[t]}this.subscribers.delete(t.id)}}publishFromModel(t,e,s){if(Ml!==this)throw Error("Cannot publish a model event from outside model code");const i=e.endsWith(El);i&&(e=e.slice(0,e.length-El.length));const n=t+":"+e;this.handleModelEventInModel(n,s,i),this.handleModelEventInView(n,s)}publishFromModelOnly(t,e,s){if(Ml!==this)throw Error("Cannot publish a model event from outside model code");const i=t+":"+e;this.handleModelEventInModel(i,s)}publishFromView(t,e,s){if(Ml)throw Error("Cannot publish a view event from model code");const i=t+":"+e;this.handleViewEventInModel(i,s),this.handleViewEventInView(i,s)}handleBundledEvents(t){for(const e of t){const t=tc.fromState(e,this);this.verifyExternal(t),t.executeOn(this,!0)}}handleModelEventInModel(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Ml!==this)throw Error("handleModelEventInModel called from outside model code");if(s){if(!0!==this.controller.synced)return;const s=t+"#__vote",i=t+"#divergence",n=!!Mt.subscriptions[s],o=!!this.subscriptions[t],r=!!this.subscriptions[i];n&&r&&console.log(`divergence subscription for ${t} overridden by vote subscription`);const a=o?new tc(this.time,0,"_","handleModelEventInModel",[t,e]):null;let l;l=n?["handleModelEventInView",s]:["handleTuttiDivergence",i],Promise.resolve().then((()=>this.controller.sendTutti({time:this.time,topic:t,data:e,firstMessage:a,wantsVote:n,tallyTarget:l})))}else if(this.subscriptions[t]){const s=this.subscriptions[t],i=s.slice();for(let n=0;n<i.length;n++){const o=i[n];if(o!==s[n]&&!s.includes(o))continue;const[r,...a]=o.split("."),l=a.join("."),c=this.lookUpModel(r);if(c)if("{"!==l[0])if(l.indexOf(".")>=0){const s=l.indexOf("."),i=l.slice(0,s),n=l.slice(s+1);try{c.call(i,n,e)}catch(e){yt(`event ${t} ${c}.call(${JSON.stringify(i)}, ${JSON.stringify(n)})`,e)}}else if("function"==typeof c[l])try{c[l](e)}catch(e){yt(`event ${t} ${c}.${l}()`,e)}else yt(`event ${t} ${c}.${l}(): method not found`);else{const s=jl(l,c);try{s(e)}catch(e){yt(`event ${t} ${c} ${s}`,e)}}else ft(`event ${t} .${l}(): subscriber not found`)}}}handleViewEventInModel(t,e){if(this.subscriptions[t]){const s=[t];void 0!==e&&s.push(e);const i=new tc(this.time,0,"_","handleModelEventInModel",s);this.controller.sendMessage(i)}}handleModelEventInView(t,e){Il.write&&(e=this.debugWriteProxy(this,e,`event ${t} arg`)),Mt.handleEvent(t,e,(t=>function(t){if(!Ml)throw Error("VirtualMachine confusion");const e=Ml;try{Ml=null,t()}finally{Ml=e}}((()=>_t(this,t,!0)))))}handleViewEventInView(t,e){Mt.handleEvent(t,e)}handleTuttiDivergence(t,e){if(this.subscriptions[t])this.handleModelEventInModel(t,e);else{const s=t.split(":").slice(-1)[0];console.warn(`uncaptured divergence in ${s}:`,e)}}handleSessionDiverged(t){const{key:e,url:s}=t;this.diverged||(this.diverged=new Map);let i=this.diverged.get(e);i||this.diverged.set(e,i=[]),i.push(s),2===i.length&&this.controller&&!this.controller.fastForwardHandler&&this.debugDiverged(e)}debugDiverged(t){t||(t=this.diverged.keys().next().value);const e=this.diverged.get(t);if(!e||e.length<2)throw Error(`no diverged urls for snapshot ${t}`);Promise.resolve().then((()=>this.controller.diffDivergedSnapshots(e)))}processModelViewEvents(t){if(Ml)throw Error("cannot process view events in model code");return _t(this,(()=>Mt.processFrameEvents(t,!!this.controller.synced)))}handlePollForSnapshot(){const t=this.time,e=t-this.lastSnapshotPoll;e<5e3?console.log(`rejecting snapshot poll ${e}ms after previous`):(this.lastSnapshotPoll=t,this.controller.handlePollForSnapshot(t))}handleTuttiResult(t){this.controller.handleTuttiResult(t)}handleSnapshotVote(t){this.controller.handleSnapshotVote(t)}handlePersistVote(t){this.controller.handlePersistVote(t)}snapshot(){return ic.newOrRecycled(this).snapshot(this,"_")}getSummaryHash(){return y((new sc).getHash(this))}persist(t,e){this.controller&&"no.appId"===this.controller.sessionSpec.appId&&console.warn("Croquet: appId should be provided in Session.join() to not overwrite another apps's persistent data");const s=ot.begin("snapshot"),i="function"==typeof e?e.call(t):e;if("object"!=typeof i)throw Error(`Croquet: persistSession() can only persist objects (got ${typeof i})`);const n=y(i),o=Rl.hash(n),r=ot.end("snapshot")-s,a=this.persisted===o,l=this.time;var c,d;if(Il.snapshot&&console.log(this.id,`persistent data @${l} collected, stringified and hashed in ${Math.ceil(r)}ms${a?" (unchanged, ignoring)":""}`),!a)if(c=this,d={persistTime:l,persistentString:n,persistentHash:o,ms:r},Dl.set(c,d),this.persisted=o,this.inPersistenceCoolOff)Il.snapshot&&console.log(this.id,"persistence poll postponed by cooloff");else{const t=this.lastPersistencePoll?this.lastPersistencePoll+25e3-this.time:0;t>0?(Il.snapshot&&console.log(this.id,`postponing persistence poll by ${t}ms`),this.futureSend(t,"_","triggerPersistencePoll",[]),this.inPersistenceCoolOff=!0):this.triggerPersistencePoll()}}triggerPersistencePoll(){this.inPersistenceCoolOff=!1,this.lastPersistencePoll=this.controller?this.time:0;const t=(e=this,Dl.get(e));var e;if(!t)return;const{persistTime:s,persistentString:i,persistentHash:n,ms:o}=t;if(Ol(this),this.controller&&this.controller.synced){Il.snapshot&&console.log(this.id,`asking controller to poll for persistence @${s}`);const t=this.time;Promise.resolve().then((()=>this.controller.pollForPersist(t,s,i,n,o)))}}random(){if(Ml!==this)throw Error("synchronized random accessed from outside the model");return this._random()}randomID(){if(Ml!==this)throw Error("synchronized random accessed from outside the model");let t="";for(let e=0;e<4;e++)t+=(this._random.int32()>>>0).toString(16).padStart(8,"0");return t}toString(){return`VirtualMachine[${this.id}]`}[Symbol.toPrimitive](){return this.toString()}}function $l(t,e,s){let i;if("_"===t){const t=Ul[e];"number"==typeof t&&(i=t.toString(36))}if(void 0===i&&(i=`${t}>${e}`),s.length>0){const t=rc.newOrRecycled();i+=JSON.stringify(t.encode(s))}return i}function ql(t,e){return(e-t|0)>=0}class tc{constructor(t,e,s,i,n){this.time=t,this.seq=e,this.receiver=s,this.selector=i,this.args=n}before(t){return this.time!==t.time?this.time<t.time:this.isExternal()!==t.isExternal()?t.isExternal():this.isExternal()?ql(this.externalSeq,t.externalSeq):ql(this.internalSeq,t.internalSeq)}hasReceiver(t){return this.receiver===t}isExternal(){return 1&this.seq}get externalSeq(){return this.seq/2>>>0}set externalSeq(t){this.seq=2*t+1}get internalSeq(){return this.seq/2>>>0}set internalSeq(t){this.seq=2*t}asState(){return[this.time,this.seq,$l(this.receiver,this.selector,this.args)]}static fromState(t,e){const[s,i,n]=t,{receiver:o,selector:r,args:a}=function(t,e){let s,i,n;if(1===t.length||"["===t[1]){const e=parseInt(t[0],36);s="_",i=Jl[e],n=t.slice(1)}else{const e=t.indexOf(">");let o=t.indexOf("[");-1===o&&(o=t.length),s=t.slice(0,e),i=t.slice(e+1,o),n=t.slice(o)}let o=[];n&&(o=ac.newOrRecycled(e).decode(JSON.parse(n)));return{receiver:s,selector:i,args:o}}(n,e);return new tc(s,i,o,r,a)}executeOn(t){const e=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t=>t():e=>Ql(t,(()=>Ft(t,e))),{receiver:s,selector:i,args:n}=this,o=t.lookUpModel(s);if(o)if("{"===i[0]){const t=jl(i,o);e((()=>{try{t(...n)}catch(e){yt(`${this.shortString()} ${t}`,e)}}))}else i.indexOf(".")>=0?e((()=>{const t=i.indexOf("."),e=i.slice(0,t),s=i.slice(t+1);try{o.call(e,s,...n)}catch(t){yt(`${this.shortString()} ${o}.call(${JSON.stringify(e)}, ${JSON.stringify(s)})`,t)}})):"function"!=typeof o[i]?ft(`${this.shortString()} ${o}.${i}(): method not found`):e((()=>{try{o[i](...n)}catch(t){yt(`${this.shortString()} ${o}.${i}()`,t)}}));else ft(`${this.shortString()} ${i}(): receiver not found`)}shortString(){return(this.isExternal()?"External":"Future")+"Message"}toString(){const{receiver:t,selector:e,args:s}=this,i=this.isExternal(),n=i?this.externalSeq:this.internalSeq;return`${i?"External":"Future"}Message[${this.time}${":#"[+i]}${n} ${t}.${e}(${s.map(JSON.stringify).join(", ")})]`}[Symbol.toPrimitive](){return this.toString()}}const ec=(()=>{const t=new ArrayBuffer(8),e=new DataView(t);return t=>(e.setFloat64(0,t,!0),e.getInt32(0,!0)+e.getInt32(4,!0))})();class sc{constructor(){this.done=new Set,this.todo=[],this.hashers=new Map,this.addHasher("Teatime:Message",tc),this.addHasher("Teatime:Data",Yl);for(const[t,e]of mc.allClassTypes())this.addHasher(t,e)}addHasher(t,e){const{cls:s,write:i}=Object.getPrototypeOf(e)===Object.prototype?e:{cls:e,write:t=>({...t})};this.hashers.set(s,(t=>this.hashStructure(t,i(t))))}getHash(t){this.hashState={oC:0,mC:0,nanC:0,infC:0,zC:0,nC:0,nH:0,sC:0,sL:0,fC:0};for(const[e,s]of Object.entries(t))if("controller"!==e&&"meta"!==e)if("_random"===e)this.hash(s.state(),!1);else if("messages"===e){const t=s.asArray();(this.hashState.fC=t.length)&&this.hash(t,!1)}else this.hashEntry(e,s);return this.hashDeferred(),this.hashState}hashDeferred(){let t=0;for(;t<this.todo.length;){const{key:e,value:s}=this.todo[t++];this.hashEntry(e,s,!1)}this.todo.length=0}hash(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];switch(typeof t){case"number":return void(Number.isNaN(t)?this.hashState.nanC++:Number.isFinite(t)?0===t?this.hashState.zC++:(this.hashState.nC++,this.hashState.nH+=ec(t)):this.hashState.infC++);case"string":return this.hashState.sC++,void(this.hashState.sL+=t.length);case"boolean":case"undefined":return;case"bigint":if(0n===t)this.hashState.zC++;else{this.hashState.nC++;const e=t<0?-1n:0n;for(;t!==e;)this.hashState.nH+=Number(0xFFFFFFFFn&t),t>>=32n}return;default:{if(this.done.has(t))return;if(null===t)return;if(this.hashers.has(t.constructor))return void this.hashers.get(t.constructor)(t);const s=Object.prototype.toString.call(t).slice(8,-1);if(this.hashers.has(s))return void this.hashers.get(s)(t);switch(s){case"Array":return void this.hashArray(t,e);case"ArrayBuffer":return void this.hashIntArray(new Uint8Array(t));case"Set":return void this.hashStructure(t,[...t]);case"Map":return void this.hashStructure(t,[...t],!1);case"DataView":return void this.hashIntArray(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":return void this.hashIntArray(t);case"Float32Array":case"Float64Array":return void this.hashArray(t,!1);case"Object":t instanceof mc?this.hashModel(t):t.constructor===Object&&this.hashObject(t,e)}}}}hashModel(t){this.hashState.mC++,this.done.add(t);for(const[e,s]of Object.entries(t))"__realm"!==e&&void 0!==s&&this.hashEntry(e,s)}hashObject(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.hashState.oC++,this.done.add(t);for(const[s,i]of Object.entries(t))void 0!==i&&this.hashEntry(s,i,e)}hashArray(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.done.add(t);for(let s=0;s<t.length;s++)this.hashEntry(s,t[s],e)}hashIntArray(t){this.done.add(t);for(let e=0;e<t.length;e++){const s=t[e];0===s?this.hashState.zC++:(this.hashState.nC++,this.hashState.nH+=s)}}hashStructure(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];void 0!==e&&(this.done.add(t),this.hash(e,s))}hashEntry(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];"$"!==t[0]&&(s&&"object"==typeof e?this.todo.push({key:t,value:e}):this.hash(e,s))}}class ic{static newOrRecycled(t){let e=this.reusableInstance;return e?(e.vm=t,e.nextRef=1,e.refs=new Map,e.todo=[]):e=this.reusableInstance=new this(t),e}static get reusableInstance(){return this[this.name+"-instance"]}static set reusableInstance(t){this[this.name+"-instance"]=t}static resetInstance(){this.reusableInstance=null}constructor(t){this.vm=t,this.nextRef=1,this.refs=new Map,this.todo=[],this.writers=new Map,this.addWriter("Teatime:Message",tc),this.addWriter("Teatime:Data",Yl);for(const[t,e]of mc.allClassTypes())this.addWriter(t,e);this.okayToIgnore={$debugWriteProxyHandler:!0};for(const t of mc.allClasses())if(Object.prototype.hasOwnProperty.call(t,"okayToIgnore")){const e=t.okayToIgnore();if(!Array.isArray(e))throw new Error("okayToIgnore() must return an array");for(const t of e){if("$"!==t[0])throw Error(`okayToIgnore: ignored prop "${t}" must start with '$'`);this.okayToIgnore[t]=!0}}}addWriter(t,e){const{cls:s,write:i}=Object.getPrototypeOf(e)===Object.prototype?e:{cls:e,write:t=>({...t})};this.writers.set(s,((e,s)=>this.writeAs(t,e,i(e),s)))}snapshot(t){const e={_random:t._random.state(),messages:this.write(t.messages.asArray(),"vm.messages"),subscribers:void 0,controller:void 0};for(const[s,i]of Object.entries(t))s in e||this.writeInto(e,s,i,`vm.${s}`);return this.writeDeferred(),e}writeDeferred(){let t=0;for(;t<this.todo.length;){const{state:e,key:s,value:i,path:n}=this.todo[t++];this.writeInto(e,s,i,n,!1)}this.todo.length=0}write(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];switch(typeof t){case"number":return Object.is(t,-0)?{$class:"NegZero"}:Number.isFinite(t)?t:Number.isNaN(t)?{$class:"NaN"}:{$class:"Infinity",$value:Math.sign(t)};case"string":case"boolean":return t;case"undefined":return{$class:"Undefined"};case"bigint":return{$class:"BigInt",$value:t.toString()};default:{if(this.refs.has(t))return this.writeRef(t);if(null===t)return t;if(this.writers.has(t.constructor))return this.writers.get(t.constructor)(t,e);const i=Object.prototype.toString.call(t).slice(8,-1);if(this.writers.has(i))return this.writers.get(i)(t,e);switch(i){case"Array":return this.writeArray(t,e,s);case"ArrayBuffer":return this.writeArrayBuffer(t);case"Set":return this.writeAs(i,t,[...t],e);case"Map":return this.writeAs(i,t,[...t].flat(),e);case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":return this.writeTypedArray(i,t);case"Object":if(t instanceof mc)return this.writeModel(t,e);if(t.constructor===Object||"function"!=typeof t.constructor)return this.writeObject(t,e,s);throw console.error(`Croquet: unknown class at ${e}:`,t),Error(`Croquet: class not registered in Model.types(): ${t.constructor.name}`);default:throw console.error(`Croquet: unsupported property at ${e}:`,t),Error(`Croquet: serialization of ${i}s is not supported`)}}}}writeModel(t,e){const s={};this.refs.set(t,s);try{s.$model=mc.classToID(t.constructor)}catch(s){throw console.error(`unregistered model class at ${e}:`,t),s}for(const i of Object.keys(t).sort()){if("__realm"===i)continue;const n=t[i];("number"==typeof n&&Number.isFinite(n)&&!Object.is(n,-0)||"string"==typeof n||"boolean"==typeof n)&&"$"!==i[0]?s[i]=n:this.writeInto(s,i,n,e)}return s}writeObject(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const i={};this.refs.set(t,i);for(const n of Object.keys(t).sort()){const o=t[n];("number"==typeof o&&Number.isFinite(o)&&!Object.is(o,-0)||"string"==typeof o||"boolean"==typeof o)&&"$"!==n[0]?i[n]=o:this.writeInto(i,n,o,e,s)}return i}writeArray(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const i=[];this.refs.set(t,i);for(let n=0;n<t.length;n++){const o=t[n];"number"==typeof o&&Number.isFinite(o)&&!Object.is(o,-0)||"string"==typeof o||"boolean"==typeof o?i[n]=o:this.writeInto(i,n,o,e,s)}return i}writeArrayBuffer(t){const e={$class:"ArrayBuffer",$value:cc(t)};return this.refs.set(t,e),e}writeTypedArray(t,e){const s={$class:t,$value:[this.write(e.buffer),e.byteOffset,"DataView"===t?e.byteLength:e.length]};return this.refs.set(e,s),s}writeAs(t,e,s,i){const n={$class:t};this.refs.set(e,n);const o=this.write(s,i,!1);return"object"!=typeof o||null===o||o.$class||Array.isArray(o)?n.$value=o:Object.assign(n,o),n}writeRef(t){const e=this.refs.get(t);if("object"!=typeof e)throw Error("Non-object in refs: "+t);Array.isArray(e)&&(e.toJSON=function(){return{$id:this.$id,$class:"Array",$value:[...this]}});return{$ref:e.$id||(e.$id=this.nextRef++)}}writeInto(t,e,s,i){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if("$"===e[0])return void(this.okayToIgnore[e]||(ft(`snapshot: ignoring property ${e} (declare as okayToIgnore to suppress warning)`,{only:"once"}),this.okayToIgnore[e]=!0));if(n&&"object"==typeof s)return void this.todo.push({state:t,key:e,value:s,path:i});const o=this.write(s,i+zl(t,e));t[e]=o}}const nc=Symbol("croquet:unresolved");class oc{static newOrRecycled(t){let e=this.reusableInstance;return e?(e.vm=t,e.refs=new Map,e.todo=[],e.unresolved=[],e.postprocess=[]):e=this.reusableInstance=new this(t),e}static get reusableInstance(){return this[this.name+"-instance"]}static set reusableInstance(t){this[this.name+"-instance"]=t}static resetInstance(){this.reusableInstance=null}constructor(t){this.vm=t,this.refs=new Map,this.todo=[],this.unresolved=[],this.postprocess=[],this.readers=new Map,this.addReader("Teatime:Message",tc),this.addReader("Teatime:Data",Yl),this.readers.set("Undefined",(()=>{})),this.readers.set("NaN",(()=>NaN)),this.readers.set("Infinity",(t=>t*(1/0))),this.readers.set("NegZero",(()=>-0)),this.readers.set("BigInt",(t=>BigInt(t))),this.readers.set("ArrayBuffer",(t=>function(t){const e=globalThis.atob(t),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.charCodeAt(t);return i.buffer}(t))),this.readers.set("DataView",(t=>new DataView(...t))),this.readers.set("Int8Array",(t=>new Int8Array(...t))),this.readers.set("Uint8Array",(t=>new Uint8Array(...t))),this.readers.set("Uint8ClampedArray",(t=>new Uint8ClampedArray(...t))),this.readers.set("Int16Array",(t=>new Int16Array(...t))),this.readers.set("Uint16Array",(t=>new Uint16Array(...t))),this.readers.set("Int32Array",(t=>new Int32Array(...t))),this.readers.set("Uint32Array",(t=>new Uint32Array(...t))),this.readers.set("Float32Array",(t=>new Float32Array(...t))),this.readers.set("Float64Array",(t=>new Float64Array(...t)));for(const[t,e]of mc.allClassTypes())this.addReader(t,e)}addReader(t,e){const s="object"==typeof e?e.read:t=>Object.assign(Object.create(e.prototype),t);this.readers.set(t,s)}readVM(t,e){if("vm"!==e)throw Error("VirtualMachine must be root object");const s=this.read(t,e,!1);return this.readDeferred(),this.resolveRefs(),this.doPostprocess(),s}readDeferred(){let t=0;for(;t<this.todo.length;){const{object:e,key:s,value:i,path:n}=this.todo[t++];this.readInto(e,s,i,n,!1)}this.todo.length=0}resolveRefs(){for(const{object:t,key:e,ref:s,path:i}of this.unresolved){if(!this.refs.has(s))throw Error(`Unresolved ref: ${s} at ${i}[${JSON.stringify(e)}]`);t[e]=this.refs.get(s)}this.unresolved.length=0,this.refs.clear()}doPostprocess(){for(const t of this.postprocess)t();this.postprocess.length=0}read(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];switch(typeof t){case"number":case"string":case"boolean":return t;default:{const i=Object.prototype.toString.call(t).slice(8,-1);switch(i){case"Array":return this.readArray(t,e,s);case"Null":return null;case"Object":{const{$class:i,$model:n,$ref:o}=t;if(o)throw Error("refs should have been handled in readInto()");return n?this.readModel(t,e):i?this.readAs(i,t,e):this.readObject(Object,t,e,s)}default:throw Error(`Don't know how to deserialize ${i} at ${e}`)}}}}readModel(t,e){const s=mc.instantiateClassID(t.$model,t.id);t.$id&&this.refs.set(t.$id,s);for(const[i,n]of Object.entries(t))"id"!==i&&"$"!==i[0]&&this.readInto(s,i,n,e);return s}readObject(t,e,s){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const n=new t;e.$id&&this.refs.set(e.$id,n);for(const[t,o]of Object.entries(e))"$"!==t[0]&&this.readInto(n,t,o,s,i);return n}readArray(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const i=[];t.$id&&this.refs.set(t.$id,i);for(let n=0;n<t.length;n++)void 0!==t[n]&&this.readInto(i,n,t[n],e,s);return i}readAsArray(t,e){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const i=t.$value;return t.$id&&(i.$id=t.$id),this.readArray(i,e,s)}readAsSet(t,e){const s=new Set;t.$id&&this.refs.set(t.$id,s);const i=this.unresolved.length,n=this.read(t.$value,e,!1),o=()=>{for(const t of n)s.add(t)};return this.unresolved.length===i?o():this.postprocess.push(o),s}readAsMap(t,e){const s=new Map;t.$id&&this.refs.set(t.$id,s);const i=this.unresolved.length,n=this.read(t.$value,e,!1),o=()=>{for(let t=0;t<n.length;t+=2)s.set(n[t],n[t+1])};return this.unresolved.length===i?o():this.postprocess.push(o),s}readAsClass(t,e,s){let i={};const n=new Map;if("$value"in e)i=this.read(e.$value,s,!1);else for(const[t,o]of Object.entries(e)){if("$"===t[0])continue;const e=o&&o.$ref;e?this.refs.has(e)?i[t]=this.refs.get(e):(i[t]=nc,n.set(e,t)):this.readInto(i,t,o,s,!1)}const o=this.readers.get(t)(i,s);o||"Undefined"===t||"BigInt"===t||"NaN"===t||"NegZero"===t||console.warn(`Reading "${t}" returned ${o} at ${s}`),e.$id&&this.refs.set(e.$id,o);for(const[t,e]of n.entries())this.unresolved.push({object:o,key:e,ref:t,path:s});return o}readAs(t,e,s){switch(t){case"Array":return this.readAsArray(e,s);case"Set":return this.readAsSet(e,s);case"Map":return this.readAsMap(e,s);default:return this.readAsClass(t,e,s)}}readRef(t,e,s,i){if(!s||!s.$ref)return!1;const n=s.$ref;return this.refs.has(n)?t[e]=this.refs.get(n):(t[e]=nc,this.unresolved.push({object:t,key:e,ref:n,path:i})),!0}readInto(t,e,s,i){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];this.readRef(t,e,s,i)||(n&&"object"==typeof s?this.todo.push({object:t,key:e,value:s,path:i}):t[e]=this.read(s,i+zl(t,e)))}}class rc extends ic{encode(t){const e=this.writeArray(t,"args");return this.writeDeferred(),e}writeModel(t){return{$ref:t.id}}}class ac extends oc{decode(t){const e=this.readArray(t,"args");return this.readDeferred(),this.resolveRefs(),this.doPostprocess(),e}resolveRefs(){for(const{object:t,key:e,ref:s,path:i}of this.unresolved)if(this.refs.has(s))t[e]=this.refs.get(s);else{const n=this.vm.lookUpModel(s);if(!n)throw Error(`Unresolved ref: ${s} at ${i}[${JSON.stringify(e)}]`);t[e]=n}}}function lc(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Set;const n=Object.values(t).filter((t=>{const e=Object.prototype.toString.call(t).slice(8,-1);return("Object"===e||"Array"===e)&&!i.has(t)}));for(const t of n){i.add(t);const n=e+"."+t.constructor.name;if(s[n]){if(s[n]!==t.constructor)throw new Error("Class with name "+n+" already gathered, but new one has different identity")}else s[n]=t.constructor}for(const t of n)lc(t,e,s,i)}function cc(t){const e=new Uint8Array(t),s=[];for(let t=0;t<e.byteLength;t+=4096){const i=e.subarray(t,t+4096);s.push(String.fromCharCode.apply(null,i))}return globalThis.btoa(s.join(""))}const dc={classes:a.has("debug","classes",!1),write:void 0};let hc=Symbol("SECRET");const uc=new WeakSet;class mc{static create(t,e,s){if(!yc(this))throw Error(`Model class "${this.name}" not registered`);const i=this,n=this.createNoInit();return uc.add(n),"string"==typeof e&&(console.warn(`Croquet: Model.create(..., "${e}") with a well-known name argument is deprecated!`),n.beWellKnownAs(e),e=void 0),s&&n.beWellKnownAs(s),n.init(t,e),uc.has(n)&&(uc.delete(n),Object.getPrototypeOf(i)!==mc&&console.warn(`${n} did not call super.init(options)`)),n}static createNoInit(t){const e=Nt(),s=new this(hc);return t||(t=e.register(s)),void 0===dc.write&&(dc.write=a.has("debug","write",!1)),Object.defineProperty(s,"__realm",{value:e,writable:dc.write}),Object.defineProperty(s,"id",{value:t,enumerable:!0}),s}static allowConstructors(){hc=void 0,console.warn("disabling error reporting for Model constructors")}static register(t){return t||(t=this.name,console.warn(`Deprecation warning: ${this.name}.register(classId) called without classId. See https://croquet.io/docs/croquet/Model.html#.register`)),oc.resetInstance(),ic.resetInstance(),rc.resetInstance(),ac.resetInstance(),function(t,e){const s=G(t),i=P(`${e}:${s}`);V.push(i),i.then((t=>T[t].what=`Class ${e}`))}(this,t),function(t,e){const s=pc[e];if(s&&s!==t)throw Error(`Registering model class ${t.name} failed, id "${e}" already used by ${s.name}`);yc(t)?dc.classes&&!s&&console.warn(`ignoring re-exported model class ${e}`):(dc.classes&&console.log(`registering model class ${e}`),t[fc]=e);pc[e]=t}(this,t),mc.lastRegistered=this,this}static wellKnownModel(t){if(!Al.hasCurrent())throw Error("static Model.wellKnownModel() called from outside model");return Al.current().get(t)}static evaluate(t){return Al.evaluate(t)}static types(){return{}}static okayToIgnore(){return[]}static classToID(t){return function(t){if(yc(t))return t[fc];const e=t.name||"ClassName";throw Error(`Model class not registered, did you call ${e}.register("${e}")?`)}(t)}static classFromID(t){return gc(t)}static allClasses(){return bc()}static allClassTypes(){return function(){const t={};for(const e of bc())Object.assign(t,e.types());return Object.entries(t)}()}static instantiateClassID(t,e){return gc(t).createNoInit(e)}constructor(t){if(t!==hc)throw Error('You must create Croquet Models using create() not "new"!')}init(t,e){uc.delete(this)}destroy(){Nt().unsubscribeAll(this),Nt().deregister(this)}publish(t,e,s){this.__realm||this.__realmError(),this.__realm.publish(e,s,t)}subscribe(t,e,s){return this.__realm||this.__realmError(),this.__realm.subscribe(this,t,e,s)}unsubscribe(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"*";this.__realm||this.__realmError(),this.__realm.unsubscribe(this,t,e,s)}unsubscribeAll(){this.__realm||this.__realmError(),this.__realm.unsubscribeAll(this)}__realmError(){if(!this.id)throw Error(`${this} has no ID, did you call super.init(options)?`)}future(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1?arguments[1]:void 0;this.__realm||this.__realmError();for(var s=arguments.length,i=new Array(s>2?s-2:0),n=2;n<s;n++)i[n-2]=arguments[n];return this.__realm.future(this,t,e,i)}cancelFuture(t){return this.__realm||this.__realmError(),this.__realm.cancelFuture(this,t)}random(){return Nt().random()}now(){return Nt().now()}beWellKnownAs(t){Nt().vm.set(t,this)}getModel(t){return this.__realm.vm.lookUpModel(t)}wellKnownModel(t){return this.__realm.vm.get(t)}modelOnly(t){if(Al.current()===this.__realm.vm)return!0;const e=Error(t||`${this}.modelOnly() called from outside a model!`);throw yt("view code",e),e}get sessionId(){return this.__realm.vm.id}get viewCount(){return Object.keys(this.__realm.vm.views).length}persistSession(t){if(this!==this.wellKnownModel("modelRoot"))throw Error("persistSession() must only be called on the root model");this.__realm.vm.persist(this,t)}[Symbol.toPrimitive](){return`${this.constructor[fc]||this.constructor.name}#${this.id}`}}const pc={},fc=Symbol("CLASS_ID");function bc(){return Object.values(pc)}function yc(t){return Object.prototype.hasOwnProperty.call(t,fc)}function gc(t){if(pc[t])return pc[t];throw Error(`Model class "${t}" in snapshot, but not registered?`)}const wc="Croquet.Model";mc[fc]=wc,pc[wc]=mc;class Zc{static displayStatus(t,e){return bt(t,e)}static displayWarning(t,e){return ft(t,e)}static displayError(t,e){return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t&&Vt.showMessage(t,{...e,level:"error"})}(t,e)}constructor(t){"object"==typeof t&&"__realm"in t||console.warn("Croquet: argument to View constructor needs to be a Model");let e=Nt("");e&&e.isViewRealm()||(e=_t(t.__realm.vm,(()=>Nt()),!0)),Object.defineProperty(this,"realm",{value:e}),Object.defineProperty(this,"id",{value:e.register(this),configurable:!0});const s=e.controller.session;s.view||(s.view=this)}detach(){this.unsubscribeAll(),this.realm.deregister(this),Object.defineProperty(this,"id",{value:""})}reattach(){Object.defineProperty(this,"id",{value:this.realm.register(this)})}publish(t,e,s){this.realm.publish(e,s,t)}subscribe(t,e,s){"string"==typeof s&&(s=this[s]);const i=s;(s=i.bind(this)).unbound=i;const{event:n,handling:o}=e.event?e:{event:e};this.realm.subscribe(n,this.id,s,t,o)}unsubscribe(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;"string"==typeof s&&(s=this[s]),this.realm.unsubscribe(e,this.id,s,t)}unsubscribeAll(){this.realm.unsubscribeAll(this.id)}future(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.realm.future(this,t)}random(){return Nt().random()}now(){return this.realm.now()}externalNow(){return this.realm.externalNow()}extrapolatedNow(){return this.realm.extrapolatedNow()}update(t){}wellKnownModel(t){return this.realm.vm.get(t)}get sessionId(){return this.realm.controller.sessionSpec.id}get session(){if(this.id&&this.realm.valid())return this.realm.controller.session}get viewId(){return this.realm.controller.viewId}[Symbol.toPrimitive](){const t=this.constructor.name;return t.includes("View")?t:`${t}[View]`}}const vc=new class{constructor(){this.ready=!1,this.isInIframe=window.top!==window,this.subscriptions={},this.enumerator=null}setReceiver(t){this.receiver=t,this.ready=!0}setIframeEnumerator(t){this.enumerator=t}on(t,e){if(!this.receiver)throw Error("setReceiver() has not been called");if("string"==typeof e&&(e=this.receiver[e]),!e)throw Error("Messenger.on: the second argument must be a method name or a function");if(this.subscriptions[t]){if(this.findIndex(this.subscriptions[t],e)>=0)throw Error(`${e} is already subscribed`)}else this.subscriptions[t]=[];this.subscriptions[t].push(e),this.listener||(this.listener=t=>this.receive(t),window.addEventListener("message",this.listener))}detach(){this.listener&&(window.removeEventListener("message",this.listener),this.listener=null),this.stopPublishingPointerMove(),this.receiver=null,this.subscriptions={},this.enumerator=null,this.ready=!1}removeSubscription(t,e){"string"==typeof e&&(e=this.receiver[e]);const s=this.subscriptions[t];if(s){const i=this.findIndex(s,e);s.splice(i,1),0===s.length&&delete this.subscriptions[t]}}removeAllSubscriptions(){this.subscriptions={}}receive(t){const{event:e,data:s}=t.data,i=t.source;this.handleEvent(e,s,i)}handleEvent(t,e,s){const i=this.subscriptions[t];i&&i.forEach((t=>{t.call(this.receiver,e,s)}))}send(t,e,s){if(this.isInIframe)return void window.top.postMessage({event:t,data:e},"*");if(s)return void s.postMessage({event:t,data:e},"*");if(!this.enumerator)return;this.enumerator().forEach((s=>{s.contentWindow.postMessage({event:t,data:e},"*")}))}findIndex(t,e){const s=e.name;return t.findIndex((t=>{const i=t.name;return s||i?s===i:e===t}))}startPublishingPointerMove(){this._moveHandler||(this._moveHandler=t=>this.send("pointerPosition",{x:t.clientX,y:t.clientY,type:t.type}),window.document.addEventListener("pointermove",this._moveHandler,!0))}stopPublishingPointerMove(){this._moveHandler&&(window.document.removeEventListener("pointermove",this._moveHandler,!0),this._moveHandler=null)}},Xc="node"===s.CROQUET_PLATFORM;let Lc=60;class xc{static async join(t){try{return await this.join_impl(t)}catch(t){throw Vt.showMessage(t.message||t,{level:"fatal"}),t}}static async join_impl(t){if("object"!=typeof t)throw Error("Croquet: please use new Session.join( {apiKey, ...} ) API. See https://croquet.io/docs/croquet/Session.html#.join");t.appId||(t.appId="no.appId"),t.name||(t.name=Vt.autoSession(),t.password||(t.password=Vt.autoPassword())),t.model||(t.model=mc.lastRegistered),t.view||(t.view=Zc);for(const[f,b]of Object.entries(t))b instanceof Promise&&(t[f]=await b);function e(t,e){return t===e||t.prototype instanceof e}if("string"!=typeof t.apiKey)throw Error("Croquet: no apiKey provided in Session.join()!");if(t.apiKey.length>128)throw Error("Croquet: apiKey > 128 characters in Session.join()!");if("string"!=typeof t.name)throw Error("Croquet: no session name provided in Session.join()!");if(t.name.length>128)throw Error("Croquet: session name > 128 characters in Session.join()!");const s=t.model;if("function"!=typeof s||!e(s,mc))throw Error("Croquet: bad model class in Session.join()");const i=t.view||Zc;if("function"!=typeof i||!e(i,Zc))throw Error("Croquet: bad view class in Session.join()");if("string"!=typeof t.appId)throw Error("Croquet: no appId provided in Session.join()");if(!t.appId.length>128)throw Error("Croquet: appId > 128 characters in Session.join()");if(!t.appId.match(/^[a-z](-?[a-z0-9_])*(\.[a-z0-9_](-?[a-z0-9_])*)+$/i))throw Error("Croquet: malformed appId in Session.join()");if("string"!=typeof t.password||!t.password)throw Error("Croquet: no password provided in Session.join()");const n=a.reflector||t.reflector;n&&(a.reflector=n);const o=a.files||t.files;o&&(a.files=o);const r=a.backend||t.backend;if(r&&(a.backend=r),Xc&&"manual"!==t.step)throw Error("stepping must be manual in a Node.js app");if("rejoinLimit"in t){if("number"!=typeof t.rejoinLimit||t.rejoinLimit<0||t.rejoinLimit>6e4)throw Error("rejoinLimit range: 0-60000")}else t.rejoinLimit=1e3;if("eventRateLimit"in t){if("number"!=typeof t.eventRateLimit||t.eventRateLimit<1||t.eventRateLimit>60)throw Error("eventRateLimit range: 1-60")}else t.eventRateLimit=20;if(t.heraldUrl){if(t.heraldUrl.length>256)throw Error("heraldUrl can only be 256 characters");if(!t.heraldUrl.startsWith("https://"))throw Error("heraldUrl needs to be https")}if(t.hashOverride){if(43!==t.hashOverride.length)throw Error("hashOverride must be 43 characters");if(-1!==t.hashOverride.search(/[^-_a-zA-Z0-9]/))throw Error("hashOverride must be base64url encoded")}if(t.debug){function g(t){return"string"==typeof t&&(t=t.split(",")),t?Array.isArray(t)?t:[t]:[]}a.debug=[...g(t.debug),...g(a.debug)].join(",")}if("autoSleep"in t){const w=t.autoSleep,Z=typeof w;if("number"===Z){if(w<0)throw Error("an autoSleep value must be >= 0")}else{if("boolean"!==Z)throw Error("autoSleep must be numeric or boolean");t.autoSleep=w?10:0}}else t.autoSleep=10;if(t.flags){let v=t.flags;"string"==typeof v&&(v=v.split(",")),v=v?Array.isArray(v)?v:[v]:[],v=v.filter((t=>"object"!=typeof t)),v.length?(t.flags={},v.forEach((e=>t.flags[e]=!0))):t.flags=null}"expectedSimFPS"in t&&(Lc=Math.min(t.expectedSimFPS,120));const l=["name","password","apiKey","appId","tps","autoSleep","heraldUrl","rejoinLimit","eventRateLimit","optionsFromUrl","viewOptions","viewIdDebugSuffix","hashOverride","location","flags","progressReporter"];!function(){if(Object.isFrozen(Sc))return;Gc(Sc),function(t){const e=JSON.stringify(t,((t,e)=>"function"==typeof e?G(e):e));if("{}"===e)return;const s=JSON.parse(e),i=P(y(s));V.push(i),i.then((t=>T[t].what="Croquet Constants"))}(Sc)}();const c=new vl,d=JSON.parse(JSON.stringify({...t.options})),h={id:"",persistentId:"",versionId:"",name:t.name,model:null,view:null,step(t){c.stepSession("animation",{frameTime:t,view:h.view,expectedSimFPS:Lc})},leave:()=>xc.leave(h.id),data:{store:(t,e)=>Rl.store(t,{...e,sessionId:h.id}),fetch:(t,e)=>Rl.fetch(t,{...e,sessionId:h.id}),hash:t=>Rl.hash(t),toId:t=>Rl.toId(t),fromId:t=>Rl.fromId(t)},get latency(){return c.latency},get latencies(){return c.latencies}},u={options:d,initFn:(t,e)=>s.create(t,e,"modelRoot"),rebootModelView:p};for(const[X,L]of Object.entries(t))l.includes(X)&&(u[X]=L);await c.initFromSessionSpec(u);let m=!1;return await p(),"manual"!==t.step&&c.startStepping(h.step),h;async function p(){!function(){h.model=null,h.view&&(a.has("debug","session",!1)&&console.log(h.id,"detaching root view"),h.view.detach(),""!==h.view.id&&console.warn(`Croquet: ${h.view} did not call super.detach()`),h.view=null);Vt.clearSessionMoniker(),vc.ready&&vc.detach()}(),c.leaving?c.leaving(!0):m||(m=!0,await c.establishSession(u),m=!1,h.model=c.vm.get("modelRoot"),h.id=c.id,h.persistentId=c.persistentId,h.versionId=c.versionId,c.session=h,Vt.makeSessionWidgets(h.id),c.inViewRealm((()=>{a.has("debug","session",!1)&&console.log(h.id,"creating root view"),new i(h.model,u.viewOptions)})))}}static async leave(t){const e=function(t){for(const e of wl)if(e.id===t)return e;return null}(t);if(!e)return!1;e.reconnectTimeout&&(clearTimeout(e.reconnectTimeout),delete e.reconnectTimeout);const s=new Promise((t=>e.leaving=t)),i=e.connection;return!!i.connected&&(i.closeConnection(1e3),s)}static thisSession(){const t=Al.current();return t?t.id:""}get id(){return""}get persistentId(){return""}get versionId(){return""}get name(){return""}get data(){return{}}step(t){}leave(){}}const Sc={};function Gc(t){if(!Object.isFrozen(t)){Object.freeze(t);for(const e of Object.values(t))!e||"object"!=typeof e&&"function"!=typeof e||Gc(e)}}return t.App=Vt,t.Constants=Sc,t.Data=Rl,t.Messenger=vc,t.Model=mc,t.Session=xc,t.View=Zc,t.gatherInternalClassTypes=function(t,e){const s={};return lc({root:t},e,s,new Set),s},t.startSession=function(){return Vt.showMessage("Croquet.startSession() is deprecated, please use Croquet.Session.join()",{level:"warning",only:"once"}),xc.join(...arguments)},Object.defineProperty(t,"__esModule",{value:!0}),t}({});

