@sketch-hq/sketch-web-renderer 12.1.2 → 12.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import e,{useRef as t,useLayoutEffect as n,useCallback as o,createContext as r,useContext as i,useReducer as a,useMemo as s,useEffect as u,useState as l}from"react";var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var h=function(){return h=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},h.apply(this,arguments)};function p(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}function g(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function v(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function f(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}const m=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function y(e){return e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const b="undefined"==typeof window,w=(()=>{if(b)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(e),r="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:r,isMobile:/android/i.test(e)||o||r,isSafari12:/Version\/12.+Safari/.test(e)}})();class C extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const P=[],E=[];function M(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let o=e.length,r=t.length;for(;o>0&&e.charCodeAt(~-o)===t.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,l=0,c=0,d=0;for(;c<o;)E[c]=e.charCodeAt(a+c),P[c]=++c;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,l=d,c=0;c<o;c++)u=i===E[c]?s:s+1,s=P[c],l=P[c]=s>l?u>l?l+1:u:u>s?s+1:u;return l}function L(e){return null!=e}const x=({mobileTiers:e=[0,15,30,60],desktopTiers:t=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@5.0.25/dist/benchmarks"}={})=>f(void 0,void 0,void 0,(function*(){const a={};if(b)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==w?void 0:w.isIpad),isMobile:u=!!(null==w?void 0:w.isMobile),screenSize:l=window.screen,loadBenchmarks:c=(e=>f(void 0,void 0,void 0,(function*(){const t=yield fetch(`${i}/${e}`).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<4)throw new C("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:e,type:t});let p,g="";if(d)d=y(d),p=[d];else{const e=o||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==w?void 0:w.isSafari12,r);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");g=d,d=y(d),p=function(e,t,n){return"apple gpu"===t?function(e,t,n){if(!n)return[t];const o=function(e){const t=e.createShader(35633),n=e.createShader(35632),o=e.createProgram();if(!(n&&t&&o))return;e.shaderSource(t,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(n,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(t),e.compileShader(n),e.attachShader(o,t),e.attachShader(o,n),e.linkProgram(o),e.detachShader(o,t),e.detachShader(o,n),e.deleteShader(t),e.deleteShader(n),e.useProgram(o);const r=e.createBuffer();e.bindBuffer(34962,r),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=e.getAttribLocation(o,"aPosition");e.vertexAttribPointer(i,3,5126,!1,0,0),e.enableVertexAttribArray(i),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);const a=new Uint8Array(4);return e.readPixels(0,0,1,1,6408,5121,a),e.deleteProgram(o),e.deleteBuffer(r),a.join("")}(e),r="801621810",i="8016218135",a="80162181161",s=(null==w?void 0:w.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,e])=>e>=14)):(u=s.filter((([,e])=>e===o)),u.length||(u=s)),u.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,u)}const v=(yield Promise.all(p.map((function(e){var t;return f(this,void 0,void 0,(function*(){const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(t=a[o])&&void 0!==t?t:c(o);let i;try{i=yield r}catch(n){if(n instanceof C)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const p=h.length;if(0===p)return;const g=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let v,[f,,,,m]=p>1?h.map((e=>[e,M(g,e[2])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],y=Number.MAX_VALUE;const{devicePixelRatio:b}=window,w=l.width*b*l.height*b;for(const e of m){const[t,n]=e,o=t*n,r=Math.abs(w-o);r<y&&(y=r,v=e)}if(!v)return;const[,,P,E]=v;return[y,P,f,E]}))})))).filter(L).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!v.length){const e=m.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${g})`)}const[,P,E,x]=v[0];if(-1===P)return h(0,"BLOCKLISTED",E,P,x);const R=u?e:t;let W=0;for(let e=0;e<R.length;e++)P>=R[e]&&(W=e);return h(W,"BENCHMARK",E,P,x)}));var R,W,S=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"(".concat(n,") ").concat(o))||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return d(t,e),t}(Error);function T(e){return void 0!==e}!function(e){e.debug="debug",e.release="release"}(R||(R={})),function(e){e.Fit="Fit",e.FillWidth="FillWidth",e.ActualSize="ActualSize"}(W||(W={}));var F=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,o;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(o=this.listeners[e])||void 0===o||o.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.forwardEvent=function(e,t){this.on(t,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];e.emit.apply(e,v([t],n,!1))}))},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.listeners[e];(null==o?void 0:o.size)&&o.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e.prototype.detachAllListeners=function(){this.listeners={}},e}(),I=function(){function e(e){void 0===e&&(e=!1),this.removeListenerCallbacks=[],this.disabled=e}return e.prototype.add=function(e,t,n,o){var r=this,i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r.disabled||n.apply(void 0,e)};e.addEventListener(t,i,o);var a=function(){e.removeEventListener(t,i,o)};return this.removeListenerCallbacks.push(a),a},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e.prototype.setDisabled=function(e){this.disabled=e},e}(),A={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1,canvasLayersEvents:!1},D=function(e){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(e)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},G=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,U=function(e){if(void 0===e&&(e=window.navigator.userAgent),e.includes("Chrome/")||e.includes("Chromium/")||e.includes("Opera/")||e.includes("Firefox/"))return null;var t=e.match(G);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}};function k(e,t){var n;function o(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,o)}),t)}return o.cancel=function(){n&&clearTimeout(n)},o}function B(e){var t,n,o,r,i,a=null!==(n=null===(t=e.touches)||void 0===t?void 0:t[0])&&void 0!==n?n:null===(o=e.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:e.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:e.clientY}}function z(e,t,n){return Math.max(t,Math.min(n,e))}function Z(e){return Boolean(window.chrome)&&e.gpu&&/amd\sradeon\s(pro|rx)\s5\d\d\d/gi.test(e.gpu)||U()&&!A.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function O(e){if(!e)return[];for(var t=[],n=0;n<e.size();n++)t.push(e.get(n));return t}function _(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function H(e){var t=h({},e);return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function N(e){return _()?{onTouchEnd:e}:{onClick:e}}var j=function(e){return 0===(null==e?void 0:e.$$.count.value)?null:e},V=function(e){function t(t,n){void 0===n&&(n=!1);var o=e.call(this)||this;return o.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},o.handleGestureStart=function(e){e.preventDefault(),o.state.lastGestureScale=e.scale},o.handleGestureChange=function(e){e.preventDefault();var t=e.scale/o.state.lastGestureScale;o.state.lastGestureScale=e.scale;var n=o.getCorrectPointerPosition(e);o.emitZoomEvent(t,n)},o.handleGestureEnd=function(e){e.preventDefault()},o.updateMousePosition=function(e){o.emit("pointermove",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.updateGlobalMousePosition=function(e){o.emit("globalpointermove",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.handleTouchStart=function(e){e.preventDefault(),o.handleTouchPinchToZoomStart(e),o.emit("pointerdown",{type:"touch",position:o.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},o.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),o.emit("pointerdown",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},o.handleTouchMove=function(e){o.handleTouchPinchToZoomChange(e),o.emit("pointermove",{type:"touch",position:o.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},o.handleMouseMove=function(e){o.updateMousePosition(e)},o.handleGlobalTouchMove=function(e){o.emit("globalpointermove",{type:"touch",position:o.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},o.handleGlobalMouseMove=function(e){o.updateGlobalMousePosition(e)},o.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(o.state.pinchToZoomLastDistance=o.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},o.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var n=o.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),r=o.getCorrectPointerPosition(e),i=1+.004*(n-o.state.pinchToZoomLastDistance);o.state.pinchToZoomLastDistance=n,o.emitZoomEvent(i,r)}},o.handleTouchEnd=function(e){var t=o.getCorrectPointerPosition(e);o.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},o.handleMouseUp=function(e){o.emit("pointerup",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.debouncedUpdateMousePosition=k(o.updateMousePosition,40),o.debouncedUpdateGlobalMousePosition=k(o.updateGlobalMousePosition,40),o.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!o.state.isCtrlPressed,n=e.metaKey||t||o.state.isCtrlPressed;if(o.debouncedUpdateMousePosition(e),o.debouncedUpdateGlobalMousePosition(e),n){var r=t?-1:1,i=o.getCorrectPointerPosition(e),a=1+.005*e.deltaY*r;o.emitZoomEvent(a,i)}else o.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.target=t,o.targetBounds=t.getBoundingClientRect(),o.listenersCollector=new I(n),o.addListeners(),o.targetResizeObserver=new ResizeObserver(o.updateTargetBounds.bind(o)),o.targetResizeObserver.observe(o.target),o}return d(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){_()||(this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart,{capture:!0}),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange,{capture:!0}),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd,{capture:!0}))},t.prototype.clampPointerToTargetBounds=function(e){return{x:e.x-this.targetBounds.x,y:e.y-this.targetBounds.y}},t.prototype.getCorrectPointerPosition=function(e){var t,n={x:0,y:0};if((null===(t=e.touches)||void 0===t?void 0:t.length)>1){var o=e,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=B(e);return this.clampPointerToTargetBounds(n)},t.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},t.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.targetResizeObserver.disconnect()},t.prototype.setDisable=function(e){this.listenersCollector.setDisabled(e)},t}(F),J=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.handleKeyUp=function(e){n.emit("keyUp",e.code)},n.target=t,n.addListeners(),n}return d(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(F),K=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now()}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(t," ms")}var n=(e/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},e}();function Y(e){setTimeout((function(){e()}),0)}var $=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.prototype.logDebug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,v(["log","debug"],e,!1))},t.prototype.logWarning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,v(["log","warn"],e,!1))},t.prototype.logError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,v(["log","error"],e,!1))},t}(F)),X=function(e,r){var i=t(e);i.current=e;var a=t((function(){}));return n((function(){var e=k((function(){i.current()}),r);return a.current=e,function(){e.cancel()}}),[r]),o((function(){return a.current()}),[])},q=function(e){function t(t){var n,o=this;return(o=e.call(this)||this).listenersCollector=new I,o.size={width:0,height:0},o.pixelRatio=1,o.maxPixelRatio=2,o.handleCanvasResizeObserver=function(e){o.resizeCanvas(e[0].contentRect)},o.resizeCanvas=function(e){var t=e.width,n=e.height;window.requestAnimationFrame((function(){o.setSize(t,n),o.emit("resize",t,n,o.getDevicePixelRatio())}))},o.getCanvasCenterPoint=function(){var e=o.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},o.container=t.container,o.canvas=t.canvas,o.maxPixelRatio=null!==(n=t.maxPixelRatio)&&void 0!==n?n:o.maxPixelRatio,o.canvasResizeObserver=new ResizeObserver(o.handleCanvasResizeObserver),o.canvasResizeObserver.observe(o.container),o.listenersCollector.add(window,"orientationchange",o.handleDeviceOrientationChange),o.setSize(o.container.clientWidth,o.container.clientHeight),o}return d(t,e),t.prototype.setSize=function(e,t){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.size.width=e*this.pixelRatio,this.size.height=t*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},t.prototype.getDevicePixelRatio=function(){return z(window.devicePixelRatio,1,this.maxPixelRatio)},t.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},t.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},t}(F),Q=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===R.release},e.prototype.init=function(){return p(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return g(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:e=a.sent(),t=e.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,t({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:this.settings.webglVersion,bridge:this.settings.jsBridge,locateFile:function(e){return i.settings.locateFile.replace("{file}",e)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new S("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerTypeEnum.Unset,mouse:this.instance.PRUserPointerTypeEnum.Mouse,touch:this.instance.PRUserPointerTypeEnum.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorTypeEnum.Auto.value]="auto",r[this.instance.PRCursorTypeEnum.Default.value]="default",r[this.instance.PRCursorTypeEnum.Pointer.value]="pointer",r[this.instance.PRCursorTypeEnum.Grab.value]="grab",r[this.instance.PRCursorTypeEnum.Grabbing.value]="grabbing",r),this.prototypeResizeModeToWASMMap={Fit:this.instance.PrototypeResizeModeWasmEnum.Fit,FillWidth:this.instance.PrototypeResizeModeWasmEnum.FillWidth,ActualSize:this.instance.PrototypeResizeModeWasmEnum.ActualSize},[2]}}))}))},e.prototype.makeWebGLContext=function(e,t){var n;void 0===t&&(t={});var o=h({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},t),r=this.instance.GL.createContext(e,o);if(!r)throw new S("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");var i=null===(n=this.instance.GL.getContext(r))||void 0===n?void 0:n.GLctx;return i&&i.getExtension("WEBGL_debug_renderer_info"),r},e.prototype.createWebGLTextureFromImage=function(e,t){var n=this.instance.GL,o=n.getContext(t);if(!o)throw new Error("Unable to retrieve emscripten WebGL context from handle");var r=o.GLctx;if(!r)throw new Error("WebGL context is null");var i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);var a=n.getNewId(n.textures);return n.textures[a]=i,r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.bindTexture(r.TEXTURE_2D,null),a},e.prototype.destroyWebGLContext=function(e){var t;$.logDebug("Destroying WebGL context");var n=null===(t=this.instance)||void 0===t?void 0:t.GL.getContext(e);if(n){this.instance.GL.deleteContext(e);var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),$.logDebug("WebGL destroyed"),!0;$.logError("WEBGL_lose_context not available. Not possible to destroy WebGL context manually.")}else $.logError("WebGL context not found while trying to destroy it")},e.prototype.importModule=function(){return this.isReleaseMode()?import("./web-renderer-release-28643f00.js"):import("./web-renderer-debug-d3774856.js")},e.prototype.mapToCSSCursor=function(e){return this.prCursorTypeToCSSCursorMap[e.value]},e.prototype.mapToPRPointerType=function(e){var t;return null!==(t=this.pointerTypeToWASMMap[e])&&void 0!==t?t:this.instance.PRUserPointerTypeEnum.Unset},e.prototype.mapPointerInfo=function(e){return h(h({},e),{type:this.mapToPRPointerType(e.type)})},e.prototype.mapResizeMode=function(e){return this.prototypeResizeModeToWASMMap[e]},e}();function ee(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){t(o)},o.onerror=function(e){n(e)},o.src=e}))}var te,ne,oe,re,ie,ae,se,ue,le,ce,de,he,pe,ge,ve,fe,me,ye,be,we,Ce,Pe=function(){function e(e,t,n){this.canvas=e,this.container=t,this.filePath=n,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:1,g:1,b:1,a:1},this.mode=R.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=A,this.manualInitialization=!1,this.panBoundariesPadding=0,this.selectedArtboard=null,this.initialZoom=null,this.initialPan=null}return e.FromSettings=function(t){return Object.assign(new e(t.canvas,t.container,t.filePath),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),Ee={png:"image/png",jpg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",raster:"binary/octet-stream"};!function(e){e[e.None=0]="None",e[e.Scale=1]="Scale",e[e.Width=2]="Width",e[e.Height=3]="Height"}(te||(te={})),function(e){e[e.None=0]="None",e[e.PNG=1]="PNG",e[e.JPG=2]="JPG",e[e.TIFF=3]="TIFF",e[e.WEBP=4]="WEBP",e[e.PDF=5]="PDF",e[e.EPS=6]="EPS",e[e.SVG=7]="SVG",e[e.HEIC=8]="HEIC"}(ne||(ne={})),function(e){e[e.Color=0]="Color",e[e.Gradient=1]="Gradient",e[e.Pattern=2]="Pattern"}(oe||(oe={})),function(e){e[e.Fit=0]="Fit",e[e.Fill=1]="Fill",e[e.Stretch=2]="Stretch",e[e.Tile=3]="Tile"}(re||(re={})),function(e){e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Angular=2]="Angular"}(ie||(ie={})),function(e){e[e.Center=0]="Center",e[e.Inside=1]="Inside",e[e.Outside=2]="Outside"}(ae||(ae={})),function(e){e[e.Butt=0]="Butt",e[e.Round=1]="Round",e[e.Square=2]="Square"}(se||(se={})),function(e){e[e.Miter=0]="Miter",e[e.Round=1]="Round",e[e.Bevel=2]="Bevel"}(ue||(ue={})),function(e){e[e.Motion=0]="Motion",e[e.Zoom=1]="Zoom",e[e.Background=2]="Background",e[e.Gaussian=3]="Gaussian"}(le||(le={})),function(e){e[e.Normal=0]="Normal",e[e.DestAtop=1]="DestAtop",e[e.Clear=2]="Clear",e[e.Source=3]="Source",e[e.Darken=4]="Darken",e[e.Multiply=5]="Multiply",e[e.ColorBurn=6]="ColorBurn",e[e.Lighten=7]="Lighten",e[e.Screen=8]="Screen",e[e.ColorDodge=9]="ColorDodge",e[e.Overlay=10]="Overlay",e[e.SoftLight=11]="SoftLight",e[e.HardLight=12]="HardLight",e[e.Difference=13]="Difference",e[e.Exclusion=14]="Exclusion",e[e.Hue=15]="Hue",e[e.Saturation=16]="Saturation",e[e.Color=17]="Color",e[e.Luminosity=18]="Luminosity",e[e.PlusLighter=19]="PlusLighter",e[e.PlusDarker=20]="PlusDarker"}(ce||(ce={})),function(e){e[e.Artboard=0]="Artboard",e[e.SymbolMaster=1]="SymbolMaster",e[e.SymbolInstance=2]="SymbolInstance",e[e.Hotspot=3]="Hotspot",e[e.Bitmap=4]="Bitmap",e[e.Group=5]="Group",e[e.Oval=6]="Oval",e[e.Polygon=7]="Polygon",e[e.Rectangle=8]="Rectangle",e[e.ShapeGroup=9]="ShapeGroup",e[e.ShapePath=10]="ShapePath",e[e.Star=11]="Star",e[e.Text=12]="Text",e[e.Triangle=13]="Triangle",e[e.Slice=14]="Slice"}(de||(de={})),function(e){e[e.Angled=2]="Angled",e[e.InsideArc=4]="InsideArc",e[e.InsideSquare=3]="InsideSquare",e[e.Rounded=0]="Rounded",e[e.Smooth=1]="Smooth"}(he||(he={})),function(e){e[e.Lowercase=2]="Lowercase",e[e.None=0]="None",e[e.Uppercase=1]="Uppercase"}(pe||(pe={})),function(e){e[e.Center=1]="Center",e[e.Justified=3]="Justified",e[e.Left=0]="Left",e[e.Right=2]="Right"}(ge||(ge={})),function(e){e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom"}(ve||(ve={})),function(e){e[e.LineThrough=2]="LineThrough",e[e.Underline=1]="Underline",e[e.None=0]="None"}(fe||(fe={})),function(e){e[e.Unset=0]="Unset",e[e.Mouse=1]="Mouse",e[e.Touch=2]="Touch"}(me||(me={})),function(e){e[e.Auto=0]="Auto",e[e.Default=1]="Default",e[e.Pointer=2]="Pointer",e[e.Grab=3]="Grab",e[e.Grabbing=4]="Grabbing"}(ye||(ye={})),function(e){e[e.PNG=0]="PNG",e[e.JPG=1]="JPG",e[e.WEBP=2]="WEBP",e[e.PDF=4]="PDF",e[e.SVG=3]="SVG",e[e.RASTER=5]="RASTER"}(be||(be={})),function(e){e[e.Screen=0]="Screen",e[e.Overlay=1]="Overlay"}(we||(we={})),function(e){e[e.Fit=0]="Fit",e[e.FillWidth=1]="FillWidth",e[e.ActualSize=2]="ActualSize"}(Ce||(Ce={}));var Me=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(e.x,e.y,n.wasmModule.mapPointerInfo(t)))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(e)))},n.settings=Pe.FromSettings(t),$.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container),n.canvasManager=new q({container:n.settings.container,canvas:n.settings.canvas}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.exporterFetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,x()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=Z(this.deviceInfo),$.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initCanvasRendererWasm()];case 4:return t.sent(),[4,this.setFile(this.settings.filePath)];case 5:return t.sent(),this.settings.selectedArtboard&&this.selectArtboard(this.settings.selectedArtboard),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof S?e:new S("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=null!==this.settings.initialZoom,r=null!==this.settings.initialPan;o||r?(o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(e=this.settings.initialPan)||void 0===e?void 0:e.x)||0,(null===(t=this.settings.initialPan)||void 0===t?void 0:t.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},t.prototype.startRendering=function(){var e;this.traceInitialRender=new K("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.pageCanvasWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){$.logDebug("[C++] ".concat(e))},logWarning:function(e){$.logWarning("[C++] ".concat(e))},logError:function(e){$.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):($.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):($.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(){var t=e.getPan();e.emit("cameraPanChange",(null==t?void 0:t.x)||0,(null==t?void 0:t.y)||0)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},fetch:this.handleJSBridgeFetch.bind(this),exporterFetch:this.handleJSBridgeExporterFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onLayerClick:function(t){e.emit("layerClick",t)},onLayerMouseHoverChange:function(t){e.emit("layerMouseHoverChange",t)},onSceneChange:function(){e.emit("sceneChange")},onFragmentLoad:function(t){e.emit("fragmentLoad",t)}}},t.prototype.handleJSBridgeExporterFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l;return g(this,(function(c){if(!this.wasmModule)return[2];if(this.disposed)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0,buffer:new Uint8Array(t.data.buffer)},o.exec(n);break;case"error":$.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(a=null===(i=t.data.error)||void 0===i?void 0:i.statusCode)&&void 0!==a?a:500,statusText:null!==(u=null===(s=t.data.error)||void 0===s?void 0:s.statusText)&&void 0!==u?u:"Unknown error",contentType:null!==(l=t.data.contentType)&&void 0!==l?l:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:0,width:0,height:0})}return this.exporterFetchWorker.removeEventListener("message",r),[2]}))}))};this.exporterFetchWorker.addEventListener("message",r),this.exporterFetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return g(this,(function(p){switch(p.label){case 0:if(!this.wasmModule)return[2];if(this.disposed)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ee(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return $.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:0,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new K("WasmModuleDownload"),this.wasmModule=new Q({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),$.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){if(this.disposed)return[2];try{if(!this.wasmModule)throw Error("WASM module not initialized");this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRendererWasm(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new S("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}if(!this.pageCanvasWasm)return[2];if(!(e=this.pageCanvasWasm.getUserEventsCollector()))throw new S("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=e,this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.pageCanvasWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&($.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),$.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;(null===(e=this.wasmModule)||void 0===e?void 0:e.destroyWebGLContext(this.webglCtxHandle))||$.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return p(this,void 0,void 0,(function(){var t=this;return g(this,(function(n){return this.disposed?[2]:(this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=t.pageCanvasWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("12.1.2");t.emit("fileReady",i,o,r),n()}),(function(){return o(new S("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))])}))}))},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),$.logError(e),e.cause&&$.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&($.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getPRFileCachedData=function(){var e;if(!this.pageCanvasWasm)return null;if((null===(e=this.prFileHandle)||void 0===e?void 0:e.filePath)!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.prFileHandle={handle:t,filePath:this.settings.filePath,artboards:O(t.getArtboards())}}return this.prFileHandle},t.prototype.getPRFile=function(){var e;return null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.handle},t.prototype.releasePRFileHandle=function(){var e,t;null===(t=null===(e=this.prFileHandle)||void 0===e?void 0:e.handle)||void 0===t||t.delete(),this.prFileHandle=void 0},t.prototype.getRootNodeExtent=function(){var e,t,n;return null!==(n=null===(t=null===(e=this.getPRFile())||void 0===e?void 0:e.getRootNode())||void 0===t?void 0:t.getAbsoluteExtent())&&void 0!==n?n:null},t.prototype.getPRFileArtboards=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.artboards)&&void 0!==t?t:[]},t.prototype.getArtboardAtPosition=function(e,t){if(!this.pageCanvasWasm)return null;for(var n=this.getPRFileArtboards(),o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n;s<u.length;s++){var l=u[s],c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(i>=l.bounds.x&&a>=l.bounds.y&&i<=c&&a<=d)return l.getNode()}return null},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n;return null===(n=this.pageCanvasWasm)||void 0===n?void 0:n.mapRelativePositionToCameraPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=e/o,i=t/o;return{x:n.x-r,y:n.y-i}},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o=null!=t?t:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(e,o.x,o.y)},t.prototype.getPan=function(){var e,t,n=this.getRootNodeExtent();if(!n)return{x:0,y:0};var o=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getPan(),r=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},t.prototype.getZoom=function(){var e;return(null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom())||0},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1);var r=this.getRootNodeExtent();if(r){var i=e,a=t,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);i+=this.canvasManager.size.width/u,a+=this.canvasManager.size.height/u}var l=(i-r.x)*s,c=(a-r.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(l,c)}},t.prototype.selectArtboard=function(e){var t;this.pageCanvasWasm&&(this.settings.selectedArtboard=e,null===(t=this.pageCanvasWasm)||void 0===t||t.selectArtboard(null!=e?e:""))},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.exportNode=function(e,t){return p(this,void 0,void 0,(function(){var n=this;return g(this,(function(o){return[2,new Promise((function(o,r){if(n.wasmModule&&n.pageCanvasWasm){var i=t.format.toUpperCase(),a=be[i];if(void 0!==a){var s={format:{value:a},backingScale:t.backingScale};n.pageCanvasWasm.exportNode(e,s,(function(e,n,i,a){if(null!==e){var s=Ee[t.format],u=new Blob([e.buffer],{type:s});o({blob:u,width:n,height:i,bytesPerPixel:a})}else r("Export failed")}))}else r("Unsupported export format: ".concat(t.format))}else r("Wasm module is not ready or was disposed.")}))]}))}))},t.prototype.dispose=function(){var e,t,n,o;try{this.disposeFetchWorker(),this.disposed=!0,this.detachAllListeners(),this.releasePRFileHandle(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.pageCanvasWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.pageCanvasWasm)||void 0===n||n.delete(),null===(o=this.renderTarget)||void 0===o||o.delete(),this.pageCanvasWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new S("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(F),Le=r(void 0),xe=r(void 0),Re=r(void 0),We=r(void 0),Se=r(void 0),Te=r("auto"),Fe=r(void 0),Ie=function(){var e=i(Fe);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},Ae=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:t.pan});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return h(h({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return h(h({},e),{isCameraZooming:!1});case"on-camera-move-start":return h(h({},e),{isCameraMoving:!0});case"on-camera-move-end":return h(h({},e),{isCameraMoving:!1});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});default:return e}},De=function(n){var r=t(null),i=t(null),u=a(Ae,{pan:null,zoom:null,status:{type:"IDLE"},isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),l=u[0],c=l.status,d=l.zoom,p=l.pan,g=l.isCameraZooming,v=l.isCameraMoving,f=l.cursor,m=u[1],y=o((function(e){return m({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return m({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){m({type:"on-status",status:e})}),[]),C=o((function(){return m({type:"on-camera-zoom-start"})}),[]),P=o((function(){return m({type:"on-camera-zoom-end"})}),[]),E=o((function(){return m({type:"on-camera-move-start"})}),[]),M=o((function(){return m({type:"on-camera-move-end"})}),[]),L=o((function(e){return m({type:"on-cursor-change",cursor:e})}),[]),x=o((function(){if(r.current){var e=r.current.getPan();m({type:"on-pan",pan:e})}}),[]),R=o((function(){var e=r.current;e&&($.logDebug("Provider dispose"),e.off("status",w),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.off("cameraZoomStart",C),e.off("cameraZoomEnd",P),e.off("cameraMoveStart",E),e.off("cameraMoveEnd",M),e.off("cursorChange",L),e.off("sceneChange",x),e.dispose(),r.current=null,m({type:"dispose"}))}),[w,b,y,C,P,E,M,L,x]),W=o((function(e,t,n){if(""!==e&&t&&n&&i.current){$.logDebug("Provider init");var o=new Me(h(h({},i.current),{filePath:e,container:n,canvas:t,manualInitialization:!0}));o.on("status",w),o.on("cameraZoomChange",y),o.on("cameraPanChange",b),o.on("cameraZoomStart",C),o.on("cameraZoomEnd",P),o.on("cameraMoveStart",E),o.on("cameraMoveEnd",M),o.on("cursorChange",L),o.on("sceneChange",x),r.current=o,o.init()}}),[w,y,b,C,P,E,M,L,x]),S=o((function(e){var t,n;$.logDebug("Provider setSettings"),e.backgroundColor&&(null===(t=r.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(n=r.current)||void 0===n||n.selectArtboard(e.selectedArtboard||null),i.current=e}),[]),T=o((function(){return r.current}),[]),F=s((function(){return{dispose:R,init:W,setSettings:S,getInstance:T,dispatch:m}}),[R,W,S,T]);return e.createElement(Fe.Provider,{value:F},e.createElement(Le.Provider,{value:c},e.createElement(xe.Provider,{value:d},e.createElement(Se.Provider,{value:p},e.createElement(Re.Provider,{value:g},e.createElement(We.Provider,{value:v},e.createElement(Te.Provider,{value:f},n.children)))))))},Ge=function(e,t){var n=(0,Ie().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},Ue=function(){var e=i(Le);if(void 0===e)throw Error("useStatus must be used within a provider");return e},ke=function(){var e=i(xe);if(void 0===e)throw Error("useZoom must be used within a provider");return e},Be=function(){var e=i(Se);if(void 0===e)throw Error("usePan must be used within a provider");return e},ze=function(){var e=i(Te);if(void 0===e)throw Error("useCursor must be used within a provider");return e},Ze=function(){var e=i(Re);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},Oe=function(){var e=i(We);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},_e=function(){var e=(0,Ie().getInstance)(),t=Ue();return s((function(){return e&&"READY"===t.type?e.getPRFile():null}),[e,t])},He=function(){var e=(0,Ie().getInstance)(),t=Ue();return s((function(){return e&&"READY"===t.type?e.getPRFileArtboards():null}),[e,t])},Ne=function(){var e,t,n,o,r=_e(),i=l(null),a=i[0],c=i[1],d=X((function(){c((function(e){var t,n,o,i=null!==(o=null===(n=null===(t=j(r))||void 0===t?void 0:t.getRootNode())||void 0===n?void 0:n.getAbsoluteExtent())&&void 0!==o?o:null;return(null==e?void 0:e.width)===(null==i?void 0:i.width)&&(null==e?void 0:e.height)===(null==i?void 0:i.height)&&(null==e?void 0:e.x)===(null==i?void 0:i.x)&&(null==e?void 0:e.y)===(null==i?void 0:i.y)?e:i}))}),16);Ge("sceneChange",d),u((function(){d()}),[d]);var h=null!==(e=null==a?void 0:a.x)&&void 0!==e?e:0,p=null!==(t=null==a?void 0:a.y)&&void 0!==t?t:0,g=null!==(n=null==a?void 0:a.width)&&void 0!==n?n:0,v=null!==(o=null==a?void 0:a.height)&&void 0!==o?o:0;return s((function(){return{x:h,y:p,width:g,height:v}}),[h,p,g,v])},je=function(){var e=(0,Ie().getInstance)();return o((function(t){null==e||e.setZoom(t)}),[e])},Ve=function(){var e=je(),t=ke();return o((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},Je=function(){var e=je(),t=ke();return o((function(){"number"==typeof t&&e(t/2)}),[e,t])},Ke=function(){var e=(0,Ie().getInstance)();return o((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},Ye=function(){var e=(0,Ie().getInstance)();return o((function(){null==e||e.zoomToFit()}),[e])},$e=function(){var e=(0,Ie().getInstance)();return o((function(){null==e||e.looseWebGLContext()}),[e])},Xe=function(){var e=(0,Ie().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return g(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},qe=function(){var e=(0,Ie().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return g(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Qe=function(){var e=(0,Ie().getInstance)();return o((function(t){null==e||e.setIsCameraLocked(t)}),[e])},et=function(){var e=(0,Ie().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},tt=function(){var e=(0,Ie().getInstance)(),t=_e();return o((function(n,o){return e&&t?e.exportNode(n,o):Promise.reject("WebRenderer instance not ready")}),[e,t])};function nt(e){var n=t(e);n.current=e;var r=o((function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];n.current.apply(n,v([e],t,!1))}),[]);u((function(){return $.on("log",r),function(){$.off("log",r)}}),[r])}var ot={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},rt={position:"absolute",top:0,left:0},it=function(n){var r=n.filePath,i=n.locateFile,a=n.imagesURLFormat,c=n.imagesURLMap,d=n.fragmentsURLFormat,p=n.fragmentsURLMap,g=n.backgroundColor,v=n.mode,f=n.showTilesBorders,m=n.minimumZoomLevel,y=n.maximumZoomLevel,b=n.preserveDrawingBuffer,w=n.panBoundariesPadding,C=n.initialPan,P=n.initialZoom,E=n.children,M=n.containerProps,L=n.canvasProps,x=n.featureFlags,R=n.selectedArtboard,W=t(null),S=t(null),T=l(!1),F=T[0],I=T[1],A=o((function(){return I(!0)}),[]),D=Ie(),G=D.dispose,U=D.init,k=D.setSettings,B=ze(),z=Ue();Ge("allImagesReady",A),u((function(){return $.logDebug("CanvasRenderer mounted"),function(){return $.logDebug("CanvasRenderer unmounted")}}),[]),u((function(){k({locateFile:i,imagesURLFormat:a,imagesURLMap:c,fragmentsURLFormat:d,fragmentsURLMap:p,backgroundColor:g,mode:v,showTilesBorders:f,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:b,panBoundariesPadding:w,initialPan:C,initialZoom:P,featureFlags:x,selectedArtboard:R})}),[k,i,a,c,d,p,g,v,f,m,y,b,w,C,P,x,R]),u((function(){if(r)return U(r,W.current,S.current),function(){G()}}),[G,U,r]);var Z=s((function(){var e;return null!==(e=n.cursor)&&void 0!==e?e:B}),[n.cursor,B]),O=s((function(){return h(h({},ot),{cursor:Z})}),[Z]);return e.createElement("div",h({},M,{ref:S,style:O}),r&&e.createElement("canvas",h({},L,{key:r,ref:W,"data-sketchweb-all-images-ready":F,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==z?void 0:z.type.toLowerCase())||"null"),style:rt})),"READY"===(null==z?void 0:z.type)&&E)},at=function(){function e(e,t,n,o){this.prototypeStructure=e,this.startArtboardUUID=t,this.canvas=n,this.container=o,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:0,g:0,b:0,a:1},this.mode=R.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=A,this.manualInitialization=!1,this.highlightHotspots=!0,this.resizeMode=W.Fit,this.assetsManagerLimits={maxDepthForBackgroundRequests:1,maxArtboardsForBackgroundRequests:5,maxInitialLoadingDepth:2,maxInitialArtboardToLoad:10},this.disableInteraction=!1}return e.FromSettings=function(t){return Object.assign(new e(t.prototypeStructure,t.startArtboardUUID,t.canvas,t.container),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),st=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(e.x,e.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(t))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.restartPrototype=function(e){var t;null===(t=n.playerWasm)||void 0===t||t.restartPrototype(e)},n.navigateToFirstFlow=function(){var e;null===(e=n.playerWasm)||void 0===e||e.navigateToFirstFlow()},n.goBack=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goBack()},n.goForwards=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goForwards()},n.setResizeMode=function(e){var t;if(n.wasmModule){var o=n.wasmModule.mapResizeMode(e);null===(t=n.playerWasm)||void 0===t||t.setResizeMode(o)}},n.getScreen=function(e){var t;void 0===e&&(e=!0);var o=null===(t=n.playerWasm)||void 0===t?void 0:t.getJSScreen(e);return o?{layers:O(o.layers)}:{layers:[]}},n.settings=at.FromSettings(t),$.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container,n.settings.disableInteraction),n.canvasManager=new q({container:n.settings.container,canvas:n.settings.canvas,maxPixelRatio:3}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,x()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=Z(this.deviceInfo),$.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initPlayerWasm()];case 4:return t.sent(),[4,this.startDownload()];case 5:return t.sent(),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof S?e:new S("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new K("WasmModuleDownload"),this.wasmModule=new Q({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.startDownload=function(){var e=this;return this.setStatus({type:"LOADING_FILE"}),new Promise((function(t){var n;null===(n=e.playerWasm)||void 0===n||n.startDownload((function(){t()}))}))},t.prototype.startRendering=function(){var e;this.traceInitialRender=new K("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.playerWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){$.logDebug("[C++] ".concat(e))},logWarning:function(e){$.logWarning("[C++] ".concat(e))},logError:function(e){$.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):($.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):($.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(t,n){e.emit("cameraPanChange",t,n)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPrototypeStateWillChange:function(t,n,o){e.emit("prototypeStateWillChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},onPrototypeStateChange:function(t,n,o){e.emit("prototypeStateChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeUnhandledPointerUp:function(){e.emit("prototypeUnhandledPointerUp")},onSceneChange:function(){e.emit("sceneChange")}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return g(this,(function(p){switch(p.label){case 0:if(this.disposed||!this.wasmModule)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ee(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return $.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initPlayerWasm=function(){var e,t;return p(this,void 0,void 0,(function(){var n,o,r,i,a,s,u,l,c,d,p,v,f,m,y,b,w,C,P,E,M;return g(this,(function(g){try{if(!this.wasmModule)throw Error("WASM module not initialized");for(this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion}),n=this.wasmModule.instance,o=n.RenderTarget,r=n.PrototypeRendererWasm,i=n.PrototypeStructureArtboardVector,a=n.PrototypeStructureFlowVector,s=n.PrototypeStructureAssetVector,u=n.PrototypeStructureFlowTypeEnum,this.renderTarget=o.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),l={artboards:new i},c={Overlay:u.Overlay,Screen:u.Screen},d=0,p=this.settings.prototypeStructure.artboards;d<p.length;d++){for(v=p[d],f=new a,m=0,y=null!==(e=v.flows)&&void 0!==e?e:[];m<y.length;m++)b=y[m],f.push_back(h(h({},b),{type:c[b.type]}));for(w=new s,C=0,P=null!==(t=v.assets)&&void 0!==t?t:[];C<P.length;C++)E=P[C],w.push_back(E);l.artboards.push_back(h(h({},v),{flows:f,assets:w}))}this.playerWasm=new r(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID,l,this.settings.highlightHotspots,this.settings.assetsManagerLimits)}catch(e){throw new S("WASM_ERROR","An error occurred while trying to create the PrototypeRenderer WASM object.",e)}if(!(M=this.playerWasm.getUserEventsCollector()))throw new S("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=M,this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.setResizeMode(this.settings.resizeMode),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.playerWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.playerWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),$.logError(e),e.cause&&$.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&($.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getStatus=function(){return this.status},t.prototype.getArtboardAtPosition=function(e,t){var n=this.playerWasm;if(!n)return null;for(var o=n.getJSScreen(!1),r=n.getPan(),i=n.getZoom(),a=(e-r.x)/i,s=(t-r.y)/i,u=o.layers.size()-1;u>=0;u-=1){var l=o.layers.get(u);if(l&&"artboard"===l.type){var c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(a>=l.bounds.x&&s>=l.bounds.y&&a<=c&&s<=d)return l.getNode()}}return null},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.dispose=function(){var e,t,n;try{this.disposeFetchWorker(),this.detachAllListeners(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.playerWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.playerWasm)||void 0===n||n.delete(),this.renderTarget.delete(),this.playerWasm=void 0,this.wasmModule=void 0,this.disposed=!0}catch(e){this.fail(new S("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n=this.playerWasm;return n?n.mapRelativePositionToCameraPosition(e,t):null},t.prototype.updateHighlightHotspotsSetting=function(e){var t=this.playerWasm;if(!t)return null;t.updateHighlightHotspotsSetting(e)},t}(F),ut=r(void 0),lt=r("auto"),ct=r(void 0),dt=r(void 0),ht=r(void 0),pt=r(void 0),gt=function(){var e=i(pt);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},vt=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},cursor:"auto"});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});case"on-prototype-state-will-change":return h(h({},e),{prototypeState:h(h({},e.prototypeState),{isChanging:!0})});case"on-prototype-state-change":return h(h({},e),{prototypeState:h(h(h({},e.prototypeState),t.prototypeState),{isChanging:!1})});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:{x:t.pan.x,y:t.pan.y}});default:return e}},ft=function(n){var r=t(null),i=t(null),u=a(vt,{status:{type:"IDLE"},cursor:"auto",prototypeState:{currentArtboardId:"",canGoBack:!1,canGoForwards:!1,isChanging:!1},zoom:1,pan:{x:0,y:0}}),l=u[0],c=l.status,d=l.cursor,p=l.prototypeState,g=l.zoom,v=l.pan,f=u[1],m=o((function(e){f({type:"on-status",status:e})}),[]),y=o((function(e){return f({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return f({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){return f({type:"on-cursor-change",cursor:e})}),[]),C=o((function(){return f({type:"on-prototype-state-will-change"})}),[]),P=o((function(e){return f({type:"on-prototype-state-change",prototypeState:e})}),[]),E=o((function(){var e=r.current;e&&($.logDebug("Provider dispose"),e.off("status",m),e.off("cursorChange",w),e.off("prototypeStateWillChange",C),e.off("prototypeStateChange",P),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.dispose(),r.current=null,f({type:"dispose"}))}),[m,w,C,P,b,y]),M=o((function(e,t){if(e&&t&&i.current){$.logDebug("Provider init");var n=new st(h(h({},i.current),{container:t,canvas:e,manualInitialization:!0}));n.on("status",m),n.on("cursorChange",w),n.on("prototypeStateWillChange",C),n.on("prototypeStateChange",P),n.on("cameraZoomChange",y),n.on("cameraPanChange",b),r.current=n,n.init()}}),[m,w,C,P,b,y]),L=o((function(e){var t,n,o,a,s,u,l,c;$.logDebug("Provider setSettings"),e.backgroundColor&&e.backgroundColor!=(null===(t=i.current)||void 0===t?void 0:t.backgroundColor)&&(null===(n=r.current)||void 0===n||n.setBackgroundColor(e.backgroundColor)),(null===(o=i.current)||void 0===o?void 0:o.resizeMode)!=e.resizeMode&&(null===(a=r.current)||void 0===a||a.setResizeMode(e.resizeMode||W.Fit)),void 0!==e.highlightHotspots&&(null===(s=i.current)||void 0===s?void 0:s.highlightHotspots)!==e.highlightHotspots&&(null===(u=r.current)||void 0===u||u.updateHighlightHotspotsSetting(e.highlightHotspots)),e.disableInteraction!==(null===(l=i.current)||void 0===l?void 0:l.disableInteraction)&&(null===(c=r.current)||void 0===c||c.gestureManager.setDisable(e.disableInteraction||!1)),i.current=e}),[]),x=o((function(){return r.current}),[]),R=s((function(){return{dispose:E,init:M,setSettings:L,getInstance:x,dispatch:f}}),[E,M,L,x]);return e.createElement(pt.Provider,{value:R},e.createElement(ut.Provider,{value:c},e.createElement(lt.Provider,{value:d},e.createElement(ct.Provider,{value:p},e.createElement(dt.Provider,{value:g},e.createElement(ht.Provider,{value:v},n.children))))))},mt=function(){var e=(0,gt().getInstance)();return o((function(t){null==e||e.restartPrototype(t)}),[e])},yt=function(){var e=(0,gt().getInstance)();return o((function(){null==e||e.navigateToFirstFlow()}),[e])},bt=function(){var e=(0,gt().getInstance)();return o((function(){null==e||e.goBack()}),[e])},wt=function(){var e=(0,gt().getInstance)();return o((function(){null==e||e.goForwards()}),[e])},Ct=function(){var e=(0,gt().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return g(this,(function(o){return[2,null==e?void 0:e.getArtboardAtPosition(t,n)]}))}))}),[e])},Pt=function(){var e=(0,gt().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},Et=function(){var e=i(ut);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},Mt=function(){var e=i(lt);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},Lt=function(){var e=i(ct);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},xt=function(){var e=i(dt);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},Rt=function(){var e=i(ht);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},Wt=function(e,t){var n=(0,gt().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function St(){var e=(0,gt().getInstance)();return o((function(t){return void 0===t&&(t=!0),null==e?void 0:e.getScreen(t)}),[e])}var Tt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ft={position:"absolute",top:0,left:0},It=function(n){var o=n.locateFile,r=n.imagesURLFormat,i=n.imagesURLMap,a=n.backgroundColor,l=n.mode,c=n.showTilesBorders,d=n.minimumZoomLevel,p=n.maximumZoomLevel,g=n.preserveDrawingBuffer,v=n.children,f=n.containerProps,m=n.canvasProps,y=n.featureFlags,b=n.startArtboardUUID,w=n.prototypeStructure,C=n.fragmentsURLFormat,P=n.fragmentsURLMap,E=n.highlightHotspots,M=n.resizeMode,L=n.assetsManagerLimits,x=n.cursor,R=n.disableInteraction,W=t(null),S=t(null),T=gt(),F=T.dispose,I=T.init,A=T.setSettings,D=Et(),G=Mt(),U=("function"==typeof x?x(G):x)||G;u((function(){return $.logDebug("PrototypeRenderer mounted"),function(){return $.logDebug("PrototypeRenderer unmounted")}}),[]),u((function(){A({locateFile:o,imagesURLFormat:r,imagesURLMap:i,backgroundColor:a,mode:l,showTilesBorders:c,minimumZoomLevel:d,maximumZoomLevel:p,preserveDrawingBuffer:g,featureFlags:y,startArtboardUUID:b,prototypeStructure:w,fragmentsURLFormat:C,fragmentsURLMap:P,highlightHotspots:E,resizeMode:M,assetsManagerLimits:L,disableInteraction:R})}),[A,o,r,i,a,l,c,d,p,g,y,b,E,M,C,P,w,L,R]),u((function(){return I(W.current,S.current),function(){F()}}),[F,I]);var k=s((function(){return h(h({},Tt),{cursor:U})}),[U]);return e.createElement("div",h({},f,{ref:S,style:k}),e.createElement("canvas",h({},m,{ref:W,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==D?void 0:D.type.toLowerCase())||"null"),style:Ft})),"READY"===(null==D?void 0:D.type)&&v)},At={position:"absolute",inset:0,pointerEvents:"none"};function Dt(t){var n=t.visualize,r=void 0!==n&&n,i=St(),a=l((function(){return i()||null})),u=a[0],c=a[1],d=o((function(){c(i()||null)}),[i]);Wt("sceneChange",d);var p=s((function(){return h(h({},At),{opacity:r?1:0})}),[r]);return u?e.createElement("div",{style:p},u.layers.map((function(t,n){return e.createElement(Gt,{key:"".concat(n,"/").concat(t.id),bounds:t.bounds,id:t.id,name:t.name,type:t.type})}))):null}function Gt(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,a=xt(),u=Rt()||{x:0,y:0},l=u.x,c=u.y,d=s((function(){return h({position:"absolute",left:l/window.devicePixelRatio+n.x*a,top:c/window.devicePixelRatio+n.y*a,width:n.width*a,height:n.height*a,backgroundColor:"rgba(0, 255, 255, 0.2)",border:"2px dotted white"},"hotspot"===i?{cursor:"pointer",pointerEvents:"auto"}:{})}),[n.x,n.y,n.width,n.height,l,c,a,i]);return e.createElement("div",{style:d,"data-testid":"".concat(i,"-").concat(Ut(o),"-").concat(r),"data-entity-name":o,"data-entity-id":r,"data-entity-bounds-x":n.x,"data-entity-bounds-y":n.x,"data-entity-bounds-width":n.width,"data-entity-bounds-height":n.height})}function Ut(e){var t,n;return null!==(n=null===(t=e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))||void 0===t?void 0:t.join("-").toLowerCase())&&void 0!==n?n:""}export{We as CameraMoveContext,Re as CameraZoomingContext,Me as CanvasRenderer,De as CanvasRendererProvider,it as CanvasRendererReact,Te as CursorContext,A as DefaultFeatureFlags,F as EventEmitter,V as GestureManager,J as KeyboardManager,I as ListenersCollector,ye as PRCursorType,ce as PRMarinaBlendMode,ne as PRMarinaExportFormatType,le as PRMarinaLayerBlurType,ae as PRMarinaLayerBorderPosition,he as PRMarinaLayerCornerStyle,oe as PRMarinaLayerFillType,ie as PRMarinaLayerGradientType,ge as PRMarinaLayerHorizontalTextAlignment,re as PRMarinaLayerImageFillType,se as PRMarinaLayerLineCap,ue as PRMarinaLayerLineJoin,fe as PRMarinaLayerTextDecoration,pe as PRMarinaLayerTextTransform,de as PRMarinaLayerType,ve as PRMarinaLayerVerticalTextAlignment,te as PRMarinaVisibleScaleType,be as PRNodeExportFormat,me as PRUserPointerType,Se as PanContext,K as Performance,st as PrototypeRenderer,ft as PrototypeRendererProvider,It as PrototypeRendererReact,W as PrototypeResizeMode,Ce as PrototypeResizeModeWasm,we as PrototypeStructureFlowType,Dt as PrototypeTestOverlay,Le as StatusContext,S as WebRendererError,R as WebRendererMode,xe as ZoomContext,z as clamp,O as convertEmbindVectorToArray,k as debounce,B as extractPointer,Z as getSupportedWebGLVersion,D as getiOSVersion,T as isDefinedPresentationManifestArtboard,_ as isTouchDevice,$ as logger,Y as nextTick,U as parseSafariUserAgent,Ae as reducer,H as removeUndefinedKeys,j as safePtrAccess,N as touchableClick,ze as useCursor,X as useDebounceFunction,Je as useDecrementZoom,Ge as useEvent,tt as useExportNode,Xe as useGetArtboardAtPosition,qe as useGetPanAtPosition,St as useGetScreen,bt as useGoBack,wt as useGoForwards,Ve as useIncrementZoom,Oe as useIsCameraMoving,Ze as useIsCameraZooming,Qe as useLockCamera,nt as useLogEvent,$e as useLooseWebGLContext,et as useMapRelativePositionToCameraPosition,yt as useNavigateToFirstFlow,_e as usePRFile,He as usePRFileArtboards,Be as usePan,Mt as usePrototypeCursor,Wt as usePrototypeEvent,Ct as usePrototypeGetArtboardAtPosition,Pt as usePrototypeMapRelativePositionToCameraPosition,Rt as usePrototypePan,Lt as usePrototypeState,Et as usePrototypeStatus,xt as usePrototypeZoom,mt as useRestartPrototype,Ne as useRootNodeAbsoluteExtent,Ke as useSetPan,je as useSetZoom,Ue as useStatus,ke as useZoom,Ye as useZoomToFit};
1
+ import e,{useRef as t,useLayoutEffect as n,useCallback as o,createContext as r,useContext as i,useReducer as a,useMemo as s,useEffect as u,useState as l}from"react";var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},c(e,t)};function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var h=function(){return h=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},h.apply(this,arguments)};function p(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}function g(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function v(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function f(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function s(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((o=o.apply(e,t||[])).next())}))}const m=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function y(e){return e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const b="undefined"==typeof window,w=(()=>{if(b)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(e),r="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:r,isMobile:/android/i.test(e)||o||r,isSafari12:/Version\/12.+Safari/.test(e)}})();class C extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const P=[],E=[];function M(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let o=e.length,r=t.length;for(;o>0&&e.charCodeAt(~-o)===t.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&e.charCodeAt(a)===t.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,l=0,c=0,d=0;for(;c<o;)E[c]=e.charCodeAt(a+c),P[c]=++c;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,l=d,c=0;c<o;c++)u=i===E[c]?s:s+1,s=P[c],l=P[c]=s>l?u>l?l+1:u:u>s?s+1:u;return l}function L(e){return null!=e}const x=({mobileTiers:e=[0,15,30,60],desktopTiers:t=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@5.0.25/dist/benchmarks"}={})=>f(void 0,void 0,void 0,(function*(){const a={};if(b)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==w?void 0:w.isIpad),isMobile:u=!!(null==w?void 0:w.isMobile),screenSize:l=window.screen,loadBenchmarks:c=(e=>f(void 0,void 0,void 0,(function*(){const t=yield fetch(`${i}/${e}`).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<4)throw new C("Detect GPU benchmark data is out of date. Please update to version 4x");return t})))}=n;let{renderer:d}=n;const h=(e,t,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:e,type:t});let p,g="";if(d)d=y(d),p=[d];else{const e=o||function(e,t=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:t,powerPreference:"high-performance",stencil:!1};e&&delete n.powerPreference;const o=window.document.createElement("canvas"),r=o.getContext("webgl",n)||o.getContext("experimental-webgl",n);return null!=r?r:void 0}(null==w?void 0:w.isSafari12,r);if(!e)return h(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(t&&(d=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");g=d,d=y(d),p=function(e,t,n){return"apple gpu"===t?function(e,t,n){if(!n)return[t];const o=function(e){const t=e.createShader(35633),n=e.createShader(35632),o=e.createProgram();if(!(n&&t&&o))return;e.shaderSource(t,"\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n "),e.shaderSource(n,"\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n "),e.compileShader(t),e.compileShader(n),e.attachShader(o,t),e.attachShader(o,n),e.linkProgram(o),e.detachShader(o,t),e.detachShader(o,n),e.deleteShader(t),e.deleteShader(n),e.useProgram(o);const r=e.createBuffer();e.bindBuffer(34962,r),e.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=e.getAttribLocation(o,"aPosition");e.vertexAttribPointer(i,3,5126,!1,0,0),e.enableVertexAttribArray(i),e.clearColor(1,1,1,1),e.clear(16384),e.viewport(0,0,1,1),e.drawArrays(4,0,3);const a=new Uint8Array(4);return e.readPixels(0,0,1,1,6408,5121,a),e.deleteProgram(o),e.deleteBuffer(r),a.join("")}(e),r="801621810",i="8016218135",a="80162181161",s=(null==w?void 0:w.isIpad)?[["a7",a,12],["a8",i,15],["a8x",i,15],["a9",i,15],["a9x",i,15],["a10",i,15],["a10x",i,15],["a12",r,15],["a12x",r,15],["a12z",r,15],["a14",r,15],["m1",r,15]]:[["a7",a,12],["a8",i,12],["a9",i,15],["a10",i,15],["a11",r,15],["a12",r,15],["a13",r,15],["a14",r,15]];let u;return"80162181255"===o?u=s.filter((([,,e])=>e>=14)):(u=s.filter((([,e])=>e===o)),u.length||(u=s)),u.map((([e])=>`apple ${e} gpu`))}(e,t,n):[t]}(e,d,u)}const v=(yield Promise.all(p.map((function(e){var t;return f(this,void 0,void 0,(function*(){const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(t=a[o])&&void 0!==t?t:c(o);let i;try{i=yield r}catch(n){if(n instanceof C)throw n;return}const d=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let h=i.filter((([,e])=>e===d));h.length||(h=i.filter((([t])=>t.includes(e))));const p=h.length;if(0===p)return;const g=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let v,[f,,,,m]=p>1?h.map((e=>[e,M(g,e[2])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],y=Number.MAX_VALUE;const{devicePixelRatio:b}=window,w=l.width*b*l.height*b;for(const e of m){const[t,n]=e,o=t*n,r=Math.abs(w-o);r<y&&(y=r,v=e)}if(!v)return;const[,,P,E]=v;return[y,P,f,E]}))})))).filter(L).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!v.length){const e=m.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${g})`)}const[,P,E,x]=v[0];if(-1===P)return h(0,"BLOCKLISTED",E,P,x);const R=u?e:t;let W=0;for(let e=0;e<R.length;e++)P>=R[e]&&(W=e);return h(W,"BENCHMARK",E,P,x)}));var R,W,S=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"(".concat(n,") ").concat(o))||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return d(t,e),t}(Error);function T(e){return void 0!==e}!function(e){e.debug="debug",e.release="release"}(R||(R={})),function(e){e.Fit="Fit",e.FillWidth="FillWidth",e.ActualSize="ActualSize"}(W||(W={}));var F=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,o;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(o=this.listeners[e])||void 0===o||o.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.forwardEvent=function(e,t){this.on(t,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];e.emit.apply(e,v([t],n,!1))}))},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.listeners[e];(null==o?void 0:o.size)&&o.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e.prototype.detachAllListeners=function(){this.listeners={}},e}(),I=function(){function e(e){void 0===e&&(e=!1),this.removeListenerCallbacks=[],this.disabled=e}return e.prototype.add=function(e,t,n,o){var r=this,i=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];r.disabled||n.apply(void 0,e)};e.addEventListener(t,i,o);var a=function(){e.removeEventListener(t,i,o)};return this.removeListenerCallbacks.push(a),a},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e.prototype.setDisabled=function(e){this.disabled=e},e}(),A={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1,canvasLayersEvents:!1},D=function(e){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(e)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},G=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,U=function(e){if(void 0===e&&(e=window.navigator.userAgent),e.includes("Chrome/")||e.includes("Chromium/")||e.includes("Opera/")||e.includes("Firefox/"))return null;var t=e.match(G);if(!t)return null;var n=t[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(t[4])||0,minor:parseInt(t[5])||0,patch:parseInt(t[6])||0}}};function k(e,t){var n;function o(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,o)}),t)}return o.cancel=function(){n&&clearTimeout(n)},o}function B(e){var t,n,o,r,i,a=null!==(n=null===(t=e.touches)||void 0===t?void 0:t[0])&&void 0!==n?n:null===(o=e.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:e.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:e.clientY}}function z(e,t,n){return Math.max(t,Math.min(n,e))}function Z(e){return Boolean(window.chrome)&&e.gpu&&/amd\sradeon\s(pro|rx)\s5\d\d\d/gi.test(e.gpu)||U()&&!A.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function O(e){if(!e)return[];for(var t=[],n=0;n<e.size();n++)t.push(e.get(n));return t}function _(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function H(e){var t=h({},e);return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function N(e){return _()?{onTouchEnd:e}:{onClick:e}}var j=function(e){return 0===(null==e?void 0:e.$$.count.value)?null:e},V=function(e){function t(t,n){void 0===n&&(n=!1);var o=e.call(this)||this;return o.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},o.handleGestureStart=function(e){e.preventDefault(),o.state.lastGestureScale=e.scale},o.handleGestureChange=function(e){e.preventDefault();var t=e.scale/o.state.lastGestureScale;o.state.lastGestureScale=e.scale;var n=o.getCorrectPointerPosition(e);o.emitZoomEvent(t,n)},o.handleGestureEnd=function(e){e.preventDefault()},o.updateMousePosition=function(e){o.emit("pointermove",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.updateGlobalMousePosition=function(e){o.emit("globalpointermove",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.handleTouchStart=function(e){e.preventDefault(),o.handleTouchPinchToZoomStart(e),o.emit("pointerdown",{type:"touch",position:o.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},o.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),o.emit("pointerdown",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},o.handleTouchMove=function(e){o.handleTouchPinchToZoomChange(e),o.emit("pointermove",{type:"touch",position:o.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},o.handleMouseMove=function(e){o.updateMousePosition(e)},o.handleGlobalTouchMove=function(e){o.emit("globalpointermove",{type:"touch",position:o.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},o.handleGlobalMouseMove=function(e){o.updateGlobalMousePosition(e)},o.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(o.state.pinchToZoomLastDistance=o.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},o.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var n=o.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),r=o.getCorrectPointerPosition(e),i=1+.004*(n-o.state.pinchToZoomLastDistance);o.state.pinchToZoomLastDistance=n,o.emitZoomEvent(i,r)}},o.handleTouchEnd=function(e){var t=o.getCorrectPointerPosition(e);o.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},o.handleMouseUp=function(e){o.emit("pointerup",{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.debouncedUpdateMousePosition=k(o.updateMousePosition,40),o.debouncedUpdateGlobalMousePosition=k(o.updateGlobalMousePosition,40),o.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!o.state.isCtrlPressed,n=e.metaKey||t||o.state.isCtrlPressed;if(o.debouncedUpdateMousePosition(e),o.debouncedUpdateGlobalMousePosition(e),n){var r=t?-1:1,i=o.getCorrectPointerPosition(e),a=1+.005*e.deltaY*r;o.emitZoomEvent(a,i)}else o.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:o.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},o.target=t,o.targetBounds=t.getBoundingClientRect(),o.listenersCollector=new I(n),o.addListeners(),o.targetResizeObserver=new ResizeObserver(o.updateTargetBounds.bind(o)),o.targetResizeObserver.observe(o.target),o}return d(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){_()||(this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart,{capture:!0}),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange,{capture:!0}),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd,{capture:!0}))},t.prototype.clampPointerToTargetBounds=function(e){return{x:e.x-this.targetBounds.x,y:e.y-this.targetBounds.y}},t.prototype.getCorrectPointerPosition=function(e){var t,n={x:0,y:0};if((null===(t=e.touches)||void 0===t?void 0:t.length)>1){var o=e,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=B(e);return this.clampPointerToTargetBounds(n)},t.prototype.calculateDistanceBetweenTouches=function(e,t){return Math.hypot(e.clientX-t.clientX,e.clientY-t.clientY)},t.prototype.emitZoomEvent=function(e,t){this.emit("pinchToZoom",e,t)},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.targetResizeObserver.disconnect()},t.prototype.setDisable=function(e){this.listenersCollector.setDisabled(e)},t}(F),J=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.handleKeyUp=function(e){n.emit("keyUp",e.code)},n.target=t,n.addListeners(),n}return d(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(F),K=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now()}return e.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(t," ms")}var n=(e/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},e}();function Y(e){setTimeout((function(){e()}),0)}var $=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return d(t,e),t.prototype.logDebug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,v(["log","debug"],e,!1))},t.prototype.logWarning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,v(["log","warn"],e,!1))},t.prototype.logError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.emit.apply(this,v(["log","error"],e,!1))},t}(F)),X=function(e,r){var i=t(e);i.current=e;var a=t((function(){}));return n((function(){var e=k((function(){i.current()}),r);return a.current=e,function(){e.cancel()}}),[r]),o((function(){return a.current()}),[])},q=function(e){function t(t){var n,o=this;return(o=e.call(this)||this).listenersCollector=new I,o.size={width:0,height:0},o.pixelRatio=1,o.maxPixelRatio=2,o.handleCanvasResizeObserver=function(e){o.resizeCanvas(e[0].contentRect)},o.resizeCanvas=function(e){var t=e.width,n=e.height;window.requestAnimationFrame((function(){o.setSize(t,n),o.emit("resize",t,n,o.getDevicePixelRatio())}))},o.getCanvasCenterPoint=function(){var e=o.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},o.container=t.container,o.canvas=t.canvas,o.maxPixelRatio=null!==(n=t.maxPixelRatio)&&void 0!==n?n:o.maxPixelRatio,o.canvasResizeObserver=new ResizeObserver(o.handleCanvasResizeObserver),o.canvasResizeObserver.observe(o.container),o.listenersCollector.add(window,"orientationchange",o.handleDeviceOrientationChange),o.setSize(o.container.clientWidth,o.container.clientHeight),o}return d(t,e),t.prototype.setSize=function(e,t){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(e,"px"),this.canvas.style.height="".concat(t,"px"),this.size.width=e*this.pixelRatio,this.size.height=t*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},t.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},t.prototype.getDevicePixelRatio=function(){return z(window.devicePixelRatio,1,this.maxPixelRatio)},t.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},t.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},t}(F),Q=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===R.release},e.prototype.init=function(){return p(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return g(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:e=a.sent(),t=e.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,t({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:this.settings.webglVersion,bridge:this.settings.jsBridge,locateFile:function(e){return i.settings.locateFile.replace("{file}",e)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new S("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerTypeEnum.Unset,mouse:this.instance.PRUserPointerTypeEnum.Mouse,touch:this.instance.PRUserPointerTypeEnum.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorTypeEnum.Auto.value]="auto",r[this.instance.PRCursorTypeEnum.Default.value]="default",r[this.instance.PRCursorTypeEnum.Pointer.value]="pointer",r[this.instance.PRCursorTypeEnum.Grab.value]="grab",r[this.instance.PRCursorTypeEnum.Grabbing.value]="grabbing",r),this.prototypeResizeModeToWASMMap={Fit:this.instance.PrototypeResizeModeWasmEnum.Fit,FillWidth:this.instance.PrototypeResizeModeWasmEnum.FillWidth,ActualSize:this.instance.PrototypeResizeModeWasmEnum.ActualSize},[2]}}))}))},e.prototype.makeWebGLContext=function(e,t){var n;void 0===t&&(t={});var o=h({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},t),r=this.instance.GL.createContext(e,o);if(!r)throw new S("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");var i=null===(n=this.instance.GL.getContext(r))||void 0===n?void 0:n.GLctx;return i&&i.getExtension("WEBGL_debug_renderer_info"),r},e.prototype.createWebGLTextureFromImage=function(e,t){var n=this.instance.GL,o=n.getContext(t);if(!o)throw new Error("Unable to retrieve emscripten WebGL context from handle");var r=o.GLctx;if(!r)throw new Error("WebGL context is null");var i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);var a=n.getNewId(n.textures);return n.textures[a]=i,r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.bindTexture(r.TEXTURE_2D,null),a},e.prototype.destroyWebGLContext=function(e){var t;$.logDebug("Destroying WebGL context");var n=null===(t=this.instance)||void 0===t?void 0:t.GL.getContext(e);if(n){this.instance.GL.deleteContext(e);var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),$.logDebug("WebGL destroyed"),!0;$.logError("WEBGL_lose_context not available. Not possible to destroy WebGL context manually.")}else $.logError("WebGL context not found while trying to destroy it")},e.prototype.importModule=function(){return"true"===process.env.USE_ESM?this.isReleaseMode()?import("./web-renderer-release-ffcc1a42.js"):import("./web-renderer-debug-2597c40b.js"):this.isReleaseMode()?import("./web-renderer-release-28643f00.js"):import("./web-renderer-debug-d3774856.js")},e.prototype.mapToCSSCursor=function(e){return this.prCursorTypeToCSSCursorMap[e.value]},e.prototype.mapToPRPointerType=function(e){var t;return null!==(t=this.pointerTypeToWASMMap[e])&&void 0!==t?t:this.instance.PRUserPointerTypeEnum.Unset},e.prototype.mapPointerInfo=function(e){return h(h({},e),{type:this.mapToPRPointerType(e.type)})},e.prototype.mapResizeMode=function(e){return this.prototypeResizeModeToWASMMap[e]},e}();function ee(e){return new Promise((function(t,n){var o=new Image;o.onload=function(){t(o)},o.onerror=function(e){n(e)},o.src=e}))}var te,ne,oe,re,ie,ae,se,ue,le,ce,de,he,pe,ge,ve,fe,me,ye,be,we,Ce,Pe=function(){function e(e,t,n){this.canvas=e,this.container=t,this.filePath=n,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:1,g:1,b:1,a:1},this.mode=R.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=A,this.manualInitialization=!1,this.panBoundariesPadding=0,this.selectedArtboard=null,this.initialZoom=null,this.initialPan=null}return e.FromSettings=function(t){return Object.assign(new e(t.canvas,t.container,t.filePath),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),Ee={png:"image/png",jpg:"image/jpeg",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",raster:"binary/octet-stream"};!function(e){e[e.None=0]="None",e[e.Scale=1]="Scale",e[e.Width=2]="Width",e[e.Height=3]="Height"}(te||(te={})),function(e){e[e.None=0]="None",e[e.PNG=1]="PNG",e[e.JPG=2]="JPG",e[e.TIFF=3]="TIFF",e[e.WEBP=4]="WEBP",e[e.PDF=5]="PDF",e[e.EPS=6]="EPS",e[e.SVG=7]="SVG",e[e.HEIC=8]="HEIC"}(ne||(ne={})),function(e){e[e.Color=0]="Color",e[e.Gradient=1]="Gradient",e[e.Pattern=2]="Pattern"}(oe||(oe={})),function(e){e[e.Fit=0]="Fit",e[e.Fill=1]="Fill",e[e.Stretch=2]="Stretch",e[e.Tile=3]="Tile"}(re||(re={})),function(e){e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.Angular=2]="Angular"}(ie||(ie={})),function(e){e[e.Center=0]="Center",e[e.Inside=1]="Inside",e[e.Outside=2]="Outside"}(ae||(ae={})),function(e){e[e.Butt=0]="Butt",e[e.Round=1]="Round",e[e.Square=2]="Square"}(se||(se={})),function(e){e[e.Miter=0]="Miter",e[e.Round=1]="Round",e[e.Bevel=2]="Bevel"}(ue||(ue={})),function(e){e[e.Motion=0]="Motion",e[e.Zoom=1]="Zoom",e[e.Background=2]="Background",e[e.Gaussian=3]="Gaussian"}(le||(le={})),function(e){e[e.Normal=0]="Normal",e[e.DestAtop=1]="DestAtop",e[e.Clear=2]="Clear",e[e.Source=3]="Source",e[e.Darken=4]="Darken",e[e.Multiply=5]="Multiply",e[e.ColorBurn=6]="ColorBurn",e[e.Lighten=7]="Lighten",e[e.Screen=8]="Screen",e[e.ColorDodge=9]="ColorDodge",e[e.Overlay=10]="Overlay",e[e.SoftLight=11]="SoftLight",e[e.HardLight=12]="HardLight",e[e.Difference=13]="Difference",e[e.Exclusion=14]="Exclusion",e[e.Hue=15]="Hue",e[e.Saturation=16]="Saturation",e[e.Color=17]="Color",e[e.Luminosity=18]="Luminosity",e[e.PlusLighter=19]="PlusLighter",e[e.PlusDarker=20]="PlusDarker"}(ce||(ce={})),function(e){e[e.Artboard=0]="Artboard",e[e.SymbolMaster=1]="SymbolMaster",e[e.SymbolInstance=2]="SymbolInstance",e[e.Hotspot=3]="Hotspot",e[e.Bitmap=4]="Bitmap",e[e.Group=5]="Group",e[e.Oval=6]="Oval",e[e.Polygon=7]="Polygon",e[e.Rectangle=8]="Rectangle",e[e.ShapeGroup=9]="ShapeGroup",e[e.ShapePath=10]="ShapePath",e[e.Star=11]="Star",e[e.Text=12]="Text",e[e.Triangle=13]="Triangle",e[e.Slice=14]="Slice"}(de||(de={})),function(e){e[e.Angled=2]="Angled",e[e.InsideArc=4]="InsideArc",e[e.InsideSquare=3]="InsideSquare",e[e.Rounded=0]="Rounded",e[e.Smooth=1]="Smooth"}(he||(he={})),function(e){e[e.Lowercase=2]="Lowercase",e[e.None=0]="None",e[e.Uppercase=1]="Uppercase"}(pe||(pe={})),function(e){e[e.Center=1]="Center",e[e.Justified=3]="Justified",e[e.Left=0]="Left",e[e.Right=2]="Right"}(ge||(ge={})),function(e){e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom"}(ve||(ve={})),function(e){e[e.LineThrough=2]="LineThrough",e[e.Underline=1]="Underline",e[e.None=0]="None"}(fe||(fe={})),function(e){e[e.Unset=0]="Unset",e[e.Mouse=1]="Mouse",e[e.Touch=2]="Touch"}(me||(me={})),function(e){e[e.Auto=0]="Auto",e[e.Default=1]="Default",e[e.Pointer=2]="Pointer",e[e.Grab=3]="Grab",e[e.Grabbing=4]="Grabbing"}(ye||(ye={})),function(e){e[e.PNG=0]="PNG",e[e.JPG=1]="JPG",e[e.WEBP=2]="WEBP",e[e.PDF=4]="PDF",e[e.SVG=3]="SVG",e[e.RASTER=5]="RASTER"}(be||(be={})),function(e){e[e.Screen=0]="Screen",e[e.Overlay=1]="Overlay"}(we||(we={})),function(e){e[e.Fit=0]="Fit",e[e.FillWidth=1]="FillWidth",e[e.ActualSize=2]="ActualSize"}(Ce||(Ce={}));var Me=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(e.x,e.y,n.wasmModule.mapPointerInfo(t)))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(e)))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&(null===(t=n.userEventsCollectorWasm)||void 0===t||t.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(e)))},n.settings=Pe.FromSettings(t),$.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container),n.canvasManager=new q({container:n.settings.container,canvas:n.settings.canvas}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.exporterFetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,x()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=Z(this.deviceInfo),$.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initCanvasRendererWasm()];case 4:return t.sent(),[4,this.setFile(this.settings.filePath)];case 5:return t.sent(),this.settings.selectedArtboard&&this.selectArtboard(this.settings.selectedArtboard),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof S?e:new S("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=null!==this.settings.initialZoom,r=null!==this.settings.initialPan;o||r?(o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(e=this.settings.initialPan)||void 0===e?void 0:e.x)||0,(null===(t=this.settings.initialPan)||void 0===t?void 0:t.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},t.prototype.startRendering=function(){var e;this.traceInitialRender=new K("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.pageCanvasWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){$.logDebug("[C++] ".concat(e))},logWarning:function(e){$.logWarning("[C++] ".concat(e))},logError:function(e){$.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):($.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):($.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(){var t=e.getPan();e.emit("cameraPanChange",(null==t?void 0:t.x)||0,(null==t?void 0:t.y)||0)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},fetch:this.handleJSBridgeFetch.bind(this),exporterFetch:this.handleJSBridgeExporterFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onLayerClick:function(t){e.emit("layerClick",t)},onLayerMouseHoverChange:function(t){e.emit("layerMouseHoverChange",t)},onSceneChange:function(){e.emit("sceneChange")},onFragmentLoad:function(t){e.emit("fragmentLoad",t)}}},t.prototype.handleJSBridgeExporterFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l;return g(this,(function(c){if(!this.wasmModule)return[2];if(this.disposed)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0,buffer:new Uint8Array(t.data.buffer)},o.exec(n);break;case"error":$.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(a=null===(i=t.data.error)||void 0===i?void 0:i.statusCode)&&void 0!==a?a:500,statusText:null!==(u=null===(s=t.data.error)||void 0===s?void 0:s.statusText)&&void 0!==u?u:"Unknown error",contentType:null!==(l=t.data.contentType)&&void 0!==l?l:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:0,width:0,height:0})}return this.exporterFetchWorker.removeEventListener("message",r),[2]}))}))};this.exporterFetchWorker.addEventListener("message",r),this.exporterFetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return g(this,(function(p){switch(p.label){case 0:if(!this.wasmModule)return[2];if(this.disposed)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ee(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return $.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:0,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new K("WasmModuleDownload"),this.wasmModule=new Q({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),$.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){if(this.disposed)return[2];try{if(!this.wasmModule)throw Error("WASM module not initialized");this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion}),this.renderTarget=this.wasmModule.instance.RenderTarget.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),this.pageCanvasWasm=new this.wasmModule.instance.CanvasRendererWasm(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new S("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}if(!this.pageCanvasWasm)return[2];if(!(e=this.pageCanvasWasm.getUserEventsCollector()))throw new S("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=e,this.pageCanvasWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.pageCanvasWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.pageCanvasWasm.setPanBoundariesPadding(this.settings.panBoundariesPadding),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.pageCanvasWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&($.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),$.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;(null===(e=this.wasmModule)||void 0===e?void 0:e.destroyWebGLContext(this.webglCtxHandle))||$.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return p(this,void 0,void 0,(function(){var t=this;return g(this,(function(n){return this.disposed?[2]:(this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=t.pageCanvasWasm)||void 0===r||r.setFile(e,(function(e,o,r){t.setStatus({type:"FILE_READY"});var i="".concat(e,"-v").concat("12.1.3");t.emit("fileReady",i,o,r),n()}),(function(){return o(new S("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))])}))}))},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),$.logError(e),e.cause&&$.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&($.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getPRFileCachedData=function(){var e;if(!this.pageCanvasWasm)return null;if((null===(e=this.prFileHandle)||void 0===e?void 0:e.filePath)!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.prFileHandle={handle:t,filePath:this.settings.filePath,artboards:O(t.getArtboards())}}return this.prFileHandle},t.prototype.getPRFile=function(){var e;return null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.handle},t.prototype.releasePRFileHandle=function(){var e,t;null===(t=null===(e=this.prFileHandle)||void 0===e?void 0:e.handle)||void 0===t||t.delete(),this.prFileHandle=void 0},t.prototype.getRootNodeExtent=function(){var e,t,n;return null!==(n=null===(t=null===(e=this.getPRFile())||void 0===e?void 0:e.getRootNode())||void 0===t?void 0:t.getAbsoluteExtent())&&void 0!==n?n:null},t.prototype.getPRFileArtboards=function(){var e,t;return null!==(t=null===(e=this.getPRFileCachedData())||void 0===e?void 0:e.artboards)&&void 0!==t?t:[]},t.prototype.getArtboardAtPosition=function(e,t){if(!this.pageCanvasWasm)return null;for(var n=this.getPRFileArtboards(),o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n;s<u.length;s++){var l=u[s],c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(i>=l.bounds.x&&a>=l.bounds.y&&i<=c&&a<=d)return l.getNode()}return null},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n;return null===(n=this.pageCanvasWasm)||void 0===n?void 0:n.mapRelativePositionToCameraPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=e/o,i=t/o;return{x:n.x-r,y:n.y-i}},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o=null!=t?t:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(e,o.x,o.y)},t.prototype.getPan=function(){var e,t,n=this.getRootNodeExtent();if(!n)return{x:0,y:0};var o=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getPan(),r=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},t.prototype.getZoom=function(){var e;return(null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom())||0},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1);var r=this.getRootNodeExtent();if(r){var i=e,a=t,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);i+=this.canvasManager.size.width/u,a+=this.canvasManager.size.height/u}var l=(i-r.x)*s,c=(a-r.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(l,c)}},t.prototype.selectArtboard=function(e){var t;this.pageCanvasWasm&&(this.settings.selectedArtboard=e,null===(t=this.pageCanvasWasm)||void 0===t||t.selectArtboard(null!=e?e:""))},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.exportNode=function(e,t){return p(this,void 0,void 0,(function(){var n=this;return g(this,(function(o){return[2,new Promise((function(o,r){if(n.wasmModule&&n.pageCanvasWasm){var i=t.format.toUpperCase(),a=be[i];if(void 0!==a){var s={format:{value:a},backingScale:t.backingScale};n.pageCanvasWasm.exportNode(e,s,(function(e,n,i,a){if(null!==e){var s=Ee[t.format],u=new Blob([e.buffer],{type:s});o({blob:u,width:n,height:i,bytesPerPixel:a})}else r("Export failed")}))}else r("Unsupported export format: ".concat(t.format))}else r("Wasm module is not ready or was disposed.")}))]}))}))},t.prototype.dispose=function(){var e,t,n,o;try{this.disposeFetchWorker(),this.disposed=!0,this.detachAllListeners(),this.releasePRFileHandle(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.pageCanvasWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.pageCanvasWasm)||void 0===n||n.delete(),null===(o=this.renderTarget)||void 0===o||o.delete(),this.pageCanvasWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new S("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(F),Le=r(void 0),xe=r(void 0),Re=r(void 0),We=r(void 0),Se=r(void 0),Te=r("auto"),Fe=r(void 0),Ie=function(){var e=i(Fe);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},Ae=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:t.pan});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return h(h({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return h(h({},e),{isCameraZooming:!1});case"on-camera-move-start":return h(h({},e),{isCameraMoving:!0});case"on-camera-move-end":return h(h({},e),{isCameraMoving:!1});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});default:return e}},De=function(n){var r=t(null),i=t(null),u=a(Ae,{pan:null,zoom:null,status:{type:"IDLE"},isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),l=u[0],c=l.status,d=l.zoom,p=l.pan,g=l.isCameraZooming,v=l.isCameraMoving,f=l.cursor,m=u[1],y=o((function(e){return m({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return m({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){m({type:"on-status",status:e})}),[]),C=o((function(){return m({type:"on-camera-zoom-start"})}),[]),P=o((function(){return m({type:"on-camera-zoom-end"})}),[]),E=o((function(){return m({type:"on-camera-move-start"})}),[]),M=o((function(){return m({type:"on-camera-move-end"})}),[]),L=o((function(e){return m({type:"on-cursor-change",cursor:e})}),[]),x=o((function(){if(r.current){var e=r.current.getPan();m({type:"on-pan",pan:e})}}),[]),R=o((function(){var e=r.current;e&&($.logDebug("Provider dispose"),e.off("status",w),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.off("cameraZoomStart",C),e.off("cameraZoomEnd",P),e.off("cameraMoveStart",E),e.off("cameraMoveEnd",M),e.off("cursorChange",L),e.off("sceneChange",x),e.dispose(),r.current=null,m({type:"dispose"}))}),[w,b,y,C,P,E,M,L,x]),W=o((function(e,t,n){if(""!==e&&t&&n&&i.current){$.logDebug("Provider init");var o=new Me(h(h({},i.current),{filePath:e,container:n,canvas:t,manualInitialization:!0}));o.on("status",w),o.on("cameraZoomChange",y),o.on("cameraPanChange",b),o.on("cameraZoomStart",C),o.on("cameraZoomEnd",P),o.on("cameraMoveStart",E),o.on("cameraMoveEnd",M),o.on("cursorChange",L),o.on("sceneChange",x),r.current=o,o.init()}}),[w,y,b,C,P,E,M,L,x]),S=o((function(e){var t,n;$.logDebug("Provider setSettings"),e.backgroundColor&&(null===(t=r.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(n=r.current)||void 0===n||n.selectArtboard(e.selectedArtboard||null),i.current=e}),[]),T=o((function(){return r.current}),[]),F=s((function(){return{dispose:R,init:W,setSettings:S,getInstance:T,dispatch:m}}),[R,W,S,T]);return e.createElement(Fe.Provider,{value:F},e.createElement(Le.Provider,{value:c},e.createElement(xe.Provider,{value:d},e.createElement(Se.Provider,{value:p},e.createElement(Re.Provider,{value:g},e.createElement(We.Provider,{value:v},e.createElement(Te.Provider,{value:f},n.children)))))))},Ge=function(e,t){var n=(0,Ie().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},Ue=function(){var e=i(Le);if(void 0===e)throw Error("useStatus must be used within a provider");return e},ke=function(){var e=i(xe);if(void 0===e)throw Error("useZoom must be used within a provider");return e},Be=function(){var e=i(Se);if(void 0===e)throw Error("usePan must be used within a provider");return e},ze=function(){var e=i(Te);if(void 0===e)throw Error("useCursor must be used within a provider");return e},Ze=function(){var e=i(Re);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},Oe=function(){var e=i(We);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},_e=function(){var e=(0,Ie().getInstance)(),t=Ue();return s((function(){return e&&"READY"===t.type?e.getPRFile():null}),[e,t])},He=function(){var e=(0,Ie().getInstance)(),t=Ue();return s((function(){return e&&"READY"===t.type?e.getPRFileArtboards():null}),[e,t])},Ne=function(){var e,t,n,o,r=_e(),i=l(null),a=i[0],c=i[1],d=X((function(){c((function(e){var t,n,o,i=null!==(o=null===(n=null===(t=j(r))||void 0===t?void 0:t.getRootNode())||void 0===n?void 0:n.getAbsoluteExtent())&&void 0!==o?o:null;return(null==e?void 0:e.width)===(null==i?void 0:i.width)&&(null==e?void 0:e.height)===(null==i?void 0:i.height)&&(null==e?void 0:e.x)===(null==i?void 0:i.x)&&(null==e?void 0:e.y)===(null==i?void 0:i.y)?e:i}))}),16);Ge("sceneChange",d),u((function(){d()}),[d]);var h=null!==(e=null==a?void 0:a.x)&&void 0!==e?e:0,p=null!==(t=null==a?void 0:a.y)&&void 0!==t?t:0,g=null!==(n=null==a?void 0:a.width)&&void 0!==n?n:0,v=null!==(o=null==a?void 0:a.height)&&void 0!==o?o:0;return s((function(){return{x:h,y:p,width:g,height:v}}),[h,p,g,v])},je=function(){var e=(0,Ie().getInstance)();return o((function(t){null==e||e.setZoom(t)}),[e])},Ve=function(){var e=je(),t=ke();return o((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},Je=function(){var e=je(),t=ke();return o((function(){"number"==typeof t&&e(t/2)}),[e,t])},Ke=function(){var e=(0,Ie().getInstance)();return o((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},Ye=function(){var e=(0,Ie().getInstance)();return o((function(){null==e||e.zoomToFit()}),[e])},$e=function(){var e=(0,Ie().getInstance)();return o((function(){null==e||e.looseWebGLContext()}),[e])},Xe=function(){var e=(0,Ie().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return g(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},qe=function(){var e=(0,Ie().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return g(this,(function(o){switch(o.label){case 0:return[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},Qe=function(){var e=(0,Ie().getInstance)();return o((function(t){null==e||e.setIsCameraLocked(t)}),[e])},et=function(){var e=(0,Ie().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},tt=function(){var e=(0,Ie().getInstance)(),t=_e();return o((function(n,o){return e&&t?e.exportNode(n,o):Promise.reject("WebRenderer instance not ready")}),[e,t])};function nt(e){var n=t(e);n.current=e;var r=o((function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];n.current.apply(n,v([e],t,!1))}),[]);u((function(){return $.on("log",r),function(){$.off("log",r)}}),[r])}var ot={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},rt={position:"absolute",top:0,left:0},it=function(n){var r=n.filePath,i=n.locateFile,a=n.imagesURLFormat,c=n.imagesURLMap,d=n.fragmentsURLFormat,p=n.fragmentsURLMap,g=n.backgroundColor,v=n.mode,f=n.showTilesBorders,m=n.minimumZoomLevel,y=n.maximumZoomLevel,b=n.preserveDrawingBuffer,w=n.panBoundariesPadding,C=n.initialPan,P=n.initialZoom,E=n.children,M=n.containerProps,L=n.canvasProps,x=n.featureFlags,R=n.selectedArtboard,W=t(null),S=t(null),T=l(!1),F=T[0],I=T[1],A=o((function(){return I(!0)}),[]),D=Ie(),G=D.dispose,U=D.init,k=D.setSettings,B=ze(),z=Ue();Ge("allImagesReady",A),u((function(){return $.logDebug("CanvasRenderer mounted"),function(){return $.logDebug("CanvasRenderer unmounted")}}),[]),u((function(){k({locateFile:i,imagesURLFormat:a,imagesURLMap:c,fragmentsURLFormat:d,fragmentsURLMap:p,backgroundColor:g,mode:v,showTilesBorders:f,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:b,panBoundariesPadding:w,initialPan:C,initialZoom:P,featureFlags:x,selectedArtboard:R})}),[k,i,a,c,d,p,g,v,f,m,y,b,w,C,P,x,R]),u((function(){if(r)return U(r,W.current,S.current),function(){G()}}),[G,U,r]);var Z=s((function(){var e;return null!==(e=n.cursor)&&void 0!==e?e:B}),[n.cursor,B]),O=s((function(){return h(h({},ot),{cursor:Z})}),[Z]);return e.createElement("div",h({},M,{ref:S,style:O}),r&&e.createElement("canvas",h({},L,{key:r,ref:W,"data-sketchweb-all-images-ready":F,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==z?void 0:z.type.toLowerCase())||"null"),style:rt})),"READY"===(null==z?void 0:z.type)&&E)},at=function(){function e(e,t,n,o){this.prototypeStructure=e,this.startArtboardUUID=t,this.canvas=n,this.container=o,this.locateFile="/{file}",this.imagesURLFormat="",this.imagesURLMap={},this.fragmentsURLFormat="",this.fragmentsURLMap={},this.backgroundColor={r:0,g:0,b:0,a:1},this.mode=R.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=A,this.manualInitialization=!1,this.highlightHotspots=!0,this.resizeMode=W.Fit,this.assetsManagerLimits={maxDepthForBackgroundRequests:1,maxArtboardsForBackgroundRequests:5,maxInitialLoadingDepth:2,maxInitialArtboardToLoad:10},this.disableInteraction=!1}return e.FromSettings=function(t){return Object.assign(new e(t.prototypeStructure,t.startArtboardUUID,t.canvas,t.container),Object.fromEntries(Object.entries(t).filter((function(e){return void 0!==e[1]}))))},e}(),st=function(e){function t(t){var n=e.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(e,t,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(e,t,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(e,t){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(e,t.x,t.y)},n.handleWheelEvent=function(e,t){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(e.x,e.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(t))},n.handlePointerDownEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handleGlobalPointerMoveEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.handlePointerUpEvent=function(e){var t;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(t=n.wasmModule)||void 0===t?void 0:t.mapPointerInfo(e))},n.restartPrototype=function(e){var t;null===(t=n.playerWasm)||void 0===t||t.restartPrototype(e)},n.navigateToFirstFlow=function(){var e;null===(e=n.playerWasm)||void 0===e||e.navigateToFirstFlow()},n.goBack=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goBack()},n.goForwards=function(){var e;null===(e=n.playerWasm)||void 0===e||e.goForwards()},n.setResizeMode=function(e){var t;if(n.wasmModule){var o=n.wasmModule.mapResizeMode(e);null===(t=n.playerWasm)||void 0===t||t.setResizeMode(o)}},n.getScreen=function(e){var t;void 0===e&&(e=!0);var o=null===(t=n.playerWasm)||void 0===t?void 0:t.getJSScreen(e);return o?{layers:O(o.layers)}:{layers:[]}},n.settings=at.FromSettings(t),$.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container,n.settings.disableInteraction),n.canvasManager=new q({container:n.settings.container,canvas:n.settings.canvas,maxPixelRatio:3}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return d(t,e),t.prototype.addListeners=function(){this.canvasManager.on("resize",this.handleCanvasResize),this.gestureManager.on("wheel",this.handleWheelEvent),this.gestureManager.on("pointerup",this.handlePointerUpEvent),this.gestureManager.on("pointermove",this.handlePointerMoveEvent),this.gestureManager.on("globalpointermove",this.handleGlobalPointerMoveEvent),this.gestureManager.on("pointerdown",this.handlePointerDownEvent),this.gestureManager.on("pinchToZoom",this.handlePinchToZoomEvent),this.settings.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost)},t.prototype.collectAndEmitDeviceInfo=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,x()];case 1:return e=t.sent(),this.deviceInfo=h(h({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.detectWebGLVersion=function(){this.webglVersion=Z(this.deviceInfo),$.logDebug("Using WebGL ".concat(this.webglVersion))},t.prototype.init=function(){return p(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),[4,this.collectAndEmitDeviceInfo()];case 1:t.sent(),this.detectWebGLVersion(),t.label=2;case 2:return t.trys.push([2,6,,7]),[4,this.initWasmModule()];case 3:return t.sent(),[4,this.initPlayerWasm()];case 4:return t.sent(),[4,this.startDownload()];case 5:return t.sent(),[3,7];case 6:return e=t.sent(),[2,this.fail(e instanceof S?e:new S("ERROR","Unexpected exception initializing the web renderer",e))];case 7:return this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return p(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new K("WasmModuleDownload"),this.wasmModule=new Q({mode:this.settings.mode,locateFile:this.settings.locateFile,jsBridge:this.createJSBridge(),featureFlags:this.settings.featureFlags,webglVersion:this.webglVersion}),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),t.printMeasurement(),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.startDownload=function(){var e=this;return this.setStatus({type:"LOADING_FILE"}),new Promise((function(t){var n;null===(n=e.playerWasm)||void 0===n||n.startDownload((function(){t()}))}))},t.prototype.startRendering=function(){var e;this.traceInitialRender=new K("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(e=this.playerWasm)||void 0===e||e.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){$.logDebug("[C++] ".concat(e))},logWarning:function(e){$.logWarning("[C++] ".concat(e))},logError:function(e){$.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t,n){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t].replace(":format",n):e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t).replace(":format",n):($.logWarning("Not able to resolve the url for the image with UUID: ".concat(t)),"")},resolveFragmentUrl:function(t){return e.settings.fragmentsURLMap&&e.settings.fragmentsURLMap[t]?e.settings.fragmentsURLMap[t]:e.settings.fragmentsURLFormat?e.settings.fragmentsURLFormat.replace(":fragmentId",t):($.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(t)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){e.emit("allImagesReady")},onCameraMoveStart:function(){e.emit("cameraMoveStart")},onCameraMoveEnd:function(){e.emit("cameraMoveEnd")},onCameraZoomStart:function(){e.emit("cameraZoomStart")},onCameraZoomEnd:function(){e.emit("cameraZoomEnd")},onCameraZoomChange:function(t){e.emit("cameraZoomChange",t)},onCameraPanChange:function(t,n){e.emit("cameraPanChange",t,n)},onCursorChange:function(t){var n,o=null===(n=e.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(t);o&&e.emit("cursorChange",o)},onPrototypeStateWillChange:function(t,n,o){e.emit("prototypeStateWillChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},onPrototypeStateChange:function(t,n,o){e.emit("prototypeStateChange",{currentArtboardId:t,canGoBack:n,canGoForwards:o})},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeUnhandledPointerUp:function(){e.emit("prototypeUnhandledPointerUp")},onSceneChange:function(){e.emit("sceneChange")}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return p(n,void 0,void 0,(function(){var n,i,a,s,u,l,c,d,h;return g(this,(function(p){switch(p.label){case 0:if(this.disposed||!this.wasmModule)return[2];if(t.data.url!==e)return[2];switch(t.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:t.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(t.data.contentType)?(i=new Blob([t.data.buffer]),[4,ee(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),this.wasmModule?(s=this.wasmModule.createWebGLTextureFromImage(a,this.webglCtxHandle),n.buffer=new Uint8Array(0),n.isWebGLTexture=!0,n.emscriptenWebGLTextureHandle=s,n.width=a.width,n.height=a.height,[3,4]):[2];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return $.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(l=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==l?l:500,statusText:null!==(d=null===(c=t.data.error)||void 0===c?void 0:c.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=t.data.contentType)&&void 0!==h?h:"",isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0}),[3,7];case 6:return[3,7];case 7:return this.fetchWorker.removeEventListener("message",r),[2]}}))}))};this.fetchWorker.addEventListener("message",r),this.fetchWorker.postMessage({type:"fetch",url:e})},t.prototype.handleJSBridgeAbortFetch=function(e){this.fetchWorker.postMessage({type:"abort",url:e})},t.prototype.initPlayerWasm=function(){var e,t;return p(this,void 0,void 0,(function(){var n,o,r,i,a,s,u,l,c,d,p,v,f,m,y,b,w,C,P,E,M;return g(this,(function(g){try{if(!this.wasmModule)throw Error("WASM module not initialized");for(this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:this.webglVersion}),n=this.wasmModule.instance,o=n.RenderTarget,r=n.PrototypeRendererWasm,i=n.PrototypeStructureArtboardVector,a=n.PrototypeStructureFlowVector,s=n.PrototypeStructureAssetVector,u=n.PrototypeStructureFlowTypeEnum,this.renderTarget=o.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),l={artboards:new i},c={Overlay:u.Overlay,Screen:u.Screen},d=0,p=this.settings.prototypeStructure.artboards;d<p.length;d++){for(v=p[d],f=new a,m=0,y=null!==(e=v.flows)&&void 0!==e?e:[];m<y.length;m++)b=y[m],f.push_back(h(h({},b),{type:c[b.type]}));for(w=new s,C=0,P=null!==(t=v.assets)&&void 0!==t?t:[];C<P.length;C++)E=P[C],w.push_back(E);l.artboards.push_back(h(h({},v),{flows:f,assets:w}))}this.playerWasm=new r(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID,l,this.settings.highlightHotspots,this.settings.assetsManagerLimits)}catch(e){throw new S("WASM_ERROR","An error occurred while trying to create the PrototypeRenderer WASM object.",e)}if(!(M=this.playerWasm.getUserEventsCollector()))throw new S("WASM_ERROR","An error occurred while trying to create the user events collector");return this.userEventsCollectorWasm=M,this.playerWasm.setBackgroundColor(this.settings.backgroundColor.r,this.settings.backgroundColor.g,this.settings.backgroundColor.b,this.settings.backgroundColor.a),this.playerWasm.setZoomLevels(this.settings.minimumZoomLevel,this.settings.maximumZoomLevel),this.setResizeMode(this.settings.resizeMode),[2]}))}))},t.prototype.setIsCameraLocked=function(e){var t;null===(t=this.playerWasm)||void 0===t||t.setIsCameraLocked(e)},t.prototype.setBackgroundColor=function(e){var t;e.r===this.settings.backgroundColor.r&&e.g===this.settings.backgroundColor.g&&e.b===this.settings.backgroundColor.b&&e.a===this.settings.backgroundColor.a||(null===(t=this.playerWasm)||void 0===t||t.setBackgroundColor(e.r,e.g,e.b,e.a),this.settings.backgroundColor=e)},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(this.traceInitialRender.printMeasurement(),this.emit("metric",this.traceInitialRender.measure()),this.traceFirstPaint.printMeasurement(),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},t.prototype.looseWebGLContext=function(){var e;null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:"".concat(e.toString()).concat(e.cause?"\nWrapped Error: ".concat(e.cause.toString()):"")}),$.logError(e),e.cause&&$.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&($.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getStatus=function(){return this.status},t.prototype.getArtboardAtPosition=function(e,t){var n=this.playerWasm;if(!n)return null;for(var o=n.getJSScreen(!1),r=n.getPan(),i=n.getZoom(),a=(e-r.x)/i,s=(t-r.y)/i,u=o.layers.size()-1;u>=0;u-=1){var l=o.layers.get(u);if(l&&"artboard"===l.type){var c=l.bounds.x+l.bounds.width,d=l.bounds.y+l.bounds.height;if(a>=l.bounds.x&&s>=l.bounds.y&&a<=c&&s<=d)return l.getNode()}}return null},t.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.dispose=function(){var e,t,n;try{this.disposeFetchWorker(),this.detachAllListeners(),null===(e=this.wasmModule)||void 0===e||e.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(t=this.playerWasm)||void 0===t||t.stopRenderLoop(),null===(n=this.playerWasm)||void 0===n||n.delete(),this.renderTarget.delete(),this.playerWasm=void 0,this.wasmModule=void 0,this.disposed=!0}catch(e){this.fail(new S("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t.prototype.mapRelativePositionToCameraPosition=function(e,t){var n=this.playerWasm;return n?n.mapRelativePositionToCameraPosition(e,t):null},t.prototype.updateHighlightHotspotsSetting=function(e){var t=this.playerWasm;if(!t)return null;t.updateHighlightHotspotsSetting(e)},t}(F),ut=r(void 0),lt=r("auto"),ct=r(void 0),dt=r(void 0),ht=r(void 0),pt=r(void 0),gt=function(){var e=i(pt);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},vt=function(e,t){switch(t.type){case"on-status":return h(h({},e),{status:t.status});case"dispose":return h(h({},e),{status:{type:"DISPOSED"},cursor:"auto"});case"on-cursor-change":return h(h({},e),{cursor:t.cursor});case"on-prototype-state-will-change":return h(h({},e),{prototypeState:h(h({},e.prototypeState),{isChanging:!0})});case"on-prototype-state-change":return h(h({},e),{prototypeState:h(h(h({},e.prototypeState),t.prototypeState),{isChanging:!1})});case"on-zoom":return h(h({},e),{zoom:t.zoom});case"on-pan":return h(h({},e),{pan:{x:t.pan.x,y:t.pan.y}});default:return e}},ft=function(n){var r=t(null),i=t(null),u=a(vt,{status:{type:"IDLE"},cursor:"auto",prototypeState:{currentArtboardId:"",canGoBack:!1,canGoForwards:!1,isChanging:!1},zoom:1,pan:{x:0,y:0}}),l=u[0],c=l.status,d=l.cursor,p=l.prototypeState,g=l.zoom,v=l.pan,f=u[1],m=o((function(e){f({type:"on-status",status:e})}),[]),y=o((function(e){return f({type:"on-zoom",zoom:e})}),[]),b=o((function(e,t){return f({type:"on-pan",pan:{x:e,y:t}})}),[]),w=o((function(e){return f({type:"on-cursor-change",cursor:e})}),[]),C=o((function(){return f({type:"on-prototype-state-will-change"})}),[]),P=o((function(e){return f({type:"on-prototype-state-change",prototypeState:e})}),[]),E=o((function(){var e=r.current;e&&($.logDebug("Provider dispose"),e.off("status",m),e.off("cursorChange",w),e.off("prototypeStateWillChange",C),e.off("prototypeStateChange",P),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.dispose(),r.current=null,f({type:"dispose"}))}),[m,w,C,P,b,y]),M=o((function(e,t){if(e&&t&&i.current){$.logDebug("Provider init");var n=new st(h(h({},i.current),{container:t,canvas:e,manualInitialization:!0}));n.on("status",m),n.on("cursorChange",w),n.on("prototypeStateWillChange",C),n.on("prototypeStateChange",P),n.on("cameraZoomChange",y),n.on("cameraPanChange",b),r.current=n,n.init()}}),[m,w,C,P,b,y]),L=o((function(e){var t,n,o,a,s,u,l,c;$.logDebug("Provider setSettings"),e.backgroundColor&&e.backgroundColor!=(null===(t=i.current)||void 0===t?void 0:t.backgroundColor)&&(null===(n=r.current)||void 0===n||n.setBackgroundColor(e.backgroundColor)),(null===(o=i.current)||void 0===o?void 0:o.resizeMode)!=e.resizeMode&&(null===(a=r.current)||void 0===a||a.setResizeMode(e.resizeMode||W.Fit)),void 0!==e.highlightHotspots&&(null===(s=i.current)||void 0===s?void 0:s.highlightHotspots)!==e.highlightHotspots&&(null===(u=r.current)||void 0===u||u.updateHighlightHotspotsSetting(e.highlightHotspots)),e.disableInteraction!==(null===(l=i.current)||void 0===l?void 0:l.disableInteraction)&&(null===(c=r.current)||void 0===c||c.gestureManager.setDisable(e.disableInteraction||!1)),i.current=e}),[]),x=o((function(){return r.current}),[]),R=s((function(){return{dispose:E,init:M,setSettings:L,getInstance:x,dispatch:f}}),[E,M,L,x]);return e.createElement(pt.Provider,{value:R},e.createElement(ut.Provider,{value:c},e.createElement(lt.Provider,{value:d},e.createElement(ct.Provider,{value:p},e.createElement(dt.Provider,{value:g},e.createElement(ht.Provider,{value:v},n.children))))))},mt=function(){var e=(0,gt().getInstance)();return o((function(t){null==e||e.restartPrototype(t)}),[e])},yt=function(){var e=(0,gt().getInstance)();return o((function(){null==e||e.navigateToFirstFlow()}),[e])},bt=function(){var e=(0,gt().getInstance)();return o((function(){null==e||e.goBack()}),[e])},wt=function(){var e=(0,gt().getInstance)();return o((function(){null==e||e.goForwards()}),[e])},Ct=function(){var e=(0,gt().getInstance)();return o((function(t,n){return p(void 0,void 0,void 0,(function(){return g(this,(function(o){return[2,null==e?void 0:e.getArtboardAtPosition(t,n)]}))}))}),[e])},Pt=function(){var e=(0,gt().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},Et=function(){var e=i(ut);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},Mt=function(){var e=i(lt);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},Lt=function(){var e=i(ct);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},xt=function(){var e=i(dt);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},Rt=function(){var e=i(ht);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},Wt=function(e,t){var n=(0,gt().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function St(){var e=(0,gt().getInstance)();return o((function(t){return void 0===t&&(t=!0),null==e?void 0:e.getScreen(t)}),[e])}var Tt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ft={position:"absolute",top:0,left:0},It=function(n){var o=n.locateFile,r=n.imagesURLFormat,i=n.imagesURLMap,a=n.backgroundColor,l=n.mode,c=n.showTilesBorders,d=n.minimumZoomLevel,p=n.maximumZoomLevel,g=n.preserveDrawingBuffer,v=n.children,f=n.containerProps,m=n.canvasProps,y=n.featureFlags,b=n.startArtboardUUID,w=n.prototypeStructure,C=n.fragmentsURLFormat,P=n.fragmentsURLMap,E=n.highlightHotspots,M=n.resizeMode,L=n.assetsManagerLimits,x=n.cursor,R=n.disableInteraction,W=t(null),S=t(null),T=gt(),F=T.dispose,I=T.init,A=T.setSettings,D=Et(),G=Mt(),U=("function"==typeof x?x(G):x)||G;u((function(){return $.logDebug("PrototypeRenderer mounted"),function(){return $.logDebug("PrototypeRenderer unmounted")}}),[]),u((function(){A({locateFile:o,imagesURLFormat:r,imagesURLMap:i,backgroundColor:a,mode:l,showTilesBorders:c,minimumZoomLevel:d,maximumZoomLevel:p,preserveDrawingBuffer:g,featureFlags:y,startArtboardUUID:b,prototypeStructure:w,fragmentsURLFormat:C,fragmentsURLMap:P,highlightHotspots:E,resizeMode:M,assetsManagerLimits:L,disableInteraction:R})}),[A,o,r,i,a,l,c,d,p,g,y,b,E,M,C,P,w,L,R]),u((function(){return I(W.current,S.current),function(){F()}}),[F,I]);var k=s((function(){return h(h({},Tt),{cursor:U})}),[U]);return e.createElement("div",h({},f,{ref:S,style:k}),e.createElement("canvas",h({},m,{ref:W,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==D?void 0:D.type.toLowerCase())||"null"),style:Ft})),"READY"===(null==D?void 0:D.type)&&v)},At={position:"absolute",inset:0,pointerEvents:"none"};function Dt(t){var n=t.visualize,r=void 0!==n&&n,i=St(),a=l((function(){return i()||null})),u=a[0],c=a[1],d=o((function(){c(i()||null)}),[i]);Wt("sceneChange",d);var p=s((function(){return h(h({},At),{opacity:r?1:0})}),[r]);return u?e.createElement("div",{style:p},u.layers.map((function(t,n){return e.createElement(Gt,{key:"".concat(n,"/").concat(t.id),bounds:t.bounds,id:t.id,name:t.name,type:t.type})}))):null}function Gt(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,a=xt(),u=Rt()||{x:0,y:0},l=u.x,c=u.y,d=s((function(){return h({position:"absolute",left:l/window.devicePixelRatio+n.x*a,top:c/window.devicePixelRatio+n.y*a,width:n.width*a,height:n.height*a,backgroundColor:"rgba(0, 255, 255, 0.2)",border:"2px dotted white"},"hotspot"===i?{cursor:"pointer",pointerEvents:"auto"}:{})}),[n.x,n.y,n.width,n.height,l,c,a,i]);return e.createElement("div",{style:d,"data-testid":"".concat(i,"-").concat(Ut(o),"-").concat(r),"data-entity-name":o,"data-entity-id":r,"data-entity-bounds-x":n.x,"data-entity-bounds-y":n.x,"data-entity-bounds-width":n.width,"data-entity-bounds-height":n.height})}function Ut(e){var t,n;return null!==(n=null===(t=e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))||void 0===t?void 0:t.join("-").toLowerCase())&&void 0!==n?n:""}export{We as CameraMoveContext,Re as CameraZoomingContext,Me as CanvasRenderer,De as CanvasRendererProvider,it as CanvasRendererReact,Te as CursorContext,A as DefaultFeatureFlags,F as EventEmitter,V as GestureManager,J as KeyboardManager,I as ListenersCollector,ye as PRCursorType,ce as PRMarinaBlendMode,ne as PRMarinaExportFormatType,le as PRMarinaLayerBlurType,ae as PRMarinaLayerBorderPosition,he as PRMarinaLayerCornerStyle,oe as PRMarinaLayerFillType,ie as PRMarinaLayerGradientType,ge as PRMarinaLayerHorizontalTextAlignment,re as PRMarinaLayerImageFillType,se as PRMarinaLayerLineCap,ue as PRMarinaLayerLineJoin,fe as PRMarinaLayerTextDecoration,pe as PRMarinaLayerTextTransform,de as PRMarinaLayerType,ve as PRMarinaLayerVerticalTextAlignment,te as PRMarinaVisibleScaleType,be as PRNodeExportFormat,me as PRUserPointerType,Se as PanContext,K as Performance,st as PrototypeRenderer,ft as PrototypeRendererProvider,It as PrototypeRendererReact,W as PrototypeResizeMode,Ce as PrototypeResizeModeWasm,we as PrototypeStructureFlowType,Dt as PrototypeTestOverlay,Le as StatusContext,S as WebRendererError,R as WebRendererMode,xe as ZoomContext,z as clamp,O as convertEmbindVectorToArray,k as debounce,B as extractPointer,Z as getSupportedWebGLVersion,D as getiOSVersion,T as isDefinedPresentationManifestArtboard,_ as isTouchDevice,$ as logger,Y as nextTick,U as parseSafariUserAgent,Ae as reducer,H as removeUndefinedKeys,j as safePtrAccess,N as touchableClick,ze as useCursor,X as useDebounceFunction,Je as useDecrementZoom,Ge as useEvent,tt as useExportNode,Xe as useGetArtboardAtPosition,qe as useGetPanAtPosition,St as useGetScreen,bt as useGoBack,wt as useGoForwards,Ve as useIncrementZoom,Oe as useIsCameraMoving,Ze as useIsCameraZooming,Qe as useLockCamera,nt as useLogEvent,$e as useLooseWebGLContext,et as useMapRelativePositionToCameraPosition,yt as useNavigateToFirstFlow,_e as usePRFile,He as usePRFileArtboards,Be as usePan,Mt as usePrototypeCursor,Wt as usePrototypeEvent,Ct as usePrototypeGetArtboardAtPosition,Pt as usePrototypeMapRelativePositionToCameraPosition,Rt as usePrototypePan,Lt as usePrototypeState,Et as usePrototypeStatus,xt as usePrototypeZoom,mt as useRestartPrototype,Ne as useRootNodeAbsoluteExtent,Ke as useSetPan,je as useSetZoom,Ue as useStatus,ke as useZoom,Ye as useZoomToFit};
@@ -1 +1 @@
1
- {"version":3,"file":"WasmModule.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/WasmModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,WAAW,EACX,SAAS,EAET,gCAAgC,EAChC,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,EACpB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;AAEtC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAErB,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,oBAAoB,CAAA;AAE3B,UAAU,kBAAkB;IAC1B,IAAI,EAAE,eAAe,CAAA;IAIrB,UAAU,EAAE,MAAM,CAAA;IAElB,QAAQ,EAAE,QAAQ,CAAA;IAElB,YAAY,EAAE,kBAAkB,CAAA;IAEhC,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACd,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,QAAQ,EAAG,qBAAqB,CAAA;IAChC,oBAAoB,EAAG,MAAM,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAA;IACjE,0BAA0B,EAAG,MAAM,CACxC,gBAAgB,CAAC,OAAO,CAAC,EACzB,SAAS,CACV,CAAA;IACM,4BAA4B,EAAG,MAAM,CAC1C,mBAAmB,EACnB,2BAA2B,CAC5B,CAAA;gBAEW,QAAQ,EAAE,kBAAkB;IAIxC,OAAO,CAAC,aAAa;IAIf,IAAI;IA8CH,gBAAgB,CACrB,MAAM,EAAE,iBAAiB,EACzB,sBAAsB,GAAE,gCAAqC,GAC5D,MAAM;IAiCT,2BAA2B,CACzB,KAAK,EAAE,gBAAgB,EACvB,cAAc,EAAE,0BAA0B;IA0C5C;;OAEG;IACI,mBAAmB,CAAC,cAAc,EAAE,0BAA0B;IA8BrE;;;;;;;;OAQG;IACH,YAAY;;;IA6BZ,cAAc,CAAC,YAAY,EAAE,gBAAgB;IAI7C,kBAAkB,CAAC,WAAW,EAAE,WAAW;IAO3C,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,iBAAiB;IAO3D,aAAa,CAAC,UAAU,EAAE,mBAAmB;CAG9C"}
1
+ {"version":3,"file":"WasmModule.d.ts","sourceRoot":"","sources":["../../../../src/ts/utils/WasmModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,WAAW,EACX,SAAS,EAET,gCAAgC,EAChC,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,EACpB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;AAEtC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAErB,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,oBAAoB,CAAA;AAE3B,UAAU,kBAAkB;IAC1B,IAAI,EAAE,eAAe,CAAA;IAIrB,UAAU,EAAE,MAAM,CAAA;IAElB,QAAQ,EAAE,QAAQ,CAAA;IAElB,YAAY,EAAE,kBAAkB,CAAA;IAEhC,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACd,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,QAAQ,EAAG,qBAAqB,CAAA;IAChC,oBAAoB,EAAG,MAAM,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAA;IACjE,0BAA0B,EAAG,MAAM,CACxC,gBAAgB,CAAC,OAAO,CAAC,EACzB,SAAS,CACV,CAAA;IACM,4BAA4B,EAAG,MAAM,CAC1C,mBAAmB,EACnB,2BAA2B,CAC5B,CAAA;gBAEW,QAAQ,EAAE,kBAAkB;IAIxC,OAAO,CAAC,aAAa;IAIf,IAAI;IA8CH,gBAAgB,CACrB,MAAM,EAAE,iBAAiB,EACzB,sBAAsB,GAAE,gCAAqC,GAC5D,MAAM;IAiCT,2BAA2B,CACzB,KAAK,EAAE,gBAAgB,EACvB,cAAc,EAAE,0BAA0B;IA0C5C;;OAEG;IACI,mBAAmB,CAAC,cAAc,EAAE,0BAA0B;IA8BrE;;;;;;;;OAQG;IACH,YAAY;;;IA+BZ,cAAc,CAAC,YAAY,EAAE,gBAAgB;IAI7C,kBAAkB,CAAC,WAAW,EAAE,WAAW;IAO3C,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,iBAAiB;IAO3D,aAAa,CAAC,UAAU,EAAE,mBAAmB;CAG9C"}
@@ -0,0 +1 @@
1
+ var e,r=(e=import.meta.url,function(){var r,t,n,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=Object.assign({},a),i=new Promise(((e,r)=>{t=e,n=r}));if(["_malloc","_free","_memory","___indirect_function_table","onRuntimeInitialized"].forEach((e=>{Object.getOwnPropertyDescriptor(i,e)||Object.defineProperty(i,e,{get:()=>O("You are getting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>O("You are setting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})})),o.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var s=Object.assign({},o),c="";if("undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),e&&(c=e),c=c.startsWith("blob:")?"":c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1),"object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var l,u,d=o.print||console.log.bind(console),f=o.printErr||console.error.bind(console);Object.assign(o,s),s=null,H("ENVIRONMENT"),H("GL_MAX_TEXTURE_IMAGE_UNITS"),H("SDL_canPlayWithWebAudio"),H("SDL_numSimultaneouslyQueuedBuffers"),H("INITIAL_MEMORY"),H("arguments"),H("canvas"),H("doNotCaptureKeyboard"),H("dynamicLibraries"),H("elementPointerLock"),H("extraStackTrace"),H("forcedAspectRatio"),H("keyboardListeningElement"),H("freePreloadedMediaOnUse"),H("loadSplitModule"),H("logReadFiles"),H("mem"),H("monitorRunDependencies"),H("noInitialRun"),H("onCustomMessage"),H("onExit"),H("onFree"),H("onFullScreen"),H("onMalloc"),H("onRealloc"),H("onRuntimeInitialized"),H("postMainLoop"),H("postRun"),H("preInit"),H("preMainLoop"),H("preRun"),H("preinitializedWebGLContext"),H("preloadPlugins"),H("quit"),H("setStatus"),H("statusMessage"),H("stderr"),H("stdin"),H("stdout"),H("thisProgram"),H("wasm"),H("wasmBinary"),H("websocket"),H("fetchSettings"),j("arguments","arguments_"),j("thisProgram","thisProgram"),j("quit","quit_"),x(void 0===o.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),x(void 0===o.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),x(void 0===o.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),x(void 0===o.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),x(void 0===o.read,"Module.read option was removed (modify read_ in JS)"),x(void 0===o.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),x(void 0===o.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),x(void 0===o.setWindowTitle,"Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),x(void 0===o.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),j("asm","wasmExports"),j("read","read_"),j("readAsync","readAsync"),j("readBinary","readBinary"),j("setWindowTitle","setWindowTitle"),x(!0,"worker environment detected but not enabled at build time. Add `worker` to `-sENVIRONMENT` to enable."),x(!0,"node environment detected but not enabled at build time. Add `node` to `-sENVIRONMENT` to enable."),x(!0,"shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable."),j("wasmBinary","wasmBinary"),"object"!=typeof WebAssembly&&f("no native wasm support detected");var m,g,v,p,h,y,b,_,w,T,E=!1;function x(e,r){e||O("Assertion failed"+(r?": "+r:""))}function S(){var e=u.buffer;m=new Int8Array(e),v=new Int16Array(e),g=new Uint8Array(e),p=new Uint16Array(e),h=new Int32Array(e),y=new Uint32Array(e),b=new Float32Array(e),T=new Float64Array(e),_=new BigInt64Array(e),w=new BigUint64Array(e)}function C(){if(!E){var e=Ft();0==e&&(e+=4);var r=y[e>>2],t=y[e+4>>2];34821223==r&&2310721022==t||O("Stack overflow! Stack cookie has been overwritten at ".concat(K(e),", expected hex dwords 0x89BACDFE and 0x2135467, but received ").concat(K(t)," ").concat(K(r))),1668509029!=y[0]&&O("Runtime error: The application has corrupted its heap memory area (address zero)!")}}x(!o.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),x("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),x(!o.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),x(!o.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically"),function(){var e=new Int16Array(1),r=new Int8Array(e.buffer);if(e[0]=25459,115!==r[0]||99!==r[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"}();var P=[],A=[],F=[],I=!1;x(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),x(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),x(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),x(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var L=0,k=null,D=null,M={};function O(e){var r;null===(r=o.onAbort)||void 0===r||r.call(o,e),f(e="Aborted("+e+")"),E=!0;var t=new WebAssembly.RuntimeError(e);throw n(t),t}var U={error(){O("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM")},init(){U.error()},createDataFile(){U.error()},createPreloadedFile(){U.error()},createLazyFile(){U.error()},open(){U.error()},mkdev(){U.error()},registerDevice(){U.error()},analyzePath(){U.error()},ErrnoError(){U.error()}};o.FS_createDataFile=U.createDataFile,o.FS_createPreloadedFile=U.createPreloadedFile;var B,W=e=>e.startsWith("data:application/octet-stream;base64,"),R=e=>e.startsWith("file://");function N(e,r){return function(){x(I,"native function `".concat(e,"` called before runtime initialization"));var t=Tt[e];return x(t,"exported native function `".concat(e,"` not found")),x(arguments.length<=r,"native function `".concat(e,"` called with ").concat(arguments.length," args but expects ").concat(r)),t(...arguments)}}function G(){if(o.locateFile){var e="web-renderer-debug.wasm";return W(e)?e:(r=e,o.locateFile?o.locateFile(r,c):c+r)}var r;return new URL("web-renderer-debug.wasm",import.meta.url).href}function $(e){if(e==B&&l)return new Uint8Array(l);throw"both async and sync fetching of the wasm failed"}function V(e,r,t){return function(e){return"function"==typeof fetch?fetch(e,{credentials:"same-origin"}).then((r=>{if(!r.ok)throw"failed to load wasm binary file at '".concat(e,"'");return r.arrayBuffer()})).catch((()=>$(e))):Promise.resolve().then((()=>$(e)))}(e).then((e=>WebAssembly.instantiate(e,r))).then(t,(e=>{f("failed to asynchronously prepare wasm: ".concat(e)),R(B)&&f("warning: Loading from a file URI (".concat(B,") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing")),O(e)}))}function j(e,r){var t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];Object.getOwnPropertyDescriptor(o,e)||Object.defineProperty(o,e,{configurable:!0,get(){var n=t?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":"";O("`Module.".concat(e,"` has been replaced by `").concat(r,"`")+n)}})}function H(e){Object.getOwnPropertyDescriptor(o,e)&&O("`Module.".concat(e,"` was supplied but `").concat(e,"` not included in INCOMING_MODULE_JS_API"))}function Y(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}function z(e,r){"undefined"!=typeof globalThis&&Object.defineProperty(globalThis,e,{configurable:!0,get(){re("`".concat(e,"` is not longer defined by emscripten. ").concat(r))}})}function J(e){Object.getOwnPropertyDescriptor(o,e)||Object.defineProperty(o,e,{configurable:!0,get(){var r="'".concat(e,"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)");Y(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),O(r)}})}function X(e){this.name="ExitStatus",this.message="Program terminated with exit(".concat(e,")"),this.status=e}z("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),z("asm","Please use wasmExports instead");var q=e=>{for(;e.length>0;)e.shift()(o)},Z=o.noExitRuntime||!0,K=e=>(x("number"==typeof e),"0x"+(e>>>=0).toString(16).padStart(8,"0")),Q=e=>It(e),ee=()=>Lt(),re=e=>{re.shown||(re.shown={}),re.shown[e]||(re.shown[e]=1,f(e))},te="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,ne=(e,r,t)=>{for(var n=r+t,a=r;e[a]&&!(a>=n);)++a;if(a-r>16&&e.buffer&&te)return te.decode(e.subarray(r,a));for(var o="";r<a;){var i=e[r++];if(128&i){var s=63&e[r++];if(192!=(224&i)){var c=63&e[r++];if(224==(240&i)?i=(15&i)<<12|s<<6|c:(240!=(248&i)&&re("Invalid UTF-8 leading byte "+K(i)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),i=(7&i)<<18|s<<12|c<<6|63&e[r++]),i<65536)o+=String.fromCharCode(i);else{var l=i-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|s)}else o+=String.fromCharCode(i)}return o},ae=(e,r)=>(x("number"==typeof e,"UTF8ToString expects a number (got ".concat(typeof e,")")),e?ne(g,e,r):""),oe={},ie=e=>{for(;e.length;){var r=e.pop();e.pop()(r)}};function se(e){return this.fromWireType(y[e>>2])}var ce,le,ue,de={},fe={},me={},ge=e=>{throw new ce(e)},ve=(e,r,t)=>{function n(r){var n=t(r);n.length!==e.length&&ge("Mismatched type converter count");for(var a=0;a<e.length;++a)be(e[a],n[a])}e.forEach((function(e){me[e]=r}));var a=new Array(r.length),o=[],i=0;r.forEach(((e,r)=>{fe.hasOwnProperty(e)?a[r]=fe[e]:(o.push(e),de.hasOwnProperty(e)||(de[e]=[]),de[e].push((()=>{a[r]=fe[e],++i===o.length&&n(a)})))})),0===o.length&&n(a)},pe=e=>{if(null===e)return"null";var r=typeof e;return"object"===r||"array"===r||"function"===r?e.toString():""+e},he=e=>{for(var r="",t=e;g[t];)r+=le[g[t++]];return r},ye=e=>{throw new ue(e)};function be(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.name;if(e||ye('type "'.concat(n,'" must have a positive integer typeid pointer')),fe.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;ye("Cannot register type '".concat(n,"' twice"))}if(fe[e]=r,delete me[e],de.hasOwnProperty(e)){var a=de[e];delete de[e],a.forEach((e=>e()))}}(e,r,t)}var _e,we=(e,r,t)=>{switch(r){case 1:return t?e=>m[e]:e=>g[e];case 2:return t?e=>v[e>>1]:e=>p[e>>1];case 4:return t?e=>h[e>>2]:e=>y[e>>2];case 8:return t?e=>_[e>>3]:e=>w[e>>3];default:throw new TypeError("invalid integer width (".concat(r,"): ").concat(e))}},Te=8,Ee=e=>{ye(e.$$.ptrType.registeredClass.name+" instance already deleted")},xe=!1,Se=e=>{},Ce=e=>{e.count.value-=1,0===e.count.value&&(e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)})(e)},Pe=(e,r,t)=>{if(r===t)return e;if(void 0===t.baseClass)return null;var n=Pe(e,r,t.baseClass);return null===n?null:t.downcast(n)},Ae={},Fe=()=>Object.keys(Me).length,Ie=()=>{var e=[];for(var r in Me)Me.hasOwnProperty(r)&&e.push(Me[r]);return e},Le=[],ke=()=>{for(;Le.length;){var e=Le.pop();e.$$.deleteScheduled=!1,e.delete()}},De=e=>{_e=e,Le.length&&_e&&_e(ke)},Me={},Oe=(e,r)=>(r=((e,r)=>{for(void 0===r&&ye("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r})(e,r),Me[r]),Ue=(e,r)=>(r.ptrType&&r.ptr||ge("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&ge("Both smartPtrType and smartPtr must be specified"),r.count={value:1},We(Object.create(e,{$$:{value:r,writable:!0}})));function Be(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Oe(this.registeredClass,r);if(void 0!==t){if(0===t.$$.count.value)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function a(){return this.isSmartPointer?Ue(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Ue(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o,i=this.registeredClass.getActualType(r),s=Ae[i];if(!s)return a.call(this);o=this.isConst?s.constPointerType:s.pointerType;var c=Pe(r,this.registeredClass,o.registeredClass);return null===c?a.call(this):this.isSmartPointer?Ue(o.registeredClass.instancePrototype,{ptrType:o,ptr:c,smartPtrType:this,smartPtr:e}):Ue(o.registeredClass.instancePrototype,{ptrType:o,ptr:c})}var We=e=>"undefined"==typeof FinalizationRegistry?(We=e=>e,e):(xe=new FinalizationRegistry((e=>{console.warn(e.leakWarning.stack.replace(/^Error: /,"")),Ce(e.$$)})),We=e=>{var r=e.$$;if(r.smartPtr){var t={$$:r},n=r.ptrType.registeredClass;t.leakWarning=new Error("Embind found a leaked C++ instance ".concat(n.name," <").concat(K(r.ptr),">.\n")+"We'll free it automatically in this case, but this functionality is not reliable across various environments.\nMake sure to invoke .delete() manually once you're done with the instance instead.\nOriginally allocated"),"captureStackTrace"in Error&&Error.captureStackTrace(t.leakWarning,Be),xe.register(e,t,e)}return e},Se=e=>xe.unregister(e),We(e));function Re(){}var Ne=(e,r)=>Object.defineProperty(r,"name",{value:e}),Ge=(e,r,t)=>{if(void 0===e[r].overloadTable){var n=e[r];e[r]=function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return e[r].overloadTable.hasOwnProperty(a.length)||ye("Function '".concat(t,"' called with an invalid number of arguments (").concat(a.length,") - expects one of (").concat(e[r].overloadTable,")!")),e[r].overloadTable[a.length].apply(this,a)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},$e=(e,r,t)=>{o.hasOwnProperty(e)?((void 0===t||void 0!==o[e].overloadTable&&void 0!==o[e].overloadTable[t])&&ye("Cannot register public name '".concat(e,"' twice")),Ge(o,e,e),o.hasOwnProperty(t)&&ye("Cannot register multiple overloads of a function with the same number of arguments (".concat(t,")!")),o[e].overloadTable[t]=r):(o[e]=r,void 0!==t&&(o[e].numArguments=t))};function Ve(e,r,t,n,a,o,i,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}var je=(e,r,t)=>{for(;r!==t;)r.upcast||ye("Expected null or instance of ".concat(t.name,", got an instance of ").concat(r.name)),e=r.upcast(e),r=r.baseClass;return e};function He(e,r){if(null===r)return this.isReference&&ye("null is not a valid ".concat(this.name)),0;r.$$||ye('Cannot pass "'.concat(pe(r),'" as a ').concat(this.name)),r.$$.ptr||ye("Cannot pass deleted object as a pointer of type ".concat(this.name));var t=r.$$.ptrType.registeredClass;return je(r.$$.ptr,t,this.registeredClass)}function Ye(e,r){var t;if(null===r)return this.isReference&&ye("null is not a valid ".concat(this.name)),this.isSmartPointer?(t=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,t),t):0;r&&r.$$||ye('Cannot pass "'.concat(pe(r),'" as a ').concat(this.name)),r.$$.ptr||ye("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&r.$$.ptrType.isConst&&ye("Cannot convert argument of type ".concat(r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name," to parameter type ").concat(this.name));var n=r.$$.ptrType.registeredClass;if(t=je(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&ye("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:ye("Cannot convert argument of type ".concat(r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name," to parameter type ").concat(this.name));break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var a=r.clone();t=this.rawShare(t,mr.toHandle((()=>a.delete()))),null!==e&&e.push(this.rawDestructor,t)}break;default:ye("Unsupporting sharing policy")}return t}function ze(e,r){if(null===r)return this.isReference&&ye("null is not a valid ".concat(this.name)),0;r.$$||ye('Cannot pass "'.concat(pe(r),'" as a ').concat(this.name)),r.$$.ptr||ye("Cannot pass deleted object as a pointer of type ".concat(this.name)),r.$$.ptrType.isConst&&ye("Cannot convert argument of type ".concat(r.$$.ptrType.name," to parameter type ").concat(this.name));var t=r.$$.ptrType.registeredClass;return je(r.$$.ptr,t,this.registeredClass)}function Je(e,r,t,n,a,o,i,s,c,l,u){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=l,this.rawDestructor=u,a||void 0!==r.baseClass?this.toWireType=Ye:n?(this.toWireType=He,this.destructorFunction=null):(this.toWireType=ze,this.destructorFunction=null)}var Xe,qe,Ze=[],Ke=e=>{var r=Ze[e];return r||(e>=Ze.length&&(Ze.length=e+1),Ze[e]=r=Xe.get(e)),x(Xe.get(e)==r,"JavaScript-side Wasm function table mirror is out of date!"),r},Qe=(e,r)=>{e=he(e);var t=Ke(r);return"function"!=typeof t&&ye("unknown function pointer with signature ".concat(e,": ").concat(r)),t},er=e=>{var r=Et(e),t=he(r);return St(r),t},rr=(e,r)=>{var t=[],n={};throw r.forEach((function e(r){n[r]||fe[r]||(me[r]?me[r].forEach(e):(t.push(r),n[r]=!0))})),new qe("".concat(e,": ")+t.map(er).join([", "]))};function tr(e){for(var r=1;r<e.length;++r)if(null!==e[r]&&void 0===e[r].destructorFunction)return!0;return!1}function nr(e,r){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(typeof e," which is not a function"));var t=Ne(e.name||"unknownFunctionName",(function(){}));t.prototype=e.prototype;var n=new t,a=e.apply(n,r);return a instanceof Object?a:n}function ar(e,r,t,n,a,o){var i=r.length;i<2&&ye("argTypes array size mismatch! Must at least get return value and 'this' types!"),x(!o,"Async bindings are only supported with JSPI.");for(var s=null!==r[1]&&null!==t,c=tr(r),l="void"!==r[0].name,u=[e,ye,n,a,ie,r[0],r[1]],d=0;d<i-2;++d)u.push(r[d+2]);if(!c)for(d=s?1:2;d<r.length;++d)null!==r[d].destructorFunction&&u.push(r[d].destructorFunction);var[f,m]=function(e,r,t,n){for(var a=tr(e),o=e.length,i="",s="",c=0;c<o-2;++c)i+=(0!==c?", ":"")+"arg"+c,s+=(0!==c?", ":"")+"arg"+c+"Wired";var l="\n return function (".concat(i,") {\n if (arguments.length !== ").concat(o-2,") {\n throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ").concat(o-2,"');\n }");a&&(l+="var destructors = [];\n");var u=a?"destructors":"null",d=["humanName","throwBindingError","invoker","fn","runDestructors","retType","classParam"];for(r&&(l+="var thisWired = classParam['toWireType']("+u+", this);\n"),c=0;c<o-2;++c)l+="var arg"+c+"Wired = argType"+c+"['toWireType']("+u+", arg"+c+");\n",d.push("argType"+c);if(r&&(s="thisWired"+(s.length>0?", ":"")+s),l+=(t||n?"var rv = ":"")+"invoker(fn"+(s.length>0?", ":"")+s+");\n",a)l+="runDestructors(destructors);\n";else for(c=r?1:2;c<e.length;++c){var f=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==e[c].destructorFunction&&(l+="".concat(f,"_dtor(").concat(f,");\n"),d.push("".concat(f,"_dtor")))}return t&&(l+="var ret = retType['fromWireType'](rv);\nreturn ret;\n"),l+="}\n",[d,l="if (arguments.length !== ".concat(d.length,'){ throw new Error(humanName + "Expected ').concat(d.length,' closure arguments " + arguments.length + " given."); }\n').concat(l)]}(r,s,l,o);f.push(m);var g=nr(Function,f)(...u);return Ne(e,g)}var or,ir=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(y[r+4*n>>2]);return t},sr=e=>{var r=(e=e.trim()).indexOf("(");return-1!==r?(x(")"==e[e.length-1],"Parentheses for argument names should match."),e.substr(0,r)):e},cr=(e,r,t)=>(e instanceof Object||ye("".concat(t,' with invalid "this": ').concat(e)),e instanceof r.registeredClass.constructor||ye("".concat(t,' incompatible with "this" of type ').concat(e.constructor.name)),e.$$.ptr||ye("cannot call emscripten binding method ".concat(t," on deleted object")),je(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),lr=[],ur=[],dr=e=>{e>9&&0==--ur[e+1]&&(x(void 0!==ur[e],"Decref for unallocated handle."),ur[e]=void 0,lr.push(e))},fr=()=>ur.length/2-5-lr.length,mr={toValue:e=>(e||ye("Cannot use deleted val. handle = "+e),x(2===e||void 0!==ur[e]&&e%2==0,"invalid handle: ".concat(e)),ur[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:var r=lr.pop()||ur.length;return ur[r]=e,ur[r+1]=1,r}}},gr={name:"emscripten::val",fromWireType:e=>{var r=mr.toValue(e);return dr(e),r},toWireType:(e,r)=>mr.toHandle(r),argPackAdvance:Te,readValueFromPointer:se,destructorFunction:null},vr=e=>be(e,gr),pr=(e,r,t)=>{switch(r){case 1:return t?function(e){return this.fromWireType(m[e])}:function(e){return this.fromWireType(g[e])};case 2:return t?function(e){return this.fromWireType(v[e>>1])}:function(e){return this.fromWireType(p[e>>1])};case 4:return t?function(e){return this.fromWireType(h[e>>2])}:function(e){return this.fromWireType(y[e>>2])};default:throw new TypeError("invalid integer width (".concat(r,"): ").concat(e))}},hr=(e,r)=>{var t=fe[e];return void 0===t&&ye("".concat(r," has unknown type ").concat(er(e))),t},yr=(e,r)=>{switch(r){case 4:return function(e){return this.fromWireType(b[e>>2])};case 8:return function(e){return this.fromWireType(T[e>>3])};default:throw new TypeError("invalid float width (".concat(r,"): ").concat(e))}},br=(e,r,t,n)=>{if(x("string"==typeof e,"stringToUTF8Array expects a string (got ".concat(typeof e,")")),!(n>0))return 0;for(var a=t,o=t+n-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),s<=127){if(t>=o)break;r[t++]=s}else if(s<=2047){if(t+1>=o)break;r[t++]=192|s>>6,r[t++]=128|63&s}else if(s<=65535){if(t+2>=o)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(t+3>=o)break;s>1114111&&re("Invalid Unicode code point "+K(s)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|63&s}}return r[t]=0,t-a},_r=(e,r,t)=>(x("number"==typeof t,"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),br(e,g,r,t)),wr=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Tr="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,Er=(e,r)=>{x(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");for(var t=e,n=t>>1,a=n+r/2;!(n>=a)&&p[n];)++n;if((t=n<<1)-e>32&&Tr)return Tr.decode(g.subarray(e,t));for(var o="",i=0;!(i>=r/2);++i){var s=v[e+2*i>>1];if(0==s)break;o+=String.fromCharCode(s)}return o},xr=(e,r,t)=>{var n;if(x(r%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),x("number"==typeof t,"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),null!==(n=t)&&void 0!==n||(t=2147483647),t<2)return 0;for(var a=r,o=(t-=2)<2*e.length?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);v[r>>1]=s,r+=2}return v[r>>1]=0,r-a},Sr=e=>2*e.length,Cr=(e,r)=>{x(e%4==0,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var t=0,n="";!(t>=r/4);){var a=h[e+4*t>>2];if(0==a)break;if(++t,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(a)}return n},Pr=(e,r,t)=>{var n;if(x(r%4==0,"Pointer passed to stringToUTF32 must be aligned to four bytes!"),x("number"==typeof t,"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),null!==(n=t)&&void 0!==n||(t=2147483647),t<4)return 0;for(var a=r,o=a+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),h[r>>2]=s,(r+=4)+4>o)break}return h[r>>2]=0,r-a},Ar=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4}return r},Fr=(e,r,t)=>{var n=[],a=e.toWireType(n,t);return n.length&&(y[r>>2]=mr.toHandle(n)),a},Ir=[],Lr={},kr=e=>{var r=Lr[e];return void 0===r?he(e):r},Dr=()=>"object"==typeof globalThis?globalThis:Function("return this")();or=()=>performance.now();var Mr,Or,Ur,Br,Wr=e=>{var r=u.buffer,t=(e-r.byteLength+65535)/65536;try{return u.grow(t),S(),1}catch(t){f("growMemory: Attempted to grow heap from ".concat(r.byteLength," bytes to ").concat(e," bytes, but got error: ").concat(t))}},Rr=e=>{var r=["ANGLE_instanced_arrays","EXT_blend_minmax","EXT_disjoint_timer_query","EXT_frag_depth","EXT_shader_texture_lod","EXT_sRGB","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","WEBGL_color_buffer_float","WEBGL_depth_texture","WEBGL_draw_buffers","EXT_color_buffer_float","EXT_conservative_depth","EXT_disjoint_timer_query_webgl2","EXT_texture_norm16","NV_shader_noperspective_interpolation","WEBGL_clip_cull_distance","EXT_color_buffer_half_float","EXT_depth_clamp","EXT_float_blend","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","KHR_parallel_shader_compile","OES_texture_float_linear","WEBGL_blend_func_extended","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_lose_context","WEBGL_multi_draw"];return(e.getSupportedExtensions()||[]).filter((e=>r.includes(e)))},Nr={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:[],offscreenCanvases:{},queries:[],samplers:[],transformFeedbacks:[],syncs:[],stringCache:{},stringiCache:{},unpackAlignment:4,recordError:e=>{Nr.lastError||(Nr.lastError=e)},getNewId:e=>{for(var r=Nr.counter++,t=e.length;t<r;t++)e[t]=null;return r},genObject:(e,r,t,n)=>{for(var a=0;a<e;a++){var o=Br[t](),i=o&&Nr.getNewId(n);o?(o.name=i,n[i]=o):Nr.recordError(1282),h[r+4*a>>2]=i}},getSource:(e,r,t,n)=>{for(var a="",o=0;o<r;++o){var i=n?y[n+4*o>>2]:void 0;a+=ae(y[t+4*o>>2],i)}return a},createContext:(e,r)=>{e.getContextSafariWebGL2Fixed||(e.getContextSafariWebGL2Fixed=e.getContext,e.getContext=function(r,t){var n=e.getContextSafariWebGL2Fixed(r,t);return"webgl"==r==n instanceof WebGLRenderingContext?n:null});var t=r.majorVersion>1?e.getContext("webgl2",r):e.getContext("webgl",r);return t?Nr.registerContext(t,r):0},registerContext:(e,r)=>{var t=Nr.getNewId(Nr.contexts),n={handle:t,attributes:r,version:r.majorVersion,GLctx:e};return e.canvas&&(e.canvas.GLctxObject=n),Nr.contexts[t]=n,(void 0===r.enableExtensionsByDefault||r.enableExtensionsByDefault)&&Nr.initExtensions(n),t},makeContextCurrent:e=>{var r;return Nr.currentContext=Nr.contexts[e],o.ctx=Br=null===(r=Nr.currentContext)||void 0===r?void 0:r.GLctx,!(e&&!Br)},getContext:e=>Nr.contexts[e],deleteContext:e=>{Nr.currentContext===Nr.contexts[e]&&(Nr.currentContext=null),"object"==typeof JSEvents&&JSEvents.removeAllHandlersOnTarget(Nr.contexts[e].GLctx.canvas),Nr.contexts[e]&&Nr.contexts[e].GLctx.canvas&&(Nr.contexts[e].GLctx.canvas.GLctxObject=void 0),Nr.contexts[e]=null},initExtensions:e=>{if(e||(e=Nr.currentContext),!e.initExtensionsDone){e.initExtensionsDone=!0;var r,t=e.GLctx;(e=>{var r=e.getExtension("ANGLE_instanced_arrays");r&&(e.vertexAttribDivisor=(e,t)=>r.vertexAttribDivisorANGLE(e,t),e.drawArraysInstanced=(e,t,n,a)=>r.drawArraysInstancedANGLE(e,t,n,a),e.drawElementsInstanced=(e,t,n,a,o)=>r.drawElementsInstancedANGLE(e,t,n,a,o))})(t),(e=>{var r=e.getExtension("OES_vertex_array_object");r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.deleteVertexArray=e=>r.deleteVertexArrayOES(e),e.bindVertexArray=e=>r.bindVertexArrayOES(e),e.isVertexArray=e=>r.isVertexArrayOES(e))})(t),(e=>{var r=e.getExtension("WEBGL_draw_buffers");r&&(e.drawBuffers=(e,t)=>r.drawBuffersWEBGL(e,t))})(t),(r=t).dibvbi=r.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),(e=>{e.mdibvbi=e.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance")})(t),e.version>=2&&(t.disjointTimerQueryExt=t.getExtension("EXT_disjoint_timer_query_webgl2")),(e.version<2||!t.disjointTimerQueryExt)&&(t.disjointTimerQueryExt=t.getExtension("EXT_disjoint_timer_query")),(e=>{e.multiDrawWebgl=e.getExtension("WEBGL_multi_draw")})(t),Rr(t).forEach((e=>{e.includes("lose_context")||e.includes("debug")||t.getExtension(e)}))}}},Gr={},$r=()=>{if(!$r.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:"./this.program"};for(var r in Gr)void 0===Gr[r]?delete e[r]:e[r]=Gr[r];var t=[];for(var r in e)t.push("".concat(r,"=").concat(e[r]));$r.strings=t}return $r.strings},Vr=()=>Z||!1,jr=(e,r)=>{if(function(){var e=d,r=f,t=!1;d=f=e=>{t=!0};try{zr()}catch(e){}d=e,f=r,t&&(re("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc."),re("(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)"))}(),Vr()&&!r){var t="program exited (with status: ".concat(e,"), but keepRuntimeAlive() is set (counter=").concat(0,") due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)");n(t),f(t)}var a;a=e,Vr()||(E=!0),((e,r)=>{throw r})(0,new X(a))},Hr=[null,[],[]],Yr=(e,r)=>{var t=Hr[e];x(t),0===r||10===r?((1===e?d:f)(ne(t,0)),t.length=0):t.push(r)},zr=()=>{Ct(0),Hr[1].length&&Yr(1,10),Hr[2].length&&Yr(2,10)},Jr=e=>{Br.bindVertexArray(Nr.vaos[e])},Xr=Jr,qr=(e,r)=>{for(var t=0;t<e;t++){var n=h[r+4*t>>2];Br.deleteVertexArray(Nr.vaos[n]),Nr.vaos[n]=null}},Zr=qr,Kr=[],Qr=(e,r,t,n)=>{Br.drawElements(e,r,t,n)},et=(e,r)=>{Nr.genObject(e,r,"createVertexArray",Nr.vaos)},rt=et,tt=(e,r)=>{y[e>>2]=r;var t=y[e>>2];y[e+4>>2]=(r-t)/4294967296;var n=r>=0?(e=>y[e>>2]+4294967296*y[e+4>>2])(e):(e=>y[e>>2]+4294967296*h[e+4>>2])(e),a=e>>2;n!=r&&re("writeI53ToI64() out of range: serialized JS Number ".concat(r," to Wasm heap as bytes lo=").concat(K(y[a]),", hi=").concat(K(y[a+1]),", which deserializes back to ").concat(n," instead!"))},nt=function(){var e=Rr(Br);return e=e.concat(e.map((e=>"GL_"+e)))},at=(e,r,t)=>{if(r){var n=void 0;switch(e){case 36346:n=1;break;case 36344:return void(0!=t&&1!=t&&Nr.recordError(1280));case 34814:case 36345:n=0;break;case 34466:var a=Br.getParameter(34467);n=a?a.length:0;break;case 33309:if(Nr.currentContext.version<2)return void Nr.recordError(1282);n=nt().length;break;case 33307:case 33308:if(Nr.currentContext.version<2)return void Nr.recordError(1280);n=33307==e?3:0}if(void 0===n){var o=Br.getParameter(e);switch(typeof o){case"number":n=o;break;case"boolean":n=o?1:0;break;case"string":return void Nr.recordError(1280);case"object":if(null===o)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:n=0;break;default:return void Nr.recordError(1280)}else{if(o instanceof Float32Array||o instanceof Uint32Array||o instanceof Int32Array||o instanceof Array){for(var i=0;i<o.length;++i)switch(t){case 0:h[r+4*i>>2]=o[i];break;case 2:b[r+4*i>>2]=o[i];break;case 4:m[r+i]=o[i]?1:0}return}try{n=0|o.name}catch(r){return Nr.recordError(1280),void f("GL_INVALID_ENUM in glGet".concat(t,"v: Unknown object returned from WebGL getParameter(").concat(e,")! (error: ").concat(r,")"))}}break;default:return Nr.recordError(1280),void f("GL_INVALID_ENUM in glGet".concat(t,"v: Native code calling glGet").concat(t,"v(").concat(e,") and it returns ").concat(o," of type ").concat(typeof o,"!"))}}switch(t){case 1:tt(r,n);break;case 0:h[r>>2]=n;break;case 2:b[r>>2]=n;break;case 4:m[r]=n?1:0}}else Nr.recordError(1281)},ot=e=>{var r=wr(e)+1,t=xt(r);return t&&_r(e,t,r),t},it=e=>"]"==e.slice(-1)&&e.lastIndexOf("["),st=e=>0==(e-=5120)?m:1==e?g:2==e?v:4==e?h:6==e?b:5==e||28922==e||28520==e||30779==e||30782==e?y:p,ct=(e,r)=>e>>>31-Math.clz32(r.BYTES_PER_ELEMENT),lt=(e,r,t,n,a,o)=>{var i=st(e),s=(e=>({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[e-6402]||1))(r)*i.BYTES_PER_ELEMENT,c=((e,r,t,n)=>{var a;return r*(e*t+(a=n)-1&-a)})(t,n,s,Nr.unpackAlignment);return i.subarray(ct(a,i),ct(a+c,i))},ut=e=>{var r=Br.currentProgram;if(r){var t=r.uniformLocsById[e];return"number"==typeof t&&(r.uniformLocsById[e]=t=Br.getUniformLocation(r,r.uniformArrayNamesById[e]+(t>0?"[".concat(t,"]"):""))),t}Nr.recordError(1282)},dt=[],ft=[],mt=e=>e%4==0&&(e%100!=0||e%400==0),gt=[31,29,31,30,31,30,31,31,30,31,30,31],vt=[31,28,31,30,31,30,31,31,30,31,30,31],pt=(e,r,t,n)=>{var a=y[n+40>>2],o={tm_sec:h[n>>2],tm_min:h[n+4>>2],tm_hour:h[n+8>>2],tm_mday:h[n+12>>2],tm_mon:h[n+16>>2],tm_year:h[n+20>>2],tm_wday:h[n+24>>2],tm_yday:h[n+28>>2],tm_isdst:h[n+32>>2],tm_gmtoff:h[n+36>>2],tm_zone:a?ae(a):""},i=ae(t),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var c in s)i=i.replace(new RegExp(c,"g"),s[c]);var l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],u=["January","February","March","April","May","June","July","August","September","October","November","December"];function d(e,r,t){for(var n="number"==typeof e?e.toString():e||"";n.length<r;)n=t[0]+n;return n}function f(e,r){return d(e,r,"0")}function g(e,r){function t(e){return e<0?-1:e>0?1:0}var n;return 0===(n=t(e.getFullYear()-r.getFullYear()))&&0===(n=t(e.getMonth()-r.getMonth()))&&(n=t(e.getDate()-r.getDate())),n}function v(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function p(e){var r=((e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=mt(t.getFullYear()),a=t.getMonth(),o=(n?gt:vt)[a];if(!(r>o-t.getDate()))return t.setDate(t.getDate()+r),t;r-=o-t.getDate()+1,t.setDate(1),a<11?t.setMonth(a+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return t})(new Date(e.tm_year+1900,0,1),e.tm_yday),t=new Date(r.getFullYear(),0,4),n=new Date(r.getFullYear()+1,0,4),a=v(t),o=v(n);return g(a,r)<=0?g(o,r)<=0?r.getFullYear()+1:r.getFullYear():r.getFullYear()-1}var b={"%a":e=>l[e.tm_wday].substring(0,3),"%A":e=>l[e.tm_wday],"%b":e=>u[e.tm_mon].substring(0,3),"%B":e=>u[e.tm_mon],"%C":e=>f((e.tm_year+1900)/100|0,2),"%d":e=>f(e.tm_mday,2),"%e":e=>d(e.tm_mday,2," "),"%g":e=>p(e).toString().substring(2),"%G":p,"%H":e=>f(e.tm_hour,2),"%I":e=>{var r=e.tm_hour;return 0==r?r=12:r>12&&(r-=12),f(r,2)},"%j":e=>f(e.tm_mday+((e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t})(mt(e.tm_year+1900)?gt:vt,e.tm_mon-1),3),"%m":e=>f(e.tm_mon+1,2),"%M":e=>f(e.tm_min,2),"%n":()=>"\n","%p":e=>e.tm_hour>=0&&e.tm_hour<12?"AM":"PM","%S":e=>f(e.tm_sec,2),"%t":()=>"\t","%u":e=>e.tm_wday||7,"%U":e=>{var r=e.tm_yday+7-e.tm_wday;return f(Math.floor(r/7),2)},"%V":e=>{var r=Math.floor((e.tm_yday+7-(e.tm_wday+6)%7)/7);if((e.tm_wday+371-e.tm_yday-2)%7<=2&&r++,r){if(53==r){var t=(e.tm_wday+371-e.tm_yday)%7;4==t||3==t&&mt(e.tm_year)||(r=1)}}else{r=52;var n=(e.tm_wday+7-e.tm_yday-1)%7;(4==n||5==n&&mt(e.tm_year%400-1))&&r++}return f(r,2)},"%w":e=>e.tm_wday,"%W":e=>{var r=e.tm_yday+7-(e.tm_wday+6)%7;return f(Math.floor(r/7),2)},"%y":e=>(e.tm_year+1900).toString().substring(2),"%Y":e=>e.tm_year+1900,"%z":e=>{var r=e.tm_gmtoff,t=r>=0;return r=(r=Math.abs(r)/60)/60*100+r%60,(t?"+":"-")+String("0000"+r).slice(-4)},"%Z":e=>e.tm_zone,"%%":()=>"%"};for(var c in i=i.replace(/%%/g,"\0\0"),b)i.includes(c)&&(i=i.replace(new RegExp(c,"g"),b[c](o)));i=i.replace(/\0\0/g,"%");var _,w,T,E,S,C,P,A,F=(_=i,w=!1,E=T>0?T:wr(_)+1,S=new Array(E),C=br(_,S,0,S.length),w&&(S.length=C),S);return F.length>r?0:(A=e,x((P=F).length>=0,"writeArrayToMemory array must have a length (should be an array or typed array)"),m.set(P,A),F.length-1)};ce=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},(()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);le=e})(),ue=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Object.assign(Re.prototype,{isAliasOf(e){if(!(this instanceof Re))return!1;if(!(e instanceof Re))return!1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,a=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return r===n&&t===a},clone(){if(this.$$.ptr||Ee(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,r=We(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return r.$$.count.value+=1,r.$$.deleteScheduled=!1,r},delete(){this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ye("Object already scheduled for deletion"),Se(this),Ce(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&ye("Object already scheduled for deletion"),Le.push(this),1===Le.length&&_e&&_e(ke),this.$$.deleteScheduled=!0,this}}),o.getInheritedInstanceCount=Fe,o.getLiveInheritedInstances=Ie,o.flushPendingDeletes=ke,o.setDelayFunction=De,Object.assign(Je.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){var r;null===(r=this.rawDestructor)||void 0===r||r.call(this,e)},argPackAdvance:Te,readValueFromPointer:se,fromWireType:Be}),qe=o.UnboundTypeError=(Mr=Error,(Ur=Ne(Or="UnboundTypeError",(function(e){this.name=Or,this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(Mr.prototype),Ur.prototype.constructor=Ur,Ur.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},Ur),ur.push(0,1,void 0,1,null,1,!0,1,!1,1),x(10===ur.length),o.count_emval_handles=fr;for(var ht=0;ht<32;++ht)Kr.push(new Array(ht));var yt=new Float32Array(288);for(ht=0;ht<288;++ht)dt[ht]=yt.subarray(0,ht);var bt=new Int32Array(288);for(ht=0;ht<288;++ht)ft[ht]=bt.subarray(0,ht);var _t,wt={__assert_fail:(e,r,t,n)=>{O("Assertion failed: ".concat(ae(e),", at: ")+[r?ae(r):"unknown filename",t,n?ae(n):"unknown function"])},_abort_js:()=>{O("native code called abort()")},_embind_finalize_value_object:e=>{var r=oe[e];delete oe[e];var t=r.rawConstructor,n=r.rawDestructor,a=r.fields,o=a.map((e=>e.getterReturnType)).concat(a.map((e=>e.setterArgumentType)));ve([e],o,(e=>{var o={};return a.forEach(((r,t)=>{var n=r.fieldName,i=e[t],s=r.getter,c=r.getterContext,l=e[t+a.length],u=r.setter,d=r.setterContext;o[n]={read:e=>i.fromWireType(s(c,e)),write:(e,r)=>{var t=[];u(d,e,l.toWireType(t,r)),ie(t)}}})),[{name:r.name,fromWireType:e=>{var r={};for(var t in o)r[t]=o[t].read(e);return n(e),r},toWireType:(e,r)=>{for(var a in o)if(!(a in r))throw new TypeError('Missing field: "'.concat(a,'"'));var i=t();for(a in o)o[a].write(i,r[a]);return null!==e&&e.push(n,i),i},argPackAdvance:Te,readValueFromPointer:se,destructorFunction:n}]}))},_embind_register_bigint:(e,r,t,n,a)=>{var o=-1!=(r=he(r)).indexOf("u");o&&(a=(1n<<64n)-1n),be(e,{name:r,fromWireType:e=>e,toWireType:function(e,t){if("bigint"!=typeof t&&"number"!=typeof t)throw new TypeError('Cannot convert "'.concat(pe(t),'" to ').concat(this.name));if("number"==typeof t&&(t=BigInt(t)),t<n||t>a)throw new TypeError('Passing a number "'.concat(pe(t),'" from JS side to C/C++ side to an argument of type "').concat(r,'", which is outside the valid range [').concat(n,", ").concat(a,"]!"));return t},argPackAdvance:Te,readValueFromPointer:we(r,t,!o),destructorFunction:null})},_embind_register_bool:(e,r,t,n)=>{be(e,{name:r=he(r),fromWireType:function(e){return!!e},toWireType:function(e,r){return r?t:n},argPackAdvance:Te,readValueFromPointer:function(e){return this.fromWireType(g[e])},destructorFunction:null})},_embind_register_class:(e,r,t,n,a,i,s,c,l,u,d,f,m)=>{d=he(d),i=Qe(a,i),c&&(c=Qe(s,c)),u&&(u=Qe(l,u)),m=Qe(f,m);var g=(e=>{if(void 0===e)return"_unknown";var r=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?"_".concat(e):e})(d);$e(g,(function(){rr("Cannot construct ".concat(d," due to unbound types"),[n])})),ve([e,r,t],n?[n]:[],(r=>{var t,a;r=r[0],a=n?(t=r.registeredClass).instancePrototype:Re.prototype;var s=Ne(d,(function(){if(Object.getPrototypeOf(this)!==l)throw new ue("Use 'new' to construct "+d);if(void 0===p.constructor_body)throw new ue(d+" has no accessible constructor");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var n=p.constructor_body[r.length];if(void 0===n)throw new ue("Tried to invoke ctor of ".concat(d," with invalid number of parameters (").concat(r.length,") - expected (").concat(Object.keys(p.constructor_body).toString(),") parameters instead!"));return n.apply(this,r)})),l=Object.create(a,{constructor:{value:s}});s.prototype=l;var f,v,p=new Ve(d,s,l,m,t,i,c,u);p.baseClass&&(null!==(v=(f=p.baseClass).__derivedClasses)&&void 0!==v||(f.__derivedClasses=[]),p.baseClass.__derivedClasses.push(p));var h=new Je(d,p,!0,!1,!1),y=new Je(d+"*",p,!1,!1,!1),b=new Je(d+" const*",p,!1,!0,!1);return Ae[e]={pointerType:y,constPointerType:b},((e,r,t)=>{o.hasOwnProperty(e)||ge("Replacing nonexistent public symbol"),void 0!==o[e].overloadTable&&void 0!==t?o[e].overloadTable[t]=r:(o[e]=r,o[e].argCount=t)})(g,s),[h,y,b]}))},_embind_register_class_class_function:(e,r,t,n,a,o,i,s)=>{var c=ir(t,n);r=he(r),r=sr(r),o=Qe(a,o),ve([],[e],(e=>{e=e[0];var n="".concat(e.name,".").concat(r);function a(){rr("Cannot call ".concat(n," due to unbound types"),c)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var l=e.registeredClass.constructor;return void 0===l[r]?(a.argCount=t-1,l[r]=a):(Ge(l,r,n),l[r].overloadTable[t-1]=a),ve([],c,(a=>{var c=[a[0],null].concat(a.slice(1)),u=ar(n,c,null,o,i,s);if(void 0===l[r].overloadTable?(u.argCount=t-1,l[r]=u):l[r].overloadTable[t-1]=u,e.registeredClass.__derivedClasses)for(var d of e.registeredClass.__derivedClasses)d.constructor.hasOwnProperty(r)||(d.constructor[r]=u);return[]})),[]}))},_embind_register_class_constructor:(e,r,t,n,a,o)=>{x(r>0);var i=ir(r,t);a=Qe(n,a),ve([],[e],(e=>{e=e[0];var t="constructor ".concat(e.name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[r-1])throw new ue("Cannot register multiple constructors with identical number of parameters (".concat(r-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[r-1]=()=>{rr("Cannot construct ".concat(e.name," due to unbound types"),i)},ve([],i,(n=>(n.splice(1,0,null),e.registeredClass.constructor_body[r-1]=ar(t,n,null,a,o),[]))),[]}))},_embind_register_class_function:(e,r,t,n,a,o,i,s,c)=>{var l=ir(t,n);r=he(r),r=sr(r),o=Qe(a,o),ve([],[e],(e=>{e=e[0];var n="".concat(e.name,".").concat(r);function a(){rr("Cannot call ".concat(n," due to unbound types"),l)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(r);var u=e.registeredClass.instancePrototype,d=u[r];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===t-2?(a.argCount=t-2,a.className=e.name,u[r]=a):(Ge(u,r,n),u[r].overloadTable[t-2]=a),ve([],l,(a=>{var s=ar(n,a,e,o,i,c);return void 0===u[r].overloadTable?(s.argCount=t-2,u[r]=s):u[r].overloadTable[t-2]=s,[]})),[]}))},_embind_register_class_property:(e,r,t,n,a,o,i,s,c,l)=>{r=he(r),a=Qe(n,a),ve([],[e],(e=>{e=e[0];var n="".concat(e.name,".").concat(r),u={get(){rr("Cannot access ".concat(n," due to unbound types"),[t,i])},enumerable:!0,configurable:!0};return u.set=c?()=>rr("Cannot access ".concat(n," due to unbound types"),[t,i]):e=>ye(n+" is a read-only property"),Object.defineProperty(e.registeredClass.instancePrototype,r,u),ve([],c?[t,i]:[t],(t=>{var i=t[0],u={get(){var r=cr(this,e,n+" getter");return i.fromWireType(a(o,r))},enumerable:!0};if(c){c=Qe(s,c);var d=t[1];u.set=function(r){var t=cr(this,e,n+" setter"),a=[];c(l,t,d.toWireType(a,r)),ie(a)}}return Object.defineProperty(e.registeredClass.instancePrototype,r,u),[]})),[]}))},_embind_register_emval:vr,_embind_register_enum:(e,r,t,n)=>{function a(){}r=he(r),a.values={},be(e,{name:r,constructor:a,fromWireType:function(e){return this.constructor.values[e]},toWireType:(e,r)=>r.value,argPackAdvance:Te,readValueFromPointer:pr(r,t,n),destructorFunction:null}),$e(r,a)},_embind_register_enum_value:(e,r,t)=>{var n=hr(e,"enum");r=he(r);var a=n.constructor,o=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:Ne("".concat(n.name,"_").concat(r),(function(){}))}});a.values[t]=o,a[r]=o},_embind_register_float:(e,r,t)=>{be(e,{name:r=he(r),fromWireType:e=>e,toWireType:(e,r)=>{if("number"!=typeof r&&"boolean"!=typeof r)throw new TypeError("Cannot convert ".concat(pe(r)," to ").concat(this.name));return r},argPackAdvance:Te,readValueFromPointer:yr(r,t),destructorFunction:null})},_embind_register_integer:(e,r,t,n,a)=>{r=he(r),-1===a&&(a=4294967295);var o=e=>e;if(0===n){var i=32-8*t;o=e=>e<<i>>>i}var s=r.includes("unsigned"),c=(e,t)=>{if("number"!=typeof e&&"boolean"!=typeof e)throw new TypeError('Cannot convert "'.concat(pe(e),'" to ').concat(t));if(e<n||e>a)throw new TypeError('Passing a number "'.concat(pe(e),'" from JS side to C/C++ side to an argument of type "').concat(r,'", which is outside the valid range [').concat(n,", ").concat(a,"]!"))};be(e,{name:r,fromWireType:o,toWireType:s?function(e,r){return c(r,this.name),r>>>0}:function(e,r){return c(r,this.name),r},argPackAdvance:Te,readValueFromPointer:we(r,t,0!==n),destructorFunction:null})},_embind_register_memory_view:(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][r];function a(e){var r=y[e>>2],t=y[e+4>>2];return new n(m.buffer,t,r)}be(e,{name:t=he(t),fromWireType:a,argPackAdvance:Te,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},_embind_register_optional:(e,r)=>{vr(e)},_embind_register_smart_ptr:(e,r,t,n,a,o,i,s,c,l,u,d)=>{t=he(t),o=Qe(a,o),s=Qe(i,s),l=Qe(c,l),d=Qe(u,d),ve([e],[r],(e=>(e=e[0],[new Je(t,e.registeredClass,!1,!1,!0,e,n,o,s,l,d)])))},_embind_register_std_string:(e,r)=>{var t="std::string"===(r=he(r));be(e,{name:r,fromWireType(e){var r,n=y[e>>2],a=e+4;if(t)for(var o=a,i=0;i<=n;++i){var s=a+i;if(i==n||0==g[s]){var c=ae(o,s-o);void 0===r?r=c:(r+=String.fromCharCode(0),r+=c),o=s+1}}else{var l=new Array(n);for(i=0;i<n;++i)l[i]=String.fromCharCode(g[a+i]);r=l.join("")}return St(e),r},toWireType(e,r){var n;r instanceof ArrayBuffer&&(r=new Uint8Array(r));var a="string"==typeof r;a||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array||ye("Cannot pass non-string to std::string"),n=t&&a?wr(r):r.length;var o=xt(4+n+1),i=o+4;if(y[o>>2]=n,t&&a)_r(r,i,n+1);else if(a)for(var s=0;s<n;++s){var c=r.charCodeAt(s);c>255&&(St(i),ye("String has UTF-16 code units that do not fit in 8 bits")),g[i+s]=c}else for(s=0;s<n;++s)g[i+s]=r[s];return null!==e&&e.push(St,o),o},argPackAdvance:Te,readValueFromPointer:se,destructorFunction(e){St(e)}})},_embind_register_std_wstring:(e,r,t)=>{var n,a,o,i;t=he(t),2===r?(n=Er,a=xr,i=Sr,o=e=>p[e>>1]):4===r&&(n=Cr,a=Pr,i=Ar,o=e=>y[e>>2]),be(e,{name:t,fromWireType:e=>{for(var t,a=y[e>>2],i=e+4,s=0;s<=a;++s){var c=e+4+s*r;if(s==a||0==o(c)){var l=n(i,c-i);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),i=c+r}}return St(e),t},toWireType:(e,n)=>{"string"!=typeof n&&ye("Cannot pass non-string to C++ string type ".concat(t));var o=i(n),s=xt(4+o+r);return y[s>>2]=o/r,a(n,s+4,o+r),null!==e&&e.push(St,s),s},argPackAdvance:Te,readValueFromPointer:se,destructorFunction(e){St(e)}})},_embind_register_user_type:(e,r)=>{vr(e)},_embind_register_value_object:(e,r,t,n,a,o)=>{oe[e]={name:he(r),rawConstructor:Qe(t,n),rawDestructor:Qe(a,o),fields:[]}},_embind_register_value_object_field:(e,r,t,n,a,o,i,s,c,l)=>{oe[e].fields.push({fieldName:he(r),getterReturnType:t,getter:Qe(n,a),getterContext:o,setterArgumentType:i,setter:Qe(s,c),setterContext:l})},_embind_register_void:(e,r)=>{be(e,{isVoid:!0,name:r=he(r),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,r)=>{}})},_emscripten_get_now_is_monotonic:()=>1,_emscripten_throw_longjmp:()=>{throw 1/0},_emval_as:(e,r,t)=>(e=mr.toValue(e),r=hr(r,"emval::as"),Fr(r,t,e)),_emval_call:(e,r,t,n)=>(e=Ir[e])(null,r=mr.toValue(r),t,n),_emval_call_method:(e,r,t,n,a)=>(e=Ir[e])(r=mr.toValue(r),r[t=kr(t)],n,a),_emval_decref:dr,_emval_get_global:e=>0===e?mr.toHandle(Dr()):(e=kr(e),mr.toHandle(Dr()[e])),_emval_get_method_caller:(e,r,t)=>{var n=((e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=hr(y[r+4*n>>2],"parameter "+n);return t})(e,r),a=n.shift();e--;var o="return function (obj, func, destructorsRef, args) {\n",i=0,s=[];0===t&&s.push("obj");for(var c=["retType"],l=[a],u=0;u<e;++u)s.push("arg"+u),c.push("argType"+u),l.push(n[u]),o+=" var arg".concat(u," = argType").concat(u,".readValueFromPointer(args").concat(i?"+"+i:"",");\n"),i+=n[u].argPackAdvance;o+=" var rv = ".concat(1===t?"new func":"func.call","(").concat(s.join(", "),");\n"),a.isVoid||(c.push("emval_returnValue"),l.push(Fr),o+=" return emval_returnValue(retType, destructorsRef, rv);\n"),o+="};\n",c.push(o);var d,f,m=nr(Function,c)(...l),g="methodCaller<(".concat(n.map((e=>e.name)).join(", "),") => ").concat(a.name,">");return d=Ne(g,m),f=Ir.length,Ir.push(d),f},_emval_get_module_property:e=>(e=kr(e),mr.toHandle(o[e])),_emval_get_property:(e,r)=>(e=mr.toValue(e),r=mr.toValue(r),mr.toHandle(e[r])),_emval_incref:e=>{e>9&&(ur[e+1]+=1)},_emval_new_array:()=>mr.toHandle([]),_emval_new_cstring:e=>mr.toHandle(kr(e)),_emval_run_destructors:e=>{var r=mr.toValue(e);ie(r),dr(e)},_emval_take_value:(e,r)=>{var t=(e=hr(e,"_emval_take_value")).readValueFromPointer(r);return mr.toHandle(t)},_gmtime_js:function(e,r){var t;e=(t=e)<-9007199254740992||t>9007199254740992?NaN:Number(t);var n=new Date(1e3*e);h[r>>2]=n.getUTCSeconds(),h[r+4>>2]=n.getUTCMinutes(),h[r+8>>2]=n.getUTCHours(),h[r+12>>2]=n.getUTCDate(),h[r+16>>2]=n.getUTCMonth(),h[r+20>>2]=n.getUTCFullYear()-1900,h[r+24>>2]=n.getUTCDay();var a=Date.UTC(n.getUTCFullYear(),0,1,0,0,0,0),o=(n.getTime()-a)/864e5|0;h[r+28>>2]=o},_tzset_js:(e,r,t,n)=>{var a=(new Date).getFullYear(),o=new Date(a,0,1),i=new Date(a,6,1),s=o.getTimezoneOffset(),c=i.getTimezoneOffset(),l=Math.max(s,c);y[e>>2]=60*l,h[r>>2]=Number(s!=c);var u=e=>e.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],d=u(o),f=u(i);x(d),x(f),x(wr(d)<=16,"timezone name truncated to fit in TZNAME_MAX (".concat(d,")")),x(wr(f)<=16,"timezone name truncated to fit in TZNAME_MAX (".concat(f,")")),c<s?(_r(d,t,17),_r(f,n,17)):(_r(d,n,17),_r(f,t,17))},emscripten_cancel_animation_frame:e=>cancelAnimationFrame(e),emscripten_date_now:()=>Date.now(),emscripten_get_now:or,emscripten_request_animation_frame:(e,r)=>requestAnimationFrame((t=>Ke(e)(t,r))),emscripten_resize_heap:e=>{var r=g.length;x((e>>>=0)>r);var t=2147483648;if(e>t)return f("Cannot enlarge memory, requested ".concat(e," bytes, but the limit is ").concat(t," bytes!")),!1;for(var n,a,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,(n=Math.max(e,i))+((a=65536)-n%a)%a);if(Wr(s))return!0}return f("Failed to grow the heap from ".concat(r," bytes to ").concat(s," bytes, not enough memory!")),!1},emscripten_webgl_make_context_current:e=>Nr.makeContextCurrent(e)?0:-5,environ_get:(e,r)=>{var t=0;return $r().forEach(((n,a)=>{var o=r+t;y[e+4*a>>2]=o,((e,r)=>{for(var t=0;t<e.length;++t)x(e.charCodeAt(t)===(255&e.charCodeAt(t))),m[r++]=e.charCodeAt(t);m[r]=0})(n,o),t+=n.length+1})),0},environ_sizes_get:(e,r)=>{var t=$r();y[e>>2]=t.length;var n=0;return t.forEach((e=>n+=e.length+1)),y[r>>2]=n,0},exit:jr,fd_close:e=>{O("fd_close called without SYSCALLS_REQUIRE_FILESYSTEM")},fd_seek:function(e,r,t,n){return 70},fd_write:(e,r,t,n)=>{for(var a=0,o=0;o<t;o++){var i=y[r>>2],s=y[r+4>>2];r+=8;for(var c=0;c<s;c++)Yr(e,g[i+c]);a+=s}return y[n>>2]=a,0},glActiveTexture:e=>Br.activeTexture(e),glAttachShader:(e,r)=>{Br.attachShader(Nr.programs[e],Nr.shaders[r])},glBindAttribLocation:(e,r,t)=>{Br.bindAttribLocation(Nr.programs[e],r,ae(t))},glBindBuffer:(e,r)=>{35051==e?Br.currentPixelPackBufferBinding=r:35052==e&&(Br.currentPixelUnpackBufferBinding=r),Br.bindBuffer(e,Nr.buffers[r])},glBindFramebuffer:(e,r)=>{Br.bindFramebuffer(e,Nr.framebuffers[r])},glBindRenderbuffer:(e,r)=>{Br.bindRenderbuffer(e,Nr.renderbuffers[r])},glBindSampler:(e,r)=>{Br.bindSampler(e,Nr.samplers[r])},glBindTexture:(e,r)=>{Br.bindTexture(e,Nr.textures[r])},glBindVertexArray:Jr,glBindVertexArrayOES:Xr,glBlendColor:(e,r,t,n)=>Br.blendColor(e,r,t,n),glBlendEquation:e=>Br.blendEquation(e),glBlendFunc:(e,r)=>Br.blendFunc(e,r),glBlitFramebuffer:(e,r,t,n,a,o,i,s,c,l)=>Br.blitFramebuffer(e,r,t,n,a,o,i,s,c,l),glBufferData:(e,r,t,n)=>{Nr.currentContext.version>=2?t&&r?Br.bufferData(e,g,n,t,r):Br.bufferData(e,r,n):Br.bufferData(e,t?g.subarray(t,t+r):r,n)},glBufferSubData:(e,r,t,n)=>{Nr.currentContext.version>=2?t&&Br.bufferSubData(e,r,g,n,t):Br.bufferSubData(e,r,g.subarray(n,n+t))},glCheckFramebufferStatus:e=>Br.checkFramebufferStatus(e),glClear:e=>Br.clear(e),glClearColor:(e,r,t,n)=>Br.clearColor(e,r,t,n),glClearStencil:e=>Br.clearStencil(e),glClientWaitSync:(e,r,t)=>(t=Number(t),Br.clientWaitSync(Nr.syncs[e],r,t)),glColorMask:(e,r,t,n)=>{Br.colorMask(!!e,!!r,!!t,!!n)},glCompileShader:e=>{Br.compileShader(Nr.shaders[e])},glCompressedTexImage2D:(e,r,t,n,a,o,i,s)=>{if(Nr.currentContext.version>=2)return Br.currentPixelUnpackBufferBinding||!i?void Br.compressedTexImage2D(e,r,t,n,a,o,i,s):void Br.compressedTexImage2D(e,r,t,n,a,o,g,s,i);Br.compressedTexImage2D(e,r,t,n,a,o,s?g.subarray(s,s+i):null)},glCompressedTexSubImage2D:(e,r,t,n,a,o,i,s,c)=>{if(Nr.currentContext.version>=2)return Br.currentPixelUnpackBufferBinding||!s?void Br.compressedTexSubImage2D(e,r,t,n,a,o,i,s,c):void Br.compressedTexSubImage2D(e,r,t,n,a,o,i,g,c,s);Br.compressedTexSubImage2D(e,r,t,n,a,o,i,c?g.subarray(c,c+s):null)},glCopyBufferSubData:(e,r,t,n,a)=>Br.copyBufferSubData(e,r,t,n,a),glCopyTexSubImage2D:(e,r,t,n,a,o,i,s)=>Br.copyTexSubImage2D(e,r,t,n,a,o,i,s),glCreateProgram:()=>{var e=Nr.getNewId(Nr.programs),r=Br.createProgram();return r.name=e,r.maxUniformLength=r.maxAttributeLength=r.maxUniformBlockNameLength=0,r.uniformIdCounter=1,Nr.programs[e]=r,e},glCreateShader:e=>{var r=Nr.getNewId(Nr.shaders);return Nr.shaders[r]=Br.createShader(e),r},glCullFace:e=>Br.cullFace(e),glDeleteBuffers:(e,r)=>{for(var t=0;t<e;t++){var n=h[r+4*t>>2],a=Nr.buffers[n];a&&(Br.deleteBuffer(a),a.name=0,Nr.buffers[n]=null,n==Br.currentPixelPackBufferBinding&&(Br.currentPixelPackBufferBinding=0),n==Br.currentPixelUnpackBufferBinding&&(Br.currentPixelUnpackBufferBinding=0))}},glDeleteFramebuffers:(e,r)=>{for(var t=0;t<e;++t){var n=h[r+4*t>>2],a=Nr.framebuffers[n];a&&(Br.deleteFramebuffer(a),a.name=0,Nr.framebuffers[n]=null)}},glDeleteProgram:e=>{if(e){var r=Nr.programs[e];r?(Br.deleteProgram(r),r.name=0,Nr.programs[e]=null):Nr.recordError(1281)}},glDeleteRenderbuffers:(e,r)=>{for(var t=0;t<e;t++){var n=h[r+4*t>>2],a=Nr.renderbuffers[n];a&&(Br.deleteRenderbuffer(a),a.name=0,Nr.renderbuffers[n]=null)}},glDeleteSamplers:(e,r)=>{for(var t=0;t<e;t++){var n=h[r+4*t>>2],a=Nr.samplers[n];a&&(Br.deleteSampler(a),a.name=0,Nr.samplers[n]=null)}},glDeleteShader:e=>{if(e){var r=Nr.shaders[e];r?(Br.deleteShader(r),Nr.shaders[e]=null):Nr.recordError(1281)}},glDeleteSync:e=>{if(e){var r=Nr.syncs[e];r?(Br.deleteSync(r),r.name=0,Nr.syncs[e]=null):Nr.recordError(1281)}},glDeleteTextures:(e,r)=>{for(var t=0;t<e;t++){var n=h[r+4*t>>2],a=Nr.textures[n];a&&(Br.deleteTexture(a),a.name=0,Nr.textures[n]=null)}},glDeleteVertexArrays:qr,glDeleteVertexArraysOES:Zr,glDepthMask:e=>{Br.depthMask(!!e)},glDisable:e=>Br.disable(e),glDisableVertexAttribArray:e=>{Br.disableVertexAttribArray(e)},glDrawArrays:(e,r,t)=>{Br.drawArrays(e,r,t)},glDrawArraysInstanced:(e,r,t,n)=>{Br.drawArraysInstanced(e,r,t,n)},glDrawArraysInstancedBaseInstanceWEBGL:(e,r,t,n,a)=>{Br.dibvbi.drawArraysInstancedBaseInstanceWEBGL(e,r,t,n,a)},glDrawBuffers:(e,r)=>{for(var t=Kr[e],n=0;n<e;n++)t[n]=h[r+4*n>>2];Br.drawBuffers(t)},glDrawElements:Qr,glDrawElementsInstanced:(e,r,t,n,a)=>{Br.drawElementsInstanced(e,r,t,n,a)},glDrawElementsInstancedBaseVertexBaseInstanceWEBGL:(e,r,t,n,a,o,i)=>{Br.dibvbi.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,r,t,n,a,o,i)},glDrawRangeElements:(e,r,t,n,a,o)=>{Qr(e,n,a,o)},glEnable:e=>Br.enable(e),glEnableVertexAttribArray:e=>{Br.enableVertexAttribArray(e)},glFenceSync:(e,r)=>{var t=Br.fenceSync(e,r);if(t){var n=Nr.getNewId(Nr.syncs);return t.name=n,Nr.syncs[n]=t,n}return 0},glFinish:()=>Br.finish(),glFlush:()=>Br.flush(),glFramebufferRenderbuffer:(e,r,t,n)=>{Br.framebufferRenderbuffer(e,r,t,Nr.renderbuffers[n])},glFramebufferTexture2D:(e,r,t,n,a)=>{Br.framebufferTexture2D(e,r,t,Nr.textures[n],a)},glFrontFace:e=>Br.frontFace(e),glGenBuffers:(e,r)=>{Nr.genObject(e,r,"createBuffer",Nr.buffers)},glGenFramebuffers:(e,r)=>{Nr.genObject(e,r,"createFramebuffer",Nr.framebuffers)},glGenRenderbuffers:(e,r)=>{Nr.genObject(e,r,"createRenderbuffer",Nr.renderbuffers)},glGenSamplers:(e,r)=>{Nr.genObject(e,r,"createSampler",Nr.samplers)},glGenTextures:(e,r)=>{Nr.genObject(e,r,"createTexture",Nr.textures)},glGenVertexArrays:et,glGenVertexArraysOES:rt,glGenerateMipmap:e=>Br.generateMipmap(e),glGetBufferParameteriv:(e,r,t)=>{t?h[t>>2]=Br.getBufferParameter(e,r):Nr.recordError(1281)},glGetError:()=>{var e=Br.getError()||Nr.lastError;return Nr.lastError=0,e},glGetFloatv:(e,r)=>at(e,r,2),glGetFramebufferAttachmentParameteriv:(e,r,t,n)=>{var a=Br.getFramebufferAttachmentParameter(e,r,t);(a instanceof WebGLRenderbuffer||a instanceof WebGLTexture)&&(a=0|a.name),h[n>>2]=a},glGetIntegerv:(e,r)=>at(e,r,0),glGetProgramInfoLog:(e,r,t,n)=>{var a=Br.getProgramInfoLog(Nr.programs[e]);null===a&&(a="(unknown error)");var o=r>0&&n?_r(a,n,r):0;t&&(h[t>>2]=o)},glGetProgramiv:(e,r,t)=>{if(t)if(e>=Nr.counter)Nr.recordError(1281);else if(e=Nr.programs[e],35716==r){var n=Br.getProgramInfoLog(e);null===n&&(n="(unknown error)"),h[t>>2]=n.length+1}else if(35719==r){if(!e.maxUniformLength)for(var a=0;a<Br.getProgramParameter(e,35718);++a)e.maxUniformLength=Math.max(e.maxUniformLength,Br.getActiveUniform(e,a).name.length+1);h[t>>2]=e.maxUniformLength}else if(35722==r){if(!e.maxAttributeLength)for(a=0;a<Br.getProgramParameter(e,35721);++a)e.maxAttributeLength=Math.max(e.maxAttributeLength,Br.getActiveAttrib(e,a).name.length+1);h[t>>2]=e.maxAttributeLength}else if(35381==r){if(!e.maxUniformBlockNameLength)for(a=0;a<Br.getProgramParameter(e,35382);++a)e.maxUniformBlockNameLength=Math.max(e.maxUniformBlockNameLength,Br.getActiveUniformBlockName(e,a).length+1);h[t>>2]=e.maxUniformBlockNameLength}else h[t>>2]=Br.getProgramParameter(e,r);else Nr.recordError(1281)},glGetRenderbufferParameteriv:(e,r,t)=>{t?h[t>>2]=Br.getRenderbufferParameter(e,r):Nr.recordError(1281)},glGetShaderInfoLog:(e,r,t,n)=>{var a=Br.getShaderInfoLog(Nr.shaders[e]);null===a&&(a="(unknown error)");var o=r>0&&n?_r(a,n,r):0;t&&(h[t>>2]=o)},glGetShaderPrecisionFormat:(e,r,t,n)=>{var a=Br.getShaderPrecisionFormat(e,r);h[t>>2]=a.rangeMin,h[t+4>>2]=a.rangeMax,h[n>>2]=a.precision},glGetShaderiv:(e,r,t)=>{if(t)if(35716==r){var n=Br.getShaderInfoLog(Nr.shaders[e]);null===n&&(n="(unknown error)");var a=n?n.length+1:0;h[t>>2]=a}else if(35720==r){var o=Br.getShaderSource(Nr.shaders[e]),i=o?o.length+1:0;h[t>>2]=i}else h[t>>2]=Br.getShaderParameter(Nr.shaders[e],r);else Nr.recordError(1281)},glGetString:e=>{var r=Nr.stringCache[e];if(!r){switch(e){case 7939:r=ot(nt().join(" "));break;case 7936:case 7937:case 37445:case 37446:var t=Br.getParameter(e);t||Nr.recordError(1280),r=t?ot(t):0;break;case 7938:var n=Br.getParameter(7938);n=Nr.currentContext.version>=2?"OpenGL ES 3.0 (".concat(n,")"):"OpenGL ES 2.0 (".concat(n,")"),r=ot(n);break;case 35724:var a=Br.getParameter(35724),o=a.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==o&&(3==o[1].length&&(o[1]=o[1]+"0"),a="OpenGL ES GLSL ES ".concat(o[1]," (").concat(a,")")),r=ot(a);break;default:Nr.recordError(1280)}Nr.stringCache[e]=r}return r},glGetStringi:(e,r)=>{if(Nr.currentContext.version<2)return Nr.recordError(1282),0;var t=Nr.stringiCache[e];if(t)return r<0||r>=t.length?(Nr.recordError(1281),0):t[r];if(7939===e){var n=nt().map(ot);return t=Nr.stringiCache[e]=n,r<0||r>=t.length?(Nr.recordError(1281),0):t[r]}return Nr.recordError(1280),0},glGetUniformLocation:(e,r)=>{if(r=ae(r),e=Nr.programs[e]){(e=>{var r,t,n=e.uniformLocsById,a=e.uniformSizeAndIdsByName;if(!n)for(e.uniformLocsById=n={},e.uniformArrayNamesById={},r=0;r<Br.getProgramParameter(e,35718);++r){var o=Br.getActiveUniform(e,r),i=o.name,s=o.size,c=it(i),l=c>0?i.slice(0,c):i,u=e.uniformIdCounter;for(e.uniformIdCounter+=s,a[l]=[s,u],t=0;t<s;++t)n[u]=t,e.uniformArrayNamesById[u++]=l}})(e);var t=e.uniformLocsById,n=0,a=r,o=it(r);o>0&&(s=r.slice(o+1),n=parseInt(s)>>>0,a=r.slice(0,o));var i=e.uniformSizeAndIdsByName[a];if(i&&n<i[0]&&(t[n+=i[1]]=t[n]||Br.getUniformLocation(e,r)))return n}else Nr.recordError(1281);var s;return-1},glInvalidateFramebuffer:(e,r,t)=>{for(var n=Kr[r],a=0;a<r;a++)n[a]=h[t+4*a>>2];Br.invalidateFramebuffer(e,n)},glInvalidateSubFramebuffer:(e,r,t,n,a,o,i)=>{for(var s=Kr[r],c=0;c<r;c++)s[c]=h[t+4*c>>2];Br.invalidateSubFramebuffer(e,s,n,a,o,i)},glIsSync:e=>Br.isSync(Nr.syncs[e]),glIsTexture:e=>{var r=Nr.textures[e];return r?Br.isTexture(r):0},glLineWidth:e=>Br.lineWidth(e),glLinkProgram:e=>{e=Nr.programs[e],Br.linkProgram(e),e.uniformLocsById=0,e.uniformSizeAndIdsByName={}},glMultiDrawArraysInstancedBaseInstanceWEBGL:(e,r,t,n,a,o)=>{Br.mdibvbi.multiDrawArraysInstancedBaseInstanceWEBGL(e,h,r>>2,h,t>>2,h,n>>2,y,a>>2,o)},glMultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL:(e,r,t,n,a,o,i,s)=>{Br.mdibvbi.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,h,r>>2,t,h,n>>2,h,a>>2,h,o>>2,y,i>>2,s)},glPixelStorei:(e,r)=>{3317==e&&(Nr.unpackAlignment=r),Br.pixelStorei(e,r)},glReadBuffer:e=>Br.readBuffer(e),glReadPixels:(e,r,t,n,a,o,i)=>{if(Nr.currentContext.version>=2){if(Br.currentPixelPackBufferBinding)return void Br.readPixels(e,r,t,n,a,o,i);var s=st(o),c=ct(i,s);Br.readPixels(e,r,t,n,a,o,s,c)}else{var l=lt(o,a,t,n,i);l?Br.readPixels(e,r,t,n,a,o,l):Nr.recordError(1280)}},glRenderbufferStorage:(e,r,t,n)=>Br.renderbufferStorage(e,r,t,n),glRenderbufferStorageMultisample:(e,r,t,n,a)=>Br.renderbufferStorageMultisample(e,r,t,n,a),glSamplerParameterf:(e,r,t)=>{Br.samplerParameterf(Nr.samplers[e],r,t)},glSamplerParameteri:(e,r,t)=>{Br.samplerParameteri(Nr.samplers[e],r,t)},glSamplerParameteriv:(e,r,t)=>{var n=h[t>>2];Br.samplerParameteri(Nr.samplers[e],r,n)},glScissor:(e,r,t,n)=>Br.scissor(e,r,t,n),glShaderSource:(e,r,t,n)=>{var a=Nr.getSource(e,r,t,n);Br.shaderSource(Nr.shaders[e],a)},glStencilFunc:(e,r,t)=>Br.stencilFunc(e,r,t),glStencilFuncSeparate:(e,r,t,n)=>Br.stencilFuncSeparate(e,r,t,n),glStencilMask:e=>Br.stencilMask(e),glStencilMaskSeparate:(e,r)=>Br.stencilMaskSeparate(e,r),glStencilOp:(e,r,t)=>Br.stencilOp(e,r,t),glStencilOpSeparate:(e,r,t,n)=>Br.stencilOpSeparate(e,r,t,n),glTexImage2D:(e,r,t,n,a,o,i,s,c)=>{if(Nr.currentContext.version>=2){if(Br.currentPixelUnpackBufferBinding)return void Br.texImage2D(e,r,t,n,a,o,i,s,c);if(c){var l=st(s),u=ct(c,l);return void Br.texImage2D(e,r,t,n,a,o,i,s,l,u)}}var d=c?lt(s,i,n,a,c):null;Br.texImage2D(e,r,t,n,a,o,i,s,d)},glTexParameterf:(e,r,t)=>Br.texParameterf(e,r,t),glTexParameterfv:(e,r,t)=>{var n=b[t>>2];Br.texParameterf(e,r,n)},glTexParameteri:(e,r,t)=>Br.texParameteri(e,r,t),glTexParameteriv:(e,r,t)=>{var n=h[t>>2];Br.texParameteri(e,r,n)},glTexStorage2D:(e,r,t,n,a)=>Br.texStorage2D(e,r,t,n,a),glTexSubImage2D:(e,r,t,n,a,o,i,s,c)=>{if(Nr.currentContext.version>=2){if(Br.currentPixelUnpackBufferBinding)return void Br.texSubImage2D(e,r,t,n,a,o,i,s,c);if(c){var l=st(s);return void Br.texSubImage2D(e,r,t,n,a,o,i,s,l,ct(c,l))}}var u=c?lt(s,i,a,o,c):null;Br.texSubImage2D(e,r,t,n,a,o,i,s,u)},glUniform1f:(e,r)=>{Br.uniform1f(ut(e),r)},glUniform1fv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform1fv(ut(e),b,t>>2,r);else{if(r<=288)for(var n=dt[r],a=0;a<r;++a)n[a]=b[t+4*a>>2];else n=b.subarray(t>>2,t+4*r>>2);Br.uniform1fv(ut(e),n)}},glUniform1i:(e,r)=>{Br.uniform1i(ut(e),r)},glUniform1iv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform1iv(ut(e),h,t>>2,r);else{if(r<=288)for(var n=ft[r],a=0;a<r;++a)n[a]=h[t+4*a>>2];else n=h.subarray(t>>2,t+4*r>>2);Br.uniform1iv(ut(e),n)}},glUniform2f:(e,r,t)=>{Br.uniform2f(ut(e),r,t)},glUniform2fv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform2fv(ut(e),b,t>>2,2*r);else{if(r<=144)for(var n=dt[2*r],a=0;a<2*r;a+=2)n[a]=b[t+4*a>>2],n[a+1]=b[t+(4*a+4)>>2];else n=b.subarray(t>>2,t+8*r>>2);Br.uniform2fv(ut(e),n)}},glUniform2i:(e,r,t)=>{Br.uniform2i(ut(e),r,t)},glUniform2iv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform2iv(ut(e),h,t>>2,2*r);else{if(r<=144)for(var n=ft[2*r],a=0;a<2*r;a+=2)n[a]=h[t+4*a>>2],n[a+1]=h[t+(4*a+4)>>2];else n=h.subarray(t>>2,t+8*r>>2);Br.uniform2iv(ut(e),n)}},glUniform3f:(e,r,t,n)=>{Br.uniform3f(ut(e),r,t,n)},glUniform3fv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform3fv(ut(e),b,t>>2,3*r);else{if(r<=96)for(var n=dt[3*r],a=0;a<3*r;a+=3)n[a]=b[t+4*a>>2],n[a+1]=b[t+(4*a+4)>>2],n[a+2]=b[t+(4*a+8)>>2];else n=b.subarray(t>>2,t+12*r>>2);Br.uniform3fv(ut(e),n)}},glUniform3i:(e,r,t,n)=>{Br.uniform3i(ut(e),r,t,n)},glUniform3iv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform3iv(ut(e),h,t>>2,3*r);else{if(r<=96)for(var n=ft[3*r],a=0;a<3*r;a+=3)n[a]=h[t+4*a>>2],n[a+1]=h[t+(4*a+4)>>2],n[a+2]=h[t+(4*a+8)>>2];else n=h.subarray(t>>2,t+12*r>>2);Br.uniform3iv(ut(e),n)}},glUniform4f:(e,r,t,n,a)=>{Br.uniform4f(ut(e),r,t,n,a)},glUniform4fv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform4fv(ut(e),b,t>>2,4*r);else{if(r<=72){var n=dt[4*r],a=b;t>>=2;for(var o=0;o<4*r;o+=4){var i=t+o;n[o]=a[i],n[o+1]=a[i+1],n[o+2]=a[i+2],n[o+3]=a[i+3]}}else n=b.subarray(t>>2,t+16*r>>2);Br.uniform4fv(ut(e),n)}},glUniform4i:(e,r,t,n,a)=>{Br.uniform4i(ut(e),r,t,n,a)},glUniform4iv:(e,r,t)=>{if(Nr.currentContext.version>=2)r&&Br.uniform4iv(ut(e),h,t>>2,4*r);else{if(r<=72)for(var n=ft[4*r],a=0;a<4*r;a+=4)n[a]=h[t+4*a>>2],n[a+1]=h[t+(4*a+4)>>2],n[a+2]=h[t+(4*a+8)>>2],n[a+3]=h[t+(4*a+12)>>2];else n=h.subarray(t>>2,t+16*r>>2);Br.uniform4iv(ut(e),n)}},glUniformMatrix2fv:(e,r,t,n)=>{if(Nr.currentContext.version>=2)r&&Br.uniformMatrix2fv(ut(e),!!t,b,n>>2,4*r);else{if(r<=72)for(var a=dt[4*r],o=0;o<4*r;o+=4)a[o]=b[n+4*o>>2],a[o+1]=b[n+(4*o+4)>>2],a[o+2]=b[n+(4*o+8)>>2],a[o+3]=b[n+(4*o+12)>>2];else a=b.subarray(n>>2,n+16*r>>2);Br.uniformMatrix2fv(ut(e),!!t,a)}},glUniformMatrix3fv:(e,r,t,n)=>{if(Nr.currentContext.version>=2)r&&Br.uniformMatrix3fv(ut(e),!!t,b,n>>2,9*r);else{if(r<=32)for(var a=dt[9*r],o=0;o<9*r;o+=9)a[o]=b[n+4*o>>2],a[o+1]=b[n+(4*o+4)>>2],a[o+2]=b[n+(4*o+8)>>2],a[o+3]=b[n+(4*o+12)>>2],a[o+4]=b[n+(4*o+16)>>2],a[o+5]=b[n+(4*o+20)>>2],a[o+6]=b[n+(4*o+24)>>2],a[o+7]=b[n+(4*o+28)>>2],a[o+8]=b[n+(4*o+32)>>2];else a=b.subarray(n>>2,n+36*r>>2);Br.uniformMatrix3fv(ut(e),!!t,a)}},glUniformMatrix4fv:(e,r,t,n)=>{if(Nr.currentContext.version>=2)r&&Br.uniformMatrix4fv(ut(e),!!t,b,n>>2,16*r);else{if(r<=18){var a=dt[16*r],o=b;n>>=2;for(var i=0;i<16*r;i+=16){var s=n+i;a[i]=o[s],a[i+1]=o[s+1],a[i+2]=o[s+2],a[i+3]=o[s+3],a[i+4]=o[s+4],a[i+5]=o[s+5],a[i+6]=o[s+6],a[i+7]=o[s+7],a[i+8]=o[s+8],a[i+9]=o[s+9],a[i+10]=o[s+10],a[i+11]=o[s+11],a[i+12]=o[s+12],a[i+13]=o[s+13],a[i+14]=o[s+14],a[i+15]=o[s+15]}}else a=b.subarray(n>>2,n+64*r>>2);Br.uniformMatrix4fv(ut(e),!!t,a)}},glUseProgram:e=>{e=Nr.programs[e],Br.useProgram(e),Br.currentProgram=e},glVertexAttrib1f:(e,r)=>Br.vertexAttrib1f(e,r),glVertexAttrib2fv:(e,r)=>{Br.vertexAttrib2f(e,b[r>>2],b[r+4>>2])},glVertexAttrib3fv:(e,r)=>{Br.vertexAttrib3f(e,b[r>>2],b[r+4>>2],b[r+8>>2])},glVertexAttrib4fv:(e,r)=>{Br.vertexAttrib4f(e,b[r>>2],b[r+4>>2],b[r+8>>2],b[r+12>>2])},glVertexAttribDivisor:(e,r)=>{Br.vertexAttribDivisor(e,r)},glVertexAttribIPointer:(e,r,t,n,a)=>{Br.vertexAttribIPointer(e,r,t,n,a)},glVertexAttribPointer:(e,r,t,n,a,o)=>{Br.vertexAttribPointer(e,r,t,!!n,a,o)},glViewport:(e,r,t,n)=>Br.viewport(e,r,t,n),glWaitSync:(e,r,t)=>{t=Number(t),Br.waitSync(Nr.syncs[e],r,t)},invoke_ii:function(e,r){var t=ee();try{return Ke(e)(r)}catch(e){if(Q(t),e!==e+0)throw e;Pt(1,0)}},invoke_iii:function(e,r,t){var n=ee();try{return Ke(e)(r,t)}catch(e){if(Q(n),e!==e+0)throw e;Pt(1,0)}},invoke_iiii:function(e,r,t,n){var a=ee();try{return Ke(e)(r,t,n)}catch(e){if(Q(a),e!==e+0)throw e;Pt(1,0)}},invoke_iiiii:function(e,r,t,n,a){var o=ee();try{return Ke(e)(r,t,n,a)}catch(e){if(Q(o),e!==e+0)throw e;Pt(1,0)}},invoke_iiiiii:function(e,r,t,n,a,o){var i=ee();try{return Ke(e)(r,t,n,a,o)}catch(e){if(Q(i),e!==e+0)throw e;Pt(1,0)}},invoke_iiiiiii:function(e,r,t,n,a,o,i){var s=ee();try{return Ke(e)(r,t,n,a,o,i)}catch(e){if(Q(s),e!==e+0)throw e;Pt(1,0)}},invoke_v:function(e){var r=ee();try{Ke(e)()}catch(e){if(Q(r),e!==e+0)throw e;Pt(1,0)}},invoke_vi:function(e,r){var t=ee();try{Ke(e)(r)}catch(e){if(Q(t),e!==e+0)throw e;Pt(1,0)}},invoke_vii:function(e,r,t){var n=ee();try{Ke(e)(r,t)}catch(e){if(Q(n),e!==e+0)throw e;Pt(1,0)}},invoke_viii:function(e,r,t,n){var a=ee();try{Ke(e)(r,t,n)}catch(e){if(Q(a),e!==e+0)throw e;Pt(1,0)}},invoke_viiii:function(e,r,t,n,a){var o=ee();try{Ke(e)(r,t,n,a)}catch(e){if(Q(o),e!==e+0)throw e;Pt(1,0)}},invoke_viiiii:function(e,r,t,n,a,o){var i=ee();try{Ke(e)(r,t,n,a,o)}catch(e){if(Q(i),e!==e+0)throw e;Pt(1,0)}},invoke_viiiiii:function(e,r,t,n,a,o,i){var s=ee();try{Ke(e)(r,t,n,a,o,i)}catch(e){if(Q(s),e!==e+0)throw e;Pt(1,0)}},invoke_viiiiiiiii:function(e,r,t,n,a,o,i,s,c,l){var u=ee();try{Ke(e)(r,t,n,a,o,i,s,c,l)}catch(e){if(Q(u),e!==e+0)throw e;Pt(1,0)}},strftime_l:(e,r,t,n,a)=>pt(e,r,t,n)},Tt=function(){var e,r={env:wt,wasi_snapshot_preview1:wt};function t(e,r){var t;return Tt=e.exports,x(u=Tt.memory,"memory not found in wasm exports"),S(),x(Xe=Tt.__indirect_function_table,"table not found in wasm exports"),t=Tt.__wasm_call_ctors,A.unshift(t),function(e){if(L--,e?(x(M[e]),delete M[e]):f("warning: run dependency removed without ID"),0==L&&(null!==k&&(clearInterval(k),k=null),D)){var r=D;D=null,r()}}("wasm-instantiate"),Tt}L++,(e="wasm-instantiate")?(x(!M[e]),M[e]=1,null===k&&"undefined"!=typeof setInterval&&(k=setInterval((()=>{if(E)return clearInterval(k),void(k=null);var e=!1;for(var r in M)e||(e=!0,f("still waiting on run dependencies:")),f("dependency: ".concat(r));e&&f("(end of list)")}),1e4))):f("warning: run dependency added without ID");var a,i,s,c,d=o;if(o.instantiateWasm)try{return o.instantiateWasm(r,t)}catch(e){f("Module.instantiateWasm callback failed with error: ".concat(e)),n(e)}return B||(B=G()),(a=l,i=B,s=r,c=function(e){x(o===d,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),d=null,t(e.instance)},a||"function"!=typeof WebAssembly.instantiateStreaming||W(i)||"function"!=typeof fetch?V(i,s,c):fetch(i,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,s).then(c,(function(e){return f("wasm streaming compile failed: ".concat(e)),f("falling back to ArrayBuffer instantiation"),V(i,s,c)}))))).catch(n),{}}(),Et=N("__getTypeName",1),xt=o._malloc=N("malloc",1),St=o._free=N("free",1),Ct=N("fflush",1),Pt=N("setThrew",2),At=()=>(At=Tt.emscripten_stack_init)(),Ft=()=>(Ft=Tt.emscripten_stack_get_end)(),It=e=>(It=Tt._emscripten_stack_restore)(e),Lt=()=>(Lt=Tt.emscripten_stack_get_current)();function kt(){var e;At(),x(0==(3&(e=Ft()))),0==e&&(e+=4),y[e>>2]=34821223,y[e+4>>2]=2310721022,y[0]=1668509029}function Dt(){L>0||(kt(),q(P),L>0||(_t||(_t=!0,o.calledRun=!0,E||(x(!I),I=!0,C(),q(A),t(o),x(!o._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),C(),q(F))),C()))}o.GL=Nr,["writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","stackAlloc","getTempRet0","setTempRet0","zeroMemory","ydayFromDate","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","initRandomFill","randomFill","emscriptenLog","readEmAsmArgs","listenOnce","autoResumeAudioContext","getDynCaller","dynCall","handleException","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","asyncLoad","alignMemory","mmapAlloc","HandleAllocator","getNativeTypeSize","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","getCFunc","ccall","cwrap","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","reallyNegative","unSign","strLen","reSign","formatString","intArrayToString","AsciiToString","stringToUTF8OnStack","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","createDyncallWrapper","safeSetTimeout","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","getPromise","makePromise","idsToPromises","makePromiseCallback","Browser_asyncPrepareDataCounter","setMainLoop","getSocketFromFD","getSocketAddress","emscriptenWebGLGetUniform","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","emscriptenWebGLGetIndexed","getFunctionArgsName","createJsInvokerSignature","registerInheritedInstance","unregisterInheritedInstance","writeGLArray","registerWebGlEventCallback","fetchDeleteCachedData","fetchLoadCachedData","fetchCacheData","fetchXHR"].forEach((function(e){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get(){var r="`".concat(e,"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line"),t=e;t.startsWith("_")||(t="$"+e),r+=" (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='".concat(t,"')"),Y(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),re(r)}}),J(e)})),["run","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","FS_createFolder","FS_createPath","FS_createLazyFile","FS_createLink","FS_createDevice","FS_readFile","out","err","callMain","abort","wasmMemory","wasmExports","HEAPF32","HEAPF64","HEAP_DATA_VIEW","HEAP8","HEAPU8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAP64","HEAPU64","writeStackCookie","checkStackCookie","writeI53ToI64","readI53FromI64","readI53FromU64","MAX_INT53","MIN_INT53","bigintToI53Checked","stackSave","stackRestore","ptrToString","exitJS","getHeapMax","growMemory","ENV","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","arraySum","addDays","ERRNO_CODES","ERRNO_MESSAGES","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","jstoi_q","jstoi_s","getExecutableName","keepRuntimeAlive","wasmTable","noExitRuntime","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","stringToAscii","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","writeArrayToMemory","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","flush_NO_FILESYSTEM","promiseMap","Browser","getPreloadedImageData__data","wget","SYSCALLS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance","webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","embind_charCodes","embind_init_charCodes","readLatin1String","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","createJsInvoker","UnboundTypeError","PureVirtualError","GenericWireTypeSize","EmValType","init_embind","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","extendError","createNamedFunction","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","readPointer","runDestructors","newFunc","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","setDelayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","init_emval","count_emval_handles","getStringOrSymbol","Emval","emval_get_global","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller","reflectConstruct","Fetch"].forEach(J),D=function e(){_t||Dt(),_t||(D=e)},Dt(),r=i;var Mt=function(e){e in a||Object.defineProperty(a,e,{configurable:!0,get(){O("Access to module property ('".concat(e,"') is no longer possible via the module constructor argument; Instead, use the result of the module constructor."))}})};for(var Ot of Object.keys(o))Mt(Ot);return r});export{r as default};
@@ -0,0 +1 @@
1
+ var e,r=(e=import.meta.url,function(){var r,t,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=Object.assign({},a),o=new Promise(((e,a)=>{r=e,t=a})),i=Object.assign({},n),s="";"undefined"!=typeof document&&document.currentScript&&(s=document.currentScript.src),e&&(s=e),s=s.startsWith("blob:")?"":s.substr(0,s.replace(/[?#].*/,"").lastIndexOf("/")+1);var c,u,l=n.print||console.log.bind(console),f=n.printErr||console.error.bind(console);Object.assign(n,i),i=null;var d,m,v,h,g,p,y,b,w,_,x=!1;function C(){var e=u.buffer;d=new Int8Array(e),v=new Int16Array(e),m=new Uint8Array(e),h=new Uint16Array(e),g=new Int32Array(e),p=new Uint32Array(e),y=new Float32Array(e),_=new Float64Array(e),b=new BigInt64Array(e),w=new BigUint64Array(e)}var T=[],E=[],P=[],A=0,S=null;function $(e){var r;null===(r=n.onAbort)||void 0===r||r.call(n,e),f(e="Aborted("+e+")"),x=!0,e+=". Build with -sASSERTIONS for more info.";var a=new WebAssembly.RuntimeError(e);throw t(a),a}var W,B=e=>e.startsWith("data:application/octet-stream;base64,");function L(){if(n.locateFile){var e="web-renderer-release.wasm";return B(e)?e:(r=e,n.locateFile?n.locateFile(r,s):s+r)}var r;return new URL("web-renderer-release.wasm",import.meta.url).href}function k(e){if(e==W&&c)return new Uint8Array(c);throw"both async and sync fetching of the wasm failed"}function F(e,r,t){return function(e){return"function"==typeof fetch?fetch(e,{credentials:"same-origin"}).then((r=>{if(!r.ok)throw"failed to load wasm binary file at '".concat(e,"'");return r.arrayBuffer()})).catch((()=>k(e))):Promise.resolve().then((()=>k(e)))}(e).then((e=>WebAssembly.instantiate(e,r))).then(t,(e=>{f("failed to asynchronously prepare wasm: ".concat(e)),$(e)}))}function O(e){this.name="ExitStatus",this.message="Program terminated with exit(".concat(e,")"),this.status=e}var D=e=>{for(;e.length>0;)e.shift()(n)},I=n.noExitRuntime||!0,G=e=>ct(e),j=()=>ut(),U={},M=e=>{for(;e.length;){var r=e.pop();e.pop()(r)}};function V(e){return this.fromWireType(p[e>>2])}var N,R,Y,H={},X={},z={},q=e=>{throw new N(e)},J=(e,r,t)=>{function a(r){var a=t(r);a.length!==e.length&&q("Mismatched type converter count");for(var n=0;n<e.length;++n)ee(e[n],a[n])}e.forEach((function(e){z[e]=r}));var n=new Array(r.length),o=[],i=0;r.forEach(((e,r)=>{X.hasOwnProperty(e)?n[r]=X[e]:(o.push(e),H.hasOwnProperty(e)||(H[e]=[]),H[e].push((()=>{n[r]=X[e],++i===o.length&&a(n)})))})),0===o.length&&a(n)},Q=e=>{if(null===e)return"null";var r=typeof e;return"object"===r||"array"===r||"function"===r?e.toString():""+e},Z=e=>{for(var r="",t=e;m[t];)r+=R[m[t++]];return r},K=e=>{throw new Y(e)};function ee(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.name;if(e||K('type "'.concat(a,'" must have a positive integer typeid pointer')),X.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;K("Cannot register type '".concat(a,"' twice"))}if(X[e]=r,delete z[e],H.hasOwnProperty(e)){var n=H[e];delete H[e],n.forEach((e=>e()))}}(e,r,t)}var re,te=(e,r,t)=>{switch(r){case 1:return t?e=>d[e]:e=>m[e];case 2:return t?e=>v[e>>1]:e=>h[e>>1];case 4:return t?e=>g[e>>2]:e=>p[e>>2];case 8:return t?e=>b[e>>3]:e=>w[e>>3];default:throw new TypeError("invalid integer width (".concat(r,"): ").concat(e))}},ae=8,ne=e=>{K(e.$$.ptrType.registeredClass.name+" instance already deleted")},oe=!1,ie=e=>{},se=e=>{e.count.value-=1,0===e.count.value&&(e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)})(e)},ce=(e,r,t)=>{if(r===t)return e;if(void 0===t.baseClass)return null;var a=ce(e,r,t.baseClass);return null===a?null:t.downcast(a)},ue={},le=()=>Object.keys(he).length,fe=()=>{var e=[];for(var r in he)he.hasOwnProperty(r)&&e.push(he[r]);return e},de=[],me=()=>{for(;de.length;){var e=de.pop();e.$$.deleteScheduled=!1,e.delete()}},ve=e=>{re=e,de.length&&re&&re(me)},he={},ge=(e,r)=>(r=((e,r)=>{for(void 0===r&&K("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r})(e,r),he[r]),pe=(e,r)=>(r.ptrType&&r.ptr||q("makeClassHandle requires ptr and ptrType"),!!r.smartPtrType!=!!r.smartPtr&&q("Both smartPtrType and smartPtr must be specified"),r.count={value:1},be(Object.create(e,{$$:{value:r,writable:!0}})));function ye(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=ge(this.registeredClass,r);if(void 0!==t){if(0===t.$$.count.value)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var a=t.clone();return this.destructor(e),a}function n(){return this.isSmartPointer?pe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):pe(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o,i=this.registeredClass.getActualType(r),s=ue[i];if(!s)return n.call(this);o=this.isConst?s.constPointerType:s.pointerType;var c=ce(r,this.registeredClass,o.registeredClass);return null===c?n.call(this):this.isSmartPointer?pe(o.registeredClass.instancePrototype,{ptrType:o,ptr:c,smartPtrType:this,smartPtr:e}):pe(o.registeredClass.instancePrototype,{ptrType:o,ptr:c})}var be=e=>"undefined"==typeof FinalizationRegistry?(be=e=>e,e):(oe=new FinalizationRegistry((e=>{se(e.$$)})),be=e=>{var r=e.$$;if(r.smartPtr){var t={$$:r};oe.register(e,t,e)}return e},ie=e=>oe.unregister(e),be(e));function we(){}var _e=(e,r)=>Object.defineProperty(r,"name",{value:e}),xe=(e,r,t)=>{if(void 0===e[r].overloadTable){var a=e[r];e[r]=function(){for(var a=arguments.length,n=new Array(a),o=0;o<a;o++)n[o]=arguments[o];return e[r].overloadTable.hasOwnProperty(n.length)||K("Function '".concat(t,"' called with an invalid number of arguments (").concat(n.length,") - expects one of (").concat(e[r].overloadTable,")!")),e[r].overloadTable[n.length].apply(this,n)},e[r].overloadTable=[],e[r].overloadTable[a.argCount]=a}},Ce=(e,r,t)=>{n.hasOwnProperty(e)?((void 0===t||void 0!==n[e].overloadTable&&void 0!==n[e].overloadTable[t])&&K("Cannot register public name '".concat(e,"' twice")),xe(n,e,e),n.hasOwnProperty(t)&&K("Cannot register multiple overloads of a function with the same number of arguments (".concat(t,")!")),n[e].overloadTable[t]=r):(n[e]=r,void 0!==t&&(n[e].numArguments=t))};function Te(e,r,t,a,n,o,i,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=a,this.baseClass=n,this.getActualType=o,this.upcast=i,this.downcast=s,this.pureVirtualFunctions=[]}var Ee=(e,r,t)=>{for(;r!==t;)r.upcast||K("Expected null or instance of ".concat(t.name,", got an instance of ").concat(r.name)),e=r.upcast(e),r=r.baseClass;return e};function Pe(e,r){if(null===r)return this.isReference&&K("null is not a valid ".concat(this.name)),0;r.$$||K('Cannot pass "'.concat(Q(r),'" as a ').concat(this.name)),r.$$.ptr||K("Cannot pass deleted object as a pointer of type ".concat(this.name));var t=r.$$.ptrType.registeredClass;return Ee(r.$$.ptr,t,this.registeredClass)}function Ae(e,r){var t;if(null===r)return this.isReference&&K("null is not a valid ".concat(this.name)),this.isSmartPointer?(t=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,t),t):0;r&&r.$$||K('Cannot pass "'.concat(Q(r),'" as a ').concat(this.name)),r.$$.ptr||K("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&r.$$.ptrType.isConst&&K("Cannot convert argument of type ".concat(r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name," to parameter type ").concat(this.name));var a=r.$$.ptrType.registeredClass;if(t=Ee(r.$$.ptr,a,this.registeredClass),this.isSmartPointer)switch(void 0===r.$$.smartPtr&&K("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:K("Cannot convert argument of type ".concat(r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name," to parameter type ").concat(this.name));break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var n=r.clone();t=this.rawShare(t,ze.toHandle((()=>n.delete()))),null!==e&&e.push(this.rawDestructor,t)}break;default:K("Unsupporting sharing policy")}return t}function Se(e,r){if(null===r)return this.isReference&&K("null is not a valid ".concat(this.name)),0;r.$$||K('Cannot pass "'.concat(Q(r),'" as a ').concat(this.name)),r.$$.ptr||K("Cannot pass deleted object as a pointer of type ".concat(this.name)),r.$$.ptrType.isConst&&K("Cannot convert argument of type ".concat(r.$$.ptrType.name," to parameter type ").concat(this.name));var t=r.$$.ptrType.registeredClass;return Ee(r.$$.ptr,t,this.registeredClass)}function $e(e,r,t,a,n,o,i,s,c,u,l){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=a,this.isSmartPointer=n,this.pointeeType=o,this.sharingPolicy=i,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=u,this.rawDestructor=l,n||void 0!==r.baseClass?this.toWireType=Ae:a?(this.toWireType=Pe,this.destructorFunction=null):(this.toWireType=Se,this.destructorFunction=null)}var We,Be,Le=[],ke=e=>{var r=Le[e];return r||(e>=Le.length&&(Le.length=e+1),Le[e]=r=We.get(e)),r},Fe=(e,r)=>{e=Z(e);var t=ke(r);return"function"!=typeof t&&K("unknown function pointer with signature ".concat(e,": ").concat(r)),t},Oe=e=>{var r=nt(e),t=Z(r);return it(r),t},De=(e,r)=>{var t=[],a={};throw r.forEach((function e(r){a[r]||X[r]||(z[r]?z[r].forEach(e):(t.push(r),a[r]=!0))})),new Be("".concat(e,": ")+t.map(Oe).join([", "]))};function Ie(e){for(var r=1;r<e.length;++r)if(null!==e[r]&&void 0===e[r].destructorFunction)return!0;return!1}function Ge(e,r){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(typeof e," which is not a function"));var t=_e(e.name||"unknownFunctionName",(function(){}));t.prototype=e.prototype;var a=new t,n=e.apply(a,r);return n instanceof Object?n:a}function je(e,r,t,a,n,o){var i=r.length;i<2&&K("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==r[1]&&null!==t,c=Ie(r),u="void"!==r[0].name,l=[e,K,a,n,M,r[0],r[1]],f=0;f<i-2;++f)l.push(r[f+2]);if(!c)for(f=s?1:2;f<r.length;++f)null!==r[f].destructorFunction&&l.push(r[f].destructorFunction);var[d,m]=function(e,r,t,a){for(var n=Ie(e),o=e.length,i="",s="",c=0;c<o-2;++c)i+=(0!==c?", ":"")+"arg"+c,s+=(0!==c?", ":"")+"arg"+c+"Wired";var u="\n return function (".concat(i,") {\n if (arguments.length !== ").concat(o-2,") {\n throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ").concat(o-2,"');\n }");n&&(u+="var destructors = [];\n");var l=n?"destructors":"null",f=["humanName","throwBindingError","invoker","fn","runDestructors","retType","classParam"];for(r&&(u+="var thisWired = classParam['toWireType']("+l+", this);\n"),c=0;c<o-2;++c)u+="var arg"+c+"Wired = argType"+c+"['toWireType']("+l+", arg"+c+");\n",f.push("argType"+c);if(r&&(s="thisWired"+(s.length>0?", ":"")+s),u+=(t||a?"var rv = ":"")+"invoker(fn"+(s.length>0?", ":"")+s+");\n",n)u+="runDestructors(destructors);\n";else for(c=r?1:2;c<e.length;++c){var d=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==e[c].destructorFunction&&(u+="".concat(d,"_dtor(").concat(d,");\n"),f.push("".concat(d,"_dtor")))}return t&&(u+="var ret = retType['fromWireType'](rv);\nreturn ret;\n"),[f,u+="}\n"]}(r,s,u,o);d.push(m);var v=Ge(Function,d)(...l);return _e(e,v)}var Ue,Me=(e,r)=>{for(var t=[],a=0;a<e;a++)t.push(p[r+4*a>>2]);return t},Ve=e=>{var r=(e=e.trim()).indexOf("(");return-1!==r?e.substr(0,r):e},Ne=(e,r,t)=>(e instanceof Object||K("".concat(t,' with invalid "this": ').concat(e)),e instanceof r.registeredClass.constructor||K("".concat(t,' incompatible with "this" of type ').concat(e.constructor.name)),e.$$.ptr||K("cannot call emscripten binding method ".concat(t," on deleted object")),Ee(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),Re=[],Ye=[],He=e=>{e>9&&0==--Ye[e+1]&&(Ye[e]=void 0,Re.push(e))},Xe=()=>Ye.length/2-5-Re.length,ze={toValue:e=>(e||K("Cannot use deleted val. handle = "+e),Ye[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:var r=Re.pop()||Ye.length;return Ye[r]=e,Ye[r+1]=1,r}}},qe={name:"emscripten::val",fromWireType:e=>{var r=ze.toValue(e);return He(e),r},toWireType:(e,r)=>ze.toHandle(r),argPackAdvance:ae,readValueFromPointer:V,destructorFunction:null},Je=e=>ee(e,qe),Qe=(e,r,t)=>{switch(r){case 1:return t?function(e){return this.fromWireType(d[e])}:function(e){return this.fromWireType(m[e])};case 2:return t?function(e){return this.fromWireType(v[e>>1])}:function(e){return this.fromWireType(h[e>>1])};case 4:return t?function(e){return this.fromWireType(g[e>>2])}:function(e){return this.fromWireType(p[e>>2])};default:throw new TypeError("invalid integer width (".concat(r,"): ").concat(e))}},Ze=(e,r)=>{var t=X[e];return void 0===t&&K("".concat(r," has unknown type ").concat(Oe(e))),t},Ke=(e,r)=>{switch(r){case 4:return function(e){return this.fromWireType(y[e>>2])};case 8:return function(e){return this.fromWireType(_[e>>3])};default:throw new TypeError("invalid float width (".concat(r,"): ").concat(e))}},er=(e,r,t,a)=>{if(!(a>0))return 0;for(var n=t,o=t+a-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),s<=127){if(t>=o)break;r[t++]=s}else if(s<=2047){if(t+1>=o)break;r[t++]=192|s>>6,r[t++]=128|63&s}else if(s<=65535){if(t+2>=o)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|63&s}else{if(t+3>=o)break;r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|63&s}}return r[t]=0,t-n},rr=(e,r,t)=>er(e,m,r,t),tr=e=>{for(var r=0,t=0;t<e.length;++t){var a=e.charCodeAt(t);a<=127?r++:a<=2047?r+=2:a>=55296&&a<=57343?(r+=4,++t):r+=3}return r},ar="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,nr=(e,r,t)=>{for(var a=r+t,n=r;e[n]&&!(n>=a);)++n;if(n-r>16&&e.buffer&&ar)return ar.decode(e.subarray(r,n));for(var o="";r<n;){var i=e[r++];if(128&i){var s=63&e[r++];if(192!=(224&i)){var c=63&e[r++];if((i=224==(240&i)?(15&i)<<12|s<<6|c:(7&i)<<18|s<<12|c<<6|63&e[r++])<65536)o+=String.fromCharCode(i);else{var u=i-65536;o+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else o+=String.fromCharCode((31&i)<<6|s)}else o+=String.fromCharCode(i)}return o},or=(e,r)=>e?nr(m,e,r):"",ir="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,sr=(e,r)=>{for(var t=e,a=t>>1,n=a+r/2;!(a>=n)&&h[a];)++a;if((t=a<<1)-e>32&&ir)return ir.decode(m.subarray(e,t));for(var o="",i=0;!(i>=r/2);++i){var s=v[e+2*i>>1];if(0==s)break;o+=String.fromCharCode(s)}return o},cr=(e,r,t)=>{var a;if(null!==(a=t)&&void 0!==a||(t=2147483647),t<2)return 0;for(var n=r,o=(t-=2)<2*e.length?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);v[r>>1]=s,r+=2}return v[r>>1]=0,r-n},ur=e=>2*e.length,lr=(e,r)=>{for(var t=0,a="";!(t>=r/4);){var n=g[e+4*t>>2];if(0==n)break;if(++t,n>=65536){var o=n-65536;a+=String.fromCharCode(55296|o>>10,56320|1023&o)}else a+=String.fromCharCode(n)}return a},fr=(e,r,t)=>{var a;if(null!==(a=t)&&void 0!==a||(t=2147483647),t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),g[r>>2]=s,(r+=4)+4>o)break}return g[r>>2]=0,r-n},dr=e=>{for(var r=0,t=0;t<e.length;++t){var a=e.charCodeAt(t);a>=55296&&a<=57343&&++t,r+=4}return r},mr=(e,r,t)=>{var a=[],n=e.toWireType(a,t);return a.length&&(p[r>>2]=ze.toHandle(a)),n},vr=[],hr={},gr=e=>{var r=hr[e];return void 0===r?Z(e):r},pr=()=>"object"==typeof globalThis?globalThis:Function("return this")();Ue=()=>performance.now();var yr,br,wr,_r,xr=e=>{var r=(e-u.buffer.byteLength+65535)/65536;try{return u.grow(r),C(),1}catch(e){}},Cr=e=>{var r=["ANGLE_instanced_arrays","EXT_blend_minmax","EXT_disjoint_timer_query","EXT_frag_depth","EXT_shader_texture_lod","EXT_sRGB","OES_element_index_uint","OES_fbo_render_mipmap","OES_standard_derivatives","OES_texture_float","OES_texture_half_float","OES_texture_half_float_linear","OES_vertex_array_object","WEBGL_color_buffer_float","WEBGL_depth_texture","WEBGL_draw_buffers","EXT_color_buffer_float","EXT_conservative_depth","EXT_disjoint_timer_query_webgl2","EXT_texture_norm16","NV_shader_noperspective_interpolation","WEBGL_clip_cull_distance","EXT_color_buffer_half_float","EXT_depth_clamp","EXT_float_blend","EXT_texture_compression_bptc","EXT_texture_compression_rgtc","EXT_texture_filter_anisotropic","KHR_parallel_shader_compile","OES_texture_float_linear","WEBGL_blend_func_extended","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_debug_renderer_info","WEBGL_debug_shaders","WEBGL_lose_context","WEBGL_multi_draw"];return(e.getSupportedExtensions()||[]).filter((e=>r.includes(e)))},Tr={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:[],offscreenCanvases:{},queries:[],samplers:[],transformFeedbacks:[],syncs:[],stringCache:{},stringiCache:{},unpackAlignment:4,recordError:e=>{Tr.lastError||(Tr.lastError=e)},getNewId:e=>{for(var r=Tr.counter++,t=e.length;t<r;t++)e[t]=null;return r},genObject:(e,r,t,a)=>{for(var n=0;n<e;n++){var o=_r[t](),i=o&&Tr.getNewId(a);o?(o.name=i,a[i]=o):Tr.recordError(1282),g[r+4*n>>2]=i}},getSource:(e,r,t,a)=>{for(var n="",o=0;o<r;++o){var i=a?p[a+4*o>>2]:void 0;n+=or(p[t+4*o>>2],i)}return n},createContext:(e,r)=>{e.getContextSafariWebGL2Fixed||(e.getContextSafariWebGL2Fixed=e.getContext,e.getContext=function(r,t){var a=e.getContextSafariWebGL2Fixed(r,t);return"webgl"==r==a instanceof WebGLRenderingContext?a:null});var t=r.majorVersion>1?e.getContext("webgl2",r):e.getContext("webgl",r);return t?Tr.registerContext(t,r):0},registerContext:(e,r)=>{var t=Tr.getNewId(Tr.contexts),a={handle:t,attributes:r,version:r.majorVersion,GLctx:e};return e.canvas&&(e.canvas.GLctxObject=a),Tr.contexts[t]=a,(void 0===r.enableExtensionsByDefault||r.enableExtensionsByDefault)&&Tr.initExtensions(a),t},makeContextCurrent:e=>{var r;return Tr.currentContext=Tr.contexts[e],n.ctx=_r=null===(r=Tr.currentContext)||void 0===r?void 0:r.GLctx,!(e&&!_r)},getContext:e=>Tr.contexts[e],deleteContext:e=>{Tr.currentContext===Tr.contexts[e]&&(Tr.currentContext=null),"object"==typeof JSEvents&&JSEvents.removeAllHandlersOnTarget(Tr.contexts[e].GLctx.canvas),Tr.contexts[e]&&Tr.contexts[e].GLctx.canvas&&(Tr.contexts[e].GLctx.canvas.GLctxObject=void 0),Tr.contexts[e]=null},initExtensions:e=>{if(e||(e=Tr.currentContext),!e.initExtensionsDone){e.initExtensionsDone=!0;var r,t=e.GLctx;(e=>{var r=e.getExtension("ANGLE_instanced_arrays");r&&(e.vertexAttribDivisor=(e,t)=>r.vertexAttribDivisorANGLE(e,t),e.drawArraysInstanced=(e,t,a,n)=>r.drawArraysInstancedANGLE(e,t,a,n),e.drawElementsInstanced=(e,t,a,n,o)=>r.drawElementsInstancedANGLE(e,t,a,n,o))})(t),(e=>{var r=e.getExtension("OES_vertex_array_object");r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.deleteVertexArray=e=>r.deleteVertexArrayOES(e),e.bindVertexArray=e=>r.bindVertexArrayOES(e),e.isVertexArray=e=>r.isVertexArrayOES(e))})(t),(e=>{var r=e.getExtension("WEBGL_draw_buffers");r&&(e.drawBuffers=(e,t)=>r.drawBuffersWEBGL(e,t))})(t),(r=t).dibvbi=r.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),(e=>{e.mdibvbi=e.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance")})(t),e.version>=2&&(t.disjointTimerQueryExt=t.getExtension("EXT_disjoint_timer_query_webgl2")),(e.version<2||!t.disjointTimerQueryExt)&&(t.disjointTimerQueryExt=t.getExtension("EXT_disjoint_timer_query")),(e=>{e.multiDrawWebgl=e.getExtension("WEBGL_multi_draw")})(t),Cr(t).forEach((e=>{e.includes("lose_context")||e.includes("debug")||t.getExtension(e)}))}}},Er={},Pr=()=>{if(!Pr.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:"./this.program"};for(var r in Er)void 0===Er[r]?delete e[r]:e[r]=Er[r];var t=[];for(var r in e)t.push("".concat(r,"=").concat(e[r]));Pr.strings=t}return Pr.strings},Ar=e=>{I||(x=!0),((e,r)=>{throw r})(0,new O(e))},Sr=(e,r)=>{Ar(e)},$r=[null,[],[]],Wr=e=>{_r.bindVertexArray(Tr.vaos[e])},Br=Wr,Lr=(e,r)=>{for(var t=0;t<e;t++){var a=g[r+4*t>>2];_r.deleteVertexArray(Tr.vaos[a]),Tr.vaos[a]=null}},kr=Lr,Fr=[],Or=(e,r,t,a)=>{_r.drawElements(e,r,t,a)},Dr=(e,r)=>{Tr.genObject(e,r,"createVertexArray",Tr.vaos)},Ir=Dr,Gr=function(){var e=Cr(_r);return e=e.concat(e.map((e=>"GL_"+e)))},jr=(e,r,t)=>{if(r){var a=void 0;switch(e){case 36346:a=1;break;case 36344:return void(0!=t&&1!=t&&Tr.recordError(1280));case 34814:case 36345:a=0;break;case 34466:var n=_r.getParameter(34467);a=n?n.length:0;break;case 33309:if(Tr.currentContext.version<2)return void Tr.recordError(1282);a=Gr().length;break;case 33307:case 33308:if(Tr.currentContext.version<2)return void Tr.recordError(1280);a=33307==e?3:0}if(void 0===a){var o=_r.getParameter(e);switch(typeof o){case"number":a=o;break;case"boolean":a=o?1:0;break;case"string":return void Tr.recordError(1280);case"object":if(null===o)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:a=0;break;default:return void Tr.recordError(1280)}else{if(o instanceof Float32Array||o instanceof Uint32Array||o instanceof Int32Array||o instanceof Array){for(var i=0;i<o.length;++i)switch(t){case 0:g[r+4*i>>2]=o[i];break;case 2:y[r+4*i>>2]=o[i];break;case 4:d[r+i]=o[i]?1:0}return}try{a=0|o.name}catch(r){return Tr.recordError(1280),void f("GL_INVALID_ENUM in glGet".concat(t,"v: Unknown object returned from WebGL getParameter(").concat(e,")! (error: ").concat(r,")"))}}break;default:return Tr.recordError(1280),void f("GL_INVALID_ENUM in glGet".concat(t,"v: Native code calling glGet").concat(t,"v(").concat(e,") and it returns ").concat(o," of type ").concat(typeof o,"!"))}}switch(t){case 1:((e,r)=>{p[e>>2]=r;var t=p[e>>2];p[e+4>>2]=(r-t)/4294967296})(r,a);break;case 0:g[r>>2]=a;break;case 2:y[r>>2]=a;break;case 4:d[r]=a?1:0}}else Tr.recordError(1281)},Ur=e=>{var r=tr(e)+1,t=ot(r);return t&&rr(e,t,r),t},Mr=e=>"]"==e.slice(-1)&&e.lastIndexOf("["),Vr=e=>0==(e-=5120)?d:1==e?m:2==e?v:4==e?g:6==e?y:5==e||28922==e||28520==e||30779==e||30782==e?p:h,Nr=(e,r)=>e>>>31-Math.clz32(r.BYTES_PER_ELEMENT),Rr=(e,r,t,a,n,o)=>{var i=Vr(e),s=(e=>({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[e-6402]||1))(r)*i.BYTES_PER_ELEMENT,c=((e,r,t,a)=>{var n;return r*(e*t+(n=a)-1&-n)})(t,a,s,Tr.unpackAlignment);return i.subarray(Nr(n,i),Nr(n+c,i))},Yr=e=>{var r=_r.currentProgram;if(r){var t=r.uniformLocsById[e];return"number"==typeof t&&(r.uniformLocsById[e]=t=_r.getUniformLocation(r,r.uniformArrayNamesById[e]+(t>0?"[".concat(t,"]"):""))),t}Tr.recordError(1282)},Hr=[],Xr=[],zr=e=>e%4==0&&(e%100!=0||e%400==0),qr=[31,29,31,30,31,30,31,31,30,31,30,31],Jr=[31,28,31,30,31,30,31,31,30,31,30,31],Qr=(e,r,t,a)=>{var n=p[a+40>>2],o={tm_sec:g[a>>2],tm_min:g[a+4>>2],tm_hour:g[a+8>>2],tm_mday:g[a+12>>2],tm_mon:g[a+16>>2],tm_year:g[a+20>>2],tm_wday:g[a+24>>2],tm_yday:g[a+28>>2],tm_isdst:g[a+32>>2],tm_gmtoff:g[a+36>>2],tm_zone:n?or(n):""},i=or(t),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var c in s)i=i.replace(new RegExp(c,"g"),s[c]);var u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],l=["January","February","March","April","May","June","July","August","September","October","November","December"];function f(e,r,t){for(var a="number"==typeof e?e.toString():e||"";a.length<r;)a=t[0]+a;return a}function m(e,r){return f(e,r,"0")}function v(e,r){function t(e){return e<0?-1:e>0?1:0}var a;return 0===(a=t(e.getFullYear()-r.getFullYear()))&&0===(a=t(e.getMonth()-r.getMonth()))&&(a=t(e.getDate()-r.getDate())),a}function h(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function y(e){var r=((e,r)=>{for(var t=new Date(e.getTime());r>0;){var a=zr(t.getFullYear()),n=t.getMonth(),o=(a?qr:Jr)[n];if(!(r>o-t.getDate()))return t.setDate(t.getDate()+r),t;r-=o-t.getDate()+1,t.setDate(1),n<11?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return t})(new Date(e.tm_year+1900,0,1),e.tm_yday),t=new Date(r.getFullYear(),0,4),a=new Date(r.getFullYear()+1,0,4),n=h(t),o=h(a);return v(n,r)<=0?v(o,r)<=0?r.getFullYear()+1:r.getFullYear():r.getFullYear()-1}var b={"%a":e=>u[e.tm_wday].substring(0,3),"%A":e=>u[e.tm_wday],"%b":e=>l[e.tm_mon].substring(0,3),"%B":e=>l[e.tm_mon],"%C":e=>m((e.tm_year+1900)/100|0,2),"%d":e=>m(e.tm_mday,2),"%e":e=>f(e.tm_mday,2," "),"%g":e=>y(e).toString().substring(2),"%G":y,"%H":e=>m(e.tm_hour,2),"%I":e=>{var r=e.tm_hour;return 0==r?r=12:r>12&&(r-=12),m(r,2)},"%j":e=>m(e.tm_mday+((e,r)=>{for(var t=0,a=0;a<=r;t+=e[a++]);return t})(zr(e.tm_year+1900)?qr:Jr,e.tm_mon-1),3),"%m":e=>m(e.tm_mon+1,2),"%M":e=>m(e.tm_min,2),"%n":()=>"\n","%p":e=>e.tm_hour>=0&&e.tm_hour<12?"AM":"PM","%S":e=>m(e.tm_sec,2),"%t":()=>"\t","%u":e=>e.tm_wday||7,"%U":e=>{var r=e.tm_yday+7-e.tm_wday;return m(Math.floor(r/7),2)},"%V":e=>{var r=Math.floor((e.tm_yday+7-(e.tm_wday+6)%7)/7);if((e.tm_wday+371-e.tm_yday-2)%7<=2&&r++,r){if(53==r){var t=(e.tm_wday+371-e.tm_yday)%7;4==t||3==t&&zr(e.tm_year)||(r=1)}}else{r=52;var a=(e.tm_wday+7-e.tm_yday-1)%7;(4==a||5==a&&zr(e.tm_year%400-1))&&r++}return m(r,2)},"%w":e=>e.tm_wday,"%W":e=>{var r=e.tm_yday+7-(e.tm_wday+6)%7;return m(Math.floor(r/7),2)},"%y":e=>(e.tm_year+1900).toString().substring(2),"%Y":e=>e.tm_year+1900,"%z":e=>{var r=e.tm_gmtoff,t=r>=0;return r=(r=Math.abs(r)/60)/60*100+r%60,(t?"+":"-")+String("0000"+r).slice(-4)},"%Z":e=>e.tm_zone,"%%":()=>"%"};for(var c in i=i.replace(/%%/g,"\0\0"),b)i.includes(c)&&(i=i.replace(new RegExp(c,"g"),b[c](o)));i=i.replace(/\0\0/g,"%");var w,_,x,C,T,E,P,A,S=(w=i,_=!1,C=x>0?x:tr(w)+1,T=new Array(C),E=er(w,T,0,T.length),_&&(T.length=E),T);return S.length>r?0:(P=S,A=e,d.set(P,A),S.length-1)};N=n.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},(()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);R=e})(),Y=n.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Object.assign(we.prototype,{isAliasOf(e){if(!(this instanceof we))return!1;if(!(e instanceof we))return!1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var a=e.$$.ptrType.registeredClass,n=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;a.baseClass;)n=a.upcast(n),a=a.baseClass;return r===a&&t===n},clone(){if(this.$$.ptr||ne(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,r=be(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return r.$$.count.value+=1,r.$$.deleteScheduled=!1,r},delete(){this.$$.ptr||ne(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&K("Object already scheduled for deletion"),ie(this),se(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||ne(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&K("Object already scheduled for deletion"),de.push(this),1===de.length&&re&&re(me),this.$$.deleteScheduled=!0,this}}),n.getInheritedInstanceCount=le,n.getLiveInheritedInstances=fe,n.flushPendingDeletes=me,n.setDelayFunction=ve,Object.assign($e.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){var r;null===(r=this.rawDestructor)||void 0===r||r.call(this,e)},argPackAdvance:ae,readValueFromPointer:V,fromWireType:ye}),Be=n.UnboundTypeError=(yr=Error,(wr=_e(br="UnboundTypeError",(function(e){this.name=br,this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(yr.prototype),wr.prototype.constructor=wr,wr.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},wr),Ye.push(0,1,void 0,1,null,1,!0,1,!1,1),n.count_emval_handles=Xe;for(var Zr=0;Zr<32;++Zr)Fr.push(new Array(Zr));var Kr=new Float32Array(288);for(Zr=0;Zr<288;++Zr)Hr[Zr]=Kr.subarray(0,Zr);var et=new Int32Array(288);for(Zr=0;Zr<288;++Zr)Xr[Zr]=et.subarray(0,Zr);var rt,tt={mb:()=>{$("")},p:e=>{var r=U[e];delete U[e];var t=r.rawConstructor,a=r.rawDestructor,n=r.fields,o=n.map((e=>e.getterReturnType)).concat(n.map((e=>e.setterArgumentType)));J([e],o,(e=>{var o={};return n.forEach(((r,t)=>{var a=r.fieldName,i=e[t],s=r.getter,c=r.getterContext,u=e[t+n.length],l=r.setter,f=r.setterContext;o[a]={read:e=>i.fromWireType(s(c,e)),write:(e,r)=>{var t=[];l(f,e,u.toWireType(t,r)),M(t)}}})),[{name:r.name,fromWireType:e=>{var r={};for(var t in o)r[t]=o[t].read(e);return a(e),r},toWireType:(e,r)=>{for(var n in o)if(!(n in r))throw new TypeError('Missing field: "'.concat(n,'"'));var i=t();for(n in o)o[n].write(i,r[n]);return null!==e&&e.push(a,i),i},argPackAdvance:ae,readValueFromPointer:V,destructorFunction:a}]}))},R:(e,r,t,a,n)=>{var o=-1!=(r=Z(r)).indexOf("u");ee(e,{name:r,fromWireType:e=>e,toWireType:function(e,r){if("bigint"!=typeof r&&"number"!=typeof r)throw new TypeError('Cannot convert "'.concat(Q(r),'" to ').concat(this.name));return"number"==typeof r&&(r=BigInt(r)),r},argPackAdvance:ae,readValueFromPointer:te(r,t,!o),destructorFunction:null})},$a:(e,r,t,a)=>{ee(e,{name:r=Z(r),fromWireType:function(e){return!!e},toWireType:function(e,r){return r?t:a},argPackAdvance:ae,readValueFromPointer:function(e){return this.fromWireType(m[e])},destructorFunction:null})},g:(e,r,t,a,o,i,s,c,u,l,f,d,m)=>{f=Z(f),i=Fe(o,i),c&&(c=Fe(s,c)),l&&(l=Fe(u,l)),m=Fe(d,m);var v=(e=>{if(void 0===e)return"_unknown";var r=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return r>=48&&r<=57?"_".concat(e):e})(f);Ce(v,(function(){De("Cannot construct ".concat(f," due to unbound types"),[a])})),J([e,r,t],a?[a]:[],(r=>{var t,o;r=r[0],o=a?(t=r.registeredClass).instancePrototype:we.prototype;var s=_e(f,(function(){if(Object.getPrototypeOf(this)!==u)throw new Y("Use 'new' to construct "+f);if(void 0===g.constructor_body)throw new Y(f+" has no accessible constructor");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];var a=g.constructor_body[r.length];if(void 0===a)throw new Y("Tried to invoke ctor of ".concat(f," with invalid number of parameters (").concat(r.length,") - expected (").concat(Object.keys(g.constructor_body).toString(),") parameters instead!"));return a.apply(this,r)})),u=Object.create(o,{constructor:{value:s}});s.prototype=u;var d,h,g=new Te(f,s,u,m,t,i,c,l);g.baseClass&&(null!==(h=(d=g.baseClass).__derivedClasses)&&void 0!==h||(d.__derivedClasses=[]),g.baseClass.__derivedClasses.push(g));var p=new $e(f,g,!0,!1,!1),y=new $e(f+"*",g,!1,!1,!1),b=new $e(f+" const*",g,!1,!0,!1);return ue[e]={pointerType:y,constPointerType:b},((e,r,t)=>{n.hasOwnProperty(e)||q("Replacing nonexistent public symbol"),void 0!==n[e].overloadTable&&void 0!==t?n[e].overloadTable[t]=r:(n[e]=r,n[e].argCount=t)})(v,s),[p,y,b]}))},da:(e,r,t,a,n,o,i,s)=>{var c=Me(t,a);r=Z(r),r=Ve(r),o=Fe(n,o),J([],[e],(e=>{e=e[0];var a="".concat(e.name,".").concat(r);function n(){De("Cannot call ".concat(a," due to unbound types"),c)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var u=e.registeredClass.constructor;return void 0===u[r]?(n.argCount=t-1,u[r]=n):(xe(u,r,a),u[r].overloadTable[t-1]=n),J([],c,(n=>{var c=[n[0],null].concat(n.slice(1)),l=je(a,c,null,o,i,s);if(void 0===u[r].overloadTable?(l.argCount=t-1,u[r]=l):u[r].overloadTable[t-1]=l,e.registeredClass.__derivedClasses)for(var f of e.registeredClass.__derivedClasses)f.constructor.hasOwnProperty(r)||(f.constructor[r]=l);return[]})),[]}))},w:(e,r,t,a,n,o)=>{var i=Me(r,t);n=Fe(a,n),J([],[e],(e=>{e=e[0];var t="constructor ".concat(e.name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[r-1])throw new Y("Cannot register multiple constructors with identical number of parameters (".concat(r-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[r-1]=()=>{De("Cannot construct ".concat(e.name," due to unbound types"),i)},J([],i,(a=>(a.splice(1,0,null),e.registeredClass.constructor_body[r-1]=je(t,a,null,n,o),[]))),[]}))},a:(e,r,t,a,n,o,i,s,c)=>{var u=Me(t,a);r=Z(r),r=Ve(r),o=Fe(n,o),J([],[e],(e=>{e=e[0];var a="".concat(e.name,".").concat(r);function n(){De("Cannot call ".concat(a," due to unbound types"),u)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(r);var l=e.registeredClass.instancePrototype,f=l[r];return void 0===f||void 0===f.overloadTable&&f.className!==e.name&&f.argCount===t-2?(n.argCount=t-2,n.className=e.name,l[r]=n):(xe(l,r,a),l[r].overloadTable[t-2]=n),J([],u,(n=>{var s=je(a,n,e,o,i,c);return void 0===l[r].overloadTable?(s.argCount=t-2,l[r]=s):l[r].overloadTable[t-2]=s,[]})),[]}))},c:(e,r,t,a,n,o,i,s,c,u)=>{r=Z(r),n=Fe(a,n),J([],[e],(e=>{e=e[0];var a="".concat(e.name,".").concat(r),l={get(){De("Cannot access ".concat(a," due to unbound types"),[t,i])},enumerable:!0,configurable:!0};return l.set=c?()=>De("Cannot access ".concat(a," due to unbound types"),[t,i]):e=>K(a+" is a read-only property"),Object.defineProperty(e.registeredClass.instancePrototype,r,l),J([],c?[t,i]:[t],(t=>{var i=t[0],l={get(){var r=Ne(this,e,a+" getter");return i.fromWireType(n(o,r))},enumerable:!0};if(c){c=Fe(s,c);var f=t[1];l.set=function(r){var t=Ne(this,e,a+" setter"),n=[];c(u,t,f.toWireType(n,r)),M(n)}}return Object.defineProperty(e.registeredClass.instancePrototype,r,l),[]})),[]}))},_a:Je,n:(e,r,t,a)=>{function n(){}r=Z(r),n.values={},ee(e,{name:r,constructor:n,fromWireType:function(e){return this.constructor.values[e]},toWireType:(e,r)=>r.value,argPackAdvance:ae,readValueFromPointer:Qe(r,t,a),destructorFunction:null}),Ce(r,n)},b:(e,r,t)=>{var a=Ze(e,"enum");r=Z(r);var n=a.constructor,o=Object.create(a.constructor.prototype,{value:{value:t},constructor:{value:_e("".concat(a.name,"_").concat(r),(function(){}))}});n.values[t]=o,n[r]=o},Q:(e,r,t)=>{ee(e,{name:r=Z(r),fromWireType:e=>e,toWireType:(e,r)=>r,argPackAdvance:ae,readValueFromPointer:Ke(r,t),destructorFunction:null})},y:(e,r,t,a,n)=>{r=Z(r);var o=e=>e;if(0===a){var i=32-8*t;o=e=>e<<i>>>i}var s=r.includes("unsigned");ee(e,{name:r,fromWireType:o,toWireType:s?function(e,r){return this.name,r>>>0}:function(e,r){return this.name,r},argPackAdvance:ae,readValueFromPointer:te(r,t,0!==a),destructorFunction:null})},s:(e,r,t)=>{var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][r];function n(e){var r=p[e>>2],t=p[e+4>>2];return new a(d.buffer,t,r)}ee(e,{name:t=Z(t),fromWireType:n,argPackAdvance:ae,readValueFromPointer:n},{ignoreDuplicateRegistrations:!0})},x:(e,r)=>{Je(e)},I:(e,r,t,a,n,o,i,s,c,u,l,f)=>{t=Z(t),o=Fe(n,o),s=Fe(i,s),u=Fe(c,u),f=Fe(l,f),J([e],[r],(e=>(e=e[0],[new $e(t,e.registeredClass,!1,!1,!0,e,a,o,s,u,f)])))},P:(e,r)=>{var t="std::string"===(r=Z(r));ee(e,{name:r,fromWireType(e){var r,a=p[e>>2],n=e+4;if(t)for(var o=n,i=0;i<=a;++i){var s=n+i;if(i==a||0==m[s]){var c=or(o,s-o);void 0===r?r=c:(r+=String.fromCharCode(0),r+=c),o=s+1}}else{var u=new Array(a);for(i=0;i<a;++i)u[i]=String.fromCharCode(m[n+i]);r=u.join("")}return it(e),r},toWireType(e,r){var a;r instanceof ArrayBuffer&&(r=new Uint8Array(r));var n="string"==typeof r;n||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int8Array||K("Cannot pass non-string to std::string"),a=t&&n?tr(r):r.length;var o=ot(4+a+1),i=o+4;if(p[o>>2]=a,t&&n)rr(r,i,a+1);else if(n)for(var s=0;s<a;++s){var c=r.charCodeAt(s);c>255&&(it(i),K("String has UTF-16 code units that do not fit in 8 bits")),m[i+s]=c}else for(s=0;s<a;++s)m[i+s]=r[s];return null!==e&&e.push(it,o),o},argPackAdvance:ae,readValueFromPointer:V,destructorFunction(e){it(e)}})},G:(e,r,t)=>{var a,n,o,i;t=Z(t),2===r?(a=sr,n=cr,i=ur,o=e=>h[e>>1]):4===r&&(a=lr,n=fr,i=dr,o=e=>p[e>>2]),ee(e,{name:t,fromWireType:e=>{for(var t,n=p[e>>2],i=e+4,s=0;s<=n;++s){var c=e+4+s*r;if(s==n||0==o(c)){var u=a(i,c-i);void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),i=c+r}}return it(e),t},toWireType:(e,a)=>{"string"!=typeof a&&K("Cannot pass non-string to C++ string type ".concat(t));var o=i(a),s=ot(4+o+r);return p[s>>2]=o/r,n(a,s+4,o+r),null!==e&&e.push(it,s),s},argPackAdvance:ae,readValueFromPointer:V,destructorFunction(e){it(e)}})},Jc:(e,r)=>{Je(e)},q:(e,r,t,a,n,o)=>{U[e]={name:Z(r),rawConstructor:Fe(t,a),rawDestructor:Fe(n,o),fields:[]}},e:(e,r,t,a,n,o,i,s,c,u)=>{U[e].fields.push({fieldName:Z(r),getterReturnType:t,getter:Fe(a,n),getterContext:o,setterArgumentType:i,setter:Fe(s,c),setterContext:u})},ab:(e,r)=>{ee(e,{isVoid:!0,name:r=Z(r),argPackAdvance:0,fromWireType:()=>{},toWireType:(e,r)=>{}})},kb:()=>1,cb:()=>{throw 1/0},E:(e,r,t)=>(e=ze.toValue(e),r=Ze(r,"emval::as"),mr(r,t,e)),B:(e,r,t,a)=>(e=vr[e])(null,r=ze.toValue(r),t,a),l:(e,r,t,a,n)=>(e=vr[e])(r=ze.toValue(r),r[t=gr(t)],a,n),d:He,S:e=>0===e?ze.toHandle(pr()):(e=gr(e),ze.toHandle(pr()[e])),j:(e,r,t)=>{var a=((e,r)=>{for(var t=new Array(e),a=0;a<e;++a)t[a]=Ze(p[r+4*a>>2],"parameter "+a);return t})(e,r),n=a.shift();e--;var o="return function (obj, func, destructorsRef, args) {\n",i=0,s=[];0===t&&s.push("obj");for(var c=["retType"],u=[n],l=0;l<e;++l)s.push("arg"+l),c.push("argType"+l),u.push(a[l]),o+=" var arg".concat(l," = argType").concat(l,".readValueFromPointer(args").concat(i?"+"+i:"",");\n"),i+=a[l].argPackAdvance;o+=" var rv = ".concat(1===t?"new func":"func.call","(").concat(s.join(", "),");\n"),n.isVoid||(c.push("emval_returnValue"),u.push(mr),o+=" return emval_returnValue(retType, destructorsRef, rv);\n"),o+="};\n",c.push(o);var f,d,m=Ge(Function,c)(...u),v="methodCaller<(".concat(a.map((e=>e.name)).join(", "),") => ").concat(n.name,">");return f=_e(v,m),d=vr.length,vr.push(f),d},m:e=>(e=gr(e),ze.toHandle(n[e])),H:(e,r)=>(e=ze.toValue(e),r=ze.toValue(r),ze.toHandle(e[r])),o:e=>{e>9&&(Ye[e+1]+=1)},Za:()=>ze.toHandle([]),D:e=>ze.toHandle(gr(e)),h:e=>{var r=ze.toValue(e);M(r),He(e)},u:(e,r)=>{var t=(e=Ze(e,"_emval_take_value")).readValueFromPointer(r);return ze.toHandle(t)},fb:function(e,r){var t;e=(t=e)<-9007199254740992||t>9007199254740992?NaN:Number(t);var a=new Date(1e3*e);g[r>>2]=a.getUTCSeconds(),g[r+4>>2]=a.getUTCMinutes(),g[r+8>>2]=a.getUTCHours(),g[r+12>>2]=a.getUTCDate(),g[r+16>>2]=a.getUTCMonth(),g[r+20>>2]=a.getUTCFullYear()-1900,g[r+24>>2]=a.getUTCDay();var n=Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0),o=(a.getTime()-n)/864e5|0;g[r+28>>2]=o},eb:(e,r,t,a)=>{var n=(new Date).getFullYear(),o=new Date(n,0,1),i=new Date(n,6,1),s=o.getTimezoneOffset(),c=i.getTimezoneOffset(),u=Math.max(s,c);p[e>>2]=60*u,g[r>>2]=Number(s!=c);var l=e=>e.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],f=l(o),d=l(i);c<s?(rr(f,t,17),rr(d,a,17)):(rr(f,a,17),rr(d,t,17))},O:e=>cancelAnimationFrame(e),U:()=>Date.now(),jb:Ue,C:(e,r)=>requestAnimationFrame((t=>ke(e)(t,r))),db:e=>{var r=m.length,t=2147483648;if((e>>>=0)>t)return!1;for(var a,n,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,(a=Math.max(e,i))+((n=65536)-a%n)%n);if(xr(s))return!0}return!1},Ya:e=>Tr.makeContextCurrent(e)?0:-5,hb:(e,r)=>{var t=0;return Pr().forEach(((a,n)=>{var o=r+t;p[e+4*n>>2]=o,((e,r)=>{for(var t=0;t<e.length;++t)d[r++]=e.charCodeAt(t);d[r]=0})(a,o),t+=a.length+1})),0},ib:(e,r)=>{var t=Pr();p[e>>2]=t.length;var a=0;return t.forEach((e=>a+=e.length+1)),p[r>>2]=a,0},nb:Sr,lb:e=>52,gb:function(e,r,t,a){return 70},T:(e,r,t,a)=>{for(var n,o,i,s=0,c=0;c<t;c++){var u=p[r>>2],d=p[r+4>>2];r+=8;for(var v=0;v<d;v++)n=e,o=m[u+v],i=void 0,i=$r[n],0===o||10===o?((1===n?l:f)(nr(i,0)),i.length=0):i.push(o);s+=d}return p[a>>2]=s,0},Mc:e=>_r.activeTexture(e),Nc:(e,r)=>{_r.attachShader(Tr.programs[e],Tr.shaders[r])},Oc:(e,r,t)=>{_r.bindAttribLocation(Tr.programs[e],r,or(t))},Pc:(e,r)=>{35051==e?_r.currentPixelPackBufferBinding=r:35052==e&&(_r.currentPixelUnpackBufferBinding=r),_r.bindBuffer(e,Tr.buffers[r])},N:(e,r)=>{_r.bindFramebuffer(e,Tr.framebuffers[r])},Pb:(e,r)=>{_r.bindRenderbuffer(e,Tr.renderbuffers[r])},xb:(e,r)=>{_r.bindSampler(e,Tr.samplers[r])},Qc:(e,r)=>{_r.bindTexture(e,Tr.textures[r])},ic:Wr,kc:Br,Rc:(e,r,t,a)=>_r.blendColor(e,r,t,a),Sc:e=>_r.blendEquation(e),Tc:(e,r)=>_r.blendFunc(e,r),Jb:(e,r,t,a,n,o,i,s,c,u)=>_r.blitFramebuffer(e,r,t,a,n,o,i,s,c,u),V:(e,r,t,a)=>{Tr.currentContext.version>=2?t&&r?_r.bufferData(e,m,a,t,r):_r.bufferData(e,r,a):_r.bufferData(e,t?m.subarray(t,t+r):r,a)},W:(e,r,t,a)=>{Tr.currentContext.version>=2?t&&_r.bufferSubData(e,r,m,a,t):_r.bufferSubData(e,r,m.subarray(a,a+t))},Qb:e=>_r.checkFramebufferStatus(e),K:e=>_r.clear(e),M:(e,r,t,a)=>_r.clearColor(e,r,t,a),L:e=>_r.clearStencil(e),Hb:(e,r,t)=>(t=Number(t),_r.clientWaitSync(Tr.syncs[e],r,t)),X:(e,r,t,a)=>{_r.colorMask(!!e,!!r,!!t,!!a)},Y:e=>{_r.compileShader(Tr.shaders[e])},Z:(e,r,t,a,n,o,i,s)=>{if(Tr.currentContext.version>=2)return _r.currentPixelUnpackBufferBinding||!i?void _r.compressedTexImage2D(e,r,t,a,n,o,i,s):void _r.compressedTexImage2D(e,r,t,a,n,o,m,s,i);_r.compressedTexImage2D(e,r,t,a,n,o,s?m.subarray(s,s+i):null)},_:(e,r,t,a,n,o,i,s,c)=>{if(Tr.currentContext.version>=2)return _r.currentPixelUnpackBufferBinding||!s?void _r.compressedTexSubImage2D(e,r,t,a,n,o,i,s,c):void _r.compressedTexSubImage2D(e,r,t,a,n,o,i,m,c,s);_r.compressedTexSubImage2D(e,r,t,a,n,o,i,c?m.subarray(c,c+s):null)},Gb:(e,r,t,a,n)=>_r.copyBufferSubData(e,r,t,a,n),$:(e,r,t,a,n,o,i,s)=>_r.copyTexSubImage2D(e,r,t,a,n,o,i,s),aa:()=>{var e=Tr.getNewId(Tr.programs),r=_r.createProgram();return r.name=e,r.maxUniformLength=r.maxAttributeLength=r.maxUniformBlockNameLength=0,r.uniformIdCounter=1,Tr.programs[e]=r,e},ba:e=>{var r=Tr.getNewId(Tr.shaders);return Tr.shaders[r]=_r.createShader(e),r},ca:e=>_r.cullFace(e),ea:(e,r)=>{for(var t=0;t<e;t++){var a=g[r+4*t>>2],n=Tr.buffers[a];n&&(_r.deleteBuffer(n),n.name=0,Tr.buffers[a]=null,a==_r.currentPixelPackBufferBinding&&(_r.currentPixelPackBufferBinding=0),a==_r.currentPixelUnpackBufferBinding&&(_r.currentPixelUnpackBufferBinding=0))}},Rb:(e,r)=>{for(var t=0;t<e;++t){var a=g[r+4*t>>2],n=Tr.framebuffers[a];n&&(_r.deleteFramebuffer(n),n.name=0,Tr.framebuffers[a]=null)}},fa:e=>{if(e){var r=Tr.programs[e];r?(_r.deleteProgram(r),r.name=0,Tr.programs[e]=null):Tr.recordError(1281)}},Sb:(e,r)=>{for(var t=0;t<e;t++){var a=g[r+4*t>>2],n=Tr.renderbuffers[a];n&&(_r.deleteRenderbuffer(n),n.name=0,Tr.renderbuffers[a]=null)}},yb:(e,r)=>{for(var t=0;t<e;t++){var a=g[r+4*t>>2],n=Tr.samplers[a];n&&(_r.deleteSampler(n),n.name=0,Tr.samplers[a]=null)}},ga:e=>{if(e){var r=Tr.shaders[e];r?(_r.deleteShader(r),Tr.shaders[e]=null):Tr.recordError(1281)}},Ib:e=>{if(e){var r=Tr.syncs[e];r?(_r.deleteSync(r),r.name=0,Tr.syncs[e]=null):Tr.recordError(1281)}},ha:(e,r)=>{for(var t=0;t<e;t++){var a=g[r+4*t>>2],n=Tr.textures[a];n&&(_r.deleteTexture(n),n.name=0,Tr.textures[a]=null)}},jc:Lr,lc:kr,ia:e=>{_r.depthMask(!!e)},ja:e=>_r.disable(e),ka:e=>{_r.disableVertexAttribArray(e)},la:(e,r,t)=>{_r.drawArrays(e,r,t)},gc:(e,r,t,a)=>{_r.drawArraysInstanced(e,r,t,a)},dc:(e,r,t,a,n)=>{_r.dibvbi.drawArraysInstancedBaseInstanceWEBGL(e,r,t,a,n)},bc:(e,r)=>{for(var t=Fr[e],a=0;a<e;a++)t[a]=g[r+4*a>>2];_r.drawBuffers(t)},ma:Or,hc:(e,r,t,a,n)=>{_r.drawElementsInstanced(e,r,t,a,n)},ec:(e,r,t,a,n,o,i)=>{_r.dibvbi.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,r,t,a,n,o,i)},Xb:(e,r,t,a,n,o)=>{Or(e,a,n,o)},na:e=>_r.enable(e),oa:e=>{_r.enableVertexAttribArray(e)},Db:(e,r)=>{var t=_r.fenceSync(e,r);if(t){var a=Tr.getNewId(Tr.syncs);return t.name=a,Tr.syncs[a]=t,a}return 0},pa:()=>_r.finish(),qa:()=>_r.flush(),Tb:(e,r,t,a)=>{_r.framebufferRenderbuffer(e,r,t,Tr.renderbuffers[a])},Ub:(e,r,t,a,n)=>{_r.framebufferTexture2D(e,r,t,Tr.textures[a],n)},ra:e=>_r.frontFace(e),sa:(e,r)=>{Tr.genObject(e,r,"createBuffer",Tr.buffers)},Vb:(e,r)=>{Tr.genObject(e,r,"createFramebuffer",Tr.framebuffers)},Wb:(e,r)=>{Tr.genObject(e,r,"createRenderbuffer",Tr.renderbuffers)},zb:(e,r)=>{Tr.genObject(e,r,"createSampler",Tr.samplers)},ta:(e,r)=>{Tr.genObject(e,r,"createTexture",Tr.textures)},fc:Dr,mc:Ir,Lb:e=>_r.generateMipmap(e),ua:(e,r,t)=>{t?g[t>>2]=_r.getBufferParameter(e,r):Tr.recordError(1281)},va:()=>{var e=_r.getError()||Tr.lastError;return Tr.lastError=0,e},wa:(e,r)=>jr(e,r,2),Mb:(e,r,t,a)=>{var n=_r.getFramebufferAttachmentParameter(e,r,t);(n instanceof WebGLRenderbuffer||n instanceof WebGLTexture)&&(n=0|n.name),g[a>>2]=n},F:(e,r)=>jr(e,r,0),xa:(e,r,t,a)=>{var n=_r.getProgramInfoLog(Tr.programs[e]);null===n&&(n="(unknown error)");var o=r>0&&a?rr(n,a,r):0;t&&(g[t>>2]=o)},ya:(e,r,t)=>{if(t)if(e>=Tr.counter)Tr.recordError(1281);else if(e=Tr.programs[e],35716==r){var a=_r.getProgramInfoLog(e);null===a&&(a="(unknown error)"),g[t>>2]=a.length+1}else if(35719==r){if(!e.maxUniformLength)for(var n=0;n<_r.getProgramParameter(e,35718);++n)e.maxUniformLength=Math.max(e.maxUniformLength,_r.getActiveUniform(e,n).name.length+1);g[t>>2]=e.maxUniformLength}else if(35722==r){if(!e.maxAttributeLength)for(n=0;n<_r.getProgramParameter(e,35721);++n)e.maxAttributeLength=Math.max(e.maxAttributeLength,_r.getActiveAttrib(e,n).name.length+1);g[t>>2]=e.maxAttributeLength}else if(35381==r){if(!e.maxUniformBlockNameLength)for(n=0;n<_r.getProgramParameter(e,35382);++n)e.maxUniformBlockNameLength=Math.max(e.maxUniformBlockNameLength,_r.getActiveUniformBlockName(e,n).length+1);g[t>>2]=e.maxUniformBlockNameLength}else g[t>>2]=_r.getProgramParameter(e,r);else Tr.recordError(1281)},Nb:(e,r,t)=>{t?g[t>>2]=_r.getRenderbufferParameter(e,r):Tr.recordError(1281)},za:(e,r,t,a)=>{var n=_r.getShaderInfoLog(Tr.shaders[e]);null===n&&(n="(unknown error)");var o=r>0&&a?rr(n,a,r):0;t&&(g[t>>2]=o)},ub:(e,r,t,a)=>{var n=_r.getShaderPrecisionFormat(e,r);g[t>>2]=n.rangeMin,g[t+4>>2]=n.rangeMax,g[a>>2]=n.precision},Aa:(e,r,t)=>{if(t)if(35716==r){var a=_r.getShaderInfoLog(Tr.shaders[e]);null===a&&(a="(unknown error)");var n=a?a.length+1:0;g[t>>2]=n}else if(35720==r){var o=_r.getShaderSource(Tr.shaders[e]),i=o?o.length+1:0;g[t>>2]=i}else g[t>>2]=_r.getShaderParameter(Tr.shaders[e],r);else Tr.recordError(1281)},J:e=>{var r=Tr.stringCache[e];if(!r){switch(e){case 7939:r=Ur(Gr().join(" "));break;case 7936:case 7937:case 37445:case 37446:var t=_r.getParameter(e);t||Tr.recordError(1280),r=t?Ur(t):0;break;case 7938:var a=_r.getParameter(7938);a=Tr.currentContext.version>=2?"OpenGL ES 3.0 (".concat(a,")"):"OpenGL ES 2.0 (".concat(a,")"),r=Ur(a);break;case 35724:var n=_r.getParameter(35724),o=n.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==o&&(3==o[1].length&&(o[1]=o[1]+"0"),n="OpenGL ES GLSL ES ".concat(o[1]," (").concat(n,")")),r=Ur(n);break;default:Tr.recordError(1280)}Tr.stringCache[e]=r}return r},Xa:(e,r)=>{if(Tr.currentContext.version<2)return Tr.recordError(1282),0;var t=Tr.stringiCache[e];if(t)return r<0||r>=t.length?(Tr.recordError(1281),0):t[r];if(7939===e){var a=Gr().map(Ur);return t=Tr.stringiCache[e]=a,r<0||r>=t.length?(Tr.recordError(1281),0):t[r]}return Tr.recordError(1280),0},Ba:(e,r)=>{if(r=or(r),e=Tr.programs[e]){(e=>{var r,t,a=e.uniformLocsById,n=e.uniformSizeAndIdsByName;if(!a)for(e.uniformLocsById=a={},e.uniformArrayNamesById={},r=0;r<_r.getProgramParameter(e,35718);++r){var o=_r.getActiveUniform(e,r),i=o.name,s=o.size,c=Mr(i),u=c>0?i.slice(0,c):i,l=e.uniformIdCounter;for(e.uniformIdCounter+=s,n[u]=[s,l],t=0;t<s;++t)a[l]=t,e.uniformArrayNamesById[l++]=u}})(e);var t=e.uniformLocsById,a=0,n=r,o=Mr(r);o>0&&(s=r.slice(o+1),a=parseInt(s)>>>0,n=r.slice(0,o));var i=e.uniformSizeAndIdsByName[n];if(i&&a<i[0]&&(t[a+=i[1]]=t[a]||_r.getUniformLocation(e,r)))return a}else Tr.recordError(1281);var s;return-1},vb:(e,r,t)=>{for(var a=Fr[r],n=0;n<r;n++)a[n]=g[t+4*n>>2];_r.invalidateFramebuffer(e,a)},wb:(e,r,t,a,n,o,i)=>{for(var s=Fr[r],c=0;c<r;c++)s[c]=g[t+4*c>>2];_r.invalidateSubFramebuffer(e,s,a,n,o,i)},Eb:e=>_r.isSync(Tr.syncs[e]),Ca:e=>{var r=Tr.textures[e];return r?_r.isTexture(r):0},Da:e=>_r.lineWidth(e),Ea:e=>{e=Tr.programs[e],_r.linkProgram(e),e.uniformLocsById=0,e.uniformSizeAndIdsByName={}},$b:(e,r,t,a,n,o)=>{_r.mdibvbi.multiDrawArraysInstancedBaseInstanceWEBGL(e,g,r>>2,g,t>>2,g,a>>2,p,n>>2,o)},ac:(e,r,t,a,n,o,i,s)=>{_r.mdibvbi.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,g,r>>2,t,g,a>>2,g,n>>2,g,o>>2,p,i>>2,s)},Fa:(e,r)=>{3317==e&&(Tr.unpackAlignment=r),_r.pixelStorei(e,r)},cc:e=>_r.readBuffer(e),Ga:(e,r,t,a,n,o,i)=>{if(Tr.currentContext.version>=2){if(_r.currentPixelPackBufferBinding)return void _r.readPixels(e,r,t,a,n,o,i);var s=Vr(o),c=Nr(i,s);_r.readPixels(e,r,t,a,n,o,s,c)}else{var u=Rr(o,n,t,a,i);u?_r.readPixels(e,r,t,a,n,o,u):Tr.recordError(1280)}},Ob:(e,r,t,a)=>_r.renderbufferStorage(e,r,t,a),Kb:(e,r,t,a,n)=>_r.renderbufferStorageMultisample(e,r,t,a,n),Ab:(e,r,t)=>{_r.samplerParameterf(Tr.samplers[e],r,t)},Bb:(e,r,t)=>{_r.samplerParameteri(Tr.samplers[e],r,t)},Cb:(e,r,t)=>{var a=g[t>>2];_r.samplerParameteri(Tr.samplers[e],r,a)},Ha:(e,r,t,a)=>_r.scissor(e,r,t,a),Ia:(e,r,t,a)=>{var n=Tr.getSource(e,r,t,a);_r.shaderSource(Tr.shaders[e],n)},Ja:(e,r,t)=>_r.stencilFunc(e,r,t),Ka:(e,r,t,a)=>_r.stencilFuncSeparate(e,r,t,a),La:e=>_r.stencilMask(e),Ma:(e,r)=>_r.stencilMaskSeparate(e,r),Na:(e,r,t)=>_r.stencilOp(e,r,t),Oa:(e,r,t,a)=>_r.stencilOpSeparate(e,r,t,a),Pa:(e,r,t,a,n,o,i,s,c)=>{if(Tr.currentContext.version>=2){if(_r.currentPixelUnpackBufferBinding)return void _r.texImage2D(e,r,t,a,n,o,i,s,c);if(c){var u=Vr(s),l=Nr(c,u);return void _r.texImage2D(e,r,t,a,n,o,i,s,u,l)}}var f=c?Rr(s,i,a,n,c):null;_r.texImage2D(e,r,t,a,n,o,i,s,f)},Qa:(e,r,t)=>_r.texParameterf(e,r,t),Ra:(e,r,t)=>{var a=y[t>>2];_r.texParameterf(e,r,a)},Sa:(e,r,t)=>_r.texParameteri(e,r,t),Ta:(e,r,t)=>{var a=g[t>>2];_r.texParameteri(e,r,a)},Yb:(e,r,t,a,n)=>_r.texStorage2D(e,r,t,a,n),Ua:(e,r,t,a,n,o,i,s,c)=>{if(Tr.currentContext.version>=2){if(_r.currentPixelUnpackBufferBinding)return void _r.texSubImage2D(e,r,t,a,n,o,i,s,c);if(c){var u=Vr(s);return void _r.texSubImage2D(e,r,t,a,n,o,i,s,u,Nr(c,u))}}var l=c?Rr(s,i,n,o,c):null;_r.texSubImage2D(e,r,t,a,n,o,i,s,l)},Va:(e,r)=>{_r.uniform1f(Yr(e),r)},Wa:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform1fv(Yr(e),y,t>>2,r);else{if(r<=288)for(var a=Hr[r],n=0;n<r;++n)a[n]=y[t+4*n>>2];else a=y.subarray(t>>2,t+4*r>>2);_r.uniform1fv(Yr(e),a)}},Hc:(e,r)=>{_r.uniform1i(Yr(e),r)},Ic:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform1iv(Yr(e),g,t>>2,r);else{if(r<=288)for(var a=Xr[r],n=0;n<r;++n)a[n]=g[t+4*n>>2];else a=g.subarray(t>>2,t+4*r>>2);_r.uniform1iv(Yr(e),a)}},Kc:(e,r,t)=>{_r.uniform2f(Yr(e),r,t)},Lc:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform2fv(Yr(e),y,t>>2,2*r);else{if(r<=144)for(var a=Hr[2*r],n=0;n<2*r;n+=2)a[n]=y[t+4*n>>2],a[n+1]=y[t+(4*n+4)>>2];else a=y.subarray(t>>2,t+8*r>>2);_r.uniform2fv(Yr(e),a)}},Gc:(e,r,t)=>{_r.uniform2i(Yr(e),r,t)},Fc:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform2iv(Yr(e),g,t>>2,2*r);else{if(r<=144)for(var a=Xr[2*r],n=0;n<2*r;n+=2)a[n]=g[t+4*n>>2],a[n+1]=g[t+(4*n+4)>>2];else a=g.subarray(t>>2,t+8*r>>2);_r.uniform2iv(Yr(e),a)}},Ec:(e,r,t,a)=>{_r.uniform3f(Yr(e),r,t,a)},Dc:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform3fv(Yr(e),y,t>>2,3*r);else{if(r<=96)for(var a=Hr[3*r],n=0;n<3*r;n+=3)a[n]=y[t+4*n>>2],a[n+1]=y[t+(4*n+4)>>2],a[n+2]=y[t+(4*n+8)>>2];else a=y.subarray(t>>2,t+12*r>>2);_r.uniform3fv(Yr(e),a)}},Cc:(e,r,t,a)=>{_r.uniform3i(Yr(e),r,t,a)},Bc:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform3iv(Yr(e),g,t>>2,3*r);else{if(r<=96)for(var a=Xr[3*r],n=0;n<3*r;n+=3)a[n]=g[t+4*n>>2],a[n+1]=g[t+(4*n+4)>>2],a[n+2]=g[t+(4*n+8)>>2];else a=g.subarray(t>>2,t+12*r>>2);_r.uniform3iv(Yr(e),a)}},Ac:(e,r,t,a,n)=>{_r.uniform4f(Yr(e),r,t,a,n)},zc:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform4fv(Yr(e),y,t>>2,4*r);else{if(r<=72){var a=Hr[4*r],n=y;t>>=2;for(var o=0;o<4*r;o+=4){var i=t+o;a[o]=n[i],a[o+1]=n[i+1],a[o+2]=n[i+2],a[o+3]=n[i+3]}}else a=y.subarray(t>>2,t+16*r>>2);_r.uniform4fv(Yr(e),a)}},nc:(e,r,t,a,n)=>{_r.uniform4i(Yr(e),r,t,a,n)},oc:(e,r,t)=>{if(Tr.currentContext.version>=2)r&&_r.uniform4iv(Yr(e),g,t>>2,4*r);else{if(r<=72)for(var a=Xr[4*r],n=0;n<4*r;n+=4)a[n]=g[t+4*n>>2],a[n+1]=g[t+(4*n+4)>>2],a[n+2]=g[t+(4*n+8)>>2],a[n+3]=g[t+(4*n+12)>>2];else a=g.subarray(t>>2,t+16*r>>2);_r.uniform4iv(Yr(e),a)}},pc:(e,r,t,a)=>{if(Tr.currentContext.version>=2)r&&_r.uniformMatrix2fv(Yr(e),!!t,y,a>>2,4*r);else{if(r<=72)for(var n=Hr[4*r],o=0;o<4*r;o+=4)n[o]=y[a+4*o>>2],n[o+1]=y[a+(4*o+4)>>2],n[o+2]=y[a+(4*o+8)>>2],n[o+3]=y[a+(4*o+12)>>2];else n=y.subarray(a>>2,a+16*r>>2);_r.uniformMatrix2fv(Yr(e),!!t,n)}},qc:(e,r,t,a)=>{if(Tr.currentContext.version>=2)r&&_r.uniformMatrix3fv(Yr(e),!!t,y,a>>2,9*r);else{if(r<=32)for(var n=Hr[9*r],o=0;o<9*r;o+=9)n[o]=y[a+4*o>>2],n[o+1]=y[a+(4*o+4)>>2],n[o+2]=y[a+(4*o+8)>>2],n[o+3]=y[a+(4*o+12)>>2],n[o+4]=y[a+(4*o+16)>>2],n[o+5]=y[a+(4*o+20)>>2],n[o+6]=y[a+(4*o+24)>>2],n[o+7]=y[a+(4*o+28)>>2],n[o+8]=y[a+(4*o+32)>>2];else n=y.subarray(a>>2,a+36*r>>2);_r.uniformMatrix3fv(Yr(e),!!t,n)}},rc:(e,r,t,a)=>{if(Tr.currentContext.version>=2)r&&_r.uniformMatrix4fv(Yr(e),!!t,y,a>>2,16*r);else{if(r<=18){var n=Hr[16*r],o=y;a>>=2;for(var i=0;i<16*r;i+=16){var s=a+i;n[i]=o[s],n[i+1]=o[s+1],n[i+2]=o[s+2],n[i+3]=o[s+3],n[i+4]=o[s+4],n[i+5]=o[s+5],n[i+6]=o[s+6],n[i+7]=o[s+7],n[i+8]=o[s+8],n[i+9]=o[s+9],n[i+10]=o[s+10],n[i+11]=o[s+11],n[i+12]=o[s+12],n[i+13]=o[s+13],n[i+14]=o[s+14],n[i+15]=o[s+15]}}else n=y.subarray(a>>2,a+64*r>>2);_r.uniformMatrix4fv(Yr(e),!!t,n)}},sc:e=>{e=Tr.programs[e],_r.useProgram(e),_r.currentProgram=e},tc:(e,r)=>_r.vertexAttrib1f(e,r),uc:(e,r)=>{_r.vertexAttrib2f(e,y[r>>2],y[r+4>>2])},vc:(e,r)=>{_r.vertexAttrib3f(e,y[r>>2],y[r+4>>2],y[r+8>>2])},wc:(e,r)=>{_r.vertexAttrib4f(e,y[r>>2],y[r+4>>2],y[r+8>>2],y[r+12>>2])},Zb:(e,r)=>{_r.vertexAttribDivisor(e,r)},_b:(e,r,t,a,n)=>{_r.vertexAttribIPointer(e,r,t,a,n)},xc:(e,r,t,a,n,o)=>{_r.vertexAttribPointer(e,r,t,!!a,n,o)},yc:(e,r,t,a)=>_r.viewport(e,r,t,a),Fb:(e,r,t)=>{t=Number(t),_r.waitSync(Tr.syncs[e],r,t)},f:function(e,r){var t=j();try{return ke(e)(r)}catch(e){if(G(t),e!==e+0)throw e;st(1,0)}},t:function(e,r,t){var a=j();try{return ke(e)(r,t)}catch(e){if(G(a),e!==e+0)throw e;st(1,0)}},i:function(e,r,t,a){var n=j();try{return ke(e)(r,t,a)}catch(e){if(G(n),e!==e+0)throw e;st(1,0)}},z:function(e,r,t,a,n){var o=j();try{return ke(e)(r,t,a,n)}catch(e){if(G(o),e!==e+0)throw e;st(1,0)}},qb:function(e,r,t,a,n,o){var i=j();try{return ke(e)(r,t,a,n,o)}catch(e){if(G(i),e!==e+0)throw e;st(1,0)}},pb:function(e,r,t,a,n,o,i){var s=j();try{return ke(e)(r,t,a,n,o,i)}catch(e){if(G(s),e!==e+0)throw e;st(1,0)}},sb:function(e){var r=j();try{ke(e)()}catch(e){if(G(r),e!==e+0)throw e;st(1,0)}},k:function(e,r){var t=j();try{ke(e)(r)}catch(e){if(G(t),e!==e+0)throw e;st(1,0)}},A:function(e,r,t){var a=j();try{ke(e)(r,t)}catch(e){if(G(a),e!==e+0)throw e;st(1,0)}},v:function(e,r,t,a){var n=j();try{ke(e)(r,t,a)}catch(e){if(G(n),e!==e+0)throw e;st(1,0)}},r:function(e,r,t,a,n){var o=j();try{ke(e)(r,t,a,n)}catch(e){if(G(o),e!==e+0)throw e;st(1,0)}},ob:function(e,r,t,a,n,o){var i=j();try{ke(e)(r,t,a,n,o)}catch(e){if(G(i),e!==e+0)throw e;st(1,0)}},rb:function(e,r,t,a,n,o,i){var s=j();try{ke(e)(r,t,a,n,o,i)}catch(e){if(G(s),e!==e+0)throw e;st(1,0)}},tb:function(e,r,t,a,n,o,i,s,c,u){var l=j();try{ke(e)(r,t,a,n,o,i,s,c,u)}catch(e){if(G(l),e!==e+0)throw e;st(1,0)}},bb:(e,r,t,a,n)=>Qr(e,r,t,a)},at=function(){var e,r,a,o,i={a:tt};function s(e,r){var t;return at=e.exports,u=at.Uc,C(),We=at.Yc,t=at.Vc,E.unshift(t),function(e){if(0==--A&&S){var r=S;S=null,r()}}(),at}if(A++,n.instantiateWasm)try{return n.instantiateWasm(i,s)}catch(e){f("Module.instantiateWasm callback failed with error: ".concat(e)),t(e)}return W||(W=L()),(e=c,r=W,a=i,o=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||B(r)||"function"!=typeof fetch?F(r,a,o):fetch(r,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,a).then(o,(function(e){return f("wasm streaming compile failed: ".concat(e)),f("falling back to ArrayBuffer instantiation"),F(r,a,o)}))))).catch(t),{}}(),nt=e=>(nt=at.Wc)(e),ot=n._malloc=e=>(ot=n._malloc=at.Xc)(e),it=n._free=e=>(it=n._free=at.Zc)(e),st=(e,r)=>(st=at._c)(e,r),ct=e=>(ct=at.$c)(e),ut=()=>(ut=at.ad)();function lt(){A>0||(D(T),A>0||rt||(rt=!0,n.calledRun=!0,x||(D(E),r(n),D(P))))}return n.GL=Tr,S=function e(){rt||lt(),rt||(S=e)},lt(),o});export{r as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sketch-hq/sketch-web-renderer",
3
- "version": "12.1.2",
3
+ "version": "12.1.3",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Sketch Web Renderer",
6
6
  "repository": "git@github.com:sketch-hq/web-renderer",
@@ -52,7 +52,7 @@
52
52
  "@rollup/plugin-replace": "5.0.2",
53
53
  "@rollup/plugin-terser": "0.4.3",
54
54
  "@rollup/plugin-typescript": "11.1.1",
55
- "@sketch-hq/sketch-file-format-marina": "12.1.2",
55
+ "@sketch-hq/sketch-file-format-marina": "12.1.3",
56
56
  "@types/node": "18.16.0",
57
57
  "@types/offscreencanvas": "2019.7.0",
58
58
  "@types/pixelmatch": "5.2.4",