leafer-ui 1.3.0 → 1.3.2
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/web.cjs +8 -5
- package/dist/web.esm.js +8 -5
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +25 -11
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +104 -90
- package/dist/web.module.min.js +1 -1
- package/package.json +12 -12
package/dist/web.cjs
CHANGED
|
@@ -221,7 +221,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
221
221
|
},
|
|
222
222
|
loadImage(src) {
|
|
223
223
|
return new Promise((resolve, reject) => {
|
|
224
|
-
const img = new Image();
|
|
224
|
+
const img = new core.Platform.origin.Image();
|
|
225
225
|
const { crossOrigin } = core.Platform.image;
|
|
226
226
|
if (crossOrigin) {
|
|
227
227
|
img.setAttribute('crossOrigin', crossOrigin);
|
|
@@ -231,7 +231,10 @@ function useCanvas(_canvasType, _power) {
|
|
|
231
231
|
img.onerror = (e) => { reject(e); };
|
|
232
232
|
img.src = core.Platform.image.getRealURL(src);
|
|
233
233
|
});
|
|
234
|
-
}
|
|
234
|
+
},
|
|
235
|
+
Image,
|
|
236
|
+
PointerEvent,
|
|
237
|
+
DragEvent
|
|
235
238
|
};
|
|
236
239
|
core.Platform.event = {
|
|
237
240
|
stopDefault(origin) { origin.preventDefault(); },
|
|
@@ -707,7 +710,7 @@ class Renderer {
|
|
|
707
710
|
partRender() {
|
|
708
711
|
const { canvas, updateBlocks: list } = this;
|
|
709
712
|
if (!list)
|
|
710
|
-
return
|
|
713
|
+
return;
|
|
711
714
|
this.mergeBlocks();
|
|
712
715
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
713
716
|
this.clipRender(block); });
|
|
@@ -2558,7 +2561,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2558
2561
|
rows.forEach(row => {
|
|
2559
2562
|
if (row.words) {
|
|
2560
2563
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2561
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2564
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2562
2565
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2563
2566
|
if (row.isOverflow && !letterSpacing)
|
|
2564
2567
|
row.textMode = true;
|
|
@@ -2580,7 +2583,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2580
2583
|
else {
|
|
2581
2584
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2582
2585
|
}
|
|
2583
|
-
if (!row.paraEnd
|
|
2586
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2584
2587
|
charX += addWordWidth;
|
|
2585
2588
|
row.width += addWordWidth;
|
|
2586
2589
|
}
|
package/dist/web.esm.js
CHANGED
|
@@ -222,7 +222,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
222
222
|
},
|
|
223
223
|
loadImage(src) {
|
|
224
224
|
return new Promise((resolve, reject) => {
|
|
225
|
-
const img = new Image();
|
|
225
|
+
const img = new Platform.origin.Image();
|
|
226
226
|
const { crossOrigin } = Platform.image;
|
|
227
227
|
if (crossOrigin) {
|
|
228
228
|
img.setAttribute('crossOrigin', crossOrigin);
|
|
@@ -232,7 +232,10 @@ function useCanvas(_canvasType, _power) {
|
|
|
232
232
|
img.onerror = (e) => { reject(e); };
|
|
233
233
|
img.src = Platform.image.getRealURL(src);
|
|
234
234
|
});
|
|
235
|
-
}
|
|
235
|
+
},
|
|
236
|
+
Image,
|
|
237
|
+
PointerEvent,
|
|
238
|
+
DragEvent
|
|
236
239
|
};
|
|
237
240
|
Platform.event = {
|
|
238
241
|
stopDefault(origin) { origin.preventDefault(); },
|
|
@@ -708,7 +711,7 @@ class Renderer {
|
|
|
708
711
|
partRender() {
|
|
709
712
|
const { canvas, updateBlocks: list } = this;
|
|
710
713
|
if (!list)
|
|
711
|
-
return
|
|
714
|
+
return;
|
|
712
715
|
this.mergeBlocks();
|
|
713
716
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
714
717
|
this.clipRender(block); });
|
|
@@ -2559,7 +2562,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2559
2562
|
rows.forEach(row => {
|
|
2560
2563
|
if (row.words) {
|
|
2561
2564
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2562
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2565
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2563
2566
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2564
2567
|
if (row.isOverflow && !letterSpacing)
|
|
2565
2568
|
row.textMode = true;
|
|
@@ -2581,7 +2584,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2581
2584
|
else {
|
|
2582
2585
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2583
2586
|
}
|
|
2584
|
-
if (!row.paraEnd
|
|
2587
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2585
2588
|
charX += addWordWidth;
|
|
2586
2589
|
row.width += addWordWidth;
|
|
2587
2590
|
}
|
package/dist/web.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as r,Creator as a,LeaferImage as h,defineKey as l,FileHelper as c,LeafList as d,RenderEvent as u,ChildEvent as p,WatchEvent as f,PropertyEvent as g,LeafHelper as _,BranchHelper as w,Bounds as y,LeafBoundsHelper as v,LeafLevelList as m,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as L,Plugin as E,MathHelper as k,MatrixHelper as R,AlignHelper as T,ImageEvent as S,AroundHelper as M,PointHelper as C,Direction4 as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as O,InteractionBase as P,Cursor as W,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as z,PaintGradient as F,Export as j,Group as G,TextConvert as U,Paint as V,Effect as Y}from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class N extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else X.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}r(CanvasRenderingContext2D.prototype),r(Path2D.prototype);const{mineType:H,fileType:q}=c;function K(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,H(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(H(q(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}))},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=a.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new h(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):Q.indexOf("Safari")>-1&&-1===Q.indexOf("Chrome")&&(i.fullImageShadow=!0),Q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?i.os="Mac":Q.indexOf("Linux")>-1&&(i.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;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 d,this.target=t,e&&(this.config=s.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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 f(f.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(f.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:J,updateAllWorldOpacity:tt}=_,{pushAllChildBranch:et,pushAllParent:it}=w;const{worldBounds:st}=v,nt={x:0,y:0,width:1e5,height:1e5};class ot{constructor(t){this.updatedBounds=new y,this.beforeBounds=new y,this.afterBounds=new y,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),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:rt,updateAllChange:at}=_,ht=t.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.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.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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(f.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=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=x,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new x(n,a,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?(Z(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(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||J(s[t])}J(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new x(o,a,this.times)),i.emitEvent(new x(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new d(e));e.emitEvent(new x(i,o,this.times)),lt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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(){const{target:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(f.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class dt{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:60},this.target=t,this.canvas=e,i&&(this.config=s.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)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new y,ct.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(u.CHILD_START,e),this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.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 y,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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;if(!e)return ct.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=b.start("PartRender"),{canvas:s}=this,n=e.getIntersect(s.bounds),o=e.includes(this.target.__world),r=new y(n);s.save(),o&&!t.showRepaint?s.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),s.clearWorld(n,!0),s.clipWorld(n,!0)),this.__render(n,o,r),s.restore(),b.end(i)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(e,i,s){const n=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),t.showHitView&&this.renderHitView(n),t.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(s)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new y;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new y(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 y(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 u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ut}=L;class pt{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new d(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||_.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;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&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ut(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):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&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class ft{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,e,s){return i.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,e,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):E.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new ft(t,e)}),i.layout=lt.fullLayout;const gt={convert(t,e){const i=O.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=O.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=gt.getTouch(t),s=O.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},_t={convert(t){const e=O.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:wt}=O;class yt extends P{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(_t.convert(t))}onKeyUp(t){this.keyUp(_t.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(gt.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(gt.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(gt.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(gt.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(gt.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(gt.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(gt.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=gt.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&wt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(gt.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=gt.getTouch(t);this.pointerMove(gt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=gt.getTouch(t);this.pointerUp(gt.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(O.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},O.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=O.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(k.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&W.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function vt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function mt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Bt(t,!0,e,i):bt(e,i);break;case"inside":xt("inside",t,n,e,i);break;case"outside":xt("outside",t,n,e,i)}}function xt(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?Bt(e,!0,s,a):bt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",vt(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function bt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Bt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?bt(i,s):s.stroke(),s.restoreBlendMode()):e?bt(i,s):s.stroke())}function Lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Et,getOuterOf:kt,getByMove:Rt,getIntersectData:Tt}=L;let St;function Mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:z.string(r,a)};case"image":return I.image(i,t,e,s,!St||!St[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:z.string(e)}:void 0}}const Ct={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),St=I.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Mt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?vt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?vt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?vt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?vt(e,i):n?i.fill(n):i.fill())},fillText:vt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Lt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Bt(t,!1,e,i),s.__useArrow&&Lt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),Bt(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:bt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,d=Tt(s?Et(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(d);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=p),a=kt(n,r),o=Rt(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let At={};const{get:Ot,rotateOfOuter:Pt,translate:Wt,scaleOfOuter:Dt,scale:It,rotate:zt}=R;function Ft(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),It(a,n,o),r&&Pt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function jt(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),n&&It(a,n,o),r&&zt(a,r),t.transform=a}function Gt(t,e,i,s,n,o,r,a,h,l){const c=Ot();if(h)if("center"===l)Pt(c,{x:i/2,y:s/2},h);else switch(zt(c,h),h){case 90:Wt(c,s,0);break;case 180:Wt(c,i,s);break;case 270:Wt(c,0,i)}At.x=e.x+n,At.y=e.y+o,Wt(c,At.x,At.y),r&&Dt(c,At,r,a),t.transform=c}const{get:Ut,translate:Vt}=R,Yt=new y,Xt={},Nt={};function Ht(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=qt(i,s,e)}function qt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:h,scale:l,size:c,rotation:d,repeat:u}=t,p=e.width===s&&e.height===n,f={mode:r},g="center"!==a&&(d||0)%180==90,_=g?n:s,w=g?s:n;let y,v,m=0,x=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(k.getScaleData(l,c,i,Nt),y=Nt.scaleX,v=Nt.scaleY);else if(!p||d){const t=e.width/_,i=e.height/w;y=v="fit"===r?Math.min(t,i):Math.max(t,i),m+=(e.width-s*y)/2,x+=(e.height-n*v)/2}if(a){const t={x:m,y:x,width:_,height:w};y&&(t.width*=y,t.height*=v),T.toPoint(a,t,e,Xt,!0),m+=Xt.x,x+=Xt.y}switch(h&&(m+=h.x,x+=h.y),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(m||x||y||d)&&jt(f,e,m,x,y,v,d);break;case"repeat":(!p||y||d)&&Gt(f,e,s,n,m,x,y,v,d,a),u||(f.repeat="repeat");break;default:y&&Ft(f,e,m,x,y,v,d)}return f.transform||(e.x||e.y)&&(f.transform=Ut(),Vt(f.transform,e.x,e.y)),y&&"stretch"!==r&&(f.scaleX=y,f.scaleY=v),f.width=s,f.height=n,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let Kt,Qt=new y;const{isSame:$t}=L;function Zt(t,e,i,s,n,o){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||Ht(n,s,i,o),!0}function Jt(t,e){ie(t,S.LOAD,e)}function te(t,e){ie(t,S.LOADED,e)}function ee(t,e,i){e.error=i,t.forceUpdate("surface"),ie(t,S.ERROR,e)}function ie(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:oe,copy:re}=R,{ceil:ae,abs:he}=Math;function le(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{n=he(n),o=he(o);const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=a;u&&(l=ne(),re(l,g),oe(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,d*=o;const w=c*d;if(!_&&w>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(h=Math.sqrt(w/y)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=p),(g||1!==n||1!==o)&&(l||(l=ne(),g&&re(l,g)),oe(l,1/n,1/o));const v=t.getCanvas(ae(c)||1,ae(d)||1,f),m=t.getPattern(v,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=r,!0}}function ce(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:de}=Math;const ue={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return Kt&&i===Kt.paint&&$t(s,Kt.boxBounds)?o=Kt.leafPaint:(o={type:i.type,image:a},Kt=a.use>1?{leafPaint:o,paint:i,boxBounds:Qt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Zt(t,e,i,a,o,s),n&&(Jt(t,r),te(t,r))):a.error?n&&ee(t,r,a.error):(n&&(se(t,!0),Jt(t,r)),o.loadId=a.load((()=>{se(t,!1),t.destroyed||(Zt(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),te(t,r)),o.loadId=null}),(e=>{se(t,!1),ee(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:a}=e;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!j.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:e}=h;t*=de(o)*a,e*=de(r)*a,h.scaleX&&(t*=h.scaleX,e*=h.scaleY),n=t*e>i.image.maxCacheSize||j.running}return n?(e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),s.blendMode&&(e.blendMode=s.blendMode),h.opacity&&(e.opacity*=h.opacity),h.transform&&e.transform(h.transform),e.drawImage(s.image.view,0,0,h.width,h.height),e.restore(),!0):(!s.style||s.sync||j.running?le(t,s,a):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ce(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&le(t,s,a),t.forceUpdate("surface")}))),300)),!1)}},createPattern:le,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null},createData:Ht,getPatternData:qt,fillOrFitMode:Ft,clipMode:jt,repeatMode:Gt},{toPoint:pe}=M,fe={},ge={};function _e(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),z.string(s,i)):t.addColorStop(s.offset,z.string(s.color,i))}}const{getAngle:we,getDistance:ye}=C,{get:ve,rotateOfOuter:me,scaleOfOuter:xe}=R,{toPoint:be}=M,Be={},Le={};function Ee(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=we(e,i);o=ve(),n?(xe(o,e,r/a*(s||1),1),me(o,e,t+90)):(xe(o,e,1,r/a*(s||1)),me(o,e,t))}return o}const{getDistance:ke}=C,{toPoint:Re}=M,Te={},Se={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;pe(s||"top",e,fe),pe(n||"bottom",e,ge);const h=i.canvas.createLinearGradient(fe.x,fe.y,ge.x,ge.y);_e(h,t.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;be(s||"center",e,Be),be(n||"bottom",e,Le);const l=i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,ye(Be,Le));_e(l,t.stops,r);const c={type:o,style:l},d=Ee(e,Be,Le,h,!0);return d&&(c.transform=d),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Re(s||"center",e,Te),Re(n||"bottom",e,Se);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Te.x,Te.y):i.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,ke(Te,Se));_e(l,t.stops,r);const c={type:o,style:l},d=Ee(e,Te,Se,h||1,i.conicGradientRotate90);return d&&(c.transform=d),a&&(c.blendMode=a),c},getTransform:Ee},{copy:Ce,toOffsetOutBounds:Ae}=L,Oe={},Pe={};function We(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ce(Oe,t.bounds),Oe.x+=e.x-r.x,Oe.y+=e.y-r.y,s){const{matrix:t}=n;Oe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Oe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Ce(Oe,e),Oe.x-=e.width/2*(s-1),Oe.y-=e.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,r,s?Oe:e)}const{toOffsetOutBounds:De}=L,Ie={};const ze={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Ae(l,Pe),a.forEach(((a,g)=>{p.setWorldShadow(Pe.offsetX+a.x*d,Pe.offsetY+a.y*u,a.blur*d,a.color),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Pe,n,i),s=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),s=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;De(l,Ie),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(Ie.offsetX+a.x*d,Ie.offsetY+a.y*u,a.blur*d),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Ie,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(s,!0)})),p.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){}},{excludeRenderBounds:Fe}=v;function je(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}G.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++)i=h[l],a=i.__.mask,a&&(r&&(je(this,r,t,n,s,o),s=n=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Ge(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||Fe(i,e)||i.__render(n||t,e);je(this,r,t,n,s,o)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ye=Ve+"_#~&*+\\=|≮≯≈≠=…",Xe=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const He=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ne(Ve),Qe=Ne(Ye),$e=Ne("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Je,Single:ti,Before:ei,After:ii,Symbol:si,Break:ni}=Ze;function oi(t){return He[t]?Je:$e[t]?ni:qe[t]?ei:Ke[t]?ii:Qe[t]?si:Xe.test(t)?ti:Je}const ri={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ai(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:hi}=ri,{Letter:li,Single:ci,Before:di,After:ui,Symbol:pi,Break:fi}=Ze;let gi,_i,wi,yi,vi,mi,xi,bi,Bi,Li,Ei,ki,Ri,Ti,Si,Mi,Ci,Ai=[];function Oi(t,e){Bi&&!bi&&(bi=Bi),gi.data.push({char:t,width:e}),wi+=e}function Pi(){yi+=wi,gi.width=wi,_i.words.push(gi),gi={data:[]},wi=0}function Wi(){Ti&&(Si.paraNumber++,_i.paraStart=!0,Ti=!1),Bi&&(_i.startCharSize=bi,_i.endCharSize=Bi,bi=0),_i.width=yi,Mi.width?hi(_i):Ci&&Di(),Ai.push(_i),_i={words:[]},yi=0}function Di(){yi>(Si.maxWidth||0)&&(Si.maxWidth=yi)}const Ii=0,zi=1,Fi=2;const{top:ji,right:Gi,bottom:Ui,left:Vi}=A;function Yi(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 Xi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=e;l&&(o?(s=l[Vi],o-=l[Gi]+l[Vi]):e.autoSizeAlign||(s=l[Vi]),r?(n=l[ji],r-=l[ji]+l[Ui]):e.autoSizeAlign||(n=l[ji]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Si=t,Ai=t.rows,Mi=t.bounds,Ci=!Mi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Mi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ti=!0,Ei=null,bi=xi=Bi=wi=yi=0,gi={data:[]},_i={words:[]};for(let s=0,l=e.length;s<l;s++)mi=e[s],"\n"===mi?(wi&&Pi(),_i.paraEnd=!0,Wi(),Ti=!0):(Li=oi(mi),Li===li&&"none"!==r&&(mi=ai(mi,r,!wi)),xi=a.measureText(mi).width,n&&(n<0&&(Bi=xi),xi+=n),ki=Li===ci&&(Ei===ci||Ei===li)||Ei===ci&&Li!==ui,Ri=!(Li!==di&&Li!==ci||Ei!==pi&&Ei!==ui),vi=Ti&&o?h-o:h,t&&h&&yi+wi+xi>vi&&(i?(wi&&Pi(),yi&&Wi()):(Ri||(Ri=Li===li&&Ei==ui),ki||Ri||Li===fi||Li===di||Li===ci||wi+xi>vi?(wi&&Pi(),yi&&Wi()):yi&&Wi()))," "===mi&&!0!==Ti&&yi+wi===0||(Li===fi?(" "===mi&&wi&&Pi(),Oi(mi,xi),Pi()):ki||Ri?(wi&&Pi(),Oi(mi,xi)):Oi(mi,xi)),Ei=Li);wi&&Pi(),yi&&Wi(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Si.paraNumber++,yi=a.measureText(t).width,Ai.push({x:o||0,text:t,width:yi,paraStart:!0}),Ci&&Di()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Vi]);break;case"right":Yi(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[ji]);break;case"bottom":Yi(e,"y",-t[Ui])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:c,autoSizeAlign:d}=e;let{x:u,y:p,width:f,height:g}=s,_=n*i.length+(c?c*(t.paraNumber-1):0),w=o;if(a&&_>g)_=Math.max(g,n),t.overflow=i.length;else if(g||d)switch(l){case"middle":p+=(g-_)/2;break;case"bottom":p+=g-_}w+=p;let y,v,m,x=f||d?f:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(y=i[o],y.x=u,y.width<f||y.width>f&&!a)switch(h){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&o>0&&(w+=c),y.y=w,w+=n,t.overflow>o&&w>_&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,m=y.width,r<0&&(y.width<0?(m=-y.width+e.fontSize+r,v-=m,m+=e.fontSize):m-=r),v<s.x&&(s.x=v),m>s.width&&(s.width=m),a&&f&&f<m&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(c,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,c,d,u;n.forEach((t=>{t.words&&(c=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,d=a||t.isOverflow?Ii:l>.01?zi:Fi,t.isOverflow&&!a&&(t.textMode=!0),d===Fi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,h=t.x,t.data=[],t.words.forEach((e=>{d===zi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[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],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,e),c}};const Ni={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!z.object)return t;t=z.object(t)}let s=void 0===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(U,Xi),Object.assign(z,Ni),Object.assign(V,Ct),Object.assign(I,ue),Object.assign(F,Me),Object.assign(Y,ze),Object.assign(a,{interaction:(t,e,i,s)=>new yt(t,e,i,s),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new D}),K();export{yt as Interaction,lt as Layouter,N as LeaferCanvas,pt as Picker,dt as Renderer,ft as Selector,$ as Watcher,K as useCanvas};
|
|
1
|
+
import{Debug as t,LeaferCanvasBase as e,Platform as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,canvasPatch as r,Creator as a,LeaferImage as h,defineKey as l,FileHelper as c,LeafList as d,RenderEvent as u,ChildEvent as p,WatchEvent as g,PropertyEvent as f,LeafHelper as _,BranchHelper as w,Bounds as v,LeafBoundsHelper as y,LeafLevelList as m,LayoutEvent as b,Run as x,ImageManager as B,BoundsHelper as E,Plugin as L,MathHelper as k,MatrixHelper as T,AlignHelper as R,ImageEvent as S,AroundHelper as M,PointHelper as C,Direction4 as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as O,InteractionBase as P,Cursor as W,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as I,ColorConvert as z,PaintGradient as F,Export as j,Group as G,TextConvert as U,Paint as V,Effect as Y}from"@leafer-ui/draw";const X=t.get("LeaferCanvas");class N extends e{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const s=i.children[t];s?(this.setAbsolute(s),i.insertBefore(e,s)):i.appendChild(s)}}init(){const{config:t}=this,e=t.view||t.canvas;e?this.__createViewFrom(e):this.__createView();const{style:s}=this.view;if(s.display||(s.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}i.syncDomFont&&!this.parentView&&(s.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(t)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else X.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){this.autoBounds=t;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),X.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const t=i.devicePixelRatio;if(this.pixelRatio!==t){const{width:e,height:i}=this;this.emitResize({width:e,height:i,pixelRatio:t})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),i.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const e=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t),a={width:o,height:r,pixelRatio:i.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=e;t.marginLeft=s+"px",t.marginTop=n+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),this.resizeListener&&void 0!==this.width&&this.resizeListener(new o(t,e))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}r(CanvasRenderingContext2D.prototype),r(Path2D.prototype);const{mineType:H,fileType:q}=c;function K(t,e){i.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,H(e),i))),canvasSaveAs:(t,e,s)=>{const n=t.toDataURL(H(q(e)),s);return i.origin.download(n,e)},download:(t,e)=>new Promise((i=>{let s=document.createElement("a");s.href=t,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),i()})),loadImage:t=>new Promise(((e,s)=>{const n=new i.origin.Image,{crossOrigin:o}=i.image;o&&(n.setAttribute("crossOrigin",o),n.crossOrigin=o),n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)})),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},i.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},i.canvas=a.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new N(t,e),image:t=>new h(t)}),i.name="web",i.isMobile="ontouchstart"in window,i.requestRender=function(t){window.requestAnimationFrame(t)},l(i,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(i.conicGradientRotate90=!0,i.intWheelDeltaY=!0,i.syncDomFont=!0):Q.indexOf("Safari")>-1&&-1===Q.indexOf("Chrome")&&(i.fullImageShadow=!0),Q.indexOf("Windows")>-1?(i.os="Windows",i.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?i.os="Mac":Q.indexOf("Linux")>-1&&(i.os="Linux");class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new d;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 d,this.target=t,e&&(this.config=s.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(u.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===p.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 g(g.DATA,{updatedList:this.updatedList})),this.__updatedList=new d,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([p.ADD,p.REMOVE],this.__onChildEvent,this),t.on_(g.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:Z,updateBounds:J,updateAllWorldOpacity:tt}=_,{pushAllChildBranch:et,pushAllParent:it}=w;const{worldBounds:st}=y,nt={x:0,y:0,width:1e5,height:1e5};class ot{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,t instanceof Array&&(t=new d(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),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:rt,updateAllChange:at}=_,ht=t.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=s.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.running)return;const{target:t}=this;this.times=0;try{t.emit(b.START),this.layoutOnce(),t.emitEvent(new b(b.END,this.layoutedBlocks,this.times))}catch(t){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(g.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=b,a=this.getBlocks(s);a.forEach((t=>t.setBefore())),i.emitEvent(new b(n,a,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?(Z(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(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||J(s[t])}J(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&a.push(this.extraBlock),a.forEach((t=>t.setAfter())),i.emitEvent(new b(o,a,this.times)),i.emitEvent(new b(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=b,o=this.getBlocks(new d(e));e.emitEvent(new b(i,o,this.times)),lt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new b(s,o,this.times)),e.emitEvent(new b(n,o,this.times)),this.addBlocks(o),x.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?w.updateBounds(t):_.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ot(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(){const{target:t}=this;this.__eventIds=[t.on_(b.REQUEST,this.layout,this),t.on_(b.AGAIN,this.layoutAgain,this),t.on_(g.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=t.get("Renderer");class dt{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:60},this.target=t,this.canvas=e,i&&(this.config=s.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(b.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(u.CHILD_START,e),this.emitRender(u.START),this.renderOnce(t),this.emitRender(u.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 v,this.renderOptions={},t)this.emitRender(u.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(u.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(u.RENDER,this.renderBounds,this.renderOptions),this.emitRender(u.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(e){const i=x.start("PartRender"),{canvas:s}=this,n=e.getIntersect(s.bounds),o=e.includes(this.target.__world),r=new v(n);s.save(),o&&!t.showRepaint?s.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),s.clearWorld(n,!0),s.clipWorld(n,!0)),this.__render(n,o,r),s.restore(),x.end(i)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),x.end(t)}__render(e,i,s){const n=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,n),this.renderBounds=s=s||e,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),t.showHitView&&this.renderHitView(n),t.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(s)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();i.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(u.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(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 v(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 u(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.update,this),t.on_(b.END,this.__onLayoutEnd,this),t.on_(u.AGAIN,this.renderAgain,this),t.on_(o.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ut}=E;class pt{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,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new d(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,a=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:h,target:a,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:a}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new d;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||_.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.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),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new d;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new d;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new d,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;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&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ut(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):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&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class gt{constructor(t,e){this.config={},e&&(this.config=s.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=a.finder&&a.finder()}getByPoint(t,e,s){return i.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,e,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):L.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(a,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new gt(t,e)}),i.layout=lt.fullLayout;const ft={convert(t,e){const i=O.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=O.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=ft.getTouch(t),s=O.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},_t={convert(t){const e=O.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{pathCanDrag:wt}=O;class vt extends P{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(_t.convert(t))}onKeyUp(t){this.keyUp(_t.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(ft.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(ft.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(ft.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(ft.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(ft.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(ft.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(ft.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=ft.getTouch(t),i=this.getLocal(e,!0),{preventDefault:s}=this.config.touch;(!0===s||"auto"===s&&wt(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(ft.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=ft.getTouch(t);this.pointerMove(ft.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=ft.getTouch(t);this.pointerUp(ft.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(O.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},O.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(t){if(this.useMultiTouch)return;this.preventDefaultWheel(t);const e=O.getBase(t);Object.assign(e,this.getLocal(t));const i=t.scale/this.lastGestureScale,s=(t.rotation-this.lastGestureRotation)/Math.PI*180*(k.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},e),{scale:i*i})),this.rotate(Object.assign(Object.assign({},e),{rotation:s})),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&W.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function mt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Bt(t,!0,e,i):xt(e,i);break;case"inside":bt("inside",t,n,e,i);break;case"outside":bt("outside",t,n,e,i)}}function bt(t,e,i,s,n){const{__strokeWidth:o,__font:r}=s.__,a=n.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,s.__),a.font=r,i?Bt(e,!0,s,a):xt(s,a),a.blendMode="outside"===t?"destination-out":"destination-in",yt(s,a),a.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(a,s.__nowWorld):n.copyWorldToInner(a,s.__nowWorld,s.__layout.renderBounds),a.recycle(s.__nowWorld)}function xt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Bt(t,e,i,s){let n;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&I.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?xt(i,s):s.stroke(),s.restoreBlendMode()):e?xt(i,s):s.stroke())}function Et(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Lt,getOuterOf:kt,getByMove:Tt,getIntersectData:Rt}=E;let St;function Mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:z.string(r,a)};case"image":return I.image(i,t,e,s,!St||!St[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:z.string(e)}:void 0}}const Ct={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),St=I.recycleImage(t,i);for(let i,n=0,r=o.length;n<r;n++)i=Mt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?yt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let r=0,a=t.length;r<a;r++)s=t[r],s.image&&I.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?yt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?yt(e,i):n?i.fill(n):i.fill())},fillText:yt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)mt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Bt(t,!1,e,i),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Bt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*n,s),Bt(t,!1,e,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:mt,drawTextStroke:xt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:c}=n;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(n))h=s,o=a=n;else{const{renderShapeSpread:s}=t.__layout,d=Rt(s?Lt(e.bounds,l===c?s*l:[s*c,s*l]):e.bounds,n);r=e.bounds.getFitMatrix(d);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,c*=p),a=kt(n,r),o=Tt(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:c}}};let At={};const{get:Ot,rotateOfOuter:Pt,translate:Wt,scaleOfOuter:Dt,scale:It,rotate:zt}=T;function Ft(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),It(a,n,o),r&&Pt(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function jt(t,e,i,s,n,o,r){const a=Ot();Wt(a,e.x+i,e.y+s),n&&It(a,n,o),r&&zt(a,r),t.transform=a}function Gt(t,e,i,s,n,o,r,a,h,l){const c=Ot();if(h)if("center"===l)Pt(c,{x:i/2,y:s/2},h);else switch(zt(c,h),h){case 90:Wt(c,s,0);break;case 180:Wt(c,i,s);break;case 270:Wt(c,0,i)}At.x=e.x+n,At.y=e.y+o,Wt(c,At.x,At.y),r&&Dt(c,At,r,a),t.transform=c}const{get:Ut,translate:Vt}=T,Yt=new v,Xt={},Nt={};function Ht(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=qt(i,s,e)}function qt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Yt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:r,align:a,offset:h,scale:l,size:c,rotation:d,repeat:u}=t,p=e.width===s&&e.height===n,g={mode:r},f="center"!==a&&(d||0)%180==90,_=f?n:s,w=f?s:n;let v,y,m=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(l||c)&&(k.getScaleData(l,c,i,Nt),v=Nt.scaleX,y=Nt.scaleY);else if(!p||d){const t=e.width/_,i=e.height/w;v=y="fit"===r?Math.min(t,i):Math.max(t,i),m+=(e.width-s*v)/2,b+=(e.height-n*y)/2}if(a){const t={x:m,y:b,width:_,height:w};v&&(t.width*=v,t.height*=y),R.toPoint(a,t,e,Xt,!0),m+=Xt.x,b+=Xt.y}switch(h&&(m+=h.x,b+=h.y),r){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(m||b||v||d)&&jt(g,e,m,b,v,y,d);break;case"repeat":(!p||v||d)&&Gt(g,e,s,n,m,b,v,y,d,a),u||(g.repeat="repeat");break;default:v&&Ft(g,e,m,b,v,y,d)}return g.transform||(e.x||e.y)&&(g.transform=Ut(),Vt(g.transform,e.x,e.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=n,o&&(g.opacity=o),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Kt,Qt=new v;const{isSame:$t}=E;function Zt(t,e,i,s,n,o){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||Ht(n,s,i,o),!0}function Jt(t,e){ie(t,S.LOAD,e)}function te(t,e){ie(t,S.LOADED,e)}function ee(t,e,i){e.error=i,t.forceUpdate("surface"),ie(t,S.ERROR,e)}function ie(t,e,i){t.hasEvent(e)&&t.emitEvent(new S(e,i))}function se(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:oe,copy:re}=T,{ceil:ae,abs:he}=Math;function le(t,e,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const r=n+"-"+o+"-"+s;if(e.patternId===r||t.destroyed)return!1;{n=he(n),o=he(o);const{image:t,data:a}=e;let h,l,{width:c,height:d,scaleX:u,scaleY:p,opacity:g,transform:f,repeat:_}=a;u&&(l=ne(),re(l,f),oe(l,1/u,1/p),n*=u,o*=p),n*=s,o*=s,c*=n,d*=o;const w=c*d;if(!_&&w>i.image.maxCacheSize)return!1;let v=i.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;v>e&&(v=e)}w>v&&(h=Math.sqrt(w/v)),h&&(n/=h,o/=h,c/=h,d/=h),u&&(n/=u,o/=p),(f||1!==n||1!==o)&&(l||(l=ne(),f&&re(l,f)),oe(l,1/n,1/o));const y=t.getCanvas(ae(c)||1,ae(d)||1,g),m=t.getPattern(y,_||i.origin.noRepeat||"no-repeat",l,e);return e.style=m,e.patternId=r,!0}}function ce(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:de}=Math;const ue={image:function(t,e,i,s,n){let o,r;const a=B.get(i);return Kt&&i===Kt.paint&&$t(s,Kt.boxBounds)?o=Kt.leafPaint:(o={type:i.type,image:a},Kt=a.use>1?{leafPaint:o,paint:i,boxBounds:Qt.set(s)}:null),(n||a.loading)&&(r={image:a,attrName:e,attrValue:i}),a.ready?(Zt(t,e,i,a,o,s),n&&(Jt(t,r),te(t,r))):a.error?n&&ee(t,r,a.error):(n&&(se(t,!0),Jt(t,r)),o.loadId=a.load((()=>{se(t,!1),t.destroyed||(Zt(t,e,i,a,o,s)&&(a.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),te(t,r)),o.loadId=null}),(e=>{se(t,!1),ee(t,r,e),o.loadId=null}))),o},checkImage:function(t,e,s,n){const{scaleX:o,scaleY:r}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:a}=e;if(!s.data||s.patternId===o+"-"+r+"-"+a&&!j.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:e}=h;t*=de(o)*a,e*=de(r)*a,h.scaleX&&(t*=h.scaleX,e*=h.scaleY),n=t*e>i.image.maxCacheSize||j.running}return n?(e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),s.blendMode&&(e.blendMode=s.blendMode),h.opacity&&(e.opacity*=h.opacity),h.transform&&e.transform(h.transform),e.drawImage(s.image.view,0,0,h.width,h.height),e.restore(),!0):(!s.style||s.sync||j.running?le(t,s,a):s.patternTask||(s.patternTask=B.patternTasker.add((()=>ce(this,void 0,void 0,(function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&le(t,s,a),t.forceUpdate("surface")}))),300)),!1)}},createPattern:le,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null},createData:Ht,getPatternData:qt,fillOrFitMode:Ft,clipMode:jt,repeatMode:Gt},{toPoint:pe}=M,ge={},fe={};function _e(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),z.string(s,i)):t.addColorStop(s.offset,z.string(s.color,i))}}const{getAngle:we,getDistance:ve}=C,{get:ye,rotateOfOuter:me,scaleOfOuter:be}=T,{toPoint:xe}=M,Be={},Ee={};function Le(t,e,i,s,n){let o;const{width:r,height:a}=t;if(r!==a||s){const t=we(e,i);o=ye(),n?(be(o,e,r/a*(s||1),1),me(o,e,t+90)):(be(o,e,1,r/a*(s||1)),me(o,e,t))}return o}const{getDistance:ke}=C,{toPoint:Te}=M,Re={},Se={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:o,blendMode:r,opacity:a}=t;pe(s||"top",e,ge),pe(n||"bottom",e,fe);const h=i.canvas.createLinearGradient(ge.x,ge.y,fe.x,fe.y);_e(h,t.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;xe(s||"center",e,Be),xe(n||"bottom",e,Ee);const l=i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,ve(Be,Ee));_e(l,t.stops,r);const c={type:o,style:l},d=Le(e,Be,Ee,h,!0);return d&&(c.transform=d),a&&(c.blendMode=a),c},conicGradient:function(t,e){let{from:s,to:n,type:o,opacity:r,blendMode:a,stretch:h}=t;Te(s||"center",e,Re),Te(n||"bottom",e,Se);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Re.x,Re.y):i.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ke(Re,Se));_e(l,t.stops,r);const c={type:o,style:l},d=Le(e,Re,Se,h||1,i.conicGradientRotate90);return d&&(c.transform=d),a&&(c.blendMode=a),c},getTransform:Le},{copy:Ce,toOffsetOutBounds:Ae}=E,Oe={},Pe={};function We(t,e,s,n){const{bounds:o,shapeBounds:r}=n;if(i.fullImageShadow){if(Ce(Oe,t.bounds),Oe.x+=e.x-r.x,Oe.y+=e.y-r.y,s){const{matrix:t}=n;Oe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Oe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Ce(Oe,e),Oe.x-=e.width/2*(s-1),Oe.y-=e.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,r,s?Oe:e)}const{toOffsetOutBounds:De}=E,Ie={};const ze={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),g=a.length-1;Ae(l,Pe),a.forEach(((a,f)=>{p.setWorldShadow(Pe.offsetX+a.x*d,Pe.offsetY+a.y*u,a.blur*d,a.color),n=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Pe,n,i),s=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),s=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),g&&f<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:d,scaleY:u}=i,p=e.getSameCanvas(),g=a.length-1;De(l,Ie),a.forEach(((a,f)=>{p.save(),p.setWorldShadow(Ie.offsetX+a.x*d,Ie.offsetY+a.y*u,a.blur*d),n=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,We(p,Ie,n,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,c,l,"source-out"),s=l),p.fillWorld(s,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,o,a.blendMode):e.copyWorldToInner(p,s,r.renderBounds,a.blendMode),g&&f<g&&p.clearWorld(s,!0)})),p.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){}},{excludeRenderBounds:Fe}=y;function je(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ue(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ue(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function Ue(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}G.prototype.__renderMask=function(t,e){let i,s,n,o,r,a;const{children:h}=this;for(let l=0,c=h.length;l<c;l++)i=h[l],a=i.__.mask,a&&(r&&(je(this,r,t,n,s,o),s=n=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,n||(n=Ge(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===a?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==a&&"clipping-path"!==a)||Fe(i,e)||i.__render(n||t,e);je(this,r,t,n,s,o)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ye=Ve+"_#~&*+\\=|≮≯≈≠=…",Xe=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 Ne(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const He=Ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),qe=Ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ne(Ve),Qe=Ne(Ye),$e=Ne("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Je,Single:ti,Before:ei,After:ii,Symbol:si,Break:ni}=Ze;function oi(t){return He[t]?Je:$e[t]?ni:qe[t]?ei:Ke[t]?ii:Qe[t]?si:Xe.test(t)?ti:Je}const ri={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ai(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:hi}=ri,{Letter:li,Single:ci,Before:di,After:ui,Symbol:pi,Break:gi}=Ze;let fi,_i,wi,vi,yi,mi,bi,xi,Bi,Ei,Li,ki,Ti,Ri,Si,Mi,Ci,Ai=[];function Oi(t,e){Bi&&!xi&&(xi=Bi),fi.data.push({char:t,width:e}),wi+=e}function Pi(){vi+=wi,fi.width=wi,_i.words.push(fi),fi={data:[]},wi=0}function Wi(){Ri&&(Si.paraNumber++,_i.paraStart=!0,Ri=!1),Bi&&(_i.startCharSize=xi,_i.endCharSize=Bi,xi=0),_i.width=vi,Mi.width?hi(_i):Ci&&Di(),Ai.push(_i),_i={words:[]},vi=0}function Di(){vi>(Si.maxWidth||0)&&(Si.maxWidth=vi)}const Ii=0,zi=1,Fi=2;const{top:ji,right:Gi,bottom:Ui,left:Vi}=A;function Yi(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 Xi={getDrawData:function(t,e){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=e;l&&(o?(s=l[Vi],o-=l[Gi]+l[Vi]):e.autoSizeAlign||(s=l[Vi]),r?(n=l[ji],r-=l[ji]+l[Ui]):e.autoSizeAlign||(n=l[ji]));const c={bounds:{x:s,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=h};return function(t,e,s){Si=t,Ai=t.rows,Mi=t.bounds,Ci=!Mi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:r}=s,{canvas:a}=i,{width:h,height:l}=Mi;if(h||l||n||"none"!==r){const t="none"!==s.textWrap,i="break"===s.textWrap;Ri=!0,Li=null,xi=bi=Bi=wi=vi=0,fi={data:[]},_i={words:[]};for(let s=0,l=e.length;s<l;s++)mi=e[s],"\n"===mi?(wi&&Pi(),_i.paraEnd=!0,Wi(),Ri=!0):(Ei=oi(mi),Ei===li&&"none"!==r&&(mi=ai(mi,r,!wi)),bi=a.measureText(mi).width,n&&(n<0&&(Bi=bi),bi+=n),ki=Ei===ci&&(Li===ci||Li===li)||Li===ci&&Ei!==ui,Ti=!(Ei!==di&&Ei!==ci||Li!==pi&&Li!==ui),yi=Ri&&o?h-o:h,t&&h&&vi+wi+bi>yi&&(i?(wi&&Pi(),vi&&Wi()):(Ti||(Ti=Ei===li&&Li==ui),ki||Ti||Ei===gi||Ei===di||Ei===ci||wi+bi>yi?(wi&&Pi(),vi&&Wi()):vi&&Wi()))," "===mi&&!0!==Ri&&vi+wi===0||(Ei===gi?(" "===mi&&wi&&Pi(),Oi(mi,bi),Pi()):ki||Ti?(wi&&Pi(),Oi(mi,bi)):Oi(mi,bi)),Li=Ei);wi&&Pi(),vi&&Wi(),Ai.length>0&&(Ai[Ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{Si.paraNumber++,vi=a.measureText(t).width,Ai.push({x:o||0,text:t,width:vi,paraStart:!0}),Ci&&Di()}))}(c,t,e),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Yi(e,"x",t[Vi]);break;case"right":Yi(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Yi(e,"y",t[ji]);break;case"bottom":Yi(e,"y",-t[Ui])}}(l,c,e,o,r),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:c,autoSizeAlign:d}=e;let{x:u,y:p,width:g,height:f}=s,_=n*i.length+(c?c*(t.paraNumber-1):0),w=o;if(a&&_>f)_=Math.max(f,n),t.overflow=i.length;else if(f||d)switch(l){case"middle":p+=(f-_)/2;break;case"bottom":p+=f-_}w+=p;let v,y,m,b=g||d?g:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(v=i[o],v.x=u,v.width<g||v.width>g&&!a)switch(h){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&c&&o>0&&(w+=c),v.y=w,w+=n,t.overflow>o&&w>_&&(v.isOverflow=!0,t.overflow=o+1),y=v.x,m=v.width,r<0&&(v.width<0?(m=-v.width+e.fontSize+r,y-=m,m+=e.fontSize):m-=r),y<s.x&&(s.x=y),m>s.width&&(s.width=m),a&&g&&g<m&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=_}(c,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,c,d,u;n.forEach((t=>{t.words&&(c=r&&t.paraStart?r:0,l=i&&("justify"===o||"both"===o)&&t.words.length>1?(i-t.width-c)/(t.words.length-1):0,d=a||t.isOverflow?Ii:l>.01?zi:Fi,t.isOverflow&&!a&&(t.textMode=!0),d===Fi?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,h=t.x,t.data=[],t.words.forEach((e=>{d===zi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==o||(h+=l,t.width+=l)}))),t.words=null)}))}(c,e,o),c.overflow&&function(t,e,s,n){if(!n)return;const{rows:o,overflow:r}=t;let{textOverflow:a}=e;if(o.splice(r),a&&"show"!==a){let t,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?i.canvas.measureText(a).width:0,c=s+n-l;("none"===e.textWrap?o:[o[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],h=t.x+t.width,!(s===i&&h<c));s--){if(h<c&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:a,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,e,s,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(c,e),c}};const Ni={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!z.object)return t;t=z.object(t)}let s=void 0===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(U,Xi),Object.assign(z,Ni),Object.assign(V,Ct),Object.assign(I,ue),Object.assign(F,Me),Object.assign(Y,ze),Object.assign(a,{interaction:(t,e,i,s)=>new vt(t,e,i,s),hitCanvas:(t,e)=>new N(t,e),hitCanvasManager:()=>new D}),K();export{vt as Interaction,lt as Layouter,N as LeaferCanvas,pt as Picker,dt as Renderer,gt as Selector,$ as Watcher,K as useCanvas};
|
package/dist/web.js
CHANGED
|
@@ -6010,7 +6010,7 @@ var LeaferUI = (function (exports) {
|
|
|
6010
6010
|
}
|
|
6011
6011
|
}
|
|
6012
6012
|
|
|
6013
|
-
const version = "1.3.
|
|
6013
|
+
const version = "1.3.2";
|
|
6014
6014
|
|
|
6015
6015
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
6016
6016
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6229,7 +6229,7 @@ var LeaferUI = (function (exports) {
|
|
|
6229
6229
|
},
|
|
6230
6230
|
loadImage(src) {
|
|
6231
6231
|
return new Promise((resolve, reject) => {
|
|
6232
|
-
const img = new Image();
|
|
6232
|
+
const img = new Platform.origin.Image();
|
|
6233
6233
|
const { crossOrigin } = Platform.image;
|
|
6234
6234
|
if (crossOrigin) {
|
|
6235
6235
|
img.setAttribute('crossOrigin', crossOrigin);
|
|
@@ -6239,7 +6239,10 @@ var LeaferUI = (function (exports) {
|
|
|
6239
6239
|
img.onerror = (e) => { reject(e); };
|
|
6240
6240
|
img.src = Platform.image.getRealURL(src);
|
|
6241
6241
|
});
|
|
6242
|
-
}
|
|
6242
|
+
},
|
|
6243
|
+
Image,
|
|
6244
|
+
PointerEvent,
|
|
6245
|
+
DragEvent
|
|
6243
6246
|
};
|
|
6244
6247
|
Platform.event = {
|
|
6245
6248
|
stopDefault(origin) { origin.preventDefault(); },
|
|
@@ -6715,7 +6718,7 @@ var LeaferUI = (function (exports) {
|
|
|
6715
6718
|
partRender() {
|
|
6716
6719
|
const { canvas, updateBlocks: list } = this;
|
|
6717
6720
|
if (!list)
|
|
6718
|
-
return
|
|
6721
|
+
return;
|
|
6719
6722
|
this.mergeBlocks();
|
|
6720
6723
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6721
6724
|
this.clipRender(block); });
|
|
@@ -7571,7 +7574,7 @@ var LeaferUI = (function (exports) {
|
|
|
7571
7574
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7572
7575
|
return Plugin.need('animate');
|
|
7573
7576
|
}
|
|
7574
|
-
killAnimate(_type,
|
|
7577
|
+
killAnimate(_type, _nextStyle) { }
|
|
7575
7578
|
export(_filename, _options) {
|
|
7576
7579
|
return Plugin.need('export');
|
|
7577
7580
|
}
|
|
@@ -8067,8 +8070,6 @@ var LeaferUI = (function (exports) {
|
|
|
8067
8070
|
this.created = true;
|
|
8068
8071
|
}
|
|
8069
8072
|
__onReady() {
|
|
8070
|
-
if (this.ready)
|
|
8071
|
-
return;
|
|
8072
8073
|
this.ready = true;
|
|
8073
8074
|
this.emitLeafer(LeaferEvent.BEFORE_READY);
|
|
8074
8075
|
this.emitLeafer(LeaferEvent.READY);
|
|
@@ -8082,6 +8083,20 @@ var LeaferUI = (function (exports) {
|
|
|
8082
8083
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
8083
8084
|
WaitHelper.run(this.__viewReadyWait);
|
|
8084
8085
|
}
|
|
8086
|
+
__onLayoutEnd() {
|
|
8087
|
+
const { grow, growWidth, growHeight } = this.config;
|
|
8088
|
+
if (grow) {
|
|
8089
|
+
let { width, height, pixelRatio } = this;
|
|
8090
|
+
const bounds = grow === 'box' ? this.worldBoxBounds : this.__world;
|
|
8091
|
+
if (growWidth !== false)
|
|
8092
|
+
width = Math.max(1, bounds.x + bounds.width);
|
|
8093
|
+
if (growHeight !== false)
|
|
8094
|
+
height = Math.max(1, bounds.y + bounds.height);
|
|
8095
|
+
this.__doResize({ width, height, pixelRatio });
|
|
8096
|
+
}
|
|
8097
|
+
if (!this.ready)
|
|
8098
|
+
this.__onReady();
|
|
8099
|
+
}
|
|
8085
8100
|
__onNextRender() {
|
|
8086
8101
|
if (this.viewReady) {
|
|
8087
8102
|
WaitHelper.run(this.__nextRenderWait);
|
|
@@ -8175,10 +8190,9 @@ var LeaferUI = (function (exports) {
|
|
|
8175
8190
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
8176
8191
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
8177
8192
|
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
8178
|
-
this.once(LayoutEvent.END, () => this.__onReady());
|
|
8179
8193
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
8180
8194
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
8181
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8195
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8182
8196
|
}
|
|
8183
8197
|
__removeListenEvents() {
|
|
8184
8198
|
this.off_(this.__eventIds);
|
|
@@ -11729,7 +11743,7 @@ var LeaferUI = (function (exports) {
|
|
|
11729
11743
|
rows.forEach(row => {
|
|
11730
11744
|
if (row.words) {
|
|
11731
11745
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
11732
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
11746
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
11733
11747
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
11734
11748
|
if (row.isOverflow && !letterSpacing)
|
|
11735
11749
|
row.textMode = true;
|
|
@@ -11751,7 +11765,7 @@ var LeaferUI = (function (exports) {
|
|
|
11751
11765
|
else {
|
|
11752
11766
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
11753
11767
|
}
|
|
11754
|
-
if (!row.paraEnd
|
|
11768
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
11755
11769
|
charX += addWordWidth;
|
|
11756
11770
|
row.width += addWordWidth;
|
|
11757
11771
|
}
|