/**
* @file ext-shapes.js
*
* @license MIT
*
* @copyright 2010 Christian Tzurcanu, 2010 Alexis Deveria
*
*/
const e="shapes",loadExtensionTranslation=async function(t){let s;const r=t.configObj.pref("lang");try{s=await function __variableDynamicImportRuntime0__(e){switch(e){case"./locale/en.js":return Promise.resolve().then((function(){return a}));case"./locale/fr.js":return Promise.resolve().then((function(){return o}));case"./locale/tr.js":return Promise.resolve().then((function(){return l}));case"./locale/zh-CN.js":return Promise.resolve().then((function(){return n}));default:return new Promise((function(t,a){("function"==typeof queueMicrotask?queueMicrotask:setTimeout)(a.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}("./locale/".concat(r,".js"))}catch(t){console.warn("Missing translation (".concat(r,") for ").concat(e," - using 'en'")),s=await Promise.resolve().then((function(){return a}))}t.i18next.addResourceBundle(r,e,s.default)};var t={name:e,async init(){const t=this,a=t.svgCanvas,{$id:o,$click:l}=a,n=a.getSvgRoot();let s={};await loadExtensionTranslation(t);const r="shapelib",i={};let c,m,u;return{callback(){if(null===o("tool_shapelib")){const n=t.configObj.curConfig.extPath,s='\n \n ');a.insertChildAtIndex(o("tools_left"),s,9),l(o("tool_shapelib"),(()=>{this.leftPanel.updateLeftPanel("tool_shapelib")&&a.setMode(r)}))}},mouseDown(e){if(a.getMode()!==r)return;const t=document.getElementById("tool_shapelib").dataset.draw;m=e.start_x;const o=m;u=e.start_y;const l=u,n=a.getStyle();return i.x=e.event.clientX,i.y=e.event.clientY,c=a.addSVGElementsFromJson({element:"path",curStyles:!0,attr:{d:t,id:a.getNextId(),opacity:n.opacity/2,style:"pointer-events:none"}}),c.setAttribute("transform","translate("+o+","+l+") scale(0.005) translate("+-o+","+-l+")"),a.recalculateDimensions(c),s=c.getBBox(),{started:!0}},mouseMove(e){if(a.getMode()!==r)return;const t=a.getZoom(),o=e.event,l=e.mouse_x/t,i=e.mouse_y/t,h=c.transform.baseVal,b=c.getBBox(),p=b.x,d=b.y,f=(Math.min(m,l),Math.min(u,i),Math.abs(l-m)),g=Math.abs(i-u);let _=f/s.width||1,y=g/s.height||1,j=0;l