import{isEmpty}from"../../../base/helpers.mjs";import{ScribbleView}from"../../scribble.mjs";import{ImageEditorNodeView,ImageEditorBaseOptionsFormView}from"./base.mjs";class ImageEditorScribbleNodeView extends ImageEditorNodeView{static pencilSquareIcon="fa-regular fa-square";static pencilSquareTooltip="Change Pencil Shape to Square";static pencilCircleIcon="fa-regular fa-circle";static pencilCircleTooltip="Change Pencil Shape to Circle";static eraserIcon="fa-solid fa-eraser";static eraserTooltip="Switch to Eraser (Hold <code>alt</code> To Quick-Toggle)";static pencilIcon="fa-solid fa-pencil";static pencilTooltip="Switch Back to Pencil";static nodeButtons={...ImageEditorNodeView.nodeButtons,shape:{icon:ImageEditorScribbleNodeView.pencilSquareIcon,tooltip:ImageEditorScribbleNodeView.pencilSquareTooltip,callback:function(){this.togglePencilShape()}},erase:{icon:ImageEditorScribbleNodeView.eraserIcon,tooltip:ImageEditorScribbleNodeView.eraserTooltip,callback:function(){this.toggleEraser()}},clear:{icon:"fa-solid fa-delete-left",tooltip:"Clear the entire canvas.",callback:function(){this.scribbleView.clearMemory()}},increase:{icon:"fa-solid fa-plus",tooltip:"Increase Pencil Size",callback:function(){this.scribbleView.increaseSize()}},decrease:{icon:"fa-solid fa-minus",tooltip:"Decrease Pencil Size",callback:function(){this.scribbleView.decreaseSize()}}};togglePencilShape(){let e=this.scribbleView.shape,i=this.node.find(".node-button-shape"),t=i.find("i");"circle"===e?(this.scribbleView.shape="square",i.data("tooltip",this.constructor.pencilCircleTooltip),t.class(this.constructor.pencilCircleIcon)):(this.scribbleView.shape="circle",i.data("tooltip",this.constructor.pencilSquareTooltip),t.class(this.constructor.pencilSquareIcon))}toggleEraser(){let e=!0===this.scribbleView.isEraser,i=this.node.find(".node-button-erase"),t=i.find("i");e?(this.scribbleView.isEraser=!1,i.data("tooltip",this.constructor.eraserTooltip),t.class(this.constructor.eraserIcon)):(this.scribbleView.isEraser=!0,this.scribbleView.shape="circle",i.data("tooltip",this.constructor.pencilTooltip),t.class(this.constructor.pencilIcon))}constructor(e,i,t,s,c,o,r){super(e,i,new ScribbleView(e.config,o,r),s,c,o,r),this.scribbleView=this.content}async resized(){super.resized(),this.scribbleView.resizeCanvas(this.visibleWidth-2*this.constructor.padding,this.visibleHeight-2*this.constructor.padding)}getState(){let e=super.getState();return e.src=this.scribbleView.src,e}setState(e){if(super.setState(e),isEmpty(e.src))this.scribbleView.clearMemory();else{let i=new Image;i.onload=()=>this.scribbleView.setMemory(i),i.src=e.src}}}export{ImageEditorScribbleNodeView};
