@leafer-draw/worker 1.9.6 → 1.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.cjs +10 -1
- package/dist/worker.esm.js +10 -1
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.esm.min.js.map +1 -1
- package/dist/worker.js +45 -14
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.cjs.map +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +47 -15
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/worker.cjs
CHANGED
|
@@ -556,7 +556,7 @@ class Renderer {
|
|
|
556
556
|
};
|
|
557
557
|
if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
|
|
558
558
|
if (core.Debug.showRepaint) core.Debug.drawRepaint(canvas, bounds);
|
|
559
|
-
this.target
|
|
559
|
+
core.Platform.render(this.target, canvas, options);
|
|
560
560
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
561
561
|
this.renderOptions = options;
|
|
562
562
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
@@ -649,6 +649,15 @@ Object.assign(core.Creator, {
|
|
|
649
649
|
|
|
650
650
|
core.Platform.layout = Layouter.fullLayout;
|
|
651
651
|
|
|
652
|
+
core.Platform.render = function(target, canvas, options) {
|
|
653
|
+
const topOptions = Object.assign(Object.assign({}, options), {
|
|
654
|
+
topRendering: true
|
|
655
|
+
});
|
|
656
|
+
options.topList = new core.LeafList;
|
|
657
|
+
target.__render(canvas, options);
|
|
658
|
+
if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
|
|
659
|
+
};
|
|
660
|
+
|
|
652
661
|
function fillText(ui, canvas) {
|
|
653
662
|
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
654
663
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
package/dist/worker.esm.js
CHANGED
|
@@ -560,7 +560,7 @@ class Renderer {
|
|
|
560
560
|
};
|
|
561
561
|
if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
|
|
562
562
|
if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
|
|
563
|
-
this.target
|
|
563
|
+
Platform.render(this.target, canvas, options);
|
|
564
564
|
this.renderBounds = realBounds = realBounds || bounds;
|
|
565
565
|
this.renderOptions = options;
|
|
566
566
|
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
|
|
@@ -653,6 +653,15 @@ Object.assign(Creator, {
|
|
|
653
653
|
|
|
654
654
|
Platform.layout = Layouter.fullLayout;
|
|
655
655
|
|
|
656
|
+
Platform.render = function(target, canvas, options) {
|
|
657
|
+
const topOptions = Object.assign(Object.assign({}, options), {
|
|
658
|
+
topRendering: true
|
|
659
|
+
});
|
|
660
|
+
options.topList = new LeafList;
|
|
661
|
+
target.__render(canvas, options);
|
|
662
|
+
if (options.topList.length) options.topList.forEach(item => item.__render(canvas, topOptions));
|
|
663
|
+
};
|
|
664
|
+
|
|
656
665
|
function fillText(ui, canvas) {
|
|
657
666
|
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
658
667
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,isObject as k,BoundsHelper as B,Matrix as E,isUndefined as R,isString as A,getMatrixData as L,MatrixHelper as T,MathHelper as O,AlignHelper as W,PointHelper as M,ImageEvent as C,AroundHelper as D,Direction4 as P,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as F,Paint as z,ColorConvert as Y,PaintGradient as U,Export as G,Effect as X,Group as q,TextConvert as N}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class j extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:H}=s;function V(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:H(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:H(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new j(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?e.os="Mac":Q.indexOf("Linux")>-1&&(e.os="Linux");class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:$,updateBounds:J,updateChange:K}=f,{pushAllChildBranch:tt,pushAllParent:et}=p;const{worldBounds:it}=g;class st{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,it),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:nt,updateAllChange:at}=f,rt=y.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?($(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(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){t.list.forEach(K)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ot.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const lt=y.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:120},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,lt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,lt.error(t)}lt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return lt.warn("rendering");if(this.times>3)return lt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(dt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&t>n-.5)return e.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||lt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ct(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function ht(t,e){t.__.__font?ct(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i){switch(e.__.strokeAlign){case"center":ft(t,1,e,i);break;case"inside":pt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i):pt(t,"outside",e,i)}}function ft(t,e,i,s){const n=i.__;k(t)?_t(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),gt(i,s))}function pt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ct(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function gt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function _t(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!F.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?gt(s,n):n.stroke(),n.restoreBlendMode()):i?gt(s,n):n.stroke()}}function wt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ut(t,e,i);else switch(s.strokeAlign){case"center":yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function yt(t,e,i,s){const n=i.__;k(t)?_t(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&z.strokeArrow(t,i,s)}dt.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=ot.fullLayout;const{getSpread:mt,getOuterOf:xt,getByMove:vt,getIntersectData:bt}=B;let St;const{stintSet:kt}=l,{hasTransparent:Bt}=Y;function Et(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=F.image(i,t,e,n,!St||!St[e.url]);break;case"linear":s=U.linearGradient(e,n);break;case"radial":s=U.radialGradient(e,n);break;case"angular":s=U.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:Y.string(r,o)};break;default:R(e.r)||(s={type:"solid",style:Y.string(e)})}if(s){if(A(s.style)&&Bt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),St=F.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Et(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",n),kt(i,"__isTransparentFill",a)):(kt(i,"__isAlphaPixelStroke",n),kt(i,"__isTransparentStroke",a),kt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,ht(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(F.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),ht(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),ht(e,i),i.restoreBlendMode()):ht(e,i)}},fillPathOrText:ht,fillText:ct,stroke:wt,strokes:function(t,e,i){wt(t,e,i)},strokeText:ut,drawTextStroke:gt,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,r=i.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(a))h=n,o=c=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(e.fullImageShadow)p=a;else{const t=n?mt(r,u===f?n*u:[n*f,n*u]):r;p=bt(t,a)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=i.getSameCanvas(),t.__renderShape(h,s),u*=g,f*=_),c=xt(a,d),o=vt(c,-d.e,-d.f);const w=s.matrix;w?(l=new E(d),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=d,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let At={},Lt=L();const{get:Tt,rotateOfOuter:Ot,translate:Wt,scaleOfOuter:Mt,multiplyParent:Ct,scale:Dt,rotate:Pt,skew:It}=T;function Ft(t,e,i,s,n,a,r){const o=Tt();Wt(o,e.x+i,e.y+s),Dt(o,n,a),r&&Ot(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function zt(t,e,i,s,n,a,r,o,l){const d=Tt();Ut(d,e,i,s,n,a,r,o),l&&(Lt.a=e.width/l.width,Lt.d=e.height/l.height,Ct(d,Lt)),t.transform=d}function Yt(t,e,i,s,n,a,r,o,l,d,c,h){const u=Tt();if(h)Ut(u,e,n,a,r,o,l,d);else{if(l)if("center"===c)Ot(u,{x:i/2,y:s/2},l);else switch(Pt(u,l),l){case 90:Wt(u,s,0);break;case 180:Wt(u,i,s);break;case 270:Wt(u,0,i)}At.x=e.x+n,At.y=e.y+a,Wt(u,At.x,At.y),r&&Mt(u,At,r,o)}t.transform=u}function Ut(t,e,i,s,n,a,r,o){r&&Pt(t,r),o&&It(t,o.x,o.y),n&&Dt(t,n,a),Wt(t,e.x+i,e.y+s)}const{get:Gt,translate:Xt}=T,qt=new _,Nt={},jt={};function Ht(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=Vt(i,s,e)}function Vt(t,e,i){t.padding&&(e=qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(h||0)%180==90;let x,v;switch(B.set(jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(O.getScaleData(d,c,i,Nt),x=Nt.scaleX,v=Nt.scaleY),(o||g||p)&&(x&&B.scale(jt,x,v,!0),o&&W.toPoint(o,jt,e,jt,!0,!0))):w&&!h||(x=v=B.getFitScale(e,jt,"fit"!==r),B.put(e,i,o,x,!1,jt),B.scale(jt,x,v,!0)),l&&M.move(jt,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":(jt.x||jt.y||x||f||h||u)&&zt(y,e,jt.x,jt.y,x,v,h,u,t.clipSize);break;case"repeat":(!w||x||h||u)&&Yt(y,e,s,n,jt.x,jt.y,x,v,h,u,o,t.freeTransform),p||(y.repeat="repeat");const i=k(p);(g||i)&&(y.gap=function(t,e,i,s,n){let a,r;k(t)?(a=t.x,r=t.y):a=r=t;return{x:Qt(a,i,n.width,e&&e.x),y:Qt(r,s,n.height,e&&e.y)}}(g,i&&p,jt.width,jt.height,e));break;default:x&&Ft(y,e,jt.x,jt.y,x,v,h)}return y.transform||(e.x||e.y)&&(y.transform=Gt(),Xt(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),p&&(y.repeat=A(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),y}function Qt(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Zt,$t=new _;const{isSame:Jt}=B;function Kt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ht(n,s,i,a),!0}function te(t,e){se(t,C.LOAD,e)}function ee(t,e){se(t,C.LOADED,e)}function ie(t,e,i){e.error=i,t.forceUpdate("surface"),se(t,C.ERROR,e)}function se(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function ne(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ae,scale:re,copy:oe}=T,{floor:le,ceil:de,max:ce,abs:he}=Math;function ue(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=he(f),p=he(p),c=ae(),oe(c,g),re(c,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const y=h*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/de(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,h/=d,u/=d),f&&(n/=f,a/=p);const x=w&&w.x*n,v=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(x||0),e=u+(v||0);n/=t/ce(le(t),1),a/=e/ce(le(e),1),c||(c=ae(),g&&oe(c,g)),re(c,1/n,1/a)}const b=o.getCanvas(h,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),S=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,i);return i.style=S,i.patternId=r,!0}}function fe(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const pe={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return Zt&&i===Zt.paint&&Jt(s,Zt.boxBounds)?a=Zt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Zt=o.use>1?{leafPaint:a,paint:i,boxBounds:$t.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Kt(t,e,i,o,a,s),n&&(te(t,r),ee(t,r))):o.error?n&&ie(t,r,o.error):(n&&(ne(t,!0),te(t,r)),a.loadId=o.load(()=>{ne(t,!1),t.destroyed||(Kt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ee(t,r)),a.loadId=void 0},e=>{ne(t,!1),ie(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!G.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&S.isResizing(t)||G.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||G.running?ue(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>fe(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ue(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ue,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:Ht,getPatternData:Vt,fillOrFitMode:Ft,clipMode:zt,repeatMode:Yt},{toPoint:ge}=D,{hasTransparent:_e}=Y,we={},ye={};function me(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=Y.string(n,s)):(r=n.offset,a=Y.string(n.color,s)),e.addColorStop(r,a),!o&&_e(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:xe,getDistance:ve}=M,{get:be,rotateOfOuter:Se,scaleOfOuter:ke}=T,{toPoint:Be}=D,Ee={},Re={};function Ae(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=xe(e,i);a=be(),n?(ke(a,e,r/o*(s||1),1),Se(a,e,t+90)):(ke(a,e,1,r/o*(s||1)),Se(a,e,t))}return a}const{getDistance:Le}=M,{toPoint:Te}=D,Oe={},We={};const Me={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;ge(s||"top",i,we),ge(n||"bottom",i,ye);const o=e.canvas.createLinearGradient(we.x,we.y,ye.x,ye.y),l={type:a,style:o};return me(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Be(s||"center",i,Ee),Be(n||"bottom",i,Re);const l=e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,ve(Ee,Re)),d={type:a,style:l};me(d,l,t.stops,r);const c=Ae(i,Ee,Re,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Te(s||"center",i,Oe),Te(n||"bottom",i,We);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Le(Oe,We)),d={type:a,style:l};me(d,l,t.stops,r);const c=Ae(i,Oe,We,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ae},{copy:Ce,toOffsetOutBounds:De}=B,Pe={},Ie={};function Fe(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Ce(Pe,t.bounds),Pe.x+=i.x-r.x,Pe.y+=i.y-r.y,s){const{fitMatrix:t}=n;Pe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Pe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Pe.width*=s,Pe.height*=s}t.copyWorld(n.canvas,t.bounds,Pe)}else s&&(Ce(Pe,i),Pe.x-=i.width/2*(s-1),Pe.y-=i.height/2*(s-1),Pe.width*=s,Pe.height*=s),t.copyWorld(n.canvas,r,s?Pe:i)}const{toOffsetOutBounds:ze}=B,Ye={};const Ue={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;De(d,Ie),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Ie.offsetX+o.x*h*w,Ie.offsetY+o.y*u*w,o.blur*h*w,Y.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,Fe(p,Ie,n,i),s=d,o.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,d,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,c,d,"destination-out")),X.isTransformShadow(o)?X.renderTransformShadow(t,e,p,s,o):f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;ze(d,Ye),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Ye.offsetX+o.x*h*w,Ye.offsetY+o.y*u*w,o.blur*h*w),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,Fe(p,Ye,n,i),p.restore(),l?(p.copyWorld(p,d,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,c,d,"source-out"),s=d),p.fillWorld(s,Y.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),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){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:Ge}=g;let Xe;function qe(t,e,i,s,n,a,r,o){switch(e){case"grayscale":Xe||(Xe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);je(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":je(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function je(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}q.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(qe(this,r,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Xe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ne(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ne(t)),n||(n=Ne(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o||Ge(i,e)||i.__render(t,e);continue}const c=1===a&&i.__.__blendMode;c&&qe(this,r,t,n,s,a,void 0,!1),Ge(i,e)||i.__render(n||t,e),c&&qe(this,r,t,n,s,a,c,!1)}qe(this,r,t,n,s,a,void 0,!0)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=He+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Ze(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Je=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ze(He),ti=Ze(Ve),ei=Ze("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:si,Single:ni,Before:ai,After:ri,Symbol:oi,Break:li}=ii;function di(t){return $e[t]?si:ei[t]?li:Je[t]?ai:Ke[t]?ri:ti[t]?oi:Qe.test(t)?ni:si}const ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function hi(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:ui}=ci,{Letter:fi,Single:pi,Before:gi,After:_i,Symbol:wi,Break:yi}=ii;let mi,xi,vi,bi,Si,ki,Bi,Ei,Ri,Ai,Li,Ti,Oi,Wi,Mi,Ci,Di,Pi=[];function Ii(t,e){Ri&&!Ei&&(Ei=Ri),mi.data.push({char:t,width:e}),vi+=e}function Fi(){bi+=vi,mi.width=vi,xi.words.push(mi),mi={data:[]},vi=0}function zi(){Wi&&(Mi.paraNumber++,xi.paraStart=!0,Wi=!1),Ri&&(xi.startCharSize=Ei,xi.endCharSize=Ri,Ei=0),xi.width=bi,Ci.width?ui(xi):Di&&Yi(),Pi.push(xi),xi={words:[]},bi=0}function Yi(){bi>(Mi.maxWidth||0)&&(Mi.maxWidth=bi)}const{top:Ui,right:Gi,bottom:Xi,left:qi}=P;function Ni(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 ji={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[qi],a-=d[Gi]+d[qi]):i.autoSizeAlign||(s=d[qi]),r?(n=d[Ui],r-=d[Ui]+d[Xi]):i.autoSizeAlign||(n=d[Ui]));const c={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Mi=t,Pi=t.rows,Ci=t.bounds,Di=!Ci.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Ci;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Wi=!0,Li=null,Ei=Bi=Ri=vi=bi=0,mi={data:[]},xi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)ki=i[s],"\n"===ki?(vi&&Fi(),xi.paraEnd=!0,zi(),Wi=!0):(Ai=di(ki),Ai===fi&&"none"!==r&&(ki=hi(ki,r,!vi)),Bi=o.measureText(ki).width,n&&(n<0&&(Ri=Bi),Bi+=n),Ti=Ai===pi&&(Li===pi||Li===fi)||Li===pi&&Ai!==_i,Oi=!(Ai!==gi&&Ai!==pi||Li!==wi&&Li!==_i),Si=Wi&&a?l-a:l,t&&l&&bi+vi+Bi>Si&&(e?(vi&&Fi(),bi&&zi()):(Oi||(Oi=Ai===fi&&Li==_i),Ti||Oi||Ai===yi||Ai===gi||Ai===pi||vi+Bi>Si?(vi&&Fi(),bi&&zi()):bi&&zi()))," "===ki&&!0!==Wi&&bi+vi===0||(Ai===yi?(" "===ki&&vi&&Fi(),Ii(ki,Bi),Fi()):Ti||Oi?(vi&&Fi(),Ii(ki,Bi)):Ii(ki,Bi)),Li=Ai);vi&&Fi(),bi&&zi(),Pi.length>0&&(Pi[Pi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Mi.paraNumber++,bi=o.measureText(t).width,Pi.push({x:a||0,text:t,width:bi,paraStart:!0}),Di&&Yi()})}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ni(e,"x",t[qi]);break;case"right":Ni(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ni(e,"y",t[Ui]);break;case"bottom":Ni(e,"y",-t[Xi])}}(d,c,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,x,v,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(y+=h),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,c,h,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(h={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,i,a),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,k(a)?(i=a.type,a.color&&(t.decorationColor=Y.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,i),c}};const Hi={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!Y.object)return t;t=Y.object(t)}let s=R(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(N,ji),Object.assign(Y,Hi),Object.assign(z,Rt),Object.assign(F,pe),Object.assign(U,Me),Object.assign(X,Ue),V();export{ot as Layouter,j as LeaferCanvas,dt as Renderer,Z as Watcher,V as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as S,isObject as k,BoundsHelper as B,Matrix as E,isUndefined as R,isString as A,getMatrixData as L,MatrixHelper as T,MathHelper as O,AlignHelper as W,PointHelper as M,ImageEvent as C,AroundHelper as D,Direction4 as P,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as F,Paint as z,ColorConvert as Y,PaintGradient as U,Export as G,Effect as X,Group as q,TextConvert as N}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class j extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:H}=s;function V(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:H(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:H(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new j(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:Q}=navigator;Q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),Q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):Q.indexOf("Mac")>-1?e.os="Mac":Q.indexOf("Linux")>-1&&(e.os="Linux");class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:$,updateBounds:J,updateChange:K}=f,{pushAllChildBranch:tt,pushAllParent:et}=p;const{worldBounds:it}=g;class st{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,it)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,it),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:nt,updateAllChange:at}=f,rt=y.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?($(t,!0),e.add(t),t.isBranch&&tt(t,e),et(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),et(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){t.list.forEach(K)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ot.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new st([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new st(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const lt=y.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:120},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,lt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,lt.error(t)}lt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return lt.warn("rendering");if(this.times>3)return lt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(dt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&t>n-.5)return e.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||lt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ct(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function ht(t,e){t.__.__font?ct(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i){switch(e.__.strokeAlign){case"center":ft(t,1,e,i);break;case"inside":pt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i):pt(t,"outside",e,i)}}function ft(t,e,i,s){const n=i.__;k(t)?_t(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),gt(i,s))}function pt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ct(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function gt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[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)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function _t(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!F.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?gt(s,n):n.stroke(),n.restoreBlendMode()):i?gt(s,n):n.stroke()}}function wt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ut(t,e,i);else switch(s.strokeAlign){case"center":yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function yt(t,e,i,s){const n=i.__;k(t)?_t(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&z.strokeArrow(t,i,s)}dt.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=ot.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:mt,getOuterOf:xt,getByMove:vt,getIntersectData:bt}=B;let St;const{stintSet:kt}=l,{hasTransparent:Bt}=Y;function Et(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=F.image(i,t,e,n,!St||!St[e.url]);break;case"linear":s=U.linearGradient(e,n);break;case"radial":s=U.radialGradient(e,n);break;case"angular":s=U.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:Y.string(r,o)};break;default:R(e.r)||(s={type:"solid",style:Y.string(e)})}if(s){if(A(s.style)&&Bt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Rt={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),St=F.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Et(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",n),kt(i,"__isTransparentFill",a)):(kt(i,"__isAlphaPixelStroke",n),kt(i,"__isTransparentStroke",a),kt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,ht(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(F.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),ht(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),ht(e,i),i.restoreBlendMode()):ht(e,i)}},fillPathOrText:ht,fillText:ct,stroke:wt,strokes:function(t,e,i){wt(t,e,i)},strokeText:ut,drawTextStroke:gt,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,r=i.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(a))h=n,o=c=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(e.fullImageShadow)p=a;else{const t=n?mt(r,u===f?n*u:[n*f,n*u]):r;p=bt(t,a)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=i.getSameCanvas(),t.__renderShape(h,s),u*=g,f*=_),c=xt(a,d),o=vt(c,-d.e,-d.f);const w=s.matrix;w?(l=new E(d),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=d,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let At={},Lt=L();const{get:Tt,rotateOfOuter:Ot,translate:Wt,scaleOfOuter:Mt,multiplyParent:Ct,scale:Dt,rotate:Pt,skew:It}=T;function Ft(t,e,i,s,n,a,r){const o=Tt();Wt(o,e.x+i,e.y+s),Dt(o,n,a),r&&Ot(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function zt(t,e,i,s,n,a,r,o,l){const d=Tt();Ut(d,e,i,s,n,a,r,o),l&&(Lt.a=e.width/l.width,Lt.d=e.height/l.height,Ct(d,Lt)),t.transform=d}function Yt(t,e,i,s,n,a,r,o,l,d,c,h){const u=Tt();if(h)Ut(u,e,n,a,r,o,l,d);else{if(l)if("center"===c)Ot(u,{x:i/2,y:s/2},l);else switch(Pt(u,l),l){case 90:Wt(u,s,0);break;case 180:Wt(u,i,s);break;case 270:Wt(u,0,i)}At.x=e.x+n,At.y=e.y+a,Wt(u,At.x,At.y),r&&Mt(u,At,r,o)}t.transform=u}function Ut(t,e,i,s,n,a,r,o){r&&Pt(t,r),o&&It(t,o.x,o.y),n&&Dt(t,n,a),Wt(t,e.x+i,e.y+s)}const{get:Gt,translate:Xt}=T,qt=new _,Nt={},jt={};function Ht(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=Vt(i,s,e)}function Vt(t,e,i){t.padding&&(e=qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(h||0)%180==90;let x,v;switch(B.set(jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||c)&&(O.getScaleData(d,c,i,Nt),x=Nt.scaleX,v=Nt.scaleY),(o||g||p)&&(x&&B.scale(jt,x,v,!0),o&&W.toPoint(o,jt,e,jt,!0,!0))):w&&!h||(x=v=B.getFitScale(e,jt,"fit"!==r),B.put(e,i,o,x,!1,jt),B.scale(jt,x,v,!0)),l&&M.move(jt,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":(jt.x||jt.y||x||f||h||u)&&zt(y,e,jt.x,jt.y,x,v,h,u,t.clipSize);break;case"repeat":(!w||x||h||u)&&Yt(y,e,s,n,jt.x,jt.y,x,v,h,u,o,t.freeTransform),p||(y.repeat="repeat");const i=k(p);(g||i)&&(y.gap=function(t,e,i,s,n){let a,r;k(t)?(a=t.x,r=t.y):a=r=t;return{x:Qt(a,i,n.width,e&&e.x),y:Qt(r,s,n.height,e&&e.y)}}(g,i&&p,jt.width,jt.height,e));break;default:x&&Ft(y,e,jt.x,jt.y,x,v,h)}return y.transform||(e.x||e.y)&&(y.transform=Gt(),Xt(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),p&&(y.repeat=A(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),y}function Qt(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let Zt,$t=new _;const{isSame:Jt}=B;function Kt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ht(n,s,i,a),!0}function te(t,e){se(t,C.LOAD,e)}function ee(t,e){se(t,C.LOADED,e)}function ie(t,e,i){e.error=i,t.forceUpdate("surface"),se(t,C.ERROR,e)}function se(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function ne(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ae,scale:re,copy:oe}=T,{floor:le,ceil:de,max:ce,abs:he}=Math;function ue(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=he(f),p=he(p),c=ae(),oe(c,g),re(c,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const y=h*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/de(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,h/=d,u/=d),f&&(n/=f,a/=p);const x=w&&w.x*n,v=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(x||0),e=u+(v||0);n/=t/ce(le(t),1),a/=e/ce(le(e),1),c||(c=ae(),g&&oe(c,g)),re(c,1/n,1/a)}const b=o.getCanvas(h,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),S=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,i);return i.style=S,i.patternId=r,!0}}function fe(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const pe={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return Zt&&i===Zt.paint&&Jt(s,Zt.boxBounds)?a=Zt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Zt=o.use>1?{leafPaint:a,paint:i,boxBounds:$t.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Kt(t,e,i,o,a,s),n&&(te(t,r),ee(t,r))):o.error?n&&ie(t,r,o.error):(n&&(ne(t,!0),te(t,r)),a.loadId=o.load(()=>{ne(t,!1),t.destroyed||(Kt(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ee(t,r)),a.loadId=void 0},e=>{ne(t,!1),ie(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!G.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&S.isResizing(t)||G.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||G.running?ue(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>fe(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ue(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ue,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:Ht,getPatternData:Vt,fillOrFitMode:Ft,clipMode:zt,repeatMode:Yt},{toPoint:ge}=D,{hasTransparent:_e}=Y,we={},ye={};function me(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=Y.string(n,s)):(r=n.offset,a=Y.string(n.color,s)),e.addColorStop(r,a),!o&&_e(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:xe,getDistance:ve}=M,{get:be,rotateOfOuter:Se,scaleOfOuter:ke}=T,{toPoint:Be}=D,Ee={},Re={};function Ae(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=xe(e,i);a=be(),n?(ke(a,e,r/o*(s||1),1),Se(a,e,t+90)):(ke(a,e,1,r/o*(s||1)),Se(a,e,t))}return a}const{getDistance:Le}=M,{toPoint:Te}=D,Oe={},We={};const Me={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;ge(s||"top",i,we),ge(n||"bottom",i,ye);const o=e.canvas.createLinearGradient(we.x,we.y,ye.x,ye.y),l={type:a,style:o};return me(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Be(s||"center",i,Ee),Be(n||"bottom",i,Re);const l=e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,ve(Ee,Re)),d={type:a,style:l};me(d,l,t.stops,r);const c=Ae(i,Ee,Re,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Te(s||"center",i,Oe),Te(n||"bottom",i,We);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Le(Oe,We)),d={type:a,style:l};me(d,l,t.stops,r);const c=Ae(i,Oe,We,o||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ae},{copy:Ce,toOffsetOutBounds:De}=B,Pe={},Ie={};function Fe(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(Ce(Pe,t.bounds),Pe.x+=i.x-r.x,Pe.y+=i.y-r.y,s){const{fitMatrix:t}=n;Pe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Pe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Pe.width*=s,Pe.height*=s}t.copyWorld(n.canvas,t.bounds,Pe)}else s&&(Ce(Pe,i),Pe.x-=i.width/2*(s-1),Pe.y-=i.height/2*(s-1),Pe.width*=s,Pe.height*=s),t.copyWorld(n.canvas,r,s?Pe:i)}const{toOffsetOutBounds:ze}=B,Ye={};const Ue={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;De(d,Ie),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(Ie.offsetX+o.x*h*w,Ie.offsetY+o.y*u*w,o.blur*h*w,Y.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,Fe(p,Ie,n,i),s=d,o.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,d,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,c,d,"destination-out")),X.isTransformShadow(o)?X.renderTransformShadow(t,e,p,s,o):f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=o.length-1;ze(d,Ye),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(Ye.offsetX+o.x*h*w,Ye.offsetY+o.y*u*w,o.blur*h*w),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,Fe(p,Ye,n,i),p.restore(),l?(p.copyWorld(p,d,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,c,d,"source-out"),s=d),p.fillWorld(s,Y.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,o.blendMode),g&&_<g&&p.clearWorld(s)}),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){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:Ge}=g;let Xe;function qe(t,e,i,s,n,a,r,o){switch(e){case"grayscale":Xe||(Xe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);je(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":je(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function je(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}q.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(qe(this,r,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Xe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ne(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ne(t)),n||(n=Ne(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o||Ge(i,e)||i.__render(t,e);continue}const c=1===a&&i.__.__blendMode;c&&qe(this,r,t,n,s,a,void 0,!1),Ge(i,e)||i.__render(n||t,e),c&&qe(this,r,t,n,s,a,c,!1)}qe(this,r,t,n,s,a,void 0,!0)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=He+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Ze(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Je=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ze(He),ti=Ze(Ve),ei=Ze("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:si,Single:ni,Before:ai,After:ri,Symbol:oi,Break:li}=ii;function di(t){return $e[t]?si:ei[t]?li:Je[t]?ai:Ke[t]?ri:ti[t]?oi:Qe.test(t)?ni:si}const ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function hi(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:ui}=ci,{Letter:fi,Single:pi,Before:gi,After:_i,Symbol:wi,Break:yi}=ii;let mi,xi,vi,bi,Si,ki,Bi,Ei,Ri,Ai,Li,Ti,Oi,Wi,Mi,Ci,Di,Pi=[];function Ii(t,e){Ri&&!Ei&&(Ei=Ri),mi.data.push({char:t,width:e}),vi+=e}function Fi(){bi+=vi,mi.width=vi,xi.words.push(mi),mi={data:[]},vi=0}function zi(){Wi&&(Mi.paraNumber++,xi.paraStart=!0,Wi=!1),Ri&&(xi.startCharSize=Ei,xi.endCharSize=Ri,Ei=0),xi.width=bi,Ci.width?ui(xi):Di&&Yi(),Pi.push(xi),xi={words:[]},bi=0}function Yi(){bi>(Mi.maxWidth||0)&&(Mi.maxWidth=bi)}const{top:Ui,right:Gi,bottom:Xi,left:qi}=P;function Ni(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 ji={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[qi],a-=d[Gi]+d[qi]):i.autoSizeAlign||(s=d[qi]),r?(n=d[Ui],r-=d[Ui]+d[Xi]):i.autoSizeAlign||(n=d[Ui]));const c={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Mi=t,Pi=t.rows,Ci=t.bounds,Di=!Ci.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=Ci;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Wi=!0,Li=null,Ei=Bi=Ri=vi=bi=0,mi={data:[]},xi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)ki=i[s],"\n"===ki?(vi&&Fi(),xi.paraEnd=!0,zi(),Wi=!0):(Ai=di(ki),Ai===fi&&"none"!==r&&(ki=hi(ki,r,!vi)),Bi=o.measureText(ki).width,n&&(n<0&&(Ri=Bi),Bi+=n),Ti=Ai===pi&&(Li===pi||Li===fi)||Li===pi&&Ai!==_i,Oi=!(Ai!==gi&&Ai!==pi||Li!==wi&&Li!==_i),Si=Wi&&a?l-a:l,t&&l&&bi+vi+Bi>Si&&(e?(vi&&Fi(),bi&&zi()):(Oi||(Oi=Ai===fi&&Li==_i),Ti||Oi||Ai===yi||Ai===gi||Ai===pi||vi+Bi>Si?(vi&&Fi(),bi&&zi()):bi&&zi()))," "===ki&&!0!==Wi&&bi+vi===0||(Ai===yi?(" "===ki&&vi&&Fi(),Ii(ki,Bi),Fi()):Ti||Oi?(vi&&Fi(),Ii(ki,Bi)):Ii(ki,Bi)),Li=Ai);vi&&Fi(),bi&&zi(),Pi.length>0&&(Pi[Pi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Mi.paraNumber++,bi=o.measureText(t).width,Pi.push({x:a||0,text:t,width:bi,paraStart:!0}),Di&&Yi()})}(c,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ni(e,"x",t[qi]);break;case"right":Ni(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ni(e,"y",t[Ui]);break;case"bottom":Ni(e,"y",-t[Xi])}}(d,c,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,x,v,b=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(m=i[r],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(y+=h),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,c,h,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(h={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,i,a),c.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+n-d;("none"===i.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,k(a)?(i=a.type,a.color&&(t.decorationColor=Y.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,i),c}};const Hi={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!Y.object)return t;t=Y.object(t)}let s=R(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(N,ji),Object.assign(Y,Hi),Object.assign(z,Rt),Object.assign(F,pe),Object.assign(U,Me),Object.assign(X,Ue),V();export{ot as Layouter,j as LeaferCanvas,dt as Renderer,Z as Watcher,V as useCanvas};
|
|
2
2
|
//# sourceMappingURL=worker.esm.min.js.map
|