@leafer-draw/worker 1.9.10 → 1.9.11

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