@leafer-draw/worker 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/worker.cjs +3 -3
- package/dist/worker.esm.js +3 -3
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +20 -9
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +20 -9
- package/dist/worker.module.min.js +1 -1
- package/package.json +7 -7
package/dist/worker.cjs
CHANGED
|
@@ -533,7 +533,7 @@ class Renderer {
|
|
|
533
533
|
partRender() {
|
|
534
534
|
const { canvas, updateBlocks: list } = this;
|
|
535
535
|
if (!list)
|
|
536
|
-
return
|
|
536
|
+
return;
|
|
537
537
|
this.mergeBlocks();
|
|
538
538
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
539
539
|
this.clipRender(block); });
|
|
@@ -1924,7 +1924,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1924
1924
|
rows.forEach(row => {
|
|
1925
1925
|
if (row.words) {
|
|
1926
1926
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
1927
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
1927
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
1928
1928
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
1929
1929
|
if (row.isOverflow && !letterSpacing)
|
|
1930
1930
|
row.textMode = true;
|
|
@@ -1946,7 +1946,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1946
1946
|
else {
|
|
1947
1947
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
1948
1948
|
}
|
|
1949
|
-
if (!row.paraEnd
|
|
1949
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
1950
1950
|
charX += addWordWidth;
|
|
1951
1951
|
row.width += addWordWidth;
|
|
1952
1952
|
}
|
package/dist/worker.esm.js
CHANGED
|
@@ -534,7 +534,7 @@ class Renderer {
|
|
|
534
534
|
partRender() {
|
|
535
535
|
const { canvas, updateBlocks: list } = this;
|
|
536
536
|
if (!list)
|
|
537
|
-
return
|
|
537
|
+
return;
|
|
538
538
|
this.mergeBlocks();
|
|
539
539
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
540
540
|
this.clipRender(block); });
|
|
@@ -1925,7 +1925,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1925
1925
|
rows.forEach(row => {
|
|
1926
1926
|
if (row.words) {
|
|
1927
1927
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
1928
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
1928
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
1929
1929
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
1930
1930
|
if (row.isOverflow && !letterSpacing)
|
|
1931
1931
|
row.textMode = true;
|
|
@@ -1947,7 +1947,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1947
1947
|
else {
|
|
1948
1948
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
1949
1949
|
}
|
|
1950
|
-
if (!row.paraEnd
|
|
1950
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
1951
1951
|
charX += addWordWidth;
|
|
1952
1952
|
row.width += addWordWidth;
|
|
1953
1953
|
}
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as p,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as M,Export as C,Group as D,TextConvert as I,Paint as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class G 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:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:Y}=a;function z(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:Y(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:Y(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:U}=navigator;U.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):U.indexOf("Safari")>-1&&-1===U.indexOf("Chrome")&&(e.fullImageShadow=!0),U.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):U.indexOf("Mac")>-1?e.os="Mac":U.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.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(l.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.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:q,updateBounds:X,updateAllWorldOpacity:j}=f,{pushAllChildBranch:V,pushAllParent:H}=_;const{worldBounds:Q}=g,Z={x:0,y:0,width:1e5,height:1e5};class ${constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Z):this.afterBounds.setListWithFn(t,Q),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:J,updateAllChange:K}=f,tt=w.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.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:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&V(t,e),H(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),H(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||X(i[t])}X(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&j(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),et.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){J(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new $([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new $(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=w.get("Renderer");class it{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,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(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,nt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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 nt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new p(i);n.save(),s&&!w.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.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(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new p(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(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||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function st(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function ot(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":at("inside",t,s,e,n);break;case"outside":at("outside",t,s,e,n)}}function at(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function dt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}function lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(i,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,n)=>new it(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=et.fullLayout;const{getSpread:ct,getOuterOf:ht,getByMove:ut,getIntersectData:ft}=B;let _t;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:T.string(a,r)};case"image":return O.image(n,t,e,i,!_t||!_t[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const gt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),_t=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=pt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?st(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&O.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?st(e,n):s?n.fill(s):n.fill())},fillText:st,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&<(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n),i.__useArrow&<(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),dt(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ot,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ft(i?ct(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ht(s,a),o=ut(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let wt={};const{get:yt,rotateOfOuter:mt,translate:vt,scaleOfOuter:xt,scale:bt,rotate:Bt}=R;function Rt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),bt(r,s,o),a&&mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function kt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),s&&bt(r,s,o),a&&Bt(r,a),t.transform=r}function Et(t,e,n,i,s,o,a,r,d,l){const c=yt();if(d)if("center"===l)mt(c,{x:n/2,y:i/2},d);else switch(Bt(c,d),d){case 90:vt(c,i,0);break;case 180:vt(c,n,i);break;case 270:vt(c,0,n)}wt.x=e.x+s,wt.y=e.y+o,vt(c,wt.x,wt.y),a&&xt(c,wt,a,r),t.transform=c}const{get:St,translate:Lt}=R,At=new p,Wt={},Ot={};function Tt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Mt(n,i,e)}function Mt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===i&&e.height===s,_={mode:a},p="center"!==r&&(h||0)%180==90,g=p?s:i,w=p?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Ot),y=Ot.scaleX,m=Ot.scaleY);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Wt,!0),v+=Wt.x,x+=Wt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&kt(_,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Et(_,e,i,s,v,x,y,m,h,r),u||(_.repeat="repeat");break;default:y&&Rt(_,e,v,x,y,m,h)}return _.transform||(e.x||e.y)&&(_.transform=St(),Lt(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=i,_.height=s,o&&(_.opacity=o),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Ct,Dt=new p;const{isSame:It}=B;function Pt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Tt(s,i,n,o),!0}function Ft(t,e){zt(t,S.LOAD,e)}function Gt(t,e){zt(t,S.LOADED,e)}function Yt(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,S.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function Ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Nt,scale:qt,copy:Xt}=R,{ceil:jt,abs:Vt}=Math;function Ht(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Nt(),Xt(l,p),qt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Nt(),p&&Xt(l,p)),qt(l,1/s,1/o));const m=t.getCanvas(jt(c)||1,jt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Qt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Ct&&n===Ct.paint&&It(i,Ct.boxBounds)?o=Ct.leafPaint:(o={type:n.type,image:r},Ct=r.use>1?{leafPaint:o,paint:n,boxBounds:Dt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Pt(t,e,n,r,o,i),s&&(Ft(t,a),Gt(t,a))):r.error?s&&Yt(t,a,r.error):(s&&(Ut(t,!0),Ft(t,a)),o.loadId=r.load((()=>{Ut(t,!1),t.destroyed||(Pt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Ut(t,!1),Yt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!C.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=Zt(o)*r,n*=Zt(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||C.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||C.running?Ht(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ht(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Ht,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,x.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Tt,getPatternData:Mt,fillOrFitMode:Rt,clipMode:kt,repeatMode:Et},{toPoint:Jt}=L,Kt={},te={};function ee(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),T.string(i,n)):t.addColorStop(i.offset,T.string(i.color,n))}}const{getAngle:ne,getDistance:ie}=A,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=L,de={},le={};function ce(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ne(e,n);o=se(),s?(ae(o,e,a/r*(i||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(i||1)),oe(o,e,t))}return o}const{getDistance:he}=A,{toPoint:ue}=L,fe={},_e={};const pe={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Jt(i||"top",n,Kt),Jt(s||"bottom",n,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;re(i||"center",n,de),re(s||"bottom",n,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ie(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,de,le,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(i||"center",n,fe),ue(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,_e));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,fe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function ve(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-a.x,ye.y+=n.y-a.y,i){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,a,i?ye:n)}const{toOffsetOutBounds:xe}=B,be={};const Be={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;we(l,me),r.forEach(((r,p)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;xe(l,be),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Re}=g;function ke(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,o);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(ke(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ee(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Re(n,e)||n.__render(s||t,e);ke(this,a,t,s,i,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",We=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 Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=Oe(Le),De=Oe(Ae),Ie=Oe("- —/~|┆·");var Pe;!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"}(Pe||(Pe={}));const{Letter:Fe,Single:Ge,Before:Ye,After:ze,Symbol:Ue,Break:Ne}=Pe;function qe(t){return Te[t]?Fe:Ie[t]?Ne:Me[t]?Ye:Ce[t]?ze:De[t]?Ue:We.test(t)?Ge:Fe}const Xe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function je(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ve}=Xe,{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Pe;let tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn=[];function mn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function vn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function xn(){_n&&(pn.paraNumber++,en.paraStart=!0,_n=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width?Ve(en):wn&&bn(),yn.push(en),en={words:[]},sn=0}function bn(){sn>(pn.maxWidth||0)&&(pn.maxWidth=sn)}const Bn=0,Rn=1,kn=2;const{top:En,right:Sn,bottom:Ln,left:An}=W;function Wn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const On={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[An],o-=l[Sn]+l[An]):n.autoSizeAlign||(i=l[An]),a?(s=l[En],a-=l[En]+l[Ln]):n.autoSizeAlign||(s=l[En]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){pn=t,yn=t.rows,gn=t.bounds,wn=!gn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)an=n[i],"\n"===an?(nn&&vn(),en.paraEnd=!0,xn(),_n=!0):(cn=qe(an),cn===He&&"none"!==a&&(an=je(an,a,!nn)),rn=r.measureText(an).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===He)||hn===Qe&&cn!==$e,fn=!(cn!==Ze&&cn!==Qe||hn!==Je&&hn!==$e),on=_n&&o?d-o:d,t&&d&&sn+nn+rn>on&&(e?(nn&&vn(),sn&&xn()):(fn||(fn=cn===He&&hn==$e),un||fn||cn===Ke||cn===Ze||cn===Qe||nn+rn>on?(nn&&vn(),sn&&xn()):sn&&xn()))," "===an&&!0!==_n&&sn+nn===0||(cn===Ke?(" "===an&&nn&&vn(),mn(an,rn),vn()):un||fn?(nn&&vn(),mn(an,rn)):mn(an,rn)),hn=cn);nn&&vn(),sn&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{pn.paraNumber++,sn=r.measureText(t).width,yn.push({x:o||0,text:t,width:sn,paraStart:!0}),wn&&bn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Wn(e,"x",t[An]);break;case"right":Wn(e,"x",-t[Sn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Wn(e,"y",t[En]);break;case"bottom":Wn(e,"y",-t[Ln])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:_,height:p}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>p)g=Math.max(p,s),t.overflow=n.length;else if(p||h)switch(l){case"middle":f+=(p-g)/2;break;case"bottom":f+=p-g}w+=f;let y,m,v,x=_||h?_:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<_||y.width>_&&!r)switch(d){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+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Bn:l>.01?Rn:kn,t.isOverflow&&!r&&(t.textMode=!0),h===kn?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Rn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Tn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!T.object)return t;t=T.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(I,On),Object.assign(T,Tn),Object.assign(P,gt),Object.assign(O,$t),Object.assign(M,pe),Object.assign(F,Be),z();export{et as Layouter,G as LeaferCanvas,it as Renderer,N as Watcher,z as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as n,Creator as i,LeaferImage as s,defineKey as o,FileHelper as a,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as _,Bounds as p,LeafBoundsHelper as g,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,MatrixHelper as R,MathHelper as k,AlignHelper as E,ImageEvent as S,AroundHelper as L,PointHelper as A,Direction4 as W}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as O,ColorConvert as T,PaintGradient as M,Export as C,Group as D,TextConvert as I,Paint as P,Effect as F}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class G 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:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}n(OffscreenCanvasRenderingContext2D.prototype),n(Path2D.prototype);const{mineType:Y}=a;function z(t,n){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:Y(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:Y(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},e.canvas=i.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(i,{canvas:(t,e)=>new G(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},o(e,"devicePixelRatio",{get:()=>1});const{userAgent:U}=navigator;U.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):U.indexOf("Safari")>-1&&-1===U.indexOf("Chrome")&&(e.fullImageShadow=!0),U.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):U.indexOf("Mac")>-1?e.os="Mac":U.indexOf("Linux")>-1&&(e.os="Linux");class N{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.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(l.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,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([c.ADD,c.REMOVE],this.__onChildEvent,this),t.on_(h.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:q,updateBounds:X,updateAllWorldOpacity:j}=f,{pushAllChildBranch:V,pushAllParent:H}=_;const{worldBounds:Q}=g,Z={x:0,y:0,width:1e5,height:1e5};class ${constructor(t){this.updatedBounds=new p,this.beforeBounds=new p,this.afterBounds=new p,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,Q)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(Z):this.afterBounds.setListWithFn(t,Q),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:J,updateAllChange:K}=f,tt=w.get("Layouter");class et{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){tt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?tt.warn("layouting"):this.times>3?tt.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:n,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:a}=m,r=this.getBlocks(i);r.forEach((t=>t.setBefore())),n.emitEvent(new m(s,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(q(t,!0),e.add(t),t.isBranch&&V(t,e),H(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),H(t,e)))}))}(i,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||X(i[t])}X(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&j(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),n.emitEvent(new m(o,r,this.times)),n.emitEvent(new m(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:n,LAYOUT:i,AFTER:s}=m,o=this.getBlocks(new r(e));e.emitEvent(new m(n,o,this.times)),et.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new m(i,o,this.times)),e.emitEvent(new m(s,o,this.times)),this.addBlocks(o),v.end(t)}static fullLayout(t){J(t,!0),t.isBranch?_.updateBounds(t):f.updateBounds(t),K(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new $([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new $(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(h.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const nt=w.get("Renderer");class it{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,n&&(this.config=d.default(n,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(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new p,nt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,nt.error(t)}nt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return nt.warn("rendering");if(this.times>3)return nt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new p,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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:n}=this,i=t.getIntersect(n.bounds),s=t.includes(this.target.__world),o=new p(i);n.save(),s&&!w.showRepaint?n.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(i,!0),n.clipWorld(i,!0)),this.__render(i,s,o),n.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,n){const i=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=n=n||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),w.showHitView&&this.renderHitView(i),w.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new p;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.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(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:n}=t.old;if(!new p(0,0,e,n).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new p(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||nt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,n){this.target.emitEvent(new l(t,this.times,e,n))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function st(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function ot(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?dt(t,!0,e,n):rt(e,n);break;case"inside":at("inside",t,s,e,n);break;case"outside":at("outside",t,s,e,n)}}function at(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?dt(e,!0,i,r):rt(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",st(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function rt(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function dt(t,e,n,i){let s;for(let o=0,a=t.length;o<a;o++)s=t[o],s.image&&O.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?rt(n,i):i.stroke(),i.restoreBlendMode()):e?rt(n,i):i.stroke())}function lt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(i,{watcher:(t,e)=>new N(t,e),layouter:(t,e)=>new et(t,e),renderer:(t,e,n)=>new it(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),e.layout=et.fullLayout;const{getSpread:ct,getOuterOf:ht,getByMove:ut,getIntersectData:ft}=B;let _t;function pt(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:i}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:a,opacity:r}=e;return{type:s,blendMode:o,style:T.string(a,r)};case"image":return O.image(n,t,e,i,!_t||!_t[e.url]);case"linear":return M.linearGradient(e,i);case"radial":return M.radialGradient(e,i);case"angular":return M.conicGradient(e,i);default:return void 0!==e.r?{type:"solid",style:T.string(e)}:void 0}}const gt={compute:function(t,e){const n=e.__,i=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),_t=O.recycleImage(t,n);for(let n,s=0,a=o.length;s<a;s++)n=pt(t,o[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?st(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)i=t[a],i.image&&O.checkImage(e,n,i,!o)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),o?st(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?st(e,n):s?n.fill(s):n.fill())},fillText:st,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&<(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)ot(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),dt(t,!1,e,n),i.__useArrow&<(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),dt(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),dt(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:ot,drawTextStroke:rt,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,d,{scaleX:l,scaleY:c}=s;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(s))d=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=ft(i?ct(e.bounds,l===c?i*l:[i*c,i*l]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=ht(s,a),o=ut(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let wt={};const{get:yt,rotateOfOuter:mt,translate:vt,scaleOfOuter:xt,scale:bt,rotate:Bt}=R;function Rt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),bt(r,s,o),a&&mt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function kt(t,e,n,i,s,o,a){const r=yt();vt(r,e.x+n,e.y+i),s&&bt(r,s,o),a&&Bt(r,a),t.transform=r}function Et(t,e,n,i,s,o,a,r,d,l){const c=yt();if(d)if("center"===l)mt(c,{x:n/2,y:i/2},d);else switch(Bt(c,d),d){case 90:vt(c,i,0);break;case 180:vt(c,n,i);break;case 270:vt(c,0,n)}wt.x=e.x+s,wt.y=e.y+o,vt(c,wt.x,wt.y),a&&xt(c,wt,a,r),t.transform=c}const{get:St,translate:Lt}=R,At=new p,Wt={},Ot={};function Tt(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Mt(n,i,e)}function Mt(t,e,n){let{width:i,height:s}=n;t.padding&&(e=At.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:d,scale:l,size:c,rotation:h,repeat:u}=t,f=e.width===i&&e.height===s,_={mode:a},p="center"!==r&&(h||0)%180==90,g=p?s:i,w=p?i:s;let y,m,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(l||c)&&(k.getScaleData(l,c,n,Ot),y=Ot.scaleX,m=Ot.scaleY);else if(!f||h){const t=e.width/g,n=e.height/w;y=m="fit"===a?Math.min(t,n):Math.max(t,n),v+=(e.width-i*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:g,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Wt,!0),v+=Wt.x,x+=Wt.y}switch(d&&(v+=d.x,x+=d.y),a){case"stretch":f||(i=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||h)&&kt(_,e,v,x,y,m,h);break;case"repeat":(!f||y||h)&&Et(_,e,i,s,v,x,y,m,h,r),u||(_.repeat="repeat");break;default:y&&Rt(_,e,v,x,y,m,h)}return _.transform||(e.x||e.y)&&(_.transform=St(),Lt(_.transform,e.x,e.y)),y&&"stretch"!==a&&(_.scaleX=y,_.scaleY=m),_.width=i,_.height=s,o&&(_.opacity=o),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),_}let Ct,Dt=new p;const{isSame:It}=B;function Pt(t,e,n,i,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||Tt(s,i,n,o),!0}function Ft(t,e){zt(t,S.LOAD,e)}function Gt(t,e){zt(t,S.LOADED,e)}function Yt(t,e,n){e.error=n,t.forceUpdate("surface"),zt(t,S.ERROR,e)}function zt(t,e,n){t.hasEvent(e)&&t.emitEvent(new S(e,n))}function Ut(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:Nt,scale:qt,copy:Xt}=R,{ceil:jt,abs:Vt}=Math;function Ht(t,n,i){let{scaleX:s,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||t.destroyed)return!1;{s=Vt(s),o=Vt(o);const{image:t,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:_,transform:p,repeat:g}=r;u&&(l=Nt(),Xt(l,p),qt(l,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,h*=o;const w=c*h;if(!g&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,o/=d,c/=d,h/=d),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(l||(l=Nt(),p&&Xt(l,p)),qt(l,1/s,1/o));const m=t.getCanvas(jt(c)||1,jt(h)||1,_),v=t.getPattern(m,g||e.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=a,!0}}function Qt(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(t){try{d(i.next(t))}catch(t){o(t)}}function r(t){try{d(i.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Zt}=Math;const $t={image:function(t,e,n,i,s){let o,a;const r=x.get(n);return Ct&&n===Ct.paint&&It(i,Ct.boxBounds)?o=Ct.leafPaint:(o={type:n.type,image:r},Ct=r.use>1?{leafPaint:o,paint:n,boxBounds:Dt.set(i)}:null),(s||r.loading)&&(a={image:r,attrName:e,attrValue:n}),r.ready?(Pt(t,e,n,r,o,i),s&&(Ft(t,a),Gt(t,a))):r.error?s&&Yt(t,a,r.error):(s&&(Ut(t,!0),Ft(t,a)),o.loadId=r.load((()=>{Ut(t,!1),t.destroyed||(Pt(t,e,n,r,o,i)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Gt(t,a)),o.loadId=null}),(e=>{Ut(t,!1),Yt(t,a,e),o.loadId=null}))),o},checkImage:function(t,n,i,s){const{scaleX:o,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=n;if(!i.data||i.patternId===o+"-"+a+"-"+r&&!C.running)return!1;{const{data:d}=i;if(s)if(d.repeat)s=!1;else{let{width:t,height:n}=d;t*=Zt(o)*r,n*=Zt(a)*r,d.scaleX&&(t*=d.scaleX,n*=d.scaleY),s=t*n>e.image.maxCacheSize||C.running}return s?(n.save(),t.windingRule?n.clip(t.windingRule):n.clip(),i.blendMode&&(n.blendMode=i.blendMode),d.opacity&&(n.opacity*=d.opacity),d.transform&&n.transform(d.transform),n.drawImage(i.image.view,0,0,d.width,d.height),n.restore(),!0):(!i.style||i.sync||C.running?Ht(t,i,r):i.patternTask||(i.patternTask=x.patternTasker.add((()=>Qt(this,void 0,void 0,(function*(){i.patternTask=null,n.bounds.hit(t.__nowWorld)&&Ht(t,i,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:Ht,recycleImage:function(t,e){const n=e["_"+t];if(n instanceof Array){let i,s,o,a;for(let r=0,d=n.length;r<d;r++)i=n[r].image,a=i&&i.url,a&&(s||(s={}),s[a]=!0,x.recycle(i),i.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),i.unload(n[r].loadId,!o.some((t=>t.url===a)))));return s}return null},createData:Tt,getPatternData:Mt,fillOrFitMode:Rt,clipMode:kt,repeatMode:Et},{toPoint:Jt}=L,Kt={},te={};function ee(t,e,n){if(e){let i;for(let s=0,o=e.length;s<o;s++)i=e[s],"string"==typeof i?t.addColorStop(s/(o-1),T.string(i,n)):t.addColorStop(i.offset,T.string(i.color,n))}}const{getAngle:ne,getDistance:ie}=A,{get:se,rotateOfOuter:oe,scaleOfOuter:ae}=R,{toPoint:re}=L,de={},le={};function ce(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=ne(e,n);o=se(),s?(ae(o,e,a/r*(i||1),1),oe(o,e,t+90)):(ae(o,e,1,a/r*(i||1)),oe(o,e,t))}return o}const{getDistance:he}=A,{toPoint:ue}=L,fe={},_e={};const pe={linearGradient:function(t,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=t;Jt(i||"top",n,Kt),Jt(s||"bottom",n,te);const d=e.canvas.createLinearGradient(Kt.x,Kt.y,te.x,te.y);ee(d,t.stops,r);const l={type:o,style:d};return a&&(l.blendMode=a),l},radialGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;re(i||"center",n,de),re(s||"bottom",n,le);const l=e.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ie(de,le));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,de,le,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(t,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:d}=t;ue(i||"center",n,fe),ue(s||"bottom",n,_e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,fe.x,fe.y):e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,he(fe,_e));ee(l,t.stops,a);const c={type:o,style:l},h=ce(n,fe,_e,d||1,e.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:ce},{copy:ge,toOffsetOutBounds:we}=B,ye={},me={};function ve(t,n,i,s){const{bounds:o,shapeBounds:a}=s;if(e.fullImageShadow){if(ge(ye,t.bounds),ye.x+=n.x-a.x,ye.y+=n.y-a.y,i){const{matrix:t}=s;ye.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),ye.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),ye.width*=i,ye.height*=i}t.copyWorld(s.canvas,t.bounds,ye)}else i&&(ge(ye,n),ye.x-=n.width/2*(i-1),ye.y-=n.height/2*(i-1),ye.width*=i,ye.height*=i),t.copyWorld(s.canvas,a,i?ye:n)}const{toOffsetOutBounds:xe}=B,be={};const Be={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;we(l,me),r.forEach(((r,p)=>{f.setWorldShadow(me.offsetX+r.x*h,me.offsetY+r.y*u,r.blur*h,r.color),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,me,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),i=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),_=r.length-1;xe(l,be),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(be.offsetX+r.x*h,be.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ve(f,be,s,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,a.renderBounds,r.blendMode),_&&p<_&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Re}=g;function ke(t,e,n,i,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Se(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Se(t,n,i,o);break;case"path":n.restore()}}function Ee(t){return t.getSameCanvas(!1,!0)}function Se(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}D.prototype.__renderMask=function(t,e){let n,i,s,o,a,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(a&&(ke(this,a,t,s,i,o),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Ee(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",i||(i=Ee(t)),s||(s=Ee(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Re(n,e)||n.__render(s||t,e);ke(this,a,t,s,i,o)};const Le=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ae=Le+"_#~&*+\\=|≮≯≈≠=…",We=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 Oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=Oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=Oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ce=Oe(Le),De=Oe(Ae),Ie=Oe("- —/~|┆·");var Pe;!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"}(Pe||(Pe={}));const{Letter:Fe,Single:Ge,Before:Ye,After:ze,Symbol:Ue,Break:Ne}=Pe;function qe(t){return Te[t]?Fe:Ie[t]?Ne:Me[t]?Ye:Ce[t]?ze:De[t]?Ue:We.test(t)?Ge:Fe}const Xe={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function je(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ve}=Xe,{Letter:He,Single:Qe,Before:Ze,After:$e,Symbol:Je,Break:Ke}=Pe;let tn,en,nn,sn,on,an,rn,dn,ln,cn,hn,un,fn,_n,pn,gn,wn,yn=[];function mn(t,e){ln&&!dn&&(dn=ln),tn.data.push({char:t,width:e}),nn+=e}function vn(){sn+=nn,tn.width=nn,en.words.push(tn),tn={data:[]},nn=0}function xn(){_n&&(pn.paraNumber++,en.paraStart=!0,_n=!1),ln&&(en.startCharSize=dn,en.endCharSize=ln,dn=0),en.width=sn,gn.width?Ve(en):wn&&bn(),yn.push(en),en={words:[]},sn=0}function bn(){sn>(pn.maxWidth||0)&&(pn.maxWidth=sn)}const Bn=0,Rn=1,kn=2;const{top:En,right:Sn,bottom:Ln,left:An}=W;function Wn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const On={getDrawData:function(t,n){"string"!=typeof t&&(t=String(t));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(i=l[An],o-=l[Sn]+l[An]):n.autoSizeAlign||(i=l[An]),a?(s=l[En],a-=l[En]+l[Ln]):n.autoSizeAlign||(s=l[En]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,n,i){pn=t,yn=t.rows,gn=t.bounds,wn=!gn.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=e,{width:d,height:l}=gn;if(d||l||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;_n=!0,hn=null,dn=rn=ln=nn=sn=0,tn={data:[]},en={words:[]};for(let i=0,l=n.length;i<l;i++)an=n[i],"\n"===an?(nn&&vn(),en.paraEnd=!0,xn(),_n=!0):(cn=qe(an),cn===He&&"none"!==a&&(an=je(an,a,!nn)),rn=r.measureText(an).width,s&&(s<0&&(ln=rn),rn+=s),un=cn===Qe&&(hn===Qe||hn===He)||hn===Qe&&cn!==$e,fn=!(cn!==Ze&&cn!==Qe||hn!==Je&&hn!==$e),on=_n&&o?d-o:d,t&&d&&sn+nn+rn>on&&(e?(nn&&vn(),sn&&xn()):(fn||(fn=cn===He&&hn==$e),un||fn||cn===Ke||cn===Ze||cn===Qe||nn+rn>on?(nn&&vn(),sn&&xn()):sn&&xn()))," "===an&&!0!==_n&&sn+nn===0||(cn===Ke?(" "===an&&nn&&vn(),mn(an,rn),vn()):un||fn?(nn&&vn(),mn(an,rn)):mn(an,rn)),hn=cn);nn&&vn(),sn&&xn(),yn.length>0&&(yn[yn.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{pn.paraNumber++,sn=r.measureText(t).width,yn.push({x:o||0,text:t,width:sn,paraStart:!0}),wn&&bn()}))}(c,t,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Wn(e,"x",t[An]);break;case"right":Wn(e,"x",-t[Sn])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Wn(e,"y",t[En]);break;case"bottom":Wn(e,"y",-t[Ln])}}(l,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:_,height:p}=i,g=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&g>p)g=Math.max(p,s),t.overflow=n.length;else if(p||h)switch(l){case"middle":f+=(p-g)/2;break;case"bottom":f+=p-g}w+=f;let y,m,v,x=_||h?_:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<_||y.width>_&&!r)switch(d){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+=s,t.overflow>o&&w>g&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,a<0&&(y.width<0?(v=-y.width+e.fontSize+a,m-=v,v+=e.fontSize):v-=a),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&_&&_<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=g}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let d,l,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,l=n&&("justify"===o||"both"===o)&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Bn:l>.01?Rn:kn,t.isOverflow&&!r&&(t.textMode=!0),h===kn?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Rn?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==o||(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(t,n,i,s){if(!s)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,c=i+s-l;("none"===n.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let n=e.data.length-1;for(let i=n;i>-1&&(t=e.data[i],d=t.x+t.width,!(i===n&&d<c));i--){if(d<c&&" "!==t.char){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,n,i,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Tn={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!T.object)return t;t=T.object(t)}let i=void 0===t.a?1:t.a;n&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(I,On),Object.assign(T,Tn),Object.assign(P,gt),Object.assign(O,$t),Object.assign(M,pe),Object.assign(F,Be),z();export{et as Layouter,G as LeaferCanvas,it as Renderer,N as Watcher,z as useCanvas};
|
package/dist/worker.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
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6016
6016
|
get allowBackgroundColor() { return true; }
|
|
@@ -6542,7 +6542,7 @@ var LeaferUI = (function (exports) {
|
|
|
6542
6542
|
partRender() {
|
|
6543
6543
|
const { canvas, updateBlocks: list } = this;
|
|
6544
6544
|
if (!list)
|
|
6545
|
-
return
|
|
6545
|
+
return;
|
|
6546
6546
|
this.mergeBlocks();
|
|
6547
6547
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
6548
6548
|
this.clipRender(block); });
|
|
@@ -7242,7 +7242,7 @@ var LeaferUI = (function (exports) {
|
|
|
7242
7242
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7243
7243
|
return Plugin.need('animate');
|
|
7244
7244
|
}
|
|
7245
|
-
killAnimate(_type,
|
|
7245
|
+
killAnimate(_type, _nextStyle) { }
|
|
7246
7246
|
export(_filename, _options) {
|
|
7247
7247
|
return Plugin.need('export');
|
|
7248
7248
|
}
|
|
@@ -7738,8 +7738,6 @@ var LeaferUI = (function (exports) {
|
|
|
7738
7738
|
this.created = true;
|
|
7739
7739
|
}
|
|
7740
7740
|
__onReady() {
|
|
7741
|
-
if (this.ready)
|
|
7742
|
-
return;
|
|
7743
7741
|
this.ready = true;
|
|
7744
7742
|
this.emitLeafer(LeaferEvent.BEFORE_READY);
|
|
7745
7743
|
this.emitLeafer(LeaferEvent.READY);
|
|
@@ -7753,6 +7751,20 @@ var LeaferUI = (function (exports) {
|
|
|
7753
7751
|
this.emitLeafer(LeaferEvent.VIEW_READY);
|
|
7754
7752
|
WaitHelper.run(this.__viewReadyWait);
|
|
7755
7753
|
}
|
|
7754
|
+
__onLayoutEnd() {
|
|
7755
|
+
const { grow, growWidth, growHeight } = this.config;
|
|
7756
|
+
if (grow) {
|
|
7757
|
+
let { width, height, pixelRatio } = this;
|
|
7758
|
+
const bounds = grow === 'box' ? this.worldBoxBounds : this.__world;
|
|
7759
|
+
if (growWidth !== false)
|
|
7760
|
+
width = Math.max(1, bounds.x + bounds.width);
|
|
7761
|
+
if (growHeight !== false)
|
|
7762
|
+
height = Math.max(1, bounds.y + bounds.height);
|
|
7763
|
+
this.__doResize({ width, height, pixelRatio });
|
|
7764
|
+
}
|
|
7765
|
+
if (!this.ready)
|
|
7766
|
+
this.__onReady();
|
|
7767
|
+
}
|
|
7756
7768
|
__onNextRender() {
|
|
7757
7769
|
if (this.viewReady) {
|
|
7758
7770
|
WaitHelper.run(this.__nextRenderWait);
|
|
@@ -7846,10 +7858,9 @@ var LeaferUI = (function (exports) {
|
|
|
7846
7858
|
const runId = Run.start('FirstCreate ' + this.innerName);
|
|
7847
7859
|
this.once(LeaferEvent.START, () => Run.end(runId));
|
|
7848
7860
|
this.once(LayoutEvent.START, () => this.updateLazyBounds());
|
|
7849
|
-
this.once(LayoutEvent.END, () => this.__onReady());
|
|
7850
7861
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
7851
7862
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
7852
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
7863
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(LayoutEvent.END, this.__onLayoutEnd, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
7853
7864
|
}
|
|
7854
7865
|
__removeListenEvents() {
|
|
7855
7866
|
this.off_(this.__eventIds);
|
|
@@ -9808,7 +9819,7 @@ var LeaferUI = (function (exports) {
|
|
|
9808
9819
|
rows.forEach(row => {
|
|
9809
9820
|
if (row.words) {
|
|
9810
9821
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
9811
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
9822
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
9812
9823
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
9813
9824
|
if (row.isOverflow && !letterSpacing)
|
|
9814
9825
|
row.textMode = true;
|
|
@@ -9830,7 +9841,7 @@ var LeaferUI = (function (exports) {
|
|
|
9830
9841
|
else {
|
|
9831
9842
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
9832
9843
|
}
|
|
9833
|
-
if (!row.paraEnd
|
|
9844
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
9834
9845
|
charX += addWordWidth;
|
|
9835
9846
|
row.width += addWordWidth;
|
|
9836
9847
|
}
|
package/dist/worker.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a}=t.FileHelper;function i(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,s)=>{t.convertToBlob({type:a(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,a)=>{let i=new XMLHttpRequest;i.open("GET",t.Platform.image.getRealURL(e),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then((t=>{n(t)})).catch((t=>{a(t)}))},i.onerror=t=>a(t),i.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):s.indexOf("Safari")>-1&&-1===s.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?t.Platform.os="Mac":s.indexOf("Linux")>-1&&(t.Platform.os="Linux");class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:r,updateBounds:d,updateAllWorldOpacity:l}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),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:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:s,LAYOUT:o,AFTER:u}=t.LayoutEvent,f=this.getBlocks(i);f.forEach((t=>t.setBefore())),a.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(i,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){a=n.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||d(a[t])}d(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&l(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),a.emitEvent(new t.LayoutEvent(o,f,this.times)),a.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:a,LAYOUT:i,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,o,this.times)),y.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(i,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const m=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,a&&(this.config=t.DataHelper.default(a,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(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,m.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,m.error(t)}m.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return m.warn("rendering");if(this.times>3)return m.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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 m.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:a}=this,i=e.getIntersect(a.bounds),s=e.includes(this.target.__world),o=new t.Bounds(i);a.save(),s&&!t.Debug.showRepaint?a.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),a.clearWorld(i,!0),a.clipWorld(i,!0)),this.__render(i,s,o),a.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,a){const i=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,i),this.renderBounds=a=a||e,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),t.Debug.showHitView&&this.renderHitView(i),t.Debug.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(a)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:a}=e.old;if(!new t.Bounds(0,0,n,a).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||m.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,a){this.target.emitEvent(new t.RenderEvent(e,this.times,n,a))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:a,decorationY:i,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=a.length;t<o;t++)n=a[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),i&&e.fillRect(n.x,n.y+i,n.width,s)}function b(t,e,n){const{strokeAlign:a}=e.__,i="string"!=typeof t;switch(a){case"center":n.setStroke(i?void 0:t,e.__.strokeWidth,e.__),i?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,i,e,n);break;case"outside":B("outside",t,i,e,n)}}function B(t,e,n,a,i){const{__strokeWidth:s,__font:o}=a.__,r=i.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,a.__),r.font=o,n?R(e,!0,a,r):E(a,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(a,r),r.blendMode="normal",a.__worldFlipped?i.copyWorldByReset(r,a.__nowWorld):i.copyWorldToInner(r,a.__nowWorld,a.__layout.renderBounds),r.recycle(a.__nowWorld)}function E(t,e){let n;const{rows:a,decorationY:i,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=a.length;t<o;t++)n=a[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),i&&e.strokeRect(n.x,n.y+i,n.width,s)}function R(t,n,a,i){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&e.PaintImage.checkImage(a,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),n?E(a,i):i.stroke(),i.restoreBlendMode()):n?E(a,i):i.stroke())}function L(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,a)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let W;function C(t,n,a){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:i}=a.__layout;switch(n.type){case"solid":let{type:s,blendMode:o,color:r,opacity:d}=n;return{type:s,blendMode:o,style:e.ColorConvert.string(r,d)};case"image":return e.PaintImage.image(a,t,n,i,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,i);case"radial":return e.PaintGradient.radialGradient(n,i);case"angular":return e.PaintGradient.conicGradient(n,i);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const O={compute:function(t,n){const a=n.__,i=[];let s,o=a.__input[t];o instanceof Array||(o=[o]),W=e.PaintImage.recycleImage(t,a);for(let e,a=0,s=o.length;a<s;a++)e=C(t,o[a],n),e&&i.push(e);a["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?a.__pixelFill=s:a.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,a){let i;const{windingRule:s,__font:o}=n.__;for(let r=0,d=t.length;r<d;r++)i=t[r],i.image&&e.PaintImage.checkImage(n,a,i,!o)||i.style&&(a.fillStyle=i.style,i.transform?(a.save(),a.transform(i.transform),i.blendMode&&(a.blendMode=i.blendMode),o?x(n,a):s?a.fill(s):a.fill(),a.restore()):i.blendMode?(a.saveBlendMode(i.blendMode),o?x(n,a):s?a.fill(s):a.fill(),a.restoreBlendMode()):o?x(n,a):s?a.fill(s):a.fill())},fillText:x,stroke:function(t,e,n){const a=e.__,{__strokeWidth:i,strokeAlign:s,__font:o}=a;if(i)if(o)b(t,e,n);else switch(s){case"center":n.setStroke(t,i,a),n.stroke(),a.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(t,2*i,a),a.windingRule?n.clip(a.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*i,a),e.__drawRenderPath(s),s.stroke(),a.windingRule?s.clip(a.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const a=e.__,{__strokeWidth:i,strokeAlign:s,__font:o}=a;if(i)if(o)b(t,e,n);else switch(s){case"center":n.setStroke(void 0,i,a),R(t,!1,e,n),a.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*i,a),a.windingRule?n.clip(a.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*i,a),R(t,!1,e,o),a.windingRule?o.clip(a.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const a=e.getSameCanvas(),i=t.__nowWorld;let s,o,r,d,{scaleX:l,scaleY:c}=i;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(i))d=a,s=r=i;else{const{renderShapeSpread:a}=t.__layout,h=A(a?k(e.bounds,l===c?a*l:[a*c,a*l]):e.bounds,i);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(i,o),s=P(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(a,n),{canvas:a,matrix:o,bounds:s,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let M={};const{get:T,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:G}=t.MatrixHelper;function j(t,e,n,a,i,s,o){const r=T();D(r,e.x+n,e.y+a),F(r,i,s),o&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Y(t,e,n,a,i,s,o){const r=T();D(r,e.x+n,e.y+a),i&&F(r,i,s),o&&G(r,o),t.transform=r}function z(t,e,n,a,i,s,o,r,d,l){const c=T();if(d)if("center"===l)I(c,{x:n/2,y:a/2},d);else switch(G(c,d),d){case 90:D(c,a,0);break;case 180:D(c,n,a);break;case 270:D(c,0,n)}M.x=e.x+i,M.y=e.y+s,D(c,M.x,M.y),o&&H(c,M,o,r),t.transform=c}const{get:q,translate:U}=t.MatrixHelper,N=new t.Bounds,X={},V={};function Q(t,e,n,a){const{blendMode:i,sync:s}=n;i&&(t.blendMode=i),s&&(t.sync=s),t.data=Z(n,a,e)}function Z(e,n,a){let{width:i,height:s}=a;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:d,offset:l,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===i&&n.height===s,g={mode:r},_="center"!==d&&(u||0)%180==90,w=_?s:i,y=_?i:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,a,V),m=V.scaleX,v=V.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-i*m)/2,b+=(n.height-s*v)/2}if(d){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(d,e,n,X,!0),x+=X.x,b+=X.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":p||(i=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&Y(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&z(g,n,i,s,x,b,m,v,u,d),f||(g.repeat="repeat");break;default:m&&j(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=q(),U(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=i,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let K,$=new t.Bounds;const{isSame:J}=t.BoundsHelper;function tt(t,e,n,a,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||Q(i,a,n,s),!0}function et(e,n){it(e,t.ImageEvent.LOAD,n)}function nt(e,n){it(e,t.ImageEvent.LOADED,n)}function at(e,n,a){n.error=a,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ot,scale:rt,copy:dt}=t.MatrixHelper,{ceil:lt,abs:ct}=Math;function ht(e,n,a){let{scaleX:i,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=i+"-"+s+"-"+a;if(n.patternId===o||e.destroyed)return!1;{i=ct(i),s=ct(s);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=ot(),dt(l,g),rt(l,1/u,1/f),i*=u,s*=f),i*=a,s*=a,c*=i,h*=s;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(i/=d,s/=d,c/=d,h/=d),u&&(i/=u,s/=f),(g||1!==i||1!==s)&&(l||(l=ot(),g&&dt(l,g)),rt(l,1/i,1/s));const m=e.getCanvas(lt(c)||1,lt(h)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}function ut(t,e,n,a){return new(n||(n=Promise))((function(i,s){function o(t){try{d(a.next(t))}catch(t){s(t)}}function r(t){try{d(a.throw(t))}catch(t){s(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}d((a=a.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ft}=Math;const pt={image:function(e,n,a,i,s){let o,r;const d=t.ImageManager.get(a);return K&&a===K.paint&&J(i,K.boxBounds)?o=K.leafPaint:(o={type:a.type,image:d},K=d.use>1?{leafPaint:o,paint:a,boxBounds:$.set(i)}:null),(s||d.loading)&&(r={image:d,attrName:n,attrValue:a}),d.ready?(tt(e,n,a,d,o,i),s&&(et(e,r),nt(e,r))):d.error?s&&at(e,r,d.error):(s&&(st(e,!0),et(e,r)),o.loadId=d.load((()=>{st(e,!1),e.destroyed||(tt(e,n,a,d,o,i)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),nt(e,r)),o.loadId=null}),(t=>{st(e,!1),at(e,r,t),o.loadId=null}))),o},checkImage:function(n,a,i,s){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:d}=a;if(!i.data||i.patternId===o+"-"+r+"-"+d&&!e.Export.running)return!1;{const{data:l}=i;if(s)if(l.repeat)s=!1;else{let{width:n,height:a}=l;n*=ft(o)*d,a*=ft(r)*d,l.scaleX&&(n*=l.scaleX,a*=l.scaleY),s=n*a>t.Platform.image.maxCacheSize||e.Export.running}return s?(a.save(),n.windingRule?a.clip(n.windingRule):a.clip(),i.blendMode&&(a.blendMode=i.blendMode),l.opacity&&(a.opacity*=l.opacity),l.transform&&a.transform(l.transform),a.drawImage(i.image.view,0,0,l.width,l.height),a.restore(),!0):(!i.style||i.sync||e.Export.running?ht(n,i,d):i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add((()=>ut(this,void 0,void 0,(function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&ht(n,i,d),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ht,recycleImage:function(e,n){const a=n["_"+e];if(a instanceof Array){let i,s,o,r;for(let d=0,l=a.length;d<l;d++)i=a[d].image,r=i&&i.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(i),i.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),i.unload(a[d].loadId,!o.some((t=>t.url===r)))));return s}return null},createData:Q,getPatternData:Z,fillOrFitMode:j,clipMode:Y,repeatMode:z},{toPoint:gt}=t.AroundHelper,_t={},wt={};function yt(t,n,a){if(n){let i;for(let s=0,o=n.length;s<o;s++)i=n[s],"string"==typeof i?t.addColorStop(s/(o-1),e.ColorConvert.string(i,a)):t.addColorStop(i.offset,e.ColorConvert.string(i.color,a))}}const{getAngle:mt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,a,i){let s;const{width:o,height:r}=t;if(o!==r||a){const t=mt(e,n);s=xt(),i?(Bt(s,e,o/r*(a||1),1),bt(s,e,t+90)):(Bt(s,e,1,o/r*(a||1)),bt(s,e,t))}return s}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Wt={};const Ct={linearGradient:function(e,n){let{from:a,to:i,type:s,blendMode:o,opacity:r}=e;gt(a||"top",n,_t),gt(i||"bottom",n,wt);const d=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);yt(d,e.stops,r);const l={type:s,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:a,to:i,type:s,opacity:o,blendMode:r,stretch:d}=e;Et(a||"center",n,Rt),Et(i||"bottom",n,Lt);const l=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));yt(l,e.stops,o);const c={type:s,style:l},h=kt(n,Rt,Lt,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:a,to:i,type:s,opacity:o,blendMode:r,stretch:d}=e;Pt(a||"center",n,At),Pt(i||"bottom",n,Wt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Wt));yt(l,e.stops,o);const c={type:s,style:l},h=kt(n,At,Wt,d||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Ot,toOffsetOutBounds:Mt}=t.BoundsHelper,Tt={},It={};function Dt(e,n,a,i){const{bounds:s,shapeBounds:o}=i;if(t.Platform.fullImageShadow){if(Ot(Tt,e.bounds),Tt.x+=n.x-o.x,Tt.y+=n.y-o.y,a){const{matrix:t}=i;Tt.x-=(s.x+(t?t.e:0)+s.width/2)*(a-1),Tt.y-=(s.y+(t?t.f:0)+s.height/2)*(a-1),Tt.width*=a,Tt.height*=a}e.copyWorld(i.canvas,e.bounds,Tt)}else a&&(Ot(Tt,n),Tt.x-=n.width/2*(a-1),Tt.y-=n.height/2*(a-1),Tt.width*=a,Tt.height*=a),e.copyWorld(i.canvas,o,a?Tt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Gt={shadow:function(t,e,n){let a,i;const{__nowWorld:s,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(l,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),i=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Dt(f,It,i,n),a=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,s,"copy"),a=s),d?f.copyWorld(d,s,s,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,a,s,r.blendMode):e.copyWorldToInner(f,a,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(a,!0)})),f.recycle(a)},innerShadow:function(t,e,n){let a,i;const{__nowWorld:s,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(l,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),i=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Dt(f,Ft,i,n),f.restore(),d?(f.copyWorld(f,l,s,"copy"),f.copyWorld(d,s,s,"source-out"),a=s):(f.copyWorld(n.canvas,c,l,"source-out"),a=l),f.fillWorld(a,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,a,s,r.blendMode):e.copyWorldToInner(f,a,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(a,!0)})),f.recycle(a)},blur:function(t,e,n){const{blur:a}=t.__;n.setWorldBlur(a*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:jt}=t.LeafBoundsHelper;function Yt(t,e,n,a,i,s){switch(e){case"grayscale":i.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,a){const i=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,i),a.recycle(i),qt(t,e,n,1)}(t,n,a,i);break;case"opacity-path":qt(t,n,a,s);break;case"path":n.restore()}}function zt(t){return t.getSameCanvas(!1,!0)}function qt(t,e,n,a){const i=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,i),n.recycle(i)}e.Group.prototype.__renderMask=function(t,e){let n,a,i,s,o,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(o&&(Yt(this,o,t,i,a,s),a=i=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,i||(i=zt(t))):(o="path",t.save()),n.__clip(i||t,e)):(o="grayscale"===r?"grayscale":"alpha",a||(a=zt(t)),i||(i=zt(t)),n.__render(a,e)),"clipping"!==r&&"clipping-path"!==r)||jt(n,e)||n.__render(i||t,e);Yt(this,o,t,i,a,s)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=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 Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Vt(Ut),$t=Vt(Nt),Jt=Vt("- —/~|┆·");var te;!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"}(te||(te={}));const{Letter:ee,Single:ne,Before:ae,After:ie,Symbol:se,Break:oe}=te;function re(t){return Qt[t]?ee:Jt[t]?oe:Zt[t]?ae:Kt[t]?ie:$t[t]?se:Xt.test(t)?ne:ee}const de={trimRight(t){const{words:e}=t;let n,a=0,i=e.length;for(let s=i-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)a++,t.width-=n.width;a&&e.splice(i-a,a)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ce}=de,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,ye,me,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,We,Ce,Oe,Me=[];function Te(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),me+=e}function Ie(){ve+=me,we.width=me,ye.words.push(we),we={data:[]},me=0}function De(){Ae&&(We.paraNumber++,ye.paraStart=!0,Ae=!1),Re&&(ye.startCharSize=Ee,ye.endCharSize=Re,Ee=0),ye.width=ve,Ce.width?ce(ye):Oe&&He(),Me.push(ye),ye={words:[]},ve=0}function He(){ve>(We.maxWidth||0)&&(We.maxWidth=ve)}const Fe=0,Ge=1,je=2;const{top:Ye,right:ze,bottom:qe,left:Ue}=t.Direction4;function Ne(t,e,n){const{bounds:a,rows:i}=t;a[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let a=0,i=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(s?(a=l[Ue],s-=l[ze]+l[Ue]):n.autoSizeAlign||(a=l[Ue]),o?(i=l[Ye],o-=l[Ye]+l[qe]):n.autoSizeAlign||(i=l[Ye]));const c={bounds:{x:a,y:i,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){We=e,Me=e.rows,Ce=e.bounds,Oe=!Ce.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:s,textCase:o}=a,{canvas:r}=t.Platform,{width:d,height:l}=Ce;if(d||l||i||"none"!==o){const t="none"!==a.textWrap,e="break"===a.textWrap;Ae=!0,ke=null,Ee=Be=Re=me=ve=0,we={data:[]},ye={words:[]};for(let a=0,l=n.length;a<l;a++)be=n[a],"\n"===be?(me&&Ie(),ye.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==o&&(be=le(be,o,!me)),Be=r.measureText(be).width,i&&(i<0&&(Re=Be),Be+=i),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==ge&&ke!==pe),xe=Ae&&s?d-s:d,t&&d&&ve+me+Be>xe&&(e?(me&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||me+Be>xe?(me&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+me===0||(Le===_e?(" "===be&&me&&Ie(),Te(be,Be),Ie()):Se||Pe?(me&&Ie(),Te(be,Be)):Te(be,Be)),ke=Le);me&&Ie(),ve&&De(),Me.length>0&&(Me[Me.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,ve=r.measureText(t).width,Me.push({x:s||0,text:t,width:ve,paraStart:!0}),Oe&&He()}))}(c,e,n),l&&function(t,e,n,a,i){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[Ue]);break;case"right":Ne(e,"x",-t[ze])}if(!i&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ye]);break;case"bottom":Ne(e,"y",-t[qe])}}(l,c,n,s,o),function(t,e){const{rows:n,bounds:a}=t,{__lineHeight:i,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=a,_=i*n.length+(c?c*(t.paraNumber-1):0),w=s;if(r&&_>g)_=Math.max(g,i),t.overflow=n.length;else if(g||h)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||h?p:t.maxWidth;for(let s=0,l=n.length;s<l;s++){if(y=n[s],y.x=u,y.width<p||y.width>p&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&c&&s>0&&(w+=c),y.y=w,w+=i,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<a.x&&(a.x=m),v>a.width&&(a.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}a.y=f,a.height=_}(c,n),function(t,e,n,a){const{rows:i}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let d,l,c,h,u;i.forEach((t=>{t.words&&(c=o&&t.paraStart?o:0,l=n&&"justify"===s&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:l>.01?Ge:je,t.isOverflow&&!r&&(t.textMode=!0),h===je?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ge?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,a){return t.forEach((t=>{(a||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,s),c.overflow&&function(e,n,a,i){if(!i)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,c=a+i-l;("none"===n.textWrap?s:[s[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let a=n;a>-1&&(e=t.data[a],d=e.x+e.width,!(a===n&&d<c));a--){if(d<c&&" "!==e.char){t.data.splice(a+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,a,s),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ve={string:function(t,n){const a="number"==typeof n&&1!==n;if("string"==typeof t){if(!a||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let i=void 0===t.a?1:t.a;a&&(i*=n);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}};Object.assign(e.TextConvert,Xe),Object.assign(e.ColorConvert,Ve),Object.assign(e.Paint,O),Object.assign(e.PaintImage,pt),Object.assign(e.PaintGradient,Ct),Object.assign(e.Effect,Gt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=o,exports.useCanvas=i,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a}=t.FileHelper;function i(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,o)=>{t.convertToBlob({type:a(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>o(t),e.readAsDataURL(t)})).catch((t=>{o(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,a)=>{let i=new XMLHttpRequest;i.open("GET",t.Platform.image.getRealURL(e),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then((t=>{n(t)})).catch((t=>{a(t)}))},i.onerror=t=>a(t),i.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.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:r,updateBounds:d,updateAllWorldOpacity:l}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),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:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:o,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(i);f.forEach((t=>t.setBefore())),a.emitEvent(new t.LayoutEvent(o,f,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(i,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach((i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){a=n.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||d(a[t])}d(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&l(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),a.emitEvent(new t.LayoutEvent(s,f,this.times)),a.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:a,LAYOUT:i,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,s,this.times)),y.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(i,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(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:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const m=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,a&&(this.config=t.DataHelper.default(a,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(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,m.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,m.error(t)}m.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return m.warn("rendering");if(this.times>3)return m.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.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 n=t.Run.start("PartRender"),{canvas:a}=this,i=e.getIntersect(a.bounds),o=e.includes(this.target.__world),s=new t.Bounds(i);a.save(),o&&!t.Debug.showRepaint?a.clear():(i.spread(10+1/this.canvas.pixelRatio).ceil(),a.clearWorld(i,!0),a.clipWorld(i,!0)),this.__render(i,o,s),a.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,a){const i=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,i),this.renderBounds=a=a||e,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=a:this.totalBounds.add(a),t.Debug.showHitView&&this.renderHitView(i),t.Debug.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender(a)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:a}=e.old;if(!new t.Bounds(0,0,n,a).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(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||m.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,a){this.target.emitEvent(new t.RenderEvent(e,this.times,n,a))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){let n;const{rows:a,decorationY:i,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=a.length;t<s;t++)n=a[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),i&&e.fillRect(n.x,n.y+i,n.width,o)}function b(t,e,n){const{strokeAlign:a}=e.__,i="string"!=typeof t;switch(a){case"center":n.setStroke(i?void 0:t,e.__.strokeWidth,e.__),i?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,i,e,n);break;case"outside":B("outside",t,i,e,n)}}function B(t,e,n,a,i){const{__strokeWidth:o,__font:s}=a.__,r=i.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,a.__),r.font=s,n?R(e,!0,a,r):E(a,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(a,r),r.blendMode="normal",a.__worldFlipped?i.copyWorldByReset(r,a.__nowWorld):i.copyWorldToInner(r,a.__nowWorld,a.__layout.renderBounds),r.recycle(a.__nowWorld)}function E(t,e){let n;const{rows:a,decorationY:i,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=a.length;t<s;t++)n=a[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),i&&e.strokeRect(n.x,n.y+i,n.width,o)}function R(t,n,a,i){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&e.PaintImage.checkImage(a,i,o,!1)||o.style&&(i.strokeStyle=o.style,o.blendMode?(i.saveBlendMode(o.blendMode),n?E(a,i):i.stroke(),i.restoreBlendMode()):n?E(a,i):i.stroke())}function L(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,a)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let W;function C(t,n,a){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:i}=a.__layout;switch(n.type){case"solid":let{type:o,blendMode:s,color:r,opacity:d}=n;return{type:o,blendMode:s,style:e.ColorConvert.string(r,d)};case"image":return e.PaintImage.image(a,t,n,i,!W||!W[n.url]);case"linear":return e.PaintGradient.linearGradient(n,i);case"radial":return e.PaintGradient.radialGradient(n,i);case"angular":return e.PaintGradient.conicGradient(n,i);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const O={compute:function(t,n){const a=n.__,i=[];let o,s=a.__input[t];s instanceof Array||(s=[s]),W=e.PaintImage.recycleImage(t,a);for(let e,a=0,o=s.length;a<o;a++)e=C(t,s[a],n),e&&i.push(e);a["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(o=i[0].image.hasOpacityPixel),"fill"===t?a.__pixelFill=o:a.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,a){let i;const{windingRule:o,__font:s}=n.__;for(let r=0,d=t.length;r<d;r++)i=t[r],i.image&&e.PaintImage.checkImage(n,a,i,!s)||i.style&&(a.fillStyle=i.style,i.transform?(a.save(),a.transform(i.transform),i.blendMode&&(a.blendMode=i.blendMode),s?x(n,a):o?a.fill(o):a.fill(),a.restore()):i.blendMode?(a.saveBlendMode(i.blendMode),s?x(n,a):o?a.fill(o):a.fill(),a.restoreBlendMode()):s?x(n,a):o?a.fill(o):a.fill())},fillText:x,stroke:function(t,e,n){const a=e.__,{__strokeWidth:i,strokeAlign:o,__font:s}=a;if(i)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(t,i,a),n.stroke(),a.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(t,2*i,a),a.windingRule?n.clip(a.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*i,a),e.__drawRenderPath(o),o.stroke(),a.windingRule?o.clip(a.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const a=e.__,{__strokeWidth:i,strokeAlign:o,__font:s}=a;if(i)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,i,a),R(t,!1,e,n),a.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*i,a),a.windingRule?n.clip(a.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*i,a),R(t,!1,e,s),a.windingRule?s.clip(a.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const a=e.getSameCanvas(),i=t.__nowWorld;let o,s,r,d,{scaleX:l,scaleY:c}=i;if(l<0&&(l=-l),c<0&&(c=-c),e.bounds.includes(i))d=a,o=r=i;else{const{renderShapeSpread:a}=t.__layout,h=A(a?k(e.bounds,l===c?a*l:[a*c,a*l]):e.bounds,i);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,c*=f),r=S(i,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(a,n),{canvas:a,matrix:s,bounds:o,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:c}}};let M={};const{get:T,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:G}=t.MatrixHelper;function j(t,e,n,a,i,o,s){const r=T();D(r,e.x+n,e.y+a),F(r,i,o),s&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function Y(t,e,n,a,i,o,s){const r=T();D(r,e.x+n,e.y+a),i&&F(r,i,o),s&&G(r,s),t.transform=r}function z(t,e,n,a,i,o,s,r,d,l){const c=T();if(d)if("center"===l)I(c,{x:n/2,y:a/2},d);else switch(G(c,d),d){case 90:D(c,a,0);break;case 180:D(c,n,a);break;case 270:D(c,0,n)}M.x=e.x+i,M.y=e.y+o,D(c,M.x,M.y),s&&H(c,M,s,r),t.transform=c}const{get:q,translate:U}=t.MatrixHelper,N=new t.Bounds,X={},V={};function Q(t,e,n,a){const{blendMode:i,sync:o}=n;i&&(t.blendMode=i),o&&(t.sync=o),t.data=Z(n,a,e)}function Z(e,n,a){let{width:i,height:o}=a;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:d,offset:l,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===i&&n.height===o,g={mode:r},_="center"!==d&&(u||0)%180==90,w=_?o:i,y=_?i:o;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,a,V),m=V.scaleX,v=V.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-i*m)/2,b+=(n.height-o*v)/2}if(d){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(d,e,n,X,!0),x+=X.x,b+=X.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":p||(i=n.width,o=n.height);break;case"normal":case"clip":(x||b||m||u)&&Y(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&z(g,n,i,o,x,b,m,v,u,d),f||(g.repeat="repeat");break;default:m&&j(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=q(),U(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=i,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let K,$=new t.Bounds;const{isSame:J}=t.BoundsHelper;function tt(t,e,n,a,i,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||Q(i,a,n,o),!0}function et(e,n){it(e,t.ImageEvent.LOAD,n)}function nt(e,n){it(e,t.ImageEvent.LOADED,n)}function at(e,n,a){n.error=a,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function ot(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:st,scale:rt,copy:dt}=t.MatrixHelper,{ceil:lt,abs:ct}=Math;function ht(e,n,a){let{scaleX:i,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=i+"-"+o+"-"+a;if(n.patternId===s||e.destroyed)return!1;{i=ct(i),o=ct(o);const{image:e,data:r}=n;let d,l,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(l=st(),dt(l,g),rt(l,1/u,1/f),i*=u,o*=f),i*=a,o*=a,c*=i,h*=o;const w=c*h;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(i/=d,o/=d,c/=d,h/=d),u&&(i/=u,o/=f),(g||1!==i||1!==o)&&(l||(l=st(),g&&dt(l,g)),rt(l,1/i,1/o));const m=e.getCanvas(lt(c)||1,lt(h)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=s,!0}}function ut(t,e,n,a){return new(n||(n=Promise))((function(i,o){function s(t){try{d(a.next(t))}catch(t){o(t)}}function r(t){try{d(a.throw(t))}catch(t){o(t)}}function d(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}d((a=a.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ft}=Math;const pt={image:function(e,n,a,i,o){let s,r;const d=t.ImageManager.get(a);return K&&a===K.paint&&J(i,K.boxBounds)?s=K.leafPaint:(s={type:a.type,image:d},K=d.use>1?{leafPaint:s,paint:a,boxBounds:$.set(i)}:null),(o||d.loading)&&(r={image:d,attrName:n,attrValue:a}),d.ready?(tt(e,n,a,d,s,i),o&&(et(e,r),nt(e,r))):d.error?o&&at(e,r,d.error):(o&&(ot(e,!0),et(e,r)),s.loadId=d.load((()=>{ot(e,!1),e.destroyed||(tt(e,n,a,d,s,i)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),nt(e,r)),s.loadId=null}),(t=>{ot(e,!1),at(e,r,t),s.loadId=null}))),s},checkImage:function(n,a,i,o){const{scaleX:s,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:d}=a;if(!i.data||i.patternId===s+"-"+r+"-"+d&&!e.Export.running)return!1;{const{data:l}=i;if(o)if(l.repeat)o=!1;else{let{width:n,height:a}=l;n*=ft(s)*d,a*=ft(r)*d,l.scaleX&&(n*=l.scaleX,a*=l.scaleY),o=n*a>t.Platform.image.maxCacheSize||e.Export.running}return o?(a.save(),n.windingRule?a.clip(n.windingRule):a.clip(),i.blendMode&&(a.blendMode=i.blendMode),l.opacity&&(a.opacity*=l.opacity),l.transform&&a.transform(l.transform),a.drawImage(i.image.view,0,0,l.width,l.height),a.restore(),!0):(!i.style||i.sync||e.Export.running?ht(n,i,d):i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add((()=>ut(this,void 0,void 0,(function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&ht(n,i,d),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ht,recycleImage:function(e,n){const a=n["_"+e];if(a instanceof Array){let i,o,s,r;for(let d=0,l=a.length;d<l;d++)i=a[d].image,r=i&&i.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(i),i.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),i.unload(a[d].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:Q,getPatternData:Z,fillOrFitMode:j,clipMode:Y,repeatMode:z},{toPoint:gt}=t.AroundHelper,_t={},wt={};function yt(t,n,a){if(n){let i;for(let o=0,s=n.length;o<s;o++)i=n[o],"string"==typeof i?t.addColorStop(o/(s-1),e.ColorConvert.string(i,a)):t.addColorStop(i.offset,e.ColorConvert.string(i.color,a))}}const{getAngle:mt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,a,i){let o;const{width:s,height:r}=t;if(s!==r||a){const t=mt(e,n);o=xt(),i?(Bt(o,e,s/r*(a||1),1),bt(o,e,t+90)):(Bt(o,e,1,s/r*(a||1)),bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Wt={};const Ct={linearGradient:function(e,n){let{from:a,to:i,type:o,blendMode:s,opacity:r}=e;gt(a||"top",n,_t),gt(i||"bottom",n,wt);const d=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);yt(d,e.stops,r);const l={type:o,style:d};return s&&(l.blendMode=s),l},radialGradient:function(e,n){let{from:a,to:i,type:o,opacity:s,blendMode:r,stretch:d}=e;Et(a||"center",n,Rt),Et(i||"bottom",n,Lt);const l=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));yt(l,e.stops,s);const c={type:o,style:l},h=kt(n,Rt,Lt,d,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:a,to:i,type:o,opacity:s,blendMode:r,stretch:d}=e;Pt(a||"center",n,At),Pt(i||"bottom",n,Wt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Wt));yt(l,e.stops,s);const c={type:o,style:l},h=kt(n,At,Wt,d||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Ot,toOffsetOutBounds:Mt}=t.BoundsHelper,Tt={},It={};function Dt(e,n,a,i){const{bounds:o,shapeBounds:s}=i;if(t.Platform.fullImageShadow){if(Ot(Tt,e.bounds),Tt.x+=n.x-s.x,Tt.y+=n.y-s.y,a){const{matrix:t}=i;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(a-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(a-1),Tt.width*=a,Tt.height*=a}e.copyWorld(i.canvas,e.bounds,Tt)}else a&&(Ot(Tt,n),Tt.x-=n.width/2*(a-1),Tt.y-=n.height/2*(a-1),Tt.width*=a,Tt.height*=a),e.copyWorld(i.canvas,s,a?Tt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Gt={shadow:function(t,e,n){let a,i;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(l,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),i=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,It,i,n),a=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,o,"copy"),a=o),d?f.copyWorld(d,o,o,"destination-out"):f.copyWorld(n.canvas,c,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,a,o,r.blendMode):e.copyWorldToInner(f,a,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(a,!0)})),f.recycle(a)},innerShadow:function(t,e,n){let a,i;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(l,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),i=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,Ft,i,n),f.restore(),d?(f.copyWorld(f,l,o,"copy"),f.copyWorld(d,o,o,"source-out"),a=o):(f.copyWorld(n.canvas,c,l,"source-out"),a=l),f.fillWorld(a,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,a,o,r.blendMode):e.copyWorldToInner(f,a,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(a,!0)})),f.recycle(a)},blur:function(t,e,n){const{blur:a}=t.__;n.setWorldBlur(a*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:jt}=t.LeafBoundsHelper;function Yt(t,e,n,a,i,o){switch(e){case"grayscale":i.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,a){const i=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,i),a.recycle(i),qt(t,e,n,1)}(t,n,a,i);break;case"opacity-path":qt(t,n,a,o);break;case"path":n.restore()}}function zt(t){return t.getSameCanvas(!1,!0)}function qt(t,e,n,a){const i=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,i),n.recycle(i)}e.Group.prototype.__renderMask=function(t,e){let n,a,i,o,s,r;const{children:d}=this;for(let l=0,c=d.length;l<c;l++)n=d[l],r=n.__.mask,r&&(s&&(Yt(this,s,t,i,a,o),a=i=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,i||(i=zt(t))):(s="path",t.save()),n.__clip(i||t,e)):(s="grayscale"===r?"grayscale":"alpha",a||(a=zt(t)),i||(i=zt(t)),n.__render(a,e)),"clipping"!==r&&"clipping-path"!==r)||jt(n,e)||n.__render(i||t,e);Yt(this,s,t,i,a,o)};const Ut=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Ut+"_#~&*+\\=|≮≯≈≠=…",Xt=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 Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Kt=Vt(Ut),$t=Vt(Nt),Jt=Vt("- —/~|┆·");var te;!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"}(te||(te={}));const{Letter:ee,Single:ne,Before:ae,After:ie,Symbol:oe,Break:se}=te;function re(t){return Qt[t]?ee:Jt[t]?se:Zt[t]?ae:Kt[t]?ie:$t[t]?oe:Xt.test(t)?ne:ee}const de={trimRight(t){const{words:e}=t;let n,a=0,i=e.length;for(let o=i-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)a++,t.width-=n.width;a&&e.splice(i-a,a)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ce}=de,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,ye,me,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,We,Ce,Oe,Me=[];function Te(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),me+=e}function Ie(){ve+=me,we.width=me,ye.words.push(we),we={data:[]},me=0}function De(){Ae&&(We.paraNumber++,ye.paraStart=!0,Ae=!1),Re&&(ye.startCharSize=Ee,ye.endCharSize=Re,Ee=0),ye.width=ve,Ce.width?ce(ye):Oe&&He(),Me.push(ye),ye={words:[]},ve=0}function He(){ve>(We.maxWidth||0)&&(We.maxWidth=ve)}const Fe=0,Ge=1,je=2;const{top:Ye,right:ze,bottom:qe,left:Ue}=t.Direction4;function Ne(t,e,n){const{bounds:a,rows:i}=t;a[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let a=0,i=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(o?(a=l[Ue],o-=l[ze]+l[Ue]):n.autoSizeAlign||(a=l[Ue]),s?(i=l[Ye],s-=l[Ye]+l[qe]):n.autoSizeAlign||(i=l[Ye]));const c={bounds:{x:a,y:i,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){We=e,Me=e.rows,Ce=e.bounds,Oe=!Ce.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:o,textCase:s}=a,{canvas:r}=t.Platform,{width:d,height:l}=Ce;if(d||l||i||"none"!==s){const t="none"!==a.textWrap,e="break"===a.textWrap;Ae=!0,ke=null,Ee=Be=Re=me=ve=0,we={data:[]},ye={words:[]};for(let a=0,l=n.length;a<l;a++)be=n[a],"\n"===be?(me&&Ie(),ye.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=le(be,s,!me)),Be=r.measureText(be).width,i&&(i<0&&(Re=Be),Be+=i),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==ge&&ke!==pe),xe=Ae&&o?d-o:d,t&&d&&ve+me+Be>xe&&(e?(me&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||me+Be>xe?(me&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+me===0||(Le===_e?(" "===be&&me&&Ie(),Te(be,Be),Ie()):Se||Pe?(me&&Ie(),Te(be,Be)):Te(be,Be)),ke=Le);me&&Ie(),ve&&De(),Me.length>0&&(Me[Me.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{We.paraNumber++,ve=r.measureText(t).width,Me.push({x:o||0,text:t,width:ve,paraStart:!0}),Oe&&He()}))}(c,e,n),l&&function(t,e,n,a,i){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[Ue]);break;case"right":Ne(e,"x",-t[ze])}if(!i&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ye]);break;case"bottom":Ne(e,"y",-t[qe])}}(l,c,n,o,s),function(t,e){const{rows:n,bounds:a}=t,{__lineHeight:i,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=a,_=i*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,i),t.overflow=n.length;else if(g||h)switch(l){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||h?p:t.maxWidth;for(let o=0,l=n.length;o<l;o++){if(y=n[o],y.x=u,y.width<p||y.width>p&&!r)switch(d){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+=i,t.overflow>o&&w>_&&(y.isOverflow=!0,t.overflow=o+1),m=y.x,v=y.width,s<0&&(y.width<0?(v=-y.width+e.fontSize+s,m-=v,v+=e.fontSize):v-=s),m<a.x&&(a.x=m),v>a.width&&(a.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}a.y=f,a.height=_}(c,n),function(t,e,n,a){const{rows:i}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let d,l,c,h,u;i.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,l=n&&("justify"===o||"both"===o)&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:l>.01?Ge:je,t.isOverflow&&!r&&(t.textMode=!0),h===je?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,d=t.x,t.data=[],t.words.forEach((e=>{h===Ge?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,a){return t.forEach((t=>{(a||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==o||(d+=l,t.width+=l)}))),t.words=null)}))}(c,n,o),c.overflow&&function(e,n,a,i){if(!i)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,c=a+i-l;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let a=n;a>-1&&(e=t.data[a],d=e.x+e.width,!(a===n&&d<c));a--){if(d<c&&" "!==e.char){t.data.splice(a+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(c,n,a,o),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(c,n),c}};const Ve={string:function(t,n){const a="number"==typeof n&&1!==n;if("string"==typeof t){if(!a||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let i=void 0===t.a?1:t.a;a&&(i*=n);const o=t.r+","+t.g+","+t.b;return 1===i?"rgb("+o+")":"rgba("+o+","+i+")"}};Object.assign(e.TextConvert,Xe),Object.assign(e.ColorConvert,Ve),Object.assign(e.Paint,O),Object.assign(e.PaintImage,pt),Object.assign(e.PaintGradient,Ct),Object.assign(e.Effect,Gt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=s,exports.useCanvas=i,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|