@leafer-ui/worker 1.10.0 → 1.10.1

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/worker.cjs CHANGED
@@ -866,30 +866,31 @@ function fill(fill, ui, canvas, renderOptions) {
866
866
  }
867
867
 
868
868
  function fills(fills, ui, canvas, renderOptions) {
869
- let item;
869
+ let item, originPaint, countImage;
870
870
  for (let i = 0, len = fills.length; i < len; i++) {
871
- item = fills[i];
871
+ item = fills[i], originPaint = item.originPaint;
872
872
  if (item.image) {
873
+ countImage ? countImage++ : countImage = 1;
873
874
  if (draw.PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
874
875
  if (!item.style) {
875
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
876
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
876
877
  continue;
877
878
  }
878
879
  }
879
880
  canvas.fillStyle = item.style;
880
- if (item.transform || item.scaleFixed) {
881
+ if (item.transform || originPaint.scaleFixed) {
881
882
  canvas.save();
882
883
  if (item.transform) canvas.transform(item.transform);
883
- if (item.scaleFixed) {
884
+ if (originPaint.scaleFixed) {
884
885
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
885
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
886
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
886
887
  }
887
- if (item.blendMode) canvas.blendMode = item.blendMode;
888
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
888
889
  fillPathOrText(ui, canvas, renderOptions);
889
890
  canvas.restore();
890
891
  } else {
891
- if (item.blendMode) {
892
- canvas.saveBlendMode(item.blendMode);
892
+ if (originPaint.blendMode) {
893
+ canvas.saveBlendMode(originPaint.blendMode);
893
894
  fillPathOrText(ui, canvas, renderOptions);
894
895
  canvas.restoreBlendMode();
895
896
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -1042,8 +1043,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
1042
1043
  const {strokeStyle: strokeStyle} = item;
1043
1044
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
1044
1045
  } else canvas.strokeStyle = item.style;
1045
- if (item.blendMode) {
1046
- canvas.saveBlendMode(item.blendMode);
1046
+ if (item.originPaint.blendMode) {
1047
+ canvas.saveBlendMode(item.originPaint.blendMode);
1047
1048
  isText ? draw.Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
1048
1049
  canvas.restoreBlendMode();
1049
1050
  } else {
@@ -1140,62 +1141,63 @@ function compute(attrName, ui) {
1140
1141
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
1141
1142
  isTransparent = true;
1142
1143
  }
1143
- }
1144
- if (attrName === "fill") {
1145
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
1146
- stintSet(data, "__isTransparentFill", isTransparent);
1144
+ if (attrName === "fill") {
1145
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
1146
+ stintSet(data, "__isTransparentFill", isTransparent);
1147
+ } else {
1148
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
1149
+ stintSet(data, "__isTransparentStroke", isTransparent);
1150
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
1151
+ }
1147
1152
  } else {
1148
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
1149
- stintSet(data, "__isTransparentStroke", isTransparent);
1150
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
1153
+ data.__removePaint(attrName, false);
1151
1154
  }
1152
1155
  }
1153
1156
 
1154
1157
  function getLeafPaint(attrName, paint, ui) {
1155
1158
  if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1156
- let data;
1159
+ let leafPaint;
1157
1160
  const {boxBounds: boxBounds} = ui.__layout;
1158
1161
  switch (paint.type) {
1159
1162
  case "image":
1160
- data = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1163
+ leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1161
1164
  break;
1162
1165
 
1163
1166
  case "linear":
1164
- data = draw.PaintGradient.linearGradient(paint, boxBounds);
1167
+ leafPaint = draw.PaintGradient.linearGradient(paint, boxBounds);
1165
1168
  break;
1166
1169
 
1167
1170
  case "radial":
1168
- data = draw.PaintGradient.radialGradient(paint, boxBounds);
1171
+ leafPaint = draw.PaintGradient.radialGradient(paint, boxBounds);
1169
1172
  break;
1170
1173
 
1171
1174
  case "angular":
1172
- data = draw.PaintGradient.conicGradient(paint, boxBounds);
1175
+ leafPaint = draw.PaintGradient.conicGradient(paint, boxBounds);
1173
1176
  break;
1174
1177
 
1175
1178
  case "solid":
1176
1179
  const {type: type, color: color, opacity: opacity} = paint;
1177
- data = {
1180
+ leafPaint = {
1178
1181
  type: type,
1179
1182
  style: draw.ColorConvert.string(color, opacity)
1180
1183
  };
1181
1184
  break;
1182
1185
 
1183
1186
  default:
1184
- if (!core.isUndefined(paint.r)) data = {
1187
+ if (!core.isUndefined(paint.r)) leafPaint = {
1185
1188
  type: "solid",
1186
1189
  style: draw.ColorConvert.string(paint)
1187
1190
  };
1188
1191
  }
1189
- if (data) {
1190
- if (core.isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
1192
+ if (leafPaint) {
1193
+ leafPaint.originPaint = paint;
1194
+ if (core.isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
1191
1195
  if (paint.style) {
1192
1196
  if (paint.style.strokeWidth === 0) return undefined;
1193
- data.strokeStyle = paint.style;
1197
+ leafPaint.strokeStyle = paint.style;
1194
1198
  }
1195
- if (paint.editing) data.editing = paint.editing;
1196
- if (paint.blendMode) data.blendMode = paint.blendMode;
1197
1199
  }
1198
- return data;
1200
+ return leafPaint;
1199
1201
  }
1200
1202
 
1201
1203
  const PaintModule = {
@@ -1328,10 +1330,6 @@ const tempScaleData = {};
1328
1330
  const tempImage = {};
1329
1331
 
1330
1332
  function createData(leafPaint, image, paint, box) {
1331
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
1332
- if (changeful) leafPaint.changeful = changeful;
1333
- if (sync) leafPaint.sync = sync;
1334
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
1335
1333
  leafPaint.data = draw.PaintImage.getPatternData(paint, box, image);
1336
1334
  }
1337
1335
 
@@ -1591,14 +1589,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1591
1589
 
1592
1590
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1593
1591
  const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1594
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
1592
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
1595
1593
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
1596
1594
  return false;
1597
1595
  } else {
1598
1596
  if (drawImage) {
1599
1597
  if (data.repeat) {
1600
1598
  drawImage = false;
1601
- } else if (!(paint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1599
+ } else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
1602
1600
  drawImage = core.Platform.image.isLarge(image, scaleX, scaleY);
1603
1601
  }
1604
1602
  }
@@ -1610,16 +1608,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1610
1608
  draw.PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
1611
1609
  return true;
1612
1610
  } else {
1613
- if (!paint.style || paint.sync || exporting) draw.PaintImage.createPattern(paint, ui, canvas, renderOptions); else draw.PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
1611
+ if (!paint.style || originPaint.sync || exporting) draw.PaintImage.createPattern(paint, ui, canvas, renderOptions); else draw.PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
1614
1612
  return false;
1615
1613
  }
1616
1614
  }
1617
1615
  }
1618
1616
 
1619
1617
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1620
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1618
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1621
1619
  let {width: width, height: height} = image, clipUI;
1622
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
1620
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1623
1621
  canvas.save();
1624
1622
  clipUI && canvas.clipUI(ui);
1625
1623
  blendMode && (canvas.blendMode = blendMode);
@@ -1634,7 +1632,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
1634
1632
  }
1635
1633
 
1636
1634
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
1637
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
1635
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
1638
1636
  if (canvas) {
1639
1637
  const {pixelRatio: pixelRatio} = canvas;
1640
1638
  scaleData.scaleX *= pixelRatio;
@@ -870,30 +870,31 @@ function fill(fill, ui, canvas, renderOptions) {
870
870
  }
871
871
 
872
872
  function fills(fills, ui, canvas, renderOptions) {
873
- let item;
873
+ let item, originPaint, countImage;
874
874
  for (let i = 0, len = fills.length; i < len; i++) {
875
- item = fills[i];
875
+ item = fills[i], originPaint = item.originPaint;
876
876
  if (item.image) {
877
+ countImage ? countImage++ : countImage = 1;
877
878
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
878
879
  if (!item.style) {
879
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
880
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
880
881
  continue;
881
882
  }
882
883
  }
883
884
  canvas.fillStyle = item.style;
884
- if (item.transform || item.scaleFixed) {
885
+ if (item.transform || originPaint.scaleFixed) {
885
886
  canvas.save();
886
887
  if (item.transform) canvas.transform(item.transform);
887
- if (item.scaleFixed) {
888
+ if (originPaint.scaleFixed) {
888
889
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
889
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
890
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
890
891
  }
891
- if (item.blendMode) canvas.blendMode = item.blendMode;
892
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
892
893
  fillPathOrText(ui, canvas, renderOptions);
893
894
  canvas.restore();
894
895
  } else {
895
- if (item.blendMode) {
896
- canvas.saveBlendMode(item.blendMode);
896
+ if (originPaint.blendMode) {
897
+ canvas.saveBlendMode(originPaint.blendMode);
897
898
  fillPathOrText(ui, canvas, renderOptions);
898
899
  canvas.restoreBlendMode();
899
900
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -1046,8 +1047,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
1046
1047
  const {strokeStyle: strokeStyle} = item;
1047
1048
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
1048
1049
  } else canvas.strokeStyle = item.style;
1049
- if (item.blendMode) {
1050
- canvas.saveBlendMode(item.blendMode);
1050
+ if (item.originPaint.blendMode) {
1051
+ canvas.saveBlendMode(item.originPaint.blendMode);
1051
1052
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
1052
1053
  canvas.restoreBlendMode();
1053
1054
  } else {
@@ -1144,62 +1145,63 @@ function compute(attrName, ui) {
1144
1145
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
1145
1146
  isTransparent = true;
1146
1147
  }
1147
- }
1148
- if (attrName === "fill") {
1149
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
1150
- stintSet(data, "__isTransparentFill", isTransparent);
1148
+ if (attrName === "fill") {
1149
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
1150
+ stintSet(data, "__isTransparentFill", isTransparent);
1151
+ } else {
1152
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
1153
+ stintSet(data, "__isTransparentStroke", isTransparent);
1154
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
1155
+ }
1151
1156
  } else {
1152
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
1153
- stintSet(data, "__isTransparentStroke", isTransparent);
1154
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
1157
+ data.__removePaint(attrName, false);
1155
1158
  }
1156
1159
  }
1157
1160
 
1158
1161
  function getLeafPaint(attrName, paint, ui) {
1159
1162
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1160
- let data;
1163
+ let leafPaint;
1161
1164
  const {boxBounds: boxBounds} = ui.__layout;
1162
1165
  switch (paint.type) {
1163
1166
  case "image":
1164
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1167
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1165
1168
  break;
1166
1169
 
1167
1170
  case "linear":
1168
- data = PaintGradient.linearGradient(paint, boxBounds);
1171
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
1169
1172
  break;
1170
1173
 
1171
1174
  case "radial":
1172
- data = PaintGradient.radialGradient(paint, boxBounds);
1175
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
1173
1176
  break;
1174
1177
 
1175
1178
  case "angular":
1176
- data = PaintGradient.conicGradient(paint, boxBounds);
1179
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
1177
1180
  break;
1178
1181
 
1179
1182
  case "solid":
1180
1183
  const {type: type, color: color, opacity: opacity} = paint;
1181
- data = {
1184
+ leafPaint = {
1182
1185
  type: type,
1183
1186
  style: ColorConvert.string(color, opacity)
1184
1187
  };
1185
1188
  break;
1186
1189
 
1187
1190
  default:
1188
- if (!isUndefined(paint.r)) data = {
1191
+ if (!isUndefined(paint.r)) leafPaint = {
1189
1192
  type: "solid",
1190
1193
  style: ColorConvert.string(paint)
1191
1194
  };
1192
1195
  }
1193
- if (data) {
1194
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
1196
+ if (leafPaint) {
1197
+ leafPaint.originPaint = paint;
1198
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
1195
1199
  if (paint.style) {
1196
1200
  if (paint.style.strokeWidth === 0) return undefined;
1197
- data.strokeStyle = paint.style;
1201
+ leafPaint.strokeStyle = paint.style;
1198
1202
  }
1199
- if (paint.editing) data.editing = paint.editing;
1200
- if (paint.blendMode) data.blendMode = paint.blendMode;
1201
1203
  }
1202
- return data;
1204
+ return leafPaint;
1203
1205
  }
1204
1206
 
1205
1207
  const PaintModule = {
@@ -1332,10 +1334,6 @@ const tempScaleData = {};
1332
1334
  const tempImage = {};
1333
1335
 
1334
1336
  function createData(leafPaint, image, paint, box) {
1335
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
1336
- if (changeful) leafPaint.changeful = changeful;
1337
- if (sync) leafPaint.sync = sync;
1338
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
1339
1337
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
1340
1338
  }
1341
1339
 
@@ -1595,14 +1593,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
1595
1593
 
1596
1594
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1597
1595
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
1598
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
1596
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
1599
1597
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
1600
1598
  return false;
1601
1599
  } else {
1602
1600
  if (drawImage) {
1603
1601
  if (data.repeat) {
1604
1602
  drawImage = false;
1605
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1603
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
1606
1604
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
1607
1605
  }
1608
1606
  }
@@ -1614,16 +1612,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
1614
1612
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
1615
1613
  return true;
1616
1614
  } else {
1617
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
1615
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
1618
1616
  return false;
1619
1617
  }
1620
1618
  }
1621
1619
  }
1622
1620
 
1623
1621
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
1624
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1622
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
1625
1623
  let {width: width, height: height} = image, clipUI;
1626
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
1624
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
1627
1625
  canvas.save();
1628
1626
  clipUI && canvas.clipUI(ui);
1629
1627
  blendMode && (canvas.blendMode = blendMode);
@@ -1638,7 +1636,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
1638
1636
  }
1639
1637
 
1640
1638
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
1641
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
1639
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
1642
1640
  if (canvas) {
1643
1641
  const {pixelRatio: pixelRatio} = canvas;
1644
1642
  scaleData.scaleX *= pixelRatio;
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,BoundsHelper as k,Plugin as B,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as T,isString as A,ImageEvent as P,MatrixHelper as M,MathHelper as O,AlignHelper as C,PointHelper as W,getMatrixData as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as X,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as G,PaintImage as z,ColorConvert as q,PaintGradient as N,Effect as j,Group as H,TextConvert as V}from"@leafer-ui/draw";class Q extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:Z}=s;function $(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Z(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Q(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),J.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):J.indexOf("Mac")>-1?e.os="Mac":J.indexOf("Linux")>-1&&(e.os="Linux");class K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=f,{pushAllChildBranch:st,pushAllParent:nt}=g;const{worldBounds:at}=p;class rt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:lt}=f,dt=y.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ht.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new rt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new rt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=y.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ct.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ut.clipSpread=10;const{hitRadiusPoint:ft}=k;class gt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new o;if(t.length){let e;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=t.length;s<a;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)if(i=t[a],i.__.visible&&(!e||i.__.mask))if(s=!!i.__.hitRadius||ft(i.__world,n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&i.__.__clipAfterFill&&!i.__hitWorld(n))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else s&&this.hitChild(i,n)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class pt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new gt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):B.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function _t(t,e,i){t.__.__font?G.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function wt(t,e,i,s,n){const a=i.__;E(t)?G.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&G.strokeArrow(t,i,s,n)}function yt(t,e,i,s,n){const a=i.__;E(t)?G.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),G.drawTextStroke(i,s,n))}function mt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,yt(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",G.fillText(i,a,n),a.blendMode="normal",f.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}Object.assign(n,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new pt(t,e)}),e.layout=ht.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:xt,copyAndSpread:vt,toOuterOf:bt,getOuterOf:St,getByMove:kt,move:Bt,getIntersectData:Et}=k,Rt={};let Lt;const{stintSet:Tt}=l,{hasTransparent:At}=q;function Pt(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=z.image(i,t,e,n,!Lt||!Lt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:T(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(A(s.style)&&At(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Mt={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Lt=z.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Pt(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Tt(i,"__isAlphaPixelFill",n),Tt(i,"__isTransparentFill",a)):(Tt(i,"__isAlphaPixelStroke",n),Tt(i,"__isTransparentStroke",a),Tt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i,s){i.fillStyle=t,_t(e,i,s)},fills:function(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++){if(n=t[a],n.image){if(z.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){!a&&n.image.isPlacehold&&e.drawImagePlaceholder(n.image,i,s);continue}}if(i.fillStyle=n.style,n.transform||n.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}n.blendMode&&(i.blendMode=n.blendMode),_t(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),_t(e,i,s),i.restoreBlendMode()):_t(e,i,s)}},fillPathOrText:_t,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)G.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":wt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),wt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)wt(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),wt(t,2,e,r,s),r.clipUI(n),r.clearWorld(a),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){G.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":yt(t,1,e,i,s);break;case"inside":mt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?yt(t,2,e,i,s):mt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:r}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;a.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||n.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!z.checkImage(r,!1,s,n,a))&&r.style){if(l){const{strokeStyle:t}=r;t?n.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(r.style,o.__strokeWidth*e,o)}else n.strokeStyle=r.style;r.blendMode?(n.saveBlendMode(r.blendMode),i?G.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?G.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;bt(o.strokeSpread?(vt(Rt,o.boxBounds,o.strokeSpread),Rt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?xt(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Et(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=St(l,u),d=kt(f,-u.e,-u.f),h=St(r,u),Bt(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Ot,Ct=new _;const{isSame:Wt}=k;function Dt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||z.createData(n,s,i,a),!0}function Ft(t,e){Xt(t,P.LOAD,e)}function It(t,e){Xt(t,P.LOADED,e)}function Yt(t,e,i){e.error=i,t.forceUpdate("surface"),Xt(t,P.ERROR,e)}function Xt(t,e,i){t.hasEvent(e)&&t.emitEvent(new P(e,i))}function Ut(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Gt,translate:zt}=M,qt=new _,Nt={},jt={};function Ht(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Vt={},Qt=D();const{get:Zt,set:$t,rotateOfOuter:Jt,translate:Kt,scaleOfOuter:te,multiplyParent:ee,scale:ie,rotate:se,skew:ne}=M;function ae(t,e,i,s,n,a,r,o){r&&se(t,r),o&&ne(t,o.x,o.y),n&&ie(t,n,a),Kt(t,e.x+i,e.y+s)}function re(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:oe,scale:le,copy:de}=M,{getFloorScale:he}=O,{abs:ce}=Math;const ue={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return Ot&&i===Ot.paint&&Wt(s,Ot.boxBounds)?a=Ot.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Ot=o.use>1?{leafPaint:a,paint:i,boxBounds:Ct.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Dt(t,e,i,o,a,s),n&&(Ft(t,r),It(t,r))):o.error?n&&Yt(t,r,o.error):(n&&(Ut(t,!0),Ft(t,r)),a.loadId=o.load(()=>{Ut(t,!1),t.destroyed||(Dt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),It(t,r)),a.loadId=void 0},e=>{Ut(t,!1),Yt(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n,a){const{scaleX:r,scaleY:o}=z.getImageRenderScaleData(t,s,n,a),{image:l,data:d}=t,{exporting:h}=a;return!(!d||t.patternId===r+"-"+o&&!h)&&(i&&(d.repeat?i=!1:t.changeful||"miniapp"===e.name&&S.isResizing(s)||h||(i=e.image.isLarge(l,r,o))),i?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),z.drawImage(t,r,o,s,n,a),!0):(!t.style||t.sync||h?z.createPattern(t,s,n,a):z.createPatternTask(t,s,n,a),!1))},drawImage:function(t,e,i,s,n,a){const{data:r,image:o,blendMode:l}=t,{opacity:d,transform:h}=r,c=o.getFull(r.filters),u=s.__;let f,{width:g,height:p}=o;h&&!h.onlyScale||(f=u.path||u.cornerRadius)||d||l?(n.save(),f&&n.clipUI(s),l&&(n.blendMode=l),d&&(n.opacity*=d),h&&n.transform(h),n.drawImage(c,0,0,g,p),n.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),n.drawImage(c,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=b.patternTasker.add(()=>re(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&z.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,i,s,n){let{scaleX:a,scaleY:r}=z.getImageRenderScaleData(t,i,s,n),o=a+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:s,data:n}=t,{transform:l,gap:d}=n,h=z.getPatternFixScale(t,a,r);let c,u,f,{width:g,height:p}=s;h&&(a*=h,r*=h),g*=a,p*=r,d&&(u=d.x*a/ce(n.scaleX||1),f=d.y*r/ce(n.scaleY||1)),(l||1!==a||1!==r)&&(a*=he(g+(u||0)),r*=he(p+(f||0)),c=oe(),l&&de(c,l),le(c,1/a,1/r));const _=s.getCanvas(g,p,n.opacity,n.filters,u,f,i.leafer&&i.leafer.config.smooth),w=s.getPattern(_,n.repeat||e.origin.noRepeat||"no-repeat",c,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:n}=t;let a,r=e.image.maxPatternSize,o=n.width*n.height;return n.isSVG?i>1&&(a=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=z.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(k.set(jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(O.getScaleData(d,h,i,Nt),x=Nt.scaleX,v=Nt.scaleY),(o||p||g)&&(x&&k.scale(jt,x,v,!0),o&&C.toPoint(o,jt,e,jt,!0,!0))):w&&!c||(x=v=k.getFitScale(e,jt,"fit"!==r),k.put(e,i,o,x,!1,jt),k.scale(jt,x,v,!0)),l&&W.move(jt,l),r){case"stretch":w?x&&(x=v=void 0):(x=e.width/s,v=e.height/n,z.stretchMode(y,e,x,v));break;case"normal":case"clip":if(jt.x||jt.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),z.clipMode(y,e,jt.x,jt.y,x,v,c,u,t,i),t&&(x=x?x*t:t,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&z.repeatMode(y,e,s,n,jt.x,jt.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:Ht(a,i,n.width,e&&e.x),y:Ht(r,s,n.height,e&&e.y)}}(p,i&&g,jt.width,jt.height,e));break;default:x&&z.fillOrFitMode(y,e,jt.x,jt.y,x,v,c)}return y.transform||(e.x||e.y)&&zt(y.transform=Gt(),e.x,e.y),x&&(y.scaleX=x,y.scaleY=v),a&&a<1&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y},stretchMode:function(t,e,i,s){const n=Zt(),{x:a,y:r}=e;a||r?Kt(n,a,r):n.onlyScale=!0,ie(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,r){const o=Zt();Kt(o,e.x+i,e.y+s),ie(o,n,a),r&&Jt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,n,a,r,o,l,d){const h=Zt();ae(h,e,i,s,n,a,r,o),l&&(r||o?($t(Qt),te(Qt,e,l,d),ee(h,Qt)):te(h,e,l,d)),t.transform=h},repeatMode:function(t,e,i,s,n,a,r,o,l,d,h,c){const u=Zt();if(c)ae(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Jt(u,{x:i/2,y:s/2},l);else switch(se(u,l),l){case 90:Kt(u,s,0);break;case 180:Kt(u,i,s);break;case 270:Kt(u,0,i)}Vt.x=e.x+n,Vt.y=e.y+a,Kt(u,Vt.x,Vt.y),r&&te(u,Vt,r,o)}t.transform=u}},{toPoint:fe}=F,{hasTransparent:ge}=q,pe={},_e={};function we(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&ge(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:ye,getDistance:me}=W,{get:xe,rotateOfOuter:ve,scaleOfOuter:be}=M,{toPoint:Se}=F,ke={},Be={};function Ee(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=ye(e,i);a=xe(),n?(be(a,e,r/o*(s||1),1),ve(a,e,t+90)):(be(a,e,1,r/o*(s||1)),ve(a,e,t))}return a}const{getDistance:Re}=W,{toPoint:Le}=F,Te={},Ae={};const Pe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;fe(s||"top",i,pe),fe(n||"bottom",i,_e);const o=e.canvas.createLinearGradient(pe.x,pe.y,_e.x,_e.y),l={type:a,style:o};return we(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Se(s||"center",i,ke),Se(n||"bottom",i,Be);const l=e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,me(ke,Be)),d={type:a,style:l};we(d,l,t.stops,r);const h=Ee(i,ke,Be,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Le(s||"center",i,Te),Le(n||"bottom",i,Ae);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Te.x,Te.y):e.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,Re(Te,Ae)),d={type:a,style:l};we(d,l,t.stops,r);const h=Ee(i,Te,Ae,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ee},{copy:Me,move:Oe,toOffsetOutBounds:Ce}=k,{max:We,abs:De}=Math,Fe={},Ie=new L,Ye={};function Xe(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=De(t.spread||0),r=We(r,n+a-s),o=We(o,n+a+i),l=We(l,n+a+s),d=We(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ue(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(Me(Fe,t.bounds),Oe(Fe,i.x-n.x,i.y-n.y),a=t.bounds,r=Fe):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:Ge}=k,ze={};const qe=Xe;const Ne={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ce(l,Ye,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Ye.offsetX+(r.x||0)*c*w,Ye.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w,q.string(r.color)),n=j.getShadowTransform(t,g,i,r,Ye,w),n&&g.setTransform(n),Ue(g,Ye,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ge(l,ze,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ze.offsetX+(r.x||0)*c*w,ze.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w),n=j.getShadowTransform(t,g,i,r,ze,w,!0),n&&g.setTransform(n),Ue(g,ze,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Xe,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=2*s.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Ie.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/o,1+i/l),Ie}},isTransformShadow(t){},getInnerShadowSpread:qe},{excludeRenderBounds:je}=p;let He;function Ve(t,e,i,s,n,a,r,o){switch(e){case"grayscale":He||(He=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);Ze(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":Ze(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Qe(t){return t.getSameCanvas(!1,!0)}function Ze(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(Ve(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||je(i,e)||i.__render(t,e),a=i.__.opacity,He=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Qe(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Qe(t)),n||(n=Qe(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&Ve(this,r,t,n,s,a,void 0,!1),je(i,e)||i.__render(n||t,e),h&&Ve(this,r,t,n,s,a,h,!1)}Ve(this,r,t,n,s,a,void 0,!0)};const $e=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Je=$e+"_#~&*+\\=|≮≯≈≠=…",Ke=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function ti(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ei=ti("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ii=ti("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),si=ti($e),ni=ti(Je),ai=ti("- —/~|┆·");var ri;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ri||(ri={}));const{Letter:oi,Single:li,Before:di,After:hi,Symbol:ci,Break:ui}=ri;function fi(t){return ei[t]?oi:ai[t]?ui:ii[t]?di:si[t]?hi:ni[t]?ci:Ke.test(t)?li:oi}const gi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function pi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:_i}=gi,{Letter:wi,Single:yi,Before:mi,After:xi,Symbol:vi,Break:bi}=ri;let Si,ki,Bi,Ei,Ri,Li,Ti,Ai,Pi,Mi,Oi,Ci,Wi,Di,Fi,Ii,Yi,Xi=[];function Ui(t,e){Pi&&!Ai&&(Ai=Pi),Si.data.push({char:t,width:e}),Bi+=e}function Gi(){Ei+=Bi,Si.width=Bi,ki.words.push(Si),Si={data:[]},Bi=0}function zi(){Di&&(Fi.paraNumber++,ki.paraStart=!0,Di=!1),Pi&&(ki.startCharSize=Ai,ki.endCharSize=Pi,Ai=0),ki.width=Ei,Ii.width?_i(ki):Yi&&qi(),Xi.push(ki),ki={words:[]},Ei=0}function qi(){Ei>(Fi.maxWidth||0)&&(Fi.maxWidth=Ei)}const{top:Ni,right:ji,bottom:Hi,left:Vi}=I;function Qi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Zi={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(a?(s=o[Vi],a-=o[ji]+o[Vi],!a&&(a=.01)):i.autoSizeAlign||(s=o[Vi]),r?(n=o[Ni],r-=o[Ni]+o[Hi],!r&&(r=.01)):i.autoSizeAlign||(n=o[Ni]));const l={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){Fi=t,Xi=t.rows,Ii=t.bounds,Yi=!Ii.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l}=Ii;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;Di=!0,Oi=null,Ai=Ti=Pi=Bi=Ei=0,Si={data:[]},ki={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Li=i[s],"\n"===Li?(Bi&&Gi(),ki.paraEnd=!0,zi(),Di=!0):(Mi=fi(Li),Mi===wi&&"none"!==r&&(Li=pi(Li,r,!Bi)),Ti=o.measureText(Li).width,n&&(n<0&&(Pi=Ti),Ti+=n),Ci=Mi===yi&&(Oi===yi||Oi===wi)||Oi===yi&&Mi!==xi,Wi=!(Mi!==mi&&Mi!==yi||Oi!==vi&&Oi!==xi),Ri=Di&&a?l-a:l,t&&l&&Ei+Bi+Ti>Ri&&(e?(Bi&&Gi(),Ei&&zi()):(Wi||(Wi=Mi===wi&&Oi==xi),Ci||Wi||Mi===bi||Mi===mi||Mi===yi||Bi+Ti>Ri?(Bi&&Gi(),Ei&&zi()):Ei&&zi()))," "===Li&&!0!==Di&&Ei+Bi===0||(Mi===bi?(" "===Li&&Bi&&Gi(),Ui(Li,Ti),Gi()):Ci||Wi?(Bi&&Gi(),Ui(Li,Ti)):Ui(Li,Ti)),Oi=Mi);Bi&&Gi(),Ei&&zi(),Xi.length>0&&(Xi[Xi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Fi.paraNumber++,Ei=o.measureText(t).width,Xi.push({x:a||0,text:t,width:Ei,paraStart:!0}),Yi&&qi()})}(l,t,i),o&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Qi(e,"x",t[Vi]);break;case"right":Qi(e,"x",-t[ji])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qi(e,"y",t[Ni]);break;case"bottom":Qi(e,"y",-t[Hi])}}(o,l,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e,o=i&&n.includes("both"),l=o||i&&n.includes("justify"),d=l&&n.includes("letter");let h,c,u,f,g,p,_,w,y,m;s.forEach(t=>{t.words&&(g=a&&t.paraStart?a:0,w=t.words.length,l&&(m=!t.paraEnd||o,c=i-t.width-g,d?f=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?c/(w-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,h=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:h},h=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,h,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):h=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,h,t.data,t.isOverflow,m&&f),m&&(y=i===w-1,u?y||(h+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(y?1:0))))})),t.words=null)})}(l,i,a),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,a),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(l,i),l}};const $i={string:function(t,e){if(!t)return"#000";const i=Y(e)&&e<1;if(A(t)){if(!i||!q.object)return t;t=q.object(t)}let s=T(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,Zi),Object.assign(q,$i),Object.assign(G,Mt),Object.assign(z,ue),Object.assign(N,Pe),Object.assign(j,Ne),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new X}),$();export{ht as Layouter,Q as LeaferCanvas,gt as Picker,ut as Renderer,pt as Selector,K as Watcher,$ as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,BoundsHelper as k,Plugin as B,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as T,isString as A,ImageEvent as P,MatrixHelper as O,MathHelper as C,AlignHelper as M,PointHelper as W,getMatrixData as D,AroundHelper as I,Direction4 as F,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as X,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{Paint as G,PaintImage as z,ColorConvert as q,PaintGradient as N,Effect as j,Group as H,TextConvert as V}from"@leafer-ui/draw";class Q extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:Z}=s;function $(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Z(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Q(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:J}=navigator;J.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),J.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):J.indexOf("Mac")>-1?e.os="Mac":J.indexOf("Linux")>-1&&(e.os="Linux");class K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=f,{pushAllChildBranch:st,pushAllParent:nt}=g;const{worldBounds:at}=p;class rt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:lt}=f,dt=y.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ht.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new rt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new rt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=y.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ct.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ut.clipSpread=10;const{hitRadiusPoint:ft}=k;class gt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n,!!i.findList),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i,s){const n=this.findList=new o;if(t.length){let e;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=t.length;s<a;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,r),n.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){n.reset();break}return n.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),n.length)return n.list[0];return s?null:i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o,i=[],{target:s}=this;for(;t&&(t.syncEventer&&i.push(t.syncEventer),e.add(t),(t=t.parent)!==s););return i.length&&i.forEach(t=>{for(;t&&(t.__.hittable&&e.add(t),(t=t.parent)!==s););}),s&&e.add(s),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)if(i=t[a],i.__.visible&&(!e||i.__.mask))if(s=!!i.__.hitRadius||ft(i.__world,n),i.isBranch){if(s||i.__ignoreHitWorld){if(i.isBranchLeaf&&i.__.__clipAfterFill&&!i.__hitWorld(n))continue;i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)}}else s&&this.hitChild(i,n)}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class pt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new gt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):B.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function _t(t,e,i){t.__.__font?G.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function wt(t,e,i,s,n){const a=i.__;E(t)?G.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&G.strokeArrow(t,i,s,n)}function yt(t,e,i,s,n){const a=i.__;E(t)?G.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),G.drawTextStroke(i,s,n))}function mt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,yt(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",G.fillText(i,a,n),a.blendMode="normal",f.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}Object.assign(n,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new pt(t,e)}),e.layout=ht.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:xt,copyAndSpread:vt,toOuterOf:bt,getOuterOf:St,getByMove:kt,move:Bt,getIntersectData:Et}=k,Rt={};let Lt;const{stintSet:Tt}=l,{hasTransparent:At}=q;function Pt(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=z.image(i,t,e,n,!Lt||!Lt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:T(e.r)||(s={type:"solid",style:q.string(e)})}if(s&&(s.originPaint=e,A(s.style)&&At(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const Ot={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Lt=z.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Pt(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Tt(i,"__isAlphaPixelFill",n),Tt(i,"__isTransparentFill",a)):(Tt(i,"__isAlphaPixelStroke",n),Tt(i,"__isTransparentStroke",a),Tt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,_t(e,i,s)},fills:function(t,e,i,s){let n,a,r;for(let o=0,l=t.length;o<l;o++){if(n=t[o],a=n.originPaint,n.image){if(r?r++:r=1,z.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||a.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}a.blendMode&&(i.blendMode=a.blendMode),_t(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),_t(e,i,s),i.restoreBlendMode()):_t(e,i,s)}},fillPathOrText:_t,fillText:function(t,e,i){const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)G.strokeText(t,e,i,s);else switch(n.strokeAlign){case"center":wt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),wt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)wt(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),wt(t,2,e,r,s),r.clipUI(n),r.clearWorld(a),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){G.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":yt(t,1,e,i,s);break;case"inside":mt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?yt(t,2,e,i,s):mt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:r}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;a.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||n.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!z.checkImage(r,!1,s,n,a))&&r.style){if(l){const{strokeStyle:t}=r;t?n.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(r.style,o.__strokeWidth*e,o)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?G.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?G.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;bt(o.strokeSpread?(vt(Rt,o.boxBounds,o.strokeSpread),Rt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?xt(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Et(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=St(l,u),d=kt(f,-u.e,-u.f),h=St(r,u),Bt(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Ct,Mt=new _;const{isSame:Wt}=k;function Dt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||z.createData(n,s,i,a),!0}function It(t,e){Xt(t,P.LOAD,e)}function Ft(t,e){Xt(t,P.LOADED,e)}function Yt(t,e,i){e.error=i,t.forceUpdate("surface"),Xt(t,P.ERROR,e)}function Xt(t,e,i){t.hasEvent(e)&&t.emitEvent(new P(e,i))}function Ut(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Gt,translate:zt}=O,qt=new _,Nt={},jt={};function Ht(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Vt={},Qt=D();const{get:Zt,set:$t,rotateOfOuter:Jt,translate:Kt,scaleOfOuter:te,multiplyParent:ee,scale:ie,rotate:se,skew:ne}=O;function ae(t,e,i,s,n,a,r,o){r&&se(t,r),o&&ne(t,o.x,o.y),n&&ie(t,n,a),Kt(t,e.x+i,e.y+s)}function re(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:oe,scale:le,copy:de}=O,{getFloorScale:he}=C,{abs:ce}=Math;const ue={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return Ct&&i===Ct.paint&&Wt(s,Ct.boxBounds)?a=Ct.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Ct=o.use>1?{leafPaint:a,paint:i,boxBounds:Mt.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Dt(t,e,i,o,a,s),n&&(It(t,r),Ft(t,r))):o.error?n&&Yt(t,r,o.error):(n&&(Ut(t,!0),It(t,r)),a.loadId=o.load(()=>{Ut(t,!1),t.destroyed||(Dt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ft(t,r)),a.loadId=void 0},e=>{Ut(t,!1),Yt(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n,a){const{scaleX:r,scaleY:o}=z.getImageRenderScaleData(t,s,n,a),{image:l,data:d,originPaint:h}=t,{exporting:c}=a;return!(!d||t.patternId===r+"-"+o&&!c)&&(i&&(d.repeat?i=!1:h.changeful||"miniapp"===e.name&&S.isResizing(s)||c||(i=e.image.isLarge(l,r,o))),i?(s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill()),z.drawImage(t,r,o,s,n,a),!0):(!t.style||h.sync||c?z.createPattern(t,s,n,a):z.createPatternTask(t,s,n,a),!1))},drawImage:function(t,e,i,s,n,a){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:h}=r,c=o.getFull(r.filters),u=s.__;let f,{width:g,height:p}=o;(f=h&&!h.onlyScale||u.path||u.cornerRadius)||d||l?(n.save(),f&&n.clipUI(s),l&&(n.blendMode=l),d&&(n.opacity*=d),h&&n.transform(h),n.drawImage(c,0,0,g,p),n.restore()):(r.scaleX&&(g*=r.scaleX,p*=r.scaleY),n.drawImage(c,0,0,g,p))},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=b.patternTasker.add(()=>re(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&z.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,i,s,n){let{scaleX:a,scaleY:r}=z.getImageRenderScaleData(t,i,s,n),o=a+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:s,data:n}=t,{transform:l,gap:d}=n,h=z.getPatternFixScale(t,a,r);let c,u,f,{width:g,height:p}=s;h&&(a*=h,r*=h),g*=a,p*=r,d&&(u=d.x*a/ce(n.scaleX||1),f=d.y*r/ce(n.scaleY||1)),(l||1!==a||1!==r)&&(a*=he(g+(u||0)),r*=he(p+(f||0)),c=oe(),l&&de(c,l),le(c,1/a,1/r));const _=s.getCanvas(g,p,n.opacity,n.filters,u,f,i.leafer&&i.leafer.config.smooth),w=s.getPattern(_,n.repeat||e.origin.noRepeat||"no-repeat",c,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:n}=t;let a,r=e.image.maxPatternSize,o=n.width*n.height;return n.isSVG?i>1&&(a=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,s){t.data=z.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:n}=i,{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(k.set(jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(C.getScaleData(d,h,i,Nt),x=Nt.scaleX,v=Nt.scaleY),(o||p||g)&&(x&&k.scale(jt,x,v,!0),o&&M.toPoint(o,jt,e,jt,!0,!0))):w&&!c||(x=v=k.getFitScale(e,jt,"fit"!==r),k.put(e,i,o,x,!1,jt),k.scale(jt,x,v,!0)),l&&W.move(jt,l),r){case"stretch":w?x&&(x=v=void 0):(x=e.width/s,v=e.height/n,z.stretchMode(y,e,x,v));break;case"normal":case"clip":if(jt.x||jt.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),z.clipMode(y,e,jt.x,jt.y,x,v,c,u,t,i),t&&(x=x?x*t:t,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&z.repeatMode(y,e,s,n,jt.x,jt.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:Ht(a,i,n.width,e&&e.x),y:Ht(r,s,n.height,e&&e.y)}}(p,i&&g,jt.width,jt.height,e));break;default:x&&z.fillOrFitMode(y,e,jt.x,jt.y,x,v,c)}return y.transform||(e.x||e.y)&&zt(y.transform=Gt(),e.x,e.y),x&&(y.scaleX=x,y.scaleY=v),a&&a<1&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y},stretchMode:function(t,e,i,s){const n=Zt(),{x:a,y:r}=e;a||r?Kt(n,a,r):n.onlyScale=!0,ie(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,r){const o=Zt();Kt(o,e.x+i,e.y+s),ie(o,n,a),r&&Jt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,n,a,r,o,l,d){const h=Zt();ae(h,e,i,s,n,a,r,o),l&&(r||o?($t(Qt),te(Qt,e,l,d),ee(h,Qt)):te(h,e,l,d)),t.transform=h},repeatMode:function(t,e,i,s,n,a,r,o,l,d,h,c){const u=Zt();if(c)ae(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Jt(u,{x:i/2,y:s/2},l);else switch(se(u,l),l){case 90:Kt(u,s,0);break;case 180:Kt(u,i,s);break;case 270:Kt(u,0,i)}Vt.x=e.x+n,Vt.y=e.y+a,Kt(u,Vt.x,Vt.y),r&&te(u,Vt,r,o)}t.transform=u}},{toPoint:fe}=I,{hasTransparent:ge}=q,pe={},_e={};function we(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&ge(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:ye,getDistance:me}=W,{get:xe,rotateOfOuter:ve,scaleOfOuter:be}=O,{toPoint:Se}=I,ke={},Be={};function Ee(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=ye(e,i);a=xe(),n?(be(a,e,r/o*(s||1),1),ve(a,e,t+90)):(be(a,e,1,r/o*(s||1)),ve(a,e,t))}return a}const{getDistance:Re}=W,{toPoint:Le}=I,Te={},Ae={};const Pe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;fe(s||"top",i,pe),fe(n||"bottom",i,_e);const o=e.canvas.createLinearGradient(pe.x,pe.y,_e.x,_e.y),l={type:a,style:o};return we(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Se(s||"center",i,ke),Se(n||"bottom",i,Be);const l=e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,me(ke,Be)),d={type:a,style:l};we(d,l,t.stops,r);const h=Ee(i,ke,Be,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Le(s||"center",i,Te),Le(n||"bottom",i,Ae);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Te.x,Te.y):e.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,Re(Te,Ae)),d={type:a,style:l};we(d,l,t.stops,r);const h=Ee(i,Te,Ae,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ee},{copy:Oe,move:Ce,toOffsetOutBounds:Me}=k,{max:We,abs:De}=Math,Ie={},Fe=new L,Ye={};function Xe(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=De(t.spread||0),r=We(r,n+a-s),o=We(o,n+a+i),l=We(l,n+a+s),d=We(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ue(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(Oe(Ie,t.bounds),Ce(Ie,i.x-n.x,i.y-n.y),a=t.bounds,r=Ie):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:Ge}=k,ze={};const qe=Xe;const Ne={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Me(l,Ye,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Ye.offsetX+(r.x||0)*c*w,Ye.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w,q.string(r.color)),n=j.getShadowTransform(t,g,i,r,Ye,w),n&&g.setTransform(n),Ue(g,Ye,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ge(l,ze,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ze.offsetX+(r.x||0)*c*w,ze.offsetY+(r.y||0)*u*w,(r.blur||0)*c*w),n=j.getShadowTransform(t,g,i,r,ze,w,!0),n&&g.setTransform(n),Ue(g,ze,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Xe,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=2*s.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Fe.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/o,1+i/l),Fe}},isTransformShadow(t){},getInnerShadowSpread:qe},{excludeRenderBounds:je}=p;let He;function Ve(t,e,i,s,n,a,r,o){switch(e){case"grayscale":He||(He=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);Ze(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":Ze(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Qe(t){return t.getSameCanvas(!1,!0)}function Ze(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(Ve(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||je(i,e)||i.__render(t,e),a=i.__.opacity,He=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Qe(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Qe(t)),n||(n=Qe(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&Ve(this,r,t,n,s,a,void 0,!1),je(i,e)||i.__render(n||t,e),h&&Ve(this,r,t,n,s,a,h,!1)}Ve(this,r,t,n,s,a,void 0,!0)};const $e=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Je=$e+"_#~&*+\\=|≮≯≈≠=…",Ke=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function ti(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ei=ti("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ii=ti("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),si=ti($e),ni=ti(Je),ai=ti("- —/~|┆·");var ri;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ri||(ri={}));const{Letter:oi,Single:li,Before:di,After:hi,Symbol:ci,Break:ui}=ri;function fi(t){return ei[t]?oi:ai[t]?ui:ii[t]?di:si[t]?hi:ni[t]?ci:Ke.test(t)?li:oi}const gi={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function pi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:_i}=gi,{Letter:wi,Single:yi,Before:mi,After:xi,Symbol:vi,Break:bi}=ri;let Si,ki,Bi,Ei,Ri,Li,Ti,Ai,Pi,Oi,Ci,Mi,Wi,Di,Ii,Fi,Yi,Xi=[];function Ui(t,e){Pi&&!Ai&&(Ai=Pi),Si.data.push({char:t,width:e}),Bi+=e}function Gi(){Ei+=Bi,Si.width=Bi,ki.words.push(Si),Si={data:[]},Bi=0}function zi(){Di&&(Ii.paraNumber++,ki.paraStart=!0,Di=!1),Pi&&(ki.startCharSize=Ai,ki.endCharSize=Pi,Ai=0),ki.width=Ei,Fi.width?_i(ki):Yi&&qi(),Xi.push(ki),ki={words:[]},Ei=0}function qi(){Ei>(Ii.maxWidth||0)&&(Ii.maxWidth=Ei)}const{top:Ni,right:ji,bottom:Hi,left:Vi}=F;function Qi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Zi={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;o&&(a?(s=o[Vi],a-=o[ji]+o[Vi],!a&&(a=.01)):i.autoSizeAlign||(s=o[Vi]),r?(n=o[Ni],r-=o[Ni]+o[Hi],!r&&(r=.01)):i.autoSizeAlign||(n=o[Ni]));const l={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){Ii=t,Xi=t.rows,Fi=t.bounds,Yi=!Fi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l}=Fi;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;Di=!0,Ci=null,Ai=Ti=Pi=Bi=Ei=0,Si={data:[]},ki={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Li=i[s],"\n"===Li?(Bi&&Gi(),ki.paraEnd=!0,zi(),Di=!0):(Oi=fi(Li),Oi===wi&&"none"!==r&&(Li=pi(Li,r,!Bi)),Ti=o.measureText(Li).width,n&&(n<0&&(Pi=Ti),Ti+=n),Mi=Oi===yi&&(Ci===yi||Ci===wi)||Ci===yi&&Oi!==xi,Wi=!(Oi!==mi&&Oi!==yi||Ci!==vi&&Ci!==xi),Ri=Di&&a?l-a:l,t&&l&&Ei+Bi+Ti>Ri&&(e?(Bi&&Gi(),Ei&&zi()):(Wi||(Wi=Oi===wi&&Ci==xi),Mi||Wi||Oi===bi||Oi===mi||Oi===yi||Bi+Ti>Ri?(Bi&&Gi(),Ei&&zi()):Ei&&zi()))," "===Li&&!0!==Di&&Ei+Bi===0||(Oi===bi?(" "===Li&&Bi&&Gi(),Ui(Li,Ti),Gi()):Mi||Wi?(Bi&&Gi(),Ui(Li,Ti)):Ui(Li,Ti)),Ci=Oi);Bi&&Gi(),Ei&&zi(),Xi.length>0&&(Xi[Xi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ii.paraNumber++,Ei=o.measureText(t).width,Xi.push({x:a||0,text:t,width:Ei,paraStart:!0}),Yi&&qi()})}(l,t,i),o&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Qi(e,"x",t[Vi]);break;case"right":Qi(e,"x",-t[ji])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qi(e,"y",t[Ni]);break;case"bottom":Qi(e,"y",-t[Hi])}}(o,l,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e,o=i&&n.includes("both"),l=o||i&&n.includes("justify"),d=l&&n.includes("letter");let h,c,u,f,g,p,_,w,y,m;s.forEach(t=>{t.words&&(g=a&&t.paraStart?a:0,w=t.words.length,l&&(m=!t.paraEnd||o,c=i-t.width-g,d?f=c/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?c/(w-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,h=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:h},h=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,h,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):h=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,h,t.data,t.isOverflow,m&&f),m&&(y=i===w-1,u?y||(h+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(y?1:0))))})),t.words=null)})}(l,i,a),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,h=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,a),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(l,i),l}};const $i={string:function(t,e){if(!t)return"#000";const i=Y(e)&&e<1;if(A(t)){if(!i||!q.object)return t;t=q.object(t)}let s=T(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,Zi),Object.assign(q,$i),Object.assign(G,Ot),Object.assign(z,ue),Object.assign(N,Pe),Object.assign(j,Ne),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new X}),$();export{ht as Layouter,Q as LeaferCanvas,gt as Picker,ut as Renderer,pt as Selector,K as Watcher,$ as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map