Socket
Socket
Sign inDemoInstall

satori

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

satori - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

4

dist/esm/index.js

@@ -1,3 +0,3 @@

var it=Object.defineProperty,Ut=Object.defineProperties,zt=Object.getOwnPropertyDescriptor,Xt=Object.getOwnPropertyDescriptors,Ht=Object.getOwnPropertyNames,Tt=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var It=(t,r,e)=>r in t?it(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Z=(t,r)=>{for(var e in r||(r={}))Lt.call(r,e)&&It(t,e,r[e]);if(Tt)for(var e of Tt(r))Vt.call(r,e)&&It(t,e,r[e]);return t},wt=(t,r)=>Ut(t,Xt(r)),Jt=t=>it(t,"__esModule",{value:!0});var At=(t,r)=>()=>(t&&(r=t(t=0)),r);var jt=(t,r)=>{for(var e in r)it(t,e,{get:r[e],enumerable:!0})},Kt=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Ht(r))!Lt.call(t,s)&&(e||s!=="default")&&it(t,s,{get:()=>r[s],enumerable:!(i=zt(r,s))||i.enumerable});return t};var qt=(t=>(r,e)=>t&&t.get(r)||(e=Kt(Jt({}),r,1),t&&t.set(r,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var u=At(()=>{});var Ct={};jt(Ct,{default:()=>Qt});import*as Zt from"yoga-layout-prebuilt";var Qt,Ft=At(()=>{u();Qt=Zt});u();u();u();var at;{let t=(Ft(),qt(Ct));t.default?at=t.default:at=t}function te(t){at=t}function Y(){return at}u();u();function ut(t){let r=typeof t;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function Ot(t){return/^class\s/.test(Function.prototype.toString.call(t))}function Q(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}function v(t,r,e){let i=r[t];return typeof i=="undefined"?e:i}u();u();var Nt={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};u();var ee=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function ct(t){let r={};for(let e in t)ee.has(e)&&(r[e]=t[e]);return r}u();import{getPropertyName as kt,getStylesForProperty as re}from"css-to-react-native";import Gt from"parse-css-dimension";import{parseElementStyle as ne}from"css-background-parser";var oe=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),vt=[1,0,0,1,0,0];function ie(t,r){return typeof r=="number"?oe.has(t)?String(r):r+"px":r}function Wt(t,r){if(typeof t=="number")return t;try{let e=new Gt(t);if(e.type==="length")switch(e.unit){case"em":return e.value*r;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function st(t,r){let e=[];for(let o in t){let n=kt(o);e.push([n,ie(n,t[o])])}let i=e.reduce((o,n)=>{let a=kt(n[0]),f=n[1];return Object.assign(o,re(a,f,!0))},{});if(i.backgroundImage){let{backgrounds:o}=ne(i);i.backgroundImage=o}let s=i.fontSize||r.fontSize;if(typeof s=="string")try{let o=new Gt(s);switch(o.unit){case"em":s=o.value*r.fontSize;break;case"rem":s=o.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s);for(let o in i){let n=i[o];if(typeof n=="string"){let a=Wt(n,s);typeof a!="undefined"&&(i[o]=a),n=i[o]}if(o==="opacity"&&(n=i[o]=n*r.opacity),o==="transform"){let a=[...vt],f=n;for(let m of f){let y=Object.keys(m)[0],p=m[y],d=typeof p=="string"?Wt(p,s):p,g=[...vt];switch(y){case"translateX":g[4]=d;break;case"translateY":g[5]=d;break;case"scaleX":g[0]=d;break;case"scaleY":g[3]=d;break;case"rotate":let c=d*Math.PI/180,E=Math.cos(c),T=Math.sin(c);g[0]=E,g[1]=T,g[2]=-T,g[3]=E;break;case"skewX":g[2]=Math.tan(d*Math.PI/180);break;case"skewY":g[1]=Math.tan(d*Math.PI/180);break}a=Q(g,a)}i.transform=a}}return i}function mt(t,r,e,i,s){let o=Y(),n=Z(Z(Z({},e),st(Nt[r],e)),st(i,e));if(r==="img"){let a=parseInt(s.width),m=parseInt(s.height)/a;n.width||(n.width=a),n.height||(n.height=m*n.width)}return t.setDisplay(v(n.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),t.setAlignContent(v(n.alignContent,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,"space-between":o.ALIGN_SPACE_BETWEEN,"space-around":o.ALIGN_SPACE_AROUND,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),t.setAlignItems(v(n.alignItems,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_FLEX_START)),t.setAlignSelf(v(n.alignSelf,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),t.setJustifyContent(v(n.justifyContent,{center:o.JUSTIFY_CENTER,"flex-start":o.JUSTIFY_FLEX_START,"flex-end":o.JUSTIFY_FLEX_END,"space-between":o.JUSTIFY_SPACE_BETWEEN,"space-around":o.JUSTIFY_SPACE_AROUND},o.JUSTIFY_FLEX_START)),t.setFlexDirection(v(n.flexDirection,{row:o.FLEX_DIRECTION_ROW,column:o.FLEX_DIRECTION_COLUMN,"row-reverse":o.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":o.FLEX_DIRECTION_COLUMN_REVERSE},o.FLEX_DIRECTION_ROW)),t.setFlexWrap(v(n.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&t.setFlexBasis(n.flexBasis),t.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),t.setFlexShrink(typeof n.flexShrink=="undefined"?1:n.flexShrink),typeof n.maxHeight!="undefined"&&t.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&t.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&t.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&t.setMinWidth(n.minWidth),t.setOverflow(v(n.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),t.setMargin(o.EDGE_TOP,n.marginTop||0),t.setMargin(o.EDGE_BOTTOM,n.marginBottom||0),t.setMargin(o.EDGE_LEFT,n.marginLeft||0),t.setMargin(o.EDGE_RIGHT,n.marginRight||0),t.setBorder(o.EDGE_TOP,n.borderWidth||0),t.setBorder(o.EDGE_BOTTOM,n.borderWidth||0),t.setBorder(o.EDGE_LEFT,n.borderWidth||0),t.setBorder(o.EDGE_RIGHT,n.borderWidth||0),t.setPadding(o.EDGE_TOP,n.paddingTop||0),t.setPadding(o.EDGE_BOTTOM,n.paddingBottom||0),t.setPadding(o.EDGE_LEFT,n.paddingLeft||0),t.setPadding(o.EDGE_RIGHT,n.paddingRight||0),t.setPositionType(v(n.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&t.setPosition(o.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&t.setPosition(o.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&t.setPosition(o.EDGE_LEFT,n.left),typeof n.right!="undefined"&&t.setPosition(o.EDGE_RIGHT,n.right),typeof n.height!="undefined"?t.setHeight(n.height):t.setHeightAuto(),typeof n.width!="undefined"?t.setWidth(n.width):t.setWidthAuto(),[n,ct(n)]}u();import{LineBreaker as ae}from"css-line-break";import{splitGraphemes as se}from"text-segmentation";u();u();function et({left:t,top:r,width:e,height:i},s,o){let n;if(o)n=s;else{let a=t+e/2,f=r+i/2;n=Q([1,0,0,1,a,f],Q(s,[1,0,0,1,-a,-f])),s.__parent&&(n=Q(s.__parent,n)),s.splice(0,6,...n)}return`matrix(${n.map(a=>a.toFixed(2)).join(",")})`}function Pt({left:t,top:r,width:e,height:i,isInheritingTransform:s},o){let n="",a=1;return o.transform&&(n=et({left:t,top:r,width:e,height:i},o.transform,s)),o.opacity&&(a=+o.opacity),{matrix:n,opacity:a}}function pt({id:t,content:r,filter:e,left:i,top:s,width:o,height:n,matrix:a,opacity:f,image:m,debug:y},p){let d="";return y&&(d=`<rect x="${i}" y="${s}" width="${o}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),m?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${m}" x="${i}" y="${s}" width="${o}" height="${n}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${e?"</g>":""}${d}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${s}" width="${o}" height="${n}" fill="${p.color}" font-weight="${p.fontWeight}" font-style="${p.fontStyle}" font-size="${p.fontSize}" font-family="${p.fontFamily}" ${p.letterSpacing?`letter-spacing="${p.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${r}</text>${e?"</g>":""}${d}`}u();function K({id:t,width:r,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-s,0),n=Math.max(i.shadowOffset.width+s+r,r),a=Math.min(i.shadowOffset.height-s,0),f=Math.max(i.shadowOffset.height+s+e,e);return`<defs><filter id="satori_s-${t}" x="${o/r*100}%" y="${a/e*100}%" width="${(n-o)/r*100}%" height="${(f-a)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var rt=void 0,gt=typeof Intl!="undefined"&&"Segmenter"in Intl,fe=gt?new Intl.Segmenter(rt,{granularity:"word"}):null,le=gt?new Intl.Segmenter(rt,{granularity:"grapheme"}):null,ue=[32,160,4961,65792,65793,4153,4241],ce=t=>{let r=ae(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=r.next()).done;)if(i.value){let s=i.value.slice(),o=[].map.call(s,a=>a.codePointAt(0)),n="";o.forEach(a=>{ue.includes(a)?(n.length&&e.push(n),e.push(String.fromCodePoint(a)),n=""):n+=String.fromCodePoint(a)}),n.length&&e.push(n)}return e};function dt(t,r){return gt?r==="word"?[...fe.segment(t)].map(e=>e.segment):[...le.segment(t)].map(e=>e.segment):r==="word"?ce(t):se(t)}function*ht(t,r){let e=Y(),{parentStyle:i,parent:s,font:o,id:n,isInheritingTransform:a,debug:f,embedFont:m,graphemeImages:y}=r;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(rt):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(rt):i.textTransform==="capitalize"&&(t=dt(t,"word").map(x=>dt(x,"grapheme").map((L,G)=>G===0?L.toLocaleUpperCase(rt):L).join("")).join(""));let p=v(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),d=dt(t,p),g=e.Node.create();g.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?g.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?g.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?g.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&g.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),s.insertChild(g,s.getChildCount());let c=o.getFont(i),E=c.ascender/c.unitsPerEm*i.fontSize,T=-(c.descender/c.unitsPerEm)*i.fontSize,h=(E+T)*1.2,{textAlign:$}=i,C=[],M=[],O=[];g.setMeasureFunc(x=>{let L=[],G="",P=0,J="",A=0,q=0,tt=-1;C=[],M=[0];for(let B=0;B<d.length;B++){let D=d[B];if([" ",`
`," ","\u3000"].includes(D))G+=D,P=o.measure(c,G,i),O[B]=null;else{let j=y&&y[D]?i.fontSize:o.measure(c,D,i);A||(G="",P=0);let _t=P||",.!?:-@)>]}%#".indexOf(D[0])<0,Rt=!A||!!P;_t&&A+P+j>x?(C.push(A),L.push(J),J=D,A=j,M.push(1),tt=-1):(J+=G+D,A+=P+j,Rt&&M[M.length-1]++),G="",P=0,Rt&&tt++,q=Math.max(q,A),O[B]={y:L.length*h,x:A-j,width:j,line:L.length,lineIndex:tt}}}return A&&(L.push(J),C.push(A)),L.length>1&&(q=x),{width:q,height:L.length*h}});let[U,z]=yield,X="";i.position==="absolute"&&g.calculateLayout();let{left:H,top:N,width:F,height:W}=g.getComputedLayout(),w=U+H,k=z+N,{matrix:V,opacity:l}=Pt({left:H,top:N,width:F,height:W,isInheritingTransform:a},i),b="";i.textShadowOffset&&(b=K({width:F,height:W,id:n},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let S="";for(let x=0;x<d.length;x++){if(!O[x])continue;let L=d[x],G=null,P=null,J=O[x].y,A=O[x].x,q=O[x].width,tt=h,B=F-C[O[x].line];if($==="right"||$==="end")A+=B;else if($==="center")A+=B/2;else if($==="justify"){let D=O[x].line;if(D<C.length-1){let j=M[D];A+=(j>1?B/(j-1):0)*O[x].lineIndex}}y&&y[L]?P=y[L]:m?G=o.getSVG(c,L,wt(Z({},i),{left:w+A,top:k+J,letterSpacing:i.letterSpacing})):J+=E,G?S+=G+" ":X+=pt({content:L,filter:b,id:n,left:w+A,top:k+J,width:q,height:tt,matrix:V,opacity:l,image:P,debug:f},i)}if(S){let x="";f&&(x=`<rect x="${w}" y="${k}" width="${F}" height="${W}" fill="transparent" stroke="#575eff" stroke-width="1" ${V?`transform="${V}"`:""}></rect>`),X+=`${b?`${b}<g filter="url(#satori_s-${n})">`:""}<path fill="${i.color}" ${V?`transform="${V}"`:""} ${l!==1?`opacity="${l}"`:""} d="${S}"></path>${b?"</g>":""}${x}`}return X}u();u();import me from"parse-css-dimension";u();var bt=bt||{};bt.parse=function(){var 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:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function e(l){var b=new Error(r+": "+l);throw b.source=r,b}function i(){var l=s();return r.length>0&&e("Invalid input not EOF"),l}function s(){return $(o)}function o(){return n("linear-gradient",t.linearGradient,f)||n("repeating-linear-gradient",t.repeatingLinearGradient,f)||n("radial-gradient",t.radialGradient,p)||n("repeating-radial-gradient",t.repeatingRadialGradient,p)}function n(l,b,S){return a(b,function(x){var L=S();return L&&(k(t.comma)||e("Missing comma before color stops")),{type:l,orientation:L,colorStops:$(C)}})}function a(l,b){var S=k(l);if(S){k(t.startCall)||e("Missing (");var x=b(S);return k(t.endCall)||e("Missing )"),x}}function f(){return m()||y()}function m(){return w("directional",t.sideOrCorner,1)}function y(){return w("angular",t.angleValue,1)}function p(){var l,b=d(),S;return b&&(l=[],l.push(b),S=r,k(t.comma)&&(b=d(),b?l.push(b):r=S)),l}function d(){var l=g()||c();if(l)l.at=T();else{var b=E();if(b){l=b;var S=T();S&&(l.at=S)}else{var x=I();x&&(l={type:"default-radial",at:x})}}return l}function g(){var l=w("shape",/^(circle)/i,0);return l&&(l.style=W()||E()),l}function c(){var l=w("shape",/^(ellipse)/i,0);return l&&(l.style=N()||E()),l}function E(){return w("extent-keyword",t.extentKeywords,1)}function T(){if(w("position",/^at/,0)){var l=I();return l||e("Missing positioning value"),l}}function I(){var l=h();if(l.x||l.y)return{type:"position",value:l}}function h(){return{x:N(),y:N()}}function $(l){var b=l(),S=[];if(b)for(S.push(b);k(t.comma);)b=l(),b?S.push(b):e("One extra comma");return S}function C(){var l=M();return l||e("Expected color definition"),l.length=N(),l}function M(){return U()||X()||z()||O()}function O(){return w("literal",t.literalColor,0)}function U(){return w("hex",t.hexColor,1)}function z(){return a(t.rgbColor,function(){return{type:"rgb",value:$(H)}})}function X(){return a(t.rgbaColor,function(){return{type:"rgba",value:$(H)}})}function H(){return k(t.number)[1]}function N(){return w("%",t.percentageValue,1)||F()||W()}function F(){return w("position-keyword",t.positionKeywords,1)}function W(){return w("px",t.pixelValue,1)||w("em",t.emValue,1)}function w(l,b,S){var x=k(b);if(x)return{type:l,value:x[S]}}function k(l){var b,S;return S=/^[\n\r\t\s]+/.exec(r),S&&V(S[0].length),b=l.exec(r),b&&V(b[0].length),b}function V(l){r=r.substr(l)}return function(l){return r=l.toString(),i()}}();var Dt=bt;function pe(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function de(t,r){return typeof t=="string"&&t.endsWith("%")?r*parseFloat(t)/100:+t}function Mt(t,{x:r,y:e,defaultX:i,defaultY:s}){return(t?t.split(" ").map(o=>{try{let n=new me(o);return n.type==="length"?n.value:n.value+n.unit}catch{return null}}).filter(o=>o!==null):[i,s]).map((o,n)=>de(o,[r,e][n]))}function yt({id:t,width:r,height:e},{image:i,size:s,position:o}){let n=Mt(s,{x:r,y:e,defaultX:r,defaultY:e}),a=Mt(o,{x:r,y:e,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let f=Dt.parse(i)[0],m,y,p,d;if(f.orientation.type==="directional")[m,y,p,d]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let h=+f.orientation.value/180*Math.PI-Math.PI/2,$=Math.cos(h),C=Math.sin(h);m=0,y=0,p=$,d=C,p<0&&(m-=p,p=0),d<0&&(y-=d,d=0)}let g=r,c=[];for(let h of f.colorStops){let $=pe(h);if(!c.length&&(c.push({offset:0,color:$}),typeof h.length=="undefined"||h.length.value==="0"))continue;let C=typeof h.length=="undefined"?void 0:h.length.type==="%"?h.length.value/100:h.length.value/g;c.push({offset:C,color:$})}c.length||c.push({offset:0,color:"transparent"});let E=c[c.length-1];E.offset!==1&&(typeof E.offset=="undefined"?E.offset=1:c.push({offset:1,color:E.color}));let T=0,I=1;for(let h=0;h<c.length;h++)if(typeof c[h].offset=="undefined"){for(I<h&&(I=h);typeof c[I].offset=="undefined";)I++;c[h].offset=(c[I].offset-c[T].offset)/(I-T)*(h-T)+c[T].offset}else T=h;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${m}" y1="${y}" x2="${p}" y2="${d}">${c.map(h=>`<stop offset="${h.offset*100}%" stop-color="${h.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("url(")){let f=i.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${n[0]}" height="${n[1]}"><image href="${f}" x="0" y="0" width="${n[0]}" height="${n[1]}"/></pattern>`]}}u();function ft(t,r,e){return e<t+r&&(e/2<t&&e/2<r?t=r=e/2:e/2<t?t=e-r:e/2<r&&(r=e-t)),[t,r]}function nt({left:t,top:r,width:e,height:i},s){let{borderTopLeftRadius:o,borderTopRightRadius:n,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return o=Math.min(o||0,e,i),n=Math.min(n||0,e,i),a=Math.min(a||0,e,i),f=Math.min(f||0,e,i),!o&&!n&&!a&&!f?"":([o,n]=ft(o,n,e),[o,a]=ft(o,a,i),[n,f]=ft(n,f,i),[a,f]=ft(a,f,e),`M${t+o},${r} h${e-o-n} a${n},${n} 0 0 1 ${n},${n} v${i-n-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function xt({id:t,left:r,top:e,width:i,height:s,isInheritingTransform:o,debug:n},a){if(a.display==="none")return"";let f="rect",m="transparent",y=0,p="",d="",g=[],c=1,E="";if(a.backgroundColor&&g.push(a.backgroundColor),a.borderWidth&&(y=a.borderWidth,m=a.borderColor),a.opacity&&(c=+a.opacity),a.transform&&(p=et({left:r,top:e,width:i,height:s},a.transform,o)),a.backgroundImage){let h=a.backgroundImage.map(($,C)=>yt({id:t+"_"+C,width:i,height:s},$)).filter(Boolean);for(let $ of h)d+=$[1],g.push(`url(#${$[0]})`)}let T=nt({left:r,top:e,width:i,height:s},a);T&&(f="path");let I=K({width:i,height:s,id:t},a);return g.length||g.push("transparent"),n&&(E=`<rect x="${r}" y="${e}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),`${d?`<defs>${d}</defs>`:""}${I?`${I}<g filter="url(#satori_s-${t})">`:""}${c!==1?`<g opacity="${c}">`:""}${g.map((h,$)=>h==="transparent"&&!($===g.length-1&&y)?"":`<${f} x="${r}" y="${e}" width="${i}" height="${s}" fill="${h}" ${$===g.length-1&&y?`stroke="${m}" stroke-width="${y}"`:""} ${T?`d="${T}"`:""} ${p?`transform="${p}"`:""}></${f}>`).join("")}${c!==1?"</g>":""}${I?"</g>":""}${E}`}u();function $t({id:t,left:r,top:e,width:i,height:s,src:o,debug:n},a){if(a.display==="none")return"";let f="",m=1,y=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",p=nt({left:r,top:e,width:i,height:s},a);p&&(f=`<clipPath id="satori_c-${t}"><path x="${r}" y="${e}" width="${i}" height="${s}" d="${p}"></path></clipPath>`),a.opacity&&(m=+a.opacity);let d=K({width:i,height:s,id:t},a);return`${d}${d?`<g filter="url(#satori_s-${t})">`:""}${f}<image href="${o}" x="${r}" y="${e}" width="${i}" height="${s}" preserveAspectRatio="${y}" ${f?`clip-path="url(#satori_c-${t})"`:""} ${m!==1?`opacity="${m}"`:""}></image>${d?"</g>":""}`}function*ot(t,r){let e=Y(),{id:i,inheritedStyle:s,parent:o,font:n,debug:a,embedFont:f=!0,graphemeImages:m}=r;if(t===null||typeof t=="undefined")return yield,"";if(!ut(t)||typeof t.type=="function"){let F;if(!ut(t))F=ht(String(t),r);else{if(Ot(t.type))throw new Error("Class component is not supported.");F=ot(t.type(t.props),r)}F.next();let W=yield;return F.next(W).value}let{type:y,props:p}=t,{style:d,children:g}=p,c=e.Node.create();o.insertChild(c,o.getChildCount());let[E,T]=mt(c,y,s,d,p),I=E.transform===s.transform;I||(E.transform.__parent=s.transform);let h=typeof g=="undefined"?[]:[].concat(g),$=[],C=0;for(let F of h){let W=ot(F,{id:i*h.length+ ++C,parentStyle:E,inheritedStyle:T,isInheritingTransform:!0,parent:c,font:n,embedFont:f,debug:a,graphemeImages:m});W.next(),$.push(W)}let[M,O]=yield;E.position==="absolute"&&c.calculateLayout();let{left:U,top:z,width:X,height:H}=c.getComputedLayout();U+=M,z+=O;let N="";y==="img"?N=$t({id:i,left:U,top:z,width:X,height:H,src:p.src,isInheritingTransform:I,debug:a},E):N=xt({id:i,left:U,top:z,width:X,height:H,isInheritingTransform:I,debug:a},E);for(let F of $)N+=F.next([U,z]).value;return N}u();import Bt from"@shuding/opentype.js";var lt=class{constructor(r){this.fonts=new Map;for(let e of r){let i=e.data,s="buffer"in i?Bt.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):Bt.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([s,e.weight,e.style])}}get({name:r,weight:e,style:i}){if(!this.fonts.has(r))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let s=[...this.fonts.get(r)];return s.sort(([o,n,a],[f,m,y])=>{if(n!==m)return n?!m||n===e?-1:m===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&m===500||e===500&&m===400?1:e<400?n<e&&m<e?m-n:n<e?-1:m<e?1:n-m:e<n&&e<m?n-m:e<n?-1:e<m?1:m-n:1;if(a!==y){if(a===i)return-1;if(y===i)return 1}return-1}),s[0][0]}getFont({fontFamily:r,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:r,weight:e,style:i})}measure(r,e,{fontSize:i,letterSpacing:s=0}){return r.getAdvanceWidth(e,i,{letterSpacing:s/i})}getSVG(r,e,{fontSize:i,top:s,left:o,letterSpacing:n=0}){return s+=r.ascender/r.unitsPerEm*i,r.getPath(e,o,s,i,{letterSpacing:n/i}).toPathData(1)}};u();function Et({width:t,height:r,content:e},i){return`<svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}var St=new WeakMap;function Yt(t,r){let e=Y();if(!e)throw new Error("Satori is not initialized.");let i;St.has(r.fonts)?i=St.get(r.fonts):St.set(r.fonts,i=new lt(r.fonts));let s=e.Node.create();s.setWidth(r.width),s.setHeight(r.height),s.setFlexDirection(e.FLEX_DIRECTION_ROW),s.setFlexWrap(e.WRAP_WRAP),s.setAlignContent(e.ALIGN_AUTO),s.setAlignItems(e.ALIGN_FLEX_START),s.setJustifyContent(e.JUSTIFY_FLEX_START);let o=ot(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});o.next(),s.calculateLayout(r.width,r.height,e.DIRECTION_LTR);let n=o.next([0,0]).value;return Et({width:r.width,height:r.height,content:n})}export{Yt as default,te as init};
var ie=Object.defineProperty,ze=Object.defineProperties,He=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyDescriptors,Je=Object.getOwnPropertyNames,Le=Object.getOwnPropertySymbols;var Ae=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var we=(e,r,t)=>r in e?ie(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Y=(e,r)=>{for(var t in r||(r={}))Ae.call(r,t)&&we(e,t,r[t]);if(Le)for(var t of Le(r))je.call(r,t)&&we(e,t,r[t]);return e},ve=(e,r)=>ze(e,Ve(r)),Ke=e=>ie(e,"__esModule",{value:!0});var Ce=(e,r)=>()=>(e&&(r=e(e=0)),r);var qe=(e,r)=>{for(var t in r)ie(e,t,{get:r[t],enumerable:!0})},Ze=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Je(r))!Ae.call(e,s)&&(t||s!=="default")&&ie(e,s,{get:()=>r[s],enumerable:!(o=He(r,s))||o.enumerable});return e};var Qe=(e=>(r,t)=>e&&e.get(r)||(t=Ze(Ke({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var u=Ce(()=>{});var Fe={};qe(Fe,{default:()=>tt});import*as et from"yoga-layout-prebuilt";var tt,Oe=Ce(()=>{u();tt=et});u();u();u();var ae;{let e=(Oe(),Qe(Fe));e.default?ae=e.default:ae=e}function rt(e){ae=e}function U(){return ae}u();u();function ue(e){let r=typeof e;return!(r==="number"||r==="bigint"||r==="string"||r==="boolean")}function Ne(e){return/^class\s/.test(Function.prototype.toString.call(e))}function Q(e,r){return[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]}function k(e,r,t){let o=r[e];return typeof o=="undefined"?t:o}u();u();var ke={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};u();var nt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function ce(e){let r={};for(let t in e)nt.has(t)&&(r[t]=e[t]);return r}u();import{getPropertyName as Pe,getStylesForProperty as st}from"css-to-react-native";import De from"parse-css-dimension";import{parseElementStyle as ft}from"css-background-parser";u();import ot from"postcss-value-parser";import it from"parse-css-dimension";function at(e,r){try{let t=new it(e);switch(t.unit){case"px":return{absolute:t.value};case"em":return{absolute:t.value*r};case"rem":return{absolute:t.value*16};case"%":return{relative:t.value};default:return{}}}catch{return{}}}function me(e,r,t){switch(e){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let o=at(e,r);return o.absolute?{[t?"xAbsolute":"yAbsolute"]:o.absolute}:o.relative?{[t?"xRelative":"yRelative"]:o.relative}:{}}}function pe(e,r){if(typeof e=="number")return{xAbsolute:e};let t;try{t=ot(e).nodes.filter(o=>o.type==="word").map(o=>o.value)}catch{return{}}return t.length===1?me(t[0],r,!0):t.length===2?((t[0]==="top"||t[0]==="bottom"||t[1]==="left"||t[1]==="right")&&t.reverse(),Y(Y({},me(t[0],r,!0)),me(t[1],r,!1))):{}}var lt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),We=[1,0,0,1,0,0];function ut(e,r){return typeof r=="number"?lt.has(e)?String(r):r+"px":r}function Ge(e,r){if(typeof e=="number")return e;try{let t=new De(e);if(t.type==="length")switch(t.unit){case"em":return t.value*r;case"rem":return t.value*16;default:return t.value}else if(t.type==="angle")switch(t.unit){case"deg":return t.value;case"rad":return t.value*180/Math.PI;default:return t.value}}catch{}}function se(e,r){let t=[];for(let i in e){let n=Pe(i);t.push([n,ut(n,e[i])])}let o=t.reduce((i,n)=>{let a=Pe(n[0]),f=n[1];return Object.assign(i,st(a,f,!0))},{});if(o.backgroundImage){let{backgrounds:i}=ft(o);o.backgroundImage=i}let s=o.fontSize||r.fontSize;if(typeof s=="string")try{let i=new De(s);switch(i.unit){case"em":s=i.value*r.fontSize;break;case"rem":s=i.value*16;break}}catch{s=16}typeof o.fontSize!="undefined"&&(o.fontSize=s),o.transformOrigin&&(o.transformOrigin=pe(o.transformOrigin,s));for(let i in o){let n=o[i];if(typeof n=="string"){let a=Ge(n,s);typeof a!="undefined"&&(o[i]=a),n=o[i]}if(i==="opacity"&&(n=o[i]=n*r.opacity),i==="transform"){let a=[...We],f=n;for(let m of f){let y=Object.keys(m)[0],d=m[y],p=typeof d=="string"?Ge(d,s):d,g=[...We];switch(y){case"translateX":g[4]=p;break;case"translateY":g[5]=p;break;case"scaleX":g[0]=p;break;case"scaleY":g[3]=p;break;case"rotate":let c=p*Math.PI/180,x=Math.cos(c),_=Math.sin(c);g[0]=x,g[1]=_,g[2]=-_,g[3]=x;break;case"skewX":g[2]=Math.tan(p*Math.PI/180);break;case"skewY":g[1]=Math.tan(p*Math.PI/180);break}a=Q(g,a)}o.transform=a}}return o}function de(e,r,t,o,s){let i=U(),n=Y(Y(Y({},t),se(ke[r],t)),se(o,t));if(r==="img"){let a=parseInt(s.width),m=parseInt(s.height)/a;n.width||(n.width=a),n.height||(n.height=m*n.width)}return e.setDisplay(k(n.display,{flex:i.DISPLAY_FLEX,none:i.DISPLAY_NONE},i.DISPLAY_FLEX)),e.setAlignContent(k(n.alignContent,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,"space-between":i.ALIGN_SPACE_BETWEEN,"space-around":i.ALIGN_SPACE_AROUND,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),e.setAlignItems(k(n.alignItems,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_FLEX_START)),e.setAlignSelf(k(n.alignSelf,{stretch:i.ALIGN_STRETCH,center:i.ALIGN_CENTER,"flex-start":i.ALIGN_FLEX_START,"flex-end":i.ALIGN_FLEX_END,baseline:i.ALIGN_BASELINE,normal:i.ALIGN_AUTO},i.ALIGN_AUTO)),e.setJustifyContent(k(n.justifyContent,{center:i.JUSTIFY_CENTER,"flex-start":i.JUSTIFY_FLEX_START,"flex-end":i.JUSTIFY_FLEX_END,"space-between":i.JUSTIFY_SPACE_BETWEEN,"space-around":i.JUSTIFY_SPACE_AROUND},i.JUSTIFY_FLEX_START)),e.setFlexDirection(k(n.flexDirection,{row:i.FLEX_DIRECTION_ROW,column:i.FLEX_DIRECTION_COLUMN,"row-reverse":i.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":i.FLEX_DIRECTION_COLUMN_REVERSE},i.FLEX_DIRECTION_ROW)),e.setFlexWrap(k(n.flexWrap,{wrap:i.WRAP_WRAP,nowrap:i.WRAP_NO_WRAP,"wrap-reverse":i.WRAP_WRAP_REVERSE},i.WRAP_WRAP)),typeof n.flexBasis!="undefined"&&e.setFlexBasis(n.flexBasis),e.setFlexGrow(typeof n.flexGrow=="undefined"?0:n.flexGrow),e.setFlexShrink(typeof n.flexShrink=="undefined"?1:n.flexShrink),typeof n.maxHeight!="undefined"&&e.setMaxHeight(n.maxHeight),typeof n.maxWidth!="undefined"&&e.setMaxWidth(n.maxWidth),typeof n.minHeight!="undefined"&&e.setMinHeight(n.minHeight),typeof n.minWidth!="undefined"&&e.setMinWidth(n.minWidth),e.setOverflow(k(n.overflow,{visible:i.OVERFLOW_VISIBLE,hidden:i.OVERFLOW_HIDDEN},i.OVERFLOW_VISIBLE)),e.setMargin(i.EDGE_TOP,n.marginTop||0),e.setMargin(i.EDGE_BOTTOM,n.marginBottom||0),e.setMargin(i.EDGE_LEFT,n.marginLeft||0),e.setMargin(i.EDGE_RIGHT,n.marginRight||0),e.setBorder(i.EDGE_TOP,n.borderWidth||0),e.setBorder(i.EDGE_BOTTOM,n.borderWidth||0),e.setBorder(i.EDGE_LEFT,n.borderWidth||0),e.setBorder(i.EDGE_RIGHT,n.borderWidth||0),e.setPadding(i.EDGE_TOP,n.paddingTop||0),e.setPadding(i.EDGE_BOTTOM,n.paddingBottom||0),e.setPadding(i.EDGE_LEFT,n.paddingLeft||0),e.setPadding(i.EDGE_RIGHT,n.paddingRight||0),e.setPositionType(k(n.position,{absolute:i.POSITION_TYPE_ABSOLUTE,relative:i.POSITION_TYPE_RELATIVE},i.POSITION_TYPE_RELATIVE)),typeof n.top!="undefined"&&e.setPosition(i.EDGE_TOP,n.top),typeof n.bottom!="undefined"&&e.setPosition(i.EDGE_BOTTOM,n.bottom),typeof n.left!="undefined"&&e.setPosition(i.EDGE_LEFT,n.left),typeof n.right!="undefined"&&e.setPosition(i.EDGE_RIGHT,n.right),typeof n.height!="undefined"?e.setHeight(n.height):e.setHeightAuto(),typeof n.width!="undefined"?e.setWidth(n.width):e.setWidthAuto(),[n,ce(n)]}u();import{LineBreaker as ct}from"css-line-break";import{splitGraphemes as mt}from"text-segmentation";u();u();function te({left:e,top:r,width:t,height:o},s,i,n){var f,m,y,d;let a;if(i)a=s;else{let p=(m=n==null?void 0:n.xAbsolute)!=null?m:((f=n==null?void 0:n.xRelative)!=null?f:50)*t/100,g=(d=n==null?void 0:n.yAbsolute)!=null?d:((y=n==null?void 0:n.yRelative)!=null?y:50)*o/100,c=e+p,x=r+g;a=Q([1,0,0,1,c,x],Q(s,[1,0,0,1,-c,-x])),s.__parent&&(a=Q(s.__parent,a)),s.splice(0,6,...a)}return`matrix(${a.map(p=>p.toFixed(2)).join(",")})`}function Me({left:e,top:r,width:t,height:o,isInheritingTransform:s},i){let n="",a=1;return i.transform&&(n=te({left:e,top:r,width:t,height:o},i.transform,s,i.transformOrigin)),i.opacity&&(a=+i.opacity),{matrix:n,opacity:a}}function ge({id:e,content:r,filter:t,left:o,top:s,width:i,height:n,matrix:a,opacity:f,image:m,debug:y},d){let p="";return y&&(p=`<rect x="${o}" y="${s}" width="${i}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),m?`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<image href="${m}" x="${o}" y="${s}" width="${i}" height="${n}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${t?"</g>":""}${p}`:`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<text x="${o}" y="${s}" width="${i}" height="${n}" fill="${d.color}" font-weight="${d.fontWeight}" font-style="${d.fontStyle}" font-size="${d.fontSize}" font-family="${d.fontFamily}" ${d.letterSpacing?`letter-spacing="${d.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${r}</text>${t?"</g>":""}${p}`}u();function q({id:e,width:r,height:t},o){if(!o.shadowColor||!o.shadowOffset||typeof o.shadowRadius=="undefined")return"";let s=o.shadowRadius*o.shadowRadius/4,i=Math.min(o.shadowOffset.width-s,0),n=Math.max(o.shadowOffset.width+s+r,r),a=Math.min(o.shadowOffset.height-s,0),f=Math.max(o.shadowOffset.height+s+t,t);return`<defs><filter id="satori_s-${e}" x="${i/r*100}%" y="${a/t*100}%" width="${(n-i)/r*100}%" height="${(f-a)/t*100}%"><feDropShadow dx="${o.shadowOffset.width}" dy="${o.shadowOffset.height}" stdDeviation="${o.shadowRadius/2}" flood-color="${o.shadowColor}" flood-opacity="1"/></filter></defs>`}var re=void 0,be=typeof Intl!="undefined"&&"Segmenter"in Intl,pt=be?new Intl.Segmenter(re,{granularity:"word"}):null,dt=be?new Intl.Segmenter(re,{granularity:"grapheme"}):null,gt=[32,160,4961,65792,65793,4153,4241],ht=e=>{let r=ct(e,{lineBreak:"strict",wordBreak:"normal"}),t=[],o;for(;!(o=r.next()).done;)if(o.value){let s=o.value.slice(),i=[].map.call(s,a=>a.codePointAt(0)),n="";i.forEach(a=>{gt.includes(a)?(n.length&&t.push(n),t.push(String.fromCodePoint(a)),n=""):n+=String.fromCodePoint(a)}),n.length&&t.push(n)}return t};function he(e,r){return be?r==="word"?[...pt.segment(e)].map(t=>t.segment):[...dt.segment(e)].map(t=>t.segment):r==="word"?ht(e):mt(e)}function*ye(e,r){let t=U(),{parentStyle:o,parent:s,font:i,id:n,isInheritingTransform:a,debug:f,embedFont:m,graphemeImages:y}=r;o.textTransform==="uppercase"?e=e.toLocaleUpperCase(re):o.textTransform==="lowercase"?e=e.toLocaleLowerCase(re):o.textTransform==="capitalize"&&(e=he(e,"word").map($=>he($,"grapheme").map((L,W)=>W===0?L.toLocaleUpperCase(re):L).join("")).join(""));let d=k(o.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),p=he(e,d),g=t.Node.create();g.setAlignItems(t.ALIGN_BASELINE),o.textAlign==="left"?g.setJustifyContent(t.JUSTIFY_FLEX_START):o.textAlign==="center"?g.setJustifyContent(t.JUSTIFY_CENTER):o.textAlign==="right"?g.setJustifyContent(t.JUSTIFY_FLEX_END):o.textAlign==="justify"&&g.setJustifyContent(t.JUSTIFY_SPACE_BETWEEN),s.insertChild(g,s.getChildCount());let c=i.getFont(o),x=c.ascender/c.unitsPerEm*o.fontSize,_=-(c.descender/c.unitsPerEm)*o.fontSize,h=(x+_)*1.2,{textAlign:E}=o,v=[],M=[],F=[];g.setMeasureFunc($=>{let L=[],W="",G=0,j="",A=0,Z=0,ee=-1;v=[],M=[0];for(let B=0;B<p.length;B++){let D=p[B];if([" ",`
`," ","\u3000"].includes(D))W+=D,G=i.measure(c,W,o),F[B]=null;else{let K=y&&y[D]?o.fontSize:i.measure(c,D,o);A||(W="",G=0);let _e=G||",.!?:-@)>]}%#".indexOf(D[0])<0,Ie=!A||!!G;_e&&A+G+K>$?(v.push(A),L.push(j),j=D,A=K,M.push(1),ee=-1):(j+=W+D,A+=G+K,Ie&&M[M.length-1]++),W="",G=0,Ie&&ee++,Z=Math.max(Z,A),F[B]={y:L.length*h,x:A-K,width:K,line:L.length,lineIndex:ee}}}return A&&(L.push(j),v.push(A)),L.length>1&&(Z=$),{width:Z,height:L.length*h}});let[X,z]=yield,H="";o.position==="absolute"&&g.calculateLayout();let{left:V,top:O,width:C,height:P}=g.getComputedLayout(),w=X+V,N=z+O,{matrix:J,opacity:l}=Me({left:V,top:O,width:C,height:P,isInheritingTransform:a},o),b="";o.textShadowOffset&&(b=q({width:C,height:P,id:n},{shadowColor:o.textShadowColor,shadowOffset:o.textShadowOffset,shadowRadius:o.textShadowRadius}));let S="";for(let $=0;$<p.length;$++){if(!F[$])continue;let L=p[$],W=null,G=null,j=F[$].y,A=F[$].x,Z=F[$].width,ee=h,B=C-v[F[$].line];if(E==="right"||E==="end")A+=B;else if(E==="center")A+=B/2;else if(E==="justify"){let D=F[$].line;if(D<v.length-1){let K=M[D];A+=(K>1?B/(K-1):0)*F[$].lineIndex}}y&&y[L]?G=y[L]:m?W=i.getSVG(c,L,ve(Y({},o),{left:w+A,top:N+j,letterSpacing:o.letterSpacing})):j+=x,W?S+=W+" ":H+=ge({content:L,filter:b,id:n,left:w+A,top:N+j,width:Z,height:ee,matrix:J,opacity:l,image:G,debug:f},o)}if(S){let $="";f&&($=`<rect x="${w}" y="${N}" width="${C}" height="${P}" fill="transparent" stroke="#575eff" stroke-width="1" ${J?`transform="${J}"`:""}></rect>`),H+=`${b?`${b}<g filter="url(#satori_s-${n})">`:""}<path fill="${o.color}" ${J?`transform="${J}"`:""} ${l!==1?`opacity="${l}"`:""} d="${S}"></path>${b?"</g>":""}${$}`}return H}u();u();import bt from"parse-css-dimension";u();var xe=xe||{};xe.parse=function(){var e={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:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},r="";function t(l){var b=new Error(r+": "+l);throw b.source=r,b}function o(){var l=s();return r.length>0&&t("Invalid input not EOF"),l}function s(){return E(i)}function i(){return n("linear-gradient",e.linearGradient,f)||n("repeating-linear-gradient",e.repeatingLinearGradient,f)||n("radial-gradient",e.radialGradient,d)||n("repeating-radial-gradient",e.repeatingRadialGradient,d)}function n(l,b,S){return a(b,function($){var L=S();return L&&(N(e.comma)||t("Missing comma before color stops")),{type:l,orientation:L,colorStops:E(v)}})}function a(l,b){var S=N(l);if(S){N(e.startCall)||t("Missing (");var $=b(S);return N(e.endCall)||t("Missing )"),$}}function f(){return m()||y()}function m(){return w("directional",e.sideOrCorner,1)}function y(){return w("angular",e.angleValue,1)}function d(){var l,b=p(),S;return b&&(l=[],l.push(b),S=r,N(e.comma)&&(b=p(),b?l.push(b):r=S)),l}function p(){var l=g()||c();if(l)l.at=_();else{var b=x();if(b){l=b;var S=_();S&&(l.at=S)}else{var $=I();$&&(l={type:"default-radial",at:$})}}return l}function g(){var l=w("shape",/^(circle)/i,0);return l&&(l.style=P()||x()),l}function c(){var l=w("shape",/^(ellipse)/i,0);return l&&(l.style=O()||x()),l}function x(){return w("extent-keyword",e.extentKeywords,1)}function _(){if(w("position",/^at/,0)){var l=I();return l||t("Missing positioning value"),l}}function I(){var l=h();if(l.x||l.y)return{type:"position",value:l}}function h(){return{x:O(),y:O()}}function E(l){var b=l(),S=[];if(b)for(S.push(b);N(e.comma);)b=l(),b?S.push(b):t("One extra comma");return S}function v(){var l=M();return l||t("Expected color definition"),l.length=O(),l}function M(){return X()||H()||z()||F()}function F(){return w("literal",e.literalColor,0)}function X(){return w("hex",e.hexColor,1)}function z(){return a(e.rgbColor,function(){return{type:"rgb",value:E(V)}})}function H(){return a(e.rgbaColor,function(){return{type:"rgba",value:E(V)}})}function V(){return N(e.number)[1]}function O(){return w("%",e.percentageValue,1)||C()||P()}function C(){return w("position-keyword",e.positionKeywords,1)}function P(){return w("px",e.pixelValue,1)||w("em",e.emValue,1)}function w(l,b,S){var $=N(b);if($)return{type:l,value:$[S]}}function N(l){var b,S;return S=/^[\n\r\t\s]+/.exec(r),S&&J(S[0].length),b=l.exec(r),b&&J(b[0].length),b}function J(l){r=r.substr(l)}return function(l){return r=l.toString(),o()}}();var Be=xe;function yt(e){return e.type==="literal"?e.value:e.type==="hex"?`#${e.value}`:e.type==="rgb"?`rgb(${e.value.join(",")})`:e.type==="rgba"?`rgba(${e.value.join(",")})`:"transparent"}function xt(e,r){return typeof e=="string"&&e.endsWith("%")?r*parseFloat(e)/100:+e}function Ye(e,{x:r,y:t,defaultX:o,defaultY:s}){return(e?e.split(" ").map(i=>{try{let n=new bt(i);return n.type==="length"?n.value:n.value+n.unit}catch{return null}}).filter(i=>i!==null):[o,s]).map((i,n)=>xt(i,[r,t][n]))}function $e({id:e,width:r,height:t},{image:o,size:s,position:i}){let n=Ye(s,{x:r,y:t,defaultX:r,defaultY:t}),a=Ye(i,{x:r,y:t,defaultX:0,defaultY:0});if(o.startsWith("linear-gradient(")){let f=Be.parse(o)[0],m,y,d,p;if(f.orientation.type==="directional")[m,y,d,p]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let h=+f.orientation.value/180*Math.PI-Math.PI/2,E=Math.cos(h),v=Math.sin(h);m=0,y=0,d=E,p=v,d<0&&(m-=d,d=0),p<0&&(y-=p,p=0)}let g=r,c=[];for(let h of f.colorStops){let E=yt(h);if(!c.length&&(c.push({offset:0,color:E}),typeof h.length=="undefined"||h.length.value==="0"))continue;let v=typeof h.length=="undefined"?void 0:h.length.type==="%"?h.length.value/100:h.length.value/g;c.push({offset:v,color:E})}c.length||c.push({offset:0,color:"transparent"});let x=c[c.length-1];x.offset!==1&&(typeof x.offset=="undefined"?x.offset=1:c.push({offset:1,color:x.color}));let _=0,I=1;for(let h=0;h<c.length;h++)if(typeof c[h].offset=="undefined"){for(I<h&&(I=h);typeof c[I].offset=="undefined";)I++;c[h].offset=(c[I].offset-c[_].offset)/(I-_)*(h-_)+c[_].offset}else _=h;return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${m}" y1="${y}" x2="${d}" y2="${p}">${c.map(h=>`<stop offset="${h.offset*100}%" stop-color="${h.color}"/>`).join("")}</linearGradient>`]}if(o.startsWith("url(")){let f=o.slice(4,-1);return[`satori_bi${e}`,`<pattern id="satori_bi${e}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${n[0]}" height="${n[1]}"><image href="${f}" x="0" y="0" width="${n[0]}" height="${n[1]}"/></pattern>`]}}u();function fe(e,r,t){return t<e+r&&(t/2<e&&t/2<r?e=r=t/2:t/2<e?e=t-r:t/2<r&&(r=t-e)),[e,r]}function ne({left:e,top:r,width:t,height:o},s){let{borderTopLeftRadius:i,borderTopRightRadius:n,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return i=Math.min(i||0,t,o),n=Math.min(n||0,t,o),a=Math.min(a||0,t,o),f=Math.min(f||0,t,o),!i&&!n&&!a&&!f?"":([i,n]=fe(i,n,t),[i,a]=fe(i,a,o),[n,f]=fe(n,f,o),[a,f]=fe(a,f,t),`M${e+i},${r} h${t-i-n} a${n},${n} 0 0 1 ${n},${n} v${o-n-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-t} a${a},${a} 0 0 1 ${-a},${-a} v${a+i-o} a${i},${i} 0 0 1 ${i},${-i}`)}function Ee({id:e,left:r,top:t,width:o,height:s,isInheritingTransform:i,debug:n},a){if(a.display==="none")return"";let f="rect",m="transparent",y=0,d="",p="",g=[],c=1,x="";if(a.backgroundColor&&g.push(a.backgroundColor),a.borderWidth&&(y=a.borderWidth,m=a.borderColor),a.opacity&&(c=+a.opacity),a.transform&&(d=te({left:r,top:t,width:o,height:s},a.transform,i,a.transformOrigin)),a.backgroundImage){let h=a.backgroundImage.map((E,v)=>$e({id:e+"_"+v,width:o,height:s},E)).filter(Boolean);for(let E of h)p+=E[1],g.push(`url(#${E[0]})`)}let _=ne({left:r,top:t,width:o,height:s},a);_&&(f="path");let I=q({width:o,height:s,id:e},a);return g.length||g.push("transparent"),n&&(x=`<rect x="${r}" y="${t}" width="${o}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${d?`transform="${d}"`:""}></rect>`),`${p?`<defs>${p}</defs>`:""}${I?`${I}<g filter="url(#satori_s-${e})">`:""}${c!==1?`<g opacity="${c}">`:""}${g.map((h,E)=>h==="transparent"&&!(E===g.length-1&&y)?"":`<${f} x="${r}" y="${t}" width="${o}" height="${s}" fill="${h}" ${E===g.length-1&&y?`stroke="${m}" stroke-width="${y}"`:""} ${_?`d="${_}"`:""} ${d?`transform="${d}"`:""}></${f}>`).join("")}${c!==1?"</g>":""}${I?"</g>":""}${x}`}u();function Se({id:e,left:r,top:t,width:o,height:s,src:i,debug:n},a){if(a.display==="none")return"";let f="",m=1,y=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",d=ne({left:r,top:t,width:o,height:s},a);d&&(f=`<clipPath id="satori_c-${e}"><path x="${r}" y="${t}" width="${o}" height="${s}" d="${d}"></path></clipPath>`),a.opacity&&(m=+a.opacity);let p=q({width:o,height:s,id:e},a);return`${p}${p?`<g filter="url(#satori_s-${e})">`:""}${f}<image href="${i}" x="${r}" y="${t}" width="${o}" height="${s}" preserveAspectRatio="${y}" ${f?`clip-path="url(#satori_c-${e})"`:""} ${m!==1?`opacity="${m}"`:""}></image>${p?"</g>":""}`}function*oe(e,r){let t=U(),{id:o,inheritedStyle:s,parent:i,font:n,debug:a,embedFont:f=!0,graphemeImages:m}=r;if(e===null||typeof e=="undefined")return yield,"";if(!ue(e)||typeof e.type=="function"){let C;if(!ue(e))C=ye(String(e),r);else{if(Ne(e.type))throw new Error("Class component is not supported.");C=oe(e.type(e.props),r)}C.next();let P=yield;return C.next(P).value}let{type:y,props:d}=e,{style:p,children:g}=d,c=t.Node.create();i.insertChild(c,i.getChildCount());let[x,_]=de(c,y,s,p,d),I=x.transform===s.transform;I||(x.transform.__parent=s.transform);let h=typeof g=="undefined"?[]:[].concat(g),E=[],v=0;for(let C of h){let P=oe(C,{id:o*h.length+ ++v,parentStyle:x,inheritedStyle:_,isInheritingTransform:!0,parent:c,font:n,embedFont:f,debug:a,graphemeImages:m});P.next(),E.push(P)}let[M,F]=yield;x.position==="absolute"&&c.calculateLayout();let{left:X,top:z,width:H,height:V}=c.getComputedLayout();X+=M,z+=F;let O="";y==="img"?O=Se({id:o,left:X,top:z,width:H,height:V,src:d.src,isInheritingTransform:I,debug:a},x):O=Ee({id:o,left:X,top:z,width:H,height:V,isInheritingTransform:I,debug:a},x);for(let C of E)O+=C.next([X,z]).value;return O}u();import Ue from"@shuding/opentype.js";var le=class{constructor(r){this.fonts=new Map;for(let t of r){let o=t.data,s="buffer"in o?Ue.parse(o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)):Ue.parse(o);this.defaultFont||(this.defaultFont=s),this.fonts.has(t.name)||this.fonts.set(t.name,[]),this.fonts.get(t.name).push([s,t.weight,t.style])}}get({name:r,weight:t,style:o}){if(!this.fonts.has(r))return this.defaultFont;t==="normal"&&(t=400),t==="bold"&&(t=700);let s=[...this.fonts.get(r)];return s.sort(([i,n,a],[f,m,y])=>{if(n!==m)return n?!m||n===t?-1:m===t?1:t===400&&n===500||t===500&&n===400?-1:t===400&&m===500||t===500&&m===400?1:t<400?n<t&&m<t?m-n:n<t?-1:m<t?1:n-m:t<n&&t<m?n-m:t<n?-1:t<m?1:m-n:1;if(a!==y){if(a===o)return-1;if(y===o)return 1}return-1}),s[0][0]}getFont({fontFamily:r,fontWeight:t=400,fontStyle:o="normal"}){return this.get({name:r,weight:t,style:o})}measure(r,t,{fontSize:o,letterSpacing:s=0}){return r.getAdvanceWidth(t,o,{letterSpacing:s/o})}getSVG(r,t,{fontSize:o,top:s,left:i,letterSpacing:n=0}){return s+=r.ascender/r.unitsPerEm*o,r.getPath(t,i,s,o,{letterSpacing:n/o}).toPathData(1)}};u();function Re({width:e,height:r,content:t},o){return`<svg width="${e}" height="${r}" viewBox="0 0 ${e} ${r}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}var Te=new WeakMap;function Xe(e,r){let t=U();if(!t)throw new Error("Satori is not initialized.");let o;Te.has(r.fonts)?o=Te.get(r.fonts):Te.set(r.fonts,o=new le(r.fonts));let s=t.Node.create();s.setWidth(r.width),s.setHeight(r.height),s.setFlexDirection(t.FLEX_DIRECTION_ROW),s.setFlexWrap(t.WRAP_WRAP),s.setAlignContent(t.ALIGN_AUTO),s.setAlignItems(t.ALIGN_FLEX_START),s.setJustifyContent(t.JUSTIFY_FLEX_START);let i=oe(e,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:o,embedFont:r.embedFont,debug:r.debug,graphemeImages:r.graphemeImages});i.next(),s.calculateLayout(r.width,r.height,t.DIRECTION_LTR);let n=i.next([0,0]).value;return Re({width:r.width,height:r.height,content:n})}export{Xe as default,rt as init};
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

var Gt=Object.defineProperty,Pt=Object.defineProperties;var Mt=Object.getOwnPropertyDescriptors;var St=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var _t=(t,o,e)=>o in t?Gt(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,q=(t,o)=>{for(var e in o||(o={}))Bt.call(o,e)&&_t(t,e,o[e]);if(St)for(var e of St(o))Dt.call(o,e)&&_t(t,e,o[e]);return t},Rt=(t,o)=>Pt(t,Mt(o));var Tt;function Yt(t){Tt=t}function D(){return Tt}function st(t){let o=typeof t;return!(o==="number"||o==="bigint"||o==="string"||o==="boolean")}function It(t){return/^class\s/.test(Function.prototype.toString.call(t))}function Z(t,o){return[t[0]*o[0]+t[2]*o[1],t[1]*o[0]+t[3]*o[1],t[0]*o[2]+t[2]*o[3],t[1]*o[2]+t[3]*o[3],t[0]*o[4]+t[2]*o[5]+t[4],t[1]*o[4]+t[3]*o[5]+t[5]]}function k(t,o,e){let i=o[t];return typeof i=="undefined"?e:i}var Lt={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var zt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function ft(t){let o={};for(let e in t)zt.has(e)&&(o[e]=t[e]);return o}import{getPropertyName as wt,getStylesForProperty as Ut}from"css-to-react-native";import Ft from"parse-css-dimension";import{parseElementStyle as Xt}from"css-background-parser";var Ht=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),At=[1,0,0,1,0,0];function Vt(t,o){return typeof o=="number"?Ht.has(t)?String(o):o+"px":o}function Ct(t,o){if(typeof t=="number")return t;try{let e=new Ft(t);if(e.type==="length")switch(e.unit){case"em":return e.value*o;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function ot(t,o){let e=[];for(let n in t){let r=wt(n);e.push([r,Vt(r,t[n])])}let i=e.reduce((n,r)=>{let a=wt(r[0]),f=r[1];return Object.assign(n,Ut(a,f,!0))},{});if(i.backgroundImage){let{backgrounds:n}=Xt(i);i.backgroundImage=n}let s=i.fontSize||o.fontSize;if(typeof s=="string")try{let n=new Ft(s);switch(n.unit){case"em":s=n.value*o.fontSize;break;case"rem":s=n.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s);for(let n in i){let r=i[n];if(typeof r=="string"){let a=Ct(r,s);typeof a!="undefined"&&(i[n]=a),r=i[n]}if(n==="opacity"&&(r=i[n]=r*o.opacity),n==="transform"){let a=[...At],f=r;for(let c of f){let b=Object.keys(c)[0],m=c[b],d=typeof m=="string"?Ct(m,s):m,p=[...At];switch(b){case"translateX":p[4]=d;break;case"translateY":p[5]=d;break;case"scaleX":p[0]=d;break;case"scaleY":p[3]=d;break;case"rotate":let u=d*Math.PI/180,$=Math.cos(u),S=Math.sin(u);p[0]=$,p[1]=S,p[2]=-S,p[3]=$;break;case"skewX":p[2]=Math.tan(d*Math.PI/180);break;case"skewY":p[1]=Math.tan(d*Math.PI/180);break}a=Z(p,a)}i.transform=a}}return i}function lt(t,o,e,i,s){let n=D(),r=q(q(q({},e),ot(Lt[o],e)),ot(i,e));if(o==="img"){let a=parseInt(s.width),c=parseInt(s.height)/a;r.width||(r.width=a),r.height||(r.height=c*r.width)}return t.setDisplay(k(r.display,{flex:n.DISPLAY_FLEX,none:n.DISPLAY_NONE},n.DISPLAY_FLEX)),t.setAlignContent(k(r.alignContent,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,"space-between":n.ALIGN_SPACE_BETWEEN,"space-around":n.ALIGN_SPACE_AROUND,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setAlignItems(k(r.alignItems,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_FLEX_START)),t.setAlignSelf(k(r.alignSelf,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setJustifyContent(k(r.justifyContent,{center:n.JUSTIFY_CENTER,"flex-start":n.JUSTIFY_FLEX_START,"flex-end":n.JUSTIFY_FLEX_END,"space-between":n.JUSTIFY_SPACE_BETWEEN,"space-around":n.JUSTIFY_SPACE_AROUND},n.JUSTIFY_FLEX_START)),t.setFlexDirection(k(r.flexDirection,{row:n.FLEX_DIRECTION_ROW,column:n.FLEX_DIRECTION_COLUMN,"row-reverse":n.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":n.FLEX_DIRECTION_COLUMN_REVERSE},n.FLEX_DIRECTION_ROW)),t.setFlexWrap(k(r.flexWrap,{wrap:n.WRAP_WRAP,nowrap:n.WRAP_NO_WRAP,"wrap-reverse":n.WRAP_WRAP_REVERSE},n.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&t.setFlexBasis(r.flexBasis),t.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),t.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&t.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&t.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&t.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&t.setMinWidth(r.minWidth),t.setOverflow(k(r.overflow,{visible:n.OVERFLOW_VISIBLE,hidden:n.OVERFLOW_HIDDEN},n.OVERFLOW_VISIBLE)),t.setMargin(n.EDGE_TOP,r.marginTop||0),t.setMargin(n.EDGE_BOTTOM,r.marginBottom||0),t.setMargin(n.EDGE_LEFT,r.marginLeft||0),t.setMargin(n.EDGE_RIGHT,r.marginRight||0),t.setBorder(n.EDGE_TOP,r.borderWidth||0),t.setBorder(n.EDGE_BOTTOM,r.borderWidth||0),t.setBorder(n.EDGE_LEFT,r.borderWidth||0),t.setBorder(n.EDGE_RIGHT,r.borderWidth||0),t.setPadding(n.EDGE_TOP,r.paddingTop||0),t.setPadding(n.EDGE_BOTTOM,r.paddingBottom||0),t.setPadding(n.EDGE_LEFT,r.paddingLeft||0),t.setPadding(n.EDGE_RIGHT,r.paddingRight||0),t.setPositionType(k(r.position,{absolute:n.POSITION_TYPE_ABSOLUTE,relative:n.POSITION_TYPE_RELATIVE},n.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&t.setPosition(n.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&t.setPosition(n.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&t.setPosition(n.EDGE_LEFT,r.left),typeof r.right!="undefined"&&t.setPosition(n.EDGE_RIGHT,r.right),typeof r.height!="undefined"?t.setHeight(r.height):t.setHeightAuto(),typeof r.width!="undefined"?t.setWidth(r.width):t.setWidthAuto(),[r,ft(r)]}import{LineBreaker as Jt}from"css-line-break";import{splitGraphemes as jt}from"text-segmentation";function tt({left:t,top:o,width:e,height:i},s,n){let r;if(n)r=s;else{let a=t+e/2,f=o+i/2;r=Z([1,0,0,1,a,f],Z(s,[1,0,0,1,-a,-f])),s.__parent&&(r=Z(s.__parent,r)),s.splice(0,6,...r)}return`matrix(${r.map(a=>a.toFixed(2)).join(",")})`}function Ot({left:t,top:o,width:e,height:i,isInheritingTransform:s},n){let r="",a=1;return n.transform&&(r=tt({left:t,top:o,width:e,height:i},n.transform,s)),n.opacity&&(a=+n.opacity),{matrix:r,opacity:a}}function ut({id:t,content:o,filter:e,left:i,top:s,width:n,height:r,matrix:a,opacity:f,image:c,debug:b},m){let d="";return b&&(d=`<rect x="${i}" y="${s}" width="${n}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),c?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${c}" x="${i}" y="${s}" width="${n}" height="${r}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${e?"</g>":""}${d}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${s}" width="${n}" height="${r}" fill="${m.color}" font-weight="${m.fontWeight}" font-style="${m.fontStyle}" font-size="${m.fontSize}" font-family="${m.fontFamily}" ${m.letterSpacing?`letter-spacing="${m.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${o}</text>${e?"</g>":""}${d}`}function j({id:t,width:o,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,n=Math.min(i.shadowOffset.width-s,0),r=Math.max(i.shadowOffset.width+s+o,o),a=Math.min(i.shadowOffset.height-s,0),f=Math.max(i.shadowOffset.height+s+e,e);return`<defs><filter id="satori_s-${t}" x="${n/o*100}%" y="${a/e*100}%" width="${(r-n)/o*100}%" height="${(f-a)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var et=void 0,mt=typeof Intl!="undefined"&&"Segmenter"in Intl,Kt=mt?new Intl.Segmenter(et,{granularity:"word"}):null,qt=mt?new Intl.Segmenter(et,{granularity:"grapheme"}):null,Zt=[32,160,4961,65792,65793,4153,4241],Qt=t=>{let o=Jt(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=o.next()).done;)if(i.value){let s=i.value.slice(),n=[].map.call(s,a=>a.codePointAt(0)),r="";n.forEach(a=>{Zt.includes(a)?(r.length&&e.push(r),e.push(String.fromCodePoint(a)),r=""):r+=String.fromCodePoint(a)}),r.length&&e.push(r)}return e};function ct(t,o){return mt?o==="word"?[...Kt.segment(t)].map(e=>e.segment):[...qt.segment(t)].map(e=>e.segment):o==="word"?Qt(t):jt(t)}function*dt(t,o){let e=D(),{parentStyle:i,parent:s,font:n,id:r,isInheritingTransform:a,debug:f,embedFont:c,graphemeImages:b}=o;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(et):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(et):i.textTransform==="capitalize"&&(t=ct(t,"word").map(y=>ct(y,"grapheme").map((I,W)=>W===0?I.toLocaleUpperCase(et):I).join("")).join(""));let m=k(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),d=ct(t,m),p=e.Node.create();p.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?p.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?p.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?p.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&p.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),s.insertChild(p,s.getChildCount());let u=n.getFont(i),$=u.ascender/u.unitsPerEm*i.fontSize,S=-(u.descender/u.unitsPerEm)*i.fontSize,g=($+S)*1.2,{textAlign:x}=i,A=[],M=[],F=[];p.setMeasureFunc(y=>{let I=[],W="",G=0,V="",w=0,K=0,Q=-1;A=[],M=[0];for(let B=0;B<d.length;B++){let P=d[B];if([" ",`
`," ","\u3000"].includes(P))W+=P,G=n.measure(u,W,i),F[B]=null;else{let J=b&&b[P]?i.fontSize:n.measure(u,P,i);w||(W="",G=0);let $t=G||",.!?:-@)>]}%#".indexOf(P[0])<0,Et=!w||!!G;$t&&w+G+J>y?(A.push(w),I.push(V),V=P,w=J,M.push(1),Q=-1):(V+=W+P,w+=G+J,Et&&M[M.length-1]++),W="",G=0,Et&&Q++,K=Math.max(K,w),F[B]={y:I.length*g,x:w-J,width:J,line:I.length,lineIndex:Q}}}return w&&(I.push(V),A.push(w)),I.length>1&&(K=y),{width:K,height:I.length*g}});let[Y,z]=yield,U="";i.position==="absolute"&&p.calculateLayout();let{left:X,top:O,width:C,height:v}=p.getComputedLayout(),L=Y+X,N=z+O,{matrix:H,opacity:l}=Ot({left:X,top:O,width:C,height:v,isInheritingTransform:a},i),h="";i.textShadowOffset&&(h=j({width:C,height:v,id:r},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let E="";for(let y=0;y<d.length;y++){if(!F[y])continue;let I=d[y],W=null,G=null,V=F[y].y,w=F[y].x,K=F[y].width,Q=g,B=C-A[F[y].line];if(x==="right"||x==="end")w+=B;else if(x==="center")w+=B/2;else if(x==="justify"){let P=F[y].line;if(P<A.length-1){let J=M[P];w+=(J>1?B/(J-1):0)*F[y].lineIndex}}b&&b[I]?G=b[I]:c?W=n.getSVG(u,I,Rt(q({},i),{left:L+w,top:N+V,letterSpacing:i.letterSpacing})):V+=$,W?E+=W+" ":U+=ut({content:I,filter:h,id:r,left:L+w,top:N+V,width:K,height:Q,matrix:H,opacity:l,image:G,debug:f},i)}if(E){let y="";f&&(y=`<rect x="${L}" y="${N}" width="${C}" height="${v}" fill="transparent" stroke="#575eff" stroke-width="1" ${H?`transform="${H}"`:""}></rect>`),U+=`${h?`${h}<g filter="url(#satori_s-${r})">`:""}<path fill="${i.color}" ${H?`transform="${H}"`:""} ${l!==1?`opacity="${l}"`:""} d="${E}"></path>${h?"</g>":""}${y}`}return U}import te from"parse-css-dimension";var pt=pt||{};pt.parse=function(){var 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:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},o="";function e(l){var h=new Error(o+": "+l);throw h.source=o,h}function i(){var l=s();return o.length>0&&e("Invalid input not EOF"),l}function s(){return x(n)}function n(){return r("linear-gradient",t.linearGradient,f)||r("repeating-linear-gradient",t.repeatingLinearGradient,f)||r("radial-gradient",t.radialGradient,m)||r("repeating-radial-gradient",t.repeatingRadialGradient,m)}function r(l,h,E){return a(h,function(y){var I=E();return I&&(N(t.comma)||e("Missing comma before color stops")),{type:l,orientation:I,colorStops:x(A)}})}function a(l,h){var E=N(l);if(E){N(t.startCall)||e("Missing (");var y=h(E);return N(t.endCall)||e("Missing )"),y}}function f(){return c()||b()}function c(){return L("directional",t.sideOrCorner,1)}function b(){return L("angular",t.angleValue,1)}function m(){var l,h=d(),E;return h&&(l=[],l.push(h),E=o,N(t.comma)&&(h=d(),h?l.push(h):o=E)),l}function d(){var l=p()||u();if(l)l.at=S();else{var h=$();if(h){l=h;var E=S();E&&(l.at=E)}else{var y=T();y&&(l={type:"default-radial",at:y})}}return l}function p(){var l=L("shape",/^(circle)/i,0);return l&&(l.style=v()||$()),l}function u(){var l=L("shape",/^(ellipse)/i,0);return l&&(l.style=O()||$()),l}function $(){return L("extent-keyword",t.extentKeywords,1)}function S(){if(L("position",/^at/,0)){var l=T();return l||e("Missing positioning value"),l}}function T(){var l=g();if(l.x||l.y)return{type:"position",value:l}}function g(){return{x:O(),y:O()}}function x(l){var h=l(),E=[];if(h)for(E.push(h);N(t.comma);)h=l(),h?E.push(h):e("One extra comma");return E}function A(){var l=M();return l||e("Expected color definition"),l.length=O(),l}function M(){return Y()||U()||z()||F()}function F(){return L("literal",t.literalColor,0)}function Y(){return L("hex",t.hexColor,1)}function z(){return a(t.rgbColor,function(){return{type:"rgb",value:x(X)}})}function U(){return a(t.rgbaColor,function(){return{type:"rgba",value:x(X)}})}function X(){return N(t.number)[1]}function O(){return L("%",t.percentageValue,1)||C()||v()}function C(){return L("position-keyword",t.positionKeywords,1)}function v(){return L("px",t.pixelValue,1)||L("em",t.emValue,1)}function L(l,h,E){var y=N(h);if(y)return{type:l,value:y[E]}}function N(l){var h,E;return E=/^[\n\r\t\s]+/.exec(o),E&&H(E[0].length),h=l.exec(o),h&&H(h[0].length),h}function H(l){o=o.substr(l)}return function(l){return o=l.toString(),i()}}();var Nt=pt;function ee(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function re(t,o){return typeof t=="string"&&t.endsWith("%")?o*parseFloat(t)/100:+t}function kt(t,{x:o,y:e,defaultX:i,defaultY:s}){return(t?t.split(" ").map(n=>{try{let r=new te(n);return r.type==="length"?r.value:r.value+r.unit}catch{return null}}).filter(n=>n!==null):[i,s]).map((n,r)=>re(n,[o,e][r]))}function gt({id:t,width:o,height:e},{image:i,size:s,position:n}){let r=kt(s,{x:o,y:e,defaultX:o,defaultY:e}),a=kt(n,{x:o,y:e,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let f=Nt.parse(i)[0],c,b,m,d;if(f.orientation.type==="directional")[c,b,m,d]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let g=+f.orientation.value/180*Math.PI-Math.PI/2,x=Math.cos(g),A=Math.sin(g);c=0,b=0,m=x,d=A,m<0&&(c-=m,m=0),d<0&&(b-=d,d=0)}let p=o,u=[];for(let g of f.colorStops){let x=ee(g);if(!u.length&&(u.push({offset:0,color:x}),typeof g.length=="undefined"||g.length.value==="0"))continue;let A=typeof g.length=="undefined"?void 0:g.length.type==="%"?g.length.value/100:g.length.value/p;u.push({offset:A,color:x})}u.length||u.push({offset:0,color:"transparent"});let $=u[u.length-1];$.offset!==1&&(typeof $.offset=="undefined"?$.offset=1:u.push({offset:1,color:$.color}));let S=0,T=1;for(let g=0;g<u.length;g++)if(typeof u[g].offset=="undefined"){for(T<g&&(T=g);typeof u[T].offset=="undefined";)T++;u[g].offset=(u[T].offset-u[S].offset)/(T-S)*(g-S)+u[S].offset}else S=g;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${c}" y1="${b}" x2="${m}" y2="${d}">${u.map(g=>`<stop offset="${g.offset*100}%" stop-color="${g.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("url(")){let f=i.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${r[0]}" height="${r[1]}"><image href="${f}" x="0" y="0" width="${r[0]}" height="${r[1]}"/></pattern>`]}}function it(t,o,e){return e<t+o&&(e/2<t&&e/2<o?t=o=e/2:e/2<t?t=e-o:e/2<o&&(o=e-t)),[t,o]}function rt({left:t,top:o,width:e,height:i},s){let{borderTopLeftRadius:n,borderTopRightRadius:r,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return n=Math.min(n||0,e,i),r=Math.min(r||0,e,i),a=Math.min(a||0,e,i),f=Math.min(f||0,e,i),!n&&!r&&!a&&!f?"":([n,r]=it(n,r,e),[n,a]=it(n,a,i),[r,f]=it(r,f,i),[a,f]=it(a,f,e),`M${t+n},${o} h${e-n-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+n-i} a${n},${n} 0 0 1 ${n},${-n}`)}function ht({id:t,left:o,top:e,width:i,height:s,isInheritingTransform:n,debug:r},a){if(a.display==="none")return"";let f="rect",c="transparent",b=0,m="",d="",p=[],u=1,$="";if(a.backgroundColor&&p.push(a.backgroundColor),a.borderWidth&&(b=a.borderWidth,c=a.borderColor),a.opacity&&(u=+a.opacity),a.transform&&(m=tt({left:o,top:e,width:i,height:s},a.transform,n)),a.backgroundImage){let g=a.backgroundImage.map((x,A)=>gt({id:t+"_"+A,width:i,height:s},x)).filter(Boolean);for(let x of g)d+=x[1],p.push(`url(#${x[0]})`)}let S=rt({left:o,top:e,width:i,height:s},a);S&&(f="path");let T=j({width:i,height:s,id:t},a);return p.length||p.push("transparent"),r&&($=`<rect x="${o}" y="${e}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${m?`transform="${m}"`:""}></rect>`),`${d?`<defs>${d}</defs>`:""}${T?`${T}<g filter="url(#satori_s-${t})">`:""}${u!==1?`<g opacity="${u}">`:""}${p.map((g,x)=>g==="transparent"&&!(x===p.length-1&&b)?"":`<${f} x="${o}" y="${e}" width="${i}" height="${s}" fill="${g}" ${x===p.length-1&&b?`stroke="${c}" stroke-width="${b}"`:""} ${S?`d="${S}"`:""} ${m?`transform="${m}"`:""}></${f}>`).join("")}${u!==1?"</g>":""}${T?"</g>":""}${$}`}function bt({id:t,left:o,top:e,width:i,height:s,src:n,debug:r},a){if(a.display==="none")return"";let f="",c=1,b=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",m=rt({left:o,top:e,width:i,height:s},a);m&&(f=`<clipPath id="satori_c-${t}"><path x="${o}" y="${e}" width="${i}" height="${s}" d="${m}"></path></clipPath>`),a.opacity&&(c=+a.opacity);let d=j({width:i,height:s,id:t},a);return`${d}${d?`<g filter="url(#satori_s-${t})">`:""}${f}<image href="${n}" x="${o}" y="${e}" width="${i}" height="${s}" preserveAspectRatio="${b}" ${f?`clip-path="url(#satori_c-${t})"`:""} ${c!==1?`opacity="${c}"`:""}></image>${d?"</g>":""}`}function*nt(t,o){let e=D(),{id:i,inheritedStyle:s,parent:n,font:r,debug:a,embedFont:f=!0,graphemeImages:c}=o;if(t===null||typeof t=="undefined")return yield,"";if(!st(t)||typeof t.type=="function"){let C;if(!st(t))C=dt(String(t),o);else{if(It(t.type))throw new Error("Class component is not supported.");C=nt(t.type(t.props),o)}C.next();let v=yield;return C.next(v).value}let{type:b,props:m}=t,{style:d,children:p}=m,u=e.Node.create();n.insertChild(u,n.getChildCount());let[$,S]=lt(u,b,s,d,m),T=$.transform===s.transform;T||($.transform.__parent=s.transform);let g=typeof p=="undefined"?[]:[].concat(p),x=[],A=0;for(let C of g){let v=nt(C,{id:i*g.length+ ++A,parentStyle:$,inheritedStyle:S,isInheritingTransform:!0,parent:u,font:r,embedFont:f,debug:a,graphemeImages:c});v.next(),x.push(v)}let[M,F]=yield;$.position==="absolute"&&u.calculateLayout();let{left:Y,top:z,width:U,height:X}=u.getComputedLayout();Y+=M,z+=F;let O="";b==="img"?O=bt({id:i,left:Y,top:z,width:U,height:X,src:m.src,isInheritingTransform:T,debug:a},$):O=ht({id:i,left:Y,top:z,width:U,height:X,isInheritingTransform:T,debug:a},$);for(let C of x)O+=C.next([Y,z]).value;return O}import vt from"@shuding/opentype.js";var at=class{constructor(o){this.fonts=new Map;for(let e of o){let i=e.data,s="buffer"in i?vt.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):vt.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([s,e.weight,e.style])}}get({name:o,weight:e,style:i}){if(!this.fonts.has(o))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let s=[...this.fonts.get(o)];return s.sort(([n,r,a],[f,c,b])=>{if(r!==c)return r?!c||r===e?-1:c===e?1:e===400&&r===500||e===500&&r===400?-1:e===400&&c===500||e===500&&c===400?1:e<400?r<e&&c<e?c-r:r<e?-1:c<e?1:r-c:e<r&&e<c?r-c:e<r?-1:e<c?1:c-r:1;if(a!==b){if(a===i)return-1;if(b===i)return 1}return-1}),s[0][0]}getFont({fontFamily:o,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:o,weight:e,style:i})}measure(o,e,{fontSize:i,letterSpacing:s=0}){return o.getAdvanceWidth(e,i,{letterSpacing:s/i})}getSVG(o,e,{fontSize:i,top:s,left:n,letterSpacing:r=0}){return s+=o.ascender/o.unitsPerEm*i,o.getPath(e,n,s,i,{letterSpacing:r/i}).toPathData(1)}};function yt({width:t,height:o,content:e},i){return`<svg width="${t}" height="${o}" viewBox="0 0 ${t} ${o}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}var xt=new WeakMap;function Wt(t,o){let e=D();if(!e)throw new Error("Satori is not initialized.");let i;xt.has(o.fonts)?i=xt.get(o.fonts):xt.set(o.fonts,i=new at(o.fonts));let s=e.Node.create();s.setWidth(o.width),s.setHeight(o.height),s.setFlexDirection(e.FLEX_DIRECTION_ROW),s.setFlexWrap(e.WRAP_WRAP),s.setAlignContent(e.ALIGN_AUTO),s.setAlignItems(e.ALIGN_FLEX_START),s.setJustifyContent(e.JUSTIFY_FLEX_START);let n=nt(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:o.embedFont,debug:o.debug,graphemeImages:o.graphemeImages});n.next(),s.calculateLayout(o.width,o.height,e.DIRECTION_LTR);let r=n.next([0,0]).value;return yt({width:o.width,height:o.height,content:r})}export{Wt as default,Yt as init};
var De=Object.defineProperty,Me=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var Te=Object.getOwnPropertySymbols;var Ye=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var _e=(e,n,t)=>n in e?De(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,B=(e,n)=>{for(var t in n||(n={}))Ye.call(n,t)&&_e(e,t,n[t]);if(Te)for(var t of Te(n))Ue.call(n,t)&&_e(e,t,n[t]);return e},Ie=(e,n)=>Me(e,Be(n));var Le;function Xe(e){Le=e}function Y(){return Le}function se(e){let n=typeof e;return!(n==="number"||n==="bigint"||n==="string"||n==="boolean")}function we(e){return/^class\s/.test(Function.prototype.toString.call(e))}function Z(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}function N(e,n,t){let i=n[e];return typeof i=="undefined"?t:i}var Ae={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var ze=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function fe(e){let n={};for(let t in e)ze.has(t)&&(n[t]=e[t]);return n}import{getPropertyName as ve,getStylesForProperty as je}from"css-to-react-native";import Oe from"parse-css-dimension";import{parseElementStyle as Ke}from"css-background-parser";import He from"postcss-value-parser";import Ve from"parse-css-dimension";function Je(e,n){try{let t=new Ve(e);switch(t.unit){case"px":return{absolute:t.value};case"em":return{absolute:t.value*n};case"rem":return{absolute:t.value*16};case"%":return{relative:t.value};default:return{}}}catch{return{}}}function le(e,n,t){switch(e){case"top":return{yRelative:0};case"left":return{xRelative:0};case"right":return{xRelative:100};case"bottom":return{yRelative:100};case"center":return{};default:let i=Je(e,n);return i.absolute?{[t?"xAbsolute":"yAbsolute"]:i.absolute}:i.relative?{[t?"xRelative":"yRelative"]:i.relative}:{}}}function ue(e,n){if(typeof e=="number")return{xAbsolute:e};let t;try{t=He(e).nodes.filter(i=>i.type==="word").map(i=>i.value)}catch{return{}}return t.length===1?le(t[0],n,!0):t.length===2?((t[0]==="top"||t[0]==="bottom"||t[1]==="left"||t[1]==="right")&&t.reverse(),B(B({},le(t[0],n,!0)),le(t[1],n,!1))):{}}var qe=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Ce=[1,0,0,1,0,0];function Ze(e,n){return typeof n=="number"?qe.has(e)?String(n):n+"px":n}function Fe(e,n){if(typeof e=="number")return e;try{let t=new Oe(e);if(t.type==="length")switch(t.unit){case"em":return t.value*n;case"rem":return t.value*16;default:return t.value}else if(t.type==="angle")switch(t.unit){case"deg":return t.value;case"rad":return t.value*180/Math.PI;default:return t.value}}catch{}}function oe(e,n){let t=[];for(let o in e){let r=ve(o);t.push([r,Ze(r,e[o])])}let i=t.reduce((o,r)=>{let a=ve(r[0]),f=r[1];return Object.assign(o,je(a,f,!0))},{});if(i.backgroundImage){let{backgrounds:o}=Ke(i);i.backgroundImage=o}let s=i.fontSize||n.fontSize;if(typeof s=="string")try{let o=new Oe(s);switch(o.unit){case"em":s=o.value*n.fontSize;break;case"rem":s=o.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s),i.transformOrigin&&(i.transformOrigin=ue(i.transformOrigin,s));for(let o in i){let r=i[o];if(typeof r=="string"){let a=Fe(r,s);typeof a!="undefined"&&(i[o]=a),r=i[o]}if(o==="opacity"&&(r=i[o]=r*n.opacity),o==="transform"){let a=[...Ce],f=r;for(let c of f){let b=Object.keys(c)[0],d=c[b],m=typeof d=="string"?Fe(d,s):d,p=[...Ce];switch(b){case"translateX":p[4]=m;break;case"translateY":p[5]=m;break;case"scaleX":p[0]=m;break;case"scaleY":p[3]=m;break;case"rotate":let u=m*Math.PI/180,y=Math.cos(u),T=Math.sin(u);p[0]=y,p[1]=T,p[2]=-T,p[3]=y;break;case"skewX":p[2]=Math.tan(m*Math.PI/180);break;case"skewY":p[1]=Math.tan(m*Math.PI/180);break}a=Z(p,a)}i.transform=a}}return i}function ce(e,n,t,i,s){let o=Y(),r=B(B(B({},t),oe(Ae[n],t)),oe(i,t));if(n==="img"){let a=parseInt(s.width),c=parseInt(s.height)/a;r.width||(r.width=a),r.height||(r.height=c*r.width)}return e.setDisplay(N(r.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),e.setAlignContent(N(r.alignContent,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,"space-between":o.ALIGN_SPACE_BETWEEN,"space-around":o.ALIGN_SPACE_AROUND,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setAlignItems(N(r.alignItems,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_FLEX_START)),e.setAlignSelf(N(r.alignSelf,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),e.setJustifyContent(N(r.justifyContent,{center:o.JUSTIFY_CENTER,"flex-start":o.JUSTIFY_FLEX_START,"flex-end":o.JUSTIFY_FLEX_END,"space-between":o.JUSTIFY_SPACE_BETWEEN,"space-around":o.JUSTIFY_SPACE_AROUND},o.JUSTIFY_FLEX_START)),e.setFlexDirection(N(r.flexDirection,{row:o.FLEX_DIRECTION_ROW,column:o.FLEX_DIRECTION_COLUMN,"row-reverse":o.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":o.FLEX_DIRECTION_COLUMN_REVERSE},o.FLEX_DIRECTION_ROW)),e.setFlexWrap(N(r.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&e.setFlexBasis(r.flexBasis),e.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),e.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&e.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&e.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&e.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&e.setMinWidth(r.minWidth),e.setOverflow(N(r.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),e.setMargin(o.EDGE_TOP,r.marginTop||0),e.setMargin(o.EDGE_BOTTOM,r.marginBottom||0),e.setMargin(o.EDGE_LEFT,r.marginLeft||0),e.setMargin(o.EDGE_RIGHT,r.marginRight||0),e.setBorder(o.EDGE_TOP,r.borderWidth||0),e.setBorder(o.EDGE_BOTTOM,r.borderWidth||0),e.setBorder(o.EDGE_LEFT,r.borderWidth||0),e.setBorder(o.EDGE_RIGHT,r.borderWidth||0),e.setPadding(o.EDGE_TOP,r.paddingTop||0),e.setPadding(o.EDGE_BOTTOM,r.paddingBottom||0),e.setPadding(o.EDGE_LEFT,r.paddingLeft||0),e.setPadding(o.EDGE_RIGHT,r.paddingRight||0),e.setPositionType(N(r.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&e.setPosition(o.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&e.setPosition(o.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&e.setPosition(o.EDGE_LEFT,r.left),typeof r.right!="undefined"&&e.setPosition(o.EDGE_RIGHT,r.right),typeof r.height!="undefined"?e.setHeight(r.height):e.setHeightAuto(),typeof r.width!="undefined"?e.setWidth(r.width):e.setWidthAuto(),[r,fe(r)]}import{LineBreaker as Qe}from"css-line-break";import{splitGraphemes as et}from"text-segmentation";function ee({left:e,top:n,width:t,height:i},s,o,r){var f,c,b,d;let a;if(o)a=s;else{let m=(c=r==null?void 0:r.xAbsolute)!=null?c:((f=r==null?void 0:r.xRelative)!=null?f:50)*t/100,p=(d=r==null?void 0:r.yAbsolute)!=null?d:((b=r==null?void 0:r.yRelative)!=null?b:50)*i/100,u=e+m,y=n+p;a=Z([1,0,0,1,u,y],Z(s,[1,0,0,1,-u,-y])),s.__parent&&(a=Z(s.__parent,a)),s.splice(0,6,...a)}return`matrix(${a.map(m=>m.toFixed(2)).join(",")})`}function Ne({left:e,top:n,width:t,height:i,isInheritingTransform:s},o){let r="",a=1;return o.transform&&(r=ee({left:e,top:n,width:t,height:i},o.transform,s,o.transformOrigin)),o.opacity&&(a=+o.opacity),{matrix:r,opacity:a}}function me({id:e,content:n,filter:t,left:i,top:s,width:o,height:r,matrix:a,opacity:f,image:c,debug:b},d){let m="";return b&&(m=`<rect x="${i}" y="${s}" width="${o}" height="0.5" fill="transparent" stroke="#575eff" stroke-width="1" ${a?`transform="${a}"`:""}></rect>`),c?`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<image href="${c}" x="${i}" y="${s}" width="${o}" height="${r}" ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${t?"</g>":""}${m}`:`${t?`${t}<g filter="url(#satori_s-${e})">`:""}<text x="${i}" y="${s}" width="${o}" height="${r}" fill="${d.color}" font-weight="${d.fontWeight}" font-style="${d.fontStyle}" font-size="${d.fontSize}" font-family="${d.fontFamily}" ${d.letterSpacing?`letter-spacing="${d.letterSpacing}"`:""} ${a?`transform="${a}"`:""} ${f!==1?`opacity="${f}"`:""}>${n}</text>${t?"</g>":""}${m}`}function K({id:e,width:n,height:t},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-s,0),r=Math.max(i.shadowOffset.width+s+n,n),a=Math.min(i.shadowOffset.height-s,0),f=Math.max(i.shadowOffset.height+s+t,t);return`<defs><filter id="satori_s-${e}" x="${o/n*100}%" y="${a/t*100}%" width="${(r-o)/n*100}%" height="${(f-a)/t*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var te=void 0,pe=typeof Intl!="undefined"&&"Segmenter"in Intl,tt=pe?new Intl.Segmenter(te,{granularity:"word"}):null,rt=pe?new Intl.Segmenter(te,{granularity:"grapheme"}):null,nt=[32,160,4961,65792,65793,4153,4241],ot=e=>{let n=Qe(e,{lineBreak:"strict",wordBreak:"normal"}),t=[],i;for(;!(i=n.next()).done;)if(i.value){let s=i.value.slice(),o=[].map.call(s,a=>a.codePointAt(0)),r="";o.forEach(a=>{nt.includes(a)?(r.length&&t.push(r),t.push(String.fromCodePoint(a)),r=""):r+=String.fromCodePoint(a)}),r.length&&t.push(r)}return t};function de(e,n){return pe?n==="word"?[...tt.segment(e)].map(t=>t.segment):[...rt.segment(e)].map(t=>t.segment):n==="word"?ot(e):et(e)}function*ge(e,n){let t=Y(),{parentStyle:i,parent:s,font:o,id:r,isInheritingTransform:a,debug:f,embedFont:c,graphemeImages:b}=n;i.textTransform==="uppercase"?e=e.toLocaleUpperCase(te):i.textTransform==="lowercase"?e=e.toLocaleLowerCase(te):i.textTransform==="capitalize"&&(e=de(e,"word").map(x=>de(x,"grapheme").map((I,W)=>W===0?I.toLocaleUpperCase(te):I).join("")).join(""));let d=N(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),m=de(e,d),p=t.Node.create();p.setAlignItems(t.ALIGN_BASELINE),i.textAlign==="left"?p.setJustifyContent(t.JUSTIFY_FLEX_START):i.textAlign==="center"?p.setJustifyContent(t.JUSTIFY_CENTER):i.textAlign==="right"?p.setJustifyContent(t.JUSTIFY_FLEX_END):i.textAlign==="justify"&&p.setJustifyContent(t.JUSTIFY_SPACE_BETWEEN),s.insertChild(p,s.getChildCount());let u=o.getFont(i),y=u.ascender/u.unitsPerEm*i.fontSize,T=-(u.descender/u.unitsPerEm)*i.fontSize,g=(y+T)*1.2,{textAlign:$}=i,A=[],D=[],C=[];p.setMeasureFunc(x=>{let I=[],W="",P=0,J="",w=0,q=0,Q=-1;A=[],D=[0];for(let M=0;M<m.length;M++){let G=m[M];if([" ",`
`," ","\u3000"].includes(G))W+=G,P=o.measure(u,W,i),C[M]=null;else{let j=b&&b[G]?i.fontSize:o.measure(u,G,i);w||(W="",P=0);let Se=P||",.!?:-@)>]}%#".indexOf(G[0])<0,Re=!w||!!P;Se&&w+P+j>x?(A.push(w),I.push(J),J=G,w=j,D.push(1),Q=-1):(J+=W+G,w+=P+j,Re&&D[D.length-1]++),W="",P=0,Re&&Q++,q=Math.max(q,w),C[M]={y:I.length*g,x:w-j,width:j,line:I.length,lineIndex:Q}}}return w&&(I.push(J),A.push(w)),I.length>1&&(q=x),{width:q,height:I.length*g}});let[U,X]=yield,z="";i.position==="absolute"&&p.calculateLayout();let{left:H,top:F,width:v,height:k}=p.getComputedLayout(),L=U+H,O=X+F,{matrix:V,opacity:l}=Ne({left:H,top:F,width:v,height:k,isInheritingTransform:a},i),h="";i.textShadowOffset&&(h=K({width:v,height:k,id:r},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let E="";for(let x=0;x<m.length;x++){if(!C[x])continue;let I=m[x],W=null,P=null,J=C[x].y,w=C[x].x,q=C[x].width,Q=g,M=v-A[C[x].line];if($==="right"||$==="end")w+=M;else if($==="center")w+=M/2;else if($==="justify"){let G=C[x].line;if(G<A.length-1){let j=D[G];w+=(j>1?M/(j-1):0)*C[x].lineIndex}}b&&b[I]?P=b[I]:c?W=o.getSVG(u,I,Ie(B({},i),{left:L+w,top:O+J,letterSpacing:i.letterSpacing})):J+=y,W?E+=W+" ":z+=me({content:I,filter:h,id:r,left:L+w,top:O+J,width:q,height:Q,matrix:V,opacity:l,image:P,debug:f},i)}if(E){let x="";f&&(x=`<rect x="${L}" y="${O}" width="${v}" height="${k}" fill="transparent" stroke="#575eff" stroke-width="1" ${V?`transform="${V}"`:""}></rect>`),z+=`${h?`${h}<g filter="url(#satori_s-${r})">`:""}<path fill="${i.color}" ${V?`transform="${V}"`:""} ${l!==1?`opacity="${l}"`:""} d="${E}"></path>${h?"</g>":""}${x}`}return z}import it from"parse-css-dimension";var he=he||{};he.parse=function(){var e={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:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},n="";function t(l){var h=new Error(n+": "+l);throw h.source=n,h}function i(){var l=s();return n.length>0&&t("Invalid input not EOF"),l}function s(){return $(o)}function o(){return r("linear-gradient",e.linearGradient,f)||r("repeating-linear-gradient",e.repeatingLinearGradient,f)||r("radial-gradient",e.radialGradient,d)||r("repeating-radial-gradient",e.repeatingRadialGradient,d)}function r(l,h,E){return a(h,function(x){var I=E();return I&&(O(e.comma)||t("Missing comma before color stops")),{type:l,orientation:I,colorStops:$(A)}})}function a(l,h){var E=O(l);if(E){O(e.startCall)||t("Missing (");var x=h(E);return O(e.endCall)||t("Missing )"),x}}function f(){return c()||b()}function c(){return L("directional",e.sideOrCorner,1)}function b(){return L("angular",e.angleValue,1)}function d(){var l,h=m(),E;return h&&(l=[],l.push(h),E=n,O(e.comma)&&(h=m(),h?l.push(h):n=E)),l}function m(){var l=p()||u();if(l)l.at=T();else{var h=y();if(h){l=h;var E=T();E&&(l.at=E)}else{var x=_();x&&(l={type:"default-radial",at:x})}}return l}function p(){var l=L("shape",/^(circle)/i,0);return l&&(l.style=k()||y()),l}function u(){var l=L("shape",/^(ellipse)/i,0);return l&&(l.style=F()||y()),l}function y(){return L("extent-keyword",e.extentKeywords,1)}function T(){if(L("position",/^at/,0)){var l=_();return l||t("Missing positioning value"),l}}function _(){var l=g();if(l.x||l.y)return{type:"position",value:l}}function g(){return{x:F(),y:F()}}function $(l){var h=l(),E=[];if(h)for(E.push(h);O(e.comma);)h=l(),h?E.push(h):t("One extra comma");return E}function A(){var l=D();return l||t("Expected color definition"),l.length=F(),l}function D(){return U()||z()||X()||C()}function C(){return L("literal",e.literalColor,0)}function U(){return L("hex",e.hexColor,1)}function X(){return a(e.rgbColor,function(){return{type:"rgb",value:$(H)}})}function z(){return a(e.rgbaColor,function(){return{type:"rgba",value:$(H)}})}function H(){return O(e.number)[1]}function F(){return L("%",e.percentageValue,1)||v()||k()}function v(){return L("position-keyword",e.positionKeywords,1)}function k(){return L("px",e.pixelValue,1)||L("em",e.emValue,1)}function L(l,h,E){var x=O(h);if(x)return{type:l,value:x[E]}}function O(l){var h,E;return E=/^[\n\r\t\s]+/.exec(n),E&&V(E[0].length),h=l.exec(n),h&&V(h[0].length),h}function V(l){n=n.substr(l)}return function(l){return n=l.toString(),i()}}();var ke=he;function at(e){return e.type==="literal"?e.value:e.type==="hex"?`#${e.value}`:e.type==="rgb"?`rgb(${e.value.join(",")})`:e.type==="rgba"?`rgba(${e.value.join(",")})`:"transparent"}function st(e,n){return typeof e=="string"&&e.endsWith("%")?n*parseFloat(e)/100:+e}function We(e,{x:n,y:t,defaultX:i,defaultY:s}){return(e?e.split(" ").map(o=>{try{let r=new it(o);return r.type==="length"?r.value:r.value+r.unit}catch{return null}}).filter(o=>o!==null):[i,s]).map((o,r)=>st(o,[n,t][r]))}function be({id:e,width:n,height:t},{image:i,size:s,position:o}){let r=We(s,{x:n,y:t,defaultX:n,defaultY:t}),a=We(o,{x:n,y:t,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let f=ke.parse(i)[0],c,b,d,m;if(f.orientation.type==="directional")[c,b,d,m]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[f.orientation.value];else if(f.orientation.type==="angular"){let g=+f.orientation.value/180*Math.PI-Math.PI/2,$=Math.cos(g),A=Math.sin(g);c=0,b=0,d=$,m=A,d<0&&(c-=d,d=0),m<0&&(b-=m,m=0)}let p=n,u=[];for(let g of f.colorStops){let $=at(g);if(!u.length&&(u.push({offset:0,color:$}),typeof g.length=="undefined"||g.length.value==="0"))continue;let A=typeof g.length=="undefined"?void 0:g.length.type==="%"?g.length.value/100:g.length.value/p;u.push({offset:A,color:$})}u.length||u.push({offset:0,color:"transparent"});let y=u[u.length-1];y.offset!==1&&(typeof y.offset=="undefined"?y.offset=1:u.push({offset:1,color:y.color}));let T=0,_=1;for(let g=0;g<u.length;g++)if(typeof u[g].offset=="undefined"){for(_<g&&(_=g);typeof u[_].offset=="undefined";)_++;u[g].offset=(u[_].offset-u[T].offset)/(_-T)*(g-T)+u[T].offset}else T=g;return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${c}" y1="${b}" x2="${d}" y2="${m}">${u.map(g=>`<stop offset="${g.offset*100}%" stop-color="${g.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("url(")){let f=i.slice(4,-1);return[`satori_bi${e}`,`<pattern id="satori_bi${e}" patternContentUnits="userSpaceOnUse" patternUnits="userSpaceOnUse" x="${a[0]}" y="${a[1]}" width="${r[0]}" height="${r[1]}"><image href="${f}" x="0" y="0" width="${r[0]}" height="${r[1]}"/></pattern>`]}}function ie(e,n,t){return t<e+n&&(t/2<e&&t/2<n?e=n=t/2:t/2<e?e=t-n:t/2<n&&(n=t-e)),[e,n]}function re({left:e,top:n,width:t,height:i},s){let{borderTopLeftRadius:o,borderTopRightRadius:r,borderBottomLeftRadius:a,borderBottomRightRadius:f}=s;return o=Math.min(o||0,t,i),r=Math.min(r||0,t,i),a=Math.min(a||0,t,i),f=Math.min(f||0,t,i),!o&&!r&&!a&&!f?"":([o,r]=ie(o,r,t),[o,a]=ie(o,a,i),[r,f]=ie(r,f,i),[a,f]=ie(a,f,t),`M${e+o},${n} h${t-o-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-f} a${f},${f} 0 0 1 ${-f},${f} h${f+a-t} a${a},${a} 0 0 1 ${-a},${-a} v${a+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function ye({id:e,left:n,top:t,width:i,height:s,isInheritingTransform:o,debug:r},a){if(a.display==="none")return"";let f="rect",c="transparent",b=0,d="",m="",p=[],u=1,y="";if(a.backgroundColor&&p.push(a.backgroundColor),a.borderWidth&&(b=a.borderWidth,c=a.borderColor),a.opacity&&(u=+a.opacity),a.transform&&(d=ee({left:n,top:t,width:i,height:s},a.transform,o,a.transformOrigin)),a.backgroundImage){let g=a.backgroundImage.map(($,A)=>be({id:e+"_"+A,width:i,height:s},$)).filter(Boolean);for(let $ of g)m+=$[1],p.push(`url(#${$[0]})`)}let T=re({left:n,top:t,width:i,height:s},a);T&&(f="path");let _=K({width:i,height:s,id:e},a);return p.length||p.push("transparent"),r&&(y=`<rect x="${n}" y="${t}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${d?`transform="${d}"`:""}></rect>`),`${m?`<defs>${m}</defs>`:""}${_?`${_}<g filter="url(#satori_s-${e})">`:""}${u!==1?`<g opacity="${u}">`:""}${p.map((g,$)=>g==="transparent"&&!($===p.length-1&&b)?"":`<${f} x="${n}" y="${t}" width="${i}" height="${s}" fill="${g}" ${$===p.length-1&&b?`stroke="${c}" stroke-width="${b}"`:""} ${T?`d="${T}"`:""} ${d?`transform="${d}"`:""}></${f}>`).join("")}${u!==1?"</g>":""}${_?"</g>":""}${y}`}function xe({id:e,left:n,top:t,width:i,height:s,src:o,debug:r},a){if(a.display==="none")return"";let f="",c=1,b=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",d=re({left:n,top:t,width:i,height:s},a);d&&(f=`<clipPath id="satori_c-${e}"><path x="${n}" y="${t}" width="${i}" height="${s}" d="${d}"></path></clipPath>`),a.opacity&&(c=+a.opacity);let m=K({width:i,height:s,id:e},a);return`${m}${m?`<g filter="url(#satori_s-${e})">`:""}${f}<image href="${o}" x="${n}" y="${t}" width="${i}" height="${s}" preserveAspectRatio="${b}" ${f?`clip-path="url(#satori_c-${e})"`:""} ${c!==1?`opacity="${c}"`:""}></image>${m?"</g>":""}`}function*ne(e,n){let t=Y(),{id:i,inheritedStyle:s,parent:o,font:r,debug:a,embedFont:f=!0,graphemeImages:c}=n;if(e===null||typeof e=="undefined")return yield,"";if(!se(e)||typeof e.type=="function"){let v;if(!se(e))v=ge(String(e),n);else{if(we(e.type))throw new Error("Class component is not supported.");v=ne(e.type(e.props),n)}v.next();let k=yield;return v.next(k).value}let{type:b,props:d}=e,{style:m,children:p}=d,u=t.Node.create();o.insertChild(u,o.getChildCount());let[y,T]=ce(u,b,s,m,d),_=y.transform===s.transform;_||(y.transform.__parent=s.transform);let g=typeof p=="undefined"?[]:[].concat(p),$=[],A=0;for(let v of g){let k=ne(v,{id:i*g.length+ ++A,parentStyle:y,inheritedStyle:T,isInheritingTransform:!0,parent:u,font:r,embedFont:f,debug:a,graphemeImages:c});k.next(),$.push(k)}let[D,C]=yield;y.position==="absolute"&&u.calculateLayout();let{left:U,top:X,width:z,height:H}=u.getComputedLayout();U+=D,X+=C;let F="";b==="img"?F=xe({id:i,left:U,top:X,width:z,height:H,src:d.src,isInheritingTransform:_,debug:a},y):F=ye({id:i,left:U,top:X,width:z,height:H,isInheritingTransform:_,debug:a},y);for(let v of $)F+=v.next([U,X]).value;return F}import Pe from"@shuding/opentype.js";var ae=class{constructor(n){this.fonts=new Map;for(let t of n){let i=t.data,s="buffer"in i?Pe.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):Pe.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(t.name)||this.fonts.set(t.name,[]),this.fonts.get(t.name).push([s,t.weight,t.style])}}get({name:n,weight:t,style:i}){if(!this.fonts.has(n))return this.defaultFont;t==="normal"&&(t=400),t==="bold"&&(t=700);let s=[...this.fonts.get(n)];return s.sort(([o,r,a],[f,c,b])=>{if(r!==c)return r?!c||r===t?-1:c===t?1:t===400&&r===500||t===500&&r===400?-1:t===400&&c===500||t===500&&c===400?1:t<400?r<t&&c<t?c-r:r<t?-1:c<t?1:r-c:t<r&&t<c?r-c:t<r?-1:t<c?1:c-r:1;if(a!==b){if(a===i)return-1;if(b===i)return 1}return-1}),s[0][0]}getFont({fontFamily:n,fontWeight:t=400,fontStyle:i="normal"}){return this.get({name:n,weight:t,style:i})}measure(n,t,{fontSize:i,letterSpacing:s=0}){return n.getAdvanceWidth(t,i,{letterSpacing:s/i})}getSVG(n,t,{fontSize:i,top:s,left:o,letterSpacing:r=0}){return s+=n.ascender/n.unitsPerEm*i,n.getPath(t,o,s,i,{letterSpacing:r/i}).toPathData(1)}};function $e({width:e,height:n,content:t},i){return`<svg width="${e}" height="${n}" viewBox="0 0 ${e} ${n}" xmlns="http://www.w3.org/2000/svg">${t}</svg>`}var Ee=new WeakMap;function Ge(e,n){let t=Y();if(!t)throw new Error("Satori is not initialized.");let i;Ee.has(n.fonts)?i=Ee.get(n.fonts):Ee.set(n.fonts,i=new ae(n.fonts));let s=t.Node.create();s.setWidth(n.width),s.setHeight(n.height),s.setFlexDirection(t.FLEX_DIRECTION_ROW),s.setFlexWrap(t.WRAP_WRAP),s.setAlignContent(t.ALIGN_AUTO),s.setAlignItems(t.ALIGN_FLEX_START),s.setJustifyContent(t.JUSTIFY_FLEX_START);let o=ne(e,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:n.embedFont,debug:n.debug,graphemeImages:n.graphemeImages});o.next(),s.calculateLayout(n.width,n.height,t.DIRECTION_LTR);let r=o.next([0,0]).value;return $e({width:n.width,height:n.height,content:r})}export{Ge as default,Xe as init};
//# sourceMappingURL=index.wasm.js.map
{
"name": "satori",
"version": "0.0.14",
"version": "0.0.15",
"description": "Satori converts HTML JSX to SVG string.",

@@ -60,2 +60,3 @@ "module": "./dist/esm/index.js",

"parse-css-dimension": "^1.1.0",
"postcss-value-parser": "^4.2.0",
"text-segmentation": "^1.0.3",

@@ -62,0 +63,0 @@ "yoga-layout-prebuilt": "^1.10.0"

@@ -145,2 +145,3 @@ <h1 align="center">

| `transform` | Support absolute values |
| `transform-origin` | Support one-value and two-value syntax (both relative and absolute values) |
| `object-fit` | `contain`, `cover`, `none` |

@@ -159,3 +160,2 @@ | `opacity` | Supported |

| `text-decoration` | TBD |
| `transform-origin` | TBD |
| `line-height` | TBD |

@@ -162,0 +162,0 @@ | `white-space` | TBD |

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc