@sketch-hq/sketch-web-renderer 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sketch-hq/sketch-web-renderer
2
2
 
3
+ ## 0.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - bf592a8: Ensure SketchWebReact sets Logger.active from the outset.
8
+
3
9
  ## 0.10.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.react);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(function(e){return(()=>{var t,n,o,r,i={519:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});const o={delayedDraw:!0,offscreenCanvas:!1,safariWebGL2:!1,pageBoundariesLimit:!1}},933:(e,t,n)=>{"use strict";n.d(t,{d:()=>j});var o,r=n(480),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}(),a=n(388),s=function(){function e(e,t){var n=this;this.cameraMoveState={status:"inactive"},this.endInteractionDebounced=(0,a.Ds)((function(){"inactive"!==n.cameraMoveState.status&&("moving"===n.cameraMoveState.status&&n.onCameraMoveEnd(),n.setCameraMoveStatus("inactive"))}),100),this.onCameraMoveStart=e,this.onCameraMoveEnd=t}return e.prototype.dispose=function(){this.endInteractionDebounced.cancel(),this.cameraMoveState={status:"inactive"}},e.prototype.handleCameraMoveEvent=function(){var e;this.endInteractionDebounced(),"inactive"===this.cameraMoveState.status&&this.setCameraMoveStatus("uncertain"),"uncertain"===this.cameraMoveState.status&&(e=this.cameraMoveState,Date.now()-e.interactionStartTimestamp>=20)&&(this.onCameraMoveStart(),this.setCameraMoveStatus("moving"))},e.prototype.setCameraMoveStatus=function(e){this.cameraMoveState="uncertain"===e?{status:"uncertain",interactionStartTimestamp:Date.now()}:{status:e}},e}(),u=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),c=function(){return(c=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}).apply(this,arguments)},l=function(e){function t(t,n){var o=e.call(this)||this;return o.listenersCollector=new i,o.state={panning:!1,lastPan:{x:0,y:0},zoomCenter:{x:0,y:0},lastGestureScale:1,mouse:{x:0,y:0},isWaitingForSecondClick:!1,lastMouseClickPosition:{x:0,y:0}},o.handleGestureStart=function(e){e.preventDefault(),o.state.lastGestureScale=e.scale},o.handleGestureChange=function(e){e.preventDefault(),o.state.zoomCenter=o.getCorrectPointerPosition(e);var t=e.scale/o.state.lastGestureScale;o.state.lastGestureScale=e.scale,o.emit("zoomChange",t,o.state.zoomCenter),o.cameraMoveTracker.handleCameraMoveEvent()},o.handleGestureEnd=function(e){e.preventDefault()},o.handlePointerDown=function(e){var t=e instanceof MouseEvent&&0===e.button,n="undefined"!=typeof TouchEvent&&e instanceof TouchEvent;(t||n)&&(e.preventDefault(),o.updateMousePosition(e),o.state.panning=!0,o.state.lastPan.x=o.state.mouse.x,o.state.lastPan.y=o.state.mouse.y,o.emit("mousedown"))},o.handlePointerMove=function(e){o.state.panning||o.updateMousePosition(e)},o.handlePanMove=function(e){if(o.state.panning){e.preventDefault();var t=o.getCorrectPointerPosition(e),n=o.state.lastPan.x-t.x,r=o.state.lastPan.y-t.y;o.state.lastPan.x=t.x,o.state.lastPan.y=t.y,o.emit("panChange",-n,-r),o.cameraMoveTracker.handleCameraMoveEvent()}},o.handleDoubleClick=function(e){if(!("undefined"!=typeof TouchEvent&&e instanceof TouchEvent&&e.touches.length>0)){var t=o.getCorrectPointerPosition(e),n=Math.hypot(o.state.lastMouseClickPosition.x-t.x,o.state.lastMouseClickPosition.y-t.y)>("undefined"!=typeof TouchEvent&&e instanceof TouchEvent?15:0);if(!o.state.isWaitingForSecondClick||n)return o.state.isWaitingForSecondClick=!0,o.state.lastMouseClickPosition=o.getCorrectPointerPosition(e),void o.resetDoubleClick();o.state.isWaitingForSecondClick=!1,o.emit("doubleClick")}},o.resetDoubleClick=(0,a.Ds)((function(){o.state.isWaitingForSecondClick=!1}),500),o.handlePanEnd=function(){o.state.panning=!1},o.handlePointerUp=function(e){"undefined"!=typeof TouchEvent&&e instanceof TouchEvent&&e.touches.length>0||o.emit("mouseup")},o.handleMouseWheel=function(e){e.preventDefault();var t=e.metaKey||e.ctrlKey;if(o.updateMousePosition(e),t){var n=e.ctrlKey?-1:1;o.state.zoomCenter=o.getCorrectPointerPosition(e);var r=1+.01*e.deltaY*n;o.emit("zoomChange",r,o.state.zoomCenter)}else o.emit("panChange",-e.deltaX,-e.deltaY);o.cameraMoveTracker.handleCameraMoveEvent()},o.handleCameraMoveStart=function(){o.emit("cameraMoveStart")},o.handleCameraMoveEnd=function(){o.emit("cameraMoveEnd")},o.target=t,o.settings=n,o.targetBounds=t.getBoundingClientRect(),o.addListeners(),o.cameraMoveTracker=new s(o.handleCameraMoveStart,o.handleCameraMoveEnd),o}return u(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handlePointerDown),this.listenersCollector.add(this.target,"mousemove",this.handlePointerMove),this.listenersCollector.add(document,"mousemove",this.handlePanMove),this.listenersCollector.add(this.target,"mouseup",this.handlePointerUp),this.listenersCollector.add(document,"mouseup",this.handlePanEnd),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel),this.listenersCollector.add(this.target,"mouseup",this.handleDoubleClick),this.listenersCollector.add(this.target,"touchstart",this.handlePointerDown),this.listenersCollector.add(document,"touchmove",this.handlePanMove),this.listenersCollector.add(this.target,"touchmove",this.handlePointerMove),this.listenersCollector.add(this.target,"touchend",this.handlePointerUp),this.listenersCollector.add(document,"touchend",this.handlePanEnd),this.listenersCollector.add(this.target,"touchend",this.handleDoubleClick),this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd)},t.prototype.getCorrectPointerPosition=function(e){var t=(0,a.MP)(e),n={x:0,y:0};return n.x=(0,a.uZ)(t.x-this.targetBounds.x,0,this.target.clientWidth),n.y=(0,a.uZ)(t.y-this.targetBounds.y,0,this.target.clientHeight),n},t.prototype.updateMousePosition=function(e){this.state.mouse=this.getCorrectPointerPosition(e),this.emit("mousemove",this.state.mouse.x,this.state.mouse.y)},t.prototype.getMouse=function(){return c({},this.state.mouse)},t.prototype.setMouse=function(e,t){this.state.mouse.x=e,this.state.mouse.y=t,this.emit("mousemove",this.state.mouse.x,this.state.mouse.y)},t.prototype.getMinZoomLevel=function(){return this.settings.minimumZoomLevel},t.prototype.getMaxZoomLevel=function(){return this.settings.maximumZoomLevel},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.cameraMoveTracker.dispose()},t}(r.v),h=n(475),d=n(419);const f=Symbol("Comlink.proxy"),v=Symbol("Comlink.endpoint"),p=Symbol("Comlink.releaseProxy"),m=Symbol("Comlink.thrown"),b=e=>"object"==typeof e&&null!==e||"function"==typeof e,g=new Map([["proxy",{canHandle:e=>b(e)&&e[f],serialize(e){const{port1:t,port2:n}=new MessageChannel;return y(e,t),[n,[n]]},deserialize:e=>(e.start(),k(e))}],["throw",{canHandle:e=>b(e)&&m in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function y(e,t=self){t.addEventListener("message",(function n(o){if(!o||!o.data)return;const{id:r,type:i,path:a}=Object.assign({path:[]},o.data),s=(o.data.argumentList||[]).map(D);let u;try{const t=a.slice(0,-1).reduce(((e,t)=>e[t]),e),n=a.reduce(((e,t)=>e[t]),e);switch(i){case"GET":u=n;break;case"SET":t[a.slice(-1)[0]]=D(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,s);break;case"CONSTRUCT":u=E(new n(...s));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;y(e,n),u=M(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(e){u={value:e,[m]:0}}Promise.resolve(u).catch((e=>({value:e,[m]:0}))).then((e=>{const[o,a]=x(e);t.postMessage(Object.assign(Object.assign({},o),{id:r}),a),"RELEASE"===i&&(t.removeEventListener("message",n),w(t))}))})),t.start&&t.start()}function w(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function k(e,t){return P(e,[],t)}function C(e){if(e)throw new Error("Proxy has been released and is not useable")}function P(e,t=[],n=function(){}){let o=!1;const r=new Proxy(n,{get(n,i){if(C(o),i===p)return()=>L(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{w(e),o=!0}));if("then"===i){if(0===t.length)return{then:()=>r};const n=L(e,{type:"GET",path:t.map((e=>e.toString()))}).then(D);return n.then.bind(n)}return P(e,[...t,i])},set(n,r,i){C(o);const[a,s]=x(i);return L(e,{type:"SET",path:[...t,r].map((e=>e.toString())),value:a},s).then(D)},apply(n,r,i){C(o);const a=t[t.length-1];if(a===v)return L(e,{type:"ENDPOINT"}).then(D);if("bind"===a)return P(e,t.slice(0,-1));const[s,u]=W(i);return L(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:s},u).then(D)},construct(n,r){C(o);const[i,a]=W(r);return L(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},a).then(D)}});return r}function W(e){const t=e.map(x);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const S=new WeakMap;function M(e,t){return S.set(e,t),e}function E(e){return Object.assign(e,{[f]:!0})}function x(e){for(const[t,n]of g)if(n.canHandle(e)){const[o,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:o},r]}return[{type:"RAW",value:e},S.get(e)||[]]}function D(e){switch(e.type){case"HANDLER":return g.get(e.name).deserialize(e.value);case"RAW":return e.value}}function L(e,t,n){return new Promise((o=>{const r=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===r&&(e.removeEventListener("message",t),o(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:r},t),n)}))}var R,A=n(849),U=n(519),Z=n(332),_=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),O=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 _(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(r.v),T=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),z=function(){return(z=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}).apply(this,arguments)},I=function(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())}))},G=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},F=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o};!function(e){e[e.browser=0]="browser",e[e.worker=1]="worker"}(R||(R={}));var j=function(e){function t(t){var n=e.call(this)||this;return n.handleKeyUp=function(e){var t;null===(t=n.sketchWeb)||void 0===t||t.keyUp(e)},n.handleMouseDoubleClick=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.mouseDoubleClick()},n.handleCameraMoveStart=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.setIsCameraMoving(!0)},n.handleCameraMoveEnd=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.setIsCameraMoving(!1)},n.handleMouseChange=function(e,t){var o;null===(o=n.sketchWeb)||void 0===o||o.setMouse(e,t)},n.handlePanChange=function(e,t){return I(n,void 0,void 0,(function(){var n;return G(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.addPan(e,t),this.emitPanEvent(),[2]}))}))},n.handleZoomChange=function(e,t){return I(n,void 0,void 0,(function(){var n;return G(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.addZoom(e,t),this.emitZoomEvent(),this.emitPanEvent(),[2]}))}))},n.handleMouseDown=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.mouseDown()},n.handleMouseUp=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.mouseUp()},n.handleCanvasResize=function(e){window.requestAnimationFrame((function(){var t,o,r=e[0].contentRect,i=r.width,a=r.height;n.setCanvasSize(i,a),n.gestureManager.updateTargetBounds(),null===(t=n.sketchWeb)||void 0===t||t.setPixelRatio(n.getDevicePixelRatio()),null===(o=n.sketchWeb)||void 0===o||o.setSize(i*n.getDevicePixelRatio(),a*n.getDevicePixelRatio())}))},n.settings=t,n.canvas=t.canvas,n.gestureManager=new l(n.canvas,{minimumZoomLevel:t.minimumZoomLevel,maximumZoomLevel:t.maximumZoomLevel}),n.keyboardManager=new O(document.body),A.Z.active=t.mode===Z.p.debug,n.init(),n}return T(t,e),t.prototype.init=function(){var e;return I(this,void 0,void 0,(function(){var t,n,o;return G(this,(function(r){switch(r.label){case 0:return this.setCanvasSize(this.settings.container.clientWidth,this.settings.container.clientHeight),[4,this.initSketchWeb()];case 1:return r.sent(),[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()];case 2:return"FILE_READY"!==(null==(t=r.sent())?void 0:t.type)?[2]:(n=void 0!==this.settings.initialZoom,o=void 0!==this.settings.initialPan,n||o?n?[4,this.setZoom(this.settings.initialZoom)]:[3,4]:[3,7]);case 3:r.sent(),r.label=4;case 4:return o?[4,this.setPan(this.settings.initialPan.x,this.settings.initialPan.y,this.settings.initialPan.centerPointInViewport)]:[3,6];case 5:r.sent(),r.label=6;case 6:return[3,9];case 7:return[4,this.zoomToFit()];case 8:r.sent(),r.label=9;case 9:return this.sketchWeb.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initSketchWeb=function(){return I(this,void 0,void 0,(function(){var e,t,o,r,i;return G(this,(function(a){switch(a.label){case 0:return e=U.Z.offscreenCanvas&&"function"==typeof this.canvas.transferControlToOffscreen,t=z(z({},this.settings),{size:{width:this.canvas.width,height:this.canvas.height},pixelRatio:this.getDevicePixelRatio()}),e?(this.environment=R.worker,A.Z.debug("Using offscreen canvas"),this.offscreenCanvas=this.canvas.transferControlToOffscreen(),this.worker=new Worker(new URL(n.p+n.u(509),n.b),{type:void 0}),o=k(this.worker),r=this,[4,new o(M(z(z({},t),{canvas:this.offscreenCanvas}),[this.offscreenCanvas]))]):[3,2];case 1:return r.sketchWeb=a.sent(),[3,3];case 2:this.environment=R.browser,A.Z.debug("Using normal canvas"),this.sketchWeb=new h.U(t),a.label=3;case 3:return(i=this.sketchWeb).on("status",this.forwardEvent("status")),i.on("metric",this.forwardEvent("metric")),i.on("warnings",this.forwardEvent("warnings")),i.on("artboardSelected",this.forwardEvent("artboardSelected")),i.on("artboardDeselected",this.forwardEvent("artboardDeselected")),i.on("artboardMouseEnter",this.forwardEvent("artboardMouseEnter")),i.on("artboardMouseLeave",this.forwardEvent("artboardMouseLeave")),i.on("goToArtboard",this.forwardEvent("goToArtboard")),[4,this.sketchWeb.init()];case 4:return a.sent(),[2]}}))}))},t.prototype.forwardEvent=function(e){var t=this,n=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,F([e],n))};return this.environment===R.worker?E(n):n},t.prototype.isRunningInsideWorker=function(){return this.environment===R.worker},t.prototype.looseWebGLContext=function(){var e;null===(e=this.sketchWeb)||void 0===e||e.looseWebGLContext()},t.prototype.addListeners=function(){this.canvasResizeObserver=new ResizeObserver(this.handleCanvasResize),this.canvasResizeObserver.observe(this.settings.container),this.gestureManager.on("panChange",this.handlePanChange),this.gestureManager.on("mousemove",this.handleMouseChange),this.gestureManager.on("mousedown",this.handleMouseDown),this.gestureManager.on("mouseup",this.handleMouseUp),this.gestureManager.on("doubleClick",this.handleMouseDoubleClick),this.gestureManager.on("zoomChange",this.handleZoomChange),this.gestureManager.on("cameraMoveStart",this.handleCameraMoveStart),this.gestureManager.on("cameraMoveEnd",this.handleCameraMoveEnd),this.keyboardManager.on("keyUp",this.handleKeyUp)},t.prototype.emitPanEvent=function(){var e;return I(this,void 0,void 0,(function(){var t;return G(this,(function(n){switch(n.label){case 0:return[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()];case 1:return(t=n.sent())?(this.emit("pan",t.x,t.y),[2]):[2]}}))}))},t.prototype.emitZoomEvent=function(){var e;return I(this,void 0,void 0,(function(){var t;return G(this,(function(n){switch(n.label){case 0:return[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()];case 1:return"undefined"===(t=n.sent())||this.emit("zoom",t),[2]}}))}))},t.prototype.getDevicePixelRatio=function(){return(0,d.uZ)(window.devicePixelRatio,1,2)},t.prototype.setCanvasSize=function(e,t){this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.getDevicePixelRatio(),this.canvas.height=t*this.getDevicePixelRatio()},t.prototype.zoomToFit=function(){return I(this,void 0,void 0,(function(){return G(this,(function(e){switch(e.label){case 0:return[4,this.sketchWeb.scaleDocumentToFit()];case 1:return e.sent(),this.emitZoomEvent(),this.emitPanEvent(),[2]}}))}))},t.prototype.getStatus=function(){var e;return I(this,void 0,void 0,(function(){return G(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()]}))}))},t.prototype.generateDocumentPNG=function(){var e;return I(this,void 0,void 0,(function(){return G(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},t.prototype.getArtboardAtPosition=function(e,t){var n;return I(this,void 0,void 0,(function(){return G(this,(function(o){switch(o.label){case 0:return[4,null===(n=this.sketchWeb)||void 0===n?void 0:n.getArtboardAtPosition(e,t)];case 1:return[2,o.sent()||null]}}))}))},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWeb)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.setPan=function(e,t,n){var o;return I(this,void 0,void 0,(function(){return G(this,(function(r){switch(r.label){case 0:return[4,null===(o=this.sketchWeb)||void 0===o?void 0:o.setPan(e,t,Boolean(n))];case 1:return r.sent(),this.emitPanEvent(),[2]}}))}))},t.prototype.setZoom=function(e,t){var n;return I(this,void 0,void 0,(function(){var o;return G(this,(function(r){return o=null!=t?t:this.getCanvasCenterPoint(),null===(n=this.sketchWeb)||void 0===n||n.setZoom(e,o),this.emitZoomEvent(),this.emitPanEvent(),[2]}))}))},t.prototype.getCanvasCenterPoint=function(){var e=this.canvas.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()},t.prototype.getPan=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()},t.prototype.dispose=function(){var e,t,n,o;return I(this,void 0,void 0,(function(){return G(this,(function(r){switch(r.label){case 0:return this.gestureManager.dispose(),this.keyboardManager.dispose(),null===(e=this.canvasResizeObserver)||void 0===e||e.disconnect(),this.isRunningInsideWorker()?[4,null===(t=this.sketchWeb)||void 0===t?void 0:t.dispose()]:[3,2];case 1:return r.sent(),null===(n=this.worker)||void 0===n||n.terminate(),[3,3];case 2:null===(o=this.sketchWeb)||void 0===o||o.dispose(),r.label=3;case 3:return[2]}}))}))},t}(r.v)},475:(e,t,n)=>{"use strict";n.d(t,{U:()=>v});var o,r=n(419),i=n(519),a=n(480),s=n(108),u=n(849),c=n(758),l=n(332),h=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),d=function(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())}))},f=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},v=(globalThis.indexedDB,function(e){function t(t){var n=t.canvas,o=t.locateFile,i=t.filePath,a=t.imagesURLFormat,c=t.imagesURLMap,h=t.backgroundColor,d=void 0===h?{r:1,g:1,b:1,a:1}:h,f=t.highlightColor,v=void 0===f?{r:0,g:0,b:0,a:1}:f,p=t.size,m=t.pixelRatio,b=t.mode,g=t.showTilesBorders,y=void 0!==g&&g,w=t.minimumZoomLevel,k=t.maximumZoomLevel,C=t.preserveDrawingBuffer,P=void 0!==C&&C,W=t.panBoundariesPadding,S=void 0===W?40:W,M=e.call(this)||this;return M.status={type:"INIT"},M.handleWebGLContextLost=function(){M.setStatus({type:"WEBGL_CONTEXT_LOST"})},M.debouncedFullDraw=(0,r.Ds)((function(){return M.draw(!0)}),200),M.canvas=n,M.locateFile=o,M.filePath=i,M.imagesURLFormat=a,M.imagesURLMap=c,M.backgroundColor=d,M.highlightColor=v,M.size=p,M.pixelRatio=m,M.mode=b,M.showTilesBorders=y,M.currentWebGLVersion=(0,r.wX)(),M.zoomLevels={min:w,max:k},M.preserveDrawingBuffer=P,M.panBoundariesPadding=S,u.Z.active=b===l.p.debug,M.traceFirstPaint=new s.S("FirstPaint"),M}return h(t,e),t.prototype.init=function(){return d(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:this.setStatus({type:"INIT"}),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,this.initSketchWebWasm()];case 2:return t.sent(),[4,this.setFile(this.filePath)];case 3:return t.sent(),[3,5];case 4:return e=t.sent(),[2,this.fail(e instanceof c.k?e:new c.k("ERROR","Unexpected exception initializing the web renderer",e))];case 5:return[2]}}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new s.S("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.draw(!0,!1),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){u.Z.debug("[C++] "+e)},logWarning:function(e){u.Z.warning("[C++] "+e)},logError:function(e){u.Z.error("[C++] "+e)},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(u.Z.warning("Not able to resolve the url for the image with UUID: "+t),"")},onDrawComplete:this.handleDrawComplete.bind(this),onArtboardMouseEnter:function(t){e.emit("artboardMouseEnter",t)},onArtboardMouseLeave:function(t){e.emit("artboardMouseLeave",t)},onArtboardSelected:function(t){e.emit("artboardSelected",t)},onArtboardDeselected:function(t){e.emit("artboardDeselected",t)},onGoToArtboard:function(t,n){e.emit("goToArtboard",t,n)}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n=new s.S("ImagesDownload");e.sketchWebWasm.downloadImages((function(){n.printMeasurement(),e.emit("metric",n.measure()),u.Z.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return d(this,void 0,void 0,(function(){var e,t,o,r,a,h,d,v=this;return f(this,(function(f){switch(f.label){case 0:return e=new s.S("WasmModuleDownload"),this.mode!==l.p.debug?[3,2]:[4,n.e(425).then(n.t.bind(n,425,23))];case 1:return o=f.sent(),[3,4];case 2:return[4,n.e(816).then(n.t.bind(n,816,23))];case 3:o=f.sent(),f.label=4;case 4:t=o.default,f.label=5;case 5:return f.trys.push([5,7,,8]),r=this,[4,t({FeatureFlags:i.Z,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return v.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return r.wasmModule=f.sent(),[3,8];case 7:throw a=f.sent(),new c.k("WASM_ERROR","An error occurred while trying to create the wasm module.",a);case 8:if(e.printMeasurement(),this.emit("metric",e.measure()),h={antialias:!1,majorVersion:this.currentWebGLVersion,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},u.Z.debug("Using WebGL "+h.majorVersion),!(d=this.wasmModule.GL.createContext(this.canvas,h)))throw new c.k("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=d;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height)}catch(e){throw new c.k("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.sketchWebWasm.setPixelRatio(this.pixelRatio),this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setHighlightColor(this.highlightColor.r,this.highlightColor.g,this.highlightColor.b,this.highlightColor.a),this.sketchWebWasm.setRendererConfiguration({showTilesBorders:this.showTilesBorders}),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.generateDocumentPNG=function(){var e;return d(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this.downloadImages()];case 1:return t.sent(),[2,null===(e=this.sketchWebWasm)||void 0===e?void 0:e.generateDocumentPNG()]}}))}))},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"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit(),this.delayedDraw()},t.prototype.setFile=function(e){return d(this,void 0,void 0,(function(){var t=this;return f(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){t.sketchWebWasm.setFile(e,(function(e){if(void 0===e&&(e=[]),e.length){u.Z.debug("Parser warnings: "+e);var o=e.map((function(e){return{key:e}}));t.emit("warnings",o)}t.setStatus({type:"FILE_READY"}),n()}),(function(){return o(new c.k("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.delayedDraw=function(){if(!i.Z.delayedDraw)return this.draw(!0);this.draw(),this.debouncedFullDraw()},t.prototype.draw=function(e,t){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),null===(n=this.sketchWebWasm)||void 0===n||n.setNeedsUpdate(e,t)},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:e.toString()+(e.cause?"\nWrapped Error: "+e.cause.toString():"")}),u.Z.error(e),e.cause&&u.Z.error(e.cause)},t.prototype.setPixelRatio=function(e){var t;this.pixelRatio=e,null===(t=this.sketchWebWasm)||void 0===t||t.setPixelRatio(e),this.delayedDraw()},t.prototype.setSize=function(e,t){var n;this.size.width=e,this.size.height=t,this.canvas.width=e,this.canvas.height=t,null===(n=this.sketchWebWasm)||void 0===n||n.resize(e,t)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(u.Z.debug("Status transition "+this.status.type+" => "+e.type+"}"),this.status=e,this.emit("status",e))},t.prototype.getArtboardAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getArtboardAtPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(o=this.sketchWebWasm)||void 0===o||o.setZoom(e),this.delayedDraw()},t.prototype.addZoom=function(e,t){var n,o;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(o=this.sketchWebWasm)||void 0===o||o.addZoom(e),this.delayedDraw()},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1),null===(o=this.sketchWebWasm)||void 0===o||o.setPan(e,t,n),this.delayedDraw()},t.prototype.addPan=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.addPan(e,t),this.delayedDraw()},t.prototype.getPan=function(){if(this.sketchWebWasm)return this.sketchWebWasm.getPan()},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.setMouse=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.setMouse(e,t)},t.prototype.setIsCameraMoving=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraMoving(e)},t.prototype.mouseDown=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDown()},t.prototype.mouseUp=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseUp()},t.prototype.mouseDoubleClick=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDoubleClick()},t.prototype.keyUp=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.keyUp(e)},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete()}catch(e){this.fail(new c.k("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}this.sketchWebWasm=null},t}(a.v))},948:(e,t,n)=>{"use strict";n.d(t,{z0:()=>U,oW:()=>Z,JB:()=>m,SC:()=>x,zB:()=>L,GC:()=>W,xH:()=>v,z7:()=>R,rR:()=>C,JU:()=>M,vN:()=>g,Y6:()=>D,$5:()=>w});var o,r=n(297),i=n.n(r),a=n(933),s=n(849),u=function(){return(u=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}).apply(this,arguments)},c=function(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())}))},l=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},h=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o},d=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.Z.debug.apply(s.Z,h(["SketchWebContext"],e))};!function(e){e.Draggable="grab",e.Dragging="grabbing",e.Hover="pointer",e.Default="auto"}(o||(o={}));var f=(0,r.createContext)(void 0),v=function(){var e=(0,r.useContext)(f);if(void 0===e)throw Error("useSketchWebManager must be used within a SketchWebProvider");return e},p=(0,r.createContext)(void 0),m=function(){var e=(0,r.useContext)(p);if(void 0===e)throw Error("useSketchWebActions must be used within a SketchWebProvider");return e},b=(0,r.createContext)(void 0),g=function(){var e=(0,r.useContext)(b);if(void 0===e)throw Error("useSketchWebStatus must be used within a SketchWebProvider");return e},y=(0,r.createContext)(void 0),w=function(){var e=(0,r.useContext)(y);if(void 0===e)throw Error("useSketchWebZoom must be used within a SketchWebProvider");return e},k=(0,r.createContext)(void 0),C=function(){var e=(0,r.useContext)(k);if(void 0===e)throw Error("useSketchWebPan must be used within a SketchWebProvider");return e},P=(0,r.createContext)(void 0),W=function(){var e=(0,r.useContext)(P);if(void 0===e)throw Error("useSketchWebHoveredArtboardUUID must be used within a SketchWebProvider");return e},S=(0,r.createContext)(void 0),M=function(){var e=(0,r.useContext)(S);if(void 0===e)throw Error("useSketchWebSelectedArtboardUUID must be used within a SketchWebProvider");return e},E=(0,r.createContext)(void 0),x=function(){var e=(0,r.useContext)(E);if(void 0===e)throw Error("useSketchWebCursor must be used within a SketchWebProvider");return e},D=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("warnings",e),function(){null==t||t.off("warnings",e)}}),[t,e])},L=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("goToArtboard",e),function(){null==t||t.off("goToArtboard",e)}}),[t,e])},R=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("metric",e),function(){null==t||t.off("metric",e)}}),[t,e])},A=function(e,t){switch(d('dispatched: "'+t.type+'"',t),t.type){case"on-status":return u(u({},e),{status:t.status});case"on-zoom":return u(u({},e),{zoom:t.zoom});case"on-pan":return u(u({},e),{pan:t.pan});case"dispose":return u(u({},e),{status:null,filePath:null,selectedArtboardUUID:null,hoveredArtboardUUID:null,zoom:null,pan:null,cursor:o.Default});case"post-init":return u(u({},e),{status:t.status,zoom:t.zoom});case"set-file-path":return u(u({},e),{filePath:t.filePath});case"on-artboard-mouse-enter":return u(u({},e),{hoveredArtboardUUID:t.uuid,cursor:o.Hover});case"on-artboard-mouse-leave":return u(u({},e),{hoveredArtboardUUID:null,cursor:e.isMouseDown?o.Dragging:o.Draggable});case"on-artboard-selected":return u(u({},e),{selectedArtboardUUID:t.uuid});case"on-artboard-deselected":return u(u({},e),{selectedArtboardUUID:null});case"on-mouse-down":return u(u({},e),{cursor:o.Dragging,isMouseDown:!0});case"on-mouse-up":return u(u({},e),{cursor:e.hoveredArtboardUUID?o.Hover:o.Draggable,isMouseDown:!1});default:return e}},U=function(e){var t=e.children,n=(0,r.useRef)(null),s=(0,r.useRef)(null),h=(0,r.useReducer)(A,{pan:null,zoom:null,status:null,filePath:null,hoveredArtboardUUID:null,selectedArtboardUUID:null,cursor:o.Default,isMouseDown:!1}),v=h[0],m=v.status,g=v.zoom,w=v.pan,C=v.hoveredArtboardUUID,W=v.selectedArtboardUUID,M=v.cursor,x=h[1],D=(0,r.useCallback)((function(e){return x({type:"on-zoom",zoom:e})}),[]),L=(0,r.useCallback)((function(e,t){return x({type:"on-pan",pan:{x:e,y:t}})}),[]),R=(0,r.useCallback)((function(e){x({type:"on-status",status:e})}),[]),U=(0,r.useCallback)((function(e){return x({type:"on-artboard-mouse-enter",uuid:e})}),[]),Z=(0,r.useCallback)((function(){return x({type:"on-artboard-mouse-leave"})}),[]),_=(0,r.useCallback)((function(e){x({type:"on-artboard-selected",uuid:e})}),[]),O=(0,r.useCallback)((function(){return x({type:"on-artboard-deselected"})}),[]),T=(0,r.useCallback)((function(){return x({type:"on-mouse-down"})}),[]),z=(0,r.useCallback)((function(){return x({type:"on-mouse-up"})}),[]),I=(0,r.useCallback)((function(){n.current&&(d("dispose"),n.current.off("status",R),n.current.off("artboardMouseEnter",U),n.current.off("artboardMouseLeave",Z),n.current.off("artboardSelected",_),n.current.off("artboardDeselected",O),n.current.off("zoom",D),n.current.off("pan",L),n.current.gestureManager.off("mousedown",T),n.current.gestureManager.off("mouseup",z),n.current.dispose(),n.current=null,x({type:"dispose"}))}),[R,L,D,U,Z,_,O,z,T]),G=(0,r.useCallback)((function(e){e&&!n.current&&s.current&&(d("init"),x({type:"set-file-path",filePath:e}),n.current=new a.d(u(u({},s.current),{filePath:e})),n.current.on("status",R),n.current.on("artboardMouseEnter",U),n.current.on("artboardMouseLeave",Z),n.current.on("artboardSelected",_),n.current.on("artboardDeselected",O),n.current.on("zoom",D),n.current.on("pan",L),n.current.gestureManager.on("mousedown",T),n.current.gestureManager.on("mouseup",z),c(void 0,void 0,void 0,(function(){var e,t,o,r,i,a;return l(this,(function(s){switch(s.label){case 0:return[4,null===(r=n.current)||void 0===r?void 0:r.getPan()];case 1:return e=s.sent()||null,t=x,o={type:"post-init",zoom:(null===(i=n.current)||void 0===i?void 0:i.getZoom())||null},[4,null===(a=n.current)||void 0===a?void 0:a.getStatus()];case 2:return t.apply(void 0,[(o.status=s.sent()||null,o.pan=null!=e?e:null,o)]),[2]}}))})))}),[R,D,L,U,Z,_,O,T,z]),F=(0,r.useCallback)((function(e){d("setSettings",e),s.current=e}),[]),j=(0,r.useCallback)((function(e){var t;d("setZoom",e),null===(t=n.current)||void 0===t||t.setZoom(e)}),[]),B=(0,r.useCallback)((function(){var e,t;d("incrementZoom"),"number"==typeof g&&(t=g>=1?Math.round(2*g):g>.5?1:2*g,null===(e=n.current)||void 0===e||e.setZoom(t))}),[g]),N=(0,r.useCallback)((function(){var e;d("decrementZoom"),"number"==typeof g&&(null===(e=n.current)||void 0===e||e.setZoom(g/2))}),[g]),H=(0,r.useCallback)((function(e){var t,o=e.x,r=e.y,i=e.centerPointInViewport;d("setPan",o,r,"centerPointInViewport",i),null===(t=n.current)||void 0===t||t.setPan(o,r,i)}),[]),Y=(0,r.useCallback)((function(){var e;d("zoomToFit"),null===(e=n.current)||void 0===e||e.zoomToFit()}),[]),V=(0,r.useCallback)((function(){var e;d("looseWebGLContext"),null===(e=n.current)||void 0===e||e.looseWebGLContext()}),[]),X=(0,r.useCallback)((function(){return c(void 0,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return d("generateDocumentPNG"),[4,null===(e=n.current)||void 0===e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[]),q=(0,r.useCallback)((function(e,t){return c(void 0,void 0,void 0,(function(){var o;return l(this,(function(r){switch(r.label){case 0:return d("getArtboardAtPosition",e,t),[4,null===(o=n.current)||void 0===o?void 0:o.getArtboardAtPosition(e,t)];case 1:return[2,r.sent()||null]}}))}))}),[]),K=(0,r.useCallback)((function(e,t){return c(void 0,void 0,void 0,(function(){var o;return l(this,(function(r){switch(r.label){case 0:return d("invoked: getPanAtPosition",e,t),[4,null===(o=n.current)||void 0===o?void 0:o.getPanAtPosition(e,t)];case 1:return[2,r.sent()||null]}}))}))}),[]),J=(0,r.useMemo)((function(){return{setSettings:F,init:G,dispose:I,setZoom:j,incrementZoom:B,decrementZoom:N,setPan:H,zoomToFit:Y,looseWebGLContext:V,generateDocumentPNG:X,getArtboardAtPosition:q,getPanAtPosition:K}}),[F,G,I,j,B,N,H,Y,V,X,q,K]);return i().createElement(f.Provider,{value:n.current},i().createElement(p.Provider,{value:J},i().createElement(b.Provider,{value:m},i().createElement(y.Provider,{value:g},i().createElement(k.Provider,{value:w},i().createElement(S.Provider,{value:W},i().createElement(P.Provider,{value:C},i().createElement(E.Provider,{value:M},t))))))))},Z=function(e){var t=e.filePath,n=e.locateFile,o=e.imagesURLFormat,a=e.imagesURLMap,s=e.backgroundColor,u=e.highlightColor,c=e.mode,l=e.showTilesBorders,h=e.minimumZoomLevel,d=e.maximumZoomLevel,f=e.preserveDrawingBuffer,v=e.panBoundariesPadding,p=e.initialPan,b=e.initialZoom,y=e.onCanvasClick,w=e.onCanvasContextMenu,k=(0,r.useState)(null),C=k[0],P=k[1],W=(0,r.useState)(null),S=W[0],M=W[1],E=m(),D=E.dispose,L=E.setSettings,R=E.init,A=x(),U=g();return(0,r.useEffect)((function(){S&&C&&L({locateFile:n,imagesURLFormat:o,imagesURLMap:a,backgroundColor:s,highlightColor:u,mode:c,showTilesBorders:l,minimumZoomLevel:h,maximumZoomLevel:d,preserveDrawingBuffer:f,panBoundariesPadding:v,initialPan:p,initialZoom:b,container:S,canvas:C})}),[L,n,o,a,s,u,c,l,h,d,f,v,p,b,S,C]),(0,r.useEffect)((function(){if(t&&C&&S)return R(t),function(){return D()}}),[D,R,t,C,S]),i().createElement("div",{ref:function(e){return M(e)},style:{position:"relative",width:"100%",height:"100%"}},i().createElement("canvas",{onClick:y,onContextMenu:w,ref:function(e){return P(e)},"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-"+((null==U?void 0:U.type.toLowerCase())||"null"),style:{position:"absolute",inset:"0",cursor:A}}))}},758:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var o,r=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"("+n+") "+o)||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return r(t,e),t}(Error)},18:()=>{},689:()=>{},332:(e,t,n)=>{"use strict";var o;n.d(t,{p:()=>o}),function(e){e.debug="debug",e.release="release"}(o||(o={}))},119:()=>{},312:()=>{},480:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var o=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.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}()},849:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o};const r=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,o(["[SketchWeb] [Debug]"],e))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,o(["[SketchWeb] [Warn]"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,o(["[SketchWeb] [Error]"],e))},e}())},108:(e,t,n)=>{"use strict";n.d(t,{S:()=>r});var o=n(849),r=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),o.Z.debug("[Performance] Start: "+this.label)}return e.prototype.measure=function(){var e=performance.now()-this.startTime;return{duration:e,end:this.startTimestamp+e,start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);o.Z.debug("[Performance] End: "+this.label+" -> "+t+" ms")}else{var n=(e/1e3).toFixed(2);o.Z.debug("[Performance] End: "+this.label+" -> "+n+" s")}},e}()},419:(e,t,n)=>{"use strict";n.d(t,{uZ:()=>o.uZ,Ds:()=>o.Ds,wX:()=>o.wX});var o=n(388)},388:(e,t,n)=>{"use strict";n.d(t,{Ds:()=>i,MP:()=>a,uZ:()=>s,wX:()=>u});var o=n(519),r=n(66);function i(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 a(e){var t,n;return{x:null!==(t=e.pageX)&&void 0!==t?t:e.clientX,y:null!==(n=e.pageY)&&void 0!==n?n:e.clientY}}function s(e,t,n){return Math.max(t,Math.min(n,e))}function u(){return(0,r.t)()&&!o.Z.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}},66:(e,t,n)=>{"use strict";n.d(t,{t:()=>r});var o=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,r=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(o);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}}}},297:t=>{"use strict";t.exports=e}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.m=i,s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var r=Object.create(null);s.r(r);var i={};t=t||[null,n({}),n([]),n(n)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>"static/js/web-renderer-"+{425:"370688708cb08dced537",509:"ce56606bbb268b01c7c9",816:"5f40dbb4c3823984584b"}[e]+".chunk.js",s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},r="@sketch-hq/sketch-web-renderer:",s.l=(e,t,n,i)=>{if(o[e])o[e].push(t);else{var a,u;if(void 0!==n)for(var c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var h=c[l];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==r+n){a=h;break}}a||(u=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",r+n),a.src=e),o[e]=[t];var d=(t,n)=>{a.onerror=a.onload=null,clearTimeout(f);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),u&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.p="/",(()=>{s.b=document.baseURI||self.location.href;var e={826:0};s.f.j=(t,n)=>{var o=s.o(e,t)?e[t]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise(((n,r)=>o=e[t]=[n,r]));n.push(o[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(n=>{if(s.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}}),"chunk-"+t,t)}};var t=(t,n)=>{var o,r,[i,a,u]=n,c=0;if(i.some((t=>0!==e[t]))){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);u&&u(s)}for(t&&t(n);c<i.length;c++)r=i[c],s.o(e,r)&&e[r]&&e[r][0](),e[i[c]]=0},n=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var u={};return(()=>{"use strict";s.r(u),s.d(u,{default:()=>d,SketchWeb:()=>t.U,SketchWebMode:()=>i.p,SketchWebError:()=>c.k,SketchWebProvider:()=>h.z0,SketchWebReact:()=>h.oW,useSketchWebActions:()=>h.JB,useSketchWebCursor:()=>h.SC,useSketchWebGoToArtboardEvent:()=>h.zB,useSketchWebHoveredArtboardUUID:()=>h.GC,useSketchWebManager:()=>h.xH,useSketchWebMetricEvent:()=>h.z7,useSketchWebPan:()=>h.rR,useSketchWebSelectedArtboardUUID:()=>h.JU,useSketchWebStatus:()=>h.vN,useSketchWebWarningsEvent:()=>h.Y6,useSketchWebZoom:()=>h.$5});var e=s(933),t=s(475),n=s(18),o={};for(const e in n)["default","SketchWeb"].indexOf(e)<0&&(o[e]=()=>n[e]);s.d(u,o);var r=s(119);o={};for(const e in r)["default","SketchWeb"].indexOf(e)<0&&(o[e]=()=>r[e]);s.d(u,o);var i=s(332),a=s(312);o={};for(const e in a)["default","SketchWeb","SketchWebMode"].indexOf(e)<0&&(o[e]=()=>a[e]);s.d(u,o);var c=s(758),l=s(689);o={};for(const e in l)["default","SketchWeb","SketchWebMode","SketchWebError"].indexOf(e)<0&&(o[e]=()=>l[e]);s.d(u,o);var h=s(948);const d=e.d})(),u})()}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(require("react")):t(e.react);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(function(e){return(()=>{var t,n,o,r,i={519:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});const o={delayedDraw:!0,offscreenCanvas:!1,safariWebGL2:!1,pageBoundariesLimit:!1}},933:(e,t,n)=>{"use strict";n.d(t,{d:()=>j});var o,r=n(480),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}(),a=n(388),s=function(){function e(e,t){var n=this;this.cameraMoveState={status:"inactive"},this.endInteractionDebounced=(0,a.Ds)((function(){"inactive"!==n.cameraMoveState.status&&("moving"===n.cameraMoveState.status&&n.onCameraMoveEnd(),n.setCameraMoveStatus("inactive"))}),100),this.onCameraMoveStart=e,this.onCameraMoveEnd=t}return e.prototype.dispose=function(){this.endInteractionDebounced.cancel(),this.cameraMoveState={status:"inactive"}},e.prototype.handleCameraMoveEvent=function(){var e;this.endInteractionDebounced(),"inactive"===this.cameraMoveState.status&&this.setCameraMoveStatus("uncertain"),"uncertain"===this.cameraMoveState.status&&(e=this.cameraMoveState,Date.now()-e.interactionStartTimestamp>=20)&&(this.onCameraMoveStart(),this.setCameraMoveStatus("moving"))},e.prototype.setCameraMoveStatus=function(e){this.cameraMoveState="uncertain"===e?{status:"uncertain",interactionStartTimestamp:Date.now()}:{status:e}},e}(),u=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),c=function(){return(c=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}).apply(this,arguments)},l=function(e){function t(t,n){var o=e.call(this)||this;return o.listenersCollector=new i,o.state={panning:!1,lastPan:{x:0,y:0},zoomCenter:{x:0,y:0},lastGestureScale:1,mouse:{x:0,y:0},isWaitingForSecondClick:!1,lastMouseClickPosition:{x:0,y:0}},o.handleGestureStart=function(e){e.preventDefault(),o.state.lastGestureScale=e.scale},o.handleGestureChange=function(e){e.preventDefault(),o.state.zoomCenter=o.getCorrectPointerPosition(e);var t=e.scale/o.state.lastGestureScale;o.state.lastGestureScale=e.scale,o.emit("zoomChange",t,o.state.zoomCenter),o.cameraMoveTracker.handleCameraMoveEvent()},o.handleGestureEnd=function(e){e.preventDefault()},o.handlePointerDown=function(e){var t=e instanceof MouseEvent&&0===e.button,n="undefined"!=typeof TouchEvent&&e instanceof TouchEvent;(t||n)&&(e.preventDefault(),o.updateMousePosition(e),o.state.panning=!0,o.state.lastPan.x=o.state.mouse.x,o.state.lastPan.y=o.state.mouse.y,o.emit("mousedown"))},o.handlePointerMove=function(e){o.state.panning||o.updateMousePosition(e)},o.handlePanMove=function(e){if(o.state.panning){e.preventDefault();var t=o.getCorrectPointerPosition(e),n=o.state.lastPan.x-t.x,r=o.state.lastPan.y-t.y;o.state.lastPan.x=t.x,o.state.lastPan.y=t.y,o.emit("panChange",-n,-r),o.cameraMoveTracker.handleCameraMoveEvent()}},o.handleDoubleClick=function(e){if(!("undefined"!=typeof TouchEvent&&e instanceof TouchEvent&&e.touches.length>0)){var t=o.getCorrectPointerPosition(e),n=Math.hypot(o.state.lastMouseClickPosition.x-t.x,o.state.lastMouseClickPosition.y-t.y)>("undefined"!=typeof TouchEvent&&e instanceof TouchEvent?15:0);if(!o.state.isWaitingForSecondClick||n)return o.state.isWaitingForSecondClick=!0,o.state.lastMouseClickPosition=o.getCorrectPointerPosition(e),void o.resetDoubleClick();o.state.isWaitingForSecondClick=!1,o.emit("doubleClick")}},o.resetDoubleClick=(0,a.Ds)((function(){o.state.isWaitingForSecondClick=!1}),500),o.handlePanEnd=function(){o.state.panning=!1},o.handlePointerUp=function(e){"undefined"!=typeof TouchEvent&&e instanceof TouchEvent&&e.touches.length>0||o.emit("mouseup")},o.handleMouseWheel=function(e){e.preventDefault();var t=e.metaKey||e.ctrlKey;if(o.updateMousePosition(e),t){var n=e.ctrlKey?-1:1;o.state.zoomCenter=o.getCorrectPointerPosition(e);var r=1+.01*e.deltaY*n;o.emit("zoomChange",r,o.state.zoomCenter)}else o.emit("panChange",-e.deltaX,-e.deltaY);o.cameraMoveTracker.handleCameraMoveEvent()},o.handleCameraMoveStart=function(){o.emit("cameraMoveStart")},o.handleCameraMoveEnd=function(){o.emit("cameraMoveEnd")},o.target=t,o.settings=n,o.targetBounds=t.getBoundingClientRect(),o.addListeners(),o.cameraMoveTracker=new s(o.handleCameraMoveStart,o.handleCameraMoveEnd),o}return u(t,e),t.prototype.updateTargetBounds=function(){this.targetBounds=this.target.getBoundingClientRect()},t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"mousedown",this.handlePointerDown),this.listenersCollector.add(this.target,"mousemove",this.handlePointerMove),this.listenersCollector.add(document,"mousemove",this.handlePanMove),this.listenersCollector.add(this.target,"mouseup",this.handlePointerUp),this.listenersCollector.add(document,"mouseup",this.handlePanEnd),this.listenersCollector.add(this.target,"wheel",this.handleMouseWheel),this.listenersCollector.add(this.target,"mouseup",this.handleDoubleClick),this.listenersCollector.add(this.target,"touchstart",this.handlePointerDown),this.listenersCollector.add(document,"touchmove",this.handlePanMove),this.listenersCollector.add(this.target,"touchmove",this.handlePointerMove),this.listenersCollector.add(this.target,"touchend",this.handlePointerUp),this.listenersCollector.add(document,"touchend",this.handlePanEnd),this.listenersCollector.add(this.target,"touchend",this.handleDoubleClick),this.listenersCollector.add(this.target,"gesturestart",this.handleGestureStart),this.listenersCollector.add(this.target,"gesturechange",this.handleGestureChange),this.listenersCollector.add(this.target,"gestureend",this.handleGestureEnd)},t.prototype.getCorrectPointerPosition=function(e){var t=(0,a.MP)(e),n={x:0,y:0};return n.x=(0,a.uZ)(t.x-this.targetBounds.x,0,this.target.clientWidth),n.y=(0,a.uZ)(t.y-this.targetBounds.y,0,this.target.clientHeight),n},t.prototype.updateMousePosition=function(e){this.state.mouse=this.getCorrectPointerPosition(e),this.emit("mousemove",this.state.mouse.x,this.state.mouse.y)},t.prototype.getMouse=function(){return c({},this.state.mouse)},t.prototype.setMouse=function(e,t){this.state.mouse.x=e,this.state.mouse.y=t,this.emit("mousemove",this.state.mouse.x,this.state.mouse.y)},t.prototype.getMinZoomLevel=function(){return this.settings.minimumZoomLevel},t.prototype.getMaxZoomLevel=function(){return this.settings.maximumZoomLevel},t.prototype.dispose=function(){this.listenersCollector.dispose(),this.cameraMoveTracker.dispose()},t}(r.v),h=n(475),d=n(419);const f=Symbol("Comlink.proxy"),v=Symbol("Comlink.endpoint"),p=Symbol("Comlink.releaseProxy"),m=Symbol("Comlink.thrown"),b=e=>"object"==typeof e&&null!==e||"function"==typeof e,g=new Map([["proxy",{canHandle:e=>b(e)&&e[f],serialize(e){const{port1:t,port2:n}=new MessageChannel;return y(e,t),[n,[n]]},deserialize:e=>(e.start(),k(e))}],["throw",{canHandle:e=>b(e)&&m in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function y(e,t=self){t.addEventListener("message",(function n(o){if(!o||!o.data)return;const{id:r,type:i,path:a}=Object.assign({path:[]},o.data),s=(o.data.argumentList||[]).map(D);let u;try{const t=a.slice(0,-1).reduce(((e,t)=>e[t]),e),n=a.reduce(((e,t)=>e[t]),e);switch(i){case"GET":u=n;break;case"SET":t[a.slice(-1)[0]]=D(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,s);break;case"CONSTRUCT":u=E(new n(...s));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;y(e,n),u=M(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(e){u={value:e,[m]:0}}Promise.resolve(u).catch((e=>({value:e,[m]:0}))).then((e=>{const[o,a]=x(e);t.postMessage(Object.assign(Object.assign({},o),{id:r}),a),"RELEASE"===i&&(t.removeEventListener("message",n),w(t))}))})),t.start&&t.start()}function w(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function k(e,t){return P(e,[],t)}function C(e){if(e)throw new Error("Proxy has been released and is not useable")}function P(e,t=[],n=function(){}){let o=!1;const r=new Proxy(n,{get(n,i){if(C(o),i===p)return()=>L(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{w(e),o=!0}));if("then"===i){if(0===t.length)return{then:()=>r};const n=L(e,{type:"GET",path:t.map((e=>e.toString()))}).then(D);return n.then.bind(n)}return P(e,[...t,i])},set(n,r,i){C(o);const[a,s]=x(i);return L(e,{type:"SET",path:[...t,r].map((e=>e.toString())),value:a},s).then(D)},apply(n,r,i){C(o);const a=t[t.length-1];if(a===v)return L(e,{type:"ENDPOINT"}).then(D);if("bind"===a)return P(e,t.slice(0,-1));const[s,u]=W(i);return L(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:s},u).then(D)},construct(n,r){C(o);const[i,a]=W(r);return L(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},a).then(D)}});return r}function W(e){const t=e.map(x);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const S=new WeakMap;function M(e,t){return S.set(e,t),e}function E(e){return Object.assign(e,{[f]:!0})}function x(e){for(const[t,n]of g)if(n.canHandle(e)){const[o,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:o},r]}return[{type:"RAW",value:e},S.get(e)||[]]}function D(e){switch(e.type){case"HANDLER":return g.get(e.name).deserialize(e.value);case"RAW":return e.value}}function L(e,t,n){return new Promise((o=>{const r=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===r&&(e.removeEventListener("message",t),o(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:r},t),n)}))}var R,A=n(849),Z=n(519),U=n(332),_=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),O=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 _(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(r.v),T=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),z=function(){return(z=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}).apply(this,arguments)},I=function(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())}))},G=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},F=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o};!function(e){e[e.browser=0]="browser",e[e.worker=1]="worker"}(R||(R={}));var j=function(e){function t(t){var n=e.call(this)||this;return n.handleKeyUp=function(e){var t;null===(t=n.sketchWeb)||void 0===t||t.keyUp(e)},n.handleMouseDoubleClick=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.mouseDoubleClick()},n.handleCameraMoveStart=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.setIsCameraMoving(!0)},n.handleCameraMoveEnd=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.setIsCameraMoving(!1)},n.handleMouseChange=function(e,t){var o;null===(o=n.sketchWeb)||void 0===o||o.setMouse(e,t)},n.handlePanChange=function(e,t){return I(n,void 0,void 0,(function(){var n;return G(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.addPan(e,t),this.emitPanEvent(),[2]}))}))},n.handleZoomChange=function(e,t){return I(n,void 0,void 0,(function(){var n;return G(this,(function(o){return null===(n=this.sketchWeb)||void 0===n||n.addZoom(e,t),this.emitZoomEvent(),this.emitPanEvent(),[2]}))}))},n.handleMouseDown=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.mouseDown()},n.handleMouseUp=function(){var e;null===(e=n.sketchWeb)||void 0===e||e.mouseUp()},n.handleCanvasResize=function(e){window.requestAnimationFrame((function(){var t,o,r=e[0].contentRect,i=r.width,a=r.height;n.setCanvasSize(i,a),n.gestureManager.updateTargetBounds(),null===(t=n.sketchWeb)||void 0===t||t.setPixelRatio(n.getDevicePixelRatio()),null===(o=n.sketchWeb)||void 0===o||o.setSize(i*n.getDevicePixelRatio(),a*n.getDevicePixelRatio())}))},n.settings=t,n.canvas=t.canvas,n.gestureManager=new l(n.canvas,{minimumZoomLevel:t.minimumZoomLevel,maximumZoomLevel:t.maximumZoomLevel}),n.keyboardManager=new O(document.body),A.Z.active=t.mode===U.p.debug,n.init(),n}return T(t,e),t.prototype.init=function(){var e;return I(this,void 0,void 0,(function(){var t,n,o;return G(this,(function(r){switch(r.label){case 0:return this.setCanvasSize(this.settings.container.clientWidth,this.settings.container.clientHeight),[4,this.initSketchWeb()];case 1:return r.sent(),[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()];case 2:return"FILE_READY"!==(null==(t=r.sent())?void 0:t.type)?[2]:(n=void 0!==this.settings.initialZoom,o=void 0!==this.settings.initialPan,n||o?n?[4,this.setZoom(this.settings.initialZoom)]:[3,4]:[3,7]);case 3:r.sent(),r.label=4;case 4:return o?[4,this.setPan(this.settings.initialPan.x,this.settings.initialPan.y,this.settings.initialPan.centerPointInViewport)]:[3,6];case 5:r.sent(),r.label=6;case 6:return[3,9];case 7:return[4,this.zoomToFit()];case 8:r.sent(),r.label=9;case 9:return this.sketchWeb.startRendering(),this.addListeners(),[2]}}))}))},t.prototype.initSketchWeb=function(){return I(this,void 0,void 0,(function(){var e,t,o,r,i;return G(this,(function(a){switch(a.label){case 0:return e=Z.Z.offscreenCanvas&&"function"==typeof this.canvas.transferControlToOffscreen,t=z(z({},this.settings),{size:{width:this.canvas.width,height:this.canvas.height},pixelRatio:this.getDevicePixelRatio()}),e?(this.environment=R.worker,A.Z.debug("Using offscreen canvas"),this.offscreenCanvas=this.canvas.transferControlToOffscreen(),this.worker=new Worker(new URL(n.p+n.u(509),n.b),{type:void 0}),o=k(this.worker),r=this,[4,new o(M(z(z({},t),{canvas:this.offscreenCanvas}),[this.offscreenCanvas]))]):[3,2];case 1:return r.sketchWeb=a.sent(),[3,3];case 2:this.environment=R.browser,A.Z.debug("Using normal canvas"),this.sketchWeb=new h.U(t),a.label=3;case 3:return(i=this.sketchWeb).on("status",this.forwardEvent("status")),i.on("metric",this.forwardEvent("metric")),i.on("warnings",this.forwardEvent("warnings")),i.on("artboardSelected",this.forwardEvent("artboardSelected")),i.on("artboardDeselected",this.forwardEvent("artboardDeselected")),i.on("artboardMouseEnter",this.forwardEvent("artboardMouseEnter")),i.on("artboardMouseLeave",this.forwardEvent("artboardMouseLeave")),i.on("goToArtboard",this.forwardEvent("goToArtboard")),[4,this.sketchWeb.init()];case 4:return a.sent(),[2]}}))}))},t.prototype.forwardEvent=function(e){var t=this,n=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];t.emit.apply(t,F([e],n))};return this.environment===R.worker?E(n):n},t.prototype.isRunningInsideWorker=function(){return this.environment===R.worker},t.prototype.looseWebGLContext=function(){var e;null===(e=this.sketchWeb)||void 0===e||e.looseWebGLContext()},t.prototype.addListeners=function(){this.canvasResizeObserver=new ResizeObserver(this.handleCanvasResize),this.canvasResizeObserver.observe(this.settings.container),this.gestureManager.on("panChange",this.handlePanChange),this.gestureManager.on("mousemove",this.handleMouseChange),this.gestureManager.on("mousedown",this.handleMouseDown),this.gestureManager.on("mouseup",this.handleMouseUp),this.gestureManager.on("doubleClick",this.handleMouseDoubleClick),this.gestureManager.on("zoomChange",this.handleZoomChange),this.gestureManager.on("cameraMoveStart",this.handleCameraMoveStart),this.gestureManager.on("cameraMoveEnd",this.handleCameraMoveEnd),this.keyboardManager.on("keyUp",this.handleKeyUp)},t.prototype.emitPanEvent=function(){var e;return I(this,void 0,void 0,(function(){var t;return G(this,(function(n){switch(n.label){case 0:return[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()];case 1:return(t=n.sent())?(this.emit("pan",t.x,t.y),[2]):[2]}}))}))},t.prototype.emitZoomEvent=function(){var e;return I(this,void 0,void 0,(function(){var t;return G(this,(function(n){switch(n.label){case 0:return[4,null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()];case 1:return void 0===(t=n.sent())||this.emit("zoom",t),[2]}}))}))},t.prototype.getDevicePixelRatio=function(){return(0,d.uZ)(window.devicePixelRatio,1,2)},t.prototype.setCanvasSize=function(e,t){this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this.canvas.width=e*this.getDevicePixelRatio(),this.canvas.height=t*this.getDevicePixelRatio()},t.prototype.zoomToFit=function(){return I(this,void 0,void 0,(function(){return G(this,(function(e){switch(e.label){case 0:return[4,this.sketchWeb.scaleDocumentToFit()];case 1:return e.sent(),this.emitZoomEvent(),this.emitPanEvent(),[2]}}))}))},t.prototype.getStatus=function(){var e;return I(this,void 0,void 0,(function(){return G(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.getStatus()]}))}))},t.prototype.generateDocumentPNG=function(){var e;return I(this,void 0,void 0,(function(){return G(this,(function(t){return[2,null===(e=this.sketchWeb)||void 0===e?void 0:e.generateDocumentPNG()]}))}))},t.prototype.getArtboardAtPosition=function(e,t){var n;return I(this,void 0,void 0,(function(){return G(this,(function(o){switch(o.label){case 0:return[4,null===(n=this.sketchWeb)||void 0===n?void 0:n.getArtboardAtPosition(e,t)];case 1:return[2,o.sent()||null]}}))}))},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWeb)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.setPan=function(e,t,n){var o;return I(this,void 0,void 0,(function(){return G(this,(function(r){switch(r.label){case 0:return[4,null===(o=this.sketchWeb)||void 0===o?void 0:o.setPan(e,t,Boolean(n))];case 1:return r.sent(),this.emitPanEvent(),[2]}}))}))},t.prototype.setZoom=function(e,t){var n;return I(this,void 0,void 0,(function(){var o;return G(this,(function(r){return o=null!=t?t:this.getCanvasCenterPoint(),null===(n=this.sketchWeb)||void 0===n||n.setZoom(e,o),this.emitZoomEvent(),this.emitPanEvent(),[2]}))}))},t.prototype.getCanvasCenterPoint=function(){var e=this.canvas.getBoundingClientRect();return{x:e.width/2+e.x,y:e.height/2+e.y}},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getZoom()},t.prototype.getPan=function(){var e;return null===(e=this.sketchWeb)||void 0===e?void 0:e.getPan()},t.prototype.dispose=function(){var e,t,n,o;return I(this,void 0,void 0,(function(){return G(this,(function(r){switch(r.label){case 0:return this.gestureManager.dispose(),this.keyboardManager.dispose(),null===(e=this.canvasResizeObserver)||void 0===e||e.disconnect(),this.isRunningInsideWorker()?[4,null===(t=this.sketchWeb)||void 0===t?void 0:t.dispose()]:[3,2];case 1:return r.sent(),null===(n=this.worker)||void 0===n||n.terminate(),[3,3];case 2:null===(o=this.sketchWeb)||void 0===o||o.dispose(),r.label=3;case 3:return[2]}}))}))},t}(r.v)},475:(e,t,n)=>{"use strict";n.d(t,{U:()=>v});var o,r=n(419),i=n(519),a=n(480),s=n(108),u=n(849),c=n(758),l=n(332),h=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),d=function(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())}))},f=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},v=(globalThis.indexedDB,function(e){function t(t){var n=t.canvas,o=t.locateFile,i=t.filePath,a=t.imagesURLFormat,c=t.imagesURLMap,h=t.backgroundColor,d=void 0===h?{r:1,g:1,b:1,a:1}:h,f=t.highlightColor,v=void 0===f?{r:0,g:0,b:0,a:1}:f,p=t.size,m=t.pixelRatio,b=t.mode,g=t.showTilesBorders,y=void 0!==g&&g,w=t.minimumZoomLevel,k=t.maximumZoomLevel,C=t.preserveDrawingBuffer,P=void 0!==C&&C,W=t.panBoundariesPadding,S=void 0===W?40:W,M=e.call(this)||this;return M.status={type:"INIT"},M.handleWebGLContextLost=function(){M.setStatus({type:"WEBGL_CONTEXT_LOST"})},M.debouncedFullDraw=(0,r.Ds)((function(){return M.draw(!0)}),200),M.canvas=n,M.locateFile=o,M.filePath=i,M.imagesURLFormat=a,M.imagesURLMap=c,M.backgroundColor=d,M.highlightColor=v,M.size=p,M.pixelRatio=m,M.mode=b,M.showTilesBorders=y,M.currentWebGLVersion=(0,r.wX)(),M.zoomLevels={min:w,max:k},M.preserveDrawingBuffer=P,M.panBoundariesPadding=S,u.Z.active=b===l.p.debug,M.traceFirstPaint=new s.S("FirstPaint"),M}return h(t,e),t.prototype.init=function(){return d(this,void 0,void 0,(function(){var e;return f(this,(function(t){switch(t.label){case 0:this.setStatus({type:"INIT"}),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,this.initSketchWebWasm()];case 2:return t.sent(),[4,this.setFile(this.filePath)];case 3:return t.sent(),[3,5];case 4:return e=t.sent(),[2,this.fail(e instanceof c.k?e:new c.k("ERROR","Unexpected exception initializing the web renderer",e))];case 5:return[2]}}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new s.S("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.draw(!0,!1),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){u.Z.debug("[C++] "+e)},logWarning:function(e){u.Z.warning("[C++] "+e)},logError:function(e){u.Z.error("[C++] "+e)},emitMetric:function(t,n,o,r){e.emit("metric",{id:t,start:n,end:o,duration:r})},resolveImageUrl:function(t){return e.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(u.Z.warning("Not able to resolve the url for the image with UUID: "+t),"")},onDrawComplete:this.handleDrawComplete.bind(this),onArtboardMouseEnter:function(t){e.emit("artboardMouseEnter",t)},onArtboardMouseLeave:function(t){e.emit("artboardMouseLeave",t)},onArtboardSelected:function(t){e.emit("artboardSelected",t)},onArtboardDeselected:function(t){e.emit("artboardDeselected",t)},onGoToArtboard:function(t,n){e.emit("goToArtboard",t,n)}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,o=new s.S("ImagesDownload");null===(n=e.sketchWebWasm)||void 0===n||n.downloadImages((function(){o.printMeasurement(),e.emit("metric",o.measure()),u.Z.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return d(this,void 0,void 0,(function(){var e,t,o,r,a,h,d,v=this;return f(this,(function(f){switch(f.label){case 0:return e=new s.S("WasmModuleDownload"),this.mode!==l.p.debug?[3,2]:[4,n.e(425).then(n.t.bind(n,425,23))];case 1:return t=f.sent(),[3,4];case 2:return[4,n.e(816).then(n.t.bind(n,816,23))];case 3:t=f.sent(),f.label=4;case 4:o=t.default,f.label=5;case 5:return f.trys.push([5,7,,8]),r=this,[4,o({FeatureFlags:i.Z,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return v.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return r.wasmModule=f.sent(),[3,8];case 7:throw a=f.sent(),new c.k("WASM_ERROR","An error occurred while trying to create the wasm module.",a);case 8:if(e.printMeasurement(),this.emit("metric",e.measure()),h={antialias:!1,majorVersion:this.currentWebGLVersion,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},u.Z.debug("Using WebGL "+h.majorVersion),!(d=this.wasmModule.GL.createContext(this.canvas,h)))throw new c.k("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=d;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height)}catch(e){throw new c.k("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.sketchWebWasm.setPixelRatio(this.pixelRatio),this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setHighlightColor(this.highlightColor.r,this.highlightColor.g,this.highlightColor.b,this.highlightColor.a),this.sketchWebWasm.setRendererConfiguration({showTilesBorders:this.showTilesBorders}),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.generateDocumentPNG=function(){return d(this,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,this.sketchWebWasm.generateDocumentPNG()]}}))}))},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"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit(),this.delayedDraw()},t.prototype.setFile=function(e){return d(this,void 0,void 0,(function(){var t=this;return f(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,o){t.sketchWebWasm.setFile(e,(function(e){if(void 0===e&&(e=[]),e.length){u.Z.debug("Parser warnings: "+e);var o=e.map((function(e){return{key:e}}));t.emit("warnings",o)}t.setStatus({type:"FILE_READY"}),n()}),(function(){return o(new c.k("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.delayedDraw=function(){if(!i.Z.delayedDraw)return this.draw(!0);this.draw(),this.debouncedFullDraw()},t.prototype.draw=function(e,t){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),null===(n=this.sketchWebWasm)||void 0===n||n.setNeedsUpdate(e,t)},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:e.toString()+(e.cause?"\nWrapped Error: "+e.cause.toString():"")}),u.Z.error(e),e.cause&&u.Z.error(e.cause)},t.prototype.setPixelRatio=function(e){var t;this.pixelRatio=e,null===(t=this.sketchWebWasm)||void 0===t||t.setPixelRatio(e),this.delayedDraw()},t.prototype.setSize=function(e,t){var n;this.size.width=e,this.size.height=t,this.canvas.width=e,this.canvas.height=t,null===(n=this.sketchWebWasm)||void 0===n||n.resize(e,t)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(u.Z.debug("Status transition "+this.status.type+" => "+e.type+"}"),this.status=e,this.emit("status",e))},t.prototype.getArtboardAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getArtboardAtPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,o;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(o=this.sketchWebWasm)||void 0===o||o.setZoom(e),this.delayedDraw()},t.prototype.addZoom=function(e,t){var n,o;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(o=this.sketchWebWasm)||void 0===o||o.addZoom(e),this.delayedDraw()},t.prototype.setPan=function(e,t,n){var o;void 0===n&&(n=!1),null===(o=this.sketchWebWasm)||void 0===o||o.setPan(e,t,n),this.delayedDraw()},t.prototype.addPan=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.addPan(e,t),this.delayedDraw()},t.prototype.getPan=function(){if(this.sketchWebWasm)return this.sketchWebWasm.getPan()},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.setMouse=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.setMouse(e,t)},t.prototype.setIsCameraMoving=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraMoving(e)},t.prototype.mouseDown=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDown()},t.prototype.mouseUp=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseUp()},t.prototype.mouseDoubleClick=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDoubleClick()},t.prototype.keyUp=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.keyUp(e)},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete()}catch(e){this.fail(new c.k("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}this.sketchWebWasm=null},t}(a.v))},948:(e,t,n)=>{"use strict";n.d(t,{z0:()=>Z,oW:()=>_,JB:()=>m,SC:()=>x,zB:()=>L,GC:()=>W,xH:()=>v,z7:()=>R,rR:()=>C,JU:()=>M,vN:()=>g,Y6:()=>D,$5:()=>w});var o,r=n(297),i=n.n(r),a=n(933),s=n(849),u=function(){return(u=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}).apply(this,arguments)},c=function(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())}))},l=function(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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},h=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o},d=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.Z.debug.apply(s.Z,h(["SketchWebContext"],e))};!function(e){e.Draggable="grab",e.Dragging="grabbing",e.Hover="pointer",e.Default="auto"}(o||(o={}));var f=(0,r.createContext)(void 0),v=function(){var e=(0,r.useContext)(f);if(void 0===e)throw Error("useSketchWebManager must be used within a SketchWebProvider");return e},p=(0,r.createContext)(void 0),m=function(){var e=(0,r.useContext)(p);if(void 0===e)throw Error("useSketchWebActions must be used within a SketchWebProvider");return e},b=(0,r.createContext)(void 0),g=function(){var e=(0,r.useContext)(b);if(void 0===e)throw Error("useSketchWebStatus must be used within a SketchWebProvider");return e},y=(0,r.createContext)(void 0),w=function(){var e=(0,r.useContext)(y);if(void 0===e)throw Error("useSketchWebZoom must be used within a SketchWebProvider");return e},k=(0,r.createContext)(void 0),C=function(){var e=(0,r.useContext)(k);if(void 0===e)throw Error("useSketchWebPan must be used within a SketchWebProvider");return e},P=(0,r.createContext)(void 0),W=function(){var e=(0,r.useContext)(P);if(void 0===e)throw Error("useSketchWebHoveredArtboardUUID must be used within a SketchWebProvider");return e},S=(0,r.createContext)(void 0),M=function(){var e=(0,r.useContext)(S);if(void 0===e)throw Error("useSketchWebSelectedArtboardUUID must be used within a SketchWebProvider");return e},E=(0,r.createContext)(void 0),x=function(){var e=(0,r.useContext)(E);if(void 0===e)throw Error("useSketchWebCursor must be used within a SketchWebProvider");return e},D=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("warnings",e),function(){null==t||t.off("warnings",e)}}),[t,e])},L=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("goToArtboard",e),function(){null==t||t.off("goToArtboard",e)}}),[t,e])},R=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("metric",e),function(){null==t||t.off("metric",e)}}),[t,e])},A=function(e,t){switch(d('dispatched: "'+t.type+'"',t),t.type){case"on-status":return u(u({},e),{status:t.status});case"on-zoom":return u(u({},e),{zoom:t.zoom});case"on-pan":return u(u({},e),{pan:t.pan});case"dispose":return u(u({},e),{status:null,filePath:null,selectedArtboardUUID:null,hoveredArtboardUUID:null,zoom:null,pan:null,cursor:o.Default});case"post-init":return u(u({},e),{status:t.status,zoom:t.zoom});case"set-file-path":return u(u({},e),{filePath:t.filePath});case"on-artboard-mouse-enter":return u(u({},e),{hoveredArtboardUUID:t.uuid,cursor:o.Hover});case"on-artboard-mouse-leave":return u(u({},e),{hoveredArtboardUUID:null,cursor:e.isMouseDown?o.Dragging:o.Draggable});case"on-artboard-selected":return u(u({},e),{selectedArtboardUUID:t.uuid});case"on-artboard-deselected":return u(u({},e),{selectedArtboardUUID:null});case"on-mouse-down":return u(u({},e),{cursor:o.Dragging,isMouseDown:!0});case"on-mouse-up":return u(u({},e),{cursor:e.hoveredArtboardUUID?o.Hover:o.Draggable,isMouseDown:!1});default:return e}},Z=function(e){var t=e.children,n=(0,r.useRef)(null),s=(0,r.useRef)(null),h=(0,r.useReducer)(A,{pan:null,zoom:null,status:null,filePath:null,hoveredArtboardUUID:null,selectedArtboardUUID:null,cursor:o.Default,isMouseDown:!1}),v=h[0],m=v.status,g=v.zoom,w=v.pan,C=v.hoveredArtboardUUID,W=v.selectedArtboardUUID,M=v.cursor,x=h[1],D=(0,r.useCallback)((function(e){return x({type:"on-zoom",zoom:e})}),[]),L=(0,r.useCallback)((function(e,t){return x({type:"on-pan",pan:{x:e,y:t}})}),[]),R=(0,r.useCallback)((function(e){x({type:"on-status",status:e})}),[]),Z=(0,r.useCallback)((function(e){return x({type:"on-artboard-mouse-enter",uuid:e})}),[]),U=(0,r.useCallback)((function(){return x({type:"on-artboard-mouse-leave"})}),[]),_=(0,r.useCallback)((function(e){x({type:"on-artboard-selected",uuid:e})}),[]),O=(0,r.useCallback)((function(){return x({type:"on-artboard-deselected"})}),[]),T=(0,r.useCallback)((function(){return x({type:"on-mouse-down"})}),[]),z=(0,r.useCallback)((function(){return x({type:"on-mouse-up"})}),[]),I=(0,r.useCallback)((function(){n.current&&(d("dispose"),n.current.off("status",R),n.current.off("artboardMouseEnter",Z),n.current.off("artboardMouseLeave",U),n.current.off("artboardSelected",_),n.current.off("artboardDeselected",O),n.current.off("zoom",D),n.current.off("pan",L),n.current.gestureManager.off("mousedown",T),n.current.gestureManager.off("mouseup",z),n.current.dispose(),n.current=null,x({type:"dispose"}))}),[R,L,D,Z,U,_,O,z,T]),G=(0,r.useCallback)((function(e){e&&!n.current&&s.current&&(d("init"),x({type:"set-file-path",filePath:e}),n.current=new a.d(u(u({},s.current),{filePath:e})),n.current.on("status",R),n.current.on("artboardMouseEnter",Z),n.current.on("artboardMouseLeave",U),n.current.on("artboardSelected",_),n.current.on("artboardDeselected",O),n.current.on("zoom",D),n.current.on("pan",L),n.current.gestureManager.on("mousedown",T),n.current.gestureManager.on("mouseup",z),c(void 0,void 0,void 0,(function(){var e,t,o,r,i,a;return l(this,(function(s){switch(s.label){case 0:return[4,null===(r=n.current)||void 0===r?void 0:r.getPan()];case 1:return e=s.sent()||null,t=x,o={type:"post-init"},[4,null===(i=n.current)||void 0===i?void 0:i.getZoom()];case 2:return o.zoom=s.sent()||null,[4,null===(a=n.current)||void 0===a?void 0:a.getStatus()];case 3:return t.apply(void 0,[(o.status=s.sent()||null,o.pan=null!=e?e:null,o)]),[2]}}))})))}),[R,D,L,Z,U,_,O,T,z]),F=(0,r.useCallback)((function(e){d("setSettings",e),s.current=e}),[]),j=(0,r.useCallback)((function(e){var t;d("setZoom",e),null===(t=n.current)||void 0===t||t.setZoom(e)}),[]),B=(0,r.useCallback)((function(){var e,t;d("incrementZoom"),"number"==typeof g&&(t=g>=1?Math.round(2*g):g>.5?1:2*g,null===(e=n.current)||void 0===e||e.setZoom(t))}),[g]),N=(0,r.useCallback)((function(){var e;d("decrementZoom"),"number"==typeof g&&(null===(e=n.current)||void 0===e||e.setZoom(g/2))}),[g]),H=(0,r.useCallback)((function(e){var t,o=e.x,r=e.y,i=e.centerPointInViewport;d("setPan",o,r,"centerPointInViewport",i),null===(t=n.current)||void 0===t||t.setPan(o,r,i)}),[]),Y=(0,r.useCallback)((function(){var e;d("zoomToFit"),null===(e=n.current)||void 0===e||e.zoomToFit()}),[]),V=(0,r.useCallback)((function(){var e;d("looseWebGLContext"),null===(e=n.current)||void 0===e||e.looseWebGLContext()}),[]),X=(0,r.useCallback)((function(){return c(void 0,void 0,void 0,(function(){var e;return l(this,(function(t){switch(t.label){case 0:return d("generateDocumentPNG"),[4,null===(e=n.current)||void 0===e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[]),q=(0,r.useCallback)((function(e,t){return c(void 0,void 0,void 0,(function(){var o;return l(this,(function(r){switch(r.label){case 0:return d("getArtboardAtPosition",e,t),[4,null===(o=n.current)||void 0===o?void 0:o.getArtboardAtPosition(e,t)];case 1:return[2,r.sent()||null]}}))}))}),[]),K=(0,r.useCallback)((function(e,t){return c(void 0,void 0,void 0,(function(){var o;return l(this,(function(r){switch(r.label){case 0:return d("invoked: getPanAtPosition",e,t),[4,null===(o=n.current)||void 0===o?void 0:o.getPanAtPosition(e,t)];case 1:return[2,r.sent()||null]}}))}))}),[]),J=(0,r.useMemo)((function(){return{setSettings:F,init:G,dispose:I,setZoom:j,incrementZoom:B,decrementZoom:N,setPan:H,zoomToFit:Y,looseWebGLContext:V,generateDocumentPNG:X,getArtboardAtPosition:q,getPanAtPosition:K}}),[F,G,I,j,B,N,H,Y,V,X,q,K]);return i().createElement(f.Provider,{value:n.current},i().createElement(p.Provider,{value:J},i().createElement(b.Provider,{value:m},i().createElement(y.Provider,{value:g},i().createElement(k.Provider,{value:w},i().createElement(S.Provider,{value:W},i().createElement(P.Provider,{value:C},i().createElement(E.Provider,{value:M},t))))))))},U=n(332),_=function(e){s.Z.active=e.mode===U.p.debug;var t=e.filePath,n=e.locateFile,o=e.imagesURLFormat,a=e.imagesURLMap,u=e.backgroundColor,c=e.highlightColor,l=e.mode,h=e.showTilesBorders,d=e.minimumZoomLevel,f=e.maximumZoomLevel,v=e.preserveDrawingBuffer,p=e.panBoundariesPadding,b=e.initialPan,y=e.initialZoom,w=e.onCanvasClick,k=e.onCanvasContextMenu,C=(0,r.useState)(null),P=C[0],W=C[1],S=(0,r.useState)(null),M=S[0],E=S[1],D=m(),L=D.dispose,R=D.setSettings,A=D.init,Z=x(),_=g();return(0,r.useEffect)((function(){M&&P&&R({locateFile:n,imagesURLFormat:o,imagesURLMap:a,backgroundColor:u,highlightColor:c,mode:l,showTilesBorders:h,minimumZoomLevel:d,maximumZoomLevel:f,preserveDrawingBuffer:v,panBoundariesPadding:p,initialPan:b,initialZoom:y,container:M,canvas:P})}),[R,n,o,a,u,c,l,h,d,f,v,p,b,y,M,P]),(0,r.useEffect)((function(){if(t&&P&&M)return A(t),function(){return L()}}),[L,A,t,P,M]),i().createElement("div",{ref:function(e){return E(e)},style:{position:"relative",width:"100%",height:"100%"}},i().createElement("canvas",{onClick:w,onContextMenu:k,ref:function(e){return W(e)},"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-"+((null==_?void 0:_.type.toLowerCase())||"null"),style:{position:"absolute",inset:"0",cursor:Z}}))}},758:(e,t,n)=>{"use strict";n.d(t,{k:()=>i});var o,r=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=function(e){function t(n,o,r){var i=this.constructor,a=e.call(this,"("+n+") "+o)||this;return a.code=n,a.cause=r,a.name=t.name,Object.setPrototypeOf(a,i.prototype),a}return r(t,e),t}(Error)},18:()=>{},689:()=>{},332:(e,t,n)=>{"use strict";var o;n.d(t,{p:()=>o}),function(e){e.debug="debug",e.release="release"}(o||(o={}))},119:()=>{},312:()=>{},480:(e,t,n)=>{"use strict";n.d(t,{v:()=>o});var o=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.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}()},849:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var o=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),r=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,r++)o[r]=i[a];return o};const r=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,o(["[SketchWeb] [Debug]"],e))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,o(["[SketchWeb] [Warn]"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,o(["[SketchWeb] [Error]"],e))},e}())},108:(e,t,n)=>{"use strict";n.d(t,{S:()=>r});var o=n(849),r=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),o.Z.debug("[Performance] Start: "+this.label)}return e.prototype.measure=function(){var e=performance.now()-this.startTime;return{duration:e,end:this.startTimestamp+e,start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);o.Z.debug("[Performance] End: "+this.label+" -> "+t+" ms")}else{var n=(e/1e3).toFixed(2);o.Z.debug("[Performance] End: "+this.label+" -> "+n+" s")}},e}()},419:(e,t,n)=>{"use strict";n.d(t,{uZ:()=>o.uZ,Ds:()=>o.Ds,wX:()=>o.wX});var o=n(388)},388:(e,t,n)=>{"use strict";n.d(t,{Ds:()=>i,MP:()=>a,uZ:()=>s,wX:()=>u});var o=n(519),r=n(66);function i(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 a(e){var t,n;return{x:null!==(t=e.pageX)&&void 0!==t?t:e.clientX,y:null!==(n=e.pageY)&&void 0!==n?n:e.clientY}}function s(e,t,n){return Math.max(t,Math.min(n,e))}function u(){return(0,r.t)()&&!o.Z.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1}},66:(e,t,n)=>{"use strict";n.d(t,{t:()=>r});var o=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/,r=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(o);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}}}},297:t=>{"use strict";t.exports=e}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.m=i,s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var r=Object.create(null);s.r(r);var i={};t=t||[null,n({}),n([]),n(n)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>"static/js/web-renderer-"+{425:"3effe72d4cf4931fc6e0",509:"79e8d17ff29317dab85e",816:"8526d667c341405f97bb"}[e]+".chunk.js",s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},r="@sketch-hq/sketch-web-renderer:",s.l=(e,t,n,i)=>{if(o[e])o[e].push(t);else{var a,u;if(void 0!==n)for(var c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var h=c[l];if(h.getAttribute("src")==e||h.getAttribute("data-webpack")==r+n){a=h;break}}a||(u=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",r+n),a.src=e),o[e]=[t];var d=(t,n)=>{a.onerror=a.onload=null,clearTimeout(f);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),u&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.p="/",(()=>{s.b=document.baseURI||self.location.href;var e={826:0};s.f.j=(t,n)=>{var o=s.o(e,t)?e[t]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise(((n,r)=>o=e[t]=[n,r]));n.push(o[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(n=>{if(s.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}}),"chunk-"+t,t)}};var t=(t,n)=>{var o,r,[i,a,u]=n,c=0;if(i.some((t=>0!==e[t]))){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);u&&u(s)}for(t&&t(n);c<i.length;c++)r=i[c],s.o(e,r)&&e[r]&&e[r][0](),e[i[c]]=0},n=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var u={};return(()=>{"use strict";s.r(u),s.d(u,{default:()=>d,SketchWeb:()=>t.U,SketchWebMode:()=>i.p,SketchWebError:()=>c.k,SketchWebProvider:()=>h.z0,SketchWebReact:()=>h.oW,useSketchWebActions:()=>h.JB,useSketchWebCursor:()=>h.SC,useSketchWebGoToArtboardEvent:()=>h.zB,useSketchWebHoveredArtboardUUID:()=>h.GC,useSketchWebManager:()=>h.xH,useSketchWebMetricEvent:()=>h.z7,useSketchWebPan:()=>h.rR,useSketchWebSelectedArtboardUUID:()=>h.JU,useSketchWebStatus:()=>h.vN,useSketchWebWarningsEvent:()=>h.Y6,useSketchWebZoom:()=>h.$5});var e=s(933),t=s(475),n=s(18),o={};for(const e in n)["default","SketchWeb"].indexOf(e)<0&&(o[e]=()=>n[e]);s.d(u,o);var r=s(119);o={};for(const e in r)["default","SketchWeb"].indexOf(e)<0&&(o[e]=()=>r[e]);s.d(u,o);var i=s(332),a=s(312);o={};for(const e in a)["default","SketchWeb","SketchWebMode"].indexOf(e)<0&&(o[e]=()=>a[e]);s.d(u,o);var c=s(758),l=s(689);o={};for(const e in l)["default","SketchWeb","SketchWebMode","SketchWebError"].indexOf(e)<0&&(o[e]=()=>l[e]);s.d(u,o);var h=s(948);const d=e.d})(),u})()}));
Binary file
Binary file
@@ -0,0 +1 @@
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(){return(()=>{"use strict";var e,t,n={},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&r&&n;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>n[e]));return s.default=()=>n,o.d(i,s),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,n)=>(o.f[n](e,t),t)),[])),o.u=e=>"static/js/web-renderer-"+{425:"3effe72d4cf4931fc6e0",816:"8526d667c341405f97bb"}[e]+".chunk.js",o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/",(()=>{var e={509:1};o.f.i=(t,n)=>{e[t]||importScripts(o.p+o.u(t))};var t=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[],n=t.push.bind(t);t.push=t=>{var[r,i,s]=t;for(var a in i)o.o(i,a)&&(o.m[a]=i[a]);for(s&&s(o);r.length;)e[r.pop()]=1;n(t)}})();const i={delayedDraw:!0,offscreenCanvas:!1,safariWebGL2:!1,pageBoundariesLimit:!1};var s=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/;var a=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,r;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(r=this.listeners[e])||void 0===r||r.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this.listeners[e];(null==r?void 0:r.size)&&r.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e}(),c=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};const u=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,c(["[SketchWeb] [Debug]"],e))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,c(["[SketchWeb] [Warn]"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,c(["[SketchWeb] [Error]"],e))},e}());var l,h,d=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),u.debug("[Performance] Start: "+this.label)}return e.prototype.measure=function(){var e=performance.now()-this.startTime;return{duration:e,end:this.startTimestamp+e,start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);u.debug("[Performance] End: "+this.label+" -> "+t+" ms")}else{var n=(e/1e3).toFixed(2);u.debug("[Performance] End: "+this.label+" -> "+n+" s")}},e}(),p=(l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(e){function t(n,r,o){var i=this.constructor,s=e.call(this,"("+n+") "+r)||this;return s.code=n,s.cause=o,s.name=t.name,Object.setPrototypeOf(s,i.prototype),s}return p(t,e),t}(Error);!function(e){e.debug="debug",e.release="release"}(h||(h={}));var m=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),b=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},v=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},g=(globalThis.indexedDB,function(e){function t(t){var n=t.canvas,r=t.locateFile,o=t.filePath,a=t.imagesURLFormat,c=t.imagesURLMap,l=t.backgroundColor,p=void 0===l?{r:1,g:1,b:1,a:1}:l,f=t.highlightColor,m=void 0===f?{r:0,g:0,b:0,a:1}:f,b=t.size,v=t.pixelRatio,g=t.mode,y=t.showTilesBorders,w=void 0!==y&&y,W=t.minimumZoomLevel,k=t.maximumZoomLevel,L=t.preserveDrawingBuffer,P=void 0!==L&&L,E=t.panBoundariesPadding,R=void 0===E?40:E,x=e.call(this)||this;return x.status={type:"INIT"},x.handleWebGLContextLost=function(){x.setStatus({type:"WEBGL_CONTEXT_LOST"})},x.debouncedFullDraw=function(e,t){var n;function r(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,t)}),200)}return r.cancel=function(){n&&clearTimeout(n)},r}((function(){return x.draw(!0)})),x.canvas=n,x.locateFile=r,x.filePath=o,x.imagesURLFormat=a,x.imagesURLMap=c,x.backgroundColor=p,x.highlightColor=m,x.size=b,x.pixelRatio=v,x.mode=g,x.showTilesBorders=w,x.currentWebGLVersion=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(s);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}}}()&&!i.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1,x.zoomLevels={min:W,max:k},x.preserveDrawingBuffer=P,x.panBoundariesPadding=R,u.active=g===h.debug,x.traceFirstPaint=new d("FirstPaint"),x}return m(t,e),t.prototype.init=function(){return b(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:this.setStatus({type:"INIT"}),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,this.initSketchWebWasm()];case 2:return t.sent(),[4,this.setFile(this.filePath)];case 3:return t.sent(),[3,5];case 4:return e=t.sent(),[2,this.fail(e instanceof f?e:new f("ERROR","Unexpected exception initializing the web renderer",e))];case 5:return[2]}}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new d("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.draw(!0,!1),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){u.debug("[C++] "+e)},logWarning:function(e){u.warning("[C++] "+e)},logError:function(e){u.error("[C++] "+e)},emitMetric:function(t,n,r,o){e.emit("metric",{id:t,start:n,end:r,duration:o})},resolveImageUrl:function(t){return e.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(u.warning("Not able to resolve the url for the image with UUID: "+t),"")},onDrawComplete:this.handleDrawComplete.bind(this),onArtboardMouseEnter:function(t){e.emit("artboardMouseEnter",t)},onArtboardMouseLeave:function(t){e.emit("artboardMouseLeave",t)},onArtboardSelected:function(t){e.emit("artboardSelected",t)},onArtboardDeselected:function(t){e.emit("artboardDeselected",t)},onGoToArtboard:function(t,n){e.emit("goToArtboard",t,n)}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n,r=new d("ImagesDownload");null===(n=e.sketchWebWasm)||void 0===n||n.downloadImages((function(){r.printMeasurement(),e.emit("metric",r.measure()),u.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return b(this,void 0,void 0,(function(){var e,t,n,r,s,a,c,l=this;return v(this,(function(p){switch(p.label){case 0:return e=new d("WasmModuleDownload"),this.mode!==h.debug?[3,2]:[4,o.e(425).then(o.t.bind(o,425,23))];case 1:return t=p.sent(),[3,4];case 2:return[4,o.e(816).then(o.t.bind(o,816,23))];case 3:t=p.sent(),p.label=4;case 4:n=t.default,p.label=5;case 5:return p.trys.push([5,7,,8]),r=this,[4,n({FeatureFlags:i,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return l.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return r.wasmModule=p.sent(),[3,8];case 7:throw s=p.sent(),new f("WASM_ERROR","An error occurred while trying to create the wasm module.",s);case 8:if(e.printMeasurement(),this.emit("metric",e.measure()),a={antialias:!1,majorVersion:this.currentWebGLVersion,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},u.debug("Using WebGL "+a.majorVersion),!(c=this.wasmModule.GL.createContext(this.canvas,a)))throw new f("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=c;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height)}catch(e){throw new f("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.sketchWebWasm.setPixelRatio(this.pixelRatio),this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setHighlightColor(this.highlightColor.r,this.highlightColor.g,this.highlightColor.b,this.highlightColor.a),this.sketchWebWasm.setRendererConfiguration({showTilesBorders:this.showTilesBorders}),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.generateDocumentPNG=function(){return b(this,void 0,void 0,(function(){return v(this,(function(e){switch(e.label){case 0:return[4,this.downloadImages()];case 1:return e.sent(),[2,this.sketchWebWasm.generateDocumentPNG()]}}))}))},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"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit(),this.delayedDraw()},t.prototype.setFile=function(e){return b(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,r){t.sketchWebWasm.setFile(e,(function(e){if(void 0===e&&(e=[]),e.length){u.debug("Parser warnings: "+e);var r=e.map((function(e){return{key:e}}));t.emit("warnings",r)}t.setStatus({type:"FILE_READY"}),n()}),(function(){return r(new f("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.delayedDraw=function(){if(!i.delayedDraw)return this.draw(!0);this.draw(),this.debouncedFullDraw()},t.prototype.draw=function(e,t){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),null===(n=this.sketchWebWasm)||void 0===n||n.setNeedsUpdate(e,t)},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:e.toString()+(e.cause?"\nWrapped Error: "+e.cause.toString():"")}),u.error(e),e.cause&&u.error(e.cause)},t.prototype.setPixelRatio=function(e){var t;this.pixelRatio=e,null===(t=this.sketchWebWasm)||void 0===t||t.setPixelRatio(e),this.delayedDraw()},t.prototype.setSize=function(e,t){var n;this.size.width=e,this.size.height=t,this.canvas.width=e,this.canvas.height=t,null===(n=this.sketchWebWasm)||void 0===n||n.resize(e,t)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(u.debug("Status transition "+this.status.type+" => "+e.type+"}"),this.status=e,this.emit("status",e))},t.prototype.getArtboardAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getArtboardAtPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,r;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(r=this.sketchWebWasm)||void 0===r||r.setZoom(e),this.delayedDraw()},t.prototype.addZoom=function(e,t){var n,r;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(r=this.sketchWebWasm)||void 0===r||r.addZoom(e),this.delayedDraw()},t.prototype.setPan=function(e,t,n){var r;void 0===n&&(n=!1),null===(r=this.sketchWebWasm)||void 0===r||r.setPan(e,t,n),this.delayedDraw()},t.prototype.addPan=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.addPan(e,t),this.delayedDraw()},t.prototype.getPan=function(){if(this.sketchWebWasm)return this.sketchWebWasm.getPan()},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.setMouse=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.setMouse(e,t)},t.prototype.setIsCameraMoving=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraMoving(e)},t.prototype.mouseDown=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDown()},t.prototype.mouseUp=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseUp()},t.prototype.mouseDoubleClick=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDoubleClick()},t.prototype.keyUp=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.keyUp(e)},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete()}catch(e){this.fail(new f("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}this.sketchWebWasm=null},t}(a));const y=Symbol("Comlink.proxy"),w=Symbol("Comlink.endpoint"),W=Symbol("Comlink.releaseProxy"),k=Symbol("Comlink.thrown"),L=e=>"object"==typeof e&&null!==e||"function"==typeof e,P=new Map([["proxy",{canHandle:e=>L(e)&&e[y],serialize(e){const{port1:t,port2:n}=new MessageChannel;return E(e,t),[n,[n]]},deserialize:e=>(e.start(),S(e,[],undefined))}],["throw",{canHandle:e=>L(e)&&k in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function E(e,t=self){t.addEventListener("message",(function n(r){if(!r||!r.data)return;const{id:o,type:i,path:s}=Object.assign({path:[]},r.data),a=(r.data.argumentList||[]).map(O);let c;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),n=s.reduce(((e,t)=>e[t]),e);switch(i){case"GET":c=n;break;case"SET":t[s.slice(-1)[0]]=O(r.data.value),c=!0;break;case"APPLY":c=n.apply(t,a);break;case"CONSTRUCT":c=function(e){return Object.assign(e,{[y]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;E(e,n),c=function(e,t){return _.set(e,t),e}(t,[t])}break;case"RELEASE":c=void 0;break;default:return}}catch(e){c={value:e,[k]:0}}Promise.resolve(c).catch((e=>({value:e,[k]:0}))).then((e=>{const[r,s]=D(e);t.postMessage(Object.assign(Object.assign({},r),{id:o}),s),"RELEASE"===i&&(t.removeEventListener("message",n),R(t))}))})),t.start&&t.start()}function R(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function x(e){if(e)throw new Error("Proxy has been released and is not useable")}function S(e,t=[],n=function(){}){let r=!1;const o=new Proxy(n,{get(n,i){if(x(r),i===W)return()=>M(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{R(e),r=!0}));if("then"===i){if(0===t.length)return{then:()=>o};const n=M(e,{type:"GET",path:t.map((e=>e.toString()))}).then(O);return n.then.bind(n)}return S(e,[...t,i])},set(n,o,i){x(r);const[s,a]=D(i);return M(e,{type:"SET",path:[...t,o].map((e=>e.toString())),value:s},a).then(O)},apply(n,o,i){x(r);const s=t[t.length-1];if(s===w)return M(e,{type:"ENDPOINT"}).then(O);if("bind"===s)return S(e,t.slice(0,-1));const[a,c]=C(i);return M(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:a},c).then(O)},construct(n,o){x(r);const[i,s]=C(o);return M(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},s).then(O)}});return o}function C(e){const t=e.map(D);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const _=new WeakMap;function D(e){for(const[t,n]of P)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},_.get(e)||[]]}function O(e){switch(e.type){case"HANDLER":return P.get(e.name).deserialize(e.value);case"RAW":return e.value}}function M(e,t,n){return new Promise((r=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===o&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}return E(g),{}})()}));
@@ -64,21 +64,15 @@ export declare class Manager extends EventEmitter<ManagerEvents> {
64
64
  getStatus(): Promise<SketchWebStatus | undefined>;
65
65
  generateDocumentPNG(): Promise<Uint8Array | undefined>;
66
66
  getArtboardAtPosition(x: number, y: number): Promise<string | null>;
67
- getPanAtPosition(x: number, y: number): {
68
- x: number;
69
- y: number;
70
- } | Promise<{
71
- x: number;
72
- y: number;
73
- }> | undefined;
67
+ getPanAtPosition(x: number, y: number): import("./types/WASM").Vec2D | Promise<undefined> | Promise<import("./types/WASM").Vec2D> | undefined;
74
68
  setPan(x: number, y: number, centerPointInViewport?: boolean): Promise<void>;
75
69
  setZoom(zoom: number, center?: {
76
70
  x: number;
77
71
  y: number;
78
72
  }): Promise<void>;
79
73
  private getCanvasCenterPoint;
80
- getZoom(): any;
81
- getPan(): any;
74
+ getZoom(): number | Promise<undefined> | Promise<number> | undefined;
75
+ getPan(): import("./types/WASM").Vec2D | Promise<undefined> | Promise<import("./types/WASM").Vec2D> | undefined;
82
76
  dispose(): Promise<void>;
83
77
  }
84
78
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/ts/Manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAa,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,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CAAC,CAAC;IASlD,qBAAqB;IAIrB,iBAAiB;IAIxB,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,WAAW,CAElB;IAED,OAAO,CAAC,sBAAsB,CAE7B;IAED,OAAO,CAAC,qBAAqB,CAE5B;IAED,OAAO,CAAC,mBAAmB,CAE1B;IAED,OAAO,CAAC,iBAAiB,CAExB;IAED,OAAO,CAAC,eAAe,CAItB;IAED,OAAO,CAAC,gBAAgB,CAQvB;IAED,OAAO,CAAC,eAAe,CAEtB;IAED,OAAO,CAAC,aAAa,CAEpB;YAEa,YAAY;YAQZ,aAAa;IAQ3B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,kBAAkB,CAmBzB;IAEY,SAAS;IAOT,SAAS,IAAI,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAKxD,mBAAmB;IAInB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAKzC,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAI/B,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,OAAO;IAM5D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IASpE,OAAO,CAAC,oBAAoB;IAW5B,OAAO;IAIP,MAAM;IAIO,OAAO;CAgBrB"}
@@ -95,16 +95,13 @@ export declare class SketchWeb extends EventEmitter<SketchWebEvents> {
95
95
  * element origin in the browser, or null if there is no Artboard at that
96
96
  * position.
97
97
  */
98
- getArtboardAtPosition(x: number, y: number): string | null;
98
+ getArtboardAtPosition(x: number, y: number): string | undefined;
99
99
  /**
100
100
  * Get the current pan value for a given point relative to the viewport
101
101
  * Use case: when the user clicks on the canvas, we want to know what's
102
102
  * the corresponding pan value at a given mouse position, so that we can restore the pan value later
103
103
  */
104
- getPanAtPosition(x: number, y: number): {
105
- x: number;
106
- y: number;
107
- };
104
+ getPanAtPosition(x: number, y: number): import("./types/WASM").Vec2D | undefined;
108
105
  getStatus(): SketchWebStatus;
109
106
  setZoom(delta: number, center: {
110
107
  x: number;
@@ -116,8 +113,8 @@ export declare class SketchWeb extends EventEmitter<SketchWebEvents> {
116
113
  }): void;
117
114
  setPan(x: number, y: number, centerPointInViewport?: boolean): void;
118
115
  addPan(deltaX: number, deltaY: number): void;
119
- getPan(): any;
120
- getZoom(): any;
116
+ getPan(): import("./types/WASM").Vec2D | undefined;
117
+ getZoom(): number | undefined;
121
118
  setMouse(x: number, y: number): void;
122
119
  setIsCameraMoving(isCameraMoving: boolean): void;
123
120
  mouseDown(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"SketchWeb.d.ts","sourceRoot":"","sources":["../../src/ts/SketchWeb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAInD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C,OAAO,EAAE,eAAe,EAA+B,MAAM,gBAAgB,CAAA;AAQ7E,UAAU,SAAS;IACjB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,iBAAiB,GAAG,eAAe,CAAA;IAC3C,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B,cAAc,CAAC,E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AI7B,iBAAiB,CAAC,cAAc,EAAE,OAAO;IAIzC,SAAS;IAIT,OAAO;IAIP,gBAAgB;IAIhB,KAAK,CAAC,IAAI,EAAE,MAAM;IAIlB,OAAO;CAef"}
@@ -1 +1 @@
1
- {"version":3,"file":"SketchWebReact.d.ts","sourceRoot":"","sources":["../../../src/ts/react/SketchWebReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAA;AAMtD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,aAAK,cAAc,GAAG,IAAI,CACxB,eAAe,EACf,UAAU,GAAG,WAAW,GAAG,QAAQ,CACpC,GACC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC,GAAG;IAC3C,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC5E,mBAAmB,CAAC,EAAE,CACpB,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAC/C,IAAI,CAAA;CACV,CAAA;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,cAAc,CA2F7C,CAAA"}
1
+ {"version":3,"file":"SketchWebReact.d.ts","sourceRoot":"","sources":["../../../src/ts/react/SketchWebReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAA;AAMtD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAI5C,aAAK,cAAc,GAAG,IAAI,CACxB,eAAe,EACf,UAAU,GAAG,WAAW,GAAG,QAAQ,CACpC,GACC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC,GAAG;IAC3C,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAA;IAC5E,mBAAmB,CAAC,EAAE,CACpB,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAC/C,IAAI,CAAA;CACV,CAAA;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,cAAc,CA6F7C,CAAA"}
@@ -1,7 +1,76 @@
1
- export declare type WasmModule = {
2
- [prop: string]: any;
1
+ /**
2
+ * Types for the C++ classes exported by emscripten using embind.
3
+ * Emscripten is not able to generate types automatically, so we have to manually add them.
4
+ */
5
+ import FeatureFlags from '../../featureFlags';
6
+ import { JSBridge } from './JSBridge';
7
+ /**
8
+ * When importing the js file generates by emscripten, the default exported module is a factory
9
+ * that initialised the WebAssembly module and accepts different kind of properties to customize
10
+ * how emscripten handle the module initialisation
11
+ */
12
+ export declare type SketchWebWasmWrapperFactory = (props: {
13
+ FeatureFlags: typeof FeatureFlags;
14
+ currentWebGLVersion: number;
15
+ locateFile: (file: string) => string;
16
+ bridge: JSBridge;
17
+ }) => Promise<SketchWebWasmWrapper>;
18
+ export interface EmscriptenGL {
19
+ createContext: (canvas: HTMLCanvasElement | OffscreenCanvas, ctxSettings: EmscriptenWebGLContextAttributes | null | undefined) => EmscriptenCtxContextHandle;
20
+ getContext: (ctxHandle: EmscriptenCtxContextHandle) => {
21
+ GLctx: WebGLRenderingContext;
22
+ } | undefined | null;
23
+ }
24
+ export declare type SketchWebWasmWrapper = {
25
+ SketchWeb: SketchWebWasm;
26
+ GL: EmscriptenGL;
3
27
  };
4
28
  export interface RendererConfiguration {
5
29
  showTilesBorders?: boolean;
6
30
  }
31
+ export interface SketchWebWasmInstance {
32
+ setNeedsUpdate: (fullUpdate: boolean, updateCache: boolean) => void;
33
+ startRenderLoop: () => void;
34
+ stopRenderLoop: () => void;
35
+ resize: (width: number, height: number) => void;
36
+ generateDocumentPNG: () => Uint8Array;
37
+ setFile: (url: string, onSuccess: () => void, onFailure: () => void) => void;
38
+ setBackgroundColor: (r: number, g: number, b: number, a: number) => void;
39
+ setHighlightColor: (r: number, g: number, b: number, a: number) => void;
40
+ downloadImages: (onDownloadSucceeded: () => void) => void;
41
+ setPixelRatio: (ratio: number) => void;
42
+ setPan: (x: number, y: number, centerPointInViewport: boolean) => void;
43
+ addPan: (x: number, y: number) => void;
44
+ getPan: () => Vec2D;
45
+ getPanAtPosition: (x: number, y: number) => Vec2D;
46
+ getArtboardAtPosition: (x: number, y: number) => SketchWebArtboardUUID;
47
+ setMouse: (x: number, y: number) => void;
48
+ setRendererConfiguration: (configuration: RendererConfiguration) => void;
49
+ mouseDown: () => void;
50
+ mouseUp: () => void;
51
+ mouseDoubleClick: () => void;
52
+ keyUp: (code: string) => void;
53
+ setZoom: (zoom: number) => void;
54
+ addZoom: (zoom: number) => void;
55
+ getZoom: () => number;
56
+ setZoomCenter: (x: number, y: number) => void;
57
+ setZoomLevels: (maximumZoomLeave: number, maximumZoomLevel: number) => void;
58
+ setIsCameraMoving: (isMoving: boolean) => void;
59
+ setPanBoundariesPadding: (padding: number) => void;
60
+ scaleDocumentToFit: () => void;
61
+ delete: () => void;
62
+ }
63
+ export interface SketchWebWasm {
64
+ MakeGL: (emscriptenCtxHandle: EmscriptenCtxContextHandle, width: number, height: number) => SketchWebWasmInstance;
65
+ }
66
+ export declare type Vec2D = {
67
+ x: number;
68
+ y: number;
69
+ };
70
+ export declare type SketchWebArtboardUUID = string;
71
+ export declare type EmscriptenCtxContextHandle = number;
72
+ export declare type EmscriptenWebGLContextAttributes = {
73
+ majorVersion?: number;
74
+ minorVersion?: number;
75
+ } & WebGLContextAttributes;
7
76
  //# sourceMappingURL=WASM.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WASM.d.ts","sourceRoot":"","sources":["../../../src/ts/types/WASM.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG;IACvB,CAAC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"UNLICENSED",
5
5
  "description": "Sketch Web Renderer",
6
6
  "repository": "git@github.com:sketch-hq/web-renderer",
@@ -1 +0,0 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(function(){return(()=>{"use strict";var e,t,n={},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.m=n,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&r&&n;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((e=>s[e]=()=>n[e]));return s.default=()=>n,o.d(i,s),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,n)=>(o.f[n](e,t),t)),[])),o.u=e=>"static/js/web-renderer-"+{425:"370688708cb08dced537",816:"5f40dbb4c3823984584b"}[e]+".chunk.js",o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/",(()=>{var e={509:1};o.f.i=(t,n)=>{e[t]||importScripts(o.p+o.u(t))};var t=self.webpackChunk_sketch_hq_sketch_web_renderer=self.webpackChunk_sketch_hq_sketch_web_renderer||[],n=t.push.bind(t);t.push=t=>{var[r,i,s]=t;for(var a in i)o.o(i,a)&&(o.m[a]=i[a]);for(s&&s(o);r.length;)e[r.pop()]=1;n(t)}})();const i={delayedDraw:!0,offscreenCanvas:!1,safariWebGL2:!1,pageBoundariesLimit:!1};var s=/(iPhone|Macintosh|iPad)(.*)(Version)\/(0|[1-9]\d*)\.(0|[1-9]\d*)\.?(0|[1-9]\d*)?/;var a=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){var n,r;this.listeners[e]=null!==(n=this.listeners[e])&&void 0!==n?n:new Set,null===(r=this.listeners[e])||void 0===r||r.add(t)},e.prototype.off=function(e,t){var n;null===(n=this.listeners[e])||void 0===n||n.delete(t)},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this.listeners[e];(null==r?void 0:r.size)&&r.forEach((function(e){Promise.resolve().then((function(){e.apply(void 0,t)}))}))},e}(),c=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};const u=new(function(){function e(){this.active=!0}return e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.debug.apply(console,c(["[SketchWeb] [Debug]"],e))},e.prototype.warning=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.active&&console.warn.apply(console,c(["[SketchWeb] [Warn]"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,c(["[SketchWeb] [Error]"],e))},e}());var l,h,d=function(){function e(e){this.label=e,this.startTime=performance.now(),this.startTimestamp=Date.now(),u.debug("[Performance] Start: "+this.label)}return e.prototype.measure=function(){var e=performance.now()-this.startTime;return{duration:e,end:this.startTimestamp+e,start:this.startTimestamp,id:this.label}},e.prototype.printMeasurement=function(){var e=this.measure().duration;if(e<1e3){var t=e.toFixed(2);u.debug("[Performance] End: "+this.label+" -> "+t+" ms")}else{var n=(e/1e3).toFixed(2);u.debug("[Performance] End: "+this.label+" -> "+n+" s")}},e}(),p=(l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(e){function t(n,r,o){var i=this.constructor,s=e.call(this,"("+n+") "+r)||this;return s.code=n,s.cause=o,s.name=t.name,Object.setPrototypeOf(s,i.prototype),s}return p(t,e),t}(Error);!function(e){e.debug="debug",e.release="release"}(h||(h={}));var m=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),b=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},v=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},g=(globalThis.indexedDB,function(e){function t(t){var n=t.canvas,r=t.locateFile,o=t.filePath,a=t.imagesURLFormat,c=t.imagesURLMap,l=t.backgroundColor,p=void 0===l?{r:1,g:1,b:1,a:1}:l,f=t.highlightColor,m=void 0===f?{r:0,g:0,b:0,a:1}:f,b=t.size,v=t.pixelRatio,g=t.mode,y=t.showTilesBorders,w=void 0!==y&&y,W=t.minimumZoomLevel,k=t.maximumZoomLevel,L=t.preserveDrawingBuffer,P=void 0!==L&&L,E=t.panBoundariesPadding,R=void 0===E?40:E,x=e.call(this)||this;return x.status={type:"INIT"},x.handleWebGLContextLost=function(){x.setStatus({type:"WEBGL_CONTEXT_LOST"})},x.debouncedFullDraw=function(e,t){var n;function r(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(void 0,t)}),200)}return r.cancel=function(){n&&clearTimeout(n)},r}((function(){return x.draw(!0)})),x.canvas=n,x.locateFile=r,x.filePath=o,x.imagesURLFormat=a,x.imagesURLMap=c,x.backgroundColor=p,x.highlightColor=m,x.size=b,x.pixelRatio=v,x.mode=g,x.showTilesBorders=w,x.currentWebGLVersion=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(s);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}}}()&&!i.safariWebGL2?1:"undefined"!=typeof WebGL2RenderingContext?2:1,x.zoomLevels={min:W,max:k},x.preserveDrawingBuffer=P,x.panBoundariesPadding=R,u.active=g===h.debug,x.traceFirstPaint=new d("FirstPaint"),x}return m(t,e),t.prototype.init=function(){return b(this,void 0,void 0,(function(){var e;return v(this,(function(t){switch(t.label){case 0:this.setStatus({type:"INIT"}),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,this.initSketchWebWasm()];case 2:return t.sent(),[4,this.setFile(this.filePath)];case 3:return t.sent(),[3,5];case 4:return e=t.sent(),[2,this.fail(e instanceof f?e:new f("ERROR","Unexpected exception initializing the web renderer",e))];case 5:return[2]}}))}))},t.prototype.startRendering=function(){this.traceInitialRender=new d("InitialRender"),this.setStatus({type:"DRAWING_FILE"}),this.draw(!0,!1),this.sketchWebWasm.startRenderLoop()},t.prototype.createJSBridge=function(){var e=this;return{logDebug:function(e){u.debug("[C++] "+e)},logWarning:function(e){u.warning("[C++] "+e)},logError:function(e){u.error("[C++] "+e)},emitMetric:function(t,n,r,o){e.emit("metric",{id:t,start:n,end:r,duration:o})},resolveImageUrl:function(t){return e.imagesURLFormat?e.imagesURLFormat.replace(":imageId",t):e.imagesURLMap&&e.imagesURLMap[t]?e.imagesURLMap[t]:(u.warning("Not able to resolve the url for the image with UUID: "+t),"")},onDrawComplete:this.handleDrawComplete.bind(this),onArtboardMouseEnter:function(t){e.emit("artboardMouseEnter",t)},onArtboardMouseLeave:function(t){e.emit("artboardMouseLeave",t)},onArtboardSelected:function(t){e.emit("artboardSelected",t)},onArtboardDeselected:function(t){e.emit("artboardDeselected",t)},onGoToArtboard:function(t,n){e.emit("goToArtboard",t,n)}}},t.prototype.downloadImages=function(){var e=this;return new Promise((function(t){var n=new d("ImagesDownload");e.sketchWebWasm.downloadImages((function(){n.printMeasurement(),e.emit("metric",n.measure()),u.debug("Images downloaded"),t()}))}))},t.prototype.initSketchWebWasm=function(){return b(this,void 0,void 0,(function(){var e,t,n,r,s,a,c,l=this;return v(this,(function(p){switch(p.label){case 0:return e=new d("WasmModuleDownload"),this.mode!==h.debug?[3,2]:[4,o.e(425).then(o.t.bind(o,425,23))];case 1:return n=p.sent(),[3,4];case 2:return[4,o.e(816).then(o.t.bind(o,816,23))];case 3:n=p.sent(),p.label=4;case 4:t=n.default,p.label=5;case 5:return p.trys.push([5,7,,8]),r=this,[4,t({FeatureFlags:i,currentWebGLVersion:this.currentWebGLVersion,locateFile:function(e){return l.locateFile.replace("{file}",e)},bridge:this.createJSBridge()})];case 6:return r.wasmModule=p.sent(),[3,8];case 7:throw s=p.sent(),new f("WASM_ERROR","An error occurred while trying to create the wasm module.",s);case 8:if(e.printMeasurement(),this.emit("metric",e.measure()),a={antialias:!1,majorVersion:this.currentWebGLVersion,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:this.preserveDrawingBuffer},u.debug("Using WebGL "+a.majorVersion),!(c=this.wasmModule.GL.createContext(this.canvas,a)))throw new f("WEBGL_ERROR","Unable to create WebGL context. WebGL might be unsupported, disabled, or this device is not able to run WebGL correctly.");this.webglCtxHandle=c;try{this.sketchWebWasm=this.wasmModule.SketchWeb.MakeGL(this.webglCtxHandle,this.canvas.width,this.size.height)}catch(e){throw new f("WASM_ERROR","An error occurred while trying to create the SketchWebWasm object.",e)}return this.sketchWebWasm.setPixelRatio(this.pixelRatio),this.sketchWebWasm.setBackgroundColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),this.sketchWebWasm.setHighlightColor(this.highlightColor.r,this.highlightColor.g,this.highlightColor.b,this.highlightColor.a),this.sketchWebWasm.setRendererConfiguration({showTilesBorders:this.showTilesBorders}),this.sketchWebWasm.setZoomLevels(this.zoomLevels.min,this.zoomLevels.max),this.sketchWebWasm.setPanBoundariesPadding(this.panBoundariesPadding),this.canvas.addEventListener("webglcontextlost",this.handleWebGLContextLost),[2]}}))}))},t.prototype.generateDocumentPNG=function(){var e;return b(this,void 0,void 0,(function(){return v(this,(function(t){switch(t.label){case 0:return[4,this.downloadImages()];case 1:return t.sent(),[2,null===(e=this.sketchWebWasm)||void 0===e?void 0:e.generateDocumentPNG()]}}))}))},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"}),this.downloadImages())},t.prototype.looseWebGLContext=function(){var e=this.wasmModule.GL.getContext(this.webglCtxHandle);if(e){var t=e.GLctx.getExtension("WEBGL_lose_context");t?t.loseContext():console.warn("Unable to retrieve WEBGL_lose_context extension")}else console.warn("Unable to loose context. WebGL rendering context not found")},t.prototype.scaleDocumentToFit=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.scaleDocumentToFit(),this.delayedDraw()},t.prototype.setFile=function(e){return b(this,void 0,void 0,(function(){var t=this;return v(this,(function(n){return this.setStatus({type:"LOADING_FILE"}),[2,new Promise((function(n,r){t.sketchWebWasm.setFile(e,(function(e){if(void 0===e&&(e=[]),e.length){u.debug("Parser warnings: "+e);var r=e.map((function(e){return{key:e}}));t.emit("warnings",r)}t.setStatus({type:"FILE_READY"}),n()}),(function(){return r(new f("FILE_ERROR","Error encountered while fetching and parsing the file"))}))}))]}))}))},t.prototype.delayedDraw=function(){if(!i.delayedDraw)return this.draw(!0);this.draw(),this.debouncedFullDraw()},t.prototype.draw=function(e,t){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),null===(n=this.sketchWebWasm)||void 0===n||n.setNeedsUpdate(e,t)},t.prototype.fail=function(e){this.setStatus({type:"FAILURE",code:e.code,message:e.toString()+(e.cause?"\nWrapped Error: "+e.cause.toString():"")}),u.error(e),e.cause&&u.error(e.cause)},t.prototype.setPixelRatio=function(e){var t;this.pixelRatio=e,null===(t=this.sketchWebWasm)||void 0===t||t.setPixelRatio(e),this.delayedDraw()},t.prototype.setSize=function(e,t){var n;this.size.width=e,this.size.height=t,this.canvas.width=e,this.canvas.height=t,null===(n=this.sketchWebWasm)||void 0===n||n.resize(e,t)},t.prototype.setStatus=function(e){"FAILURE"!==this.status.type&&(u.debug("Status transition "+this.status.type+" => "+e.type+"}"),this.status=e,this.emit("status",e))},t.prototype.getArtboardAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getArtboardAtPosition(e,t)},t.prototype.getPanAtPosition=function(e,t){var n;return null===(n=this.sketchWebWasm)||void 0===n?void 0:n.getPanAtPosition(e,t)},t.prototype.getStatus=function(){return this.status},t.prototype.setZoom=function(e,t){var n,r;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(r=this.sketchWebWasm)||void 0===r||r.setZoom(e),this.delayedDraw()},t.prototype.addZoom=function(e,t){var n,r;null===(n=this.sketchWebWasm)||void 0===n||n.setZoomCenter(t.x,t.y),null===(r=this.sketchWebWasm)||void 0===r||r.addZoom(e),this.delayedDraw()},t.prototype.setPan=function(e,t,n){var r;void 0===n&&(n=!1),null===(r=this.sketchWebWasm)||void 0===r||r.setPan(e,t,n),this.delayedDraw()},t.prototype.addPan=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.addPan(e,t),this.delayedDraw()},t.prototype.getPan=function(){if(this.sketchWebWasm)return this.sketchWebWasm.getPan()},t.prototype.getZoom=function(){var e;return null===(e=this.sketchWebWasm)||void 0===e?void 0:e.getZoom()},t.prototype.setMouse=function(e,t){var n;null===(n=this.sketchWebWasm)||void 0===n||n.setMouse(e,t)},t.prototype.setIsCameraMoving=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.setIsCameraMoving(e)},t.prototype.mouseDown=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDown()},t.prototype.mouseUp=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseUp()},t.prototype.mouseDoubleClick=function(){var e;null===(e=this.sketchWebWasm)||void 0===e||e.mouseDoubleClick()},t.prototype.keyUp=function(e){var t;null===(t=this.sketchWebWasm)||void 0===t||t.keyUp(e)},t.prototype.dispose=function(){var e,t;try{null===(e=this.sketchWebWasm)||void 0===e||e.stopRenderLoop(),null===(t=this.sketchWebWasm)||void 0===t||t.delete()}catch(e){this.fail(new f("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}this.sketchWebWasm=null},t}(a));const y=Symbol("Comlink.proxy"),w=Symbol("Comlink.endpoint"),W=Symbol("Comlink.releaseProxy"),k=Symbol("Comlink.thrown"),L=e=>"object"==typeof e&&null!==e||"function"==typeof e,P=new Map([["proxy",{canHandle:e=>L(e)&&e[y],serialize(e){const{port1:t,port2:n}=new MessageChannel;return E(e,t),[n,[n]]},deserialize:e=>(e.start(),S(e,[],undefined))}],["throw",{canHandle:e=>L(e)&&k in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function E(e,t=self){t.addEventListener("message",(function n(r){if(!r||!r.data)return;const{id:o,type:i,path:s}=Object.assign({path:[]},r.data),a=(r.data.argumentList||[]).map(O);let c;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),n=s.reduce(((e,t)=>e[t]),e);switch(i){case"GET":c=n;break;case"SET":t[s.slice(-1)[0]]=O(r.data.value),c=!0;break;case"APPLY":c=n.apply(t,a);break;case"CONSTRUCT":c=function(e){return Object.assign(e,{[y]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;E(e,n),c=function(e,t){return _.set(e,t),e}(t,[t])}break;case"RELEASE":c=void 0;break;default:return}}catch(e){c={value:e,[k]:0}}Promise.resolve(c).catch((e=>({value:e,[k]:0}))).then((e=>{const[r,s]=D(e);t.postMessage(Object.assign(Object.assign({},r),{id:o}),s),"RELEASE"===i&&(t.removeEventListener("message",n),R(t))}))})),t.start&&t.start()}function R(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function x(e){if(e)throw new Error("Proxy has been released and is not useable")}function S(e,t=[],n=function(){}){let r=!1;const o=new Proxy(n,{get(n,i){if(x(r),i===W)return()=>M(e,{type:"RELEASE",path:t.map((e=>e.toString()))}).then((()=>{R(e),r=!0}));if("then"===i){if(0===t.length)return{then:()=>o};const n=M(e,{type:"GET",path:t.map((e=>e.toString()))}).then(O);return n.then.bind(n)}return S(e,[...t,i])},set(n,o,i){x(r);const[s,a]=D(i);return M(e,{type:"SET",path:[...t,o].map((e=>e.toString())),value:s},a).then(O)},apply(n,o,i){x(r);const s=t[t.length-1];if(s===w)return M(e,{type:"ENDPOINT"}).then(O);if("bind"===s)return S(e,t.slice(0,-1));const[a,c]=C(i);return M(e,{type:"APPLY",path:t.map((e=>e.toString())),argumentList:a},c).then(O)},construct(n,o){x(r);const[i,s]=C(o);return M(e,{type:"CONSTRUCT",path:t.map((e=>e.toString())),argumentList:i},s).then(O)}});return o}function C(e){const t=e.map(D);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const _=new WeakMap;function D(e){for(const[t,n]of P)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},_.get(e)||[]]}function O(e){switch(e.type){case"HANDLER":return P.get(e.name).deserialize(e.value);case"RAW":return e.value}}function M(e,t,n){return new Promise((r=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===o&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},t),n)}))}return E(g),{}})()}));