@sketch-hq/sketch-web-renderer 14.8.0 → 14.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 N(){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 _(e){return N()?{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,o){void 0===n&&(n=!1),void 0===o&&(o=!1);var r=e.call(this)||this;return r.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},r.handleGestureStart=function(e){e.preventDefault(),r.state.lastGestureScale=e.scale},r.handleGestureChange=function(e){e.preventDefault();var t=e.scale/r.state.lastGestureScale;r.state.lastGestureScale=e.scale;var n=r.getCorrectPointerPosition(e);r.emitZoomEvent(t,n)},r.handleGestureEnd=function(e){e.preventDefault()},r.updateMousePosition=function(e){r.emit("pointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.updateGlobalMousePosition=function(e){r.emit("globalpointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.handleTouchStart=function(e){e.preventDefault(),r.handleTouchPinchToZoomStart(e),r.emit("pointerdown",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),r.emit("pointerdown",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},r.handleTouchMove=function(e){r.handleTouchPinchToZoomChange(e),r.emit("pointermove",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleMouseMove=function(e){r.updateMousePosition(e)},r.handleGlobalTouchMove=function(e){r.emit("globalpointermove",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleGlobalMouseMove=function(e){r.updateGlobalMousePosition(e)},r.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(r.state.pinchToZoomLastDistance=r.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},r.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var n=r.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),o=r.getCorrectPointerPosition(e),i=1+.004*(n-r.state.pinchToZoomLastDistance);r.state.pinchToZoomLastDistance=n,r.emitZoomEvent(i,o)}},r.handleTouchEnd=function(e){var t=r.getCorrectPointerPosition(e);r.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},r.handleMouseUp=function(e){r.emit("pointerup",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.debouncedUpdateMousePosition=k(r.updateMousePosition,40),r.debouncedUpdateGlobalMousePosition=k(r.updateGlobalMousePosition,40),r.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!r.state.isCtrlPressed,n=e.metaKey||t||r.state.isCtrlPressed;if(r.debouncedUpdateMousePosition(e),r.debouncedUpdateGlobalMousePosition(e),n){var o=t||r.invertedWheelZoom?-1:1,i=r.getCorrectPointerPosition(e),a=1+.005*e.deltaY*o;r.emitZoomEvent(a,i)}else r.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.target=t,r.invertedWheelZoom=n,r.targetBounds=t.getBoundingClientRect(),r.listenersCollector=new I(o),r.addListeners(),r.targetResizeObserver=new ResizeObserver(r.updateTargetBounds.bind(r)),r.targetResizeObserver.observe(r.target),r}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(){N()||(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.prototype.setInvertedWheelZoom=function(e){this.invertedWheelZoom=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-1b3f108d.js"):import("./web-renderer-debug-60dcc9c3.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,Ee,Me,Le,xe=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,this.showArtboardsDecorations=!0,this.invertedWheelZoom=!1}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}(),Re={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.Fixed=0]="Fixed",e[e.Fill=1]="Fill",e[e.Fit=2]="Fit",e[e.Relative=3]="Relative"}(me||(me={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical"}(ye||(ye={})),function(e){e[e.Start=0]="Start",e[e.Center=1]="Center",e[e.End=2]="End",e[e.SpaceBetween=3]="SpaceBetween",e[e.SpaceAround=4]="SpaceAround",e[e.SpaceEvenly=5]="SpaceEvenly"}(be||(be={})),function(e){e[e.None=0]="None",e[e.Start=1]="Start",e[e.Center=2]="Center",e[e.End=3]="End",e[e.Stretch=4]="Stretch"}(we||(we={})),function(e){e[e.Unset=0]="Unset",e[e.Mouse=1]="Mouse",e[e.Touch=2]="Touch"}(Ce||(Ce={})),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"}(Pe||(Pe={})),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"}(Ee||(Ee={})),function(e){e[e.Screen=0]="Screen",e[e.Overlay=1]="Overlay"}(Me||(Me={})),function(e){e[e.Fit=0]="Fit",e[e.FillWidth=1]="FillWidth",e[e.ActualSize=2]="ActualSize"}(Le||(Le={}));var We=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=xe.FromSettings(t),$.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container,n.settings.invertedWheelZoom),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.setShowArtboardsDecorations(this.settings.showArtboardsDecorations),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.zoomToFitNode=function(e,t,n){var o;void 0===t&&(t=.82),void 0===n&&(n=!1),null===(o=this.pageCanvasWasm)||void 0===o||o.scaleNodeToFit(e,t,n)},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("14.8.0");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.getFrames())}}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=Ee[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=Re[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),Se=r(void 0),Te=r(void 0),Fe=r(void 0),Ie=r(void 0),Ae=r(void 0),De=r("auto"),Ge=r(void 0),Ue=function(){var e=i(Ge);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ke=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}},Be=function(n){var r=t(null),i=t(null),u=a(ke,{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 We(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,o;$.logDebug("Provider setSettings"),e.backgroundColor&&(null===(t=r.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(n=r.current)||void 0===n||n.gestureManager.setInvertedWheelZoom(e.invertedWheelZoom||!1),null===(o=r.current)||void 0===o||o.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(Ge.Provider,{value:F},e.createElement(Se.Provider,{value:c},e.createElement(Te.Provider,{value:d},e.createElement(Ae.Provider,{value:p},e.createElement(Fe.Provider,{value:g},e.createElement(Ie.Provider,{value:v},e.createElement(De.Provider,{value:f},n.children)))))))},ze=function(e,t){var n=(0,Ue().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},Ze=function(){var e=i(Se);if(void 0===e)throw Error("useStatus must be used within a provider");return e},Oe=function(){var e=i(Te);if(void 0===e)throw Error("useZoom must be used within a provider");return e},Ne=function(){var e=i(Ae);if(void 0===e)throw Error("usePan must be used within a provider");return e},He=function(){var e=i(De);if(void 0===e)throw Error("useCursor must be used within a provider");return e},_e=function(){var e=i(Fe);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},je=function(){var e=i(Ie);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},Ve=function(){var e=(0,Ue().getInstance)(),t=Ze();return s((function(){return e&&"READY"===t.type?e.getPRFile():null}),[e,t])},Je=function(){var e=(0,Ue().getInstance)(),t=Ze();return s((function(){return e&&"READY"===t.type?e.getPRFileArtboards():null}),[e,t])},Ke=function(){var e,t,n,o,r=Ve(),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);ze("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])},Ye=function(){var e=(0,Ue().getInstance)();return o((function(t){null==e||e.setZoom(t)}),[e])},$e=function(){var e=Ye(),t=Oe();return o((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},Xe=function(){var e=Ye(),t=Oe();return o((function(){"number"==typeof t&&e(t/2)}),[e,t])},qe=function(){var e=(0,Ue().getInstance)();return o((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},Qe=function(){var e=(0,Ue().getInstance)();return o((function(){null==e||e.zoomToFit()}),[e])},et=function(){var e=(0,Ue().getInstance)();return o((function(t,n,o){null==e||e.zoomToFitNode(t,n,o)}),[e])},tt=function(){var e=(0,Ue().getInstance)();return o((function(){null==e||e.looseWebGLContext()}),[e])},nt=function(){var e=(0,Ue().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])},ot=function(){var e=(0,Ue().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])},rt=function(){var e=(0,Ue().getInstance)();return o((function(t){null==e||e.setIsCameraLocked(t)}),[e])},it=function(){var e=(0,Ue().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},at=function(){var e=(0,Ue().getInstance)(),t=Ve();return o((function(n,o){return e&&t?e.exportNode(n,o):Promise.reject("WebRenderer instance not ready")}),[e,t])};function st(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 ut={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},lt={position:"absolute",top:0,left:0},ct=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=n.showArtboardsDecorations,S=n.invertedWheelZoom,T=t(null),F=t(null),I=l(!1),A=I[0],D=I[1],G=o((function(){return D(!0)}),[]),U=Ue(),k=U.dispose,B=U.init,z=U.setSettings,Z=He(),O=Ze();ze("allImagesReady",G),u((function(){return $.logDebug("CanvasRenderer mounted"),function(){return $.logDebug("CanvasRenderer unmounted")}}),[]),u((function(){z({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,showArtboardsDecorations:W,invertedWheelZoom:S})}),[z,i,a,c,d,p,g,v,f,m,y,b,w,C,P,x,R,W,S]),u((function(){if(r)return B(r,T.current,F.current),function(){k()}}),[k,B,r]);var N=s((function(){var e;return null!==(e=n.cursor)&&void 0!==e?e:Z}),[n.cursor,Z]),H=s((function(){return h(h({},ut),{cursor:N})}),[N]);return e.createElement("div",h({},M,{ref:F,style:H}),r&&e.createElement("canvas",h({},L,{key:r,ref:T,"data-sketchweb-all-images-ready":A,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==O?void 0:O.type.toLowerCase())||"null"),style:lt})),"READY"===(null==O?void 0:O.type)&&E)},dt=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}(),ht=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=dt.FromSettings(t),$.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container,!1,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),pt=r(void 0),gt=r("auto"),vt=r(void 0),ft=r(void 0),mt=r(void 0),yt=r(void 0),bt=function(){var e=i(yt);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},wt=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}},Ct=function(n){var r=t(null),i=t(null),u=a(wt,{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 ht(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(yt.Provider,{value:R},e.createElement(pt.Provider,{value:c},e.createElement(gt.Provider,{value:d},e.createElement(vt.Provider,{value:p},e.createElement(ft.Provider,{value:g},e.createElement(mt.Provider,{value:v},n.children))))))},Pt=function(){var e=(0,bt().getInstance)();return o((function(t){null==e||e.restartPrototype(t)}),[e])},Et=function(){var e=(0,bt().getInstance)();return o((function(){null==e||e.navigateToFirstFlow()}),[e])},Mt=function(){var e=(0,bt().getInstance)();return o((function(){null==e||e.goBack()}),[e])},Lt=function(){var e=(0,bt().getInstance)();return o((function(){null==e||e.goForwards()}),[e])},xt=function(){var e=(0,bt().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])},Rt=function(){var e=(0,bt().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},Wt=function(){var e=i(pt);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},St=function(){var e=i(gt);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},Tt=function(){var e=i(vt);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},Ft=function(){var e=i(ft);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},It=function(){var e=i(mt);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},At=function(e,t){var n=(0,bt().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Dt(){var e=(0,bt().getInstance)();return o((function(t){return void 0===t&&(t=!0),null==e?void 0:e.getScreen(t)}),[e])}var Gt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ut={position:"absolute",top:0,left:0},kt=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=bt(),F=T.dispose,I=T.init,A=T.setSettings,D=Wt(),G=St(),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({},Gt),{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:Ut})),"READY"===(null==D?void 0:D.type)&&v)},Bt={position:"absolute",inset:0,pointerEvents:"none"};function zt(t){var n=t.visualize,r=void 0!==n&&n,i=Dt(),a=l((function(){return i()||null})),u=a[0],c=a[1],d=o((function(){c(i()||null)}),[i]);At("sceneChange",d);var p=s((function(){return h(h({},Bt),{opacity:r?1:0})}),[r]);return u?e.createElement("div",{style:p},u.layers.map((function(t,n){return e.createElement(Zt,{key:"".concat(n,"/").concat(t.id),bounds:t.bounds,id:t.id,name:t.name,type:t.type})}))):null}function Zt(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,a=Ft(),u=It()||{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(Ot(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 Ot(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{Ie as CameraMoveContext,Fe as CameraZoomingContext,We as CanvasRenderer,Be as CanvasRendererProvider,ct as CanvasRendererReact,De as CursorContext,A as DefaultFeatureFlags,F as EventEmitter,V as GestureManager,J as KeyboardManager,I as ListenersCollector,Pe as PRCursorType,me as PRLayerSizingBehaviour,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,Ee as PRNodeExportFormat,we as PRStackCrossAxisAlignment,ye as PRStackDirection,be as PRStackMainAxisAlignment,Ce as PRUserPointerType,Ae as PanContext,K as Performance,ht as PrototypeRenderer,Ct as PrototypeRendererProvider,kt as PrototypeRendererReact,W as PrototypeResizeMode,Le as PrototypeResizeModeWasm,Me as PrototypeStructureFlowType,zt as PrototypeTestOverlay,Se as StatusContext,S as WebRendererError,R as WebRendererMode,Te as ZoomContext,z as clamp,O as convertEmbindVectorToArray,k as debounce,B as extractPointer,Z as getSupportedWebGLVersion,D as getiOSVersion,T as isDefinedPresentationManifestFrame,N as isTouchDevice,$ as logger,Y as nextTick,U as parseSafariUserAgent,ke as reducer,H as removeUndefinedKeys,j as safePtrAccess,_ as touchableClick,He as useCursor,X as useDebounceFunction,Xe as useDecrementZoom,ze as useEvent,at as useExportNode,nt as useGetArtboardAtPosition,ot as useGetPanAtPosition,Dt as useGetScreen,Mt as useGoBack,Lt as useGoForwards,$e as useIncrementZoom,je as useIsCameraMoving,_e as useIsCameraZooming,rt as useLockCamera,st as useLogEvent,tt as useLooseWebGLContext,it as useMapRelativePositionToCameraPosition,Et as useNavigateToFirstFlow,Ve as usePRFile,Je as usePRFileArtboards,Ne as usePan,St as usePrototypeCursor,At as usePrototypeEvent,xt as usePrototypeGetArtboardAtPosition,Rt as usePrototypeMapRelativePositionToCameraPosition,It as usePrototypePan,Tt as usePrototypeState,Wt as usePrototypeStatus,Ft as usePrototypeZoom,Pt as useRestartPrototype,Ke as useRootNodeAbsoluteExtent,qe as useSetPan,Ye as useSetZoom,Ze as useStatus,Oe as useZoom,Qe as useZoomToFit,et as useZoomToFitNode};
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 N(){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 _(e){return N()?{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,o){void 0===n&&(n=!1),void 0===o&&(o=!1);var r=e.call(this)||this;return r.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},r.handleGestureStart=function(e){e.preventDefault(),r.state.lastGestureScale=e.scale},r.handleGestureChange=function(e){e.preventDefault();var t=e.scale/r.state.lastGestureScale;r.state.lastGestureScale=e.scale;var n=r.getCorrectPointerPosition(e);r.emitZoomEvent(t,n)},r.handleGestureEnd=function(e){e.preventDefault()},r.updateMousePosition=function(e){r.emit("pointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.updateGlobalMousePosition=function(e){r.emit("globalpointermove",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.handleTouchStart=function(e){e.preventDefault(),r.handleTouchPinchToZoomStart(e),r.emit("pointerdown",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),r.emit("pointerdown",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},r.handleTouchMove=function(e){r.handleTouchPinchToZoomChange(e),r.emit("pointermove",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleMouseMove=function(e){r.updateMousePosition(e)},r.handleGlobalTouchMove=function(e){r.emit("globalpointermove",{type:"touch",position:r.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},r.handleGlobalMouseMove=function(e){r.updateGlobalMousePosition(e)},r.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(r.state.pinchToZoomLastDistance=r.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},r.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var n=r.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),o=r.getCorrectPointerPosition(e),i=1+.004*(n-r.state.pinchToZoomLastDistance);r.state.pinchToZoomLastDistance=n,r.emitZoomEvent(i,o)}},r.handleTouchEnd=function(e){var t=r.getCorrectPointerPosition(e);r.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},r.handleMouseUp=function(e){r.emit("pointerup",{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.debouncedUpdateMousePosition=k(r.updateMousePosition,40),r.debouncedUpdateGlobalMousePosition=k(r.updateGlobalMousePosition,40),r.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!r.state.isCtrlPressed,n=e.metaKey||t||r.state.isCtrlPressed;if(r.debouncedUpdateMousePosition(e),r.debouncedUpdateGlobalMousePosition(e),n){var o=t||r.invertedWheelZoom?-1:1,i=r.getCorrectPointerPosition(e),a=1+.005*e.deltaY*o;r.emitZoomEvent(a,i)}else r.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:r.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},r.target=t,r.invertedWheelZoom=n,r.targetBounds=t.getBoundingClientRect(),r.listenersCollector=new I(o),r.addListeners(),r.targetResizeObserver=new ResizeObserver(r.updateTargetBounds.bind(r)),r.targetResizeObserver.observe(r.target),r}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(){N()||(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.prototype.setInvertedWheelZoom=function(e){this.invertedWheelZoom=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-1b3f108d.js"):import("./web-renderer-debug-60dcc9c3.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,Ee,Me,Le,xe=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=.01,this.maximumZoomLevel=5,this.preserveDrawingBuffer=!1,this.featureFlags=A,this.manualInitialization=!1,this.panBoundariesPadding=0,this.selectedArtboard=null,this.initialZoom=null,this.initialPan=null,this.showArtboardsDecorations=!0,this.invertedWheelZoom=!1}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}(),Re={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.Fixed=0]="Fixed",e[e.Fill=1]="Fill",e[e.Fit=2]="Fit",e[e.Relative=3]="Relative"}(me||(me={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical"}(ye||(ye={})),function(e){e[e.Start=0]="Start",e[e.Center=1]="Center",e[e.End=2]="End",e[e.SpaceBetween=3]="SpaceBetween",e[e.SpaceAround=4]="SpaceAround",e[e.SpaceEvenly=5]="SpaceEvenly"}(be||(be={})),function(e){e[e.None=0]="None",e[e.Start=1]="Start",e[e.Center=2]="Center",e[e.End=3]="End",e[e.Stretch=4]="Stretch"}(we||(we={})),function(e){e[e.Unset=0]="Unset",e[e.Mouse=1]="Mouse",e[e.Touch=2]="Touch"}(Ce||(Ce={})),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"}(Pe||(Pe={})),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"}(Ee||(Ee={})),function(e){e[e.Screen=0]="Screen",e[e.Overlay=1]="Overlay"}(Me||(Me={})),function(e){e[e.Fit=0]="Fit",e[e.FillWidth=1]="FillWidth",e[e.ActualSize=2]="ActualSize"}(Le||(Le={}));var We=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=xe.FromSettings(t),$.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container,n.settings.invertedWheelZoom),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.setShowArtboardsDecorations(this.settings.showArtboardsDecorations),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.zoomToFitNode=function(e,t,n){var o;void 0===t&&(t=.82),void 0===n&&(n=!1),null===(o=this.pageCanvasWasm)||void 0===o||o.scaleNodeToFit(e,t,n)},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("14.8.1");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.getFrames())}}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=Ee[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=Re[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),Se=r(void 0),Te=r(void 0),Fe=r(void 0),Ie=r(void 0),Ae=r(void 0),De=r("auto"),Ge=r(void 0),Ue=function(){var e=i(Ge);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ke=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}},Be=function(n){var r=t(null),i=t(null),u=a(ke,{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 We(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,o;$.logDebug("Provider setSettings"),e.backgroundColor&&(null===(t=r.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(n=r.current)||void 0===n||n.gestureManager.setInvertedWheelZoom(e.invertedWheelZoom||!1),null===(o=r.current)||void 0===o||o.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(Ge.Provider,{value:F},e.createElement(Se.Provider,{value:c},e.createElement(Te.Provider,{value:d},e.createElement(Ae.Provider,{value:p},e.createElement(Fe.Provider,{value:g},e.createElement(Ie.Provider,{value:v},e.createElement(De.Provider,{value:f},n.children)))))))},ze=function(e,t){var n=(0,Ue().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},Ze=function(){var e=i(Se);if(void 0===e)throw Error("useStatus must be used within a provider");return e},Oe=function(){var e=i(Te);if(void 0===e)throw Error("useZoom must be used within a provider");return e},Ne=function(){var e=i(Ae);if(void 0===e)throw Error("usePan must be used within a provider");return e},He=function(){var e=i(De);if(void 0===e)throw Error("useCursor must be used within a provider");return e},_e=function(){var e=i(Fe);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},je=function(){var e=i(Ie);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},Ve=function(){var e=(0,Ue().getInstance)(),t=Ze();return s((function(){return e&&"READY"===t.type?e.getPRFile():null}),[e,t])},Je=function(){var e=(0,Ue().getInstance)(),t=Ze();return s((function(){return e&&"READY"===t.type?e.getPRFileArtboards():null}),[e,t])},Ke=function(){var e,t,n,o,r=Ve(),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);ze("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])},Ye=function(){var e=(0,Ue().getInstance)();return o((function(t){null==e||e.setZoom(t)}),[e])},$e=function(){var e=Ye(),t=Oe();return o((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},Xe=function(){var e=Ye(),t=Oe();return o((function(){"number"==typeof t&&e(t/2)}),[e,t])},qe=function(){var e=(0,Ue().getInstance)();return o((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},Qe=function(){var e=(0,Ue().getInstance)();return o((function(){null==e||e.zoomToFit()}),[e])},et=function(){var e=(0,Ue().getInstance)();return o((function(t,n,o){null==e||e.zoomToFitNode(t,n,o)}),[e])},tt=function(){var e=(0,Ue().getInstance)();return o((function(){null==e||e.looseWebGLContext()}),[e])},nt=function(){var e=(0,Ue().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])},ot=function(){var e=(0,Ue().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])},rt=function(){var e=(0,Ue().getInstance)();return o((function(t){null==e||e.setIsCameraLocked(t)}),[e])},it=function(){var e=(0,Ue().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},at=function(){var e=(0,Ue().getInstance)(),t=Ve();return o((function(n,o){return e&&t?e.exportNode(n,o):Promise.reject("WebRenderer instance not ready")}),[e,t])};function st(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 ut={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},lt={position:"absolute",top:0,left:0},ct=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=n.showArtboardsDecorations,S=n.invertedWheelZoom,T=t(null),F=t(null),I=l(!1),A=I[0],D=I[1],G=o((function(){return D(!0)}),[]),U=Ue(),k=U.dispose,B=U.init,z=U.setSettings,Z=He(),O=Ze();ze("allImagesReady",G),u((function(){return $.logDebug("CanvasRenderer mounted"),function(){return $.logDebug("CanvasRenderer unmounted")}}),[]),u((function(){z({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,showArtboardsDecorations:W,invertedWheelZoom:S})}),[z,i,a,c,d,p,g,v,f,m,y,b,w,C,P,x,R,W,S]),u((function(){if(r)return B(r,T.current,F.current),function(){k()}}),[k,B,r]);var N=s((function(){var e;return null!==(e=n.cursor)&&void 0!==e?e:Z}),[n.cursor,Z]),H=s((function(){return h(h({},ut),{cursor:N})}),[N]);return e.createElement("div",h({},M,{ref:F,style:H}),r&&e.createElement("canvas",h({},L,{key:r,ref:T,"data-sketchweb-all-images-ready":A,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==O?void 0:O.type.toLowerCase())||"null"),style:lt})),"READY"===(null==O?void 0:O.type)&&E)},dt=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}(),ht=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=dt.FromSettings(t),$.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new V(n.settings.container,!1,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),pt=r(void 0),gt=r("auto"),vt=r(void 0),ft=r(void 0),mt=r(void 0),yt=r(void 0),bt=function(){var e=i(yt);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},wt=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}},Ct=function(n){var r=t(null),i=t(null),u=a(wt,{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 ht(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(yt.Provider,{value:R},e.createElement(pt.Provider,{value:c},e.createElement(gt.Provider,{value:d},e.createElement(vt.Provider,{value:p},e.createElement(ft.Provider,{value:g},e.createElement(mt.Provider,{value:v},n.children))))))},Pt=function(){var e=(0,bt().getInstance)();return o((function(t){null==e||e.restartPrototype(t)}),[e])},Et=function(){var e=(0,bt().getInstance)();return o((function(){null==e||e.navigateToFirstFlow()}),[e])},Mt=function(){var e=(0,bt().getInstance)();return o((function(){null==e||e.goBack()}),[e])},Lt=function(){var e=(0,bt().getInstance)();return o((function(){null==e||e.goForwards()}),[e])},xt=function(){var e=(0,bt().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])},Rt=function(){var e=(0,bt().getInstance)();return o((function(t,n){if(!e)return null;var o=e.mapRelativePositionToCameraPosition(t,n);return null!=o?o:null}),[e])},Wt=function(){var e=i(pt);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},St=function(){var e=i(gt);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},Tt=function(){var e=i(vt);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},Ft=function(){var e=i(ft);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},It=function(){var e=i(mt);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},At=function(e,t){var n=(0,bt().getInstance)();u((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Dt(){var e=(0,bt().getInstance)();return o((function(t){return void 0===t&&(t=!0),null==e?void 0:e.getScreen(t)}),[e])}var Gt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Ut={position:"absolute",top:0,left:0},kt=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=bt(),F=T.dispose,I=T.init,A=T.setSettings,D=Wt(),G=St(),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({},Gt),{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:Ut})),"READY"===(null==D?void 0:D.type)&&v)},Bt={position:"absolute",inset:0,pointerEvents:"none"};function zt(t){var n=t.visualize,r=void 0!==n&&n,i=Dt(),a=l((function(){return i()||null})),u=a[0],c=a[1],d=o((function(){c(i()||null)}),[i]);At("sceneChange",d);var p=s((function(){return h(h({},Bt),{opacity:r?1:0})}),[r]);return u?e.createElement("div",{style:p},u.layers.map((function(t,n){return e.createElement(Zt,{key:"".concat(n,"/").concat(t.id),bounds:t.bounds,id:t.id,name:t.name,type:t.type})}))):null}function Zt(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,a=Ft(),u=It()||{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(Ot(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 Ot(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{Ie as CameraMoveContext,Fe as CameraZoomingContext,We as CanvasRenderer,Be as CanvasRendererProvider,ct as CanvasRendererReact,De as CursorContext,A as DefaultFeatureFlags,F as EventEmitter,V as GestureManager,J as KeyboardManager,I as ListenersCollector,Pe as PRCursorType,me as PRLayerSizingBehaviour,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,Ee as PRNodeExportFormat,we as PRStackCrossAxisAlignment,ye as PRStackDirection,be as PRStackMainAxisAlignment,Ce as PRUserPointerType,Ae as PanContext,K as Performance,ht as PrototypeRenderer,Ct as PrototypeRendererProvider,kt as PrototypeRendererReact,W as PrototypeResizeMode,Le as PrototypeResizeModeWasm,Me as PrototypeStructureFlowType,zt as PrototypeTestOverlay,Se as StatusContext,S as WebRendererError,R as WebRendererMode,Te as ZoomContext,z as clamp,O as convertEmbindVectorToArray,k as debounce,B as extractPointer,Z as getSupportedWebGLVersion,D as getiOSVersion,T as isDefinedPresentationManifestFrame,N as isTouchDevice,$ as logger,Y as nextTick,U as parseSafariUserAgent,ke as reducer,H as removeUndefinedKeys,j as safePtrAccess,_ as touchableClick,He as useCursor,X as useDebounceFunction,Xe as useDecrementZoom,ze as useEvent,at as useExportNode,nt as useGetArtboardAtPosition,ot as useGetPanAtPosition,Dt as useGetScreen,Mt as useGoBack,Lt as useGoForwards,$e as useIncrementZoom,je as useIsCameraMoving,_e as useIsCameraZooming,rt as useLockCamera,st as useLogEvent,tt as useLooseWebGLContext,it as useMapRelativePositionToCameraPosition,Et as useNavigateToFirstFlow,Ve as usePRFile,Je as usePRFileArtboards,Ne as usePan,St as usePrototypeCursor,At as usePrototypeEvent,xt as usePrototypeGetArtboardAtPosition,Rt as usePrototypeMapRelativePositionToCameraPosition,It as usePrototypePan,Tt as usePrototypeState,Wt as usePrototypeStatus,Ft as usePrototypeZoom,Pt as useRestartPrototype,Ke as useRootNodeAbsoluteExtent,qe as useSetPan,Ye as useSetZoom,Ze as useStatus,Oe as useZoom,Qe as useZoomToFit,et as useZoomToFitNode};
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasSettings.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/CanvasSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAE9C,KAAK,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE3E,MAAM,MAAM,cAAc,GAAG;IAE3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAErC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,YAAY,CAAC,EAAE,OAAO,mBAAmB,CAAA;IACzC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAG3B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;IACzB,MAAM,EAAE,iBAAiB,CAAA;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,CAAA;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,QAAQ,CAAC,cAAc,CAAC;IAsB7D,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,cAAc;IACzB,QAAQ,EAAE,MAAM;IAvBzB,UAAU,SAAY;IACtB,eAAe,SAAK;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IACzC,kBAAkB,SAAK;IACvB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAC5C,eAAe,EAAE,SAAS,CAA6B;IACvD,IAAI,EAAE,eAAe,CAA0B;IAC/C,gBAAgB,UAAQ;IACxB,gBAAgB,SAAI;IACpB,gBAAgB,SAAO;IACvB,qBAAqB,UAAQ;IAC7B,YAAY;;;;;;;MAAsB;IAClC,oBAAoB,UAAQ;IAC5B,oBAAoB,SAAI;IACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAO;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IACjC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAO;IACpC,wBAAwB,UAAO;IAC/B,iBAAiB,UAAQ;gBAGhB,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,MAAM;IAGzB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,uBAAuB;CAYvE"}
1
+ {"version":3,"file":"CanvasSettings.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/CanvasSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAE9C,KAAK,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAE3E,MAAM,MAAM,cAAc,GAAG;IAE3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAErC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,YAAY,CAAC,EAAE,OAAO,mBAAmB,CAAA;IACzC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAG3B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;IACzB,MAAM,EAAE,iBAAiB,CAAA;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC,CAAA;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,QAAQ,CAAC,cAAc,CAAC;IAsB7D,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,cAAc;IACzB,QAAQ,EAAE,MAAM;IAvBzB,UAAU,SAAY;IACtB,eAAe,SAAK;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IACzC,kBAAkB,SAAK;IACvB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAC5C,eAAe,EAAE,SAAS,CAA6B;IACvD,IAAI,EAAE,eAAe,CAA0B;IAC/C,gBAAgB,UAAQ;IACxB,gBAAgB,SAAO;IACvB,gBAAgB,SAAI;IACpB,qBAAqB,UAAQ;IAC7B,YAAY;;;;;;;MAAsB;IAClC,oBAAoB,UAAQ;IAC5B,oBAAoB,SAAI;IACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAO;IACtC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IACjC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAO;IACpC,wBAAwB,UAAO;IAC/B,iBAAiB,UAAQ;gBAGhB,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,MAAM;IAGzB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,uBAAuB;CAYvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sketch-hq/sketch-web-renderer",
3
- "version": "14.8.0",
3
+ "version": "14.8.1",
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": "14.8.0",
55
+ "@sketch-hq/sketch-file-format-marina": "14.8.1",
56
56
  "@types/node": "18.16.0",
57
57
  "@types/offscreencanvas": "2019.7.0",
58
58
  "@types/pixelmatch": "5.2.4",