modern-idoc 0.6.15 → 0.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1265,8 +1265,8 @@ function isEqualStyle(style1, style2) {
1265
1265
  }
1266
1266
  function normalizeTextContent(value) {
1267
1267
  const paragraphs = [];
1268
- function getParagraph() {
1269
- return paragraphs[paragraphs.length - 1] || addParagraph();
1268
+ function lastParagraph() {
1269
+ return paragraphs[paragraphs.length - 1];
1270
1270
  }
1271
1271
  function addParagraph(style = {}) {
1272
1272
  let paragraph = paragraphs[paragraphs.length - 1];
@@ -1282,7 +1282,7 @@ function normalizeTextContent(value) {
1282
1282
  function addFragment(content = "", style = {}) {
1283
1283
  Array.from(content).forEach((c) => {
1284
1284
  if (isCRLF(c)) {
1285
- const { fragments, ...pStyle } = getParagraph();
1285
+ const { fragments, ...pStyle } = lastParagraph() || addParagraph();
1286
1286
  if (!fragments.length) {
1287
1287
  fragments.push({
1288
1288
  ...style,
@@ -1291,7 +1291,7 @@ function normalizeTextContent(value) {
1291
1291
  }
1292
1292
  addParagraph(pStyle);
1293
1293
  } else {
1294
- const paragraph = getParagraph();
1294
+ const paragraph = lastParagraph() || addParagraph();
1295
1295
  const fragment = paragraph.fragments[paragraph.fragments.length - 1];
1296
1296
  if (fragment) {
1297
1297
  const { content: content2, ...fStyle } = fragment;
@@ -1337,8 +1337,11 @@ function normalizeTextContent(value) {
1337
1337
  console.warn("Failed to parse text content", p);
1338
1338
  }
1339
1339
  });
1340
- if (!getParagraph().fragments.length) {
1341
- addFragment(NORMALIZED_CRLF);
1340
+ const lastP = lastParagraph();
1341
+ if (lastP && !lastP.fragments.length) {
1342
+ lastP.fragments.push({
1343
+ content: NORMALIZED_CRLF
1344
+ });
1342
1345
  }
1343
1346
  return paragraphs;
1344
1347
  }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(o,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(o=typeof globalThis<"u"?globalThis:o||self,y(o.modernIdoc={}))})(this,function(o){"use strict";var We=Object.defineProperty;var Be=(o,y,E)=>y in o?We(o,y,{enumerable:!0,configurable:!0,writable:!0,value:E}):o[y]=E;var ce=(o,y,E)=>Be(o,typeof y!="symbol"?y+"":y,E);function y(t){return typeof t=="string"?{src:t}:t}var E={grad:.9,turn:360,rad:360/(2*Math.PI)},_=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},m=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},C=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ut=function(t){return{r:C(t.r,0,255),g:C(t.g,0,255),b:C(t.b,0,255),a:C(t.a)}},K=function(t){return{r:m(t.r),g:m(t.g),b:m(t.b),a:m(t.a,3)}},fe=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},lt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=Math.max(e,n,r),l=c-Math.min(e,n,r),u=l?c===e?(n-r)/l:c===n?2+(r-e)/l:4+(e-n)/l:0;return{h:60*(u<0?u+6:u),s:c?l/c*100:0,v:c/255*100,a:i}},st=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var c=Math.floor(e),l=r*(1-n),u=r*(1-(e-c)*n),g=r*(1-(1-e+c)*n),h=c%6;return{r:255*[r,u,l,l,g,r][h],g:255*[g,r,r,u,l,l][h],b:255*[l,l,g,r,r,u][h],a:i}},ct=function(t){return{h:at(t.h),s:C(t.s,0,100),l:C(t.l,0,100),a:C(t.a)}},ft=function(t){return{h:m(t.h),s:m(t.s),l:m(t.l),a:m(t.a,3)}},dt=function(t){return st((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},L=function(t){return{h:(e=lt(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},de=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gt={string:[[function(t){var e=fe.exec(t);return e?(t=e[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?m(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?m(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=he.exec(t)||ve.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:ut({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=de.exec(t)||ge.exec(t);if(!e)return null;var n,r,i=ct({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(E[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return dt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=i===void 0?1:i;return _(e)&&_(n)&&_(r)?ut({r:Number(e),g:Number(n),b:Number(r),a:Number(c)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,c=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var l=ct({h:Number(e),s:Number(n),l:Number(r),a:Number(c)});return dt(l)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,c=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var l=function(u){return{h:at(u.h),s:C(u.s,0,100),v:C(u.v,0,100),a:C(u.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(c)});return st(l)},"hsv"]]},ht=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},me=function(t){return typeof t=="string"?ht(t.trim(),gt.string):typeof t=="object"&&t!==null?ht(t,gt.object):[null,void 0]},X=function(t,e){var n=L(t);return{h:n.h,s:C(n.s+100*e,0,100),l:n.l,a:n.a}},Y=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},vt=function(t,e){var n=L(t);return{h:n.h,s:n.s,l:C(n.l+100*e,0,100),a:n.a}},mt=function(){function t(e){this.parsed=me(e)[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 m(Y(this.rgba),2)},t.prototype.isDark=function(){return Y(this.rgba)<.5},t.prototype.isLight=function(){return Y(this.rgba)>=.5},t.prototype.toHex=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,l=(c=e.a)<1?A(m(255*c)):"","#"+A(n)+A(r)+A(i)+l;var e,n,r,i,c,l},t.prototype.toRgb=function(){return K(this.rgba)},t.prototype.toRgbString=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,(c=e.a)<1?"rgba("+n+", "+r+", "+i+", "+c+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,c},t.prototype.toHsl=function(){return ft(L(this.rgba))},t.prototype.toHslString=function(){return e=ft(L(this.rgba)),n=e.h,r=e.s,i=e.l,(c=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+c+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,c},t.prototype.toHsv=function(){return e=lt(this.rgba),{h:m(e.h),s:m(e.s),v:m(e.v),a:m(e.a,3)};var e},t.prototype.invert=function(){return z({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),z(X(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),z(X(this.rgba,-e))},t.prototype.grayscale=function(){return z(X(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),z(vt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),z(vt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?z({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):m(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=L(this.rgba);return typeof e=="number"?z({h:e,s:n.s,l:n.l,a:n.a}):m(n.h)},t.prototype.isEqual=function(e){return this.toHex()===z(e).toHex()},t}(),z=function(t){return t instanceof mt?t:new mt(t)};function d(t){return t==null||t==="none"}function O(t,e=0,n=10**e){return Math.round(n*t)/n+0}function R(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>R(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=R(i,e):n[r]=i)}return n}function M(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function pt(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function bt(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function yt(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),pt(t,e.split("."),n))}function St(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n)}class Ct{constructor(){ce(this,"_map",new WeakMap)}_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function q(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,z(e)}function pe(t){return{r:O(t.r),g:O(t.g),b:O(t.b),a:O(t.a,3)}}function T(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const G="#000000FF";function wt(t){return q(t).isValid()}function b(t,e=!1){const n=q(t);if(!n.isValid()){if(typeof t=="string")return t;const u=`Failed to normalizeColor ${t}`;if(e)throw new Error(u);return console.warn(u),G}const{r,g:i,b:c,a:l}=pe(n.rgba);return`#${T(r)}${T(i)}${T(c)}${T(O(l*255))}`}var $=$||{};$.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 e="";function n(a){const s=new Error(`${e}: ${a}`);throw s.source=e,s}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return j(c)}function c(){return l("linear-gradient",t.linearGradient,g)||l("repeating-linear-gradient",t.repeatingLinearGradient,g)||l("radial-gradient",t.radialGradient,F)||l("repeating-radial-gradient",t.repeatingRadialGradient,F)}function l(a,s,f){return u(s,p=>{const k=f();return k&&(v(t.comma)||n("Missing comma before color stops")),{type:a,orientation:k,colorStops:j(Ee)}})}function u(a,s){const f=v(a);if(f){v(t.startCall)||n("Missing (");const p=s(f);return v(t.endCall)||n("Missing )"),p}}function g(){const a=h();if(a)return a;const s=S("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:w()}function h(){return S("directional",t.sideOrCorner,1)}function w(){return S("angular",t.angleValue,1)||S("angular",t.radianValue,1)}function F(){let a,s=B(),f;return s&&(a=[],a.push(s),f=e,v(t.comma)&&(s=B(),s?a.push(s):e=f)),a}function B(){let a=Oe()||Re();if(a)a.at=rt();else{const s=nt();if(s){a=s;const f=rt();f&&(a.at=f)}else{const f=rt();if(f)a={type:"default-radial",at:f};else{const p=it();p&&(a={type:"default-radial",at:p})}}}return a}function Oe(){const a=S("shape",/^(circle)/i,0);return a&&(a.style=se()||nt()),a}function Re(){const a=S("shape",/^(ellipse)/i,0);return a&&(a.style=it()||x()||nt()),a}function nt(){return S("extent-keyword",t.extentKeywords,1)}function rt(){if(S("position",/^at/,0)){const a=it();return a||n("Missing positioning value"),a}}function it(){const a=ke();if(a.x||a.y)return{type:"position",value:a}}function ke(){return{x:x(),y:x()}}function j(a){let s=a();const f=[];if(s)for(f.push(s);v(t.comma);)s=a(),s?f.push(s):n("One extra comma");return f}function Ee(){const a=De();return a||n("Expected color definition"),a.length=x(),a}function De(){return Ge()||Me()||Ae()||Ve()||Ie()||Pe()||Le()}function Le(){return S("literal",t.literalColor,0)}function Ge(){return S("hex",t.hexColor,1)}function Ie(){return u(t.rgbColor,()=>({type:"rgb",value:j(P)}))}function Ve(){return u(t.rgbaColor,()=>({type:"rgba",value:j(P)}))}function Pe(){return u(t.varColor,()=>({type:"var",value:Te()}))}function Ae(){return u(t.hslColor,()=>{v(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const s=P();v(t.comma);let f=v(t.percentageValue);const p=f?f[1]:null;v(t.comma),f=v(t.percentageValue);const k=f?f[1]:null;return(!p||!k)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,p,k]}})}function Me(){return u(t.hslaColor,()=>{const a=P();v(t.comma);let s=v(t.percentageValue);const f=s?s[1]:null;v(t.comma),s=v(t.percentageValue);const p=s?s[1]:null;v(t.comma);const k=P();return(!f||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,p,k]}})}function Te(){return v(t.variableName)[1]}function P(){return v(t.number)[1]}function x(){return S("%",t.percentageValue,1)||$e()||He()||se()}function $e(){return S("position-keyword",t.positionKeywords,1)}function He(){return u(t.calcValue,()=>{let a=1,s=0;for(;a>0&&s<e.length;){const p=e.charAt(s);p==="("?a++:p===")"&&a--,s++}a>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,s-1);return ot(s-1),{type:"calc",value:f}})}function se(){return S("px",t.pixelValue,1)||S("em",t.emValue,1)}function S(a,s,f){const p=v(s);if(p)return{type:a,value:p[f]}}function v(a){let s,f;return f=/^\s+/.exec(e),f&&ot(f[0].length),s=a.exec(e),s&&ot(s[0].length),s}function ot(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const zt=$.parse.bind($);var H=H||{};H.stringify=function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,c){n+=t.visit(i),c<r-1&&(n+=", ")}),n},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const be=H.stringify.bind(H);function _t(t){const e=t.length-1;return t.map((n,r)=>{var u;const i=n.value;let c=O(r/e,3),l="#00000000";switch(n.type){case"rgb":l=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":l=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":l=b(n.value);break;case"hex":l=b(`#${n.value}`);break}switch((u=n.length)==null?void 0:u.type){case"%":c=Number(n.length.value)/100;break}return{offset:c,color:l}})}function Ft(t){var n;let e=0;switch((n=t.orientation)==null?void 0:n.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:_t(t.colorStops)}}function Nt(t){var e;return(e=t.orientation)==null||e.map(n=>{switch(n==null?void 0:n.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:_t(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Ot(t){return zt(t).map(e=>{switch(e==null?void 0:e.type){case"linear-gradient":return Ft(e);case"repeating-linear-gradient":return{...Ft(e),repeat:!0};case"radial-gradient":return Nt(e);case"repeating-radial-gradient":return{...Nt(e),repeat:!0};default:return}}).filter(Boolean)}function Rt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function kt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Ot(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Et(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Dt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:d(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:d(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Lt(t){return!d(t.color)}function Gt(t){return typeof t=="string"?wt(t):Lt(t)}function It(t){return!d(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):It(t)}function Pt(t){return!d(t.image)&&!I(t.image)}function At(t){return typeof t=="string"?!I(t):Pt(t)}function Mt(t){return!d(t.preset)}function Tt(t){return typeof t=="string"?!1:Mt(t)}function N(t){return Gt(t)?Rt(t):Vt(t)?kt(t):At(t)?Et(t):Tt(t)?Dt(t):{}}function $t(t){return typeof t=="string"?{...N(t)}:{...N(t),...M(t,["fillWithShape"])}}const Ht=new Ct;function U(t){let e=Ht.get(t);if(!e){const n=Object.getPrototypeOf(t);e=new Map(n?U(n):void 0),Ht.set(t,e)}return e}function Wt(t,e,n={}){U(t).set(e,n);const{default:r,alias:i=Symbol.for(String(e))}=n,c=()=>typeof r=="function"?r():r,l=Object.getOwnPropertyDescriptor(t.prototype,e)||{get(){return typeof i=="string"?yt(this,i):this[i]},set(u){typeof i=="string"?St(this,i,u):this[i]=u}};Object.defineProperty(t.prototype,e,{get(){var g,h;let u=(g=l.get)==null?void 0:g.call(this);return u===void 0&&(u=c(),u!==void 0&&((h=l.set)==null||h.call(this,u))),u},set(u){var h,w,F;let g=(h=l.get)==null?void 0:h.call(this);g===void 0&&(g=c()),(w=l.set)==null||w.call(this,u),(F=this.requestUpdate)==null||F.call(this,e,u,g,n)},configurable:!0,enumerable:!0})}function ye(t){return function(e,n){Wt(e.constructor,n,t)}}function Z(){return{color:G,offsetX:0,offsetY:0,blurRadius:1}}function J(t){return{...Z(),...R({...t,color:d(t.color)?G:b(t.color)})}}function Bt(){return{...Z(),scaleX:1,scaleY:1}}function jt(t){return{...Bt(),...J(t)}}function Se(t){return t}function xt(t){return R({...t,softEdge:d(t.softEdge)?void 0:t.softEdge,outerShadow:d(t.outerShadow)?void 0:jt(t.outerShadow),innerShadow:d(t.innerShadow)?void 0:J(t.innerShadow)})}function Kt(t){return typeof t=="string"?{...N(t)}:{...N(t),...M(t,["fillWithShape"])}}function Xt(t){return typeof t=="string"?{...N(t)}:{...N(t),...M(t,["width","style","headEnd","tailEnd"])}}function Yt(t){return typeof t=="string"?{color:b(t)}:{...t,color:d(t.color)?G:b(t.color)}}function qt(){return{boxShadow:"none"}}function Ut(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function Zt(){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 Jt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Qt(){return{...Zt(),...Jt(),...qt(),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 te(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ee(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ne(){return{...te(),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 re(){return{...ee(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ie(){return{...re(),...ne(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function D(t){return R({...t,color:d(t.color)?void 0:b(t.color),backgroundColor:d(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:d(t.borderColor)?void 0:b(t.borderColor),outlineColor:d(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:d(t.shadowColor)?void 0:b(t.shadowColor)})}function Ce(){return{...Qt(),...ie()}}const Q=/\r\n|\n\r|\n|\r/,we=new RegExp(`${Q.source}|<br\\/>`,"g"),ze=new RegExp(`^(${Q.source})$`),W=`
2
- `;function _e(t){return Q.test(t)}function tt(t){return ze.test(t)}function oe(t){return t.replace(we,W)}function ae(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function V(t){const e=[];function n(){return e[e.length-1]||r()}function r(l={}){let u=e[e.length-1];return(u==null?void 0:u.fragments.length)===0?(u={...l,fragments:[]},e[e.length-1]=u):(u={...l,fragments:[]},e.push(u)),u}function i(l="",u={}){Array.from(l).forEach(g=>{if(tt(g)){const{fragments:h,...w}=n();h.length||h.push({...u,content:W}),r(w)}else{const h=n(),w=h.fragments[h.fragments.length-1];if(w){const{content:F,...B}=w;if(ae(u,B)){w.content=`${F}${g}`;return}}h.fragments.push({...u,content:g})}})}return(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l=="string")r(),i(l);else if("content"in l){const{content:u,...g}=l;r(D(g)),i(u)}else if("fragments"in l){const{fragments:u,...g}=l;r(D(g)),u.forEach(h=>{const{content:w,...F}=h;i(w,D(F))})}else Array.isArray(l)?(r(),l.forEach(u=>{if(typeof u=="string")i(u);else{const{content:g,...h}=u;i(g,D(h))}})):console.warn("Failed to parse text content",l)}),n().fragments.length||i(W),e}function ue(t){return typeof t=="string"?{content:V(t)}:"content"in t?{...t,content:V(t.content)}:{content:V(t)}}function Fe(t){return V(t).map(e=>{const n=oe(e.fragments.flatMap(r=>r.content).join(""));return tt(n)?"":n}).join(W)}function le(t){return typeof t=="string"?{src:t}:t}function et(t){var e;return R({...t,style:d(t.style)?void 0:D(t.style),text:d(t.text)?void 0:ue(t.text),background:d(t.background)?void 0:$t(t.background),shape:d(t.shape)?void 0:Ut(t.shape),fill:d(t.fill)?void 0:N(t.fill),outline:d(t.outline)?void 0:Xt(t.outline),foreground:d(t.foreground)?void 0:Kt(t.foreground),shadow:d(t.shadow)?void 0:Yt(t.shadow),video:d(t.video)?void 0:le(t.video),audio:d(t.audio)?void 0:y(t.audio),effect:d(t.effect)?void 0:xt(t.effect),children:(e=t.children)==null?void 0:e.map(n=>et(n))})}function Ne(t){return et(t)}o.RawWeakMap=Ct,o.clearUndef=R,o.defaultColor=G,o.defineProperty=Wt,o.getDeclarations=U,o.getDefaultElementStyle=Qt,o.getDefaultHighlightStyle=te,o.getDefaultInnerShadow=Z,o.getDefaultLayoutStyle=Zt,o.getDefaultListStyleStyle=ee,o.getDefaultOuterShadow=Bt,o.getDefaultShadowStyle=qt,o.getDefaultStyle=Ce,o.getDefaultTextInlineStyle=ne,o.getDefaultTextLineStyle=re,o.getDefaultTextStyle=ie,o.getDefaultTransformStyle=Jt,o.getNestedValue=pt,o.getObjectValueByPath=yt,o.hasCRLF=_e,o.isCRLF=tt,o.isColor=wt,o.isColorFill=Gt,o.isColorFillObject=Lt,o.isEqualStyle=ae,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=It,o.isImageFill=At,o.isImageFillObject=Pt,o.isNone=d,o.isPresetFill=Tt,o.isPresetFillObject=Mt,o.normalizeAudio=y,o.normalizeBackground=$t,o.normalizeCRLF=oe,o.normalizeColor=b,o.normalizeColorFill=Rt,o.normalizeDocument=Ne,o.normalizeEffect=xt,o.normalizeElement=et,o.normalizeFill=N,o.normalizeForeground=Kt,o.normalizeGradient=Ot,o.normalizeGradientFill=kt,o.normalizeImageFill=Et,o.normalizeInnerShadow=J,o.normalizeOuterShadow=jt,o.normalizeOutline=Xt,o.normalizePresetFill=Dt,o.normalizeShadow=Yt,o.normalizeShape=Ut,o.normalizeSoftEdge=Se,o.normalizeStyle=D,o.normalizeText=ue,o.normalizeTextContent=V,o.normalizeVideo=le,o.parseColor=q,o.parseGradient=zt,o.pick=M,o.property=ye,o.round=O,o.setNestedValue=bt,o.setObjectValueByPath=St,o.stringifyGradient=be,o.textContentToString=Fe,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(o=typeof globalThis<"u"?globalThis:o||self,S(o.modernIdoc={}))})(this,function(o){"use strict";var We=Object.defineProperty;var Be=(o,S,E)=>S in o?We(o,S,{enumerable:!0,configurable:!0,writable:!0,value:E}):o[S]=E;var fe=(o,S,E)=>Be(o,typeof S!="symbol"?S+"":S,E);function S(t){return typeof t=="string"?{src:t}:t}var E={grad:.9,turn:360,rad:360/(2*Math.PI)},F=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},m=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},z=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},ut=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},lt=function(t){return{r:z(t.r,0,255),g:z(t.g,0,255),b:z(t.b,0,255),a:z(t.a)}},K=function(t){return{r:m(t.r),g:m(t.g),b:m(t.b),a:m(t.a,3)}},de=/^#([0-9a-f]{3,8})$/i,M=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},st=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=Math.max(e,n,r),s=c-Math.min(e,n,r),u=s?c===e?(n-r)/s:c===n?2+(r-e)/s:4+(e-n)/s:0;return{h:60*(u<0?u+6:u),s:c?s/c*100:0,v:c/255*100,a:i}},ct=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var c=Math.floor(e),s=r*(1-n),u=r*(1-(e-c)*n),f=r*(1-(1-e+c)*n),h=c%6;return{r:255*[r,u,s,s,f,r][h],g:255*[f,r,r,u,s,s][h],b:255*[s,s,f,r,r,u][h],a:i}},ft=function(t){return{h:ut(t.h),s:z(t.s,0,100),l:z(t.l,0,100),a:z(t.a)}},dt=function(t){return{h:m(t.h),s:m(t.s),l:m(t.l),a:m(t.a,3)}},gt=function(t){return ct((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},G=function(t){return{h:(e=st(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},ge=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,me=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ht={string:[[function(t){var e=de.exec(t);return e?(t=e[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?m(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?m(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=ve.exec(t)||me.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:lt({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=ge.exec(t)||he.exec(t);if(!e)return null;var n,r,i=ft({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(E[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return gt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=i===void 0?1:i;return F(e)&&F(n)&&F(r)?lt({r:Number(e),g:Number(n),b:Number(r),a:Number(c)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,c=i===void 0?1:i;if(!F(e)||!F(n)||!F(r))return null;var s=ft({h:Number(e),s:Number(n),l:Number(r),a:Number(c)});return gt(s)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,c=i===void 0?1:i;if(!F(e)||!F(n)||!F(r))return null;var s=function(u){return{h:ut(u.h),s:z(u.s,0,100),v:z(u.v,0,100),a:z(u.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(c)});return ct(s)},"hsv"]]},vt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},pe=function(t){return typeof t=="string"?vt(t.trim(),ht.string):typeof t=="object"&&t!==null?vt(t,ht.object):[null,void 0]},X=function(t,e){var n=G(t);return{h:n.h,s:z(n.s+100*e,0,100),l:n.l,a:n.a}},Y=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},mt=function(t,e){var n=G(t);return{h:n.h,s:n.s,l:z(n.l+100*e,0,100),a:n.a}},pt=function(){function t(e){this.parsed=pe(e)[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 m(Y(this.rgba),2)},t.prototype.isDark=function(){return Y(this.rgba)<.5},t.prototype.isLight=function(){return Y(this.rgba)>=.5},t.prototype.toHex=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,s=(c=e.a)<1?M(m(255*c)):"","#"+M(n)+M(r)+M(i)+s;var e,n,r,i,c,s},t.prototype.toRgb=function(){return K(this.rgba)},t.prototype.toRgbString=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,(c=e.a)<1?"rgba("+n+", "+r+", "+i+", "+c+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,c},t.prototype.toHsl=function(){return dt(G(this.rgba))},t.prototype.toHslString=function(){return e=dt(G(this.rgba)),n=e.h,r=e.s,i=e.l,(c=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+c+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,c},t.prototype.toHsv=function(){return e=st(this.rgba),{h:m(e.h),s:m(e.s),v:m(e.v),a:m(e.a,3)};var e},t.prototype.invert=function(){return _({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),_(X(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),_(X(this.rgba,-e))},t.prototype.grayscale=function(){return _(X(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),_(mt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),_(mt(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?_({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):m(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=G(this.rgba);return typeof e=="number"?_({h:e,s:n.s,l:n.l,a:n.a}):m(n.h)},t.prototype.isEqual=function(e){return this.toHex()===_(e).toHex()},t}(),_=function(t){return t instanceof pt?t:new pt(t)};function g(t){return t==null||t==="none"}function O(t,e=0,n=10**e){return Math.round(n*t)/n+0}function R(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>R(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=R(i,e):n[r]=i)}return n}function T(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function bt(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function yt(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function St(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n))}function Ct(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),yt(t,e.split("."),n)}class wt{constructor(){fe(this,"_map",new WeakMap)}_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function q(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,_(e)}function be(t){return{r:O(t.r),g:O(t.g),b:O(t.b),a:O(t.a,3)}}function $(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const I="#000000FF";function zt(t){return q(t).isValid()}function b(t,e=!1){const n=q(t);if(!n.isValid()){if(typeof t=="string")return t;const u=`Failed to normalizeColor ${t}`;if(e)throw new Error(u);return console.warn(u),I}const{r,g:i,b:c,a:s}=be(n.rgba);return`#${$(r)}${$(i)}${$(c)}${$(O(s*255))}`}var H=H||{};H.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 e="";function n(a){const l=new Error(`${e}: ${a}`);throw l.source=e,l}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return j(c)}function c(){return s("linear-gradient",t.linearGradient,f)||s("repeating-linear-gradient",t.repeatingLinearGradient,f)||s("radial-gradient",t.radialGradient,w)||s("repeating-radial-gradient",t.repeatingRadialGradient,w)}function s(a,l,d){return u(l,p=>{const k=d();return k&&(v(t.comma)||n("Missing comma before color stops")),{type:a,orientation:k,colorStops:j(Ee)}})}function u(a,l){const d=v(a);if(d){v(t.startCall)||n("Missing (");const p=l(d);return v(t.endCall)||n("Missing )"),p}}function f(){const a=h();if(a)return a;const l=C("position-keyword",t.positionKeywords,1);return l?{type:"directional",value:l.value}:y()}function h(){return C("directional",t.sideOrCorner,1)}function y(){return C("angular",t.angleValue,1)||C("angular",t.radianValue,1)}function w(){let a,l=L(),d;return l&&(a=[],a.push(l),d=e,v(t.comma)&&(l=L(),l?a.push(l):e=d)),a}function L(){let a=nt()||Re();if(a)a.at=it();else{const l=rt();if(l){a=l;const d=it();d&&(a.at=d)}else{const d=it();if(d)a={type:"default-radial",at:d};else{const p=ot();p&&(a={type:"default-radial",at:p})}}}return a}function nt(){const a=C("shape",/^(circle)/i,0);return a&&(a.style=ce()||rt()),a}function Re(){const a=C("shape",/^(ellipse)/i,0);return a&&(a.style=ot()||x()||rt()),a}function rt(){return C("extent-keyword",t.extentKeywords,1)}function it(){if(C("position",/^at/,0)){const a=ot();return a||n("Missing positioning value"),a}}function ot(){const a=ke();if(a.x||a.y)return{type:"position",value:a}}function ke(){return{x:x(),y:x()}}function j(a){let l=a();const d=[];if(l)for(d.push(l);v(t.comma);)l=a(),l?d.push(l):n("One extra comma");return d}function Ee(){const a=De();return a||n("Expected color definition"),a.length=x(),a}function De(){return Ge()||Me()||Ae()||Ve()||Ie()||Pe()||Le()}function Le(){return C("literal",t.literalColor,0)}function Ge(){return C("hex",t.hexColor,1)}function Ie(){return u(t.rgbColor,()=>({type:"rgb",value:j(A)}))}function Ve(){return u(t.rgbaColor,()=>({type:"rgba",value:j(A)}))}function Pe(){return u(t.varColor,()=>({type:"var",value:Te()}))}function Ae(){return u(t.hslColor,()=>{v(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const l=A();v(t.comma);let d=v(t.percentageValue);const p=d?d[1]:null;v(t.comma),d=v(t.percentageValue);const k=d?d[1]:null;return(!p||!k)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[l,p,k]}})}function Me(){return u(t.hslaColor,()=>{const a=A();v(t.comma);let l=v(t.percentageValue);const d=l?l[1]:null;v(t.comma),l=v(t.percentageValue);const p=l?l[1]:null;v(t.comma);const k=A();return(!d||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,d,p,k]}})}function Te(){return v(t.variableName)[1]}function A(){return v(t.number)[1]}function x(){return C("%",t.percentageValue,1)||$e()||He()||ce()}function $e(){return C("position-keyword",t.positionKeywords,1)}function He(){return u(t.calcValue,()=>{let a=1,l=0;for(;a>0&&l<e.length;){const p=e.charAt(l);p==="("?a++:p===")"&&a--,l++}a>0&&n("Missing closing parenthesis in calc() expression");const d=e.substring(0,l-1);return at(l-1),{type:"calc",value:d}})}function ce(){return C("px",t.pixelValue,1)||C("em",t.emValue,1)}function C(a,l,d){const p=v(l);if(p)return{type:a,value:p[d]}}function v(a){let l,d;return d=/^\s+/.exec(e),d&&at(d[0].length),l=a.exec(e),l&&at(l[0].length),l}function at(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const _t=H.parse.bind(H);var W=W||{};W.stringify=function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,c){n+=t.visit(i),c<r-1&&(n+=", ")}),n},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const ye=W.stringify.bind(W);function Ft(t){const e=t.length-1;return t.map((n,r)=>{var u;const i=n.value;let c=O(r/e,3),s="#00000000";switch(n.type){case"rgb":s=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":s=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":s=b(n.value);break;case"hex":s=b(`#${n.value}`);break}switch((u=n.length)==null?void 0:u.type){case"%":c=Number(n.length.value)/100;break}return{offset:c,color:s}})}function Nt(t){var n;let e=0;switch((n=t.orientation)==null?void 0:n.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Ft(t.colorStops)}}function Ot(t){var e;return(e=t.orientation)==null||e.map(n=>{switch(n==null?void 0:n.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:Ft(t.colorStops)}}function V(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Rt(t){return _t(t).map(e=>{switch(e==null?void 0:e.type){case"linear-gradient":return Nt(e);case"repeating-linear-gradient":return{...Nt(e),repeat:!0};case"radial-gradient":return Ot(e);case"repeating-radial-gradient":return{...Ot(e),repeat:!0};default:return}}).filter(Boolean)}function kt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function Et(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Rt(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Dt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Lt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:g(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:g(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Gt(t){return!g(t.color)}function It(t){return typeof t=="string"?zt(t):Gt(t)}function Vt(t){return!g(t.image)&&V(t.image)||!!t.linearGradient||!!t.radialGradient}function Pt(t){return typeof t=="string"?V(t):Vt(t)}function At(t){return!g(t.image)&&!V(t.image)}function Mt(t){return typeof t=="string"?!V(t):At(t)}function Tt(t){return!g(t.preset)}function $t(t){return typeof t=="string"?!1:Tt(t)}function N(t){return It(t)?kt(t):Pt(t)?Et(t):Mt(t)?Dt(t):$t(t)?Lt(t):{}}function Ht(t){return typeof t=="string"?{...N(t)}:{...N(t),...T(t,["fillWithShape"])}}const Wt=new wt;function U(t){let e=Wt.get(t);if(!e){const n=Object.getPrototypeOf(t);e=new Map(n?U(n):void 0),Wt.set(t,e)}return e}function Bt(t,e,n={}){U(t).set(e,n);const{default:r,alias:i=Symbol.for(String(e))}=n,c=()=>typeof r=="function"?r():r,s=Object.getOwnPropertyDescriptor(t.prototype,e)||{get(){return typeof i=="string"?St(this,i):this[i]},set(u){typeof i=="string"?Ct(this,i,u):this[i]=u}};Object.defineProperty(t.prototype,e,{get(){var f,h;let u=(f=s.get)==null?void 0:f.call(this);return u===void 0&&(u=c(),u!==void 0&&((h=s.set)==null||h.call(this,u))),u},set(u){var h,y,w;let f=(h=s.get)==null?void 0:h.call(this);f===void 0&&(f=c()),(y=s.set)==null||y.call(this,u),(w=this.requestUpdate)==null||w.call(this,e,u,f,n)},configurable:!0,enumerable:!0})}function Se(t){return function(e,n){Bt(e.constructor,n,t)}}function Z(){return{color:I,offsetX:0,offsetY:0,blurRadius:1}}function J(t){return{...Z(),...R({...t,color:g(t.color)?I:b(t.color)})}}function jt(){return{...Z(),scaleX:1,scaleY:1}}function xt(t){return{...jt(),...J(t)}}function Ce(t){return t}function Kt(t){return R({...t,softEdge:g(t.softEdge)?void 0:t.softEdge,outerShadow:g(t.outerShadow)?void 0:xt(t.outerShadow),innerShadow:g(t.innerShadow)?void 0:J(t.innerShadow)})}function Xt(t){return typeof t=="string"?{...N(t)}:{...N(t),...T(t,["fillWithShape"])}}function Yt(t){return typeof t=="string"?{...N(t)}:{...N(t),...T(t,["width","style","headEnd","tailEnd"])}}function qt(t){return typeof t=="string"?{color:b(t)}:{...t,color:g(t.color)?I:b(t.color)}}function Ut(){return{boxShadow:"none"}}function Zt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function Jt(){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 Qt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function te(){return{...Jt(),...Qt(),...Ut(),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 ee(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ne(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function re(){return{...ee(),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 ie(){return{...ne(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function oe(){return{...ie(),...re(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function D(t){return R({...t,color:g(t.color)?void 0:b(t.color),backgroundColor:g(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:g(t.borderColor)?void 0:b(t.borderColor),outlineColor:g(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:g(t.shadowColor)?void 0:b(t.shadowColor)})}function we(){return{...te(),...oe()}}const Q=/\r\n|\n\r|\n|\r/,ze=new RegExp(`${Q.source}|<br\\/>`,"g"),_e=new RegExp(`^(${Q.source})$`),B=`
2
+ `;function Fe(t){return Q.test(t)}function tt(t){return _e.test(t)}function ae(t){return t.replace(ze,B)}function ue(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function P(t){const e=[];function n(){return e[e.length-1]}function r(u={}){let f=e[e.length-1];return(f==null?void 0:f.fragments.length)===0?(f={...u,fragments:[]},e[e.length-1]=f):(f={...u,fragments:[]},e.push(f)),f}function i(u="",f={}){Array.from(u).forEach(h=>{if(tt(h)){const{fragments:y,...w}=n()||r();y.length||y.push({...f,content:B}),r(w)}else{const y=n()||r(),w=y.fragments[y.fragments.length-1];if(w){const{content:L,...nt}=w;if(ue(f,nt)){w.content=`${L}${h}`;return}}y.fragments.push({...f,content:h})}})}(Array.isArray(t)?t:[t]).forEach(u=>{if(typeof u=="string")r(),i(u);else if("content"in u){const{content:f,...h}=u;r(D(h)),i(f)}else if("fragments"in u){const{fragments:f,...h}=u;r(D(h)),f.forEach(y=>{const{content:w,...L}=y;i(w,D(L))})}else Array.isArray(u)?(r(),u.forEach(f=>{if(typeof f=="string")i(f);else{const{content:h,...y}=f;i(h,D(y))}})):console.warn("Failed to parse text content",u)});const s=n();return s&&!s.fragments.length&&s.fragments.push({content:B}),e}function le(t){return typeof t=="string"?{content:P(t)}:"content"in t?{...t,content:P(t.content)}:{content:P(t)}}function Ne(t){return P(t).map(e=>{const n=ae(e.fragments.flatMap(r=>r.content).join(""));return tt(n)?"":n}).join(B)}function se(t){return typeof t=="string"?{src:t}:t}function et(t){var e;return R({...t,style:g(t.style)?void 0:D(t.style),text:g(t.text)?void 0:le(t.text),background:g(t.background)?void 0:Ht(t.background),shape:g(t.shape)?void 0:Zt(t.shape),fill:g(t.fill)?void 0:N(t.fill),outline:g(t.outline)?void 0:Yt(t.outline),foreground:g(t.foreground)?void 0:Xt(t.foreground),shadow:g(t.shadow)?void 0:qt(t.shadow),video:g(t.video)?void 0:se(t.video),audio:g(t.audio)?void 0:S(t.audio),effect:g(t.effect)?void 0:Kt(t.effect),children:(e=t.children)==null?void 0:e.map(n=>et(n))})}function Oe(t){return et(t)}o.RawWeakMap=wt,o.clearUndef=R,o.defaultColor=I,o.defineProperty=Bt,o.getDeclarations=U,o.getDefaultElementStyle=te,o.getDefaultHighlightStyle=ee,o.getDefaultInnerShadow=Z,o.getDefaultLayoutStyle=Jt,o.getDefaultListStyleStyle=ne,o.getDefaultOuterShadow=jt,o.getDefaultShadowStyle=Ut,o.getDefaultStyle=we,o.getDefaultTextInlineStyle=re,o.getDefaultTextLineStyle=ie,o.getDefaultTextStyle=oe,o.getDefaultTransformStyle=Qt,o.getNestedValue=bt,o.getObjectValueByPath=St,o.hasCRLF=Fe,o.isCRLF=tt,o.isColor=zt,o.isColorFill=It,o.isColorFillObject=Gt,o.isEqualStyle=ue,o.isGradient=V,o.isGradientFill=Pt,o.isGradientFillObject=Vt,o.isImageFill=Mt,o.isImageFillObject=At,o.isNone=g,o.isPresetFill=$t,o.isPresetFillObject=Tt,o.normalizeAudio=S,o.normalizeBackground=Ht,o.normalizeCRLF=ae,o.normalizeColor=b,o.normalizeColorFill=kt,o.normalizeDocument=Oe,o.normalizeEffect=Kt,o.normalizeElement=et,o.normalizeFill=N,o.normalizeForeground=Xt,o.normalizeGradient=Rt,o.normalizeGradientFill=Et,o.normalizeImageFill=Dt,o.normalizeInnerShadow=J,o.normalizeOuterShadow=xt,o.normalizeOutline=Yt,o.normalizePresetFill=Lt,o.normalizeShadow=qt,o.normalizeShape=Zt,o.normalizeSoftEdge=Ce,o.normalizeStyle=D,o.normalizeText=le,o.normalizeTextContent=P,o.normalizeVideo=se,o.parseColor=q,o.parseGradient=_t,o.pick=T,o.property=Se,o.round=O,o.setNestedValue=yt,o.setObjectValueByPath=Ct,o.stringifyGradient=ye,o.textContentToString=Ne,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1263,8 +1263,8 @@ function isEqualStyle(style1, style2) {
1263
1263
  }
1264
1264
  function normalizeTextContent(value) {
1265
1265
  const paragraphs = [];
1266
- function getParagraph() {
1267
- return paragraphs[paragraphs.length - 1] || addParagraph();
1266
+ function lastParagraph() {
1267
+ return paragraphs[paragraphs.length - 1];
1268
1268
  }
1269
1269
  function addParagraph(style = {}) {
1270
1270
  let paragraph = paragraphs[paragraphs.length - 1];
@@ -1280,7 +1280,7 @@ function normalizeTextContent(value) {
1280
1280
  function addFragment(content = "", style = {}) {
1281
1281
  Array.from(content).forEach((c) => {
1282
1282
  if (isCRLF(c)) {
1283
- const { fragments, ...pStyle } = getParagraph();
1283
+ const { fragments, ...pStyle } = lastParagraph() || addParagraph();
1284
1284
  if (!fragments.length) {
1285
1285
  fragments.push({
1286
1286
  ...style,
@@ -1289,7 +1289,7 @@ function normalizeTextContent(value) {
1289
1289
  }
1290
1290
  addParagraph(pStyle);
1291
1291
  } else {
1292
- const paragraph = getParagraph();
1292
+ const paragraph = lastParagraph() || addParagraph();
1293
1293
  const fragment = paragraph.fragments[paragraph.fragments.length - 1];
1294
1294
  if (fragment) {
1295
1295
  const { content: content2, ...fStyle } = fragment;
@@ -1335,8 +1335,11 @@ function normalizeTextContent(value) {
1335
1335
  console.warn("Failed to parse text content", p);
1336
1336
  }
1337
1337
  });
1338
- if (!getParagraph().fragments.length) {
1339
- addFragment(NORMALIZED_CRLF);
1338
+ const lastP = lastParagraph();
1339
+ if (lastP && !lastP.fragments.length) {
1340
+ lastP.fragments.push({
1341
+ content: NORMALIZED_CRLF
1342
+ });
1340
1343
  }
1341
1344
  return paragraphs;
1342
1345
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.6.15",
4
+ "version": "0.6.16",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",