leafer-ui 1.0.0-beta.12 → 1.0.0-beta.16
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/README.md +2 -6
- package/dist/web.esm.js +2652 -0
- package/dist/web.esm.min.js +1 -0
- package/dist/web.js +10520 -0
- package/dist/web.min.js +1 -0
- package/package.json +10 -7
- package/src/index.ts +1 -7
- package/types/index.d.ts +1 -0
- package/dist/global.js +0 -1
- package/dist/index.js +0 -1
- package/src/global.ts +0 -5
- package/src/index.d.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as o,LeafHelper as r,BranchHelper as a,Bounds as h,LeafBoundsHelper as l,BoundsHelper as d,Debug as c,LeafLevelList as u,LayoutEvent as g,Run as f,ImageManager as p,Platform as _,AnimateEvent as w,ResizeEvent as v,Creator as y,LeaferCanvasBase as m,Cursor as x,canvasSizeAttrs as b,canvasPatch as B,InteractionHelper as L,MathHelper as E,InteractionBase as R,LeaferImage as T,FileHelper as M,MatrixHelper as k,ImageEvent as S,PointHelper as C,TaskProcessor as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as A,Paint as D,Effect as P,TextConvert as W,Export as I}from"@leafer-ui/core";export*from"@leafer-ui/core";class F{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,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(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(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 n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(o.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:U,updateAllWorldOpacity:V}=r,{pushAllChildBranch:Y,pushAllParent:G}=a;const{worldBounds:N}=l,{setByListWithHandle:j}=d;class z{constructor(e){this.updatedBounds=new h,this.beforeBounds=new h,this.afterBounds=new h,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){j(this.beforeBounds,this.updatedList.list,N)}setAfter(){j(this.afterBounds,this.updatedList.list,N),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:X,updateAllChange:H}=r,{pushAllBranchStack:K,updateWorldBoundsByBranchStack:q}=a,Q=c.get("Layouter");class ${constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,i&&(this.config=e.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(g.START),this.layoutOnce(),t.emitEvent(new g(g.END,this.layoutedBlocks,this.times))}catch(t){Q.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?Q.warn("layouting"):this.times>3?Q.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.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=f.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:r}=g,a=this.getBlocks(s);a.forEach((t=>{t.setBefore()})),i.emitEvent(new g(n,a,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.useZoomProxy&&(i.matrixChanged?(U(t),e.push(t),t.isBranch&&Y(t,e),G(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),G(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&V(t),t.__updateChange()}))}(s),a.forEach((t=>t.setAfter())),i.emitEvent(new g(o,a,this.times)),i.emitEvent(new g(r,a,this.times)),this.addBlocks(a),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:o}=g,r=this.getBlocks(new t(i));i.emitEvent(new g(s,r,this.times)),$.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new g(n,r,this.times)),i.emitEvent(new g(o,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){if(X(t),t.isBranch){const e=[t];K(t,e),q(e)}else t.__updateWorldBounds();H(t)}createBlock(t){return new z(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(g.REQUEST,this.layout,this),t.on_(g.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Z=c.get("Renderer");class J{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(g.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new h,Z.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),p.clearRecycled()}catch(t){this.rendering=!1,Z.error(t)}Z.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Z.warn("rendering"):this.times>3?Z.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new h,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Z.warn("PartRender: need update attr");e.some((t=>t.includes(this.target.__world)))&&this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=(new h).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o),i.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),f.end(t)}__render(t,e){const i=(null==t?void 0:t.includes(this.target.__world))?{}:{bounds:t};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,i),this.renderBounds=e||t,this.renderOptions=i,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(i),c.showBoundsView&&this.renderBoundsView(i),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new h;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();_.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(w.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new h(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Z.warn(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 i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(g.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(v.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:tt}=d;class et{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),a=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:a,leaf:r,throughPath:o.length?this.getThroughPath(o):a}:{path:a,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,o,r;for(let t=0,e=s.length;t<e;t++){n=s[t],o=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!o||!o.has(r));t++)i.push(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||tt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class it{constructor(t,i){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,i&&(this.config=e.default(i,this.config)),this.findPath=new et(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===_.name&&this.target.emit(g.CHECK_UPDATE),this.findPath.getByPoint(t,e,i)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let i,s=this.innerIdList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(i=e,this.innerIdList[t]=i,!0))),i)}getById(t,e){let i,s=this.idList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(i=e,this.idList[t]=i,!0))),i)}getByClassName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.className===t&&i.push(e),!1))),i}getByTagName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.__tag===t&&i.push(e),!1))),i}loopFind(t,e){if(e(t))return;const{children:i}=t;for(let s=0,n=i.length;s<n;s++){if(e(t=i[s]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(y,{watcher:(t,e)=>new F(t,e),layouter:(t,e)=>new $(t,e),renderer:(t,e,i)=>new J(t,e,i),selector:(t,e)=>new it(t,e)}),_.layout=$.fullLayout;const st=c.get("LeaferCanvas");class nt extends m{init(){const{view:t}=this.config;t?this.__createViewFrom(t):this.__createView();const{style:e}=this.view;e.display||(e.display="block"),this.parentView=this.view.parentElement,_.syncDomFont&&!this.parentView&&(this.view.style.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(this.config)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}setCursor(t){const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,e,i=0){if(i++,t instanceof Array)t.forEach((t=>this.eachCursor(t,e,i)));else{const s="string"==typeof t&&x.get(t);s&&i<2?this.eachCursor(s,e,i):e.push(t)}}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;if(t.hasChildNodes()){const{style:e}=i;e.position="absolute",e.top=e.left="0px",t.style.position||(t.style.position="relative")}t.appendChild(i)}else st.error(`no id: ${t}`),this.__createView()}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:s}=this.view;s.width=t+"px",s.height=e+"px",this.view.width=t*i,this.view.height=e*i}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(t,e){this.autoBounds=t,this.resizeListener=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t&&(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect()))}catch(t){this.imitateResizeObserver()}}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),_.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(t){const i=this.view,{x:s,y:n,width:o,height:r}=this.autoBounds.getBoundsFrom(t);if(o!==this.width||r!==this.height){const{style:t}=i,{pixelRatio:a}=this;t.marginLeft=s+"px",t.marginTop=n+"px";const h={width:o,height:r,pixelRatio:a},l={};e.copyAttrs(l,this,b),this.resize(h),void 0!==this.width&&this.resizeListener(new v(h,l))}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}B(CanvasRenderingContext2D.prototype),B(Path2D.prototype);const ot={convert(t,e){const i=L.getBase(t),s=Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,e){const i=L.getBase(t);return Object.assign(Object.assign({},i),{x:e.x,y:e.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,e){const i=ot.getTouch(t),s=L.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",pressure:i.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},rt={getMove(t,e){let{moveSpeed:i}=e,{deltaX:s,deltaY:n}=t;return t.shiftKey&&!s&&(s=n,n=0),s>50&&(s=Math.max(50,s/3)),n>50&&(n=Math.max(50,n/3)),{x:-s*i*2,y:-n*i*2}},getScale(t,e){let i,s=1,{zoomMode:n,zoomSpeed:o}=e;const r=t.deltaY||t.deltaX;if(n?(i=!t.deltaX&&(_.intWheelDeltaY?Math.abs(r)>17:Math.ceil(r)!==r),(t.shiftKey||t.metaKey||t.ctrlKey)&&(i=!0)):i=!t.shiftKey&&(t.metaKey||t.ctrlKey),i){o=E.within(o,0,1);s=1-r/(25*(t.deltaY?e.delta.y:e.delta.x)*(1-o)+10),s<.5&&(s=.5),s>=1.5&&(s=1.5)}return s}},at={convert(t){const e=L.getBase(t);return Object.assign(Object.assign({},e),{code:t.code,key:t.key})}},{getMoveEventData:ht,getZoomEventData:lt,getRotateEventData:dt}=L;class ct extends R{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getLocal(t,e){e&&this.canvas.updateClientBounds();const{clientBounds:i}=this.canvas;return{x:t.clientX-i.x,y:t.clientY-i.y}}getTouches(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(at.convert(t))}onKeyUp(t){this.keyUp(at.convert(t))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.pointerDown(ot.convert(t,this.getLocal(t)))}onPointerMove(t){this.usePointer||(this.usePointer=!0),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerMove(ot.convert(t,this.getLocal(t,!0)))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(ot.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(ot.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(ot.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(ot.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){if(t.preventDefault(),this.multiTouchStart(t),this.usePointer)return;this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0;const e=ot.getTouch(t);this.pointerDown(ot.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=ot.getTouch(t);this.pointerMove(ot.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=ot.getTouch(t);this.pointerUp(ot.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>=2,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(L.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t);const{wheel:e}=this.config,i=e.getScale?e.getScale(t,e):rt.getScale(t,e),s=this.getLocal(t),n=L.getBase(t);1!==i?this.zoom(lt(s,i,n)):this.move(ht(s,e.getMove?e.getMove(t,e):rt.getMove(t,e),n))}onGesturestart(t){this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0}onGesturechange(t){this.preventDefaultWheel(t);const e=this.getLocal(t),i=L.getBase(t),s=t.scale/this.lastGestureScale,n=t.rotation-this.lastGestureRotation;let{rotateSpeed:o}=this.config.wheel;o=E.within(o,0,1),this.zoom(lt(e,s*s,i)),this.rotate(dt(e,n/Math.PI*180*(o/4+.1),i)),this.lastGestureScale=t.scale,this.lastGestureRotation=t.rotation}onGestureend(t){this.preventDefaultWheel(t),this.transformEnd()}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}const{mineType:ut,fileType:gt}=M;function ft(t,e){_.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(ut(e),i),canvasToBolb:(t,e,i)=>new Promise((s=>t.toBlob(s,ut(e),i))),canvasSaveAs:(t,e,i)=>new Promise((s=>{let n=document.createElement("a");n.href=t.toDataURL(ut(gt(e)),i),n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),s()})),loadImage:t=>new Promise(((e,i)=>{const s=new Image;s.setAttribute("crossOrigin","anonymous"),s.crossOrigin="anonymous",s.onload=()=>{e(s)},s.onerror=t=>{i(t)},!t.startsWith("data:")&&_.imageSuffix&&(t+=(t.includes("?")?"&":"?")+_.imageSuffix),s.src=t}))},_.canvas=y.canvas(),_.conicGradientSupport=!!_.canvas.context.createConicGradient}Object.assign(y,{canvas:(t,e)=>new nt(t,e),image:t=>new T(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new ct(t,e,i,s)}),_.name="web",_.isMobile="ontouchstart"in window,_.requestRender=function(t){window.requestAnimationFrame(t)},_.devicePixelRatio=devicePixelRatio,_.realtimeLayout=!0;const{userAgent:pt}=navigator;pt.indexOf("Firefox")>-1?(_.conicGradientRotate90=!0,_.intWheelDeltaY=!0,_.syncDomFont=!0):pt.indexOf("Safari")>-1&&-1===pt.indexOf("Chrome")&&(_.fullImageShadow=!0),pt.indexOf("Windows")>-1?(_.os="Windows",_.intWheelDeltaY=!0):pt.indexOf("Mac")>-1?_.os="Mac":pt.indexOf("Linux")>-1&&(_.os="Linux");const{get:_t,rotateOfOuter:wt,translate:vt,scaleOfOuter:yt,scale:mt,rotate:xt}=k;const{get:bt,translate:Bt}=k;function Lt(t,e,i,s){let{width:n,height:o}=e;const{opacity:r,mode:a,offset:h,scale:l,rotation:d,blendMode:c}=i,u=s.width===n&&s.height===o;c&&(t.blendMode=c);const g=t.data={mode:a};switch(a){case"strench":u||(n=s.width,o=s.height),(s.x||s.y)&&(g.transform=bt(),Bt(g.transform,s.x,s.y));break;case"clip":(h||l||d)&&function(t,e,i,s,n){const o=_t();vt(o,e.x,e.y),i&&vt(o,i.x,i.y),s&&("number"==typeof s?mt(o,s):mt(o,s.x,s.y),t.scaleX=o.a,t.scaleY=o.d),n&&xt(o,n),t.transform=o}(g,s,h,l,d);break;case"repeat":(!u||l||d)&&function(t,e,i,s,n,o){const r=_t();if(o)switch(xt(r,o),o){case 90:vt(r,s,0);break;case 180:vt(r,i,s);break;case 270:vt(r,0,i)}vt(r,e.x,e.y),n&&(yt(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(g,s,n,o,l,d);break;default:u&&!d||function(t,e,i,s,n,o){const r=_t(),a=o&&180!==o,h=i.width/(a?n:s),l=i.height/(a?s:n),d="fit"===e?Math.min(h,l):Math.max(h,l),c=i.x+(i.width-s*d)/2,u=i.y+(i.height-n*d)/2;vt(r,c,u),mt(r,d),o&&wt(r,{x:i.x+i.width/2,y:i.y+i.height/2},o),t.scaleX=t.scaleY=d,t.transform=r}(g,a,s,n,o,d)}g.width=n,g.height=o,r&&(g.opacity=r)}function Et(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function Rt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new S(t,e))}function Tt(t,e,i,s){return new(i||(i=Promise))((function(n,o){function r(t){try{h(s.next(t))}catch(t){o(t)}}function a(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:Mt,scale:kt,copy:St}=k;function Ct(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const o=s+"-"+n;if(e.patternId===o||t.destroyed)return!1;{e.patternId=o,s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e,a=t.isSVG?4096:Math.min(t.width,4096),h=t.isSVG?4096:Math.min(t.height,4096);let l,d,{width:c,height:u,scaleX:g,scaleY:f,opacity:p,transform:w,mode:v}=r;g&&(d=Mt(),St(d,w),kt(d,1/g,1/f),s*=g,n*=f),s*=i,n*=i,c*=s,u*=n,(c>a||u>h)&&(l=Math.max(c/a,u/h)),l&&(s/=l,n/=l,c/=l,u/=l),g&&(s/=g,n/=f),(w||1!==s||1!==n)&&(d||(d=Mt(),w&&St(d,w)),kt(d,1/s,1/n));const y=_.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,p),"repeat"===v?"repeat":_.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),d&&(y.setTransform?y.setTransform(d):e.transform=d)}catch(t){e.transform=d}return e.style=y,!0}}function Ot(t,e,i,s){const{scaleX:n,scaleY:o}=t.__world;if(i.data&&i.patternId!==n+"-"+o){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:r}=i.data;t*=n*e.pixelRatio,r*=o*e.pixelRatio,s=t>4096||r>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?p.patternTasker.add((()=>Tt(this,void 0,void 0,(function*(){e.bounds.hit(t.__world)&&Ct(t,i,e.pixelRatio)&&t.forceUpdate("surface")}))),300):Ct(t,i,e.pixelRatio),!1}return!1}function At(t,e){const i="fill"===e?t._fill:t._stroke;if(i instanceof Array){let s,n,o,r;for(let a=0,h=i.length;a<h;a++)s=i[a].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,p.recycle(s),s.loading&&(o||(o=t.__input&&t.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[a].loadId,!o.some((t=>t.url===r)))));return n}return null}function Dt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function Pt(t,e,i){const{strokeAlign:s}=t.__,n="string"!=typeof i;switch(s){case"center":e.setStroke(n?void 0:i,t.__.strokeWidth,t.__),n?Ft(t,i,e,!0):It(t,e);break;case"inside":Wt(t,e,i,"inside",n);break;case"outside":Wt(t,e,i,"outside",n)}}function Wt(t,e,i,s,n){const{strokeWidth:o,__font:r}=t.__,a=e.getSameCanvas(!0);a.setStroke(n?void 0:i,2*o,t.__),a.font=r,n?Ft(t,i,a,!0):It(t,a),a.blendMode="outside"===s?"destination-out":"destination-in",Dt(t,a),a.blendMode="normal",e.copyWorldToInner(a,t.__world,t.__layout.renderBounds),a.recycle()}function It(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Ft(t,e,i,s){let n;for(let o=0,r=e.length;o<r;o++)n=e[o],n.image&&Ot(t,i,n,!1)||n.style&&(i.strokeStyle=n.style,n.blendMode?(i.saveBlendMode(n.blendMode),s?It(t,i):i.stroke(),i.restoreBlendMode()):s?It(t,i):i.stroke())}const{getSpread:Ut,getOuterOf:Vt,getByMove:Yt,getIntersectData:Gt}=d;const Nt={x:.5,y:0},jt={x:.5,y:1};function zt(t,e,i){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],t.addColorStop(s.offset,A.string(s.color,i))}const{set:Xt,getAngle:Ht,getDistance:Kt}=C,{get:qt,rotateOfOuter:Qt,scaleOfOuter:$t}=k,Zt={x:.5,y:.5},Jt={x:.5,y:1},te={},ee={};const{set:ie,getAngle:se,getDistance:ne}=C,{get:oe,rotateOfOuter:re,scaleOfOuter:ae}=k,he={x:.5,y:.5},le={x:.5,y:1},de={},ce={};let ue;function ge(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=t.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:r,opacity:a}=e;return{type:n,blendMode:o,style:A.string(r,a)};case"image":return function(t,e,i,s,n){const o={type:i.type},r=o.image=p.get(i),a=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(Et(t,e,r)&&Lt(o,r,i,s),n&&(Rt(S.LOAD,a),Rt(S.LOADED,a))):r.error?n&&(t.forceUpdate("surface"),a.error=r.error,Rt(S.ERROR,a)):(n&&Rt(S.LOAD,a),o.loadId=r.load((()=>{t.destroyed||(Et(t,e,r)&&(Lt(o,r,i,s),t.forceUpdate("surface")),Rt(S.LOADED,a))}),(e=>{t.forceUpdate("surface"),a.error=e,Rt(S.ERROR,a)}))),o}(t,i,e,s,!ue||!ue[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:o,opacity:r}=t;i||(i=Nt),s||(s=jt);const a=_.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);zt(a,t.stops,r);const h={type:n,style:a};return o&&(h.blendMode=o),h}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=Zt),s||(s=Jt);const{x:h,y:l,width:d,height:c}=e;let u;Xt(te,h+i.x*d,l+i.y*c),Xt(ee,h+s.x*d,l+s.y*c),(d!==c||a)&&(u=qt(),$t(u,te,d/c*(a||1),1),Qt(u,te,Ht(te,ee)+90));const g=_.canvas.createRadialGradient(te.x,te.y,0,te.x,te.y,Kt(te,ee));zt(g,t.stops,o);const f={type:n,style:g,transform:u};return r&&(f.blendMode=r),f}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:o,blendMode:r,stretch:a}=t;i||(i=he),s||(s=le);const{x:h,y:l,width:d,height:c}=e;ie(de,h+i.x*d,l+i.y*c),ie(ce,h+s.x*d,l+s.y*c);const u=oe(),g=se(de,ce);_.conicGradientRotate90?(ae(u,de,d/c*(a||1),1),re(u,de,g+90)):(ae(u,de,1,d/c*(a||1)),re(u,de,g));const f=_.conicGradientSupport?_.canvas.createConicGradient(0,de.x,de.y):_.canvas.createRadialGradient(de.x,de.y,0,de.x,de.y,ne(de,ce));zt(f,t.stops,o);const p={type:n,style:f,transform:u};return r&&(p.blendMode=r),p}(e,s);default:return e.r?{type:"solid",style:A.string(e)}:void 0}}var fe=Object.freeze({__proto__:null,compute:function(t,e){const i=[];let s,n=t.__.__input[e];n instanceof Array||(n=[n]),ue=At(t.__,e);for(let o=0,r=n.length;o<r;o++)s=ge(t,n[o],e),s&&i.push(s);t.__["_"+e]=i.length?i:void 0},drawTextStroke:It,fill:function(t,e,i){e.fillStyle=i,t.__.__font?Dt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()},fillText:Dt,fills:function(t,e,i){let s;const{windingRule:n,__font:o}=t.__;for(let r=0,a=i.length;r<a;r++)s=i[r],s.image&&Ot(t,e,s,!o)||s.style&&(e.fillStyle=s.style,s.transform?(e.save(),e.transform(s.transform),s.blendMode&&(e.blendMode=s.blendMode),o?Dt(t,e):n?e.fill(n):e.fill(),e.restore()):s.blendMode?(e.saveBlendMode(s.blendMode),o?Dt(t,e):n?e.fill(n):e.fill(),e.restoreBlendMode()):o?Dt(t,e):n?e.fill(n):e.fill())},recycleImage:At,shape:function(t,e,i){const s=e.getSameCanvas();let n,o,r,a;const{__world:h}=t;let{scaleX:l,scaleY:d}=h;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(h,i.matrix))i.matrix?(l*=i.matrix.a,d*=i.matrix.d,n=r=Vt(h,i.matrix)):n=r=h,a=s;else{const{renderShapeSpread:s}=t.__layout,c=Gt(s?Ut(e.bounds,s*l,s*d):e.bounds,h,i.matrix);o=e.bounds.getFitMatrix(c),o.a<1&&(a=e.getSameCanvas(),t.__renderShape(a,i),l*=o.a,d*=o.d),r=Vt(h,o),n=Yt(r,-o.e,-o.f),i.matrix&&o.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:o})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:n,worldCanvas:a,shapeBounds:r,scaleX:l,scaleY:d}},stroke:function(t,e,i){const s=t.__,{strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Pt(t,e,i);else switch(o){case"center":e.setStroke(i,n,s),e.stroke();break;case"inside":e.save(),e.setStroke(i,2*n,s),s.windingRule?e.clip(s.windingRule):e.clip(),e.stroke(),e.restore();break;case"outside":const o=e.getSameCanvas(!0);o.setStroke(i,2*n,t.__),t.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(t.__layout.renderBounds),e.copyWorldToInner(o,t.__world,t.__layout.renderBounds),o.recycle()}},strokeText:Pt,strokes:function(t,e,i){const s=t.__,{strokeWidth:n,strokeAlign:o,__font:r}=s;if(n)if(r)Pt(t,e,i);else switch(o){case"center":e.setStroke(void 0,n,s),Ft(t,i,e);break;case"inside":e.save(),e.setStroke(void 0,2*n,s),s.windingRule?e.clip(s.windingRule):e.clip(),Ft(t,i,e),e.restore();break;case"outside":const{renderBounds:o}=t.__layout,r=e.getSameCanvas(!0);t.__drawRenderPath(r),r.setStroke(void 0,2*n,t.__),Ft(t,i,r),s.windingRule?r.clip(s.windingRule):r.clip(),r.clearWorld(o),e.copyWorldToInner(r,t.__world,o),r.recycle()}}});const{copy:pe,toOffsetOutBounds:_e}=d,we={},ve={};function ye(t,e,i,s){const{bounds:n,shapeBounds:o}=s;if(_.fullImageShadow){if(pe(we,t.bounds),we.x+=e.x-o.x,we.y+=e.y-o.y,i){const{matrix:t}=s;we.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),we.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),we.width*=i,we.height*=i}t.copyWorld(s.canvas,t.bounds,we)}else i&&(pe(we,e),we.x-=e.width/2*(i-1),we.y-=e.height/2*(i-1),we.width*=i,we.height*=i),t.copyWorld(s.canvas,o,i?we:e)}const{toOffsetOutBounds:me}=d,xe={};var be=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{innerShadow:h}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),p=h.length-1;me(d,xe),h.forEach(((s,h)=>{f.save(),f.setWorldShadow(xe.offsetX+s.x*u,xe.offsetY+s.y*g,s.blur*u),o=s.spread?1-2*s.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ye(f,xe,o,i),f.restore(),l?(f.copyWorld(f,d,r,"copy"),f.copyWorld(l,r,r,"source-out"),n=r):(f.copyWorld(i.canvas,c,d,"source-out"),n=d),f.fillWorld(n,s.color,"source-in"),t.__hasMirror?e.copyWorldByReset(f,n,r,s.blendMode):e.copyWorldToInner(f,n,a.renderBounds,s.blendMode),p&&h<p&&f.clear()})),f.recycle()},shadow:function(t,e,i,s){let n,o;const{__world:r,__layout:a}=t,{shadow:h}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:u,scaleY:g}=i,f=e.getSameCanvas(),p=h.length-1;_e(d,ve),h.forEach(((s,h)=>{f.setWorldShadow(ve.offsetX+s.x*u,ve.offsetY+s.y*g,s.blur*u,s.color),o=s.spread?1+2*s.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,ye(f,ve,o,i),n=d,s.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,r,"copy"),n=r),l?f.copyWorld(l,r,r,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__hasMirror?e.copyWorldByReset(f,n,r,s.blendMode):e.copyWorldToInner(f,n,a.renderBounds,s.blendMode),p&&h<p&&f.clear()})),f.recycle()}});const Be=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Le=Be+"_#~&*+\\=|≮≯≈≠=…",Ee=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 Re(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Te=Re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Me=Re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ke=Re(Be),Se=Re(Le),Ce=Re("- —/~|┆·");var Oe;!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"}(Oe||(Oe={}));const{Letter:Ae,Single:De,Before:Pe,After:We,Symbol:Ie,Break:Fe}=Oe;function Ue(t){return Te[t]?Ae:Ce[t]?Fe:Me[t]?Pe:ke[t]?We:Se[t]?Ie:Ee.test(t)?De:Ae}const Ve={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ye(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:Ge}=Ve,{Letter:Ne,Single:je,Before:ze,After:Xe,Symbol:He,Break:Ke}=Oe;let qe,Qe,$e,Ze,Je,ti,ei,ii,si,ni,oi,ri,ai,hi,li=[];function di(t,e){qe.data.push({char:t,width:e}),$e+=e}function ci(){Ze+=$e,qe.width=$e,Qe.words.push(qe),qe={data:[]},$e=0}function ui(){ri&&(ai.paraNumber++,Qe.paraStart=!0,ri=!1),Qe.width=Ze,hi.width&&Ge(Qe),li.push(Qe),Qe={words:[]},Ze=0}const gi={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,{width:n,height:o,padding:r}=e;const{textDecoration:a,textOverflow:h,__font:l}=e;if(n||(n=0),r){const[t,e,a,h]=E.fourNumber(r);n&&(i=h,n-=e+h),o&&(s=t,o-=t+a)}const d={bounds:{x:i,y:s,width:n,height:o},rows:[],paraNumber:0,font:_.canvas.font=l};return function(t,e,i){ai=t,li=t.rows,hi=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:o}=i,{canvas:r}=_,{width:a,height:h}=hi;if(a||h||s||"none"!==o){ri=!0,si=null,$e=Ze=0,qe={data:[]},Qe={words:[]};for(let t=0,i=e.length;t<i;t++)ti=e[t],"\n"===ti?($e&&ci(),Qe.paraEnd=!0,ui(),ri=!0):(ii=Ue(ti),ii===Ne&&"none"!==o&&(ti=Ye(ti,o,!$e)),ei=r.measureText(ti).width,s&&(ei+=s),ni=ii===je&&(si===je||si===Ne)||si===je&&ii!==Xe,oi=!(ii!==ze&&ii!==je||si!==He&&si!==Xe),Je=ri&&n?a-n:a,a&&Ze+$e+ei>Je&&(oi||(oi=ii===Ne&&si==Xe),ni||oi||ii===Ke||ii===ze||ii===je||$e+ei>Je?($e&&ci(),ui()):ui())," "===ti&&!0!==ri&&Ze+$e===0||(ii===Ke?(" "===ti&&$e&&ci(),di(ti,ei),ci()):ni||oi?($e&&ci(),di(ti,ei)):di(ti,ei)),si=ii);$e&&ci(),Ze&&ui(),li.length>0&&(li[li.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ai.paraNumber++,li.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(d,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,textAlign:r,verticalAlign:a,paraSpacing:h,textOverflow:l}=e;let d,{x:c,y:u,width:g,height:f}=s,p=n*i.length+(h?h*(t.paraNumber-1):0),_=o;if("show"!==l&&p>f)p=Math.max(f,n),t.overflow=i.length;else switch(a){case"middle":u+=(f-p)/2;break;case"bottom":u+=f-p}_+=u;for(let o=0,a=i.length;o<a;o++){switch(d=i[o],d.x=c,r){case"center":d.x+=(g-d.width)/2;break;case"right":d.x+=g-d.width}if(d.paraStart&&h&&o>0&&(_+=h),d.y=_,_+=n,t.overflow>o&&_>p&&(d.isOverflow=!0,t.overflow=o+1),d.width<0){const t=d.words[0].data[0].width,i=d.x+d.width;i<s.x&&(s.x=i-t),-d.width>s.width&&(s.width=-d.width+e.fontSize+t)}else d.x<s.x&&(s.x=d.x),d.width>s.width&&(s.width=d.width)}s.y=u,s.height=p}(d,e),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,d,c,u;n.forEach((t=>{t.words&&(d=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?0:l>.01?1:2,2===c?(t.text="",t.x+=d,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u)," "!==u.char&&t.data.push(u)):h=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,e,n),d.overflow&&function(t,e){const{rows:i,overflow:s}=t;if(i.splice(s),"hide"!==e){"ellipsis"===e&&(e="...");const n=_.canvas.measureText(e).width,o=i[s-1];let r,a,h=o.data.length-1;const{x:l,width:d}=t.bounds,c=l+d-n;for(let t=h;t>-1&&(r=o.data[t],a=r.x+r.width,!(t===h&&a<c));t--){if(a<c&&" "!==r.char){o.data.splice(t+1),o.width-=r.width;break}o.width-=r.width}o.width+=n,o.data.push({char:e,x:a})}}(d,h),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,e),d}},fi={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},pi={export(t,e,i){return function(t){_i||(_i=new O);return new Promise((e=>{_i.add((()=>Tt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:o}=t;o?o.waitViewCompleted((()=>Tt(this,void 0,void 0,(function*(){let t,r,a,{canvas:h}=o,{unreal:l}=h;switch(l&&(h=h.getSameCanvas(),h.backgroundColor=o.config.fill,o.__render(h,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}a=e.includes(".")?yield h.saveAs(e,t):r?yield h.toBlob(e,t):yield h.toDataURL(e,t),s({data:a}),n(),l&&h.recycle()})))):(s({data:!1}),n())}))))}};let _i;Object.assign(D,fe),Object.assign(P,be),Object.assign(W,gi),Object.assign(A,fi),Object.assign(I,pi),ft();export{ct as Interaction,$ as Layouter,nt as LeaferCanvas,J as Renderer,it as Selector,F as Watcher,ft as useCanvas};
|