@sketch-hq/sketch-web-renderer 7.6.8 → 7.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/module-debug.wasm +0 -0
- package/dist/module-release.wasm +0 -0
- package/dist/ts/canvas-renderer/CanvasRenderer.d.ts +5 -30
- package/dist/ts/canvas-renderer/CanvasRenderer.d.ts.map +1 -1
- package/dist/ts/canvas-renderer/CanvasSettings.d.ts +65 -0
- package/dist/ts/canvas-renderer/CanvasSettings.d.ts.map +1 -0
- package/dist/ts/canvas-renderer/react/CanvasRendererProvider.d.ts.map +1 -1
- package/dist/ts/canvas-renderer/react/CanvasRendererReact.d.ts +4 -3
- package/dist/ts/canvas-renderer/react/CanvasRendererReact.d.ts.map +1 -1
- package/dist/ts/canvas-renderer/react/types.d.ts +2 -2
- package/dist/ts/canvas-renderer/react/types.d.ts.map +1 -1
- package/dist/ts/prototype-renderer/react/PrototypeRendererReact.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{createContext as t,useContext as n,useRef as o,useReducer as r,useCallback as i,useMemo as a,useEffect as s,useState as u}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 l(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 d=function(){return d=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},d.apply(this,arguments)};function h(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 p(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 g(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 f=["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 m(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 y="undefined"==typeof window,b=(()=>{if(y)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 w extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const C=[],P=[];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,c=0,l=0,d=0;for(;l<o;)P[l]=e.charCodeAt(a+l),C[l]=++l;for(;d<r;)for(i=t.charCodeAt(a+d),s=d++,c=d,l=0;l<o;l++)u=i===P[l]?s:s+1,s=C[l],c=C[l]=s>c?u>c?c+1:u:u>s?s+1:u;return c}function E(e){return null!=e}const L=({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"}={})=>g(void 0,void 0,void 0,(function*(){const a={};if(y)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==b?void 0:b.isIpad),isMobile:u=!!(null==b?void 0:b.isMobile),screenSize:c=window.screen,loadBenchmarks:l=(e=>g(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 w("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,v="";if(d)d=m(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==b?void 0:b.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");v=d,d=m(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==b?void 0:b.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 C=(yield Promise.all(p.map((function(e){var t;return g(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:l(o);let i;try{i=yield r}catch(n){if(n instanceof w)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 v=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let g,[f,,,,m]=p>1?h.map((e=>[e,M(v,e[2])])).sort((([,e],[,t])=>e-t))[0][0]:h[0],y=Number.MAX_VALUE;const{devicePixelRatio:b}=window,C=c.width*b*c.height*b;for(const e of m){const[t,n]=e,o=t*n,r=Math.abs(C-o);r<y&&(y=r,g=e)}if(!g)return;const[,,P,E]=g;return[y,P,f,E]}))})))).filter(E).sort((([e=Number.MAX_VALUE,t],[n=Number.MAX_VALUE,o])=>e===n?t-o:e-n));if(!C.length){const e=f.find((e=>d.includes(e)));return e?h(0,"BLOCKLISTED",e):h(1,"FALLBACK",`${d} (${v})`)}const[,P,L,x]=C[0];if(-1===P)return h(0,"BLOCKLISTED",L,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",L,P,x)}));var x,R,W=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 l(t,e),t}(Error);function S(e){return void 0!==e}!function(e){e.debug="debug",e.release="release"}(x||(x={})),function(e){e.Fit="Fit",e.FitWidth="FitWidth",e.ActualSize="ActualSize"}(R||(R={}));var T=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(){this.removeListenerCallbacks=[]}return e.prototype.add=function(e,t,n,o){e.addEventListener(t,n,o);var r=function(){e.removeEventListener(t,n,o)};return this.removeListenerCallbacks.push(r),r},e.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(e){return e()}))},e}(),D={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1},F=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},U=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,A=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(U);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 G(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 B(e,t,n){return Math.max(t,Math.min(n,e))}function z(){return A()&&!D.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function Z(e){for(var t=e.size(),n=[],o=0;o<t;++o){var r=e.get(o);if(null==r)throw Error("Error converting embind vector to array");n.push(r)}return n}function _(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function O(e){var t=d({},e);return Object.keys(t).forEach((function(e){void 0===t[e]&&delete t[e]})),t}function j(e){return _()?{onTouchEnd:e}:{onClick:e}}var N=function(e){function t(t){var n=e.call(this)||this;return n.listenersCollector=new I,n.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},n.handleGestureStart=function(e){e.preventDefault(),n.state.lastGestureScale=e.scale},n.handleGestureChange=function(e){e.preventDefault();var t=e.scale/n.state.lastGestureScale;n.state.lastGestureScale=e.scale;var o=n.getCorrectPointerPosition(e);n.emitZoomEvent(t,o)},n.handleGestureEnd=function(e){e.preventDefault()},n.handleTouchStart=function(e){e.preventDefault(),n.handleTouchPinchToZoomStart(e),n.emit("pointerdown",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleMouseDown=function(e){e.ctrlKey||(e.preventDefault(),n.emit("pointerdown",{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0}))},n.handleTouchMove=function(e){n.handleTouchPinchToZoomChange(e),n.emit("pointermove",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleMouseMove=function(e){n.updateMousePosition(e)},n.handleGlobalTouchMove=function(e){n.emit("globalpointermove",{type:"touch",position:n.getCorrectPointerPosition(e),button:0,touchesCount:e.touches.length})},n.handleGlobalMouseMove=function(e){n.updateGlobalMousePosition(e)},n.handleTouchPinchToZoomStart=function(e){var t;!e.touches||(null===(t=e.touches)||void 0===t?void 0:t.length)<2||(n.state.pinchToZoomLastDistance=n.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]))},n.handleTouchPinchToZoomChange=function(e){var t;if(e.touches&&!((null===(t=e.touches)||void 0===t?void 0:t.length)<2)){var o=n.calculateDistanceBetweenTouches(e.touches[0],e.touches[1]),r=n.getCorrectPointerPosition(e),i=1+.004*(o-n.state.pinchToZoomLastDistance);n.state.pinchToZoomLastDistance=o,n.emitZoomEvent(i,r)}},n.handleTouchEnd=function(e){var t=n.getCorrectPointerPosition(e);n.emit("pointerup",{position:t,type:"touch",button:0,touchesCount:e.touches.length})},n.handleMouseUp=function(e){n.emit("pointerup",{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.handleMouseWheel=function(e){e.preventDefault();var t=e.ctrlKey&&!n.state.isCtrlPressed,o=e.metaKey||t||n.state.isCtrlPressed;if(n.updateMousePosition(e),n.updateGlobalMousePosition(e),o){var r=t?-1:1,i=n.getCorrectPointerPosition(e),a=1+.005*e.deltaY*r;n.emitZoomEvent(a,i)}else n.emit("wheel",{x:-e.deltaX,y:-e.deltaY},{type:"mouse",position:n.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},n.target=t,n.targetBounds=t.getBoundingClientRect(),n.addListeners(),n}return l(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},t.prototype.addKeyboardEventListeners=function(){var e=this;this.listenersCollector.add(document,"keydown",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(t){"Control"===t.key&&(e.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(t){t.ctrlKey&&(e.state.isCtrlPressed=!1)}))},t.prototype.addMouseEventListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handleMouseDown),this.listenersCollector.add(this.target,"mousemove",this.handleMouseMove),this.listenersCollector.add(document,"mousemove",this.handleGlobalMouseMove),this.listenersCollector.add(document,"mouseup",this.handleMouseUp),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel)},t.prototype.addTouchEventListeners=function(){this.listenersCollector.add(this.target,"touchstart",this.handleTouchStart),this.listenersCollector.add(document,"touchmove",this.handleGlobalTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(this.target,"touchmove",this.handleTouchMove,{passive:!0,capture:!0}),this.listenersCollector.add(document,"touchcancel",this.handleTouchEnd),this.listenersCollector.add(document,"touchend",this.handleTouchEnd)},t.prototype.addSafariGesturesEventListeners=function(){_()||(this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart,{capture:!0}),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange,{capture:!0}),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd,{capture:!0}))},t.prototype.clampPointerToTargetBounds=function(e){return{x:e.x-this.targetBounds.x,y:e.y-this.targetBounds.y}},t.prototype.getCorrectPointerPosition=function(e){var t,n={x:0,y:0};if((null===(t=e.touches)||void 0===t?void 0:t.length)>1){var o=e,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=G(e);return this.clampPointerToTargetBounds(n)},t.prototype.updateMousePosition=function(e){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},t.prototype.updateGlobalMousePosition=function(e){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(e),button:e.button,touchesCount:0})},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()},t}(T),H=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 l(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(T),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 X(e){setTimeout((function(){e()}),0)}var Y=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(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}(T)),J=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 l(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 B(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}(T),V=function(){function e(e){this.settings=e}return e.prototype.isReleaseMode=function(){return this.settings.mode===x.release},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var e,t,n,o,r,i=this;return p(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:z(),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 W("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerType.Unset,mouse:this.instance.PRUserPointerType.Mouse,touch:this.instance.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorType.Auto.value]="auto",r[this.instance.PRCursorType.Default.value]="default",r[this.instance.PRCursorType.Pointer.value]="pointer",r[this.instance.PRCursorType.Grab.value]="grab",r[this.instance.PRCursorType.Grabbing.value]="grabbing",r),this.prototypeResizeModeToWASMMap={Fit:this.instance.PrototypeResizeMode.Fit,FitWidth:this.instance.PrototypeResizeMode.FitWidth,ActualSize:this.instance.PrototypeResizeMode.ActualSize},[2]}}))}))},e.prototype.makeWebGLContext=function(e,t){var n;void 0===t&&(t={});var o=d({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 W("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;Y.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(),Y.logDebug("WebGL destroyed"),!0;Y.logError("WEBGL_lose_context not available. Not possible to destroy WebGL context manually.")}else Y.logError("WebGL context not found while trying to destroy it")},e.prototype.importModule=function(){return this.isReleaseMode()?import("./module-release-4773acfa.js"):import("./module-debug-2361a8e7.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.PRUserPointerType.Unset},e.prototype.mapPointerInfo=function(e){return d(d({},e),{type:this.mapToPRPointerType(e.type)})},e.prototype.mapResizeMode=function(e){return this.prototypeResizeModeToWASMMap[e]},e}();function $(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 q=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=d(d({backgroundColor:{r:1,g:1,b:1,a:1},showTilesBorders:!1,preserveDrawingBuffer:!1,panBoundariesPadding:0},O(t)),{featureFlags:d(d({},D),t.featureFlags)}),n.gestureManager=new N(n.settings.container),n.canvasManager=new J({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new V({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return l(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 h(this,void 0,void 0,(function(){var e;return p(this,(function(t){switch(t.label){case 0:return[4,L()];case 1:return e=t.sent(),this.deviceInfo=d(d({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var e;return p(this,(function(t){switch(t.label){case 0:this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.initWasmModule()];case 2:return t.sent(),[4,this.initCanvasRendererWasm()];case 3:return t.sent(),[4,this.setFile(this.settings.filePath)];case 4:return t.sent(),this.settings.selectedArtboard&&this.selectArtboard(this.settings.selectedArtboard),[3,6];case 5:return e=t.sent(),[2,this.fail(e instanceof W?e:new W("ERROR","Unexpected exception initializing the web renderer",e))];case 6:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.setInitialCameraState=function(){var e,t,n,o=void 0!==this.settings.initialZoom,r=void 0!==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){Y.logDebug("[C++] ".concat(e))},logWarning:function(e){Y.logWarning("[C++] ".concat(e))},logError:function(e){Y.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t]:e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t):(Y.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):(Y.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),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeStateChange:function(){},onPrototypeUnhandledPointerUp:function(){},onPrototypeSceneChange:function(){}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return h(n,void 0,void 0,(function(){var n,i,a,s,u,c,l,d,h;return p(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,$(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),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];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return Y.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(c=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==c?c:500,statusText:null!==(d=null===(l=t.data.error)||void 0===l?void 0:l.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 h(this,void 0,void 0,(function(){var t;return p(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(t=new K("WasmModuleDownload"),[4,null===(e=this.wasmModule)||void 0===e?void 0:e.init()]);case 1:return n.sent(),Y.logDebug(t.printMeasurement()),this.emit("metric",t.measure()),[2]}}))}))},t.prototype.initCanvasRendererWasm=function(){return h(this,void 0,void 0,(function(){var e;return p(this,(function(t){if(this.disposed)return[2];try{if(!this.wasmModule)throw Error("WASM module not initialized");e=z(),Y.logDebug("Using WebGL ".concat(e)),this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:e}),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.CanvasRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(e){throw new W("WASM_ERROR","An error occurred while trying to create the wasm object.",e)}return this.userEventsCollectorWasm=this.pageCanvasWasm.getUserEventsCollector(),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.generateDocumentPNG=function(){var e;return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},t.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(Y.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),Y.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))||Y.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},t.prototype.zoomToFit=function(){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.scaleDocumentToFit()},t.prototype.setFile=function(e){return h(this,void 0,void 0,(function(){var t=this;return p(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("7.6.8");t.emit("fileReady",t.getDocument(),i,o,r),n()}),(function(){return o(new W("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()):"")}),Y.logError(e),e.cause&&Y.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(Y.logDebug("Status transition ".concat(this.status.type," => ").concat(e.type)),this.status=e,this.emit("status",e))},t.prototype.getDocument=function(){if(!this.pageCanvasWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var e=this.pageCanvasWasm.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},e),{artboards:Z(e.artboards)})}}return this.cachedDocumentInfo.document},t.prototype.getArtboardAtPosition=function(e,t){if(this.pageCanvasWasm){var n=this.getDocument();if(n){for(var o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(e-o.x)/r,a=(t-o.y)/r,s=0,u=n.artboards;s<u.length;s++){var c=u[s],l=c.bounds.x+c.bounds.width,d=c.bounds.y+c.bounds.height;if(i>=c.bounds.x&&a>=c.bounds.y&&i<=l&&a<=d)return c.objectId}return null}}},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.getDocument().bounds,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=e,i=t,a=this.getDocument().bounds,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);r+=this.canvasManager.size.width/u,i+=this.canvasManager.size.height/u}var c=(r-a.x)*s,l=(i-a.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(c,l)},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.dispose=function(){var e,t,n,o;try{this.disposed=!0,this.detachAllListeners(),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.disposeFetchWorker(),this.pageCanvasWasm=void 0,this.wasmModule=void 0}catch(e){this.fail(new W("ERROR","Unexpected exception while disposing the wasm object",e))}},t}(T),Q=t(void 0),ee=t(void 0),te=t(void 0),ne=t(void 0),oe=t(void 0),re=t(void 0),ie=t("auto"),ae=t(void 0),se=function(){var e=n(ae);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},ue=function(e,t){switch(t.type){case"on-status":return d(d({},e),{status:t.status});case"on-file-ready":return d(d({},e),{document:t.document});case"on-zoom":return d(d({},e),{zoom:t.zoom});case"on-pan":return d(d({},e),{pan:t.pan});case"dispose":return d(d({},e),{status:{type:"DISPOSED"},zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return d(d({},e),{isCameraZooming:!0});case"on-camera-zoom-end":return d(d({},e),{isCameraZooming:!1});case"on-camera-move-start":return d(d({},e),{isCameraMoving:!0});case"on-camera-move-end":return d(d({},e),{isCameraMoving:!1});case"on-cursor-change":return d(d({},e),{cursor:t.cursor});default:return e}},ce=function(t){var n=o(null),s=o(null),u=r(ue,{pan:null,zoom:null,status:{type:"IDLE"},document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),c=u[0],l=c.status,h=c.document,p=c.zoom,v=c.pan,g=c.isCameraZooming,f=c.isCameraMoving,m=c.cursor,y=u[1],b=i((function(e){return y({type:"on-zoom",zoom:e})}),[]),w=i((function(e,t){return y({type:"on-pan",pan:{x:e,y:t}})}),[]),C=i((function(e){y({type:"on-status",status:e})}),[]),P=i((function(e){y({type:"on-file-ready",document:e})}),[]),M=i((function(){return y({type:"on-camera-zoom-start"})}),[]),E=i((function(){return y({type:"on-camera-zoom-end"})}),[]),L=i((function(){return y({type:"on-camera-move-start"})}),[]),x=i((function(){return y({type:"on-camera-move-end"})}),[]),R=i((function(e){return y({type:"on-cursor-change",cursor:e})}),[]),W=i((function(){var e=n.current;e&&(Y.logDebug("Provider dispose"),e.off("status",C),e.off("fileReady",P),e.off("cameraZoomChange",b),e.off("cameraPanChange",w),e.off("cameraZoomStart",M),e.off("cameraZoomEnd",E),e.off("cameraMoveStart",L),e.off("cameraMoveEnd",x),e.off("cursorChange",R),e.dispose(),n.current=null,y({type:"dispose"}))}),[C,P,w,b,M,E,L,x,R]),S=i((function(e,t,o){if(""!==e&&t&&o&&s.current){Y.logDebug("Provider init");var r=new q(d(d({},s.current),{filePath:e,container:o,canvas:t,manualInitialization:!0}));r.on("status",C),r.on("fileReady",P),r.on("cameraZoomChange",b),r.on("cameraPanChange",w),r.on("cameraZoomStart",M),r.on("cameraZoomEnd",E),r.on("cameraMoveStart",L),r.on("cameraMoveEnd",x),r.on("cursorChange",R),n.current=r,r.init()}}),[C,P,b,w,M,E,L,x,R]),T=i((function(e){var t,o;Y.logDebug("Provider setSettings",e),e.backgroundColor&&(null===(t=n.current)||void 0===t||t.setBackgroundColor(e.backgroundColor)),null===(o=n.current)||void 0===o||o.selectArtboard(e.selectedArtboard),s.current=e}),[]),I=i((function(){return n.current}),[]),D=a((function(){return{dispose:W,init:S,setSettings:T,getInstance:I,dispatch:y}}),[W,S,T,I]);return e.createElement(ae.Provider,{value:D},e.createElement(Q.Provider,{value:l},e.createElement(ee.Provider,{value:h},e.createElement(te.Provider,{value:p},e.createElement(re.Provider,{value:v},e.createElement(ne.Provider,{value:g},e.createElement(oe.Provider,{value:f},e.createElement(ie.Provider,{value:m},t.children))))))))},le=function(){var e=n(Q);if(void 0===e)throw Error("useStatus must be used within a provider");return e},de=function(){var e=n(ee);if(void 0===e)throw Error("useDocument must be used within a provider");return e},he=function(){var e=n(te);if(void 0===e)throw Error("useZoom must be used within a provider");return e},pe=function(){var e=n(re);if(void 0===e)throw Error("usePan must be used within a provider");return e},ve=function(){var e=n(ie);if(void 0===e)throw Error("useCursor must be used within a provider");return e},ge=function(){var e=n(ne);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return e},fe=function(){var e=n(oe);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return e},me=function(){var e=(0,se().getInstance)();return i((function(t){null==e||e.setZoom(t)}),[e])},ye=function(){var e=me(),t=he();return i((function(){var n;"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},be=function(){var e=me(),t=he();return i((function(){"number"==typeof t&&e(t/2)}),[e,t])},we=function(){var e=(0,se().getInstance)();return i((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;null==e||e.setPan(n,o,r)}),[e])},Ce=function(){var e=(0,se().getInstance)();return i((function(){null==e||e.zoomToFit()}),[e])},Pe=function(){var e=(0,se().getInstance)();return i((function(){null==e||e.looseWebGLContext()}),[e])},Me=function(){var e=(0,se().getInstance)();return i((function(){return h(void 0,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,null==e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[e])},Ee=function(){var e=(0,se().getInstance)();return i((function(t,n){return h(void 0,void 0,void 0,(function(){return p(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])},Le=function(){var e=(0,se().getInstance)();return i((function(t,n){return h(void 0,void 0,void 0,(function(){return p(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])},xe=function(){var e=(0,se().getInstance)();return i((function(t){null==e||e.setIsCameraLocked(t)}),[e])},Re=function(e,t){var n=(0,se().getInstance)();s((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function We(e){var t=o(e);t.current=e;var n=i((function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];t.current.apply(t,v([e],n,!1))}),[]);s((function(){return Y.on("log",n),function(){Y.off("log",n)}}),[n])}var Se={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},Te={position:"absolute",top:0,left:0},Ie=function(t){var n=t.filePath,r=t.locateFile,c=t.imagesURLFormat,l=t.imagesURLMap,h=t.fragmentsURLFormat,p=t.fragmentsURLMap,v=t.backgroundColor,g=t.mode,f=t.showTilesBorders,m=t.minimumZoomLevel,y=t.maximumZoomLevel,b=t.preserveDrawingBuffer,w=t.panBoundariesPadding,C=t.initialPan,P=t.initialZoom,M=t.children,E=t.containerProps,L=void 0===E?{}:E,x=t.canvasProps,R=void 0===x?{}:x,W=t.featureFlags,S=void 0===W?{}:W,T=t.selectedArtboard,I=o(null),D=o(null),F=u(!1),U=F[0],A=F[1],k=i((function(){return A(!0)}),[]),G=se(),B=G.dispose,z=G.init,Z=G.setSettings,_=ve(),O=le();Re("allImagesReady",k),s((function(){return Y.logDebug("WebRenderer mounted"),function(){return Y.logDebug("WebRenderer unmounted")}}),[]),s((function(){Z({locateFile:r,imagesURLFormat:c,imagesURLMap:l,fragmentsURLFormat:h,fragmentsURLMap:p,backgroundColor:v,mode:g,showTilesBorders:f,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:b,panBoundariesPadding:w,initialPan:C,initialZoom:P,featureFlags:S,selectedArtboard:T})}),[Z,r,c,l,h,p,v,g,f,m,y,b,w,C,P,S,T]),s((function(){if(n)return z(n,I.current,D.current),function(){B()}}),[B,z,n]);var j=a((function(){var e;return null!==(e=t.cursor)&&void 0!==e?e:_}),[t.cursor,_]),N=a((function(){return d(d({},Se),{cursor:j})}),[j]);return e.createElement("div",d({},L,{ref:D,style:N}),n&&e.createElement("canvas",d({},R,{key:n,ref:I,"data-sketchweb-all-images-ready":U,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==O?void 0:O.type.toLowerCase())||"null"),style:Te})),"READY"===(null==O?void 0:O.type)&&M)},De=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=x.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=D,this.manualInitialization=!1,this.highlightHotspots=!0,this.resizeMode=R.Fit,this.assetsManagerLimits={maxDepthForBackgroundRequests:1,maxArtboardsForBackgroundRequests:5,maxInitialLoadingDepth:2,maxInitialArtboardToLoad:10}}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}(),Fe=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(){var e,t=null===(e=n.playerWasm)||void 0===e?void 0:e.getJSScreen();return t?{layers:Z(t.layers)}:{layers:[]}},n.settings=De.FromSettings(t),Y.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new N(n.settings.container),n.canvasManager=new J({container:n.settings.container,canvas:n.settings.canvas,maxPixelRatio:3}),n.wasmModule=new V({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return l(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 h(this,void 0,void 0,(function(){var e;return p(this,(function(t){switch(t.label){case 0:return[4,L()];case 1:return e=t.sent(),this.deviceInfo=d(d({},e),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var e;return p(this,(function(t){switch(t.label){case 0:this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),this.collectAndEmitDeviceInfo(),t.label=1;case 1:return t.trys.push([1,5,,6]),[4,this.initWasmModule()];case 2:return t.sent(),[4,this.initPlayerWasm()];case 3:return t.sent(),[4,this.startDownload()];case 4:return t.sent(),[3,6];case 5:return e=t.sent(),[2,this.fail(e instanceof W?e:new W("ERROR","Unexpected exception initializing the web renderer",e))];case 6:return this.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initWasmModule=function(){var e;return h(this,void 0,void 0,(function(){var t;return p(this,(function(n){switch(n.label){case 0:return t=new K("WasmModuleDownload"),[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){Y.logDebug("[C++] ".concat(e))},logWarning:function(e){Y.logWarning("[C++] ".concat(e))},logError:function(e){Y.logError("[C++] ".concat(e))},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.settings.imagesURLMap&&e.settings.imagesURLMap[t]?e.settings.imagesURLMap[t]:e.settings.imagesURLFormat?e.settings.imagesURLFormat.replace(":imageId",t):(Y.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):(Y.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)},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")},onPrototypeSceneChange:function(){e.emit("prototypeSceneChange")}}},t.prototype.handleJSBridgeFetch=function(e,t){var n=this,o=t.clone(),r=function(t){return h(n,void 0,void 0,(function(){var n,i,a,s,u,c,l,d,h;return p(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,$(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),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];case 3:n.buffer=new Uint8Array(t.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return Y.logError("Error while fetching ".concat(e),t.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(c=null===(u=t.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==c?c:500,statusText:null!==(d=null===(l=t.data.error)||void 0===l?void 0:l.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 h(this,void 0,void 0,(function(){var n,o,r,i,a,s,u,c,l,h,v,g,f,m,y,b,w,C;return p(this,(function(p){try{if(!this.wasmModule)throw Error("WASM module not initialized");for(this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:z()}),n=this.wasmModule.instance,o=n.RenderTarget,r=n.PrototypeRenderer,i=n.PrototypeStructureArtboardVector,a=n.PrototypeStructureFlowVector,s=n.PrototypeStructureAssetVector,this.renderTarget=o.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),u={artboards:new i},c=0,l=this.settings.prototypeStructure.artboards;c<l.length;c++){for(h=l[c],v=new a,g=0,f=null!==(e=h.flows)&&void 0!==e?e:[];g<f.length;g++)m=f[g],v.push_back(m);for(y=new s,b=0,w=null!==(t=h.assets)&&void 0!==t?t:[];b<w.length;b++)C=w[b],y.push_back(C);u.artboards.push_back(d(d({},h),{flows:v,assets:y}))}this.playerWasm=new r(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID,u,this.settings.highlightHotspots,this.settings.assetsManagerLimits)}catch(e){throw new W("WASM_ERROR","An error occurred while trying to create the PrototypeRenderer WASM object.",e)}return this.userEventsCollectorWasm=this.playerWasm.getUserEventsCollector(),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()):"")}),Y.logError(e),e.cause&&Y.logError(e.cause)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(Y.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.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},t.prototype.dispose=function(){var e,t,n;try{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.disposeFetchWorker(),this.playerWasm=void 0,this.wasmModule=void 0,this.disposed=!0}catch(e){this.fail(new W("ERROR","Unexpected exception while disposing the WebRendererWasm object",e))}},t}(T),Ue=t(void 0),Ae=t("auto"),ke=t(void 0),Ge=t(void 0),Be=t(void 0),ze=t(void 0),Ze=function(){var e=n(ze);if(void 0===e)throw Error("useInternalContext must be used within a provider");return e},_e=function(e,t){switch(t.type){case"on-status":return d(d({},e),{status:t.status});case"dispose":return d(d({},e),{status:{type:"DISPOSED"},cursor:"auto"});case"on-cursor-change":return d(d({},e),{cursor:t.cursor});case"on-prototype-state-change":return d(d({},e),{prototypeState:d(d({},e.prototypeState),t.prototypeState)});case"on-zoom":return d(d({},e),{zoom:t.zoom});case"on-pan":return d(d({},e),{pan:{x:t.pan.x,y:t.pan.y}});default:return e}},Oe=function(t){var n=o(null),s=o(null),u=r(_e,{status:{type:"IDLE"},cursor:"auto",prototypeState:{currentArtboardId:"",canGoBack:!1,canGoForwards:!1},zoom:1,pan:{x:0,y:0}}),c=u[0],l=c.status,h=c.cursor,p=c.prototypeState,v=c.zoom,g=c.pan,f=u[1],m=i((function(e){f({type:"on-status",status:e})}),[]),y=i((function(e){return f({type:"on-zoom",zoom:e})}),[]),b=i((function(e,t){return f({type:"on-pan",pan:{x:e,y:t}})}),[]),w=i((function(e){return f({type:"on-cursor-change",cursor:e})}),[]),C=i((function(e){return f({type:"on-prototype-state-change",prototypeState:e})}),[]),P=i((function(){var e=n.current;e&&(Y.logDebug("Provider dispose"),e.off("status",m),e.off("cursorChange",w),e.off("prototypeStateChange",C),e.off("cameraZoomChange",y),e.off("cameraPanChange",b),e.dispose(),n.current=null,f({type:"dispose"}))}),[m,w,C,b,y]),M=i((function(e,t){if(e&&t&&s.current){Y.logDebug("Provider init");var o=new Fe(d(d({},s.current),{container:t,canvas:e,manualInitialization:!0}));o.on("status",m),o.on("cursorChange",w),o.on("prototypeStateChange",C),o.on("cameraZoomChange",y),o.on("cameraPanChange",b),n.current=o,o.init()}}),[m,w,C,b,y]),E=i((function(e){var t,o,r,i;Y.logDebug("Provider setSettings"),e.backgroundColor&&e.backgroundColor!=(null===(t=s.current)||void 0===t?void 0:t.backgroundColor)&&(null===(o=n.current)||void 0===o||o.setBackgroundColor(e.backgroundColor)),(null===(r=s.current)||void 0===r?void 0:r.resizeMode)!=e.resizeMode&&(null===(i=n.current)||void 0===i||i.setResizeMode(e.resizeMode||R.Fit)),s.current=e}),[]),L=i((function(){return n.current}),[]),x=a((function(){return{dispose:P,init:M,setSettings:E,getInstance:L,dispatch:f}}),[P,M,E,L]);return e.createElement(ze.Provider,{value:x},e.createElement(Ue.Provider,{value:l},e.createElement(Ae.Provider,{value:h},e.createElement(ke.Provider,{value:p},e.createElement(Ge.Provider,{value:v},e.createElement(Be.Provider,{value:g},t.children))))))},je=function(){var e=(0,Ze().getInstance)();return i((function(t){null==e||e.restartPrototype(t)}),[e])},Ne=function(){var e=(0,Ze().getInstance)();return i((function(){null==e||e.navigateToFirstFlow()}),[e])},He=function(){var e=(0,Ze().getInstance)();return i((function(){null==e||e.goBack()}),[e])},Ke=function(){var e=(0,Ze().getInstance)();return i((function(){null==e||e.goForwards()}),[e])},Xe=function(){var e=n(Ue);if(void 0===e)throw Error("usePrototypeStatus must be used within a provider");return e},Ye=function(){var e=n(Ae);if(void 0===e)throw Error("usePrototypeCursor must be used within a provider");return e},Je=function(){var e=n(ke);if(void 0===e)throw Error("usePrototypeState must be used within a provider");return e},Ve=function(){var e=n(Ge);if(void 0===e)throw Error("usePrototypeZoom must be used within a provider");return e},$e=function(){var e=n(Be);if(void 0===e)throw Error("usePrototypePan must be used within a provider");return e},qe=function(e,t){var n=(0,Ze().getInstance)();s((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])};function Qe(){var e=(0,Ze().getInstance)();return i((function(){return null==e?void 0:e.getScreen()}),[e])}var et={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},tt={position:"absolute",top:0,left:0},nt=function(t){var n=t.locateFile,r=t.imagesURLFormat,i=t.imagesURLMap,u=t.backgroundColor,c=t.mode,l=t.showTilesBorders,h=t.minimumZoomLevel,p=t.maximumZoomLevel,v=t.preserveDrawingBuffer,g=t.children,f=t.containerProps,m=t.canvasProps,y=t.featureFlags,b=t.startArtboardUUID,w=t.prototypeStructure,C=t.fragmentsURLFormat,P=t.fragmentsURLMap,M=t.highlightHotspots,E=t.resizeMode,L=t.assetsManagerLimits,x=o(null),R=o(null),W=Ze(),S=W.dispose,T=W.init,I=W.setSettings,D=Ye(),F=Xe();s((function(){I({locateFile:n,imagesURLFormat:r,imagesURLMap:i,backgroundColor:u,mode:c,showTilesBorders:l,minimumZoomLevel:h,maximumZoomLevel:p,preserveDrawingBuffer:v,featureFlags:y,startArtboardUUID:b,prototypeStructure:w,fragmentsURLFormat:C,fragmentsURLMap:P,highlightHotspots:M,resizeMode:E,assetsManagerLimits:L})}),[I,n,r,i,u,c,l,h,p,v,y,b,M,E,C,P,w,L]),s((function(){return T(x.current,R.current),function(){S()}}),[S,T]);var U=a((function(){return d(d({},et),{cursor:D})}),[D]);return e.createElement("div",d({},f,{ref:R,style:U}),e.createElement("canvas",d({},m,{ref:x,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==F?void 0:F.type.toLowerCase())||"null"),style:tt})),"READY"===(null==F?void 0:F.type)&&g)},ot={position:"absolute",inset:0,pointerEvents:"none"};function rt(t){var n=t.visualize,o=void 0!==n&&n,r=Qe(),s=u((function(){return r()||null})),c=s[0],l=s[1],h=i((function(){l(r()||null)}),[r]);qe("prototypeSceneChange",h);var p=a((function(){return d(d({},ot),{opacity:o?1:0})}),[o]);return c?e.createElement("div",{style:p},c.layers.map((function(t,n){return e.createElement(it,d({key:"".concat(n,"/").concat(t.id)},t))}))):null}function it(t){var n=t.bounds,o=t.name,r=t.id,i=t.type,s=Ve(),u=$e()||{x:0,y:0},c=u.x,l=u.y,h=a((function(){return d({position:"absolute",left:c/window.devicePixelRatio+n.x*s,top:l/window.devicePixelRatio+n.y*s,width:n.width*s,height:n.height*s,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,c,l,s,i]);return e.createElement("div",{style:h,"data-testid":"".concat(i,"-").concat(at(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 at(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{oe as CameraMoveContext,ne as CameraZoomingContext,q as CanvasRenderer,ce as CanvasRendererProvider,Ie as CanvasRendererReact,ie as CursorContext,D as DefaultFeatureFlags,ee as DocumentContext,T as EventEmitter,N as GestureManager,H as KeyboardManager,I as ListenersCollector,re as PanContext,K as Performance,Fe as PrototypeRenderer,Oe as PrototypeRendererProvider,nt as PrototypeRendererReact,R as PrototypeResizeMode,rt as PrototypeTestOverlay,Q as StatusContext,W as WebRendererError,x as WebRendererMode,te as ZoomContext,B as clamp,Z as convertEmbindVectorToArray,k as debounce,G as extractPointer,z as getSupportedWebGLVersion,F as getiOSVersion,S as isDefinedPresentationManifestArtboard,_ as isTouchDevice,Y as logger,X as nextTick,A as parseSafariUserAgent,ue as reducer,O as removeUndefinedKeys,j as touchableClick,ve as useCursor,be as useDecrementZoom,de as useDocument,Re as useEvent,Me as useGenerateDocumentPNG,Ee as useGetArtboardAtPosititon,Le as useGetPanAtPosition,Qe as useGetScreen,He as useGoBack,Ke as useGoForwards,ye as useIncrementZoom,fe as useIsCameraMoving,ge as useIsCameraZooming,xe as useLockCamera,We as useLogEvent,Pe as useLooseWebGLContext,Ne as useNavigateToFirstFlow,pe as usePan,Ye as usePrototypeCursor,qe as usePrototypeEvent,$e as usePrototypePan,Je as usePrototypeState,Xe as usePrototypeStatus,Ve as usePrototypeZoom,je as useRestartPrototype,we as useSetPan,me as useSetZoom,le as useStatus,he as useZoom,Ce as useZoomToFit};
|
|
1
|
+
import t,{createContext as e,useContext as n,useRef as o,useReducer as r,useCallback as i,useMemo as a,useEffect as s,useState as u}from"react";var c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var d=function(){return d=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},d.apply(this,arguments)};function h(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((o=o.apply(t,e||[])).next())}))}function p(t,e){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=e.call(t,a)}catch(t){s=[6,t],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 g(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function v(t,e,n,o){return new(n||(n=Promise))((function(r,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function s(t){try{u(o.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((o=o.apply(t,e||[])).next())}))}const f=["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 m(t){return t.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 y="undefined"==typeof window,b=(()=>{if(y)return;const{userAgent:t,platform:e,maxTouchPoints:n}=window.navigator,o=/(iphone|ipod|ipad)/i.test(t),r="iPad"===e||"MacIntel"===e&&n>0&&!window.MSStream;return{isIpad:r,isMobile:/android/i.test(t)||o||r,isSafari12:/Version\/12.+Safari/.test(t)}})();class w extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}const C=[],P=[];function M(t,e){if(t===e)return 0;const n=t;t.length>e.length&&(t=e,e=n);let o=t.length,r=e.length;for(;o>0&&t.charCodeAt(~-o)===e.charCodeAt(~-r);)o--,r--;let i,a=0;for(;a<o&&t.charCodeAt(a)===e.charCodeAt(a);)a++;if(o-=a,r-=a,0===o)return r;let s,u,c=0,l=0,d=0;for(;l<o;)P[l]=t.charCodeAt(a+l),C[l]=++l;for(;d<r;)for(i=e.charCodeAt(a+d),s=d++,c=d,l=0;l<o;l++)u=i===P[l]?s:s+1,s=C[l],c=C[l]=s>c?u>c?c+1:u:u>s?s+1:u;return c}function E(t){return null!=t}const L=({mobileTiers:t=[0,15,30,60],desktopTiers:e=[0,15,30,60],override:n={},glContext:o,failIfMajorPerformanceCaveat:r=!1,benchmarksURL:i="https://unpkg.com/detect-gpu@5.0.25/dist/benchmarks"}={})=>v(void 0,void 0,void 0,(function*(){const a={};if(y)return{tier:0,type:"SSR"};const{isIpad:s=!!(null==b?void 0:b.isIpad),isMobile:u=!!(null==b?void 0:b.isMobile),screenSize:c=window.screen,loadBenchmarks:l=(t=>v(void 0,void 0,void 0,(function*(){const e=yield fetch(`${i}/${t}`).then((t=>t.json()));if(parseInt(e.shift().split(".")[0],10)<4)throw new w("Detect GPU benchmark data is out of date. Please update to version 4x");return e})))}=n;let{renderer:d}=n;const h=(t,e,n,o,r)=>({device:r,fps:o,gpu:n,isMobile:u,tier:t,type:e});let p,g="";if(d)d=m(d),p=[d];else{const t=o||function(t,e=!1){const n={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:e,powerPreference:"high-performance",stencil:!1};t&&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==b?void 0:b.isSafari12,r);if(!t)return h(0,"WEBGL_UNSUPPORTED");const e=t.getExtension("WEBGL_debug_renderer_info");if(e&&(d=t.getParameter(e.UNMASKED_RENDERER_WEBGL)),!d)return h(1,"FALLBACK");g=d,d=m(d),p=function(t,e,n){return"apple gpu"===e?function(t,e,n){if(!n)return[e];const o=function(t){const e=t.createShader(35633),n=t.createShader(35632),o=t.createProgram();if(!(n&&e&&o))return;t.shaderSource(e,"\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 "),t.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 "),t.compileShader(e),t.compileShader(n),t.attachShader(o,e),t.attachShader(o,n),t.linkProgram(o),t.detachShader(o,e),t.detachShader(o,n),t.deleteShader(e),t.deleteShader(n),t.useProgram(o);const r=t.createBuffer();t.bindBuffer(34962,r),t.bufferData(34962,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),35044);const i=t.getAttribLocation(o,"aPosition");t.vertexAttribPointer(i,3,5126,!1,0,0),t.enableVertexAttribArray(i),t.clearColor(1,1,1,1),t.clear(16384),t.viewport(0,0,1,1),t.drawArrays(4,0,3);const a=new Uint8Array(4);return t.readPixels(0,0,1,1,6408,5121,a),t.deleteProgram(o),t.deleteBuffer(r),a.join("")}(t),r="801621810",i="8016218135",a="80162181161",s=(null==b?void 0:b.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((([,,t])=>t>=14)):(u=s.filter((([,t])=>t===o)),u.length||(u=s)),u.map((([t])=>`apple ${t} gpu`))}(t,e,n):[e]}(t,d,u)}const C=(yield Promise.all(p.map((function(t){var e;return v(this,void 0,void 0,(function*(){const n=(t=>{const e=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of e)if(t.includes(n))return n})(t);if(!n)return;const o=`${u?"m":"d"}-${n}${s?"-ipad":""}.json`,r=a[o]=null!==(e=a[o])&&void 0!==e?e:l(o);let i;try{i=yield r}catch(n){if(n instanceof w)throw n;return}const d=function(t){var e;const n=(t=t.replace(/\([^)]+\)/,"")).match(/\d+/)||t.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(e=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==e?e:""}(t);let h=i.filter((([,t])=>t===d));h.length||(h=i.filter((([e])=>e.includes(t))));const p=h.length;if(0===p)return;const g=t.split(/[.,()\[\]/\s]/g).sort().filter(((t,e,n)=>0===e||t!==n[e-1])).join(" ");let v,[f,,,,m]=p>1?h.map((t=>[t,M(g,t[2])])).sort((([,t],[,e])=>t-e))[0][0]:h[0],y=Number.MAX_VALUE;const{devicePixelRatio:b}=window,C=c.width*b*c.height*b;for(const t of m){const[e,n]=t,o=e*n,r=Math.abs(C-o);r<y&&(y=r,v=t)}if(!v)return;const[,,P,E]=v;return[y,P,f,E]}))})))).filter(E).sort((([t=Number.MAX_VALUE,e],[n=Number.MAX_VALUE,o])=>t===n?e-o:t-n));if(!C.length){const t=f.find((t=>d.includes(t)));return t?h(0,"BLOCKLISTED",t):h(1,"FALLBACK",`${d} (${g})`)}const[,P,L,x]=C[0];if(-1===P)return h(0,"BLOCKLISTED",L,P,x);const R=u?t:e;let W=0;for(let t=0;t<R.length;t++)P>=R[t]&&(W=t);return h(W,"BENCHMARK",L,P,x)}));var x,R,W=function(t){function e(n,o,r){var i=this.constructor,a=t.call(this,"(".concat(n,") ").concat(o))||this;return a.code=n,a.cause=r,a.name=e.name,Object.setPrototypeOf(a,i.prototype),a}return l(e,t),e}(Error);function S(t){return void 0!==t}!function(t){t.debug="debug",t.release="release"}(x||(x={})),function(t){t.Fit="Fit",t.FitWidth="FitWidth",t.ActualSize="ActualSize"}(R||(R={}));var T=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){var n,o;this.listeners[t]=null!==(n=this.listeners[t])&&void 0!==n?n:new Set,null===(o=this.listeners[t])||void 0===o||o.add(e)},t.prototype.off=function(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.delete(e)},t.prototype.forwardEvent=function(t,e){this.on(e,(function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,g([e],n,!1))}))},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var o=this.listeners[t];(null==o?void 0:o.size)&&o.forEach((function(t){Promise.resolve().then((function(){t.apply(void 0,e)}))}))},t.prototype.detachAllListeners=function(){this.listeners={}},t}(),I=function(){function t(){this.removeListenerCallbacks=[]}return t.prototype.add=function(t,e,n,o){t.addEventListener(e,n,o);var r=function(){t.removeEventListener(e,n,o)};return this.removeListenerCallbacks.push(r),r},t.prototype.dispose=function(){this.removeListenerCallbacks.forEach((function(t){return t()}))},t}(),D={delayedDraw:!0,offscreenCanvas:!1,useDirtyRectsRendering:!0,safariWebGL2:!1,pageBoundariesLimit:!1},F=function(t){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(t)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1},U=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,A=function(t){if(void 0===t&&(t=window.navigator.userAgent),t.includes("Chrome/")||t.includes("Chromium/")||t.includes("Opera/")||t.includes("Firefox/"))return null;var e=t.match(U);if(!e)return null;var n=e[1];return"Macintosh"!==n&&"iPad"!==n&&"iPhone"!==n?null:{hardware:n,version:{major:parseInt(e[4])||0,minor:parseInt(e[5])||0,patch:parseInt(e[6])||0}}};function k(t,e){var n;function o(){for(var o=[],r=0;r<arguments.length;r++)o[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){t.apply(void 0,o)}),e)}return o.cancel=function(){n&&clearTimeout(n)},o}function G(t){var e,n,o,r,i,a=null!==(n=null===(e=t.touches)||void 0===e?void 0:e[0])&&void 0!==n?n:null===(o=t.changedTouches)||void 0===o?void 0:o[0];return{x:null!==(r=null==a?void 0:a.clientX)&&void 0!==r?r:t.clientX,y:null!==(i=null==a?void 0:a.clientY)&&void 0!==i?i:t.clientY}}function z(t,e,n){return Math.max(e,Math.min(n,t))}function B(){return A()&&!D.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}function Z(t){for(var e=t.size(),n=[],o=0;o<e;++o){var r=t.get(o);if(null==r)throw Error("Error converting embind vector to array");n.push(r)}return n}function _(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function O(t){var e=d({},t);return Object.keys(e).forEach((function(t){void 0===e[t]&&delete e[t]})),e}function j(t){return _()?{onTouchEnd:t}:{onClick:t}}var N=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new I,n.state={pinchToZoomLastDistance:0,lastGestureScale:1,isCtrlPressed:!1},n.handleGestureStart=function(t){t.preventDefault(),n.state.lastGestureScale=t.scale},n.handleGestureChange=function(t){t.preventDefault();var e=t.scale/n.state.lastGestureScale;n.state.lastGestureScale=t.scale;var o=n.getCorrectPointerPosition(t);n.emitZoomEvent(e,o)},n.handleGestureEnd=function(t){t.preventDefault()},n.handleTouchStart=function(t){t.preventDefault(),n.handleTouchPinchToZoomStart(t),n.emit("pointerdown",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleMouseDown=function(t){t.ctrlKey||(t.preventDefault(),n.emit("pointerdown",{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0}))},n.handleTouchMove=function(t){n.handleTouchPinchToZoomChange(t),n.emit("pointermove",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleMouseMove=function(t){n.updateMousePosition(t)},n.handleGlobalTouchMove=function(t){n.emit("globalpointermove",{type:"touch",position:n.getCorrectPointerPosition(t),button:0,touchesCount:t.touches.length})},n.handleGlobalMouseMove=function(t){n.updateGlobalMousePosition(t)},n.handleTouchPinchToZoomStart=function(t){var e;!t.touches||(null===(e=t.touches)||void 0===e?void 0:e.length)<2||(n.state.pinchToZoomLastDistance=n.calculateDistanceBetweenTouches(t.touches[0],t.touches[1]))},n.handleTouchPinchToZoomChange=function(t){var e;if(t.touches&&!((null===(e=t.touches)||void 0===e?void 0:e.length)<2)){var o=n.calculateDistanceBetweenTouches(t.touches[0],t.touches[1]),r=n.getCorrectPointerPosition(t),i=1+.004*(o-n.state.pinchToZoomLastDistance);n.state.pinchToZoomLastDistance=o,n.emitZoomEvent(i,r)}},n.handleTouchEnd=function(t){var e=n.getCorrectPointerPosition(t);n.emit("pointerup",{position:e,type:"touch",button:0,touchesCount:t.touches.length})},n.handleMouseUp=function(t){n.emit("pointerup",{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},n.handleMouseWheel=function(t){t.preventDefault();var e=t.ctrlKey&&!n.state.isCtrlPressed,o=t.metaKey||e||n.state.isCtrlPressed;if(n.updateMousePosition(t),n.updateGlobalMousePosition(t),o){var r=e?-1:1,i=n.getCorrectPointerPosition(t),a=1+.005*t.deltaY*r;n.emitZoomEvent(a,i)}else n.emit("wheel",{x:-t.deltaX,y:-t.deltaY},{type:"mouse",position:n.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},n.target=e,n.targetBounds=e.getBoundingClientRect(),n.addListeners(),n}return l(e,t),e.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},e.prototype.addListeners=function(){this.addTouchEventListeners(),this.addMouseEventListeners(),this.addKeyboardEventListeners(),this.addSafariGesturesEventListeners()},e.prototype.addKeyboardEventListeners=function(){var t=this;this.listenersCollector.add(document,"keydown",(function(e){"Control"===e.key&&(t.state.isCtrlPressed=!0)})),this.listenersCollector.add(document,"keyup",(function(e){"Control"===e.key&&(t.state.isCtrlPressed=!1)})),this.listenersCollector.add(document,"contextmenu",(function(e){e.ctrlKey&&(t.state.isCtrlPressed=!1)}))},e.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)},e.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)},e.prototype.addSafariGesturesEventListeners=function(){_()||(this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart,{capture:!0}),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange,{capture:!0}),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd,{capture:!0}))},e.prototype.clampPointerToTargetBounds=function(t){return{x:t.x-this.targetBounds.x,y:t.y-this.targetBounds.y}},e.prototype.getCorrectPointerPosition=function(t){var e,n={x:0,y:0};if((null===(e=t.touches)||void 0===e?void 0:e.length)>1){var o=t,r=o.touches[0],i=o.touches[1];n={x:(r.clientX+i.clientX)/2,y:(r.clientY+i.clientY)/2}}else n=G(t);return this.clampPointerToTargetBounds(n)},e.prototype.updateMousePosition=function(t){this.emit("pointermove",{type:"mouse",position:this.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},e.prototype.updateGlobalMousePosition=function(t){this.emit("globalpointermove",{type:"mouse",position:this.getCorrectPointerPosition(t),button:t.button,touchesCount:0})},e.prototype.calculateDistanceBetweenTouches=function(t,e){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)},e.prototype.emitZoomEvent=function(t,e){this.emit("pinchToZoom",t,e)},e.prototype.dispose=function(){this.listenersCollector.dispose()},e}(T),H=function(t){function e(e){var n=t.call(this)||this;return n.listenersCollector=new I,n.handleKeyUp=function(t){n.emit("keyUp",t.code)},n.target=e,n.addListeners(),n}return l(e,t),e.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},e.prototype.dispose=function(){this.listenersCollector.dispose()},e}(T),K=function(){function t(t){this.label=t,this.startTime=performance.now(),this.startTimestamp=Date.now()}return t.prototype.measure=function(){return{duration:performance.now()-this.startTime,end:Date.now(),start:this.startTimestamp,id:this.label}},t.prototype.printMeasurement=function(){var t=this.measure().duration;if(t<1e3){var e=t.toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(e," ms")}var n=(t/1e3).toFixed(2);return"[Performance] ".concat(this.label," -> ").concat(n," s")},t}();function J(t){setTimeout((function(){t()}),0)}var X=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e.prototype.logDebug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,g(["log","debug"],t,!1))},e.prototype.logWarning=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,g(["log","warn"],t,!1))},e.prototype.logError=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.emit.apply(this,g(["log","error"],t,!1))},e}(T)),Y=function(t){function e(e){var n,o=this;return(o=t.call(this)||this).listenersCollector=new I,o.size={width:0,height:0},o.pixelRatio=1,o.maxPixelRatio=2,o.handleCanvasResizeObserver=function(t){o.resizeCanvas(t[0].contentRect)},o.resizeCanvas=function(t){var e=t.width,n=t.height;window.requestAnimationFrame((function(){o.setSize(e,n),o.emit("resize",e,n,o.getDevicePixelRatio())}))},o.getCanvasCenterPoint=function(){var t=o.getBoundingClientRect();return{x:t.width/2+t.x,y:t.height/2+t.y}},o.container=e.container,o.canvas=e.canvas,o.maxPixelRatio=null!==(n=e.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 l(e,t),e.prototype.setSize=function(t,e){this.pixelRatio=this.getDevicePixelRatio(),this.canvas.style.width="".concat(t,"px"),this.canvas.style.height="".concat(e,"px"),this.size.width=t*this.pixelRatio,this.size.height=e*this.pixelRatio,this.canvas.width=this.size.width,this.canvas.height=this.size.height},e.prototype.handleDeviceOrientationChange=function(){this.resizeCanvas({width:this.container.clientWidth,height:this.container.clientHeight})},e.prototype.getDevicePixelRatio=function(){return z(window.devicePixelRatio,1,this.maxPixelRatio)},e.prototype.getBoundingClientRect=function(){return this.canvas.getBoundingClientRect()},e.prototype.dispose=function(){this.detachAllListeners(),this.canvasResizeObserver.disconnect(),this.listenersCollector.dispose()},e}(T),V=function(){function t(t){this.settings=t}return t.prototype.isReleaseMode=function(){return this.settings.mode===x.release},t.prototype.init=function(){return h(this,void 0,void 0,(function(){var t,e,n,o,r,i=this;return p(this,(function(a){switch(a.label){case 0:return[4,this.importModule()];case 1:t=a.sent(),e=t.default,a.label=2;case 2:return a.trys.push([2,4,,5]),n=this,[4,e({FeatureFlags:this.settings.featureFlags,currentWebGLVersion:B(),bridge:this.settings.jsBridge,locateFile:function(t){return i.settings.locateFile.replace("{file}",t)}})];case 3:return n.instance=a.sent(),[3,5];case 4:throw o=a.sent(),new W("WASM_ERROR","An error occurred while trying to create the wasm module.",o);case 5:return this.pointerTypeToWASMMap={unset:this.instance.PRUserPointerType.Unset,mouse:this.instance.PRUserPointerType.Mouse,touch:this.instance.PRUserPointerType.Touch},this.prCursorTypeToCSSCursorMap=((r={})[this.instance.PRCursorType.Auto.value]="auto",r[this.instance.PRCursorType.Default.value]="default",r[this.instance.PRCursorType.Pointer.value]="pointer",r[this.instance.PRCursorType.Grab.value]="grab",r[this.instance.PRCursorType.Grabbing.value]="grabbing",r),this.prototypeResizeModeToWASMMap={Fit:this.instance.PrototypeResizeMode.Fit,FitWidth:this.instance.PrototypeResizeMode.FitWidth,ActualSize:this.instance.PrototypeResizeMode.ActualSize},[2]}}))}))},t.prototype.makeWebGLContext=function(t,e){var n;void 0===e&&(e={});var o=d({antialias:!1,alpha:!1,stencil:!1,depth:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1,desynchronized:!0},e),r=this.instance.GL.createContext(t,o);if(!r)throw new W("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},t.prototype.createWebGLTextureFromImage=function(t,e){var n=this.instance.GL,o=n.getContext(e);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,t),r.bindTexture(r.TEXTURE_2D,null),a},t.prototype.destroyWebGLContext=function(t){var e;X.logDebug("Destroying WebGL context");var n=null===(e=this.instance)||void 0===e?void 0:e.GL.getContext(t);if(n){this.instance.GL.deleteContext(t);var o=n.GLctx.getExtension("WEBGL_lose_context");if(o)return o.loseContext(),X.logDebug("WebGL destroyed"),!0;X.logError("WEBGL_lose_context not available. Not possible to destroy WebGL context manually.")}else X.logError("WebGL context not found while trying to destroy it")},t.prototype.importModule=function(){return this.isReleaseMode()?import("./module-release-4773acfa.js"):import("./module-debug-2361a8e7.js")},t.prototype.mapToCSSCursor=function(t){return this.prCursorTypeToCSSCursorMap[t.value]},t.prototype.mapToPRPointerType=function(t){var e;return null!==(e=this.pointerTypeToWASMMap[t])&&void 0!==e?e:this.instance.PRUserPointerType.Unset},t.prototype.mapPointerInfo=function(t){return d(d({},t),{type:this.mapToPRPointerType(t.type)})},t.prototype.mapResizeMode=function(t){return this.prototypeResizeModeToWASMMap[t]},t}();function $(t){return new Promise((function(e,n){var o=new Image;o.onload=function(){e(o)},o.onerror=function(t){n(t)},o.src=t}))}var q=function(){function t(t,e,n){this.canvas=t,this.container=e,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=x.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=D,this.manualInitialization=!1,this.panBoundariesPadding=0,this.selectedArtboard=null,this.initialZoom=null,this.initialPan=null}return t.FromSettings=function(e){return Object.assign(new t(e.canvas,e.container,e.filePath),Object.fromEntries(Object.entries(e).filter((function(t){return void 0!==t[1]}))))},t}(),Q=function(t){function e(e){var n=t.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(t,e,o){var r;null===(r=n.pageCanvasWasm)||void 0===r||r.resize(t,e,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(t,e.x,e.y)},n.handleWheelEvent=function(t,e){var o;n.wasmModule&&(null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchWheelEvent(t.x,t.y,n.wasmModule.mapPointerInfo(e)))},n.handlePointerDownEvent=function(t){var e;n.wasmModule&&(null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerDownEvent(n.wasmModule.mapPointerInfo(t)))},n.handlePointerMoveEvent=function(t){var e;n.wasmModule&&(null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerMoveEvent(n.wasmModule.mapPointerInfo(t)))},n.handleGlobalPointerMoveEvent=function(t){var e;n.wasmModule&&(null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchGlobalPointerMoveEvent(n.wasmModule.mapPointerInfo(t)))},n.handlePointerUpEvent=function(t){var e;n.wasmModule&&(null===(e=n.userEventsCollectorWasm)||void 0===e||e.dispatchPointerUpEvent(n.wasmModule.mapPointerInfo(t)))},n.settings=q.FromSettings(e),X.logDebug("CanvasRenderer JS constructed with settings:",n.settings),n.gestureManager=new N(n.settings.container),n.canvasManager=new Y({container:n.settings.container,canvas:n.settings.canvas}),n.wasmModule=new V({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return l(e,t),e.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)},e.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,L()];case 1:return t=e.sent(),this.deviceInfo=d(d({},t),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),this.collectAndEmitDeviceInfo(),e.label=1;case 1:return e.trys.push([1,5,,6]),[4,this.initWasmModule()];case 2:return e.sent(),[4,this.initCanvasRendererWasm()];case 3:return e.sent(),[4,this.setFile(this.settings.filePath)];case 4:return e.sent(),this.settings.selectedArtboard&&this.selectArtboard(this.settings.selectedArtboard),[3,6];case 5:return t=e.sent(),[2,this.fail(t instanceof W?t:new W("ERROR","Unexpected exception initializing the web renderer",t))];case 6:return this.setInitialCameraState(),this.startRendering(),this.addListeners(),[2]}}))}))},e.prototype.setInitialCameraState=function(){var t,e,n,o=null!==this.settings.initialZoom,r=null!==this.settings.initialPan;o||r?(o&&this.setZoom(this.settings.initialZoom||1),r&&this.setPan((null===(t=this.settings.initialPan)||void 0===t?void 0:t.x)||0,(null===(e=this.settings.initialPan)||void 0===e?void 0:e.y)||0,null===(n=this.settings.initialPan)||void 0===n?void 0:n.centerPointInViewport)):this.zoomToFit()},e.prototype.startRendering=function(){var t;this.traceInitialRender=new K("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(t=this.pageCanvasWasm)||void 0===t||t.startRenderLoop()},e.prototype.createJSBridge=function(){var t=this;return{logDebug:function(t){X.logDebug("[C++] ".concat(t))},logWarning:function(t){X.logWarning("[C++] ".concat(t))},logError:function(t){X.logError("[C++] ".concat(t))},emitMetric:function(e,n,o,r){t.emit("metric",{id:e,start:n,end:o,duration:r})},resolveImageUrl:function(e){return t.settings.imagesURLMap&&t.settings.imagesURLMap[e]?t.settings.imagesURLMap[e]:t.settings.imagesURLFormat?t.settings.imagesURLFormat.replace(":imageId",e):(X.logWarning("Not able to resolve the url for the image with UUID: ".concat(e)),"")},resolveFragmentUrl:function(e){return t.settings.fragmentsURLMap&&t.settings.fragmentsURLMap[e]?t.settings.fragmentsURLMap[e]:t.settings.fragmentsURLFormat?t.settings.fragmentsURLFormat.replace(":fragmentId",e):(X.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(e)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){t.emit("allImagesReady")},onCameraMoveStart:function(){t.emit("cameraMoveStart")},onCameraMoveEnd:function(){t.emit("cameraMoveEnd")},onCameraZoomStart:function(){t.emit("cameraZoomStart")},onCameraZoomEnd:function(){t.emit("cameraZoomEnd")},onCameraZoomChange:function(e){t.emit("cameraZoomChange",e)},onCameraPanChange:function(){var e=t.getPan();t.emit("cameraPanChange",(null==e?void 0:e.x)||0,(null==e?void 0:e.y)||0)},onCursorChange:function(e){var n,o=null===(n=t.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(e);o&&t.emit("cursorChange",o)},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeStateChange:function(){},onPrototypeUnhandledPointerUp:function(){},onPrototypeSceneChange:function(){}}},e.prototype.handleJSBridgeFetch=function(t,e){var n=this,o=e.clone(),r=function(e){return h(n,void 0,void 0,(function(){var n,i,a,s,u,c,l,d,h;return p(this,(function(p){switch(p.label){case 0:if(!this.wasmModule)return[2];if(this.disposed)return[2];if(e.data.url!==t)return[2];switch(e.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:e.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(e.data.contentType)?(i=new Blob([e.data.buffer]),[4,$(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),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];case 3:n.buffer=new Uint8Array(e.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return X.logError("Error while fetching ".concat(t),e.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(c=null===(u=e.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==c?c:500,statusText:null!==(d=null===(l=e.data.error)||void 0===l?void 0:l.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=e.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:t})},e.prototype.handleJSBridgeAbortFetch=function(t){this.fetchWorker.postMessage({type:"abort",url:t})},e.prototype.initWasmModule=function(){var t;return h(this,void 0,void 0,(function(){var e;return p(this,(function(n){switch(n.label){case 0:return this.disposed?[2]:(e=new K("WasmModuleDownload"),[4,null===(t=this.wasmModule)||void 0===t?void 0:t.init()]);case 1:return n.sent(),X.logDebug(e.printMeasurement()),this.emit("metric",e.measure()),[2]}}))}))},e.prototype.initCanvasRendererWasm=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){if(this.disposed)return[2];try{if(!this.wasmModule)throw Error("WASM module not initialized");t=B(),X.logDebug("Using WebGL ".concat(t)),this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:t}),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.CanvasRenderer(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders})}catch(t){throw new W("WASM_ERROR","An error occurred while trying to create the wasm object.",t)}return this.userEventsCollectorWasm=this.pageCanvasWasm.getUserEventsCollector(),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]}))}))},e.prototype.setIsCameraLocked=function(t){var e;null===(e=this.pageCanvasWasm)||void 0===e||e.setIsCameraLocked(t)},e.prototype.setBackgroundColor=function(t){var e;t.r===this.settings.backgroundColor.r&&t.g===this.settings.backgroundColor.g&&t.b===this.settings.backgroundColor.b&&t.a===this.settings.backgroundColor.a||(null===(e=this.pageCanvasWasm)||void 0===e||e.setBackgroundColor(t.r,t.g,t.b,t.a),this.settings.backgroundColor=t)},e.prototype.generateDocumentPNG=function(){var t;return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.generateDocumentPNG()]}))}))},e.prototype.handleDrawComplete=function(){"DRAWING_FILE"===this.status.type&&(X.logDebug(this.traceInitialRender.printMeasurement()),this.emit("metric",this.traceInitialRender.measure()),X.logDebug(this.traceFirstPaint.printMeasurement()),this.emit("metric",this.traceFirstPaint.measure()),this.setStatus({type:"READY"}))},e.prototype.looseWebGLContext=function(){var t;(null===(t=this.wasmModule)||void 0===t?void 0:t.destroyWebGLContext(this.webglCtxHandle))||X.logWarning("Failed to loose WebGL context"),this.webglCtxHandle=-1},e.prototype.zoomToFit=function(){var t;null===(t=this.pageCanvasWasm)||void 0===t||t.scaleDocumentToFit()},e.prototype.setFile=function(t){return h(this,void 0,void 0,(function(){var e=this;return p(this,(function(n){return this.disposed?[2]:(this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){var r;null===(r=e.pageCanvasWasm)||void 0===r||r.setFile(t,(function(t,o,r){e.setStatus({type:"FILE_READY"});var i="".concat(t,"-v").concat("7.6.9");e.emit("fileReady",e.getDocument(),i,o,r),n()}),(function(){return o(new W("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))])}))}))},e.prototype.fail=function(t){this.setStatus({type:"FAILURE",code:t.code,message:"".concat(t.toString()).concat(t.cause?"\nWrapped Error: ".concat(t.cause.toString()):"")}),X.logError(t),t.cause&&X.logError(t.cause)},e.prototype.setStatus=function(t){"FAILURE"!==this.status.type&&(X.logDebug("Status transition ".concat(this.status.type," => ").concat(t.type)),this.status=t,this.emit("status",t))},e.prototype.getDocument=function(){if(!this.pageCanvasWasm)return{artboards:[],bounds:{x:0,y:0,width:0,height:0}};if(!this.cachedDocumentInfo||this.cachedDocumentInfo.filePath!==this.settings.filePath){var t=this.pageCanvasWasm.getPRFile();this.cachedDocumentInfo={filePath:this.settings.filePath,document:d(d({},t),{artboards:Z(t.artboards)})}}return this.cachedDocumentInfo.document},e.prototype.getArtboardAtPosition=function(t,e){if(this.pageCanvasWasm){var n=this.getDocument();if(n){for(var o=this.pageCanvasWasm.getPan(),r=this.pageCanvasWasm.getZoom(),i=(t-o.x)/r,a=(e-o.y)/r,s=0,u=n.artboards;s<u.length;s++){var c=u[s],l=c.bounds.x+c.bounds.width,d=c.bounds.y+c.bounds.height;if(i>=c.bounds.x&&a>=c.bounds.y&&i<=l&&a<=d)return c.objectId}return null}}},e.prototype.getPanAtPosition=function(t,e){var n=this.getPan(),o=Math.max(this.getZoom(),Number.EPSILON),r=t/o,i=e/o;return{x:n.x-r,y:n.y-i}},e.prototype.getStatus=function(){return this.status},e.prototype.setZoom=function(t,e){var n,o=null!=e?e:this.canvasManager.getCanvasCenterPoint();null===(n=this.pageCanvasWasm)||void 0===n||n.setZoom(t,o.x,o.y)},e.prototype.getPan=function(){var t,e,n=this.getDocument().bounds,o=null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getPan(),r=null===(e=this.pageCanvasWasm)||void 0===e?void 0:e.getZoom();return o&&r?{x:o.x/r+n.x,y:o.y/r+n.y}:{x:0,y:0}},e.prototype.getZoom=function(){var t;return(null===(t=this.pageCanvasWasm)||void 0===t?void 0:t.getZoom())||0},e.prototype.setPan=function(t,e,n){var o;void 0===n&&(n=!1);var r=t,i=e,a=this.getDocument().bounds,s=this.getZoom();if(n){var u=Math.max(2*s*this.canvasManager.pixelRatio,Number.EPSILON);r+=this.canvasManager.size.width/u,i+=this.canvasManager.size.height/u}var c=(r-a.x)*s,l=(i-a.y)*s;null===(o=this.pageCanvasWasm)||void 0===o||o.setPan(c,l)},e.prototype.selectArtboard=function(t){var e;this.pageCanvasWasm&&(this.settings.selectedArtboard=t,null===(e=this.pageCanvasWasm)||void 0===e||e.selectArtboard(null!=t?t:""))},e.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},e.prototype.dispose=function(){var t,e,n,o;try{this.disposed=!0,this.detachAllListeners(),null===(t=this.wasmModule)||void 0===t||t.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(e=this.pageCanvasWasm)||void 0===e||e.stopRenderLoop(),null===(n=this.pageCanvasWasm)||void 0===n||n.delete(),null===(o=this.renderTarget)||void 0===o||o.delete(),this.disposeFetchWorker(),this.pageCanvasWasm=void 0,this.wasmModule=void 0}catch(t){this.fail(new W("ERROR","Unexpected exception while disposing the wasm object",t))}},e}(T),tt=e(void 0),et=e(void 0),nt=e(void 0),ot=e(void 0),rt=e(void 0),it=e(void 0),at=e("auto"),st=e(void 0),ut=function(){var t=n(st);if(void 0===t)throw Error("useInternalContext must be used within a provider");return t},ct=function(t,e){switch(e.type){case"on-status":return d(d({},t),{status:e.status});case"on-file-ready":return d(d({},t),{document:e.document});case"on-zoom":return d(d({},t),{zoom:e.zoom});case"on-pan":return d(d({},t),{pan:e.pan});case"dispose":return d(d({},t),{status:{type:"DISPOSED"},zoom:null,pan:null,cursor:"auto"});case"on-camera-zoom-start":return d(d({},t),{isCameraZooming:!0});case"on-camera-zoom-end":return d(d({},t),{isCameraZooming:!1});case"on-camera-move-start":return d(d({},t),{isCameraMoving:!0});case"on-camera-move-end":return d(d({},t),{isCameraMoving:!1});case"on-cursor-change":return d(d({},t),{cursor:e.cursor});default:return t}},lt=function(e){var n=o(null),s=o(null),u=r(ct,{pan:null,zoom:null,status:{type:"IDLE"},document:null,isCameraZooming:!1,isCameraMoving:!1,cursor:"auto"}),c=u[0],l=c.status,h=c.document,p=c.zoom,g=c.pan,v=c.isCameraZooming,f=c.isCameraMoving,m=c.cursor,y=u[1],b=i((function(t){return y({type:"on-zoom",zoom:t})}),[]),w=i((function(t,e){return y({type:"on-pan",pan:{x:t,y:e}})}),[]),C=i((function(t){y({type:"on-status",status:t})}),[]),P=i((function(t){y({type:"on-file-ready",document:t})}),[]),M=i((function(){return y({type:"on-camera-zoom-start"})}),[]),E=i((function(){return y({type:"on-camera-zoom-end"})}),[]),L=i((function(){return y({type:"on-camera-move-start"})}),[]),x=i((function(){return y({type:"on-camera-move-end"})}),[]),R=i((function(t){return y({type:"on-cursor-change",cursor:t})}),[]),W=i((function(){var t=n.current;t&&(X.logDebug("Provider dispose"),t.off("status",C),t.off("fileReady",P),t.off("cameraZoomChange",b),t.off("cameraPanChange",w),t.off("cameraZoomStart",M),t.off("cameraZoomEnd",E),t.off("cameraMoveStart",L),t.off("cameraMoveEnd",x),t.off("cursorChange",R),t.dispose(),n.current=null,y({type:"dispose"}))}),[C,P,w,b,M,E,L,x,R]),S=i((function(t,e,o){if(""!==t&&e&&o&&s.current){X.logDebug("Provider init");var r=new Q(d(d({},s.current),{filePath:t,container:o,canvas:e,manualInitialization:!0}));r.on("status",C),r.on("fileReady",P),r.on("cameraZoomChange",b),r.on("cameraPanChange",w),r.on("cameraZoomStart",M),r.on("cameraZoomEnd",E),r.on("cameraMoveStart",L),r.on("cameraMoveEnd",x),r.on("cursorChange",R),n.current=r,r.init()}}),[C,P,b,w,M,E,L,x,R]),T=i((function(t){var e,o;X.logDebug("Provider setSettings"),t.backgroundColor&&(null===(e=n.current)||void 0===e||e.setBackgroundColor(t.backgroundColor)),null===(o=n.current)||void 0===o||o.selectArtboard(t.selectedArtboard||null),s.current=t}),[]),I=i((function(){return n.current}),[]),D=a((function(){return{dispose:W,init:S,setSettings:T,getInstance:I,dispatch:y}}),[W,S,T,I]);return t.createElement(st.Provider,{value:D},t.createElement(tt.Provider,{value:l},t.createElement(et.Provider,{value:h},t.createElement(nt.Provider,{value:p},t.createElement(it.Provider,{value:g},t.createElement(ot.Provider,{value:v},t.createElement(rt.Provider,{value:f},t.createElement(at.Provider,{value:m},e.children))))))))},dt=function(){var t=n(tt);if(void 0===t)throw Error("useStatus must be used within a provider");return t},ht=function(){var t=n(et);if(void 0===t)throw Error("useDocument must be used within a provider");return t},pt=function(){var t=n(nt);if(void 0===t)throw Error("useZoom must be used within a provider");return t},gt=function(){var t=n(it);if(void 0===t)throw Error("usePan must be used within a provider");return t},vt=function(){var t=n(at);if(void 0===t)throw Error("useCursor must be used within a provider");return t},ft=function(){var t=n(ot);if(void 0===status)throw Error("useIsCameraZooming must be used within a provider");return t},mt=function(){var t=n(rt);if(void 0===status)throw Error("useIsCameraMoving must be used within a provider");return t},yt=function(){var t=(0,ut().getInstance)();return i((function(e){null==t||t.setZoom(e)}),[t])},bt=function(){var t=yt(),e=pt();return i((function(){var n;"number"==typeof e&&(n=e>=1?Math.round(2*e):e>.5?1:2*e,t(n))}),[t,e])},wt=function(){var t=yt(),e=pt();return i((function(){"number"==typeof e&&t(e/2)}),[t,e])},Ct=function(){var t=(0,ut().getInstance)();return i((function(e){var n=e.x,o=e.y,r=e.centerPointInViewport;null==t||t.setPan(n,o,r)}),[t])},Pt=function(){var t=(0,ut().getInstance)();return i((function(){null==t||t.zoomToFit()}),[t])},Mt=function(){var t=(0,ut().getInstance)();return i((function(){null==t||t.looseWebGLContext()}),[t])},Et=function(){var t=(0,ut().getInstance)();return i((function(){return h(void 0,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,null==t?void 0:t.generateDocumentPNG()];case 1:return[2,e.sent()]}}))}))}),[t])},Lt=function(){var t=(0,ut().getInstance)();return i((function(e,n){return h(void 0,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,null==t?void 0:t.getArtboardAtPosition(e,n)];case 1:return[2,o.sent()||null]}}))}))}),[t])},xt=function(){var t=(0,ut().getInstance)();return i((function(e,n){return h(void 0,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,null==t?void 0:t.getPanAtPosition(e,n)];case 1:return[2,o.sent()||null]}}))}))}),[t])},Rt=function(){var t=(0,ut().getInstance)();return i((function(e){null==t||t.setIsCameraLocked(e)}),[t])},Wt=function(t,e){var n=(0,ut().getInstance)();s((function(){return null==n||n.on(t,e),function(){null==n||n.off(t,e)}}),[t,n,e])};function St(t){var e=o(t);e.current=t;var n=i((function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.current.apply(e,g([t],n,!1))}),[]);s((function(){return X.on("log",n),function(){X.off("log",n)}}),[n])}var Tt={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},It={position:"absolute",top:0,left:0},Dt=function(e){var n=e.filePath,r=e.locateFile,c=e.imagesURLFormat,l=e.imagesURLMap,h=e.fragmentsURLFormat,p=e.fragmentsURLMap,g=e.backgroundColor,v=e.mode,f=e.showTilesBorders,m=e.minimumZoomLevel,y=e.maximumZoomLevel,b=e.preserveDrawingBuffer,w=e.panBoundariesPadding,C=e.initialPan,P=e.initialZoom,M=e.children,E=e.containerProps,L=e.canvasProps,x=e.featureFlags,R=e.selectedArtboard,W=o(null),S=o(null),T=u(!1),I=T[0],D=T[1],F=i((function(){return D(!0)}),[]),U=ut(),A=U.dispose,k=U.init,G=U.setSettings,z=vt(),B=dt();Wt("allImagesReady",F),s((function(){return X.logDebug("CanvasRenderer mounted"),function(){return X.logDebug("CanvasRenderer unmounted")}}),[]),s((function(){G({locateFile:r,imagesURLFormat:c,imagesURLMap:l,fragmentsURLFormat:h,fragmentsURLMap:p,backgroundColor:g,mode:v,showTilesBorders:f,minimumZoomLevel:m,maximumZoomLevel:y,preserveDrawingBuffer:b,panBoundariesPadding:w,initialPan:C,initialZoom:P,featureFlags:x,selectedArtboard:R})}),[G,r,c,l,h,p,g,v,f,m,y,b,w,C,P,x,R]),s((function(){if(n)return k(n,W.current,S.current),function(){A()}}),[A,k,n]);var Z=a((function(){var t;return null!==(t=e.cursor)&&void 0!==t?t:z}),[e.cursor,z]),_=a((function(){return d(d({},Tt),{cursor:Z})}),[Z]);return t.createElement("div",d({},E,{ref:S,style:_}),n&&t.createElement("canvas",d({},L,{key:n,ref:W,"data-sketchweb-all-images-ready":I,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-".concat((null==B?void 0:B.type.toLowerCase())||"null"),style:It})),"READY"===(null==B?void 0:B.type)&&M)},Ft=function(){function t(t,e,n,o){this.prototypeStructure=t,this.startArtboardUUID=e,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=x.release,this.showTilesBorders=!1,this.minimumZoomLevel=5,this.maximumZoomLevel=.01,this.preserveDrawingBuffer=!1,this.featureFlags=D,this.manualInitialization=!1,this.highlightHotspots=!0,this.resizeMode=R.Fit,this.assetsManagerLimits={maxDepthForBackgroundRequests:1,maxArtboardsForBackgroundRequests:5,maxInitialLoadingDepth:2,maxInitialArtboardToLoad:10}}return t.FromSettings=function(e){return Object.assign(new t(e.prototypeStructure,e.startArtboardUUID,e.canvas,e.container),Object.fromEntries(Object.entries(e).filter((function(t){return void 0!==t[1]}))))},t}(),Ut=function(t){function e(e){var n=t.call(this)||this;return n.status={type:"IDLE"},n.disposed=!1,n.handleCanvasResize=function(t,e,o){var r;null===(r=n.playerWasm)||void 0===r||r.resize(t,e,o)},n.handleWebGLContextLost=function(){n.setStatus({type:"WEBGL_CONTEXT_LOST"})},n.handlePinchToZoomEvent=function(t,e){var o;null===(o=n.userEventsCollectorWasm)||void 0===o||o.dispatchPinchToZoomEvent(t,e.x,e.y)},n.handleWheelEvent=function(t,e){var o;n.wasmModule&&n.userEventsCollectorWasm.dispatchWheelEvent(t.x,t.y,null===(o=n.wasmModule)||void 0===o?void 0:o.mapPointerInfo(e))},n.handlePointerDownEvent=function(t){var e;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerDownEvent(null===(e=n.wasmModule)||void 0===e?void 0:e.mapPointerInfo(t))},n.handlePointerMoveEvent=function(t){var e;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerMoveEvent(null===(e=n.wasmModule)||void 0===e?void 0:e.mapPointerInfo(t))},n.handleGlobalPointerMoveEvent=function(t){var e;n.wasmModule&&n.userEventsCollectorWasm.dispatchGlobalPointerMoveEvent(null===(e=n.wasmModule)||void 0===e?void 0:e.mapPointerInfo(t))},n.handlePointerUpEvent=function(t){var e;n.wasmModule&&n.userEventsCollectorWasm.dispatchPointerUpEvent(null===(e=n.wasmModule)||void 0===e?void 0:e.mapPointerInfo(t))},n.restartPrototype=function(t){var e;null===(e=n.playerWasm)||void 0===e||e.restartPrototype(t)},n.navigateToFirstFlow=function(){var t;null===(t=n.playerWasm)||void 0===t||t.navigateToFirstFlow()},n.goBack=function(){var t;null===(t=n.playerWasm)||void 0===t||t.goBack()},n.goForwards=function(){var t;null===(t=n.playerWasm)||void 0===t||t.goForwards()},n.setResizeMode=function(t){var e;if(n.wasmModule){var o=n.wasmModule.mapResizeMode(t);null===(e=n.playerWasm)||void 0===e||e.setResizeMode(o)}},n.getScreen=function(){var t,e=null===(t=n.playerWasm)||void 0===t?void 0:t.getJSScreen();return e?{layers:Z(e.layers)}:{layers:[]}},n.settings=Ft.FromSettings(e),X.logDebug("PrototypeRenderer JS constructed with settings:",n.settings),n.gestureManager=new N(n.settings.container),n.canvasManager=new Y({container:n.settings.container,canvas:n.settings.canvas,maxPixelRatio:3}),n.wasmModule=new V({mode:n.settings.mode,locateFile:n.settings.locateFile,jsBridge:n.createJSBridge(),featureFlags:n.settings.featureFlags}),n.fetchWorker=new Worker(n.settings.locateFile.replace("{file}","fetch-worker.js")),n.settings.manualInitialization||n.init(),n}return l(e,t),e.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)},e.prototype.collectAndEmitDeviceInfo=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return[4,L()];case 1:return t=e.sent(),this.deviceInfo=d(d({},t),{hardwareConcurrency:navigator.hardwareConcurrency}),this.emit("deviceInfo",this.deviceInfo),[2]}}))}))},e.prototype.init=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:this.traceFirstPaint=new K("FirstPaint"),this.setStatus({type:"INITIALIZING"}),this.collectAndEmitDeviceInfo(),e.label=1;case 1:return e.trys.push([1,5,,6]),[4,this.initWasmModule()];case 2:return e.sent(),[4,this.initPlayerWasm()];case 3:return e.sent(),[4,this.startDownload()];case 4:return e.sent(),[3,6];case 5:return t=e.sent(),[2,this.fail(t instanceof W?t:new W("ERROR","Unexpected exception initializing the web renderer",t))];case 6:return this.startRendering(),this.addListeners(),[2]}}))}))},e.prototype.initWasmModule=function(){var t;return h(this,void 0,void 0,(function(){var e;return p(this,(function(n){switch(n.label){case 0:return e=new K("WasmModuleDownload"),[4,null===(t=this.wasmModule)||void 0===t?void 0:t.init()];case 1:return n.sent(),e.printMeasurement(),this.emit("metric",e.measure()),[2]}}))}))},e.prototype.startDownload=function(){var t=this;return this.setStatus({type:"LOADING_FILE"}),new Promise((function(e){var n;null===(n=t.playerWasm)||void 0===n||n.startDownload((function(){e()}))}))},e.prototype.startRendering=function(){var t;this.traceInitialRender=new K("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),null===(t=this.playerWasm)||void 0===t||t.startRenderLoop()},e.prototype.createJSBridge=function(){var t=this;return{logDebug:function(t){X.logDebug("[C++] ".concat(t))},logWarning:function(t){X.logWarning("[C++] ".concat(t))},logError:function(t){X.logError("[C++] ".concat(t))},emitMetric:function(e,n,o,r){t.emit("metric",{id:e,start:n,end:o,duration:r})},resolveImageUrl:function(e){return t.settings.imagesURLMap&&t.settings.imagesURLMap[e]?t.settings.imagesURLMap[e]:t.settings.imagesURLFormat?t.settings.imagesURLFormat.replace(":imageId",e):(X.logWarning("Not able to resolve the url for the image with UUID: ".concat(e)),"")},resolveFragmentUrl:function(e){return t.settings.fragmentsURLMap&&t.settings.fragmentsURLMap[e]?t.settings.fragmentsURLMap[e]:t.settings.fragmentsURLFormat?t.settings.fragmentsURLFormat.replace(":fragmentId",e):(X.logWarning("Not able to resolve the url for the fragment with UUID: ".concat(e)),"")},onDrawComplete:this.handleDrawComplete.bind(this),onAllImagesReady:function(){t.emit("allImagesReady")},onCameraMoveStart:function(){t.emit("cameraMoveStart")},onCameraMoveEnd:function(){t.emit("cameraMoveEnd")},onCameraZoomStart:function(){t.emit("cameraZoomStart")},onCameraZoomEnd:function(){t.emit("cameraZoomEnd")},onCameraZoomChange:function(e){t.emit("cameraZoomChange",e)},onCameraPanChange:function(e,n){t.emit("cameraPanChange",e,n)},onCursorChange:function(e){var n,o=null===(n=t.wasmModule)||void 0===n?void 0:n.mapToCSSCursor(e);o&&t.emit("cursorChange",o)},onPrototypeStateChange:function(e,n,o){t.emit("prototypeStateChange",{currentArtboardId:e,canGoBack:n,canGoForwards:o})},fetch:this.handleJSBridgeFetch.bind(this),abortFetch:this.handleJSBridgeAbortFetch.bind(this),onPrototypeUnhandledPointerUp:function(){t.emit("prototypeUnhandledPointerUp")},onPrototypeSceneChange:function(){t.emit("prototypeSceneChange")}}},e.prototype.handleJSBridgeFetch=function(t,e){var n=this,o=e.clone(),r=function(e){return h(n,void 0,void 0,(function(){var n,i,a,s,u,c,l,d,h;return p(this,(function(p){switch(p.label){case 0:if(this.disposed||!this.wasmModule)return[2];if(e.data.url!==t)return[2];switch(e.data.type){case"success":return[3,1];case"error":return[3,5]}return[3,6];case 1:return n={statusCode:200,statusText:"OK",contentType:e.data.contentType,isWebGLTexture:!1,emscriptenWebGLTextureHandle:-1,width:0,height:0},/image/.test(e.data.contentType)?(i=new Blob([e.data.buffer]),[4,$(URL.createObjectURL(i))]):[3,3];case 2:return a=p.sent(),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];case 3:n.buffer=new Uint8Array(e.data.buffer),p.label=4;case 4:return o.exec(n),[3,7];case 5:return X.logError("Error while fetching ".concat(t),e.data.error),o.exec({buffer:new Uint8Array(0),statusCode:null!==(c=null===(u=e.data.error)||void 0===u?void 0:u.statusCode)&&void 0!==c?c:500,statusText:null!==(d=null===(l=e.data.error)||void 0===l?void 0:l.statusText)&&void 0!==d?d:"Unknown error",contentType:null!==(h=e.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:t})},e.prototype.handleJSBridgeAbortFetch=function(t){this.fetchWorker.postMessage({type:"abort",url:t})},e.prototype.initPlayerWasm=function(){var t,e;return h(this,void 0,void 0,(function(){var n,o,r,i,a,s,u,c,l,h,g,v,f,m,y,b,w,C;return p(this,(function(p){try{if(!this.wasmModule)throw Error("WASM module not initialized");for(this.webglCtxHandle=this.wasmModule.makeWebGLContext(this.settings.canvas,{preserveDrawingBuffer:this.settings.preserveDrawingBuffer,majorVersion:B()}),n=this.wasmModule.instance,o=n.RenderTarget,r=n.PrototypeRenderer,i=n.PrototypeStructureArtboardVector,a=n.PrototypeStructureFlowVector,s=n.PrototypeStructureAssetVector,this.renderTarget=o.MakeWebGL(this.webglCtxHandle,this.canvasManager.size.width,this.canvasManager.size.height,this.canvasManager.pixelRatio),u={artboards:new i},c=0,l=this.settings.prototypeStructure.artboards;c<l.length;c++){for(h=l[c],g=new a,v=0,f=null!==(t=h.flows)&&void 0!==t?t:[];v<f.length;v++)m=f[v],g.push_back(m);for(y=new s,b=0,w=null!==(e=h.assets)&&void 0!==e?e:[];b<w.length;b++)C=w[b],y.push_back(C);u.artboards.push_back(d(d({},h),{flows:g,assets:y}))}this.playerWasm=new r(this.renderTarget,{showTilesBorders:this.settings.showTilesBorders},this.settings.startArtboardUUID,u,this.settings.highlightHotspots,this.settings.assetsManagerLimits)}catch(t){throw new W("WASM_ERROR","An error occurred while trying to create the PrototypeRenderer WASM object.",t)}return this.userEventsCollectorWasm=this.playerWasm.getUserEventsCollector(),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]}))}))},e.prototype.setIsCameraLocked=function(t){var e;null===(e=this.playerWasm)||void 0===e||e.setIsCameraLocked(t)},e.prototype.setBackgroundColor=function(t){var e;t.r===this.settings.backgroundColor.r&&t.g===this.settings.backgroundColor.g&&t.b===this.settings.backgroundColor.b&&t.a===this.settings.backgroundColor.a||(null===(e=this.playerWasm)||void 0===e||e.setBackgroundColor(t.r,t.g,t.b,t.a),this.settings.backgroundColor=t)},e.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"}))},e.prototype.looseWebGLContext=function(){var t;null===(t=this.wasmModule)||void 0===t||t.destroyWebGLContext(this.webglCtxHandle),this.webglCtxHandle=-1},e.prototype.fail=function(t){this.setStatus({type:"FAILURE",code:t.code,message:"".concat(t.toString()).concat(t.cause?"\nWrapped Error: ".concat(t.cause.toString()):"")}),X.logError(t),t.cause&&X.logError(t.cause)},e.prototype.setStatus=function(t){"FAILURE"!==this.status.type&&(X.logDebug("Status transition ".concat(this.status.type," => ").concat(t.type)),this.status=t,this.emit("status",t))},e.prototype.getStatus=function(){return this.status},e.prototype.disposeFetchWorker=function(){this.fetchWorker.postMessage({type:"abort-all"}),this.fetchWorker.terminate()},e.prototype.dispose=function(){var t,e,n;try{this.detachAllListeners(),null===(t=this.wasmModule)||void 0===t||t.destroyWebGLContext(this.webglCtxHandle),this.canvasManager.dispose(),this.gestureManager.dispose(),null===(e=this.playerWasm)||void 0===e||e.stopRenderLoop(),null===(n=this.playerWasm)||void 0===n||n.delete(),this.renderTarget.delete(),this.disposeFetchWorker(),this.playerWasm=void 0,this.wasmModule=void 0,this.disposed=!0}catch(t){this.fail(new W("ERROR","Unexpected exception while disposing the WebRendererWasm object",t))}},e}(T),At=e(void 0),kt=e("auto"),Gt=e(void 0),zt=e(void 0),Bt=e(void 0),Zt=e(void 0),_t=function(){var t=n(Zt);if(void 0===t)throw Error("useInternalContext must be used within a provider");return t},Ot=function(t,e){switch(e.type){case"on-status":return d(d({},t),{status:e.status});case"dispose":return d(d({},t),{status:{type:"DISPOSED"},cursor:"auto"});case"on-cursor-change":return d(d({},t),{cursor:e.cursor});case"on-prototype-state-change":return d(d({},t),{prototypeState:d(d({},t.prototypeState),e.prototypeState)});case"on-zoom":return d(d({},t),{zoom:e.zoom});case"on-pan":return d(d({},t),{pan:{x:e.pan.x,y:e.pan.y}});default:return t}},jt=function(e){var n=o(null),s=o(null),u=r(Ot,{status:{type:"IDLE"},cursor:"auto",prototypeState:{currentArtboardId:"",canGoBack:!1,canGoForwards:!1},zoom:1,pan:{x:0,y:0}}),c=u[0],l=c.status,h=c.cursor,p=c.prototypeState,g=c.zoom,v=c.pan,f=u[1],m=i((function(t){f({type:"on-status",status:t})}),[]),y=i((function(t){return f({type:"on-zoom",zoom:t})}),[]),b=i((function(t,e){return f({type:"on-pan",pan:{x:t,y:e}})}),[]),w=i((function(t){return f({type:"on-cursor-change",cursor:t})}),[]),C=i((function(t){return f({type:"on-prototype-state-change",prototypeState:t})}),[]),P=i((function(){var t=n.current;t&&(X.logDebug("Provider dispose"),t.off("status",m),t.off("cursorChange",w),t.off("prototypeStateChange",C),t.off("cameraZoomChange",y),t.off("cameraPanChange",b),t.dispose(),n.current=null,f({type:"dispose"}))}),[m,w,C,b,y]),M=i((function(t,e){if(t&&e&&s.current){X.logDebug("Provider init");var o=new Ut(d(d({},s.current),{container:e,canvas:t,manualInitialization:!0}));o.on("status",m),o.on("cursorChange",w),o.on("prototypeStateChange",C),o.on("cameraZoomChange",y),o.on("cameraPanChange",b),n.current=o,o.init()}}),[m,w,C,b,y]),E=i((function(t){var e,o,r,i;X.logDebug("Provider setSettings"),t.backgroundColor&&t.backgroundColor!=(null===(e=s.current)||void 0===e?void 0:e.backgroundColor)&&(null===(o=n.current)||void 0===o||o.setBackgroundColor(t.backgroundColor)),(null===(r=s.current)||void 0===r?void 0:r.resizeMode)!=t.resizeMode&&(null===(i=n.current)||void 0===i||i.setResizeMode(t.resizeMode||R.Fit)),s.current=t}),[]),L=i((function(){return n.current}),[]),x=a((function(){return{dispose:P,init:M,setSettings:E,getInstance:L,dispatch:f}}),[P,M,E,L]);return t.createElement(Zt.Provider,{value:x},t.createElement(At.Provider,{value:l},t.createElement(kt.Provider,{value:h},t.createElement(Gt.Provider,{value:p},t.createElement(zt.Provider,{value:g},t.createElement(Bt.Provider,{value:v},e.children))))))},Nt=function(){var t=(0,_t().getInstance)();return i((function(e){null==t||t.restartPrototype(e)}),[t])},Ht=function(){var t=(0,_t().getInstance)();return i((function(){null==t||t.navigateToFirstFlow()}),[t])},Kt=function(){var t=(0,_t().getInstance)();return i((function(){null==t||t.goBack()}),[t])},Jt=function(){var t=(0,_t().getInstance)();return i((function(){null==t||t.goForwards()}),[t])},Xt=function(){var t=n(At);if(void 0===t)throw Error("usePrototypeStatus must be used within a provider");return t},Yt=function(){var t=n(kt);if(void 0===t)throw Error("usePrototypeCursor must be used within a provider");return t},Vt=function(){var t=n(Gt);if(void 0===t)throw Error("usePrototypeState must be used within a provider");return t},$t=function(){var t=n(zt);if(void 0===t)throw Error("usePrototypeZoom must be used within a provider");return t},qt=function(){var t=n(Bt);if(void 0===t)throw Error("usePrototypePan must be used within a provider");return t},Qt=function(t,e){var n=(0,_t().getInstance)();s((function(){return null==n||n.on(t,e),function(){null==n||n.off(t,e)}}),[t,n,e])};function te(){var t=(0,_t().getInstance)();return i((function(){return null==t?void 0:t.getScreen()}),[t])}var ee={position:"relative",width:"100%",height:"100%",touchAction:"manipulation"},ne={position:"absolute",top:0,left:0},oe=function(e){var n=e.locateFile,r=e.imagesURLFormat,i=e.imagesURLMap,u=e.backgroundColor,c=e.mode,l=e.showTilesBorders,h=e.minimumZoomLevel,p=e.maximumZoomLevel,g=e.preserveDrawingBuffer,v=e.children,f=e.containerProps,m=e.canvasProps,y=e.featureFlags,b=e.startArtboardUUID,w=e.prototypeStructure,C=e.fragmentsURLFormat,P=e.fragmentsURLMap,M=e.highlightHotspots,E=e.resizeMode,L=e.assetsManagerLimits,x=o(null),R=o(null),W=_t(),S=W.dispose,T=W.init,I=W.setSettings,D=Yt(),F=Xt();s((function(){return X.logDebug("PrototypeRenderer mounted"),function(){return X.logDebug("PrototypeRenderer unmounted")}}),[]),s((function(){I({locateFile:n,imagesURLFormat:r,imagesURLMap:i,backgroundColor:u,mode:c,showTilesBorders:l,minimumZoomLevel:h,maximumZoomLevel:p,preserveDrawingBuffer:g,featureFlags:y,startArtboardUUID:b,prototypeStructure:w,fragmentsURLFormat:C,fragmentsURLMap:P,highlightHotspots:M,resizeMode:E,assetsManagerLimits:L})}),[I,n,r,i,u,c,l,h,p,g,y,b,M,E,C,P,w,L]),s((function(){return T(x.current,R.current),function(){S()}}),[S,T]);var U=a((function(){return d(d({},ee),{cursor:D})}),[D]);return t.createElement("div",d({},f,{ref:R,style:U}),t.createElement("canvas",d({},m,{ref:x,"data-testid":"prototype-canvas","data-prototype-status":"prototype-status-".concat((null==F?void 0:F.type.toLowerCase())||"null"),style:ne})),"READY"===(null==F?void 0:F.type)&&v)},re={position:"absolute",inset:0,pointerEvents:"none"};function ie(e){var n=e.visualize,o=void 0!==n&&n,r=te(),s=u((function(){return r()||null})),c=s[0],l=s[1],h=i((function(){l(r()||null)}),[r]);Qt("prototypeSceneChange",h);var p=a((function(){return d(d({},re),{opacity:o?1:0})}),[o]);return c?t.createElement("div",{style:p},c.layers.map((function(e,n){return t.createElement(ae,d({key:"".concat(n,"/").concat(e.id)},e))}))):null}function ae(e){var n=e.bounds,o=e.name,r=e.id,i=e.type,s=$t(),u=qt()||{x:0,y:0},c=u.x,l=u.y,h=a((function(){return d({position:"absolute",left:c/window.devicePixelRatio+n.x*s,top:l/window.devicePixelRatio+n.y*s,width:n.width*s,height:n.height*s,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,c,l,s,i]);return t.createElement("div",{style:h,"data-testid":"".concat(i,"-").concat(se(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 se(t){var e,n;return null!==(n=null===(e=t.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g))||void 0===e?void 0:e.join("-").toLowerCase())&&void 0!==n?n:""}export{rt as CameraMoveContext,ot as CameraZoomingContext,Q as CanvasRenderer,lt as CanvasRendererProvider,Dt as CanvasRendererReact,at as CursorContext,D as DefaultFeatureFlags,et as DocumentContext,T as EventEmitter,N as GestureManager,H as KeyboardManager,I as ListenersCollector,it as PanContext,K as Performance,Ut as PrototypeRenderer,jt as PrototypeRendererProvider,oe as PrototypeRendererReact,R as PrototypeResizeMode,ie as PrototypeTestOverlay,tt as StatusContext,W as WebRendererError,x as WebRendererMode,nt as ZoomContext,z as clamp,Z as convertEmbindVectorToArray,k as debounce,G as extractPointer,B as getSupportedWebGLVersion,F as getiOSVersion,S as isDefinedPresentationManifestArtboard,_ as isTouchDevice,X as logger,J as nextTick,A as parseSafariUserAgent,ct as reducer,O as removeUndefinedKeys,j as touchableClick,vt as useCursor,wt as useDecrementZoom,ht as useDocument,Wt as useEvent,Et as useGenerateDocumentPNG,Lt as useGetArtboardAtPosititon,xt as useGetPanAtPosition,te as useGetScreen,Kt as useGoBack,Jt as useGoForwards,bt as useIncrementZoom,mt as useIsCameraMoving,ft as useIsCameraZooming,Rt as useLockCamera,St as useLogEvent,Mt as useLooseWebGLContext,Ht as useNavigateToFirstFlow,gt as usePan,Yt as usePrototypeCursor,Qt as usePrototypeEvent,qt as usePrototypePan,Vt as usePrototypeState,Xt as usePrototypeStatus,$t as usePrototypeZoom,Nt as useRestartPrototype,Ct as useSetPan,yt as useSetZoom,dt as useStatus,pt as useZoom,Pt as useZoomToFit};
|
package/dist/module-debug.wasm
CHANGED
|
Binary file
|
package/dist/module-release.wasm
CHANGED
|
Binary file
|
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
import { ColorRGBA,
|
|
2
|
-
import { EventEmitter, GestureManager
|
|
3
|
-
|
|
4
|
-
container: HTMLDivElement;
|
|
5
|
-
canvas: HTMLCanvasElement;
|
|
6
|
-
locateFile: string;
|
|
7
|
-
filePath: string;
|
|
8
|
-
imagesURLFormat?: string;
|
|
9
|
-
imagesURLMap?: Record<string, string>;
|
|
10
|
-
fragmentsURLFormat?: string;
|
|
11
|
-
fragmentsURLMap?: Record<string, string>;
|
|
12
|
-
backgroundColor?: ColorRGBA;
|
|
13
|
-
mode: WebRendererMode;
|
|
14
|
-
showTilesBorders?: boolean;
|
|
15
|
-
minimumZoomLevel: number;
|
|
16
|
-
maximumZoomLevel: number;
|
|
17
|
-
preserveDrawingBuffer?: boolean;
|
|
18
|
-
panBoundariesPadding?: number;
|
|
19
|
-
featureFlags?: Partial<typeof DefaultFeatureFlags>;
|
|
20
|
-
initialZoom?: number;
|
|
21
|
-
initialPan?: {
|
|
22
|
-
x: number;
|
|
23
|
-
y: number;
|
|
24
|
-
centerPointInViewport?: boolean;
|
|
25
|
-
};
|
|
26
|
-
manualInitialization?: boolean;
|
|
27
|
-
selectedArtboard?: string | null;
|
|
28
|
-
}
|
|
1
|
+
import { ColorRGBA, WebRendererEvents, WebRendererStatus, PointerInfo, WebRendererDocument, Vec2D } from '../types';
|
|
2
|
+
import { EventEmitter, GestureManager } from '../utils';
|
|
3
|
+
import { CanvasSettings } from './CanvasSettings';
|
|
29
4
|
export declare class CanvasRenderer extends EventEmitter<WebRendererEvents> {
|
|
30
5
|
private settings;
|
|
31
6
|
private status;
|
|
@@ -45,7 +20,7 @@ export declare class CanvasRenderer extends EventEmitter<WebRendererEvents> {
|
|
|
45
20
|
filePath: string;
|
|
46
21
|
document: WebRendererDocument;
|
|
47
22
|
};
|
|
48
|
-
constructor(settings:
|
|
23
|
+
constructor(settings: CanvasSettings);
|
|
49
24
|
private addListeners;
|
|
50
25
|
private handleCanvasResize;
|
|
51
26
|
collectAndEmitDeviceInfo(): Promise<void>;
|
|
@@ -115,7 +90,7 @@ export declare class CanvasRenderer extends EventEmitter<WebRendererEvents> {
|
|
|
115
90
|
handlePointerMoveEvent: (pointerInfo: PointerInfo) => void;
|
|
116
91
|
handleGlobalPointerMoveEvent: (pointerInfo: PointerInfo) => void;
|
|
117
92
|
handlePointerUpEvent: (pointerInfo: PointerInfo) => void;
|
|
118
|
-
selectArtboard(artboardId
|
|
93
|
+
selectArtboard(artboardId: string | null): void;
|
|
119
94
|
disposeFetchWorker(): void;
|
|
120
95
|
dispose(): void;
|
|
121
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRenderer.d.ts","sourceRoot":"","sources":["../../../src/ts/canvas-renderer/CanvasRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"CanvasRenderer.d.ts","sourceRoot":"","sources":["../../../src/ts/canvas-renderer/CanvasRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EAMjB,WAAW,EAGX,mBAAmB,EACnB,KAAK,EAGN,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,YAAY,EACZ,cAAc,EAKf,MAAM,UAAU,CAAA;AAIjB,OAAO,EAAE,cAAc,EAA2B,MAAM,kBAAkB,CAAA;AAQ1E,qBAAa,cAAe,SAAQ,YAAY,CAAC,iBAAiB,CAAC;IACjE,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,cAAc,CAAC,CAAoB;IAC3C,OAAO,CAAC,uBAAuB,CAAwB;IACvD,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,kBAAkB,CAAc;IACxC,OAAO,CAAC,WAAW,CAAS;IAErB,QAAQ,UAAQ;IAEhB,cAAc,EAAE,cAAc,CAAA;IAC9B,kBAAkB,EAAG;QAC1B,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,mBAAmB,CAAA;KAC9B,CAAA;gBAEW,QAAQ,EAAE,cAAc;IAkCpC,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,kBAAkB,CAMzB;IAEK,wBAAwB;IAcjB,IAAI;IAgCjB,qBAAqB;IAyBd,cAAc;IAMrB,OAAO,CAAC,cAAc;IA2GtB,OAAO,CAAC,mBAAmB;IA4E3B,wBAAwB,CAAC,GAAG,EAAE,MAAM;YAOtB,cAAc;YAWd,sBAAsB;IA2D7B,iBAAiB,CAAC,QAAQ,EAAE,OAAO;IAInC,kBAAkB,CAAC,KAAK,EAAE,SAAS;IAa7B,mBAAmB;IAIhC,OAAO,CAAC,sBAAsB,CAE7B;IAED,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACI,iBAAiB;IAUxB;;;OAGG;IACI,SAAS;IAIhB,oEAAoE;YACtD,OAAO;IAsCrB,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,SAAS;IAUjB;;;OAGG;IACI,WAAW,IAAI,mBAAmB;IAyBzC;;;;OAIG;IACI,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAgCjD;;;;OAIG;IACI,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;;;;IAarC,SAAS,IAAI,iBAAiB;IAI9B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAKxD,MAAM,IAAI,KAAK;IAef,OAAO,IAAI,MAAM;IAKjB,sBAAsB,eACf,MAAM,UACV;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,UAOjC;IAEM,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,qBAAqB,UAAQ;IA2B1D,gBAAgB,UACd;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,eAClB,WAAW,UAQzB;IAEM,sBAAsB,gBAAiB,WAAW,UAKxD;IAEM,sBAAsB,gBAAiB,WAAW,UAKxD;IAEM,4BAA4B,gBAAiB,WAAW,UAK9D;IAEM,oBAAoB,gBAAiB,WAAW,UAKtD;IAEM,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IASxC,kBAAkB;IAKlB,OAAO;CAuBf"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ColorRGBA, WebRendererMode } from '../types';
|
|
2
|
+
import { DefaultFeatureFlags } from '../utils';
|
|
3
|
+
type PanSetting = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
centerPointInViewport?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type CanvasSettings = {
|
|
9
|
+
locateFile?: string;
|
|
10
|
+
imagesURLFormat?: string;
|
|
11
|
+
imagesURLMap?: Record<string, string>;
|
|
12
|
+
fragmentsURLFormat?: string;
|
|
13
|
+
fragmentsURLMap?: Record<string, string>;
|
|
14
|
+
backgroundColor?: ColorRGBA;
|
|
15
|
+
mode?: WebRendererMode;
|
|
16
|
+
showTilesBorders?: boolean;
|
|
17
|
+
minimumZoomLevel?: number;
|
|
18
|
+
maximumZoomLevel?: number;
|
|
19
|
+
preserveDrawingBuffer?: boolean;
|
|
20
|
+
featureFlags?: typeof DefaultFeatureFlags;
|
|
21
|
+
manualInitialization?: boolean;
|
|
22
|
+
panBoundariesPadding?: number;
|
|
23
|
+
selectedArtboard?: string | null;
|
|
24
|
+
initialZoom?: number | null;
|
|
25
|
+
initialPan?: PanSetting | null;
|
|
26
|
+
filePath: string;
|
|
27
|
+
container: HTMLDivElement;
|
|
28
|
+
canvas: HTMLCanvasElement;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Container for Canvas settings. All properties are marked as required to
|
|
32
|
+
* force either initizalization or assignment in the constructor.
|
|
33
|
+
*/
|
|
34
|
+
export declare class CanvasSettingsContainer implements Required<CanvasSettings> {
|
|
35
|
+
canvas: HTMLCanvasElement;
|
|
36
|
+
container: HTMLDivElement;
|
|
37
|
+
filePath: string;
|
|
38
|
+
locateFile: string;
|
|
39
|
+
imagesURLFormat: string;
|
|
40
|
+
imagesURLMap: Record<string, string>;
|
|
41
|
+
fragmentsURLFormat: string;
|
|
42
|
+
fragmentsURLMap: Record<string, string>;
|
|
43
|
+
backgroundColor: ColorRGBA;
|
|
44
|
+
mode: WebRendererMode;
|
|
45
|
+
showTilesBorders: boolean;
|
|
46
|
+
minimumZoomLevel: number;
|
|
47
|
+
maximumZoomLevel: number;
|
|
48
|
+
preserveDrawingBuffer: boolean;
|
|
49
|
+
featureFlags: {
|
|
50
|
+
delayedDraw: boolean;
|
|
51
|
+
offscreenCanvas: boolean;
|
|
52
|
+
useDirtyRectsRendering: boolean;
|
|
53
|
+
safariWebGL2: boolean;
|
|
54
|
+
pageBoundariesLimit: boolean;
|
|
55
|
+
};
|
|
56
|
+
manualInitialization: boolean;
|
|
57
|
+
panBoundariesPadding: number;
|
|
58
|
+
selectedArtboard: string | null;
|
|
59
|
+
initialZoom: number | null;
|
|
60
|
+
initialPan: PanSetting | null;
|
|
61
|
+
constructor(canvas: HTMLCanvasElement, container: HTMLDivElement, filePath: string);
|
|
62
|
+
static FromSettings(settings: CanvasSettings): CanvasSettingsContainer;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=CanvasSettings.d.ts.map
|
|
@@ -0,0 +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,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,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;IAG9B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,cAAc,CAAA;IACzB,MAAM,EAAE,iBAAiB,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,QAAQ,CAAC,cAAc,CAAC;IAoB7D,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,cAAc;IACzB,QAAQ,EAAE,MAAM;IArBzB,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;gBAG3B,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,MAAM;IAGzB,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,uBAAuB;CAYvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRendererProvider.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/react/CanvasRendererProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAA;AAkBd,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,UAAW,2BAA2B,
|
|
1
|
+
{"version":3,"file":"CanvasRendererProvider.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/react/CanvasRendererProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAA;AAkBd,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,UAAW,2BAA2B,sBAgMxE,CAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export type CanvasRendererProps = Omit<
|
|
4
|
-
cursor?: string;
|
|
2
|
+
import { CanvasSettings } from '../CanvasSettings';
|
|
3
|
+
export type CanvasRendererProps = Omit<CanvasSettings, 'filePath' | 'container' | 'canvas'> & {
|
|
5
4
|
containerProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
6
5
|
canvasProps?: React.HTMLAttributes<HTMLCanvasElement>;
|
|
7
6
|
children?: ReactNode;
|
|
7
|
+
cursor?: string;
|
|
8
|
+
filePath?: string;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* The CanvasRendererReact component renders a canvas element, and connects it to the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasRendererReact.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/react/CanvasRendererReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,SAAS,EACV,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"CanvasRendererReact.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/react/CanvasRendererReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAMZ,SAAS,EACV,MAAM,OAAO,CAAA;AAId,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,cAAc,EACd,UAAU,GAAG,WAAW,GAAG,QAAQ,CACpC,GAAG;IACF,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;IACrD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAA;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAkBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,UAAW,mBAAmB,sBA4H7D,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebRendererDocument } from '../../types/wasm';
|
|
2
2
|
import { CSSCursor } from '../../types/CSSCursor';
|
|
3
|
-
import { CanvasRendererSettings } from '../CanvasRenderer';
|
|
4
3
|
import { WebRendererStatus } from '../../types';
|
|
4
|
+
import { CanvasSettings } from '../CanvasSettings';
|
|
5
5
|
/**
|
|
6
6
|
* State definition for the source of truth state reducer.
|
|
7
7
|
*/
|
|
@@ -52,5 +52,5 @@ export type ReducerAction = {
|
|
|
52
52
|
/**
|
|
53
53
|
* All Manager static settings, with the "reactive" filePath property omitted.
|
|
54
54
|
*/
|
|
55
|
-
export type CanvasRendererReactSettings = Omit<
|
|
55
|
+
export type CanvasRendererReactSettings = Omit<CanvasSettings, 'filePath' | 'canvas' | 'container'>;
|
|
56
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/react/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/ts/canvas-renderer/react/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,iBAAiB,CAAA;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACpC,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,OAAO,CAAA;IACxB,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;CACrC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA;AAEnD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,cAAc,EACd,UAAU,GAAG,QAAQ,GAAG,WAAW,CACpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrototypeRendererReact.d.ts","sourceRoot":"","sources":["../../../../src/ts/prototype-renderer/react/PrototypeRendererReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA8B,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"PrototypeRendererReact.d.ts","sourceRoot":"","sources":["../../../../src/ts/prototype-renderer/react/PrototypeRendererReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA8B,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAGxD,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,iBAAiB,EACjB,WAAW,GAAG,QAAQ,CACvB,GAAG;IACF,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;IACrD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAA;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CAAA;AAkBD,eAAO,MAAM,sBAAsB,UAAW,sBAAsB,sBA6GnE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sketch-hq/sketch-web-renderer",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.9",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Sketch Web Renderer",
|
|
6
6
|
"repository": "git@github.com:sketch-hq/web-renderer",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@rollup/plugin-replace": "5.0.2",
|
|
50
50
|
"@rollup/plugin-terser": "0.4.3",
|
|
51
51
|
"@rollup/plugin-typescript": "11.1.1",
|
|
52
|
-
"@sketch-hq/sketch-file-format-marina": "7.6.
|
|
52
|
+
"@sketch-hq/sketch-file-format-marina": "7.6.9",
|
|
53
53
|
"@types/node": "18.16.0",
|
|
54
54
|
"@types/offscreencanvas": "2019.7.0",
|
|
55
55
|
"@types/pixelmatch": "5.2.4",
|