@leafer-draw/miniapp 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/miniapp.cjs CHANGED
@@ -1286,7 +1286,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1286
1286
  data.__naturalWidth = image.width / data.pixelRatio;
1287
1287
  data.__naturalHeight = image.height / data.pixelRatio;
1288
1288
  if (data.__autoSide) {
1289
- ui.forceUpdate("width");
1289
+ ui.forceUpdate();
1290
1290
  core.LeafHelper.updateBounds(ui);
1291
1291
  ui.__layout.boundsChanged = true;
1292
1292
  if (ui.__proxyData) {
@@ -1290,7 +1290,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
1290
1290
  data.__naturalWidth = image.width / data.pixelRatio;
1291
1291
  data.__naturalHeight = image.height / data.pixelRatio;
1292
1292
  if (data.__autoSide) {
1293
- ui.forceUpdate("width");
1293
+ ui.forceUpdate();
1294
1294
  LeafHelper.updateBounds(ui);
1295
1295
  ui.__layout.boundsChanged = true;
1296
1296
  if (ui.__proxyData) {
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as r,isUndefined as o,ResizeEvent as l,Creator as c,LeaferImage as d,FileHelper as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as x,Bounds as v,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as T,BoundsHelper as L,FourNumberHelper as A,Matrix as P,ImageEvent as C,MatrixHelper as O,MathHelper as W,AlignHelper as M,PointHelper as D,getMatrixData as I,AroundHelper as F,OneRadian as z,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as q,PaintGradient as N,Effect as G,Group as j,TextConvert as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={}));class Q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:a,pixelRatio:r}=this.config,o={width:e||t.width,height:a||t.height,pixelRatio:r};this.resize(o),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,this.updateViewSize(),t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,r),this.resize(t),o(this.width)||this.resizeListener(new l(t,e))}}function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(h.mimeType(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(h.mimeType(h.fileType(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let r;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,r=!0);const o=e.getFileSystemManager();o.writeFile({filePath:s,data:t,encoding:"base64",success(){r?i.miniapp.saveToAlbum(s).then(()=>{o.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:(t,e,s)=>new Promise((e,s)=>{const n=i.getCanvas().view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),loadContent:(t,i="text")=>new Promise((s,n)=>e.request({url:t,responseType:"arrayBuffer"===i?"arraybuffer":"text",success:t=>s("json"===i&&"string"==typeof t.data?JSON.parse(t.data):t.data),fail:n})),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient,u(i,"devicePixelRatio",{get:()=>Math.max(1,e.getWindowInfo?e.getWindowInfo().pixelRatio:e.getSystemInfoSync().pixelRatio)})}Object.assign(c,{canvas:(t,e)=>new Q(t,e),image:t=>new d(t)}),i.name="miniapp",i.getCanvas=function(){const{renderCanvas:t}=i;return t&&t.view?t:i.canvas},i.requestRender=function(t){const{view:e}=i.getCanvas();e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)};class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new f;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 f,this.target=t,e&&(this.config=a.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(p.REQUEST)}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y;const{worldBounds:st}=x;class nt{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:at,updateAllChange:rt}=m,ot=b.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new k,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=B,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new B(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new B(a,o,this.times)),i.emitEvent(new B(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){at(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=b.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=a.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new v(s);i.save(),s.spread(dt.clipSpread).ceil();const{ceilPartPixel:a}=this.config;i.clipWorld(s,a),i.clearWorld(s,a),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s,target:n}=this,a=t.includes(n.__world),r=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),i.render(n,s,r),this.renderBounds=e=e||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e,i){t.__.__font?Y.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}dt.clipSpread=10,Object.assign(c,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=lt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const ut={};function ft(t,e,i,s,n){const a=i.__;T(t)?Y.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&Y.strokeArrow(t,i,s,n)}function pt(t,e,i,s,n){const a=i.__;T(t)?Y.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),Y.drawTextStroke(i,s,n))}function gt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,pt(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(i,a,n),a.blendMode="normal",m.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}const{getSpread:_t,copyAndSpread:wt,toOuterOf:mt,getOuterOf:yt,getByMove:xt,move:vt,getIntersectData:St}=L,bt={};let kt;const{stintSet:Bt}=a,{hasTransparent:Rt}=q;function Et(t,i,s){if(!T(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout,{type:r}=i;switch(r){case"image":case"film":case"video":if(!i.url)return;n=X.image(s,t,i,a,!kt||!kt[i.url]),"image"!==r&&X[r](n);break;case"linear":n=N.linearGradient(i,a);break;case"radial":n=N.radialGradient(i,a);break;case"angular":n=N.conicGradient(i,a);break;case"solid":const{color:e,opacity:l}=i;n={type:r,style:q.string(e,l)};break;default:o(i.r)||(n={type:"solid",style:q.string(i)})}if(n&&(n.originPaint=i,e(n.style)&&Rt(n.style)&&(n.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}return n}const Tt={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];S(o)||(o=[o]),kt=X.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Et(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));s.length?(i["_"+t]=s,s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Bt(i,"__isAlphaPixelFill",n),Bt(i,"__isTransparentFill",a)):(Bt(i,"__isAlphaPixelStroke",n),Bt(i,"__isTransparentStroke",a),Bt(i,"__hasMultiStrokeStyle",r))):(i.__removePaint(t,!1),i["_"+t]="")},fill:function(t,e,i,s){i.fillStyle=t,ht(e,i,s)},fills:function(t,e,i,s){let n,a,r;for(let o=0,l=t.length;o<l;o++){if(n=t[o],a=n.originPaint,n.image){if(r?r++:r=1,X.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||a.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,a.scaleFixed,!1);1!==t&&i.scale(t,s)}a.blendMode&&(i.blendMode=a.blendMode),ht(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),ht(e,i,s),i.restoreBlendMode()):ht(e,i,s)}},fillPathOrText:ht,fillText:function(t,e,i){if(t.motionText)return ut.fillMotionText(t,e,i);const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)Y.strokeText(t,e,i,s);else if(n.__pathForStroke)Y.fillStroke(t,e,i,s);else switch(n.strokeAlign){case"center":ft(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),ft(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)ft(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ft(t,2,e,r,s),r.clipUI(n),r.clearWorld(a),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Y.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":pt(t,1,e,i,s);break;case"inside":gt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,i,s):gt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:r}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;a.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||n.setStroke(void 0,o.__strokeWidth*e,o);for(let c=0,d=t.length;c<d;c++)if(r=t[c],(!r.image||!X.checkImage(r,!1,s,n,a))&&r.style){if(l){const{strokeStyle:t}=r;t?n.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(r.style,o.__strokeWidth*e,o)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?Y.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?Y.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),a=e.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,d,h,u,f,p;mt(o.strokeSpread?(wt(bt,o.boxBounds,o.strokeSpread),bt):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,c=f=l,d=r;else{let n;if(i.fullImageShadow)n=l;else{const t=o.renderShapeSpread?_t(a,A.swapAndScale(o.renderShapeSpread,g,_)):a;n=St(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=yt(l,u),c=xt(f,-u.e,-u.f),d=yt(r,u),vt(d,-u.e,-u.f);const y=s.matrix;y?(h=new P(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:u,bounds:c,renderBounds:d,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Lt,At=new v;const{isSame:Pt}=L;function Ct(t,e,i,s,n,a){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate("width"),m.updateBounds(t),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),"brush"===i.mode&&X.brush(t,e,n),!n.data){X.createData(n,s,i,a);const{transform:t}=n.data,{opacity:e}=i,r=(t&&!t.onlyScale||o.path||o.cornerRadius)&&!n.brush;(r||e&&e<1||i.blendMode)&&(n.complex=!r||2)}return i.filter&&X.applyFilter(n,s,i.filter,t),r}function Ot(t,e){Dt(t,C.LOAD,e)}function Wt(t,e){Dt(t,C.LOADED,e)}function Mt(t,e,i){e.error=i,t.forceUpdate("surface"),Dt(t,C.ERROR,e)}function Dt(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function It(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ft,translate:zt}=O,Ut=new v,Yt={},Xt={};function qt(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let Nt={},Gt=I();const{get:jt,set:Vt,rotateOfOuter:Ht,translate:Qt,scaleOfOuter:Zt,multiplyParent:$t,scale:Jt,rotate:Kt,skew:te}=O;function ee(t,e,i,s,n,a,r,o){r&&Kt(t,r),o&&te(t,o.x,o.y),n&&Jt(t,n,a),Qt(t,e.x+i,e.y+s)}function ie(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:se,scale:ne,copy:ae}=O,{getFloorScale:re}=W,{abs:oe}=Math;const le={image:function(t,e,i,s,n){let a,r;const o=E.get(i,i.type);return Lt&&i===Lt.paint&&Pt(s,Lt.boxBounds)?a=Lt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Lt=o.use>1?{leafPaint:a,paint:i,boxBounds:At.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Ct(t,e,i,o,a,s),n&&(Ot(t,r),Wt(t,r))):o.error?n&&Mt(t,r,o.error):(n&&(It(t,!0),Ot(t,r)),a.loadId=o.load(()=>{It(t,!1),t.destroyed||(Ct(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Wt(t,r)),a.loadId=void 0},e=>{It(t,!1),Mt(t,r,e),a.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,e,s,n,a){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,s,n,a),l=t.film?t.nowIndex:r+"-"+o,{image:c,brush:d,data:h,originPaint:u}=t,{exporting:f,snapshot:p}=a;if(!h||t.patternId===l&&!f||p){if(!d||!t.style)return!1}else if(e&&(h.repeat?e=!1:u.changeful||t.film||"miniapp"===i.name||f||(e=i.image.isLarge(c,r,o)||c.width*r>8096||c.height*o>8096)),e)s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill());else if(!t.style||u.sync||f?X.createPattern(t,s,n,a):X.createPatternTask(t,s,n,a),!d||!t.style)return!1;return X.drawImage(t,r,o,s,n,a),!0},drawImage:function(t,e,i,s,n,a){const{data:r,image:o,brush:l,complex:c}=t;let{width:d,height:h}=o,u=l||o;if(c){const{blendMode:a,opacity:o}=t.originPaint,{transform:l}=r;n.save(),2===c&&n.clipUI(s),a&&(n.blendMode=a),o&&(n.opacity*=o),l&&n.transform(l),u.render(n,0,0,d,h,s,t,e,i),n.restore()}else r.scaleX&&(d*=r.scaleX,h*=r.scaleY),u.render(n,0,0,d,h,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(t.brush&&X.addBrushScale(n,t,e),i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,n,a,r,o;const l=e.__leaf;for(let c=0,d=i.length;c<d;c++)s=i[c],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,E.recyclePaint(s),s.brush&&X.recycleBrush(s,l),e.__willDestroy&&n.parent&&X.recycleFilter(n,l),n.loading&&(r||(r=e.__input&&e.__input[t]||[],S(r)||(r=[r])),n.unload(i[c].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=E.patternTasker.add(()=>ie(this,void 0,void 0,function*(){X.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:a,scaleY:r}=X.getImageRenderScaleData(t,e,s,n),o=t.film?t.nowIndex:a+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!i.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:l,brush:c,data:d}=t,{transform:h,gap:u}=d,f=X.getPatternFixScale(t,a,r);let p,g,_,{width:w,height:m}=l,{opacity:y}=t.originPaint;(c||1===y)&&(y=void 0),f&&(a*=f,r*=f),w*=a,m*=r,u&&!c&&(g=u.x*a/oe(d.scaleX||1),_=u.y*r/oe(d.scaleY||1)),(h||1!==a||1!==r)&&(a*=re(w+(g||0)),r*=re(m+(_||0)),p=se(),h&&ae(p,h),ne(p,1/a,1/r));const x=l.getCanvas(w,m,y,void 0,g,_,e.leafer&&e.leafer.config.smooth,d.interlace);c?(t.style=x,X.cacheBrush(t,e,s,n)):t.style=l.getPattern(x,d.repeat||i.origin.noRepeat||"no-repeat",p,t),t.patternId=o}},getPatternFixScale:function(t,e,s){const{image:n}=t;let a,r=i.image.maxPatternSize,o=n.width*n.height;return n.isSVG?e>1&&(a=Math.ceil(e)/e):r>o&&(r=o),(o*=e*s)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,s){t.data=X.getPatternData(i,s,e)},getPatternData:function(t,i,n){t.padding&&(i=Ut.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:r}=n,{mode:o,align:l,offset:c,scale:d,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,interlace:w}=t,m=i.width===a&&i.height===r,y={mode:o},x="center"!==l&&(u||0)%180==90;let v,S;switch(L.set(Xt,0,0,x?r:a,x?a:r),o&&"cover"!==o&&"fit"!==o?((d||h)&&(W.getScaleData(d,h,n,Yt),v=Yt.scaleX,S=Yt.scaleY),(l||_||g)&&(v&&L.scale(Xt,v,S,!0),l&&M.toPoint(l,Xt,i,Xt,!0,!0))):m&&!u||(v=S=L.getFitScale(i,Xt,"fit"!==o),L.put(i,n,l,v,!1,Xt),L.scale(Xt,v,S,!0)),c&&D.move(Xt,c),o){case"stretch":m?v&&(v=S=void 0):(v=i.width/a,S=i.height/r,X.stretchMode(y,i,v,S));break;case"normal":case"clip":if(Xt.x||Xt.y||v||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),X.clipMode(y,i,Xt.x,Xt.y,v,S,u,f,t,e),t&&(v=v?v*t:t,S=S?S*e:e)}break;case"repeat":(!m||v||u||f)&&X.repeatMode(y,i,a,r,Xt.x,Xt.y,v,S,u,f,l,t.freeTransform);case"brush":g||(y.repeat="repeat");const e=T(g);(_||e)&&(y.gap=function(t,e,i,s,n){let a,r;T(t)?(a=t.x,r=t.y):a=r=t;return{x:qt(a,i,n.width,e&&e.x),y:qt(r,s,n.height,e&&e.y)}}(_,e&&g,Xt.width,Xt.height,i));break;default:v&&X.fillOrFitMode(y,i,Xt.x,Xt.y,v,S,u)}return y.transform||"brush"===o||(i.x||i.y)&&zt(y.transform=Ft(),i.x,i.y),v&&(y.scaleX=v,y.scaleY=S),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w&&(y.interlace=s(w)||"percent"===w.type?{type:"x",offset:w}:w),y},stretchMode:function(t,e,i,s){const n=jt(),{x:a,y:r}=e;a||r?Qt(n,a,r):i>0&&s>0&&(n.onlyScale=!0),Jt(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,r){const o=jt();Qt(o,e.x+i,e.y+s),Jt(o,n,a),r&&Ht(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,n,a,r,o,l,c){const d=jt();ee(d,e,i,s,n,a,r,o),l&&(r||o?(Vt(Gt),Zt(Gt,e,l,c),$t(d,Gt)):Zt(d,e,l,c)),t.transform=d},repeatMode:function(t,e,i,s,n,a,r,o,l,c,d,h){const u=jt();if(h)ee(u,e,n,a,r,o,l,c);else{if(l)if("center"===d)Ht(u,{x:i/2,y:s/2},l);else switch(Kt(u,l),l){case 90:Qt(u,s,0);break;case 180:Qt(u,i,s);break;case 270:Qt(u,0,i)}Nt.x=e.x+n,Nt.y=e.y+a,Qt(u,Nt.x,Nt.y),r&&Zt(u,Nt,r,o)}t.transform=u}},{toPoint:ce}=F,{hasTransparent:de}=q,he={},ue={};function fe(t,i,s,n){if(s){let a,r,o,l;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(o=t/(c-1),r=q.string(a,n)):(o=a.offset,r=q.string(a.color,n)),i.addColorStop(o,r),!l&&de(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:pe,getDistance:ge}=D,{get:_e,rotateOfOuter:we,scaleOfOuter:me}=O,{toPoint:ye}=F,xe={},ve={};function Se(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=pe(e,i);a=_e(),n?(me(a,e,r/o*(s||1),1),we(a,e,t+90)):(me(a,e,1,r/o*(s||1)),we(a,e,t))}return a}const{getDistance:be}=D,{toPoint:ke}=F,Be={},Re={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:r}=t;ce(s||"top",e,he),ce(n||"bottom",e,ue);const o=i.canvas.createLinearGradient(he.x,he.y,ue.x,ue.y),l={type:a,style:o};return fe(l,o,t.stops,r),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;ye(s||"center",e,xe),ye(n||"bottom",e,ve);const l=i.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,ge(xe,ve)),c={type:a,style:l};fe(c,l,t.stops,r);const d=Se(e,xe,ve,o,!0);return d&&(c.transform=d),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:r,rotation:o,stretch:l}=t;ke(s||"center",e,Be),ke(n||"bottom",e,Re);const c=i.conicGradientSupport?i.canvas.createConicGradient(o?o*z:0,Be.x,Be.y):i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,be(Be,Re)),d={type:a,style:c};fe(d,c,t.stops,r);const h=Se(e,Be,Re,l||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Se},{copy:Te,move:Le,toOffsetOutBounds:Ae}=L,{max:Pe,abs:Ce}=Math,Oe={},We=new P,Me={};function De(t,e){let i,s,n,a,r=0,o=0,l=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=Ce(t.spread||0),r=Pe(r,n+a-s),o=Pe(o,n+a+i),l=Pe(l,n+a+s),c=Pe(c,n+a-i)}),r===o&&o===l&&l===c?r:[r,o,l,c]}function Ie(t,e,s){const{shapeBounds:n}=s;let a,r;i.fullImageShadow?(Te(Oe,t.bounds),Le(Oe,e.x-n.x,e.y-n.y),a=t.bounds,r=Oe):(a=n,r=e),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:Fe}=L,ze={};const Ue=De;const Ye={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ae(l,Me,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Me.offsetX+(r.x||0)*h*_,Me.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_,q.string(r.color)),n=G.getShadowTransform(t,f,i,r,Me,_),n&&f.setTransform(n),Ie(f,Me,i),n&&f.resetTransform(),s=c,r.box&&(f.restore(),f.save(),o&&(f.copyWorld(f,c,a,"copy"),s=a),o?f.copyWorld(o,a,a,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Fe(l,ze,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(ze.offsetX+(r.x||0)*h*_,ze.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_),n=G.getShadowTransform(t,f,i,r,ze,_,!0),n&&f.setTransform(n),Ie(f,ze,i),f.restore(),o?(f.copyWorld(f,c,a,"copy"),f.copyWorld(o,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,d,l,"source-out"),s=c),f.fillWorld(s,q.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:De,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=2*s.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return We.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/o,1+i/l),We}},isTransformShadow(t){},getInnerShadowSpread:Ue},{excludeRenderBounds:Xe}=x;let qe;function Ne(t,e,i,s,n,a,r,o){switch(e){case"grayscale":qe||(qe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);je(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":je(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function je(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}j.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let c=0,d=l.length;c<d;c++){if(i=l[c],o=i.__.mask,o){r&&(Ne(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||Xe(i,e)||i.__render(t,e),a=i.__.opacity,qe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ge(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e));continue}const d=1===a&&i.__.__blendMode;d&&Ne(this,r,t,n,s,a,void 0,!1),Xe(i,e)||i.__render(n||t,e),d&&Ne(this,r,t,n,s,a,d,!1)}Ne(this,r,t,n,s,a,void 0,!0)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=Ve+"_#~&*+\\=|≮≯≈≠=…",Qe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function Ze(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Je=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ze(Ve),ti=Ze(He),ei=Ze("- —/~|┆·");var ii;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ii||(ii={}));const{Letter:si,Single:ni,Before:ai,After:ri,Symbol:oi,Break:li}=ii;function ci(t){return $e[t]?si:ei[t]?li:Je[t]?ai:Ke[t]?ri:ti[t]?oi:Qe.test(t)?ni:si}const di={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function hi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ui}=di,{Letter:fi,Single:pi,Before:gi,After:_i,Symbol:wi,Break:mi}=ii;let yi,xi,vi,Si,bi,ki,Bi,Ri,Ei,Ti,Li,Ai,Pi,Ci,Oi,Wi,Mi,Di=[];function Ii(t,e){Ei&&!Ri&&(Ri=Ei),yi.data.push({char:t,width:e}),vi+=e}function Fi(){Si+=vi,yi.width=vi,xi.words.push(yi),yi={data:[]},vi=0}function zi(){Ci&&(Oi.paraNumber++,xi.paraStart=!0,Ci=!1),Ei&&(xi.startCharSize=Ri,xi.endCharSize=Ei,Ri=0),xi.width=Si,Wi.width?ui(xi):Mi&&Ui(),Di.push(xi),xi={words:[]},Si=0}function Ui(){Si>(Oi.maxWidth||0)&&(Oi.maxWidth=Si)}const{top:Yi,right:Xi,bottom:qi,left:Ni}=U;function Gi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ji={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,r=s.__getInput("width")||0,o=s.__getInput("height")||0;const{__padding:l}=s;s.motionText&&(r=o=0),l&&(r?(n=l[Ni],r-=l[Xi]+l[Ni],!r&&(r=.01)):s.autoSizeAlign||(n=l[Ni]),o?(a=l[Yi],o-=l[Yi]+l[qi],!o&&(o=.01)):s.autoSizeAlign||(a=l[Yi]));const c={bounds:{x:n,y:a,width:r,height:o},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Oi=t,Di=t.rows,Wi=t.bounds,Mi=!Wi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=i,{width:l}=Wi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Ci=!0,Li=null,Ri=Bi=Ei=vi=Si=0,yi={data:[]},xi={words:[]};for(let s=0,c=(e=[...e]).length;s<c;s++)ki=e[s],"\n"===ki?(vi&&Fi(),xi.paraEnd=!0,zi(),Ci=!0):(Ti=ci(ki),Ti===fi&&"none"!==r&&(ki=hi(ki,r,!vi)),Bi=o.measureText(ki).width,n&&(n<0&&(Ei=Bi),Bi+=n),Ai=Ti===pi&&(Li===pi||Li===fi)||Li===pi&&Ti!==_i,Pi=!(Ti!==gi&&Ti!==pi||Li!==wi&&Li!==_i),bi=Ci&&a?l-a:l,t&&l&&Si+vi+Bi>bi&&(i?(vi&&Fi(),Si&&zi()):(Pi||(Pi=Ti===fi&&Li==_i),Ai||Pi||Ti===mi||Ti===gi||Ti===pi||vi+Bi>bi?(vi&&Fi(),Si&&zi()):Si&&zi()))," "===ki&&!0!==Ci&&Si+vi===0||(Ti===mi?(" "===ki&&vi&&Fi(),Ii(ki,Bi),Fi()):Ai||Pi?(vi&&Fi(),Ii(ki,Bi)):Ii(ki,Bi)),Li=Ti);vi&&Fi(),Si&&zi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Oi.paraNumber++,Si=o.measureText(t).width,Di.push({x:a||0,text:t,width:Si,paraStart:!0}),Mi&&Ui()})}(c,t,s),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Gi(e,"x",t[Ni]);break;case"right":Gi(e,"x",-t[Xi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Gi(e,"y",t[Yi]);break;case"bottom":Gi(e,"y",-t[qi])}}(l,c,s,r,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:c,verticalAlign:d,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(e.__autoHeight?w:_,a),n>1&&(t.overflow=n);else if(_||u)switch(d){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,S=g||u?g:t.maxWidth;for(let r=0,d=n;r<d;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=a,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a}=e,r=e.__letterSpacing||e.motionText,o=i&&n.includes("both"),l=o||i&&n.includes("justify"),c=l&&n.includes("letter");let d,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=a&&t.paraStart?a:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,c?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=r||t.isOverflow||c?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):d=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(d+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(c,s,r),c.overflow&&function(t,e,s,n){const{rows:a,overflow:r}=t;let{textOverflow:o}=e;if(r&&a.splice(r),n&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const c=o?i.canvas.measureText(o).width:0,d=s+n-c;("none"===e.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,n,r),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,T(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,s),c}};const Vi={string:function(t,i){if(!t)return"#000";const n=s(i)&&i<1;if(e(t)){if(!n||!q.object)return t;t=q.object(t)}let a=o(t.a)?1:t.a;n&&(a*=i);const r=t.r+","+t.g+","+t.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(V,ji),Object.assign(q,Vi),Object.assign(Y,Tt),Object.assign(X,le),Object.assign(N,Ee),Object.assign(G,Ye);try{wx&&Z(0,wx)}catch(t){}export{lt as Layouter,Q as LeaferCanvas,H as PathNodeHandleType,dt as Renderer,$ as Watcher,Z as useCanvas};
1
+ import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as r,isUndefined as o,ResizeEvent as l,Creator as c,LeaferImage as d,FileHelper as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as x,Bounds as v,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as T,BoundsHelper as L,FourNumberHelper as A,Matrix as P,ImageEvent as C,MatrixHelper as O,MathHelper as W,AlignHelper as M,PointHelper as D,getMatrixData as I,AroundHelper as F,OneRadian as z,Direction4 as U}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as Y,PaintImage as X,ColorConvert as q,PaintGradient as N,Effect as G,Group as j,TextConvert as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={}));class Q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:a,pixelRatio:r}=this.config,o={width:e||t.width,height:a||t.height,pixelRatio:r};this.resize(o),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,this.updateViewSize(),t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,r),this.resize(t),o(this.width)||this.resizeListener(new l(t,e))}}function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(h.mimeType(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(h.mimeType(h.fileType(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let r;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,r=!0);const o=e.getFileSystemManager();o.writeFile({filePath:s,data:t,encoding:"base64",success(){r?i.miniapp.saveToAlbum(s).then(()=>{o.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:(t,e,s)=>new Promise((e,s)=>{const n=i.getCanvas().view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),loadContent:(t,i="text")=>new Promise((s,n)=>e.request({url:t,responseType:"arrayBuffer"===i?"arraybuffer":"text",success:t=>s("json"===i&&"string"==typeof t.data?JSON.parse(t.data):t.data),fail:n})),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient,u(i,"devicePixelRatio",{get:()=>Math.max(1,e.getWindowInfo?e.getWindowInfo().pixelRatio:e.getSystemInfoSync().pixelRatio)})}Object.assign(c,{canvas:(t,e)=>new Q(t,e),image:t=>new d(t)}),i.name="miniapp",i.getCanvas=function(){const{renderCanvas:t}=i;return t&&t.view?t:i.canvas},i.requestRender=function(t){const{view:e}=i.getCanvas();e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)};class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new f;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 f,this.target=t,e&&(this.config=a.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(p.REQUEST)}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}__onChildEvent(t){this.config.usePartLayout&&(t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent))),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y;const{worldBounds:st}=x;class nt{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:at,updateAllChange:rt}=m,ot=b.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new k,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1&&this.config.usePartLayout?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=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=B,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new B(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new B(a,o,this.times)),i.emitEvent(new B(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){at(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=b.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=a.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.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=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new v(s);i.save(),s.spread(dt.clipSpread).ceil();const{ceilPartPixel:a}=this.config;i.clipWorld(s,a),i.clearWorld(s,a),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s,target:n}=this,a=t.includes(n.__world),r=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),i.render(n,s,r),this.renderBounds=e=e||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e,i){t.__.__font?Y.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}dt.clipSpread=10,Object.assign(c,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=lt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const ut={};function ft(t,e,i,s,n){const a=i.__;T(t)?Y.drawStrokesStyle(t,e,!1,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),s.stroke()),a.__useArrow&&Y.strokeArrow(t,i,s,n)}function pt(t,e,i,s,n){const a=i.__;T(t)?Y.drawStrokesStyle(t,e,!0,i,s,n):(s.setStroke(t,a.__strokeWidth*e,a),Y.drawTextStroke(i,s,n))}function gt(t,e,i,s,n){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,pt(t,2,i,a,n),a.blendMode="outside"===e?"destination-out":"destination-in",Y.fillText(i,a,n),a.blendMode="normal",m.copyCanvasByWorld(i,s,a),a.recycle(i.__nowWorld)}const{getSpread:_t,copyAndSpread:wt,toOuterOf:mt,getOuterOf:yt,getByMove:xt,move:vt,getIntersectData:St}=L,bt={};let kt;const{stintSet:Bt}=a,{hasTransparent:Rt}=q;function Et(t,i,s){if(!T(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout,{type:r}=i;switch(r){case"image":case"film":case"video":if(!i.url)return;n=X.image(s,t,i,a,!kt||!kt[i.url]),"image"!==r&&X[r](n);break;case"linear":n=N.linearGradient(i,a);break;case"radial":n=N.radialGradient(i,a);break;case"angular":n=N.conicGradient(i,a);break;case"solid":const{color:e,opacity:l}=i;n={type:r,style:q.string(e,l)};break;default:o(i.r)||(n={type:"solid",style:q.string(i)})}if(n&&(n.originPaint=i,e(n.style)&&Rt(n.style)&&(n.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}return n}const Tt={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];S(o)||(o=[o]),kt=X.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Et(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));s.length?(i["_"+t]=s,s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Bt(i,"__isAlphaPixelFill",n),Bt(i,"__isTransparentFill",a)):(Bt(i,"__isAlphaPixelStroke",n),Bt(i,"__isTransparentStroke",a),Bt(i,"__hasMultiStrokeStyle",r))):(i.__removePaint(t,!1),i["_"+t]="")},fill:function(t,e,i,s){i.fillStyle=t,ht(e,i,s)},fills:function(t,e,i,s){let n,a,r;for(let o=0,l=t.length;o<l;o++){if(n=t[o],a=n.originPaint,n.image){if(r?r++:r=1,X.checkImage(n,!e.__.__font,e,i,s))continue;if(!n.style){1===r&&n.image.isPlacehold&&e.drawImagePlaceholder(n,i,s);continue}}if(i.fillStyle=n.style,n.transform||a.scaleFixed){if(i.save(),n.transform&&i.transform(n.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,a.scaleFixed,!1);1!==t&&i.scale(t,s)}a.blendMode&&(i.blendMode=a.blendMode),ht(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),ht(e,i,s),i.restoreBlendMode()):ht(e,i,s)}},fillPathOrText:ht,fillText:function(t,e,i){if(t.motionText)return ut.fillMotionText(t,e,i);const s=t.__,{rows:n,decorationY:a}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(a){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const n=e.__;if(n.__strokeWidth)if(n.__font)Y.strokeText(t,e,i,s);else if(n.__pathForStroke)Y.fillStroke(t,e,i,s);else switch(n.strokeAlign){case"center":ft(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),ft(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const n=e.__;if(n.__fillAfterStroke)ft(t,2,e,i,s);else{const{renderBounds:a}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ft(t,2,e,r,s),r.clipUI(n),r.clearWorld(a),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){Y.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":pt(t,1,e,i,s);break;case"inside":gt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,i,s):gt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,n=t.__.__textDrawData;const{rows:a,decorationY:r}=n;for(let t=0,i=a.length;t<i;t++)s=a[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=n;a.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,n,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||n.setStroke(void 0,o.__strokeWidth*e,o);for(let c=0,d=t.length;c<d;c++)if(r=t[c],(!r.image||!X.checkImage(r,!1,s,n,a))&&r.style){if(l){const{strokeStyle:t}=r;t?n.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(r.style,o.__strokeWidth*e,o)}else n.strokeStyle=r.style;r.originPaint.blendMode?(n.saveBlendMode(r.originPaint.blendMode),i?Y.drawTextStroke(s,n,a):n.stroke(),n.restoreBlendMode()):i?Y.drawTextStroke(s,n,a):n.stroke()}},shape:function(t,e,s){const n=e.getSameCanvas(),a=e.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,d,h,u,f,p;mt(o.strokeSpread?(wt(bt,o.boxBounds,o.strokeSpread),bt):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,c=f=l,d=r;else{let n;if(i.fullImageShadow)n=l;else{const t=o.renderShapeSpread?_t(a,A.swapAndScale(o.renderShapeSpread,g,_)):a;n=St(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=yt(l,u),c=xt(f,-u.e,-u.f),d=yt(r,u),vt(d,-u.e,-u.f);const y=s.matrix;y?(h=new P(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:u,bounds:c,renderBounds:d,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Lt,At=new v;const{isSame:Pt}=L;function Ct(t,e,i,s,n,a){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate(),m.updateBounds(t),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),"brush"===i.mode&&X.brush(t,e,n),!n.data){X.createData(n,s,i,a);const{transform:t}=n.data,{opacity:e}=i,r=(t&&!t.onlyScale||o.path||o.cornerRadius)&&!n.brush;(r||e&&e<1||i.blendMode)&&(n.complex=!r||2)}return i.filter&&X.applyFilter(n,s,i.filter,t),r}function Ot(t,e){Dt(t,C.LOAD,e)}function Wt(t,e){Dt(t,C.LOADED,e)}function Mt(t,e,i){e.error=i,t.forceUpdate("surface"),Dt(t,C.ERROR,e)}function Dt(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function It(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Ft,translate:zt}=O,Ut=new v,Yt={},Xt={};function qt(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let Nt={},Gt=I();const{get:jt,set:Vt,rotateOfOuter:Ht,translate:Qt,scaleOfOuter:Zt,multiplyParent:$t,scale:Jt,rotate:Kt,skew:te}=O;function ee(t,e,i,s,n,a,r,o){r&&Kt(t,r),o&&te(t,o.x,o.y),n&&Jt(t,n,a),Qt(t,e.x+i,e.y+s)}function ie(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:se,scale:ne,copy:ae}=O,{getFloorScale:re}=W,{abs:oe}=Math;const le={image:function(t,e,i,s,n){let a,r;const o=E.get(i,i.type);return Lt&&i===Lt.paint&&Pt(s,Lt.boxBounds)?a=Lt.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),Lt=o.use>1?{leafPaint:a,paint:i,boxBounds:At.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Ct(t,e,i,o,a,s),n&&(Ot(t,r),Wt(t,r))):o.error?n&&Mt(t,r,o.error):(n&&(It(t,!0),Ot(t,r)),a.loadId=o.load(()=>{It(t,!1),t.destroyed||(Ct(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Wt(t,r)),a.loadId=void 0},e=>{It(t,!1),Mt(t,r,e),a.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,e,s,n,a){const{scaleX:r,scaleY:o}=X.getImageRenderScaleData(t,s,n,a),l=t.film?t.nowIndex:r+"-"+o,{image:c,brush:d,data:h,originPaint:u}=t,{exporting:f,snapshot:p}=a;if(!h||t.patternId===l&&!f||p){if(!d||!t.style)return!1}else if(e&&(h.repeat?e=!1:u.changeful||t.film||"miniapp"===i.name||f||(e=i.image.isLarge(c,r,o)||c.width*r>8096||c.height*o>8096)),e)s.__.__isFastShadow&&(n.fillStyle=t.style||"#000",n.fill());else if(!t.style||u.sync||f?X.createPattern(t,s,n,a):X.createPatternTask(t,s,n,a),!d||!t.style)return!1;return X.drawImage(t,r,o,s,n,a),!0},drawImage:function(t,e,i,s,n,a){const{data:r,image:o,brush:l,complex:c}=t;let{width:d,height:h}=o,u=l||o;if(c){const{blendMode:a,opacity:o}=t.originPaint,{transform:l}=r;n.save(),2===c&&n.clipUI(s),a&&(n.blendMode=a),o&&(n.opacity*=o),l&&n.transform(l),u.render(n,0,0,d,h,s,t,e,i),n.restore()}else r.scaleX&&(d*=r.scaleX,h*=r.scaleY),u.render(n,0,0,d,h,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:a}=t;if(t.brush&&X.addBrushScale(n,t,e),i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return a&&a.scaleX&&(n.scaleX*=Math.abs(a.scaleX),n.scaleY*=Math.abs(a.scaleY)),n},recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,n,a,r,o;const l=e.__leaf;for(let c=0,d=i.length;c<d;c++)s=i[c],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,E.recyclePaint(s),s.brush&&X.recycleBrush(s,l),e.__willDestroy&&n.parent&&X.recycleFilter(n,l),n.loading&&(r||(r=e.__input&&e.__input[t]||[],S(r)||(r=[r])),n.unload(i[c].loadId,!r.some(t=>t.url===o))));return a}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=E.patternTasker.add(()=>ie(this,void 0,void 0,function*(){X.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,e,s,n){let{scaleX:a,scaleY:r}=X.getImageRenderScaleData(t,e,s,n),o=t.film?t.nowIndex:a+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!i.image.isLarge(t.image,a,r)||t.data.repeat)){const{image:l,brush:c,data:d}=t,{transform:h,gap:u}=d,f=X.getPatternFixScale(t,a,r);let p,g,_,{width:w,height:m}=l,{opacity:y}=t.originPaint;(c||1===y)&&(y=void 0),f&&(a*=f,r*=f),w*=a,m*=r,u&&!c&&(g=u.x*a/oe(d.scaleX||1),_=u.y*r/oe(d.scaleY||1)),(h||1!==a||1!==r)&&(a*=re(w+(g||0)),r*=re(m+(_||0)),p=se(),h&&ae(p,h),ne(p,1/a,1/r));const x=l.getCanvas(w,m,y,void 0,g,_,e.leafer&&e.leafer.config.smooth,d.interlace);c?(t.style=x,X.cacheBrush(t,e,s,n)):t.style=l.getPattern(x,d.repeat||i.origin.noRepeat||"no-repeat",p,t),t.patternId=o}},getPatternFixScale:function(t,e,s){const{image:n}=t;let a,r=i.image.maxPatternSize,o=n.width*n.height;return n.isSVG?e>1&&(a=Math.ceil(e)/e):r>o&&(r=o),(o*=e*s)>r&&(a=Math.sqrt(r/o)),a},createData:function(t,e,i,s){t.data=X.getPatternData(i,s,e)},getPatternData:function(t,i,n){t.padding&&(i=Ut.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:r}=n,{mode:o,align:l,offset:c,scale:d,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,interlace:w}=t,m=i.width===a&&i.height===r,y={mode:o},x="center"!==l&&(u||0)%180==90;let v,S;switch(L.set(Xt,0,0,x?r:a,x?a:r),o&&"cover"!==o&&"fit"!==o?((d||h)&&(W.getScaleData(d,h,n,Yt),v=Yt.scaleX,S=Yt.scaleY),(l||_||g)&&(v&&L.scale(Xt,v,S,!0),l&&M.toPoint(l,Xt,i,Xt,!0,!0))):m&&!u||(v=S=L.getFitScale(i,Xt,"fit"!==o),L.put(i,n,l,v,!1,Xt),L.scale(Xt,v,S,!0)),c&&D.move(Xt,c),o){case"stretch":m?v&&(v=S=void 0):(v=i.width/a,S=i.height/r,X.stretchMode(y,i,v,S));break;case"normal":case"clip":if(Xt.x||Xt.y||v||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),X.clipMode(y,i,Xt.x,Xt.y,v,S,u,f,t,e),t&&(v=v?v*t:t,S=S?S*e:e)}break;case"repeat":(!m||v||u||f)&&X.repeatMode(y,i,a,r,Xt.x,Xt.y,v,S,u,f,l,t.freeTransform);case"brush":g||(y.repeat="repeat");const e=T(g);(_||e)&&(y.gap=function(t,e,i,s,n){let a,r;T(t)?(a=t.x,r=t.y):a=r=t;return{x:qt(a,i,n.width,e&&e.x),y:qt(r,s,n.height,e&&e.y)}}(_,e&&g,Xt.width,Xt.height,i));break;default:v&&X.fillOrFitMode(y,i,Xt.x,Xt.y,v,S,u)}return y.transform||"brush"===o||(i.x||i.y)&&zt(y.transform=Ft(),i.x,i.y),v&&(y.scaleX=v,y.scaleY=S),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w&&(y.interlace=s(w)||"percent"===w.type?{type:"x",offset:w}:w),y},stretchMode:function(t,e,i,s){const n=jt(),{x:a,y:r}=e;a||r?Qt(n,a,r):i>0&&s>0&&(n.onlyScale=!0),Jt(n,i,s),t.transform=n},fillOrFitMode:function(t,e,i,s,n,a,r){const o=jt();Qt(o,e.x+i,e.y+s),Jt(o,n,a),r&&Ht(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,n,a,r,o,l,c){const d=jt();ee(d,e,i,s,n,a,r,o),l&&(r||o?(Vt(Gt),Zt(Gt,e,l,c),$t(d,Gt)):Zt(d,e,l,c)),t.transform=d},repeatMode:function(t,e,i,s,n,a,r,o,l,c,d,h){const u=jt();if(h)ee(u,e,n,a,r,o,l,c);else{if(l)if("center"===d)Ht(u,{x:i/2,y:s/2},l);else switch(Kt(u,l),l){case 90:Qt(u,s,0);break;case 180:Qt(u,i,s);break;case 270:Qt(u,0,i)}Nt.x=e.x+n,Nt.y=e.y+a,Qt(u,Nt.x,Nt.y),r&&Zt(u,Nt,r,o)}t.transform=u}},{toPoint:ce}=F,{hasTransparent:de}=q,he={},ue={};function fe(t,i,s,n){if(s){let a,r,o,l;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(o=t/(c-1),r=q.string(a,n)):(o=a.offset,r=q.string(a.color,n)),i.addColorStop(o,r),!l&&de(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:pe,getDistance:ge}=D,{get:_e,rotateOfOuter:we,scaleOfOuter:me}=O,{toPoint:ye}=F,xe={},ve={};function Se(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=pe(e,i);a=_e(),n?(me(a,e,r/o*(s||1),1),we(a,e,t+90)):(me(a,e,1,r/o*(s||1)),we(a,e,t))}return a}const{getDistance:be}=D,{toPoint:ke}=F,Be={},Re={};const Ee={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:r}=t;ce(s||"top",e,he),ce(n||"bottom",e,ue);const o=i.canvas.createLinearGradient(he.x,he.y,ue.x,ue.y),l={type:a,style:o};return fe(l,o,t.stops,r),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;ye(s||"center",e,xe),ye(n||"bottom",e,ve);const l=i.canvas.createRadialGradient(xe.x,xe.y,0,xe.x,xe.y,ge(xe,ve)),c={type:a,style:l};fe(c,l,t.stops,r);const d=Se(e,xe,ve,o,!0);return d&&(c.transform=d),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:r,rotation:o,stretch:l}=t;ke(s||"center",e,Be),ke(n||"bottom",e,Re);const c=i.conicGradientSupport?i.canvas.createConicGradient(o?o*z:0,Be.x,Be.y):i.canvas.createRadialGradient(Be.x,Be.y,0,Be.x,Be.y,be(Be,Re)),d={type:a,style:c};fe(d,c,t.stops,r);const h=Se(e,Be,Re,l||1,i.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Se},{copy:Te,move:Le,toOffsetOutBounds:Ae}=L,{max:Pe,abs:Ce}=Math,Oe={},We=new P,Me={};function De(t,e){let i,s,n,a,r=0,o=0,l=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,a=1.5*(t.blur||0),n=Ce(t.spread||0),r=Pe(r,n+a-s),o=Pe(o,n+a+i),l=Pe(l,n+a+s),c=Pe(c,n+a-i)}),r===o&&o===l&&l===c?r:[r,o,l,c]}function Ie(t,e,s){const{shapeBounds:n}=s;let a,r;i.fullImageShadow?(Te(Oe,t.bounds),Le(Oe,e.x-n.x,e.y-n.y),a=t.bounds,r=Oe):(a=n,r=e),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:Fe}=L,ze={};const Ue=De;const Ye={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ae(l,Me,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Me.offsetX+(r.x||0)*h*_,Me.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_,q.string(r.color)),n=G.getShadowTransform(t,f,i,r,Me,_),n&&f.setTransform(n),Ie(f,Me,i),n&&f.resetTransform(),s=c,r.box&&(f.restore(),f.save(),o&&(f.copyWorld(f,c,a,"copy"),s=a),o?f.copyWorld(o,a,a,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Fe(l,ze,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(ze.offsetX+(r.x||0)*h*_,ze.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_),n=G.getShadowTransform(t,f,i,r,ze,_,!0),n&&f.setTransform(n),Ie(f,ze,i),f.restore(),o?(f.copyWorld(f,c,a,"copy"),f.copyWorld(o,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,d,l,"source-out"),s=c),f.fillWorld(s,q.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:De,getShadowTransform:function(t,e,i,s,n,a,r){if(s.spread){const i=2*s.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return We.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/o,1+i/l),We}},isTransformShadow(t){},getInnerShadowSpread:Ue},{excludeRenderBounds:Xe}=x;let qe;function Ne(t,e,i,s,n,a,r,o){switch(e){case"grayscale":qe||(qe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);je(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":je(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function je(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}j.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let c=0,d=l.length;c<d;c++){if(i=l[c],o=i.__.mask,o){r&&(Ne(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||Xe(i,e)||i.__render(t,e),a=i.__.opacity,qe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=Ge(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e));continue}const d=1===a&&i.__.__blendMode;d&&Ne(this,r,t,n,s,a,void 0,!1),Xe(i,e)||i.__render(n||t,e),d&&Ne(this,r,t,n,s,a,d,!1)}Ne(this,r,t,n,s,a,void 0,!0)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",He=Ve+"_#~&*+\\=|≮≯≈≠=…",Qe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function Ze(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const $e=Ze("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Je=Ze("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Ze(Ve),ti=Ze(He),ei=Ze("- —/~|┆·");var ii;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ii||(ii={}));const{Letter:si,Single:ni,Before:ai,After:ri,Symbol:oi,Break:li}=ii;function ci(t){return $e[t]?si:ei[t]?li:Je[t]?ai:Ke[t]?ri:ti[t]?oi:Qe.test(t)?ni:si}const di={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function hi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ui}=di,{Letter:fi,Single:pi,Before:gi,After:_i,Symbol:wi,Break:mi}=ii;let yi,xi,vi,Si,bi,ki,Bi,Ri,Ei,Ti,Li,Ai,Pi,Ci,Oi,Wi,Mi,Di=[];function Ii(t,e){Ei&&!Ri&&(Ri=Ei),yi.data.push({char:t,width:e}),vi+=e}function Fi(){Si+=vi,yi.width=vi,xi.words.push(yi),yi={data:[]},vi=0}function zi(){Ci&&(Oi.paraNumber++,xi.paraStart=!0,Ci=!1),Ei&&(xi.startCharSize=Ri,xi.endCharSize=Ei,Ri=0),xi.width=Si,Wi.width?ui(xi):Mi&&Ui(),Di.push(xi),xi={words:[]},Si=0}function Ui(){Si>(Oi.maxWidth||0)&&(Oi.maxWidth=Si)}const{top:Yi,right:Xi,bottom:qi,left:Ni}=U;function Gi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ji={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,r=s.__getInput("width")||0,o=s.__getInput("height")||0;const{__padding:l}=s;s.motionText&&(r=o=0),l&&(r?(n=l[Ni],r-=l[Xi]+l[Ni],!r&&(r=.01)):s.autoSizeAlign||(n=l[Ni]),o?(a=l[Yi],o-=l[Yi]+l[qi],!o&&(o=.01)):s.autoSizeAlign||(a=l[Yi]));const c={bounds:{x:n,y:a,width:r,height:o},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Oi=t,Di=t.rows,Wi=t.bounds,Mi=!Wi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=i,{width:l}=Wi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Ci=!0,Li=null,Ri=Bi=Ei=vi=Si=0,yi={data:[]},xi={words:[]};for(let s=0,c=(e=[...e]).length;s<c;s++)ki=e[s],"\n"===ki?(vi&&Fi(),xi.paraEnd=!0,zi(),Ci=!0):(Ti=ci(ki),Ti===fi&&"none"!==r&&(ki=hi(ki,r,!vi)),Bi=o.measureText(ki).width,n&&(n<0&&(Ei=Bi),Bi+=n),Ai=Ti===pi&&(Li===pi||Li===fi)||Li===pi&&Ti!==_i,Pi=!(Ti!==gi&&Ti!==pi||Li!==wi&&Li!==_i),bi=Ci&&a?l-a:l,t&&l&&Si+vi+Bi>bi&&(i?(vi&&Fi(),Si&&zi()):(Pi||(Pi=Ti===fi&&Li==_i),Ai||Pi||Ti===mi||Ti===gi||Ti===pi||vi+Bi>bi?(vi&&Fi(),Si&&zi()):Si&&zi()))," "===ki&&!0!==Ci&&Si+vi===0||(Ti===mi?(" "===ki&&vi&&Fi(),Ii(ki,Bi),Fi()):Ai||Pi?(vi&&Fi(),Ii(ki,Bi)):Ii(ki,Bi)),Li=Ti);vi&&Fi(),Si&&zi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Oi.paraNumber++,Si=o.measureText(t).width,Di.push({x:a||0,text:t,width:Si,paraStart:!0}),Mi&&Ui()})}(c,t,s),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Gi(e,"x",t[Ni]);break;case"right":Gi(e,"x",-t[Xi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Gi(e,"y",t[Yi]);break;case"bottom":Gi(e,"y",-t[qi])}}(l,c,s,r,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:c,verticalAlign:d,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(e.__autoHeight?w:_,a),n>1&&(t.overflow=n);else if(_||u)switch(d){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,S=g||u?g:t.maxWidth;for(let r=0,d=n;r<d;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=a,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a}=e,r=e.__letterSpacing||e.motionText,o=i&&n.includes("both"),l=o||i&&n.includes("justify"),c=l&&n.includes("letter");let d,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=a&&t.paraStart?a:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,c?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=r||t.isOverflow||c?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):d=function(t,e,i,s,n){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,d,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(d+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(c,s,r),c.overflow&&function(t,e,s,n){const{rows:a,overflow:r}=t;let{textOverflow:o}=e;if(r&&a.splice(r),n&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const c=o?i.canvas.measureText(o).width:0,d=s+n-c;("none"===e.textWrap?a:[a[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,n,r),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,T(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(c,s),c}};const Vi={string:function(t,i){if(!t)return"#000";const n=s(i)&&i<1;if(e(t)){if(!n||!q.object)return t;t=q.object(t)}let a=o(t.a)?1:t.a;n&&(a*=i);const r=t.r+","+t.g+","+t.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(V,ji),Object.assign(q,Vi),Object.assign(Y,Tt),Object.assign(X,le),Object.assign(N,Ee),Object.assign(G,Ye);try{wx&&Z(0,wx)}catch(t){}export{lt as Layouter,Q as LeaferCanvas,H as PathNodeHandleType,dt as Renderer,$ as Watcher,Z as useCanvas};
2
2
  //# sourceMappingURL=miniapp.esm.min.js.map