@idraw/renderer 0.4.2 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/calculator.d.ts +17 -12
- package/dist/esm/calculator.js +103 -88
- package/dist/esm/draw/base.d.ts +19 -0
- package/dist/esm/draw/base.js +141 -0
- package/dist/esm/draw/box.d.ts +2 -28
- package/dist/esm/draw/box.js +3 -335
- package/dist/esm/draw/circle.d.ts +2 -2
- package/dist/esm/draw/circle.js +4 -72
- package/dist/esm/draw/color.d.ts +3 -3
- package/dist/esm/draw/color.js +10 -8
- package/dist/esm/draw/ellipse.d.ts +2 -0
- package/dist/esm/draw/ellipse.js +6 -0
- package/dist/esm/draw/foreign-object.d.ts +2 -0
- package/dist/esm/draw/foreign-object.js +15 -0
- package/dist/esm/draw/global.d.ts +2 -2
- package/dist/esm/draw/global.js +2 -2
- package/dist/esm/draw/group.d.ts +3 -3
- package/dist/esm/draw/group.js +60 -94
- package/dist/esm/draw/image.d.ts +2 -2
- package/dist/esm/draw/image.js +70 -86
- package/dist/esm/draw/index.d.ts +6 -5
- package/dist/esm/draw/index.js +6 -5
- package/dist/esm/draw/layout.d.ts +2 -2
- package/dist/esm/draw/layout.js +21 -35
- package/dist/esm/draw/materials.d.ts +2 -0
- package/dist/esm/draw/materials.js +27 -0
- package/dist/esm/draw/path.d.ts +2 -2
- package/dist/esm/draw/path.js +4 -89
- package/dist/esm/draw/rect.d.ts +2 -2
- package/dist/esm/draw/rect.js +4 -22
- package/dist/esm/draw/svg-code.d.ts +2 -0
- package/dist/esm/draw/svg-code.js +15 -0
- package/dist/esm/draw/text.d.ts +2 -2
- package/dist/esm/draw/text.js +60 -50
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +15 -15
- package/dist/esm/loader.d.ts +4 -4
- package/dist/esm/loader.js +68 -70
- package/dist/esm/virtual/base.d.ts +2 -0
- package/dist/esm/virtual/base.js +52 -0
- package/dist/esm/virtual/circle.d.ts +2 -0
- package/dist/esm/virtual/circle.js +38 -0
- package/dist/esm/virtual/ellipse.d.ts +2 -0
- package/dist/esm/virtual/ellipse.js +40 -0
- package/dist/esm/virtual/index.d.ts +6 -0
- package/dist/esm/virtual/index.js +77 -0
- package/dist/esm/virtual/path.d.ts +2 -0
- package/dist/esm/virtual/path.js +10 -0
- package/dist/esm/virtual/rect.d.ts +2 -0
- package/dist/esm/virtual/rect.js +146 -0
- package/dist/esm/virtual/text.d.ts +2 -0
- package/dist/esm/virtual/text.js +165 -0
- package/dist/esm/visible/index.d.ts +22 -0
- package/dist/esm/{view-visible → visible}/index.js +29 -23
- package/dist/index.global.js +1794 -1578
- package/dist/index.global.min.js +1 -1
- package/package.json +3 -3
- package/dist/esm/draw/elements.d.ts +0 -2
- package/dist/esm/draw/elements.js +0 -27
- package/dist/esm/draw/html.d.ts +0 -2
- package/dist/esm/draw/html.js +0 -17
- package/dist/esm/draw/svg.d.ts +0 -2
- package/dist/esm/draw/svg.js +0 -17
- package/dist/esm/view-visible/index.d.ts +0 -22
- package/dist/esm/virtual-flat/index.d.ts +0 -7
- package/dist/esm/virtual-flat/index.js +0 -45
- package/dist/esm/virtual-flat/text.d.ts +0 -2
- package/dist/esm/virtual-flat/text.js +0 -151
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawRenderer=function(t){"use strict";var e,n,i,o,a,r,l,s,c,h,u,f,d,g,p,y,w,v,m,x,b=t=>{throw TypeError(t)},S=(t,e,n)=>e.has(t)||b("Cannot "+n),I=(t,e,n)=>(S(t,e,"read from private field"),n?n.call(t):e.get(t)),M=(t,e,n)=>e.has(t)?b("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),P=(t,e,n,i)=>(S(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),C=(t,e,n)=>(S(t,e,"access private method"),n);function A(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}function z(t,e){if(1===e)return t;let n=1;const i=/^#[0-9a-f]{6,6}$/i;let o=t;if(i.test(t)?n=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(n=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),n*=e,i.test(o)&&n>0&&n<1){const t=Math.max(0,Math.min(255,Math.ceil(256*n)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o}function R(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`}function T(t,e){let n=0;for(let e=0;e<t.length;e++)n+=t.charCodeAt(e);return(n+e).toString(16).substring(0,4)}function k(t,e){const n=t.length,i=function(t){let e=0;for(let n=0;n<t.length;n++)e+=t.charCodeAt(n);return e}(e),o=Math.floor(n/2),a=t.substring(0,4).padStart(4,"0"),r=t.substring(0,4).padStart(4,"0");return`@assets/${T(n.toString(16).padStart(4,a),i).padStart(4,"0")}${T(t.substring(o-4,o).padStart(4,a),i).padStart(4,"0")}-${T(t.substring(o-8,o-4).padStart(4,a),i).padStart(4,"0")}-${T(t.substring(o-12,o-8).padStart(4,a),i).padStart(4,"0")}-${T(t.substring(o-16,o-12).padStart(4,r),i).padStart(4,"0")}-${T(t.substring(o,o+4).padStart(4,r),i).padStart(4,"0")}${T(t.substring(o+4,o+8).padStart(4,r),i).padStart(4,"0")}${T(r.padStart(4,a).padStart(4,r),i)}`}function L(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function E(t){return function t(e){const n=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(n)>=0)return e;if("Array"===n){const n=[];return e.forEach((e=>{n.push(t(e))})),n}if("Object"===n){const n={};Object.keys(e).forEach((i=>{n[i]=t(e[i])}));return Object.getOwnPropertySymbols(e).forEach((i=>{n[i]=t(e[i])})),n}}(t)}function O(t){return(Object.prototype.toString.call(t)||"").replace(/(\[object|\])/gi,"").trim()}const W={type(t,e){const n=O(t);return!0===e?n.toLocaleLowerCase():n},array:t=>"Array"===O(t),json:t=>"Object"===O(t),function:t=>"Function"===O(t),asyncFunction:t=>"AsyncFunction"===O(t),boolean:t=>"Boolean"===O(t),string:t=>"String"===O(t),number:t=>"Number"===O(t),undefined:t=>"Undefined"===O(t),null:t=>"Null"===O(t),promise:t=>"Promise"===O(t)};var $=function(t,e,n,i){return new(n||(n=Promise))((function(o,a){function r(t){try{s(i.next(t))}catch(t){a(t)}}function l(t){try{s(i.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,l)}s((i=i.apply(t,e||[])).next())}))};const{Image:F}=window;function D(t){return new Promise(((e,n)=>{const i=new F;i.crossOrigin="anonymous",i.onload=function(){e(i)},i.onabort=n,i.onerror=n,i.src=t}))}function B(t){return $(this,void 0,void 0,(function*(){const e=yield function(t){return new Promise(((e,n)=>{const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(i),o.onload=function(t){var n;const i=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(i)},o.onerror=function(t){n(t)}}))}(t);return yield D(e)}))}function V(t,e){return $(this,void 0,void 0,(function*(){t=t.replace(/\&/gi,"&");const n=yield function(t,e){const{width:n,height:i}=e;return new Promise(((e,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 ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(a),r.onload=function(t){var n;const i=null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.result;e(i)},r.onerror=function(t){o(t)}}))}(t,e);return yield D(n)}))}function j(t){return"number"==typeof t&&t>=0}function X(t){return"number"==typeof t&&(t>0||t<=0)}function Y(t){return X(t)}function H(t){return X(t)}function U(t){return j(t)}function N(t){return j(t)}function Q(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function G(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function q(t){return["rect","circle","text","image","svg","html","group"].includes(t)}const J={positiveNum:j,data:function(t){return!!(Array(null==t?void 0:t.elements)&&(null==t?void 0:t.elements.length)>=0)},element:function(t){return!!t&&(q(null==t?void 0:t.type)&&Y(null==t?void 0:t.x)&&H(null==t?void 0:t.y)&&U(null==t?void 0:t.w)&&N(null==t?void 0:t.h))},layout:function(t){return!!t&&(Y(null==t?void 0:t.x)&&H(null==t?void 0:t.y)&&U(null==t?void 0:t.w)&&N(null==t?void 0:t.h))},type:q,x:Y,y:H,w:U,h:N,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:X,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},borderWidth:function(t){return j(t)||Array.isArray(t)&&j(t[0])&&j(t[1])&&j(t[2])&&j(t[3])},borderRadius:function(t){return j(t)||Array.isArray(t)&&j(t[0])&&j(t[1])&&j(t[2])&&j(t[3])},color:function(t){return A(t)},imageSrc:function(t){return G(t)||Q(t)},imageURL:Q,imageBase64:G,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let n=document.createElement("div");n.innerHTML=t,n.children.length>0&&(e=!0),n=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return X(t)&&t>0},lineHeight:function(t){return X(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)},strokeWidth:function(t){return X(t)&&t>0}};var K,Z=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class _{constructor(){K.set(this,void 0),function(t,e,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 e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===i?o.call(t,n):o?o.value=n:e.set(t,n)}(this,K,new Map,"f")}on(t,e){if(Z(this,K,"f").has(t)){const n=Z(this,K,"f").get(t)||[];null==n||n.push(e),Z(this,K,"f").set(t,n)}else Z(this,K,"f").set(t,[e])}off(t,e){if(Z(this,K,"f").has(t)){const n=Z(this,K,"f").get(t);if(Array.isArray(n))for(let t=0;t<(null==n?void 0:n.length);t++)if(n[t]===e){n.splice(t,1);break}Z(this,K,"f").set(t,n||[])}}trigger(t,e){const n=Z(this,K,"f").get(t);return!!Array.isArray(n)&&(n.forEach((t=>{t(e)})),!0)}has(t){if(Z(this,K,"f").has(t)){const e=Z(this,K,"f").get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){Z(this,K,"f").clear()}}function tt(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}K=new WeakMap;var et,nt,it,ot,at,rt=function(t,e,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 e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?o.call(t,n):o?o.value=n:e.set(t,n),n},lt=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class st{constructor(t){et.add(this),nt.set(this,void 0),it.set(this,void 0),ot.set(this,void 0),rt(this,it,E(t.defaultStorage),"f"),rt(this,nt,lt(this,et,"m",at).call(this),"f"),rt(this,ot,t.defaultStatic||{},"f")}set(t,e){lt(this,nt,"f")[t]=e}get(t){return lt(this,nt,"f")[t]}setStatic(t,e){lt(this,ot,"f")[t]=e}getStatic(t){return lt(this,ot,"f")[t]}getSnapshot(t){return!0===(null==t?void 0:t.deepClone)?E(lt(this,nt,"f")):Object.assign({},lt(this,nt,"f"))}clear(){rt(this,nt,lt(this,et,"m",at).call(this),"f")}destroy(){rt(this,nt,null,"f"),rt(this,ot,null,"f")}}function ct(t){return t/180*Math.PI}function ht(t,e,n){const i=ut(e);!function(t,e,n,i){const o=ct(e||0);n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(o),t.translate(-n.x,-n.y)),i(t),n&&(o>0||o<0)&&(t.translate(n.x,n.y),t.rotate(-o),t.translate(-n.x,-n.y))}(t,e.angle||0,i,(()=>{n(t)}))}function ut(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function ft(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),n=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return ut({x:e,y:n,w:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,h:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-n})}function dt(t,e,n){const i=function(t,e){const n=e.x-t.x,i=e.y-t.y;if(0===n){if(i<0)return 0;if(i>0)return Math.PI}else if(0===i){if(n<0)return 3*Math.PI/2;if(n>0)return Math.PI/2}return n>0&&i<0?Math.atan(Math.abs(n)/Math.abs(i)):n>0&&i>0?Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i>0?Math.PI+Math.atan(Math.abs(n)/Math.abs(i)):n<0&&i<0?2*Math.PI-Math.atan(Math.abs(n)/Math.abs(i)):0}(t,e);let o=i+n;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const a=function(t,e){const n=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===n?n:Math.sqrt(n)}(t,e);let r=0,l=0;return 0===o?(r=0,l=0-a):o>0&&o<Math.PI/2?(r=Math.sin(o)*a,l=0-Math.cos(o)*a):o===Math.PI/2?(r=a,l=0):o>Math.PI/2&&o<Math.PI?(r=Math.sin(Math.PI-o)*a,l=Math.cos(Math.PI-o)*a):o===Math.PI?(r=0,l=a):o>Math.PI&&o<1.5*Math.PI?(r=0-Math.sin(o-Math.PI)*a,l=Math.cos(o-Math.PI)*a):o===1.5*Math.PI?(r=0-a,l=0):o>1.5*Math.PI&&o<2*Math.PI?(r=0-Math.sin(2*Math.PI-o)*a,l=0-Math.cos(2*Math.PI-o)*a):o===2*Math.PI&&(r=0,l=0-a),r+=t.x,l+=t.y,{x:r,y:l}}function gt(t,e,n){const{x:i,y:o,w:a,h:r}=t;let l={x:i,y:o},s={x:i+a,y:o},c={x:i+a,y:o+r},h={x:i,y:o+r};if(n&&(n>0||n<0)){const t=ct(function(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;e<0?e+=360:360===t&&(e=0);return e}(n));l=dt(e,l,t),s=dt(e,s,t),c=dt(e,c,t),h=dt(e,h,t)}return[l,s,c,h]}function pt(t,e,n){return[dt(t,{x:e[0].x,y:e[0].y},n),dt(t,{x:e[1].x,y:e[1].y},n),dt(t,{x:e[2].x,y:e[2].y},n),dt(t,{x:e[3].x,y:e[3].y},n)]}function yt(t,e){var n;const i=[];let o=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const a=o[e[t]];if("group"!==(null==a?void 0:a.type)||!Array.isArray(null===(n=null==a?void 0:a.detail)||void 0===n?void 0:n.children))return null;i.push(a),o=a.detail.children}return i}function wt(t){const{x:e,y:n,h:i,w:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e+o,y:n+i},{x:e,y:n+i}]}function vt(t){const{x:e,y:n,w:i,h:o,angle:a=0}=t;return 0===a?wt(t):gt(t,ut({x:e,y:n,w:i,h:o}),a)}function mt(t,e){const{groupQueue:n}=e;if(!(n.length>0))return[vt(t)];const i=function(t){const e=[];let n=0,i=0;const o=[],a=[...t];for(let t=0;t<a.length;t++){const{x:r,y:l,w:s,h:c,angle:h=0}=a[t];let u;if(n+=r,i+=l,0===t){const t={x:n,y:i,w:s,h:c};u=vt({x:r,y:l,w:s,h:c,angle:h}),o.push({center:ut(t),angle:h,radian:ct(h)})}else{u=wt({x:n,y:i,w:s,h:c});for(let t=0;t<o.length;t++){const{center:e,radian:n}=o[t];u=pt(e,u,n)}const t=ft(u);(h>0||h<0)&&(u=pt(t,u,ct(h))),o.push({center:t,angle:h,radian:ct(h)})}e.push(u)}return e}([...n,t]);return i}function xt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o,w:a,h:r,angle:l}=t,{scale:s,offsetTop:c,offsetLeft:h}=n;return{x:i*s+h,y:o*s+c,w:a*s,h:r*s,angle:l}}function bt(t,e){const{viewScaleInfo:n}=e,{x:i,y:o}=t,{scale:a,offsetTop:r,offsetLeft:l}=n;return{x:i*a+l,y:o*a+r}}function St(t,e){const{context2d:n,element:i,viewScaleInfo:o}=e,{angle:a=0}=i,{x:r,y:l,w:s,h:c}=xt(i,{viewScaleInfo:o}),h=function(t){const{angle:e=0}=t;return gt(t,ut(t),e)}({x:r,y:l,w:s,h:c,angle:a});if(h.length>=2){n.beginPath(),n.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)n.lineTo(h[t].x,h[t].y);n.closePath()}return!!n.isPointInPath(t.x,t.y)}function It(t,e){const{groupQueue:n}=e,i=function(t,e){return mt(t,e).pop()||null}(t,{groupQueue:n}),o=tt(i[0],i[1]),a=tt(i[1],i[2]),r=tt(i[2],i[3]),l=tt(i[3],i[0]),s=i[0],c=i[1],h=i[2],u=i[3],f=Math.max(s.x,c.x,h.x,u.x),d=Math.max(s.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(s.x,c.x,h.x,u.x))/2,y:(d+Math.min(s.y,c.y,h.y,u.y))/2},topLeft:s,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:a,left:l,bottom:r}}function Mt(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),n=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),i=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),a={x:t.center.x,y:t.center.y},r={x:i,y:o},l={x:e,y:o},s={x:e,y:n},c={x:i,y:n},h=tt(r,l),u=tt(c,s),f=tt(r,c);return{center:a,topLeft:r,topRight:l,bottomLeft:c,bottomRight:s,top:h,right:tt(l,s),left:f,bottom:u}}function Pt(t){let e="";return t.forEach((t=>{e+=t.type+t.params.join(" ")})),e}nt=new WeakMap,it=new WeakMap,ot=new WeakMap,et=new WeakSet,at=function(){return E(lt(this,it,"f"))};const Ct={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 At(t,e){const{viewScaleInfo:n}=e,{scale:i}=n;let{borderRadius:o}=t.detail;const{borderDash:a}=t.detail,r=Array.isArray(a)&&a.length>0,{boxSizing:l=Ct.boxSizing,borderWidth:s}=t.detail;Array.isArray(s)&&(o=0);let{x:c,y:h,w:u,h:f}=t,d=[0,0,0,0];if("number"==typeof o){const t=o*i;d=[t,t,t,t]}else Array.isArray(o)&&4===(null==o?void 0:o.length)&&(d=[o[0]*i,o[1]*i,o[2]*i,o[3]*i]);let g=0;return"number"==typeof s&&(g=(s||0)*i),"border-box"!==l||r?"content-box"===l?(c=t.x-g/2,h=t.y-g/2,u=t.w+g,f=t.h+g):(c=t.x,h=t.y,u=t.w,f=t.h):(c=t.x+g/2,h=t.y+g/2,u=t.w-g,f=t.h-g),u=Math.max(u,1),f=Math.max(f,1),d=d.map((t=>Math.min(t,u/2,f/2))),{x:c,y:h,w:u,h:f,radiusList:d}}const zt=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function Rt(t){return[t,...zt].join(", ")}function Tt(t,e,n){if("string"==typeof e)return e;const{viewElementSize:i,viewScaleInfo:o,opacity:a=1}=n,{x:r,y:l}=i,{scale:s}=o;if("linear-gradient"===(null==e?void 0:e.type)){const{start:n,end:i,stops:o}=e,c={x:r+n.x*s,y:l+n.y*s},h={x:r+i.x*s,y:l+i.y*s},u=t.createLinearGradient(c.x,c.y,h.x,h.y);return o.forEach((t=>{u.addColorStop(t.offset,z(t.color,a))})),u}if("radial-gradient"===(null==e?void 0:e.type)){const{inner:n,outer:i,stops:o}=e,c={x:r+n.x*s,y:l+n.y*s,radius:n.radius*s},h={x:r+i.x*s,y:l+i.y*s,radius:i.radius*s},u=t.createRadialGradient(c.x,c.y,c.radius,h.x,h.y,h.radius);return o.forEach((t=>{u.addColorStop(t.offset,z(t.color,a))})),u}return"#000000"}const kt={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 Lt(t){var e,n,i,o;let a=1;return void 0!==(null==(e=null==t?void 0:t.detail)?void 0:e.opacity)&&(null==(n=null==t?void 0:t.detail)?void 0:n.opacity)>=0&&(null==(i=null==t?void 0:t.detail)?void 0:i.opacity)<=1&&(a=null==(o=null==t?void 0:t.detail)?void 0:o.opacity),a}function Et(t,e,n){const{pattern:i,renderContent:o,originElem:a,calcElemSize:r,viewScaleInfo:l,viewSizeInfo:s}=n||{},{parentOpacity:c}=n,h=Lt(a)*c,{clipPath:u,clipPathStrokeColor:f,clipPathStrokeWidth:d}=a.detail,g=()=>{t.globalAlpha=h,Ot(t,e,{pattern:i,viewScaleInfo:l,viewSizeInfo:s}),null==o||o(),Wt(t,e,{viewScaleInfo:l}),t.globalAlpha=c};u?(function(t,e,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:h,originH:u,originX:f,originY:d}=s,g=r/h,p=c/u,y=n-f*g,w=o-d*p;t.save(),t.translate(y,w),t.scale(l*g,l*p);const v=Pt(s.commands||[]),m=new Path2D(v);t.clip(m,"nonzero"),t.translate(0-y,0-w),t.setTransform(1,0,0,1,0,0),ht(t,{...e},(()=>{null==i||i()})),t.restore()}else null==i||i()}(t,e,{originElem:a,calcElemSize:r,viewSizeInfo:s,renderContent:()=>{g()}}),"number"==typeof d&&d>0&&f&&function(t,e,n){const{renderContent:i,originElem:o,calcElemSize:a,viewSizeInfo:r,parentOpacity:l}=n,s=r.devicePixelRatio,{clipPath:c,clipPathStrokeColor:h,clipPathStrokeWidth:u}=(null==o?void 0:o.detail)||{};if(c&&a&&c.commands&&"number"==typeof u&&u>0&&h){const{x:n,y:o,w:r,h:f}=a,{originW:d,originH:g,originX:p,originY:y}=c,w=r/d,v=f/g,m=n-p*w,x=o-y*v;t.save(),t.globalAlpha=l,t.translate(m,x),t.scale(s*w,s*v);const b=Pt(c.commands||[]),S=new Path2D(b);t.strokeStyle=h,t.lineWidth=u,t.stroke(S),t.translate(0-m,0-x),t.setTransform(1,0,0,1,0,0),ht(t,{...e},(()=>{null==i||i()})),t.restore()}else null==i||i()}(t,e,{originElem:a,calcElemSize:r,viewSizeInfo:s,parentOpacity:c})):g()}function Ot(t,e,n){var i,o;const{pattern:a,viewScaleInfo:r,viewSizeInfo:l}=n,s=[];if(e.detail.background||a){const{x:n,y:l,w:c,h:h,radiusList:u}=At(e,{viewScaleInfo:r});if(t.beginPath(),t.moveTo(n+u[0],l),t.arcTo(n+c,l,n+c,l+h,u[1]),t.arcTo(n+c,l+h,n,l+h,u[2]),t.arcTo(n,l+h,n,l,u[3]),t.arcTo(n,l,n+c,l,u[0]),t.closePath(),"string"==typeof a)t.fillStyle=a;else if(["CanvasPattern"].includes(W.type(a)))t.fillStyle=a;else if("string"==typeof e.detail.background)t.fillStyle=e.detail.background;else if("linear-gradient"===(null==(i=e.detail.background)?void 0:i.type)){const i=Tt(t,e.detail.background,{viewElementSize:{x:n,y:l,w:c,h:h},viewScaleInfo:r,opacity:t.globalAlpha});t.fillStyle=i}else if("radial-gradient"===(null==(o=e.detail.background)?void 0:o.type)){const i=Tt(t,e.detail.background,{viewElementSize:{x:n,y:l,w:c,h:h},viewScaleInfo:r,opacity:t.globalAlpha});if(t.fillStyle=i,s&&s.length>0)for(let e=0;e<(null==s?void 0:s.length);e++){const i=s[e];"translate"===i.method?t.translate(i.args[0]+n,i.args[1]+l):"rotate"===i.method?t.rotate(...i.args):"scale"===i.method&&t.scale(...i.args)}}t.fill("nonzero"),s&&s.length>0&&t.setTransform(1,0,0,1,0,0)}}function Wt(t,e,n){if(0===e.detail.borderWidth)return;if(!A(e.detail.borderColor))return;const{viewScaleInfo:i}=n,{scale:o}=i;let a=kt.borderColor;!0===A(e.detail.borderColor)&&(a=e.detail.borderColor);const{borderDash:r,borderWidth:l,borderRadius:s,boxSizing:c=kt.boxSizing}=e.detail;let h=[];Array.isArray(r)&&r.length>0&&(h=r.map((t=>Math.ceil(t*o)))),h.length>0?t.lineCap="butt":t.lineCap="square";let u=[0,0,0,0];if("number"==typeof s){const t=s*o;u=[t,t,t,t]}else Array.isArray(s)&&4===(null==s?void 0:s.length)&&(u=[s[0]*o,s[1]*o,s[2]*o,s[3]*o]);let f=0;"number"==typeof l&&(f=l||1),f*=o,t.strokeStyle=a;let d=0,g=0,p=0,y=0;if(Array.isArray(l)&&(d=(l[0]||0)*o,g=(l[1]||0)*o,p=(l[2]||0)*o,y=(l[3]||0)*o),y||g||d||p){t.lineCap="butt";let{x:n,y:i,w:o,h:a}=e;"border-box"===c?(n+=y/2,i+=d/2,o=o-y/2-g/2,a=a-d/2-p/2):"content-box"===c?(n-=y/2,i-=d/2,o=o+y/2+g/2,a=a+d/2+p/2):(n=e.x,i=e.y,o=e.w,a=e.h),d&&(t.beginPath(),t.lineWidth=d,t.moveTo(n-y/2,i),t.lineTo(n+o+g/2,i),t.closePath(),t.stroke()),g&&(t.beginPath(),t.lineWidth=g,t.moveTo(n+o,i-d/2),t.lineTo(n+o,i+a+p/2),t.closePath(),t.stroke()),p&&(t.beginPath(),t.lineWidth=p,t.moveTo(n-y/2,i+a),t.lineTo(n+o+g/2,i+a),t.closePath(),t.stroke()),y&&(t.beginPath(),t.lineWidth=y,t.moveTo(n,i-d/2),t.lineTo(n,i+a+p/2),t.closePath(),t.stroke())}else{let{x:n,y:i,w:o,h:a}=e;"border-box"===c?(n=e.x+f/2,i=e.y+f/2,o=e.w-f,a=e.h-f):"content-box"===c?(n=e.x-f/2,i=e.y-f/2,o=e.w+f,a=e.h+f):(n=e.x,i=e.y,o=e.w,a=e.h),o=Math.max(o,1),a=Math.max(a,1),u=u.map((t=>Math.min(t,o/2,a/2))),t.setLineDash(h),t.lineWidth=f,t.beginPath(),t.moveTo(n+u[0],i),t.arcTo(n+o,i,n+o,i+a,u[1]),t.arcTo(n+o,i+a,n,i+a,u[2]),t.arcTo(n,i+a,n,i,u[3]),t.arcTo(n,i,n+o,i,u[0]),t.closePath(),t.stroke()}t.setLineDash([])}function $t(t,e,n){const{detail:i}=e,{viewScaleInfo:o,renderContent:a}=n,{shadowColor:r,shadowOffsetX:l,shadowOffsetY:s,shadowBlur:c}=i;J.number(c)?(t.save(),t.shadowColor=r||kt.shadowColor,t.shadowOffsetX=(l||0)*o.scale,t.shadowOffsetY=(s||0)*o.scale,t.shadowBlur=(c||0)*o.scale,a(),t.restore()):(t.save(),t.shadowColor="transparent",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,a(),t.restore())}function Ft(t,e,n){const{detail:i,angle:o}=e,{viewScaleInfo:a,viewSizeInfo:r,parentOpacity:l}=n,{background:s="#000000",borderColor:c="#000000",boxSizing:h,borderWidth:u=0,borderDash:f}=i;let d=0;"number"==typeof u&&u>0?d=u:Array.isArray(u)&&"number"==typeof u[0]&&u[0]>0&&(d=u[0]),d*=a.scale;const{x:g,y:p,w:y,h:w}=xt({x:e.x,y:e.y,w:e.w,h:e.h},{viewScaleInfo:a})||e,v={...e,x:g,y:p,w:y,h:w,angle:o};ht(t,{x:g,y:p,w:y,h:w,angle:o},(()=>{$t(t,v,{viewScaleInfo:a,renderContent:()=>{let e=y/2,n=w/2;const i=g+e,o=p+n,r=e,u=n;if(d>0&&("content-box"===h||("center-line"===h?(e-=d/2,n-=d/2):(e-=d,n-=d))),e>=0&&n>=0){const h=Lt(v)*l;t.globalAlpha=h,t.beginPath();const m=Tt(t,s,{viewElementSize:{x:g,y:p,w:y,h:w},viewScaleInfo:a,opacity:t.globalAlpha});if(t.fillStyle=m,t.circle(i,o,r,u,0,0,2*Math.PI),t.closePath(),t.fill("nonzero"),t.globalAlpha=l,"number"==typeof d&&d>0){const r=d/2+e,l=d/2+n;if(t.beginPath(),f){const e=f.map((t=>t*a.scale));t.setLineDash(e)}t.strokeStyle=c,t.lineWidth=d,t.circle(i,o,r,l,0,0,2*Math.PI),t.closePath(),t.stroke(),t.setLineDash([])}}}})}))}function Dt(t,e,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:h}=xt(e,{viewScaleInfo:i})||e,u={...e,x:r,y:l,w:s,h:c,angle:h};ht(t,{x:r,y:l,w:s,h:c,angle:h},(()=>{$t(t,u,{viewScaleInfo:i,renderContent:()=>{Et(t,u,{originElem:e,calcElemSize:{x:r,y:l,w:s,h:c,angle:h},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{}})}})}))}function Bt(t,e,n){const i=n.loader.getContent(e),{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,{x:l,y:s,w:c,h:h,angle:u}=xt(e,{viewScaleInfo:o})||e,f={...e,x:l,y:s,w:c,h:h,angle:u};ht(t,{x:l,y:s,w:c,h:h,angle:u},(()=>{$t(t,f,{viewScaleInfo:o,renderContent:()=>{Et(t,f,{originElem:e,calcElemSize:{x:l,y:s,w:c,h:h,angle:u},viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r,renderContent:()=>{if(i||n.loader.isDestroyed()||n.loader.load(e,n.elementAssets||{}),"image"===e.type&&i){t.globalAlpha=Lt(e)*r;const{x:n,y:a,w:l,h:s,radiusList:c}=At(f,{viewScaleInfo:o}),{detail:h}=e,{scaleMode:u,originW:d=0,originH:g=0}=h,p=t.$undoPixelRatio(d),y=t.$undoPixelRatio(g);if(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(n+c[0],a),t.arcTo(n+l,a,n+l,a+s,c[1]),t.arcTo(n+l,a+s,n,a+s,c[2]),t.arcTo(n,a+s,n,a,c[3]),t.arcTo(n,a,n+l,a,c[0]),t.closePath(),t.fill("nonzero"),t.clip("nonzero"),u&&g&&d){let o=0,r=0,c=p,h=y;const f=n,d=a,g=l,w=s;if(p>e.w||y>e.h)if("fill"===u){const t=Math.max(e.w/p,e.h/y),n=y*t;o=(p*t-e.w)/2/t,r=(n-e.h)/2/t,c=e.w/t,h=e.h/t}else if("tile"===u)o=0,r=0,c=e.w,h=e.h;else if("fit"===u){const t=Math.min(e.w/p,e.h/y);o=(p-e.w/t)/2,r=(y-e.h/t)/2,c=e.w/t,h=e.h/t}t.drawImage(i,o,r,c,h,f,d,g,w)}else t.drawImage(i,n,a,l,s);t.globalAlpha=r,t.restore()}}})}})}))}function Vt(t,e,n){const i=n.loader.getContent(e),{viewScaleInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:h}=xt(e,{viewScaleInfo:o})||e;ht(t,{x:r,y:l,w:s,h:c,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(e,n.elementAssets||{}),"svg"===e.type&&i&&(t.globalAlpha=Lt(e)*a,t.drawImage(i,r,l,s,c),t.globalAlpha=a)}))}function jt(t,e,n){const i=n.loader.getContent(e),{viewScaleInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:h}=xt(e,{viewScaleInfo:o})||e;ht(t,{x:r,y:l,w:s,h:c,angle:h},(()=>{i||n.loader.isDestroyed()||n.loader.load(e,n.elementAssets||{}),"html"===e.type&&i&&(t.globalAlpha=Lt(e)*a,t.drawImage(i,r,l,s,c),t.globalAlpha=a)}))}const Xt={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 Yt(t,e,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,calculator:r}=n,{x:l,y:s,w:c,h:h,angle:u}=xt(e,{viewScaleInfo:i})||e,f={...e,x:l,y:s,w:c,h:h,angle:u};ht(t,{x:l,y:s,w:c,h:h,angle:u},(()=>{var d,g;$t(t,f,{viewScaleInfo:i,renderContent:()=>{Et(t,f,{originElem:e,calcElemSize:{x:l,y:s,w:c,h:h,angle:u},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a})}});{const o={...Xt,...e.detail},a=(o.fontSize||Xt.fontSize)*i.scale;if(a<2)return;const{parentOpacity:c}=n,h=Lt(e)*c;t.globalAlpha=h,t.fillStyle=e.detail.color||Xt.color,t.textBaseline="top",t.$setFont({fontWeight:o.fontWeight,fontSize:a,fontFamily:Rt(o.fontFamily)});{const n=r.getVirtualFlatItem(e.uuid);Array.isArray(null==n?void 0:n.textLines)&&(null==(d=null==n?void 0:n.textLines)?void 0:d.length)>0&&(void 0!==o.textShadowColor&&A(o.textShadowColor)&&(t.shadowColor=o.textShadowColor),void 0!==o.textShadowOffsetX&&J.number(o.textShadowOffsetX)&&(t.shadowOffsetX=o.textShadowOffsetX),void 0!==o.textShadowOffsetY&&J.number(o.textShadowOffsetY)&&(t.shadowOffsetY=o.textShadowOffsetY),void 0!==o.textShadowBlur&&J.number(o.textShadowBlur)&&(t.shadowBlur=o.textShadowBlur),null==(g=null==n?void 0:n.textLines)||g.forEach((e=>{t.fillText(e.text,l+e.x*i.scale,s+e.y*i.scale)})))}t.globalAlpha=c}}))}function Ht(t,e,n){var i,o,a;if(!0===(null==(i=null==e?void 0:e.operations)?void 0:i.invisible))return;const{w:r,h:l}=e,{scale:s}=n.viewScaleInfo;if(s<1&&(r*s<.4||l*s<.4)||0===n.parentOpacity)return;const{overrideElementMap:c}=n;if(!(null==(a=null==(o=null==c?void 0:c[e.uuid])?void 0:o.operations)?void 0:a.invisible))try{switch(e.type){case"rect":Dt(t,e,n);break;case"circle":Ft(t,e,n);break;case"text":Yt(t,e,n);break;case"image":Bt(t,e,n);break;case"svg":Vt(t,e,n);break;case"html":jt(t,e,n);break;case"path":!function(t,e,n){var i,o;const{detail:a}=e,{originX:r,originY:l,originW:s,originH:c,fillRule:h}=a,{viewScaleInfo:u,viewSizeInfo:f,parentOpacity:d}=n,{x:g,y:p,w:y,h:w,angle:v}=xt(e,{viewScaleInfo:u})||e,m=y/s,x=w/c,b=g-r*m,S=p-l*x,{clipPath:I,clipPathStrokeColor:M,clipPathStrokeWidth:P,...C}=e.detail,A=u.scale*f.devicePixelRatio,z={...e,x:g,y:p,w:y,h:w,angle:v};let R={...z};R.detail=C;let T={...e};T.detail=C,a.fill&&"string"!==a.fill&&(null==(o=null==(i=a.fill)?void 0:i.type)?void 0:o.includes("gradient"))&&(R={...z,detail:{...z.detail,background:a.fill,clipPath:{commands:a.commands,originX:r,originY:l,originW:s,originH:c}}},T.detail={...R.detail}),ht(t,{x:g,y:p,w:y,h:w,angle:v},(()=>{Et(t,R,{originElem:T,calcElemSize:{x:g,y:p,w:y,h:w,angle:v},viewScaleInfo:u,viewSizeInfo:f,parentOpacity:d,renderContent:()=>{$t(t,z,{viewScaleInfo:u,renderContent:()=>{t.save(),t.translate(b,S),t.scale(A*m/u.scale,A*x/u.scale);const e=Pt(a.commands||[]),n=new Path2D(e);a.fill&&("string"==typeof a.fill?t.fillStyle=a.fill:t.fillStyle="transparent"),a.fill&&t.fill(n,h||"nonzero"),a.stroke&&0!==a.strokeWidth&&(t.strokeStyle=a.stroke,t.lineWidth=(a.strokeWidth||1)/f.devicePixelRatio,t.lineCap=a.strokeLineCap||"square",t.stroke(n)),t.translate(-b,-S),t.restore()}})}})}))}(t,e,n);break;case"group":{const i={...n.elementAssets||{},...e.detail.assets||{}};Ut(t,e,{...n,elementAssets:i});break}}}catch(t){console.error(t)}}function Ut(t,e,n){const{viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a}=n,{x:r,y:l,w:s,h:c,angle:h}=xt({x:e.x,y:e.y,w:e.w,h:e.h,angle:e.angle},{viewScaleInfo:i})||e,u={...e,x:r,y:l,w:s,h:c,angle:h};ht(t,{x:r,y:l,w:s,h:c,angle:h},(()=>{t.globalAlpha=Lt(e)*a,$t(t,u,{viewScaleInfo:i,renderContent:()=>{Et(t,u,{originElem:e,calcElemSize:{x:r,y:l,w:s,h:c,angle:h},viewScaleInfo:i,viewSizeInfo:o,parentOpacity:a,renderContent:()=>{const{x:o,y:r,w:l,h:s,radiusList:c}=At(u,{viewScaleInfo:i});if("hidden"===e.detail.overflow&&(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(o+c[0],r),t.arcTo(o+l,r,o+l,r+s,c[1]),t.arcTo(o+l,r+s,o,r+s,c[2]),t.arcTo(o,r+s,o,r,c[3]),t.arcTo(o,r,o+l,r,c[0]),t.closePath(),t.fill("nonzero"),t.clip("nonzero")),Array.isArray(e.detail.children)){const{parentElementSize:i}=n,o={x:i.x+e.x,y:i.y+e.y,w:e.w||i.w,h:e.h||i.h,angle:e.angle},{calculator:r}=n;for(let i=0;i<e.detail.children.length;i++){let l=e.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{Ht(t,l,{...n,parentOpacity:a*Lt(e)})}catch(t){console.error(t)}}}"hidden"===e.detail.overflow&&t.restore()}})}}),t.globalAlpha=a}))}const Nt={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 Qt(t,e,n){var i;const{elements:o=[]}=e,{parentOpacity:a}=n;for(let e=0;e<o.length;e++){const r=o[e],l={...r,detail:{...Nt,...null==r?void 0:r.detail}};if(!0===n.forceDrawAll||(null==(i=n.calculator)?void 0:i.needRender(l)))try{Ht(t,l,{...n,parentOpacity:a})}catch(t){console.error(t)}}}function Gt(t,e,n,i){const{viewScaleInfo:o,viewSizeInfo:a,parentOpacity:r}=n,l={uuid:"layout",type:"group",...e},{x:s,y:c,w:h,h:u}=xt(l,{viewScaleInfo:o})||l,f={...l,x:s,y:c,w:h,h:u,angle:0};if(t.globalAlpha=1,$t(t,f,{viewScaleInfo:o,renderContent:()=>{Ot(t,f,{viewScaleInfo:o,viewSizeInfo:a})}}),"hidden"===e.detail.overflow){const{viewScaleInfo:i,viewSizeInfo:o}=n,a={uuid:"layout",type:"group",...e},r=xt(a,{viewScaleInfo:i})||a,l={...a,...r},{x:s,y:c,w:h,h:u,radiusList:f}=At(l,{viewScaleInfo:i});t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(s+f[0],c),t.arcTo(s+h,c,s+h,c+u,f[1]),t.arcTo(s+h,c+u,s,c+u,f[2]),t.arcTo(s,c+u,s,c,f[3]),t.arcTo(s,c,s+h,c,f[0]),t.closePath(),t.fill("nonzero"),t.clip("nonzero")}i(t),"hidden"===e.detail.overflow&&t.restore(),Wt(t,f,{viewScaleInfo:o}),t.globalAlpha=r}function qt(t,e,n){if("string"==typeof(null==e?void 0:e.background)){const{viewSizeInfo:i}=n,{width:o,height:a}=i;t.globalAlpha=1,t.fillStyle=e.background,t.fillRect(0,0,o,a)}}const Jt=["image","svg","html"],Kt=t=>{var e,n,i;let o=null;return"image"===t.type?o=(null==(e=null==t?void 0:t.detail)?void 0:e.src)||null:"svg"===t.type?o=(null==(n=null==t?void 0:t.detail)?void 0:n.svg)||null:"html"===t.type&&(o=(null==(i=null==t?void 0:t.detail)?void 0:i.html)||null),"string"==typeof o&&o?L(o)?o:k(o,t.uuid):k(`${R()}-${t.uuid}-${R()}-${R()}`,t.uuid)};class Zt extends _{constructor(){super(),M(this,a),M(this,e,{}),M(this,n,{}),M(this,i,{}),M(this,o,!1),C(this,a,r).call(this,"image",(async(t,e)=>{var n;const i=(null==(n=e[t.detail.src])?void 0:n.value)||t.detail.src,o=await D(i);return{uuid:t.uuid,lastModified:Date.now(),content:o}})),C(this,a,r).call(this,"html",(async(t,e)=>{var n;const i=(null==(n=e[t.detail.html])?void 0:n.value)||t.detail.html,o=await V(i,{width:t.detail.originW||t.w,height:t.detail.originH||t.h});return{uuid:t.uuid,lastModified:Date.now(),content:o}})),C(this,a,r).call(this,"svg",(async(t,e)=>{var n;const i=(null==(n=e[t.detail.svg])?void 0:n.value)||t.detail.svg,o=await B(i);return{uuid:t.uuid,lastModified:Date.now(),content:o}}))}isDestroyed(){return I(this,o)}reset(){!0!==I(this,o)&&(P(this,n,{}),P(this,i,{}))}resetElementAsset(t){var e,o,a;if(Jt.includes(t.type)){let r=null,l=null;"image"===t.type&&"string"==typeof(null==(e=null==t?void 0:t.detail)?void 0:e.src)?l=t.detail.src:"svg"===t.type&&"string"==typeof(null==(o=null==t?void 0:t.detail)?void 0:o.svg)?l=t.detail.svg:"html"===t.type&&"string"==typeof(null==(a=null==t?void 0:t.detail)?void 0:a.html)&&(l=t.detail.html),"string"==typeof l&&(this.load(t,{}),L(l)?r=l:t.uuid&&(r=k(l,t.uuid))),r&&L(r)&&(delete I(this,i)[r],delete I(this,n)[r])}}destroy(){P(this,o,!0),this.clear(),P(this,e,null),P(this,n,null),P(this,i,null)}load(t,e){!0!==I(this,o)&&(C(this,a,f).call(this,t)||Jt.includes(t.type)&&C(this,a,u).call(this,t,e))}getContent(t){var e,n;const o=Kt(t);return(null==(n=null==(e=I(this,i))?void 0:e[o])?void 0:n.content)||null}getLoadItemMap(){return I(this,i)}setLoadItemMap(t){P(this,i,t)}}e=new WeakMap,n=new WeakMap,i=new WeakMap,o=new WeakMap,a=new WeakSet,r=function(t,n){I(this,e)[t]=n},l=function(t){var e,n,i;let o=null;return"image"===t.type?o=(null==(e=null==t?void 0:t.detail)?void 0:e.src)||null:"svg"===t.type?o=(null==(n=null==t?void 0:t.detail)?void 0:n.svg)||null:"html"===t.type&&(o=(null==(i=null==t?void 0:t.detail)?void 0:i.html)||null),o},s=function(t){return{element:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:C(this,a,l).call(this,t)}},c=function(t){const e=Kt(t.element),n=I(this,i)[e];I(this,o)||(n?n.startTime<t.startTime&&(I(this,i)[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})):(I(this,i)[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})))},h=function(t){var e;const n=Kt(t.element),a=null==(e=I(this,i))?void 0:e[n];I(this,o)||(a?a.startTime<t.startTime&&(I(this,i)[n]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})):(I(this,i)[n]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})))},u=function(t,i){const r=C(this,a,s).call(this,t),l=Kt(t);if(I(this,n)[l])return;I(this,n)[l]=r;const u=I(this,e)[t.type];"function"!=typeof u||I(this,o)||(r.startTime=Date.now(),u(t,i).then((t=>{I(this,o)||(r.content=t.content,r.endTime=Date.now(),r.status="load",C(this,a,c).call(this,r))})).catch((e=>{console.warn(`Load element source "${r.source}" fail`,e,t),r.endTime=Date.now(),r.status="error",r.error=e,C(this,a,h).call(this,r)})))},f=function(t){var e;const i=Kt(t),o=null==(e=I(this,n))?void 0:e[i];return!(!o||"error"!==o.status||!o.source||o.source!==C(this,a,l).call(this,t))};const _t={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 te(t,e){const{w:n,h:i}=t,o=e.tempContext,a=[],r={..._t,...t.detail},l=r.fontSize||_t.fontSize,s=l;if(s<2)return{};const c=r.lineHeight||l;o.textBaseline="top",o.$setFont({fontWeight:r.fontWeight,fontSize:s,fontFamily:Rt(r.fontFamily)});let h=r.text.replace(/\r\n/gi,"\n");"lowercase"===r.textTransform?h=h.toLowerCase():"uppercase"===r.textTransform&&(h=h.toUpperCase());const u=c,f=h.split("\n");let d=0;f.forEach(((t,e)=>{if("maxContent"===r.minInlineSize)a.push({x:0,y:0,text:t,width:o.$undoPixelRatio(o.measureText(t).width)});else{let c="",h="",g=t.split(h);if("normal"===r.wordBreak){h=" ";const e=t.split(h);g=[],e.forEach(((t,n)=>{g.push(t),n<e.length-1&&g.push(h)}))}if(1===g.length&&"visible"===r.overflow)a.push({x:0,y:0,text:g[0],width:o.$undoPixelRatio(o.measureText(g[0]).width)});else if(g.length>0){for(let t=0;t<g.length&&(l=o.$doPixelRatio(n),s=o.measureText(c+g[t]).width,l>=s?c+=g[t]||"":(a.push({x:0,y:0,text:c,width:o.$undoPixelRatio(o.measureText(c).width)}),c=g[t]||"",d++),!((d+1)*u>i&&"hidden"===r.overflow));t++)if(g.length-1===t&&(d+1)*u<=i){a.push({x:0,y:0,text:c,width:o.$undoPixelRatio(o.measureText(c).width)}),e<f.length-1&&d++;break}}else a.push({x:0,y:0,text:"",width:0})}var l,s}));let g=0,p=0;u>s&&(p=(u-s)/2),a.length*u<i&&("top"===r.verticalAlign?g=0:"bottom"===r.verticalAlign?g+=i-a.length*u:g+=(i-a.length*u)/2);{const t=0+g;a.forEach(((e,i)=>{let o=0;"center"===r.textAlign?o=0+(n-e.width)/2:"right"===r.textAlign&&(o=n-e.width+0),a[i].x=o,a[i].y=t+u*i+p}))}return{textLines:a}}function ee(t,e){let n={};return"text"===t.type&&(n=te(t,e)),n}function ne(t,e){const{viewScaleInfo:n,viewSizeInfo:i,tempContext:o}=e,a=function(t,e){const n={},i=[],o=a=>{const r={type:a.type,isVisibleInView:!0,position:[...i]};let l=null;l=It(a,{groupQueue:yt(t,i)||[]});const s={...r,originRectInfo:l,rangeRectInfo:J.angle(a.angle)?Mt(l):l,...ee(a,e)};n[a.uuid]=s,"group"===a.type&&a.detail.children.forEach(((t,e)=>{i.push(e),o(t),i.pop()}))};return t.forEach(((t,e)=>{i.push(e),o(t),i.pop()})),n}(t,{tempContext:o});return ie(a,{viewScaleInfo:n,viewSizeInfo:i})}function ie(t,e){const n=function(t){const{viewScaleInfo:e,viewSizeInfo:n}=t,{scale:i,offsetTop:o,offsetLeft:a}=e,{width:r,height:l}=n,s=0-a/i,c=0-o/i,h=r/i,u=l/i,f=ut({x:s,y:c,w:h,h:u}),d={x:s,y:c},g={x:s+h,y:c},p={x:s,y:c+u},y={x:s+h,y:c+u},w={x:s,y:f.y},v={x:f.x,y:c},m={x:s+h,y:f.y},x={x:f.x,y:c+u};return{center:f,topLeft:d,topRight:g,bottomLeft:p,bottomRight:y,left:w,top:v,right:m,bottom:x}}(e);let i=0,o=0;return Object.keys(t).forEach((e=>{const a=t[e];a.isVisibleInView=function(t,e){const n=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),i=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),a=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),r=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),l=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),s=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),c=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y);return n<=l&&i>=r&&o<=c&&a>=s||l<=a&&l>=a&&l<=a&&l>=a}(a.rangeRectInfo,n),a.isVisibleInView?i++:o++})),{virtualFlatItemMap:t,visibleCount:i,invisibleCount:o}}class oe{constructor(t){M(this,d),M(this,g),P(this,d,t),P(this,g,new st({defaultStorage:{virtualFlatItemMap:{},visibleCount:0,invisibleCount:0}}))}toGridNum(t,e){return!0===(null==e?void 0:e.ignore)?t:Math.round(t)}destroy(){P(this,d,null)}needRender(t){const e=I(this,g).get("virtualFlatItemMap")[t.uuid];return!e||e.isVisibleInView}getPointElement(t,e){return function(t,e){var n,i,o;const{context2d:a,data:r,viewScaleInfo:l,groupQueue:s}=e,c={index:-1,element:null,groupQueueIndex:-1};if(s&&Array.isArray(s)&&(null==s?void 0:s.length)>0)for(let e=s.length-1;e>=0;e--){let o=0,r=0,h=0;for(let t=0;t<=e;t++)o+=s[t].x,r+=s[t].y,h+=s[t].angle||0;const u=s[e];if(u&&"group"===u.type&&Array.isArray(null===(n=u.detail)||void 0===n?void 0:n.children))for(let n=0;n<u.detail.children.length;n++){const f=u.detail.children[n];if(!0!==(null===(i=null==f?void 0:f.operations)||void 0===i?void 0:i.invisible)){if(!f)break;if(St(t,{context2d:a,element:{x:o+f.x,y:r+f.y,w:f.w,h:f.h,angle:h+(f.angle||0)},viewScaleInfo:l})){c.element=f,(e<s.length-1||"group"!==f.type)&&(c.groupQueueIndex=e);break}}}if(c.element)break}if(c.element)return c;for(let e=r.elements.length-1;e>=0;e--){const n=r.elements[e];if(!0!==(null===(o=null==n?void 0:n.operations)||void 0===o?void 0:o.invisible)&&St(t,{context2d:a,element:n,viewScaleInfo:l})){c.index=e,c.element=n;break}}return c}(t,{...e,context2d:I(this,d).tempContext})}resetVirtualFlatItemMap(t,e){if(t){const{virtualFlatItemMap:n,invisibleCount:i,visibleCount:o}=ne(t.elements,{...e,tempContext:I(this,d).tempContext});I(this,g).set("virtualFlatItemMap",n),I(this,g).set("invisibleCount",i),I(this,g).set("visibleCount",o)}}updateVisiableStatus(t){const{virtualFlatItemMap:e,invisibleCount:n,visibleCount:i}=ie(I(this,g).get("virtualFlatItemMap"),t);I(this,g).set("virtualFlatItemMap",e),I(this,g).set("invisibleCount",n),I(this,g).set("visibleCount",i)}calcViewRectInfoFromOrigin(t,e){const n=I(this,g).get("virtualFlatItemMap")[t];if(!(null==n?void 0:n.originRectInfo))return null;const{checkVisible:i,viewScaleInfo:o,viewSizeInfo:a}=e,{center:r,left:l,right:s,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:d,bottomRight:p}=n.originRectInfo;if(!0===i&&!1===n.isVisibleInView)return null;const y={viewScaleInfo:o};return{center:bt(r,y),left:bt(l,y),right:bt(s,y),bottom:bt(c,y),top:bt(h,y),topLeft:bt(u,y),topRight:bt(f,y),bottomLeft:bt(d,y),bottomRight:bt(p,y)}}calcViewRectInfoFromRange(t,e){const n=I(this,g).get("virtualFlatItemMap")[t];if(!(null==n?void 0:n.originRectInfo))return null;const{checkVisible:i,viewScaleInfo:o,viewSizeInfo:a}=e,{center:r,left:l,right:s,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:d,bottomRight:p}=n.rangeRectInfo;if(!0===i&&!1===n.isVisibleInView)return null;const y={viewScaleInfo:o};return{center:bt(r,y),left:bt(l,y),right:bt(s,y),bottom:bt(c,y),top:bt(h,y),topLeft:bt(u,y),topRight:bt(f,y),bottomLeft:bt(d,y),bottomRight:bt(p,y)}}modifyText(t){const e=I(this,g).get("virtualFlatItemMap"),n=e[t.uuid];if(t&&"text"===t.type){const i={...n,...te(t,{tempContext:I(this,d).tempContext})};e[t.uuid]=i,I(this,g).set("virtualFlatItemMap",e)}}modifyVirtualFlatItemMap(t,e){const{modifyInfo:n,viewScaleInfo:i,viewSizeInfo:o}=e,{type:a,content:r}=n,l=t.elements,s=I(this,g).get("virtualFlatItemMap");if("deleteElement"===a){const{element:t}=r,e=[],n=t=>{e.push(t.uuid),"group"===t.type&&Array.isArray(t.detail.children)&&t.detail.children.forEach((t=>{n(t)}))};n(t),e.forEach((t=>{delete s[t]})),I(this,g).set("virtualFlatItemMap",s)}else if("addElement"===a||"updateElement"===a){const{position:e}=r,n=function(t,e){let n=null,i=e;for(let e=0;e<t.length;e++){const o=i[t[e]];if(e<t.length-1&&"group"===(null==o?void 0:o.type))i=o.detail.children;else{if(e!==t.length-1)break;n=o}}return n}(e,t.elements),c=yt(l,e);if(n)if("updateElement"===a&&"group"===n.type)this.resetVirtualFlatItemMap(t,{viewScaleInfo:i,viewSizeInfo:o});else{const t=It(n,{groupQueue:c||[]}),r={type:n.type,originRectInfo:t,rangeRectInfo:J.angle(n.angle)?Mt(t):t,isVisibleInView:!0,position:[...e],...ee(n,{tempContext:I(this,d).tempContext})};s[n.uuid]=r,I(this,g).set("virtualFlatItemMap",s),"updateElement"===a&&this.updateVisiableStatus({viewScaleInfo:i,viewSizeInfo:o})}}else"moveElement"===a&&this.resetVirtualFlatItemMap(t,{viewScaleInfo:i,viewSizeInfo:o})}getVirtualFlatItem(t){return I(this,g).get("virtualFlatItemMap")[t]||null}}d=new WeakMap,g=new WeakMap;return p=new WeakMap,y=new WeakMap,w=new WeakMap,v=new WeakMap,m=new WeakSet,x=function(){const t=I(this,y);t.on("load",(t=>{this.trigger("load",t)})),t.on("error",(t=>{console.error(t)}))},t.Calculator=oe,t.Renderer=class extends _{constructor(t){super(),M(this,m),M(this,p),M(this,y,new Zt),M(this,w),M(this,v,!1),P(this,p,t),P(this,w,new oe({tempContext:t.tempContext})),C(this,m,x).call(this)}isDestroyed(){return I(this,v)}destroy(){this.clear(),P(this,p,null),I(this,y).destroy(),P(this,y,null),P(this,v,!0)}updateOptions(t){P(this,p,t)}drawData(t,e){const n=I(this,y),i=I(this,w),{sharer:o}=I(this,p),a=I(this,p).viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const r={x:0,y:0,w:e.viewSizeInfo.width,h:e.viewSizeInfo.height};!0===e.forceDrawAll&&I(this,w).resetVirtualFlatItemMap(t,{viewScaleInfo:e.viewScaleInfo,viewSizeInfo:e.viewSizeInfo});const l={loader:n,calculator:i,parentElementSize:r,elementAssets:t.assets,parentOpacity:1,overrideElementMap:null==o?void 0:o.getActiveOverrideElemenentMap(),...e};qt(a,t.global,l),t.layout?Gt(a,t.layout,l,(()=>{Qt(a,t,l)})):Qt(a,t,l)}scale(t){const{sharer:e}=I(this,p);if(!e)return;const{data:n,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r,width:l,height:s,contextHeight:c,contextWidth:h,devicePixelRatio:u}=e.getActiveStoreSnapshot();n&&this.drawData(n,{viewScaleInfo:{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:a,offsetRight:r},viewSizeInfo:{width:l,height:s,contextHeight:c,contextWidth:h,devicePixelRatio:u}})}setLoadItemMap(t){I(this,y).setLoadItemMap(t)}getLoadItemMap(){return I(this,y).getLoadItemMap()}getLoader(){return I(this,y)}getCalculator(){return I(this,w)}},t.drawCircle=Ft,t.drawElement=Ht,t.drawElementList=Qt,t.drawGlobalBackground=qt,t.drawGroup=Ut,t.drawHTML=jt,t.drawImage=Bt,t.drawLayout=Gt,t.drawRect=Dt,t.drawSVG=Vt,t.drawText=Yt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|
|
1
|
+
var iDrawRenderer=function(t){"use strict";function e(t,e){if(1===e)return t;let i=1;const n=/^#[0-9a-f]{6,6}$/i;let o=t;if(n.test(t)?i=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(i=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),i*=e,n.test(o)&&i>0&&i<1){const t=Math.max(0,Math.min(255,Math.ceil(256*i)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o}function i(t){return(65536*(1+Math.random())|0).toString(16).substring(1)}function n(){return`${i()}${i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}function o(t,e){let i=0;for(let e=0;e<t.length;e++)i+=t.charCodeAt(e);return(i+e).toString(16).substring(0,4)}function r(t,e){const i=t.length,n=function(t){let e=0;for(let i=0;i<t.length;i++)e+=t.charCodeAt(i);return e}(e),r=Math.floor(i/2),a=t.substring(0,4).padStart(4,"0"),s=t.substring(0,4).padStart(4,"0");return`@assets/${o(i.toString(16).padStart(4,a),n).padStart(4,"0")}${o(t.substring(r-4,r).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-8,r-4).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-12,r-8).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-16,r-12).padStart(4,s),n).padStart(4,"0")}-${o(t.substring(r,r+4).padStart(4,s),n).padStart(4,"0")}${o(t.substring(r+4,r+8).padStart(4,s),n).padStart(4,"0")}${o(s.padStart(4,a).padStart(4,s),n)}`}function a(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function s(t){return function t(e){const i=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return e;if("Array"===i){const i=[];return e.forEach(e=>{i.push(t(e))}),i}if("Object"===i){const i={};Object.keys(e).forEach(n=>{i[n]=t(e[n])});return Object.getOwnPropertySymbols(e).forEach(n=>{i[n]=t(e[n])}),i}}(t)}const{Image:l}=window;function c(t){return new Promise((e,i)=>{const n=new l;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t})}async function h(t){const e=await(i=t,new Promise((t,e)=>{const n=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(n),o.onload=function(e){const i=e?.target?.result;t(i)},o.onerror=function(t){e(t)}}));var i;return await c(e)}async function u(t,e){t=t.replace(/&/gi,"&");const i=await function(t,e){const{width:i,height:n}=e;return new Promise((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${n||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){const i=t?.target?.result;e(i)},a.onerror=function(t){o(t)}})}(t,e);return await c(i)}function f(t){return"number"==typeof t&&t>=0}function p(t){return"number"==typeof t&&(t>0||t<=0)}function d(t){return p(t)}function y(t){return p(t)}function g(t){return f(t)}function m(t){return f(t)}function x(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function w(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function b(t){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(t)}const I={positiveNum:f,data:function(t){return!!(Array(t?.materials)&&t?.materials.length>=0)},material:function(t){return!!t&&(b(t?.type)&&d(t?.x)&&y(t?.y)&&g(t?.w)&&m(t?.h))},layout:function(t){return!!t&&(d(t?.x)&&y(t?.y)&&g(t?.w)&&m(t?.h))},type:b,x:d,y:y,width:g,height:m,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:p,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},strokeWidth:function(t){return f(t)||Array.isArray(t)&&f(t[0])&&f(t[1])&&f(t[2])&&f(t[3])},cornerRadius:function(t){return f(t)||Array.isArray(t)&&f(t[0])&&f(t[1])&&f(t[2])&&f(t[3])},color:function(t){return"string"==typeof(e=t)&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e));var e},imageSrc:function(t){return w(t)||x(t)},imageURL:x,imageBase64:w,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let i=document.createElement("div");i.innerHTML=t,i.children.length>0&&(e=!0),i=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return p(t)&&t>0},lineHeight:function(t){return p(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)}};class v{#t;constructor(){this.#t=new Map}on(t,e){if(this.#t.has(t)){const i=this.#t.get(t)||[];i?.push(e),this.#t.set(t,i)}else this.#t.set(t,[e])}off(t,e){if(this.#t.has(t)){const i=this.#t.get(t);if(Array.isArray(i))for(let t=0;t<i?.length;t++)if(i[t]===e){i.splice(t,1);break}this.#t.set(t,i||[])}}trigger(t,e){const i=this.#t.get(t);return!!Array.isArray(i)&&(i.forEach(t=>{t(e)}),!0)}has(t){if(this.#t.has(t)){const e=this.#t.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#t.clear()}}function M(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}class S{#e;#i;#n;constructor(t){this.#i=s(t.defaultStorage),this.#e=this.#o(),this.#n=t.defaultStatic||{}}set(t,e){this.#e[t]=e}get(t){return this.#e[t]}setStatic(t,e){this.#n[t]=e}getStatic(t){return this.#n[t]}getSnapshot(t){return!0===t?.deepClone?s(this.#e):{...this.#e}}clear(){this.#e=this.#o()}destroy(){this.#e=null,this.#n=null}#o(){return s(this.#i)}}function L(t){return t/180*Math.PI}function C(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function k(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),i=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return C({x:e,y:i,width:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,height:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-i})}function A(t,e,i){const n=function(t,e){const i=e.x-t.x,n=e.y-t.y;if(0===i){if(n<0)return 0;if(n>0)return Math.PI}else if(0===n){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&n<0?Math.atan(Math.abs(i)/Math.abs(n)):i>0&&n>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):0}(t,e);let o=n+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=function(t,e){const i=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===i?i:Math.sqrt(i)}(t,e);let a=0,s=0;return 0===o?(a=0,s=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,s=0-Math.cos(o)*r):o===Math.PI/2?(a=r,s=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,s=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,s=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,s=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,s=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,s=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,s=0-r),a+=t.x,s+=t.y,{x:a,y:s}}function R(t,e,i){const{x:n,y:o,width:r,height:a}=t;let s={x:n,y:o},l={x:n+r,y:o},c={x:n+r,y:o+a},h={x:n,y:o+a};if(i&&(i>0||i<0)){const t=L(T(i));s=A(e,s,t),l=A(e,l,t),c=A(e,c,t),h=A(e,h,t)}return[s,l,c,h]}function P(t,e,i){return[A(t,{x:e[0].x,y:e[0].y},i),A(t,{x:e[1].x,y:e[1].y},i),A(t,{x:e[2].x,y:e[2].y},i),A(t,{x:e[3].x,y:e[3].y},i)]}function T(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function $(t,e){const i=[];let n=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const o=n[e[t]];if("group"!==o?.type||!Array.isArray(o?.children))return null;i.push(o),n=o.children}return i}function D(t){const{x:e,y:i,height:n,width:o}=t;return[{x:e,y:i},{x:e+o,y:i},{x:e+o,y:i+n},{x:e,y:i+n}]}function z(t){const{x:e,y:i,width:n,height:o,angle:r=0}=t;return 0===r?D(t):R(t,C({x:e,y:i,width:n,height:o}),r)}function O(t,e){const{groupQueue:i}=e;if(!(i.length>0))return[z(t)];const n=function(t){const e=[];let i=0,n=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:s,width:l,height:c,angle:h=0}=r[t];let u;if(i+=a,n+=s,0===t){const t={x:i,y:n,width:l,height:c};u=z({x:a,y:s,width:l,height:c,angle:h}),o.push({center:C(t),angle:h,radian:L(h)})}else{u=D({x:i,y:n,width:l,height:c});for(let t=0;t<o.length;t++){const{center:e,radian:i}=o[t];u=P(e,u,i)}const t=k(u);(h>0||h<0)&&(u=P(t,u,L(h))),o.push({center:t,angle:h,radian:L(h)})}e.push(u)}return e}([...i,t]);return n}function V(t,e){const{viewScaleInfo:i}=e,{id:n,x:o,y:r,width:a,height:s,angle:l}=t,{scale:c=1,offsetTop:h=0,offsetLeft:u=0}=i;return{id:n,x:o*c+u,y:r*c+h,width:a*c,height:s*c,angle:l}}function E(t,e){const{viewScaleInfo:i}=e,{x:n,y:o}=t,{scale:r,offsetTop:a,offsetLeft:s}=i;return{x:n*r+s,y:o*r+a}}function j(t,e){const{context2d:i,material:n,viewScaleInfo:o}=e,{angle:r=0}=n,{x:a,y:s,width:l,height:c}=V(n,{viewScaleInfo:o}),h=function(t){const{angle:e=0}=t;return R(t,C(t),e)}({x:a,y:s,width:l,height:c,angle:r});if(h.length>=2){i.beginPath(),i.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)i.lineTo(h[t].x,h[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function F(t,e){const{groupQueue:i}=e,n=function(t,e){return O(t,e).pop()||null}(t,{groupQueue:i}),o=M(n[0],n[1]),r=M(n[1],n[2]),a=M(n[2],n[3]),s=M(n[3],n[0]),l=n[0],c=n[1],h=n[2],u=n[3],f=Math.max(l.x,c.x,h.x,u.x),p=Math.max(l.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(l.x,c.x,h.x,u.x))/2,y:(p+Math.min(l.y,c.y,h.y,u.y))/2},topLeft:l,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:r,left:s,bottom:a}}function B(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),i=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),n=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},a={x:n,y:o},s={x:e,y:o},l={x:e,y:i},c={x:n,y:i},h=M(a,s),u=M(c,l),f=M(a,c);return{center:r,topLeft:a,topRight:s,bottomLeft:c,bottomRight:l,top:h,right:M(s,l),left:f,bottom:u}}function W(t){let e="";return t.forEach(t=>{e+=t.type+t.params?.join?.(" ")}),e}const Q="#787878",U=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200" fill="${Q}"><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zM338 304c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64z m513.9 437.1c-1.4 1.2-3.3 1.9-5.2 1.9H177.2c-4.4 0-8-3.6-8-8 0-1.9 0.7-3.7 1.9-5.2l170.3-202c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l99.4 118 158.1-187.5c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l229.6 271.6c2.6 3.3 2.2 8.4-1.2 11.2z" ></path></svg>`)}`;function H(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:Q,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:"Text",fontSize:12,fontFamily:"system-ui",fontWeight:"normal",fontStyle:"normal",textAnchor:"start",textDecoration:"none",letterSpacing:"normal",wordSpacing:"normal",writingMode:"horizontal-tb",textAlign:"left",verticalAlign:"top",href:U}}const G=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function N(t){return[t,...G].join(", ")}const Z=()=>Math.random().toString(36).substring(2);function J(){return`${Z()}${Z()}`.substring(0,16)}function X(t,e,i){const n=[];return t.forEach(t=>{const o=function(t,e,i){const{type:n}=t,o=[...t.params],r=t.id;let a={id:r};if(t.start&&t.end){const n={...t.start},o={...t.end};n.x+=e,n.y+=i,o.x+=e,o.y+=i,a={id:r,start:n,end:o}}switch(n){case"M":case"L":case"T":return o[0]+=e,o[1]+=i,{type:n,params:o,...a};case"H":return o[0]+=e,{type:n,params:o,...a};case"V":return o[0]+=i,{type:n,params:o,...a};case"C":return o[0]+=e,o[1]+=i,o[2]+=e,o[3]+=i,o[4]+=e,o[5]+=i,{type:n,params:o,...a};case"S":case"Q":return o[0]+=e,o[1]+=i,o[2]+=e,o[3]+=i,{type:n,params:o,...a};case"A":return o[5]+=e,o[6]+=i,{type:n,params:o,...a};default:return{type:n,params:o,...a}}}(t,e,i);n.push(o)}),n}function Y(t,e,i){return t.map(t=>{const{id:n,type:o,params:r}=t,a=[];let s={id:n};if(t.start&&t.end){const o={...t.start},r={...t.end};o.x*=e,o.y*=i,r.x*=e,r.y*=i,s={id:n,start:o,end:r}}switch(o.toUpperCase()){case"M":case"L":case"T":for(let t=0;t<r.length;t+=2)a.push(r[t]*e,r[t+1]*i);break;case"C":for(let t=0;t<r.length;t+=6)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i,r[t+4]*e,r[t+5]*i);break;case"S":for(let t=0;t<r.length;t+=4)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i);break;case"Q":for(let t=0;t<r.length;t+=4)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i);break;case"H":r.forEach(t=>a.push(t*e));break;case"V":r.forEach(t=>a.push(t*i));break;case"A":for(let t=0;t<r.length;t+=7)a.push(r[t]*e,r[t+1]*i,r[t+2],r[t+3],r[t+4],r[t+5]*e,r[t+6]*i);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let t=0;t<r.length;t++){const n="a"===o&&(t%7==0||t%7==5)||"h"===o||"v"!==o&&t%2==0;a.push(r[t]*(n?e:i))}break;default:return{type:o,params:[...r],...s}}return{type:o,params:a,...s}})}function q(t,i,n){if("string"==typeof i)return i;const{viewMaterialSize:o,viewScaleInfo:r,opacity:a=1}=n,{x:s,y:l}=o,{scale:c}=r;if("linear-gradient"===i?.type){const{start:n,end:o,stops:r}=i,h={x:s+n.x*c,y:l+n.y*c},u={x:s+o.x*c,y:l+o.y*c},f=t.createLinearGradient(h.x,h.y,u.x,u.y);return r.forEach(t=>{t.offset>=0&&t.color&&f.addColorStop(t.offset,e(t.color,a))}),f}if("radial-gradient"===i?.type){const{inner:n,outer:o,stops:r}=i,h={x:s+n.x*c,y:l+n.y*c,radius:n.radius*c},u={x:s+o.x*c,y:l+o.y*c,radius:o.radius*c},f=t.createRadialGradient(h.x,h.y,h.radius,u.x,u.y,u.radius);return r.forEach(t=>{f.addColorStop(t.offset,e(t.color,a))}),f}return"#000000"}let K=H();function _(t,e,i){const{viewScaleInfo:n,viewSizeInfo:o,calculator:r}=i,{opacity:a,fill:s,fillOpacity:l,fillRule:c,stroke:h,strokeWidth:u,strokeOpacity:f,strokeLinecap:p,strokeLinejoin:d,strokeDasharray:y,strokeDashoffset:g,strokeMiterlimit:m}={...K,...e},{scale:x,offsetLeft:w,offsetTop:b}=n,{devicePixelRatio:v}=o,M=r.getVirtualItem(e.id),{commands:S,worldCenter:L}=M,{width:C,height:k}=e;let A=S;A=Y(A,x,x),A=X(A,(w+(L.x-C/2)*x)*v,(b+(L.y-k/2)*x)*v);const R=t.globalAlpha,P=W(A),T=new Path2D(P);!function(t,e,i){const{...n}=e,{viewScaleInfo:o,viewSizeInfo:r,tempContext:a,path2d:s}=i,{width:l,height:c}=r,{shadowColor:h,shadowOffsetX:u,shadowOffsetY:f,shadowBlur:p}=n;I.number(p)&&h&&(a.clearRect(0,0,a.canvas.width,a.canvas.height),a.save(),a.shadowColor=h,a.shadowOffsetX=(u||0)*o.scale,a.shadowOffsetY=(f||0)*o.scale,a.shadowBlur=(p||0)*o.scale,a.fillStyle="#ffffff",a.fill(s),a.restore(),a.save(),a.globalCompositeOperation="destination-out",a.fillStyle="#ffffff",a.fill(s),a.restore(),t.drawImage(a.canvas,0,0,l,c),a.clearRect(0,0,a.canvas.width,a.canvas.height))}(t,e,{...i,path2d:T}),tt(t,e,{path2d:T,viewScaleInfo:n,viewSizeInfo:o,calculator:r,renderContent:()=>{if(s){const i=V(e,{viewScaleInfo:n});"number"==typeof l&&l>0&&(t.globalAlpha=R*l*a),t.fillStyle=q(t,s,{viewMaterialSize:i,viewScaleInfo:n,opacity:e.opacity||1}),t.fill(T,c),t.globalAlpha=R}if("number"==typeof u&&u>0){if("number"==typeof f&&f>0&&(t.globalAlpha=R*f*a),t.lineCap=p,t.lineJoin=d,t.lineDashOffset=g,t.miterLimit=m,Array.isArray(y)){const e=y.map(t=>x*t);t.setLineDash(e)}t.lineWidth=u*x,t.strokeStyle=h,t.stroke(T),t.setLineDash([]),t.lineCap=K.strokeLinecap,t.lineJoin=K.strokeLinejoin,t.lineDashOffset=K.strokeDashoffset,t.miterLimit=K.strokeMiterlimit,t.globalAlpha=R}}})}function tt(t,e,i){const{renderContent:n,calculator:o,viewScaleInfo:r,viewSizeInfo:a}=i;if("hidden"===e.overflow){let s=i.path2d;if(!s){const{scale:t,offsetLeft:i,offsetTop:n}=r,{devicePixelRatio:l}=a,c=o.getVirtualItem(e.id),{commands:h,worldCenter:u}=c,{width:f,height:p}=e;let d=h;d=Y(d,t,t),d=X(d,(i+(u.x-f/2)*t)*l,(n+(u.y-p/2)*t)*l);const y=W(d);s=new Path2D(y)}t.save(),t.clip(s,"nonzero"),n?.(),t.restore()}else n?.()}function et(t,e,i,n){const{viewScaleInfo:o,calculator:r}=i,a=r?.getVirtualItem(e.id);if(a){const{worldAngle:i,worldCenter:r}=a,s=E(r,{viewScaleInfo:o}),{scale:l}=o;!function(t,e,i,n){const o=L(e||0);i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(o),t.translate(-i.x,-i.y)),n(t),i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(-o),t.translate(-i.x,-i.y))}(t,i,s,()=>{const t=e.width*l,i=e.height*l,o={x:s.x-t/2,y:s.y-i/2,width:t,height:i};n({viewWorldCenter:s,viewWorldSize:o})})}}function it(t,e,i){et(t,e,i,()=>{_(t,e,i)})}function nt(t,e,i){et(t,e,i,()=>{_(t,e,i)})}function ot(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o,parentOpacity:r}=i,{x:a,y:s,width:l,height:c,angle:h}=V(e,{viewScaleInfo:o})||e,u={...e,x:a,y:s,width:l,height:c,angle:h};et(t,e,i,()=>{if(n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"image"===e.type&&n){t.globalAlpha=function(t){let e=1;return void 0!==t?.opacity&&t?.opacity>=0&&t?.opacity<=1&&(e=t?.opacity),e}(e)*r;const{x:i,y:o,width:a,height:s}=u,l=[0,0,0,0],c=e,{scaleMode:h,originW:f=0,originH:p=0}=c,d=t.$undoPixelRatio(f),y=t.$undoPixelRatio(p);if(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(i+l[0],o),t.arcTo(i+a,o,i+a,o+s,l[1]),t.arcTo(i+a,o+s,i,o+s,l[2]),t.arcTo(i,o+s,i,o,l[3]),t.arcTo(i,o,i+a,o,l[0]),t.closePath(),t.fill("nonzero"),t.clip("nonzero"),h&&p&&f){let r=0,l=0,c=d,u=y;const f=i,p=o,g=a,m=s;if(d>e.width||y>e.height)if("fill"===h){const t=Math.max(e.width/d,e.height/y),i=y*t;r=(d*t-e.width)/2/t,l=(i-e.height)/2/t,c=e.width/t,u=e.height/t}else if("tile"===h)r=0,l=0,c=e.width,u=e.height;else if("fit"===h){const t=Math.min(e.width/d,e.height/y);r=(d-e.width/t)/2,l=(y-e.height/t)/2,c=e.width/t,u=e.height/t}t.drawImage(n,r,l,c,u,f,p,g,m)}else t.drawImage(n,i,o,a,s);t.globalAlpha=r,t.restore()}})}function rt(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o}=i,{x:r,y:a,width:s,height:l}=V(e,{viewScaleInfo:o})||e;et(t,e,i,()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"svgCode"===e.type&&n&&t.drawImage(n,r,a,s,l)})}function at(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o}=i,{x:r,y:a,width:s,height:l}=V(e,{viewScaleInfo:o})||e;et(t,e,i,()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"foreignObject"===e.type&&n&&t.drawImage(n,r,a,s,l)})}K=function(t,e){const i={...t};for(const t of e)delete i[t];return i}(K,["fill"]);const st=H();function lt(t,e,i){const{viewScaleInfo:n,viewSizeInfo:o,calculator:r}=i,a=V(e,{viewScaleInfo:n})||e,{scale:s}=n;et(t,e,i,({viewWorldSize:i})=>{{const l={...st,...e},{x:c,y:h}=i,u=(l.fontSize||st.fontSize)*n.scale,{opacity:f,fill:p,fillOpacity:d,stroke:y,strokeWidth:g,strokeOpacity:m,strokeLinecap:x,strokeLinejoin:w,strokeDasharray:b,strokeDashoffset:I,strokeMiterlimit:v}=l;if(u<2)return;const M=t.globalAlpha,S=r.getVirtualItem(e.id);t.textBaseline="top",t.$setFont({fontWeight:l.fontWeight,fontSize:u,fontFamily:N(l.fontFamily)}),tt(t,e,{viewScaleInfo:n,viewSizeInfo:o,calculator:r,renderContent:()=>{if(p&&("number"==typeof d&&d>0&&(t.globalAlpha=M*d*f),t.fillStyle=q(t,p,{viewMaterialSize:a,viewScaleInfo:n,opacity:e.opacity||1}),Array.isArray(S?.textLines)&&S?.textLines?.length>0&&S?.textLines?.forEach(e=>{t.fillText(e.text,c+e.x*n.scale,h+e.y*n.scale)}),t.globalAlpha=M),"number"==typeof g&&g>0){if("number"==typeof m&&m>0&&(t.globalAlpha=M*m*f),t.lineCap=x,t.lineJoin=w,t.lineDashOffset=I,t.miterLimit=v,Array.isArray(b)){const e=b.map(t=>s*t);t.setLineDash(e)}t.lineWidth=g*s,t.strokeStyle=y,S?.textLines?.forEach(e=>{t.strokeText(e.text,c+e.x*n.scale,h+e.y*n.scale)}),t.setLineDash([]),t.lineCap=st.strokeLinecap,t.lineJoin=st.strokeLinejoin,t.lineDashOffset=st.strokeDashoffset,t.miterLimit=st.strokeMiterlimit,t.globalAlpha=M}}})}})}function ct(t,e,i){if(!0===e?.operations?.invisible)return;const{width:n,height:o}=e,{scale:r}=i.viewScaleInfo;if(r<1&&(n*r<.4||o*r<.4)||0===i.parentOpacity)return;const{overrideMaterialMap:a}=i;if(!a?.[e.id]?.operations?.invisible)try{switch(e.type){case"rect":it(t,e,i);break;case"circle":nt(t,e,i);break;case"ellipse":case"path":!function(t,e,i){et(t,e,i,()=>{_(t,e,i)})}(t,e,i);break;case"text":lt(t,e,i);break;case"image":ot(t,e,i);break;case"svgCode":rt(t,e,i);break;case"foreignObject":at(t,e,i);break;case"group":{const n={...i.materialAssets||{},...e.assets||{}};ht(t,e,{...i,materialAssets:n});break}}}catch(t){console.error(t)}}function ht(t,e,i){if(et(t,e,i,()=>{_(t,e,i)}),Array.isArray(e.children)){const{parentMaterialSize:n}=i,o={x:n.x+e.x,y:n.y+e.y,width:e.width||n.width,height:e.height||n.height,angle:e.angle},{calculator:r}=i;for(let n=0;n<e.children.length;n++){let a=e.children[n];if(a={...a,x:o.x+a.x,y:o.y+a.y},!0===i.forceDrawAll||r?.needRender(a))try{ct(t,a,i)}catch(t){console.error(t)}}}}const ut=H();function ft(t,e,i){const{materials:n=[]}=e,{parentOpacity:o}=i;for(let e=0;e<n.length;e++){const r=n[e],a={...r,attributes:{...ut,...r}};if(!0===i.forceDrawAll||i.calculator?.needRender(a))try{ct(t,a,{...i,parentOpacity:o})}catch(t){console.error(t)}}}function pt(t,e,i,n){const{parentOpacity:o}=i;t.globalAlpha=1;const{viewScaleInfo:r}=i,a={id:"layout",type:"group",...e},s=V(a,{viewScaleInfo:r})||a,l={...a,...s},{x:c,y:h,width:u,height:f,fill:p}=l,d=[0,0,0,0];t.save(),t.fillStyle=q(t,p,{viewMaterialSize:s,viewScaleInfo:r,opacity:a.opacity||1}),t.beginPath(),t.moveTo(c+d[0],h),t.arcTo(c+u,h,c+u,h+f,d[1]),t.arcTo(c+u,h+f,c,h+f,d[2]),t.arcTo(c,h+f,c,h,d[3]),t.arcTo(c,h,c+u,h,d[0]),t.closePath(),t.fill("nonzero"),"hidden"===e.overflow&&t.clip("nonzero"),n(t),"hidden"===e.overflow&&t.restore(),t.globalAlpha=o}function dt(t,e,i){if("string"==typeof e?.fill){const{viewSizeInfo:n}=i,{width:o,height:r}=n;t.globalAlpha=1,t.fillStyle=e.fill,t.fillRect(0,0,o,r)}}const yt=["image","svgCode","foreignObject"],gt=t=>{let e=null;return"image"===t.type?e=t?.href||null:"svgCode"===t.type?e=t?.code||null:"foreignObject"===t.type&&(e=t?.content||null),"string"==typeof e&&e?a(e)?e:r(e,t.id):r(`${n()}-${t.id}-${n()}-${n()}`,t.id)};class mt extends v{#r={};#a={};#s={};#l=!1;constructor(){super(),this.#c("image",async(t,e)=>{const i=e[t.href]?.value||t.href,n=await c(i);return{id:t.id,lastModified:Date.now(),content:n}}),this.#c("foreignObject",async(t,e)=>{const i=e[t.content]?.value||t.content,n=await u(i,{width:t.originW||t.width,height:t.originH||t.height});return{id:t.id,lastModified:Date.now(),content:n}}),this.#c("svgCode",async(t,e)=>{const i=e[t.code]?.value||t.code,n=await h(i);return{id:t.id,lastModified:Date.now(),content:n}})}isDestroyed(){return this.#l}reset(){!0!==this.#l&&(this.#a={},this.#s={})}resetMaterialAsset(t){if(yt.includes(t.type)){let e=null,i=null;"image"===t.type&&"string"==typeof t?.href?i=t.href:"svgCode"===t.type&&"string"==typeof t?.code?i=t.code:"foreignObject"===t.type&&"string"==typeof t?.content&&(i=t.content),"string"==typeof i&&(this.load(t,{}),a(i)?e=i:t.id&&(e=r(i,t.id))),e&&a(e)&&(delete this.#s[e],delete this.#a[e])}}destroy(){this.#l=!0,this.clear(),this.#r=null,this.#a=null,this.#s=null}#c(t,e){this.#r[t]=e}#h(t){let e=null;return"image"===t.type?e=t?.href||null:"svgCode"===t.type?e=t?.code||null:"foreignObject"===t.type&&(e=t?.content||null),e}#u(t){return{material:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this.#h(t)}}#f(t){const e=gt(t.material),i=this.#s[e];this.#l||(i?i.startTime<t.startTime&&(this.#s[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})):(this.#s[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})))}#p(t){const e=gt(t.material),i=this.#s?.[e];this.#l||(i?i.startTime<t.startTime&&(this.#s[e]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})):(this.#s[e]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})))}#d(t,e){const i=this.#u(t),n=gt(t);if(this.#a[n])return;this.#a[n]=i;const o=this.#r[t.type];"function"!=typeof o||this.#l||(i.startTime=Date.now(),o(t,e).then(t=>{this.#l||(i.content=t.content,i.endTime=Date.now(),i.status="load",this.#f(i))}).catch(e=>{console.warn(`Load material source "${i.source}" fail`,e,t),i.endTime=Date.now(),i.status="error",i.error=e,this.#p(i)}))}#y(t){const e=gt(t),i=this.#a?.[e];return!(!i||"error"!==i.status||!i.source||i.source!==this.#h(t))}load(t,e){!0!==this.#l&&(this.#y(t)||yt.includes(t.type)&&this.#d(t,e))}getContent(t){const e=gt(t);return this.#s?.[e]?.content||null}getLoadItemMap(){return this.#s}setLoadItemMap(t){this.#s=t}}function xt(t,e){const i=e.width/2,n=e.height/2,o=t.x-i,r=t.y-n;let a=o,s=r;if("number"==typeof e.angle&&0!==e.angle){const t=e.angle*Math.PI/180,i=Math.cos(t),n=Math.sin(t);a=o*i-r*n,s=o*n+r*i}const l=s+n;return{x:a+i+e.x,y:l+e.y}}function wt(t,e){const{groupQueue:i=[]}=e;let n=t.angle||0;i.forEach(t=>{n+=t.angle||0});return{worldCenter:function(t,e){if(!(e=[...e].reverse())||0===e.length)return{x:t.x+t.width/2,y:t.y+t.height/2};let i=t.x+t.width/2,n=t.y+t.height/2;for(let t=0;t<e.length;t++){const o=xt({x:i,y:n},e[t]);i=o.x,n=o.y}return{x:i,y:n}}(t,i),worldAngle:T(n)}}function bt(t,e){const{dpr:i}=e;let{width:n,height:o,rx:r=0,ry:a=0}=t;const{cornerRadius:s}=t;o*=i,n*=i;const l=[];let c=0,h=0,u=0,f=0,p=0,d=0,y=0,g=0;if("number"==typeof r&&"number"==typeof a)r*=i,a*=i,c=r,h=r,u=r,f=r,p=a,d=a,y=a,g=a;else if(Array.isArray(s)&&4===s.length){const t=s.map(t=>t*i);c=t[0]||0,h=t[1]||0,u=t[2]||0,f=t[3]||0,p=t[0]||0,d=t[1]||0,y=t[2]||0,g=t[3]||0}else if("number"==typeof s){const t=s*i;c=t,h=t,u=t,f=t,p=t,d=t,y=t,g=t}const m=0+n,x=0+o;l.push({id:J(),type:"M",params:[0+c,0]}),h>0||d>0?(l.push({id:J(),type:"L",params:[m-h,0]}),l.push({id:J(),type:"A",params:[h,d,0,0,1,m,0+d]})):l.push({id:J(),type:"L",params:[m,0]}),u>0||y>0?(l.push({id:J(),type:"L",params:[m,x-y]}),l.push({id:J(),type:"A",params:[u,y,0,0,1,m-u,x]})):l.push({id:J(),type:"L",params:[m,x]}),f>0||g>0?(l.push({id:J(),type:"L",params:[0+f,x]}),l.push({id:J(),type:"A",params:[f,g,0,0,1,0,x-g]})):l.push({id:J(),type:"L",params:[0,x]}),c>0||p>0?(l.push({id:J(),type:"L",params:[0,0+p]}),l.push({id:J(),type:"A",params:[c,p,0,0,1,0+c,0]})):l.push({id:J(),type:"L",params:[0,0]}),l.push({id:J(),type:"Z",params:[]});return{...wt(t,e),commands:l}}const It=H();function vt(t,e,i){return t>=e}function Mt(t,e){const{dpr:i}=e,n={...wt(t,e),anchorCommands:[]},o=function(t){const e=[];let i={x:0,y:0},n={x:0,y:0},o=null;for(const r of t){const t=r.type,a=r.params,s=t===t.toLowerCase(),l=t.toUpperCase(),c=r.id;switch(l){case"M":{const[t,r]=a,l=s?{x:i.x+t,y:i.y+r}:{x:t,y:r};e.push({id:c,type:"M",params:[l.x,l.y],start:{x:t,y:r},end:{x:t,y:r}}),i=l,n=l,o=null;break}case"L":{const[t,n]=a,r=s?{x:i.x+t,y:i.y+n}:{x:t,y:n};e.push({id:c,type:"L",params:[r.x,r.y],start:{...i},end:{...r}}),i=r,o=null;break}case"H":{const[t]=a,n=s?{x:i.x+t,y:i.y}:{x:t,y:i.y};e.push({id:c,type:"L",params:[n.x,n.y],start:{...i},end:{...n}}),i=n,o=null;break}case"V":{const[t]=a,n=s?{x:i.x,y:i.y+t}:{x:i.x,y:t};e.push({id:c,type:"L",params:[n.x,n.y],start:{...i},end:{...n}}),i=n,o=null;break}case"C":{const[t,n,r,l,h,u]=a,f=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},p=s?{x:i.x+r,y:i.y+l}:{x:r,y:l},d=s?{x:i.x+h,y:i.y+u}:{x:h,y:u};e.push({id:c,type:"C",params:[f.x,f.y,p.x,p.y,d.x,d.y],start:{...i},end:{...d}}),i=d,o=p;break}case"S":{const[t,n,r,l]=a,h=o?{x:2*i.x-o.x,y:2*i.y-o.y}:i,u=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},f=s?{x:i.x+r,y:i.y+l}:{x:r,y:l};e.push({id:c,type:"C",params:[h.x,h.y,u.x,u.y,f.x,f.y],start:{...i},end:{...f}}),i=f,o=u;break}case"Q":{const[t,n,r,l]=a,h=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},u=s?{x:i.x+r,y:i.y+l}:{x:r,y:l};e.push({id:c,type:"C",params:[i.x+2/3*(h.x-i.x),i.y+2/3*(h.y-i.y),u.x+2/3*(h.x-u.x),u.y+2/3*(h.y-u.y),u.x,u.y],start:{...i},end:{...u}}),i=u,o=h;break}case"T":{const[t,n]=a,r=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},l=o?{x:2*i.x-o.x,y:2*i.y-o.y}:i;e.push({id:c,type:"C",params:[i.x+2/3*(l.x-i.x),i.y+2/3*(l.y-i.y),r.x+2/3*(l.x-r.x),r.y+2/3*(l.y-r.y),r.x,r.y],start:{...i},end:{...r}}),i=r,o=l;break}case"A":{const[t,n,r,l,h,u,f]=a,p=s?{x:i.x+u,y:i.y+f}:{x:u,y:f};e.push({id:c,type:"A",params:[t,n,r,l,h,p.x,p.y],start:{...i},end:{...p}}),i=p,o=null;break}case"Z":e.push({id:c,type:"Z",params:[],start:{...i},end:{...n}}),i=n,o=null;break;default:throw new Error(`Unsupported command: ${t}`)}}return e}(t.commands||[]);return n.anchorCommands=o,n.commands=Y(t.commands,i,i),n}function St(t,e){let i=null;switch(t.type){case"rect":case"group":i=bt(t,e);break;case"circle":i=function(t,e){const{dpr:i}=e,{width:n,height:o}=t;let{r:r}=t;const a=n/2*i,s=o/2*i;r*=i;const l=.55228475*r,c=[{type:"M",params:[a+r,s]},{type:"C",params:[a+r,s-l,a+l,s-r,a,s-r]},{type:"C",params:[a-l,s-r,a-r,s-l,a-r,s]},{type:"C",params:[a-r,s+l,a-l,s+r,a,s+r]},{type:"C",params:[a+l,s+r,a+r,s+l,a+r,s]},{type:"Z",params:[]}];return{...wt(t,e),commands:c}}(t,e);break;case"ellipse":i=function(t,e){const{dpr:i}=e,{width:n,height:o}=t;let{rx:r,ry:a}=t;const s=n/2*i,l=o/2*i;r*=i,a*=i;const c=.55228475*r,h=.55228475*a,u=[{type:"M",params:[s+r,l]},{type:"C",params:[s+r,l-h,s+c,l-a,s,l-a]},{type:"C",params:[s-c,l-a,s-r,l-h,s-r,l]},{type:"C",params:[s-r,l+h,s-c,l+a,s,l+a]},{type:"C",params:[s+c,l+a,s+r,l+h,s+r,l]},{type:"Z",params:[]}];return{...wt(t,e),commands:u}}(t,e);break;case"text":i=function(t,e){const{width:i,height:n}=t,o=e.tempContext,r=[],a={...It,...t},s=a.fontSize||It.fontSize,l=s,c=bt(t,e);if(l<2)return{...c,textLines:[]};const h=a.lineHeight||s;o.textBaseline="top",o.$setFont({fontWeight:a.fontWeight,fontSize:l,fontFamily:N(a.fontFamily)});let u=a.text.replace(/\r\n/gi,"\n");"lowercase"===a.textTransform?u=u.toLowerCase():"uppercase"===a.textTransform&&(u=u.toUpperCase());const f=h,p=u.split("\n");let d=0;p.forEach((t,e)=>{if("maxContent"===a.minInlineSize){const e=o.measureText(t);r.push({x:0,y:0,text:t,width:o.$undoPixelRatio(e.width)})}else{let s="",l="",c=t.split(l);if("normal"===a.wordBreak){l=" ";const e=t.split(l);c=[],e.forEach((t,i)=>{c.push(t),i<e.length-1&&c.push(l)})}if(1===c.length&&"hidden"!==a.overflow)r.push({x:0,y:0,text:c[0],width:o.$undoPixelRatio(o.measureText(c[0]).width)});else if(c.length>0){for(let t=0;t<c.length;t++){if(vt(o.$doPixelRatio(i),o.measureText(s+c[t]).width)?s+=c[t]||"":(r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s=c[t]||"",d++),d*f>=n&&"hidden"===a.overflow){s="";break}if(c.length-1===t&&(d+1)*f<=n){r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s="",e<p.length-1&&d++;break}}s&&(r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s="")}else r.push({x:0,y:0,text:"",width:0})}});let y=0,g=0;f>l&&(g=(f-l)/2),r.length*f<n&&("top"===a.verticalAlign?y=0:"bottom"===a.verticalAlign?y+=n-r.length*f:y+=(n-r.length*f)/2);{const t=0+y;r.forEach((e,n)=>{let o=0;"center"===a.textAlign?o=0+(i-e.width)/2:"right"===a.textAlign&&(o=i-e.width+0),r[n].x=o,r[n].y=t+f*n+g})}return{...c,textLines:r}}(t,e);break;case"path":i=Mt(t,e);break;default:i=wt(t,e)}return i}function Lt(t,e){const{viewScaleInfo:i,viewSizeInfo:n,tempContext:o}=e,r=function(t,e){const i={},n=[],o=r=>{const a={type:r.type,isVisibleInView:!0,position:[...n]};let s=null;const l=$(t,n);s=F(r,{groupQueue:l||[]});const c={...a,boundingInfo:s,rangeBoundingInfo:I.angle(r.angle)?B(s):s,...St(r,{...e,groupQueue:l||[]})};i[r.id]=c,"group"===r.type&&r.children.forEach((t,e)=>{n.push(e),o(t),n.pop()})};return t.forEach((t,e)=>{n.push(e),o(t),n.pop()}),i}(t,{tempContext:o,dpr:n.devicePixelRatio});return Ct(r,{viewScaleInfo:i,viewSizeInfo:n})}function Ct(t,e){const i=function(t){const{viewScaleInfo:e,viewSizeInfo:i}=t,{scale:n,offsetTop:o,offsetLeft:r}=e,{width:a,height:s}=i,l=0-r/n,c=0-o/n,h=a/n,u=s/n,f=C({x:l,y:c,width:a,height:s}),p={x:l,y:c},d={x:l+h,y:c},y={x:l,y:c+u},g={x:l+h,y:c+u},m={x:l,y:f.y},x={x:f.x,y:c},w={x:l+h,y:f.y},b={x:f.x,y:c+u};return{center:f,topLeft:p,topRight:d,bottomLeft:y,bottomRight:g,left:m,top:x,right:w,bottom:b}}(e);let n=0,o=0;return Object.keys(t).forEach(e=>{const r=t[e];r.isVisibleInView=function(t,e){const i=t.center.x,n=t.center.y,o=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),r=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),a=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),s=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),l=Math.abs(r-o),c=Math.abs(s-a),h=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x)-l,u=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x)+l,f=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y)-c,p=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y)+c;return i>=h&&i<=u&&n>=f&&n<=p}(r.rangeBoundingInfo,i),r.isVisibleInView?n++:o++}),{virtualItemMap:t,visibleCount:n,invisibleCount:o}}class kt{#g;#m;constructor(t){this.#g=t,this.#m=new S({defaultStorage:{virtualItemMap:{},visibleCount:0,invisibleCount:0}})}toGridNum(t,e){return!0===e?.ignore?t:Math.round(t)}destroy(){this.#g=null}needRender(t){const e=this.#m.get("virtualItemMap")[t.id];return!e||e.isVisibleInView}forceVisiable(t){const e=this.#m.get("virtualItemMap")[t];e&&(e.isVisibleInView=!0)}getPointMaterial(t,e){return function(t,e){const{context2d:i,data:n,viewScaleInfo:o,groupQueue:r}=e,a={index:-1,material:null,groupQueueIndex:-1};if(r&&Array.isArray(r)&&r?.length>0)for(let e=r.length-1;e>=0;e--){let n=0,s=0,l=0;for(let t=0;t<=e;t++)n+=r[t].x,s+=r[t].y,l+=r[t].angle||0;const c=r[e];if(c&&"group"===c.type&&Array.isArray(c?.children))for(let h=0;h<c.children.length;h++){const u=c.children[h];if(!0!==u?.operations?.invisible){if(!u)break;if(j(t,{context2d:i,material:{x:n+u.x,y:s+u.y,width:u.width,height:u.height,angle:l+(u.angle||0)},viewScaleInfo:o})){a.material=u,(e<r.length-1||"group"!==u.type)&&(a.groupQueueIndex=e);break}}}if(a.material)break}if(a.material)return a;for(let e=n.materials.length-1;e>=0;e--){const r=n.materials[e];if(!0!==r?.operations?.invisible&&j(t,{context2d:i,material:r,viewScaleInfo:o})){a.index=e,a.material=r;break}}return a}(t,{...e,context2d:this.#g.tempContext})}resetVirtualItemMap(t,e){if(t){const{virtualItemMap:i,invisibleCount:n,visibleCount:o}=Lt(t.materials,{...e,tempContext:this.#g.tempContext});this.#m.set("virtualItemMap",i),this.#m.set("invisibleCount",n),this.#m.set("visibleCount",o)}}updateVisiableStatus(t){const{virtualItemMap:e,invisibleCount:i,visibleCount:n}=Ct(this.#m.get("virtualItemMap"),t);this.#m.set("virtualItemMap",e),this.#m.set("invisibleCount",i),this.#m.set("visibleCount",n)}calcViewBoundingInfoFromOrigin(t,e){const i=this.#m.get("virtualItemMap")[t];if(!i?.boundingInfo)return null;const{checkVisible:n,viewScaleInfo:o,viewSizeInfo:r}=e,{center:a,left:s,right:l,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:p,bottomRight:d}=i.boundingInfo;if(!0===n&&!1===i.isVisibleInView)return null;const y={viewScaleInfo:o};return{center:E(a,y),left:E(s,y),right:E(l,y),bottom:E(c,y),top:E(h,y),topLeft:E(u,y),topRight:E(f,y),bottomLeft:E(p,y),bottomRight:E(d,y)}}calcViewBoundingInfoFromRange(t,e){const i=this.#m.get("virtualItemMap")[t];if(!i?.boundingInfo)return null;const{checkVisible:n,viewScaleInfo:o,viewSizeInfo:r}=e,{center:a,left:s,right:l,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:p,bottomRight:d}=i.rangeBoundingInfo;if(!0===n&&!1===i.isVisibleInView)return null;const y={viewScaleInfo:o};return{center:E(a,y),left:E(s,y),right:E(l,y),bottom:E(c,y),top:E(h,y),topLeft:E(u,y),topRight:E(f,y),bottomLeft:E(p,y),bottomRight:E(d,y)}}modifyVirtualAttributes(t,e){const{viewSizeInfo:i,groupQueue:n}=e,o=this.#m.get("virtualItemMap"),r=o[t.id],a=St(t,{tempContext:this.#g.tempContext,dpr:i.devicePixelRatio,groupQueue:n});if(a){const e=F(t,{groupQueue:n}),i={...r,...a,boundingInfo:e,rangeBoundingInfo:I.angle(t.angle)?B(e):e};o[t.id]=i,this.#m.set("virtualItemMap",o)}}modifyVirtualItemMap(t,e){const{modifyInfo:i,viewScaleInfo:n,viewSizeInfo:o}=e,{type:r,content:a}=i,s=t.materials,l=this.#m.get("virtualItemMap");if("deleteMaterial"===r){const{material:t}=a,e=[],i=t=>{e.push(t.id),"group"===t.type&&Array.isArray(t.children)&&t.children.forEach(t=>{i(t)})};i(t),e.forEach(t=>{delete l[t]}),this.#m.set("virtualItemMap",l)}else if("addMaterial"===r||"updateMaterial"===r){const{position:e}=a,i=function(t,e){let i=null,n=e;for(let e=0;e<t.length;e++){const o=n[t[e]];if(e<t.length-1&&"group"===o?.type)n=o.children;else{if(e!==t.length-1)break;i=o}}return i}(e,t.materials),c=$(s,e);if(i)if("updateMaterial"===r&&"group"===i.type)this.resetVirtualItemMap(t,{viewScaleInfo:n,viewSizeInfo:o});else{const t=F(i,{groupQueue:c||[]}),a={type:i.type,boundingInfo:t,rangeBoundingInfo:I.angle(i.angle)?B(t):t,isVisibleInView:!0,position:[...e],...St(i,{tempContext:this.#g.tempContext,dpr:o.devicePixelRatio,groupQueue:c||[]})};l[i.id]=a,this.#m.set("virtualItemMap",l),"updateMaterial"===r&&this.updateVisiableStatus({viewScaleInfo:n,viewSizeInfo:o})}}else"moveMaterial"===r&&this.resetVirtualItemMap(t,{viewScaleInfo:n,viewSizeInfo:o})}getVirtualItem(t){return this.#m.get("virtualItemMap")[t]||null}}return t.Calculator=kt,t.Renderer=class extends v{#g;#x=new mt;#w;#l=!1;constructor(t){super(),this.#g=t,this.#w=new kt({tempContext:t.tempContext}),this.#b()}isDestroyed(){return this.#l}destroy(){this.clear(),this.#g=null,this.#x.destroy(),this.#x=null,this.#l=!0}#b(){const t=this.#x;t.on("load",t=>{this.trigger("load",t)}),t.on("error",t=>{console.error(t)})}updateOptions(t){this.#g=t}drawData(t,e){const i=this.#x,n=this.#w,{sharer:o}=this.#g,r=this.#g.viewContext;r.clearRect(0,0,r.canvas.width,r.canvas.height);const a={x:0,y:0,width:e.viewSizeInfo.width,height:e.viewSizeInfo.height};!0===e.forceDrawAll&&this.#w.resetVirtualItemMap(t,{viewScaleInfo:e.viewScaleInfo,viewSizeInfo:e.viewSizeInfo});const s={loader:i,calculator:n,parentMaterialSize:a,materialAssets:t.assets,parentOpacity:1,overrideMaterialMap:o?.getActiveOverrideMaterialMap(),tempContext:this.#g.tempContext,...e};dt(r,t.global,s),t.layout?pt(r,t.layout,s,()=>{ft(r,t,s)}):ft(r,t,s)}scale(t){const{sharer:e}=this.#g;if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:r,offsetRight:a,width:s,height:l,contextHeight:c,contextWidth:h,devicePixelRatio:u}=e.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:t,offsetTop:n,offsetBottom:o,offsetLeft:r,offsetRight:a},viewSizeInfo:{width:s,height:l,contextHeight:c,contextWidth:h,devicePixelRatio:u}})}setLoadItemMap(t){this.#x.setLoadItemMap(t)}getLoadItemMap(){return this.#x.getLoadItemMap()}getLoader(){return this.#x}getCalculator(){return this.#w}},t.drawCircle=nt,t.drawForeignObject=at,t.drawGlobalBackground=dt,t.drawGroup=ht,t.drawImage=ot,t.drawLayout=pt,t.drawMaterial=ct,t.drawMaterialList=ft,t.drawRect=it,t.drawSVGCode=rt,t.drawText=lt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"author": "idrawjs",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@idraw/types": "^0.
|
|
24
|
+
"@idraw/types": "^1.0.0-alpha.1"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@idraw/util": "^0.
|
|
28
|
+
"@idraw/util": "^1.0.0-alpha.1"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getDefaultElementDetailConfig } from '@idraw/util';
|
|
2
|
-
import { drawElement } from './group';
|
|
3
|
-
const defaultDetail = getDefaultElementDetailConfig();
|
|
4
|
-
export function drawElementList(ctx, data, opts) {
|
|
5
|
-
var _a;
|
|
6
|
-
const { elements = [] } = data;
|
|
7
|
-
const { parentOpacity } = opts;
|
|
8
|
-
for (let i = 0; i < elements.length; i++) {
|
|
9
|
-
const element = elements[i];
|
|
10
|
-
const elem = Object.assign(Object.assign({}, element), {
|
|
11
|
-
detail: Object.assign(Object.assign({}, defaultDetail), element === null || element === void 0 ? void 0 : element.detail)
|
|
12
|
-
});
|
|
13
|
-
if (opts.forceDrawAll !== true) {
|
|
14
|
-
if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.needRender(elem))) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
drawElement(ctx, elem, Object.assign(Object.assign({}, opts), {
|
|
20
|
-
parentOpacity
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
console.error(err);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
package/dist/esm/draw/html.d.ts
DELETED
package/dist/esm/draw/html.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { rotateElement, calcViewElementSize } from '@idraw/util';
|
|
2
|
-
import { getOpacity } from './box';
|
|
3
|
-
export function drawHTML(ctx, elem, opts) {
|
|
4
|
-
const content = opts.loader.getContent(elem);
|
|
5
|
-
const { viewScaleInfo, parentOpacity } = opts;
|
|
6
|
-
const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
7
|
-
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
8
|
-
if (!content && !opts.loader.isDestroyed()) {
|
|
9
|
-
opts.loader.load(elem, opts.elementAssets || {});
|
|
10
|
-
}
|
|
11
|
-
if (elem.type === 'html' && content) {
|
|
12
|
-
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
13
|
-
ctx.drawImage(content, x, y, w, h);
|
|
14
|
-
ctx.globalAlpha = parentOpacity;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
package/dist/esm/draw/svg.d.ts
DELETED
package/dist/esm/draw/svg.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { rotateElement, calcViewElementSize } from '@idraw/util';
|
|
2
|
-
import { getOpacity } from './box';
|
|
3
|
-
export function drawSVG(ctx, elem, opts) {
|
|
4
|
-
const content = opts.loader.getContent(elem);
|
|
5
|
-
const { viewScaleInfo, parentOpacity } = opts;
|
|
6
|
-
const { x, y, w, h, angle } = calcViewElementSize(elem, { viewScaleInfo }) || elem;
|
|
7
|
-
rotateElement(ctx, { x, y, w, h, angle }, () => {
|
|
8
|
-
if (!content && !opts.loader.isDestroyed()) {
|
|
9
|
-
opts.loader.load(elem, opts.elementAssets || {});
|
|
10
|
-
}
|
|
11
|
-
if (elem.type === 'svg' && content) {
|
|
12
|
-
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
13
|
-
ctx.drawImage(content, x, y, w, h);
|
|
14
|
-
ctx.globalAlpha = parentOpacity;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Elements, ViewScaleInfo, ViewSizeInfo, ViewRectInfo, VirtualFlatItemMap, ViewContext2D } from '@idraw/types';
|
|
2
|
-
export declare function sortElementsViewVisiableInfoMap(elements: Elements, opts: {
|
|
3
|
-
viewScaleInfo: ViewScaleInfo;
|
|
4
|
-
viewSizeInfo: ViewSizeInfo;
|
|
5
|
-
tempContext: ViewContext2D;
|
|
6
|
-
}): {
|
|
7
|
-
virtualFlatItemMap: VirtualFlatItemMap;
|
|
8
|
-
visibleCount: number;
|
|
9
|
-
invisibleCount: number;
|
|
10
|
-
};
|
|
11
|
-
export declare function updateVirtualFlatItemMapStatus(virtualFlatItemMap: VirtualFlatItemMap, opts: {
|
|
12
|
-
viewScaleInfo: ViewScaleInfo;
|
|
13
|
-
viewSizeInfo: ViewSizeInfo;
|
|
14
|
-
}): {
|
|
15
|
-
virtualFlatItemMap: VirtualFlatItemMap;
|
|
16
|
-
visibleCount: number;
|
|
17
|
-
invisibleCount: number;
|
|
18
|
-
};
|
|
19
|
-
export declare function calcVisibleOriginCanvasRectInfo(opts: {
|
|
20
|
-
viewScaleInfo: ViewScaleInfo;
|
|
21
|
-
viewSizeInfo: ViewSizeInfo;
|
|
22
|
-
}): ViewRectInfo;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Element, Elements, VirtualFlatItemMap, VirtualFlatDetail, ViewContext2D } from '@idraw/types';
|
|
2
|
-
export declare function calcVirtualFlatDetail(elem: Element, opts: {
|
|
3
|
-
tempContext: ViewContext2D;
|
|
4
|
-
}): VirtualFlatDetail;
|
|
5
|
-
export declare function elementsToVirtualFlatMap(elements: Elements, opts: {
|
|
6
|
-
tempContext: ViewContext2D;
|
|
7
|
-
}): VirtualFlatItemMap;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { is, getGroupQueueByElementPosition, calcElementOriginRectInfo, originRectInfoToRangeRectInfo } from '@idraw/util';
|
|
2
|
-
import { calcVirtualTextDetail } from './text';
|
|
3
|
-
export function calcVirtualFlatDetail(elem, opts) {
|
|
4
|
-
let virtualDetail = {};
|
|
5
|
-
if (elem.type === 'text') {
|
|
6
|
-
virtualDetail = calcVirtualTextDetail(elem, opts);
|
|
7
|
-
}
|
|
8
|
-
return virtualDetail;
|
|
9
|
-
}
|
|
10
|
-
export function elementsToVirtualFlatMap(elements, opts) {
|
|
11
|
-
const virtualFlatMap = {};
|
|
12
|
-
const currentPosition = [];
|
|
13
|
-
const _walk = (elem) => {
|
|
14
|
-
const baseInfo = {
|
|
15
|
-
type: elem.type,
|
|
16
|
-
isVisibleInView: true,
|
|
17
|
-
position: [...currentPosition]
|
|
18
|
-
};
|
|
19
|
-
let originRectInfo = null;
|
|
20
|
-
const groupQueue = getGroupQueueByElementPosition(elements, currentPosition);
|
|
21
|
-
originRectInfo = calcElementOriginRectInfo(elem, {
|
|
22
|
-
groupQueue: groupQueue || []
|
|
23
|
-
});
|
|
24
|
-
const virtualItem = Object.assign(Object.assign(Object.assign({}, baseInfo), {
|
|
25
|
-
originRectInfo: originRectInfo,
|
|
26
|
-
rangeRectInfo: is.angle(elem.angle)
|
|
27
|
-
? originRectInfoToRangeRectInfo(originRectInfo)
|
|
28
|
-
: originRectInfo
|
|
29
|
-
}), calcVirtualFlatDetail(elem, opts));
|
|
30
|
-
virtualFlatMap[elem.uuid] = virtualItem;
|
|
31
|
-
if (elem.type === 'group') {
|
|
32
|
-
elem.detail.children.forEach((ele, i) => {
|
|
33
|
-
currentPosition.push(i);
|
|
34
|
-
_walk(ele);
|
|
35
|
-
currentPosition.pop();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
elements.forEach((elem, index) => {
|
|
40
|
-
currentPosition.push(index);
|
|
41
|
-
_walk(elem);
|
|
42
|
-
currentPosition.pop();
|
|
43
|
-
});
|
|
44
|
-
return virtualFlatMap;
|
|
45
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { enhanceFontFamliy, getDefaultElementDetailConfig } from '@idraw/util';
|
|
2
|
-
const detailConfig = getDefaultElementDetailConfig();
|
|
3
|
-
function isTextWidthWithinErrorRange(w0, w1, scale) {
|
|
4
|
-
if (scale < 0.5) {
|
|
5
|
-
if (w0 < w1 && (w0 - w1) / w0 > -0.15) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return w0 >= w1;
|
|
10
|
-
}
|
|
11
|
-
export function calcVirtualTextDetail(elem, opts) {
|
|
12
|
-
const { w, h } = elem;
|
|
13
|
-
const x = 0;
|
|
14
|
-
const y = 0;
|
|
15
|
-
const ctx = opts.tempContext;
|
|
16
|
-
const lines = [];
|
|
17
|
-
const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
|
|
18
|
-
const originFontSize = detail.fontSize || detailConfig.fontSize;
|
|
19
|
-
const fontSize = originFontSize;
|
|
20
|
-
if (fontSize < 2) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
const originLineHeight = detail.lineHeight || originFontSize;
|
|
24
|
-
const lineHeight = originLineHeight;
|
|
25
|
-
ctx.textBaseline = 'top';
|
|
26
|
-
ctx.$setFont({
|
|
27
|
-
fontWeight: detail.fontWeight,
|
|
28
|
-
fontSize: fontSize,
|
|
29
|
-
fontFamily: enhanceFontFamliy(detail.fontFamily)
|
|
30
|
-
});
|
|
31
|
-
let detailText = detail.text.replace(/\r\n/gi, '\n');
|
|
32
|
-
if (detail.textTransform === 'lowercase') {
|
|
33
|
-
detailText = detailText.toLowerCase();
|
|
34
|
-
}
|
|
35
|
-
else if (detail.textTransform === 'uppercase') {
|
|
36
|
-
detailText = detailText.toUpperCase();
|
|
37
|
-
}
|
|
38
|
-
const fontHeight = lineHeight;
|
|
39
|
-
const detailTextList = detailText.split('\n');
|
|
40
|
-
let lineNum = 0;
|
|
41
|
-
detailTextList.forEach((itemText, idx) => {
|
|
42
|
-
if (detail.minInlineSize === 'maxContent') {
|
|
43
|
-
lines.push({
|
|
44
|
-
x,
|
|
45
|
-
y: 0,
|
|
46
|
-
text: itemText,
|
|
47
|
-
width: ctx.$undoPixelRatio(ctx.measureText(itemText).width)
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
let lineText = '';
|
|
52
|
-
let splitStr = '';
|
|
53
|
-
let tempStrList = itemText.split(splitStr);
|
|
54
|
-
if (detail.wordBreak === 'normal') {
|
|
55
|
-
splitStr = ' ';
|
|
56
|
-
const wordList = itemText.split(splitStr);
|
|
57
|
-
tempStrList = [];
|
|
58
|
-
wordList.forEach((word, idx) => {
|
|
59
|
-
tempStrList.push(word);
|
|
60
|
-
if (idx < wordList.length - 1) {
|
|
61
|
-
tempStrList.push(splitStr);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if (tempStrList.length === 1 && detail.overflow === 'visible') {
|
|
66
|
-
lines.push({
|
|
67
|
-
x,
|
|
68
|
-
y: 0,
|
|
69
|
-
text: tempStrList[0],
|
|
70
|
-
width: ctx.$undoPixelRatio(ctx.measureText(tempStrList[0]).width)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else if (tempStrList.length > 0) {
|
|
74
|
-
for (let i = 0; i < tempStrList.length; i++) {
|
|
75
|
-
if (isTextWidthWithinErrorRange(ctx.$doPixelRatio(w), ctx.measureText(lineText + tempStrList[i]).width, 1)) {
|
|
76
|
-
lineText += tempStrList[i] || '';
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
lines.push({
|
|
80
|
-
x,
|
|
81
|
-
y: 0,
|
|
82
|
-
text: lineText,
|
|
83
|
-
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
84
|
-
});
|
|
85
|
-
lineText = tempStrList[i] || '';
|
|
86
|
-
lineNum++;
|
|
87
|
-
}
|
|
88
|
-
if ((lineNum + 1) * fontHeight > h && detail.overflow === 'hidden') {
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
if (tempStrList.length - 1 === i) {
|
|
92
|
-
if ((lineNum + 1) * fontHeight <= h) {
|
|
93
|
-
lines.push({
|
|
94
|
-
x,
|
|
95
|
-
y: 0,
|
|
96
|
-
text: lineText,
|
|
97
|
-
width: ctx.$undoPixelRatio(ctx.measureText(lineText).width)
|
|
98
|
-
});
|
|
99
|
-
if (idx < detailTextList.length - 1) {
|
|
100
|
-
lineNum++;
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
lines.push({
|
|
109
|
-
x,
|
|
110
|
-
y: 0,
|
|
111
|
-
text: '',
|
|
112
|
-
width: 0
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
let startY = 0;
|
|
118
|
-
let eachLineStartY = 0;
|
|
119
|
-
if (fontHeight > fontSize) {
|
|
120
|
-
eachLineStartY = (fontHeight - fontSize) / 2;
|
|
121
|
-
}
|
|
122
|
-
if (lines.length * fontHeight < h) {
|
|
123
|
-
if (detail.verticalAlign === 'top') {
|
|
124
|
-
startY = 0;
|
|
125
|
-
}
|
|
126
|
-
else if (detail.verticalAlign === 'bottom') {
|
|
127
|
-
startY += h - lines.length * fontHeight;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
startY += (h - lines.length * fontHeight) / 2;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
{
|
|
134
|
-
const _y = y + startY;
|
|
135
|
-
lines.forEach((line, i) => {
|
|
136
|
-
let _x = x;
|
|
137
|
-
if (detail.textAlign === 'center') {
|
|
138
|
-
_x = x + (w - line.width) / 2;
|
|
139
|
-
}
|
|
140
|
-
else if (detail.textAlign === 'right') {
|
|
141
|
-
_x = x + (w - line.width);
|
|
142
|
-
}
|
|
143
|
-
lines[i].x = _x;
|
|
144
|
-
lines[i].y = _y + fontHeight * i + eachLineStartY;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
const virtualTextDetail = {
|
|
148
|
-
textLines: lines
|
|
149
|
-
};
|
|
150
|
-
return virtualTextDetail;
|
|
151
|
-
}
|