UNPKG

dps_canvas

Version:

Html canvas üzerinde şekiller oluşturmanızı sağlar

1 lines 23.1 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.dps=t():e.dps=t()}(self,(()=>(()=>{var e={90:(e,t,n)=>{"use strict";n.d(t,{Z:()=>y});var r=n(150),i=n(393),a=n(614),o=n(476),c=["name","x","y","radius","color"];function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}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}function h(e,t,n){return f(e,t),d(n,"get"),function(e,t){return t.get?t.get.call(e):t.value}(e,n)}function d(e,t){if(void 0===e)throw new TypeError("attempted to "+t+" private static field before its declaration")}function f(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}var y=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,l;return t=e,l=[{key:"draw",value:function(e){var t=e.x,n=e.y,i=e.radius,a=e.color;r.Z.context.beginPath(),r.Z.context.fillStyle=a||r.Z.circleColor,r.Z.context.arc(t,n,i,0,2*Math.PI),r.Z.context.fill(),r.Z.context.closePath()}},{key:"circle",get:function(){return h(e,e,g)}},{key:"lastItem",get:function(){return e.circle[e.circle.length-1]}},{key:"handleDown",value:function(t,n){var i=this,a=this.prototype.getCollisionElement(t,n),o=e.activeCircle.find((function(e){return i.prototype.collisionDetection(t,n,0,e.x,e.y,e.radius)}));return a.circle||a.text?(r.Z.isMoving=!0,r.Z.isResizeable=!!o,a):r.Z.isMoving=!1}},{key:"clearItem",value:function(){var t,n,r;n=g,r=[],f(t=e,e),d(n,"set"),function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(t,n,r)}},{key:"delete",value:function(t){var n,r=h(e,e,g).findIndex((function(e){return e.uid===(null==t?void 0:t.uid)})),a=h(e,e,g).splice(r,1);i.Z.deleteTextById(null===(n=a[0])||void 0===n?void 0:n.uid)}},{key:"add",value:function(t){var n=t.name,l=t.x,v=t.y,p=t.radius,d=(t.color,s(t,c));if(p<r.Z.minDimensionsCircle)return console.info("Radius değeri ".concat(r.Z.minDimensionsCircle," değerinden büyük olmalı"));var f=(0,a.E)();h(e,e,g).push(u(u(u({},arguments[0]),{},{uid:f},d),{},{type:"circle"})),i.Z.add({name:n,x:l,y:v,uid:f}),n||(r.Z.setActiveShape(e.circle[e.circle.length-1]),r.Z.isShowInput=!0,(0,o.n)({circle:e.lastItem,text:i.Z.lastItem}))}},{key:"handleContextmenu",value:function(e,t){return this.prototype.getCollisionElement(e,t).circle}},{key:"getRadius",value:function(e,t){return Math.sqrt(Math.pow(r.Z.lastX-e,2)+Math.pow(r.Z.lastY-t,2))}},{key:"handleDblClick",value:function(t,n){var i=this.prototype.getCollisionElement(t,n,h(e,e,g)),a=i.circle,o=i.text;return a?(r.Z.isShowInput=!0,{circle:a,text:o}):r.Z.isShowInput=!1}}],(n=[{key:"getCollisionElement",value:function(t,n){var r=this,a=h(e,e,g).find((function(e){return r.collisionDetection(t,n,0,e.x,e.y,e.radius)})),o=i.Z.text.find((function(e){return e.uid===(null==a?void 0:a.uid)}));return{circle:a,text:o}}},{key:"collisionDetection",value:function(e,t,n,r,i,a){var o=e-r,c=t-i;return n+a>Math.sqrt(o*o+c*c)}}])&&v(t.prototype,n),l&&v(t,l),Object.defineProperty(t,"prototype",{writable:!1}),e}(),g={writable:!0,value:[]};p(y,"activeCircle",[])},352:(e,t,n)=>{var r=n(150).Z,i=n(114).Z,a=n(90).Z;e.exports={Square:i,Circle:a,Base:r}},150:(e,t,n)=>{"use strict";n.d(t,{Z:()=>j});var r=n(90),i=n(114),a=n(393),o="can-view",c={onlyView:[o],admin:[o,"can-show-input","can-drawing","can-move","can-delete"]},l=function(){for(var e=c[j.permission],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return null==n?void 0:n.map((function(t){return null==e?void 0:e.includes(t)})).every(Boolean)},u={"top-left":"nw-resize","top-right":"ne-resize","bottom-left":"sw-resize","bottom-right":"se-resize",top:"n-resize",left:"w-resize",bottom:"s-resize",right:"e-resize"};function s(){j.context.canvas.style.cursor="auto",j.isCreating&&(j.isResizeable?j.context.canvas.style.cursor=u[j.direction]:j.isMoving&&(j.context.canvas.style.cursor="move"))}var v=10,p=function(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))},h=n(476);function d(e){var t,n,a,o=e.offsetX,c=e.offsetY;return 2===e.button?j.isCreating=!1:(j.isCreating=l("can-drawing"),j.isShowInput=!1,null===(t=j.parent)||void 0===t||null===(n=t.querySelector("input"))||void 0===n||n.remove(),j.lastX=o,j.lastY=c,j.movedItem=null!==(a=i.Z.handleDown(o,c))&&void 0!==a?a:r.Z.handleDown(o,c),j.movedItem?j.setActiveShape(Object.values(j.movedItem)[0]):(j.setActiveShape(),j.drawAll()),l("can-move")||(j.isMoving=!1),l("can-resizable")||(j.isResizeable=!1),"creating"===j.process?j.snapshot=j.context.getImageData(0,0,j.context.canvas.width,j.context.canvas.height):void s())}function f(e){var t,n,a,o,c=e.offsetX,l=e.offsetY;s(),j.direction=(t=c,n=l,!!j.isResizeable&&(j.activeShape.height||(j.activeShape.height=j.activeShape.width),p(t,n,null===(a=j.activeShape)||void 0===a?void 0:a.x,null===(o=j.activeShape)||void 0===o?void 0:o.y)<=v?"top-left":p(t,n,j.activeShape.x+j.activeShape.width,j.activeShape.y)<=v?"top-right":p(t,n,j.activeShape.x,j.activeShape.y+j.activeShape.height)<=v?"bottom-left":p(t,n,j.activeShape.x+j.activeShape.width,j.activeShape.y+j.activeShape.height)<=v?"bottom-right":p(t,n,j.activeShape.x+j.activeShape.width/2,j.activeShape.y)<=v?"top":p(t,n,j.activeShape.x,j.activeShape.y+j.activeShape.height/2)<=v?"left":p(t,n,j.activeShape.x+j.activeShape.width/2,j.activeShape.y+j.activeShape.height)<=v?"bottom":p(t,n,j.activeShape.x+j.activeShape.width,j.activeShape.y+j.activeShape.height/2)<=v&&"right")),function(e,t){if(j.isResizeable){var n;switch(j.activeShape.height||(j.activeShape.height=j.activeShape.width),j.context.canvas.dispatchEvent((n=j.activeShape,new CustomEvent("dps:resize",{cancelable:!0,detail:{item:n}}))),j.direction){case"top-left":j.activeShape.width+=j.activeShape.x-e,j.activeShape.height+=j.activeShape.y-t,j.activeShape.x=e,j.activeShape.y=t;break;case"top-right":j.activeShape.width=e-j.activeShape.x,j.activeShape.height+=j.activeShape.y-t,j.activeShape.y=t;break;case"bottom-left":j.activeShape.width+=j.activeShape.x-e,j.activeShape.x=e,j.activeShape.height=t-j.activeShape.y;break;case"bottom-right":j.activeShape.width=e-j.activeShape.x,j.activeShape.height=t-j.activeShape.y;break;case"top":j.activeShape.height+=j.activeShape.y-t,j.activeShape.y=t;break;case"left":j.activeShape.width+=j.activeShape.x-e,j.activeShape.x=e;break;case"bottom":j.activeShape.height=t-j.activeShape.y;break;case"right":j.activeShape.width=e-j.activeShape.x}j.drawAll(),j.setActiveShape(j.activeShape)}}(c,l),"moving"!==j.process?j.isCreating&&(j.context.putImageData(j.snapshot,0,0),"square"===j.status?i.Z.draw({x:c,y:l,width:j.lastX-c,height:j.lastY-l,color:j.squareColor}):"circle"===j.status&&r.Z.draw({x:j.lastX,y:j.lastY,radius:r.Z.getRadius(c,l),color:j.circleColor})):function(e,t){if(j.isMoving){var n;j.context.canvas.dispatchEvent((n=j.movedItem,new CustomEvent("dps:drag",{cancelable:!0,detail:{item:n}})));for(var r=0,i=Object.values(j.movedItem);r<i.length;r++){var a=i[r];a.x+=e-j.lastX,a.y+=t-j.lastY}j.lastX=e,j.lastY=t,j.setActiveShape(Object.values(j.movedItem)[0])}}(c,l)}function y(e){var t=e.offsetX,n=e.offsetY;2!==e.button&&(j.isCreating=!1,j.isMoving=!1,j.isResizeable=!1,l("can-drawing")&&"creating"===j.process&&("square"===j.status?i.Z.add({x:j.lastX,y:j.lastY,width:t-j.lastX,height:n-j.lastY,color:j.squareColor,name:""}):"circle"===j.status&&r.Z.add({x:j.lastX,y:j.lastY,color:j.circleColor,name:"",radius:r.Z.getRadius(t,n)}),j.drawAll()))}function g(e){var t=e.offsetX,n=e.offsetY,a=i.Z.handleDblClick(t,n)||r.Z.handleDblClick(t,n);j.isCreating=!1,l("can-show-input")&&a&&(0,h.n)(a)}function b(e){var t;e.preventDefault(),j.isCreating=!1;var n=null!==(t=i.Z.handleContextmenu(e.offsetX,e.offsetY))&&void 0!==t?t:r.Z.handleContextmenu(e.offsetX,e.offsetY);n&&(j.setActiveShape(n),j.context.canvas.dispatchEvent(new CustomEvent("dps:click",{cancelable:!0,detail:{item:n}})))}function w(){j.isCreating=!1,j.isMoving=!1}function m(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){c=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(c)throw a}}}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function O(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=function(){function e(t){var n=t.ctx,r=t.width,i=t.height;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),e.context=n,e.width=r||700,e.height=i||500,e.context.canvas.width=r,e.context.canvas.height=i,e.context.canvas.oncontextmenu=b,e.context.canvas.onmousedown=d,e.context.canvas.onmousemove=f,e.context.canvas.onmouseup=y,e.context.canvas.onmouseleave=w,e.context.canvas.ondblclick=g}var t,n;return t=e,n=[{key:"coordinate",get:function(){return{circles:r.Z.circle,squares:i.Z.data}}},{key:"fillCanvas",set:function(e){this.color=e,i.Z.draw({x:0,y:0,width:this.width,height:this.height,color:e})}},{key:"deleteShape",value:function(){var t,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];l("can-delete")&&e.activeShape&&(null!==(t=e.activeShape)&&void 0!==t&&t.radius?r.Z.delete(e.activeShape):i.Z.delete(e.activeShape),e.setActiveShape(),n&&e.drawAll(),e.isShowInput=!1,(0,h.n)())}},{key:"setInput",value:function(t,n){e.inputStyle[t]=Z(Z({},e.inputStyle[t]),n)}},{key:"active",set:function(t){e.activeOptions=Z(Z({},e.activeOptions),t)}},{key:"drawAll",value:function(){this.context.clearRect(0,0,this.width,this.height),this.fillCanvas=this.color;var e,t=m(i.Z.data);try{for(t.s();!(e=t.n()).done;){var n=e.value;i.Z.draw(n)}}catch(e){t.e(e)}finally{t.f()}var o,c=m(i.Z.activeSquare);try{for(c.s();!(o=c.n()).done;){var l=o.value;i.Z.draw(l)}}catch(e){c.e(e)}finally{c.f()}var u,s=m(r.Z.circle);try{for(s.s();!(u=s.n()).done;){var v=u.value;r.Z.draw(v)}}catch(e){s.e(e)}finally{s.f()}var p,h=m(r.Z.activeCircle);try{for(h.s();!(p=h.n()).done;){var d=p.value;r.Z.draw(d)}}catch(e){h.e(e)}finally{h.f()}var f,y=m(a.Z.text);try{for(y.s();!(f=y.n()).done;){var g=f.value;a.Z.draw(g)}}catch(e){y.e(e)}finally{y.f()}}},{key:"setActiveShape",value:function(t){if(i.Z.activeSquare=[],r.Z.activeCircle=[],e.activeShape=t,t){var n=2*e.activeOptions.gap+((null==t?void 0:t.width)||2*(null==t?void 0:t.radius)),a=2*e.activeOptions.gap+(null==t?void 0:t.height),o=null!=t&&t.radius?-(null==t?void 0:t.radius)-e.activeOptions.gap+(null==t?void 0:t.x):(null==t?void 0:t.x)-e.activeOptions.gap,c=null!=t&&t.radius?-(null==t?void 0:t.radius)-e.activeOptions.gap+(null==t?void 0:t.y):(null==t?void 0:t.y)-e.activeOptions.gap,l={radius:e.activeOptions.cornerSize,color:e.activeOptions.cornerColor},u=[{x:o,y:c},{x:o+n,y:c},{x:o,y:c+(null!=t&&t.height?a:n)},{x:o+n,y:c+(null!=t&&t.height?a:n)}];i.Z.draw({x:o,y:c,width:n,height:a,stroke:!0,color:e.activeOptions.sideColor,dash:e.activeOptions.dashed}),i.Z.activeSquare.push({x:o,y:c,width:n,height:a,stroke:!0,color:e.activeOptions.sideColor,dash:e.activeOptions.dashed});for(var s=0,v=u;s<v.length;s++){var p=v[s];r.Z.draw(Z(Z({},p),l)),r.Z.activeCircle.push(Z(Z({},p),l))}e.drawAll()}}},{key:"clearAll",value:function(){i.Z.clearItem(),r.Z.clearItem(),a.Z.clearItem(),e.setActiveShape()}}],null&&O(t.prototype,null),n&&O(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();k(j,"context",void 0),k(j,"status","square"),k(j,"process","creating"),k(j,"permission",void 0),k(j,"direction",void 0),k(j,"inputStyle",{style:{position:"absolute",top:"50%",left:"50%",border:"1px solid #252525",outline:"none",padding:"10px 15px",color:"#252525"},prop:{type:"text",placeholder:"İsim Ver"}}),k(j,"parent",void 0),k(j,"lastX",void 0),k(j,"lastY",void 0),k(j,"snapshot",void 0),k(j,"movedItem",void 0),k(j,"color",void 0),k(j,"width",void 0),k(j,"height",void 0),k(j,"isCreating",!1),k(j,"isMoving",!1),k(j,"isResizeable",!1),k(j,"isShowInput",!1),k(j,"minDimensionsCircle",40),k(j,"minDimensionsSquare",50),k(j,"squareColor","#222"),k(j,"circleColor","#2f3640"),k(j,"activeShape",null),k(j,"activeOptions",{gap:8,cornerSize:2.5,cornerColor:"darkgreen",sideColor:"red",cornerLength:4,dashed:!0})},114:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(150),i=n(393),a=n(614),o=n(476);function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t,n){return h(e,t),p(n,"get"),function(e,t){return t.get?t.get.call(e):t.value}(e,n)}function p(e,t){if(void 0===e)throw new TypeError("attempted to "+t+" private static field before its declaration")}function h(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}var d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,c;return t=e,c=[{key:"draw",value:function(e){var t=e.x,n=e.y,i=e.width,a=e.height,o=e.color,c=e.stroke,l=e.dash;r.Z.context.beginPath(),r.Z.context.fillStyle=o||r.Z.squareColor,r.Z.context.strokeStyle=o||r.Z.squareColor,l&&r.Z.context.setLineDash([15,3,3,3]),r.Z.context.rect(t,n,i,a||i),c?r.Z.context.stroke():r.Z.context.fill(),r.Z.context.closePath()}},{key:"data",get:function(){return v(e,e,f)}},{key:"lastItem",get:function(){return e.data[e.data.length-1]}},{key:"add",value:function(t){var n=t.x,c=t.y,u=t.width,s=t.height,p=t.name,h=(0,a.E)();if(u<0&&(n-=u=Math.abs(u)),s<0&&(c-=s=Math.abs(s)),u<r.Z.minDimensionsSquare||s<r.Z.minDimensionsSquare)return console.info("Width yada height değeri ".concat(r.Z.minDimensionsSquare," değerinden büyük olmalı"));v(e,e,f).push(l(l({},t),{},{width:u,height:s,x:n,y:c,uid:h,type:"square"})),i.Z.add({uid:h,name:p,x:n+u/2,y:c+(s||u)/2}),p||(r.Z.setActiveShape(e.data[e.data.length-1]),r.Z.isShowInput=!0,(0,o.n)({square:e.lastItem,text:i.Z.lastItem}))}},{key:"handleDown",value:function(e,t){var n=this.prototype.getCollisionElement(e,t);if(n.square||n.text)return r.Z.isMoving=!0,n;r.Z.isMoving=!1}},{key:"handleContextmenu",value:function(e,t){return this.prototype.getCollisionElement(e,t).square}},{key:"handleDblClick",value:function(e,t){var n=this.prototype.getCollisionElement(e,t),i=n.square,a=n.text;return i?(r.Z.isShowInput=!0,{square:i,text:a}):r.Z.isShowInput=!1}},{key:"clearItem",value:function(){var t,n,r;n=f,r=[],h(t=e,e),p(n,"set"),function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(t,n,r)}},{key:"delete",value:function(t){var n,r=v(e,e,f).findIndex((function(e){return e.uid===(null==t?void 0:t.uid)})),a=v(e,e,f).splice(r,1);i.Z.deleteTextById(null===(n=a[0])||void 0===n?void 0:n.uid)}}],(n=[{key:"getCollisionElement",value:function(t,n){var r=this,a=v(e,e,f).find((function(e){return r.collisionDetection(t,n,l({},e))})),o=i.Z.text.find((function(e){return(null==a?void 0:a.uid)===(null==e?void 0:e.uid)}));return{square:a,text:o}}},{key:"collisionDetection",value:function(e,t,n){return e+0>=n.x&&e<=n.x+Math.abs(n.width)&&t+0>=n.y&&t<=n.y+(Math.abs(n.height)||Math.abs(n.width))}}])&&u(t.prototype,n),c&&u(t,c),Object.defineProperty(t,"prototype",{writable:!1}),e}(),f={writable:!0,value:[]};s(d,"activeSquare",[])},393:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var r=n(150);function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return c(e,t),o(n,"get"),function(e,t){return t.get?t.get.call(e):t.value}(e,n)}function o(e,t){if(void 0===e)throw new TypeError("attempted to "+t+" private static field before its declaration")}function c(e,t){if(e!==t)throw new TypeError("Private static access of wrong provenance")}var l=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n;return t=e,n=[{key:"draw",value:function(e){var t=e.x,n=e.y,i=e.name,a=e.color;r.Z.context.beginPath(),r.Z.context.fillStyle=a||"#fff",r.Z.context.font="15px Arial",r.Z.context.textAlign="center",r.Z.context.textBaseline="middle",r.Z.context.fillText(i,t,n),r.Z.context.closePath()}},{key:"text",get:function(){return a(e,e,u)}},{key:"lastItem",get:function(){return e.text[e.text.length-1]}},{key:"add",value:function(t){a(e,e,u).push(t)}},{key:"deleteTextById",value:function(t){var n=a(e,e,u).findIndex((function(e){return e.uid===t}));a(e,e,u).splice(n,1)}},{key:"clearItem",value:function(){var t,n,r;n=u,r=[],c(t=e,e),o(n,"set"),function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(t,n,r)}}],null&&i(t.prototype,null),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),u={writable:!0,value:[]}},614:(e,t,n)=>{"use strict";n.d(t,{E:()=>r});var r=function(){return"".concat(Date.now().toString(36)+Math.random().toString(36).substring(2)).concat((new Date).valueOf()).concat((Math.floor(999999999999*Math.random())+1).toString(36))}},476:(e,t,n)=>{"use strict";n.d(t,{n:()=>o});var r=n(150);function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,c=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){c=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(c)throw i}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e){var t,n,a,o,c,l,u;if(!r.Z.isShowInput)return null===(t=r.Z.parent)||void 0===t||null===(n=t.querySelector("input"))||void 0===n?void 0:n.remove();r.Z.parent=document.querySelector(".dps-content");var s=null!==(a=null===(o=r.Z.parent)||void 0===o?void 0:o.querySelector("input"))&&void 0!==a?a:document.createElement("input"),v=i(Object.values(e),2),p=v[0],h=v[1],d="";s.value=(null==h?void 0:h.name)||"",r.Z.setActiveShape(p),r.Z.parent.style.position="relative",r.Z.parent.style.width=r.Z.width,r.Z.parent.style.width=r.Z.height;var f=null!==(c=null==e||null===(l=e.square)||void 0===l?void 0:l.width)&&void 0!==c?c:2*(null==e||null===(u=e.circle)||void 0===u?void 0:u.radius);r.Z.setInput("style",{left:"".concat(p.x,"px"),top:"".concat(p.y,"px"),transform:p.radius?"translate(-50%, -50%)":"translate(0, 0)",width:f?"".concat(f,"px"):"auto",borderRadius:null!=e&&e.square?"0":"5px"});for(var y=0,g=Object.entries(r.Z.inputStyle.style);y<g.length;y++){var b=i(g[y],2),w=b[0],m=b[1];s.style[w]=m}for(var x=0,S=Object.entries(r.Z.inputStyle.prop);x<S.length;x++){var Z=i(S[x],2),O=Z[0],k=Z[1];s[O]=k}r.Z.parent.appendChild(s),s.focus(),s.oninput=function(e){var t=e.target;return d=t.value},s.onkeydown=function(e){"Enter"===e.key&&(h.name=d,p.name=d,s.remove(),d="",r.Z.drawAll())}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(352)})()));