diff --git a/Icondrop.sketchplugin/Contents/Sketch/index.js b/Icondrop.sketchplugin/Contents/Sketch/index.js index 6d4885a..46c8555 100644 --- a/Icondrop.sketchplugin/Contents/Sketch/index.js +++ b/Icondrop.sketchplugin/Contents/Sketch/index.js @@ -1 +1 @@ -var that=this;function __skpm_run(e,t){that.context=t;var n=function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=24)}([function(e,t){e.exports=require("sketch/dom")},function(e,t){e.exports=require("sketch/settings")},function(e,t,n){var i=n(4).default;e.exports=new i({options:null,"buttonClicked:":function(e){this.options.onClicked&&this.options.onClicked(e.tag()),this.release()},"button0Clicked:":function(){this.options.onClicked&&this.options.onClicked(0),this.release()},"button1Clicked:":function(){this.options.onClicked&&this.options.onClicked(1),this.release()}})},function(e,t){function n(){}n.defaultMaxListeners=10;var i,o=n.prototype;function r(e){return"function"==typeof e||!(!e||"object"!=typeof e)&&r(e.listener)}o._maxListeners=n.defaultMaxListeners,o._getListeners=function(e){var t=this._getEvents();return t[e]||(t[e]=[])},o._getEvents=function(){return this._events||(this._events={})},o.addListener=(i="on",function(){return this[i].apply(this,arguments)}),o.emit=function(e){var t,n,i=Array.prototype.slice.call(arguments,1),o=this._getListeners(e)||[];for(n=0;n0},o.eventNames=function(){var e=this._getEvents();return Object.keys(e)},o.getMaxListeners=function(){return this._maxListeners},o.listenerCount=function(e){return this._getListeners(e).length},o.listeners=function(e){return this._getListeners(e).map(function(e){return e.listener})},o.on=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.push(i?t:{listener:t,once:!1}),this},o.once=function(e,t){return this.on(e,{listener:t,once:!0})},o.prependListener=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.unshift(i?t:{listener:t,once:!1}),this},o.prependOnceListener=function(e,t){return this.prependListener(e,{listener:t,once:!0})},o.removeAllListeners=function(e){var t=this._getEvents();return"string"==typeof e?delete t[e]:delete this._events,this},o.removeListener=function(e,t){var n=this._getListeners(e),i=function(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}(n,t);return-1!==i&&(n.splice(i,1),this.emit("removeListener",e,t)),this},o.setMaxListeners=function(e){return this._maxListeners=e,this},o.rawListeners=function(e){return this._getListeners(e).slice()},e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=void 0,t.default=function(e){const t=e.superclass||NSObject,n=(e.className||e.classname||"ObjCClass")+NSUUID.UUID().UUIDString(),r=new Set(["className","classname","superclass"]);var a=MOClassDescription.allocateDescriptionForClassWithName_superclass_(n,t);const s=[];for(var l in e){const t=e[l];if("function"==typeof t&&"init"!==l){var c=NSSelectorFromString(l);a.addInstanceMethodWithSelector_function_(c,t)}else r.has(l)||(s.push(l),a.addInstanceVariableWithName_typeEncoding(l,"@"))}return a.addInstanceMethodWithSelector_function_(NSSelectorFromString("init"),function(){const t=o.call(this);return s.map(n=>{Object.defineProperty(t,n,{get:()=>(function(e,t){const n=MOPointer.new();return(0,i.object_getInstanceVariable)(e,t,n),n.value().retain().autorelease()})(t,n),set(e){(0,i.object_setInstanceVariable)(t,n,e)}}),t[n]=e[n]}),"function"==typeof e.init&&e.init.call(this),t}),a.registerClass()};var i=n(15);t.SuperCall=i.SuperCall;const o=(0,i.SuperCall)(NSStringFromSelector("init"),[],{type:"@"})},function(e,t){e.exports.getURL=function(e){return NSURL.URLWithString(String(NSString.stringWithString(e).stringByExpandingTildeInPath()).replace(/ /g,"%20"))}},function(e,t){e.exports=require("sketch/ui")},function(e,t){e.exports=require("sketch")},function(e,t,n){var i=n(3),o=n(10),r=n(11),a=n(12),s=n(13),l=n(14);function c(e){var t=(e=e||{}).identifier||NSUUID.UUID().UUIDString(),n=NSThread.mainThread().threadDictionary(),u=c.fromId(t);if(u)return u;var d,f=new i;f.id=t;try{d=coscript.createFiber()}catch(x){coscript.shouldKeepAround=!0}var h=e.width||800,p=e.height||600,m=NSScreen.screens().firstObject().frame(),S=NSMakeRect(void 0!==e.x?e.x:Math.round((NSWidth(m)-h)/2),void 0!==e.y?e.y:Math.round((NSHeight(m)-p)/2),h,p);e.titleBarStyle&&"default"!==e.titleBarStyle&&(e.frame=!1);var g="textured"!==e.windowType,v=NSTitledWindowMask;!1!==e.minimizable&&(v|=NSMiniaturizableWindowMask),!1!==e.closable&&(v|=NSClosableWindowMask),!1!==e.resizable&&(v|=NSResizableWindowMask),g&&!e.transparent&&!1!==e.frame||(v|=NSTexturedBackgroundWindowMask);var y=NSPanel.alloc().initWithContentRect_styleMask_backing_defer(S,v,NSBackingStoreBuffered,!0),b=WebView.alloc().initWithFrame(NSMakeRect(0,0,e.width||800,e.height||600));if(b.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),o(f,y,b),r(f,y,b),l(f,y,b),"desktop"===e.windowType&&(y.setLevel(kCGDesktopWindowLevel-1),y.setCollectionBehavior(NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorIgnoresCycle)),void 0===e.minWidth&&void 0===e.minHeight||f.setMinimumSize(e.minWidth||0,e.minHeight||0),void 0===e.maxWidth&&void 0===e.maxHeight||f.setMaximumSize(e.maxWidth||1e4,e.maxHeight||1e4),e.transparent||!1===e.frame){y.titlebarAppearsTransparent=!0,y.titleVisibility=NSWindowTitleHidden,y.setOpaque(0),y.isMovableByWindowBackground=!0;var w=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");w.setShowsBaselineSeparator(!1),y.setToolbar(w)}if("hiddenInset"===e.titleBarStyle){var N=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");N.setShowsBaselineSeparator(!1),y.setToolbar(N)}!1!==e.frame&&e.useContentSize||f.setSize(h,p),e.center&&f.center(),e.alwaysOnTop&&f.setAlwaysOnTop(!0),e.fullscreen&&f.setFullScreen(!0),f.setFullScreenable(!!e.fullscreenable);const M=e.title||("undefined"!=typeof __command&&__command.pluginBundle()?__command.pluginBundle().name():void 0);M&&f.setTitle(M);var F=e.backgroundColor;e.transparent&&(F=NSColor.clearColor()),!F&&!1===e.frame&&e.vibrancy&&(F=NSColor.clearColor()),f._setBackgroundColor(F||NSColor.windowBackgroundColor()),!1===e.hasShadow&&f.setHasShadow(!1),void 0!==e.opacity&&f.setOpacity(e.opacity),e.webPreferences;var C=y.contentView();return!1!==e.frame?(b.setFrame(C.bounds()),C.addSubview(b)):(C.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),a(C,C.superview()),b.setFrame(C.bounds()),C.addSubview(b),y.standardWindowButton(NSWindowFullScreenButton)&&y.standardWindowButton(NSWindowFullScreenButton).setHidden(!0),e.titleBarStyle&&"default"!==e.titleBarStyle||(y.standardWindowButton(NSWindowZoomButton).setHidden(!0),y.standardWindowButton(NSWindowMiniaturizeButton).setHidden(!0),y.standardWindowButton(NSWindowCloseButton).setHidden(!0),y.standardWindowButton(NSWindowZoomButton).setEnabled(!1))),e.vibrancy&&f.setVibrancy(e.vibrancy),f.setMaximizable(!1!==e.maximizable),e.acceptsFirstMouse&&f.on("focus",function(e){e.type()===NSEventTypeLeftMouseDown&&f.webContents.executeJavaScript(s(b,e))}),!1!==e.show&&f.show(),f.on("closed",function(){f._destroyed=!0,n.removeObjectForKey(t),d?d.cleanup():coscript.shouldKeepAround=!1}),n[t]=y,d&&d.onCleanup(function(){f._destroyed||f.destroy()}),f}c.fromId=function(e){var t=NSThread.mainThread().threadDictionary();if(t[e])return c.fromPanel(t[e],e)},c.fromPanel=function(e,t){var n=new i;if(n.id=t,!e||!e.contentView)throw new Error("needs to pass an NSPanel");var a=e.contentView().subviews()[0];if(!a)throw new Error("The NSPanel needs to have a webview");return o(n,e,a),r(n,e,a),n},e.exports=c},function(e){e.exports={name:"Icondrop",identifier:"com.iconscout.sketch.icondrop",description:"Get access to 2,000,000+ Icons, Illustrations & Stock Photos right into Sketch App",version:"2.1.0",icon:"icon.png",homepage:"https://iconscout.com",author:"Iconscout",authorEmail:"support@iconscout.com",appcast:"https://raw.githubusercontent.com/Iconscout/icondrop/master/.appcast.xml",compatibleVersion:3,bundleVersion:1,commands:[{name:"Icondrop",script:"./iconscout/index.js",identifier:"icondrop",description:"Get access to 2,000,000+ Icons, Illustrations & Stock Photos right into Sketch App",icon:"icons/favicon-64x64.png",shortcut:"cmd shift i"},{name:"Iconscout Selection Changed",identifier:"selection-changed",script:"./selection-changed.js",handlers:{actions:{"SelectionChanged.finish":"onSelectionChanged"}}}],menu:{items:["icondrop"],isRoot:!0}}},function(e,t){var n=["NSColor","NSCachedWhiteColor","NSColorSpaceColor","NSDynamicSystemColor","NSCachedColorSpaceColor"];e.exports=function(e,t,i){function o(n){e.isVisible()||(n?(NSApplication.sharedApplication().activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)):t.orderBack(null))}e._panel=t,e._webview=i,e._destroyed=!1,e.destroy=function(){return t.close()},e.close=function(){e.isClosable()&&t.performClose(null)},e.focus=o.bind(this,!0),e.blur=o.bind(this,!1),e.isFocused=function(){return t.isKeyWindow()},e.isDestroyed=function(){return e._destroyed},e.show=function(){return NSApp.activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)},e.showInactive=function(){return t.orderFrontRegardless()},e.hide=function(){return t.orderOut(null)},e.isVisible=function(){return t.isVisible()},e.isModal=function(){return!1},e.maximize=function(){e.isMaximized()||t.zoom(null)},e.unmaximize=function(){e.isMaximized()&&t.zoom(null)},e.isMaximized=function(){if(0!=(t.styleMask()&NSResizableWindowMask))return t.isZoomed();var e=NSScreen.mainScreen().visibleFrame(),n=t.frame();return e.origin.x==n.origin.x&&e.origin.y==n.origin.y&&e.size.width==n.size.width&&e.size.height==n.size.height},e.minimize=function(){return t.miniaturize(null)},e.restore=function(){return t.deminiaturize(null)},e.isMinimized=function(){return t.isMiniaturized()},e.setFullScreen=function(n){n!==e.isFullscreen()&&t.toggleFullScreen(null)},e.isFullscreen=function(){return t.styleMask()&NSFullScreenWindowMask},e.setAspectRatio=function(e){e>0?t.setAspectRatio(NSMakeSize(e,1)):t.setResizeIncrements(NSMakeSize(1,1))},e.setBounds=function(n,i){if(!e.isFullscreen()){var o=n.size,r=NSMakeRect(n.origin.x,0,o.width,o.height),a=NSScreen.screens().firstObject();r.origin.y=NSHeight(a.frame())-o.height-n.origin.y,t.setFrame_display_animate(r,!0,i)}},e.getBounds=function(){return t.frame()},e.setContentBounds=function(){},e.getContentBounds=function(){},e.setSize=function(t,n,i){var o=e.getBounds();return o.size.height=n,o.size.width=t,e.setBounds(o,i)},e.getSize=function(){var t=e.getBounds();return[t.size.width,t.size.height]},e.setContentSize=function(t,n,i){var o=e.getContentBounds();return o.size.height=n,o.size.width=t,e.setContentBounds(o,i)},e.getContentSize=function(){var t=e.getContentBounds();return[t.size.width,t.size.height]},e.setMinimumSize=function(e,n){const i={width:e,height:n};t.setContentMinSize(i)},e.getMinimumSize=function(){const e=t.contentMinSize();return[e.width,e.height]},e.setMaximumSize=function(e,n){const i={width:e,height:n};t.setContentMaxSize(i)},e.getMaximumSize=function(){const e=t.contentMaxSize();return[e.width,e.height]},e.setResizable=function(t){return e._setStyleMask(t,NSResizableWindowMask)},e.isResizable=function(){return t.styleMask()&NSResizableWindowMask},e.setMovable=function(e){return t.setMovable(e)},e.isMovable=function(){return t.isMovable()},e.setMinimizable=function(t){return e._setStyleMask(t,NSMiniaturizableWindowMask)},e.isMinimizable=function(){return t.styleMask()&NSMiniaturizableWindowMask},e.setMaximizable=function(e){t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).setEnabled(e)},e.isMaximizable=function(){return t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).isEnabled()},e.setFullScreenable=function(t){e._setCollectionBehavior(t,NSWindowCollectionBehaviorFullScreenPrimary),e._setCollectionBehavior(!t,NSWindowCollectionBehaviorFullScreenAuxiliary)},e.isFullScreenable=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorFullScreenPrimary},e.setClosable=function(t){e._setStyleMask(t,NSClosableWindowMask)},e.isClosable=function(){return t.styleMask()&NSClosableWindowMask},e.setAlwaysOnTop=function(e,n,i){var o=NSNormalWindowLevel,r=CGWindowLevelForKey(kCGMaximumWindowLevelKey),a=CGWindowLevelForKey(kCGMinimumWindowLevelKey);e&&(o="normal"===n?NSNormalWindowLevel:"torn-off-menu"===n?NSTornOffMenuWindowLevel:"modal-panel"===n?NSModalPanelWindowLevel:"main-menu"===n?NSMainMenuWindowLevel:"status"===n?NSStatusWindowLevel:"pop-up-menu"===n?NSPopUpMenuWindowLevel:"screen-saver"===n?NSScreenSaverWindowLevel:"dock"===n?NSDockWindowLevel:NSFloatingWindowLevel);var s=o+(i||0);if(!(s>=a&&s<=r))throw new Error("relativeLevel must be between "+a+" and "+r);t.setLevel(s)},e.isAlwaysOnTop=function(){return t.level()!==NSNormalWindowLevel},e.moveTop=function(){return t.orderFrontRegardless()},e.center=function(){t.center()},e.setPosition=function(t,n,i){var o=e.getBounds(),r=NSScreen.screens().firstObject().frame();return o.origin.x=t,o.origin.y=Math.round(NSHeight(r)-n),e.setBounds(o,i)},e.getPosition=function(){var t=e.getBounds(),n=NSScreen.screens().firstObject().frame();return[t.origin.x,Math.round(NSHeight(n)-t.origin.y)]},e.setTitle=function(e){t.setTitle(e)},e.getTitle=function(){return String(t.title())};var r=0;e.flashFrame=function(e){e?r=NSApp.requestUserAttention(NSInformationalRequest):(NSApp.cancelUserAttentionRequest(r),r=0)},e.getNativeWindowHandle=function(){return t},e.getNativeWebViewHandle=function(){return i},e.loadURL=function(e){/^(?!http|localhost|www|file).*\.html?$/.test(e)&&"undefined"!=typeof __command&&__command.pluginBundle()&&(e=__command.pluginBundle().urlForResourceNamed(e).path()),i.setMainFrameURL(e)},e.reload=function(){i.reload()},e.setHasShadow=function(e){return t.setHasShadow(e)},e.hasShadow=function(){return t.hasShadow()},e.setOpacity=function(e){return t.setAlphaValue(e)},e.getOpacity=function(){return t.alphaValue()},e.setVisibleOnAllWorkspaces=function(t){return e._setCollectionBehavior(t,NSWindowCollectionBehaviorCanJoinAllSpaces)},e.isVisibleOnAllWorkspaces=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorCanJoinAllSpaces},e.setIgnoreMouseEvents=function(e){return t.setIgnoresMouseEvents(e)},e.setContentProtection=function(e){t.setSharingType(e?NSWindowSharingNone:NSWindowSharingReadOnly)},e.setAutoHideCursor=function(e){t.setDisableAutoHideCursor(e)},e.setVibrancy=function(n){var i=e._vibrantView;if(!n){if(null==i)return;return i.removeFromSuperview(),void t.setVibrantView(null)}if(null==i){var o=t.contentView();i=NSVisualEffectView.alloc().initWithFrame(o.bounds()),e._vibrantView=i,i.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),i.setBlendingMode(NSVisualEffectBlendingModeBehindWindow),i.setState(NSVisualEffectStateActive),i.setFrame(o.bounds()),o.addSubview_positioned_relativeTo(i,NSWindowBelow,null)}var r=NSVisualEffectMaterialLight;"appearance-based"===n?r=NSVisualEffectMaterialAppearanceBased:"light"===n?r=NSVisualEffectMaterialLight:"dark"===n?r=NSVisualEffectMaterialDark:"titlebar"===n?r=NSVisualEffectMaterialTitlebar:"selection"===n?r=NSVisualEffectMaterialSelection:"menu"===n?r=NSVisualEffectMaterialMenu:"popover"===n?r=NSVisualEffectMaterialPopover:"sidebar"===n?r=NSVisualEffectMaterialSidebar:"medium-light"===n?r=NSVisualEffectMaterialMediumLight:"ultra-dark"===n&&(r=NSVisualEffectMaterialUltraDark),i.setMaterial(r)},e._setBackgroundColor=function(e){var o=function(e){if(!e||"#"!==e[0]){if(e&&e.class&&-1!==n.indexOf(String(e.class())))return e;throw new Error("Incorrect color formating. It should be an hex color: #RRGGBBAA")}var t,i=e.substr(1);if(3===i.length?i+="F":6===i.length&&(i+="FF"),4===i.length)for(var o=0;o<4;o+=1)t+=i[o],t+=i[o];else{if(8!==i.length)return NSColor.whiteColor();t=i}var r=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),l=parseInt(t.slice(6,8),16);return NSColor.colorWithSRGBRed_green_blue_alpha(r,a,s,l)}(e);i.setDrawsBackground(!1),t.backgroundColor=o},e._invalidate=function(){t.flushWindow(),t.contentView().setNeedsDisplay(!0)},e._setStyleMask=function(n,i){var o=e.isMaximizable();n?t.setStyleMask(t.styleMask()|i):t.setStyleMask(t.styleMask()&~i),e.setMaximizable(o)},e._setCollectionBehavior=function(n,i){var o=e.isMaximizable();n?t.setCollectionBehavior(t.collectionBehavior()|i):t.setCollectionBehavior(t.collectionBehavior()&~i),e.setMaximizable(o)},e._showWindowButton=function(e){var n=t.standardWindowButton(e);n.superview().addSubview_positioned_relative(n,NSWindowAbove,null)}}},function(e,t,n){var i=n(3);e.exports=function(e,t,n){var o=new i;o.loadURL=e.loadURL,o.getURL=n.mainFrameURL,o.getTitle=n.mainFrameTitle,o.isDestroyed=function(){},o.isLoading=function(){return n.loading()},o.stop=n.stopLoading,o.reload=n.reload,o.canGoBack=n.canGoBack,o.canGoForward=n.canGoForward,o.goBack=n.goBack,o.goForward=n.goForward,o.executeJavaScript=function(e){return n.stringByEvaluatingJavaScriptFromString(e)},o.undo=function(){n.undoManager().undo()},o.redo=function(){n.undoManager().redo()},o.cut=n.cut,o.copy=n.copy,o.paste=n.paste,o.pasteAndMatchStyle=n.pasteAsRichText,o.delete=n.delete,o.replace=n.replaceSelectionWithText,o.getNativeWebview=function(){return n},e.webContents=o}},function(e,t){function n(e,t,n,i){n.addConstraint(NSLayoutConstraint.constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(t,e,NSLayoutRelationEqual,n,e,1,i))}e.exports=function(e,t,i){i=i||[],e.setTranslatesAutoresizingMaskIntoConstraints(!1),n(NSLayoutAttributeLeft,e,t,i[0]||0),n(NSLayoutAttributeTop,e,t,i[1]||0),n(NSLayoutAttributeRight,e,t,i[2]||0),n(NSLayoutAttributeBottom,e,t,i[3]||0)}},function(e,t){e.exports=function(e,t){var n=e.convertPoint_fromView(t.locationInWindow(),null);return"var el = document.elementFromPoint("+n.x+", "+(e.frame().size.height-n.y)+'); if (el && ["text", "textarea", "date", "datetime-local", "email", "number", "month", "password", "search", "tel", "time", "url", "week" ].indexOf(el.type) >= 0 && el.focus) {el.focus();} else if (el) {el.dispatchEvent(new Event("click", {bubbles: true}))}'}},function(e,t,n){var i,o,r=n(4).default,a=n(16),s=n(17);e.exports=function(e,t,n){i||(i=r({classname:"WindowDelegateClass",utils:null,"windowDidResize:":function(){this.utils.emit("resize")},"windowDidMiniaturize:":function(){this.utils.emit("minimize")},"windowDidDeminiaturize:":function(){this.utils.emit("restore")},"windowDidEnterFullScreen:":function(){this.utils.emit("enter-full-screen")},"windowDidExitFullScreen:":function(){this.utils.emit("leave-full-screen")},"windowDidMove:":function(){this.utils.emit("move"),this.utils.emit("moved")},"windowShouldClose:":function(){var e=!0;return this.utils.emit("close",{get defaultPrevented(){return!e},preventDefault:function(){e=!1}}),e},"windowWillClose:":function(){this.utils.emit("closed")},"windowDidBecomeKey:":function(){this.utils.emit("focus",t.currentEvent())},"windowDidResignKey:":function(){this.utils.emit("blur")}})),o||(o=r({classname:"FrameLoadDelegateClass",state:NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),utils:null,"webView:didChangeLocationWithinPageForFrame:":function(e){this.utils.emit("did-navigate-in-page",[{},String(e.stringByEvaluatingJavaScriptFromString("window.location.href"))])},"webView:didCreateJavaScriptContext:forFrame:":function(e){e.windowScriptObject().setValue_forKey_(this,s.JS_BRIDGE)},"invokeUndefinedMethodFromWebScript:withArguments:":function(e,t){if("callNative"!==String(e))return!1;var n=this.utils.parseWebArguments(t);return!!n&&(this.utils.emit.apply(this,n),!0)},"webView:didFailLoadWithError:forFrame:":function(e,t){this.utils.emit("did-fail-load",t)},"webView:didFinishLoadForFrame:":function(){0==this.state.wasReady&&(this.utils.emitBrowserEvent("ready-to-show"),this.state.setObject_forKey(1,"wasReady")),this.utils.emit("did-finish-load"),this.utils.emit("did-frame-finish-load"),this.utils.emit("dom-ready")},"webView:didReceiveServerRedirectForProvisionalLoadForFrame:":function(){this.utils.emit("did-get-redirect-request")},"webView:didReceiveTitle:forFrame:":function(e,t){var n=String(t),i=!0;this.utils.emitBrowserEvent("page-title-updated",{get defaultPrevented(){return!i},preventDefault:function(){i=!1}},n),i&&n&&this.utils.setTitle(n)},"webView:didStartProvisionalLoadForFrame:":function(){this.utils.emit("did-start-loading")},"webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:":function(e,t){this.utils.emit("will-navigate",{},String(t.absoluteString))}}));var l=o.new();l.utils=NSDictionary.dictionaryWithDictionary({setTitle:e.setTitle.bind(e),emitBrowserEvent:e.emit.bind(e),emit:e.webContents.emit.bind(e.webContents),parseWebArguments:a}),l.state=NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),n.setFrameLoadDelegate(l);var c=i.new();c.utils=NSDictionary.dictionaryWithDictionary({emit:e.emit.bind(e)}),t.setDelegate(c)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=function(e,t,n){const o=r("objc_msgSendSuper",[{type:"^"+i},{type:":"},...t],n);return function(...t){const n=(i=this,r=this.superclass(),function e(t){if("object"!=typeof t||0==Object.keys(t).length)return t;const n=Object.keys(t)[0],i=t[n],o=MOStruct.structureWithName_memberNames_runtime(n,Object.keys(i),Mocha.sharedRuntime());return Object.keys(i).map(t=>{o[t]=e(i[t])}),o}({objc_super:{receiver:i,super_class:r}}));var i,r;const a=MOPointer.alloc().initWithValue_(n);return o(a,e,...t)}},t.CFunc=r;const i='{objc_super="receiver"@"super_class"#}';function o(e,t){const n=NSMutableDictionary.dictionary();n.o=e,Object.keys(t).map(e=>n.setValue_forKeyPath(t[e],"o."+e))}function r(e,t,n){function i(e){if(!e)return null;const t=MOBridgeSupportArgument.alloc().init();return o(t,{type64:e.type}),t}const r=MOBridgeSupportFunction.alloc().init();return o(r,{name:e,arguments:t.map(i),returnValue:i(n)}),r}t.object_getInstanceVariable=r("object_getInstanceVariable",[{type:"@"},{type:"*"},{type:"^@"}],{type:"^{objc_ivar=}"}),t.object_setInstanceVariable=r("object_setInstanceVariable",[{type:"@"},{type:"*"},{type:"@"}],{type:"^{objc_ivar=}"});!function(e,t){const n=MOBridgeSupportController.sharedController().valueForKey("symbols");if(!n)throw Error("Something has changed within bridge support so we can't add our definitions");if(null!==n[e])return;const i=MOBridgeSupportStruct.alloc().init();o(i,{name:e,type:t.type}),n[e]=i}("objc_super",{type:i})},function(e,t){e.exports=function(e){var t=null;try{t=JSON.parse(e[0])}catch(n){}return t&&t.constructor&&t.constructor===Array&&0!=t.length?t:null}},function(e,t){e.exports={JS_BRIDGE:"__skpm_sketchBridge"}},function(e,t,n){e.exports={showOpenDialog:n(19),showSaveDialog:n(20),showMessageBox:n(21)}},function(e,t,n){var i=n(2),o=n(5);e.exports=function(e,t,n){e&&"function"==typeof e.class||(n=t,t=e,e=void 0),t||(t={});var r,a=NSOpenPanel.openPanel();if(t.title&&(a.title=t.title),t.defaultPath&&a.setDirectoryURL(o.getURL(t.defaultPath)),t.buttonLabel&&(a.prompt=t.buttonLabel),t.filters&&t.filters.length){var s=[];t.filters.forEach(function(e){e.extensions.forEach(function(e){s.push(e)})}),a.allowedFileTypes=s}function l(){for(var e=[],t=a.URLs(),n=0;n1&&l[l.length-1]&&s.setNameFieldStringValue(l[l.length-1])}else s.setNameFieldStringValue(t.defaultPath);if(t.buttonLabel&&(s.prompt=t.buttonLabel),t.filters&&t.filters.length){var c=[];t.filters.forEach(function(e){e.extensions.forEach(function(e){c.push(e)})}),s.allowedFileTypes=c}if(t.message&&(s.message=t.message),t.nameFieldLabel&&(s.nameFieldLabel=t.nameFieldLabel),t.showsTagField&&(s.showsTagField=t.showsTagField),!e)return(r=s.runModal())==NSOKButton?(a=String(s.URL().path()),n?void n(a):a):void 0;var u=NSButton.class();function d(e,t){if(t&&t.subviews&&t.subviews())for(var n=t.subviews(),i=0;ic&&(d=(f=c)*u);var h=a+(l-d)/2,p=s+(c-f)/2;return new o.Rectangle(h,p,d,f)}),h=function(e,t,n){var i=t.url,o=t.name;d.log("fn: replaceWithSVG");var r=NSURL.alloc().initWithString(i),a=MSSVGImporter.svgImporter();a.prepareToImportFromURL(r);var s=a.importAsLayer();if(s.name=o,e){var l=s.frame(),c=f(l.width(),l.height(),e,n);l.setWidth(c.width),l.setHeight(c.height),l.setX(c.x),l.setY(c.y);var u=e.parentGroup();if(u)u.addLayer(s);else{var h=n.api().selectedDocument.selectedPage._object,p=h.currentArtboard();p?p.addLayer(s):h.addLayer(s)}}else{var m=n.api().selectedDocument.selectedPage._object,S=s.frame(),g=n.api().selectedDocument._object.contentDrawView().visibleContentRect();S.setX(g.origin.x+(g.size.width-S.width())/2),S.setY(g.origin.y+(g.size.height-S.height())/2),m.addLayer(s)}};function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=function(e){var t=NSDocumentController.sharedDocumentController().currentDocument();if(MSApplicationMetadata.metadata().appVersion>41.2)var n=t.selectedLayers().layers();else n=t.selectedLayers();return function(e){for(var t=1;tl/c?u=(f=c)*h:f=(u=l)/h;var p=a+(l-u)/2,m=s+(c-f)/2;return new o.Rectangle(p,m,u,f)},w=function e(t,i,o,r){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(d.log("fn: fillLayer"),t instanceof MSSymbolInstance){if(r){var s=g(i).url,l=y(s),c=t.overrides();null==c&&(c={});var u=NSMutableDictionary.dictionaryWithDictionary(c);u.setObject_forKey(NSMutableDictionary.dictionaryWithDictionary(c.objectForKey(0)),0),u.setObject_forKey(l,r.objectID()),t.overrides=u}}else if(t instanceof MSLayerGroup)t.layers().forEach(function(t){e(t,i,o)});else{var f=g(i).url;a?(d.log("Masking Layer "+f),function(e,t,n){d.log("fn: maskLayerWithImage");var i=n.api().selectedDocument.selectedPage._object,o=e.parentArtboard(),r=o||i,a=e.parentGroup();a&&(r=a);var s=y(t),l=MSBitmapLayer.new();l.setImage(s),l.frame().size=l.NSImage().size(),l.setConstrainProportions(0);var c=l.frame(),u=b(c.width(),c.height(),e,n);l.frame().setWidth(u.width),l.frame().setHeight(u.height),l.frame().setX(u.x),l.frame().setY(u.y);var f=MSLayerGroup.new();f.setName(e.name()),e.removeFromParent(),e.setHasClippingMask(1),e.style().addStylePartOfType(0),e.style().fills().firstObject().setFillType(0),f.addLayer(e),f.addLayer(l),r.addLayer(f),f.resizeToFitChildrenWithOption(1),f.setConstrainProportions(!0)}(t,f,o)):(d.log("Filling Layer "+f),function(e,t,i){d.log("fn: fillLayerWithImage");var o=y(t),r=e.style().fills();if(0===r.count()){var a=n(0).Style;n(0).fromNative(e).style.fills=[{color:"#c0ffee",fill:a.FillType.Color}]}var s=r.firstObject();s.setFillType(4),s.setImage(o),s.setPatternFillType(1)}(t,f))}},N=function(e,t){var n=t.force,i=t.mask,o=void 0!==i&&i,r=t.replace,a=void 0!==r&&r,s=t.context;d.log("fn: insertOrFillImage");var l=m().selection,c=l.count();if(d.log("Selected Layers "+c),c>0){var u;if(c>1){if(function(e){d.log("fn: hasDifferentSymbols");var t=[];return e.forEach(function(e){if(e instanceof MSSymbolInstance){var n=e.symbolMaster().objectID();-1===t.indexOf(n)&&t.push(n)}}),t.length>1}(l))return void s.document.showMessage("Sorry! You can't fill data in different type of layers.","Please select you have only one type of Symbol/Shape!");var f=function(e){d.log("fn: getFirstSymbolMaster");for(var t=0;t0},o.eventNames=function(){var e=this._getEvents();return Object.keys(e)},o.getMaxListeners=function(){return this._maxListeners},o.listenerCount=function(e){return this._getListeners(e).length},o.listeners=function(e){return this._getListeners(e).map(function(e){return e.listener})},o.on=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.push(i?t:{listener:t,once:!1}),this},o.once=function(e,t){return this.on(e,{listener:t,once:!0})},o.prependListener=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.unshift(i?t:{listener:t,once:!1}),this},o.prependOnceListener=function(e,t){return this.prependListener(e,{listener:t,once:!0})},o.removeAllListeners=function(e){var t=this._getEvents();return"string"==typeof e?delete t[e]:delete this._events,this},o.removeListener=function(e,t){var n=this._getListeners(e),i=function(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}(n,t);return-1!==i&&(n.splice(i,1),this.emit("removeListener",e,t)),this},o.setMaxListeners=function(e){return this._maxListeners=e,this},o.rawListeners=function(e){return this._getListeners(e).slice()},e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=void 0,t.default=function(e){const t=e.superclass||NSObject,n=(e.className||e.classname||"ObjCClass")+NSUUID.UUID().UUIDString(),r=new Set(["className","classname","superclass"]);var a=MOClassDescription.allocateDescriptionForClassWithName_superclass_(n,t);const s=[];for(var l in e){const t=e[l];if("function"==typeof t&&"init"!==l){var c=NSSelectorFromString(l);a.addInstanceMethodWithSelector_function_(c,t)}else r.has(l)||(s.push(l),a.addInstanceVariableWithName_typeEncoding(l,"@"))}return a.addInstanceMethodWithSelector_function_(NSSelectorFromString("init"),function(){const t=o.call(this);return s.map(n=>{Object.defineProperty(t,n,{get:()=>(function(e,t){const n=MOPointer.new();return(0,i.object_getInstanceVariable)(e,t,n),n.value().retain().autorelease()})(t,n),set(e){(0,i.object_setInstanceVariable)(t,n,e)}}),t[n]=e[n]}),"function"==typeof e.init&&e.init.call(this),t}),a.registerClass()};var i=n(15);t.SuperCall=i.SuperCall;const o=(0,i.SuperCall)(NSStringFromSelector("init"),[],{type:"@"})},function(e,t){e.exports.getURL=function(e){return NSURL.URLWithString(String(NSString.stringWithString(e).stringByExpandingTildeInPath()).replace(/ /g,"%20"))}},function(e,t){e.exports=require("sketch/ui")},function(e,t){e.exports=require("sketch")},function(e,t,n){var i=n(3),o=n(10),r=n(11),a=n(12),s=n(13),l=n(14);function c(e){var t=(e=e||{}).identifier||NSUUID.UUID().UUIDString(),n=NSThread.mainThread().threadDictionary(),u=c.fromId(t);if(u)return u;var d,f=new i;f.id=t;try{d=coscript.createFiber()}catch(x){coscript.shouldKeepAround=!0}var h=e.width||800,p=e.height||600,m=NSScreen.screens().firstObject().frame(),S=NSMakeRect(void 0!==e.x?e.x:Math.round((NSWidth(m)-h)/2),void 0!==e.y?e.y:Math.round((NSHeight(m)-p)/2),h,p);e.titleBarStyle&&"default"!==e.titleBarStyle&&(e.frame=!1);var g="textured"!==e.windowType,v=NSTitledWindowMask;!1!==e.minimizable&&(v|=NSMiniaturizableWindowMask),!1!==e.closable&&(v|=NSClosableWindowMask),!1!==e.resizable&&(v|=NSResizableWindowMask),g&&!e.transparent&&!1!==e.frame||(v|=NSTexturedBackgroundWindowMask);var y=NSPanel.alloc().initWithContentRect_styleMask_backing_defer(S,v,NSBackingStoreBuffered,!0),b=WebView.alloc().initWithFrame(NSMakeRect(0,0,e.width||800,e.height||600));if(b.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),o(f,y,b),r(f,y,b),l(f,y,b),"desktop"===e.windowType&&(y.setLevel(kCGDesktopWindowLevel-1),y.setCollectionBehavior(NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorIgnoresCycle)),void 0===e.minWidth&&void 0===e.minHeight||f.setMinimumSize(e.minWidth||0,e.minHeight||0),void 0===e.maxWidth&&void 0===e.maxHeight||f.setMaximumSize(e.maxWidth||1e4,e.maxHeight||1e4),e.transparent||!1===e.frame){y.titlebarAppearsTransparent=!0,y.titleVisibility=NSWindowTitleHidden,y.setOpaque(0),y.isMovableByWindowBackground=!0;var w=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");w.setShowsBaselineSeparator(!1),y.setToolbar(w)}if("hiddenInset"===e.titleBarStyle){var N=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");N.setShowsBaselineSeparator(!1),y.setToolbar(N)}!1!==e.frame&&e.useContentSize||f.setSize(h,p),e.center&&f.center(),e.alwaysOnTop&&f.setAlwaysOnTop(!0),e.fullscreen&&f.setFullScreen(!0),f.setFullScreenable(!!e.fullscreenable);const M=e.title||("undefined"!=typeof __command&&__command.pluginBundle()?__command.pluginBundle().name():void 0);M&&f.setTitle(M);var F=e.backgroundColor;e.transparent&&(F=NSColor.clearColor()),!F&&!1===e.frame&&e.vibrancy&&(F=NSColor.clearColor()),f._setBackgroundColor(F||NSColor.windowBackgroundColor()),!1===e.hasShadow&&f.setHasShadow(!1),void 0!==e.opacity&&f.setOpacity(e.opacity),e.webPreferences;var C=y.contentView();return!1!==e.frame?(b.setFrame(C.bounds()),C.addSubview(b)):(C.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),a(C,C.superview()),b.setFrame(C.bounds()),C.addSubview(b),y.standardWindowButton(NSWindowFullScreenButton)&&y.standardWindowButton(NSWindowFullScreenButton).setHidden(!0),e.titleBarStyle&&"default"!==e.titleBarStyle||(y.standardWindowButton(NSWindowZoomButton).setHidden(!0),y.standardWindowButton(NSWindowMiniaturizeButton).setHidden(!0),y.standardWindowButton(NSWindowCloseButton).setHidden(!0),y.standardWindowButton(NSWindowZoomButton).setEnabled(!1))),e.vibrancy&&f.setVibrancy(e.vibrancy),f.setMaximizable(!1!==e.maximizable),e.acceptsFirstMouse&&f.on("focus",function(e){e.type()===NSEventTypeLeftMouseDown&&f.webContents.executeJavaScript(s(b,e))}),!1!==e.show&&f.show(),f.on("closed",function(){f._destroyed=!0,n.removeObjectForKey(t),d?d.cleanup():coscript.shouldKeepAround=!1}),n[t]=y,d&&d.onCleanup(function(){f._destroyed||f.destroy()}),f}c.fromId=function(e){var t=NSThread.mainThread().threadDictionary();if(t[e])return c.fromPanel(t[e],e)},c.fromPanel=function(e,t){var n=new i;if(n.id=t,!e||!e.contentView)throw new Error("needs to pass an NSPanel");var a=e.contentView().subviews()[0];if(!a)throw new Error("The NSPanel needs to have a webview");return o(n,e,a),r(n,e,a),n},e.exports=c},function(e){e.exports={name:"Icondrop",identifier:"com.iconscout.sketch.icondrop",description:"Get access to 2,000,000+ Icons, Illustrations & Stock Photos right into Sketch App",version:"2.2.1",icon:"icon.png",homepage:"https://iconscout.com",author:"Iconscout",authorEmail:"support@iconscout.com",appcast:"https://raw.githubusercontent.com/Iconscout/icondrop/master/.appcast.xml",compatibleVersion:3,bundleVersion:1,commands:[{name:"Icondrop",script:"./iconscout/index.js",identifier:"icondrop",description:"Get access to 2,000,000+ Icons, Illustrations & Stock Photos right into Sketch App",icon:"icons/favicon-64x64.png",shortcut:"cmd shift i"},{name:"Iconscout Selection Changed",identifier:"selection-changed",script:"./selection-changed.js",handlers:{actions:{"SelectionChanged.finish":"onSelectionChanged"}}}],menu:{items:["icondrop"],isRoot:!0}}},function(e,t){var n=["NSColor","NSCachedWhiteColor","NSColorSpaceColor","NSDynamicSystemColor","NSCachedColorSpaceColor"];e.exports=function(e,t,i){function o(n){e.isVisible()||(n?(NSApplication.sharedApplication().activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)):t.orderBack(null))}e._panel=t,e._webview=i,e._destroyed=!1,e.destroy=function(){return t.close()},e.close=function(){e.isClosable()&&t.performClose(null)},e.focus=o.bind(this,!0),e.blur=o.bind(this,!1),e.isFocused=function(){return t.isKeyWindow()},e.isDestroyed=function(){return e._destroyed},e.show=function(){return NSApp.activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)},e.showInactive=function(){return t.orderFrontRegardless()},e.hide=function(){return t.orderOut(null)},e.isVisible=function(){return t.isVisible()},e.isModal=function(){return!1},e.maximize=function(){e.isMaximized()||t.zoom(null)},e.unmaximize=function(){e.isMaximized()&&t.zoom(null)},e.isMaximized=function(){if(0!=(t.styleMask()&NSResizableWindowMask))return t.isZoomed();var e=NSScreen.mainScreen().visibleFrame(),n=t.frame();return e.origin.x==n.origin.x&&e.origin.y==n.origin.y&&e.size.width==n.size.width&&e.size.height==n.size.height},e.minimize=function(){return t.miniaturize(null)},e.restore=function(){return t.deminiaturize(null)},e.isMinimized=function(){return t.isMiniaturized()},e.setFullScreen=function(n){n!==e.isFullscreen()&&t.toggleFullScreen(null)},e.isFullscreen=function(){return t.styleMask()&NSFullScreenWindowMask},e.setAspectRatio=function(e){e>0?t.setAspectRatio(NSMakeSize(e,1)):t.setResizeIncrements(NSMakeSize(1,1))},e.setBounds=function(n,i){if(!e.isFullscreen()){var o=n.size,r=NSMakeRect(n.origin.x,0,o.width,o.height),a=NSScreen.screens().firstObject();r.origin.y=NSHeight(a.frame())-o.height-n.origin.y,t.setFrame_display_animate(r,!0,i)}},e.getBounds=function(){return t.frame()},e.setContentBounds=function(){},e.getContentBounds=function(){},e.setSize=function(t,n,i){var o=e.getBounds();return o.size.height=n,o.size.width=t,e.setBounds(o,i)},e.getSize=function(){var t=e.getBounds();return[t.size.width,t.size.height]},e.setContentSize=function(t,n,i){var o=e.getContentBounds();return o.size.height=n,o.size.width=t,e.setContentBounds(o,i)},e.getContentSize=function(){var t=e.getContentBounds();return[t.size.width,t.size.height]},e.setMinimumSize=function(e,n){const i={width:e,height:n};t.setContentMinSize(i)},e.getMinimumSize=function(){const e=t.contentMinSize();return[e.width,e.height]},e.setMaximumSize=function(e,n){const i={width:e,height:n};t.setContentMaxSize(i)},e.getMaximumSize=function(){const e=t.contentMaxSize();return[e.width,e.height]},e.setResizable=function(t){return e._setStyleMask(t,NSResizableWindowMask)},e.isResizable=function(){return t.styleMask()&NSResizableWindowMask},e.setMovable=function(e){return t.setMovable(e)},e.isMovable=function(){return t.isMovable()},e.setMinimizable=function(t){return e._setStyleMask(t,NSMiniaturizableWindowMask)},e.isMinimizable=function(){return t.styleMask()&NSMiniaturizableWindowMask},e.setMaximizable=function(e){t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).setEnabled(e)},e.isMaximizable=function(){return t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).isEnabled()},e.setFullScreenable=function(t){e._setCollectionBehavior(t,NSWindowCollectionBehaviorFullScreenPrimary),e._setCollectionBehavior(!t,NSWindowCollectionBehaviorFullScreenAuxiliary)},e.isFullScreenable=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorFullScreenPrimary},e.setClosable=function(t){e._setStyleMask(t,NSClosableWindowMask)},e.isClosable=function(){return t.styleMask()&NSClosableWindowMask},e.setAlwaysOnTop=function(e,n,i){var o=NSNormalWindowLevel,r=CGWindowLevelForKey(kCGMaximumWindowLevelKey),a=CGWindowLevelForKey(kCGMinimumWindowLevelKey);e&&(o="normal"===n?NSNormalWindowLevel:"torn-off-menu"===n?NSTornOffMenuWindowLevel:"modal-panel"===n?NSModalPanelWindowLevel:"main-menu"===n?NSMainMenuWindowLevel:"status"===n?NSStatusWindowLevel:"pop-up-menu"===n?NSPopUpMenuWindowLevel:"screen-saver"===n?NSScreenSaverWindowLevel:"dock"===n?NSDockWindowLevel:NSFloatingWindowLevel);var s=o+(i||0);if(!(s>=a&&s<=r))throw new Error("relativeLevel must be between "+a+" and "+r);t.setLevel(s)},e.isAlwaysOnTop=function(){return t.level()!==NSNormalWindowLevel},e.moveTop=function(){return t.orderFrontRegardless()},e.center=function(){t.center()},e.setPosition=function(t,n,i){var o=e.getBounds(),r=NSScreen.screens().firstObject().frame();return o.origin.x=t,o.origin.y=Math.round(NSHeight(r)-n),e.setBounds(o,i)},e.getPosition=function(){var t=e.getBounds(),n=NSScreen.screens().firstObject().frame();return[t.origin.x,Math.round(NSHeight(n)-t.origin.y)]},e.setTitle=function(e){t.setTitle(e)},e.getTitle=function(){return String(t.title())};var r=0;e.flashFrame=function(e){e?r=NSApp.requestUserAttention(NSInformationalRequest):(NSApp.cancelUserAttentionRequest(r),r=0)},e.getNativeWindowHandle=function(){return t},e.getNativeWebViewHandle=function(){return i},e.loadURL=function(e){/^(?!http|localhost|www|file).*\.html?$/.test(e)&&"undefined"!=typeof __command&&__command.pluginBundle()&&(e=__command.pluginBundle().urlForResourceNamed(e).path()),i.setMainFrameURL(e)},e.reload=function(){i.reload()},e.setHasShadow=function(e){return t.setHasShadow(e)},e.hasShadow=function(){return t.hasShadow()},e.setOpacity=function(e){return t.setAlphaValue(e)},e.getOpacity=function(){return t.alphaValue()},e.setVisibleOnAllWorkspaces=function(t){return e._setCollectionBehavior(t,NSWindowCollectionBehaviorCanJoinAllSpaces)},e.isVisibleOnAllWorkspaces=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorCanJoinAllSpaces},e.setIgnoreMouseEvents=function(e){return t.setIgnoresMouseEvents(e)},e.setContentProtection=function(e){t.setSharingType(e?NSWindowSharingNone:NSWindowSharingReadOnly)},e.setAutoHideCursor=function(e){t.setDisableAutoHideCursor(e)},e.setVibrancy=function(n){var i=e._vibrantView;if(!n){if(null==i)return;return i.removeFromSuperview(),void t.setVibrantView(null)}if(null==i){var o=t.contentView();i=NSVisualEffectView.alloc().initWithFrame(o.bounds()),e._vibrantView=i,i.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),i.setBlendingMode(NSVisualEffectBlendingModeBehindWindow),i.setState(NSVisualEffectStateActive),i.setFrame(o.bounds()),o.addSubview_positioned_relativeTo(i,NSWindowBelow,null)}var r=NSVisualEffectMaterialLight;"appearance-based"===n?r=NSVisualEffectMaterialAppearanceBased:"light"===n?r=NSVisualEffectMaterialLight:"dark"===n?r=NSVisualEffectMaterialDark:"titlebar"===n?r=NSVisualEffectMaterialTitlebar:"selection"===n?r=NSVisualEffectMaterialSelection:"menu"===n?r=NSVisualEffectMaterialMenu:"popover"===n?r=NSVisualEffectMaterialPopover:"sidebar"===n?r=NSVisualEffectMaterialSidebar:"medium-light"===n?r=NSVisualEffectMaterialMediumLight:"ultra-dark"===n&&(r=NSVisualEffectMaterialUltraDark),i.setMaterial(r)},e._setBackgroundColor=function(e){var o=function(e){if(!e||"#"!==e[0]){if(e&&e.class&&-1!==n.indexOf(String(e.class())))return e;throw new Error("Incorrect color formating. It should be an hex color: #RRGGBBAA")}var t,i=e.substr(1);if(3===i.length?i+="F":6===i.length&&(i+="FF"),4===i.length)for(var o=0;o<4;o+=1)t+=i[o],t+=i[o];else{if(8!==i.length)return NSColor.whiteColor();t=i}var r=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),l=parseInt(t.slice(6,8),16);return NSColor.colorWithSRGBRed_green_blue_alpha(r,a,s,l)}(e);i.setDrawsBackground(!1),t.backgroundColor=o},e._invalidate=function(){t.flushWindow(),t.contentView().setNeedsDisplay(!0)},e._setStyleMask=function(n,i){var o=e.isMaximizable();n?t.setStyleMask(t.styleMask()|i):t.setStyleMask(t.styleMask()&~i),e.setMaximizable(o)},e._setCollectionBehavior=function(n,i){var o=e.isMaximizable();n?t.setCollectionBehavior(t.collectionBehavior()|i):t.setCollectionBehavior(t.collectionBehavior()&~i),e.setMaximizable(o)},e._showWindowButton=function(e){var n=t.standardWindowButton(e);n.superview().addSubview_positioned_relative(n,NSWindowAbove,null)}}},function(e,t,n){var i=n(3);e.exports=function(e,t,n){var o=new i;o.loadURL=e.loadURL,o.getURL=n.mainFrameURL,o.getTitle=n.mainFrameTitle,o.isDestroyed=function(){},o.isLoading=function(){return n.loading()},o.stop=n.stopLoading,o.reload=n.reload,o.canGoBack=n.canGoBack,o.canGoForward=n.canGoForward,o.goBack=n.goBack,o.goForward=n.goForward,o.executeJavaScript=function(e){return n.stringByEvaluatingJavaScriptFromString(e)},o.undo=function(){n.undoManager().undo()},o.redo=function(){n.undoManager().redo()},o.cut=n.cut,o.copy=n.copy,o.paste=n.paste,o.pasteAndMatchStyle=n.pasteAsRichText,o.delete=n.delete,o.replace=n.replaceSelectionWithText,o.getNativeWebview=function(){return n},e.webContents=o}},function(e,t){function n(e,t,n,i){n.addConstraint(NSLayoutConstraint.constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(t,e,NSLayoutRelationEqual,n,e,1,i))}e.exports=function(e,t,i){i=i||[],e.setTranslatesAutoresizingMaskIntoConstraints(!1),n(NSLayoutAttributeLeft,e,t,i[0]||0),n(NSLayoutAttributeTop,e,t,i[1]||0),n(NSLayoutAttributeRight,e,t,i[2]||0),n(NSLayoutAttributeBottom,e,t,i[3]||0)}},function(e,t){e.exports=function(e,t){var n=e.convertPoint_fromView(t.locationInWindow(),null);return"var el = document.elementFromPoint("+n.x+", "+(e.frame().size.height-n.y)+'); if (el && ["text", "textarea", "date", "datetime-local", "email", "number", "month", "password", "search", "tel", "time", "url", "week" ].indexOf(el.type) >= 0 && el.focus) {el.focus();} else if (el) {el.dispatchEvent(new Event("click", {bubbles: true}))}'}},function(e,t,n){var i,o,r=n(4).default,a=n(16),s=n(17);e.exports=function(e,t,n){i||(i=r({classname:"WindowDelegateClass",utils:null,"windowDidResize:":function(){this.utils.emit("resize")},"windowDidMiniaturize:":function(){this.utils.emit("minimize")},"windowDidDeminiaturize:":function(){this.utils.emit("restore")},"windowDidEnterFullScreen:":function(){this.utils.emit("enter-full-screen")},"windowDidExitFullScreen:":function(){this.utils.emit("leave-full-screen")},"windowDidMove:":function(){this.utils.emit("move"),this.utils.emit("moved")},"windowShouldClose:":function(){var e=!0;return this.utils.emit("close",{get defaultPrevented(){return!e},preventDefault:function(){e=!1}}),e},"windowWillClose:":function(){this.utils.emit("closed")},"windowDidBecomeKey:":function(){this.utils.emit("focus",t.currentEvent())},"windowDidResignKey:":function(){this.utils.emit("blur")}})),o||(o=r({classname:"FrameLoadDelegateClass",state:NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),utils:null,"webView:didChangeLocationWithinPageForFrame:":function(e){this.utils.emit("did-navigate-in-page",[{},String(e.stringByEvaluatingJavaScriptFromString("window.location.href"))])},"webView:didCreateJavaScriptContext:forFrame:":function(e){e.windowScriptObject().setValue_forKey_(this,s.JS_BRIDGE)},"invokeUndefinedMethodFromWebScript:withArguments:":function(e,t){if("callNative"!==String(e))return!1;var n=this.utils.parseWebArguments(t);return!!n&&(this.utils.emit.apply(this,n),!0)},"webView:didFailLoadWithError:forFrame:":function(e,t){this.utils.emit("did-fail-load",t)},"webView:didFinishLoadForFrame:":function(){0==this.state.wasReady&&(this.utils.emitBrowserEvent("ready-to-show"),this.state.setObject_forKey(1,"wasReady")),this.utils.emit("did-finish-load"),this.utils.emit("did-frame-finish-load"),this.utils.emit("dom-ready")},"webView:didReceiveServerRedirectForProvisionalLoadForFrame:":function(){this.utils.emit("did-get-redirect-request")},"webView:didReceiveTitle:forFrame:":function(e,t){var n=String(t),i=!0;this.utils.emitBrowserEvent("page-title-updated",{get defaultPrevented(){return!i},preventDefault:function(){i=!1}},n),i&&n&&this.utils.setTitle(n)},"webView:didStartProvisionalLoadForFrame:":function(){this.utils.emit("did-start-loading")},"webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:":function(e,t){this.utils.emit("will-navigate",{},String(t.absoluteString))}}));var l=o.new();l.utils=NSDictionary.dictionaryWithDictionary({setTitle:e.setTitle.bind(e),emitBrowserEvent:e.emit.bind(e),emit:e.webContents.emit.bind(e.webContents),parseWebArguments:a}),l.state=NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),n.setFrameLoadDelegate(l);var c=i.new();c.utils=NSDictionary.dictionaryWithDictionary({emit:e.emit.bind(e)}),t.setDelegate(c)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=function(e,t,n){const o=r("objc_msgSendSuper",[{type:"^"+i},{type:":"},...t],n);return function(...t){const n=(i=this,r=this.superclass(),function e(t){if("object"!=typeof t||0==Object.keys(t).length)return t;const n=Object.keys(t)[0],i=t[n],o=MOStruct.structureWithName_memberNames_runtime(n,Object.keys(i),Mocha.sharedRuntime());return Object.keys(i).map(t=>{o[t]=e(i[t])}),o}({objc_super:{receiver:i,super_class:r}}));var i,r;const a=MOPointer.alloc().initWithValue_(n);return o(a,e,...t)}},t.CFunc=r;const i='{objc_super="receiver"@"super_class"#}';function o(e,t){const n=NSMutableDictionary.dictionary();n.o=e,Object.keys(t).map(e=>n.setValue_forKeyPath(t[e],"o."+e))}function r(e,t,n){function i(e){if(!e)return null;const t=MOBridgeSupportArgument.alloc().init();return o(t,{type64:e.type}),t}const r=MOBridgeSupportFunction.alloc().init();return o(r,{name:e,arguments:t.map(i),returnValue:i(n)}),r}t.object_getInstanceVariable=r("object_getInstanceVariable",[{type:"@"},{type:"*"},{type:"^@"}],{type:"^{objc_ivar=}"}),t.object_setInstanceVariable=r("object_setInstanceVariable",[{type:"@"},{type:"*"},{type:"@"}],{type:"^{objc_ivar=}"});!function(e,t){const n=MOBridgeSupportController.sharedController().valueForKey("symbols");if(!n)throw Error("Something has changed within bridge support so we can't add our definitions");if(null!==n[e])return;const i=MOBridgeSupportStruct.alloc().init();o(i,{name:e,type:t.type}),n[e]=i}("objc_super",{type:i})},function(e,t){e.exports=function(e){var t=null;try{t=JSON.parse(e[0])}catch(n){}return t&&t.constructor&&t.constructor===Array&&0!=t.length?t:null}},function(e,t){e.exports={JS_BRIDGE:"__skpm_sketchBridge"}},function(e,t,n){e.exports={showOpenDialog:n(19),showSaveDialog:n(20),showMessageBox:n(21)}},function(e,t,n){var i=n(2),o=n(5);e.exports=function(e,t,n){e&&"function"==typeof e.class||(n=t,t=e,e=void 0),t||(t={});var r,a=NSOpenPanel.openPanel();if(t.title&&(a.title=t.title),t.defaultPath&&a.setDirectoryURL(o.getURL(t.defaultPath)),t.buttonLabel&&(a.prompt=t.buttonLabel),t.filters&&t.filters.length){var s=[];t.filters.forEach(function(e){e.extensions.forEach(function(e){s.push(e)})}),a.allowedFileTypes=s}function l(){for(var e=[],t=a.URLs(),n=0;n1&&l[l.length-1]&&s.setNameFieldStringValue(l[l.length-1])}else s.setNameFieldStringValue(t.defaultPath);if(t.buttonLabel&&(s.prompt=t.buttonLabel),t.filters&&t.filters.length){var c=[];t.filters.forEach(function(e){e.extensions.forEach(function(e){c.push(e)})}),s.allowedFileTypes=c}if(t.message&&(s.message=t.message),t.nameFieldLabel&&(s.nameFieldLabel=t.nameFieldLabel),t.showsTagField&&(s.showsTagField=t.showsTagField),!e)return(r=s.runModal())==NSOKButton?(a=String(s.URL().path()),n?void n(a):a):void 0;var u=NSButton.class();function d(e,t){if(t&&t.subviews&&t.subviews())for(var n=t.subviews(),i=0;ic&&(d=(f=c)*u);var h=a+(l-d)/2,p=s+(c-f)/2;return new o.Rectangle(h,p,d,f)}),h=function(e,t,n){var i=t.url,o=t.name;d.log("fn: replaceWithSVG");var r=NSURL.alloc().initWithString(i),a=MSSVGImporter.svgImporter();a.prepareToImportFromURL(r);var s=a.importAsLayer();if(s.name=o,e){var l=s.frame(),c=f(l.width(),l.height(),e,n);l.setWidth(c.width),l.setHeight(c.height),l.setX(c.x),l.setY(c.y);var u=e.parentGroup();if(u)u.addLayer(s);else{var h=n.api().selectedDocument.selectedPage._object,p=h.currentArtboard();p?p.addLayer(s):h.addLayer(s)}}else{var m=n.api().selectedDocument.selectedPage._object,S=s.frame(),g=n.api().selectedDocument._object.contentDrawView().visibleContentRect();S.setX(g.origin.x+(g.size.width-S.width())/2),S.setY(g.origin.y+(g.size.height-S.height())/2),m.addLayer(s)}};function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=function(e){var t=NSDocumentController.sharedDocumentController().currentDocument();if(MSApplicationMetadata.metadata().appVersion>41.2)var n=t.selectedLayers().layers();else n=t.selectedLayers();return function(e){for(var t=1;tl/c?u=(f=c)*h:f=(u=l)/h;var p=a+(l-u)/2,m=s+(c-f)/2;return new o.Rectangle(p,m,u,f)},w=function e(t,i,o,r){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(d.log("fn: fillLayer"),t instanceof MSSymbolInstance){if(r){var s=g(i).url,l=y(s),c=t.overrides();null==c&&(c={});var u=NSMutableDictionary.dictionaryWithDictionary(c);u.setObject_forKey(NSMutableDictionary.dictionaryWithDictionary(c.objectForKey(0)),0),u.setObject_forKey(l,r.objectID()),t.overrides=u}}else if(t instanceof MSLayerGroup)t.layers().forEach(function(t){e(t,i,o)});else{var f=g(i).url;a?(d.log("Masking Layer "+f),function(e,t,n){d.log("fn: maskLayerWithImage");var i=n.api().selectedDocument.selectedPage._object,o=e.parentArtboard(),r=o||i,a=e.parentGroup();a&&(r=a);var s=y(t),l=MSBitmapLayer.new();l.setImage(s),l.frame().size=l.NSImage().size(),l.setConstrainProportions(0);var c=l.frame(),u=b(c.width(),c.height(),e,n);l.frame().setWidth(u.width),l.frame().setHeight(u.height),l.frame().setX(u.x),l.frame().setY(u.y);var f=MSLayerGroup.new();f.setName(e.name()),e.removeFromParent(),e.setHasClippingMask(1),e.style().addStylePartOfType(0),e.style().fills().firstObject().setFillType(0),f.addLayer(e),f.addLayer(l),r.addLayer(f),f.resizeToFitChildrenWithOption(1),f.setConstrainProportions(!0)}(t,f,o)):(d.log("Filling Layer "+f),function(e,t,i){d.log("fn: fillLayerWithImage");var o=y(t),r=e.style().fills();if(0===r.count()){var a=n(0).Style;n(0).fromNative(e).style.fills=[{color:"#c0ffee",fill:a.FillType.Color}]}var s=r.firstObject();s.setFillType(4),s.setImage(o),s.setPatternFillType(1)}(t,f))}},N=function(e,t){var n=t.force,i=t.mask,o=void 0!==i&&i,r=t.replace,a=void 0!==r&&r,s=t.context;d.log("fn: insertOrFillImage");var l=m().selection,c=l.count();if(d.log("Selected Layers "+c),c>0){var u;if(c>1){if(function(e){d.log("fn: hasDifferentSymbols");var t=[];return e.forEach(function(e){if(e instanceof MSSymbolInstance){var n=e.symbolMaster().objectID();-1===t.indexOf(n)&&t.push(n)}}),t.length>1}(l))return void s.document.showMessage("Sorry! You can't fill data in different type of layers.","Please select you have only one type of Symbol/Shape!");var f=function(e){d.log("fn: getFirstSymbolMaster");for(var t=0;t0},o.eventNames=function(){var e=this._getEvents();return Object.keys(e)},o.getMaxListeners=function(){return this._maxListeners},o.listenerCount=function(e){return this._getListeners(e).length},o.listeners=function(e){return this._getListeners(e).map(function(e){return e.listener})},o.on=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.push(i?t:{listener:t,once:!1}),this},o.once=function(e,t){return this.on(e,{listener:t,once:!0})},o.prependListener=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.unshift(i?t:{listener:t,once:!1}),this},o.prependOnceListener=function(e,t){return this.prependListener(e,{listener:t,once:!0})},o.removeAllListeners=function(e){var t=this._getEvents();return"string"==typeof e?delete t[e]:delete this._events,this},o.removeListener=function(e,t){var n=this._getListeners(e),i=function(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}(n,t);return-1!==i&&(n.splice(i,1),this.emit("removeListener",e,t)),this},o.setMaxListeners=function(e){return this._maxListeners=e,this},o.rawListeners=function(e){return this._getListeners(e).slice()},e.exports=n},function(e,t,n){var i=n(3),o=n(5),r=n(6),a=n(7),s=n(8),l=n(9);function u(e){var t=(e=e||{}).identifier||NSUUID.UUID().UUIDString(),n=NSThread.mainThread().threadDictionary(),c=u.fromId(t);if(c)return c;var d,f=new i;f.id=t;try{d=coscript.createFiber()}catch(C){coscript.shouldKeepAround=!0}var h=e.width||800,S=e.height||600,m=NSScreen.screens().firstObject().frame(),p=NSMakeRect(void 0!==e.x?e.x:Math.round((NSWidth(m)-h)/2),void 0!==e.y?e.y:Math.round((NSHeight(m)-S)/2),h,S);e.titleBarStyle&&"default"!==e.titleBarStyle&&(e.frame=!1);var w="textured"!==e.windowType,v=NSTitledWindowMask;!1!==e.minimizable&&(v|=NSMiniaturizableWindowMask),!1!==e.closable&&(v|=NSClosableWindowMask),!1!==e.resizable&&(v|=NSResizableWindowMask),w&&!e.transparent&&!1!==e.frame||(v|=NSTexturedBackgroundWindowMask);var g=NSPanel.alloc().initWithContentRect_styleMask_backing_defer(p,v,NSBackingStoreBuffered,!0),b=WebView.alloc().initWithFrame(NSMakeRect(0,0,e.width||800,e.height||600));if(b.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),o(f,g,b),r(f,g,b),l(f,g,b),"desktop"===e.windowType&&(g.setLevel(kCGDesktopWindowLevel-1),g.setCollectionBehavior(NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorIgnoresCycle)),void 0===e.minWidth&&void 0===e.minHeight||f.setMinimumSize(e.minWidth||0,e.minHeight||0),void 0===e.maxWidth&&void 0===e.maxHeight||f.setMaximumSize(e.maxWidth||1e4,e.maxHeight||1e4),e.transparent||!1===e.frame){g.titlebarAppearsTransparent=!0,g.titleVisibility=NSWindowTitleHidden,g.setOpaque(0),g.isMovableByWindowBackground=!0;var y=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");y.setShowsBaselineSeparator(!1),g.setToolbar(y)}if("hiddenInset"===e.titleBarStyle){var N=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");N.setShowsBaselineSeparator(!1),g.setToolbar(N)}!1!==e.frame&&e.useContentSize||f.setSize(h,S),e.center&&f.center(),e.alwaysOnTop&&f.setAlwaysOnTop(!0),e.fullscreen&&f.setFullScreen(!0),f.setFullScreenable(!!e.fullscreenable);const M=e.title||("undefined"!=typeof __command&&__command.pluginBundle()?__command.pluginBundle().name():void 0);M&&f.setTitle(M);var _=e.backgroundColor;e.transparent&&(_=NSColor.clearColor()),!_&&!1===e.frame&&e.vibrancy&&(_=NSColor.clearColor()),f._setBackgroundColor(_||NSColor.windowBackgroundColor()),!1===e.hasShadow&&f.setHasShadow(!1),void 0!==e.opacity&&f.setOpacity(e.opacity),e.webPreferences;var W=g.contentView();return!1!==e.frame?(b.setFrame(W.bounds()),W.addSubview(b)):(W.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),a(W,W.superview()),b.setFrame(W.bounds()),W.addSubview(b),g.standardWindowButton(NSWindowFullScreenButton)&&g.standardWindowButton(NSWindowFullScreenButton).setHidden(!0),e.titleBarStyle&&"default"!==e.titleBarStyle||(g.standardWindowButton(NSWindowZoomButton).setHidden(!0),g.standardWindowButton(NSWindowMiniaturizeButton).setHidden(!0),g.standardWindowButton(NSWindowCloseButton).setHidden(!0),g.standardWindowButton(NSWindowZoomButton).setEnabled(!1))),e.vibrancy&&f.setVibrancy(e.vibrancy),f.setMaximizable(!1!==e.maximizable),e.acceptsFirstMouse&&f.on("focus",function(e){e.type()===NSEventTypeLeftMouseDown&&f.webContents.executeJavaScript(s(b,e))}),!1!==e.show&&f.show(),f.on("closed",function(){f._destroyed=!0,n.removeObjectForKey(t),d?d.cleanup():coscript.shouldKeepAround=!1}),n[t]=g,d&&d.onCleanup(function(){f._destroyed||f.destroy()}),f}u.fromId=function(e){var t=NSThread.mainThread().threadDictionary();if(t[e])return u.fromPanel(t[e],e)},u.fromPanel=function(e,t){var n=new i;if(n.id=t,!e||!e.contentView)throw new Error("needs to pass an NSPanel");var a=e.contentView().subviews()[0];if(!a)throw new Error("The NSPanel needs to have a webview");return o(n,e,a),r(n,e,a),n},e.exports=u},function(e,t){var n=["NSColor","NSCachedWhiteColor","NSColorSpaceColor","NSDynamicSystemColor","NSCachedColorSpaceColor"];e.exports=function(e,t,i){function o(n){e.isVisible()||(n?(NSApplication.sharedApplication().activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)):t.orderBack(null))}e._panel=t,e._webview=i,e._destroyed=!1,e.destroy=function(){return t.close()},e.close=function(){e.isClosable()&&t.performClose(null)},e.focus=o.bind(this,!0),e.blur=o.bind(this,!1),e.isFocused=function(){return t.isKeyWindow()},e.isDestroyed=function(){return e._destroyed},e.show=function(){return NSApp.activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)},e.showInactive=function(){return t.orderFrontRegardless()},e.hide=function(){return t.orderOut(null)},e.isVisible=function(){return t.isVisible()},e.isModal=function(){return!1},e.maximize=function(){e.isMaximized()||t.zoom(null)},e.unmaximize=function(){e.isMaximized()&&t.zoom(null)},e.isMaximized=function(){if(0!=(t.styleMask()&NSResizableWindowMask))return t.isZoomed();var e=NSScreen.mainScreen().visibleFrame(),n=t.frame();return e.origin.x==n.origin.x&&e.origin.y==n.origin.y&&e.size.width==n.size.width&&e.size.height==n.size.height},e.minimize=function(){return t.miniaturize(null)},e.restore=function(){return t.deminiaturize(null)},e.isMinimized=function(){return t.isMiniaturized()},e.setFullScreen=function(n){n!==e.isFullscreen()&&t.toggleFullScreen(null)},e.isFullscreen=function(){return t.styleMask()&NSFullScreenWindowMask},e.setAspectRatio=function(e){e>0?t.setAspectRatio(NSMakeSize(e,1)):t.setResizeIncrements(NSMakeSize(1,1))},e.setBounds=function(n,i){if(!e.isFullscreen()){var o=n.size,r=NSMakeRect(n.origin.x,0,o.width,o.height),a=NSScreen.screens().firstObject();r.origin.y=NSHeight(a.frame())-o.height-n.origin.y,t.setFrame_display_animate(r,!0,i)}},e.getBounds=function(){return t.frame()},e.setContentBounds=function(){},e.getContentBounds=function(){},e.setSize=function(t,n,i){var o=e.getBounds();return o.size.height=n,o.size.width=t,e.setBounds(o,i)},e.getSize=function(){var t=e.getBounds();return[t.size.width,t.size.height]},e.setContentSize=function(t,n,i){var o=e.getContentBounds();return o.size.height=n,o.size.width=t,e.setContentBounds(o,i)},e.getContentSize=function(){var t=e.getContentBounds();return[t.size.width,t.size.height]},e.setMinimumSize=function(e,n){const i={width:e,height:n};t.setContentMinSize(i)},e.getMinimumSize=function(){const e=t.contentMinSize();return[e.width,e.height]},e.setMaximumSize=function(e,n){const i={width:e,height:n};t.setContentMaxSize(i)},e.getMaximumSize=function(){const e=t.contentMaxSize();return[e.width,e.height]},e.setResizable=function(t){return e._setStyleMask(t,NSResizableWindowMask)},e.isResizable=function(){return t.styleMask()&NSResizableWindowMask},e.setMovable=function(e){return t.setMovable(e)},e.isMovable=function(){return t.isMovable()},e.setMinimizable=function(t){return e._setStyleMask(t,NSMiniaturizableWindowMask)},e.isMinimizable=function(){return t.styleMask()&NSMiniaturizableWindowMask},e.setMaximizable=function(e){t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).setEnabled(e)},e.isMaximizable=function(){return t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).isEnabled()},e.setFullScreenable=function(t){e._setCollectionBehavior(t,NSWindowCollectionBehaviorFullScreenPrimary),e._setCollectionBehavior(!t,NSWindowCollectionBehaviorFullScreenAuxiliary)},e.isFullScreenable=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorFullScreenPrimary},e.setClosable=function(t){e._setStyleMask(t,NSClosableWindowMask)},e.isClosable=function(){return t.styleMask()&NSClosableWindowMask},e.setAlwaysOnTop=function(e,n,i){var o=NSNormalWindowLevel,r=CGWindowLevelForKey(kCGMaximumWindowLevelKey),a=CGWindowLevelForKey(kCGMinimumWindowLevelKey);e&&(o="normal"===n?NSNormalWindowLevel:"torn-off-menu"===n?NSTornOffMenuWindowLevel:"modal-panel"===n?NSModalPanelWindowLevel:"main-menu"===n?NSMainMenuWindowLevel:"status"===n?NSStatusWindowLevel:"pop-up-menu"===n?NSPopUpMenuWindowLevel:"screen-saver"===n?NSScreenSaverWindowLevel:"dock"===n?NSDockWindowLevel:NSFloatingWindowLevel);var s=o+(i||0);if(!(s>=a&&s<=r))throw new Error("relativeLevel must be between "+a+" and "+r);t.setLevel(s)},e.isAlwaysOnTop=function(){return t.level()!==NSNormalWindowLevel},e.moveTop=function(){return t.orderFrontRegardless()},e.center=function(){t.center()},e.setPosition=function(t,n,i){var o=e.getBounds(),r=NSScreen.screens().firstObject().frame();return o.origin.x=t,o.origin.y=Math.round(NSHeight(r)-n),e.setBounds(o,i)},e.getPosition=function(){var t=e.getBounds(),n=NSScreen.screens().firstObject().frame();return[t.origin.x,Math.round(NSHeight(n)-t.origin.y)]},e.setTitle=function(e){t.setTitle(e)},e.getTitle=function(){return String(t.title())};var r=0;e.flashFrame=function(e){e?r=NSApp.requestUserAttention(NSInformationalRequest):(NSApp.cancelUserAttentionRequest(r),r=0)},e.getNativeWindowHandle=function(){return t},e.getNativeWebViewHandle=function(){return i},e.loadURL=function(e){/^(?!http|localhost|www|file).*\.html?$/.test(e)&&"undefined"!=typeof __command&&__command.pluginBundle()&&(e=__command.pluginBundle().urlForResourceNamed(e).path()),i.setMainFrameURL(e)},e.reload=function(){i.reload()},e.setHasShadow=function(e){return t.setHasShadow(e)},e.hasShadow=function(){return t.hasShadow()},e.setOpacity=function(e){return t.setAlphaValue(e)},e.getOpacity=function(){return t.alphaValue()},e.setVisibleOnAllWorkspaces=function(t){return e._setCollectionBehavior(t,NSWindowCollectionBehaviorCanJoinAllSpaces)},e.isVisibleOnAllWorkspaces=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorCanJoinAllSpaces},e.setIgnoreMouseEvents=function(e){return t.setIgnoresMouseEvents(e)},e.setContentProtection=function(e){t.setSharingType(e?NSWindowSharingNone:NSWindowSharingReadOnly)},e.setAutoHideCursor=function(e){t.setDisableAutoHideCursor(e)},e.setVibrancy=function(n){var i=e._vibrantView;if(!n){if(null==i)return;return i.removeFromSuperview(),void t.setVibrantView(null)}if(null==i){var o=t.contentView();i=NSVisualEffectView.alloc().initWithFrame(o.bounds()),e._vibrantView=i,i.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),i.setBlendingMode(NSVisualEffectBlendingModeBehindWindow),i.setState(NSVisualEffectStateActive),i.setFrame(o.bounds()),o.addSubview_positioned_relativeTo(i,NSWindowBelow,null)}var r=NSVisualEffectMaterialLight;"appearance-based"===n?r=NSVisualEffectMaterialAppearanceBased:"light"===n?r=NSVisualEffectMaterialLight:"dark"===n?r=NSVisualEffectMaterialDark:"titlebar"===n?r=NSVisualEffectMaterialTitlebar:"selection"===n?r=NSVisualEffectMaterialSelection:"menu"===n?r=NSVisualEffectMaterialMenu:"popover"===n?r=NSVisualEffectMaterialPopover:"sidebar"===n?r=NSVisualEffectMaterialSidebar:"medium-light"===n?r=NSVisualEffectMaterialMediumLight:"ultra-dark"===n&&(r=NSVisualEffectMaterialUltraDark),i.setMaterial(r)},e._setBackgroundColor=function(e){var o=function(e){if(!e||"#"!==e[0]){if(e&&e.class&&-1!==n.indexOf(String(e.class())))return e;throw new Error("Incorrect color formating. It should be an hex color: #RRGGBBAA")}var t,i=e.substr(1);if(3===i.length?i+="F":6===i.length&&(i+="FF"),4===i.length)for(var o=0;o<4;o+=1)t+=i[o],t+=i[o];else{if(8!==i.length)return NSColor.whiteColor();t=i}var r=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),l=parseInt(t.slice(6,8),16);return NSColor.colorWithSRGBRed_green_blue_alpha(r,a,s,l)}(e);i.setDrawsBackground(!1),t.backgroundColor=o},e._invalidate=function(){t.flushWindow(),t.contentView().setNeedsDisplay(!0)},e._setStyleMask=function(n,i){var o=e.isMaximizable();n?t.setStyleMask(t.styleMask()|i):t.setStyleMask(t.styleMask()&~i),e.setMaximizable(o)},e._setCollectionBehavior=function(n,i){var o=e.isMaximizable();n?t.setCollectionBehavior(t.collectionBehavior()|i):t.setCollectionBehavior(t.collectionBehavior()&~i),e.setMaximizable(o)},e._showWindowButton=function(e){var n=t.standardWindowButton(e);n.superview().addSubview_positioned_relative(n,NSWindowAbove,null)}}},function(e,t,n){var i=n(3);e.exports=function(e,t,n){var o=new i;o.loadURL=e.loadURL,o.getURL=n.mainFrameURL,o.getTitle=n.mainFrameTitle,o.isDestroyed=function(){},o.isLoading=function(){return n.loading()},o.stop=n.stopLoading,o.reload=n.reload,o.canGoBack=n.canGoBack,o.canGoForward=n.canGoForward,o.goBack=n.goBack,o.goForward=n.goForward,o.executeJavaScript=function(e){return n.stringByEvaluatingJavaScriptFromString(e)},o.undo=function(){n.undoManager().undo()},o.redo=function(){n.undoManager().redo()},o.cut=n.cut,o.copy=n.copy,o.paste=n.paste,o.pasteAndMatchStyle=n.pasteAsRichText,o.delete=n.delete,o.replace=n.replaceSelectionWithText,o.getNativeWebview=function(){return n},e.webContents=o}},function(e,t){function n(e,t,n,i){n.addConstraint(NSLayoutConstraint.constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(t,e,NSLayoutRelationEqual,n,e,1,i))}e.exports=function(e,t,i){i=i||[],e.setTranslatesAutoresizingMaskIntoConstraints(!1),n(NSLayoutAttributeLeft,e,t,i[0]||0),n(NSLayoutAttributeTop,e,t,i[1]||0),n(NSLayoutAttributeRight,e,t,i[2]||0),n(NSLayoutAttributeBottom,e,t,i[3]||0)}},function(e,t){e.exports=function(e,t){var n=e.convertPoint_fromView(t.locationInWindow(),null);return"var el = document.elementFromPoint("+n.x+", "+(e.frame().size.height-n.y)+'); if (el && ["text", "textarea", "date", "datetime-local", "email", "number", "month", "password", "search", "tel", "time", "url", "week" ].indexOf(el.type) >= 0 && el.focus) {el.focus();} else if (el) {el.dispatchEvent(new Event("click", {bubbles: true}))}'}},function(e,t,n){var i,o,r=n(10).default,a=n(12),s=n(13);e.exports=function(e,t,n){i||(i=r({classname:"WindowDelegateClass",utils:null,"windowDidResize:":function(){this.utils.emit("resize")},"windowDidMiniaturize:":function(){this.utils.emit("minimize")},"windowDidDeminiaturize:":function(){this.utils.emit("restore")},"windowDidEnterFullScreen:":function(){this.utils.emit("enter-full-screen")},"windowDidExitFullScreen:":function(){this.utils.emit("leave-full-screen")},"windowDidMove:":function(){this.utils.emit("move"),this.utils.emit("moved")},"windowShouldClose:":function(){var e=!0;return this.utils.emit("close",{get defaultPrevented(){return!e},preventDefault:function(){e=!1}}),e},"windowWillClose:":function(){this.utils.emit("closed")},"windowDidBecomeKey:":function(){this.utils.emit("focus",t.currentEvent())},"windowDidResignKey:":function(){this.utils.emit("blur")}})),o||(o=r({classname:"FrameLoadDelegateClass",state:NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),utils:null,"webView:didChangeLocationWithinPageForFrame:":function(e){this.utils.emit("did-navigate-in-page",[{},String(e.stringByEvaluatingJavaScriptFromString("window.location.href"))])},"webView:didCreateJavaScriptContext:forFrame:":function(e){e.windowScriptObject().setValue_forKey_(this,s.JS_BRIDGE)},"invokeUndefinedMethodFromWebScript:withArguments:":function(e,t){if("callNative"!==String(e))return!1;var n=this.utils.parseWebArguments(t);return!!n&&(this.utils.emit.apply(this,n),!0)},"webView:didFailLoadWithError:forFrame:":function(e,t){this.utils.emit("did-fail-load",t)},"webView:didFinishLoadForFrame:":function(){0==this.state.wasReady&&(this.utils.emitBrowserEvent("ready-to-show"),this.state.setObject_forKey(1,"wasReady")),this.utils.emit("did-finish-load"),this.utils.emit("did-frame-finish-load"),this.utils.emit("dom-ready")},"webView:didReceiveServerRedirectForProvisionalLoadForFrame:":function(){this.utils.emit("did-get-redirect-request")},"webView:didReceiveTitle:forFrame:":function(e,t){var n=String(t),i=!0;this.utils.emitBrowserEvent("page-title-updated",{get defaultPrevented(){return!i},preventDefault:function(){i=!1}},n),i&&n&&this.utils.setTitle(n)},"webView:didStartProvisionalLoadForFrame:":function(){this.utils.emit("did-start-loading")},"webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:":function(e,t){this.utils.emit("will-navigate",{},String(t.absoluteString))}}));var l=o.new();l.utils=NSDictionary.dictionaryWithDictionary({setTitle:e.setTitle.bind(e),emitBrowserEvent:e.emit.bind(e),emit:e.webContents.emit.bind(e.webContents),parseWebArguments:a}),l.state=NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),n.setFrameLoadDelegate(l);var u=i.new();u.utils=NSDictionary.dictionaryWithDictionary({emit:e.emit.bind(e)}),t.setDelegate(u)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=void 0,t.default=function(e){const t=e.superclass||NSObject,n=(e.className||e.classname||"ObjCClass")+NSUUID.UUID().UUIDString(),r=new Set(["className","classname","superclass"]);var a=MOClassDescription.allocateDescriptionForClassWithName_superclass_(n,t);const s=[];for(var l in e){const t=e[l];if("function"==typeof t&&"init"!==l){var u=NSSelectorFromString(l);a.addInstanceMethodWithSelector_function_(u,t)}else r.has(l)||(s.push(l),a.addInstanceVariableWithName_typeEncoding(l,"@"))}return a.addInstanceMethodWithSelector_function_(NSSelectorFromString("init"),function(){const t=o.call(this);return s.map(n=>{Object.defineProperty(t,n,{get:()=>(function(e,t){const n=MOPointer.new();return(0,i.object_getInstanceVariable)(e,t,n),n.value().retain().autorelease()})(t,n),set(e){(0,i.object_setInstanceVariable)(t,n,e)}}),t[n]=e[n]}),"function"==typeof e.init&&e.init.call(this),t}),a.registerClass()};var i=n(11);t.SuperCall=i.SuperCall;const o=(0,i.SuperCall)(NSStringFromSelector("init"),[],{type:"@"})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=function(e,t,n){const o=r("objc_msgSendSuper",[{type:"^"+i},{type:":"},...t],n);return function(...t){const n=(i=this,r=this.superclass(),function e(t){if("object"!=typeof t||0==Object.keys(t).length)return t;const n=Object.keys(t)[0],i=t[n],o=MOStruct.structureWithName_memberNames_runtime(n,Object.keys(i),Mocha.sharedRuntime());return Object.keys(i).map(t=>{o[t]=e(i[t])}),o}({objc_super:{receiver:i,super_class:r}}));var i,r;const a=MOPointer.alloc().initWithValue_(n);return o(a,e,...t)}},t.CFunc=r;const i='{objc_super="receiver"@"super_class"#}';function o(e,t){const n=NSMutableDictionary.dictionary();n.o=e,Object.keys(t).map(e=>n.setValue_forKeyPath(t[e],"o."+e))}function r(e,t,n){function i(e){if(!e)return null;const t=MOBridgeSupportArgument.alloc().init();return o(t,{type64:e.type}),t}const r=MOBridgeSupportFunction.alloc().init();return o(r,{name:e,arguments:t.map(i),returnValue:i(n)}),r}t.object_getInstanceVariable=r("object_getInstanceVariable",[{type:"@"},{type:"*"},{type:"^@"}],{type:"^{objc_ivar=}"}),t.object_setInstanceVariable=r("object_setInstanceVariable",[{type:"@"},{type:"*"},{type:"@"}],{type:"^{objc_ivar=}"});!function(e,t){const n=MOBridgeSupportController.sharedController().valueForKey("symbols");if(!n)throw Error("Something has changed within bridge support so we can't add our definitions");if(null!==n[e])return;const i=MOBridgeSupportStruct.alloc().init();o(i,{name:e,type:t.type}),n[e]=i}("objc_super",{type:i})},function(e,t){e.exports=function(e){var t=null;try{t=JSON.parse(e[0])}catch(n){}return t&&t.constructor&&t.constructor===Array&&0!=t.length?t:null}},function(e,t){e.exports={JS_BRIDGE:"__skpm_sketchBridge"}},function(e,t){e.exports=require("sketch")},function(e,t,n){"use strict";n.r(t);var i=n(1),o=n(2);function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t0},o.eventNames=function(){var e=this._getEvents();return Object.keys(e)},o.getMaxListeners=function(){return this._maxListeners},o.listenerCount=function(e){return this._getListeners(e).length},o.listeners=function(e){return this._getListeners(e).map(function(e){return e.listener})},o.on=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.push(i?t:{listener:t,once:!1}),this},o.once=function(e,t){return this.on(e,{listener:t,once:!0})},o.prependListener=function(e,t){if(!r(t))throw new Error("listener must be a function");var n=this._getListeners(e),i="object"==typeof t;return this.emit("newListener",e,i?t.listener:t),n.unshift(i?t:{listener:t,once:!1}),this},o.prependOnceListener=function(e,t){return this.prependListener(e,{listener:t,once:!0})},o.removeAllListeners=function(e){var t=this._getEvents();return"string"==typeof e?delete t[e]:delete this._events,this},o.removeListener=function(e,t){var n=this._getListeners(e),i=function(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}(n,t);return-1!==i&&(n.splice(i,1),this.emit("removeListener",e,t)),this},o.setMaxListeners=function(e){return this._maxListeners=e,this},o.rawListeners=function(e){return this._getListeners(e).slice()},e.exports=n},function(e,t,n){var i=n(3),o=n(5),r=n(6),a=n(7),s=n(8),l=n(9);function u(e){var t=(e=e||{}).identifier||NSUUID.UUID().UUIDString(),n=NSThread.mainThread().threadDictionary(),c=u.fromId(t);if(c)return c;var d,f=new i;f.id=t;try{d=coscript.createFiber()}catch(C){coscript.shouldKeepAround=!0}var h=e.width||800,S=e.height||600,m=NSScreen.screens().firstObject().frame(),p=NSMakeRect(void 0!==e.x?e.x:Math.round((NSWidth(m)-h)/2),void 0!==e.y?e.y:Math.round((NSHeight(m)-S)/2),h,S);e.titleBarStyle&&"default"!==e.titleBarStyle&&(e.frame=!1);var w="textured"!==e.windowType,v=NSTitledWindowMask;!1!==e.minimizable&&(v|=NSMiniaturizableWindowMask),!1!==e.closable&&(v|=NSClosableWindowMask),!1!==e.resizable&&(v|=NSResizableWindowMask),w&&!e.transparent&&!1!==e.frame||(v|=NSTexturedBackgroundWindowMask);var g=NSPanel.alloc().initWithContentRect_styleMask_backing_defer(p,v,NSBackingStoreBuffered,!0),b=WebView.alloc().initWithFrame(NSMakeRect(0,0,e.width||800,e.height||600));if(b.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),o(f,g,b),r(f,g,b),l(f,g,b),"desktop"===e.windowType&&(g.setLevel(kCGDesktopWindowLevel-1),g.setCollectionBehavior(NSWindowCollectionBehaviorCanJoinAllSpaces|NSWindowCollectionBehaviorStationary|NSWindowCollectionBehaviorIgnoresCycle)),void 0===e.minWidth&&void 0===e.minHeight||f.setMinimumSize(e.minWidth||0,e.minHeight||0),void 0===e.maxWidth&&void 0===e.maxHeight||f.setMaximumSize(e.maxWidth||1e4,e.maxHeight||1e4),e.transparent||!1===e.frame){g.titlebarAppearsTransparent=!0,g.titleVisibility=NSWindowTitleHidden,g.setOpaque(0),g.isMovableByWindowBackground=!0;var y=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");y.setShowsBaselineSeparator(!1),g.setToolbar(y)}if("hiddenInset"===e.titleBarStyle){var N=NSToolbar.alloc().initWithIdentifier("titlebarStylingToolbar");N.setShowsBaselineSeparator(!1),g.setToolbar(N)}!1!==e.frame&&e.useContentSize||f.setSize(h,S),e.center&&f.center(),e.alwaysOnTop&&f.setAlwaysOnTop(!0),e.fullscreen&&f.setFullScreen(!0),f.setFullScreenable(!!e.fullscreenable);const M=e.title||("undefined"!=typeof __command&&__command.pluginBundle()?__command.pluginBundle().name():void 0);M&&f.setTitle(M);var _=e.backgroundColor;e.transparent&&(_=NSColor.clearColor()),!_&&!1===e.frame&&e.vibrancy&&(_=NSColor.clearColor()),f._setBackgroundColor(_||NSColor.windowBackgroundColor()),!1===e.hasShadow&&f.setHasShadow(!1),void 0!==e.opacity&&f.setOpacity(e.opacity),e.webPreferences;var W=g.contentView();return!1!==e.frame?(b.setFrame(W.bounds()),W.addSubview(b)):(W.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),a(W,W.superview()),b.setFrame(W.bounds()),W.addSubview(b),g.standardWindowButton(NSWindowFullScreenButton)&&g.standardWindowButton(NSWindowFullScreenButton).setHidden(!0),e.titleBarStyle&&"default"!==e.titleBarStyle||(g.standardWindowButton(NSWindowZoomButton).setHidden(!0),g.standardWindowButton(NSWindowMiniaturizeButton).setHidden(!0),g.standardWindowButton(NSWindowCloseButton).setHidden(!0),g.standardWindowButton(NSWindowZoomButton).setEnabled(!1))),e.vibrancy&&f.setVibrancy(e.vibrancy),f.setMaximizable(!1!==e.maximizable),e.acceptsFirstMouse&&f.on("focus",function(e){e.type()===NSEventTypeLeftMouseDown&&f.webContents.executeJavaScript(s(b,e))}),!1!==e.show&&f.show(),f.on("closed",function(){f._destroyed=!0,n.removeObjectForKey(t),d?d.cleanup():coscript.shouldKeepAround=!1}),n[t]=g,d&&d.onCleanup(function(){f._destroyed||f.destroy()}),f}u.fromId=function(e){var t=NSThread.mainThread().threadDictionary();if(t[e])return u.fromPanel(t[e],e)},u.fromPanel=function(e,t){var n=new i;if(n.id=t,!e||!e.contentView)throw new Error("needs to pass an NSPanel");var a=e.contentView().subviews()[0];if(!a)throw new Error("The NSPanel needs to have a webview");return o(n,e,a),r(n,e,a),n},e.exports=u},function(e,t){var n=["NSColor","NSCachedWhiteColor","NSColorSpaceColor","NSDynamicSystemColor","NSCachedColorSpaceColor"];e.exports=function(e,t,i){function o(n){e.isVisible()||(n?(NSApplication.sharedApplication().activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)):t.orderBack(null))}e._panel=t,e._webview=i,e._destroyed=!1,e.destroy=function(){return t.close()},e.close=function(){e.isClosable()&&t.performClose(null)},e.focus=o.bind(this,!0),e.blur=o.bind(this,!1),e.isFocused=function(){return t.isKeyWindow()},e.isDestroyed=function(){return e._destroyed},e.show=function(){return NSApp.activateIgnoringOtherApps(!0),t.makeKeyAndOrderFront(null)},e.showInactive=function(){return t.orderFrontRegardless()},e.hide=function(){return t.orderOut(null)},e.isVisible=function(){return t.isVisible()},e.isModal=function(){return!1},e.maximize=function(){e.isMaximized()||t.zoom(null)},e.unmaximize=function(){e.isMaximized()&&t.zoom(null)},e.isMaximized=function(){if(0!=(t.styleMask()&NSResizableWindowMask))return t.isZoomed();var e=NSScreen.mainScreen().visibleFrame(),n=t.frame();return e.origin.x==n.origin.x&&e.origin.y==n.origin.y&&e.size.width==n.size.width&&e.size.height==n.size.height},e.minimize=function(){return t.miniaturize(null)},e.restore=function(){return t.deminiaturize(null)},e.isMinimized=function(){return t.isMiniaturized()},e.setFullScreen=function(n){n!==e.isFullscreen()&&t.toggleFullScreen(null)},e.isFullscreen=function(){return t.styleMask()&NSFullScreenWindowMask},e.setAspectRatio=function(e){e>0?t.setAspectRatio(NSMakeSize(e,1)):t.setResizeIncrements(NSMakeSize(1,1))},e.setBounds=function(n,i){if(!e.isFullscreen()){var o=n.size,r=NSMakeRect(n.origin.x,0,o.width,o.height),a=NSScreen.screens().firstObject();r.origin.y=NSHeight(a.frame())-o.height-n.origin.y,t.setFrame_display_animate(r,!0,i)}},e.getBounds=function(){return t.frame()},e.setContentBounds=function(){},e.getContentBounds=function(){},e.setSize=function(t,n,i){var o=e.getBounds();return o.size.height=n,o.size.width=t,e.setBounds(o,i)},e.getSize=function(){var t=e.getBounds();return[t.size.width,t.size.height]},e.setContentSize=function(t,n,i){var o=e.getContentBounds();return o.size.height=n,o.size.width=t,e.setContentBounds(o,i)},e.getContentSize=function(){var t=e.getContentBounds();return[t.size.width,t.size.height]},e.setMinimumSize=function(e,n){const i={width:e,height:n};t.setContentMinSize(i)},e.getMinimumSize=function(){const e=t.contentMinSize();return[e.width,e.height]},e.setMaximumSize=function(e,n){const i={width:e,height:n};t.setContentMaxSize(i)},e.getMaximumSize=function(){const e=t.contentMaxSize();return[e.width,e.height]},e.setResizable=function(t){return e._setStyleMask(t,NSResizableWindowMask)},e.isResizable=function(){return t.styleMask()&NSResizableWindowMask},e.setMovable=function(e){return t.setMovable(e)},e.isMovable=function(){return t.isMovable()},e.setMinimizable=function(t){return e._setStyleMask(t,NSMiniaturizableWindowMask)},e.isMinimizable=function(){return t.styleMask()&NSMiniaturizableWindowMask},e.setMaximizable=function(e){t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).setEnabled(e)},e.isMaximizable=function(){return t.standardWindowButton(NSWindowZoomButton)&&t.standardWindowButton(NSWindowZoomButton).isEnabled()},e.setFullScreenable=function(t){e._setCollectionBehavior(t,NSWindowCollectionBehaviorFullScreenPrimary),e._setCollectionBehavior(!t,NSWindowCollectionBehaviorFullScreenAuxiliary)},e.isFullScreenable=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorFullScreenPrimary},e.setClosable=function(t){e._setStyleMask(t,NSClosableWindowMask)},e.isClosable=function(){return t.styleMask()&NSClosableWindowMask},e.setAlwaysOnTop=function(e,n,i){var o=NSNormalWindowLevel,r=CGWindowLevelForKey(kCGMaximumWindowLevelKey),a=CGWindowLevelForKey(kCGMinimumWindowLevelKey);e&&(o="normal"===n?NSNormalWindowLevel:"torn-off-menu"===n?NSTornOffMenuWindowLevel:"modal-panel"===n?NSModalPanelWindowLevel:"main-menu"===n?NSMainMenuWindowLevel:"status"===n?NSStatusWindowLevel:"pop-up-menu"===n?NSPopUpMenuWindowLevel:"screen-saver"===n?NSScreenSaverWindowLevel:"dock"===n?NSDockWindowLevel:NSFloatingWindowLevel);var s=o+(i||0);if(!(s>=a&&s<=r))throw new Error("relativeLevel must be between "+a+" and "+r);t.setLevel(s)},e.isAlwaysOnTop=function(){return t.level()!==NSNormalWindowLevel},e.moveTop=function(){return t.orderFrontRegardless()},e.center=function(){t.center()},e.setPosition=function(t,n,i){var o=e.getBounds(),r=NSScreen.screens().firstObject().frame();return o.origin.x=t,o.origin.y=Math.round(NSHeight(r)-n),e.setBounds(o,i)},e.getPosition=function(){var t=e.getBounds(),n=NSScreen.screens().firstObject().frame();return[t.origin.x,Math.round(NSHeight(n)-t.origin.y)]},e.setTitle=function(e){t.setTitle(e)},e.getTitle=function(){return String(t.title())};var r=0;e.flashFrame=function(e){e?r=NSApp.requestUserAttention(NSInformationalRequest):(NSApp.cancelUserAttentionRequest(r),r=0)},e.getNativeWindowHandle=function(){return t},e.getNativeWebViewHandle=function(){return i},e.loadURL=function(e){/^(?!http|localhost|www|file).*\.html?$/.test(e)&&"undefined"!=typeof __command&&__command.pluginBundle()&&(e=__command.pluginBundle().urlForResourceNamed(e).path()),i.setMainFrameURL(e)},e.reload=function(){i.reload()},e.setHasShadow=function(e){return t.setHasShadow(e)},e.hasShadow=function(){return t.hasShadow()},e.setOpacity=function(e){return t.setAlphaValue(e)},e.getOpacity=function(){return t.alphaValue()},e.setVisibleOnAllWorkspaces=function(t){return e._setCollectionBehavior(t,NSWindowCollectionBehaviorCanJoinAllSpaces)},e.isVisibleOnAllWorkspaces=function(){return t.collectionBehavior()&NSWindowCollectionBehaviorCanJoinAllSpaces},e.setIgnoreMouseEvents=function(e){return t.setIgnoresMouseEvents(e)},e.setContentProtection=function(e){t.setSharingType(e?NSWindowSharingNone:NSWindowSharingReadOnly)},e.setAutoHideCursor=function(e){t.setDisableAutoHideCursor(e)},e.setVibrancy=function(n){var i=e._vibrantView;if(!n){if(null==i)return;return i.removeFromSuperview(),void t.setVibrantView(null)}if(null==i){var o=t.contentView();i=NSVisualEffectView.alloc().initWithFrame(o.bounds()),e._vibrantView=i,i.setAutoresizingMask(NSViewWidthSizable|NSViewHeightSizable),i.setBlendingMode(NSVisualEffectBlendingModeBehindWindow),i.setState(NSVisualEffectStateActive),i.setFrame(o.bounds()),o.addSubview_positioned_relativeTo(i,NSWindowBelow,null)}var r=NSVisualEffectMaterialLight;"appearance-based"===n?r=NSVisualEffectMaterialAppearanceBased:"light"===n?r=NSVisualEffectMaterialLight:"dark"===n?r=NSVisualEffectMaterialDark:"titlebar"===n?r=NSVisualEffectMaterialTitlebar:"selection"===n?r=NSVisualEffectMaterialSelection:"menu"===n?r=NSVisualEffectMaterialMenu:"popover"===n?r=NSVisualEffectMaterialPopover:"sidebar"===n?r=NSVisualEffectMaterialSidebar:"medium-light"===n?r=NSVisualEffectMaterialMediumLight:"ultra-dark"===n&&(r=NSVisualEffectMaterialUltraDark),i.setMaterial(r)},e._setBackgroundColor=function(e){var o=function(e){if(!e||"#"!==e[0]){if(e&&e.class&&-1!==n.indexOf(String(e.class())))return e;throw new Error("Incorrect color formating. It should be an hex color: #RRGGBBAA")}var t,i=e.substr(1);if(3===i.length?i+="F":6===i.length&&(i+="FF"),4===i.length)for(var o=0;o<4;o+=1)t+=i[o],t+=i[o];else{if(8!==i.length)return NSColor.whiteColor();t=i}var r=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16),l=parseInt(t.slice(6,8),16);return NSColor.colorWithSRGBRed_green_blue_alpha(r,a,s,l)}(e);i.setDrawsBackground(!1),t.backgroundColor=o},e._invalidate=function(){t.flushWindow(),t.contentView().setNeedsDisplay(!0)},e._setStyleMask=function(n,i){var o=e.isMaximizable();n?t.setStyleMask(t.styleMask()|i):t.setStyleMask(t.styleMask()&~i),e.setMaximizable(o)},e._setCollectionBehavior=function(n,i){var o=e.isMaximizable();n?t.setCollectionBehavior(t.collectionBehavior()|i):t.setCollectionBehavior(t.collectionBehavior()&~i),e.setMaximizable(o)},e._showWindowButton=function(e){var n=t.standardWindowButton(e);n.superview().addSubview_positioned_relative(n,NSWindowAbove,null)}}},function(e,t,n){var i=n(3);e.exports=function(e,t,n){var o=new i;o.loadURL=e.loadURL,o.getURL=n.mainFrameURL,o.getTitle=n.mainFrameTitle,o.isDestroyed=function(){},o.isLoading=function(){return n.loading()},o.stop=n.stopLoading,o.reload=n.reload,o.canGoBack=n.canGoBack,o.canGoForward=n.canGoForward,o.goBack=n.goBack,o.goForward=n.goForward,o.executeJavaScript=function(e){return n.stringByEvaluatingJavaScriptFromString(e)},o.undo=function(){n.undoManager().undo()},o.redo=function(){n.undoManager().redo()},o.cut=n.cut,o.copy=n.copy,o.paste=n.paste,o.pasteAndMatchStyle=n.pasteAsRichText,o.delete=n.delete,o.replace=n.replaceSelectionWithText,o.getNativeWebview=function(){return n},e.webContents=o}},function(e,t){function n(e,t,n,i){n.addConstraint(NSLayoutConstraint.constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(t,e,NSLayoutRelationEqual,n,e,1,i))}e.exports=function(e,t,i){i=i||[],e.setTranslatesAutoresizingMaskIntoConstraints(!1),n(NSLayoutAttributeLeft,e,t,i[0]||0),n(NSLayoutAttributeTop,e,t,i[1]||0),n(NSLayoutAttributeRight,e,t,i[2]||0),n(NSLayoutAttributeBottom,e,t,i[3]||0)}},function(e,t){e.exports=function(e,t){var n=e.convertPoint_fromView(t.locationInWindow(),null);return"var el = document.elementFromPoint("+n.x+", "+(e.frame().size.height-n.y)+'); if (el && ["text", "textarea", "date", "datetime-local", "email", "number", "month", "password", "search", "tel", "time", "url", "week" ].indexOf(el.type) >= 0 && el.focus) {el.focus();} else if (el) {el.dispatchEvent(new Event("click", {bubbles: true}))}'}},function(e,t,n){var i,o,r=n(10).default,a=n(12),s=n(13);e.exports=function(e,t,n){i||(i=r({classname:"WindowDelegateClass",utils:null,"windowDidResize:":function(){this.utils.emit("resize")},"windowDidMiniaturize:":function(){this.utils.emit("minimize")},"windowDidDeminiaturize:":function(){this.utils.emit("restore")},"windowDidEnterFullScreen:":function(){this.utils.emit("enter-full-screen")},"windowDidExitFullScreen:":function(){this.utils.emit("leave-full-screen")},"windowDidMove:":function(){this.utils.emit("move"),this.utils.emit("moved")},"windowShouldClose:":function(){var e=!0;return this.utils.emit("close",{get defaultPrevented(){return!e},preventDefault:function(){e=!1}}),e},"windowWillClose:":function(){this.utils.emit("closed")},"windowDidBecomeKey:":function(){this.utils.emit("focus",t.currentEvent())},"windowDidResignKey:":function(){this.utils.emit("blur")}})),o||(o=r({classname:"FrameLoadDelegateClass",state:NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),utils:null,"webView:didChangeLocationWithinPageForFrame:":function(e){this.utils.emit("did-navigate-in-page",[{},String(e.stringByEvaluatingJavaScriptFromString("window.location.href"))])},"webView:didCreateJavaScriptContext:forFrame:":function(e){e.windowScriptObject().setValue_forKey_(this,s.JS_BRIDGE)},"invokeUndefinedMethodFromWebScript:withArguments:":function(e,t){if("callNative"!==String(e))return!1;var n=this.utils.parseWebArguments(t);return!!n&&(this.utils.emit.apply(this,n),!0)},"webView:didFailLoadWithError:forFrame:":function(e,t){this.utils.emit("did-fail-load",t)},"webView:didFinishLoadForFrame:":function(){0==this.state.wasReady&&(this.utils.emitBrowserEvent("ready-to-show"),this.state.setObject_forKey(1,"wasReady")),this.utils.emit("did-finish-load"),this.utils.emit("did-frame-finish-load"),this.utils.emit("dom-ready")},"webView:didReceiveServerRedirectForProvisionalLoadForFrame:":function(){this.utils.emit("did-get-redirect-request")},"webView:didReceiveTitle:forFrame:":function(e,t){var n=String(t),i=!0;this.utils.emitBrowserEvent("page-title-updated",{get defaultPrevented(){return!i},preventDefault:function(){i=!1}},n),i&&n&&this.utils.setTitle(n)},"webView:didStartProvisionalLoadForFrame:":function(){this.utils.emit("did-start-loading")},"webView:willPerformClientRedirectToURL:delay:fireDate:forFrame:":function(e,t){this.utils.emit("will-navigate",{},String(t.absoluteString))}}));var l=o.new();l.utils=NSDictionary.dictionaryWithDictionary({setTitle:e.setTitle.bind(e),emitBrowserEvent:e.emit.bind(e),emit:e.webContents.emit.bind(e.webContents),parseWebArguments:a}),l.state=NSMutableDictionary.dictionaryWithDictionary({lastQueryId:null,wasReady:0}),n.setFrameLoadDelegate(l);var u=i.new();u.utils=NSDictionary.dictionaryWithDictionary({emit:e.emit.bind(e)}),t.setDelegate(u)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=void 0,t.default=function(e){const t=e.superclass||NSObject,n=(e.className||e.classname||"ObjCClass")+NSUUID.UUID().UUIDString(),r=new Set(["className","classname","superclass"]);var a=MOClassDescription.allocateDescriptionForClassWithName_superclass_(n,t);const s=[];for(var l in e){const t=e[l];if("function"==typeof t&&"init"!==l){var u=NSSelectorFromString(l);a.addInstanceMethodWithSelector_function_(u,t)}else r.has(l)||(s.push(l),a.addInstanceVariableWithName_typeEncoding(l,"@"))}return a.addInstanceMethodWithSelector_function_(NSSelectorFromString("init"),function(){const t=o.call(this);return s.map(n=>{Object.defineProperty(t,n,{get:()=>(function(e,t){const n=MOPointer.new();return(0,i.object_getInstanceVariable)(e,t,n),n.value().retain().autorelease()})(t,n),set(e){(0,i.object_setInstanceVariable)(t,n,e)}}),t[n]=e[n]}),"function"==typeof e.init&&e.init.call(this),t}),a.registerClass()};var i=n(11);t.SuperCall=i.SuperCall;const o=(0,i.SuperCall)(NSStringFromSelector("init"),[],{type:"@"})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SuperCall=function(e,t,n){const o=r("objc_msgSendSuper",[{type:"^"+i},{type:":"},...t],n);return function(...t){const n=(i=this,r=this.superclass(),function e(t){if("object"!=typeof t||0==Object.keys(t).length)return t;const n=Object.keys(t)[0],i=t[n],o=MOStruct.structureWithName_memberNames_runtime(n,Object.keys(i),Mocha.sharedRuntime());return Object.keys(i).map(t=>{o[t]=e(i[t])}),o}({objc_super:{receiver:i,super_class:r}}));var i,r;const a=MOPointer.alloc().initWithValue_(n);return o(a,e,...t)}},t.CFunc=r;const i='{objc_super="receiver"@"super_class"#}';function o(e,t){const n=NSMutableDictionary.dictionary();n.o=e,Object.keys(t).map(e=>n.setValue_forKeyPath(t[e],"o."+e))}function r(e,t,n){function i(e){if(!e)return null;const t=MOBridgeSupportArgument.alloc().init();return o(t,{type64:e.type}),t}const r=MOBridgeSupportFunction.alloc().init();return o(r,{name:e,arguments:t.map(i),returnValue:i(n)}),r}t.object_getInstanceVariable=r("object_getInstanceVariable",[{type:"@"},{type:"*"},{type:"^@"}],{type:"^{objc_ivar=}"}),t.object_setInstanceVariable=r("object_setInstanceVariable",[{type:"@"},{type:"*"},{type:"@"}],{type:"^{objc_ivar=}"});!function(e,t){const n=MOBridgeSupportController.sharedController().valueForKey("symbols");if(!n)throw Error("Something has changed within bridge support so we can't add our definitions");if(null!==n[e])return;const i=MOBridgeSupportStruct.alloc().init();o(i,{name:e,type:t.type}),n[e]=i}("objc_super",{type:i})},function(e,t){e.exports=function(e){var t=null;try{t=JSON.parse(e[0])}catch(n){}return t&&t.constructor&&t.constructor===Array&&0!=t.length?t:null}},function(e,t){e.exports={JS_BRIDGE:"__skpm_sketchBridge"}},function(e,t){e.exports=require("sketch")},function(e,t,n){"use strict";n.r(t);var i=n(1),o=n(2);function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t