@leafer-in/editor 1.3.2 → 1.3.3

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 CHANGED
@@ -3,7 +3,6 @@
3
3
  var draw = require('@leafer-ui/draw');
4
4
  var core = require('@leafer-ui/core');
5
5
  require('@leafer-in/resize');
6
- require('@leafer-in/find');
7
6
 
8
7
  /******************************************************************************
9
8
  Copyright (c) Microsoft Corporation.
@@ -19,7 +18,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
18
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
19
  PERFORMANCE OF THIS SOFTWARE.
21
20
  ***************************************************************************** */
22
- /* global Reflect, Promise, SuppressedError, Symbol */
21
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
22
 
24
23
 
25
24
  function __decorate(decorators, target, key, desc) {
@@ -163,7 +162,7 @@ class Stroker extends draw.UI {
163
162
  }
164
163
  __decorate([
165
164
  targetAttr(onTarget$1)
166
- ], Stroker.prototype, "target", void 0);
165
+ ], Stroker.prototype, "target", undefined);
167
166
  function onTarget$1(stroker) {
168
167
  const value = stroker.target;
169
168
  stroker.list = value ? (value instanceof Array ? value : [value]) : [];
@@ -189,34 +188,43 @@ class SelectArea extends draw.Group {
189
188
  }
190
189
  }
191
190
 
192
- const { No, Yes, NoAndSkip, YesAndSkip } = draw.Answer;
193
191
  const EditSelectHelper = {
194
192
  findOne(path) {
195
193
  return path.list.find((leaf) => leaf.editable);
196
194
  },
197
- findBounds(leaf, bounds) {
198
- if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
199
- if (leaf.__.editable) {
200
- if (leaf.isBranch && !leaf.__.hitChildren) {
201
- return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
202
- }
203
- else if (leaf.isFrame) {
204
- return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No;
195
+ findByBounds(branch, bounds) {
196
+ const list = [];
197
+ eachFind([branch], list, bounds);
198
+ return list;
199
+ }
200
+ };
201
+ function eachFind(children, list, bounds) {
202
+ let child, data;
203
+ for (let i = 0, len = children.length; i < len; i++) {
204
+ child = children[i], data = child.__;
205
+ if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {
206
+ if (data.editable) {
207
+ if (child.isBranch && !data.hitChildren) {
208
+ if (data.hitSelf)
209
+ list.push(child);
210
+ continue;
205
211
  }
206
- else {
207
- if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf)
208
- return Yes;
212
+ else if (child.isFrame) {
213
+ if (bounds.includes(child.__layout.boxBounds, child.__world)) {
214
+ list.push(child);
215
+ continue;
216
+ }
209
217
  }
218
+ else if (bounds.hit(child.__layout.boxBounds, child.__world) && data.hitSelf)
219
+ list.push(child);
210
220
  }
211
- return No;
212
- }
213
- else {
214
- return leaf.isBranch ? NoAndSkip : No;
221
+ if (child.isBranch)
222
+ eachFind(child.children, list, bounds);
215
223
  }
216
224
  }
217
- };
225
+ }
218
226
 
219
- const { findOne } = EditSelectHelper;
227
+ const { findOne, findByBounds } = EditSelectHelper;
220
228
  class EditSelect extends draw.Group {
221
229
  get dragging() { return !!this.originList; }
222
230
  get running() { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector; }
@@ -339,7 +347,7 @@ class EditSelect extends draw.Group {
339
347
  const { editor } = this;
340
348
  const total = e.getInnerTotal(this);
341
349
  const dragBounds = this.bounds.clone().unsign();
342
- const list = new draw.LeafList(editor.app.find(EditSelectHelper.findBounds, dragBounds));
350
+ const list = new draw.LeafList(findByBounds(editor.app, dragBounds));
343
351
  this.bounds.width = total.x;
344
352
  this.bounds.height = total.y;
345
353
  this.selectArea.setBounds(dragBounds.get());
@@ -375,7 +383,7 @@ class EditSelect extends draw.Group {
375
383
  return target.leafer !== this.editor.leafer;
376
384
  }
377
385
  allowDrag(e) {
378
- if (this.running && (this.editor.mergeConfig.boxSelect && draw.Plugin.has('find')) && !e.target.draggable) {
386
+ if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
379
387
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
380
388
  }
381
389
  else {
@@ -1084,6 +1092,8 @@ function onTarget(editor, oldValue) {
1084
1092
  const { target } = editor;
1085
1093
  if (target) {
1086
1094
  editor.leafList = target instanceof draw.LeafList ? target : new draw.LeafList(target instanceof Array ? target : target);
1095
+ if (editor.multiple)
1096
+ simulate(editor);
1087
1097
  }
1088
1098
  else {
1089
1099
  editor.simulateTarget.remove();
@@ -1094,8 +1104,6 @@ function onTarget(editor, oldValue) {
1094
1104
  editor.checkOpenedGroups();
1095
1105
  if (editor.editing) {
1096
1106
  editor.waitLeafer(() => {
1097
- if (editor.multiple)
1098
- simulate(editor);
1099
1107
  updateMoveCursor(editor);
1100
1108
  editor.updateEditTool();
1101
1109
  editor.update();
@@ -1325,6 +1333,8 @@ class Editor extends draw.Group {
1325
1333
  }
1326
1334
  update() {
1327
1335
  if (this.editing) {
1336
+ if (!this.element.parent)
1337
+ return this.cancel();
1328
1338
  if (this.innerEditing)
1329
1339
  this.innerEditor.update();
1330
1340
  this.editTool.update();
@@ -1641,10 +1651,10 @@ class Editor extends draw.Group {
1641
1651
  }
1642
1652
  __decorate([
1643
1653
  targetAttr(onHover)
1644
- ], Editor.prototype, "hoverTarget", void 0);
1654
+ ], Editor.prototype, "hoverTarget", undefined);
1645
1655
  __decorate([
1646
1656
  targetAttr(onTarget)
1647
- ], Editor.prototype, "target", void 0);
1657
+ ], Editor.prototype, "target", undefined);
1648
1658
 
1649
1659
  class InnerEditor {
1650
1660
  static registerInnerEditor() {
@@ -1879,7 +1889,7 @@ exports.LineEditTool = __decorate([
1879
1889
  registerEditTool()
1880
1890
  ], exports.LineEditTool);
1881
1891
 
1882
- draw.Plugin.add('editor', 'resize', 'find');
1892
+ draw.Plugin.add('editor', 'resize');
1883
1893
  draw.Creator.editor = function (options) { return new Editor(options); };
1884
1894
  draw.dataType(false)(draw.Box.prototype, 'textBox');
1885
1895
  draw.defineKey(draw.UI.prototype, 'editOuter', {
@@ -1,7 +1,6 @@
1
- import { Event, defineKey, getMatrixData, getBoundsData, UI, Paint, MatrixHelper, BoundsHelper, LeafBoundsHelper, Group, Rect, Answer, Bounds, LeafList, Plugin, PointHelper, AroundHelper, MathHelper, Direction9, Box, Text, Matrix, Debug, PropertyEvent, LeafHelper, DataHelper, RenderEvent, getPointData, Creator, dataType } from '@leafer-ui/draw';
2
- import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, Plugin as Plugin$1, RotateEvent, KeyEvent } from '@leafer-ui/core';
1
+ import { Event, defineKey, getMatrixData, getBoundsData, UI, Paint, MatrixHelper, BoundsHelper, LeafBoundsHelper, Group, Rect, Bounds, LeafList, PointHelper, AroundHelper, MathHelper, Direction9, Box, Text, Matrix, Debug, PropertyEvent, LeafHelper, DataHelper, RenderEvent, getPointData, Plugin as Plugin$1, Creator, dataType } from '@leafer-ui/draw';
2
+ import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, Plugin, RotateEvent, KeyEvent } from '@leafer-ui/core';
3
3
  import '@leafer-in/resize';
4
- import '@leafer-in/find';
5
4
 
6
5
  /******************************************************************************
7
6
  Copyright (c) Microsoft Corporation.
@@ -17,7 +16,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
16
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
17
  PERFORMANCE OF THIS SOFTWARE.
19
18
  ***************************************************************************** */
20
- /* global Reflect, Promise, SuppressedError, Symbol */
19
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
21
20
 
22
21
 
23
22
  function __decorate(decorators, target, key, desc) {
@@ -161,7 +160,7 @@ class Stroker extends UI {
161
160
  }
162
161
  __decorate([
163
162
  targetAttr(onTarget$1)
164
- ], Stroker.prototype, "target", void 0);
163
+ ], Stroker.prototype, "target", undefined);
165
164
  function onTarget$1(stroker) {
166
165
  const value = stroker.target;
167
166
  stroker.list = value ? (value instanceof Array ? value : [value]) : [];
@@ -187,34 +186,43 @@ class SelectArea extends Group {
187
186
  }
188
187
  }
189
188
 
190
- const { No, Yes, NoAndSkip, YesAndSkip } = Answer;
191
189
  const EditSelectHelper = {
192
190
  findOne(path) {
193
191
  return path.list.find((leaf) => leaf.editable);
194
192
  },
195
- findBounds(leaf, bounds) {
196
- if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
197
- if (leaf.__.editable) {
198
- if (leaf.isBranch && !leaf.__.hitChildren) {
199
- return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
200
- }
201
- else if (leaf.isFrame) {
202
- return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No;
193
+ findByBounds(branch, bounds) {
194
+ const list = [];
195
+ eachFind([branch], list, bounds);
196
+ return list;
197
+ }
198
+ };
199
+ function eachFind(children, list, bounds) {
200
+ let child, data;
201
+ for (let i = 0, len = children.length; i < len; i++) {
202
+ child = children[i], data = child.__;
203
+ if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {
204
+ if (data.editable) {
205
+ if (child.isBranch && !data.hitChildren) {
206
+ if (data.hitSelf)
207
+ list.push(child);
208
+ continue;
203
209
  }
204
- else {
205
- if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf)
206
- return Yes;
210
+ else if (child.isFrame) {
211
+ if (bounds.includes(child.__layout.boxBounds, child.__world)) {
212
+ list.push(child);
213
+ continue;
214
+ }
207
215
  }
216
+ else if (bounds.hit(child.__layout.boxBounds, child.__world) && data.hitSelf)
217
+ list.push(child);
208
218
  }
209
- return No;
210
- }
211
- else {
212
- return leaf.isBranch ? NoAndSkip : No;
219
+ if (child.isBranch)
220
+ eachFind(child.children, list, bounds);
213
221
  }
214
222
  }
215
- };
223
+ }
216
224
 
217
- const { findOne } = EditSelectHelper;
225
+ const { findOne, findByBounds } = EditSelectHelper;
218
226
  class EditSelect extends Group {
219
227
  get dragging() { return !!this.originList; }
220
228
  get running() { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector; }
@@ -337,7 +345,7 @@ class EditSelect extends Group {
337
345
  const { editor } = this;
338
346
  const total = e.getInnerTotal(this);
339
347
  const dragBounds = this.bounds.clone().unsign();
340
- const list = new LeafList(editor.app.find(EditSelectHelper.findBounds, dragBounds));
348
+ const list = new LeafList(findByBounds(editor.app, dragBounds));
341
349
  this.bounds.width = total.x;
342
350
  this.bounds.height = total.y;
343
351
  this.selectArea.setBounds(dragBounds.get());
@@ -373,7 +381,7 @@ class EditSelect extends Group {
373
381
  return target.leafer !== this.editor.leafer;
374
382
  }
375
383
  allowDrag(e) {
376
- if (this.running && (this.editor.mergeConfig.boxSelect && Plugin.has('find')) && !e.target.draggable) {
384
+ if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
377
385
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
378
386
  }
379
387
  else {
@@ -1082,6 +1090,8 @@ function onTarget(editor, oldValue) {
1082
1090
  const { target } = editor;
1083
1091
  if (target) {
1084
1092
  editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target);
1093
+ if (editor.multiple)
1094
+ simulate(editor);
1085
1095
  }
1086
1096
  else {
1087
1097
  editor.simulateTarget.remove();
@@ -1092,8 +1102,6 @@ function onTarget(editor, oldValue) {
1092
1102
  editor.checkOpenedGroups();
1093
1103
  if (editor.editing) {
1094
1104
  editor.waitLeafer(() => {
1095
- if (editor.multiple)
1096
- simulate(editor);
1097
1105
  updateMoveCursor(editor);
1098
1106
  editor.updateEditTool();
1099
1107
  editor.update();
@@ -1298,7 +1306,7 @@ class Editor extends Group {
1298
1306
  if (userConfig)
1299
1307
  this.config = DataHelper.default(userConfig, this.config);
1300
1308
  this.addMany(this.editMask, this.selector, this.editBox);
1301
- if (!Plugin$1.has('resize'))
1309
+ if (!Plugin.has('resize'))
1302
1310
  this.config.editSize = 'scale';
1303
1311
  }
1304
1312
  select(target) {
@@ -1323,6 +1331,8 @@ class Editor extends Group {
1323
1331
  }
1324
1332
  update() {
1325
1333
  if (this.editing) {
1334
+ if (!this.element.parent)
1335
+ return this.cancel();
1326
1336
  if (this.innerEditing)
1327
1337
  this.innerEditor.update();
1328
1338
  this.editTool.update();
@@ -1639,10 +1649,10 @@ class Editor extends Group {
1639
1649
  }
1640
1650
  __decorate([
1641
1651
  targetAttr(onHover)
1642
- ], Editor.prototype, "hoverTarget", void 0);
1652
+ ], Editor.prototype, "hoverTarget", undefined);
1643
1653
  __decorate([
1644
1654
  targetAttr(onTarget)
1645
- ], Editor.prototype, "target", void 0);
1655
+ ], Editor.prototype, "target", undefined);
1646
1656
 
1647
1657
  class InnerEditor {
1648
1658
  static registerInnerEditor() {
@@ -1877,7 +1887,7 @@ LineEditTool = __decorate([
1877
1887
  registerEditTool()
1878
1888
  ], LineEditTool);
1879
1889
 
1880
- Plugin.add('editor', 'resize', 'find');
1890
+ Plugin$1.add('editor', 'resize');
1881
1891
  Creator.editor = function (options) { return new Editor(options); };
1882
1892
  dataType(false)(Box.prototype, 'textBox');
1883
1893
  defineKey(UI.prototype, 'editOuter', {
@@ -1 +1 @@
1
- import{Event as t,defineKey as e,getMatrixData as i,getBoundsData as s,UI as o,Paint as n,MatrixHelper as r,BoundsHelper as a,LeafBoundsHelper as h,Group as l,Rect as d,Answer as c,Bounds as g,LeafList as u,Plugin as f,PointHelper as p,AroundHelper as m,MathHelper as v,Direction9 as b,Box as y,Text as w,Matrix as E,Debug as L,PropertyEvent as k,LeafHelper as _,DataHelper as x,RenderEvent as T,getPointData as O,Creator as S,dataType as M}from"@leafer-ui/draw";import{PointerEvent as P,DragEvent as C,MoveEvent as V,ZoomEvent as B,Plugin as H,RotateEvent as I,KeyEvent as R}from"@leafer-ui/core";import"@leafer-in/resize";import"@leafer-in/find";function D(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 A(t){return t?t instanceof Array?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class Z extends t{get list(){return A(this.value)}get oldList(){return A(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}Z.SELECT="editor.select",Z.HOVER="editor.hover";class z extends Z{constructor(t,e){super(t,e)}}z.MOVE="editor.move";class W extends Z{constructor(t,e){super(t,e)}}W.SCALE="editor.scale";class F extends Z{constructor(t,e){super(t,e)}}F.ROTATE="editor.rotate";class Y extends Z{constructor(t,e){super(t,e)}}function X(t){return(i,s)=>{const o="_"+s;e(i,s,{get(){return this[o]},set(e){const i=this[o];i!==e&&(this[o]=e,t(this,i))}})}}Y.SKEW="editor.skew";const{abs:G}=Math,{copy:U,scale:N}=r,{setListWithFn:j}=a,{worldBounds:K}=h,$=i(),q=s();class J extends o{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(j(q,t,K),this.set(q)):this.width=this.height=1}__draw(t,e){const{list:i}=this;if(i.length){let s;const o=this.__,{stroke:r,strokeWidth:a,fill:h}=o,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:g}=s;if(!l||l.hit(g,e.matrix)){const i=G(c.scaleX),l=G(c.scaleY);if(i!==l){U($,c),N($,1/i,1/l),t.setWorld($,e.matrix),t.beginPath(),o.strokeWidth=a;const{x:n,y:r,width:h,height:d}=s.__layout.boxBounds;t.rect(n*i,r*l,h*i,d*l)}else t.setWorld(c,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),o.strokeWidth=a/G(c.scaleX);r&&("string"==typeof r?n.stroke(r,this,t):n.strokes(r,this,t)),h&&("string"==typeof h?n.fill(h,this,t):n.fills(h,this,t))}}o.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}D([X((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],J.prototype,"target",void 0);class Q extends l{constructor(t){super(t),this.strokeArea=new d({strokeAlign:"center"}),this.fillArea=new d,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:tt,Yes:et,NoAndSkip:it,YesAndSkip:st}=c,ot={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?st:it;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?st:tt;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return et}return tt}return t.isBranch?it:tt}},{findOne:nt}=ot;class rt extends l{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 J,this.targetStroker=new J,this.bounds=new g,this.selectArea=new Q,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.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),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(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInnerPoint(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(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new u(e.app.find(ot.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(t){t.multiTouch||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&&f.has("find"))||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!nt(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new u(this.editor.editBox.rect)};return nt(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):nt(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_(Z.HOVER,this.onHover,this),t.on_(Z.SELECT,this.onSelect,this),e.on_(P.MOVE,this.onPointerMove,this),e.on_(P.BEFORE_DOWN,this.onBeforeDown,this),e.on_(P.TAP,this.onTap,this),e.on_(C.START,this.onDragStart,this,!0),e.on_(C.DRAG,this.onDrag,this),e.on_(C.END,this.onDragEnd,this),e.on_(V.MOVE,this.onAutoMove,this),e.on_([B.ZOOM,V.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:at,top:ht,topRight:lt,right:dt,bottomRight:ct,bottom:gt,bottomLeft:ut,left:ft}=b,{toPoint:pt}=m,{within:mt}=v,vt={getScaleData(t,e,i,s,o,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,y=v<0?-1:1,w=b<0?-1:1,E=a?v:y*g.width/p,L=a?b:w*g.height/m;s.x*=a?v:y,s.y*=a?b:w,Math.abs(s.x)===p&&(s.x+=.1),Math.abs(s.y)===m&&(s.y+=.1);const k=(-s.y+m)/m,_=(s.x+p)/p,x=(s.y+m)/m,T=(-s.x+p)/p;switch(i){case ht:c=k,h="bottom";break;case dt:d=_,h="left";break;case gt:c=x,h="top";break;case ft:d=T,h="right";break;case at:c=k,d=T,h="bottom-right";break;case lt:c=k,d=_,h="bottom-left";break;case ct:c=x,d=_,h="top-left";break;case ut:c=x,d=T,h="top-right"}if(o){if(!("corner"===o&&i%2)){let t;switch(i){case ht:case gt:t=c;break;case ft:case dt:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=E,c/=L,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=mt(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=mt(e*c,f)/e}return pt(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:o,around:n}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case at:n="bottom-right";break;case lt:n="bottom-left";break;case ct:n="top-left";break;case ut:n="top-right";break;default:n="center"}return pt(o||n,t,r,!0),{origin:r,rotation:p.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case ht:n={x:.5,y:0},o="bottom",a=1;break;case gt:n={x:.5,y:1},o="top",a=1;break;case ft:n={x:0,y:.5},o="right",h=1;break;case dt:n={x:1,y:.5},o="left",h=1}const{width:l,height:d}=t;n.x=n.x*l,n.y=n.y*d,pt(s||o,t,r,!0);const c=p.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-c:h=c,{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 ft:t=dt;break;case at:t=lt;break;case ut:t=ct;break;case dt:t=ft;break;case lt:t=at;break;case ct:t=ut}if(i)switch(t){case ht:t=gt;break;case at:t=ut;break;case lt:t=ct;break;case gt:t=ht;break;case ut:t=at;break;case ct:t=lt}return t}},bt={};function yt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));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(v.formatRotation(o,!0)/2);const{url:m,x:b,y:y}=p,w=m+o;bt[w]?s.cursor=bt[w]:bt[w]=s.cursor={url:Et(m,o),x:b,y:y}}function wt(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function Et(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Lt extends y{}const kt=["top","right","bottom","left"];class _t extends l{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 l,this.rect=new y({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new Lt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new l({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),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 Lt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new Lt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new Lt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,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:a}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);o.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i,s.syncEventer=i&&this.editor,i&&(e.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:e}])}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,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=e,f="number"==typeof u?u:10,p=!(u&&i<f&&s<f);let v,b,y,w={};for(let o=0;o<8;o++)m.toPoint(m.directionData[o],t,w),b=a[o],v=h[o],y=l[Math.floor(o/2)],b.set(w),v.set(w),y.set(w),b.visible=y.visible=p&&!(!c&&!g),v.visible=p&&g&&c&&!e.rotatePoint,o%2&&(b.visible=v.visible=p&&!!d,(o+1)/2%2?(y.width=i,b.width>i-30&&(b.visible=!1)):(y.height=s,b.rotation=90,b.width>s-30&&(b.visible=!1)));n.visible=p&&g&&!(!e.circle&&!e.rotatePoint),n.visible&&this.layoutCircle(e),o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0})),r.visible=p&&r.children.length>0,r.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:o,middlePoint:n}=t,r=kt.indexOf(e||(this.buttons.children.length&&"bottom"===o?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=kt.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;this.setButtonPosition(e,l,o,!!n),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*r;n?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}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,offsetX:0,offsetY:0};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){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),yt(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;if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find((t=>t.editable&&t instanceof w))||t.find((t=>t instanceof w));if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(C.START,this.onDragStart,this),t.on_(C.DRAG,this.onDrag,this),t.on_(C.END,this.onDragEnd,this),t.on_(P.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(P.ENTER,(e=>{this.enterPoint=t,yt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(Z.SELECT,this.onSelect,this),t.on_(C.START,this.onDragStart,this),t.on_(C.DRAG,e.onMove,e),t.on_(C.END,this.onDragEnd,this),t.on_(P.ENTER,(()=>wt(e))),t.on_(P.DOUBLE_TAP,this.onDoubleTap,this),t.on_(P.LONG_PRESS,this.onLongPress,this)]}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.editor=null,this.__removeListenEvents(),super.destroy()}}class xt extends o{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,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const Tt='\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"/>',Ot={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${Tt}\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${Tt}\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${Tt}\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,flipable:!0,rotateable:!0,skewable:!0},St=new g;function Mt(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(St.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),s.add(e)}const Pt=(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),Vt={group(t,e,i){t.sort(Ct);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new l(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(Pt);const r=new E(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&&!t.isBranchLeaf){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(Pt),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Ct),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Bt=L.get("EditToolCreator");function Ht(){return t=>{Rt.register(t)}}const It=Ht,Rt={list:{},register(t){const{tag:e}=t.prototype;Dt[e]&&Bt.repeat(e),Dt[e]=t},get:(t,e)=>new Dt[t](e)},{list:Dt}=Rt;class At extends Z{constructor(t,e){super(t,e)}}At.BEFORE_OPEN="innerEditor.before_open",At.OPEN="innerEditor.open",At.BEFORE_CLOSE="innerEditor.before_close",At.CLOSE="innerEditor.close";class Zt extends Z{constructor(t,e){super(t,e)}}Zt.GROUP="editor.group",Zt.BEFORE_UNGROUP="editor.before_ungroup",Zt.UNGROUP="editor.ungroup",Zt.OPEN="editor.open_group",Zt.CLOSE="editor.close_group";const{updateMatrix:zt}=_,Wt={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},Ft="top-left";class Yt extends d{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(k.CHANGE,(e=>{if(this.checkChange&&Wt[e.attrName]){const{attrName:i,newValue:s,oldValue:o}=e,n="s"===i[0]?(s||1)/(o||1):(s||0)-(o||0);this.canChange=!1;const r=this.__;r[i]=o,zt(this.parent),zt(this);const a=new E(this.__world);switch(r[i]=s,this.__layout.rotationChange(),zt(this),this.changedTransform=new E(this.__world).divide(a),i){case"x":t.move(n,0);break;case"y":t.move(0,n);break;case"rotation":t.rotateOf(Ft,n);break;case"scaleX":t.scaleOf(Ft,n,1);break;case"scaleY":t.scaleOf(Ft,1,n);break;case"skewX":t.skewOf(Ft,n,0);break;case"skewY":t.skewOf(Ft,0,n)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Xt extends l{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 dragHoverExclude(){return[this.editBox.rect]}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 moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=x.clone(Ot),this.leafList=new u,this.openedGroupList=new u,this.simulateTarget=new Yt(this),this.editBox=new _t(this),this.editToolList={},this.selector=new rt(this),this.editMask=new xt(this),this.targetEventIds=[],t&&(this.config=x.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox),H.has("resize")||(this.config.editSize="scale")}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&&Mt(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]||Rt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof V){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{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(C.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:o,flipable:n,editSize:r}=this.mergeConfig;if(t instanceof B)"zoom"===o&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:o}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=vt.getScaleData(e,this.dragStartBounds,o,t.getInnerTotal(e),s,vt.getAround(i,t.altKey),n,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:o}=this.mergeConfig,{direction:n,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:a}=this;let h,l;if(t instanceof I){if("rotate"!==i)return;t.stop(),l=t.rotation,h=a.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=vt.getRotateData(a.boxBounds,n,t.getBoxPoint(a),a.getBoxPoint(e),t.shiftKey?null:a.around||a.origin||s||"center");l=i.rotation,h=i.origin}l=v.getGapRotation(l,o,a.rotation),l&&(a.scaleX*a.scaleY<0&&(l=-l),this.rotateOf(h,v.float(l,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.checkTransform("moveable"))return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const o=new z(z.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new W(W.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.scaleOf(t,e,i))))),a=new W(W.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.safeChange((()=>e.flip(t))))):new E(_.getFlipTransform(e,t)),o=new W(W.SCALE,{target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,s=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new F(F.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.checkTransform("skewable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.skewOf(t,e,i))))),a=new Y(Y.SKEW,{target:o,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(_.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this;if(this.multiple&&!e.canChange)return e.changedTransform;const i=new E(e.worldTransform);return t(),new E(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.target=Vt.group(this.list,this.element,t),this.emitGroupEvent(Zt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Zt.BEFORE_UNGROUP,t))),this.target=Vt.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Zt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Zt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Zt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!_.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 Zt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&Rt.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||Rt.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(At.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(At.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(At.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(At.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new At(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&&(Vt.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(Vt.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e}=this;this.targetEventIds=[e.on_(T.START,this.update,this),t.on_(T.CHILD_START,this.forceRender,this),t.on_(V.BEFORE_MOVE,this.onMove,this,!0),t.on_(B.BEFORE_ZOOM,this.onScale,this,!0),t.on_(I.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([R.HOLD,R.UP],(t=>{yt(this,t)})),t.on_(R.DOWN,this.editBox.onArrow,this.editBox)]}}removeTargetEvents(){const{targetEventIds:t}=this;t.length&&(this.off_(t),t.length=0)}destroy(){this.destroyed||(this.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}D([X((function(t,e){t.emitEvent(new Z(Z.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Xt.prototype,"hoverTarget",void 0),D([X((function(t,e){const{target:i}=t;i?t.leafList=i instanceof u?i:new u(i):(t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new Z(Z.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&Mt(t),wt(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],Xt.prototype,"target",void 0);class Gt{static registerInnerEditor(){Rt.register(this)}get tag(){return"InnerEditor"}get editBox(){return this.editor.editBox}constructor(t){this.editor=t,this.create()}onCreate(){}create(){this.view=new l,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.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 Ut=class extends Gt{static registerEditTool(){Rt.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,{x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};Ut=D([Ht()],Ut);const{left:Nt,right:jt}=b,{move:Kt,copy:$t,toNumberPoints:qt}=p;let Jt=class extends Ut{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===Nt;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){const e=qt(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(Kt(t,n,r),s&&Kt(e,-n,-r)):(s&&Kt(t,-n,-r),Kt(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),$t(s[7],i),$t(e[7],i),$t(s[3],a),$t(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Nt||t===jt,s[t].visible=a,e[t].visible=!r&&a}};Jt=D([Ht()],Jt),f.add("editor","resize","find"),S.editor=function(t){return new Xt(t)},M(!1)(y.prototype,"textBox"),e(o.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),e(o.prototype,"editInner",{get:()=>"PathEditor"}),e(l.prototype,"editInner",{get:()=>""}),e(w.prototype,"editInner",{get:()=>"TextEditor"}),o.setEditConfig=function(t){e(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},o.setEditOuter=function(t){e(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},o.setEditInner=function(t){e(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{_t as EditBox,vt as EditDataHelper,Lt as EditPoint,rt as EditSelect,ot as EditSelectHelper,Ut as EditTool,Rt as EditToolCreator,Xt as Editor,Z as EditorEvent,Zt as EditorGroupEvent,Vt as EditorHelper,z as EditorMoveEvent,F as EditorRotateEvent,W as EditorScaleEvent,Y as EditorSkewEvent,Gt as InnerEditor,At as InnerEditorEvent,Jt as LineEditTool,Q as SelectArea,J as Stroker,Ht as registerEditTool,It as registerInnerEditor};
1
+ import{Event as t,defineKey as e,getMatrixData as i,getBoundsData as s,UI as o,Paint as n,MatrixHelper as r,BoundsHelper as a,LeafBoundsHelper as h,Group as l,Rect as d,Bounds as c,LeafList as g,PointHelper as u,AroundHelper as f,MathHelper as p,Direction9 as m,Box as v,Text as b,Matrix as y,Debug as w,PropertyEvent as E,LeafHelper as L,DataHelper as k,RenderEvent as x,getPointData as _,Plugin as T,Creator as O,dataType as M}from"@leafer-ui/draw";import{PointerEvent as S,DragEvent as P,MoveEvent as C,ZoomEvent as B,Plugin as V,RotateEvent as H,KeyEvent as I}from"@leafer-ui/core";import"@leafer-in/resize";function R(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 D(t){return t?t instanceof Array?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class A extends t{get list(){return D(this.value)}get oldList(){return D(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}A.SELECT="editor.select",A.HOVER="editor.hover";class Z extends A{constructor(t,e){super(t,e)}}Z.MOVE="editor.move";class z extends A{constructor(t,e){super(t,e)}}z.SCALE="editor.scale";class W extends A{constructor(t,e){super(t,e)}}W.ROTATE="editor.rotate";class F extends A{constructor(t,e){super(t,e)}}function X(t){return(i,s)=>{const o="_"+s;e(i,s,{get(){return this[o]},set(e){const i=this[o];i!==e&&(this[o]=e,t(this,i))}})}}F.SKEW="editor.skew";const{abs:Y}=Math,{copy:G,scale:U}=r,{setListWithFn:N}=a,{worldBounds:j}=h,K=i(),$=s();class q extends o{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(N($,t,j),this.set($)):this.width=this.height=1}__draw(t,e){const{list:i}=this;if(i.length){let s;const o=this.__,{stroke:r,strokeWidth:a,fill:h}=o,{bounds:l}=e;for(let d=0;d<i.length;d++){s=i[d];const{worldTransform:c,worldRenderBounds:g}=s;if(!l||l.hit(g,e.matrix)){const i=Y(c.scaleX),l=Y(c.scaleY);if(i!==l){G(K,c),U(K,1/i,1/l),t.setWorld(K,e.matrix),t.beginPath(),o.strokeWidth=a;const{x:n,y:r,width:h,height:d}=s.__layout.boxBounds;t.rect(n*i,r*l,h*i,d*l)}else t.setWorld(c,e.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),o.strokeWidth=a/Y(c.scaleX);r&&("string"==typeof r?n.stroke(r,this,t):n.strokes(r,this,t)),h&&("string"==typeof h?n.fill(h,this,t):n.fills(h,this,t))}}o.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}R([X((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],q.prototype,"target",void 0);class J extends l{constructor(t){super(t),this.strokeArea=new d({strokeAlign:"center"}),this.fillArea=new d,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 Q={findOne:t=>t.list.find((t=>t.editable)),findByBounds(t,e){const i=[];return tt([t],i,e),i}};function tt(t,e,i){let s,o;for(let n=0,r=t.length;n<r;n++)if(s=t[n],o=s.__,o.hittable&&o.visible&&!o.locked&&i.hit(s.__world)){if(o.editable){if(s.isBranch&&!o.hitChildren){o.hitSelf&&e.push(s);continue}if(s.isFrame){if(i.includes(s.__layout.boxBounds,s.__world)){e.push(s);continue}}else i.hit(s.__layout.boxBounds,s.__world)&&o.hitSelf&&e.push(s)}s.isBranch&&tt(s.children,e,i)}}const{findOne:et,findByBounds:it}=Q;class st extends l{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 q,this.targetStroker=new q,this.bounds=new c,this.selectArea=new J,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.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),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(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:s}=e.mergeConfig,{x:o,y:n}=t.getInnerPoint(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(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:e}=this,i=t.getInnerTotal(this),s=this.bounds.clone().unsign(),o=new g(it(e.app,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(t){t.multiTouch||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&&!et(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const e={exclude:new g(this.editor.editBox.rect)};return et(t.target.leafer.interaction.findPath(t,e))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):et(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_(A.HOVER,this.onHover,this),t.on_(A.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_(P.START,this.onDragStart,this,!0),e.on_(P.DRAG,this.onDrag,this),e.on_(P.END,this.onDragEnd,this),e.on_(C.MOVE,this.onAutoMove,this),e.on_([B.ZOOM,C.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:ot,top:nt,topRight:rt,right:at,bottomRight:ht,bottom:lt,bottomLeft:dt,left:ct}=m,{toPoint:gt}=f,{within:ut}=p,ft={getScaleData(t,e,i,s,o,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(s.x*=2,s.y*=2);const v=t.scaleX/e.scaleX,b=t.scaleY/e.scaleY,y=v<0?-1:1,w=b<0?-1:1,E=a?v:y*g.width/p,L=a?b:w*g.height/m;s.x*=a?v:y,s.y*=a?b:w,Math.abs(s.x)===p&&(s.x+=.1),Math.abs(s.y)===m&&(s.y+=.1);const k=(-s.y+m)/m,x=(s.x+p)/p,_=(s.y+m)/m,T=(-s.x+p)/p;switch(i){case nt:c=k,h="bottom";break;case at:d=x,h="left";break;case lt:c=_,h="top";break;case ct:d=T,h="right";break;case ot:c=k,d=T,h="bottom-right";break;case rt:c=k,d=x,h="bottom-left";break;case ht:c=_,d=x,h="top-left";break;case dt:c=_,d=T,h="top-right"}if(o){if(!("corner"===o&&i%2)){let t;switch(i){case nt:case lt:t=c;break;case ct:case at:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=E,c/=L,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=ut(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=ut(e*c,f)/e}return gt(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:o,around:n}},getRotateData(t,e,i,s,o){let n,r={};switch(e){case ot:n="bottom-right";break;case rt:n="bottom-left";break;case ht:n="top-left";break;case dt:n="top-right";break;default:n="center"}return gt(o||n,t,r,!0),{origin:r,rotation:u.getRotation(s,r,i)}},getSkewData(t,e,i,s){let o,n,r={},a=0,h=0;switch(e){case nt:n={x:.5,y:0},o="bottom",a=1;break;case lt:n={x:.5,y:1},o="top",a=1;break;case ct:n={x:0,y:.5},o="right",h=1;break;case at:n={x:1,y:.5},o="left",h=1}const{width:l,height:d}=t;n.x=n.x*l,n.y=n.y*d,gt(s||o,t,r,!0);const c=u.getRotation(n,r,{x:n.x+(a?i.x:0),y:n.y+(h?i.y:0)});return a?a=-c:h=c,{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 ct:t=at;break;case ot:t=rt;break;case dt:t=ht;break;case at:t=ct;break;case rt:t=ot;break;case ht:t=dt}if(i)switch(t){case nt:t=lt;break;case ot:t=dt;break;case rt:t=ht;break;case lt:t=nt;break;case dt:t=ot;break;case ht:t=rt}return t}},pt={};function mt(t,e){const{editBox:i}=t,s=i.enterPoint;if(!s||!t.editing||!i.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));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 m=d&&!f&&"resize-line"===s.name?a:f?n:r;o+=45*(ft.getFlipDirection(s.direction,g,u)+1),o=2*Math.round(p.formatRotation(o,!0)/2);const{url:v,x:b,y:y}=m,w=v+o;pt[w]?s.cursor=pt[w]:pt[w]=s.cursor={url:bt(v,o),x:b,y:y}}function vt(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function bt(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class yt extends v{}const wt=["top","right","bottom","left"];class Et extends l{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 l,this.rect=new v({name:"rect",hitFill:"all",hitStroke:"none",strokeAlign:"center",hitRadius:5}),this.circle=new yt({name:"circle",strokeAlign:"center",around:"center",cursor:"crosshair",hitRadius:5}),this.buttons=new l({around:"center",hitSelf:!1}),this.resizePoints=[],this.rotatePoints=[],this.resizeLines=[],this.__eventIds=[],this.editor=t,this.visible=!1,this.create(),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 yt({name:"rotate-point",around:d[s],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",s),s%2&&(e=new yt({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",s)),i=new yt({name:"resize-point",hitRadius:5}),o.push(i),this.listenPointEvents(i,"resize",s);this.listenPointEvents(h,"rotate",2),s.addMany(...n,a,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:a}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);o.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),s.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),s.hittable=!i,s.syncEventer=i&&this.editor,i&&(e.syncEventer=s,this.app.interaction.bottomList=[{target:s,proxy:e}])}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,buttons:r,resizePoints:a,rotatePoints:h,resizeLines:l}=this,{middlePoint:d,resizeable:c,rotateable:g,hideOnSmall:u}=e,p="number"==typeof u?u:10,m=!(u&&i<p&&s<p);let v,b,y,w={};for(let o=0;o<8;o++)f.toPoint(f.directionData[o],t,w),b=a[o],v=h[o],y=l[Math.floor(o/2)],b.set(w),v.set(w),y.set(w),b.visible=y.visible=m&&!(!c&&!g),v.visible=m&&g&&c&&!e.rotatePoint,o%2&&(b.visible=v.visible=m&&!!d,(o+1)/2%2?(y.width=i,b.width>i-30&&(b.visible=!1)):(y.height=s,b.rotation=90,b.width>s-30&&(b.visible=!1)));n.visible=m&&g&&!(!e.circle&&!e.rotatePoint),n.visible&&this.layoutCircle(e),o.path&&(o.path=null),o.set(Object.assign(Object.assign({},t),{visible:!0})),r.visible=m&&r.children.length>0,r.visible&&this.layoutButtons(e)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:s,buttonsDirection:o,middlePoint:n}=t,r=wt.indexOf(e||(this.buttons.children.length&&"bottom"===o?"top":"bottom"));this.setButtonPosition(this.circle,r,i||s,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:s,buttonsMargin:o,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=wt.indexOf(i);(h%2&&r||(h+1)%2&&a)&&s&&(h=(h+2)%4);const l=s?ft.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,o,!!n),s&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,s){const o=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(s?o.width:0)+t.boxBounds.width:(s?o.height:0)+t.boxBounds.height)/2)*r;n?(t.x=o.x+a,t.y=o.y):(t.x=o.x,t.y=o.y+a)}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,offsetX:0,offsetY:0};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){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),mt(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;if(i.locked)return;if(i.isBranch&&!i.editInner){if(i.textBox){const{children:t}=i,s=t.find((t=>t.editable&&t instanceof b))||t.find((t=>t instanceof b));if(s)return e.openInnerEditor(s)}e.openGroup(i),e.target=e.selector.findDeepOne(t)}else e.openInnerEditor()}}listenPointEvents(t,e,i){const{editor:s}=this;t.direction=i,t.pointType=e,t.on_(P.START,this.onDragStart,this),t.on_(P.DRAG,this.onDrag,this),t.on_(P.END,this.onDragEnd,this),t.on_(S.LEAVE,(()=>this.enterPoint=null)),"circle"!==t.name&&t.on_(S.ENTER,(e=>{this.enterPoint=t,mt(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(A.SELECT,this.onSelect,this),t.on_(P.START,this.onDragStart,this),t.on_(P.DRAG,e.onMove,e),t.on_(P.END,this.onDragEnd,this),t.on_(S.ENTER,(()=>vt(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 Lt extends o{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,!0===s?"rgba(0,0,0,0.8)":s),t.setWorld(o.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const kt='\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"/>',xt={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${kt}\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${kt}\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${kt}\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,flipable:!0,rotateable:!0,skewable:!0},_t=new c;function Tt(t){const{simulateTarget:e,list:i}=t,{zoomLayer:s}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(_t.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),s.add(e)}const Ot=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),Mt=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),St={group(t,e,i){t.sort(Mt);const{app:s,parent:o}=t[0];let n;n=i&&i.add?i:new l(i),o.addAt(n,o.children.indexOf(t[0])),t.sort(Ot);const r=new y(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&&!t.isBranchLeaf){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(Ot),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(Mt),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Pt=w.get("EditToolCreator");function Ct(){return t=>{Vt.register(t)}}const Bt=Ct,Vt={list:{},register(t){const{tag:e}=t.prototype;Ht[e]&&Pt.repeat(e),Ht[e]=t},get:(t,e)=>new Ht[t](e)},{list:Ht}=Vt;class It extends A{constructor(t,e){super(t,e)}}It.BEFORE_OPEN="innerEditor.before_open",It.OPEN="innerEditor.open",It.BEFORE_CLOSE="innerEditor.before_close",It.CLOSE="innerEditor.close";class Rt extends A{constructor(t,e){super(t,e)}}Rt.GROUP="editor.group",Rt.BEFORE_UNGROUP="editor.before_ungroup",Rt.UNGROUP="editor.ungroup",Rt.OPEN="editor.open_group",Rt.CLOSE="editor.close_group";const{updateMatrix:Dt}=L,At={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},Zt="top-left";class zt extends d{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(E.CHANGE,(e=>{if(this.checkChange&&At[e.attrName]){const{attrName:i,newValue:s,oldValue:o}=e,n="s"===i[0]?(s||1)/(o||1):(s||0)-(o||0);this.canChange=!1;const r=this.__;r[i]=o,Dt(this.parent),Dt(this);const a=new y(this.__world);switch(r[i]=s,this.__layout.rotationChange(),Dt(this),this.changedTransform=new y(this.__world).divide(a),i){case"x":t.move(n,0);break;case"y":t.move(0,n);break;case"rotation":t.rotateOf(Zt,n);break;case"scaleX":t.scaleOf(Zt,n,1);break;case"scaleY":t.scaleOf(Zt,1,n);break;case"skewX":t.skewOf(Zt,n,0);break;case"skewY":t.skewOf(Zt,0,n)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class Wt extends l{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 dragHoverExclude(){return[this.editBox.rect]}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 moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,e){super(e),this.config=k.clone(xt),this.leafList=new g,this.openedGroupList=new g,this.simulateTarget=new zt(this),this.editBox=new Et(this),this.editToolList={},this.selector=new st(this),this.editMask=new Lt(this),this.targetEventIds=[],t&&(this.config=k.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox),V.has("resize")||(this.config.editSize="scale")}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(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Tt(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){if(t instanceof C){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,s=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(s.x,s.y)):"zoom"===i&&t.stop()}}else{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(P.getValidMove(this.element,this.dragStartPoint,e))}}onScale(t){const{element:e}=this;let{around:i,lockRatio:s,resizeable:o,flipable:n,editSize:r}=this.mergeConfig;if(t instanceof B)"zoom"===o&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:o}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const a=ft.getScaleData(e,this.dragStartBounds,o,t.getInnerTotal(e),s,ft.getAround(i,t.altKey),n,this.multiple||"scale"===r);this.editTool.onScaleWithDrag?(a.drag=t,this.scaleWithDrag(a)):this.scaleOf(a.origin,a.scaleX,a.scaleY)}}onRotate(t){const{skewable:e,rotateable:i,around:s,rotateGap:o}=this.mergeConfig,{direction:n,name:r}=t.current;if(e&&"resize-line"===r)return this.onSkew(t);const{element:a}=this;let h,l;if(t instanceof H){if("rotate"!==i)return;t.stop(),l=t.rotation,h=a.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=ft.getRotateData(a.boxBounds,n,t.getBoxPoint(a),a.getBoxPoint(e),t.shiftKey?null:a.around||a.origin||s||"center");l=i.rotation,h=i.origin}l=p.getGapRotation(l,o,a.rotation),l&&(a.scaleX*a.scaleY<0&&(l=-l),this.rotateOf(h,p.float(l,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:s,skewX:o,skewY:n}=ft.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),ft.getAround(i,t.altKey));(o||n)&&this.skewOf(s,o,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,s=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const o=new Z(Z.MOVE,{target:i,editor:this,moveX:s.x,moveY:s.y});this.editTool.onMove(o),this.emitEvent(o)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new z(z.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,s){if(!this.checkTransform("resizeable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.scaleOf(t,e,i))))),a=new z(z.SCALE,{target:o,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(a),this.emitEvent(a)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>e.safeChange((()=>e.flip(t))))):new y(L.getFlipTransform(e,t)),o=new z(z.SCALE,{target:e,editor:this,worldOrigin:i,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(o),this.emitEvent(o)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,s=this.getWorldOrigin(t),o=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new W(W.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.checkTransform("skewable"))return;const{element:o}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>o.safeChange((()=>o.skewOf(t,e,i))))),a=new F(F.SKEW,{target:o,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(L.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:e}=this;if(this.multiple&&!e.canChange)return e.changedTransform;const i=new y(e.worldTransform);return t(),new y(e.worldTransform).divide(i)}group(t){return this.multiple&&(this.target=St.group(this.list,this.element,t),this.emitGroupEvent(Rt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(Rt.BEFORE_UNGROUP,t))),this.target=St.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(Rt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(Rt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(Rt.CLOSE,t)}checkOpenedGroups(){const t=this.openedGroupList;if(t.length){let{list:e}=t;this.editing&&(e=[],t.forEach((t=>this.list.every((e=>!L.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 Rt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&Vt.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||Vt.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(It.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(It.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(It.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(It.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,s=new It(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&&(St.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(St.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:e}=this;this.targetEventIds=[e.on_(x.START,this.update,this),t.on_(x.CHILD_START,this.forceRender,this),t.on_(C.BEFORE_MOVE,this.onMove,this,!0),t.on_(B.BEFORE_ZOOM,this.onScale,this,!0),t.on_(H.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([I.HOLD,I.UP],(t=>{mt(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.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}R([X((function(t,e){t.emitEvent(new A(A.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],Wt.prototype,"hoverTarget",void 0),R([X((function(t,e){const{target:i}=t;i?(t.leafList=i instanceof g?i:new g(i),t.multiple&&Tt(t)):(t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new A(A.SELECT,{editor:t,value:i,oldValue:e})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{vt(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],Wt.prototype,"target",void 0);class Ft{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 l,this.onCreate()}onLoad(){}load(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.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 Xt=class extends Ft{static registerEditTool(){Vt.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,{x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:s,scaleX:o,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}};Xt=R([Ct()],Xt);const{left:Yt,right:Gt}=m,{move:Ut,copy:Nt,toNumberPoints:jt}=u;let Kt=class extends Xt{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===Yt;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=_(),{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){const e=jt(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,s,o){const{x:n,y:r}=o;i?(Ut(t,n,r),s&&Ut(e,-n,-r)):(s&&Ut(t,-n,-r),Ut(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),Nt(s[7],i),Nt(e[7],i),Nt(s[3],a),Nt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===Yt||t===Gt,s[t].visible=a,e[t].visible=!r&&a}};Kt=R([Ct()],Kt),T.add("editor","resize"),O.editor=function(t){return new Wt(t)},M(!1)(v.prototype,"textBox"),e(o.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),e(o.prototype,"editInner",{get:()=>"PathEditor"}),e(l.prototype,"editInner",{get:()=>""}),e(b.prototype,"editInner",{get:()=>"TextEditor"}),o.setEditConfig=function(t){e(this.prototype,"editConfig",{get(){return"function"==typeof t?t(this):t}})},o.setEditOuter=function(t){e(this.prototype,"editOuter",{get(){return"string"==typeof t?t:t(this)}})},o.setEditInner=function(t){e(this.prototype,"editInner",{get(){return"string"==typeof t?t:t(this)}})};export{Et as EditBox,ft as EditDataHelper,yt as EditPoint,st as EditSelect,Q as EditSelectHelper,Xt as EditTool,Vt as EditToolCreator,Wt as Editor,A as EditorEvent,Rt as EditorGroupEvent,St as EditorHelper,Z as EditorMoveEvent,W as EditorRotateEvent,z as EditorScaleEvent,F as EditorSkewEvent,Ft as InnerEditor,It as InnerEditorEvent,Kt as LineEditTool,J as SelectArea,q as Stroker,Ct as registerEditTool,Bt as registerInnerEditor};
package/dist/editor.js CHANGED
@@ -16,7 +16,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
16
16
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
17
  PERFORMANCE OF THIS SOFTWARE.
18
18
  ***************************************************************************** */
19
- /* global Reflect, Promise, SuppressedError, Symbol */
19
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
20
20
 
21
21
 
22
22
  function __decorate(decorators, target, key, desc) {
@@ -160,7 +160,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
160
160
  }
161
161
  __decorate([
162
162
  targetAttr(onTarget$1)
163
- ], Stroker.prototype, "target", void 0);
163
+ ], Stroker.prototype, "target", undefined);
164
164
  function onTarget$1(stroker) {
165
165
  const value = stroker.target;
166
166
  stroker.list = value ? (value instanceof Array ? value : [value]) : [];
@@ -186,34 +186,43 @@ this.LeaferIN.editor = (function (exports, draw, core) {
186
186
  }
187
187
  }
188
188
 
189
- const { No, Yes, NoAndSkip, YesAndSkip } = draw.Answer;
190
189
  const EditSelectHelper = {
191
190
  findOne(path) {
192
191
  return path.list.find((leaf) => leaf.editable);
193
192
  },
194
- findBounds(leaf, bounds) {
195
- if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
196
- if (leaf.__.editable) {
197
- if (leaf.isBranch && !leaf.__.hitChildren) {
198
- return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
199
- }
200
- else if (leaf.isFrame) {
201
- return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No;
193
+ findByBounds(branch, bounds) {
194
+ const list = [];
195
+ eachFind([branch], list, bounds);
196
+ return list;
197
+ }
198
+ };
199
+ function eachFind(children, list, bounds) {
200
+ let child, data;
201
+ for (let i = 0, len = children.length; i < len; i++) {
202
+ child = children[i], data = child.__;
203
+ if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {
204
+ if (data.editable) {
205
+ if (child.isBranch && !data.hitChildren) {
206
+ if (data.hitSelf)
207
+ list.push(child);
208
+ continue;
202
209
  }
203
- else {
204
- if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf)
205
- return Yes;
210
+ else if (child.isFrame) {
211
+ if (bounds.includes(child.__layout.boxBounds, child.__world)) {
212
+ list.push(child);
213
+ continue;
214
+ }
206
215
  }
216
+ else if (bounds.hit(child.__layout.boxBounds, child.__world) && data.hitSelf)
217
+ list.push(child);
207
218
  }
208
- return No;
209
- }
210
- else {
211
- return leaf.isBranch ? NoAndSkip : No;
219
+ if (child.isBranch)
220
+ eachFind(child.children, list, bounds);
212
221
  }
213
222
  }
214
- };
223
+ }
215
224
 
216
- const { findOne } = EditSelectHelper;
225
+ const { findOne, findByBounds } = EditSelectHelper;
217
226
  class EditSelect extends draw.Group {
218
227
  get dragging() { return !!this.originList; }
219
228
  get running() { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector; }
@@ -336,7 +345,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
336
345
  const { editor } = this;
337
346
  const total = e.getInnerTotal(this);
338
347
  const dragBounds = this.bounds.clone().unsign();
339
- const list = new draw.LeafList(editor.app.find(EditSelectHelper.findBounds, dragBounds));
348
+ const list = new draw.LeafList(findByBounds(editor.app, dragBounds));
340
349
  this.bounds.width = total.x;
341
350
  this.bounds.height = total.y;
342
351
  this.selectArea.setBounds(dragBounds.get());
@@ -372,7 +381,7 @@ this.LeaferIN.editor = (function (exports, draw, core) {
372
381
  return target.leafer !== this.editor.leafer;
373
382
  }
374
383
  allowDrag(e) {
375
- if (this.running && (this.editor.mergeConfig.boxSelect && draw.Plugin.has('find')) && !e.target.draggable) {
384
+ if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
376
385
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
377
386
  }
378
387
  else {
@@ -1081,6 +1090,8 @@ ${filterStyle}
1081
1090
  const { target } = editor;
1082
1091
  if (target) {
1083
1092
  editor.leafList = target instanceof draw.LeafList ? target : new draw.LeafList(target instanceof Array ? target : target);
1093
+ if (editor.multiple)
1094
+ simulate(editor);
1084
1095
  }
1085
1096
  else {
1086
1097
  editor.simulateTarget.remove();
@@ -1091,8 +1102,6 @@ ${filterStyle}
1091
1102
  editor.checkOpenedGroups();
1092
1103
  if (editor.editing) {
1093
1104
  editor.waitLeafer(() => {
1094
- if (editor.multiple)
1095
- simulate(editor);
1096
1105
  updateMoveCursor(editor);
1097
1106
  editor.updateEditTool();
1098
1107
  editor.update();
@@ -1322,6 +1331,8 @@ ${filterStyle}
1322
1331
  }
1323
1332
  update() {
1324
1333
  if (this.editing) {
1334
+ if (!this.element.parent)
1335
+ return this.cancel();
1325
1336
  if (this.innerEditing)
1326
1337
  this.innerEditor.update();
1327
1338
  this.editTool.update();
@@ -1638,10 +1649,10 @@ ${filterStyle}
1638
1649
  }
1639
1650
  __decorate([
1640
1651
  targetAttr(onHover)
1641
- ], Editor.prototype, "hoverTarget", void 0);
1652
+ ], Editor.prototype, "hoverTarget", undefined);
1642
1653
  __decorate([
1643
1654
  targetAttr(onTarget)
1644
- ], Editor.prototype, "target", void 0);
1655
+ ], Editor.prototype, "target", undefined);
1645
1656
 
1646
1657
  class InnerEditor {
1647
1658
  static registerInnerEditor() {
@@ -1876,7 +1887,7 @@ ${filterStyle}
1876
1887
  registerEditTool()
1877
1888
  ], exports.LineEditTool);
1878
1889
 
1879
- draw.Plugin.add('editor', 'resize', 'find');
1890
+ draw.Plugin.add('editor', 'resize');
1880
1891
  draw.Creator.editor = function (options) { return new Editor(options); };
1881
1892
  draw.dataType(false)(draw.Box.prototype, 'textBox');
1882
1893
  draw.defineKey(draw.UI.prototype, 'editOuter', {
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");function i(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 o(t){return t?t instanceof Array?t:[t]:[]}require("@leafer-in/resize"),require("@leafer-in/find"),"function"==typeof SuppressedError&&SuppressedError;class s extends t.Event{get list(){return o(this.value)}get oldList(){return o(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}s.SELECT="editor.select",s.HOVER="editor.hover";class n extends s{constructor(t,e){super(t,e)}}n.MOVE="editor.move";class r extends s{constructor(t,e){super(t,e)}}r.SCALE="editor.scale";class a extends s{constructor(t,e){super(t,e)}}a.ROTATE="editor.rotate";class h extends s{constructor(t,e){super(t,e)}}function l(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))}})}}h.SKEW="editor.skew";const{abs:d}=Math,{copy:c,scale:g}=t.MatrixHelper,{setListWithFn:u}=t.BoundsHelper,{worldBounds:p}=t.LeafBoundsHelper,f=t.getMatrixData(),m=t.getBoundsData();class v extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(u(m,t,p),this.set(m)):this.width=this.height=1}__draw(e,i){const{list:o}=this;if(o.length){let s;const n=this.__,{stroke:r,strokeWidth:a,fill:h}=n,{bounds:l}=i;for(let u=0;u<o.length;u++){s=o[u];const{worldTransform:p,worldRenderBounds:m}=s;if(!l||l.hit(m,i.matrix)){const o=d(p.scaleX),l=d(p.scaleY);if(o!==l){c(f,p),g(f,1/o,1/l),e.setWorld(f,i.matrix),e.beginPath(),n.strokeWidth=a;const{x:t,y:r,width:h,height:d}=s.__layout.boxBounds;e.rect(t*o,r*l,h*o,d*l)}else e.setWorld(p,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),n.strokeWidth=a/d(p.scaleX);r&&("string"==typeof r?t.Paint.stroke(r,this,e):t.Paint.strokes(r,this,e)),h&&("string"==typeof h?t.Paint.fill(h,this,e):t.Paint.fills(h,this,e))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}i([l((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],v.prototype,"target",void 0);class E 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:y,Yes:L,NoAndSkip:b,YesAndSkip:w}=t.Answer,x={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:b;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?w:y;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return L}return y}return t.isBranch?b:y}},{findOne:k}=x;class _ 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 v,this.targetStroker=new v,this.bounds=new t.Bounds,this.selectArea=new E,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.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),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(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInnerPoint(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(!e.multiTouch){if(this.editor.dragging)return this.onDragEnd(e);if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(i.app.find(x.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(t){t.multiTouch||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(e){return!(!(this.running&&this.editor.mergeConfig.boxSelect&&t.Plugin.has("find"))||e.target.draggable)&&(!this.editor.editing&&this.allow(e.target)||e.shiftKey&&!k(e.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return k(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):k(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_(s.HOVER,this.onHover,this),t.on_(s.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,!0),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:T,top:M,topRight:O,right:S,bottomRight:P,bottom:H,bottomLeft:C,left:B}=t.Direction9,{toPoint:V}=t.AroundHelper,{within:I}=t.MathHelper,D={getScaleData(t,e,i,o,s,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:p}=t,{width:f,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,y=v<0?-1:1,L=E<0?-1:1,b=a?v:y*g.width/f,w=a?E:L*g.height/m;o.x*=a?v:y,o.y*=a?E:L,Math.abs(o.x)===f&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const x=(-o.y+m)/m,k=(o.x+f)/f,_=(o.y+m)/m,D=(-o.x+f)/f;switch(i){case M:c=x,h="bottom";break;case S:d=k,h="left";break;case H:c=_,h="top";break;case B:d=D,h="right";break;case T:c=x,d=D,h="bottom-right";break;case O:c=x,d=k,h="bottom-left";break;case P:c=_,d=k,h="top-left";break;case C:c=_,d=D,h="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case M:case H:t=c;break;case B:case S:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=b,c/=w,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=I(e*d,u)/e}if(p){const e=g.height*t.scaleY;c=I(e*c,p)/e}return V(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case T:r="bottom-right";break;case O:r="bottom-left";break;case P:r="top-left";break;case C:r="top-right";break;default:r="center"}return V(n||r,e,a,!0),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},h=0,l=0;switch(i){case M:r={x:.5,y:0},n="bottom",h=1;break;case H:r={x:.5,y:1},n="top",h=1;break;case B:r={x:0,y:.5},n="right",l=1;break;case S:r={x:1,y:.5},n="left",l=1}const{width:d,height:c}=e;r.x=r.x*d,r.y=r.y*c,V(s||n,e,a,!0);const g=t.PointHelper.getRotation(r,a,{x:r.x+(h?o.x:0),y:r.y+(l?o.y:0)});return h?h=-g:l=g,{origin:a,skewX:h,skewY:l}},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 B:t=S;break;case T:t=O;break;case C:t=P;break;case S:t=B;break;case O:t=T;break;case P:t=C}if(i)switch(t){case M:t=H;break;case T:t=C;break;case O:t=P;break;case H:t=M;break;case C:t=T;break;case P:t=O}return t}},R={};function A(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:h,resizeable:l,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!l)&&(f=!1);const m=c&&!f&&"resize-line"===s.name?h:f?r:a;n+=45*(D.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:y}=m,L=v+n;R[L]?s.cursor=R[L]:R[L]=s.cursor={url:z(v,n),x:E,y:y}}function Z(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function z(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class W extends t.Box{}const G=["top","right","bottom","left"];class F 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 W({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.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,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 o=0;o<8;o++)t=new W({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new W({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new W({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(h,"rotate",2),o.addMany(...n,a,h,l,...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}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i,o.syncEventer=i&&this.editor,i&&(e.syncEventer=o,this.app.interaction.bottomList=[{target:o,proxy:e}])}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,buttons:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:p}=i,f="number"==typeof p?p:10,m=!(p&&o<f&&s<f);let v,E,y,L={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,L),E=h[n],v=l[n],y=d[Math.floor(n/2)],E.set(L),v.set(L),y.set(L),E.visible=y.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(y.width=o,E.width>o-30&&(E.visible=!1)):(y.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=G.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=G.indexOf(i);(h%2&&r||(h+1)%2&&a)&&o&&(h=(h+2)%4);const l=o?D.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,s,!!n),o&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}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,offsetX:0,offsetY:0};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){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),A(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(e){const{editor:i}=this;if(i.single){const{element:o}=i;if(o.locked)return;if(o.isBranch&&!o.editInner){if(o.textBox){const{children:e}=o,s=e.find((e=>e.editable&&e instanceof t.Text))||e.find((e=>e instanceof t.Text));if(s)return i.openInnerEditor(s)}i.openGroup(o),i.target=i.selector.findDeepOne(e)}else i.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,A(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(s.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.PointerEvent.ENTER,(()=>Z(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 U 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,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const Y='\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"/>',X={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${Y}\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${Y}\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${Y}\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,flipable:!0,rotateable:!0,skewable:!0},K=new t.Bounds;function N(t){const{simulateTarget:e,list:i}=t,{zoomLayer:o}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(K.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),o.add(e)}const j=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),q=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),$={group(e,i,o){e.sort(q);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(j);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&&!t.isBranchLeaf){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(j),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(q),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},J=t.Debug.get("EditToolCreator");function Q(){return t=>{et.register(t)}}const tt=Q,et={list:{},register(t){const{tag:e}=t.prototype;it[e]&&J.repeat(e),it[e]=t},get:(t,e)=>new it[t](e)},{list:it}=et;class ot extends s{constructor(t,e){super(t,e)}}ot.BEFORE_OPEN="innerEditor.before_open",ot.OPEN="innerEditor.open",ot.BEFORE_CLOSE="innerEditor.before_close",ot.CLOSE="innerEditor.close";class st extends s{constructor(t,e){super(t,e)}}st.GROUP="editor.group",st.BEFORE_UNGROUP="editor.before_ungroup",st.UNGROUP="editor.ungroup",st.OPEN="editor.open_group",st.CLOSE="editor.close_group";const{updateMatrix:nt}=t.LeafHelper,rt={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},at="top-left";class ht extends t.Rect{get __tag(){return"SimulateElement"}constructor(e){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(t.PropertyEvent.CHANGE,(i=>{if(this.checkChange&&rt[i.attrName]){const{attrName:o,newValue:s,oldValue:n}=i,r="s"===o[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const a=this.__;a[o]=n,nt(this.parent),nt(this);const h=new t.Matrix(this.__world);switch(a[o]=s,this.__layout.rotationChange(),nt(this),this.changedTransform=new t.Matrix(this.__world).divide(h),o){case"x":e.move(r,0);break;case"y":e.move(0,r);break;case"rotation":e.rotateOf(at,r);break;case"scaleX":e.scaleOf(at,r,1);break;case"scaleY":e.scaleOf(at,1,r);break;case"skewX":e.skewOf(at,r,0);break;case"skewY":e.skewOf(at,0,r)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class lt 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 dragHoverExclude(){return[this.editBox.rect]}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 moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(i,o){super(o),this.config=t.DataHelper.clone(X),this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new ht(this),this.editBox=new F(this),this.editToolList={},this.selector=new _(this),this.editMask=new U(this),this.targetEventIds=[],i&&(this.config=t.DataHelper.default(i,this.config)),this.addMany(this.editMask,this.selector,this.editBox),e.Plugin.has("resize")||(this.config.editSize="scale")}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&&N(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){if(t instanceof e.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{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;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof e.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(i.getBoxPoint(t),t.scale,t.scale));else{const{direction:e}=t.current;(t.shiftKey||i.lockRatio)&&(s=!0);const n=D.getScaleData(i,this.dragStartBounds,e,t.getInnerTotal(i),s,D.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(i){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:h}=i.current;if(o&&"resize-line"===h)return this.onSkew(i);const{element:l}=this;let d,c;if(i instanceof e.RotateEvent){if("rotate"!==s)return;i.stop(),c=i.rotation,d=l.getBoxPoint(i)}else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=D.getRotateData(l.boxBounds,a,i.getBoxPoint(l),l.getBoxPoint(t),i.shiftKey?null:l.around||l.origin||n||"center");c=e.rotation,d=e.origin}c=t.MathHelper.getGapRotation(c,r,l.rotation),c&&(l.scaleX*l.scaleY<0&&(c=-c),this.rotateOf(d,t.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=D.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),D.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const s=new n(n.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new r(r.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.checkTransform("resizeable"))return;const{element:s}=this,n=this.getWorldOrigin(t),a=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.scaleOf(t,e,i))))),h=new r(r.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:a});this.editTool.onScale(h),this.emitEvent(h)}flip(e){if(!this.checkTransform("resizeable"))return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.safeChange((()=>i.flip(e))))):new t.Matrix(t.LeafHelper.getFlipTransform(i,e)),n=new r(r.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===e?-1:1,scaleY:"y"===e?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new a(a.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.checkTransform("skewable"))return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.skewOf(t,e,i))))),a=new h(h.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(e){return this.element.getWorldPoint(t.LeafHelper.getInnerOrigin(this.element,e))}getChangedTransform(e){const{element:i}=this;if(this.multiple&&!i.canChange)return i.changedTransform;const o=new t.Matrix(i.worldTransform);return e(),new t.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=$.group(this.list,this.element,t),this.emitGroupEvent(st.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(st.BEFORE_UNGROUP,t))),this.target=$.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(st.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(st.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(st.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 st(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&et.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||et.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(ot.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(ot.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(ot.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(ot.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new ot(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&&($.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&($.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:i,leafer:o}=this;this.targetEventIds=[o.on_(t.RenderEvent.START,this.update,this),i.on_(t.RenderEvent.CHILD_START,this.forceRender,this),i.on_(e.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),i.on_(e.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),i.on_(e.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{A(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.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}i([l((function(t,e){t.emitEvent(new s(s.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],lt.prototype,"hoverTarget",void 0),i([l((function(e,i){const{target:o}=e;o?e.leafList=o instanceof t.LeafList?o:new t.LeafList(o):(e.simulateTarget.remove(),e.leafList.reset(),e.closeInnerEditor()),e.emitEvent(new s(s.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{e.multiple&&N(e),Z(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],lt.prototype,"target",void 0);class dt{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(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.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 dt{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,{x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=i([Q()],exports.EditTool);const{left:ct,right:gt}=t.Direction9,{move:ut,copy:pt,toNumberPoints:ft}=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===ct;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){const e=ft(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(ut(t,n,r),o&&ut(e,-n,-r)):(o&&ut(t,-n,-r),ut(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),pt(o[7],i),pt(e[7],i),pt(o[3],a),pt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===ct||t===gt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=i([Q()],exports.LineEditTool),t.Plugin.add("editor","resize","find"),t.Creator.editor=function(t){return new lt(t)},t.dataType(!1)(t.Box.prototype,"textBox"),t.defineKey(t.UI.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),t.defineKey(t.UI.prototype,"editInner",{get:()=>"PathEditor"}),t.defineKey(t.Group.prototype,"editInner",{get:()=>""}),t.defineKey(t.Text.prototype,"editInner",{get:()=>"TextEditor"}),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=F,exports.EditDataHelper=D,exports.EditPoint=W,exports.EditSelect=_,exports.EditSelectHelper=x,exports.EditToolCreator=et,exports.Editor=lt,exports.EditorEvent=s,exports.EditorGroupEvent=st,exports.EditorHelper=$,exports.EditorMoveEvent=n,exports.EditorRotateEvent=a,exports.EditorScaleEvent=r,exports.EditorSkewEvent=h,exports.InnerEditor=dt,exports.InnerEditorEvent=ot,exports.SelectArea=E,exports.Stroker=v,exports.registerEditTool=Q,exports.registerInnerEditor=tt;
1
+ "use strict";var t=require("@leafer-ui/draw"),e=require("@leafer-ui/core");function i(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 o(t){return t?t instanceof Array?t:[t]:[]}require("@leafer-in/resize"),"function"==typeof SuppressedError&&SuppressedError;class s extends t.Event{get list(){return o(this.value)}get oldList(){return o(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}s.SELECT="editor.select",s.HOVER="editor.hover";class n extends s{constructor(t,e){super(t,e)}}n.MOVE="editor.move";class r extends s{constructor(t,e){super(t,e)}}r.SCALE="editor.scale";class a extends s{constructor(t,e){super(t,e)}}a.ROTATE="editor.rotate";class h extends s{constructor(t,e){super(t,e)}}function l(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))}})}}h.SKEW="editor.skew";const{abs:d}=Math,{copy:c,scale:g}=t.MatrixHelper,{setListWithFn:u}=t.BoundsHelper,{worldBounds:p}=t.LeafBoundsHelper,f=t.getMatrixData(),m=t.getBoundsData();class v extends t.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(u(m,t,p),this.set(m)):this.width=this.height=1}__draw(e,i){const{list:o}=this;if(o.length){let s;const n=this.__,{stroke:r,strokeWidth:a,fill:h}=n,{bounds:l}=i;for(let u=0;u<o.length;u++){s=o[u];const{worldTransform:p,worldRenderBounds:m}=s;if(!l||l.hit(m,i.matrix)){const o=d(p.scaleX),l=d(p.scaleY);if(o!==l){c(f,p),g(f,1/o,1/l),e.setWorld(f,i.matrix),e.beginPath(),n.strokeWidth=a;const{x:t,y:r,width:h,height:d}=s.__layout.boxBounds;e.rect(t*o,r*l,h*o,d*l)}else e.setWorld(p,i.matrix),e.beginPath(),s.__.__useArrow?s.__drawPath(e):s.__.__pathForRender?s.__drawRenderPath(e):s.__drawPathByBox(e),n.strokeWidth=a/d(p.scaleX);r&&("string"==typeof r?t.Paint.stroke(r,this,e):t.Paint.strokes(r,this,e)),h&&("string"==typeof h?t.Paint.fill(h,this,e):t.Paint.fills(h,this,e))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}i([l((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],v.prototype,"target",void 0);class E 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 y={findOne:t=>t.list.find((t=>t.editable)),findByBounds(t,e){const i=[];return L([t],i,e),i}};function L(t,e,i){let o,s;for(let n=0,r=t.length;n<r;n++)if(o=t[n],s=o.__,s.hittable&&s.visible&&!s.locked&&i.hit(o.__world)){if(s.editable){if(o.isBranch&&!s.hitChildren){s.hitSelf&&e.push(o);continue}if(o.isFrame){if(i.includes(o.__layout.boxBounds,o.__world)){e.push(o);continue}}else i.hit(o.__layout.boxBounds,o.__world)&&s.hitSelf&&e.push(o)}o.isBranch&&L(o.children,e,i)}}const{findOne:b,findByBounds:w}=y;class x 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 v,this.targetStroker=new v,this.bounds=new t.Bounds,this.selectArea=new E,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.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),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(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInnerPoint(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(!e.multiTouch){if(this.editor.dragging)return this.onDragEnd(e);if(this.dragging){const{editor:i}=this,o=e.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new t.LeafList(w(i.app,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(t){t.multiTouch||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&&!b(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(e){const i={exclude:new t.LeafList(this.editor.editBox.rect)};return b(e.target.leafer.interaction.findPath(e,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):b(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_(s.HOVER,this.onHover,this),t.on_(s.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,!0),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:k,top:T,topRight:_,right:M,bottomRight:O,bottom:S,bottomLeft:P,left:H}=t.Direction9,{toPoint:B}=t.AroundHelper,{within:C}=t.MathHelper,V={getScaleData(t,e,i,o,s,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:p}=t,{width:f,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,y=v<0?-1:1,L=E<0?-1:1,b=a?v:y*g.width/f,w=a?E:L*g.height/m;o.x*=a?v:y,o.y*=a?E:L,Math.abs(o.x)===f&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const x=(-o.y+m)/m,V=(o.x+f)/f,I=(o.y+m)/m,D=(-o.x+f)/f;switch(i){case T:c=x,h="bottom";break;case M:d=V,h="left";break;case S:c=I,h="top";break;case H:d=D,h="right";break;case k:c=x,d=D,h="bottom-right";break;case _:c=x,d=V,h="bottom-left";break;case O:c=I,d=V,h="top-left";break;case P:c=I,d=D,h="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case T:case S:t=c;break;case H:case M:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=b,c/=w,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=C(e*d,u)/e}if(p){const e=g.height*t.scaleY;c=C(e*c,p)/e}return B(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(e,i,o,s,n){let r,a={};switch(i){case k:r="bottom-right";break;case _:r="bottom-left";break;case O:r="top-left";break;case P:r="top-right";break;default:r="center"}return B(n||r,e,a,!0),{origin:a,rotation:t.PointHelper.getRotation(s,a,o)}},getSkewData(e,i,o,s){let n,r,a={},h=0,l=0;switch(i){case T:r={x:.5,y:0},n="bottom",h=1;break;case S:r={x:.5,y:1},n="top",h=1;break;case H:r={x:0,y:.5},n="right",l=1;break;case M:r={x:1,y:.5},n="left",l=1}const{width:d,height:c}=e;r.x=r.x*d,r.y=r.y*c,B(s||n,e,a,!0);const g=t.PointHelper.getRotation(r,a,{x:r.x+(h?o.x:0),y:r.y+(l?o.y:0)});return h?h=-g:l=g,{origin:a,skewX:h,skewY:l}},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 H:t=M;break;case k:t=_;break;case P:t=O;break;case M:t=H;break;case _:t=k;break;case O:t=P}if(i)switch(t){case T:t=S;break;case k:t=P;break;case _:t=O;break;case S:t=T;break;case P:t=k;break;case O:t=_}return t}},I={};function D(e,i){const{editBox:o}=e,s=o.enterPoint;if(!s||!e.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:h,resizeable:l,rotateable:d,skewable:c}=e.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:p}=o;let f="resize"===g;f&&d&&(i.metaKey||i.ctrlKey||!l)&&(f=!1);const m=c&&!f&&"resize-line"===s.name?h:f?r:a;n+=45*(V.getFlipDirection(s.direction,u,p)+1),n=2*Math.round(t.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:y}=m,L=v+n;I[L]?s.cursor=I[L]:I[L]=s.cursor={url:A(v,n),x:E,y:y}}function R(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function A(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class Z extends t.Box{}const z=["top","right","bottom","left"];class W 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 Z({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.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,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 o=0;o<8;o++)t=new Z({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new Z({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new Z({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(h,"rotate",2),o.addMany(...n,a,h,l,...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}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i,o.syncEventer=i&&this.editor,i&&(e.syncEventer=o,this.app.interaction.bottomList=[{target:o,proxy:e}])}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,buttons:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:p}=i,f="number"==typeof p?p:10,m=!(p&&o<f&&s<f);let v,E,y,L={};for(let n=0;n<8;n++)t.AroundHelper.toPoint(t.AroundHelper.directionData[n],e,L),E=h[n],v=l[n],y=d[Math.floor(n/2)],E.set(L),v.set(L),y.set(L),E.visible=y.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(y.width=o,E.width>o-30&&(E.visible=!1)):(y.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},e),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=z.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=z.indexOf(i);(h%2&&r||(h+1)%2&&a)&&o&&(h=(h+2)%4);const l=o?V.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,s,!!n),o&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}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,offsetX:0,offsetY:0};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){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),D(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(e){const{editor:i}=this;if(i.single){const{element:o}=i;if(o.locked)return;if(o.isBranch&&!o.editInner){if(o.textBox){const{children:e}=o,s=e.find((e=>e.editable&&e instanceof t.Text))||e.find((e=>e instanceof t.Text));if(s)return i.openInnerEditor(s)}i.openGroup(o),i.target=i.selector.findDeepOne(e)}else i.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,D(s,e)}))}__listenEvents(){const{rect:t,editor:i}=this;this.__eventIds=[i.on_(s.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.PointerEvent.ENTER,(()=>R(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 G 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,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const F='\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"/>',U={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${F}\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${F}\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${F}\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,flipable:!0,rotateable:!0,skewable:!0},X=new t.Bounds;function Y(t){const{simulateTarget:e,list:i}=t,{zoomLayer:o}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(X.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),o.add(e)}const K=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),N=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),j={group(e,i,o){e.sort(N);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(K);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&&!t.isBranchLeaf){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(K),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(N),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},q=t.Debug.get("EditToolCreator");function $(){return t=>{Q.register(t)}}const J=$,Q={list:{},register(t){const{tag:e}=t.prototype;tt[e]&&q.repeat(e),tt[e]=t},get:(t,e)=>new tt[t](e)},{list:tt}=Q;class et extends s{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 it extends s{constructor(t,e){super(t,e)}}it.GROUP="editor.group",it.BEFORE_UNGROUP="editor.before_ungroup",it.UNGROUP="editor.ungroup",it.OPEN="editor.open_group",it.CLOSE="editor.close_group";const{updateMatrix:ot}=t.LeafHelper,st={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},nt="top-left";class rt extends t.Rect{get __tag(){return"SimulateElement"}constructor(e){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(t.PropertyEvent.CHANGE,(i=>{if(this.checkChange&&st[i.attrName]){const{attrName:o,newValue:s,oldValue:n}=i,r="s"===o[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const a=this.__;a[o]=n,ot(this.parent),ot(this);const h=new t.Matrix(this.__world);switch(a[o]=s,this.__layout.rotationChange(),ot(this),this.changedTransform=new t.Matrix(this.__world).divide(h),o){case"x":e.move(r,0);break;case"y":e.move(0,r);break;case"rotation":e.rotateOf(nt,r);break;case"scaleX":e.scaleOf(nt,r,1);break;case"scaleY":e.scaleOf(nt,1,r);break;case"skewX":e.skewOf(nt,r,0);break;case"skewY":e.skewOf(nt,0,r)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class at 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 dragHoverExclude(){return[this.editBox.rect]}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 moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(i,o){super(o),this.config=t.DataHelper.clone(U),this.leafList=new t.LeafList,this.openedGroupList=new t.LeafList,this.simulateTarget=new rt(this),this.editBox=new W(this),this.editToolList={},this.selector=new x(this),this.editMask=new G(this),this.targetEventIds=[],i&&(this.config=t.DataHelper.default(i,this.config)),this.addMany(this.editMask,this.selector,this.editBox),e.Plugin.has("resize")||(this.config.editSize="scale")}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(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&Y(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]||Q.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof e.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{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;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof e.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(i.getBoxPoint(t),t.scale,t.scale));else{const{direction:e}=t.current;(t.shiftKey||i.lockRatio)&&(s=!0);const n=V.getScaleData(i,this.dragStartBounds,e,t.getInnerTotal(i),s,V.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(i){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:h}=i.current;if(o&&"resize-line"===h)return this.onSkew(i);const{element:l}=this;let d,c;if(i instanceof e.RotateEvent){if("rotate"!==s)return;i.stop(),c=i.rotation,d=l.getBoxPoint(i)}else{const t={x:i.x-i.moveX,y:i.y-i.moveY},e=V.getRotateData(l.boxBounds,a,i.getBoxPoint(l),l.getBoxPoint(t),i.shiftKey?null:l.around||l.origin||n||"center");c=e.rotation,d=e.origin}c=t.MathHelper.getGapRotation(c,r,l.rotation),c&&(l.scaleX*l.scaleY<0&&(c=-c),this.rotateOf(d,t.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=V.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),V.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const s=new n(n.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new r(r.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.checkTransform("resizeable"))return;const{element:s}=this,n=this.getWorldOrigin(t),a=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.scaleOf(t,e,i))))),h=new r(r.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:a});this.editTool.onScale(h),this.emitEvent(h)}flip(e){if(!this.checkTransform("resizeable"))return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.safeChange((()=>i.flip(e))))):new t.Matrix(t.LeafHelper.getFlipTransform(i,e)),n=new r(r.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===e?-1:1,scaleY:"y"===e?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new a(a.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.checkTransform("skewable"))return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.skewOf(t,e,i))))),a=new h(h.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(e){return this.element.getWorldPoint(t.LeafHelper.getInnerOrigin(this.element,e))}getChangedTransform(e){const{element:i}=this;if(this.multiple&&!i.canChange)return i.changedTransform;const o=new t.Matrix(i.worldTransform);return e(),new t.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=j.group(this.list,this.element,t),this.emitGroupEvent(it.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(it.BEFORE_UNGROUP,t))),this.target=j.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(it.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(it.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(it.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 it(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&Q.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||Q.get(i,this),this.innerEditor.editTarget=e,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&&(j.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(j.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:i,leafer:o}=this;this.targetEventIds=[o.on_(t.RenderEvent.START,this.update,this),i.on_(t.RenderEvent.CHILD_START,this.forceRender,this),i.on_(e.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),i.on_(e.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),i.on_(e.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),i.on_([e.KeyEvent.HOLD,e.KeyEvent.UP],(t=>{D(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.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}i([l((function(t,e){t.emitEvent(new s(s.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],at.prototype,"hoverTarget",void 0),i([l((function(e,i){const{target:o}=e;o?(e.leafList=o instanceof t.LeafList?o:new t.LeafList(o),e.multiple&&Y(e)):(e.simulateTarget.remove(),e.leafList.reset(),e.closeInnerEditor()),e.emitEvent(new s(s.SELECT,{editor:e,value:o,oldValue:i})),e.checkOpenedGroups(),e.editing?e.waitLeafer((()=>{R(e),e.updateEditTool(),e.update(),e.listenTargetEvents()})):(e.updateEditTool(),e.removeTargetEvents())}))],at.prototype,"target",void 0);class ht{static registerInnerEditor(){Q.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(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.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 ht{static registerEditTool(){Q.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,{x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},exports.EditTool=i([$()],exports.EditTool);const{left:lt,right:dt}=t.Direction9,{move:ct,copy:gt,toNumberPoints:ut}=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===lt;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){const e=ut(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(ct(t,n,r),o&&ct(e,-n,-r)):(o&&ct(t,-n,-r),ct(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),gt(o[7],i),gt(e[7],i),gt(o[3],a),gt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===lt||t===dt,o[t].visible=a,e[t].visible=!r&&a}},exports.LineEditTool=i([$()],exports.LineEditTool),t.Plugin.add("editor","resize"),t.Creator.editor=function(t){return new at(t)},t.dataType(!1)(t.Box.prototype,"textBox"),t.defineKey(t.UI.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),t.defineKey(t.UI.prototype,"editInner",{get:()=>"PathEditor"}),t.defineKey(t.Group.prototype,"editInner",{get:()=>""}),t.defineKey(t.Text.prototype,"editInner",{get:()=>"TextEditor"}),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=W,exports.EditDataHelper=V,exports.EditPoint=Z,exports.EditSelect=x,exports.EditSelectHelper=y,exports.EditToolCreator=Q,exports.Editor=at,exports.EditorEvent=s,exports.EditorGroupEvent=it,exports.EditorHelper=j,exports.EditorMoveEvent=n,exports.EditorRotateEvent=a,exports.EditorScaleEvent=r,exports.EditorSkewEvent=h,exports.InnerEditor=ht,exports.InnerEditorEvent=et,exports.SelectArea=E,exports.Stroker=v,exports.registerEditTool=$,exports.registerInnerEditor=J;
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.editor=function(t,e,i){"use strict";function o(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 s(t){return t?t instanceof Array?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class n extends e.Event{get list(){return s(this.value)}get oldList(){return s(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}n.SELECT="editor.select",n.HOVER="editor.hover";class r extends n{constructor(t,e){super(t,e)}}r.MOVE="editor.move";class a extends n{constructor(t,e){super(t,e)}}a.SCALE="editor.scale";class h extends n{constructor(t,e){super(t,e)}}h.ROTATE="editor.rotate";class l extends n{constructor(t,e){super(t,e)}}function d(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))}})}}l.SKEW="editor.skew";const{abs:c}=Math,{copy:g,scale:u}=e.MatrixHelper,{setListWithFn:f}=e.BoundsHelper,{worldBounds:p}=e.LeafBoundsHelper,m=e.getMatrixData(),v=e.getBoundsData();class E extends e.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(f(v,t,p),this.set(v)):this.width=this.height=1}__draw(t,i){const{list:o}=this;if(o.length){let s;const n=this.__,{stroke:r,strokeWidth:a,fill:h}=n,{bounds:l}=i;for(let d=0;d<o.length;d++){s=o[d];const{worldTransform:f,worldRenderBounds:p}=s;if(!l||l.hit(p,i.matrix)){const o=c(f.scaleX),l=c(f.scaleY);if(o!==l){g(m,f),u(m,1/o,1/l),t.setWorld(m,i.matrix),t.beginPath(),n.strokeWidth=a;const{x:e,y:r,width:h,height:d}=s.__layout.boxBounds;t.rect(e*o,r*l,h*o,d*l)}else t.setWorld(f,i.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=a/c(f.scaleX);r&&("string"==typeof r?e.Paint.stroke(r,this,t):e.Paint.strokes(r,this,t)),h&&("string"==typeof h?e.Paint.fill(h,this,t):e.Paint.fills(h,this,t))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}o([d((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],E.prototype,"target",void 0);class L 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:y,Yes:b,NoAndSkip:w,YesAndSkip:k}=e.Answer,x={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?k:w;if(t.isFrame)return e.includes(t.__layout.boxBounds,t.__world)?k:y;if(e.hit(t.__layout.boxBounds,t.__world)&&t.__.hitSelf)return b}return y}return t.isBranch?w:y}},{findOne:_}=x;class T 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 E,this.targetStroker=new E,this.bounds=new e.Bounds,this.selectArea=new L,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.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),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(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInnerPoint(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(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:i}=this,o=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new e.LeafList(i.app.find(x.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(t){t.multiTouch||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&&e.Plugin.has("find"))||t.target.draggable)&&(!this.editor.editing&&this.allow(t.target)||t.shiftKey&&!_(t.path))}allowSelect(t){return this.running&&!this.isMoveMode&&!t.middle}findDeepOne(t){const i={exclude:new e.LeafList(this.editor.editBox.rect)};return _(t.target.leafer.interaction.findPath(t,i))}findUI(t){return this.isMultipleSelect(t)?this.findDeepOne(t):_(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_(n.HOVER,this.onHover,this),t.on_(n.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,!0),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:M,top:O,topRight:S,right:P,bottomRight:H,bottom:C,bottomLeft:B,left:I}=e.Direction9,{toPoint:V}=e.AroundHelper,{within:D}=e.MathHelper,R={getScaleData(t,e,i,o,s,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,L=v<0?-1:1,y=E<0?-1:1,b=a?v:L*g.width/p,w=a?E:y*g.height/m;o.x*=a?v:L,o.y*=a?E:y,Math.abs(o.x)===p&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const k=(-o.y+m)/m,x=(o.x+p)/p,_=(o.y+m)/m,T=(-o.x+p)/p;switch(i){case O:c=k,h="bottom";break;case P:d=x,h="left";break;case C:c=_,h="top";break;case I:d=T,h="right";break;case M:c=k,d=T,h="bottom-right";break;case S:c=k,d=x,h="bottom-left";break;case H:c=_,d=x,h="top-left";break;case B:c=_,d=T,h="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case O:case C:t=c;break;case I:case P:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=b,c/=w,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=D(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=D(e*c,f)/e}return V(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(t,i,o,s,n){let r,a={};switch(i){case M:r="bottom-right";break;case S:r="bottom-left";break;case H:r="top-left";break;case B:r="top-right";break;default:r="center"}return V(n||r,t,a,!0),{origin:a,rotation:e.PointHelper.getRotation(s,a,o)}},getSkewData(t,i,o,s){let n,r,a={},h=0,l=0;switch(i){case O:r={x:.5,y:0},n="bottom",h=1;break;case C:r={x:.5,y:1},n="top",h=1;break;case I:r={x:0,y:.5},n="right",l=1;break;case P:r={x:1,y:.5},n="left",l=1}const{width:d,height:c}=t;r.x=r.x*d,r.y=r.y*c,V(s||n,t,a,!0);const g=e.PointHelper.getRotation(r,a,{x:r.x+(h?o.x:0),y:r.y+(l?o.y:0)});return h?h=-g:l=g,{origin:a,skewX:h,skewY:l}},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 I:t=P;break;case M:t=S;break;case B:t=H;break;case P:t=I;break;case S:t=M;break;case H:t=B}if(i)switch(t){case O:t=C;break;case M:t=B;break;case S:t=H;break;case C:t=O;break;case B:t=M;break;case H:t=S}return t}},A={};function Z(t,i){const{editBox:o}=t,s=o.enterPoint;if(!s||!t.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:h,resizeable:l,rotateable:d,skewable:c}=t.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:f}=o;let p="resize"===g;p&&d&&(i.metaKey||i.ctrlKey||!l)&&(p=!1);const m=c&&!p&&"resize-line"===s.name?h:p?r:a;n+=45*(R.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;A[y]?s.cursor=A[y]:A[y]=s.cursor={url:W(v,n),x:E,y:L}}function z(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function W(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class G extends e.Box{}const U=["top","right","bottom","left"];class F 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 G({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.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,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 o=0;o<8;o++)t=new G({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new G({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new G({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(h,"rotate",2),o.addMany(...n,a,h,l,...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}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i,o.syncEventer=i&&this.editor,i&&(e.syncEventer=o,this.app.interaction.bottomList=[{target:o,proxy:e}])}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,buttons:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:f}=i,p="number"==typeof f?f:10,m=!(f&&o<p&&s<p);let v,E,L,y={};for(let n=0;n<8;n++)e.AroundHelper.toPoint(e.AroundHelper.directionData[n],t,y),E=h[n],v=l[n],L=d[Math.floor(n/2)],E.set(y),v.set(y),L.set(y),E.visible=L.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(L.width=o,E.width>o-30&&(E.visible=!1)):(L.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=U.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=U.indexOf(i);(h%2&&r||(h+1)%2&&a)&&o&&(h=(h+2)%4);const l=o?R.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,s,!!n),o&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}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,offsetX:0,offsetY:0};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){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),Z(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:i}=this;if(i.single){const{element:o}=i;if(o.locked)return;if(o.isBranch&&!o.editInner){if(o.textBox){const{children:t}=o,s=t.find((t=>t.editable&&t instanceof e.Text))||t.find((t=>t instanceof e.Text));if(s)return i.openInnerEditor(s)}i.openGroup(o),i.target=i.selector.findDeepOne(t)}else i.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,Z(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(n.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.PointerEvent.ENTER,(()=>z(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 Y 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,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const X='\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"/>',N={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${X}\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${X}\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${X}\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,flipable:!0,rotateable:!0,skewable:!0},K=new e.Bounds;function j(t){const{simulateTarget:e,list:i}=t,{zoomLayer:o}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(K.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),o.add(e)}const $=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),q=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),J={group(t,i,o){t.sort(q);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($);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&&!t.isBranchLeaf){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($),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(q),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},Q=e.Debug.get("EditToolCreator");function tt(){return t=>{it.register(t)}}const et=tt,it={list:{},register(t){const{tag:e}=t.prototype;ot[e]&&Q.repeat(e),ot[e]=t},get:(t,e)=>new ot[t](e)},{list:ot}=it;class st extends n{constructor(t,e){super(t,e)}}st.BEFORE_OPEN="innerEditor.before_open",st.OPEN="innerEditor.open",st.BEFORE_CLOSE="innerEditor.before_close",st.CLOSE="innerEditor.close";class nt extends n{constructor(t,e){super(t,e)}}nt.GROUP="editor.group",nt.BEFORE_UNGROUP="editor.before_ungroup",nt.UNGROUP="editor.ungroup",nt.OPEN="editor.open_group",nt.CLOSE="editor.close_group";const{updateMatrix:rt}=e.LeafHelper,at={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},ht="top-left";class lt extends e.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(e.PropertyEvent.CHANGE,(i=>{if(this.checkChange&&at[i.attrName]){const{attrName:o,newValue:s,oldValue:n}=i,r="s"===o[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const a=this.__;a[o]=n,rt(this.parent),rt(this);const h=new e.Matrix(this.__world);switch(a[o]=s,this.__layout.rotationChange(),rt(this),this.changedTransform=new e.Matrix(this.__world).divide(h),o){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(ht,r);break;case"scaleX":t.scaleOf(ht,r,1);break;case"scaleY":t.scaleOf(ht,1,r);break;case"skewX":t.skewOf(ht,r,0);break;case"skewY":t.skewOf(ht,0,r)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class dt 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 dragHoverExclude(){return[this.editBox.rect]}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 moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,o){super(o),this.config=e.DataHelper.clone(N),this.leafList=new e.LeafList,this.openedGroupList=new e.LeafList,this.simulateTarget=new lt(this),this.editBox=new F(this),this.editToolList={},this.selector=new T(this),this.editMask=new Y(this),this.targetEventIds=[],t&&(this.config=e.DataHelper.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox),i.Plugin.has("resize")||(this.config.editSize="scale")}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&&j(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]||it.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof i.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{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;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof i.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const n=R.getScaleData(e,this.dragStartBounds,i,t.getInnerTotal(e),s,R.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:h}=t.current;if(o&&"resize-line"===h)return this.onSkew(t);const{element:l}=this;let d,c;if(t instanceof i.RotateEvent){if("rotate"!==s)return;t.stop(),c=t.rotation,d=l.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=R.getRotateData(l.boxBounds,a,t.getBoxPoint(l),l.getBoxPoint(e),t.shiftKey?null:l.around||l.origin||n||"center");c=i.rotation,d=i.origin}c=e.MathHelper.getGapRotation(c,r,l.rotation),c&&(l.scaleX*l.scaleY<0&&(c=-c),this.rotateOf(d,e.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=R.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),R.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const s=new r(r.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new a(a.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.checkTransform("resizeable"))return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.scaleOf(t,e,i))))),h=new a(a.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(h),this.emitEvent(h)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.safeChange((()=>i.flip(t))))):new e.Matrix(e.LeafHelper.getFlipTransform(i,t)),n=new a(a.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new h(h.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.checkTransform("skewable"))return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.skewOf(t,e,i))))),a=new l(l.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(e.LeafHelper.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:i}=this;if(this.multiple&&!i.canChange)return i.changedTransform;const o=new e.Matrix(i.worldTransform);return t(),new e.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=J.group(this.list,this.element,t),this.emitGroupEvent(nt.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(nt.BEFORE_UNGROUP,t))),this.target=J.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(nt.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(nt.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(nt.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 nt(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&it.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||it.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(st.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(st.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(st.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(st.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new st(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&&(J.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&(J.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:o}=this;this.targetEventIds=[o.on_(e.RenderEvent.START,this.update,this),t.on_(e.RenderEvent.CHILD_START,this.forceRender,this),t.on_(i.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),t.on_(i.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),t.on_(i.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([i.KeyEvent.HOLD,i.KeyEvent.UP],(t=>{Z(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.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}o([d((function(t,e){t.emitEvent(new n(n.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],dt.prototype,"hoverTarget",void 0),o([d((function(t,i){const{target:o}=t;o?t.leafList=o instanceof e.LeafList?o:new e.LeafList(o):(t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new n(n.SELECT,{editor:t,value:o,oldValue:i})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{t.multiple&&j(t),z(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],dt.prototype,"target",void 0);class ct{static registerInnerEditor(){it.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(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.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 ct{static registerEditTool(){it.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,{x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=o([tt()],t.EditTool);const{left:gt,right:ut}=e.Direction9,{move:ft,copy:pt,toNumberPoints: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===gt;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){const e=mt(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(ft(t,n,r),o&&ft(e,-n,-r)):(o&&ft(t,-n,-r),ft(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),pt(o[7],i),pt(e[7],i),pt(o[3],a),pt(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===gt||t===ut,o[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=o([tt()],t.LineEditTool),e.Plugin.add("editor","resize","find"),e.Creator.editor=function(t){return new dt(t)},e.dataType(!1)(e.Box.prototype,"textBox"),e.defineKey(e.UI.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),e.defineKey(e.UI.prototype,"editInner",{get:()=>"PathEditor"}),e.defineKey(e.Group.prototype,"editInner",{get:()=>""}),e.defineKey(e.Text.prototype,"editInner",{get:()=>"TextEditor"}),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=F,t.EditDataHelper=R,t.EditPoint=G,t.EditSelect=T,t.EditSelectHelper=x,t.EditToolCreator=it,t.Editor=dt,t.EditorEvent=n,t.EditorGroupEvent=nt,t.EditorHelper=J,t.EditorMoveEvent=r,t.EditorRotateEvent=h,t.EditorScaleEvent=a,t.EditorSkewEvent=l,t.InnerEditor=ct,t.InnerEditorEvent=st,t.SelectArea=L,t.Stroker=E,t.registerEditTool=tt,t.registerInnerEditor=et,t}({},LeaferUI,LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.editor=function(t,e,i){"use strict";function o(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 s(t){return t?t instanceof Array?t:[t]:[]}"function"==typeof SuppressedError&&SuppressedError;class n extends e.Event{get list(){return s(this.value)}get oldList(){return s(this.oldValue)}constructor(t,e){super(t),e&&Object.assign(this,e)}}n.SELECT="editor.select",n.HOVER="editor.hover";class r extends n{constructor(t,e){super(t,e)}}r.MOVE="editor.move";class a extends n{constructor(t,e){super(t,e)}}a.SCALE="editor.scale";class h extends n{constructor(t,e){super(t,e)}}h.ROTATE="editor.rotate";class l extends n{constructor(t,e){super(t,e)}}function d(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))}})}}l.SKEW="editor.skew";const{abs:c}=Math,{copy:g,scale:u}=e.MatrixHelper,{setListWithFn:f}=e.BoundsHelper,{worldBounds:p}=e.LeafBoundsHelper,m=e.getMatrixData(),v=e.getBoundsData();class E extends e.UI{constructor(){super(),this.list=[],this.hittable=!1,this.strokeAlign="center"}setTarget(t,e){this.set(e),this.target=t,this.update()}update(){const{list:t}=this;t.length?(f(v,t,p),this.set(v)):this.width=this.height=1}__draw(t,i){const{list:o}=this;if(o.length){let s;const n=this.__,{stroke:r,strokeWidth:a,fill:h}=n,{bounds:l}=i;for(let d=0;d<o.length;d++){s=o[d];const{worldTransform:f,worldRenderBounds:p}=s;if(!l||l.hit(p,i.matrix)){const o=c(f.scaleX),l=c(f.scaleY);if(o!==l){g(m,f),u(m,1/o,1/l),t.setWorld(m,i.matrix),t.beginPath(),n.strokeWidth=a;const{x:e,y:r,width:h,height:d}=s.__layout.boxBounds;t.rect(e*o,r*l,h*o,d*l)}else t.setWorld(f,i.matrix),t.beginPath(),s.__.__useArrow?s.__drawPath(t):s.__.__pathForRender?s.__drawRenderPath(t):s.__drawPathByBox(t),n.strokeWidth=a/c(f.scaleX);r&&("string"==typeof r?e.Paint.stroke(r,this,t):e.Paint.strokes(r,this,t)),h&&("string"==typeof h?e.Paint.fill(h,this,t):e.Paint.fills(h,this,t))}}n.strokeWidth=a}}destroy(){this.target=null,super.destroy()}}o([d((function(t){const e=t.target;t.list=e?e instanceof Array?e:[e]:[]}))],E.prototype,"target",void 0);class y 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 L={findOne:t=>t.list.find((t=>t.editable)),findByBounds(t,e){const i=[];return b([t],i,e),i}};function b(t,e,i){let o,s;for(let n=0,r=t.length;n<r;n++)if(o=t[n],s=o.__,s.hittable&&s.visible&&!s.locked&&i.hit(o.__world)){if(s.editable){if(o.isBranch&&!s.hitChildren){s.hitSelf&&e.push(o);continue}if(o.isFrame){if(i.includes(o.__layout.boxBounds,o.__world)){e.push(o);continue}}else i.hit(o.__layout.boxBounds,o.__world)&&s.hitSelf&&e.push(o)}o.isBranch&&b(o.children,e,i)}}const{findOne:w,findByBounds:k}=L;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 E,this.targetStroker=new E,this.bounds=new e.Bounds,this.selectArea=new y,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.hoverStroker.update(),this.targetStroker.update()}onPointerMove(t){const{app:e,editor:i}=this;if(this.running&&!this.isMoveMode&&e.interaction.canHover&&!e.interaction.dragging){const e=this.findUI(t);i.hoverTarget=i.hasItem(e)?null:e}this.isMoveMode&&(i.hoverTarget=null)}onBeforeDown(t){if(t.multiTouch)return;const{select:e}=this.editor.mergeConfig;"press"===e&&(this.app.config.mobile?this.waitSelect=()=>this.checkAndSelect(t):this.checkAndSelect(t))}onTap(t){if(t.multiTouch)return;const{editor:e}=this,{select:i}=e.mergeConfig;"tap"===i?this.checkAndSelect(t):this.waitSelect&&this.waitSelect(),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(!t.multiTouch&&(this.waitSelect&&this.waitSelect(),this.allowDrag(t))){const{editor:e}=this,{stroke:i,area:o}=e.mergeConfig,{x:s,y:n}=t.getInnerPoint(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(!t.multiTouch){if(this.editor.dragging)return this.onDragEnd(t);if(this.dragging){const{editor:i}=this,o=t.getInnerTotal(this),s=this.bounds.clone().unsign(),n=new e.LeafList(k(i.app,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(t){t.multiTouch||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(t){const i={exclude:new e.LeafList(this.editor.editBox.rect)};return w(t.target.leafer.interaction.findPath(t,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:e}=t;e.selector.proxy=t,this.__eventIds=[t.on_(n.HOVER,this.onHover,this),t.on_(n.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,!0),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:T,top:_,topRight:M,right:O,bottomRight:S,bottom:P,bottomLeft:H,left:B}=e.Direction9,{toPoint:C}=e.AroundHelper,{within:I}=e.MathHelper,V={getScaleData(t,e,i,o,s,n,r,a){let h,l={},d=1,c=1;const{boxBounds:g,widthRange:u,heightRange:f}=t,{width:p,height:m}=e;n&&(o.x*=2,o.y*=2);const v=t.scaleX/e.scaleX,E=t.scaleY/e.scaleY,y=v<0?-1:1,L=E<0?-1:1,b=a?v:y*g.width/p,w=a?E:L*g.height/m;o.x*=a?v:y,o.y*=a?E:L,Math.abs(o.x)===p&&(o.x+=.1),Math.abs(o.y)===m&&(o.y+=.1);const k=(-o.y+m)/m,x=(o.x+p)/p,V=(o.y+m)/m,D=(-o.x+p)/p;switch(i){case _:c=k,h="bottom";break;case O:d=x,h="left";break;case P:c=V,h="top";break;case B:d=D,h="right";break;case T:c=k,d=D,h="bottom-right";break;case M:c=k,d=x,h="bottom-left";break;case S:c=V,d=x,h="top-left";break;case H:c=V,d=D,h="top-right"}if(s){if(!("corner"===s&&i%2)){let t;switch(i){case _:case P:t=c;break;case B:case O:t=d;break;default:t=Math.sqrt(Math.abs(d*c))}d=d<0?-t:t,c=c<0?-t:t}}if(d/=b,c/=w,!r){const{worldTransform:e}=t;d<0&&(d=1/g.width/e.scaleX),c<0&&(c=1/g.height/e.scaleY)}if(u){const e=g.width*t.scaleX;d=I(e*d,u)/e}if(f){const e=g.height*t.scaleY;c=I(e*c,f)/e}return C(n||h,g,l,!0),{origin:l,scaleX:d,scaleY:c,direction:i,lockRatio:s,around:n}},getRotateData(t,i,o,s,n){let r,a={};switch(i){case T:r="bottom-right";break;case M:r="bottom-left";break;case S:r="top-left";break;case H:r="top-right";break;default:r="center"}return C(n||r,t,a,!0),{origin:a,rotation:e.PointHelper.getRotation(s,a,o)}},getSkewData(t,i,o,s){let n,r,a={},h=0,l=0;switch(i){case _:r={x:.5,y:0},n="bottom",h=1;break;case P:r={x:.5,y:1},n="top",h=1;break;case B:r={x:0,y:.5},n="right",l=1;break;case O:r={x:1,y:.5},n="left",l=1}const{width:d,height:c}=t;r.x=r.x*d,r.y=r.y*c,C(s||n,t,a,!0);const g=e.PointHelper.getRotation(r,a,{x:r.x+(h?o.x:0),y:r.y+(l?o.y:0)});return h?h=-g:l=g,{origin:a,skewX:h,skewY:l}},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 B:t=O;break;case T:t=M;break;case H:t=S;break;case O:t=B;break;case M:t=T;break;case S:t=H}if(i)switch(t){case _:t=P;break;case T:t=H;break;case M:t=S;break;case P:t=_;break;case H:t=T;break;case S:t=M}return t}},D={};function R(t,i){const{editBox:o}=t,s=o.enterPoint;if(!s||!t.editing||!o.visible)return;if("circle"===s.name)return;if("button"===s.pointType)return void(s.cursor||(s.cursor="pointer"));let{rotation:n}=o;const{resizeCursor:r,rotateCursor:a,skewCursor:h,resizeable:l,rotateable:d,skewable:c}=t.mergeConfig,{pointType:g}=s,{flippedX:u,flippedY:f}=o;let p="resize"===g;p&&d&&(i.metaKey||i.ctrlKey||!l)&&(p=!1);const m=c&&!p&&"resize-line"===s.name?h:p?r:a;n+=45*(V.getFlipDirection(s.direction,u,f)+1),n=2*Math.round(e.MathHelper.formatRotation(n,!0)/2);const{url:v,x:E,y:y}=m,L=v+n;D[L]?s.cursor=D[L]:D[L]=s.cursor={url:Z(v,n),x:E,y:y}}function A(t){const{moveCursor:e,moveable:i}=t.mergeConfig;t.editBox.rect.cursor=i?e:void 0}function Z(t,e){return'"data:image/svg+xml,'+encodeURIComponent(t.replace("{{rotation}}",e.toString()))+'"'}class z extends e.Box{}const W=["top","right","bottom","left"];class G 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 z({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.__listenEvents()}create(){let t,e,i;const{view:o,resizePoints:s,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 o=0;o<8;o++)t=new z({name:"rotate-point",around:d[o],width:15,height:15,hitFill:"all"}),n.push(t),this.listenPointEvents(t,"rotate",o),o%2&&(e=new z({name:"resize-line",around:"center",width:10,height:10,hitFill:"all"}),r.push(e),this.listenPointEvents(e,"resize",o)),i=new z({name:"resize-point",hitRadius:5}),s.push(i),this.listenPointEvents(i,"resize",o);this.listenPointEvents(h,"rotate",2),o.addMany(...n,a,h,l,...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}=t,h=this.getPointsStyle(),l=this.getMiddlePointsStyle();let d;for(let t=0;t<8;t++)d=n[t],d.set(this.getPointStyle(t%2?l[(t-1)/2%l.length]:h[t/2%h.length])),t%2||(d.rotation=t/2*90);s.set(this.getPointStyle(t.circle||t.rotatePoint||h[0])),o.set(Object.assign({stroke:r,strokeWidth:a},t.rect||{})),o.hittable=!i,o.syncEventer=i&&this.editor,i&&(e.syncEventer=o,this.app.interaction.bottomList=[{target:o,proxy:e}])}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,buttons:a,resizePoints:h,rotatePoints:l,resizeLines:d}=this,{middlePoint:c,resizeable:g,rotateable:u,hideOnSmall:f}=i,p="number"==typeof f?f:10,m=!(f&&o<p&&s<p);let v,E,y,L={};for(let n=0;n<8;n++)e.AroundHelper.toPoint(e.AroundHelper.directionData[n],t,L),E=h[n],v=l[n],y=d[Math.floor(n/2)],E.set(L),v.set(L),y.set(L),E.visible=y.visible=m&&!(!g&&!u),v.visible=m&&u&&g&&!i.rotatePoint,n%2&&(E.visible=v.visible=m&&!!c,(n+1)/2%2?(y.width=o,E.width>o-30&&(E.visible=!1)):(y.height=s,E.rotation=90,E.width>s-30&&(E.visible=!1)));r.visible=m&&u&&!(!i.circle&&!i.rotatePoint),r.visible&&this.layoutCircle(i),n.path&&(n.path=null),n.set(Object.assign(Object.assign({},t),{visible:!0})),a.visible=m&&a.children.length>0,a.visible&&this.layoutButtons(i)}}layoutCircle(t){const{circleDirection:e,circleMargin:i,buttonsMargin:o,buttonsDirection:s,middlePoint:n}=t,r=W.indexOf(e||(this.buttons.children.length&&"bottom"===s?"top":"bottom"));this.setButtonPosition(this.circle,r,i||o,!!n)}layoutButtons(t){const{buttons:e}=this,{buttonsDirection:i,buttonsFixed:o,buttonsMargin:s,middlePoint:n}=t,{flippedX:r,flippedY:a}=this;let h=W.indexOf(i);(h%2&&r||(h+1)%2&&a)&&o&&(h=(h+2)%4);const l=o?V.getRotateDirection(h,this.flippedOne?this.rotation:-this.rotation,4):h;this.setButtonPosition(e,l,s,!!n),o&&(e.rotation=90*(l-h)),e.scaleX=r?-1:1,e.scaleY=a?-1:1}setButtonPosition(t,e,i,o){const s=this.resizePoints[2*e+1],n=e%2,r=e&&3!==e?1:-1,a=(i+(e%2?(o?s.width:0)+t.boxBounds.width:(o?s.height:0)+t.boxBounds.height)/2)*r;n?(t.x=s.x+a,t.y=s.y):(t.x=s.x,t.y=s.y+a)}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,offsetX:0,offsetY:0};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){this.dragging=!0;const{editor:e}=this;"rect"===t.current.name?(this.moving=!0,e.dragStartPoint={x:e.element.x,y:e.element.y},e.opacity=e.mergeConfig.hideOnMove?0:1):"resize"===t.current.pointType&&(e.dragStartBounds=Object.assign({},e.element.getLayoutBounds("box","local")),e.resizeDirection=t.current.direction)}onDragEnd(t){this.dragging=!1,this.moving=!1,"rect"===t.current.name&&(this.editor.opacity=1),this.editor.resizeDirection=void 0}onDrag(t){const{editor:e}=this,i=this.enterPoint=t.current;"rotate"===i.pointType||t.metaKey||t.ctrlKey||!e.mergeConfig.resizeable?e.mergeConfig.rotateable&&e.onRotate(t):"resize"===i.pointType&&e.onScale(t),R(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:i}=this;if(i.single){const{element:o}=i;if(o.locked)return;if(o.isBranch&&!o.editInner){if(o.textBox){const{children:t}=o,s=t.find((t=>t.editable&&t instanceof e.Text))||t.find((t=>t instanceof e.Text));if(s)return i.openInnerEditor(s)}i.openGroup(o),i.target=i.selector.findDeepOne(t)}else i.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,R(s,e)}))}__listenEvents(){const{rect:t,editor:e}=this;this.__eventIds=[e.on_(n.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.PointerEvent.ENTER,(()=>A(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 U 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,!0===o?"rgba(0,0,0,0.8)":o),t.setWorld(s.__world,e.matrix),t.clearRect(0,0,n,r)}}destroy(){this.editor=null,super.destroy()}}const F='\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"/>',X={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${F}\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${F}\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${F}\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,flipable:!0,rotateable:!0,skewable:!0},Y=new e.Bounds;function K(t){const{simulateTarget:e,list:i}=t,{zoomLayer:o}=i[0].leafer.zoomLayer;e.safeChange((()=>e.reset(Y.setListWithFn(i,(t=>t.getBounds("box","page"))).get()))),o.add(e)}const N=(t,e)=>t.parent.children.indexOf(t)-e.parent.children.indexOf(e),j=(t,e)=>e.parent.children.indexOf(e)-t.parent.children.indexOf(t),$={group(t,i,o){t.sort(j);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(N);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&&!t.isBranchLeaf){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(N),t.forEach((t=>{t.parent&&t.parent.add(t)}))},toBottom(t){t.sort(j),t.forEach((t=>{t.parent&&t.parent.addAt(t,0)}))}},q=e.Debug.get("EditToolCreator");function J(){return t=>{tt.register(t)}}const Q=J,tt={list:{},register(t){const{tag:e}=t.prototype;et[e]&&q.repeat(e),et[e]=t},get:(t,e)=>new et[t](e)},{list:et}=tt;class it extends n{constructor(t,e){super(t,e)}}it.BEFORE_OPEN="innerEditor.before_open",it.OPEN="innerEditor.open",it.BEFORE_CLOSE="innerEditor.before_close",it.CLOSE="innerEditor.close";class ot extends n{constructor(t,e){super(t,e)}}ot.GROUP="editor.group",ot.BEFORE_UNGROUP="editor.before_ungroup",ot.UNGROUP="editor.ungroup",ot.OPEN="editor.open_group",ot.CLOSE="editor.close_group";const{updateMatrix:st}=e.LeafHelper,nt={x:1,y:1,scaleX:1,scaleY:1,rotation:1,skewX:1,skewY:1},rt="top-left";class at extends e.Rect{get __tag(){return"SimulateElement"}constructor(t){super(),this.checkChange=!0,this.canChange=!0,this.visible=this.hittable=!1,this.on(e.PropertyEvent.CHANGE,(i=>{if(this.checkChange&&nt[i.attrName]){const{attrName:o,newValue:s,oldValue:n}=i,r="s"===o[0]?(s||1)/(n||1):(s||0)-(n||0);this.canChange=!1;const a=this.__;a[o]=n,st(this.parent),st(this);const h=new e.Matrix(this.__world);switch(a[o]=s,this.__layout.rotationChange(),st(this),this.changedTransform=new e.Matrix(this.__world).divide(h),o){case"x":t.move(r,0);break;case"y":t.move(0,r);break;case"rotation":t.rotateOf(rt,r);break;case"scaleX":t.scaleOf(rt,r,1);break;case"scaleY":t.scaleOf(rt,1,r);break;case"skewX":t.skewOf(rt,r,0);break;case"skewY":t.skewOf(rt,0,r)}this.canChange=!0}}))}safeChange(t){this.canChange&&(this.checkChange=!1,t(),this.checkChange=!0)}}class ht 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 dragHoverExclude(){return[this.editBox.rect]}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 moving(){return this.editBox.moving}get element(){return this.multiple?this.simulateTarget:this.list[0]}get buttons(){return this.editBox.buttons}constructor(t,o){super(o),this.config=e.DataHelper.clone(X),this.leafList=new e.LeafList,this.openedGroupList=new e.LeafList,this.simulateTarget=new at(this),this.editBox=new G(this),this.editToolList={},this.selector=new x(this),this.editMask=new U(this),this.targetEventIds=[],t&&(this.config=e.DataHelper.default(t,this.config)),this.addMany(this.editMask,this.selector,this.editBox),i.Plugin.has("resize")||(this.config.editSize="scale")}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(){if(this.editing){if(!this.element.parent)return this.cancel();this.innerEditing&&this.innerEditor.update(),this.editTool.update(),this.selector.update()}}updateEditBox(){this.multiple&&K(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]||tt.get(t,this),this.editBox.load(),this.editTool.load()}}getEditSize(t){return this.mergeConfig.editSize}onMove(t){if(t instanceof i.MoveEvent){if("drag"!==t.moveType){const{moveable:e,resizeable:i}=this.mergeConfig,o=t.getLocalMove(this.element);"move"===e?(t.stop(),this.move(o.x,o.y)):"zoom"===i&&t.stop()}}else{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;let{around:o,lockRatio:s,resizeable:n,flipable:r,editSize:a}=this.mergeConfig;if(t instanceof i.ZoomEvent)"zoom"===n&&(t.stop(),this.scaleOf(e.getBoxPoint(t),t.scale,t.scale));else{const{direction:i}=t.current;(t.shiftKey||e.lockRatio)&&(s=!0);const n=V.getScaleData(e,this.dragStartBounds,i,t.getInnerTotal(e),s,V.getAround(o,t.altKey),r,this.multiple||"scale"===a);this.editTool.onScaleWithDrag?(n.drag=t,this.scaleWithDrag(n)):this.scaleOf(n.origin,n.scaleX,n.scaleY)}}onRotate(t){const{skewable:o,rotateable:s,around:n,rotateGap:r}=this.mergeConfig,{direction:a,name:h}=t.current;if(o&&"resize-line"===h)return this.onSkew(t);const{element:l}=this;let d,c;if(t instanceof i.RotateEvent){if("rotate"!==s)return;t.stop(),c=t.rotation,d=l.getBoxPoint(t)}else{const e={x:t.x-t.moveX,y:t.y-t.moveY},i=V.getRotateData(l.boxBounds,a,t.getBoxPoint(l),l.getBoxPoint(e),t.shiftKey?null:l.around||l.origin||n||"center");c=i.rotation,d=i.origin}c=e.MathHelper.getGapRotation(c,r,l.rotation),c&&(l.scaleX*l.scaleY<0&&(c=-c),this.rotateOf(d,e.MathHelper.float(c,2)))}onSkew(t){const{element:e}=this,{around:i}=this.mergeConfig,{origin:o,skewX:s,skewY:n}=V.getSkewData(e.boxBounds,t.current.direction,t.getInnerMove(e),V.getAround(i,t.altKey));(s||n)&&this.skewOf(o,s,n)}move(t,e=0){if(!this.checkTransform("moveable"))return;const{element:i}=this,o=i.getWorldPointByLocal("object"==typeof t?Object.assign({},t):{x:t,y:e},null,!0);this.multiple&&i.safeChange((()=>i.move(t,e)));const s=new r(r.MOVE,{target:i,editor:this,moveX:o.x,moveY:o.y});this.editTool.onMove(s),this.emitEvent(s)}scaleWithDrag(t){if(!this.checkTransform("resizeable"))return;const{element:e}=this,i=new a(a.SCALE,Object.assign(Object.assign({},t),{target:e,editor:this,worldOrigin:e.getWorldPoint(t.origin)}));this.editTool.onScaleWithDrag(i),this.emitEvent(i)}scaleOf(t,e,i=e,o){if(!this.checkTransform("resizeable"))return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.scaleOf(t,e,i))))),h=new a(a.SCALE,{target:s,editor:this,worldOrigin:n,scaleX:e,scaleY:i,transform:r});this.editTool.onScale(h),this.emitEvent(h)}flip(t){if(!this.checkTransform("resizeable"))return;const{element:i}=this,o=this.getWorldOrigin("center"),s=this.multiple?this.getChangedTransform((()=>i.safeChange((()=>i.flip(t))))):new e.Matrix(e.LeafHelper.getFlipTransform(i,t)),n=new a(a.SCALE,{target:i,editor:this,worldOrigin:o,scaleX:"x"===t?-1:1,scaleY:"y"===t?-1:1,transform:s});this.editTool.onScale(n),this.emitEvent(n)}rotateOf(t,e){if(!this.checkTransform("rotateable"))return;const{element:i}=this,o=this.getWorldOrigin(t),s=this.multiple&&this.getChangedTransform((()=>i.safeChange((()=>i.rotateOf(t,e))))),n=new h(h.ROTATE,{target:i,editor:this,worldOrigin:o,rotation:e,transform:s});this.editTool.onRotate(n),this.emitEvent(n)}skewOf(t,e,i=0,o){if(!this.checkTransform("skewable"))return;const{element:s}=this,n=this.getWorldOrigin(t),r=this.multiple&&this.getChangedTransform((()=>s.safeChange((()=>s.skewOf(t,e,i))))),a=new l(l.SKEW,{target:s,editor:this,worldOrigin:n,skewX:e,skewY:i,transform:r});this.editTool.onSkew(a),this.emitEvent(a)}checkTransform(t){return this.element&&!this.element.locked&&this.mergeConfig[t]}getWorldOrigin(t){return this.element.getWorldPoint(e.LeafHelper.getInnerOrigin(this.element,t))}getChangedTransform(t){const{element:i}=this;if(this.multiple&&!i.canChange)return i.changedTransform;const o=new e.Matrix(i.worldTransform);return t(),new e.Matrix(i.worldTransform).divide(o)}group(t){return this.multiple&&(this.target=$.group(this.list,this.element,t),this.emitGroupEvent(ot.GROUP,this.target)),this.target}ungroup(){const{list:t}=this;return t.length&&(t.forEach((t=>t.isBranch&&this.emitGroupEvent(ot.BEFORE_UNGROUP,t))),this.target=$.ungroup(t),t.forEach((t=>t.isBranch&&this.emitGroupEvent(ot.UNGROUP,t)))),this.list}openGroup(t){this.openedGroupList.add(t),t.hitChildren=!0,this.emitGroupEvent(ot.OPEN,t)}closeGroup(t){this.openedGroupList.remove(t),t.hitChildren=!1,this.emitGroupEvent(ot.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 ot(t,{editTarget:e});this.emitEvent(i),e.emitEvent(i)}openInnerEditor(t,e){if(t&&e&&(this.target=t),this.single){const e=t||this.element,i=e.editInner;i&&tt.list[i]&&(this.editTool.unload(),this.innerEditing=!0,this.innerEditor=this.editToolList[i]||tt.get(i,this),this.innerEditor.editTarget=e,this.emitInnerEvent(it.BEFORE_OPEN),this.innerEditor.load(),this.emitInnerEvent(it.OPEN))}}closeInnerEditor(){this.innerEditing&&(this.innerEditing=!1,this.emitInnerEvent(it.BEFORE_CLOSE),this.innerEditor.unload(),this.emitInnerEvent(it.CLOSE),this.editTool.load(),this.innerEditor=null)}emitInnerEvent(t){const{innerEditor:e}=this,{editTarget:i}=e,o=new it(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&&($.toTop(this.list),this.leafList.update())}toBottom(){this.list.length&&($.toBottom(this.list),this.leafList.update())}listenTargetEvents(){if(!this.targetEventIds.length){const{app:t,leafer:o}=this;this.targetEventIds=[o.on_(e.RenderEvent.START,this.update,this),t.on_(e.RenderEvent.CHILD_START,this.forceRender,this),t.on_(i.MoveEvent.BEFORE_MOVE,this.onMove,this,!0),t.on_(i.ZoomEvent.BEFORE_ZOOM,this.onScale,this,!0),t.on_(i.RotateEvent.BEFORE_ROTATE,this.onRotate,this,!0),t.on_([i.KeyEvent.HOLD,i.KeyEvent.UP],(t=>{R(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.target=this.hoverTarget=null,Object.values(this.editToolList).forEach((t=>t.destroy())),this.simulateTarget.destroy(),this.editToolList={},this.simulateTarget=this.editTool=this.innerEditor=null,super.destroy())}}o([d((function(t,e){t.emitEvent(new n(n.HOVER,{editor:t,value:t.hoverTarget,oldValue:e}))}))],ht.prototype,"hoverTarget",void 0),o([d((function(t,i){const{target:o}=t;o?(t.leafList=o instanceof e.LeafList?o:new e.LeafList(o),t.multiple&&K(t)):(t.simulateTarget.remove(),t.leafList.reset(),t.closeInnerEditor()),t.emitEvent(new n(n.SELECT,{editor:t,value:o,oldValue:i})),t.checkOpenedGroups(),t.editing?t.waitLeafer((()=>{A(t),t.updateEditTool(),t.update(),t.listenTargetEvents()})):(t.updateEditTool(),t.removeTargetEvents())}))],ht.prototype,"target",void 0);class lt{static registerInnerEditor(){tt.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(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.app.tree.hitChildren=!1),this.onLoad())}onUpdate(){}update(){this.onUpdate()}onUnload(){}unload(){const{editor:t}=this;t&&(t.app&&(t.selector.hittable=t.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 lt{static registerEditTool(){tt.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,{x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h,width:l,height:d}=t.element.getLayoutBounds("box",t,!0);e.set({x:i,y:o,scaleX:s,scaleY:n,rotation:r,skewX:a,skewY:h}),e.update({x:0,y:0,width:l,height:d}),this.onUpdate()}unload(){this.editBox.view.visible=!1,this.onUnload()}},t.EditTool=o([J()],t.EditTool);const{left:dt,right:ct}=e.Direction9,{move:gt,copy:ut,toNumberPoints:ft}=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===dt;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){const e=ft(t);return{from:{x:e[0],y:e[1]},to:{x:e[2],y:e[3]}}}dragPoint(t,e,i,o,s){const{x:n,y:r}=s;i?(gt(t,n,r),o&&gt(e,-n,-r)):(o&&gt(t,-n,-r),gt(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),ut(o[7],i),ut(e[7],i),ut(o[3],a),ut(e[3],a)}for(let t=0;t<8;t++)t<4&&(i[t].visible=!1),a=t===dt||t===ct,o[t].visible=a,e[t].visible=!r&&a}},t.LineEditTool=o([J()],t.LineEditTool),e.Plugin.add("editor","resize"),e.Creator.editor=function(t){return new ht(t)},e.dataType(!1)(e.Box.prototype,"textBox"),e.defineKey(e.UI.prototype,"editOuter",{get(){return this.__.__isLinePath?"LineEditTool":"EditTool"}}),e.defineKey(e.UI.prototype,"editInner",{get:()=>"PathEditor"}),e.defineKey(e.Group.prototype,"editInner",{get:()=>""}),e.defineKey(e.Text.prototype,"editInner",{get:()=>"TextEditor"}),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=G,t.EditDataHelper=V,t.EditPoint=z,t.EditSelect=x,t.EditSelectHelper=L,t.EditToolCreator=tt,t.Editor=ht,t.EditorEvent=n,t.EditorGroupEvent=ot,t.EditorHelper=$,t.EditorMoveEvent=r,t.EditorRotateEvent=h,t.EditorScaleEvent=a,t.EditorSkewEvent=l,t.InnerEditor=lt,t.InnerEditorEvent=it,t.SelectArea=y,t.Stroker=E,t.registerEditTool=J,t.registerInnerEditor=Q,t}({},LeaferUI,LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/editor",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "@leafer-in/editor",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,10 +34,9 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "peerDependencies": {
37
- "@leafer-ui/core": "^1.3.2",
38
- "@leafer-in/resize": "^1.3.2",
39
- "@leafer-in/find": "^1.3.2",
40
- "@leafer-ui/interface": "^1.3.2",
41
- "@leafer-in/interface": "^1.3.2"
37
+ "@leafer-ui/core": "^1.3.3",
38
+ "@leafer-in/resize": "^1.3.3",
39
+ "@leafer-ui/interface": "^1.3.3",
40
+ "@leafer-in/interface": "^1.3.3"
42
41
  }
43
42
  }
package/src/Editor.ts CHANGED
@@ -123,6 +123,7 @@ export class Editor extends Group implements IEditor {
123
123
 
124
124
  public update(): void {
125
125
  if (this.editing) {
126
+ if (!this.element.parent) return this.cancel()
126
127
  if (this.innerEditing) this.innerEditor.update()
127
128
  this.editTool.update()
128
129
  this.selector.update()
@@ -1,5 +1,5 @@
1
1
  import { IBounds, ILeaf, ILeafList, IUI, IEventListenerId, IPointerEvent, IFunction } from '@leafer-ui/interface'
2
- import { Bounds, LeafList, Group, Plugin } from '@leafer-ui/draw'
2
+ import { Bounds, LeafList, Group } from '@leafer-ui/draw'
3
3
  import { PointerEvent, DragEvent, MoveEvent, ZoomEvent } from '@leafer-ui/core'
4
4
 
5
5
  import { IEditSelect, IEditor, ISelectArea, IStroker } from '@leafer-in/interface'
@@ -10,7 +10,7 @@ import { EditSelectHelper } from '../helper/EditSelectHelper'
10
10
  import { EditorEvent } from '../event/EditorEvent'
11
11
 
12
12
 
13
- const { findOne } = EditSelectHelper
13
+ const { findOne, findByBounds } = EditSelectHelper
14
14
 
15
15
  export class EditSelect extends Group implements IEditSelect {
16
16
 
@@ -160,7 +160,7 @@ export class EditSelect extends Group implements IEditSelect {
160
160
  const total = e.getInnerTotal(this)
161
161
 
162
162
  const dragBounds = this.bounds.clone().unsign()
163
- const list = new LeafList(editor.app.find(EditSelectHelper.findBounds, dragBounds))
163
+ const list = new LeafList(findByBounds(editor.app, dragBounds))
164
164
 
165
165
  this.bounds.width = total.x
166
166
  this.bounds.height = total.y
@@ -207,7 +207,7 @@ export class EditSelect extends Group implements IEditSelect {
207
207
  }
208
208
 
209
209
  protected allowDrag(e: DragEvent) {
210
- if (this.running && (this.editor.mergeConfig.boxSelect && Plugin.has('find')) && !e.target.draggable) {
210
+ if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
211
211
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path))
212
212
  } else {
213
213
  return false
@@ -11,6 +11,7 @@ export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
11
11
  const { target } = editor
12
12
  if (target) {
13
13
  editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target as IUI)
14
+ if (editor.multiple) simulate(editor) // 更新模拟元素
14
15
  } else {
15
16
  editor.simulateTarget.remove()
16
17
  editor.leafList.reset()
@@ -22,7 +23,6 @@ export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
22
23
 
23
24
  if (editor.editing) {
24
25
  editor.waitLeafer(() => {
25
- if (editor.multiple) simulate(editor)
26
26
  updateMoveCursor(editor)
27
27
  editor.updateEditTool()
28
28
  editor.update()
@@ -1,7 +1,5 @@
1
- import { IBounds, ILeafList, IUI } from '@leafer-ui/interface'
2
- import { Answer } from '@leafer-ui/draw'
1
+ import { IBounds, ILeafList, IUI, IUIData } from '@leafer-ui/interface'
3
2
 
4
- const { No, Yes, NoAndSkip, YesAndSkip } = Answer
5
3
 
6
4
  export const EditSelectHelper = {
7
5
 
@@ -9,26 +7,35 @@ export const EditSelectHelper = {
9
7
  return path.list.find((leaf) => leaf.editable) as IUI
10
8
  },
11
9
 
12
- findBounds(leaf: IUI, bounds: IBounds): Answer {
13
- if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
14
-
15
- if (leaf.__.editable) {
16
- if (leaf.isBranch && !leaf.__.hitChildren) {
17
- return leaf.__.hitSelf ? YesAndSkip : NoAndSkip
18
- } else if (leaf.isFrame) {
19
- return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No
20
- } else {
21
- if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf) return Yes
22
- }
23
- }
24
-
25
- return No
10
+ findByBounds(branch: IUI, bounds: IBounds): IUI[] {
11
+ const list: IUI[] = []
12
+ eachFind([branch], list, bounds)
13
+ return list
14
+ }
26
15
 
27
- } else {
16
+ }
17
+
18
+
19
+ function eachFind(children: IUI[], list: IUI[], bounds: IBounds): void {
20
+ let child: IUI, data: IUIData
21
+ for (let i = 0, len = children.length; i < len; i++) {
22
+ child = children[i], data = child.__
23
+ if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {
24
+
25
+ if (data.editable) {
26
+ if (child.isBranch && !data.hitChildren) {
27
+ if (data.hitSelf) list.push(child)
28
+ continue
29
+ } else if (child.isFrame) {
30
+ if (bounds.includes(child.__layout.boxBounds, child.__world)) {
31
+ list.push(child)
32
+ continue
33
+ }
34
+ } else if (bounds.hit(child.__layout.boxBounds, child.__world) && data.hitSelf) list.push(child)
35
+ }
28
36
 
29
- return leaf.isBranch ? NoAndSkip : No
37
+ if (child.isBranch) eachFind(child.children, list, bounds)
30
38
 
31
39
  }
32
40
  }
33
-
34
41
  }
package/src/index.ts CHANGED
@@ -29,12 +29,11 @@ import { IEditor, IEditorConfig, IEditToolFunction, IEditorConfigFunction } from
29
29
  import { Creator, UI, Group, Text, Box, dataType, defineKey, Plugin } from '@leafer-ui/draw'
30
30
 
31
31
  import '@leafer-in/resize'
32
- import '@leafer-in/find'
33
32
 
34
33
  import { Editor } from './Editor'
35
34
 
36
35
 
37
- Plugin.add('editor', 'resize', 'find')
36
+ Plugin.add('editor', 'resize')
38
37
 
39
38
 
40
39
  Creator.editor = function (options?: IEditorConfig): IEditor { return new Editor(options) }
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IPointData, ILayoutBoundsData, IGroupInputData, IEditSize, IAlign, IAxis, IMatrix, IBox, IBoundsData, IEditorConfig as IEditorConfig$1, IBoxInputData, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround } from '@leafer-ui/interface';
2
- import { Group, UI, Direction9, Event, Box, Answer } from '@leafer-ui/draw';
2
+ import { Group, UI, Direction9, Event, Box } from '@leafer-ui/draw';
3
3
  import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent } from '@leafer-ui/core';
4
4
  import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, ISimulateElement, 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';
5
5
 
@@ -321,7 +321,7 @@ declare const EditDataHelper: {
321
321
 
322
322
  declare const EditSelectHelper: {
323
323
  findOne(path: ILeafList): IUI;
324
- findBounds(leaf: IUI, bounds: IBounds): Answer;
324
+ findByBounds(branch: IUI, bounds: IBounds): IUI[];
325
325
  };
326
326
 
327
327
  export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool, SelectArea, Stroker, registerEditTool, registerInnerEditor };