modern-idoc 0.6.8 → 0.6.9
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(o=typeof globalThis<"u"?globalThis:o||self,_(o.modernIdoc={}))})(this,function(o){"use strict";function _(t){return typeof t=="string"?{src:t}:t}var Ut={grad:.9,turn:360,rad:360/(2*Math.PI)},S=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},h=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=Math.pow(10,n)),Math.round(e*t)/e+0},b=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=1),t>e?e:t>n?t:n},Q=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Z=function(t){return{r:b(t.r,0,255),g:b(t.g,0,255),b:b(t.b,0,255),a:b(t.a)}},j=function(t){return{r:h(t.r),g:h(t.g),b:h(t.b),a:h(t.a,3)}},qt=/^#([0-9a-f]{3,8})$/i,L=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},tt=function(t){var n=t.r,e=t.g,r=t.b,a=t.a,l=Math.max(n,e,r),c=l-Math.min(n,e,r),d=c?l===n?(e-r)/c:l===e?2+(r-n)/c:4+(n-e)/c:0;return{h:60*(d<0?d+6:d),s:l?c/l*100:0,v:l/255*100,a}},nt=function(t){var n=t.h,e=t.s,r=t.v,a=t.a;n=n/360*6,e/=100,r/=100;var l=Math.floor(n),c=r*(1-e),d=r*(1-(n-l)*e),F=r*(1-(1-n+l)*e),O=l%6;return{r:255*[r,d,c,c,F,r][O],g:255*[F,r,r,d,c,c][O],b:255*[c,c,F,r,r,d][O],a}},et=function(t){return{h:Q(t.h),s:b(t.s,0,100),l:b(t.l,0,100),a:b(t.a)}},rt=function(t){return{h:h(t.h),s:h(t.s),l:h(t.l),a:h(t.a,3)}},it=function(t){return nt((e=(n=t).s,{h:n.h,s:(e*=((r=n.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:n.a}));var n,e,r},G=function(t){return{h:(n=tt(t)).h,s:(a=(200-(e=n.s))*(r=n.v)/100)>0&&a<200?e*r/100/(a<=100?a:200-a)*100:0,l:a/2,a:n.a};var n,e,r,a},Jt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ot={string:[[function(t){var n=qt.exec(t);return n?(t=n[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?h(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?h(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var n=Zt.exec(t)||tn.exec(t);return n?n[2]!==n[4]||n[4]!==n[6]?null:Z({r:Number(n[1])/(n[2]?100/255:1),g:Number(n[3])/(n[4]?100/255:1),b:Number(n[5])/(n[6]?100/255:1),a:n[7]===void 0?1:Number(n[7])/(n[8]?100:1)}):null},"rgb"],[function(t){var n=Jt.exec(t)||Qt.exec(t);if(!n)return null;var e,r,a=et({h:(e=n[1],r=n[2],r===void 0&&(r="deg"),Number(e)*(Ut[r]||1)),s:Number(n[3]),l:Number(n[4]),a:n[5]===void 0?1:Number(n[5])/(n[6]?100:1)});return it(a)},"hsl"]],object:[[function(t){var n=t.r,e=t.g,r=t.b,a=t.a,l=a===void 0?1:a;return S(n)&&S(e)&&S(r)?Z({r:Number(n),g:Number(e),b:Number(r),a:Number(l)}):null},"rgb"],[function(t){var n=t.h,e=t.s,r=t.l,a=t.a,l=a===void 0?1:a;if(!S(n)||!S(e)||!S(r))return null;var c=et({h:Number(n),s:Number(e),l:Number(r),a:Number(l)});return it(c)},"hsl"],[function(t){var n=t.h,e=t.s,r=t.v,a=t.a,l=a===void 0?1:a;if(!S(n)||!S(e)||!S(r))return null;var c=function(d){return{h:Q(d.h),s:b(d.s,0,100),v:b(d.v,0,100),a:b(d.a)}}({h:Number(n),s:Number(e),v:Number(r),a:Number(l)});return nt(c)},"hsv"]]},at=function(t,n){for(var e=0;e<n.length;e++){var r=n[e][0](t);if(r)return[r,n[e][1]]}return[null,void 0]},nn=function(t){return typeof t=="string"?at(t.trim(),ot.string):typeof t=="object"&&t!==null?at(t,ot.object):[null,void 0]},M=function(t,n){var e=G(t);return{h:e.h,s:b(e.s+100*n,0,100),l:e.l,a:e.a}},R=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},ut=function(t,n){var e=G(t);return{h:e.h,s:e.s,l:b(e.l+100*n,0,100),a:e.a}},lt=function(){function t(n){this.parsed=nn(n)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return h(R(this.rgba),2)},t.prototype.isDark=function(){return R(this.rgba)<.5},t.prototype.isLight=function(){return R(this.rgba)>=.5},t.prototype.toHex=function(){return n=j(this.rgba),e=n.r,r=n.g,a=n.b,c=(l=n.a)<1?L(h(255*l)):"","#"+L(e)+L(r)+L(a)+c;var n,e,r,a,l,c},t.prototype.toRgb=function(){return j(this.rgba)},t.prototype.toRgbString=function(){return n=j(this.rgba),e=n.r,r=n.g,a=n.b,(l=n.a)<1?"rgba("+e+", "+r+", "+a+", "+l+")":"rgb("+e+", "+r+", "+a+")";var n,e,r,a,l},t.prototype.toHsl=function(){return rt(G(this.rgba))},t.prototype.toHslString=function(){return n=rt(G(this.rgba)),e=n.h,r=n.s,a=n.l,(l=n.a)<1?"hsla("+e+", "+r+"%, "+a+"%, "+l+")":"hsl("+e+", "+r+"%, "+a+"%)";var n,e,r,a,l},t.prototype.toHsv=function(){return n=tt(this.rgba),{h:h(n.h),s:h(n.s),v:h(n.v),a:h(n.a,3)};var n},t.prototype.invert=function(){return y({r:255-(n=this.rgba).r,g:255-n.g,b:255-n.b,a:n.a});var n},t.prototype.saturate=function(n){return n===void 0&&(n=.1),y(M(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),y(M(this.rgba,-n))},t.prototype.grayscale=function(){return y(M(this.rgba,-1))},t.prototype.lighten=function(n){return n===void 0&&(n=.1),y(ut(this.rgba,n))},t.prototype.darken=function(n){return n===void 0&&(n=.1),y(ut(this.rgba,-n))},t.prototype.rotate=function(n){return n===void 0&&(n=15),this.hue(this.hue()+n)},t.prototype.alpha=function(n){return typeof n=="number"?y({r:(e=this.rgba).r,g:e.g,b:e.b,a:n}):h(this.rgba.a,3);var e},t.prototype.hue=function(n){var e=G(this.rgba);return typeof n=="number"?y({h:n,s:e.s,l:e.l,a:e.a}):h(e.h)},t.prototype.isEqual=function(n){return this.toHex()===y(n).toHex()},t}(),y=function(t){return t instanceof lt?t:new lt(t)};function f(t){return t==null||t==="none"}function w(t,n=0,e=10**n){return Math.round(e*t)/e+0}function z(t,n=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return n?t.map(r=>z(r,n)):t;const e={};for(const r in t){const a=t[r];a!=null&&(n?e[r]=z(a,n):e[r]=a)}return e}function V(t,n){const e={};return n.forEach(r=>{r in t&&(e[r]=t[r])}),e}function $(t){let n;return typeof t=="number"?n={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:n=t,y(n)}function en(t){return{r:w(t.r),g:w(t.g),b:w(t.b),a:w(t.a,3)}}function T(t){const n=t.toString(16);return n.length<2?`0${n}`:n}const D="#000000FF";function st(t){return $(t).isValid()}function m(t,n=!1){const e=$(t);if(!e.isValid()){if(typeof t=="string")return t;const d=`Failed to normalizeColor ${t}`;if(n)throw new Error(d);return console.warn(d),D}const{r,g:a,b:l,a:c}=en(e.rgba);return`#${T(r)}${T(a)}${T(l)}${T(w(c*255))}`}var A=A||{};A.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let n="";function e(i){const u=new Error(`${n}: ${i}`);throw u.source=n,u}function r(){const i=a();return n.length>0&&e("Invalid input not EOF"),i}function a(){return x(l)}function l(){return c("linear-gradient",t.linearGradient,F)||c("repeating-linear-gradient",t.repeatingLinearGradient,F)||c("radial-gradient",t.radialGradient,Kt)||c("repeating-radial-gradient",t.repeatingRadialGradient,Kt)}function c(i,u,s){return d(u,v=>{const k=s();return k&&(g(t.comma)||e("Missing comma before color stops")),{type:i,orientation:k,colorStops:x(dn)}})}function d(i,u){const s=g(i);if(s){g(t.startCall)||e("Missing (");const v=u(s);return g(t.endCall)||e("Missing )"),v}}function F(){const i=O();if(i)return i;const u=p("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:ln()}function O(){return p("directional",t.sideOrCorner,1)}function ln(){return p("angular",t.angleValue,1)||p("angular",t.radianValue,1)}function Kt(){let i,u=Xt(),s;return u&&(i=[],i.push(u),s=n,g(t.comma)&&(u=Xt(),u?i.push(u):n=s)),i}function Xt(){let i=sn()||cn();if(i)i.at=U();else{const u=Y();if(u){i=u;const s=U();s&&(i.at=s)}else{const s=U();if(s)i={type:"default-radial",at:s};else{const v=q();v&&(i={type:"default-radial",at:v})}}}return i}function sn(){const i=p("shape",/^(circle)/i,0);return i&&(i.style=Yt()||Y()),i}function cn(){const i=p("shape",/^(ellipse)/i,0);return i&&(i.style=q()||P()||Y()),i}function Y(){return p("extent-keyword",t.extentKeywords,1)}function U(){if(p("position",/^at/,0)){const i=q();return i||e("Missing positioning value"),i}}function q(){const i=fn();if(i.x||i.y)return{type:"position",value:i}}function fn(){return{x:P(),y:P()}}function x(i){let u=i();const s=[];if(u)for(s.push(u);g(t.comma);)u=i(),u?s.push(u):e("One extra comma");return s}function dn(){const i=gn();return i||e("Expected color definition"),i.length=P(),i}function gn(){return vn()||Sn()||yn()||pn()||mn()||bn()||hn()}function hn(){return p("literal",t.literalColor,0)}function vn(){return p("hex",t.hexColor,1)}function mn(){return d(t.rgbColor,()=>({type:"rgb",value:x(E)}))}function pn(){return d(t.rgbaColor,()=>({type:"rgba",value:x(E)}))}function bn(){return d(t.varColor,()=>({type:"var",value:Cn()}))}function yn(){return d(t.hslColor,()=>{g(t.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const u=E();g(t.comma);let s=g(t.percentageValue);const v=s?s[1]:null;g(t.comma),s=g(t.percentageValue);const k=s?s[1]:null;return(!v||!k)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,v,k]}})}function Sn(){return d(t.hslaColor,()=>{const i=E();g(t.comma);let u=g(t.percentageValue);const s=u?u[1]:null;g(t.comma),u=g(t.percentageValue);const v=u?u[1]:null;g(t.comma);const k=E();return(!s||!v)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[i,s,v,k]}})}function Cn(){return g(t.variableName)[1]}function E(){return g(t.number)[1]}function P(){return p("%",t.percentageValue,1)||wn()||zn()||Yt()}function wn(){return p("position-keyword",t.positionKeywords,1)}function zn(){return d(t.calcValue,()=>{let i=1,u=0;for(;i>0&&u<n.length;){const v=n.charAt(u);v==="("?i++:v===")"&&i--,u++}i>0&&e("Missing closing parenthesis in calc() expression");const s=n.substring(0,u-1);return J(u-1),{type:"calc",value:s}})}function Yt(){return p("px",t.pixelValue,1)||p("em",t.emValue,1)}function p(i,u,s){const v=g(u);if(v)return{type:i,value:v[s]}}function g(i){let u,s;return s=/^\s+/.exec(n),s&&J(s[0].length),u=i.exec(n),u&&J(u[0].length),u}function J(i){n=n.substr(i)}return function(i){return n=i.toString().trim(),n.endsWith(";")&&(n=n.slice(0,-1)),r()}}();const ct=A.parse.bind(A);var H=H||{};H.stringify=function(){var t={"visit_linear-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-linear-gradient":function(n){return t.visit_gradient(n)},"visit_radial-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-radial-gradient":function(n){return t.visit_gradient(n)},visit_gradient:function(n){var e=t.visit(n.orientation);return e&&(e+=", "),n.type+"("+e+t.visit(n.colorStops)+")"},visit_shape:function(n){var e=n.value,r=t.visit(n.at),a=t.visit(n.style);return a&&(e+=" "+a),r&&(e+=" at "+r),e},"visit_default-radial":function(n){var e="",r=t.visit(n.at);return r&&(e+=r),e},"visit_extent-keyword":function(n){var e=n.value,r=t.visit(n.at);return r&&(e+=" at "+r),e},"visit_position-keyword":function(n){return n.value},visit_position:function(n){return t.visit(n.value.x)+" "+t.visit(n.value.y)},"visit_%":function(n){return n.value+"%"},visit_em:function(n){return n.value+"em"},visit_px:function(n){return n.value+"px"},visit_calc:function(n){return"calc("+n.value+")"},visit_literal:function(n){return t.visit_color(n.value,n)},visit_hex:function(n){return t.visit_color("#"+n.value,n)},visit_rgb:function(n){return t.visit_color("rgb("+n.value.join(", ")+")",n)},visit_rgba:function(n){return t.visit_color("rgba("+n.value.join(", ")+")",n)},visit_hsl:function(n){return t.visit_color("hsl("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%)",n)},visit_hsla:function(n){return t.visit_color("hsla("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%, "+n.value[3]+")",n)},visit_var:function(n){return t.visit_color("var("+n.value+")",n)},visit_color:function(n,e){var r=n,a=t.visit(e.length);return a&&(r+=" "+a),r},visit_angular:function(n){return n.value+"deg"},visit_directional:function(n){return"to "+n.value},visit_array:function(n){var e="",r=n.length;return n.forEach(function(a,l){e+=t.visit(a),l<r-1&&(e+=", ")}),e},visit_object:function(n){return n.width&&n.height?t.visit(n.width)+" "+t.visit(n.height):""},visit:function(n){if(!n)return"";if(n instanceof Array)return t.visit_array(n);if(typeof n=="object"&&!n.type)return t.visit_object(n);if(n.type){var e=t["visit_"+n.type];if(e)return e(n);throw Error("Missing visitor visit_"+n.type)}else throw Error("Invalid node.")}};return function(n){return t.visit(n)}}();const rn=H.stringify.bind(H);function ft(t){const n=t.length-1;return t.map((e,r)=>{var d;const a=e.value;let l=w(r/n,3),c="#00000000";switch(e.type){case"rgb":c=m({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0)});break;case"rgba":c=m({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0),a:Number(a[3]??0)});break;case"literal":c=m(e.value);break;case"hex":c=m(`#${e.value}`);break}switch((d=e.length)==null?void 0:d.type){case"%":l=Number(e.length.value)/100;break}return{offset:l,color:c}})}function dt(t){var e;let n=0;switch((e=t.orientation)==null?void 0:e.type){case"angular":n=Number(t.orientation.value);break}return{type:"linear-gradient",angle:n,stops:ft(t.colorStops)}}function gt(t){var n;return(n=t.orientation)==null||n.map(e=>{switch(e==null?void 0:e.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:ft(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function ht(t){return ct(t).map(n=>{switch(n==null?void 0:n.type){case"linear-gradient":return dt(n);case"repeating-linear-gradient":return{...dt(n),repeat:!0};case"radial-gradient":return gt(n);case"repeating-radial-gradient":return{...gt(n),repeat:!0};default:return}}).filter(Boolean)}function vt(t){let n;return typeof t=="string"?n={color:t}:n=t,{color:m(n.color)}}function mt(t){let n;if(typeof t=="string"?n={image:t}:n=t,n.image){const{type:e,...r}=ht(n.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return n}function pt(t){let n;return typeof t=="string"?n={image:t}:n=t,n}function bt(t){let n;return typeof t=="string"?n={preset:t}:n=t,{preset:n.preset,foregroundColor:f(n.foregroundColor)?void 0:m(n.foregroundColor),backgroundColor:f(n.backgroundColor)?void 0:m(n.backgroundColor)}}function yt(t){return!f(t.color)}function St(t){return typeof t=="string"?st(t):yt(t)}function Ct(t){return!f(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function wt(t){return typeof t=="string"?I(t):Ct(t)}function zt(t){return!f(t.image)&&!I(t.image)}function kt(t){return typeof t=="string"?!I(t):zt(t)}function _t(t){return!f(t.preset)}function Nt(t){return typeof t=="string"?!1:_t(t)}function C(t){if(St(t))return vt(t);if(wt(t))return mt(t);if(kt(t))return pt(t);if(Nt(t))return bt(t);throw new Error("Unknown fill property object")}function Ft(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["fillWithShape"])}}function W(){return{color:D,offsetX:0,offsetY:0,blurRadius:1}}function B(t){return{...W(),...z({...t,color:f(t.color)?D:m(t.color)})}}function Gt(){return{...W(),scaleX:1,scaleY:1}}function Dt(t){return{...Gt(),...B(t)}}function on(t){return t}function It(t){return z({...t,softEdge:f(t.softEdge)?void 0:t.softEdge,outerShadow:f(t.outerShadow)?void 0:Dt(t.outerShadow),innerShadow:f(t.innerShadow)?void 0:B(t.innerShadow)})}function Ot(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["fillWithShape"])}}function Et(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["width","style","headEnd","tailEnd"])}}function Lt(t){return typeof t=="string"?{color:m(t)}:{...t,color:f(t.color)?D:m(t.color)}}function Vt(){return{boxShadow:"none"}}function Tt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(n=>typeof n=="string"?{data:n}:n)}:t}function At(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Ht(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function xt(){return{...At(),...Ht(),...Vt(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Pt(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function jt(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Mt(){return{...Pt(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function Rt(){return{...jt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function $t(){return{...Rt(),...Mt(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function N(t){return z({...t,color:f(t.color)?void 0:m(t.color),backgroundColor:f(t.backgroundColor)?void 0:m(t.backgroundColor),borderColor:f(t.borderColor)?void 0:m(t.borderColor),outlineColor:f(t.outlineColor)?void 0:m(t.outlineColor),shadowColor:f(t.shadowColor)?void 0:m(t.shadowColor)})}function an(){return{...xt(),...$t()}}function K(t=""){return(Array.isArray(t)?t:[t]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[N(e)]}:"fragments"in e?{...N(e),fragments:e.fragments.map(r=>N(r))}:Array.isArray(e)?{fragments:e.map(r=>typeof r=="string"?{content:r}:N(r))}:{fragments:[]})}function Wt(t){return typeof t=="string"?{content:[{fragments:[{content:t}]}]}:"content"in t?{...t,content:K(t.content)}:{content:K(t)}}function Bt(t){return typeof t=="string"?{src:t}:t}function X(t){var n;return z({...t,style:f(t.style)?void 0:N(t.style),text:f(t.text)?void 0:Wt(t.text),background:f(t.background)?void 0:Ft(t.background),shape:f(t.shape)?void 0:Tt(t.shape),fill:f(t.fill)?void 0:C(t.fill),outline:f(t.outline)?void 0:Et(t.outline),foreground:f(t.foreground)?void 0:Ot(t.foreground),shadow:f(t.shadow)?void 0:Lt(t.shadow),video:f(t.video)?void 0:Bt(t.video),audio:f(t.audio)?void 0:_(t.audio),effect:f(t.effect)?void 0:It(t.effect),children:(n=t.children)==null?void 0:n.map(e=>X(e))})}function un(t){return X(t)}o.clearUndef=z,o.defaultColor=D,o.getDefaultElementStyle=xt,o.getDefaultHighlightStyle=Pt,o.getDefaultInnerShadow=W,o.getDefaultLayoutStyle=At,o.getDefaultListStyleStyle=jt,o.getDefaultOuterShadow=Gt,o.getDefaultShadowStyle=Vt,o.getDefaultStyle=an,o.getDefaultTextInlineStyle=Mt,o.getDefaultTextLineStyle=Rt,o.getDefaultTextStyle=$t,o.getDefaultTransformStyle=Ht,o.isColor=st,o.isColorFill=St,o.isColorFillObject=yt,o.isGradient=I,o.isGradientFill=wt,o.isGradientFillObject=Ct,o.isImageFill=kt,o.isImageFillObject=zt,o.isNone=f,o.isPresetFill=Nt,o.isPresetFillObject=_t,o.normalizeAudio=_,o.normalizeBackground=Ft,o.normalizeColor=m,o.normalizeColorFill=vt,o.normalizeDocument=un,o.normalizeEffect=It,o.normalizeElement=X,o.normalizeFill=C,o.normalizeForeground=Ot,o.normalizeGradient=ht,o.normalizeGradientFill=mt,o.normalizeImageFill=pt,o.normalizeInnerShadow=B,o.normalizeOuterShadow=Dt,o.normalizeOutline=Et,o.normalizePresetFill=bt,o.normalizeShadow=Lt,o.normalizeShape=Tt,o.normalizeSoftEdge=on,o.normalizeStyle=N,o.normalizeText=Wt,o.normalizeTextContent=K,o.normalizeVideo=Bt,o.parseColor=$,o.parseGradient=ct,o.pick=V,o.round=w,o.stringifyGradient=rn,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(o,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(o=typeof globalThis<"u"?globalThis:o||self,_(o.modernIdoc={}))})(this,function(o){"use strict";function _(t){return typeof t=="string"?{src:t}:t}var Ut={grad:.9,turn:360,rad:360/(2*Math.PI)},S=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},h=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=Math.pow(10,n)),Math.round(e*t)/e+0},b=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=1),t>e?e:t>n?t:n},Q=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Z=function(t){return{r:b(t.r,0,255),g:b(t.g,0,255),b:b(t.b,0,255),a:b(t.a)}},M=function(t){return{r:h(t.r),g:h(t.g),b:h(t.b),a:h(t.a,3)}},qt=/^#([0-9a-f]{3,8})$/i,L=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},tt=function(t){var n=t.r,e=t.g,r=t.b,a=t.a,l=Math.max(n,e,r),c=l-Math.min(n,e,r),d=c?l===n?(e-r)/c:l===e?2+(r-n)/c:4+(n-e)/c:0;return{h:60*(d<0?d+6:d),s:l?c/l*100:0,v:l/255*100,a}},nt=function(t){var n=t.h,e=t.s,r=t.v,a=t.a;n=n/360*6,e/=100,r/=100;var l=Math.floor(n),c=r*(1-e),d=r*(1-(n-l)*e),F=r*(1-(1-n+l)*e),O=l%6;return{r:255*[r,d,c,c,F,r][O],g:255*[F,r,r,d,c,c][O],b:255*[c,c,F,r,r,d][O],a}},et=function(t){return{h:Q(t.h),s:b(t.s,0,100),l:b(t.l,0,100),a:b(t.a)}},rt=function(t){return{h:h(t.h),s:h(t.s),l:h(t.l),a:h(t.a,3)}},it=function(t){return nt((e=(n=t).s,{h:n.h,s:(e*=((r=n.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:n.a}));var n,e,r},G=function(t){return{h:(n=tt(t)).h,s:(a=(200-(e=n.s))*(r=n.v)/100)>0&&a<200?e*r/100/(a<=100?a:200-a)*100:0,l:a/2,a:n.a};var n,e,r,a},Jt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ot={string:[[function(t){var n=qt.exec(t);return n?(t=n[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?h(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?h(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var n=Zt.exec(t)||tn.exec(t);return n?n[2]!==n[4]||n[4]!==n[6]?null:Z({r:Number(n[1])/(n[2]?100/255:1),g:Number(n[3])/(n[4]?100/255:1),b:Number(n[5])/(n[6]?100/255:1),a:n[7]===void 0?1:Number(n[7])/(n[8]?100:1)}):null},"rgb"],[function(t){var n=Jt.exec(t)||Qt.exec(t);if(!n)return null;var e,r,a=et({h:(e=n[1],r=n[2],r===void 0&&(r="deg"),Number(e)*(Ut[r]||1)),s:Number(n[3]),l:Number(n[4]),a:n[5]===void 0?1:Number(n[5])/(n[6]?100:1)});return it(a)},"hsl"]],object:[[function(t){var n=t.r,e=t.g,r=t.b,a=t.a,l=a===void 0?1:a;return S(n)&&S(e)&&S(r)?Z({r:Number(n),g:Number(e),b:Number(r),a:Number(l)}):null},"rgb"],[function(t){var n=t.h,e=t.s,r=t.l,a=t.a,l=a===void 0?1:a;if(!S(n)||!S(e)||!S(r))return null;var c=et({h:Number(n),s:Number(e),l:Number(r),a:Number(l)});return it(c)},"hsl"],[function(t){var n=t.h,e=t.s,r=t.v,a=t.a,l=a===void 0?1:a;if(!S(n)||!S(e)||!S(r))return null;var c=function(d){return{h:Q(d.h),s:b(d.s,0,100),v:b(d.v,0,100),a:b(d.a)}}({h:Number(n),s:Number(e),v:Number(r),a:Number(l)});return nt(c)},"hsv"]]},at=function(t,n){for(var e=0;e<n.length;e++){var r=n[e][0](t);if(r)return[r,n[e][1]]}return[null,void 0]},nn=function(t){return typeof t=="string"?at(t.trim(),ot.string):typeof t=="object"&&t!==null?at(t,ot.object):[null,void 0]},R=function(t,n){var e=G(t);return{h:e.h,s:b(e.s+100*n,0,100),l:e.l,a:e.a}},$=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},ut=function(t,n){var e=G(t);return{h:e.h,s:e.s,l:b(e.l+100*n,0,100),a:e.a}},lt=function(){function t(n){this.parsed=nn(n)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return h($(this.rgba),2)},t.prototype.isDark=function(){return $(this.rgba)<.5},t.prototype.isLight=function(){return $(this.rgba)>=.5},t.prototype.toHex=function(){return n=M(this.rgba),e=n.r,r=n.g,a=n.b,c=(l=n.a)<1?L(h(255*l)):"","#"+L(e)+L(r)+L(a)+c;var n,e,r,a,l,c},t.prototype.toRgb=function(){return M(this.rgba)},t.prototype.toRgbString=function(){return n=M(this.rgba),e=n.r,r=n.g,a=n.b,(l=n.a)<1?"rgba("+e+", "+r+", "+a+", "+l+")":"rgb("+e+", "+r+", "+a+")";var n,e,r,a,l},t.prototype.toHsl=function(){return rt(G(this.rgba))},t.prototype.toHslString=function(){return n=rt(G(this.rgba)),e=n.h,r=n.s,a=n.l,(l=n.a)<1?"hsla("+e+", "+r+"%, "+a+"%, "+l+")":"hsl("+e+", "+r+"%, "+a+"%)";var n,e,r,a,l},t.prototype.toHsv=function(){return n=tt(this.rgba),{h:h(n.h),s:h(n.s),v:h(n.v),a:h(n.a,3)};var n},t.prototype.invert=function(){return y({r:255-(n=this.rgba).r,g:255-n.g,b:255-n.b,a:n.a});var n},t.prototype.saturate=function(n){return n===void 0&&(n=.1),y(R(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),y(R(this.rgba,-n))},t.prototype.grayscale=function(){return y(R(this.rgba,-1))},t.prototype.lighten=function(n){return n===void 0&&(n=.1),y(ut(this.rgba,n))},t.prototype.darken=function(n){return n===void 0&&(n=.1),y(ut(this.rgba,-n))},t.prototype.rotate=function(n){return n===void 0&&(n=15),this.hue(this.hue()+n)},t.prototype.alpha=function(n){return typeof n=="number"?y({r:(e=this.rgba).r,g:e.g,b:e.b,a:n}):h(this.rgba.a,3);var e},t.prototype.hue=function(n){var e=G(this.rgba);return typeof n=="number"?y({h:n,s:e.s,l:e.l,a:e.a}):h(e.h)},t.prototype.isEqual=function(n){return this.toHex()===y(n).toHex()},t}(),y=function(t){return t instanceof lt?t:new lt(t)};function f(t){return t==null||t==="none"}function w(t,n=0,e=10**n){return Math.round(e*t)/e+0}function z(t,n=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return n?t.map(r=>z(r,n)):t;const e={};for(const r in t){const a=t[r];a!=null&&(n?e[r]=z(a,n):e[r]=a)}return e}function V(t,n){const e={};return n.forEach(r=>{r in t&&(e[r]=t[r])}),e}function j(t){let n;return typeof t=="number"?n={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:n=t,y(n)}function en(t){return{r:w(t.r),g:w(t.g),b:w(t.b),a:w(t.a,3)}}function T(t){const n=t.toString(16);return n.length<2?`0${n}`:n}const D="#000000FF";function st(t){return j(t).isValid()}function m(t,n=!1){const e=j(t);if(!e.isValid()){if(typeof t=="string")return t;const d=`Failed to normalizeColor ${t}`;if(n)throw new Error(d);return console.warn(d),D}const{r,g:a,b:l,a:c}=en(e.rgba);return`#${T(r)}${T(a)}${T(l)}${T(w(c*255))}`}var A=A||{};A.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let n="";function e(i){const u=new Error(`${n}: ${i}`);throw u.source=n,u}function r(){const i=a();return n.length>0&&e("Invalid input not EOF"),i}function a(){return x(l)}function l(){return c("linear-gradient",t.linearGradient,F)||c("repeating-linear-gradient",t.repeatingLinearGradient,F)||c("radial-gradient",t.radialGradient,Kt)||c("repeating-radial-gradient",t.repeatingRadialGradient,Kt)}function c(i,u,s){return d(u,v=>{const k=s();return k&&(g(t.comma)||e("Missing comma before color stops")),{type:i,orientation:k,colorStops:x(dn)}})}function d(i,u){const s=g(i);if(s){g(t.startCall)||e("Missing (");const v=u(s);return g(t.endCall)||e("Missing )"),v}}function F(){const i=O();if(i)return i;const u=p("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:ln()}function O(){return p("directional",t.sideOrCorner,1)}function ln(){return p("angular",t.angleValue,1)||p("angular",t.radianValue,1)}function Kt(){let i,u=Xt(),s;return u&&(i=[],i.push(u),s=n,g(t.comma)&&(u=Xt(),u?i.push(u):n=s)),i}function Xt(){let i=sn()||cn();if(i)i.at=U();else{const u=Y();if(u){i=u;const s=U();s&&(i.at=s)}else{const s=U();if(s)i={type:"default-radial",at:s};else{const v=q();v&&(i={type:"default-radial",at:v})}}}return i}function sn(){const i=p("shape",/^(circle)/i,0);return i&&(i.style=Yt()||Y()),i}function cn(){const i=p("shape",/^(ellipse)/i,0);return i&&(i.style=q()||P()||Y()),i}function Y(){return p("extent-keyword",t.extentKeywords,1)}function U(){if(p("position",/^at/,0)){const i=q();return i||e("Missing positioning value"),i}}function q(){const i=fn();if(i.x||i.y)return{type:"position",value:i}}function fn(){return{x:P(),y:P()}}function x(i){let u=i();const s=[];if(u)for(s.push(u);g(t.comma);)u=i(),u?s.push(u):e("One extra comma");return s}function dn(){const i=gn();return i||e("Expected color definition"),i.length=P(),i}function gn(){return vn()||Sn()||yn()||pn()||mn()||bn()||hn()}function hn(){return p("literal",t.literalColor,0)}function vn(){return p("hex",t.hexColor,1)}function mn(){return d(t.rgbColor,()=>({type:"rgb",value:x(E)}))}function pn(){return d(t.rgbaColor,()=>({type:"rgba",value:x(E)}))}function bn(){return d(t.varColor,()=>({type:"var",value:Cn()}))}function yn(){return d(t.hslColor,()=>{g(t.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const u=E();g(t.comma);let s=g(t.percentageValue);const v=s?s[1]:null;g(t.comma),s=g(t.percentageValue);const k=s?s[1]:null;return(!v||!k)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,v,k]}})}function Sn(){return d(t.hslaColor,()=>{const i=E();g(t.comma);let u=g(t.percentageValue);const s=u?u[1]:null;g(t.comma),u=g(t.percentageValue);const v=u?u[1]:null;g(t.comma);const k=E();return(!s||!v)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[i,s,v,k]}})}function Cn(){return g(t.variableName)[1]}function E(){return g(t.number)[1]}function P(){return p("%",t.percentageValue,1)||wn()||zn()||Yt()}function wn(){return p("position-keyword",t.positionKeywords,1)}function zn(){return d(t.calcValue,()=>{let i=1,u=0;for(;i>0&&u<n.length;){const v=n.charAt(u);v==="("?i++:v===")"&&i--,u++}i>0&&e("Missing closing parenthesis in calc() expression");const s=n.substring(0,u-1);return J(u-1),{type:"calc",value:s}})}function Yt(){return p("px",t.pixelValue,1)||p("em",t.emValue,1)}function p(i,u,s){const v=g(u);if(v)return{type:i,value:v[s]}}function g(i){let u,s;return s=/^\s+/.exec(n),s&&J(s[0].length),u=i.exec(n),u&&J(u[0].length),u}function J(i){n=n.substr(i)}return function(i){return n=i.toString().trim(),n.endsWith(";")&&(n=n.slice(0,-1)),r()}}();const ct=A.parse.bind(A);var H=H||{};H.stringify=function(){var t={"visit_linear-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-linear-gradient":function(n){return t.visit_gradient(n)},"visit_radial-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-radial-gradient":function(n){return t.visit_gradient(n)},visit_gradient:function(n){var e=t.visit(n.orientation);return e&&(e+=", "),n.type+"("+e+t.visit(n.colorStops)+")"},visit_shape:function(n){var e=n.value,r=t.visit(n.at),a=t.visit(n.style);return a&&(e+=" "+a),r&&(e+=" at "+r),e},"visit_default-radial":function(n){var e="",r=t.visit(n.at);return r&&(e+=r),e},"visit_extent-keyword":function(n){var e=n.value,r=t.visit(n.at);return r&&(e+=" at "+r),e},"visit_position-keyword":function(n){return n.value},visit_position:function(n){return t.visit(n.value.x)+" "+t.visit(n.value.y)},"visit_%":function(n){return n.value+"%"},visit_em:function(n){return n.value+"em"},visit_px:function(n){return n.value+"px"},visit_calc:function(n){return"calc("+n.value+")"},visit_literal:function(n){return t.visit_color(n.value,n)},visit_hex:function(n){return t.visit_color("#"+n.value,n)},visit_rgb:function(n){return t.visit_color("rgb("+n.value.join(", ")+")",n)},visit_rgba:function(n){return t.visit_color("rgba("+n.value.join(", ")+")",n)},visit_hsl:function(n){return t.visit_color("hsl("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%)",n)},visit_hsla:function(n){return t.visit_color("hsla("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%, "+n.value[3]+")",n)},visit_var:function(n){return t.visit_color("var("+n.value+")",n)},visit_color:function(n,e){var r=n,a=t.visit(e.length);return a&&(r+=" "+a),r},visit_angular:function(n){return n.value+"deg"},visit_directional:function(n){return"to "+n.value},visit_array:function(n){var e="",r=n.length;return n.forEach(function(a,l){e+=t.visit(a),l<r-1&&(e+=", ")}),e},visit_object:function(n){return n.width&&n.height?t.visit(n.width)+" "+t.visit(n.height):""},visit:function(n){if(!n)return"";if(n instanceof Array)return t.visit_array(n);if(typeof n=="object"&&!n.type)return t.visit_object(n);if(n.type){var e=t["visit_"+n.type];if(e)return e(n);throw Error("Missing visitor visit_"+n.type)}else throw Error("Invalid node.")}};return function(n){return t.visit(n)}}();const rn=H.stringify.bind(H);function ft(t){const n=t.length-1;return t.map((e,r)=>{var d;const a=e.value;let l=w(r/n,3),c="#00000000";switch(e.type){case"rgb":c=m({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0)});break;case"rgba":c=m({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0),a:Number(a[3]??0)});break;case"literal":c=m(e.value);break;case"hex":c=m(`#${e.value}`);break}switch((d=e.length)==null?void 0:d.type){case"%":l=Number(e.length.value)/100;break}return{offset:l,color:c}})}function dt(t){var e;let n=0;switch((e=t.orientation)==null?void 0:e.type){case"angular":n=Number(t.orientation.value);break}return{type:"linear-gradient",angle:n,stops:ft(t.colorStops)}}function gt(t){var n;return(n=t.orientation)==null||n.map(e=>{switch(e==null?void 0:e.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:ft(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function ht(t){return ct(t).map(n=>{switch(n==null?void 0:n.type){case"linear-gradient":return dt(n);case"repeating-linear-gradient":return{...dt(n),repeat:!0};case"radial-gradient":return gt(n);case"repeating-radial-gradient":return{...gt(n),repeat:!0};default:return}}).filter(Boolean)}function vt(t){let n;return typeof t=="string"?n={color:t}:n=t,{color:m(n.color)}}function mt(t){let n;if(typeof t=="string"?n={image:t}:n=t,n.image){const{type:e,...r}=ht(n.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return n}function pt(t){let n;return typeof t=="string"?n={image:t}:n=t,n}function bt(t){let n;return typeof t=="string"?n={preset:t}:n=t,{preset:n.preset,foregroundColor:f(n.foregroundColor)?void 0:m(n.foregroundColor),backgroundColor:f(n.backgroundColor)?void 0:m(n.backgroundColor)}}function yt(t){return!f(t.color)}function St(t){return typeof t=="string"?st(t):yt(t)}function Ct(t){return!f(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function wt(t){return typeof t=="string"?I(t):Ct(t)}function zt(t){return!f(t.image)&&!I(t.image)}function kt(t){return typeof t=="string"?!I(t):zt(t)}function _t(t){return!f(t.preset)}function Nt(t){return typeof t=="string"?!1:_t(t)}function C(t){return St(t)?vt(t):wt(t)?mt(t):kt(t)?pt(t):Nt(t)?bt(t):{}}function Ft(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["fillWithShape"])}}function W(){return{color:D,offsetX:0,offsetY:0,blurRadius:1}}function B(t){return{...W(),...z({...t,color:f(t.color)?D:m(t.color)})}}function Gt(){return{...W(),scaleX:1,scaleY:1}}function Dt(t){return{...Gt(),...B(t)}}function on(t){return t}function It(t){return z({...t,softEdge:f(t.softEdge)?void 0:t.softEdge,outerShadow:f(t.outerShadow)?void 0:Dt(t.outerShadow),innerShadow:f(t.innerShadow)?void 0:B(t.innerShadow)})}function Ot(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["fillWithShape"])}}function Et(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["width","style","headEnd","tailEnd"])}}function Lt(t){return typeof t=="string"?{color:m(t)}:{...t,color:f(t.color)?D:m(t.color)}}function Vt(){return{boxShadow:"none"}}function Tt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(n=>typeof n=="string"?{data:n}:n)}:t}function At(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Ht(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function xt(){return{...At(),...Ht(),...Vt(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Pt(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function Mt(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Rt(){return{...Pt(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function $t(){return{...Mt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function jt(){return{...$t(),...Rt(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function N(t){return z({...t,color:f(t.color)?void 0:m(t.color),backgroundColor:f(t.backgroundColor)?void 0:m(t.backgroundColor),borderColor:f(t.borderColor)?void 0:m(t.borderColor),outlineColor:f(t.outlineColor)?void 0:m(t.outlineColor),shadowColor:f(t.shadowColor)?void 0:m(t.shadowColor)})}function an(){return{...xt(),...jt()}}function K(t=""){return(Array.isArray(t)?t:[t]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[N(e)]}:"fragments"in e?{...N(e),fragments:e.fragments.map(r=>N(r))}:Array.isArray(e)?{fragments:e.map(r=>typeof r=="string"?{content:r}:N(r))}:{fragments:[]})}function Wt(t){return typeof t=="string"?{content:[{fragments:[{content:t}]}]}:"content"in t?{...t,content:K(t.content)}:{content:K(t)}}function Bt(t){return typeof t=="string"?{src:t}:t}function X(t){var n;return z({...t,style:f(t.style)?void 0:N(t.style),text:f(t.text)?void 0:Wt(t.text),background:f(t.background)?void 0:Ft(t.background),shape:f(t.shape)?void 0:Tt(t.shape),fill:f(t.fill)?void 0:C(t.fill),outline:f(t.outline)?void 0:Et(t.outline),foreground:f(t.foreground)?void 0:Ot(t.foreground),shadow:f(t.shadow)?void 0:Lt(t.shadow),video:f(t.video)?void 0:Bt(t.video),audio:f(t.audio)?void 0:_(t.audio),effect:f(t.effect)?void 0:It(t.effect),children:(n=t.children)==null?void 0:n.map(e=>X(e))})}function un(t){return X(t)}o.clearUndef=z,o.defaultColor=D,o.getDefaultElementStyle=xt,o.getDefaultHighlightStyle=Pt,o.getDefaultInnerShadow=W,o.getDefaultLayoutStyle=At,o.getDefaultListStyleStyle=Mt,o.getDefaultOuterShadow=Gt,o.getDefaultShadowStyle=Vt,o.getDefaultStyle=an,o.getDefaultTextInlineStyle=Rt,o.getDefaultTextLineStyle=$t,o.getDefaultTextStyle=jt,o.getDefaultTransformStyle=Ht,o.isColor=st,o.isColorFill=St,o.isColorFillObject=yt,o.isGradient=I,o.isGradientFill=wt,o.isGradientFillObject=Ct,o.isImageFill=kt,o.isImageFillObject=zt,o.isNone=f,o.isPresetFill=Nt,o.isPresetFillObject=_t,o.normalizeAudio=_,o.normalizeBackground=Ft,o.normalizeColor=m,o.normalizeColorFill=vt,o.normalizeDocument=un,o.normalizeEffect=It,o.normalizeElement=X,o.normalizeFill=C,o.normalizeForeground=Ot,o.normalizeGradient=ht,o.normalizeGradientFill=mt,o.normalizeImageFill=pt,o.normalizeInnerShadow=B,o.normalizeOuterShadow=Dt,o.normalizeOutline=Et,o.normalizePresetFill=bt,o.normalizeShadow=Lt,o.normalizeShape=Tt,o.normalizeSoftEdge=on,o.normalizeStyle=N,o.normalizeText=Wt,o.normalizeTextContent=K,o.normalizeVideo=Bt,o.parseColor=j,o.parseGradient=ct,o.pick=V,o.round=w,o.stringifyGradient=rn,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED