@idraw/renderer 0.4.0-beta.3 → 0.4.0-beta.30

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.
@@ -1 +1 @@
1
- var iDrawRenderer=function(e){"use strict";var t,n,o,i,a=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},l=(e,t,n)=>(a(e,t,"read from private field"),n?n.call(e):t.get(e)),r=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},s=(e,t,n,o)=>(a(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n);function c(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function d(e,t){if(1===t)return e;let n=1;const o=/^\#[0-9a-f]{6,6}$/i;let i=e;if(o.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),i=e.substring(0,7)),n*=t,o.test(i)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));i=`${i.toUpperCase()}${e.toString(16).toUpperCase()}`}return i}function h(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function u(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function f(e){const t=e.length,n=Math.floor(t/2),o=e.substring(0,4).padEnd(4,"0"),i=e.substring(0,4).padEnd(4,"0");return`@assets/${u(t.toString(16).padEnd(4,o))}${u(e.substring(n-4,n).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(n-8,n-4).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(n-12,n-8).padEnd(4,o)).padEnd(4,"f")}-${u(e.substring(n-16,n-12).padEnd(4,i)).padEnd(4,"f")}-${u(e.substring(n,n+4).padEnd(4,i)).padEnd(4,"f")}${u(e.substring(n+4,n+8).padEnd(4,i)).padEnd(4,"f")}${u(i.padEnd(4,o).padEnd(4,i))}`}function g(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const w={type(e,t){const n=g(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===g(e),json:e=>"Object"===g(e),function:e=>"Function"===g(e),asyncFunction:e=>"AsyncFunction"===g(e),string:e=>"String"===g(e),number:e=>"Number"===g(e),undefined:e=>"Undefined"===g(e),null:e=>"Null"===g(e),promise:e=>"Promise"===g(e)};var v=function(e,t,n,o){return new(n||(n=Promise))((function(i,a){function l(e){try{s(o.next(e))}catch(e){a(e)}}function r(e){try{s(o.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,r)}s((o=o.apply(e,t||[])).next())}))};const{Image:m}=window;function y(e){return new Promise(((t,n)=>{const o=new m;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=n,o.onerror=n,o.src=e}))}function p(e){return v(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=new FileReader;i.readAsDataURL(o),i.onload=function(e){var n;const o=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(o)},i.onerror=function(e){n(e)}}))}(e);return yield y(t)}))}function x(e,t){return v(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const n=yield function(e,t){const{width:n,height:o}=t;return new Promise(((t,i)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),l=new FileReader;l.readAsDataURL(a),l.onload=function(e){var n;const o=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(o)},l.onerror=function(e){i(e)}}))}(e,t);return yield y(n)}))}function S(e){return"number"==typeof e&&(e>0||e<=0)}function b(e){return"number"==typeof e&&e>=0}function I(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function z(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const A={x:function(e){return S(e)},y:function(e){return S(e)},w:b,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:S,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return b(e)},borderRadius:function(e){return S(e)&&e>=0},color:function(e){return c(e)},imageSrc:function(e){return z(e)||I(e)},imageURL:I,imageBase64:z,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return S(e)&&e>0},lineHeight:function(e){return S(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return S(e)&&e>0}};class T{constructor(){this._listeners=new Map}on(e,t){if(this._listeners.has(e)){const n=this._listeners.get(e)||[];null==n||n.push(t),this._listeners.set(e,n)}else this._listeners.set(e,[t])}off(e,t){if(this._listeners.has(e)){const n=this._listeners.get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}this._listeners.set(e,n||[])}}trigger(e,t){const n=this._listeners.get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(this._listeners.has(e)){const t=this._listeners.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}}function E(e,t,n,o){const i=function(e){return e/180*Math.PI}(t||0);n&&(i>0||i<0)&&(e.translate(n.x,n.y),e.rotate(i),e.translate(-n.x,-n.y)),o(e),n&&(i>0||i<0)&&(e.translate(n.x,n.y),e.rotate(-i),e.translate(-n.x,-n.y))}function C(e,t,n){const o={x:(i=t).x+i.w/2,y:i.y+i.h/2};var i;E(e,t.angle||0,o,(()=>{n(e)}))}function $(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}const _={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function P(e,t){const{viewScaleInfo:n}=t,{scale:o}=n;let{borderRadius:i}=e.detail;const{boxSizing:a=_.boxSizing,borderWidth:l}=e.detail;"number"!=typeof l&&(i=0);let{x:r,y:s,w:c,h:d}=e,h=[0,0,0,0];if("number"==typeof i){const e=i*o;h=[e,e,e,e]}else Array.isArray(i)&&4===(null==i?void 0:i.length)&&(h=[i[0]*o,i[1]*o,i[2]*o,i[3]*o]);let u=0;return"number"==typeof l&&(u=(l||0)*o),"border-box"===a?(r=e.x+u/2,s=e.y+u/2,c=e.w-u,d=e.h-u):"content-box"===a?(r=e.x-u/2,s=e.y-u/2,c=e.w+u,d=e.h+u):(r=e.x,s=e.y,c=e.w,d=e.h),c=Math.max(c,1),d=Math.max(d,1),h=h.map((e=>Math.min(e,c/2,d/2))),{x:r,y:s,w:c,h:d,radiusList:h}}function L(e,t,n){if("string"==typeof t)return t;const{viewElementSize:o,viewScaleInfo:i,opacity:a=1}=n,{x:l,y:r}=o,{scale:s}=i;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:o,stops:i}=t,c={x:l+n.x*s,y:r+n.y*s},h={x:l+o.x*s,y:r+o.y*s},u=e.createLinearGradient(c.x,c.y,h.x,h.y);return i.forEach((e=>{u.addColorStop(e.offset,d(e.color,a))})),u}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:o,stops:i}=t,c={x:l+n.x*s,y:r+n.y*s,radius:n.radius*s},h={x:l+o.x*s,y:r+o.y*s,radius:o.radius*s},u=e.createRadialGradient(c.x,c.y,c.radius,h.x,h.y,h.radius);return i.forEach((e=>{u.addColorStop(e.offset,d(e.color,a))})),u}return"#000000"}const k={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function M(e,t,n){const{pattern:o,renderContent:i,originElem:a,calcElemSize:l,viewScaleInfo:r,viewSizeInfo:s}=n||{};!function(e,t,n){const{renderContent:o,originElem:i,calcElemSize:a,viewScaleInfo:l,viewSizeInfo:r}=n,s=l.scale*r.devicePixelRatio,{clipPath:c}=(null==i?void 0:i.detail)||{};if(c&&a&&c.commands){const{x:n,y:i,w:l,h:r}=a,{originW:d,originH:h,originX:u,originY:f}=c,g=l/d,w=r/h,v=n-u*g,m=i-f*w;e.save(),e.translate(v,m),e.scale(s*g,s*w);const y=$(c.commands||[]),p=new Path2D(y);e.clip(p),e.translate(0-v,0-m),e.setTransform(1,0,0,1,0,0),C(e,{...t},(()=>{null==o||o()})),e.restore()}else null==o||o()}(e,t,{originElem:a,calcElemSize:l,viewScaleInfo:r,viewSizeInfo:s,renderContent:()=>{var n,a;void 0!==(null==(n=null==t?void 0:t.detail)?void 0:n.opacity)&&(null==(a=null==t?void 0:t.detail)?void 0:a.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1,function(e,t,n){var o,i;const{pattern:a,viewScaleInfo:l,viewSizeInfo:r}=n,s=[];if(t.detail,t.detail,t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:u}=P(t,{viewScaleInfo:l,viewSizeInfo:r});if(e.beginPath(),e.moveTo(n+u[0],c),e.arcTo(n+d,c,n+d,c+h,u[1]),e.arcTo(n+d,c+h,n,c+h,u[2]),e.arcTo(n,c+h,n,c,u[3]),e.arcTo(n,c,n+d,c,u[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(w.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const o=L(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:l,opacity:e.globalAlpha});e.fillStyle=o}else if("radial-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const o=L(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:l,opacity:e.globalAlpha});if(e.fillStyle=o,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const o=s[t];"translate"===o.method?e.translate(o.args[0]+n,o.args[1]+c):"rotate"===o.method?e.rotate(...o.args):"scale"===o.method&&e.scale(...o.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}(e,t,{pattern:o,viewScaleInfo:r,viewSizeInfo:s}),null==i||i(),function(e,t,n){var o,i;if(0===t.detail.borderWidth)return;if(!c(t.detail.borderColor))return;void 0!==(null==(o=null==t?void 0:t.detail)?void 0:o.opacity)&&(null==(i=null==t?void 0:t.detail)?void 0:i.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1;const{viewScaleInfo:a}=n,{scale:l}=a;let r=k.borderColor;!0===c(t.detail.borderColor)&&(r=t.detail.borderColor);const{borderWidth:s,borderRadius:d,borderDash:h,boxSizing:u=k.boxSizing}=t.detail;let f=0;"number"==typeof s&&(f=s||1);f*=l;let g=[0,0,0,0];if("number"==typeof d){const e=d*l;g=[e,e,e,e]}else Array.isArray(d)&&4===(null==d?void 0:d.length)&&(g=[d[0]*l,d[1]*l,d[2]*l,d[3]*l]);e.strokeStyle=r;let w=[];Array.isArray(h)&&h.length>0&&(w=h.map((e=>Math.ceil(e*l))));let v=0,m=0,y=0,p=0;Array.isArray(s)&&(v=(s[0]||0)*l,m=(s[1]||0)*l,y=(s[2]||0)*l,p=(s[3]||0)*l);if(p||m||v||y){e.lineCap="butt";let{x:n,y:o,w:i,h:a}=t;"border-box"===u?(n+=p/2,o+=v/2,i=i-p/2-m/2,a=a-v/2-y/2):"content-box"===u?(n-=p/2,o-=v/2,i=i+p/2+m/2,a=a+v/2+y/2):(n=t.x,o=t.y,i=t.w,a=t.h),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n-p/2,o),e.lineTo(n+i+m/2,o),e.closePath(),e.stroke()),m&&(e.beginPath(),e.lineWidth=m,e.moveTo(n+i,o-v/2),e.lineTo(n+i,o+a+y/2),e.closePath(),e.stroke()),y&&(e.beginPath(),e.lineWidth=y,e.moveTo(n-p/2,o+a),e.lineTo(n+i+m/2,o+a),e.closePath(),e.stroke()),p&&(e.beginPath(),e.lineWidth=p,e.moveTo(n,o-v/2),e.lineTo(n,o+a+y/2),e.closePath(),e.stroke())}else{let{x:n,y:o,w:i,h:a}=t;"border-box"===u?(n=t.x+f/2,o=t.y+f/2,i=t.w-f,a=t.h-f):"content-box"===u?(n=t.x-f/2,o=t.y-f/2,i=t.w+f,a=t.h+f):(n=t.x,o=t.y,i=t.w,a=t.h),w.length>0?e.lineCap="butt":e.lineCap="square",i=Math.max(i,1),a=Math.max(a,1),g=g.map((e=>Math.min(e,i/2,a/2))),e.setLineDash(w),e.lineWidth=f,e.beginPath(),e.moveTo(n+g[0],o),e.arcTo(n+i,o,n+i,o+a,g[1]),e.arcTo(n+i,o+a,n,o+a,g[2]),e.arcTo(n,o+a,n,o,g[3]),e.arcTo(n,o,n+i,o,g[0]),e.closePath(),e.stroke(),e.globalAlpha=1}e.setLineDash([])}(e,t,{viewScaleInfo:r,viewSizeInfo:s}),e.globalAlpha=1}})}function W(e,t,n){const{detail:o}=t,{viewScaleInfo:i,renderContent:a}=n,{shadowColor:l,shadowOffsetX:r,shadowOffsetY:s,shadowBlur:c}=o;A.number(c)?(e.save(),e.shadowColor=l||k.shadowColor,e.shadowOffsetX=(r||0)*i.scale,e.shadowOffsetY=(s||0)*i.scale,e.shadowBlur=(c||0)*i.scale,a(),e.restore()):a()}const R={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};function O(e,t,n){var o;if(!0!==(null==(o=null==t?void 0:t.operations)?void 0:o.invisible))try{switch(t.type){case"rect":!function(e,t,n){const{calculator:o,viewScaleInfo:i,viewSizeInfo:a}=n,{x:l,y:r,w:s,h:c,angle:d}=(null==o?void 0:o.elementSize(t,i,a))||t,h={...t,x:l,y:r,w:s,h:c,angle:d};C(e,{x:l,y:r,w:s,h:c,angle:d},(()=>{W(e,h,{viewScaleInfo:i,viewSizeInfo:a,renderContent:()=>{M(e,h,{originElem:t,calcElemSize:{x:l,y:r,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:a,renderContent:()=>{}})}})}))}(e,t,n);break;case"circle":!function(e,t,n){const{detail:o,angle:i}=t,{background:a="#000000",borderColor:l="#000000",borderWidth:r=0}=o,{calculator:s,viewScaleInfo:c,viewSizeInfo:d}=n,{x:h,y:u,w:f,h:g}=(null==s?void 0:s.elementSize({x:t.x,y:t.y,w:t.w,h:t.h},c,d))||t,w={...t,x:h,y:u,w:f,h:g,angle:i};C(e,{x:h,y:u,w:f,h:g,angle:i},(()=>{W(e,w,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{var n,o;const i=f/2,s=g/2,d=h+i,w=u+s;if(void 0!==(null==(n=null==t?void 0:t.detail)?void 0:n.opacity)&&(null==(o=null==t?void 0:t.detail)?void 0:o.opacity)>=0?e.globalAlpha=t.detail.opacity:e.globalAlpha=1,"number"==typeof r&&r>0){const t=r/2+i,n=r/2+s;e.beginPath(),e.strokeStyle=l,e.lineWidth=r,e.circle(d,w,t,n,0,0,2*Math.PI),e.closePath(),e.stroke()}e.beginPath();const v=L(e,a,{viewElementSize:{x:h,y:u,w:f,h:g},viewScaleInfo:c,opacity:e.globalAlpha});e.fillStyle=v,e.circle(d,w,i,s,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=1}})}))}(e,t,n);break;case"text":!function(e,t,n){const{calculator:o,viewScaleInfo:i,viewSizeInfo:a}=n,{x:l,y:r,w:s,h:d,angle:h}=(null==o?void 0:o.elementSize(t,i,a))||t,u={...t,x:l,y:r,w:s,h:d,angle:h};C(e,{x:l,y:r,w:s,h:d,angle:h},(()=>{M(e,u,{originElem:t,calcElemSize:{x:l,y:r,w:s,h:d,angle:h},viewScaleInfo:i,viewSizeInfo:a,renderContent:()=>{const n={...R,...t.detail},o=(n.fontSize||R.fontSize)*i.scale,a=n.lineHeight?n.lineHeight*i.scale:o;e.fillStyle=t.detail.color||R.color,e.textBaseline="top",e.$setFont({fontWeight:n.fontWeight,fontSize:o,fontFamily:n.fontFamily});const h=n.text.replace(/\r\n/gi,"\n"),u=a,f=h.split("\n"),g=[];let w=0;f.forEach(((t,n)=>{let o="";if(t.length>0){for(let i=0;i<t.length&&(e.measureText(o+(t[i]||"")).width<e.$doPixelRatio(s)?o+=t[i]||"":(g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),o=t[i]||"",w++),!((w+1)*u>d));i++)if(t.length-1===i&&(w+1)*u<d){g.push({text:o,width:e.$undoPixelRatio(e.measureText(o).width)}),n<f.length-1&&w++;break}}else g.push({text:"",width:0})}));let v=0;g.length*u<d&&("top"===t.detail.verticalAlign?v=0:"bottom"===t.detail.verticalAlign?v+=d-g.length*u:v+=(d-g.length*u)/2);{const t=r+v;void 0!==n.textShadowColor&&c(n.textShadowColor)&&(e.shadowColor=n.textShadowColor),void 0!==n.textShadowOffsetX&&A.number(n.textShadowOffsetX)&&(e.shadowOffsetX=n.textShadowOffsetX),void 0!==n.textShadowOffsetY&&A.number(n.textShadowOffsetY)&&(e.shadowOffsetY=n.textShadowOffsetY),void 0!==n.textShadowBlur&&A.number(n.textShadowBlur)&&(e.shadowBlur=n.textShadowBlur),g.forEach(((o,i)=>{let a=l;"center"===n.textAlign?a=l+(s-o.width)/2:"right"===n.textAlign&&(a=l+(s-o.width)),e.fillText(o.text,a,t+u*i)}))}}})}))}(e,t,n);break;case"image":!function(e,t,n){const o=n.loader.getContent(t),{calculator:i,viewScaleInfo:a,viewSizeInfo:l}=n,{x:r,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,a,l))||t,u={...t,x:r,y:s,w:c,h:d,angle:h};C(e,{x:r,y:s,w:c,h:d,angle:h},(()=>{W(e,u,{viewScaleInfo:a,viewSizeInfo:l,renderContent:()=>{M(e,u,{originElem:t,calcElemSize:{x:r,y:s,w:c,h:d,angle:h},viewScaleInfo:a,viewSizeInfo:l,renderContent:()=>{if(o||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&o){const{opacity:n}=t.detail;e.globalAlpha=n||1;const{x:i,y:r,w:s,h:c,radiusList:d}=P(u,{viewScaleInfo:a,viewSizeInfo:l});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+d[0],r),e.arcTo(i+s,r,i+s,r+c,d[1]),e.arcTo(i+s,r+c,i,r+c,d[2]),e.arcTo(i,r+c,i,r,d[3]),e.arcTo(i,r,i+s,r,d[0]),e.closePath(),e.fill(),e.clip(),e.drawImage(o,i,r,s,c),e.globalAlpha=1,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const o=n.loader.getContent(t),{calculator:i,viewScaleInfo:a,viewSizeInfo:l}=n,{x:r,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,a,l))||t;C(e,{x:r,y:s,w:c,h:d,angle:h},(()=>{if(o||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&o){const{opacity:n}=t.detail;e.globalAlpha=n||1,e.drawImage(o,r,s,c,d),e.globalAlpha=1}}))}(e,t,n);break;case"html":!function(e,t,n){const o=n.loader.getContent(t),{calculator:i,viewScaleInfo:a,viewSizeInfo:l}=n,{x:r,y:s,w:c,h:d,angle:h}=(null==i?void 0:i.elementSize(t,a,l))||t;C(e,{x:r,y:s,w:c,h:d,angle:h},(()=>{if(o||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&o){const{opacity:n}=t.detail;e.globalAlpha=n||1,e.drawImage(o,r,s,c,d),e.globalAlpha=1}}))}(e,t,n);break;case"path":!function(e,t,n){const{detail:o}=t,{originX:i,originY:a,originW:l,originH:r}=o,{calculator:s,viewScaleInfo:c,viewSizeInfo:d}=n,{x:h,y:u,w:f,h:g,angle:w}=(null==s?void 0:s.elementSize(t,c,d))||t,v=f/l,m=g/r,y=h-i*v,p=u-a*m,x=c.scale*d.devicePixelRatio,S={...t,x:h,y:u,w:f,h:g,angle:w};C(e,{x:h,y:u,w:f,h:g,angle:w},(()=>{M(e,S,{originElem:t,calcElemSize:{x:h,y:u,w:f,h:g,angle:w},viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{W(e,S,{viewScaleInfo:c,viewSizeInfo:d,renderContent:()=>{e.save(),e.translate(y,p),e.scale(x*v/c.scale,x*m/c.scale);const t=$(o.commands||[]),n=new Path2D(t);o.fill&&(e.fillStyle=o.fill,e.fill(n)),o.stroke&&0!==o.strokeWidth&&(e.strokeStyle=o.stroke,e.lineWidth=(o.strokeWidth||1)/d.devicePixelRatio,e.lineCap=o.strokeLineCap||"square",e.stroke(n)),e.translate(-y,-p),e.restore()}})}})}))}(e,t,n);break;case"group":{const o={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{calculator:o,viewScaleInfo:i,viewSizeInfo:a}=n,{x:l,y:r,w:s,h:c,angle:d}=(null==o?void 0:o.elementSize({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},i,a))||t,h={...t,x:l,y:r,w:s,h:c,angle:d};C(e,{x:l,y:r,w:s,h:c,angle:d},(()=>{W(e,h,{viewScaleInfo:i,viewSizeInfo:a,renderContent:()=>{M(e,h,{originElem:t,calcElemSize:{x:l,y:r,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:a,renderContent:()=>{const{x:o,y:l,w:r,h:s,radiusList:c}=P(h,{viewScaleInfo:i,viewSizeInfo:a});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(o+c[0],l),e.arcTo(o+r,l,o+r,l+s,c[1]),e.arcTo(o+r,l+s,o,l+s,c[2]),e.arcTo(o,l+s,o,l,c[3]),e.arcTo(o,l,o+r,l,c[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:o}=n,i={x:o.x+t.x,y:o.y+t.y,w:t.w||o.w,h:t.h||o.h,angle:t.angle},{calculator:a}=n;for(let o=0;o<t.detail.children.length;o++){let l=t.detail.children[o];if(l={...l,x:i.x+l.x,y:i.y+l.y},!0===n.forceDrawAll||(null==a?void 0:a.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{O(e,l,{...n})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&(e.globalAlpha=1,e.restore())}})}})}))}(e,t,{...n,elementAssets:o});break}}}catch(e){console.error(e)}}const D={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,lineHeight:20,fontFamily:"sans-serif",fontWeight:400,overflow:"hidden"};const F=["image","svg","html"],B=e=>{var t,n,o;let i=null;return"image"===e.type?i=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?i=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(i=(null==(o=null==e?void 0:e.detail)?void 0:o.html)||null),"string"==typeof i&&i?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${i}`)?i:f(i):f(`${h()}-${e.uuid}-${h()}-${h()}`)};class H extends T{constructor(){super(),this._loadFuncMap={},this._currentLoadItemMap={},this._storageLoadItemMap={},this._registerLoadFunc("image",(async(e,t)=>{var n;const o=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,i=await y(o);return{uuid:e.uuid,lastModified:Date.now(),content:i}})),this._registerLoadFunc("html",(async(e,t)=>{var n;const o=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,i=await x(o,{width:e.detail.width||e.w,height:e.detail.height||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:i}})),this._registerLoadFunc("svg",(async(e,t)=>{var n;const o=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,i=await p(o);return{uuid:e.uuid,lastModified:Date.now(),content:i}}))}_registerLoadFunc(e,t){this._loadFuncMap[e]=t}_getLoadElementSource(e){var t,n,o;let i=null;return"image"===e.type?i=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?i=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(i=(null==(o=null==e?void 0:e.detail)?void 0:o.html)||null),i}_createLoadItem(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this._getLoadElementSource(e)}}_emitLoad(e){const t=B(e.element),n=this._storageLoadItemMap[t];n?n.startTime<e.startTime&&(this._storageLoadItemMap[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(this._storageLoadItemMap[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime}))}_emitError(e){const t=B(e.element),n=this._storageLoadItemMap[t];n?n.startTime<e.startTime&&(this._storageLoadItemMap[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(this._storageLoadItemMap[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime}))}_loadResource(e,t){const n=this._createLoadItem(e),o=B(e);this._currentLoadItemMap[o]=n;const i=this._loadFuncMap[e.type];"function"==typeof i&&(n.startTime=Date.now(),i(e,t).then((e=>{n.content=e.content,n.endTime=Date.now(),n.status="load",this._emitLoad(n)})).catch((t=>{console.warn(`Load element source "${n.source}" fail`,t,e),n.endTime=Date.now(),n.status="error",n.error=t,this._emitError(n)})))}_isExistingErrorStorage(e){var t;const n=B(e),o=null==(t=this._currentLoadItemMap)?void 0:t[n];return!(!o||"error"!==o.status||!o.source||o.source!==this._getLoadElementSource(e))}load(e,t){this._isExistingErrorStorage(e)||F.includes(e.type)&&this._loadResource(e,t)}getContent(e){var t,n;const o=B(e);return(null==(n=null==(t=this._storageLoadItemMap)?void 0:t[o])?void 0:n.content)||null}}return t=new WeakMap,n=new WeakMap,o=new WeakSet,i=function(){const e=l(this,n);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(()=>{}))},e.Renderer=class extends T{constructor(e){var l,c,d;super(),r(this,o),r(this,t,void 0),r(this,n,new H),s(this,t,e),(l=this,c=o,d=i,a(l,c,"access private method"),d).call(this)}updateOptions(e){s(this,t,e)}drawData(e,o){const i=l(this,n),{calculator:a}=l(this,t),r=l(this,t).viewContext;r.clearRect(0,0,r.canvas.width,r.canvas.height);!function(e,t,n){var o;const{elements:i=[]}=t;for(let t=0;t<i.length;t++){const a=i[t],l={...a,detail:{...D,...null==a?void 0:a.detail}};if(!0===n.forceDrawAll||(null==(o=n.calculator)?void 0:o.isElementInView(l,n.viewScaleInfo,n.viewSizeInfo)))try{O(e,l,n)}catch(e){console.error(e)}}}(r,e,{loader:i,calculator:a,parentElementSize:{x:0,y:0,w:o.viewSizeInfo.width,h:o.viewSizeInfo.height},elementAssets:e.assets,...o})}scale(e){const{sharer:n}=l(this,t);if(!n)return;const{data:o,offsetTop:i,offsetBottom:a,offsetLeft:r,offsetRight:s,width:c,height:d,contextHeight:h,contextWidth:u,devicePixelRatio:f}=n.getActiveStoreSnapshot();o&&this.drawData(o,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:a,offsetLeft:r,offsetRight:s},viewSizeInfo:{width:c,height:d,contextHeight:h,contextWidth:u,devicePixelRatio:f}})}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawRenderer=function(e){"use strict";var t,n,i,o,a,r,l,s,c,d,h,f,u,w,g,v,p,y,m,S,x,b,I,z=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},T=(e,t,n)=>(z(e,t,"read from private field"),n?n.call(e):t.get(e)),k=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},A=(e,t,n,i)=>(z(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),C=(e,t,n)=>(z(e,t,"access private method"),n);function P(e){return"string"==typeof e&&(/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}function E(e,t){if(1===t)return e;let n=1;const i=/^\#[0-9a-f]{6,6}$/i;let o=e;if(i.test(e)?n=parseInt(e.substring(5,7).replace(/^\#/,"0x")):/^\#[0-9a-f]{8,8}$/i.test(e)&&(n=parseInt(e.substring(7,9).replace(/^\#/,"0x")),o=e.substring(0,7)),n*=t,i.test(o)&&n>0&&n<1){const e=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${e.toString(16).toUpperCase()}`}return o}function W(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function O(e){let t=0;for(let n=0;n<e.length;n++)t+=e.charCodeAt(n)*e.charCodeAt(n)*n*n;return t.toString(16).substring(0,4)}function $(e){const t=e.length,n=Math.floor(t/2),i=e.substring(0,4).padEnd(4,"0"),o=e.substring(0,4).padEnd(4,"0");return`@assets/${O(t.toString(16).padEnd(4,i))}${O(e.substring(n-4,n).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-8,n-4).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-12,n-8).padEnd(4,i)).padEnd(4,"f")}-${O(e.substring(n-16,n-12).padEnd(4,o)).padEnd(4,"f")}-${O(e.substring(n,n+4).padEnd(4,o)).padEnd(4,"f")}${O(e.substring(n+4,n+8).padEnd(4,o)).padEnd(4,"f")}${O(o.padEnd(4,i).padEnd(4,o))}`}function M(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}const R={type(e,t){const n=M(e);return!0===t?n.toLocaleLowerCase():n},array:e=>"Array"===M(e),json:e=>"Object"===M(e),function:e=>"Function"===M(e),asyncFunction:e=>"AsyncFunction"===M(e),boolean:e=>"Boolean"===M(e),string:e=>"String"===M(e),number:e=>"Number"===M(e),undefined:e=>"Undefined"===M(e),null:e=>"Null"===M(e),promise:e=>"Promise"===M(e)};var D=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function l(e){try{s(i.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,l)}s((i=i.apply(e,t||[])).next())}))};const{Image:L}=window;function B(e){return new Promise(((t,n)=>{const i=new L;i.crossOrigin="anonymous",i.onload=function(){t(i)},i.onabort=n,i.onerror=n,i.src=e}))}function X(e){return D(this,void 0,void 0,(function*(){const t=yield function(e){return new Promise(((t,n)=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},o.onerror=function(e){n(e)}}))}(e);return yield B(t)}))}function Y(e,t){return D(this,void 0,void 0,(function*(){e=e.replace(/\&/gi,"&amp;");const n=yield function(e,t){const{width:n,height:i}=t;return new Promise(((t,o)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${n||""}" \n height = "${i||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(e){var n;const i=null===(n=null==e?void 0:e.target)||void 0===n?void 0:n.result;t(i)},r.onerror=function(e){o(e)}}))}(e,t);return yield B(n)}))}function F(e){return"number"==typeof e&&(e>0||e<=0)}function H(e){return"number"==typeof e&&e>=0}function j(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function U(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}const N={x:function(e){return F(e)},y:function(e){return F(e)},w:H,h:function(e){return"number"==typeof e&&e>=0},angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:F,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},borderWidth:function(e){return H(e)},borderRadius:function(e){return F(e)&&e>=0},color:function(e){return P(e)},imageSrc:function(e){return U(e)||j(e)},imageURL:j,imageBase64:U,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let n=document.createElement("div");n.innerHTML=e,n.children.length>0&&(t=!0),n=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return F(e)&&e>0},lineHeight:function(e){return F(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)},strokeWidth:function(e){return F(e)&&e>0}};var q,G=function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};class J{constructor(){q.set(this,void 0),function(e,t,n,i,o){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(e,n):o?o.value=n:t.set(e,n)}(this,q,new Map,"f")}on(e,t){if(G(this,q,"f").has(e)){const n=G(this,q,"f").get(e)||[];null==n||n.push(t),G(this,q,"f").set(e,n)}else G(this,q,"f").set(e,[t])}off(e,t){if(G(this,q,"f").has(e)){const n=G(this,q,"f").get(e);if(Array.isArray(n))for(let e=0;e<(null==n?void 0:n.length);e++)if(n[e]===t){n.splice(e,1);break}G(this,q,"f").set(e,n||[])}}trigger(e,t){const n=G(this,q,"f").get(e);return!!Array.isArray(n)&&(n.forEach((e=>{e(t)})),!0)}has(e){if(G(this,q,"f").has(e)){const t=G(this,q,"f").get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){G(this,q,"f").clear()}}function K(e,t,n,i){const o=function(e){return e/180*Math.PI}(t||0);n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(o),e.translate(-n.x,-n.y)),i(e),n&&(o>0||o<0)&&(e.translate(n.x,n.y),e.rotate(-o),e.translate(-n.x,-n.y))}function Q(e,t,n){const i={x:(o=t).x+o.w/2,y:o.y+o.h/2};var o;K(e,t.angle||0,i,(()=>{n(e)}))}function V(e,t){const{viewScaleInfo:n}=t,{x:i,y:o,w:a,h:r,angle:l}=e,{scale:s,offsetTop:c,offsetLeft:d}=n;return{x:i*s+d,y:o*s+c,w:a*s,h:r*s,angle:l}}function Z(e){let t="";return e.forEach((e=>{t+=e.type+e.params.join(" ")})),t}q=new WeakMap;const _={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function ee(e,t){const{viewScaleInfo:n}=t,{scale:i}=n;let{borderRadius:o,borderDash:a}=e.detail;const r=Array.isArray(a)&&a.length>0,{boxSizing:l=_.boxSizing,borderWidth:s}=e.detail;Array.isArray(s)&&(o=0);let{x:c,y:d,w:h,h:f}=e,u=[0,0,0,0];if("number"==typeof o){const e=o*i;u=[e,e,e,e]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(u=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let w=0;return"number"==typeof s&&(w=(s||0)*i),"border-box"!==l||r?"content-box"===l?(c=e.x-w/2,d=e.y-w/2,h=e.w+w,f=e.h+w):(c=e.x,d=e.y,h=e.w,f=e.h):(c=e.x+w/2,d=e.y+w/2,h=e.w-w,f=e.h-w),h=Math.max(h,1),f=Math.max(f,1),u=u.map((e=>Math.min(e,h/2,f/2))),{x:c,y:d,w:h,h:f,radiusList:u}}const te=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function ne(e,t,n){if("string"==typeof t)return t;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==t?void 0:t.type)){const{start:n,end:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s},d={x:r+i.x*s,y:l+i.y*s},h=e.createLinearGradient(c.x,c.y,d.x,d.y);return o.forEach((e=>{h.addColorStop(e.offset,E(e.color,a))})),h}if("radial-gradient"===(null==t?void 0:t.type)){const{inner:n,outer:i,stops:o}=t,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},d={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},h=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return o.forEach((e=>{h.addColorStop(e.offset,E(e.color,a))})),h}return"#000000"}const ie={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function oe(e){var t,n,i,o;let a=1;return void 0!==(null==(t=null==e?void 0:e.detail)?void 0:t.opacity)&&(null==(n=null==e?void 0:e.detail)?void 0:n.opacity)>=0&&(null==(i=null==e?void 0:e.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==e?void 0:e.detail)?void 0:o.opacity),a}function ae(e,t,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,d=oe(a)*c,{clipPath:h,clipPathStrokeColor:f,clipPathStrokeWidth:u}=a.detail,w=()=>{e.globalAlpha=d,re(e,t,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),le(e,t,{viewScaleInfo:l,viewSizeInfo:s}),e.globalAlpha=c};h?(function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r}=n,l=r.devicePixelRatio,{clipPath:s}=(null==o?void 0:o.detail)||{};if(s&&a&&s.commands){const{x:n,y:o,w:r,h:c}=a,{originW:d,originH:h,originX:f,originY:u}=s,w=r/d,g=c/h,v=n-f*w,p=o-u*g;e.save(),e.translate(v,p),e.scale(l*w,l*g);const y=Z(s.commands||[]),m=new Path2D(y);e.clip(m),e.translate(0-v,0-p),e.setTransform(1,0,0,1,0,0),Q(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,renderContent:()=>{w()}}),"number"==typeof u&&u>0&&f&&function(e,t,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=n,s=r.devicePixelRatio,{clipPath:c,clipPathStrokeColor:d,clipPathStrokeWidth:h}=(null==o?void 0:o.detail)||{};if(c&&a&&c.commands&&"number"==typeof h&&h>0&&d){const{x:n,y:o,w:r,h:f}=a,{originW:u,originH:w,originX:g,originY:v}=c,p=r/u,y=f/w,m=n-g*p,S=o-v*y;e.save(),e.globalAlpha=l,e.translate(m,S),e.scale(s*p,s*y);const x=Z(c.commands||[]),b=new Path2D(x);e.strokeStyle=d,e.lineWidth=h,e.stroke(b),e.translate(0-m,0-S),e.setTransform(1,0,0,1,0,0),Q(e,{...t},(()=>{null==i||i()})),e.restore()}else null==i||i()}(e,t,{originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s,parentOpacity:c})):w()}function re(e,t,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(t.detail.background||a){const{x:n,y:c,w:d,h:h,radiusList:f}=ee(t,{viewScaleInfo:r,viewSizeInfo:l});if(e.beginPath(),e.moveTo(n+f[0],c),e.arcTo(n+d,c,n+d,c+h,f[1]),e.arcTo(n+d,c+h,n,c+h,f[2]),e.arcTo(n,c+h,n,c,f[3]),e.arcTo(n,c,n+d,c,f[0]),e.closePath(),"string"==typeof a)e.fillStyle=a;else if(["CanvasPattern"].includes(R.type(a)))e.fillStyle=a;else if("string"==typeof t.detail.background)e.fillStyle=t.detail.background;else if("linear-gradient"===(null==(i=t.detail.background)?void 0:i.type)){const i=ne(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});e.fillStyle=i}else if("radial-gradient"===(null==(o=t.detail.background)?void 0:o.type)){const i=ne(e,t.detail.background,{viewElementSize:{x:n,y:c,w:d,h:h},viewScaleInfo:r,opacity:e.globalAlpha});if(e.fillStyle=i,s&&s.length>0)for(let t=0;t<(null==s?void 0:s.length);t++){const i=s[t];"translate"===i.method?e.translate(i.args[0]+n,i.args[1]+c):"rotate"===i.method?e.rotate(...i.args):"scale"===i.method&&e.scale(...i.args)}}e.fill(),s&&s.length>0&&e.setTransform(1,0,0,1,0,0)}}function le(e,t,n){if(0===t.detail.borderWidth)return;if(!P(t.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=ie.borderColor;!0===P(t.detail.borderColor)&&(a=t.detail.borderColor);const{borderWidth:r,borderRadius:l,borderDash:s,boxSizing:c=ie.boxSizing}=t.detail;let d=0;"number"==typeof r&&(d=r||1),d*=o;let h=[0,0,0,0];if("number"==typeof l){const e=l*o;h=[e,e,e,e]}else Array.isArray(l)&&4===(null==l?void 0:l.length)&&(h=[l[0]*o,l[1]*o,l[2]*o,l[3]*o]);e.strokeStyle=a;let f=[];Array.isArray(s)&&s.length>0&&(f=s.map((e=>Math.ceil(e*o))));let u=0,w=0,g=0,v=0;if(Array.isArray(r)&&(u=(r[0]||0)*o,w=(r[1]||0)*o,g=(r[2]||0)*o,v=(r[3]||0)*o),v||w||u||g){e.lineCap="butt";let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n+=v/2,i+=u/2,o=o-v/2-w/2,a=a-u/2-g/2):"content-box"===c?(n-=v/2,i-=u/2,o=o+v/2+w/2,a=a+u/2+g/2):(n=t.x,i=t.y,o=t.w,a=t.h),u&&(e.beginPath(),e.lineWidth=u,e.moveTo(n-v/2,i),e.lineTo(n+o+w/2,i),e.closePath(),e.stroke()),w&&(e.beginPath(),e.lineWidth=w,e.moveTo(n+o,i-u/2),e.lineTo(n+o,i+a+g/2),e.closePath(),e.stroke()),g&&(e.beginPath(),e.lineWidth=g,e.moveTo(n-v/2,i+a),e.lineTo(n+o+w/2,i+a),e.closePath(),e.stroke()),v&&(e.beginPath(),e.lineWidth=v,e.moveTo(n,i-u/2),e.lineTo(n,i+a+g/2),e.closePath(),e.stroke())}else{let{x:n,y:i,w:o,h:a}=t;"border-box"===c?(n=t.x+d/2,i=t.y+d/2,o=t.w-d,a=t.h-d):"content-box"===c?(n=t.x-d/2,i=t.y-d/2,o=t.w+d,a=t.h+d):(n=t.x,i=t.y,o=t.w,a=t.h),f.length>0?e.lineCap="butt":e.lineCap="square",o=Math.max(o,1),a=Math.max(a,1),h=h.map((e=>Math.min(e,o/2,a/2))),e.setLineDash(f),e.lineWidth=d,e.beginPath(),e.moveTo(n+h[0],i),e.arcTo(n+o,i,n+o,i+a,h[1]),e.arcTo(n+o,i+a,n,i+a,h[2]),e.arcTo(n,i+a,n,i,h[3]),e.arcTo(n,i,n+o,i,h[0]),e.closePath(),e.stroke()}e.setLineDash([])}function se(e,t,n){const{detail:i}=t,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;N.number(c)?(e.save(),e.shadowColor=r||ie.shadowColor,e.shadowOffsetX=(l||0)*o.scale,e.shadowOffsetY=(s||0)*o.scale,e.shadowBlur=(c||0)*o.scale,a(),e.restore()):(e.save(),e.shadowColor="transparent",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,a(),e.restore())}function ce(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V(t,{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{se(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ae(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{}})}})}))}const de={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};const he=.4;function fe(e,t,n){var i,o,a;if(!0===(null==(i=null==t?void 0:t.operations)?void 0:i.invisible))return;const{w:r,h:l}=t,{scale:s}=n.viewScaleInfo;if(s<1&&(r*s<he||l*s<he)||0===n.parentOpacity)return;const{overrideElementMap:c}=n;if(!(null==(a=null==(o=null==c?void 0:c[t.uuid])?void 0:o.operations)?void 0:a.invisible))try{switch(t.type){case"rect":ce(e,t,n);break;case"circle":!function(e,t,n){const{detail:i,angle:o}=t,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{background:s="#000000",borderColor:c="#000000",boxSizing:d,borderWidth:h=0,borderDash:f}=i;let u=0;"number"==typeof h&&h>0?u=h:Array.isArray(h)&&"number"==typeof h[0]&&h[0]>0&&(u=h[0]),u*=a.scale;const{x:w,y:g,w:v,h:p}=V({x:t.x,y:t.y,w:t.w,h:t.h},{viewScaleInfo:a})||t,y={...t,x:w,y:g,w:v,h:p,angle:o};Q(e,{x:w,y:g,w:v,h:p,angle:o},(()=>{se(e,y,{viewScaleInfo:a,viewSizeInfo:r,renderContent:()=>{let t=v/2,n=p/2;const i=w+t,o=g+n,r=t,h=n;if(u>0&&("content-box"===d||("center-line"===d?(t-=u/2,n-=u/2):(t-=u,n-=u))),t>=0&&n>=0){const d=oe(y)*l;e.globalAlpha=d,e.beginPath();const m=ne(e,s,{viewElementSize:{x:w,y:g,w:v,h:p},viewScaleInfo:a,opacity:e.globalAlpha});if(e.fillStyle=m,e.circle(i,o,r,h,0,0,2*Math.PI),e.closePath(),e.fill(),e.globalAlpha=l,"number"==typeof u&&u>0){const r=u/2+t,l=u/2+n;if(e.beginPath(),f){const t=f.map((e=>e*a.scale));e.setLineDash(t)}e.strokeStyle=c,e.lineWidth=u,e.circle(i,o,r,l,0,0,2*Math.PI),e.closePath(),e.stroke(),e.setLineDash([])}}}})}))}(e,t,n);break;case"text":!function(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V(t,{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{se(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ae(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a})}});{const o={...de,...t.detail},a=o.fontSize||de.fontSize,d=a*i.scale;if(d<2)return;const h=(o.lineHeight||a)*i.scale;e.fillStyle=t.detail.color||de.color,e.textBaseline="top",e.$setFont({fontWeight:o.fontWeight,fontSize:d,fontFamily:(n=o.fontFamily,[n,...te].join(", "))});let f=o.text.replace(/\r\n/gi,"\n");"lowercase"===o.textTransform?f=f.toLowerCase():"uppercase"===o.textTransform&&(f=f.toUpperCase());const u=h,w=f.split("\n"),g=[];let v=0;w.forEach(((t,n)=>{if("maxContent"===o.minInlineSize)g.push({text:t,width:e.$undoPixelRatio(e.measureText(t).width)});else{let l="",d="",h=t.split(d);if("normal"===o.wordBreak){const e=" ",n=t.split(e);h=[],n.forEach(((t,i)=>{h.push(t),i<n.length-1&&h.push(e)}))}if(1===h.length&&"visible"===o.overflow)g.push({text:h[0],width:e.$undoPixelRatio(e.measureText(h[0]).width)});else if(h.length>0){for(let t=0;t<h.length&&(a=e.$doPixelRatio(s),r=e.measureText(l+h[t]).width,i.scale<.5&&a<r&&(a-r)/a>-.15||a>=r?l+=h[t]||"":(g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),l=h[t]||"",v++),!((v+1)*u>c&&"hidden"===o.overflow));t++)if(h.length-1===t&&(v+1)*u<=c){g.push({text:l,width:e.$undoPixelRatio(e.measureText(l).width)}),n<w.length-1&&v++;break}}else g.push({text:"",width:0})}var a,r}));let p=0,y=0;u>d&&(y=(u-d)/2),g.length*u<c&&("top"===t.detail.verticalAlign?p=0:"bottom"===t.detail.verticalAlign?p+=c-g.length*u:p+=(c-g.length*u)/2);{const t=l+p;void 0!==o.textShadowColor&&P(o.textShadowColor)&&(e.shadowColor=o.textShadowColor),void 0!==o.textShadowOffsetX&&N.number(o.textShadowOffsetX)&&(e.shadowOffsetX=o.textShadowOffsetX),void 0!==o.textShadowOffsetY&&N.number(o.textShadowOffsetY)&&(e.shadowOffsetY=o.textShadowOffsetY),void 0!==o.textShadowBlur&&N.number(o.textShadowBlur)&&(e.shadowBlur=o.textShadowBlur),g.forEach(((n,i)=>{let a=r;"center"===o.textAlign?a=r+(s-n.width)/2:"right"===o.textAlign&&(a=r+(s-n.width)),e.fillText(n.text,a,t+u*i+y)}))}}var n}))}(e,t,n);break;case"image":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o})||t,f={...t,x:l,y:s,w:c,h:d,angle:h};Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{se(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{ae(e,f,{originElem:t,calcElemSize:{x:l,y:s,w:c,h:d,angle:h},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"image"===t.type&&i){e.globalAlpha=oe(t)*r;const{x:n,y:l,w:s,h:c,radiusList:d}=ee(f,{viewScaleInfo:o,viewSizeInfo:a}),{detail:h}=t,{scaleMode:u,originW:w=0,originH:g=0}=h,v=e.$undoPixelRatio(w),p=e.$undoPixelRatio(g);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(n+d[0],l),e.arcTo(n+s,l,n+s,l+c,d[1]),e.arcTo(n+s,l+c,n,l+c,d[2]),e.arcTo(n,l+c,n,l,d[3]),e.arcTo(n,l,n+s,l,d[0]),e.closePath(),e.fill(),e.clip(),u&&g&&w){let o=0,a=0,r=v,d=p;const h=n,f=l,w=s,g=c;if(v>t.w||p>t.h)if("fill"===u){const e=Math.max(t.w/v,t.h/p),n=p*e;o=(v*e-t.w)/2/e,a=(n-t.h)/2/e,r=t.w/e,d=t.h/e}else if("tile"===u)o=0,a=0,r=t.w,d=t.h;else if("fit"===u){const e=Math.min(t.w/v,t.h/p);o=(v-t.w/e)/2,a=(p-t.h/e)/2,r=t.w/e,d=t.h/e}e.drawImage(i,o,a,r,d,h,f,w,g)}else e.drawImage(i,n,l,s,c);e.globalAlpha=r,e.restore()}}})}})}))}(e,t,n);break;case"svg":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t;Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"svg"===t.type&&i&&(e.globalAlpha=oe(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}(e,t,n);break;case"html":!function(e,t,n){const i=n.loader.getContent(t),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:d,angle:h}=V(t,{viewScaleInfo:o,viewSizeInfo:a})||t;Q(e,{x:l,y:s,w:c,h:d,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(t,n.elementAssets||{}),"html"===t.type&&i&&(e.globalAlpha=oe(t)*r,e.drawImage(i,l,s,c,d),e.globalAlpha=r)}))}(e,t,n);break;case"path":!function(e,t,n){var i,o;const{detail:a}=t,{originX:r,originY:l,originW:s,originH:c,fillRule:d}=a,{viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u}=n,{x:w,y:g,w:v,h:p,angle:y}=V(t,{viewScaleInfo:h})||t,m=v/s,S=p/c,x=w-r*m,b=g-l*S,{clipPath:I,clipPathStrokeColor:z,clipPathStrokeWidth:T,...k}=t.detail,A=h.scale*f.devicePixelRatio,C={...t,x:w,y:g,w:v,h:p,angle:y};let P={...C};P.detail=k;let E={...t};E.detail=k,a.fill&&"string"!==a.fill&&(null==(o=null==(i=a.fill)?void 0:i.type)?void 0:o.includes("gradient"))&&(P={...C,detail:{...C.detail,background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:c}}},E.detail={...P.detail}),Q(e,{x:w,y:g,w:v,h:p,angle:y},(()=>{ae(e,P,{originElem:E,calcElemSize:{x:w,y:g,w:v,h:p,angle:y},viewScaleInfo:h,viewSizeInfo:f,parentOpacity:u,renderContent:()=>{se(e,C,{viewScaleInfo:h,viewSizeInfo:f,renderContent:()=>{e.save(),e.translate(x,b),e.scale(A*m/h.scale,A*S/h.scale);const t=Z(a.commands||[]),n=new Path2D(t);a.fill&&("string"==typeof a.fill?e.fillStyle=a.fill:e.fillStyle="transparent"),a.fill&&e.fill(n,d),a.stroke&&0!==a.strokeWidth&&(e.strokeStyle=a.stroke,e.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,e.lineCap=a.strokeLineCap||"square",e.stroke(n)),e.translate(-x,-b),e.restore()}})}})}))}(e,t,n);break;case"group":{const i={...n.elementAssets||{},...t.detail.assets||{}};!function(e,t,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:d}=V({x:t.x,y:t.y,w:t.w,h:t.h,angle:t.angle},{viewScaleInfo:i})||t,h={...t,x:r,y:l,w:s,h:c,angle:d};Q(e,{x:r,y:l,w:s,h:c,angle:d},(()=>{e.globalAlpha=oe(t)*a,se(e,h,{viewScaleInfo:i,viewSizeInfo:o,renderContent:()=>{ae(e,h,{originElem:t,calcElemSize:{x:r,y:l,w:s,h:c,angle:d},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{const{x:r,y:l,w:s,h:c,radiusList:d}=ee(h,{viewScaleInfo:i,viewSizeInfo:o});if("hidden"===t.detail.overflow&&(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(r+d[0],l),e.arcTo(r+s,l,r+s,l+c,d[1]),e.arcTo(r+s,l+c,r,l+c,d[2]),e.arcTo(r,l+c,r,l,d[3]),e.arcTo(r,l,r+s,l,d[0]),e.closePath(),e.fill(),e.clip()),Array.isArray(t.detail.children)){const{parentElementSize:i}=n,o={x:i.x+t.x,y:i.y+t.y,w:t.w||i.w,h:t.h||i.h,angle:t.angle},{calculator:r}=n;for(let i=0;i<t.detail.children.length;i++){let l=t.detail.children[i];if(l={...l,x:o.x+l.x,y:o.y+l.y},!0===n.forceDrawAll||(null==r?void 0:r.needRender(l)))try{fe(e,l,{...n,parentOpacity:a*oe(t)})}catch(e){console.error(e)}}}"hidden"===t.detail.overflow&&e.restore()}})}}),e.globalAlpha=a}))}(e,t,{...n,elementAssets:i});break}}}catch(e){console.error(e)}}const ue={boxSizing:"border-box",borderWidth:0,borderColor:"#000000",shadowColor:"#000000",borderRadius:0,borderDash:[],shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0,opacity:1,color:"#000000",textAlign:"left",verticalAlign:"top",fontSize:16,fontFamily:"sans-serif",fontWeight:400,minInlineSize:"auto",wordBreak:"break-all",overflow:"hidden"};function we(e,t,n){var i;const{elements:o=[]}=t,{parentOpacity:a}=n;for(let t=0;t<o.length;t++){const r=o[t],l={...r,detail:{...ue,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.needRender(l)))try{fe(e,l,{...n,parentOpacity:a})}catch(e){console.error(e)}}}const ge=["image","svg","html"],ve=e=>{var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),"string"==typeof o&&o?/^@assets\/[0-9a-z]{8,8}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{4,4}\-[0-9a-z]{12,12}$/.test(`${o}`)?o:$(o):$(`${W()}-${e.uuid}-${W()}-${W()}`)};class pe extends J{constructor(){super(),k(this,a),k(this,l),k(this,c),k(this,h),k(this,u),k(this,g),k(this,p),k(this,t,{}),k(this,n,{}),k(this,i,{}),k(this,o,!1),C(this,a,r).call(this,"image",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.src])?void 0:n.value)||e.detail.src,o=await B(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}})),C(this,a,r).call(this,"html",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.html])?void 0:n.value)||e.detail.html,o=await Y(i,{width:e.detail.originW||e.w,height:e.detail.originH||e.h});return{uuid:e.uuid,lastModified:Date.now(),content:o}})),C(this,a,r).call(this,"svg",(async(e,t)=>{var n;const i=(null==(n=t[e.detail.svg])?void 0:n.value)||e.detail.svg,o=await X(i);return{uuid:e.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return T(this,o)}destroy(){A(this,o,!0),this.clear(),A(this,t,null),A(this,n,null),A(this,i,null)}load(e,t){!0!==T(this,o)&&(C(this,p,y).call(this,e)||ge.includes(e.type)&&C(this,g,v).call(this,e,t))}getContent(e){var t,n;const o=ve(e);return(null==(n=null==(t=T(this,i))?void 0:t[o])?void 0:n.content)||null}getLoadItemMap(){return T(this,i)}setLoadItemMap(e){A(this,i,e)}}t=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(e,n){T(this,t)[e]=n},l=new WeakSet,s=function(e){var t,n,i;let o=null;return"image"===e.type?o=(null==(t=null==e?void 0:e.detail)?void 0:t.src)||null:"svg"===e.type?o=(null==(n=null==e?void 0:e.detail)?void 0:n.svg)||null:"html"===e.type&&(o=(null==(i=null==e?void 0:e.detail)?void 0:i.html)||null),o},c=new WeakSet,d=function(e){return{element:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:C(this,l,s).call(this,e)}},h=new WeakSet,f=function(e){const t=ve(e.element),n=T(this,i)[t];T(this,o)||(n?n.startTime<e.startTime&&(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))},u=new WeakSet,w=function(e){var t;const n=ve(e.element),a=null==(t=T(this,i))?void 0:t[n];T(this,o)||(a?a.startTime<e.startTime&&(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(T(this,i)[n]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))},g=new WeakSet,v=function(e,i){const a=C(this,c,d).call(this,e),r=ve(e);if(T(this,n)[r])return;T(this,n)[r]=a;const l=T(this,t)[e.type];"function"!=typeof l||T(this,o)||(a.startTime=Date.now(),l(e,i).then((e=>{T(this,o)||(a.content=e.content,a.endTime=Date.now(),a.status="load",C(this,h,f).call(this,a))})).catch((t=>{console.warn(`Load element source "${a.source}" fail`,t,e),a.endTime=Date.now(),a.status="error",a.error=t,C(this,u,w).call(this,a)})))},p=new WeakSet,y=function(e){var t;const i=ve(e),o=null==(t=T(this,n))?void 0:t[i];return!(!o||"error"!==o.status||!o.source||o.source!==C(this,l,s).call(this,e))};return m=new WeakMap,S=new WeakMap,x=new WeakMap,b=new WeakSet,I=function(){const e=T(this,S);e.on("load",(e=>{this.trigger("load",e)})),e.on("error",(e=>{console.error(e)}))},e.Renderer=class extends J{constructor(e){super(),k(this,b),k(this,m,void 0),k(this,S,new pe),k(this,x,!1),A(this,m,e),C(this,b,I).call(this)}isDestroyed(){return T(this,x)}destroy(){this.clear(),A(this,m,null),T(this,S).destroy(),A(this,S,null),A(this,x,!0)}updateOptions(e){A(this,m,e)}drawData(e,t){const n=T(this,S),{calculator:i,sharer:o}=T(this,m),a=T(this,m).viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={loader:n,calculator:i,parentElementSize:{x:0,y:0,w:t.viewSizeInfo.width,h:t.viewSizeInfo.height},elementAssets:e.assets,parentOpacity:1,overrideElementMap:null==o?void 0:o.getActiveOverrideElemenentMap(),...t};!function(e,t,n){if("string"==typeof(null==t?void 0:t.background)){const{viewSizeInfo:i}=n,{width:o,height:a}=i;e.globalAlpha=1,e.fillStyle=t.background,e.fillRect(0,0,o,a)}}(a,e.global,r),e.layout?function(e,t,n,i){const{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"layout",type:"group",...t},{x:s,y:c,w:d,h:h}=V(l,{viewScaleInfo:o})||l,f={...l,x:s,y:c,w:d,h:h,angle:0};if(e.globalAlpha=1,se(e,f,{viewScaleInfo:o,viewSizeInfo:a,renderContent:()=>{re(e,f,{viewScaleInfo:o,viewSizeInfo:a})}}),"hidden"===t.detail.overflow){const{viewScaleInfo:i,viewSizeInfo:o}=n,a={uuid:"layout",type:"group",...t},r=V(a,{viewScaleInfo:i})||a,l={...a,...r},{x:s,y:c,w:d,h:h,radiusList:f}=ee(l,{viewScaleInfo:i,viewSizeInfo:o});e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(s+f[0],c),e.arcTo(s+d,c,s+d,c+h,f[1]),e.arcTo(s+d,c+h,s,c+h,f[2]),e.arcTo(s,c+h,s,c,f[3]),e.arcTo(s,c,s+d,c,f[0]),e.closePath(),e.fill(),e.clip()}i(e),"hidden"===t.detail.overflow&&e.restore(),le(e,f,{viewScaleInfo:o,viewSizeInfo:a}),e.globalAlpha=r}(a,e.layout,r,(()=>{we(a,e,r)})):we(a,e,r)}scale(e){const{sharer:t}=T(this,m);if(!t)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}=t.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:e,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:d,devicePixelRatio:h}})}setLoadItemMap(e){T(this,S).setLoadItemMap(e)}getLoadItemMap(){return T(this,S).getLoadItemMap()}getLoader(){return T(this,S)}},e.drawRect=ce,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idraw/renderer",
3
- "version": "0.4.0-beta.3",
3
+ "version": "0.4.0-beta.30",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -21,11 +21,11 @@
21
21
  "author": "chenshenhai",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@idraw/types": "^0.4.0-beta.3"
24
+ "@idraw/types": "^0.4.0-beta.30"
25
25
  },
26
26
  "dependencies": {},
27
27
  "peerDependencies": {
28
- "@idraw/util": "^0.4.0-beta.3"
28
+ "@idraw/util": "^0.4.0-beta.30"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public",