@sketch-hq/sketch-web-renderer 0.10.2 → 1.0.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 +35 -0
- package/dist/index.js +1 -1
- package/dist/module-debug.wasm +0 -0
- package/dist/module-release.wasm +0 -0
- package/dist/static/js/{web-renderer-f04ca78328f96a575c42.chunk.js → web-renderer-8526d667c341405f97bb.chunk.js} +1 -1
- package/dist/static/js/web-renderer-d6dd9cc40fc76bee6ddf.chunk.js +1 -0
- package/dist/ts/Manager.d.ts +1 -5
- package/dist/ts/Manager.d.ts.map +1 -1
- package/dist/ts/SketchWeb.d.ts +3 -5
- package/dist/ts/SketchWeb.d.ts.map +1 -1
- package/dist/ts/react/SketchWebProvider.d.ts +19 -0
- package/dist/ts/react/SketchWebProvider.d.ts.map +1 -0
- package/dist/ts/react/SketchWebReact.d.ts +14 -13
- package/dist/ts/react/SketchWebReact.d.ts.map +1 -1
- package/dist/ts/react/contexts.d.ts +46 -0
- package/dist/ts/react/contexts.d.ts.map +1 -0
- package/dist/ts/react/hooks/actions.d.ts +54 -0
- package/dist/ts/react/hooks/actions.d.ts.map +1 -0
- package/dist/ts/react/hooks/index.d.ts +4 -0
- package/dist/ts/react/hooks/index.d.ts.map +1 -0
- package/dist/ts/react/hooks/state.d.ts +48 -0
- package/dist/ts/react/hooks/state.d.ts.map +1 -0
- package/dist/ts/react/hooks/useEvent.d.ts +8 -0
- package/dist/ts/react/hooks/useEvent.d.ts.map +1 -0
- package/dist/ts/react/index.d.ts +2 -1
- package/dist/ts/react/index.d.ts.map +1 -1
- package/dist/ts/react/internal.d.ts +26 -0
- package/dist/ts/react/internal.d.ts.map +1 -0
- package/dist/ts/react/reducer.d.ts +17 -0
- package/dist/ts/react/reducer.d.ts.map +1 -0
- package/dist/ts/react/types.d.ts +72 -0
- package/dist/ts/react/types.d.ts.map +1 -0
- package/dist/ts/react/utils.d.ts +6 -0
- package/dist/ts/react/utils.d.ts.map +1 -0
- package/dist/ts/types/Events.d.ts +4 -0
- package/dist/ts/types/Events.d.ts.map +1 -1
- package/dist/ts/utils/GestureManager.d.ts +2 -0
- package/dist/ts/utils/GestureManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/static/js/web-renderer-07b28f3cdd6034926378.chunk.js +0 -1
- package/dist/ts/react/SketchWebContext.d.ts +0 -78
- package/dist/ts/react/SketchWebContext.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @sketch-hq/sketch-web-renderer
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 18b05c2: Prevent the renderer from crashing when an end region instruction is missing
|
|
8
|
+
- be70d4d: Fix lifecycle hooks to avoid unnecessary disposals.
|
|
9
|
+
|
|
10
|
+
## 1.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- 0461a28: Restructure the tiled renderer to improve the tiles management
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- f46894b: Encapsulate manager in SketchWebReact
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- a6b2797: Memory usage improvements
|
|
23
|
+
- 78202fe: Fix getArtboardAtPosition event not working correctly in certain cases
|
|
24
|
+
- 343c4cf: Correctly releasing the WebGL resources
|
|
25
|
+
|
|
26
|
+
## 0.11.1
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- ffed957: Fix pan position not updated correctly on initial zoom to fit. See https://github.com/sketch-hq/Cloud/issues/11363#issuecomment-1015542659
|
|
31
|
+
|
|
32
|
+
## 0.11.0
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- 1c9a5aa: Add camera lock API to prevent user panning and zooming.
|
|
37
|
+
|
|
3
38
|
## 0.10.2
|
|
4
39
|
|
|
5
40
|
### Patch 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),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)}}(),I=function(){return(I=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)},z=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 z(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 z(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 z(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 z(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=I(I({},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(I(I({},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")),i.on("allImagesReady",this.forwardEvent("allImagesReady")),[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 z(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 z(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 z(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 z(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 z(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 z(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 z(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 z(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 z(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)},onAllImagesReady:function(){e.emit("allImagesReady")}}},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:()=>U,oW:()=>O,JB:()=>m,qX:()=>E,SC:()=>D,zB:()=>R,GC:()=>W,xH:()=>v,z7:()=>A,rR:()=>C,JU:()=>M,vN:()=>g,Y6:()=>L,$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=function(e){var t=v();(0,r.useEffect)((function(){return null==t||t.on("allImagesReady",e),function(){null==t||t.off("allImagesReady",e)}}),[t,e])},x=(0,r.createContext)(void 0),D=function(){var e=(0,r.useContext)(x);if(void 0===e)throw Error("useSketchWebCursor must be used within a SketchWebProvider");return e},L=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])},R=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])},A=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])},Z=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)(Z,{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,E=h[1],D=(0,r.useCallback)((function(e){return E({type:"on-zoom",zoom:e})}),[]),L=(0,r.useCallback)((function(e,t){return E({type:"on-pan",pan:{x:e,y:t}})}),[]),R=(0,r.useCallback)((function(e){E({type:"on-status",status:e})}),[]),A=(0,r.useCallback)((function(e){return E({type:"on-artboard-mouse-enter",uuid:e})}),[]),U=(0,r.useCallback)((function(){return E({type:"on-artboard-mouse-leave"})}),[]),_=(0,r.useCallback)((function(e){E({type:"on-artboard-selected",uuid:e})}),[]),O=(0,r.useCallback)((function(){return E({type:"on-artboard-deselected"})}),[]),T=(0,r.useCallback)((function(){return E({type:"on-mouse-down"})}),[]),I=(0,r.useCallback)((function(){return E({type:"on-mouse-up"})}),[]),z=(0,r.useCallback)((function(){n.current&&(d("dispose"),n.current.off("status",R),n.current.off("artboardMouseEnter",A),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",I),n.current.dispose(),n.current=null,E({type:"dispose"}))}),[R,L,D,A,U,_,O,I,T]),G=(0,r.useCallback)((function(e){e&&!n.current&&s.current&&(d("init"),E({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",A),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",I),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=E,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,A,U,_,O,T,I]),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)}),[]),X=(0,r.useCallback)((function(){var e;d("zoomToFit"),null===(e=n.current)||void 0===e||e.zoomToFit()}),[]),Y=(0,r.useCallback)((function(){var e;d("looseWebGLContext"),null===(e=n.current)||void 0===e||e.looseWebGLContext()}),[]),V=(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:z,setZoom:j,incrementZoom:B,decrementZoom:N,setPan:H,zoomToFit:X,looseWebGLContext:Y,generateDocumentPNG:V,getArtboardAtPosition:q,getPanAtPosition:K}}),[F,G,z,j,B,N,H,X,Y,V,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(x.Provider,{value:M},t))))))))},_=n(332),O=function(e){s.Z.active=e.mode===_.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],x=S[1],L=(0,r.useState)(!1),R=L[0],A=L[1],Z=m(),U=Z.dispose,O=Z.setSettings,T=Z.init,I=D(),z=g();return E((function(){A(!0)})),(0,r.useEffect)((function(){M&&P&&O({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})}),[O,n,o,a,u,c,l,h,d,f,v,p,b,y,M,P]),(0,r.useEffect)((function(){if(t&&P&&M)return T(t),function(){return U()}}),[U,T,t,P,M]),i().createElement("div",{ref:function(e){return x(e)},style:{position:"relative",width:"100%",height:"100%"}},i().createElement("canvas",{onClick:w,onContextMenu:k,ref:function(e){return W(e)},"data-sketchweb-all-images-ready":R,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-"+((null==z?void 0:z.type.toLowerCase())||"null"),style:{position:"absolute",inset:"0",cursor:I}}))}},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:"07b28f3cdd6034926378",816:"f04ca78328f96a575c42"}[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,useSketchWebAllImagesReadyEvent:()=>h.qX,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:()=>F});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},isCameraLocked:!1,isWaitingForSecondClick:!1,lastMouseClickPosition:{x:0,y:0}},o.handleGestureStart=function(e){e.preventDefault(),o.state.isCameraLocked||(o.state.lastGestureScale=e.scale)},o.handleGestureChange=function(e){if(e.preventDefault(),!o.state.isCameraLocked){o.state.zoomCenter=o.getCorrectPointerPosition(e);var t=e.scale/o.state.lastGestureScale;o.state.lastGestureScale=e.scale,o.emitZoomEvent(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(),!o.state.isCameraLocked)){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){if(e.preventDefault(),!o.state.isCameraLocked){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.emitZoomEvent(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.emitZoomEvent=function(e,t){this.emit("zoomChange",e,t)},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.setIsCameraLocked=function(e){this.state.isCameraLocked=e},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=x(new n(...s));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;y(e,n),u=E(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]=S(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]=S(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(S);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const M=new WeakMap;function E(e,t){return M.set(e,t),e}function x(e){return Object.assign(e,{[f]:!0})}function S(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},M.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,Z=n(849),A=n(519),U=n(332),O=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)}}(),_=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 O(t,e),t.prototype.addListeners=function(){this.listenersCollector.add(this.target,"keyup",this.handleKeyUp)},t.prototype.dispose=function(){this.listenersCollector.dispose()},t}(r.v),I=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)}}(),T=function(){return(T=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)},z=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])}}},j=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 F=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 z(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 z(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 _(document.body),Z.Z.active=t.mode===U.p.debug,n.init(),n}return I(t,e),t.prototype.init=function(){var e;return z(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 z(this,void 0,void 0,(function(){var e,t,o,r,i;return G(this,(function(a){switch(a.label){case 0:return e=A.Z.offscreenCanvas&&"function"==typeof this.canvas.transferControlToOffscreen,t=T(T({},this.settings),{size:{width:this.canvas.width,height:this.canvas.height},pixelRatio:this.getDevicePixelRatio()}),e?(this.environment=R.worker,Z.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(E(T(T({},t),{canvas:this.offscreenCanvas}),[this.offscreenCanvas]))]):[3,2];case 1:return r.sketchWeb=a.sent(),[3,3];case 2:this.environment=R.browser,Z.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")),i.on("allImagesReady",this.forwardEvent("allImagesReady")),[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,j([e],n))};return this.environment===R.worker?x(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 z(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 z(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 z(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 z(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 z(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 z(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 z(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 z(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 z(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,M=void 0===W?40:W,E=e.call(this)||this;return E.status={type:"INIT"},E.handleWebGLContextLost=function(){E.setStatus({type:"WEBGL_CONTEXT_LOST"})},E.debouncedFullDraw=(0,r.Ds)((function(){return E.draw(!0)}),60),E.canvas=n,E.locateFile=o,E.filePath=i,E.imagesURLFormat=a,E.imagesURLMap=c,E.backgroundColor=d,E.highlightColor=v,E.size=p,E.pixelRatio=m,E.mode=b,E.showTilesBorders=y,E.currentWebGLVersion=(0,r.wX)(),E.zoomLevels={min:w,max:k},E.preserveDrawingBuffer=P,E.panBoundariesPadding=M,u.Z.active=b===l.p.debug,E.traceFirstPaint=new s.S("FirstPaint"),E}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)},onAllImagesReady:function(){e.emit("allImagesReady")}}},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(),this.looseWebGLContext(),this.sketchWebWasm=null,this.wasmModule=null}catch(e){this.fail(new c.k("ERROR","Unexpected exception while disposing the SketchWebWasm object",e))}},t}(a.v))},536:(e,t,n)=>{"use strict";n.d(t,{z0:()=>F,oW:()=>I,jr:()=>P,tm:()=>S,zX:()=>_,ex:()=>Z,Jw:()=>A,m_:()=>U,qK:()=>k,Yy:()=>x,EY:()=>O,pt:()=>R,od:()=>w,bQ:()=>C,ph:()=>D,lt:()=>E,$z:()=>g,BO:()=>y,us:()=>L});var o,r=n(297),i=n.n(r),a=n(332),s=n(849),u=(0,r.createContext)(void 0),c=function(){var e=(0,r.useContext)(u);if(void 0===e)throw Error("useSketchWebInternalContext must be used within a SketchWebProvider");return e},l=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},h=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.Z.debug.apply(s.Z,l(["SketchWebReact"],e))},d=(0,r.createContext)(void 0),f=(0,r.createContext)(void 0),v=(0,r.createContext)(void 0),p=(0,r.createContext)(void 0),m=(0,r.createContext)(void 0),b=(0,r.createContext)(void 0),g=function(){var e=(0,r.useContext)(d);if(void 0===e)throw Error("useStatus must be used within a SketchWebProvider");return e},y=function(){var e=(0,r.useContext)(f);if(void 0===e)throw Error("useZoom must be used within a SketchWebProvider");return e},w=function(){var e=(0,r.useContext)(v);if(void 0===e)throw Error("usePan must be used within a SketchWebProvider");return e},k=function(){var e=(0,r.useContext)(p);if(void 0===e)throw Error("useHoveredArtboardUUID must be used within a SketchWebProvider");return e},C=function(){var e=(0,r.useContext)(m);if(void 0===e)throw Error("useSelectedArtboardUUID must be used within a SketchWebProvider");return e},P=function(){var e=(0,r.useContext)(b);if(void 0===e)throw Error("useCursor must be used within a SketchWebProvider");return e},W=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())}))},M=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])}}},E=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t){h("setZoom",t),console.log(e),null==e||e.setZoom(t)}),[e])},x=function(){var e=E(),t=y();return(0,r.useCallback)((function(){var n;h("incrementZoom"),"number"==typeof t&&(n=t>=1?Math.round(2*t):t>.5?1:2*t,e(n))}),[e,t])},S=function(){var e=E(),t=y();return(0,r.useCallback)((function(){h("decrementZoom"),"number"==typeof t&&e(t/2)}),[e,t])},D=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t){var n=t.x,o=t.y,r=t.centerPointInViewport;h("setPan",n,o,"centerPointInViewport",r),null==e||e.setPan(n,o,r)}),[e])},L=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(){h("zoomToFit"),null==e||e.zoomToFit()}),[e])},R=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(){h("looseWebGLContext"),null==e||e.looseWebGLContext()}),[e])},Z=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(){return W(void 0,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return h("generateDocumentPNG"),[4,null==e?void 0:e.generateDocumentPNG()];case 1:return[2,t.sent()]}}))}))}),[e])},A=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t,n){return W(void 0,void 0,void 0,(function(){return M(this,(function(o){switch(o.label){case 0:return h("getArtboardAtPosition",t,n),[4,null==e?void 0:e.getArtboardAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},U=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t,n){return W(void 0,void 0,void 0,(function(){return M(this,(function(o){switch(o.label){case 0:return h("getPanAtPosition",t,n),[4,null==e?void 0:e.getPanAtPosition(t,n)];case 1:return[2,o.sent()||null]}}))}))}),[e])},O=function(){var e=(0,c().getManager)();return(0,r.useCallback)((function(t){h("setIsCameraLocked",t),null==e||e.gestureManager.setIsCameraLocked(t)}),[e])},_=function(e,t){var n=(0,c().getManager)();(0,r.useEffect)((function(){return null==n||n.on(e,t),function(){null==n||n.off(e,t)}}),[e,n,t])},I=function(e){s.Z.active=e.mode===a.p.debug;var t=e.filePath,n=e.locateFile,o=e.imagesURLFormat,u=e.imagesURLMap,l=e.backgroundColor,h=e.highlightColor,d=e.mode,f=e.showTilesBorders,v=e.minimumZoomLevel,p=e.maximumZoomLevel,m=e.preserveDrawingBuffer,b=e.panBoundariesPadding,y=e.initialPan,w=e.initialZoom,k=e.onCanvasClick,C=e.onCanvasContextMenu,W=(0,r.useRef)(null),M=(0,r.useRef)(null),E=(0,r.useState)(!1),x=E[0],S=E[1],D=(0,r.useCallback)((function(){return S(!0)}),[]),L=c(),R=L.dispose,Z=L.init,A=L.setSettings,U=P(),O=g();return _("allImagesReady",D),(0,r.useEffect)((function(){A({locateFile:n,imagesURLFormat:o,imagesURLMap:u,backgroundColor:l,highlightColor:h,mode:d,showTilesBorders:f,minimumZoomLevel:v,maximumZoomLevel:p,preserveDrawingBuffer:m,panBoundariesPadding:b,initialPan:y,initialZoom:w})}),[A,n,o,u,l,h,d,f,v,p,m,b,y,w]),(0,r.useEffect)((function(){if(t)return Z(t,W.current,M.current),function(){R()}}),[R,Z,t]),i().createElement("div",{ref:M,style:{position:"relative",width:"100%",height:"100%"}},t&&i().createElement("canvas",{key:t,onClick:k,onContextMenu:C,ref:W,"data-sketchweb-all-images-ready":x,"data-testid":"sketchweb-canvas","data-sketchweb-status":"sketchweb-status-"+((null==O?void 0:O.type.toLowerCase())||"null"),style:{position:"absolute",inset:"0",cursor:U}}))},T=n(933);!function(e){e.Draggable="grab",e.Dragging="grabbing",e.Hover="pointer",e.Default="auto"}(o||(o={}));var 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)},G=function(e,t){switch(h('dispatched: "'+t.type+'"',t),t.type){case"on-status":return z(z({},e),{status:t.status});case"on-zoom":return z(z({},e),{zoom:t.zoom});case"on-pan":return z(z({},e),{pan:t.pan});case"dispose":return z(z({},e),{status:null,selectedArtboardUUID:null,hoveredArtboardUUID:null,zoom:null,pan:null,cursor:o.Default});case"post-init":return z(z({},e),{status:t.status,zoom:t.zoom});case"on-artboard-mouse-enter":return z(z({},e),{hoveredArtboardUUID:t.uuid,cursor:o.Hover});case"on-artboard-mouse-leave":return z(z({},e),{hoveredArtboardUUID:null,cursor:e.isMouseDown?o.Dragging:o.Draggable});case"on-artboard-selected":return z(z({},e),{selectedArtboardUUID:t.uuid});case"on-artboard-deselected":return z(z({},e),{selectedArtboardUUID:null});case"on-mouse-down":return z(z({},e),{cursor:o.Dragging,isMouseDown:!0});case"on-mouse-up":return z(z({},e),{cursor:e.hoveredArtboardUUID?o.Hover:o.Draggable,isMouseDown:!1});default:return e}},j=function(){return(j=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)},F=function(e){var t=e.children,n=(0,r.useRef)(null),a=(0,r.useRef)(null),s=(0,r.useReducer)(G,{pan:null,zoom:null,status:null,hoveredArtboardUUID:null,selectedArtboardUUID:null,cursor:o.Default,isMouseDown:!1}),c=s[0],l=c.status,g=c.zoom,y=c.pan,w=c.hoveredArtboardUUID,k=c.selectedArtboardUUID,C=c.cursor,P=s[1],W=(0,r.useCallback)((function(e){return P({type:"on-zoom",zoom:e})}),[]),M=(0,r.useCallback)((function(e,t){return P({type:"on-pan",pan:{x:e,y:t}})}),[]),E=(0,r.useCallback)((function(e){P({type:"on-status",status:e})}),[]),x=(0,r.useCallback)((function(e){return P({type:"on-artboard-mouse-enter",uuid:e})}),[]),S=(0,r.useCallback)((function(){return P({type:"on-artboard-mouse-leave"})}),[]),D=(0,r.useCallback)((function(e){P({type:"on-artboard-selected",uuid:e})}),[]),L=(0,r.useCallback)((function(){return P({type:"on-artboard-deselected"})}),[]),R=(0,r.useCallback)((function(){return P({type:"on-mouse-down"})}),[]),Z=(0,r.useCallback)((function(){return P({type:"on-mouse-up"})}),[]),A=(0,r.useCallback)((function(){var e=n.current;e&&(h("dispose"),e.off("status",E),e.off("artboardMouseEnter",x),e.off("artboardMouseLeave",S),e.off("artboardSelected",D),e.off("artboardDeselected",L),e.off("zoom",W),e.off("pan",M),e.gestureManager.off("mousedown",R),e.gestureManager.off("mouseup",Z),e.dispose(),n.current=null,P({type:"dispose"}))}),[E,M,W,x,S,D,L,Z,R]),U=(0,r.useCallback)((function(e,t,o){if(""!==e&&t&&o&&a.current){h("init");var r=new T.d(j(j({},a.current),{filePath:e,container:o,canvas:t}));r.on("status",E),r.on("artboardMouseEnter",x),r.on("artboardMouseLeave",S),r.on("artboardSelected",D),r.on("artboardDeselected",L),r.on("zoom",W),r.on("pan",M),r.gestureManager.on("mousedown",R),r.gestureManager.on("mouseup",Z),i=void 0,s=void 0,c=function(){var e,t,n;return 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])}}}(this,(function(o){switch(o.label){case 0:return[4,r.getPan()];case 1:return e=o.sent()||null,t=P,n={type:"post-init"},[4,r.getZoom()];case 2:return n.zoom=o.sent()||null,[4,r.getStatus()];case 3:return t.apply(void 0,[(n.status=o.sent()||null,n.pan=null!=e?e:null,n)]),[2]}}))},new((u=void 0)||(u=Promise))((function(e,t){function n(e){try{r(c.next(e))}catch(e){t(e)}}function o(e){try{r(c.throw(e))}catch(e){t(e)}}function r(t){var r;t.done?e(t.value):(r=t.value,r instanceof u?r:new u((function(e){e(r)}))).then(n,o)}r((c=c.apply(i,s||[])).next())})),n.current=r}var i,s,u,c}),[E,W,M,x,S,D,L,R,Z]),O=(0,r.useCallback)((function(e){h("setSettings",e),a.current=e}),[]),_=(0,r.useCallback)((function(){return n.current}),[]),I=(0,r.useMemo)((function(){return{dispose:A,init:U,setSettings:O,getManager:_,dispatch:P}}),[A,U,O,_]);return i().createElement(u.Provider,{value:I},i().createElement(d.Provider,{value:l},i().createElement(f.Provider,{value:g},i().createElement(v.Provider,{value:y},i().createElement(m.Provider,{value:k},i().createElement(p.Provider,{value:w},i().createElement(b.Provider,{value:C},t)))))))}},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:"d6dd9cc40fc76bee6ddf",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,useCursor:()=>h.jr,useDecrementZoom:()=>h.tm,useEvent:()=>h.zX,useGenerateDocumentPNG:()=>h.ex,useGetArtboardAtPosititon:()=>h.Jw,useGetPanAtPosition:()=>h.m_,useHoveredArtboardUUID:()=>h.qK,useIncrementZoom:()=>h.Yy,useLockCamera:()=>h.EY,useLooseWebGLContext:()=>h.pt,usePan:()=>h.od,useSelectedArtboardUUID:()=>h.bQ,useSetPan:()=>h.ph,useSetZoom:()=>h.lt,useStatus:()=>h.$z,useZoom:()=>h.BO,useZoomToFit:()=>h.us});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(536);const d=e.d})(),u})()}));
|
package/dist/module-debug.wasm
CHANGED
|
Binary file
|
package/dist/module-release.wasm
CHANGED
|
Binary file
|