var globalThis=this,global=this;function __skpm_run(key,context){globalThis.context=context;try{var exports=function(e){var t={};function o(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(r,i,function(t){return e[t]}.bind(null,i));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=3)}([function(e,t){e.exports=require("sketch")},function(module,__webpack_exports__,__webpack_require__){"use strict";function MochaJSDelegate(selectorHandlerDict,superclass){var uniqueClassName="MochaJSDelegate_DynamicClass_"+NSUUID.UUID().UUIDString(),delegateClassDesc=MOClassDescription.allocateDescriptionForClassWithName_superclass_(uniqueClassName,superclass||NSObject);delegateClassDesc.registerClass();var handlers={};if(this.setHandlerForSelector=function(selectorString,func){var handlerHasBeenSet=selectorString in handlers,selector=NSSelectorFromString(selectorString);if(handlers[selectorString]=func,!handlerHasBeenSet){for(var args=[],regex=/:/g;regex.exec(selectorString);)args.push("arg"+args.length);var dynamicFunction=eval("(function ("+args.join(", ")+") { return handlers[selectorString].apply(this, arguments); })");delegateClassDesc.addInstanceMethodWithSelector_function_(selector,dynamicFunction)}},this.removeHandlerForSelector=function(e){delete handlers[e]},this.getHandlerForSelector=function(e){return handlers[e]},this.getAllHandlers=function(){return handlers},this.getClass=function(){return NSClassFromString(uniqueClassName)},this.getClassInstance=function(){return NSClassFromString(uniqueClassName).new()},"object"==typeof selectorHandlerDict)for(var selectorString in selectorHandlerDict)this.setHandlerForSelector(selectorString,selectorHandlerDict[selectorString])}__webpack_exports__.a=MochaJSDelegate},function(e,t){e.exports=require("sketch/dom")},function(e,t,o){"use strict";o.r(t),o.d(t,"importIcons",(function(){return Fe})),o.d(t,"updateIconsOnSelectedArtboards",(function(){return ke})),o.d(t,"organizeIcons",(function(){return Ne})),o.d(t,"addMaskOnSelectedArtboards",(function(){return _e})),o.d(t,"removeMaskOnSelectedArtboards",(function(){return Ie})),o.d(t,"setSettings",(function(){return Oe}));var r=o(1),i={log:function(e){log(e)},debug:function(e){log("DEBUG: "+e)},info:function(e){log("INFO: "+e)},warn:function(e){log("WARN: "+e)},error:function(e){log("ERROR: "+e)}},n={registerSettings:function(e,t){a.forEach(o=>{NSUserDefaults.standardUserDefaults().setObject_forKey(t[o.name],o.name),e.command.setValue_forKey_onDocument(t[o.name],o.name,e.document.documentData())})},getSettings:function(e,t){const o={};return a.forEach(e=>{o[e.name]={value:NSUserDefaults.standardUserDefaults().objectForKey(e.name),default:e.default,placeholder:e.placeholder},s(o[e.name])?o[e.name].data=String(o[e.name].value):o[e.name].data=String(o[e.name][t])}),o},resetSettings:function(e){a.forEach(t=>{e.command.setValue_forKey_onDocument(null,t.name,e.document.documentData())})},hasValue:s};const a=[{name:"presets",default:"",placeholder:"24-4, 48-8..."},{name:"convertStroke",default:"0",placeholder:"0"},{name:"iconsByLine",default:"10",placeholder:"10"},{name:"marginBetweenRootObject",default:"100%",placeholder:"100%"},{name:"prefixRootObject",default:"",placeholder:"icons/$size/..."}];function s(e){return!(!e.value||"null"===String(e.value)||0===String(e.value).length)}var l=o(0),c={clearSelection:function(e){l.Document.getSelectedDocument().selectedLayers.clear()},getIconNameByNSUrl:function(e){return e.lastPathComponent().split(".")[0]},createLabel:function(e,t,o,r,i,n){const a=NSTextField.alloc().initWithFrame_(NSMakeRect(t,o,r,i));n&&a.setTextColor(NSColor.colorWithCalibratedRed_green_blue_alpha(0,0,0,.6));return a.setEditable_(!1),a.setSelectable_(!1),a.setBezeled_(!1),a.setDrawsBackground_(!1),a.setFont(NSFont.systemFontOfSize(n?11:13)),a.setStringValue_(e),a},getSelectedArtboardsAndSymbols:function(e){let t=[];return e.selection.forEach((function(e){let o=String(e.class());"MSArtboardGroup"===o&&"MSSymbolMaster"===o||(e=e.parentRoot(),o=String(e.class())),-1!==t.indexOf(String(e.objectID()))||"MSArtboardGroup"!==o&&"MSSymbolMaster"!==o||t.push({object:e,type:o,id:e.objectID()})})),t=t.filter((e,t,o)=>t===o.findIndex(t=>t.id===e.id)),t},createWebview:function(e,t,o){const n=WebView.alloc().initWithFrame(NSMakeRect(0,0,220,300)),a=n.windowScriptObject(),s=new r.a({"webView:didFinishLoadForFrame:":function(e,t){i.log("loaded")},"webView:didChangeLocationWithinPageForFrame:":function(e,r){const i=a.evaluateWebScript("window.location.hash"),n=JSON.parse(decodeURIComponent(i).split("color=")[1]);n.r=parseInt(n.r)/255,n.g=parseInt(n.g)/255,n.b=parseInt(n.b)/255,n.a=parseFloat(n.a);const s=NSColor.colorWithRed_green_blue_alpha(n.r,n.g,n.b,n.a),l=MSImmutableColor.colorWithNSColor(s);t.setImage(h(s,{width:40,height:30})),o(l)}});return n.setDrawsBackground(!1),n.setMainFrameURL_(e.plugin.urlForResourceNamed("webview.html").path()),n.setFrameLoadDelegate_(s.getClassInstance()),n},createDivider:function(e){const t=NSView.alloc().initWithFrame(e);return t.setWantsLayer(1),t.layer().setBackgroundColor(CGColorCreateGenericRGB(.8,.8,.8,1)),t},runFramework:function(e){const t=Mocha.sharedRuntime(),o=e.scriptPath.stringByDeletingLastPathComponent();return!!t.valueForKey("SketchIconsFramework")||(t.loadFrameworkWithName_inDirectory("SketchIconsFramework",o)?(t.setValue_forKey_(!0,"SketchIconsFramework"),!0):(log("❌ loadFramework: `SketchIconsFramework` failed!: "+o+". Please define SketchIcons_FrameworkPath if you're trying to @import in a custom plugin"),!1))},getImageByColor:h,hasMask:function(e){return!!e.firstLayer().hasClippingMask()},hasSharedStyle:function(e){return!!e.firstLayer().sharedStyle()},layerToSvg:function(e){const t=SketchSVGExporter.alloc().init().exportLayers([e.immutableModelObject()]);return NSString.alloc().initWithData_encoding(t,NSUTF8StringEncoding)},svgHasStroke:function(e){let t=!1;return e.children().forEach(e=>{e.usedStyle().hasEnabledBorder()&&(t=!0)}),t},convertMSColorToString:function(e){return JSON.stringify({r:e.red(),g:e.green(),b:e.blue(),a:e.alpha()})},convertStringToMSColor:function(e){const t="object"!=typeof e?e:JSON.parse(e),o=NSColor.colorWithRed_green_blue_alpha(t.r,t.g,t.b,t.a);return MSImmutableColor.colorWithNSColor(o)},getBorderColor:function(e){let t;const o=e.children();for(let r=0;r<o.length;r++){let e=o[r].usedStyle();if(t=e.firstEnabledBorder(),t)break}return t},getRootObject:function(e){const t=[];return l.Document.getSelectedDocument().selectedPage.layers.forEach(e=>{let o=String(e.sketchObject.class());"MSArtboardGroup"!==o&&"MSSymbolMaster"!==o||t.push(e)}),t},getSizeBetweenIcon:function(e,t){const o=parseInt(t),r=t.replace(o,"");return r&&"%"===r?e+e*(o/100):e+o},buildPrefix:function(e,t){const o=n.getSettings(e,"default");return"null"!==o.prefixRootObject.data?o.prefixRootObject.data.replace("$size",t):""}};function h(e,t={width:14,height:14}){const o=CGSizeMake(t.width,t.height),r=NSImage.alloc().init();return r.size=o,r.lockFocus(),e.setFill(),NSBezierPath.fillRect(NSMakeRect(0,0,t.width,t.height)),r.unlockFocus(),r}const d=NSColor.colorWithCalibratedRed_green_blue_alpha(170/255,170/255,170/255,1);function u(e){this.modalParams={messageText:"Configure your color mask",informativeText:"Select your library and choose a color to apply as mask. Your layers will all be combined.",height:190,width:300,lineHeight:35},this.coeffCurrentHeight=0,this.isLibrarySource=!0,this.adjustHeight=0,this.colorSource="sharedStyle",g.call(this,"Continue"),w.call(this,e),v.call(this,e),P.call(this,e);const t={button:this.modal.runModal()};if(this.isLibrarySource){let e=this.colorsMenuParams.selectedItem();t.color=e?this.colorsMenuParams.representedObject():null;let o=this.colorLibsMenuParams.selectedItem();t.colorLib=o?this.colorLibsMenuParams.representedObject():null,t.colorSource=this.colorSource}else t.colorPicker=this.colorPickerColor;return t}function m(e){this.settingsValues=n.getSettings(e,"default"),this.modalParams={messageText:"Configure your import",informativeText:"Your icons will be arranged in artboards. Set size and padding of your artboards.",width:300,lineHeight:35};const t=n.hasValue(this.settingsValues.presets);this.modalParams.height=n.hasValue(this.settingsValues.presets)?330+30*this.settingsValues.presets.data.split(",").length:330,this.coeffCurrentHeight=0,this.isLibrarySource=!0,this.adjustHeight=0,this.colorSource="sharedStyle",g.call(this,"Continue"),t?S.call(this):f.call(this),this.view.addSubview(c.createDivider(NSMakeRect(0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-10,this.modalParams.width,1))),this.adjustHeight=5,p.call(this),this.view.addSubview(c.createDivider(NSMakeRect(0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-15,this.modalParams.width,1))),this.adjustHeight=8,y.call(this),w.call(this),v.call(this,e),M.call(this,!1),F.call(this,!1),k.call(this,!1),P.call(this,e),C.call(this);const o={button:this.modal.runModal(),convertSymbol:this.symbolParams.state(),withColor:!!this.checkboxMaskParams.state()};if(t?(o.presets=[],this.presets.forEach(e=>{e.presetCheckBox.state()&&o.presets.push({artboardSize:parseInt(e.sizeBox.stringValue()),iconPadding:parseInt(e.paddingBox.stringValue())})})):(o.artboardSize=parseInt(this.artboardSize.stringValue()),o.iconPadding=parseInt(this.artboardPadding.stringValue())),o.withColor&&this.isLibrarySource){let e=this.colorsMenuParams.selectedItem();o.color=e?this.colorsMenuParams.representedObject():null;let t=this.colorLibsMenuParams.selectedItem();o.colorLib=t?this.colorLibsMenuParams.representedObject():null,o.color||(o.withColor=!1),o.colorSource=this.colorSource}else o.withColor&&(o.colorPicker=this.colorPickerColor||MSColor.blackColor());return o}function g(e="Continue"){this.modal=COSAlertWindow.new(),this.view=NSView.alloc().initWithFrame(NSMakeRect(0,0,this.modalParams.width,this.modalParams.height)),this.modal.addAccessoryView(this.view),this.modal.setMessageText(this.modalParams.messageText),this.modal.addButtonWithTitle(e),this.modal.setInformativeText(this.modalParams.informativeText),this.modal.addButtonWithTitle("Cancel")}function S(){const e=this.settingsValues.presets.data.split(",").map(e=>{const t=e.split("-");return{artboardSize:t[0],padding:t[1]?t[1]:0}});this.presets=[];const t=c.createLabel("Presets",0,this.modalParams.height-this.modalParams.lineHeight,150,20);this.view.addSubview(t);const o=c.createLabel("Size",180,this.modalParams.height-this.modalParams.lineHeight,100,20);this.view.addSubview(o);const r=c.createLabel("Padding",240,this.modalParams.height-this.modalParams.lineHeight,100,20);this.view.addSubview(r),this.coeffCurrentHeight++,e.forEach(e=>{this.coeffCurrentHeight++,b.call(this,e,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight,this)})}function f(){this.coeffCurrentHeight++;const e=c.createLabel("Artboard Size",0,this.modalParams.height-this.modalParams.lineHeight,150,20);this.view.addSubview(e);const t=NSTextField.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight,50,20));t.setStringValue(24),this.view.addSubview(t);const o=c.createLabel("px",205,this.modalParams.height-this.modalParams.lineHeight,50,20);this.view.addSubview(o),this.coeffCurrentHeight++;const r=c.createLabel("Artboard Padding",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight,150,20);this.view.addSubview(r);const i=NSTextField.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight,50,20));i.setStringValue(0),this.view.addSubview(i);const n=c.createLabel("px",205,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight,50,20);this.view.addSubview(n),this.artboardPadding=i,this.artboardSize=t,this.artboardSize.setNextKeyView(this.artboardPadding)}function b(e,t){const o=NSButton.alloc().initWithFrame(NSMakeRect(150,t,30,20));o.setState(!0),o.setButtonType(NSSwitchButton),o.setFont(NSFont.systemFontOfSize_(13)),o.setTitle(""),this.view.addSubview(o);const r=NSTextField.alloc().initWithFrame(NSMakeRect(180,t,50,20));r.setStringValue(e.artboardSize),this.view.addSubview(r);const i=NSTextField.alloc().initWithFrame(NSMakeRect(240,t,50,20));i.setStringValue(e.padding),this.view.addSubview(i);const n={sizeBox:r,paddingBox:i,presetCheckBox:o};!function(e){e.presetCheckBox.setCOSJSTargetFunction(()=>{e.sizeBox.setEnabled(e.presetCheckBox.state()),e.paddingBox.setEnabled(e.presetCheckBox.state())})}(n),this.presets.push(n)}function p(){this.coeffCurrentHeight++;const e=c.createLabel("Symbols",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,150,20);this.view.addSubview(e);const t=NSButton.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,200,20));t.setButtonType(NSSwitchButton),t.setState(!0),t.setFont(NSFont.systemFontOfSize_(13)),t.setTitle("Convert to symbol"),this.view.addSubview(t),this.symbolParams=t}function y(){this.coeffCurrentHeight++;const e=c.createLabel("Color",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,150,20);this.view.addSubview(e);const t=NSButton.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,200,20));t.setButtonType(NSSwitchButton),t.setState(!1),t.setFont(NSFont.systemFontOfSize_(13)),t.setTitle("Apply color"),this.view.addSubview(t),this.checkboxMaskParams=t}function w(e){this.coeffCurrentHeight++,this.coeffCurrentHeight++,this.coeffCurrentHeight++;const t=c.createLabel("Color Source",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight+40,150,20);this.view.addSubview(t);const o=NSButtonCell.alloc().init();o.setButtonType(NSRadioButton);const r=NSMatrix.alloc().initWithFrame_mode_prototype_numberOfRows_numberOfColumns(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,300,90),NSRadioModeMatrix,o,3,1);r.setCellSize(CGSizeMake(300,25));const i=r.cells();i[0].setTitle("From Shared Style"),i[0].setFont(NSFont.systemFontOfSize_(13)),i[1].setTitle("From Symbol"),i[1].setFont(NSFont.systemFontOfSize_(13)),i[2].setTitle("From Color picker"),i[2].setFont(NSFont.systemFontOfSize_(13)),this.view.addSubview(r),L.call(this,i,e),this.radioParams=r,this.radioButtonLabel=t}function v(e){this.coeffCurrentHeight++;const t=c.createLabel("Document Source",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,150,25);this.view.addSubview(t);const o=NSPopUpButton.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,130,30));this.coeffCurrentHeight++;const r=c.createLabel("Select Color",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,150,25);this.view.addSubview(r);const i=NSPopUpButton.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,130,30));this.view.addSubview(o),this.view.addSubview(i),this.colorLibsMenuParams=o,this.colorsMenuParams=i,this.colorLibsMenuParamsLabel=t,this.colorsMenuParamsLabel=r,o.menu=H.initLibsSelectList.call(this,e,AppController.sharedInstance().librariesController().availableLibraries(),i)}function P(e){const t=c.createLabel("Color picker",0,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight+20,150,20),o=NSView.alloc().initWithFrame(NSMakeRect(150,this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight-this.adjustHeight,130,60));o.setWantsLayer(!0),o.layer().setBackgroundColor(CGColorCreateGenericRGB(1,1,1,1)),o.layer().setBorderColor(CGColorCreateGenericRGB(186/255,186/255,186/255,1)),o.layer().borderWidth=1;const r=c.createLabel("#000000",60,20,100,20);o.addSubview(r);const i=NSButton.alloc().initWithFrame(NSMakeRect(5,15,50,30));i.setButtonType(NSMomentaryChangeButton),i.setImage(c.getImageByColor(NSColor.colorWithRed_green_blue_alpha(0,0,0,1),{width:40,height:30})),i.setBordered(!1);const n=AMOMain.alloc().init();i.setCOSJSTargetFunction(()=>{n.openPopover_onView_withWebview(i,this.view,c.createWebview(e,i,e=>{this.colorPickerColor=e,r.setStringValue_("#"+e.immutableModelObject().hexValue())}))}),o.addSubview(i),this.pickerView=o,this.colorPickerLabel=t}function C(){this.checkboxMaskParams.setCOSJSTargetFunction(e=>{e.state()?(k.call(this,!0),M.call(this,!0),this.colorsMenuParams.numberOfItems()>0&&F.call(this,!0)):(k.call(this,!1),M.call(this,!1),F.call(this,!1),_.call(this),O.call(this),this.radioParams.cells()[0].state=!0,this.radioParams.cells()[1].state=!1,this.radioParams.cells()[2].state=!1)})}function L(e,t){function o(e){const t=String(e.selectedCells()[0].title());"From Symbol"===t?(_.call(this),O.call(this),this.isLibrarySource=!0,this.colorSource="symbol",H.updateColorMenu.call(this,this.colorLibsMenuParams.selectedItem(),this.colorsMenuParams)):"From Color picker"===t?(N.call(this),I.call(this),this.isLibrarySource=!1):(this.isLibrarySource=!0,_.call(this),O.call(this),this.colorSource="sharedStyle",H.updateColorMenu.call(this,this.colorLibsMenuParams.selectedItem(),this.colorsMenuParams))}this.context=t,e[0].setCOSJSTargetFunction(o.bind(this)),e[1].setCOSJSTargetFunction(o.bind(this)),e[2].setCOSJSTargetFunction(o.bind(this))}function M(e){const t=e?NSColor.controlTextColor():d;this.colorLibsMenuParamsLabel.setTextColor(t),this.colorLibsMenuParams.setEnabled(e)}function F(e){this.colorsMenuParamsLabel.setTextColor(x(e)),this.colorsMenuParams.setEnabled(e)}function k(e){this.radioParams.setEnabled(e),this.radioButtonLabel.setTextColor(x(e))}function N(){this.colorLibsMenuParams.removeFromSuperview(),this.colorsMenuParams.removeFromSuperview(),this.colorLibsMenuParamsLabel.removeFromSuperview(),this.colorsMenuParamsLabel.removeFromSuperview()}function _(){this.view.addSubview(this.colorLibsMenuParams),this.view.addSubview(this.colorsMenuParams),this.view.addSubview(this.colorLibsMenuParamsLabel),this.view.addSubview(this.colorsMenuParamsLabel)}function I(){this.view.addSubview(this.pickerView),this.view.addSubview(this.colorPickerLabel)}function O(){this.pickerView.removeFromSuperview(),this.colorPickerLabel.removeFromSuperview()}function x(e){return e?NSColor.controlTextColor():d}var H={getLibById:function(e){let t,o=AppController.sharedInstance().librariesController().availableLibraries();for(let r=0;r<o.length;r++)if(String(e)===String(o[r].libraryID())){t=o[r];break}return t},initLibsSelectList:function(e,t,o){function r(e){e.setCOSJSTargetFunction(e=>{R.call(this,e,o)})}const i=NSMenu.alloc().init(),n=NSMenuItem.alloc().init();return n.title="Current file",r.call(this,n),i.addItem(n),t.forEach(e=>{let t=NSMenuItem.alloc().init();t.title=e.name(),t.representedObject=e,i.addItem(t),r.call(this,t)}),R.call(this,n,o),i},getColorFromSymbol:z,getSymbolFromDocument:function(e,t){let o,r=e.localSymbols();for(let i=0;i<r.length;i++)if(String(r[i].symbolID())===String(t)){o=r[i];break}return o},loadLibrary:function(e){return e.loadSynchronously()},updateColorMenu:R};function j(e,t){return t.removeAllItems(),V((e=e.representedObject()).document())}function T(e,t){return t.removeAllItems(),A((e=e.representedObject()).document())}function R(e,t){let o=[];o=e.representedObject()?"symbol"===this.colorSource?j.call(this,e,t):T.call(this,e,t):"symbol"===this.colorSource?V.call(this,MSDocument.currentDocument().documentData()):A.call(this,MSDocument.currentDocument().documentData()),o.length>0?(B.call(this,t,o,this.colorSource),F.call(this,!0)):F.call(this,!1)}function B(e,t,o){const r=NSMenu.alloc().init();return r.cancelTracking(),t.forEach((function(e){try{let t,i=NSMenuItem.alloc().init();if(i.title="sharedStyle"===o?e.name():e.symbol?e.symbol.name():"","sharedStyle"===o){const o=e.style().hasEnabledFill()?e.style().fills()[0].color():e.style().borders()[0].color();t=NSColor.colorWithRed_green_blue_alpha(o.red(),o.green(),o.blue(),o.alpha())}else t=e.color?NSColor.colorWithRed_green_blue_alpha(e.color.red(),e.color.green(),e.color.blue(),e.color.alpha()):NSColor.colorWithRed_green_blue_alpha(e.red(),e.green(),e.blue(),e.alpha());i.representedObject="sharedStyle"===o?e:e.symbol||t,i.image=c.getImageByColor(t),r.addItem(i)}catch(t){console.log("cannot use this style >",e.name())}})),e.menu=r,e}function V(e){const t=[];return e.localSymbols().forEach((function(e){const o=z(e);o&&t.push(o)})),t}function A(e){const t=[];return e.layerStyles().sharedStyles().forEach(e=>{t.push(e)}),t}function z(e){const t=e.layers();let o;return 0===t.length&&e.backgroundColor()?o={color:e.backgroundColor(),symbol:e}:1===t.length&&1===t[0].children().length&&t[0].style().hasEnabledFill()&&(o={color:t[0].style().fills()[0].color(),symbol:e}),o}var D={applySharedStyle:function(e,t,o){const r=function(e,t,o){const r=AppController.sharedInstance().librariesController(),i=MSShareableObjectReference.referenceForShareableObject_inLibrary(t,o);return r.importShareableObjectReference_intoDocument(i,e.document.documentData())}(e,o.color,o.colorLib);t.children()[1].sharedStyle=r?r.localSharedStyle():o.color}};var W={switchToV4:function(e,t){const o=t.lastLayer(),r={color:null,colorLib:null,colorPicker:null};if("MSSymbolInstance"===String(o.class())){const e=o.symbolMaster(),t=e.foreignSymbol();r.color=e,t&&(r.color=String(t.originalMaster().symbolID()),r.colorLib=t)}else r.colorPicker=o.style().fills()[0].color();E.registerColor(e,t,r)}};var E={initAddMaskOnSelectedArtboards:function(e,t,o){const r=n.getSettings(e,"default");o.forEach(async o=>{try{c.svgHasStroke(o.object)&&"1"===r.convertStroke.data&&Z.convertStrokeToFill(o.object),await U(e,o.object,t)}catch(i){console.log(">>>>>>>>>>>",i)}}),c.clearSelection(e)},addColor:U,removeColor:G,getMaskPropertiesFromArtboard:function(e,t){let o=q(e,t);const r=t.firstLayer();o.colorLibraryId||o.colorSymbolId||o.colorString||!r||!r.hasClippingMask()||(W.switchToV4(e,t),o=q(e,t));!o.colorLibraryId&&o.colorSymbolId?o.colorSymbol=H.getSymbolFromDocument(e.document.documentData(),o.colorSymbolId):o.colorLibraryId&&(o.colorLibrary=H.getLibById(o.colorLibraryId),H.loadLibrary(o.colorLibrary),o.colorSymbol=H.getSymbolFromDocument(o.colorLibrary.document(),o.colorSymbolId));o.colorPicker=o.colorString?c.convertStringToMSColor(o.colorString):null;const i={colorLib:o.colorLibraryId?o.colorLibrary:null,color:o.colorSymbolId?o.colorSymbol:null,colorPicker:o.colorPicker};return i.colorLib||i.color||i.colorPicker?i:{}},registerColor:J};function U(e,t,o){if("MSBitMapLayer"!==String(t.firstLayer().class()))return G(e,t),"sharedStyle"===o.colorSource?(Z.cleanSvg(t),D.applySharedStyle(e,t,o)):c.svgHasStroke(t)?K(t,o):(Z.cleanSvg(t),function(e,t,o){let r;o.color?r=function(e,t,o){c.clearSelection(e);const r=AppController.sharedInstance().librariesController();let i;if(MSApplicationMetadata.metadata().appVersion>=50){const n=MSShareableObjectReference.referenceForShareableObject_inLibrary(t,o);i=r.importShareableObjectReference_intoDocument(n,e.document.documentData())}else i=r.importForeignSymbol_fromLibrary_intoDocument_(t,o,e.document.documentData());return(o?i.symbolMaster():t).newSymbolInstance()}(e,o.color,o.colorLib):o.colorPicker&&(r=function(e,t,o){const r=t.rect(),i=MSShapeGroup.shapeWithRect({origin:{x:0,y:0},size:{width:r.size.width,height:r.size.height}});return i.style().addStylePartOfType(0).color=o,i}(0,t,o.colorPicker));const i=t.rect();r.setHeightRespectingProportions(i.size.height),r.setWidthRespectingProportions(i.size.width),r.setName("🎨 color"),t.firstLayer().style().disableAllFills(),t.addLayers([r]);const n=t.firstLayer();n.hasClippingMask=!0,n.clippingMaskMode=0}(e,t,o)),J(e,t,o)}function G(e,t){c.hasMask(t)&&!c.svgHasStroke(t)&&function(e,t){if(e.command.setValue_forKey_onLayer(null,"colorLib",t),e.command.setValue_forKey_onLayer(null,"color",t),e.command.setValue_forKey_onLayer(null,"source",t),e.command.setValue_forKey_onLayer(null,"colorPicker",t),c.svgHasStroke(t))return K(t,{colorPicker:MSImmutableColor.blackColor()});const o=t.firstLayer();if(t.layers().count()>1&&o.hasClippingMask()){o.hasClippingMask=!1,o.clippingMaskMode=1;const e=t.firstLayer().style(),r=e.fills().count()>0?e.fills()[0].color():MSColor.blackColor();e.removeAllStyleFills(),e.addStylePartOfType(0).color=r,t.lastLayer().removeFromParent()}}(e,t),c.hasSharedStyle(t)&&function(e,t){const o=t.firstLayer().style(),r=o.fills().count()>0?o.fills()[0].color():MSColor.blackColor();o.removeAllStyleFills(),o.addStylePartOfType(0).color=r,t.firstLayer().sharedStyle=null}(0,t)}function K(e,t){const o=t.colorPicker?t.colorPicker:H.getColorFromSymbol(t.color).color;e.children().forEach(e=>{if(e.usedStyle().hasEnabledBorder()){e.usedStyle().enabledBorders().forEach(e=>e.color=o)}})}function J(e,t,o){if(o.color){const r=o.colorLib?o.colorLib.libraryID():null,i="sharedStyle"===o.colorSource?o.color.objectID():o.color.symbolID();e.command.setValue_forKey_onLayer(r,"colorLib",t),e.command.setValue_forKey_onLayer(i,"color",t),e.command.setValue_forKey_onLayer(o.colorSource,"source",t),e.command.setValue_forKey_onLayer(null,"colorPicker",t)}else o.colorPicker&&(e.command.setValue_forKey_onLayer(c.convertMSColorToString(o.colorPicker),"colorPicker",t),e.command.setValue_forKey_onLayer(null,"colorLib",t),e.command.setValue_forKey_onLayer(null,"source",t),e.command.setValue_forKey_onLayer(null,"color",t))}function q(e,t){return{colorLibraryId:e.command.valueForKey_onLayer("colorLib",t),colorSymbolId:e.command.valueForKey_onLayer("color",t),colorString:e.command.valueForKey_onLayer("colorPicker",t)}}var $=o(2);function Y(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function X(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(o),!0).forEach((function(t){Q(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):Y(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function Q(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var Z={initUpdateIconsSelectedArtboards:function(e,t,o){return t.forEach((t,r)=>{const i=X(X(X({},E.getMaskPropertiesFromArtboard(e,t.object)),se.getPaddingAndSize(e,t.object)),o),n=1===o.listIcon.length?o.listIcon[0]:o.listIcon[r];t.object.removeAllLayers(),i.withColor=!!(i.colorLib||i.colorPicker||i.color);const a=String(n.toString().split(".").pop()).toLowerCase();if("pdf"===a)te(e,t.object,i,n),i.withColor&&E.addColor(e,t.object,i);else if("png"===a||"jpg"===a||"jpeg"===a)oe(e,t.object,i,n);else{const o=String(NSString.alloc().initWithContentsOfURL(n));ee(e,t.object,i,String(o),!0),i.withColor&&E.addColor(e,t.object,i)}t.object.setName(c.getIconNameByNSUrl(n))}),c.clearSelection(e),t.length},addSVG:ee,addPDF:te,addBITMAP:oe,cleanSvg:function(e){ne(e),e.firstLayer().setName(e.name()),e.layers().length>1&&"MSLayerGroup"!==String(e.firstLayer().class)&&function(e,t){const o=t.layers().slice().filter(e=>"MSSymbolMaster"!==String(e.class()));e.document.currentPage().changeSelectionBySelectingLayers(o),e.document.actionsController().actionForID("MSUnionAction").doPerformAction(null)}(context,e)},convertStrokeToFill:ae,addSVGNew:function(e,t,o,r){r=NSString.stringWithString(r);const i=MSSVGImporter.svgImporter();i.prepareToImportFromData(r.dataUsingEncoding(NSUTF8StringEncoding));const n=i.importAsLayer();t.addLayers([n]);const a=n.frame(),s=a.width(),l=a.height();a.constrainProportions=!0,s>=l?n.setWidthRespectingProportions(o.artboardSize-2*o.iconPadding+.01):n.setHeightRespectingProportions(o.artboardSize-2*o.iconPadding+.01);a.setX((o.artboardSize-a.width())/2),a.setY((o.artboardSize-a.height())/2)}};function ee(e,t,o,r,i){let a;const s=n.getSettings(e,"default");a=function(e){let t,o,r=e.match(/viewBox="(.*?)"/gm);Array.isArray(r)&&(t=r[0].match(/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g),o={width:parseFloat(t[2]),height:parseFloat(t[3])});return o}(r=NSString.stringWithString(r)),i&&(r=function(e,t){const o=`<rect width="${t.width}" height="${t.height}" id="delete-me"/></svg>`;return NSString.stringWithString(e.replace("</svg>",o))}(r,a));const l=MSSVGImporter.svgImporter();l.prepareToImportFromData(r.dataUsingEncoding(NSUTF8StringEncoding));const h=l.importAsLayer();!function(e){const t=e.children(),o=NSPredicate.predicateWithFormat("(className == %@)","MSTextLayer"),r=t.filteredArrayUsingPredicate(o).objectEnumerator();let i;for(;i=r.nextObject();)i.removeFromParent()}(h),t.addLayer(h),c.svgHasStroke(t)&&"1"===s.convertStroke.data&&ae(t),i&&ie(t,o.iconPadding),i&&function(e){const t=e.children(),o=NSPredicate.predicateWithFormat("(name == %@)","delete-me"),r=t.filteredArrayUsingPredicate(o);if(!r.length)return e.firstLayer().lastLayer().removeFromParent();const i=r.objectEnumerator();let n;for(;n=i.nextObject();)n.removeFromParent()}(t),re(o.artboardSize,t.firstLayer())}function te(e,t,o,r){const i=MSPDFImporter.pdfImporter();i.prepareToImportFromURL(r);let n=i.importAsLayer();if("MSArtboardGroup"===String(n.class())){const e=MSLayerGroup.new();e.addLayers(n.layers()),e.resizeToFitChildrenWithOption(1),n=e}t.addLayer(n);const a=n.frame(),s=a.width(),l=a.height();a.constrainProportions=!0,s>=l?n.setWidthRespectingProportions(o.artboardSize-2*o.iconPadding+.01):n.setHeightRespectingProportions(o.artboardSize-2*o.iconPadding+.01),a.setX((o.artboardSize-a.width())/2),a.setY((o.artboardSize-a.height())/2)}function oe(e,t,o,r){if("MSBitmapLayer"===String(r.class()))MSLayerGroup.moveLayers_intoGroup([r],t);else{const e=new $.Image({image:r});t.addLayer(e.sketchObject)}ie(t,o.iconPadding),re(o.artboardSize,t.firstLayer()),t.firstLayer().setName(t.name())}function re(e,t){const o=t.frame().width(),r=t.frame().height();t.frame().setX((e-o)/2),t.frame().setY((e-r)/2)}function ie(e,t){const o=e.firstLayer().frame(),r=e.rect(),i=parseInt(r.size.width),n=parseInt(r.size.height),a=o.width(),s=o.height();o.constrainProportions=!0,a>=s?o.setWidth(i-2*t+1e-7):o.setHeight(n-2*t+1e-7)}function ne(e){const t=e.children(),o=NSPredicate.predicateWithFormat("(className == %@)","MSLayerGroup"),r=t.filteredArrayUsingPredicate(o).objectEnumerator();let i;for(;i=r.nextObject();)i.ungroup()}function ae(e){e.children().forEach(e=>{e.canConvertToOutlines()&&"delete-me"!==String(e.name())&&e.layersByConvertingToOutlines()}),e.children().forEach(e=>{e.usedStyle().disableAllBorders()})}var se={initImport:function(e,t,o){const r=c.getRootObject(e);if(t.yOrigin=de(e,r).yOrigin,t.presets){const i=r;t.presets.forEach(a=>{!function(e,t){e.iconPadding=t.iconPadding,le.height=le.width=t.artboardSize}(t,a),t.xOrigin=de(e,ce).xOrigin,t.artboardSize=a.artboardSize,t.prefix=c.buildPrefix(e,t.artboardSize),i&&0===r.length&&e.document.currentPage().addLayers([ue(a,t.xOrigin)]),le.iconsByLine=parseInt(n.getSettings(e,"default").iconsByLine.data),o(e,t)})}else t.prefix=c.buildPrefix(e,t.artboardSize),le.height=le.width=t.artboardSize,le.iconsByLine=parseInt(n.getSettings(e,"default").iconsByLine.data),o(e,t);const i=t.listIcon.length*(Array.isArray(t.presets)?t.presets.length:1);return e.document.showMessage(`🎉 Tadaaa! 🎉 ${i} icon${t.listIcon.length>1?"s":""} imported`),i},initImportIcons:async function(e,t){c.clearSelection(e),t.listIcon.forEach((o,r)=>{try{const i=c.getIconNameByNSUrl(o),n=he(e,r,i,t),a=String(o.toString().split(".").pop()).toLowerCase();if("pdf"===a)return Z.addPDF(e,n,t,o);if("png"===a||"jpg"===a||"jpeg"===a)return Z.addBITMAP(e,n,t,o);const s=String(NSString.alloc().initWithContentsOfURL(o));!function(e,t,o,r){Z.addSVG(e,t,o,r,!0),o.withColor&&E.addColor(e,t,o);e.command.setValue_forKey_onLayer(o.iconPadding,"padding",t)}(e,n,t,s),ce.push(n)}catch(n){i.error(n)}}),c.clearSelection(e)},getPaddingAndSize:function(e,t){let o=e.command.valueForKey_onLayer("padding",t);if(!o){const e=t.layers()[0].rect();o=Math.min(e.origin.x,e.origin.y)}return{iconPadding:parseInt(o),artboardSize:parseInt(t.rect().size.width)}},initOrganizeIcons:function(e,t){t.listIcon.forEach(async(o,r)=>{try{const i=he(e,r,o.name(),t);if("MSBitmapLayer"===String(o.class()))return Z.addBITMAP(e,i,t,o);const n=MSImmutableLayerAncestry.ancestryWithMSLayer_(o),a=MSExportRequest.exportRequestsFromLayerAncestry_(n).firstObject();a.format="svg";const s=MSExporter.exporterForRequest_colorSpace_(a,NSColorSpace.sRGBColorSpace()),l=NSString.alloc().initWithData_encoding(s.data(),NSUTF8StringEncoding);Z.addSVGNew(e,i,t,l,!0),t.withColor&&E.addColor(e,i,t),ce.push(i)}catch(n){i.error(n)}})}};const le={iconsByLine:10,sizeBetweenPreset:200,titleFontSize:32},ce=[];function he(e,t,o,r){const i=n.getSettings(e,"default").marginBetweenRootObject,a=c.getSizeBetweenIcon(le.width,i.data);0===t?(le.y=r.yOrigin,le.x=r.xOrigin||0):t%le.iconsByLine==0?(le.y+=a,le.x=r.xOrigin||0):le.x+=a;const s=MSArtboardGroup.new();return s.setName(`${r.prefix}${o}`),function(e,t){const o=e.frame();o.setWidth(t.width),o.setHeight(t.height),o.setX(t.x),o.setY(t.y)}(s,le),e.document.currentPage().addLayers([s]),r.convertSymbol?MSSymbolMaster.convertArtboardToSymbol(s):s}function de(e,t){const o=[],r=[];let i=0;t.forEach(e=>{const t=(e=e.sketchObject).frame().height(),n=e.origin();o.push(n.y-i),r.push(n.x-i),t>i&&(i=t)});const n=0!==o.length?Math.max(...o):0,a=0!==r.length?Math.max(...r)+i:0;return{yOrigin:0===t.length?n:n+100+i,xOrigin:0===t.length?a:a+100+i}}function ue(e,t){const o=MSTextLayer.new();o.setStringValue_(e.artboardSize+"px");const r=NSFontManager.sharedFontManager().fontWithFamily_traits_weight_size("Helvetica neue",NSBoldFontMask,0,le.titleFontSize);o.setFont(r),o.lineHeight=48,o.setName(e.artboardSize+"px");const i=o.frame();return i.setX(t),i.setY(-(32+o.lineHeight())),o}var me={newModal:function(e,t,o){const r=COSAlertWindow.new(),i=NSView.alloc().initWithFrame(NSMakeRect(0,0,t.width,t.height));return r.addAccessoryView(i),r.setMessageText(o.messageText),r.setInformativeText(o.informativeText),r.addButtonWithTitle("Continue"),r.addButtonWithTitle("Cancel"),r.layout(),{modal:r,view:i,viewSize:t}},runModal:function({modal:e}){return e.runModal()},getMainButtonParam:function(e){return{button:e}},createArtboardFields:function(){const e=NSTextField.alloc().initWithFrame(NSMakeRect(0,10,130,20));e.setStringValue("24");const t=NSTextField.alloc().initWithFrame(NSMakeRect(140,10,130,20));return t.setStringValue("3"),[{item:e,getter:function(){return parseInt(e.stringValue())},name:"artboardSize",label:c.createLabel("Size",0,30,130,20)},{item:t,getter:function(){return parseInt(t.stringValue())},name:"iconPadding",label:c.createLabel("Padding",140,30,130,20)}]},createCheckBoxes:function(){const e=NSButton.alloc().initWithFrame(NSMakeRect(0,30,200,14));e.setButtonType(NSSwitchButton),e.setState(!0),e.setFont(NSFont.systemFontOfSize_(13)),e.setTitle("Convert to symbol");const t=NSButton.alloc().initWithFrame(NSMakeRect(0,5,200,14));return t.setButtonType(NSSwitchButton),t.setState(!1),t.setFont(NSFont.systemFontOfSize_(13)),t.setTitle("Add color mask"),[{item:e,name:"convertSymbol",getter:e.state},{item:t,name:"withColor",getter:t.state}]},createMaskFields:function(e,t,o){const r=NSPopUpButton.alloc().initWithFrame(NSMakeRect(0,0,130,20)),i=NSPopUpButton.alloc().initWithFrame(NSMakeRect(140,0,130,20));r.setEnabled(!1),i.setEnabled(!1),r.menu=H.initLibsSelectList(AppController.sharedInstance().librariesController().availableLibraries(),i),o?o[1].item.setCOSJSTargetFunction((function(e){e.state()?(r.setEnabled(!0),i.selectedItem()&&i.setEnabled(!0)):(r.setEnabled(!1),i.setEnabled(!1))})):r.setEnabled(!0);return[{item:i,label:c.createLabel("Color",140,25,130,20),name:"color",getter:function(){let e=this.item.selectedItem();return e?e.representedObject():null}},{item:r,label:c.createLabel("Colors Library",0,25,130,20),name:"colorLib",getter:function(){let e=this.item.selectedItem();return e?e.representedObject():null}}]},appendsFields:function({view:e,viewSize:t},o,r){o.reverse().forEach((function(o){const i=r?50*e.subviews().length+25:50*e.subviews().length,n=NSView.alloc().initWithFrame(NSMakeRect(0,i,t.width,50));o.forEach((function(e){e.label&&n.addSubview(e.label),e.item&&n.addSubview(e.item)})),e.addSubview(n)}))},getParams:function(e){const t={};return e.forEach((function(e){e.forEach((function(e){t[e.name]=e.getter()}))})),t},setNextKey:function(e){e.forEach((function(t,o){e[o+1]&&t.item&&t.item.setNextKeyView(e[o+1].item)}))},newErrorModal:function(e,t){const o=COSAlertWindow.new();o.setMessageText(e),o.setInformativeText(t),o.runModal()}};var ge={selectIconsFiles:function(){const e=NSOpenPanel.openPanel();if(e.setAllowsMultipleSelection(!0),e.setCanChooseDirectories(!0),e.setAllowedFileTypes(Se),e.setCanChooseFiles(!0),e.setPrompt("Select"),e.runModal()!==NSFileHandlingPanelOKButton)return[];const t=[];return fe(e.URLs(),t),t}};const Se=["svg","pdf","png","jpg","jpeg"];function fe(e,t){for(let o=0;o<e.length;o++)if(e[o].hasDirectoryPath())fe(NSFileManager.defaultManager().contentsOfDirectoryAtURL_includingPropertiesForKeys_options_error(e[o],null,null,null),t);else{const r=String(e[o].pathExtension()).toLowerCase();-1!==Se.indexOf(r)&&t.push(e[o])}}var be=function(e){return this.settingsValues=n.getSettings(e,"placeholder"),this.modalParams={messageText:"Settings",informativeText:"Customize your imports using presets and other features.",height:73*(Object.keys(this.settingsValues).length+1),width:340,lineHeight:45},this.coeffCurrentHeight=0,this.adjustHeight=0,this.marginLeftColRight=130,this.adjust=-5,this.lineOne=15,this.lineTwo=0,g.call(this,"Save"),pe.call(this),Pe.call(this),we.call(this),ve.call(this),ye.call(this),{button:this.modal.runModal(),presets:String(this.presets.stringValue()).replace(/ /g,""),iconsByLine:parseInt(this.iconsByLine.stringValue())||null,convertStroke:this.convertStroke.state(),marginBetweenRootObject:this.marginBetweenRootObject.stringValue().replace(/ /g,""),prefixRootObject:this.prefixRootObject.stringValue()}};function pe(){this.coeffCurrentHeight++;let e=this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight+this.adjust;const t=c.createLabel("Size Presets",0,e,this.marginLeftColRight,20);this.view.addSubview(t);const o=NSTextField.alloc().initWithFrame(NSMakeRect(this.marginLeftColRight,e,145,21));n.hasValue(this.settingsValues.presets)?o.setStringValue(String(this.settingsValues.presets.value)):o.setPlaceholderString(String(this.settingsValues.presets.placeholder)),this.view.addSubview(o),this.coeffCurrentHeight++,Ce.call(this,"Set your artboard sizes and padding.",this.lineOne),Ce.call(this,"Format: size-padding",this.lineTwo),this.presets=o}function ye(){this.coeffCurrentHeight++;const e=this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight+30,t=c.createLabel("Stroke to Fill",0,e,this.marginLeftColRight,20);this.view.addSubview(t);const o=NSButton.alloc().initWithFrame(NSMakeRect(this.marginLeftColRight,e,200,21));o.setButtonType(NSSwitchButton),o.setState(parseInt(this.settingsValues.convertStroke.data)),o.setFont(NSFont.systemFontOfSize_(13)),o.setTitle("Auto-Convert"),this.view.addSubview(o),this.coeffCurrentHeight++,Ce.call(this,"This will allow you to add a dynamic color ",this.lineOne+30),Ce.call(this,"over your outlined icons.",this.lineTwo+30),this.convertStroke=o}function we(){this.coeffCurrentHeight++;const e=this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight+this.adjust,t=c.createLabel("Icons Grid",0,e,this.marginLeftColRight,20);this.view.addSubview(t);const o=NSTextField.alloc().initWithFrame(NSMakeRect(this.marginLeftColRight,e,50,21));"null"===String(this.settingsValues.iconsByLine.value)?o.setPlaceholderString("10"):o.setStringValue(String(this.settingsValues.iconsByLine.value)),this.view.addSubview(o);const r=c.createLabel("icons per row",this.marginLeftColRight+55,e,100,20);this.view.addSubview(r),this.coeffCurrentHeight++,Ce.call(this,"Set the number of imported icons per row.",this.lineOne),this.iconsByLine=o}function ve(){this.coeffCurrentHeight++;const e=this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight+15,t=c.createLabel("Spacing",0,e,this.marginLeftColRight,20);this.view.addSubview(t);const o=NSTextField.alloc().initWithFrame(NSMakeRect(this.marginLeftColRight,e,50,21));n.hasValue(this.settingsValues.marginBetweenRootObject)?o.setStringValue(String(this.settingsValues.marginBetweenRootObject.value)):o.setPlaceholderString(String(this.settingsValues.marginBetweenRootObject.placeholder)),this.view.addSubview(o);const r=c.createLabel("px or %",this.marginLeftColRight+55,e,100,20);this.view.addSubview(r),this.coeffCurrentHeight++,Ce.call(this,"Set the spacing between the imported icons.",this.lineOne+15),this.marginBetweenRootObject=o}function Pe(){this.coeffCurrentHeight++;const e=this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight+this.adjust,t=c.createLabel("Add Prefix ",0,e,this.marginLeftColRight,20);this.view.addSubview(t);const o=NSTextField.alloc().initWithFrame(NSMakeRect(this.marginLeftColRight,e,145,21));n.hasValue(this.settingsValues.prefixRootObject)?o.setStringValue(String(this.settingsValues.prefixRootObject.value)):o.setPlaceholderString(String(this.settingsValues.prefixRootObject.placeholder)),this.view.addSubview(o),this.coeffCurrentHeight++,Ce.call(this,"Add a path structure to the name of yours icons.",this.lineOne),Ce.call(this,"$size is equal to the size of the artboard.",this.lineTwo),this.prefixRootObject=o}function Ce(e,t){const o=this.modalParams.height-this.modalParams.lineHeight*this.coeffCurrentHeight+t,r=c.createLabel(e,0,o,400,20,!0);this.view.addSubview(r)}let Le=NSUserDefaults.standardUserDefaults().objectForKey("google.analytics.uuid");Le||(Le=NSUUID.UUID().UUIDString(),NSUserDefaults.standardUserDefaults().setObject_forKey(Le,"google.analytics.uuid"));var Me={action:function(e,t,o,r,i){!function(e){try{const o=NSURL.URLWithString(NSString.stringWithFormat("https://www.google-analytics.com/collect%@",(t=e,"?"+Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&"))));if(o){const e=NSTask.alloc().init();e.setLaunchPath("/usr/bin/curl"),e.setArguments(["-X","POST",String(o)]);const t=NSPipe.pipe();e.setStandardOutput(t),e.launch()}}catch(o){}var t}({v:1,t:"event",cid:Le,tid:"UA-115448236-1",ec:t,ea:o,el:r,ev:i})}};function Fe(e){c.runFramework(e);const t=m.call({},e);if(1e3!==t.button)return;if(t.listIcon=ge.selectIconsFiles(),!t.listIcon.length)return;const o=se.initImport(e,t,se.initImportIcons),r=t.withColor?"import-mask":"import";Me.action(e,"icons","import",r,o)}function ke(e){const t=c.getSelectedArtboardsAndSymbols(e);if(0===t.length)return me.newErrorModal("No artboards selected","Please select one or more artboards to replace icons.");let o={};if(o.listIcon=ge.selectIconsFiles(),!o.listIcon.length)return;if(t.length>o.listIcon.length&&1!==o.listIcon.length)return me.newErrorModal("Too much artboards selected","Please select as many artboards as icons.");if(t.length<o.listIcon.length&&1!==o.listIcon.length)return me.newErrorModal("Too much icons selected","Please select as many icons as artboards.");const r=Z.initUpdateIconsSelectedArtboards(e,t,o);Me.action(e,"icons","replace","replace",r)}function Ne(e){const t=e.selection;if(0===t.length)return me.newErrorModal("No layers selected","Please select one or more layers.");c.runFramework(e);const o=m.call({},e);if(1e3!==o.button)return;o.listIcon=t,se.initImport(e,o,se.initOrganizeIcons),o.listIcon.forEach(e=>e.removeFromParent());const r=o.withColor?"organize-mask":"organize";Me.action(e,"icons","organize",r,o.listIcon.length)}function _e(e){c.runFramework(e);const t=c.getSelectedArtboardsAndSymbols(e);if(0===t.length)return me.newErrorModal("No artboards selected","Please select one or more artboards to add a mask.");const o=u.call({},e);1e3===o.button&&(E.initAddMaskOnSelectedArtboards(e,o,t),Me.action(e,"icons","mask","mask",t.length))}function Ie(e){const t=c.getSelectedArtboardsAndSymbols(e);if(0===t.length)return me.newErrorModal("No artboards selected","Please select one or more artboards to add a mask.");t.forEach(t=>{E.removeColor(e,t.object)}),Me.action(e,"icons","remove mask","remove mask",t.length)}function Oe(e){const t=be.call({},e);1001!==t.button&&(n.registerSettings(e,t),Me.action(e,"settings","settings","settings"))}}]);if("default"===key&&"function"==typeof exports)exports(context);else{if("function"!=typeof exports[key])throw new Error('Missing export named "'+key+'". Your command should contain something like `export function " + key +"() {}`.');exports[key](context)}}catch(err){if("undefined"==typeof process||!process.listenerCount||!process.listenerCount("uncaughtException"))throw err;process.emit("uncaughtException",err,"uncaughtException")}}globalThis.importIcons=__skpm_run.bind(this,"importIcons"),globalThis.onRun=__skpm_run.bind(this,"default"),globalThis.updateIconsOnSelectedArtboards=__skpm_run.bind(this,"updateIconsOnSelectedArtboards"),globalThis.addMaskOnSelectedArtboards=__skpm_run.bind(this,"addMaskOnSelectedArtboards"),globalThis.addMaskOnSelectedArtboards=__skpm_run.bind(this,"addMaskOnSelectedArtboards"),globalThis.removeMaskOnSelectedArtboards=__skpm_run.bind(this,"removeMaskOnSelectedArtboards"),globalThis.setSettings=__skpm_run.bind(this,"setSettings"),globalThis.organizeIcons=__skpm_run.bind(this,"organizeIcons");