@leafer-ui/draw 1.5.3 → 1.6.0
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/lib/draw.cjs +102 -58
- package/lib/draw.cjs.map +1 -1
- package/lib/draw.esm.js +103 -59
- package/lib/draw.esm.js.map +1 -1
- package/lib/draw.esm.min.js +1 -1
- package/lib/draw.esm.min.js.map +1 -1
- package/lib/draw.min.cjs +1 -1
- package/lib/draw.min.cjs.map +1 -1
- package/package.json +6 -6
package/lib/draw.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineKey as t,decorateLeafAttr as e,attr as i,Plugin as s,PathConvert as o,Debug as r,LeafData as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as A,useModule as P,rewriteAble as F,MathHelper as D,pen as E,PathCorner as I,PathDrawer as W,DataHelper as L,UICreator as z,registerUI as T,Branch as M,LeafList as O,Resource as N,getBoundsData as V,Creator as j,CanvasManager as H,WaitHelper as Y,LeaferEvent as X,Bounds as U,ResizeEvent as q,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as Q,ImageManager as Z,BoundsHelper as tt,affectRenderBoundsType as et,PathCommandDataHelper as it,Platform as st,PointHelper as ot,PathBounds as rt,affectStrokeBoundsType as at,getPointData as nt,ImageEvent as _t,LeaferImage as ht,Matrix as dt,PathCreator as pt}from"@leafer/core";export*from"@leafer/core";function lt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function ut(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function ct(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function yt(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const gt={},vt={},ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},wt={},xt={},mt={},Rt={},St={},kt={apply(){s.need("filter")}},Bt={},bt={setStyleName:()=>s.need("state"),set:()=>s.need("state")},Ct={list:{},register(t,e){Ct.list[t]=e},get:t=>Ct.list[t]},{parse:At,objectToCanvasData:Pt}=o,Ft={},Dt=r.get("UIData");class Et extends a{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Dt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Dt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ft)):(this.__isFills&&(this.__removeInput("fill"),mt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ft)):(this.__isStrokes&&(this.__removeInput("stroke"),mt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?At(t):Pt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){It(this,"shadow",t)}setInnerShadow(t){It(this,"innerShadow",t)}setFilter(t){It(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&xt.compute("fill",this.__leaf),e&&xt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}function It(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=null)):i=i&&!1!==i.visible?[i]:null,t["_"+e]=i}class Wt extends Et{}class Lt extends Wt{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class zt extends Wt{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Tt extends Lt{}class Mt extends Et{}class Ot extends Et{get __boxStroke(){return!this.__pathInputed}}class Nt extends Et{get __boxStroke(){return!this.__pathInputed}}class Vt extends Et{}class jt extends Et{}class Ht extends Et{get __pathInputed(){return 2}}class Yt extends Wt{}const Xt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Ut extends Et{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Xt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class qt extends Ot{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Gt extends Ot{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Jt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=kt.getSpread(r));let a=t=Math.ceil(t);return i&&i.forEach((t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(a=Math.max(a,o)),this.__layout.renderShapeSpread=a,t+(this.__layout.strokeSpread||0)}},$t={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;t.__useEffect=!!(e||i||s||o||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Kt(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a}=s;if(this.__drawRenderPath(t),s.__useEffect){const n=xt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:h,filter:d}=s;_&&St.shadow(this,t,n),o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),h&&St.innerShadow(this,t,n),r&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),d&&kt.apply(d,this,this.__nowWorld,t,i,n),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),r&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t))}else s.__pathInputed?Kt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?xt.fills(o,this,t):xt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?xt.strokes(r,this,t):xt.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Kt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&xt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&xt.stroke(o,t,e)}const Qt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Zt;let te=Zt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return E.set(this.path=t||[]),t||this.__drawPathByBox(E),E}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(E.set(i=[]),this.__drawPathByBox(E)),t?o.toCanvasData(i,!0):i}getPathString(t,e,i){return o.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Bt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?I.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&wt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?W.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}syncExport(t,e){return s.need("export")}clone(t){const e=L.clone(this.toJSON());return t&&Object.assign(e,t),Zt.one(e)}static one(t,e,i,s,o){return z.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};lt([_(Et)],te.prototype,"__",void 0),lt([yt()],te.prototype,"zoomLayer",void 0),lt([h("")],te.prototype,"id",void 0),lt([h("")],te.prototype,"name",void 0),lt([h("")],te.prototype,"className",void 0),lt([d("pass-through")],te.prototype,"blendMode",void 0),lt([p(1)],te.prototype,"opacity",void 0),lt([l(!0)],te.prototype,"visible",void 0),lt([d(!1)],te.prototype,"locked",void 0),lt([u(0)],te.prototype,"zIndex",void 0),lt([c(!1)],te.prototype,"mask",void 0),lt([y(!1)],te.prototype,"eraser",void 0),lt([g(0,!0)],te.prototype,"x",void 0),lt([g(0,!0)],te.prototype,"y",void 0),lt([v(100,!0)],te.prototype,"width",void 0),lt([v(100,!0)],te.prototype,"height",void 0),lt([f(1,!0)],te.prototype,"scaleX",void 0),lt([f(1,!0)],te.prototype,"scaleY",void 0),lt([w(0,!0)],te.prototype,"rotation",void 0),lt([w(0,!0)],te.prototype,"skewX",void 0),lt([w(0,!0)],te.prototype,"skewY",void 0),lt([g(0,!0)],te.prototype,"offsetX",void 0),lt([g(0,!0)],te.prototype,"offsetY",void 0),lt([g(0,!0)],te.prototype,"scrollX",void 0),lt([g(0,!0)],te.prototype,"scrollY",void 0),lt([x()],te.prototype,"origin",void 0),lt([x()],te.prototype,"around",void 0),lt([h(!1)],te.prototype,"lazy",void 0),lt([m(1)],te.prototype,"pixelRatio",void 0),lt([R()],te.prototype,"path",void 0),lt([S()],te.prototype,"windingRule",void 0),lt([S(!0)],te.prototype,"closed",void 0),lt([v(0)],te.prototype,"padding",void 0),lt([v(!1)],te.prototype,"lockRatio",void 0),lt([v()],te.prototype,"widthRange",void 0),lt([v()],te.prototype,"heightRange",void 0),lt([h(!1)],te.prototype,"draggable",void 0),lt([h()],te.prototype,"dragBounds",void 0),lt([h(!1)],te.prototype,"editable",void 0),lt([k(!0)],te.prototype,"hittable",void 0),lt([k("path")],te.prototype,"hitFill",void 0),lt([B("path")],te.prototype,"hitStroke",void 0),lt([k(!1)],te.prototype,"hitBox",void 0),lt([k(!0)],te.prototype,"hitChildren",void 0),lt([k(!0)],te.prototype,"hitSelf",void 0),lt([k()],te.prototype,"hitRadius",void 0),lt([b("")],te.prototype,"cursor",void 0),lt([d()],te.prototype,"fill",void 0),lt([B()],te.prototype,"stroke",void 0),lt([B("inside")],te.prototype,"strokeAlign",void 0),lt([B(1)],te.prototype,"strokeWidth",void 0),lt([B(!1)],te.prototype,"strokeWidthFixed",void 0),lt([B("none")],te.prototype,"strokeCap",void 0),lt([B("miter")],te.prototype,"strokeJoin",void 0),lt([B()],te.prototype,"dashPattern",void 0),lt([B(0)],te.prototype,"dashOffset",void 0),lt([B(10)],te.prototype,"miterLimit",void 0),lt([S(0)],te.prototype,"cornerRadius",void 0),lt([S()],te.prototype,"cornerSmoothing",void 0),lt([ut()],te.prototype,"shadow",void 0),lt([ut()],te.prototype,"innerShadow",void 0),lt([ut()],te.prototype,"blur",void 0),lt([ut()],te.prototype,"backgroundBlur",void 0),lt([ut()],te.prototype,"grayscale",void 0),lt([ut()],te.prototype,"filter",void 0),lt([h({})],te.prototype,"data",void 0),lt([C(A.prototype.reset)],te.prototype,"reset",null),te=Zt=lt([P(Jt),P($t),F()],te);let ee=class extends te{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var ie;lt([_(Wt)],ee.prototype,"__",void 0),lt([v(0)],ee.prototype,"width",void 0),lt([v(0)],ee.prototype,"height",void 0),ee=lt([P(M),T()],ee);const se=r.get("Leafer");let oe=ie=class extends ee{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&N.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||V()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),ie.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,L.assign(s,t));const o=this.canvas=j.canvas(s);this.__controllers.push(this.renderer=j.renderer(this,o,s),this.watcher=j.watcher(this,s),this.layouter=j.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=j.selector(this),this.interaction=j.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=j.hitCanvasManager()),this.canvasManager=new H,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Y.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(X.RESTART):this.emitLeafer(X.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(X.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=L.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new U(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=L.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new q(t,i))}__onResize(t){this.emitEvent(t),L.copyAttrs(this.__,t,n),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=L.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(X.BEFORE_READY),this.emitLeafer(X.READY),this.emitLeafer(X.AFTER_READY),Y.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(X.VIEW_READY),Y.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Y.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(X.VIEW_COMPLETED),Y.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,o){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new X(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(X.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Q.DATA,this.__onWatchData,this),this.on_($.END,this.__onLayoutEnd,this),this.on_(K.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){ie.list.remove(this);try{this.stop(),this.emitEvent(new X(X.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){se.error(t)}}};t?e():setTimeout(e)}};oe.list=new O,lt([_(zt)],oe.prototype,"__",void 0),lt([v()],oe.prototype,"pixelRatio",void 0),oe=ie=lt([T()],oe);let re=class extends te{get __tag(){return"Rect"}constructor(t){super(t)}};lt([_(Ot)],re.prototype,"__",void 0),re=lt([P(Qt),F(),T()],re);const{copy:ae,add:ne,includes:_e}=tt,he=re.prototype,de=ee.prototype,pe={};let le=class extends ee{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length&&!this.pathInputed)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ae(pe,e),this.__updateRectRenderBounds(),t=!_e(e,pe),t&&"hide"!==this.__.overflow&&ne(e,pe)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};lt([_(Lt)],le.prototype,"__",void 0),lt([v(100)],le.prototype,"width",void 0),lt([v(100)],le.prototype,"height",void 0),lt([h(!1)],le.prototype,"resizeChildren",void 0),lt([et("show")],le.prototype,"overflow",void 0),lt([C(he.__updateStrokeSpread)],le.prototype,"__updateStrokeSpread",null),lt([C(he.__updateRenderSpread)],le.prototype,"__updateRectRenderSpread",null),lt([C(he.__updateBoxBounds)],le.prototype,"__updateRectBoxBounds",null),lt([C(he.__updateStrokeBounds)],le.prototype,"__updateStrokeBounds",null),lt([C(he.__updateRenderBounds)],le.prototype,"__updateRectRenderBounds",null),lt([C(he.__updateChange)],le.prototype,"__updateRectChange",null),lt([C(he.__render)],le.prototype,"__renderRect",null),lt([C(de.__render)],le.prototype,"__renderGroup",null),le=lt([F(),T()],le);let ue=class extends le{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};lt([_(Tt)],ue.prototype,"__",void 0),lt([d("#FFFFFF")],ue.prototype,"fill",void 0),lt([et("hide")],ue.prototype,"overflow",void 0),ue=lt([T()],ue);const{moveTo:ce,closePath:ye,ellipse:ge}=it;let ve=class extends te{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&ge(n,r,a,r*i,a*i,0,s,o,!1),ge(n,r,a,r,a,0,o,s,!0),i<1&&ye(n)):(i<1&&(ge(n,r,a,r*i,a*i),ce(n,t,a)),ge(n,r,a,r,a,0,360,0,!0)),st.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ce(n,r,a),ge(n,r,a,r,a,0,s,o,!1),ye(n)):ge(n,r,a,r,a)}};lt([_(Nt)],ve.prototype,"__",void 0),lt([S(0)],ve.prototype,"innerRadius",void 0),lt([S(0)],ve.prototype,"startAngle",void 0),lt([S(0)],ve.prototype,"endAngle",void 0),ve=lt([T()],ve);const{moveTo:fe,lineTo:we,drawPoints:xe}=it,{rotate:me,getAngle:Re,getDistance:Se,defaultPoint:ke}=ot,{toBounds:Be}=rt;let be=class extends te{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=nt();return t&&(i.x=t),e&&me(i,e),i}set toPoint(t){this.width=Se(ke,t),this.rotation=Re(ke,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?xe(e,t.points,!1,t.closed):(fe(e,0,0),we(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(xe(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&wt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?Be(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};lt([_(Mt)],be.prototype,"__",void 0),lt([at("center")],be.prototype,"strokeAlign",void 0),lt([v(0)],be.prototype,"height",void 0),lt([S()],be.prototype,"points",void 0),lt([S(0)],be.prototype,"curve",void 0),lt([S(!1)],be.prototype,"closed",void 0),be=lt([T()],be);const{sin:Ce,cos:Ae,PI:Pe}=Math,{moveTo:Fe,lineTo:De,closePath:Ee,drawPoints:Ie}=it,We=be.prototype;let Le=class extends te{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ie(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Fe(t,o,0);for(let e=1;e<s;e++)De(t,o+o*Ce(2*e*Pe/s),r-r*Ae(2*e*Pe/s))}Ee(t)}__updateRenderPath(){}__updateBoxBounds(){}};lt([_(Vt)],Le.prototype,"__",void 0),lt([S(3)],Le.prototype,"sides",void 0),lt([S()],Le.prototype,"points",void 0),lt([S(0)],Le.prototype,"curve",void 0),lt([C(We.__updateRenderPath)],Le.prototype,"__updateRenderPath",null),lt([C(We.__updateBoxBounds)],Le.prototype,"__updateBoxBounds",null),Le=lt([F(),T()],Le);const{sin:ze,cos:Te,PI:Me}=Math,{moveTo:Oe,lineTo:Ne,closePath:Ve}=it;let je=class extends te{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Oe(a,o,0);for(let t=1;t<2*i;t++)Ne(a,o+(t%2==0?o:o*s)*ze(t*Me/i),r-(t%2==0?r:r*s)*Te(t*Me/i));Ve(a)}};lt([_(jt)],je.prototype,"__",void 0),lt([S(5)],je.prototype,"corners",void 0),lt([S(.382)],je.prototype,"innerRadius",void 0),je=lt([T()],je);let He=class extends re{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(_t.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};lt([_(qt)],He.prototype,"__",void 0),lt([v("")],He.prototype,"url",void 0),He=lt([T()],He);const Ye=He;let Xe=class extends re{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=j.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new ht({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new _t(_t.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new dt(t.worldTransform).invert(),r=new dt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};lt([_(Gt)],Xe.prototype,"__",void 0),lt([ct(100)],Xe.prototype,"width",void 0),lt([ct(100)],Xe.prototype,"height",void 0),lt([ct(1)],Xe.prototype,"pixelRatio",void 0),lt([ct(!0)],Xe.prototype,"smooth",void 0),lt([h(!1)],Xe.prototype,"safeResize",void 0),lt([ct()],Xe.prototype,"contextSettings",void 0),Xe=lt([T()],Xe);const{copyAndSpread:Ue,includes:qe,isSame:Ge,spread:Je,setList:$e}=tt;let Ke=class extends te{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=ft.number(e,o),t.__letterSpacing=ft.number(i,o),t.__padding=h?D.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=gt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(t.__lineHeight<i&&Je(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=qe(_,n)?_:n;Ge(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,$e(t.__textBoxBounds={},[_,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Ue(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};lt([_(Ut)],Ke.prototype,"__",void 0),lt([v(0)],Ke.prototype,"width",void 0),lt([v(0)],Ke.prototype,"height",void 0),lt([h(!1)],Ke.prototype,"resizeFontSize",void 0),lt([d("#000000")],Ke.prototype,"fill",void 0),lt([at("outside")],Ke.prototype,"strokeAlign",void 0),lt([k("all")],Ke.prototype,"hitFill",void 0),lt([v("")],Ke.prototype,"text",void 0),lt([v("caption")],Ke.prototype,"fontFamily",void 0),lt([v(12)],Ke.prototype,"fontSize",void 0),lt([v("normal")],Ke.prototype,"fontWeight",void 0),lt([v(!1)],Ke.prototype,"italic",void 0),lt([v("none")],Ke.prototype,"textCase",void 0),lt([v("none")],Ke.prototype,"textDecoration",void 0),lt([v(0)],Ke.prototype,"letterSpacing",void 0),lt([v({type:"percent",value:1.5})],Ke.prototype,"lineHeight",void 0),lt([v(0)],Ke.prototype,"paraIndent",void 0),lt([v(0)],Ke.prototype,"paraSpacing",void 0),lt([v("x")],Ke.prototype,"writingMode",void 0),lt([v("left")],Ke.prototype,"textAlign",void 0),lt([v("top")],Ke.prototype,"verticalAlign",void 0),lt([v(!0)],Ke.prototype,"autoSizeAlign",void 0),lt([v("normal")],Ke.prototype,"textWrap",void 0),lt([v("show")],Ke.prototype,"textOverflow",void 0),Ke=lt([T()],Ke);let Qe=class extends te{get __tag(){return"Path"}constructor(t){super(t)}};lt([_(Ht)],Qe.prototype,"__",void 0),lt([at("center")],Qe.prototype,"strokeAlign",void 0),Qe=lt([T()],Qe);let Ze=class extends ee{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Qe(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};lt([_(Yt)],Ze.prototype,"__",void 0),lt([(e,i)=>{t(e,i,{get(){return this.__path}})}],Ze.prototype,"path",void 0),Ze=lt([P(pt,["set","path","paint"]),T()],Ze);export{le as Box,Lt as BoxData,Xe as Canvas,Gt as CanvasData,vt as ColorConvert,St as Effect,ve as Ellipse,Nt as EllipseData,Bt as Export,kt as Filter,ue as Frame,Tt as FrameData,ee as Group,Wt as GroupData,He as Image,qt as ImageData,oe as Leafer,zt as LeaferData,be as Line,Mt as LineData,Ye as MyImage,xt as Paint,Rt as PaintGradient,mt as PaintImage,Qe as Path,wt as PathArrow,Ht as PathData,Ze as Pen,Yt as PenData,Le as Polygon,Vt as PolygonData,re as Rect,Ot as RectData,Qt as RectRender,je as Star,jt as StarData,bt as State,Ke as Text,gt as TextConvert,Ut as TextData,Ct as Transition,te as UI,Jt as UIBounds,Et as UIData,$t as UIRender,ft as UnitConvert,ut as effectType,ct as resizeType,yt as zoomLayerType};
|
|
1
|
+
import{defineKey as t,decorateLeafAttr as e,attr as i,Plugin as s,PathConvert as o,Debug as r,LeafData as a,canvasSizeAttrs as n,UICreator as _,dataProcessor as h,dataType as d,surfaceType as p,opacityType as l,visibleType as u,sortType as c,maskType as y,eraserType as g,positionType as v,boundsType as f,scaleType as w,rotationType as x,autoLayoutType as m,naturalBoundsType as R,pathInputType as S,pathType as k,hitType as b,strokeType as B,cursorType as C,rewrite as A,Leaf as P,useModule as F,rewriteAble as W,MathHelper as E,pen as I,PathCorner as D,PathDrawer as z,DataHelper as L,registerUI as T,Branch as M,LeafList as O,Resource as N,getBoundsData as V,Creator as j,CanvasManager as H,WaitHelper as Y,LeaferEvent as U,Bounds as X,ResizeEvent as q,AutoBounds as G,Run as J,LayoutEvent as $,RenderEvent as K,WatchEvent as Q,ImageManager as Z,BoundsHelper as tt,affectRenderBoundsType as et,PathCommandDataHelper as it,Platform as st,PointHelper as ot,PathBounds as rt,affectStrokeBoundsType as at,getPointData as nt,ImageEvent as _t,LeaferImage as ht,Matrix as dt,PathCreator as pt}from"@leafer/core";export*from"@leafer/core";function lt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function ut(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function ct(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function yt(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const gt={},vt={},ft={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},wt={},xt={},mt={},Rt={},St={},kt={apply(){s.need("filter")}},bt={},Bt={setStyleName:()=>s.need("state"),set:()=>s.need("state")},Ct={list:{},register(t,e){Ct.list[t]=e},get:t=>Ct.list[t]},{parse:At,objectToCanvasData:Pt}=o,Ft={},Wt=r.get("UIData");class Et extends a{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasHalf(){const t=this;return t.stroke&&"center"===t.strokeAlign&&t.strokeWidth%2||void 0}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Wt.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Wt.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){if(this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t){if("object"==typeof t){this.__setInput("fill",t);const e=this.__leaf.__layout;e.boxChanged||e.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ft)}}else this.__isFills&&(this.__removeInput("fill"),mt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t}setStroke(t){if("string"!=typeof t&&t){if("object"==typeof t){this.__setInput("stroke",t);const e=this.__leaf.__layout;e.boxChanged||e.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ft)}}else this.__isStrokes&&(this.__removeInput("stroke"),mt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?At(t):Pt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){It(this,"shadow",t)}setInnerShadow(t){It(this,"innerShadow",t)}setFilter(t){It(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&xt.compute("fill",this.__leaf),e&&xt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}function It(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=null)):i=i&&!1!==i.visible?[i]:null,t["_"+e]=i}class Dt extends Et{}class zt extends Dt{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class Lt extends Dt{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Tt extends zt{}class Mt extends Et{}class Ot extends Et{get __boxStroke(){return!this.__pathInputed}}class Nt extends Et{get __boxStroke(){return!this.__pathInputed}}class Vt extends Et{}class jt extends Et{}class Ht extends Et{get __pathInputed(){return 2}}class Yt extends Dt{}const Ut={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Xt extends Et{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Ut[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}setBoxStyle(t){let e=this.__leaf,i=e.__box;if(t){const{boxStyle:s}=this;if(i)for(let t in s)i[t]=void 0;else i=e.__box=_.get("Rect",0);const o=e.__layout,r=i.__layout;s||(i.parent=e,i.__world=e.__world,r.boxBounds=o.boxBounds),i.set(t),r.strokeChanged&&o.strokeChange(),r.renderChanged&&o.renderChange(),i.__updateChange()}else i&&(e.__box=i.parent=null,i.destroy());this._boxStyle=t}}class qt extends Ot{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Gt extends Ot{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Jt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i,r=this.__box;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),r&&(t=Math.max(r.__layout.strokeSpread=r.__updateStrokeSpread(),t),e=r.__layout.strokeBoxSpread),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=kt.getSpread(r));let a=t=Math.ceil(t);return i&&i.forEach((t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(a=Math.max(a,o)),this.__layout.renderShapeSpread=a,t+=this.__layout.strokeSpread||0,this.__box?Math.max(this.__box.__updateRenderSpread(),t):t}},$t={__updateChange(){const t=this.__,e=this.__world;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;t.__useEffect=!!(e||i||s||o||r)}const i=t.__hasHalf;e.half!==i&&(e.half=i),t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){Kt(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a}=s;if(this.__drawRenderPath(t),s.__useEffect){const n=xt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:h,filter:d}=s;_&&St.shadow(this,t,n),o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),h&&St.innerShadow(this,t,n),r&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t)),d&&kt.apply(d,this,this.__nowWorld,t,i,n),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else o&&(s.__isFills?xt.fills(o,this,t):xt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),r&&(s.__isStrokes?xt.strokes(r,this,t):xt.stroke(r,this,t))}else s.__pathInputed?Kt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?xt.fills(o,this,t):xt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?xt.strokes(r,this,t):xt.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function Kt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&xt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&xt.stroke(o,t,e)}const Qt={__drawFast(t,e){let{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;const{fill:a,stroke:n,__drawAfterFill:_}=this.__;if(a&&(t.fillStyle=a,t.fillRect(i,s,o,r)),_&&this.__drawAfterFill(t,e),n){const{strokeAlign:a,__strokeWidth:_}=this.__;if(!_)return;t.setStroke(n,_,this.__);const h=_/2;switch(a){case"center":t.strokeRect(0,0,o,r);break;case"inside":o-=_,r-=_,o<0||r<0?(t.save(),this.__clip(t,e),t.strokeRect(i+h,s+h,o,r),t.restore()):t.strokeRect(i+h,s+h,o,r);break;case"outside":t.strokeRect(i-h,s-h,o+_,r+_)}}}};var Zt;let te=Zt=class extends P{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){E.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?o.toCanvasData(i,!0):i}getPathString(t,e,i){return o.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||bt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?D.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&wt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?z.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}syncExport(t,e){return s.need("export")}clone(t){const e=L.clone(this.toJSON());return t&&Object.assign(e,t),Zt.one(e)}static one(t,e,i,s,o){return _.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){T()(this)}static registerData(t){h(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};lt([h(Et)],te.prototype,"__",void 0),lt([yt()],te.prototype,"zoomLayer",void 0),lt([d("")],te.prototype,"id",void 0),lt([d("")],te.prototype,"name",void 0),lt([d("")],te.prototype,"className",void 0),lt([p("pass-through")],te.prototype,"blendMode",void 0),lt([l(1)],te.prototype,"opacity",void 0),lt([u(!0)],te.prototype,"visible",void 0),lt([p(!1)],te.prototype,"locked",void 0),lt([p(!1)],te.prototype,"dim",void 0),lt([p(!1)],te.prototype,"dimskip",void 0),lt([c(0)],te.prototype,"zIndex",void 0),lt([y(!1)],te.prototype,"mask",void 0),lt([g(!1)],te.prototype,"eraser",void 0),lt([v(0,!0)],te.prototype,"x",void 0),lt([v(0,!0)],te.prototype,"y",void 0),lt([f(100,!0)],te.prototype,"width",void 0),lt([f(100,!0)],te.prototype,"height",void 0),lt([w(1,!0)],te.prototype,"scaleX",void 0),lt([w(1,!0)],te.prototype,"scaleY",void 0),lt([x(0,!0)],te.prototype,"rotation",void 0),lt([x(0,!0)],te.prototype,"skewX",void 0),lt([x(0,!0)],te.prototype,"skewY",void 0),lt([v(0,!0)],te.prototype,"offsetX",void 0),lt([v(0,!0)],te.prototype,"offsetY",void 0),lt([v(0,!0)],te.prototype,"scrollX",void 0),lt([v(0,!0)],te.prototype,"scrollY",void 0),lt([m()],te.prototype,"origin",void 0),lt([m()],te.prototype,"around",void 0),lt([d(!1)],te.prototype,"lazy",void 0),lt([R(1)],te.prototype,"pixelRatio",void 0),lt([S()],te.prototype,"path",void 0),lt([k()],te.prototype,"windingRule",void 0),lt([k(!0)],te.prototype,"closed",void 0),lt([f(0)],te.prototype,"padding",void 0),lt([f(!1)],te.prototype,"lockRatio",void 0),lt([f()],te.prototype,"widthRange",void 0),lt([f()],te.prototype,"heightRange",void 0),lt([d(!1)],te.prototype,"draggable",void 0),lt([d()],te.prototype,"dragBounds",void 0),lt([d(!1)],te.prototype,"editable",void 0),lt([b(!0)],te.prototype,"hittable",void 0),lt([b("path")],te.prototype,"hitFill",void 0),lt([B("path")],te.prototype,"hitStroke",void 0),lt([b(!1)],te.prototype,"hitBox",void 0),lt([b(!0)],te.prototype,"hitChildren",void 0),lt([b(!0)],te.prototype,"hitSelf",void 0),lt([b()],te.prototype,"hitRadius",void 0),lt([C("")],te.prototype,"cursor",void 0),lt([p()],te.prototype,"fill",void 0),lt([B()],te.prototype,"stroke",void 0),lt([B("inside")],te.prototype,"strokeAlign",void 0),lt([B(1)],te.prototype,"strokeWidth",void 0),lt([B(!1)],te.prototype,"strokeWidthFixed",void 0),lt([B("none")],te.prototype,"strokeCap",void 0),lt([B("miter")],te.prototype,"strokeJoin",void 0),lt([B()],te.prototype,"dashPattern",void 0),lt([B(0)],te.prototype,"dashOffset",void 0),lt([B(10)],te.prototype,"miterLimit",void 0),lt([k(0)],te.prototype,"cornerRadius",void 0),lt([k()],te.prototype,"cornerSmoothing",void 0),lt([ut()],te.prototype,"shadow",void 0),lt([ut()],te.prototype,"innerShadow",void 0),lt([ut()],te.prototype,"blur",void 0),lt([ut()],te.prototype,"backgroundBlur",void 0),lt([ut()],te.prototype,"grayscale",void 0),lt([ut()],te.prototype,"filter",void 0),lt([d({})],te.prototype,"data",void 0),lt([A(P.prototype.reset)],te.prototype,"reset",null),te=Zt=lt([F(Jt),F($t),W()],te);let ee=class extends te{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var ie;lt([h(Dt)],ee.prototype,"__",void 0),lt([f(0)],ee.prototype,"width",void 0),lt([f(0)],ee.prototype,"height",void 0),ee=lt([F(M),T()],ee);const se=r.get("Leafer");let oe=ie=class extends ee{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&N.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds(!0)||V()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),ie.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,L.assign(s,t));const o=this.canvas=j.canvas(s);this.__controllers.push(this.renderer=j.renderer(this,o,s),this.watcher=j.watcher(this,s),this.layouter=j.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=j.selector(this),this.interaction=j.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=j.hitCanvasManager()),this.canvasManager=new H,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),Y.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(U.RESTART):this.emitLeafer(U.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(U.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=L.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=L.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new q(t,i))}__onResize(t){this.emitEvent(t),L.copyAttrs(this.__,t,n),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new G(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=L.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(U.BEFORE_READY),this.emitLeafer(U.READY),this.emitLeafer(U.AFTER_READY),Y.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(U.VIEW_READY),Y.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){Y.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(U.VIEW_COMPLETED),Y.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,o){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}getClientPointByWorld(t){const{x:e,y:i}=this.clientBounds;return{x:e+t.x,y:i+t.y}}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new U(t,this))}__listenEvents(){const t=J.start("FirstCreate "+this.innerName);this.once(U.START,(()=>J.end(t))),this.once($.START,(()=>this.updateLazyBounds())),this.once(K.START,(()=>this.__onCreated())),this.once(K.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(Q.DATA,this.__onWatchData,this),this.on_($.END,this.__onLayoutEnd,this),this.on_(K.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){ie.list.remove(this);try{this.stop(),this.emitEvent(new U(U.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Z.clearRecycled()}),100)}catch(t){se.error(t)}}};t?e():setTimeout(e)}};oe.list=new O,lt([h(Lt)],oe.prototype,"__",void 0),lt([f()],oe.prototype,"pixelRatio",void 0),oe=ie=lt([T()],oe);let re=class extends te{get __tag(){return"Rect"}constructor(t){super(t)}};lt([h(Ot)],re.prototype,"__",void 0),re=lt([F(Qt),W(),T()],re);const{copy:ae,add:ne,includes:_e}=tt,he=re.prototype,de=ee.prototype,pe={};let le=class extends ee{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length&&!this.pathInputed)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ae(pe,e),this.__updateRectRenderBounds(),t=!_e(e,pe)||void 0,t&&"hide"!==this.__.overflow&&ne(e,pe)):this.__updateRectRenderBounds(),this.isOverflow!==t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};lt([h(zt)],le.prototype,"__",void 0),lt([f(100)],le.prototype,"width",void 0),lt([f(100)],le.prototype,"height",void 0),lt([d(!1)],le.prototype,"resizeChildren",void 0),lt([et("show")],le.prototype,"overflow",void 0),lt([A(he.__updateStrokeSpread)],le.prototype,"__updateStrokeSpread",null),lt([A(he.__updateRenderSpread)],le.prototype,"__updateRectRenderSpread",null),lt([A(he.__updateBoxBounds)],le.prototype,"__updateRectBoxBounds",null),lt([A(he.__updateStrokeBounds)],le.prototype,"__updateStrokeBounds",null),lt([A(he.__updateRenderBounds)],le.prototype,"__updateRectRenderBounds",null),lt([A(he.__updateChange)],le.prototype,"__updateRectChange",null),lt([A(he.__render)],le.prototype,"__renderRect",null),lt([A(de.__render)],le.prototype,"__renderGroup",null),le=lt([W(),T()],le);let ue=class extends le{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};lt([h(Tt)],ue.prototype,"__",void 0),lt([p("#FFFFFF")],ue.prototype,"fill",void 0),lt([et("hide")],ue.prototype,"overflow",void 0),ue=lt([T()],ue);const{moveTo:ce,closePath:ye,ellipse:ge}=it;let ve=class extends te{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&ge(n,r,a,r*i,a*i,0,s,o,!1),ge(n,r,a,r,a,0,o,s,!0),i<1&&ye(n)):(i<1&&(ge(n,r,a,r*i,a*i),ce(n,t,a)),ge(n,r,a,r,a,0,360,0,!0)),st.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ce(n,r,a),ge(n,r,a,r,a,0,s,o,!1),ye(n)):ge(n,r,a,r,a)}};lt([h(Nt)],ve.prototype,"__",void 0),lt([k(0)],ve.prototype,"innerRadius",void 0),lt([k(0)],ve.prototype,"startAngle",void 0),lt([k(0)],ve.prototype,"endAngle",void 0),ve=lt([T()],ve);const{moveTo:fe,lineTo:we,drawPoints:xe}=it,{rotate:me,getAngle:Re,getDistance:Se,defaultPoint:ke}=ot,{toBounds:be}=rt;let Be=class extends te{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=nt();return t&&(i.x=t),e&&me(i,e),i}set toPoint(t){this.width=Se(ke,t),this.rotation=Re(ke,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?xe(e,t.points,!1,t.closed):(fe(e,0,0),we(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(xe(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&wt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?be(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};lt([h(Mt)],Be.prototype,"__",void 0),lt([at("center")],Be.prototype,"strokeAlign",void 0),lt([f(0)],Be.prototype,"height",void 0),lt([k()],Be.prototype,"points",void 0),lt([k(0)],Be.prototype,"curve",void 0),lt([k(!1)],Be.prototype,"closed",void 0),Be=lt([T()],Be);const{sin:Ce,cos:Ae,PI:Pe}=Math,{moveTo:Fe,lineTo:We,closePath:Ee,drawPoints:Ie}=it,De=Be.prototype;let ze=class extends te{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ie(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Fe(t,o,0);for(let e=1;e<s;e++)We(t,o+o*Ce(2*e*Pe/s),r-r*Ae(2*e*Pe/s))}Ee(t)}__updateRenderPath(){}__updateBoxBounds(){}};lt([h(Vt)],ze.prototype,"__",void 0),lt([k(3)],ze.prototype,"sides",void 0),lt([k()],ze.prototype,"points",void 0),lt([k(0)],ze.prototype,"curve",void 0),lt([A(De.__updateRenderPath)],ze.prototype,"__updateRenderPath",null),lt([A(De.__updateBoxBounds)],ze.prototype,"__updateBoxBounds",null),ze=lt([W(),T()],ze);const{sin:Le,cos:Te,PI:Me}=Math,{moveTo:Oe,lineTo:Ne,closePath:Ve}=it;let je=class extends te{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Oe(a,o,0);for(let t=1;t<2*i;t++)Ne(a,o+(t%2==0?o:o*s)*Le(t*Me/i),r-(t%2==0?r:r*s)*Te(t*Me/i));Ve(a)}};lt([h(jt)],je.prototype,"__",void 0),lt([k(5)],je.prototype,"corners",void 0),lt([k(.382)],je.prototype,"innerRadius",void 0),je=lt([T()],je);let He=class extends re{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(_t.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};lt([h(qt)],He.prototype,"__",void 0),lt([f("")],He.prototype,"url",void 0),He=lt([T()],He);const Ye=He;let Ue=class extends re{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=j.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new ht({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new _t(_t.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new dt(t.worldTransform).invert(),r=new dt;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};lt([h(Gt)],Ue.prototype,"__",void 0),lt([ct(100)],Ue.prototype,"width",void 0),lt([ct(100)],Ue.prototype,"height",void 0),lt([ct(1)],Ue.prototype,"pixelRatio",void 0),lt([ct(!0)],Ue.prototype,"smooth",void 0),lt([d(!1)],Ue.prototype,"safeResize",void 0),lt([ct()],Ue.prototype,"contextSettings",void 0),Ue=lt([T()],Ue);const{copyAndSpread:Xe,includes:qe,spread:Ge,setList:Je}=tt;let $e=class extends te{get __tag(){return"Text"}get textDrawData(){return this.updateLayout(),this.__.__textDrawData}constructor(t){super(t)}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=ft.number(e,o),t.__letterSpacing=ft.number(i,o),t.__padding=h?E.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=gt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(e.contentBounds=n,t.__lineHeight<i&&Ge(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=!qe(_,n)||void 0;h?(Je(t.__textBoxBounds={},[_,n]),e.renderChanged=!0):t.__textBoxBounds=_,this.isOverflow!==h&&(this.isOverflow=h)}__onUpdateSize(){this.__box&&this.__box.__onUpdateSize(),super.__onUpdateSize()}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.isOverflow?1:0),t}__updateRenderBounds(){const{renderBounds:t,renderSpread:e}=this.__layout;Xe(t,this.__.__textBoxBounds,e),this.__box&&(this.__box.__layout.renderBounds=t)}__drawRenderPath(t){t.font=this.__.__font}__draw(t,e,i){const s=this.__box;s&&(s.__nowWorld=this.__nowWorld,s.__draw(t,e,i)),this.textEditing&&!bt.running||super.__draw(t,e,i)}destroy(){this.boxStyle&&(this.boxStyle=null),super.destroy()}};lt([h(Xt)],$e.prototype,"__",void 0),lt([f(0)],$e.prototype,"width",void 0),lt([f(0)],$e.prototype,"height",void 0),lt([p()],$e.prototype,"boxStyle",void 0),lt([d(!1)],$e.prototype,"resizeFontSize",void 0),lt([p("#000000")],$e.prototype,"fill",void 0),lt([at("outside")],$e.prototype,"strokeAlign",void 0),lt([b("all")],$e.prototype,"hitFill",void 0),lt([f("")],$e.prototype,"text",void 0),lt([f("caption")],$e.prototype,"fontFamily",void 0),lt([f(12)],$e.prototype,"fontSize",void 0),lt([f("normal")],$e.prototype,"fontWeight",void 0),lt([f(!1)],$e.prototype,"italic",void 0),lt([f("none")],$e.prototype,"textCase",void 0),lt([f("none")],$e.prototype,"textDecoration",void 0),lt([f(0)],$e.prototype,"letterSpacing",void 0),lt([f({type:"percent",value:1.5})],$e.prototype,"lineHeight",void 0),lt([f(0)],$e.prototype,"paraIndent",void 0),lt([f(0)],$e.prototype,"paraSpacing",void 0),lt([f("x")],$e.prototype,"writingMode",void 0),lt([f("left")],$e.prototype,"textAlign",void 0),lt([f("top")],$e.prototype,"verticalAlign",void 0),lt([f(!0)],$e.prototype,"autoSizeAlign",void 0),lt([f("normal")],$e.prototype,"textWrap",void 0),lt([f("show")],$e.prototype,"textOverflow",void 0),$e=lt([T()],$e);let Ke=class extends te{get __tag(){return"Path"}constructor(t){super(t)}};lt([h(Ht)],Ke.prototype,"__",void 0),lt([at("center")],Ke.prototype,"strokeAlign",void 0),Ke=lt([T()],Ke);let Qe=class extends ee{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ke(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};lt([h(Yt)],Qe.prototype,"__",void 0),lt([(e,i)=>{t(e,i,{get(){return this.__path}})}],Qe.prototype,"path",void 0),Qe=lt([F(pt,["set","path","paint"]),T()],Qe);export{le as Box,zt as BoxData,Ue as Canvas,Gt as CanvasData,vt as ColorConvert,St as Effect,ve as Ellipse,Nt as EllipseData,bt as Export,kt as Filter,ue as Frame,Tt as FrameData,ee as Group,Dt as GroupData,He as Image,qt as ImageData,oe as Leafer,Lt as LeaferData,Be as Line,Mt as LineData,Ye as MyImage,xt as Paint,Rt as PaintGradient,mt as PaintImage,Ke as Path,wt as PathArrow,Ht as PathData,Qe as Pen,Yt as PenData,ze as Polygon,Vt as PolygonData,re as Rect,Ot as RectData,Qt as RectRender,je as Star,jt as StarData,Bt as State,$e as Text,gt as TextConvert,Xt as TextData,Ct as Transition,te as UI,Jt as UIBounds,Et as UIData,$t as UIRender,ft as UnitConvert,ut as effectType,ct as resizeType,yt as zoomLayerType};
|
|
2
2
|
//# sourceMappingURL=draw.esm.min.js.map
|