UNPKG

sone

Version:

A declarative Canvas layout engine for JavaScript with advanced rich text support.

3 lines (2 loc) 39.6 kB
function D(e={}){let t=r=>{e.filters==null&&(e.filters=[]),e.filters.push(r)},a=(...r)=>{e.background==null&&(e.background=[]),e.background.push(...r)};return{props:e,tag(r){return e.tag=r,this},apply(r){return Object.assign(e,r),this},alignContent(r){return e.alignContent=r,this},alignItems(r){return e.alignItems=r,this},alignSelf(r){return e.alignSelf=r,this},aspectRatio(r){return e.aspectRatio=r,this},corner(r){return e.corner=r,this},borderWidth(r,s,n,i){return s==null&&n==null&&i==null?(e.borderWidth=r,this):s!=null&&n==null&&i==null?(e.borderTopWidth=r,e.borderBottomWidth=r,e.borderLeftWidth=s,e.borderRightWidth=s,this):s!=null&&n!=null&&i==null?(e.borderTopWidth=r,e.borderBottomWidth=n,e.borderLeftWidth=s,e.borderRightWidth=s,this):(e.borderTopWidth=r,e.borderBottomWidth=n,e.borderLeftWidth=i,e.borderRightWidth=s,this)},borderColor(r){return e.borderColor=r,this},margin(r,s,n,i){return s==null&&n==null&&i==null?(e.margin=r,this):s!=null&&n==null&&i==null?(e.marginTop=r,e.marginBottom=r,e.marginLeft=s,e.marginRight=s,this):s!=null&&n!=null&&i==null?(e.marginTop=r,e.marginLeft=s,e.marginRight=s,e.marginBottom=n,this):(e.marginTop=r,e.marginLeft=i,e.marginRight=s,e.marginBottom=n,this)},marginTop(r){return e.marginTop=r,this},marginBottom(r){return e.marginBottom=r,this},marginLeft(r){return e.marginLeft=r,this},marginRight(r){return e.marginRight=r,this},padding(r,s,n,i){return s==null&&n==null&&i==null?(e.padding=r,this):s!=null&&n==null&&i==null?(e.paddingTop=r,e.paddingBottom=r,e.paddingLeft=s,e.paddingRight=s,this):s!=null&&n!=null&&i==null?(e.paddingTop=r,e.paddingLeft=s,e.paddingRight=s,e.paddingBottom=n,this):(e.paddingTop=r,e.paddingLeft=i,e.paddingRight=s,e.paddingBottom=n,this)},paddingTop(r){return e.paddingTop=r,this},paddingBottom(r){return e.paddingBottom=r,this},paddingLeft(r){return e.paddingLeft=r,this},paddingRight(r){return e.paddingRight=r,this},boxSizing(r){return e.boxSizing=r,this},display(r){return e.display=r,this},flex(r){return e.flex=r,this},basis(r){return e.flexBasis=r,this},direction(r){return e.flexDirection=r,this},rowGap(r){return e.rowGap=r,this},gap(r){return e.gap=r,this},columnGap(r){return e.columnGap=r,this},grow(r){return e.flexGrow=r,this},shrink(r){return e.flexShrink=r,this},wrap(r){return e.flexWrap=r,this},justifyContent(r){return e.justifyContent=r,this},left(r){return e.left=r,this},right(r){return e.right=r,this},bottom(r){return e.bottom=r,this},top(r){return e.top=r,this},start(r){return e.start=r,this},end(r){return e.end=r,this},size(r,s){return e.width=r,e.height=s??r,this},width(r){return e.width=r,this},height(r){return e.height=r,this},maxWidth(r){return e.maxWidth=r,this},maxHeight(r){return e.maxHeight=r,this},minWidth(r){return e.minWidth=r,this},minHeight(r){return e.minHeight=r,this},position(r){return e.position=r,this},inset(r){return e.inset=r,this},overflow(r){return e.overflow=r,this},rotate(r){return e.rotation=r,this},scale(r,s){return e.scale=[r,s??r],this},translateX(r){return e.translateX=r,this},translateY(r){return e.translateY=r,this},bg(...r){return a(...r),this},background(...r){return a(...r),this},opacity(r){return e.opacity=r,this},borderRadius(...r){return e.cornerRadius=r,this},borderSmoothing(r){return e.cornerSmoothing=r,this},rounded(...r){return e.cornerRadius=r,this},cornerRadius(...r){return e.cornerRadius=r,this},cornerSmoothing(r){return e.cornerSmoothing=r,this},shadow(...r){return e.shadows==null&&(e.shadows=[]),e.shadows.push(...r),this},blur(r){return t(`blur(${r}px)`),this},brightness(r){return t(`brightness(${r})`),this},contrast(r){return t(`contrast(${r})`),this},grayscale(r){return t(`grayscale(${r})`),this},huerotate(r){return t(`hue-rotate(${r})`),this},invert(r){return t(`invert(${r})`),this},saturate(r){return t(`saturate(${r})`),this},sepia(r){return t(`sepia(${r})`),this}}}function j(e={}){return{props:e,underline(t){return e.underline=t??1,this},underlineColor(t){return e.underlineColor=t,this},overline(t){return e.overline=t??1,this},overlineColor(t){return e.overlineColor=t,this},lineThrough(t){return e.lineThrough=t??1,this},lineThroughColor(t){return e.lineThroughColor=t,this},highlight(t){return e.highlightColor=t,this},offsetY(t){return e.offsetY=t,this},color(t){return e.color=t,this},size(t){return e.size=t,this},font(...t){return e.font=t,this},style(t){return e.style=t,this},weight(t){return e.weight=t,this},letterSpacing(t){return e.letterSpacing=t,this},wordSpacing(t){return e.wordSpacing=t,this},strokeColor(t){return e.strokeColor=t,this},strokeWidth(t){return e.strokeWidth=t,this},dropShadow(...t){return e.dropShadows==null&&(e.dropShadows=[]),e.dropShadows.push(...t),this}}}function Pe(e={}){return{...D(e),...j(e),nowrap(){return e.nowrap=!0,this},wrap(t){return e.nowrap=!t,this},lineHeight(t){return e.lineHeight=t,this},align(t){return e.align=t,this},indent(t){return e.indentSize=t,this},hangingIndent(t){return e.hangingIndentSize=t,this},props:e}}function ct(e){return{type:"span",children:e,...j()}}function we(e){return{...j(e),nowrap(){return e.nowrap=!0,this},wrap(t){return e.nowrap=!t,this},lineHeight(t){return e.lineHeight=t,this},align(t){return e.align=t,this},indent(t){return e.indentSize=t,this},props:e}}function mt(...e){return{type:"text-default",children:e,...we({})}}function bt(...e){return{type:"text",children:e.filter(t=>t!=null),...Pe()}}function Tt(...e){return{type:"column",children:e,...D()}}function yt(...e){return{type:"row",children:e,...D()}}function Pt(e){let t={src:e};return{type:"photo",...D(t),scaleType(a,r){if(t.scaleType=a,typeof r=="string")switch(r){case"center":t.scaleAlignment=1/2;break;case"end":t.scaleAlignment=1;break;case"start":t.scaleAlignment=0;break}else t.scaleAlignment=r;return this},preserveAspectRatio(a=!0){return t.preserveAspectRatio=a,this},flipVertical(a=!0){return t.flipVertical=a,this},flipHorizontal(a=!0){return t.flipHorizontal=a,this},fill(a){return t.fill=a,this}}}function Re(e){return{...D(e),props:e,stroke(t){return e.stroke=t,this},strokeWidth(t){return e.strokeWidth=t,this},strokeLineCap(t){return e.strokeLineCap=t,this},strokeLineJoin(t){return e.strokeLineJoin=t,this},strokeMiterLimit(t){return e.strokeMiterLimit=t,this},strokeDashArray(...t){return e.strokeDashArray=t,this},strokeDashOffset(t){return e.strokeDashOffset=t,this},fill(t){return e.fill=t,this},fillOpacity(t){return e.fillOpacity=t,this},fillRule(t){return e.fillRule=t,this},scalePath(t){return e.scalePath=t,this}}}function wt(e){let t={d:e};return{type:"path",...Re(t),props:t}}function Rt(...e){let t={};return{type:"table",children:e,...D(t),spacing(...a){return t.spacing=a,this}}}function kt(...e){return{type:"table-row",children:e,...D({})}}function xt(...e){let t={};return{type:"table-cell",children:e,...D(t),colspan(a){return t.colspan=a,this},rowspan(a){return t.rowspan=a,this},props:t}}import{encode as ke}from"uqr";function Lt(e,t={}){let a=ke(e,t),{pixelSize:r=10,whiteColor:s="white",blackColor:n="black"}=t,i=a.size*r,o=a.size*r,u=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o} ${i}" width="${o}" height="${i}">`,l=[];for(let d=0;d<a.size;d++)for(let h=0;h<a.size;h++){let p=h*r,m=d*r;a.data[d][h]&&l.push(`M${p},${m}h${r}v${r}h-${r}z`)}return u+=`<rect fill="${s}" width="${o}" height="${i}"/>`,u+=`<path fill="${n}" d="${l.join("")}"/>`,u+="</svg>",Buffer.from(u)}import{parse as te}from"gradient-parser";import{klona as it}from"klona";import at from"object.pick";import st from"p-memoize";import ut from"svg-path-bounds";import{loadYoga as lt,MeasureMode as dt}from"yoga-layout/load";var se={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};var xe=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,Se=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/,Ce=/^hsl\(\s*(\d+)\s*,\s*(\d*(?:\.\d+)?%)\s*,\s*(\d*(?:\.\d+)?%)\)$/,Le=/^hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*(\d*(?:\.\d+)?)\)$/,ve=/^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;function z(e){return e==="transparent"||e in se?!0:xe.test(e)||Se.test(e)||Ce.test(e)||Le.test(e)||ve.test(e)}function qe(e){switch(e.type){case"hex":return`#${e.value}`;case"literal":return e.value;default:return`${e.type}(${e.value.join(",")})`}}function Be(e,t,a,r){let{length:s}=e;if(!s)return 1/(t-1)*a;if(s.type==="px")return Number.parseFloat(s.value);if(s.type==="%")return r?Number.parseFloat(s.value)*r/100:Number(s.value)/100}function ue(e,t){return e.reduce((a,r,s)=>{a.colors=[...a.colors,qe(r)];let n=Be(r,e.length,s,t);return a.locations=[...a.locations,n],a},{colors:[],locations:[]})}function Ne(e,t){let{width:a}=t,{colors:r,locations:s}=ue(e,a),n=s.slice(-1)[0],i=typeof n=="number"?n:Number.parseFloat(n),o=i/a,u=Math.round(a/i),l=[];for(let h=0;h<u;h++)for(let p of s)l.push(p/a+o*h);return{colors:l.map((h,p)=>r[p%r.length]),locations:l}}function We(e){return Math.round(e*1e4)/1e4}function Ae(e){return e*Math.PI/180}var De=e=>e==null?A(180):e.type==="directional"?Me(e.value):A(Number(e.value));function A(e){let t=Ae(e),a=We(Math.abs(Math.sin(t))+Math.abs(Math.cos(t))),r={x:.5,y:.5},s=Math.sin(t-Math.PI/2)*a/2,n=Math.cos(t-Math.PI/2)*a/2;return{start:{x:r.x-n,y:r.y-s},end:{x:r.x+n,y:r.y+s}}}function Me(e){switch(e){case"top":return A(0);case"right":return A(90);case"bottom":return A(180);case"left":return A(270);case"left top":return A(315);case"left bottom":return A(225);case"right top":return A(45);case"right bottom":return A(135)}}function He(e,t){let a=[];for(let{type:r,colorStops:s,orientation:n}of e){if(r==="radial-gradient"||r==="repeating-radial-gradient")continue;let i=r==="linear-gradient"?ue(s):Ne(s,t),o=De(n),u={...i,...o};a.push(u)}return a}function I(e,t,a,r,s,n){let i=He(t,{width:s,height:n}),o=[];for(let u of i){let l=e.createLinearGradient(a+u.start.x*s,r+u.start.y*n,a+u.end.x*s,r+u.end.y*n);for(let d=0;d<u.colors.length;d++){let h=u.colors[d],p=u.locations[d];p<0&&(p=0),p>1&&(p=1),l.addColorStop(p,h)}o.push(l)}return o}import{Edge as G}from"yoga-layout/load";function O(e,t,a,r,s,n){let i=t.getComputedBorder(G.Left),o=t.getComputedBorder(G.Top),u=t.getComputedBorder(G.Right),l=t.getComputedBorder(G.Bottom);i===o&&o===u&&u===l&&i>0&&(e.save(),e.translate(s,n),e.strokeStyle=a.borderColor,e.lineJoin="round",e.lineWidth=i*2,e.clip(r),e.stroke(r),e.translate(-s,-n),e.restore())}import{getSvgPath as $e}from"figma-squircle";function E(e,t){for(let a=0;a<e.length;a++)e[a]=Math.max(0,Math.min(e[a],t/2));return e}function V(e,t,a,r,s=0,n="round"){let i=s;i>1&&(i=1),i<0&&(i=0);let o={topLeftCornerRadius:0,topRightCornerRadius:0,bottomRightCornerRadius:0,bottomLeftCornerRadius:0};if(r.length===1&&(o.topLeftCornerRadius=r[0],o.topRightCornerRadius=r[0],o.bottomRightCornerRadius=r[0],o.bottomLeftCornerRadius=r[0]),r.length===2&&(o.topLeftCornerRadius=r[0],o.bottomRightCornerRadius=r[0],o.topRightCornerRadius=r[1],o.bottomLeftCornerRadius=r[1]),r.length>2&&(o.topLeftCornerRadius=r[0],o.topRightCornerRadius=r[1]??0,o.bottomRightCornerRadius=r[2]??0,o.bottomLeftCornerRadius=r[3]??0),n==="round"){let l=$e({cornerSmoothing:i,width:t,height:a,preserveSmoothing:!0,...o});return new e.Path2D(l)}let u=new e.Path2D;return u.moveTo(o.topLeftCornerRadius,0),u.lineTo(t-o.topRightCornerRadius,0),u.lineTo(t,o.topRightCornerRadius),u.lineTo(t,a-o.bottomRightCornerRadius),u.lineTo(t-o.bottomRightCornerRadius,a),u.lineTo(o.bottomLeftCornerRadius,a),u.lineTo(0,a-o.bottomLeftCornerRadius),u.lineTo(0,o.topLeftCornerRadius),u.closePath(),u}function X(e,t,a,r,s,n){let i=a.props;if(i.image==null)return;let o=i.image,u=r.getComputedWidth(),l=r.getComputedHeight(),d=a.props.scaleType??"fill",h=o.width,p=o.height,m=s,g=n,c=u,T=l,R=o.width/o.height,k=u/l,P=i.scaleAlignment??1/2;switch(d){case"cover":if(R>k){let y=o.width*l/o.height;h=o.width,p=o.height,c=y,T=l,m=s+(u-y)*P}else{let y=o.height*u/o.width;h=o.width,p=o.height,c=u,T=y,g=n+(l-y)*P}break;case"contain":R>k?(c=u,T=u/R,g=n+(l-T)*P):(T=l,c=l*R,m=s+(u-c)*P);break}t.save();let w=V(e,u,l,E(i.cornerRadius??[0],Math.min(u,l)),i.cornerSmoothing);if(t.translate(s,n),t.clip(w),t.translate(-s,-n),i.background)for(let y of i.background)typeof y=="string"&&(t.fillStyle=y,t.fillRect(s,n,u,l));let q=i.flipHorizontal??!1,B=i.flipVertical??!1;if(q||B){let y=m+c/2,x=g+T/2;t.translate(y,x),t.scale(q?-1:1,B?-1:1),t.translate(-y,-x)}t.drawImage(o,0,0,h,p,m,g,c,T),t.restore(),(i.borderWidth!=null||i.borderTopWidth!=null||i.borderLeftWidth!=null||i.borderRightWidth!=null||i.borderBottomWidth!=null)&&O(t,r,i,w,s,n)}import{Align as W,BoxSizing as le,Direction as de,Display as _,Edge as b,FlexDirection as F,Gutter as J,Justify as $,Overflow as U,PositionType as Q,Wrap as K}from"yoga-layout/load";function fe(e,t){for(let a of Object.keys(e))switch(a){case"alignContent":t.setAlignContent(ze(e.alignContent));break;case"alignItems":t.setAlignItems(he(e.alignItems));break;case"alignSelf":t.setAlignSelf(he(e.alignSelf));break;case"aspectRatio":t.setAspectRatio(e.aspectRatio);break;case"borderBottomWidth":t.setBorder(b.Bottom,e.borderBottomWidth);break;case"borderEndWidth":t.setBorder(b.End,e.borderEndWidth);break;case"borderLeftWidth":t.setBorder(b.Left,e.borderLeftWidth);break;case"borderRightWidth":t.setBorder(b.Right,e.borderRightWidth);break;case"borderStartWidth":t.setBorder(b.Start,e.borderStartWidth);break;case"borderTopWidth":t.setBorder(b.Top,e.borderTopWidth);break;case"borderWidth":t.setBorder(b.All,e.borderWidth);break;case"borderInlineWidth":t.setBorder(b.Horizontal,e.borderInlineWidth);break;case"borderBlockWidth":t.setBorder(b.Vertical,e.borderBlockWidth);break;case"bottom":t.setPosition(b.Bottom,e.bottom);break;case"boxSizing":t.setBoxSizing(Ie(e.boxSizing));break;case"direction":t.setDirection(Ge(e.direction));break;case"display":t.setDisplay(Oe(e.display));break;case"end":t.setPosition(b.End,e.end);break;case"flex":t.setFlex(e.flex);break;case"flexBasis":t.setFlexBasis(e.flexBasis);break;case"flexDirection":t.setFlexDirection(Ee(e.flexDirection));break;case"rowGap":t.setGap(J.Row,e.rowGap);break;case"gap":t.setGap(J.All,e.gap);break;case"columnGap":t.setGap(J.Column,e.columnGap);break;case"flexGrow":t.setFlexGrow(e.flexGrow);break;case"flexShrink":t.setFlexShrink(e.flexShrink);break;case"flexWrap":t.setFlexWrap(Ve(e.flexWrap));break;case"height":t.setHeight(e.height);break;case"justifyContent":t.setJustifyContent(Fe(e.justifyContent));break;case"left":t.setPosition(b.Left,e.left);break;case"margin":t.setMargin(b.All,e.margin);break;case"marginBottom":t.setMargin(b.Bottom,e.marginBottom);break;case"marginEnd":t.setMargin(b.End,e.marginEnd);break;case"marginLeft":t.setMargin(b.Left,e.marginLeft);break;case"marginRight":t.setMargin(b.Right,e.marginRight);break;case"marginStart":t.setMargin(b.Start,e.marginStart);break;case"marginTop":t.setMargin(b.Top,e.marginTop);break;case"marginInline":t.setMargin(b.Horizontal,e.marginInline);break;case"marginBlock":t.setMargin(b.Vertical,e.marginBlock);break;case"maxHeight":t.setMaxHeight(e.maxHeight);break;case"maxWidth":t.setMaxWidth(e.maxWidth);break;case"minHeight":t.setMinHeight(e.minHeight);break;case"minWidth":t.setMinWidth(e.minWidth);break;case"overflow":t.setOverflow(Ye(e.overflow));break;case"padding":t.setPadding(b.All,e.padding);break;case"paddingBottom":t.setPadding(b.Bottom,e.paddingBottom);break;case"paddingEnd":t.setPadding(b.End,e.paddingEnd);break;case"paddingLeft":t.setPadding(b.Left,e.paddingLeft);break;case"paddingRight":t.setPadding(b.Right,e.paddingRight);break;case"paddingStart":t.setPadding(b.Start,e.paddingStart);break;case"paddingTop":t.setPadding(b.Top,e.paddingTop);break;case"paddingInline":t.setPadding(b.Horizontal,e.paddingInline);break;case"paddingBlock":t.setPadding(b.Vertical,e.paddingBlock);break;case"position":t.setPositionType(je(e.position));break;case"right":t.setPosition(b.Right,e.right);break;case"start":t.setPosition(b.Start,e.start);break;case"top":t.setPosition(b.Top,e.top);break;case"insetInline":t.setPosition(b.Horizontal,e.insetInline);break;case"insetBlock":t.setPosition(b.Vertical,e.insetBlock);break;case"inset":t.setPosition(b.All,e.inset);break;case"width":t.setWidth(e.width);break}return t}function ze(e){switch(e){case"flex-start":return W.FlexStart;case"flex-end":return W.FlexEnd;case"center":return W.Center;case"stretch":return W.Stretch;case"space-between":return W.SpaceBetween;case"space-around":return W.SpaceAround;case"space-evenly":return W.SpaceEvenly}}function he(e){switch(e){case"flex-start":return W.FlexStart;case"flex-end":return W.FlexEnd;case"center":return W.Center;case"stretch":return W.Stretch;case"baseline":return W.Baseline}}function Ie(e){switch(e){case"border-box":return le.BorderBox;case"content-box":return le.ContentBox}}function Ge(e){switch(e){case"ltr":return de.LTR;case"rtl":return de.RTL}}function Oe(e){switch(e){case"none":return _.None;case"flex":return _.Flex;case"contents":return _.Contents}}function Ee(e){switch(e){case"row":return F.Row;case"column":return F.Column;case"row-reverse":return F.RowReverse;case"column-reverse":return F.ColumnReverse}}function Ve(e){switch(e){case"wrap":return K.Wrap;case"nowrap":return K.NoWrap;case"wrap-reverse":return K.WrapReverse}}function Fe(e){switch(e){case"flex-start":return $.FlexStart;case"flex-end":return $.FlexEnd;case"center":return $.Center;case"space-between":return $.SpaceBetween;case"space-around":return $.SpaceAround;case"space-evenly":return $.SpaceEvenly}}function Ye(e){switch(e){case"visible":return U.Visible;case"hidden":return U.Hidden;case"scroll":return U.Scroll}}function je(e){switch(e){case"absolute":return Q.Absolute;case"relative":return Q.Relative;case"static":return Q.Static}}var Xe=/,(?![^(]*\))/,_e=/\s(?![^(]*\))/,Je=/^[0-9]+[a-zA-Z%]+?$/;function Ue(e){let t=e.split(_e),a=t.includes("inset"),r=t.slice(-1)[0],s=Qe(r)?void 0:r,n=t.filter(d=>d!=="inset").filter(d=>d!==s).map(Ke),[i,o,u,l]=n;return{inset:a,offsetX:Number(i),offsetY:Number(o),blurRadius:Number(u),spreadRadius:l==null?void 0:Number(l),color:s}}function Qe(e){return e==="0"||Je.test(e)}function Ke(e){if(!/px$/.test(e)&&e!=="0")return e;let t=Number.parseFloat(e);return Number.isNaN(t)?e:t}var Y=e=>e.split(Xe).map(t=>t.trim()).map(Ue);import{dequal as tt}from"dequal";import{klona as rt}from"klona";import{Edge as M}from"yoga-layout/load";function Ze(e){let t=e.font!=null?e.font?.join(", "):"",a=e.size??"",r=e.weight??"";return`${e.style??""} ${r} ${a}px ${t}`.trim()}function Z(e,t){e.font=Ze(t),t.letterSpacing!=null&&(e.letterSpacing=`${t.letterSpacing}px`),t.wordSpacing!=null&&(e.wordSpacing=`${t.wordSpacing}px`),t.color!=null&&typeof t.color=="string"&&(e.fillStyle=t.color)}function pe(e,t){let a=[],r=e.indexOf(t);for(;r!==-1;)a.push(r),r=e.indexOf(t,r+1);return a}var et=/^\s+$/;function ee(e){return e.length===0?!1:et.test(e)}function nt(e,t,a,r,s){let n=r.lineHeight==null||Number.isNaN(r.lineHeight)?1:r.lineHeight,i=[],o={baseline:0,height:0,width:r.indentSize??0,segments:[],spacesCount:0};i.push(o);for(let p=0;p<e.length;p++){let m=e[p],g=typeof m=="string"?r:m.props,c=typeof m=="string"?m:m.children,T=t[p]||[];if(T.length===0){let k=s(c,g),P=k.width,w=k.fontBoundingBoxAscent+k.fontBoundingBoxDescent;if(o.width+P>a&&o.segments.length>0){o={baseline:0,height:0,width:0,segments:[],spacesCount:0},i.push(o);let B=c.trimStart();if(B!==c){let y=s(B,g);P=y.width,w=y.fontBoundingBoxAscent+y.fontBoundingBoxDescent;let x={metrics:y,props:g,text:B,width:P,height:w};o.segments.push(x),o.width+=P,o.height=Math.max(o.height,w),o.baseline=Math.max(o.baseline,y.fontBoundingBoxAscent);continue}}let q={metrics:k,props:g,text:c,width:P,height:w};o.segments.push(q),o.width+=P,o.height=Math.max(o.height,w),o.baseline=Math.max(o.baseline,k.fontBoundingBoxAscent);continue}let R=0;for(let k=0;k<T.length;k++){let P=T[k],w=c.substring(R,P);if(w.length===0){R=P;continue}let q=s(w,g),B=q.width,y=q.fontBoundingBoxAscent+q.fontBoundingBoxDescent;if(o.width+B>a&&o.segments.length>0){if(o.segments.length>0){let S=o.segments[o.segments.length-1],C=S.text.trimEnd();if(C!==S.text&&C.length>0){let L=s(C,S.props),N=L.width,H=L.fontBoundingBoxAscent+L.fontBoundingBoxDescent;S.text=C,S.metrics=L,S.width=N,S.height=H,o.width=o.segments.reduce((ae,v)=>ae+v.width,0)}}o={baseline:0,height:0,width:r.hangingIndentSize??0,segments:[],spacesCount:0},i.push(o);let f=w.trimStart();if(f!==w){if(f.length===0){R=P;continue}let S=s(f,g),C=S.width,L=S.fontBoundingBoxAscent+S.fontBoundingBoxDescent,N={metrics:S,props:g,text:f,width:C,height:L};o.segments.push(N),o.width+=C,o.height=Math.max(o.height,L),o.baseline=Math.max(o.baseline,S.fontBoundingBoxAscent),R=P;continue}}let x={metrics:q,props:g,text:w,width:B,height:y};o.segments.push(x),o.width+=B,o.height=Math.max(o.height,y),o.baseline=Math.max(o.baseline,q.fontBoundingBoxAscent),R=P}if(R<c.length){let k=c.substring(R),P=s(k,g),w=P.width,q=P.fontBoundingBoxAscent+P.fontBoundingBoxDescent;if(o.width+w>a&&o.segments.length>0){if(o.segments.length>0){let x=o.segments[o.segments.length-1],f=x.text.trimEnd();if(f!==x.text&&f.length>0){let S=s(f,x.props),C=S.width,L=S.fontBoundingBoxAscent+S.fontBoundingBoxDescent;x.text=f,x.metrics=S,x.width=C,x.height=L,o.width=o.segments.reduce((N,H)=>N+H.width,0)}}o={baseline:0,height:0,width:0,segments:[],spacesCount:0},i.push(o);let y=k.trimStart();if(y!==k){if(y.length===0)continue;let x=s(y,g),f=x.width,S=x.fontBoundingBoxAscent+x.fontBoundingBoxDescent,C={metrics:x,props:g,text:y,width:f,height:S};o.segments.push(C),o.width+=f,o.height=Math.max(o.height,S),o.baseline=Math.max(o.baseline,x.fontBoundingBoxAscent);continue}}let B={metrics:P,props:g,text:k,width:w,height:q};o.segments.push(B),o.width+=w,o.height=Math.max(o.height,q),o.baseline=Math.max(o.baseline,P.fontBoundingBoxAscent)}}for(let p of i){let m=[];for(let g=0;g<p.segments.length;g++){let c=p.segments[g];if(ee(c.text)&&(g===p.segments.length-1||g===0)){p.width-=c.width;continue}m.push(c)}p.segments=m}let u=0;for(let p of i){p.baseline*=n,p.height*=n;let m=0,g=Number.POSITIVE_INFINITY;for(let c of p.segments){let T=c.props.offsetY??0;T>m&&(m=T),T<g&&(g=T)}if(p.baseline-=g,p.height-=g,p.height+=m,u<i.length-1)for(let c of p.segments){let T=c.text.match(/[ ]/);T&&(p.spacesCount+=T.length)}u++}let l=0,d=0;for(let p of i)l+=p.height,d=Math.max(d,p.width);let h=0;if(i.length>0&&r.lineHeight!=null&&!Number.isNaN(r.lineHeight)){let p=Math.max(0,r.lineHeight-1);for(let m of i[0].segments){let g=m.metrics,c=-((g.fontBoundingBoxAscent-g.fontBoundingBoxDescent)/2)*p;c<h&&(h=c)}}return{width:d,height:l,lines:i,offsetY:h}}function ot(e,t){let a=[[]];for(let s of e){let n=typeof s=="string"?s:s.children,i=pe(n,` `);if(i.length===0){a[a.length-1].push(s);continue}i.length>0&&i[i.length-1]!==n.length&&i.push(n.length);let o=0;for(let u=0;u<i.length;u++){let l=i[u],d=n.slice(o,l);if(typeof s=="string")a[a.length-1].push(d);else{let h=rt(s);h.children=d,a[a.length-1].push(h)}u<i.length-1&&a.push([]),o=l+1}}let r=[];for(let s of a){let n=[];for(let i of s){let o=typeof i=="string"?i:i.children;n.push(Array.from(t(o)))}r.push(n)}return[a,r]}function ge(e,t,a,r,s){let[n,i]=ot(e,s),o=[];for(let u=0;u<n.length;u++){let l=i[u],d=n[u],h=nt(d,l,t,a,r);for(let p of h.lines){let m=[[]];for(let c of p.segments){let T=m[m.length-1];if(T.length>0){let R=T[T.length-1];if(a.align==="justify"&&ee(c.text)){m.push([c]),m.push([]);continue}if(!tt(R.props,c.props)){m.push([c]);continue}}T.push(c)}let g=[];for(let c of m){if(c.length===0)continue;if(c.length===1){g.push(c[0]);continue}let T=c.slice(1).reduce((R,k)=>({metrics:R.metrics,text:R.text+k.text,height:Math.max(R.height,k.height),width:R.width+k.width,props:R.props}),c[0]);g.push(T)}p.segments=g}o.push({paragraph:h})}return o}function ce(e,t,a,r,s,n){let{props:i}=a,{blocks:o}=i;if(o==null)return;let u=r.getComputedBorder(M.Left)+r.getComputedBorder(M.Right)+r.getComputedPadding(M.Left)+r.getComputedPadding(M.Right),l=0;for(let{paragraph:d}of o){d.width=Math.max(r.getComputedWidth(),d.width)-u;let h=i.boxSizing==="content-box"?r.getComputedPadding(M.Left):0,p=i.boxSizing==="content-box"?r.getComputedPadding(M.Top):0,m=r.getComputedBorder(M.Left),g=r.getComputedBorder(M.Top),c=h+m,T=p+g,R=i.align;Z(t,i);let k=d.offsetY+l;l+=d.height;for(let P=0;P<d.lines.length;P++){let w=d.lines[P],q=d.width-w.width,B=R==="justify"&&q>0&&w.spacesCount>0?q/w.spacesCount:0,y=0;switch(R){case"center":y=(d.width-w.width)/2;break;case"right":y=d.width-w.width;break;case"left":case"justify":P===0&&i.indentSize!=null&&(y+=i.indentSize),P>0&&i.hangingIndentSize!=null&&(y+=i.hangingIndentSize);break}for(let x=0;x<w.segments.length;x++){let f=w.segments[x],S=f.props.offsetY??0,C=f.width;R==="justify"&&/[ ]/.test(f.text)&&(C+=B);let L=s+c+y,N=n+w.baseline+T+k+S;if(typeof f.props.underline=="number"&&f.props.underline!==0){typeof f.props.color=="string"&&(t.fillStyle=f.props.underlineColor??f.props.color);let v=f.height*f.props.underline/18;t.fillRect(L,N+v,C,v)}if(typeof f.props.overline=="number"&&f.props.overline!==0){typeof f.props.color=="string"&&(t.fillStyle=f.props.overlineColor??f.props.color);let v=f.height*f.props.overline/18;t.fillRect(L,N-f.metrics.fontBoundingBoxAscent,C,v)}let H=N-f.height+f.metrics.fontBoundingBoxDescent;if(f.props.highlightColor!=null&&(t.fillStyle=f.props.highlightColor,t.fillRect(L,H,C,f.height)),Z(t,f.props),f.props.dropShadows)for(let v of f.props.dropShadows)typeof v!="string"&&(t.save(),t.shadowOffsetX=v.offsetX,t.shadowOffsetY=v.offsetY,t.shadowBlur=v.blurRadius,v.color&&(t.shadowColor=v.color,t.fillStyle=v.color),t.fillText(f.text,L,N),t.restore());if(t.save(),f.props.strokeColor!=null&&f.props.strokeWidth!=null&&f.props.strokeWidth!==0&&(t.strokeStyle=f.props.strokeColor,t.lineJoin="round",t.miterLimit=2,t.lineWidth=f.props.strokeWidth,t.strokeText(f.text,L,N)),typeof f.props.color!="string"&&Array.isArray(f.props.color))for(let v of f.props.color){let[ye]=I(t,[v],s,n,f.width,f.height);t.fillStyle=ye}if(t.fillText(f.text,L,N),t.restore(),typeof f.props.lineThrough=="number"&&f.props.lineThrough!==0){typeof f.props.color=="string"&&(t.fillStyle=f.props.lineThroughColor??f.props.color);let v=f.height*f.props.lineThrough/18;t.fillRect(L,N-(f.metrics.fontBoundingBoxAscent-f.metrics.fontBoundingBoxDescent)/2,C,v)}e.debug().text&&(t.save(),t.lineWidth=e.dpr()*2,t.strokeStyle="cyan",t.strokeRect(L,H,C,f.height),t.restore()),y+=C}k+=w.height}}}var ht=lt(),lr={size:11,color:"black",font:["sans-serif"],style:"normal",weight:400,letterSpacing:0,nowrap:!1,lineHeight:Number.NaN,indentSize:0,hangingIndentSize:0,align:"left",strokeColor:"black",strokeWidth:0,wordSpacing:0,blocks:[],offsetY:0,underline:0,underlineColor:null,overline:0,overlineColor:null,lineThrough:0,lineThroughColor:null,highlightColor:null,dropShadows:[]};function re(e){return Object.fromEntries(Object.entries(e).filter(([t,a])=>a!=null))}function ne(e,t){let a=e.props,r=t.width/t.height;a.preserveAspectRatio&&(typeof a.width=="number"&&typeof a.height!="number"&&(a.height=Math.round(a.width/r)),typeof a.height=="number"&&typeof a.width!="number"&&(a.width=Math.round(a.height*r))),a.width==null&&(a.width=t.width),a.height==null&&(a.height=t.height),a.image=t}async function ie(e,{defaultTextProps:t,loadImage:a,breakIterator:r}){if(e==null)return;if(e.type!=="text-default"){if(e.props.shadows!=null&&Array.isArray(e.props.shadows)){let n=[];for(let i of e.props.shadows)typeof i=="string"?n.push(...Y(i)):n.push(i);e.props.shadows=n}if(e.props.background!=null&&Array.isArray(e.props.background)){let n=[];for(let i of e.props.background){if(typeof i=="string"){if(!z(i)){let o=te(i);n.push(...o);continue}}else i.type==="photo"&&(typeof i.props.src=="string"||Buffer.isBuffer(i.props.src))&&ne(i,await a(i.props.src));n.push(i)}e.props.background=n}}if(e.type==="table-row"&&e.props.flexDirection==null&&(e.props.flexDirection="row"),e.type==="text"){if(e.props.flexShrink==null&&(e.props.flexShrink=1),e.props.boxSizing==null&&(e.props.boxSizing="content-box"),e.props={...t,...re(e.props)},e.props.dropShadows!=null&&Array.isArray(e.props.dropShadows)){let n=[];for(let i of e.props.dropShadows)typeof i=="string"?n.push(...Y(i)):n.push(i);e.props.dropShadows=n}return typeof e.props.color=="string"&&(z(e.props.color)||(e.props.color=te(e.props.color))),e.children.map(n=>{if(typeof n=="string")return n;let i=at(e.props,["size","color","font","style","weight","letterSpacing","wordSpacing","strokeColor","strokeWidth","underline","underlineColor","overline","overlineColor","lineThrough","lineThroughColor","highlightColor","dropShadows"]);if(n.props={...re(i),...n.props},n.props.dropShadows!=null&&Array.isArray(n.props.dropShadows)){let o=[];for(let u of n.props.dropShadows)typeof u=="string"?o.push(...Y(u)):o.push(u);n.props.dropShadows=o}return typeof n.props.color=="string"&&(z(n.props.color)||(n.props.color=te(n.props.color))),n}),e}if(e.type==="photo")return typeof e.props.src=="string"||Buffer.isBuffer(e.props.src)?(ne(e,await a(e.props.src)),e):void 0;if(e.type==="row"&&e.props.flexDirection==null&&(e.props.flexDirection="row"),e.type!=="text-default"&&e.props.background!=null){for(let n of e.props.background)if(typeof n!="string"&&n.type==="photo"&&(typeof n.props.src=="string"||Buffer.isBuffer(n.props.src)))return ne(n,await a(n.props.src)),e}if(e.type==="path")return e.props.d&&(e.props.bounds=ut(e.props.d)),e;let s=[];for(let n of e.children)if(n!=null){if(n.type==="text-default"){let i={...t,...re(n.props)};for(let o of n.children)o!=null&&s.push(await ie(o,{defaultTextProps:i,loadImage:a,breakIterator:r}));continue}s.push(await ie(n,{defaultTextProps:t,loadImage:a,breakIterator:r}))}if(e.children=s.filter(n=>n!=null),e.type==="table"&&e.props.spacing!=null&&Array.isArray(e.props.spacing)){let[n,i]=e.props.spacing;i=i??n;for(let o of e.children)if(o!=null)for(let u of o.children){if(u==null)return;u.type!=="text-default"&&(u.props.paddingLeft==null&&(u.props.paddingLeft=n),u.props.paddingRight==null&&(u.props.paddingRight=n),u.props.paddingTop==null&&(u.props.paddingTop=i),u.props.paddingBottom==null&&(u.props.paddingBottom=i))}}return e}function me(e){if(e==null||e.type==="photo"||e.type==="path")return;if(e.type==="text"){let a=new Set;for(let r of e.children)if(typeof r!="string"&&r.props.font!=null)for(let s of r.props.font)a.add(s);if(e.props.font!=null)for(let r of e.props.font)a.add(r);return a}let t=new Set;for(let a of e.children){let r=me(a);if(r!=null)for(let s of r)t.add(s)}return t}function be(e,t,a){if(e==null)return;if(e.type==="text-default")throw new Error("The layout includes TextDefaut node which is illegal!");let r=a.Node.create();if(fe(e.props,r),e.type==="photo")return r;if(e.type==="text"){let s=(n,i)=>{let{props:o,children:u}=e,l=ge(u,n,o,t.measureText,t.breakIterator);e.props.blocks=l;let d=0,h=0;for(let{paragraph:p}of l)p.width>d&&(d=p.width),h+=p.height;return i===dt.AtMost&&(d=Math.min(n,d)),{width:d,height:h}};return r.setMeasureFunc(s),r}if(e.type==="path"){if(e.props.bounds!=null){let[s,n,i,o]=e.props.bounds,u=e.props.scalePath??1;if(e.props.width==null){let l=i-s;r.setWidth(l*u)}if(e.props.height==null){let l=o-n;r.setHeight(l*u)}}return r}for(let s of e.children){if(s==null)continue;let n=be(s,t,a);n!=null&&r.insertChild(n,r.getChildCount())}if(e.type==="table"){let s=[];for(let n=0;n<r.getChildCount();n++){let i=0;for(let o=0;o<r.getChild(n).getChildCount();o++){s.length-1<o&&s.push(0);let u=r.getChild(n).getChild(o);u.calculateLayout(void 0,void 0);let l=u.getComputedWidth(),d=u.getComputedHeight();i<d&&(i=d),s[o]<l&&(s[o]=l)}for(let o=0;o<r.getChild(n).getChildCount();o++)r.getChild(n).getChild(o).setMinHeight(i)}for(let n=0;n<r.getChildCount();n++)for(let i=0;i<r.getChild(n).getChildCount();i++)r.getChild(n).getChild(i).setMinWidth(s[i])}return r}async function dr(e,t,a){let r=await ht,s=me(e);if(s!=null)for(let h of s)h!=="serif"&&h!=="sans-serif"&&h!=="monospace"&&(t.hasFont(h)||console.warn(`${JSON.stringify(h)} font has not been registered!`));let n=a==null||a.cache==null?new Map:a.cache,i=await ie(it(e),{defaultTextProps:t.getDefaultTextProps(),loadImage:st(t.loadImage,{cache:n}),breakIterator:t.breakIterator});(a==null||a.cache==null)&&n.clear();let o=be(i,t,r);if(o==null)throw new Error("Unable to create canvas!");o.calculateLayout(a?.width,a?.height);let u=t.createCanvas(o.getComputedWidth(),o.getComputedHeight()),l=u.getContext("2d");a?.background&&(l.fillStyle=a.background,l.fillRect(0,0,u.width,u.height));function d(h,p,m,g){if(h!=null)try{if(l.save(),h.type!=="text-default"&&Te(l,h,p,m,g),h.type==="text-default")return;if(h.type==="text"){oe(t,l,h,p,m,g),ce(t,l,h,p,m,g);return}if(h.type==="photo"){X(t,l,h,p,m,g);return}if(h.type==="path"){oe(t,l,h,p,m,g),pt(t,l,h,m,g);return}oe(t,l,h,p,m,g);for(let c=0;c<h.children.length;c++){let T=p.getChild(c),R=h.children[c];d(R,T,m+T.getComputedLeft(),g+T.getComputedTop())}h.type==="table"&&gt(t,l,h,p,m,g)}finally{l.restore(),t.debug().layout&&ft(t,l,h,p,m,g)}}return d(i,o,0,0),o.freeRecursive(),u}function oe(e,t,a,r,s,n){let i=r.getComputedWidth(),o=r.getComputedHeight(),u=a.props,l=V(e,i,o,E(u.cornerRadius??[0],Math.min(i,o)),u.cornerSmoothing,u.corner);if(u.background!=null&&u.shadows)for(let d of u.shadows)typeof d!="string"&&(t.save(),t.shadowOffsetX=d.offsetX,t.shadowOffsetY=d.offsetY,t.shadowBlur=d.blurRadius,d.color&&(t.shadowColor=d.color,t.fillStyle=d.color),t.translate(s,n),t.fill(l),t.restore());if(t.save(),t.translate(s,n),t.clip(l),t.translate(-s,-n),u.background!=null)for(let d of u.background){if(typeof d=="string"){t.fillStyle=d,t.fillRect(s,n,i,o);continue}if(d.type==="photo"){t.save(),Te(t,d,r,s,n),X(e,t,d,r,s,n),t.restore();continue}let[h]=I(t,[d],s,n,i,o);t.fillStyle=h,t.fillRect(s,n,i,o)}return t.restore(),O(t,r,u,l,s,n),l}function Te(e,t,a,r,s){if(t==null||t.type==="text-default")return;typeof t.props.opacity=="number"&&(e.globalAlpha=t.props.opacity);let{translateX:n,translateY:i}=t.props;e.translate(n??0,i??0);let o=r+a.getComputedWidth()/2,u=s+a.getComputedHeight()/2,l=t.props.rotation;typeof l=="number"&&l!==0&&(e.translate(o,u),e.rotate(l*Math.PI/180),e.translate(-o,-u));let d=t.props.scale;if(d!=null&&Array.isArray(d)&&(e.translate(o,u),e.scale(d[0],d[1]),e.translate(-o,-u)),t.props.filters!=null&&Array.isArray(t.props.filters)){let h=t.props.filters.join(" ");e.filter=h}}function ft(e,t,a,r,s,n){if(a==null||a.type==="text-default")return;t.save(),t.lineWidth=2,t.strokeStyle="cyan",t.strokeRect(s,n,r.getComputedWidth(),r.getComputedHeight());let i=a.props.tag!=null?`${a.type}:${a.props.tag}`:a.type;t.font=`${20*e.dpr()}px monospace`;let o=t.measureText(i);t.fillStyle="rgba(0,255,255,.6)",t.fillRect(s,n,o.width,o.fontBoundingBoxAscent+o.fontBoundingBoxDescent),t.strokeStyle="cyan",t.strokeRect(s,n,o.width,o.fontBoundingBoxAscent+o.fontBoundingBoxDescent),t.fillStyle="black",t.textBaseline="top",t.fillText(i,s,n),t.restore()}function pt(e,t,a,r,s){t.save();let{props:n}=a,{d:i}=n;if(!i){t.restore();return}let o=new e.Path2D(i);if(t.translate(r,s),n.bounds){let[u,l]=n.bounds;t.scale(n.scalePath??1,n.scalePath??1),t.translate(-u,-l)}if(n.fill!=null){if(t.fillStyle=n.fill,n.fillOpacity!=null){let u=t.globalAlpha;t.globalAlpha=u*n.fillOpacity}n.fillRule?t.fill(o,n.fillRule):t.fill(o),n.fillOpacity!=null&&(t.globalAlpha=t.globalAlpha/n.fillOpacity)}n.stroke!=null&&(t.strokeStyle=n.stroke,n.strokeWidth!=null&&(t.lineWidth=n.strokeWidth),n.strokeLineCap&&(t.lineCap=n.strokeLineCap),n.strokeLineJoin&&(t.lineJoin=n.strokeLineJoin),n.strokeMiterLimit!=null&&(t.miterLimit=n.strokeMiterLimit),n.strokeDashArray!=null&&t.setLineDash(n.strokeDashArray),n.strokeDashOffset!=null&&(t.lineDashOffset=n.strokeDashOffset),t.stroke(o)),t.restore()}function gt(e,t,a,r,s,n){t.save();let i=0;a.props.borderColor!=null&&(t.strokeStyle=a.props.borderColor),a.props.borderWidth!=null&&(t.lineWidth=a.props.borderWidth,i=a.props.borderWidth);let o=0,u=-1;t.beginPath();for(let l=0;l<r.getChildCount();l++){let d=r.getChild(l);(u===-1||d.getChildCount()>r.getChild(u).getChildCount())&&(u=l),l!==r.getChildCount()-1&&(t.moveTo(s,n+d.getComputedHeight()+o+i),t.lineTo(s+r.getComputedWidth(),n+d.getComputedHeight()+o+i),o+=d.getComputedHeight())}if(u!==-1){let l=r.getChild(u),d=0;for(let h=0;h<l.getChildCount();h++){let p=l.getChild(h);h>0&&(t.moveTo(s+d+i,n),t.lineTo(s+d+i,n+r.getComputedHeight())),d+=p.getComputedWidth()}}t.stroke(),t.restore()}export{Tt as Column,lr as DEFAULT_TEXT_PROPS,wt as Path,Pt as Photo,yt as Row,ct as Span,Rt as Table,xt as TableCell,kt as TableRow,bt as Text,mt as TextDefault,ie as compile,be as createLayoutNode,oe as drawLayoutNode,me as findFonts,Re as pathPropsBuilder,Lt as qrcode,dr as render};