@leafer-in/editor 1.0.0-rc.28 → 1.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.cjs +42 -5
- package/dist/editor.esm.js +42 -5
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +42 -5
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.js +1 -1
- package/package.json +5 -5
- package/src/Editor.ts +7 -5
- package/src/display/EditBox.ts +4 -1
- package/src/display/EditMask.ts +37 -0
- package/types/index.d.ts +14 -6
package/dist/editor.cjs
CHANGED
|
@@ -122,7 +122,8 @@ function scaleResizeGroup(group, scaleX, scaleY) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
draw.Leaf.prototype
|
|
125
|
+
const leaf = draw.Leaf.prototype;
|
|
126
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
126
127
|
const data = this;
|
|
127
128
|
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
128
129
|
data.scaleX *= scaleX;
|
|
@@ -136,9 +137,17 @@ draw.Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
|
136
137
|
this.__scaleResize(scaleX, scaleY);
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
|
-
|
|
140
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
140
141
|
scaleResize(this, scaleX, scaleY);
|
|
141
142
|
};
|
|
143
|
+
leaf.resizeWidth = function (width) {
|
|
144
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
145
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
146
|
+
};
|
|
147
|
+
leaf.resizeHeight = function (height) {
|
|
148
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
149
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
150
|
+
};
|
|
142
151
|
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
143
152
|
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
144
153
|
scaleResizeFontSize(this, scaleX, scaleY);
|
|
@@ -946,8 +955,11 @@ class EditBox extends draw.Group {
|
|
|
946
955
|
return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
|
|
947
956
|
}
|
|
948
957
|
onSelect(e) {
|
|
949
|
-
if (e.oldList.length === 1)
|
|
950
|
-
e.oldList[0].syncEventer =
|
|
958
|
+
if (e.oldList.length === 1) {
|
|
959
|
+
e.oldList[0].syncEventer = null;
|
|
960
|
+
if (this.app)
|
|
961
|
+
this.app.interaction.bottomList = null;
|
|
962
|
+
}
|
|
951
963
|
}
|
|
952
964
|
onDragStart(e) {
|
|
953
965
|
this.dragging = true;
|
|
@@ -1053,6 +1065,30 @@ class EditBox extends draw.Group {
|
|
|
1053
1065
|
}
|
|
1054
1066
|
}
|
|
1055
1067
|
|
|
1068
|
+
class EditMask extends draw.UI {
|
|
1069
|
+
constructor(editor) {
|
|
1070
|
+
super();
|
|
1071
|
+
this.editor = editor;
|
|
1072
|
+
this.hittable = false;
|
|
1073
|
+
}
|
|
1074
|
+
__draw(canvas, options) {
|
|
1075
|
+
const { editor } = this;
|
|
1076
|
+
const { mask } = editor.mergeConfig;
|
|
1077
|
+
if (mask && editor.list.length) {
|
|
1078
|
+
const { rect } = editor.editBox;
|
|
1079
|
+
const { width, height } = rect.__;
|
|
1080
|
+
canvas.resetTransform();
|
|
1081
|
+
canvas.fillWorld(canvas.bounds, mask);
|
|
1082
|
+
canvas.setWorld(rect.__world, options.matrix);
|
|
1083
|
+
canvas.clearRect(0, 0, width, height);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
destroy() {
|
|
1087
|
+
this.editor = null;
|
|
1088
|
+
super.destroy();
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1056
1092
|
const filterStyle = `
|
|
1057
1093
|
<feOffset dy="1"/>
|
|
1058
1094
|
<feGaussianBlur stdDeviation="1.5"/>
|
|
@@ -1291,10 +1327,11 @@ class Editor extends draw.Group {
|
|
|
1291
1327
|
this.editBox = new EditBox(this);
|
|
1292
1328
|
this.editToolList = {};
|
|
1293
1329
|
this.selector = new EditSelect(this);
|
|
1330
|
+
this.editMask = new EditMask(this);
|
|
1294
1331
|
this.targetEventIds = [];
|
|
1295
1332
|
if (userConfig)
|
|
1296
1333
|
this.config = draw.DataHelper.default(userConfig, this.config);
|
|
1297
|
-
this.addMany(this.selector, this.editBox);
|
|
1334
|
+
this.addMany(this.editMask, this.selector, this.editBox);
|
|
1298
1335
|
}
|
|
1299
1336
|
select(target) {
|
|
1300
1337
|
this.target = target;
|
package/dist/editor.esm.js
CHANGED
|
@@ -120,7 +120,8 @@ function scaleResizeGroup(group, scaleX, scaleY) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
const leaf = Leaf.prototype;
|
|
124
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
124
125
|
const data = this;
|
|
125
126
|
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
126
127
|
data.scaleX *= scaleX;
|
|
@@ -134,9 +135,17 @@ Leaf.prototype.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
|
134
135
|
this.__scaleResize(scaleX, scaleY);
|
|
135
136
|
}
|
|
136
137
|
};
|
|
137
|
-
|
|
138
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
138
139
|
scaleResize(this, scaleX, scaleY);
|
|
139
140
|
};
|
|
141
|
+
leaf.resizeWidth = function (width) {
|
|
142
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
143
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
144
|
+
};
|
|
145
|
+
leaf.resizeHeight = function (height) {
|
|
146
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
147
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
148
|
+
};
|
|
140
149
|
Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
141
150
|
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
142
151
|
scaleResizeFontSize(this, scaleX, scaleY);
|
|
@@ -944,8 +953,11 @@ class EditBox extends Group {
|
|
|
944
953
|
return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
|
|
945
954
|
}
|
|
946
955
|
onSelect(e) {
|
|
947
|
-
if (e.oldList.length === 1)
|
|
948
|
-
e.oldList[0].syncEventer =
|
|
956
|
+
if (e.oldList.length === 1) {
|
|
957
|
+
e.oldList[0].syncEventer = null;
|
|
958
|
+
if (this.app)
|
|
959
|
+
this.app.interaction.bottomList = null;
|
|
960
|
+
}
|
|
949
961
|
}
|
|
950
962
|
onDragStart(e) {
|
|
951
963
|
this.dragging = true;
|
|
@@ -1051,6 +1063,30 @@ class EditBox extends Group {
|
|
|
1051
1063
|
}
|
|
1052
1064
|
}
|
|
1053
1065
|
|
|
1066
|
+
class EditMask extends UI {
|
|
1067
|
+
constructor(editor) {
|
|
1068
|
+
super();
|
|
1069
|
+
this.editor = editor;
|
|
1070
|
+
this.hittable = false;
|
|
1071
|
+
}
|
|
1072
|
+
__draw(canvas, options) {
|
|
1073
|
+
const { editor } = this;
|
|
1074
|
+
const { mask } = editor.mergeConfig;
|
|
1075
|
+
if (mask && editor.list.length) {
|
|
1076
|
+
const { rect } = editor.editBox;
|
|
1077
|
+
const { width, height } = rect.__;
|
|
1078
|
+
canvas.resetTransform();
|
|
1079
|
+
canvas.fillWorld(canvas.bounds, mask);
|
|
1080
|
+
canvas.setWorld(rect.__world, options.matrix);
|
|
1081
|
+
canvas.clearRect(0, 0, width, height);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
destroy() {
|
|
1085
|
+
this.editor = null;
|
|
1086
|
+
super.destroy();
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1054
1090
|
const filterStyle = `
|
|
1055
1091
|
<feOffset dy="1"/>
|
|
1056
1092
|
<feGaussianBlur stdDeviation="1.5"/>
|
|
@@ -1289,10 +1325,11 @@ class Editor extends Group {
|
|
|
1289
1325
|
this.editBox = new EditBox(this);
|
|
1290
1326
|
this.editToolList = {};
|
|
1291
1327
|
this.selector = new EditSelect(this);
|
|
1328
|
+
this.editMask = new EditMask(this);
|
|
1292
1329
|
this.targetEventIds = [];
|
|
1293
1330
|
if (userConfig)
|
|
1294
1331
|
this.config = DataHelper.default(userConfig, this.config);
|
|
1295
|
-
this.addMany(this.selector, this.editBox);
|
|
1332
|
+
this.addMany(this.editMask, this.selector, this.editBox);
|
|
1296
1333
|
}
|
|
1297
1334
|
select(target) {
|
|
1298
1335
|
this.target = target;
|
package/dist/editor.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PathCommandMap as t,MatrixHelper as e,Leaf as i,Text as s,Path as o,Line as n,Polygon as r,Group as a,Box as h,Event as l,defineKey as d,UI as c,Paint as g,Rect as u,Answer as f,Bounds as p,LeafList as m,PointHelper as v,AroundHelper as y,Direction9 as _,MathHelper as b,Matrix as L,Debug as w,DataHelper as E,LeafHelper as k,RenderEvent as x,getPointData as O,Creator as M}from"@leafer-ui/draw";import{PointerEvent as S,DragEvent as T,MoveEvent as P,ZoomEvent as V,RotateEvent as C,KeyEvent as I}from"@leafer-ui/core";const{M:H,L:R,C:B,Q:D,Z:A,N:z,D:Z,X:W,G:F,F:G,O:U,P:X,U:Y}=t,N={scale(t,e,i){if(!t)return;let s,o=0,n=t.length;for(;o<n;)switch(s=t[o],s){case H:case R:j(t,e,i,o,1),o+=3;break;case B:j(t,e,i,o,3),o+=7;break;case D:j(t,e,i,o,2),o+=5;break;case A:o+=1;break;case z:j(t,e,i,o,2),o+=5;break;case Z:j(t,e,i,o,2),o+=9;break;case W:j(t,e,i,o,2),o+=6;break;case F:j(t,e,i,o,2),o+=9;break;case G:j(t,e,i,o,2),o+=5;break;case U:t[o]=F,t.splice(o+4,0,t[o+3],0),j(t,e,i,o,2),o+=9,n+=2;break;case X:t[o]=G,t.splice(o+4,0,t[o+3]),j(t,e,i,o,2),o+=5,n+=1;break;case Y:j(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let n=o?s+1:0,r=o?n+2*o:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:j}=N,K=e.get();function $(t,e,i){t.pathInputed?Q(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function q(t,e,i){const{width:s,height:o}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=o*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=s*(i-e)/2)}function Q(t,e,i){N.scale(t.__.path,e,i),t.path=t.__.path}function J(t,e,i){N.scalePoints(t.__.points,e,i),t.points=t.__.points}function tt(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)K.a=e,K.d=i,s[t].transform(K,!0)}function et(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function it(t){return t?t instanceof Array?t:[t]:[]}i.prototype.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},i.prototype.__scaleResize=function(t,e){$(this,t,e)},s.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?q(this,t,e):$(this,t,e)},o.prototype.__scaleResize=function(t,e){Q(this,t,e)},n.prototype.__scaleResize=function(t,e){this.pathInputed?Q(this,t,e):this.points?J(this,t,e):this.width*=t},r.prototype.__scaleResize=function(t,e){this.pathInputed?Q(this,t,e):this.points?J(this,t,e):$(this,t,e)},a.prototype.__scaleResize=function(t,e){tt(this,t,e)},h.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?tt(this,t,e):($(this,t,e),this.__.resizeChildren&&tt(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class st extends l{get list(){return it(this.value)}get oldList(){return it(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}st.SELECT="editor.select",st.HOVER="editor.hover";class ot extends st{constructor(t,e){super(t,e)}}ot.MOVE="editor.move";class nt extends st{constructor(t,e){super(t,e)}}nt.SCALE="editor.scale";class rt extends st{constructor(t,e){super(t,e)}}rt.ROTATE="editor.rotate";class at extends st{constructor(t,e){super(t,e)}}function ht(t){return(e,i)=>{const s="_"+i;d(e,i,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}at.SKEW="editor.skew";const lt=e.get(),{abs:dt}=Math,{copy:ct,scale:gt}=e;class ut extends c{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,e){const{list:i}=this;if(i.length){let s;const{stroke:o,strokeWidth:n,fill:r}=this.__,{bounds:a}=e;for(let h=0;h<i.length;h++)if(s=i[h],a&&a.hit(s.__world,e.matrix)){const i=dt(s.__world.scaleX),a=dt(s.__world.scaleY);if(i!==a){ct(lt,s.__world),gt(lt,1/i,1/a),t.setWorld(lt,e.matrix),t.beginPath(),this.__.strokeWidth=n;const{x:o,y:r,width:h,height:l}=s.__layout.boxBounds;t.rect(o*i,r*a,h*i,l*a)}else t.setWorld(s.__world,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=n/dt(s.__world.scaleX);o&&("string"==typeof o?g.stroke(o,this,t):g.strokes(o,this,t)),r&&("string"==typeof r?g.fill(r,this,t):g.fills(r,this,t))}this.__.strokeWidth=n}}destroy(){this.target=null,super.destroy()}}et([ht((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],ut.prototype,"target",void 0);class ft extends a{constructor(t){super(t),this.strokeArea=new u({strokeAlign:"center"}),this.fillArea=new u,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:o}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:o},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:pt,Yes:mt,NoAndSkip:vt,YesAndSkip:yt}=f,_t={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?yt:vt;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?yt:pt;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return mt}return pt}return t.isBranch?vt:pt}},{findOne:bt}=_t;class Lt extends a{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new ut,this.targetStroker=new ut,this.bounds=new p,this.selectArea=new ft,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,s/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInner(this);this.bounds.set(o,n),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:n},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new m(e.app.find(_t.findBounds,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),o.length){const t=[];this.originList.forEach((e=>{o.has(e)||t.push(e)})),o.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!bt(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new m(this.editor.editBox.rect)};return bt(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):bt(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(st.HOVER,this.onHover,this),t.on_(st.SELECT,this.onSelect,this),e.on_(S.MOVE,this.onPointerMove,this),e.on_(S.BEFORE_DOWN,this.onBeforeDown,this),e.on_(S.TAP,this.onTap,this),e.on_(T.START,this.onDragStart,this),e.on_(T.DRAG,this.onDrag,this),e.on_(T.END,this.onDragEnd,this),e.on_(P.MOVE,this.onAutoMove,this),e.on_([V.ZOOM,P.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:wt,top:Et,topRight:kt,right:xt,bottomRight:Ot,bottom:Mt,bottomLeft:St,left:Tt}=_,{toPoint:Pt}=y,Vt={getScaleData(t,e,i,s,o){let n,r={},a=1,h=1;const{width:l,height:d}=t;o&&(i.x*=2,i.y*=2),Math.abs(i.x)===l&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+l)/l,u=(i.y+d)/d,f=(-i.x+l)/l;switch(e){case Et:h=c,n="bottom";break;case xt:a=g,n="left";break;case Mt:h=u,n="top";break;case Tt:a=f,n="right";break;case wt:h=c,a=f,n="bottom-right";break;case kt:h=c,a=g,n="bottom-left";break;case Ot:h=u,a=g,n="top-left";break;case St:h=u,a=f,n="top-right"}if(s){if(!("corner"===s&&e%2)){const t=Math.sqrt(Math.abs(a*h));a=a<0?-t:t,h=h<0?-t:t}}return Pt(o||n,t,r),{origin:r,scaleX:a,scaleY:h,direction:e,lockRatio:s,around:o}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case wt:n="bottom-right";break;case kt:n="bottom-left";break;case Ot:n="top-left";break;case St:n="top-right";break;default:n="center"}return Pt(o||n,t,r),{origin:r,rotation:v.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case Et:n={x:.5,y:0},o="bottom",a=1;break;case Mt:n={x:.5,y:1},o="top",a=1;break;case Tt:n={x:0,y:.5},o="right",h=1;break;case xt:n={x:1,y:.5},o="left",h=1}const{x:l,y:d,width:c,height:g}=t;n.x=l+n.x*c,n.y=d+n.y*g,Pt(s||o,t,r);const u=v.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-u:h=u,{origin:r,skewX:a,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Tt:t=xt;break;case wt:t=kt;break;case St:t=Ot;break;case xt:t=Tt;break;case kt:t=wt;break;case Ot:t=St}if(i)switch(t){case Et:t=Mt;break;case wt:t=St;break;case kt:t=Ot;break;case Mt:t=Et;break;case St:t=wt;break;case Ot:t=kt}return t}},Ct={};function It(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;let{rotation:o}=i;const{resizeCursor:n,rotateCursor:r,skewCursor:a,resizeable:h,rotateable:l,skewable:d}=t.mergeConfig,{pointType:c}=s,{flippedX:g,flippedY:u}=i;let f="resize"===c;f&&l&&(e.metaKey||e.ctrlKey||!h)&&(f=!1);const p=d&&!f&&"resize-line"===s.name?a:f?n:r;o+=45*(Vt.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(b.formatRotation(o,!0)/2);const{url:m,x:v,y:y}=p,_=m+o;Ct[_]?s.cursor=Ct[_]:Ct[_]=s.cursor={url:Rt(m,o),x:v,y:y}}function Ht(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function Rt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Bt extends h{}const Dt=["top","right","bottom","left"];class At extends a{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new a,this.rect=new h({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Bt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new a({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:n,resizeLines:r,rect:a,circle:h,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Bt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Bt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Bt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);l.add(h),this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,l,...r,...o),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:o,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:h}=t,l=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:l[t/2%l.length])),t%2||(c.rotation=t/2*90);o.set(this.getPointStyle(t.rotatePoint||l[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i&&h,e.syncEventer=i&&h?s:null,this.app.interaction.bottomList=i&&h?[{target:s,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:e}=this.editor,{width:i,height:s}=t,{rect:o,circle:n,resizePoints:r,rotatePoints:a,resizeLines:h}=this,{middlePoint:l,resizeable:d,rotateable:c,hideOnSmall:g}=e,u="number"==typeof g?g:10,f=!(g&&i<u&&s<u);let p,m,v,_={};for(let o=0;o<8;o++)y.toPoint(y.directionData[o],t,_),m=r[o],p=a[o],v=h[Math.floor(o/2)],m.set(_),p.set(_),v.set(_),m.visible=v.visible=f&&!(!d&&!c),p.visible=f&&c&&d&&!e.rotatePoint,o%2&&(m.visible=p.visible=f&&!!l,(o+1)/2%2?(v.width=i,m.width>i-30&&(m.visible=!1)):(v.height=s,m.rotation=90,m.width>s-30&&(m.visible=!1)));n.visible=f&&c&&!!e.rotatePoint,o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0}));const b=f&&(n.visible||this.buttons.children.length>1);this.buttons.visible=b,b&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:a}=this;let h=Dt.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?Vt.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h,d=e[2*l+1],c=l%2,g=l&&3!==l?1:-1,u=(o+(h%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),s&&(t.rotation=90*(l-h),t.scaleX=r?-1:1,t.scaleY=a?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:n}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:o,height:o,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=this.app.interaction.bottomList=null)}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),It(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(T.START,this.onDragStart,this),t.on_(T.DRAG,this.onDrag,this),t.on_(T.END,this.onDragEnd,this),t.on_(S.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(S.ENTER,(e=>{this.enterPoint=t,It(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(st.SELECT,this.onSelect,this),t.on_(T.START,this.onDragStart,this),t.on_(T.DRAG,e.onMove,e),t.on_(T.END,this.onDragEnd,this),t.on_(V.BEFORE_ZOOM,e.onScale,e,!0),t.on_(C.BEFORE_ROTATE,e.onRotate,e,!0),t.on_(S.ENTER,(()=>Ht(e))),t.on_(S.DOUBLE_TAP,this.onDoubleTap,this),t.on_(S.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const zt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Zt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${zt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${zt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${zt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};function Wt(t){const{simulateTarget:e,leafList:i}=t,{x:s,y:o,width:n,height:r}=(new p).setListWithFn(i.list,(t=>t.worldBoxBounds)),a=e.parent=i.list[0].leafer.zoomLayer,{scaleX:h,scaleY:l,e:d,f:c}=a.__world;e.reset({x:(s-d)/h,y:(o-c)/l,width:n/h,height:r/l})}const Ft=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Gt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Ut={group(t,e,i){t.sort(Gt);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new a(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(Ft);const r=new L(e.worldTransform);return r.divideParent(o.worldTransform),n.setTransform(r),n.editable=!0,n.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(n))),s.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(Ft),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Gt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Xt=w.get("EditToolCreator");function Yt(){return t=>{jt.register(t)}}const Nt=Yt,jt={list:{},register(t){const{tag:e}=t.prototype;Kt[e]?Xt.repeat(e):Kt[e]=t},get:(t,e)=>new Kt[t](e)},{list:Kt}=jt;class $t extends st{constructor(t,e){super(t,e)}}$t.BEFORE_OPEN="innerEditor.before_open",$t.OPEN="innerEditor.open",$t.BEFORE_CLOSE="innerEditor.before_close",$t.CLOSE="innerEditor.close";class qt extends st{constructor(t,e){super(t,e)}}qt.GROUP="editor.group",qt.BEFORE_UNGROUP="editor.before_ungroup",qt.UNGROUP="editor.ungroup",qt.OPEN="editor.open_group",qt.CLOSE="editor.close_group";class Qt extends a{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=Zt,this.leafList=new m,this.openedGroupList=new m,this.simulateTarget=new u({visible:!1}),this.editBox=new At(this),this.editToolList={},this.selector=new Lt(this),this.targetEventIds=[],t&&(this.config=E.default(t,this.config)),this.addMany(this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&Wt(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||jt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(T.getValidMove(this.element,this.dragStartPoint,e))}onScale(t){const{element:e}=this;if(t instanceof V)"zoom"===this.mergeConfig.resizeable&&(t.stop(),this.scaleOf(e.getInnerPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;let{around:s,lockRatio:o}=this.mergeConfig;(t.shiftKey||e.lockRatio)&&(o=!0);const n=Vt.getScaleData(e.boxBounds,i,t.getInnerMove(e),o,Vt.getAround(s,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:e,around:i,rotateGap:s}=this.mergeConfig,{direction:o,name:n}=t.current;if(e&&"resize-line"===n)return this.onSkew(t);const{element:r}=this;let a,h;if(t instanceof C){if("rotate"!==this.mergeConfig.rotateable)return;t.stop(),h=t.rotation,a=r.getInnerPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},s=Vt.getRotateData(r.boxBounds,o,t.getInner(r),r.getInnerPoint(e),t.shiftKey?null:i||"center");h=s.rotation,a=s.origin}h=b.getGapRotation(h,s,r.rotation),h&&(r.scaleX*r.scaleY<0&&(h=-h),this.rotateOf(a,b.float(h,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=Vt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Vt.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),o=new ot(ot.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=e.getWorldPoint(t.origin),s=new nt(nt.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(s),this.emitEvent(s)}scaleOf(t,e,i=e,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:o}=this,n=o.getWorldPoint(k.getInnerOrigin(o,t));let r;if(this.multiple){const s=new L(o.worldTransform);o.scaleOf(t,e,i),r=new L(o.worldTransform).divide(s)}const a=new nt(nt.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,s=i.getWorldPoint(k.getInnerOrigin(i,t));let o;if(this.multiple){const s=new L(i.worldTransform);i.rotateOf(t,e),o=new L(i.worldTransform).divide(s)}const n=new rt(rt.ROTATE,{target:i,editor:this,worldOrigin:s,rotation:e,transform:o});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:o}=this,n=o.getWorldPoint(k.getInnerOrigin(o,t));let r;if(this.multiple){const s=new L(o.worldTransform);o.skewOf(t,e,i),r=new L(o.worldTransform).divide(s)}const a=new at(at.SKEW,{target:o,editor:this,skewX:e,skewY:i,transform:r,worldOrigin:n});this.editTool.onSkew(a),this.emitEvent(a)}group(t){return this.multiple&&(this.target=Ut.group(this.list,this.element,t),this.emitGroupEvent(qt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(qt.BEFORE_UNGROUP,t))),this.target=Ut.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(qt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(qt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(qt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!k.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new qt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&jt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||jt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent($t.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent($t.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent($t.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent($t.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new $t(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(Ut.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Ut.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[t.on_(x.START,this.update,this),t.on_([I.HOLD,I.UP],(t=>{It(this,t)})),t.on_(I.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}et([ht((function(t,e){t.emitEvent(new st(st.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Qt.prototype,"hoverTarget",void 0),et([ht((function(t,e){const{target:i}=t;i?t.leafList=i instanceof m?i:new m(i):t.leafList.reset(),t.emitEvent(new st(st.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&Wt(t),Ht(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],Qt.prototype,"target",void 0);class Jt{static registerInnerEditor(){jt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new a,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let te=class extends Jt{static registerEditTool(){jt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:n}=s;o.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(o,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:n,list:r}=o;n.lockLayout(),r.forEach((t=>{const n="scale"!==o.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(s,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(o,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:s}=t;t.multiple&&i.parent.updateLayout();const{x:o,y:n,scaleX:r,scaleY:a,rotation:h,skewX:l,skewY:d,width:c,height:g}=s.getLayoutBounds("box",t,!0);e.set({x:o,y:n,scaleX:r,scaleY:a,rotation:h,skewX:l,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};te=et([Yt()],te);const{left:ee,right:ie}=_,{move:se,copy:oe}=v;let ne=class extends te{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,n=t.target,r=i===ee;if(n.pathInputed){const{path:t}=n.__,{from:i,to:a}=this.getFromToByPath(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[1]=i.x,t[2]=i.y,t[4]=a.x,t[5]=a.y,n.path=t}else if(n.points){const{points:t}=n,{from:i,to:a}=this.getFromToByPoints(t);this.dragPoint(i,a,r,o,this.getInnerMove(n,e,s)),t[0]=i.x,t[1]=i.y,t[2]=a.x,t[3]=a.y,n.points=t}else{const t=O(),{toPoint:i}=n;n.rotation=0,this.dragPoint(t,i,r,o,this.getInnerMove(n,e,s)),n.getLocalPointByInner(t,null,null,!0),n.getLocalPointByInner(i,null,null,!0),n.x=t.x,n.y=t.y,n.getInnerPointByLocal(i,null,null,!0),n.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(se(t,n,r),s&&se(e,-n,-r)):(s&&se(t,-n,-r),se(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),o.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),oe(s[7],i),oe(e[7],i),oe(s[3],a),oe(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===ee||t===ie,s[t].visible=a,e[t].visible=!r&&a}};ne=et([Yt()],ne),M.editor=function(t){return new Qt(t)},c.setEditConfig=function(t){d(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},c.setEditOuter=function(t){d(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},c.setEditInner=function(t){d(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{At as EditBox,Vt as EditDataHelper,Bt as EditPoint,Lt as EditSelect,_t as EditSelectHelper,te as EditTool,jt as EditToolCreator,Qt as Editor,st as EditorEvent,qt as EditorGroupEvent,Ut as EditorHelper,ot as EditorMoveEvent,rt as EditorRotateEvent,nt as EditorScaleEvent,at as EditorSkewEvent,Jt as InnerEditor,$t as InnerEditorEvent,ne as LineEditTool,N as PathScaler,ft as SelectArea,ut as Stroker,Yt as registerEditTool,Nt as registerInnerEditor,$ as scaleResize,q as scaleResizeFontSize,tt as scaleResizeGroup,Q as scaleResizePath,J as scaleResizePoints};
|
|
1
|
+
import{PathCommandMap as t,MatrixHelper as e,Leaf as i,Text as s,Path as o,Line as n,Polygon as r,Group as h,Box as a,Event as l,defineKey as d,UI as c,Paint as g,Rect as u,Answer as f,Bounds as p,LeafList as m,PointHelper as v,AroundHelper as _,Direction9 as y,MathHelper as b,Matrix as w,Debug as L,DataHelper as E,LeafHelper as k,RenderEvent as x,getPointData as O,Creator as M}from"@leafer-ui/draw";import{PointerEvent as S,DragEvent as T,MoveEvent as P,ZoomEvent as V,RotateEvent as C,KeyEvent as I}from"@leafer-ui/core";const{M:R,L:H,C:B,Q:D,Z:z,N:A,D:Z,X:W,G:F,F:G,O:U,P:X,U:Y}=t,N={scale(t,e,i){if(!t)return;let s,o=0,n=t.length;for(;o<n;)switch(s=t[o],s){case R:case H:j(t,e,i,o,1),o+=3;break;case B:j(t,e,i,o,3),o+=7;break;case D:j(t,e,i,o,2),o+=5;break;case z:o+=1;break;case A:j(t,e,i,o,2),o+=5;break;case Z:j(t,e,i,o,2),o+=9;break;case W:j(t,e,i,o,2),o+=6;break;case F:j(t,e,i,o,2),o+=9;break;case G:j(t,e,i,o,2),o+=5;break;case U:t[o]=F,t.splice(o+4,0,t[o+3],0),j(t,e,i,o,2),o+=9,n+=2;break;case X:t[o]=G,t.splice(o+4,0,t[o+3]),j(t,e,i,o,2),o+=5,n+=1;break;case Y:j(t,e,i,o,2),o+=6}},scalePoints(t,e,i,s,o){for(let n=o?s+1:0,r=o?n+2*o:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:j}=N,K=e.get();function $(t,e,i){t.pathInputed?Q(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function q(t,e,i){const{width:s,height:o}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=o*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=s*(i-e)/2)}function Q(t,e,i){N.scale(t.__.path,e,i),t.path=t.__.path}function J(t,e,i){N.scalePoints(t.__.points,e,i),t.points=t.__.points}function tt(t,e,i){const{children:s}=t;for(let t=0;t<s.length;t++)K.a=e,K.d=i,s[t].transform(K,!0)}const et=i.prototype;function it(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function st(t){return t?t instanceof Array?t:[t]:[]}et.scaleResize=function(t,e=t,i){const s=this;i||s.editConfig&&"scale"===s.editConfig.editSize?(s.scaleX*=t,s.scaleY*=e):(t<0&&(s.scaleX*=-1,t=-t),e<0&&(s.scaleY*=-1,e=-e),this.__scaleResize(t,e))},et.__scaleResize=function(t,e){$(this,t,e)},et.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},et.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},s.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?q(this,t,e):$(this,t,e)},o.prototype.__scaleResize=function(t,e){Q(this,t,e)},n.prototype.__scaleResize=function(t,e){this.pathInputed?Q(this,t,e):this.points?J(this,t,e):this.width*=t},r.prototype.__scaleResize=function(t,e){this.pathInputed?Q(this,t,e):this.points?J(this,t,e):$(this,t,e)},h.prototype.__scaleResize=function(t,e){tt(this,t,e)},a.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?tt(this,t,e):($(this,t,e),this.__.resizeChildren&&tt(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class ot extends l{get list(){return st(this.value)}get oldList(){return st(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}ot.SELECT="editor.select",ot.HOVER="editor.hover";class nt extends ot{constructor(t,e){super(t,e)}}nt.MOVE="editor.move";class rt extends ot{constructor(t,e){super(t,e)}}rt.SCALE="editor.scale";class ht extends ot{constructor(t,e){super(t,e)}}ht.ROTATE="editor.rotate";class at extends ot{constructor(t,e){super(t,e)}}function lt(t){return(e,i)=>{const s="_"+i;d(e,i,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}at.SKEW="editor.skew";const dt=e.get(),{abs:ct}=Math,{copy:gt,scale:ut}=e;class ft extends c{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,e){const{list:i}=this;if(i.length){let s;const{stroke:o,strokeWidth:n,fill:r}=this.__,{bounds:h}=e;for(let a=0;a<i.length;a++)if(s=i[a],h&&h.hit(s.__world,e.matrix)){const i=ct(s.__world.scaleX),h=ct(s.__world.scaleY);if(i!==h){gt(dt,s.__world),ut(dt,1/i,1/h),t.setWorld(dt,e.matrix),t.beginPath(),this.__.strokeWidth=n;const{x:o,y:r,width:a,height:l}=s.__layout.boxBounds;t.rect(o*i,r*h,a*i,l*h)}else t.setWorld(s.__world,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=n/ct(s.__world.scaleX);o&&("string"==typeof o?g.stroke(o,this,t):g.strokes(o,this,t)),r&&("string"==typeof r?g.fill(r,this,t):g.fills(r,this,t))}this.__.strokeWidth=n}}destroy(){this.target=null,super.destroy()}}it([lt((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],ft.prototype,"target",void 0);class pt extends h{constructor(t){super(t),this.strokeArea=new u({strokeAlign:"center"}),this.fillArea=new u,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:s,strokeWidth:o}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:s,strokeWidth:o},e||{})),this.fillArea.reset({visible:!e,fill:s,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:mt,Yes:vt,NoAndSkip:_t,YesAndSkip:yt}=f,bt={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?yt:_t;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?yt:mt;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return vt}return mt}return t.isBranch?_t:mt}},{findOne:wt}=bt;class Lt extends h{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new ft,this.targetStroker=new ft,this.bounds=new p,this.selectArea=new pt,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:s,hoverStyle:o}=t.mergeConfig;this.hoverStroker.setTarget(s?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},o||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:s}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,s/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInner(this);this.bounds.set(o,n),this.selectArea.setStyle({visible:!0,stroke:i,x:o,y:n},s),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new m(e.app.find(bt.findBounds,s));if(this.bounds.width=i.x,this.bounds.height=i.y,this.selectArea.setBounds(s.get()),o.length){const t=[];this.originList.forEach((e=>{o.has(e)||t.push(e)})),o.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==e.list.length||e.list.some(((e,i)=>e!==t[i])))&&(e.target=t)}else e.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!wt(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new m(this.editor.editBox.rect)};return wt(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):wt(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(ot.HOVER,this.onHover,this),t.on_(ot.SELECT,this.onSelect,this),e.on_(S.MOVE,this.onPointerMove,this),e.on_(S.BEFORE_DOWN,this.onBeforeDown,this),e.on_(S.TAP,this.onTap,this),e.on_(T.START,this.onDragStart,this),e.on_(T.DRAG,this.onDrag,this),e.on_(T.END,this.onDragEnd,this),e.on_(P.MOVE,this.onAutoMove,this),e.on_([V.ZOOM,P.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Et,top:kt,topRight:xt,right:Ot,bottomRight:Mt,bottom:St,bottomLeft:Tt,left:Pt}=y,{toPoint:Vt}=_,Ct={getScaleData(t,e,i,s,o){let n,r={},h=1,a=1;const{width:l,height:d}=t;o&&(i.x*=2,i.y*=2),Math.abs(i.x)===l&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+l)/l,u=(i.y+d)/d,f=(-i.x+l)/l;switch(e){case kt:a=c,n="bottom";break;case Ot:h=g,n="left";break;case St:a=u,n="top";break;case Pt:h=f,n="right";break;case Et:a=c,h=f,n="bottom-right";break;case xt:a=c,h=g,n="bottom-left";break;case Mt:a=u,h=g,n="top-left";break;case Tt:a=u,h=f,n="top-right"}if(s){if(!("corner"===s&&e%2)){const t=Math.sqrt(Math.abs(h*a));h=h<0?-t:t,a=a<0?-t:t}}return Vt(o||n,t,r),{origin:r,scaleX:h,scaleY:a,direction:e,lockRatio:s,around:o}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case Et:n="bottom-right";break;case xt:n="bottom-left";break;case Mt:n="top-left";break;case Tt:n="top-right";break;default:n="center"}return Vt(o||n,t,r),{origin:r,rotation:v.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},h=0,a=0;switch(e){case kt:n={x:.5,y:0},o="bottom",h=1;break;case St:n={x:.5,y:1},o="top",h=1;break;case Pt:n={x:0,y:.5},o="right",a=1;break;case Ot:n={x:1,y:.5},o="left",a=1}const{x:l,y:d,width:c,height:g}=t;n.x=l+n.x*c,n.y=d+n.y*g,Vt(s||o,t,r);const u=v.getRotation(n,r,{x:n.x+(h?i.x:0),y:n.y+(a?i.y:0)});return h?h=-u:a=u,{origin:r,skewX:h,skewY:a}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Pt:t=Ot;break;case Et:t=xt;break;case Tt:t=Mt;break;case Ot:t=Pt;break;case xt:t=Et;break;case Mt:t=Tt}if(i)switch(t){case kt:t=St;break;case Et:t=Tt;break;case xt:t=Mt;break;case St:t=kt;break;case Tt:t=Et;break;case Mt:t=xt}return t}},It={};function Rt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;let{rotation:o}=i;const{resizeCursor:n,rotateCursor:r,skewCursor:h,resizeable:a,rotateable:l,skewable:d}=t.mergeConfig,{pointType:c}=s,{flippedX:g,flippedY:u}=i;let f="resize"===c;f&&l&&(e.metaKey||e.ctrlKey||!a)&&(f=!1);const p=d&&!f&&"resize-line"===s.name?h:f?n:r;o+=45*(Ct.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(b.formatRotation(o,!0)/2);const{url:m,x:v,y:_}=p,y=m+o;It[y]?s.cursor=It[y]:It[y]=s.cursor={url:Bt(m,o),x:v,y:_}}function Ht(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function Bt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Dt extends a{}const zt=["top","right","bottom","left"];class At extends h{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new h,this.rect=new a({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Dt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new h({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:s,resizePoints:o,rotatePoints:n,resizeLines:r,rect:h,circle:a,buttons:l}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let s=0;s<8;s++)t=new Dt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Dt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Dt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);l.add(a),this.listenPointEvents(a,"rotate",2),s.addMany(...n,h,l,...r,...o),this.add(s)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:s,circle:o,resizePoints:n}=this,{stroke:r,strokeWidth:h,moveable:a}=t,l=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:l[t/2%l.length])),t%2||(c.rotation=t/2*90);o.set(this.getPointStyle(t.rotatePoint||l[0])),s.set(Object.assign({stroke:r,strokeWidth:h},t.rect||{})),s.hittable=!i&&a,e.syncEventer=i&&a?s:null,this.app.interaction.bottomList=i&&a?[{target:s,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:e}=this.editor,{width:i,height:s}=t,{rect:o,circle:n,resizePoints:r,rotatePoints:h,resizeLines:a}=this,{middlePoint:l,resizeable:d,rotateable:c,hideOnSmall:g}=e,u="number"==typeof g?g:10,f=!(g&&i<u&&s<u);let p,m,v,y={};for(let o=0;o<8;o++)_.toPoint(_.directionData[o],t,y),m=r[o],p=h[o],v=a[Math.floor(o/2)],m.set(y),p.set(y),v.set(y),m.visible=v.visible=f&&!(!d&&!c),p.visible=f&&c&&d&&!e.rotatePoint,o%2&&(m.visible=p.visible=f&&!!l,(o+1)/2%2?(v.width=i,m.width>i-30&&(m.visible=!1)):(v.height=s,m.rotation=90,m.width>s-30&&(m.visible=!1)));n.visible=f&&c&&!!e.rotatePoint,o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0}));const b=f&&(n.visible||this.buttons.children.length>1);this.buttons.visible=b,b&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:h}=this;let a=zt.indexOf(i);(a%2&&r||(a+1)%2&&h)&&s&&(a=(a+2)%4);const l=s?Ct.getRotateDirection(a,this.flippedOne?this.rotation:-this.rotation,4):a,d=e[2*l+1],c=l%2,g=l&&3!==l?1:-1,u=(o+(a%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),s&&(t.rotation=90*(l-a),t.scaleX=r?-1:1,t.scaleY=h?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:s,pointSize:o,pointRadius:n}=this.editor.mergeConfig,r={fill:s,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:o,height:o,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),Rt(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(T.START,this.onDragStart,this),t.on_(T.DRAG,this.onDrag,this),t.on_(T.END,this.onDragEnd,this),t.on_(S.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(S.ENTER,(e=>{this.enterPoint=t,Rt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(ot.SELECT,this.onSelect,this),t.on_(T.START,this.onDragStart,this),t.on_(T.DRAG,e.onMove,e),t.on_(T.END,this.onDragEnd,this),t.on_(V.BEFORE_ZOOM,e.onScale,e,!0),t.on_(C.BEFORE_ROTATE,e.onRotate,e,!0),t.on_(S.ENTER,(()=>Ht(e))),t.on_(S.DOUBLE_TAP,this.onDoubleTap,this),t.on_(S.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class Zt extends c{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:s}=i.mergeConfig;if(s&&i.list.length){const{rect:o}=i.editBox,{width:n,height:r}=o.__;t.resetTransform(),t.fillWorld(t.bounds,s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const Wt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',Ft={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${Wt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${Wt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${Wt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};function Gt(t){const{simulateTarget:e,leafList:i}=t,{x:s,y:o,width:n,height:r}=(new p).setListWithFn(i.list,(t=>t.worldBoxBounds)),h=e.parent=i.list[0].leafer.zoomLayer,{scaleX:a,scaleY:l,e:d,f:c}=h.__world;e.reset({x:(s-d)/a,y:(o-c)/l,width:n/a,height:r/l})}const Ut=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Xt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),Yt={group(t,e,i){t.sort(Xt);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new h(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(Ut);const r=new w(e.worldTransform);return r.divideParent(o.worldTransform),n.setTransform(r),n.editable=!0,n.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(n))),s.unlockLayout(),n},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:s}=t;for(;s.length;)i.push(s[0]),s[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(Ut),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Xt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Nt=L.get("EditToolCreator");function jt(){return t=>{$t.register(t)}}const Kt=jt,$t={list:{},register(t){const{tag:e}=t.prototype;qt[e]?Nt.repeat(e):qt[e]=t},get:(t,e)=>new qt[t](e)},{list:qt}=$t;class Qt extends ot{constructor(t,e){super(t,e)}}Qt.BEFORE_OPEN="innerEditor.before_open",Qt.OPEN="innerEditor.open",Qt.BEFORE_CLOSE="innerEditor.before_close",Qt.CLOSE="innerEditor.close";class Jt extends ot{constructor(t,e){super(t,e)}}Jt.GROUP="editor.group",Jt.BEFORE_UNGROUP="editor.before_ungroup",Jt.UNGROUP="editor.ungroup",Jt.OPEN="editor.open_group",Jt.CLOSE="editor.close_group";class te extends h{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=Ft,this.leafList=new m,this.openedGroupList=new m,this.simulateTarget=new u({visible:!1}),this.editBox=new At(this),this.editToolList={},this.selector=new Lt(this),this.editMask=new Zt(this),this.targetEventIds=[],t&&(this.config=E.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&Gt(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||$t.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(T.getValidMove(this.element,this.dragStartPoint,e))}onScale(t){const{element:e}=this;if(t instanceof V)"zoom"===this.mergeConfig.resizeable&&(t.stop(),this.scaleOf(e.getInnerPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;let{around:s,lockRatio:o}=this.mergeConfig;(t.shiftKey||e.lockRatio)&&(o=!0);const n=Ct.getScaleData(e.boxBounds,i,t.getInnerMove(e),o,Ct.getAround(s,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:e,around:i,rotateGap:s}=this.mergeConfig,{direction:o,name:n}=t.current;if(e&&"resize-line"===n)return this.onSkew(t);const{element:r}=this;let h,a;if(t instanceof C){if("rotate"!==this.mergeConfig.rotateable)return;t.stop(),a=t.rotation,h=r.getInnerPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},s=Ct.getRotateData(r.boxBounds,o,t.getInner(r),r.getInnerPoint(e),t.shiftKey?null:i||"center");a=s.rotation,h=s.origin}a=b.getGapRotation(a,s,r.rotation),a&&(r.scaleX*r.scaleY<0&&(a=-a),this.rotateOf(h,b.float(a,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=Ct.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),Ct.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),o=new nt(nt.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=e.getWorldPoint(t.origin),s=new rt(rt.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(s),this.emitEvent(s)}scaleOf(t,e,i=e,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:o}=this,n=o.getWorldPoint(k.getInnerOrigin(o,t));let r;if(this.multiple){const s=new w(o.worldTransform);o.scaleOf(t,e,i),r=new w(o.worldTransform).divide(s)}const h=new rt(rt.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(h),this.emitEvent(h)}rotateOf(t,e){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:i}=this,s=i.getWorldPoint(k.getInnerOrigin(i,t));let o;if(this.multiple){const s=new w(i.worldTransform);i.rotateOf(t,e),o=new w(i.worldTransform).divide(s)}const n=new ht(ht.ROTATE,{target:i,editor:this,worldOrigin:s,rotation:e,transform:o});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:o}=this,n=o.getWorldPoint(k.getInnerOrigin(o,t));let r;if(this.multiple){const s=new w(o.worldTransform);o.skewOf(t,e,i),r=new w(o.worldTransform).divide(s)}const h=new at(at.SKEW,{target:o,editor:this,skewX:e,skewY:i,transform:r,worldOrigin:n});this.editTool.onSkew(h),this.emitEvent(h)}group(t){return this.multiple&&(this.target=Yt.group(this.list,this.element,t),this.emitGroupEvent(Jt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Jt.BEFORE_UNGROUP,t))),this.target=Yt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Jt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Jt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Jt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!k.hasParent(e,t)))&&e.push(t)))),e.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Jt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&$t.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||$t.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Qt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Qt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Qt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Qt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new Qt(t,{editTarget:i,innerEditor:e});this.emitEvent(s),i.emitEvent(s)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(Yt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Yt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[t.on_(x.START,this.update,this),t.on_([I.HOLD,I.UP],(t=>{Rt(this,t)})),t.on_(I.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}it([lt((function(t,e){t.emitEvent(new ot(ot.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],te.prototype,"hoverTarget",void 0),it([lt((function(t,e){const{target:i}=t;i?t.leafList=i instanceof m?i:new m(i):t.leafList.reset(),t.emitEvent(new ot(ot.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&Gt(t),Ht(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],te.prototype,"target",void 0);class ee{static registerInnerEditor(){$t.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new h,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}let ie=class extends ee{static registerEditTool(){$t.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:s}=t,{app:o,list:n}=s;o.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),o.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:h}=n;r.lockLayout(),h.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.scaleOfWorld(o,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:s,editor:o}=t,{app:n,list:r}=o;n.lockLayout(),r.forEach((t=>{const n="scale"!==o.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(s,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:s,worldOrigin:o,editor:n}=t,{app:r,list:h}=n;r.lockLayout(),h.forEach((t=>{const r="scale"!==n.getEditSize(t);s?t.transformWorld(s,r):t.skewOfWorld(o,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:s}=t;t.multiple&&i.parent.updateLayout();const{x:o,y:n,scaleX:r,scaleY:h,rotation:a,skewX:l,skewY:d,width:c,height:g}=s.getLayoutBounds("box",t,!0);e.set({x:o,y:n,scaleX:r,scaleY:h,rotation:a,skewX:l,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};ie=it([jt()],ie);const{left:se,right:oe}=y,{move:ne,copy:re}=v;let he=class extends ie{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:e,direction:i,lockRatio:s,around:o}=t,n=t.target,r=i===se;if(n.pathInputed){const{path:t}=n.__,{from:i,to:h}=this.getFromToByPath(t);this.dragPoint(i,h,r,o,this.getInnerMove(n,e,s)),t[1]=i.x,t[2]=i.y,t[4]=h.x,t[5]=h.y,n.path=t}else if(n.points){const{points:t}=n,{from:i,to:h}=this.getFromToByPoints(t);this.dragPoint(i,h,r,o,this.getInnerMove(n,e,s)),t[0]=i.x,t[1]=i.y,t[2]=h.x,t[3]=h.y,n.points=t}else{const t=O(),{toPoint:i}=n;n.rotation=0,this.dragPoint(t,i,r,o,this.getInnerMove(n,e,s)),n.getLocalPointByInner(t,null,null,!0),n.getLocalPointByInner(i,null,null,!0),n.x=t.x,n.y=t.y,n.getInnerPointByLocal(i,null,null,!0),n.toPoint=i}}getInnerMove(t,e,i){const s=e.getInnerMove(t);return i&&(Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0),s}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(ne(t,n,r),s&&ne(e,-n,-r)):(s&&ne(t,-n,-r),ne(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:s,rect:o}=t,n=this.editor.element;let r,h;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:h}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(h,h,!1,t),o.pen.clearPath().moveTo(i.x,i.y).lineTo(h.x,h.y),re(s[7],i),re(e[7],i),re(s[3],h),re(e[3],h)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),h=t===se||t===oe,s[t].visible=h,e[t].visible=!r&&h}};he=it([jt()],he),M.editor=function(t){return new te(t)},c.setEditConfig=function(t){d(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},c.setEditOuter=function(t){d(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},c.setEditInner=function(t){d(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{At as EditBox,Ct as EditDataHelper,Dt as EditPoint,Lt as EditSelect,bt as EditSelectHelper,ie as EditTool,$t as EditToolCreator,te as Editor,ot as EditorEvent,Jt as EditorGroupEvent,Yt as EditorHelper,nt as EditorMoveEvent,ht as EditorRotateEvent,rt as EditorScaleEvent,at as EditorSkewEvent,ee as InnerEditor,Qt as InnerEditorEvent,he as LineEditTool,N as PathScaler,pt as SelectArea,ft as Stroker,jt as registerEditTool,Kt as registerInnerEditor,$ as scaleResize,q as scaleResizeFontSize,tt as scaleResizeGroup,Q as scaleResizePath,J as scaleResizePoints};
|
package/dist/editor.js
CHANGED
|
@@ -121,7 +121,8 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
draw.Leaf.prototype
|
|
124
|
+
const leaf = draw.Leaf.prototype;
|
|
125
|
+
leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
|
|
125
126
|
const data = this;
|
|
126
127
|
if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
|
|
127
128
|
data.scaleX *= scaleX;
|
|
@@ -135,9 +136,17 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
135
136
|
this.__scaleResize(scaleX, scaleY);
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
|
|
139
|
+
leaf.__scaleResize = function (scaleX, scaleY) {
|
|
139
140
|
scaleResize(this, scaleX, scaleY);
|
|
140
141
|
};
|
|
142
|
+
leaf.resizeWidth = function (width) {
|
|
143
|
+
const scale = width / this.getBounds('box', 'local').width;
|
|
144
|
+
this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
|
|
145
|
+
};
|
|
146
|
+
leaf.resizeHeight = function (height) {
|
|
147
|
+
const scale = height / this.getBounds('box', 'local').height;
|
|
148
|
+
this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
|
|
149
|
+
};
|
|
141
150
|
draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
|
|
142
151
|
if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
|
|
143
152
|
scaleResizeFontSize(this, scaleX, scaleY);
|
|
@@ -945,8 +954,11 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
945
954
|
return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
|
|
946
955
|
}
|
|
947
956
|
onSelect(e) {
|
|
948
|
-
if (e.oldList.length === 1)
|
|
949
|
-
e.oldList[0].syncEventer =
|
|
957
|
+
if (e.oldList.length === 1) {
|
|
958
|
+
e.oldList[0].syncEventer = null;
|
|
959
|
+
if (this.app)
|
|
960
|
+
this.app.interaction.bottomList = null;
|
|
961
|
+
}
|
|
950
962
|
}
|
|
951
963
|
onDragStart(e) {
|
|
952
964
|
this.dragging = true;
|
|
@@ -1052,6 +1064,30 @@ this.LeaferIN.editor = (function (exports, draw, core) {
|
|
|
1052
1064
|
}
|
|
1053
1065
|
}
|
|
1054
1066
|
|
|
1067
|
+
class EditMask extends draw.UI {
|
|
1068
|
+
constructor(editor) {
|
|
1069
|
+
super();
|
|
1070
|
+
this.editor = editor;
|
|
1071
|
+
this.hittable = false;
|
|
1072
|
+
}
|
|
1073
|
+
__draw(canvas, options) {
|
|
1074
|
+
const { editor } = this;
|
|
1075
|
+
const { mask } = editor.mergeConfig;
|
|
1076
|
+
if (mask && editor.list.length) {
|
|
1077
|
+
const { rect } = editor.editBox;
|
|
1078
|
+
const { width, height } = rect.__;
|
|
1079
|
+
canvas.resetTransform();
|
|
1080
|
+
canvas.fillWorld(canvas.bounds, mask);
|
|
1081
|
+
canvas.setWorld(rect.__world, options.matrix);
|
|
1082
|
+
canvas.clearRect(0, 0, width, height);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
destroy() {
|
|
1086
|
+
this.editor = null;
|
|
1087
|
+
super.destroy();
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1055
1091
|
const filterStyle = `
|
|
1056
1092
|
<feOffset dy="1"/>
|
|
1057
1093
|
<feGaussianBlur stdDeviation="1.5"/>
|
|
@@ -1290,10 +1326,11 @@ ${filterStyle}
|
|
|
1290
1326
|
this.editBox = new EditBox(this);
|
|
1291
1327
|
this.editToolList = {};
|
|
1292
1328
|
this.selector = new EditSelect(this);
|
|
1329
|
+
this.editMask = new EditMask(this);
|
|
1293
1330
|
this.targetEventIds = [];
|
|
1294
1331
|
if (userConfig)
|
|
1295
1332
|
this.config = draw.DataHelper.default(userConfig, this.config);
|
|
1296
|
-
this.addMany(this.selector, this.editBox);
|
|
1333
|
+
this.addMany(this.editMask, this.selector, this.editBox);
|
|
1297
1334
|
}
|
|
1298
1335
|
select(target) {
|
|
1299
1336
|
this.target = target;
|
package/dist/editor.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");const{M:i,L:o,C:s,Q:n,Z:r,N:a,D:l,X:h,G:d,F:c,O:g,P:u,U:p}=t.PathCommandMap,f={scale(t,e,f){if(!t)return;let m,E=0,L=t.length;for(;E<L;)switch(m=t[E],m){case i:case o:v(t,e,f,E,1),E+=3;break;case s:v(t,e,f,E,3),E+=7;break;case n:v(t,e,f,E,2),E+=5;break;case r:E+=1;break;case a:v(t,e,f,E,2),E+=5;break;case l:v(t,e,f,E,2),E+=9;break;case h:v(t,e,f,E,2),E+=6;break;case d:v(t,e,f,E,2),E+=9;break;case c:v(t,e,f,E,2),E+=5;break;case g:t[E]=d,t.splice(E+4,0,t[E+3],0),v(t,e,f,E,2),E+=9,L+=2;break;case u:t[E]=c,t.splice(E+4,0,t[E+3]),v(t,e,f,E,2),E+=5,L+=1;break;case p:v(t,e,f,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:v}=f,m=t.MatrixHelper.get();function E(t,e,i){t.pathInputed?y(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function L(t,e,i){const{width:o,height:s}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=s*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=o*(i-e)/2)}function y(t,e,i){f.scale(t.__.path,e,i),t.path=t.__.path}function _(t,e,i){f.scalePoints(t.__.points,e,i),t.points=t.__.points}function b(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)m.a=e,m.d=i,o[t].transform(m,!0)}function w(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function x(t){return t?t instanceof Array?t:[t]:[]}t.Leaf.prototype.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},t.Leaf.prototype.__scaleResize=function(t,e){E(this,t,e)},t.Text.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?L(this,t,e):E(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){y(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?y(this,t,e):this.points?_(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?y(this,t,e):this.points?_(this,t,e):E(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){b(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?b(this,t,e):(E(this,t,e),this.__.resizeChildren&&b(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class k extends t.Event{get list(){return x(this.value)}get oldList(){return x(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}k.SELECT="editor.select",k.HOVER="editor.hover";class M extends k{constructor(t,e){super(t,e)}}M.MOVE="editor.move";class S extends k{constructor(t,e){super(t,e)}}S.SCALE="editor.scale";class P extends k{constructor(t,e){super(t,e)}}P.ROTATE="editor.rotate";class O extends k{constructor(t,e){super(t,e)}}function T(e){return(i,o)=>{const s="_"+o;t.defineKey(i,o,{get(){return this[s]},set(t){const i=this[s];i!==t&&(this[s]=t,e(this,i))}})}}O.SKEW="editor.skew";const H=t.MatrixHelper.get(),{abs:R}=Math,{copy:I,scale:V}=t.MatrixHelper;class C extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(e,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=R(s.__world.scaleX),l=R(s.__world.scaleY);if(o!==l){I(H,s.__world),V(H,1/o,1/l),e.setWorld(H,i.matrix),e.beginPath(),this.__.strokeWidth=r;const{x:t,y:n,width:a,height:h}=s.__layout.boxBounds;e.rect(t*o,n*l,a*o,h*l)}else e.setWorld(s.__world,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),this.__.strokeWidth=r/R(s.__world.scaleX);n&&("string"==typeof n?t.Paint.stroke(n,this,e):t.Paint.strokes(n,this,e)),a&&("string"==typeof a?t.Paint.fill(a,this,e):t.Paint.fills(a,this,e))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}w([T((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],C.prototype,"target",void 0);class B extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:D,Yes:A,NoAndSkip:z,YesAndSkip:Z}=t.Answer,G={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?Z:z;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?Z:D;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return A}return D}return t.isBranch?z:D}},{findOne:W}=G;class F extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new C,this.targetStroker=new C,this.bounds=new t.Bounds,this.selectArea=new B,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(e){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(i.app.find(G.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!W(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return W(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):W(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_(k.HOVER,this.onHover,this),t.on_(k.SELECT,this.onSelect,this),i.on_(e.PointerEvent.MOVE,this.onPointerMove,this),i.on_(e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),i.on_(e.PointerEvent.TAP,this.onTap,this),i.on_(e.DragEvent.START,this.onDragStart,this),i.on_(e.DragEvent.DRAG,this.onDrag,this),i.on_(e.DragEvent.END,this.onDragEnd,this),i.on_(e.MoveEvent.MOVE,this.onAutoMove,this),i.on_([e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:U,top:X,topRight:Y,right:K,bottomRight:N,bottom:j,bottomLeft:q,left:$}=t.Direction9,{toPoint:Q}=t.AroundHelper,J={getScaleData(t,e,i,o,s){let n,r={},a=1,l=1;const{width:h,height:d}=t;s&&(i.x*=2,i.y*=2),Math.abs(i.x)===h&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+h)/h,u=(i.y+d)/d,p=(-i.x+h)/h;switch(e){case X:l=c,n="bottom";break;case K:a=g,n="left";break;case j:l=u,n="top";break;case $:a=p,n="right";break;case U:l=c,a=p,n="bottom-right";break;case Y:l=c,a=g,n="bottom-left";break;case N:l=u,a=g,n="top-left";break;case q:l=u,a=p,n="top-right"}if(o){if(!("corner"===o&&e%2)){const t=Math.sqrt(Math.abs(a*l));a=a<0?-t:t,l=l<0?-t:t}}return Q(s||n,t,r),{origin:r,scaleX:a,scaleY:l,direction:e,lockRatio:o,around:s}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case U:r="bottom-right";break;case Y:r="bottom-left";break;case N:r="top-left";break;case q:r="top-right";break;default:r="center"}return Q(n||r,e,a),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},l=0,h=0;switch(i){case X:r={x:.5,y:0},n="bottom",l=1;break;case j:r={x:.5,y:1},n="top",l=1;break;case $:r={x:0,y:.5},n="right",h=1;break;case K:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=e;r.x=d+r.x*g,r.y=c+r.y*u,Q(s||n,e,a);const p=t.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-p:h=p,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case $:t=K;break;case U:t=Y;break;case q:t=N;break;case K:t=$;break;case Y:t=U;break;case N:t=q}if(i)switch(t){case X:t=j;break;case U:t=q;break;case Y:t=N;break;case j:t=X;break;case q:t=U;break;case N:t=Y}return t}},tt={};function et(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!h)&&(f=!1);const v=c&&!f&&"resize-line"===s.name?l:f?r:a;n+=45*(J.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:m,x:E,y:L}=v,y=m+n;tt[y]?s.cursor=tt[y]:tt[y]=s.cursor={url:ot(m,n),x:E,y:L}}function it(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function ot(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class st extends t.Box{}const nt=["top","right","bottom","left"];class rt extends t.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new st({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.rect.syncEventer=e,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new st({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new st({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new st({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);h.add(l),this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(e){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=e,{rect:n,circle:r,resizePoints:a,rotatePoints:l,resizeLines:h}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=i,p="number"==typeof u?u:10,f=!(u&&o<p&&s<p);let v,m,E,L={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,L),m=a[n],v=l[n],E=h[Math.floor(n/2)],m.set(L),v.set(L),E.set(L),m.visible=E.visible=f&&!(!c&&!g),v.visible=f&&g&&c&&!i.rotatePoint,n%2&&(m.visible=v.visible=f&&!!d,(n+1)/2%2?(E.width=o,m.width>o-30&&(m.visible=!1)):(E.height=s,m.rotation=90,m.width>s-30&&(m.visible=!1)));r.visible=f&&g&&!!i.rotatePoint,n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0}));const y=f&&(r.visible||this.buttons.children.length>1);this.buttons.visible=y,y&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:a}=this;let l=nt.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?J.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l,d=e[2*h+1],c=h%2,g=h&&3!==h?1:-1,u=(s+(l%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),o&&(t.rotation=90*(h-l),t.scaleX=r?-1:1,t.scaleY=a?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=this.app.interaction.bottomList=null)}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),et(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,i,o){const{editor:s}=this;t.direction=o,t.pointType=i,t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,this.onDrag,this),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(e.PointerEvent.ENTER,(e=>{this.enterPoint=t,et(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(k.SELECT,this.onSelect,this),t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,i.onMove,i),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.ZoomEvent.BEFORE_ZOOM,i.onScale,i,!0),t.on_(e.RotateEvent.BEFORE_ROTATE,i.onRotate,i,!0),t.on_(e.PointerEvent.ENTER,(()=>it(i))),t.on_(e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(e.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const at='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',lt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${at}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${at}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${at}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};function ht(e){const{simulateTarget:i,leafList:o}=e,{x:s,y:n,width:r,height:a}=(new t.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const dt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),ct=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),gt={group(e,i,o){e.sort(ct);const{app:s,parent:n}=e[0];let r;r=o&&o.add?o:new t.Group(o),n.addAt(r,n.children.indexOf(e[0])),e.sort(dt);const a=new t.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),e.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(dt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(ct),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},ut=t.Debug.get("EditToolCreator");function pt(){return t=>{vt.register(t)}}const ft=pt,vt={list:{},register(t){const{tag:e}=t.prototype;mt[e]?ut.repeat(e):mt[e]=t},get:(t,e)=>new mt[t](e)},{list:mt}=vt;class Et extends k{constructor(t,e){super(t,e)}}Et.BEFORE_OPEN="innerEditor.before_open",Et.OPEN="innerEditor.open",Et.BEFORE_CLOSE="innerEditor.before_close",Et.CLOSE="innerEditor.close";class Lt extends k{constructor(t,e){super(t,e)}}Lt.GROUP="editor.group",Lt.BEFORE_UNGROUP="editor.before_ungroup",Lt.UNGROUP="editor.ungroup",Lt.OPEN="editor.open_group",Lt.CLOSE="editor.close_group";class yt extends t.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(e,i){super(i),this.config=lt,this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new t.Rect({visible:!1}),this.editBox=new rt(this),this.editToolList={},this.selector=new F(this),this.targetEventIds=[],e&&(this.config=t.DataHelper.default(e,this.config)),this.addMany(this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&ht(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||vt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const i={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(i.x)>Math.abs(i.y)?i.y=0:i.x=0),this.move(e.DragEvent.getValidMove(this.element,this.dragStartPoint,i))}onScale(t){const{element:i}=this;if(t instanceof e.ZoomEvent)"zoom"===this.mergeConfig.resizeable&&(t.stop(),this.scaleOf(i.getInnerPoint(t),t.scale,t.scale));else{const{direction:e}=t.current;let{around:o,lockRatio:s}=this.mergeConfig;(t.shiftKey||i.lockRatio)&&(s=!0);const n=J.getScaleData(i.boxBounds,e,t.getInnerMove(i),s,J.getAround(o,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(i){const{skewable:o,around:s,rotateGap:n}=this.mergeConfig,{direction:r,name:a}=i.current;if(o&&"resize-line"===a)return this.onSkew(i);const{element:l}=this;let h,d;if(i instanceof e.RotateEvent){if("rotate"!==this.mergeConfig.rotateable)return;i.stop(),d=i.rotation,h=l.getInnerPoint(i)}else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=J.getRotateData(l.boxBounds,r,i.getInner(l),l.getInnerPoint(t),i.shiftKey?null:s||"center");d=e.rotation,h=e.origin}d=t.MathHelper.getGapRotation(d,n,l.rotation),d&&(l.scaleX*l.scaleY<0&&(d=-d),this.rotateOf(h,t.MathHelper.float(d,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=J.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),J.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new M(M.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=e.getWorldPoint(t.origin),o=new S(S.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(e,i,o=i,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(t.LeafHelper.getInnerOrigin(n,e));let a;if(this.multiple){const s=new t.Matrix(n.worldTransform);n.scaleOf(e,i,o),a=new t.Matrix(n.worldTransform).divide(s)}const l=new S(S.SCALE,{target:n,editor:this,worldOrigin:r,scaleX:i,scaleY:o,transform:a});this.editTool.onScale(l),this.emitEvent(l)}rotateOf(e,i){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:o}=this,s=o.getWorldPoint(t.LeafHelper.getInnerOrigin(o,e));let n;if(this.multiple){const s=new t.Matrix(o.worldTransform);o.rotateOf(e,i),n=new t.Matrix(o.worldTransform).divide(s)}const r=new P(P.ROTATE,{target:o,editor:this,worldOrigin:s,rotation:i,transform:n});this.editTool.onRotate(r),this.emitEvent(r)}skewOf(e,i,o=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(t.LeafHelper.getInnerOrigin(n,e));let a;if(this.multiple){const s=new t.Matrix(n.worldTransform);n.skewOf(e,i,o),a=new t.Matrix(n.worldTransform).divide(s)}const l=new O(O.SKEW,{target:n,editor:this,skewX:i,skewY:o,transform:a,worldOrigin:r});this.editTool.onSkew(l),this.emitEvent(l)}group(t){return this.multiple&&(this.target=gt.group(this.list,this.element,t),this.emitGroupEvent(Lt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Lt.BEFORE_UNGROUP,t))),this.target=gt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Lt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Lt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Lt.CLOSE,t)}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach((e=>this.list.every((i=>!t.LeafHelper.hasParent(i,e)))&&i.push(e)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new Lt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&vt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||vt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Et.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Et.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Et.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Et.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new Et(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(gt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(gt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:i}=this.list[0];this.targetEventIds=[i.on_(t.RenderEvent.START,this.update,this),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{et(this,t)})),i.on_(e.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}w([T((function(t,e){t.emitEvent(new k(k.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],yt.prototype,"hoverTarget",void 0),w([T((function(e,i){const{target:o}=e;o?e.leafList=o instanceof t.LeafList?o:new t.LeafList(o):e.leafList.reset(),e.emitEvent(new k(k.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{e.multiple&&ht(e),it(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],yt.prototype,"target",void 0);class _t{static registerInnerEditor(){vt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}exports.EditTool=class extends _t{static registerEditTool(){vt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=w([pt()],exports.EditTool);const{left:bt,right:wt}=t.Direction9,{move:xt,copy:kt}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:o,lockRatio:s,around:n}=e,r=e.target,a=o===bt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const e=t.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(e,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=e.x,r.y=e.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(xt(t,n,r),o&&xt(e,-n,-r)):(o&&xt(t,-n,-r),xt(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),kt(o[7],i),kt(e[7],i),kt(o[3],a),kt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===bt||t===wt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=w([pt()],exports.LineEditTool),t.Creator.editor=function(t){return new yt(t)},t.UI.setEditConfig=function(e){t.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof e?e(this):e}})},t.UI.setEditOuter=function(e){t.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof e?e:e(this)}})},t.UI.setEditInner=function(e){t.defineKey(this.prototype,"editInner",{get(){return"string"==typeof e?e:e(this)}})},exports.EditBox=rt,exports.EditDataHelper=J,exports.EditPoint=st,exports.EditSelect=F,exports.EditSelectHelper=G,exports.EditToolCreator=vt,exports.Editor=yt,exports.EditorEvent=k,exports.EditorGroupEvent=Lt,exports.EditorHelper=gt,exports.EditorMoveEvent=M,exports.EditorRotateEvent=P,exports.EditorScaleEvent=S,exports.EditorSkewEvent=O,exports.InnerEditor=_t,exports.InnerEditorEvent=Et,exports.PathScaler=f,exports.SelectArea=B,exports.Stroker=C,exports.registerEditTool=pt,exports.registerInnerEditor=ft,exports.scaleResize=E,exports.scaleResizeFontSize=L,exports.scaleResizeGroup=b,exports.scaleResizePath=y,exports.scaleResizePoints=_;
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");const{M:i,L:o,C:s,Q:n,Z:r,N:a,D:l,X:h,G:d,F:c,O:g,P:u,U:p}=t.PathCommandMap,f={scale(t,e,f){if(!t)return;let v,E=0,_=t.length;for(;E<_;)switch(v=t[E],v){case i:case o:m(t,e,f,E,1),E+=3;break;case s:m(t,e,f,E,3),E+=7;break;case n:m(t,e,f,E,2),E+=5;break;case r:E+=1;break;case a:m(t,e,f,E,2),E+=5;break;case l:m(t,e,f,E,2),E+=9;break;case h:m(t,e,f,E,2),E+=6;break;case d:m(t,e,f,E,2),E+=9;break;case c:m(t,e,f,E,2),E+=5;break;case g:t[E]=d,t.splice(E+4,0,t[E+3],0),m(t,e,f,E,2),E+=9,_+=2;break;case u:t[E]=c,t.splice(E+4,0,t[E+3]),m(t,e,f,E,2),E+=5,_+=1;break;case p:m(t,e,f,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:m}=f,v=t.MatrixHelper.get();function E(t,e,i){t.pathInputed?L(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function _(t,e,i){const{width:o,height:s}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=s*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=o*(i-e)/2)}function L(t,e,i){f.scale(t.__.path,e,i),t.path=t.__.path}function y(t,e,i){f.scalePoints(t.__.points,e,i),t.points=t.__.points}function b(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)v.a=e,v.d=i,o[t].transform(v,!0)}const x=t.Leaf.prototype;function w(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function k(t){return t?t instanceof Array?t:[t]:[]}x.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},x.__scaleResize=function(t,e){E(this,t,e)},x.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},x.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},t.Text.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?_(this,t,e):E(this,t,e)},t.Path.prototype.__scaleResize=function(t,e){L(this,t,e)},t.Line.prototype.__scaleResize=function(t,e){this.pathInputed?L(this,t,e):this.points?y(this,t,e):this.width*=t},t.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?L(this,t,e):this.points?y(this,t,e):E(this,t,e)},t.Group.prototype.__scaleResize=function(t,e){b(this,t,e)},t.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?b(this,t,e):(E(this,t,e),this.__.resizeChildren&&b(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class M extends t.Event{get list(){return k(this.value)}get oldList(){return k(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}M.SELECT="editor.select",M.HOVER="editor.hover";class S extends M{constructor(t,e){super(t,e)}}S.MOVE="editor.move";class O extends M{constructor(t,e){super(t,e)}}O.SCALE="editor.scale";class P extends M{constructor(t,e){super(t,e)}}P.ROTATE="editor.rotate";class T extends M{constructor(t,e){super(t,e)}}function H(e){return(i,o)=>{const s="_"+o;t.defineKey(i,o,{get(){return this[s]},set(t){const i=this[s];i!==t&&(this[s]=t,e(this,i))}})}}T.SKEW="editor.skew";const R=t.MatrixHelper.get(),{abs:I}=Math,{copy:V,scale:C}=t.MatrixHelper;class B extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(e,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=I(s.__world.scaleX),l=I(s.__world.scaleY);if(o!==l){V(R,s.__world),C(R,1/o,1/l),e.setWorld(R,i.matrix),e.beginPath(),this.__.strokeWidth=r;const{x:t,y:n,width:a,height:h}=s.__layout.boxBounds;e.rect(t*o,n*l,a*o,h*l)}else e.setWorld(s.__world,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),this.__.strokeWidth=r/I(s.__world.scaleX);n&&("string"==typeof n?t.Paint.stroke(n,this,e):t.Paint.strokes(n,this,e)),a&&("string"==typeof a?t.Paint.fill(a,this,e):t.Paint.fills(a,this,e))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}w([H((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],B.prototype,"target",void 0);class D extends t.Group{constructor(e){super(e),this.strokeArea=new t.Rect({strokeAlign:"center"}),this.fillArea=new t.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:z,Yes:A,NoAndSkip:Z,YesAndSkip:G}=t.Answer,W={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?G:Z;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?G:z;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return A}return z}return t.isBranch?Z:z}},{findOne:U}=W;class F extends t.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(e){super(),this.hoverStroker=new B,this.targetStroker=new B,this.bounds=new t.Bounds,this.selectArea=new D,this.__eventIds=[],this.editor=e,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(e){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(i.app.find(W.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!U(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return U(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):U(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:i}=t;i.selector.proxy=t,this.__eventIds=[t.on_(M.HOVER,this.onHover,this),t.on_(M.SELECT,this.onSelect,this),i.on_(e.PointerEvent.MOVE,this.onPointerMove,this),i.on_(e.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),i.on_(e.PointerEvent.TAP,this.onTap,this),i.on_(e.DragEvent.START,this.onDragStart,this),i.on_(e.DragEvent.DRAG,this.onDrag,this),i.on_(e.DragEvent.END,this.onDragEnd,this),i.on_(e.MoveEvent.MOVE,this.onAutoMove,this),i.on_([e.ZoomEvent.ZOOM,e.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:X,top:Y,topRight:K,right:N,bottomRight:j,bottom:q,bottomLeft:$,left:Q}=t.Direction9,{toPoint:J}=t.AroundHelper,tt={getScaleData(t,e,i,o,s){let n,r={},a=1,l=1;const{width:h,height:d}=t;s&&(i.x*=2,i.y*=2),Math.abs(i.x)===h&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+h)/h,u=(i.y+d)/d,p=(-i.x+h)/h;switch(e){case Y:l=c,n="bottom";break;case N:a=g,n="left";break;case q:l=u,n="top";break;case Q:a=p,n="right";break;case X:l=c,a=p,n="bottom-right";break;case K:l=c,a=g,n="bottom-left";break;case j:l=u,a=g,n="top-left";break;case $:l=u,a=p,n="top-right"}if(o){if(!("corner"===o&&e%2)){const t=Math.sqrt(Math.abs(a*l));a=a<0?-t:t,l=l<0?-t:t}}return J(s||n,t,r),{origin:r,scaleX:a,scaleY:l,direction:e,lockRatio:o,around:s}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case X:r="bottom-right";break;case K:r="bottom-left";break;case j:r="top-left";break;case $:r="top-right";break;default:r="center"}return J(n||r,e,a),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},l=0,h=0;switch(i){case Y:r={x:.5,y:0},n="bottom",l=1;break;case q:r={x:.5,y:1},n="top",l=1;break;case Q:r={x:0,y:.5},n="right",h=1;break;case N:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=e;r.x=d+r.x*g,r.y=c+r.y*u,J(s||n,e,a);const p=t.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-p:h=p,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Q:t=N;break;case X:t=K;break;case $:t=j;break;case N:t=Q;break;case K:t=X;break;case j:t=$}if(i)switch(t){case Y:t=q;break;case X:t=$;break;case K:t=j;break;case q:t=Y;break;case $:t=X;break;case j:t=K}return t}},et={};function it(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!h)&&(f=!1);const m=c&&!f&&"resize-line"===s.name?l:f?r:a;n+=45*(tt.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:_}=m,L=v+n;et[L]?s.cursor=et[L]:et[L]=s.cursor={url:st(v,n),x:E,y:_}}function ot(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function st(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class nt extends t.Box{}const rt=["top","right","bottom","left"];class at extends t.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(e){super(),this.view=new t.Group,this.rect=new t.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new nt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new t.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=e,this.visible=!1,this.create(),this.rect.syncEventer=e,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new nt({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new nt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new nt({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);h.add(l),this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(e){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=e,{rect:n,circle:r,resizePoints:a,rotatePoints:l,resizeLines:h}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=i,p="number"==typeof u?u:10,f=!(u&&o<p&&s<p);let m,v,E,_={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,_),v=a[n],m=l[n],E=h[Math.floor(n/2)],v.set(_),m.set(_),E.set(_),v.visible=E.visible=f&&!(!c&&!g),m.visible=f&&g&&c&&!i.rotatePoint,n%2&&(v.visible=m.visible=f&&!!d,(n+1)/2%2?(E.width=o,v.width>o-30&&(v.visible=!1)):(E.height=s,v.rotation=90,v.width>s-30&&(v.visible=!1)));r.visible=f&&g&&!!i.rotatePoint,n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0}));const L=f&&(r.visible||this.buttons.children.length>1);this.buttons.visible=L,L&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:a}=this;let l=rt.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?tt.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l,d=e[2*h+1],c=h%2,g=h&&3!==h?1:-1,u=(s+(l%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),o&&(t.rotation=90*(h-l),t.scaleX=r?-1:1,t.scaleY=a?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),it(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,i,o){const{editor:s}=this;t.direction=o,t.pointType=i,t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,this.onDrag,this),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(e.PointerEvent.ENTER,(e=>{this.enterPoint=t,it(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(M.SELECT,this.onSelect,this),t.on_(e.DragEvent.START,this.onDragStart,this),t.on_(e.DragEvent.DRAG,i.onMove,i),t.on_(e.DragEvent.END,this.onDragEnd,this),t.on_(e.ZoomEvent.BEFORE_ZOOM,i.onScale,i,!0),t.on_(e.RotateEvent.BEFORE_ROTATE,i.onRotate,i,!0),t.on_(e.PointerEvent.ENTER,(()=>ot(i))),t.on_(e.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(e.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class lt extends t.UI{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:o}=i.mergeConfig;if(o&&i.list.length){const{rect:s}=i.editBox,{width:n,height:r}=s.__;t.resetTransform(),t.fillWorld(t.bounds,o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const ht='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',dt={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${ht}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${ht}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${ht}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};function ct(e){const{simulateTarget:i,leafList:o}=e,{x:s,y:n,width:r,height:a}=(new t.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const gt=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),ut=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),pt={group(e,i,o){e.sort(ut);const{app:s,parent:n}=e[0];let r;r=o&&o.add?o:new t.Group(o),n.addAt(r,n.children.indexOf(e[0])),e.sort(gt);const a=new t.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),e.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(gt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(ut),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},ft=t.Debug.get("EditToolCreator");function mt(){return t=>{Et.register(t)}}const vt=mt,Et={list:{},register(t){const{tag:e}=t.prototype;_t[e]?ft.repeat(e):_t[e]=t},get:(t,e)=>new _t[t](e)},{list:_t}=Et;class Lt extends M{constructor(t,e){super(t,e)}}Lt.BEFORE_OPEN="innerEditor.before_open",Lt.OPEN="innerEditor.open",Lt.BEFORE_CLOSE="innerEditor.before_close",Lt.CLOSE="innerEditor.close";class yt extends M{constructor(t,e){super(t,e)}}yt.GROUP="editor.group",yt.BEFORE_UNGROUP="editor.before_ungroup",yt.UNGROUP="editor.ungroup",yt.OPEN="editor.open_group",yt.CLOSE="editor.close_group";class bt extends t.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(e,i){super(i),this.config=dt,this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new t.Rect({visible:!1}),this.editBox=new at(this),this.editToolList={},this.selector=new F(this),this.editMask=new lt(this),this.targetEventIds=[],e&&(this.config=t.DataHelper.default(e,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&ct(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||Et.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const i={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(i.x)>Math.abs(i.y)?i.y=0:i.x=0),this.move(e.DragEvent.getValidMove(this.element,this.dragStartPoint,i))}onScale(t){const{element:i}=this;if(t instanceof e.ZoomEvent)"zoom"===this.mergeConfig.resizeable&&(t.stop(),this.scaleOf(i.getInnerPoint(t),t.scale,t.scale));else{const{direction:e}=t.current;let{around:o,lockRatio:s}=this.mergeConfig;(t.shiftKey||i.lockRatio)&&(s=!0);const n=tt.getScaleData(i.boxBounds,e,t.getInnerMove(i),s,tt.getAround(o,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(i){const{skewable:o,around:s,rotateGap:n}=this.mergeConfig,{direction:r,name:a}=i.current;if(o&&"resize-line"===a)return this.onSkew(i);const{element:l}=this;let h,d;if(i instanceof e.RotateEvent){if("rotate"!==this.mergeConfig.rotateable)return;i.stop(),d=i.rotation,h=l.getInnerPoint(i)}else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=tt.getRotateData(l.boxBounds,r,i.getInner(l),l.getInnerPoint(t),i.shiftKey?null:s||"center");d=e.rotation,h=e.origin}d=t.MathHelper.getGapRotation(d,n,l.rotation),d&&(l.scaleX*l.scaleY<0&&(d=-d),this.rotateOf(h,t.MathHelper.float(d,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=tt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),tt.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new S(S.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=e.getWorldPoint(t.origin),o=new O(O.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(e,i,o=i,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(t.LeafHelper.getInnerOrigin(n,e));let a;if(this.multiple){const s=new t.Matrix(n.worldTransform);n.scaleOf(e,i,o),a=new t.Matrix(n.worldTransform).divide(s)}const l=new O(O.SCALE,{target:n,editor:this,worldOrigin:r,scaleX:i,scaleY:o,transform:a});this.editTool.onScale(l),this.emitEvent(l)}rotateOf(e,i){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:o}=this,s=o.getWorldPoint(t.LeafHelper.getInnerOrigin(o,e));let n;if(this.multiple){const s=new t.Matrix(o.worldTransform);o.rotateOf(e,i),n=new t.Matrix(o.worldTransform).divide(s)}const r=new P(P.ROTATE,{target:o,editor:this,worldOrigin:s,rotation:i,transform:n});this.editTool.onRotate(r),this.emitEvent(r)}skewOf(e,i,o=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(t.LeafHelper.getInnerOrigin(n,e));let a;if(this.multiple){const s=new t.Matrix(n.worldTransform);n.skewOf(e,i,o),a=new t.Matrix(n.worldTransform).divide(s)}const l=new T(T.SKEW,{target:n,editor:this,skewX:i,skewY:o,transform:a,worldOrigin:r});this.editTool.onSkew(l),this.emitEvent(l)}group(t){return this.multiple&&(this.target=pt.group(this.list,this.element,t),this.emitGroupEvent(yt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(yt.BEFORE_UNGROUP,t))),this.target=pt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(yt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(yt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(yt.CLOSE,t)}checkOpenedGroups(){const e=this.openedGroupList;if(e.length){let{list:i}=e;this.editing&&(i=[],e.forEach((e=>this.list.every((i=>!t.LeafHelper.hasParent(i,e)))&&i.push(e)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new yt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&Et.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||Et.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Lt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Lt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Lt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Lt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new Lt(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(pt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(pt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:i}=this.list[0];this.targetEventIds=[i.on_(t.RenderEvent.START,this.update,this),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{it(this,t)})),i.on_(e.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}w([H((function(t,e){t.emitEvent(new M(M.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],bt.prototype,"hoverTarget",void 0),w([H((function(e,i){const{target:o}=e;o?e.leafList=o instanceof t.LeafList?o:new t.LeafList(o):e.leafList.reset(),e.emitEvent(new M(M.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{e.multiple&&ct(e),ot(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],bt.prototype,"target",void 0);class xt{static registerInnerEditor(){Et.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new t.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}exports.EditTool=class extends xt{static registerEditTool(){Et.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=w([mt()],exports.EditTool);const{left:wt,right:kt}=t.Direction9,{move:Mt,copy:St}=t.PointHelper;exports.LineEditTool=class extends exports.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(e){const{drag:i,direction:o,lockRatio:s,around:n}=e,r=e.target,a=o===wt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const e=t.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(e,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=e.x,r.y=e.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(Mt(t,n,r),o&&Mt(e,-n,-r)):(o&&Mt(t,-n,-r),Mt(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),St(o[7],i),St(e[7],i),St(o[3],a),St(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===wt||t===kt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=w([mt()],exports.LineEditTool),t.Creator.editor=function(t){return new bt(t)},t.UI.setEditConfig=function(e){t.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof e?e(this):e}})},t.UI.setEditOuter=function(e){t.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof e?e:e(this)}})},t.UI.setEditInner=function(e){t.defineKey(this.prototype,"editInner",{get(){return"string"==typeof e?e:e(this)}})},exports.EditBox=at,exports.EditDataHelper=tt,exports.EditPoint=nt,exports.EditSelect=F,exports.EditSelectHelper=W,exports.EditToolCreator=Et,exports.Editor=bt,exports.EditorEvent=M,exports.EditorGroupEvent=yt,exports.EditorHelper=pt,exports.EditorMoveEvent=S,exports.EditorRotateEvent=P,exports.EditorScaleEvent=O,exports.EditorSkewEvent=T,exports.InnerEditor=xt,exports.InnerEditorEvent=Lt,exports.PathScaler=f,exports.SelectArea=D,exports.Stroker=B,exports.registerEditTool=mt,exports.registerInnerEditor=vt,exports.scaleResize=E,exports.scaleResizeFontSize=_,exports.scaleResizeGroup=b,exports.scaleResizePath=L,exports.scaleResizePoints=y;
|
package/dist/editor.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.editor=function(t,e,i){"use strict";const{M:o,L:s,C:n,Q:r,Z:a,N:l,D:h,X:d,G:c,F:g,O:u,P:f,U:p}=e.PathCommandMap,m={scale(t,e,i){if(!t)return;let m,E=0,L=t.length;for(;E<L;)switch(m=t[E],m){case o:case s:v(t,e,i,E,1),E+=3;break;case n:v(t,e,i,E,3),E+=7;break;case r:v(t,e,i,E,2),E+=5;break;case a:E+=1;break;case l:v(t,e,i,E,2),E+=5;break;case h:v(t,e,i,E,2),E+=9;break;case d:v(t,e,i,E,2),E+=6;break;case c:v(t,e,i,E,2),E+=9;break;case g:v(t,e,i,E,2),E+=5;break;case u:t[E]=c,t.splice(E+4,0,t[E+3],0),v(t,e,i,E,2),E+=9,L+=2;break;case f:t[E]=g,t.splice(E+4,0,t[E+3]),v(t,e,i,E,2),E+=5,L+=1;break;case p:v(t,e,i,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:v}=m,E=e.MatrixHelper.get();function L(t,e,i){t.pathInputed?_(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function y(t,e,i){const{width:o,height:s}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=s*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=o*(i-e)/2)}function _(t,e,i){m.scale(t.__.path,e,i),t.path=t.__.path}function b(t,e,i){m.scalePoints(t.__.points,e,i),t.points=t.__.points}function w(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)E.a=e,E.d=i,o[t].transform(E,!0)}function k(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function x(t){return t?t instanceof Array?t:[t]:[]}e.Leaf.prototype.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},e.Leaf.prototype.__scaleResize=function(t,e){L(this,t,e)},e.Text.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?y(this,t,e):L(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){_(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?_(this,t,e):this.points?b(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?_(this,t,e):this.points?b(this,t,e):L(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){w(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?w(this,t,e):(L(this,t,e),this.__.resizeChildren&&w(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class M extends e.Event{get list(){return x(this.value)}get oldList(){return x(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}M.SELECT="editor.select",M.HOVER="editor.hover";class S extends M{constructor(t,e){super(t,e)}}S.MOVE="editor.move";class P extends M{constructor(t,e){super(t,e)}}P.SCALE="editor.scale";class O extends M{constructor(t,e){super(t,e)}}O.ROTATE="editor.rotate";class T extends M{constructor(t,e){super(t,e)}}function H(t){return(i,o)=>{const s="_"+o;e.defineKey(i,o,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}T.SKEW="editor.skew";const I=e.MatrixHelper.get(),{abs:R}=Math,{copy:V,scale:C}=e.MatrixHelper;class B extends e.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=R(s.__world.scaleX),l=R(s.__world.scaleY);if(o!==l){V(I,s.__world),C(I,1/o,1/l),t.setWorld(I,i.matrix),t.beginPath(),this.__.strokeWidth=r;const{x:e,y:n,width:a,height:h}=s.__layout.boxBounds;t.rect(e*o,n*l,a*o,h*l)}else t.setWorld(s.__world,i.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=r/R(s.__world.scaleX);n&&("string"==typeof n?e.Paint.stroke(n,this,t):e.Paint.strokes(n,this,t)),a&&("string"==typeof a?e.Paint.fill(a,this,t):e.Paint.fills(a,this,t))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}k([H((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],B.prototype,"target",void 0);class D extends e.Group{constructor(t){super(t),this.strokeArea=new e.Rect({strokeAlign:"center"}),this.fillArea=new e.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:A,Yes:z,NoAndSkip:Z,YesAndSkip:G}=e.Answer,W={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?G:Z;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?G:A;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return z}return A}return t.isBranch?Z:A}},{findOne:U}=W;class F extends e.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new B,this.targetStroker=new B,this.bounds=new e.Bounds,this.selectArea=new D,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:i}=this,o=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new e.LeafList(i.app.find(W.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!U(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const i={exclude:new e.LeafList(this.editor.editBox.rect)};return U(t.target.leafer.interaction.findPath(t,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):U(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(M.HOVER,this.onHover,this),t.on_(M.SELECT,this.onSelect,this),e.on_(i.PointerEvent.MOVE,this.onPointerMove,this),e.on_(i.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),e.on_(i.PointerEvent.TAP,this.onTap,this),e.on_(i.DragEvent.START,this.onDragStart,this),e.on_(i.DragEvent.DRAG,this.onDrag,this),e.on_(i.DragEvent.END,this.onDragEnd,this),e.on_(i.MoveEvent.MOVE,this.onAutoMove,this),e.on_([i.ZoomEvent.ZOOM,i.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:X,top:Y,topRight:N,right:K,bottomRight:j,bottom:$,bottomLeft:q,left:Q}=e.Direction9,{toPoint:J}=e.AroundHelper,tt={getScaleData(t,e,i,o,s){let n,r={},a=1,l=1;const{width:h,height:d}=t;s&&(i.x*=2,i.y*=2),Math.abs(i.x)===h&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+h)/h,u=(i.y+d)/d,f=(-i.x+h)/h;switch(e){case Y:l=c,n="bottom";break;case K:a=g,n="left";break;case $:l=u,n="top";break;case Q:a=f,n="right";break;case X:l=c,a=f,n="bottom-right";break;case N:l=c,a=g,n="bottom-left";break;case j:l=u,a=g,n="top-left";break;case q:l=u,a=f,n="top-right"}if(o){if(!("corner"===o&&e%2)){const t=Math.sqrt(Math.abs(a*l));a=a<0?-t:t,l=l<0?-t:t}}return J(s||n,t,r),{origin:r,scaleX:a,scaleY:l,direction:e,lockRatio:o,around:s}},getRotateData(t,i,o,s,n){let r,a={};switch(i){case X:r="bottom-right";break;case N:r="bottom-left";break;case j:r="top-left";break;case q:r="top-right";break;default:r="center"}return J(n||r,t,a),{origin:a,rotation:e.PointHelper.getRotation(s,a,o)}},getSkewData(t,i,o,s){let n,r,a={},l=0,h=0;switch(i){case Y:r={x:.5,y:0},n="bottom",l=1;break;case $:r={x:.5,y:1},n="top",l=1;break;case Q:r={x:0,y:.5},n="right",h=1;break;case K:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=t;r.x=d+r.x*g,r.y=c+r.y*u,J(s||n,t,a);const f=e.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-f:h=f,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case Q:t=K;break;case X:t=N;break;case q:t=j;break;case K:t=Q;break;case N:t=X;break;case j:t=q}if(i)switch(t){case Y:t=$;break;case X:t=q;break;case N:t=j;break;case $:t=Y;break;case q:t=X;break;case j:t=N}return t}},et={};function it(t,i){const{editBox:o}=t,s=o.enterPoint;if(!s||!t.editing||!o.visible)return;if("circle"===s.name)return;let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=t.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:f}=o;let p="resize"===g;p&&d&&(i.metaKey||i.ctrlKey||!h)&&(p=!1);const m=c&&!p&&"resize-line"===s.name?l:p?r:a;n+=45*(tt.getFlipDirection(s.direction,u,f)+1),n=2*Math.round(e.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:L}=m,y=v+n;et[y]?s.cursor=et[y]:et[y]=s.cursor={url:st(v,n),x:E,y:L}}function ot(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function st(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class nt extends e.Box{}const rt=["top","right","bottom","left"];class at extends e.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new e.Group,this.rect=new e.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new nt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new e.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new nt({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new nt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new nt({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);h.add(l),this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=t,{rect:n,circle:r,resizePoints:a,rotatePoints:l,resizeLines:h}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=i,f="number"==typeof u?u:10,p=!(u&&o<f&&s<f);let m,v,E,L={};for(let n=0;n<8;n++)e.AroundHelper.toPoint(e.AroundHelper.directionData[n],t,L),v=a[n],m=l[n],E=h[Math.floor(n/2)],v.set(L),m.set(L),E.set(L),v.visible=E.visible=p&&!(!c&&!g),m.visible=p&&g&&c&&!i.rotatePoint,n%2&&(v.visible=m.visible=p&&!!d,(n+1)/2%2?(E.width=o,v.width>o-30&&(v.visible=!1)):(E.height=s,v.rotation=90,v.width>s-30&&(v.visible=!1)));r.visible=p&&g&&!!i.rotatePoint,n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!0}));const y=p&&(r.visible||this.buttons.children.length>1);this.buttons.visible=y,y&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:a}=this;let l=rt.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?tt.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l,d=e[2*h+1],c=h%2,g=h&&3!==h?1:-1,u=(s+(l%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),o&&(t.rotation=90*(h-l),t.scaleX=r?-1:1,t.scaleY=a?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=this.app.interaction.bottomList=null)}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),it(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,o){const{editor:s}=this;t.direction=o,t.pointType=e,t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,this.onDrag,this),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(i.PointerEvent.ENTER,(e=>{this.enterPoint=t,it(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(M.SELECT,this.onSelect,this),t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,e.onMove,e),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.ZoomEvent.BEFORE_ZOOM,e.onScale,e,!0),t.on_(i.RotateEvent.BEFORE_ROTATE,e.onRotate,e,!0),t.on_(i.PointerEvent.ENTER,(()=>ot(e))),t.on_(i.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(i.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}const lt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',ht={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${lt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${lt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${lt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};function dt(t){const{simulateTarget:i,leafList:o}=t,{x:s,y:n,width:r,height:a}=(new e.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const ct=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),gt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),ut={group(t,i,o){t.sort(gt);const{app:s,parent:n}=t[0];let r;r=o&&o.add?o:new e.Group(o),n.addAt(r,n.children.indexOf(t[0])),t.sort(ct);const a=new e.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(ct),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(gt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},ft=e.Debug.get("EditToolCreator");function pt(){return t=>{vt.register(t)}}const mt=pt,vt={list:{},register(t){const{tag:e}=t.prototype;Et[e]?ft.repeat(e):Et[e]=t},get:(t,e)=>new Et[t](e)},{list:Et}=vt;class Lt extends M{constructor(t,e){super(t,e)}}Lt.BEFORE_OPEN="innerEditor.before_open",Lt.OPEN="innerEditor.open",Lt.BEFORE_CLOSE="innerEditor.before_close",Lt.CLOSE="innerEditor.close";class yt extends M{constructor(t,e){super(t,e)}}yt.GROUP="editor.group",yt.BEFORE_UNGROUP="editor.before_ungroup",yt.UNGROUP="editor.ungroup",yt.OPEN="editor.open_group",yt.CLOSE="editor.close_group";class _t extends e.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,i){super(i),this.config=ht,this.leafList=new e.LeafList,this.openedGroupList=new e.LeafList,this.simulateTarget=new e.Rect({visible:!1}),this.editBox=new at(this),this.editToolList={},this.selector=new F(this),this.targetEventIds=[],t&&(this.config=e.DataHelper.default(t,this.config)),this.addMany(this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&&dt(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||vt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(i.DragEvent.getValidMove(this.element,this.dragStartPoint,e))}onScale(t){const{element:e}=this;if(t instanceof i.ZoomEvent)"zoom"===this.mergeConfig.resizeable&&(t.stop(),this.scaleOf(e.getInnerPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;let{around:o,lockRatio:s}=this.mergeConfig;(t.shiftKey||e.lockRatio)&&(s=!0);const n=tt.getScaleData(e.boxBounds,i,t.getInnerMove(e),s,tt.getAround(o,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:o,around:s,rotateGap:n}=this.mergeConfig,{direction:r,name:a}=t.current;if(o&&"resize-line"===a)return this.onSkew(t);const{element:l}=this;let h,d;if(t instanceof i.RotateEvent){if("rotate"!==this.mergeConfig.rotateable)return;t.stop(),d=t.rotation,h=l.getInnerPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=tt.getRotateData(l.boxBounds,r,t.getInner(l),l.getInnerPoint(e),t.shiftKey?null:s||"center");d=i.rotation,h=i.origin}d=e.MathHelper.getGapRotation(d,n,l.rotation),d&&(l.scaleX*l.scaleY<0&&(d=-d),this.rotateOf(h,e.MathHelper.float(d,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=tt.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),tt.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new S(S.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=e.getWorldPoint(t.origin),o=new P(P.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,i,o=i,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(e.LeafHelper.getInnerOrigin(n,t));let a;if(this.multiple){const s=new e.Matrix(n.worldTransform);n.scaleOf(t,i,o),a=new e.Matrix(n.worldTransform).divide(s)}const l=new P(P.SCALE,{target:n,editor:this,worldOrigin:r,scaleX:i,scaleY:o,transform:a});this.editTool.onScale(l),this.emitEvent(l)}rotateOf(t,i){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:o}=this,s=o.getWorldPoint(e.LeafHelper.getInnerOrigin(o,t));let n;if(this.multiple){const s=new e.Matrix(o.worldTransform);o.rotateOf(t,i),n=new e.Matrix(o.worldTransform).divide(s)}const r=new O(O.ROTATE,{target:o,editor:this,worldOrigin:s,rotation:i,transform:n});this.editTool.onRotate(r),this.emitEvent(r)}skewOf(t,i,o=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(e.LeafHelper.getInnerOrigin(n,t));let a;if(this.multiple){const s=new e.Matrix(n.worldTransform);n.skewOf(t,i,o),a=new e.Matrix(n.worldTransform).divide(s)}const l=new T(T.SKEW,{target:n,editor:this,skewX:i,skewY:o,transform:a,worldOrigin:r});this.editTool.onSkew(l),this.emitEvent(l)}group(t){return this.multiple&&(this.target=ut.group(this.list,this.element,t),this.emitGroupEvent(yt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(yt.BEFORE_UNGROUP,t))),this.target=ut.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(yt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(yt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(yt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:i}=t;this.editing&&(i=[],t.forEach((t=>this.list.every((i=>!e.LeafHelper.hasParent(i,t)))&&i.push(t)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new yt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&vt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||vt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(Lt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(Lt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(Lt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(Lt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new Lt(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(ut.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(ut.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[t.on_(e.RenderEvent.START,this.update,this),t.on_([i.KeyEvent.HOLD,i.KeyEvent.UP],(t=>{it(this,t)})),t.on_(i.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}k([H((function(t,e){t.emitEvent(new M(M.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],_t.prototype,"hoverTarget",void 0),k([H((function(t,i){const{target:o}=t;o?t.leafList=o instanceof e.LeafList?o:new e.LeafList(o):t.leafList.reset(),t.emitEvent(new M(M.SELECT,{editor:t,value:o,oldValue:i})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&dt(t),ot(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],_t.prototype,"target",void 0);class bt{static registerInnerEditor(){vt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new e.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}t.EditTool=class extends bt{static registerEditTool(){vt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=k([pt()],t.EditTool);const{left:wt,right:kt}=e.Direction9,{move:xt,copy:Mt}=e.PointHelper;return t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:i,direction:o,lockRatio:s,around:n}=t,r=t.target,a=o===wt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const t=e.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(t,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(xt(t,n,r),o&&xt(e,-n,-r)):(o&&xt(t,-n,-r),xt(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Mt(o[7],i),Mt(e[7],i),Mt(o[3],a),Mt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===wt||t===kt,o[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=k([pt()],t.LineEditTool),e.Creator.editor=function(t){return new _t(t)},e.UI.setEditConfig=function(t){e.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},e.UI.setEditOuter=function(t){e.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},e.UI.setEditInner=function(t){e.defineKey(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})},t.EditBox=at,t.EditDataHelper=tt,t.EditPoint=nt,t.EditSelect=F,t.EditSelectHelper=W,t.EditToolCreator=vt,t.Editor=_t,t.EditorEvent=M,t.EditorGroupEvent=yt,t.EditorHelper=ut,t.EditorMoveEvent=S,t.EditorRotateEvent=O,t.EditorScaleEvent=P,t.EditorSkewEvent=T,t.InnerEditor=bt,t.InnerEditorEvent=Lt,t.PathScaler=m,t.SelectArea=D,t.Stroker=B,t.registerEditTool=pt,t.registerInnerEditor=mt,t.scaleResize=L,t.scaleResizeFontSize=y,t.scaleResizeGroup=w,t.scaleResizePath=_,t.scaleResizePoints=b,t}({},LeaferUI,LeaferUI);
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.editor=function(t,e,i){"use strict";const{M:o,L:s,C:n,Q:r,Z:a,N:l,D:h,X:d,G:c,F:g,O:u,P:f,U:p}=e.PathCommandMap,m={scale(t,e,i){if(!t)return;let m,E=0,L=t.length;for(;E<L;)switch(m=t[E],m){case o:case s:v(t,e,i,E,1),E+=3;break;case n:v(t,e,i,E,3),E+=7;break;case r:v(t,e,i,E,2),E+=5;break;case a:E+=1;break;case l:v(t,e,i,E,2),E+=5;break;case h:v(t,e,i,E,2),E+=9;break;case d:v(t,e,i,E,2),E+=6;break;case c:v(t,e,i,E,2),E+=9;break;case g:v(t,e,i,E,2),E+=5;break;case u:t[E]=c,t.splice(E+4,0,t[E+3],0),v(t,e,i,E,2),E+=9,L+=2;break;case f:t[E]=g,t.splice(E+4,0,t[E+3]),v(t,e,i,E,2),E+=5,L+=1;break;case p:v(t,e,i,E,2),E+=6}},scalePoints(t,e,i,o,s){for(let n=s?o+1:0,r=s?n+2*s:t.length;n<r;n+=2)t[n]*=e,t[n+1]*=i}},{scalePoints:v}=m,E=e.MatrixHelper.get();function L(t,e,i){t.pathInputed?y(t,e,i):(1!==e&&(t.width*=e),1!==i&&(t.height*=i))}function _(t,e,i){const{width:o,height:s}=t.__localBoxBounds;1!==e?(t.fontSize*=e,t.y-=s*(e-i)/2):1!==i&&(t.fontSize*=i,t.x-=o*(i-e)/2)}function y(t,e,i){m.scale(t.__.path,e,i),t.path=t.__.path}function b(t,e,i){m.scalePoints(t.__.points,e,i),t.points=t.__.points}function w(t,e,i){const{children:o}=t;for(let t=0;t<o.length;t++)E.a=e,E.d=i,o[t].transform(E,!0)}const k=e.Leaf.prototype;function x(t,e,i,o){var s,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(n<3?s(r):n>3?s(e,i,r):s(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function M(t){return t?t instanceof Array?t:[t]:[]}k.scaleResize=function(t,e=t,i){const o=this;i||o.editConfig&&"scale"===o.editConfig.editSize?(o.scaleX*=t,o.scaleY*=e):(t<0&&(o.scaleX*=-1,t=-t),e<0&&(o.scaleY*=-1,e=-e),this.__scaleResize(t,e))},k.__scaleResize=function(t,e){L(this,t,e)},k.resizeWidth=function(t){const e=t/this.getBounds("box","local").width;this.scaleOf(this.__layout.boxBounds,e,this.__.lockRatio?e:1,!0)},k.resizeHeight=function(t){const e=t/this.getBounds("box","local").height;this.scaleOf(this.__layout.boxBounds,this.__.lockRatio?e:1,e,!0)},e.Text.prototype.__scaleResize=function(t,e){this.__.__autoSize&&(this.__.resizeFontSize||this.editConfig&&"font-size"===this.editConfig.editSize)?_(this,t,e):L(this,t,e)},e.Path.prototype.__scaleResize=function(t,e){y(this,t,e)},e.Line.prototype.__scaleResize=function(t,e){this.pathInputed?y(this,t,e):this.points?b(this,t,e):this.width*=t},e.Polygon.prototype.__scaleResize=function(t,e){this.pathInputed?y(this,t,e):this.points?b(this,t,e):L(this,t,e)},e.Group.prototype.__scaleResize=function(t,e){w(this,t,e)},e.Box.prototype.__scaleResize=function(t,e){this.__.__autoSize&&this.children.length?w(this,t,e):(L(this,t,e),this.__.resizeChildren&&w(this,t,e))},"function"==typeof SuppressedError&&SuppressedError;class S extends e.Event{get list(){return M(this.value)}get oldList(){return M(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}S.SELECT="editor.select",S.HOVER="editor.hover";class O extends S{constructor(t,e){super(t,e)}}O.MOVE="editor.move";class P extends S{constructor(t,e){super(t,e)}}P.SCALE="editor.scale";class T extends S{constructor(t,e){super(t,e)}}T.ROTATE="editor.rotate";class H extends S{constructor(t,e){super(t,e)}}function I(t){return(i,o)=>{const s="_"+o;e.defineKey(i,o,{get(){return this[s]},set(e){const i=this[s];i!==e&&(this[s]=e,t(this,i))}})}}H.SKEW="editor.skew";const R=e.MatrixHelper.get(),{abs:V}=Math,{copy:C,scale:B}=e.MatrixHelper;class D extends e.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t}__draw(t,i){const{list:o}=this;if(o.length){let s;const{stroke:n,strokeWidth:r,fill:a}=this.__,{bounds:l}=i;for(let h=0;h<o.length;h++)if(s=o[h],l&&l.hit(s.__world,i.matrix)){const o=V(s.__world.scaleX),l=V(s.__world.scaleY);if(o!==l){C(R,s.__world),B(R,1/o,1/l),t.setWorld(R,i.matrix),t.beginPath(),this.__.strokeWidth=r;const{x:e,y:n,width:a,height:h}=s.__layout.boxBounds;t.rect(e*o,n*l,a*o,h*l)}else t.setWorld(s.__world,i.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),this.__.strokeWidth=r/V(s.__world.scaleX);n&&("string"==typeof n?e.Paint.stroke(n,this,t):e.Paint.strokes(n,this,t)),a&&("string"==typeof a?e.Paint.fill(a,this,t):e.Paint.fills(a,this,t))}this.__.strokeWidth=r}}destroy(){this.target=null,super.destroy()}}x([I((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[],t.forceUpdate()}))],D.prototype,"target",void 0);class z extends e.Group{constructor(t){super(t),this.strokeArea=new e.Rect({strokeAlign:"center"}),this.fillArea=new e.Rect,this.visible=this.hittable=!1,this.addMany(this.fillArea,this.strokeArea)}setStyle(t,e){const{visible:i,stroke:o,strokeWidth:s}=t;this.visible=i,this.strokeArea.reset(Object.assign({stroke:o,strokeWidth:s},e||{})),this.fillArea.reset({visible:!e,fill:o,opacity:.2})}setBounds(t){this.strokeArea.set(t),this.fillArea.set(t)}}const{No:A,Yes:Z,NoAndSkip:G,YesAndSkip:W}=e.Answer,U={findOne:t=>t.list.find((t=>t.editable)),findBounds(t,e){if(t.__.hittable&&t.__.visible&&!t.__.locked&&e.hit(t.__world)){if(t.__.editable){if(t.isBranch&&!t.__.hitChildren)return t.__.hitSelf?W:G;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?W:A;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return Z}return A}return t.isBranch?G:A}},{findOne:F}=U;class X extends e.Group{get dragging(){return!!this.originList}get running(){const{editor:t}=this;return this.hittable&&t.visible&&t.hittable&&t.mergeConfig.selector}get isMoveMode(){return this.app&&this.app.interaction.moveMode}constructor(t){super(),this.hoverStroker=new D,this.targetStroker=new D,this.bounds=new e.Bounds,this.selectArea=new z,this.__eventIds=[],this.editor=t,this.addMany(this.targetStroker,this.hoverStroker,this.selectArea),this.__listenEvents()}onHover(){const{editor:t}=this;if(!this.running||this.dragging||t.dragging)this.hoverStroker.target=null;else{const{stroke:e,strokeWidth:i,hover:o,hoverStyle:s}=t.mergeConfig;this.hoverStroker.setTarget(o?this.editor.hoverTarget:null,Object.assign({stroke:e,strokeWidth:i},s||{}))}}onSelect(){if(this.running){const{mergeConfig:t,list:e}=this.editor,{stroke:i,strokeWidth:o}=t;this.targetStroker.setTarget(e,{stroke:i,strokeWidth:Math.max(1,o/2)}),this.hoverStroker.target=null}}update(){this.targetStroker.target&&this.targetStroker.forceUpdate()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.config.pointer.hover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){const{select:e}=this.editor.mergeConfig;"press"===e&&this.checkAndSelect(t)}onTap(t){const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i&&this.checkAndSelect(t),this.needRemoveItem?e.removeItem(this.needRemoveItem):this.isMoveMode&&(e.target=null)}checkAndSelect(t){if(this.needRemoveItem=null,this.allowSelect(t)){const{editor:e}=this,i=this.findUI(t);i?this.isMultipleSelect(t)?e.hasItem(i)?this.needRemoveItem=i:e.addItem(i):e.target=i:this.allow(t.target)&&(t.shiftKey||(e.target=null))}}onDragStart(t){if(this.allowDrag(t)){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInner(this);this.bounds.set(s,n),this.selectArea.setStyle({visible:!0,stroke:i,x:s,y:n},o),this.selectArea.setBounds(this.bounds.get()),this.originList=e.leafList.clone()}}onDrag(t){if(this.editor.dragging)this.onDragEnd();else if(this.dragging){const{editor:i}=this,o=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new e.LeafList(i.app.find(U.findBounds,s));if(this.bounds.width=o.x,this.bounds.height=o.y,this.selectArea.setBounds(s.get()),n.length){const t=[];this.originList.forEach((e=>{n.has(e)||t.push(e)})),n.forEach((e=>{this.originList.has(e)||t.push(e)})),(t.length!==i.list.length||i.list.some(((e,i)=>e!==t[i])))&&(i.target=t)}else i.target=this.originList.list}}onDragEnd(){this.dragging&&(this.originList=null,this.selectArea.visible=!1)}onAutoMove(t){if(this.dragging){const{x:e,y:i}=t.getLocalMove(this);this.bounds.x+=e,this.bounds.y+=i}}allow(t){return t.leafer!==this.editor.leafer}allowDrag(t){return!(!this.running||!this.editor.mergeConfig.boxSelect||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!F(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const i={exclude:new e.LeafList(this.editor.editBox.rect)};return F(t.target.leafer.interaction.findPath(t,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):F(t.path)}isMultipleSelect(t){return t.shiftKey||this.editor.mergeConfig.continuousSelect}__listenEvents(){const{editor:t}=this;t.waitLeafer((()=>{const{app:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(S.HOVER,this.onHover,this),t.on_(S.SELECT,this.onSelect,this),e.on_(i.PointerEvent.MOVE,this.onPointerMove,this),e.on_(i.PointerEvent.BEFORE_DOWN,this.onBeforeDown,this),e.on_(i.PointerEvent.TAP,this.onTap,this),e.on_(i.DragEvent.START,this.onDragStart,this),e.on_(i.DragEvent.DRAG,this.onDrag,this),e.on_(i.DragEvent.END,this.onDragEnd,this),e.on_(i.MoveEvent.MOVE,this.onAutoMove,this),e.on_([i.ZoomEvent.ZOOM,i.MoveEvent.MOVE],(()=>{this.editor.hoverTarget=null}))]}))}__removeListenEvents(){this.__eventIds&&(this.off_(this.__eventIds),this.__eventIds.length=0)}destroy(){this.editor=this.originList=this.needRemoveItem=null,this.__removeListenEvents(),super.destroy()}}const{topLeft:Y,top:N,topRight:K,right:j,bottomRight:$,bottom:q,bottomLeft:Q,left:J}=e.Direction9,{toPoint:tt}=e.AroundHelper,et={getScaleData(t,e,i,o,s){let n,r={},a=1,l=1;const{width:h,height:d}=t;s&&(i.x*=2,i.y*=2),Math.abs(i.x)===h&&(i.x+=.1),Math.abs(i.y)===d&&(i.y+=.1);const c=(-i.y+d)/d,g=(i.x+h)/h,u=(i.y+d)/d,f=(-i.x+h)/h;switch(e){case N:l=c,n="bottom";break;case j:a=g,n="left";break;case q:l=u,n="top";break;case J:a=f,n="right";break;case Y:l=c,a=f,n="bottom-right";break;case K:l=c,a=g,n="bottom-left";break;case $:l=u,a=g,n="top-left";break;case Q:l=u,a=f,n="top-right"}if(o){if(!("corner"===o&&e%2)){const t=Math.sqrt(Math.abs(a*l));a=a<0?-t:t,l=l<0?-t:t}}return tt(s||n,t,r),{origin:r,scaleX:a,scaleY:l,direction:e,lockRatio:o,around:s}},getRotateData(t,i,o,s,n){let r,a={};switch(i){case Y:r="bottom-right";break;case K:r="bottom-left";break;case $:r="top-left";break;case Q:r="top-right";break;default:r="center"}return tt(n||r,t,a),{origin:a,rotation:e.PointHelper.getRotation(s,a,o)}},getSkewData(t,i,o,s){let n,r,a={},l=0,h=0;switch(i){case N:r={x:.5,y:0},n="bottom",l=1;break;case q:r={x:.5,y:1},n="top",l=1;break;case J:r={x:0,y:.5},n="right",h=1;break;case j:r={x:1,y:.5},n="left",h=1}const{x:d,y:c,width:g,height:u}=t;r.x=d+r.x*g,r.y=c+r.y*u,tt(s||n,t,a);const f=e.PointHelper.getRotation(r,a,{x:r.x+(l?o.x:0),y:r.y+(h?o.y:0)});return l?l=-f:h=f,{origin:a,skewX:l,skewY:h}},getAround:(t,e)=>e&&!t?"center":t,getRotateDirection:(t,e,i=8)=>((t=(t+Math.round(e/(360/i)))%i)<0&&(t+=i),t),getFlipDirection(t,e,i){if(e)switch(t){case J:t=j;break;case Y:t=K;break;case Q:t=$;break;case j:t=J;break;case K:t=Y;break;case $:t=Q}if(i)switch(t){case N:t=q;break;case Y:t=Q;break;case K:t=$;break;case q:t=N;break;case Q:t=Y;break;case $:t=K}return t}},it={};function ot(t,i){const{editBox:o}=t,s=o.enterPoint;if(!s||!t.editing||!o.visible)return;if("circle"===s.name)return;let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:l,resizeable:h,rotateable:d,skewable:c}=t.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:f}=o;let p="resize"===g;p&&d&&(i.metaKey||i.ctrlKey||!h)&&(p=!1);const m=c&&!p&&"resize-line"===s.name?l:p?r:a;n+=45*(et.getFlipDirection(s.direction,u,f)+1),n=2*Math.round(e.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:L}=m,_=v+n;it[_]?s.cursor=it[_]:it[_]=s.cursor={url:nt(v,n),x:E,y:L}}function st(t){t.editBox.rect.cursor=t.mergeConfig.moveCursor}function nt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class rt extends e.Box{}const at=["top","right","bottom","left"];class lt extends e.Group{get flipped(){return this.flippedX||this.flippedY}get flippedX(){return this.scaleX<0}get flippedY(){return this.scaleY<0}get flippedOne(){return this.scaleX*this.scaleY<0}constructor(t){super(),this.view=new e.Group,this.rect=new e.Box({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new rt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new e.Group({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),this.rect.syncEventer=t,this.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,rotatePoints:n,resizeLines:r,rect:a,circle:l,buttons:h}=this,d=["bottom-right","bottom","bottom-left","left","top-left","top","top-right","right"];for(let o=0;o<8;o++)t=new rt({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new rt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new rt({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);h.add(l),this.listenPointEvents(l,"rotate",2),o.addMany(...n,a,h,...r,...s),this.add(o)}load(){const{mergeConfig:t,element:e,single:i}=this.editor,{rect:o,circle:s,resizePoints:n}=this,{stroke:r,strokeWidth:a,moveable:l}=t,h=this.getPointsStyle(),d=this.getMiddlePointsStyle();let c;for(let t=0;t<8;t++)c=n[t],c.set(this.getPointStyle(t%2?d[(t-1)/2%d.length]:h[t/2%h.length])),t%2||(c.rotation=t/2*90);s.set(this.getPointStyle(t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i&&l,e.syncEventer=i&&l?o:null,this.app.interaction.bottomList=i&&l?[{target:o,proxy:e}]:null}update(t){if(this.visible=!this.editor.element.locked,this.view.worldOpacity){const{mergeConfig:i}=this.editor,{width:o,height:s}=t,{rect:n,circle:r,resizePoints:a,rotatePoints:l,resizeLines:h}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=i,f="number"==typeof u?u:10,p=!(u&&o<f&&s<f);let m,v,E,L={};for(let n=0;n<8;n++)e.AroundHelper.toPoint(e.AroundHelper.directionData[n],t,L),v=a[n],m=l[n],E=h[Math.floor(n/2)],v.set(L),m.set(L),E.set(L),v.visible=E.visible=p&&!(!c&&!g),m.visible=p&&g&&c&&!i.rotatePoint,n%2&&(v.visible=m.visible=p&&!!d,(n+1)/2%2?(E.width=o,v.width>o-30&&(v.visible=!1)):(E.height=s,v.rotation=90,v.width>s-30&&(v.visible=!1)));r.visible=p&&g&&!!i.rotatePoint,n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!0}));const _=p&&(r.visible||this.buttons.children.length>1);this.buttons.visible=_,_&&this.layoutButtons()}}layoutButtons(){const{buttons:t,resizePoints:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=this.editor.mergeConfig,{flippedX:r,flippedY:a}=this;let l=at.indexOf(i);(l%2&&r||(l+1)%2&&a)&&o&&(l=(l+2)%4);const h=o?et.getRotateDirection(l,this.flippedOne?this.rotation:-this.rotation,4):l,d=e[2*h+1],c=h%2,g=h&&3!==h?1:-1,u=(s+(l%2?(n?d.width:0)+t.boxBounds.width:(n?d.height:0)+t.boxBounds.height)/2)*g;c?(t.x=d.x+u,t.y=d.y):(t.x=d.x,t.y=d.y+u),o&&(t.rotation=90*(h-l),t.scaleX=r?-1:1,t.scaleY=a?-1:1)}unload(){this.visible=!1}getPointStyle(t){const{stroke:e,strokeWidth:i,pointFill:o,pointSize:s,pointRadius:n}=this.editor.mergeConfig,r={fill:o,stroke:e,strokeWidth:i,around:"center",strokeAlign:"center",width:s,height:s,cornerRadius:n};return t?Object.assign(r,t):r}getPointsStyle(){const{point:t}=this.editor.mergeConfig;return t instanceof Array?t:[t]}getMiddlePointsStyle(){const{middlePoint:t}=this.editor.mergeConfig;return t instanceof Array?t:t?[t]:this.getPointsStyle()}onSelect(t){1===t.oldList.length&&(t.oldList[0].syncEventer=null,this.app&&(this.app.interaction.bottomList=null))}onDragStart(t){if(this.dragging=!0,"rect"===t.current.name){const{editor:t}=this;this.moving=!0,t.dragStartPoint={x:t.element.x,y:t.element.y},t.opacity=t.mergeConfig.hideOnMove?0:1}}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1)}onDrag(t){const{editor:e}=this;"rotate"===(this.enterPoint=t.current).pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):e.onScale(t),ot(e,t)}onArrow(t){if(this.editor.editing&&this.editor.mergeConfig.keyEvent){const e={x:0,y:0},i=t.shiftKey?10:1;switch(t.code){case"ArrowDown":e.y=i;break;case"ArrowUp":e.y=-i;break;case"ArrowLeft":e.x=-i;break;case"ArrowRight":e.x=i}this.editor.move(e)}}onDoubleTap(t){"double"===this.editor.mergeConfig.openInner&&this.openInner(t)}onLongPress(t){"long"===this.editor.mergeConfig.openInner&&this.openInner(t)}openInner(t){const{editor:e}=this;if(e.single){const{element:i}=e;i.isBranch?(e.openGroup(i),e.target=e.selector.findDeepOne(t)):e.openInnerEditor()}}listenPointEvents(t,e,o){const{editor:s}=this;t.direction=o,t.pointType=e,t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,this.onDrag,this),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.PointerEvent.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(i.PointerEvent.ENTER,(e=>{this.enterPoint=t,ot(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(S.SELECT,this.onSelect,this),t.on_(i.DragEvent.START,this.onDragStart,this),t.on_(i.DragEvent.DRAG,e.onMove,e),t.on_(i.DragEvent.END,this.onDragEnd,this),t.on_(i.ZoomEvent.BEFORE_ZOOM,e.onScale,e,!0),t.on_(i.RotateEvent.BEFORE_ROTATE,e.onRotate,e,!0),t.on_(i.PointerEvent.ENTER,(()=>st(e))),t.on_(i.PointerEvent.DOUBLE_TAP,this.onDoubleTap,this),t.on_(i.PointerEvent.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class ht extends e.UI{constructor(t){super(),this.editor=t,this.hittable=!1}__draw(t,e){const{editor:i}=this,{mask:o}=i.mergeConfig;if(o&&i.list.length){const{rect:s}=i.editBox,{width:n,height:r}=s.__;t.resetTransform(),t.fillWorld(t.bounds,o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const dt='\n<feOffset dy="1"/>\n<feGaussianBlur stdDeviation="1.5"/>\n<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>\n<feBlend mode="normal" in="SourceGraphic" result="shape"/>',ct={editSize:"size",keyEvent:!0,stroke:"#836DFF",strokeWidth:2,pointFill:"#FFFFFF",pointSize:10,pointRadius:16,rotateGap:45,buttonsDirection:"bottom",buttonsMargin:12,hideOnSmall:!0,moveCursor:"move",resizeCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate({{rotation}},12,12)">\n<path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>\n<path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">\n${dt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},rotateCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(135,12,12),rotate({{rotation}},12,12)">\n<path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>\n<path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">\n${dt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},skewCursor:{url:`\n<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">\n<g filter="url(#f)">\n<g transform="rotate(90,12,12),rotate({{rotation}},12,12)">\n<path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>\n<path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>\n</g>\n</g>\n<defs>\n<filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >\n${dt}\n</filter>\n</defs>\n</svg>\n`,x:12,y:12},selector:!0,hover:!0,select:"press",openInner:"double",boxSelect:!0,moveable:!0,resizeable:!0,rotateable:!0,skewable:!0};function gt(t){const{simulateTarget:i,leafList:o}=t,{x:s,y:n,width:r,height:a}=(new e.Bounds).setListWithFn(o.list,(t=>t.worldBoxBounds)),l=i.parent=o.list[0].leafer.zoomLayer,{scaleX:h,scaleY:d,e:c,f:g}=l.__world;i.reset({x:(s-c)/h,y:(n-g)/d,width:r/h,height:a/d})}const ut=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),ft=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),pt={group(t,i,o){t.sort(ft);const{app:s,parent:n}=t[0];let r;r=o&&o.add?o:new e.Group(o),n.addAt(r,n.children.indexOf(t[0])),t.sort(ut);const a=new e.Matrix(i.worldTransform);return a.divideParent(n.worldTransform),r.setTransform(a),r.editable=!0,r.hitChildren=!1,s.lockLayout(),t.forEach((t=>t.dropTo(r))),s.unlockLayout(),r},ungroup(t){const{app:e}=t[0],i=[];return e.lockLayout(),t.forEach((t=>{if(t.isBranch){const{parent:e,children:o}=t;for(;o.length;)i.push(o[0]),o[0].dropTo(e,e.children.indexOf(t));t.remove()}else i.push(t)})),e.unlockLayout(),i},toTop(t){t.sort(ut),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(ft),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},mt=e.Debug.get("EditToolCreator");function vt(){return t=>{Lt.register(t)}}const Et=vt,Lt={list:{},register(t){const{tag:e}=t.prototype;_t[e]?mt.repeat(e):_t[e]=t},get:(t,e)=>new _t[t](e)},{list:_t}=Lt;class yt extends S{constructor(t,e){super(t,e)}}yt.BEFORE_OPEN="innerEditor.before_open",yt.OPEN="innerEditor.open",yt.BEFORE_CLOSE="innerEditor.before_close",yt.CLOSE="innerEditor.close";class bt extends S{constructor(t,e){super(t,e)}}bt.GROUP="editor.group",bt.BEFORE_UNGROUP="editor.before_ungroup",bt.UNGROUP="editor.ungroup",bt.OPEN="editor.open_group",bt.CLOSE="editor.close_group";class wt extends e.Group{get mergeConfig(){const{element:t,config:e}=this;return this.single&&t.editConfig?Object.assign(Object.assign({},e),t.editConfig):e}get list(){return this.leafList.list}get editing(){return!!this.list.length}get groupOpening(){return!!this.openedGroupList.length}get multiple(){return this.list.length>1}get single(){return 1===this.list.length}get dragging(){return this.editBox.dragging}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,i){super(i),this.config=ct,this.leafList=new e.LeafList,this.openedGroupList=new e.LeafList,this.simulateTarget=new e.Rect({visible:!1}),this.editBox=new lt(this),this.editToolList={},this.selector=new X(this),this.editMask=new ht(this),this.targetEventIds=[],t&&(this.config=e.DataHelper.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox)}select(t){this.target=t}cancel(){this.target=null}hasItem(t){return this.leafList.has(t)}addItem(t){this.hasItem(t)||t.locked||(this.leafList.add(t),this.target=this.leafList.list)}removeItem(t){this.hasItem(t)&&(this.leafList.remove(t),this.target=this.leafList.list)}shiftItem(t){this.hasItem(t)?this.removeItem(t):this.addItem(t)}update(){this.editing&&(this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update())}updateEditBox(){this.multiple&>(this),this.update()}updateEditTool(){const t=this.editTool;if(t&&(this.editBox.unload(),t.unload(),this.editTool=null),this.editing){const t=this.single?this.list[0].editOuter:"EditTool";this.editTool=this.editToolList[t]=this.editToolList[t]||Lt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){const e={x:t.totalX,y:t.totalY};t.shiftKey&&(Math.abs(e.x)>Math.abs(e.y)?e.y=0:e.x=0),this.move(i.DragEvent.getValidMove(this.element,this.dragStartPoint,e))}onScale(t){const{element:e}=this;if(t instanceof i.ZoomEvent)"zoom"===this.mergeConfig.resizeable&&(t.stop(),this.scaleOf(e.getInnerPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;let{around:o,lockRatio:s}=this.mergeConfig;(t.shiftKey||e.lockRatio)&&(s=!0);const n=et.getScaleData(e.boxBounds,i,t.getInnerMove(e),s,et.getAround(o,t.altKey));this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:o,around:s,rotateGap:n}=this.mergeConfig,{direction:r,name:a}=t.current;if(o&&"resize-line"===a)return this.onSkew(t);const{element:l}=this;let h,d;if(t instanceof i.RotateEvent){if("rotate"!==this.mergeConfig.rotateable)return;t.stop(),d=t.rotation,h=l.getInnerPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=et.getRotateData(l.boxBounds,r,t.getInner(l),l.getInnerPoint(e),t.shiftKey?null:s||"center");d=i.rotation,h=i.origin}d=e.MathHelper.getGapRotation(d,n,l.rotation),d&&(l.scaleX*l.scaleY<0&&(d=-d),this.rotateOf(h,e.MathHelper.float(d,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=et.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),et.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.mergeConfig.moveable||this.element.locked)return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0),s=new O(O.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s),this.multiple&&i.move(t,e)}scaleWithDrag(t){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:e}=this,i=e.getWorldPoint(t.origin),o=new P(P.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:i}));this.editTool.onScaleWithDrag(o),this.emitEvent(o)}scaleOf(t,i,o=i,s){if(!this.mergeConfig.resizeable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(e.LeafHelper.getInnerOrigin(n,t));let a;if(this.multiple){const s=new e.Matrix(n.worldTransform);n.scaleOf(t,i,o),a=new e.Matrix(n.worldTransform).divide(s)}const l=new P(P.SCALE,{target:n,editor:this,worldOrigin:r,scaleX:i,scaleY:o,transform:a});this.editTool.onScale(l),this.emitEvent(l)}rotateOf(t,i){if(!this.mergeConfig.rotateable||this.element.locked)return;const{element:o}=this,s=o.getWorldPoint(e.LeafHelper.getInnerOrigin(o,t));let n;if(this.multiple){const s=new e.Matrix(o.worldTransform);o.rotateOf(t,i),n=new e.Matrix(o.worldTransform).divide(s)}const r=new T(T.ROTATE,{target:o,editor:this,worldOrigin:s,rotation:i,transform:n});this.editTool.onRotate(r),this.emitEvent(r)}skewOf(t,i,o=0,s){if(!this.mergeConfig.skewable||this.element.locked)return;const{element:n}=this,r=n.getWorldPoint(e.LeafHelper.getInnerOrigin(n,t));let a;if(this.multiple){const s=new e.Matrix(n.worldTransform);n.skewOf(t,i,o),a=new e.Matrix(n.worldTransform).divide(s)}const l=new H(H.SKEW,{target:n,editor:this,skewX:i,skewY:o,transform:a,worldOrigin:r});this.editTool.onSkew(l),this.emitEvent(l)}group(t){return this.multiple&&(this.target=pt.group(this.list,this.element,t),this.emitGroupEvent(bt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(bt.BEFORE_UNGROUP,t))),this.target=pt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(bt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(bt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(bt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:i}=t;this.editing&&(i=[],t.forEach((t=>this.list.every((i=>!e.LeafHelper.hasParent(i,t)))&&i.push(t)))),i.forEach((t=>this.closeGroup(t)))}this.editing&&!this.selector.dragging&&this.checkDeepSelect()}checkDeepSelect(){let t,{list:e}=this;for(let i=0;i<e.length;i++)for(t=e[i].parent;t&&!t.hitChildren;)this.openGroup(t),t=t.parent}emitGroupEvent(t,e){const i=new bt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t){if(t&&(this.target=t),this.single){const t=this.element,e=t.editInner;e&&Lt.list[e]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[e]||Lt.get(e,this),this.innerEditor.editTarget=t,this.emitInnerEvent(yt.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(yt.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(yt.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(yt.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new yt(t,{editTarget:i,innerEditor:e});this.emitEvent(o),i.emitEvent(o)}lock(){this.list.forEach((t=>t.locked=!0)),this.update()}unlock(){this.list.forEach((t=>t.locked=!1)),this.update()}toTop(){this.list.length&&(pt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(pt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{leafer:t}=this.list[0];this.targetEventIds=[t.on_(e.RenderEvent.START,this.update,this),t.on_([i.KeyEvent.HOLD,i.KeyEvent.UP],(t=>{ot(this,t)})),t.on_(i.KeyEvent.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.simulateTarget.destroy(),Object.values(this.editToolList).forEach((t=>t.destroy())),this.editToolList={},this.target=this.hoverTarget=this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}x([I((function(t,e){t.emitEvent(new S(S.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],wt.prototype,"hoverTarget",void 0),x([I((function(t,i){const{target:o}=t;o?t.leafList=o instanceof e.LeafList?o:new e.LeafList(o):t.leafList.reset(),t.emitEvent(new S(S.SELECT,{editor:t,value:o,oldValue:i})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&>(t),st(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],wt.prototype,"target",void 0);class kt{static registerInnerEditor(){Lt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new e.Group,this.onCreate()}onLoad(){}load(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!1,this.onLoad()}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){this.editor.selector.hittable=this.editor.app.tree.hitChildren=!0,this.onUnload()}onDestroy(){}destroy(){this.onDestroy(),this.editor&&(this.view&&this.view.destroy(),this.eventIds&&this.editor.off_(this.eventIds),this.editor=this.view=this.eventIds=null)}}t.EditTool=class extends kt{static registerEditTool(){Lt.register(this)}get tag(){return"EditTool"}onMove(t){const{moveX:e,moveY:i,editor:o}=t,{app:s,list:n}=o;s.lockLayout(),n.forEach((t=>{t.moveWorld(e,i)})),s.unlockLayout()}onScale(t){const{scaleX:e,scaleY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.scaleOfWorld(s,e,i,r)})),r.unlockLayout()}onRotate(t){const{rotation:e,transform:i,worldOrigin:o,editor:s}=t,{app:n,list:r}=s;n.lockLayout(),r.forEach((t=>{const n="scale"!==s.getEditSize(t);i?t.transformWorld(i,n):t.rotateOfWorld(o,e)})),n.unlockLayout()}onSkew(t){const{skewX:e,skewY:i,transform:o,worldOrigin:s,editor:n}=t,{app:r,list:a}=n;r.lockLayout(),a.forEach((t=>{const r="scale"!==n.getEditSize(t);o?t.transformWorld(o,r):t.skewOfWorld(s,e,i,r)})),r.unlockLayout()}load(){this.editBox.view.visible=!0,this.onLoad()}update(){const{editor:t,editBox:e}=this,{simulateTarget:i,element:o}=t;t.multiple&&i.parent.updateLayout();const{x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d,width:c,height:g}=o.getLayoutBounds("box",t,!0);e.set({x:s,y:n,scaleX:r,scaleY:a,rotation:l,skewX:h,skewY:d}),e.update({x:0,y:0,width:c,height:g}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=x([vt()],t.EditTool);const{left:xt,right:Mt}=e.Direction9,{move:St,copy:Ot}=e.PointHelper;return t.LineEditTool=class extends t.EditTool{constructor(){super(...arguments),this.scaleOfEvent=!0}get tag(){return"LineEditTool"}onScaleWithDrag(t){const{drag:i,direction:o,lockRatio:s,around:n}=t,r=t.target,a=o===xt;if(r.pathInputed){const{path:t}=r.__,{from:e,to:o}=this.getFromToByPath(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[1]=e.x,t[2]=e.y,t[4]=o.x,t[5]=o.y,r.path=t}else if(r.points){const{points:t}=r,{from:e,to:o}=this.getFromToByPoints(t);this.dragPoint(e,o,a,n,this.getInnerMove(r,i,s)),t[0]=e.x,t[1]=e.y,t[2]=o.x,t[3]=o.y,r.points=t}else{const t=e.getPointData(),{toPoint:o}=r;r.rotation=0,this.dragPoint(t,o,a,n,this.getInnerMove(r,i,s)),r.getLocalPointByInner(t,null,null,!0),r.getLocalPointByInner(o,null,null,!0),r.x=t.x,r.y=t.y,r.getInnerPointByLocal(o,null,null,!0),r.toPoint=o}}getInnerMove(t,e,i){const o=e.getInnerMove(t);return i&&(Math.abs(o.x)>Math.abs(o.y)?o.y=0:o.x=0),o}getFromToByPath(t){return{from:{x:t[1],y:t[2]},to:{x:t[4],y:t[5]}}}getFromToByPoints(t){return{from:{x:t[0],y:t[1]},to:{x:t[2],y:t[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(St(t,n,r),o&&St(e,-n,-r)):(o&&St(t,-n,-r),St(e,n,r))}onSkew(t){}onUpdate(){const{editBox:t}=this,{rotatePoints:e,resizeLines:i,resizePoints:o,rect:s}=t,n=this.editor.element;let r,a;if(n.pathInputed?r=this.getFromToByPath(n.__.path):n.points&&(r=this.getFromToByPoints(n.__.points)),r){const{from:i,to:a}=r;n.innerToWorld(i,i,!1,t),n.innerToWorld(a,a,!1,t),s.pen.clearPath().moveTo(i.x,i.y).lineTo(a.x,a.y),Ot(o[7],i),Ot(e[7],i),Ot(o[3],a),Ot(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===xt||t===Mt,o[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=x([vt()],t.LineEditTool),e.Creator.editor=function(t){return new wt(t)},e.UI.setEditConfig=function(t){e.defineKey(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},e.UI.setEditOuter=function(t){e.defineKey(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},e.UI.setEditInner=function(t){e.defineKey(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})},t.EditBox=lt,t.EditDataHelper=et,t.EditPoint=rt,t.EditSelect=X,t.EditSelectHelper=U,t.EditToolCreator=Lt,t.Editor=wt,t.EditorEvent=S,t.EditorGroupEvent=bt,t.EditorHelper=pt,t.EditorMoveEvent=O,t.EditorRotateEvent=T,t.EditorScaleEvent=P,t.EditorSkewEvent=H,t.InnerEditor=kt,t.InnerEditorEvent=yt,t.PathScaler=m,t.SelectArea=z,t.Stroker=D,t.registerEditTool=vt,t.registerInnerEditor=Et,t.scaleResize=L,t.scaleResizeFontSize=_,t.scaleResizeGroup=w,t.scaleResizePath=y,t.scaleResizePoints=b,t}({},LeaferUI,LeaferUI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.30",
|
|
4
4
|
"description": "@leafer-in/editor",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@leafer-ui/core": "1.0.0-rc.
|
|
38
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
39
|
-
"@leafer-in/resize": "1.0.0-rc.
|
|
40
|
-
"@leafer-in/interface": "1.0.0-rc.
|
|
37
|
+
"@leafer-ui/core": "1.0.0-rc.30",
|
|
38
|
+
"@leafer-ui/interface": "1.0.0-rc.30",
|
|
39
|
+
"@leafer-in/resize": "1.0.0-rc.30",
|
|
40
|
+
"@leafer-in/interface": "1.0.0-rc.30"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/Editor.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { EditorSkewEvent } from './event/EditorSkewEvent'
|
|
|
11
11
|
|
|
12
12
|
import { EditSelect } from './display/EditSelect'
|
|
13
13
|
import { EditBox } from './display/EditBox'
|
|
14
|
+
import { EditMask } from './display/EditMask'
|
|
14
15
|
|
|
15
16
|
import { config } from './config'
|
|
16
17
|
|
|
@@ -35,10 +36,10 @@ export class Editor extends Group implements IEditor {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
@targetAttr(onHover)
|
|
38
|
-
public hoverTarget
|
|
39
|
+
public hoverTarget?: IUI
|
|
39
40
|
|
|
40
41
|
@targetAttr(onTarget)
|
|
41
|
-
public target
|
|
42
|
+
public target?: IUI | IUI[]
|
|
42
43
|
|
|
43
44
|
// 列表
|
|
44
45
|
|
|
@@ -65,12 +66,13 @@ export class Editor extends Group implements IEditor {
|
|
|
65
66
|
public editBox: IEditBox = new EditBox(this)
|
|
66
67
|
public get buttons() { return this.editBox.buttons }
|
|
67
68
|
|
|
68
|
-
public editTool
|
|
69
|
+
public editTool?: IEditTool
|
|
69
70
|
|
|
70
|
-
public innerEditor
|
|
71
|
+
public innerEditor?: IInnerEditor
|
|
71
72
|
public editToolList: IObject = {}
|
|
72
73
|
|
|
73
74
|
public selector: EditSelect = new EditSelect(this)
|
|
75
|
+
public editMask: EditMask = new EditMask(this)
|
|
74
76
|
|
|
75
77
|
public dragStartPoint: IPointData
|
|
76
78
|
|
|
@@ -80,7 +82,7 @@ export class Editor extends Group implements IEditor {
|
|
|
80
82
|
constructor(userConfig?: IEditorConfig, data?: IGroupInputData) {
|
|
81
83
|
super(data)
|
|
82
84
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config)
|
|
83
|
-
this.addMany(this.selector, this.editBox)
|
|
85
|
+
this.addMany(this.editMask, this.selector, this.editBox)
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
// select
|
package/src/display/EditBox.ts
CHANGED
|
@@ -219,7 +219,10 @@ export class EditBox extends Group implements IEditBox {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
protected onSelect(e: EditorEvent): void {
|
|
222
|
-
if (e.oldList.length === 1)
|
|
222
|
+
if (e.oldList.length === 1) {
|
|
223
|
+
e.oldList[0].syncEventer = null
|
|
224
|
+
if (this.app) this.app.interaction.bottomList = null
|
|
225
|
+
}
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
// drag
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions } from '@leafer-ui/interface'
|
|
2
|
+
import { UI } from '@leafer-ui/draw'
|
|
3
|
+
|
|
4
|
+
import { IEditor } from '@leafer-in/interface'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class EditMask extends UI {
|
|
8
|
+
|
|
9
|
+
public editor: IEditor
|
|
10
|
+
|
|
11
|
+
constructor(editor: IEditor) {
|
|
12
|
+
super()
|
|
13
|
+
this.editor = editor
|
|
14
|
+
this.hittable = false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public __draw(canvas: ILeaferCanvas, options: IRenderOptions): void {
|
|
18
|
+
const { editor } = this
|
|
19
|
+
const { mask } = editor.mergeConfig
|
|
20
|
+
|
|
21
|
+
if (mask && editor.list.length) {
|
|
22
|
+
const { rect } = editor.editBox
|
|
23
|
+
const { width, height } = rect.__
|
|
24
|
+
|
|
25
|
+
canvas.resetTransform()
|
|
26
|
+
canvas.fillWorld(canvas.bounds, mask)
|
|
27
|
+
canvas.setWorld(rect.__world, options.matrix)
|
|
28
|
+
canvas.clearRect(0, 0, width, height)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public destroy(): void {
|
|
33
|
+
this.editor = null
|
|
34
|
+
super.destroy()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@leafer-in/resize';
|
|
2
|
-
import { IBounds, ILeafList, IUI, IEventListenerId, ILeaf, IPointerEvent, IGroup, IObject, IPointData, IGroupInputData, IEditSize, IAlign, IBox, IBoundsData, IBoxInputData, IKeyEvent, IRect, IRectInputData,
|
|
3
|
-
import { Group, Event, Direction9, Box,
|
|
2
|
+
import { IBounds, ILeafList, IUI, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IPointData, IGroupInputData, IEditSize, IAlign, IBox, IBoundsData, IBoxInputData, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround } from '@leafer-ui/interface';
|
|
3
|
+
import { Group, UI, Event, Direction9, Box, Answer } from '@leafer-ui/draw';
|
|
4
4
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent } from '@leafer-ui/core';
|
|
5
5
|
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditorEvent, IEditPoint, IEditPointType, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent, IEditorGroupEvent, IInnerEditorEvent, IUI as IUI$1, IDragEvent as IDragEvent$1, IPointData as IPointData$1, IPathCommandData, IFromToData, IAround as IAround$1 } from '@leafer-in/interface';
|
|
6
6
|
|
|
@@ -39,11 +39,18 @@ declare class EditSelect extends Group implements IEditSelect {
|
|
|
39
39
|
destroy(): void;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
declare class EditMask extends UI {
|
|
43
|
+
editor: IEditor;
|
|
44
|
+
constructor(editor: IEditor);
|
|
45
|
+
__draw(canvas: ILeaferCanvas, options: IRenderOptions): void;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
declare class Editor extends Group implements IEditor {
|
|
43
50
|
config: IEditorConfig;
|
|
44
51
|
get mergeConfig(): IEditorConfig;
|
|
45
|
-
hoverTarget
|
|
46
|
-
target
|
|
52
|
+
hoverTarget?: IUI;
|
|
53
|
+
target?: IUI | IUI[];
|
|
47
54
|
get list(): IUI[];
|
|
48
55
|
leafList: ILeafList;
|
|
49
56
|
openedGroupList: ILeafList;
|
|
@@ -57,10 +64,11 @@ declare class Editor extends Group implements IEditor {
|
|
|
57
64
|
simulateTarget: IUI;
|
|
58
65
|
editBox: IEditBox;
|
|
59
66
|
get buttons(): IGroup;
|
|
60
|
-
editTool
|
|
61
|
-
innerEditor
|
|
67
|
+
editTool?: IEditTool;
|
|
68
|
+
innerEditor?: IInnerEditor;
|
|
62
69
|
editToolList: IObject;
|
|
63
70
|
selector: EditSelect;
|
|
71
|
+
editMask: EditMask;
|
|
64
72
|
dragStartPoint: IPointData;
|
|
65
73
|
targetEventIds: IEventListenerId[];
|
|
66
74
|
constructor(userConfig?: IEditorConfig, data?: IGroupInputData);
|