import*as tslib_1 from"../polyfills/tslib.js";import{a as getMap}from"./chunk-e494a432.js";var DrawController=function(){function e(){this.defaultOptions={type:"point",multiple:!1,combine:!1,delete:!1,mode:"draw"}}return e.prototype.create=function(e,t){return tslib_1.__awaiter(this,void 0,void 0,function(){var r,n;return tslib_1.__generator(this,function(o){switch(o.label){case 0:if(!(r=getMap(t.mapId)))throw"Draw action map not found";return(n=document.querySelector("gl-draw-toolbar"))&&t.toolbarLabel&&(n.label=t.toolbarLabel),r.drawOptions=this.getControlOptions(t),r.drawing=!0,e&&r.draw.set(e),[4,new Promise(function(e){var t=function(){r.drawing=!1,e(),n.removeEventListener("glDrawCancel",t),n.removeEventListener("glDrawConfirm",o)},o=function(){var t=r.draw.getAll();r.drawing=!1,e(t),n.removeEventListener("glDrawConfirm",o),n.removeEventListener("glDrawConfirm",o)};n.addEventListener("glDrawCancel",t),n.addEventListener("glDrawConfirm",o)})];case 1:return[2,o.sent()]}})})},e.prototype.getControlOptions=function(e){var t=Object.assign({},this.defaultOptions,e||{}),r="simple_select";"direct"===t.mode&&(r="direct_select"),"draw"===t.mode&&("point"===t.type&&(r="draw_point"),"line"===t.type&&(r="draw_line_string"),"polygon"===t.type&&(r="draw_polygon"));var n={controls:{point:t.multiple&&"point"===t.type,line_string:t.multiple&&"line"===t.type,polygon:t.multiple&&"polygon"===t.type,trash:t.delete,combine_features:t.multiple&&t.combine,uncombine_features:t.multiple&&t.combine},defaultMode:r};return t.styles&&(n.styles=t.styles),n},Object.defineProperty(e,"is",{get:function(){return"gl-draw-controller"},enumerable:!0,configurable:!0}),Object.defineProperty(e,"properties",{get:function(){return{create:{method:!0}}},enumerable:!0,configurable:!0}),e}();export{DrawController as GlDrawController};