satori 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Bt=Object.defineProperty,Ut=Object.defineProperties;var Yt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var ht=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var mt=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D=(e,t)=>{for(var n in t||(t={}))ht.call(t,n)&&mt(e,n,t[n]);if(_e)for(var n of _e(t))bt.call(t,n)&&mt(e,n,t[n]);return e},se=(e,t)=>Ut(e,Yt(t));var yt=(e,t)=>{var n={};for(var r in e)ht.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_e)for(var r of _e(e))t.indexOf(r)<0&&bt.call(e,r)&&(n[r]=e[r]);return n};import*as zt from"yoga-layout-prebuilt";var xt=zt;var Ne;Ne=xt.default;function Ht(e){Ne=e}function te(){return Ne}function De(e){let t=typeof e;return!(t==="number"||t==="bigint"||t==="string"||t==="boolean")}function wt(e){return/^class\s/.test(Function.prototype.toString.call(e))}function me(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function Z(e,t,n){let r=t[e];return typeof r=="undefined"?n:r}var Et=void 0,Be=typeof Intl!="undefined"&&"Segmenter"in Intl;if(!Be)throw new Error("Intl.Segmenter does not exist, please use import a polyfill.");var Xt=Be?new Intl.Segmenter(Et,{granularity:"word"}):null,jt=Be?new Intl.Segmenter(Et,{granularity:"grapheme"}):null,Ce=[32,160,4961,65792,65793,4153,4241,10].map(e=>String.fromCodePoint(e));function le(e,t){return t==="word"?[...Xt.segment(e)].map(n=>n.segment):[...jt.segment(e)].map(n=>n.segment)}function y(e,t,n){let r="";for(let[a,o]of Object.entries(t))typeof o!="undefined"&&(r+=` ${a}="${o}"`);return n?`<${e}${r}>${n}</${e}>`:`<${e}${r}/>`}function vt(e=20){let t=new Map;function n(a,o){if(t.size>=e){let i=t.keys().next().value;t.delete(i)}t.set(a,o)}function r(a){if(!t.has(a))return;let i=t.get(a);return t.delete(a),t.set(a,i),i}return{set:n,get:r}}var Vt={accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",allowReorder:"allowreorder",arabicForm:"arabic-form",attributeName:"attributename",attributeType:"attributetype",autoReverse:"autoreverse",baseFrequency:"basefrequency",baseProfile:"baseprofile",baselineShift:"baseline-shift",calcMode:"calcmode",capHeight:"cap-height",clipPath:"clip-path",clipPathUnits:"clippathunits",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentscripttype",contentStyleType:"contentstyletype",diffuseConstant:"diffuseconstant",dominantBaseline:"dominant-baseline",edgeMode:"edgemode",enableBackground:"enable-background",externalResourcesRequired:"externalresourcesrequired",fillOpacity:"fill-opacity",fillRule:"fill-rule",filterRes:"filterres",filterUnits:"filterunits",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphref",gradientTransform:"gradienttransform",gradientUnits:"gradientunits",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",imageRendering:"image-rendering",kernelMatrix:"kernelmatrix",kernelUnitLength:"kernelunitlength",keyPoints:"keypoints",keySplines:"keysplines",keyTimes:"keytimes",lengthAdjust:"lengthadjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingconeangle",markerEnd:"marker-end",markerHeight:"markerheight",markerMid:"marker-mid",markerStart:"marker-start",markerUnits:"markerunits",markerWidth:"markerwidth",maskContentUnits:"maskcontentunits",maskUnits:"maskunits",numOctaves:"numoctaves",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathlength",patternContentUnits:"patterncontentunits",patternTransform:"patterntransform",patternUnits:"patternunits",pointerEvents:"pointer-events",pointsAtX:"pointsatx",pointsAtY:"pointsaty",pointsAtZ:"pointsatz",preserveAlpha:"preservealpha",preserveAspectRatio:"preserveaspectratio",primitiveUnits:"primitiveunits",refX:"refx",refY:"refy",renderingIntent:"rendering-intent",repeatCount:"repeatcount",repeatDur:"repeatdur",requiredExtensions:"requiredextensions",requiredFeatures:"requiredfeatures",shapeRendering:"shape-rendering",specularConstant:"specularconstant",specularExponent:"specularexponent",spreadMethod:"spreadmethod",startOffset:"startoffset",stdDeviation:"stddeviation",stitchTiles:"stitchtiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",suppressContentEditableWarning:"suppresscontenteditablewarning",suppressHydrationWarning:"suppresshydrationwarning",surfaceScale:"surfacescale",systemLanguage:"systemlanguage",tableValues:"tablevalues",targetX:"targetx",targetY:"targety",textAnchor:"text-anchor",textDecoration:"text-decoration",textLength:"textlength",textRendering:"text-rendering",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewbox",viewTarget:"viewtarget",wordSpacing:"word-spacing",writingMode:"writing-mode",xChannelSelector:"xchannelselector",xHeight:"x-height",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlLang:"xml:lang",xmlSpace:"xmlspace",xmlnsXlink:"xmlns:xlink",yChannelSelector:"ychannelselector",zoomAndPan:"zoomandpan"},Jt=/[\r\n%#()<>?[\\\]^`{|}"']/g;function Ge(e){if(!e)return"";if(Array.isArray(e))return e.map(Ge).join("");if(typeof e!="object")return String(e);let t=e.type;if(t==="text")throw new Error("<text> nodes are not currently supported, please convert them to <path>");let a=e.props||{},{children:n}=a,r=yt(a,["children"]);return`<${t}${Object.entries(r).map(([o,i])=>` ${Vt[o]||o}="${i}"`).join("")}>${Ge(n)}</${t}>`}function kt(e){let t=e.props.viewBox||e.props.viewbox,n=t.split(" ").map(o=>parseInt(o,10)),r=e.props.width||n[2]||0,a=e.props.height||n[3]||0;return`data:image/svg+xml;utf8,${`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${a}" viewBox="${t}">${Ge(e.props.children)}</svg>`.replace(Jt,encodeURIComponent)}`}var St={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 qt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","textAlign","textTransform","textShadowOffset","textShadowColor","textShadowRadius","textDecorationLine","textDecorationStyle","textDecorationColor","whiteSpace","transform","wordBreak","opacity","filter","_viewportWidth","_viewportHeight","_inheritedClipPathId","_inheritedBackgroundClipTextPath"]);function Ue(e){let t={};for(let n in e)qt.has(n)&&(t[n]=e[n]);return t}import{getPropertyName as cn,getStylesForProperty as dn}from"css-to-react-native";import{parseElementStyle as pn}from"css-background-parser";var ye=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Kt=ye((e,t)=>{t.exports=["em","ex","ch","rem","vh","vw","vmin","vmax","px","mm","cm","in","pt","pc","mozmm"]}),Zt=ye((e,t)=>{t.exports=["deg","grad","rad","turn"]}),Qt=ye((e,t)=>{t.exports=["dpi","dpcm","dppx"]}),en=ye((e,t)=>{t.exports=["Hz","kHz"]}),tn=ye((e,t)=>{t.exports=["s","ms"]}),nn=Kt(),Tt=Zt(),Rt=Qt(),_t=en(),Ct=tn();function ze(e){if(/\.\D?$/.test(e))throw new Error("The dot should be followed by a number");if(/^[+-]{2}/.test(e))throw new Error("Only one leading +/- is allowed");if(rn(e)>1)throw new Error("Only one dot is allowed");if(/%$/.test(e)){this.type="percentage",this.value=Ye(e),this.unit="%";return}var t=an(e);if(!t){this.type="number",this.value=Ye(e);return}this.type=ln(t),this.value=Ye(e.substr(0,e.length-t.length)),this.unit=t}ze.prototype.valueOf=function(){return this.value};ze.prototype.toString=function(){return this.value+(this.unit||"")};function ue(e){return new ze(e)}function rn(e){var t=e.match(/\./g);return t?t.length:0}function Ye(e){var t=parseFloat(e);if(isNaN(t))throw new Error("Invalid number: "+e);return t}var on=[].concat(Tt,_t,nn,Rt,Ct);function an(e){var t=e.match(/\D+$/),n=t&&t[0];if(n&&on.indexOf(n)===-1)throw new Error("Invalid unit: "+n);return n}var sn=Object.assign(Ie(Tt,"angle"),Ie(_t,"frequency"),Ie(Rt,"resolution"),Ie(Ct,"time"));function Ie(e,t){return Object.fromEntries(e.map(n=>[n,t]))}function ln(e){return sn[e]||"length"}import un from"postcss-value-parser";function fn(e,t){try{let n=new ue(e);switch(n.unit){case"px":return{absolute:n.value};case"em":return{absolute:n.value*t};case"rem":return{absolute:n.value*16};case"%":return{relative:n.value};default:return{}}}catch{return{}}}function He(e,t,n){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 r=fn(e,t);return r.absolute?{[n?"xAbsolute":"yAbsolute"]:r.absolute}:r.relative?{[n?"xRelative":"yRelative"]:r.relative}:{}}}function Xe(e,t){if(typeof e=="number")return{xAbsolute:e};let n;try{n=un(e).nodes.filter(r=>r.type==="word").map(r=>r.value)}catch{return{}}return n.length===1?He(n[0],t,!0):n.length===2?((n[0]==="top"||n[0]==="bottom"||n[1]==="left"||n[1]==="right")&&n.reverse(),D(D({},He(n[0],t,!0)),He(n[1],t,!1))):{}}var gn=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),mn=new Set(["lineHeight"]),It=[1,0,0,1,0,0];function hn(e,t,n,r){return e==="border"&&!n.includes(t.borderColor)?t.borderColor=r:e==="borderColor"?t.borderColor=t.borderTopColor:e==="textDecoration"&&!n.includes(t.textDecorationColor)&&(t.textDecorationColor=r),t}function Lt(e,t){return typeof t=="number"?gn.has(e)?mn.has(e)?t:String(t):t+"px":t}function bn(e,t){return e==="lineHeight"?{lineHeight:Lt(e,t)}:e==="fontFamily"?{fontFamily:t.split(",").map(n=>n.trim().replace(/(^['"])|(['"]$)/g,"").toLocaleLowerCase())}:null}function je(e,t,n,{percentage:r}={percentage:!1}){if(typeof e=="number")return e;try{let a=new ue(e);if(a.type==="length")switch(a.unit){case"em":return a.value*t;case"rem":return a.value*16;case"vw":return~~(a.value*n._viewportWidth/100);case"vh":return~~(a.value*n._viewportHeight/100);default:return a.value}else if(a.type==="angle")switch(a.unit){case"deg":return a.value;case"rad":return a.value*180/Math.PI;default:return a.value}else if(a.type==="percentage"&&r)return a.value/100*t}catch{}}function Le(e,t){let n={};for(let a in e){if(a.startsWith("_")){n[a]=e[a];continue}let o=cn(a);Object.assign(n,bn(o,e[a])||hn(o,dn(o,Lt(o,e[a]),!0),e[a],e.color||t.color))}if(n.backgroundImage){let{backgrounds:a}=pn(n);n.backgroundImage=a}let r=n.fontSize||t.fontSize;if(typeof r=="string")try{let a=new ue(r);switch(a.unit){case"em":r=a.value*t.fontSize;break;case"rem":r=a.value*16;break}}catch{r=16}typeof n.fontSize!="undefined"&&(n.fontSize=r),n.transformOrigin&&(n.transformOrigin=Xe(n.transformOrigin,r));for(let a in n){let o=n[a];if(a==="lineHeight")typeof o=="string"&&(o=n[a]=je(o,r,t,{percentage:!0})/r);else if(typeof o=="string"){let i=je(o,r,t);typeof i!="undefined"&&(n[a]=i),o=n[a]}if(a==="opacity"&&(o=n[a]=o*t.opacity),a==="transform"){let i=[...It],s=o;for(let u of s){let g=Object.keys(u)[0],m=u[g],d=typeof m=="string"?je(m,r,t):m,p=[...It];switch(g){case"translateX":p[4]=d;break;case"translateY":p[5]=d;break;case"scale":p[0]=d,p[3]=d;break;case"scaleX":p[0]=d;break;case"scaleY":p[3]=d;break;case"rotate":let h=d*Math.PI/180,l=Math.cos(h),f=Math.sin(h);p[0]=l,p[1]=f,p[2]=-f,p[3]=l;break;case"skewX":p[2]=Math.tan(d*Math.PI/180);break;case"skewY":p[1]=Math.tan(d*Math.PI/180);break}i=me(p,i)}n.transform=i}}return n}function Ve(e,t,n,r,a){let o=te(),i=D(D(D({},n),Le(St[t],n)),Le(r,n));if(t==="img"){let s=parseInt(a.width),g=parseInt(a.height)/s;i.width||(i.width=s),i.height||(i.height=g*i.width)}if(t==="svg"){let u=(a.viewBox||a.viewbox).split(" ").map(d=>parseInt(d,10)),g=a.width||u[2]||0,m=a.height||u[3]||0;i.width||(i.width=g),i.height||(i.height=m)}return e.setDisplay(Z(i.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),e.setAlignContent(Z(i.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(Z(i.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(Z(i.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(Z(i.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(Z(i.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(Z(i.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof i.flexBasis!="undefined"&&e.setFlexBasis(i.flexBasis),e.setFlexGrow(typeof i.flexGrow=="undefined"?0:i.flexGrow),e.setFlexShrink(typeof i.flexShrink=="undefined"?0:i.flexShrink),typeof i.maxHeight!="undefined"&&e.setMaxHeight(i.maxHeight),typeof i.maxWidth!="undefined"&&e.setMaxWidth(i.maxWidth),typeof i.minHeight!="undefined"&&e.setMinHeight(i.minHeight),typeof i.minWidth!="undefined"&&e.setMinWidth(i.minWidth),e.setOverflow(Z(i.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),e.setMargin(o.EDGE_TOP,i.marginTop||0),e.setMargin(o.EDGE_BOTTOM,i.marginBottom||0),e.setMargin(o.EDGE_LEFT,i.marginLeft||0),e.setMargin(o.EDGE_RIGHT,i.marginRight||0),e.setBorder(o.EDGE_TOP,i.borderWidth||0),e.setBorder(o.EDGE_BOTTOM,i.borderWidth||0),e.setBorder(o.EDGE_LEFT,i.borderWidth||0),e.setBorder(o.EDGE_RIGHT,i.borderWidth||0),e.setPadding(o.EDGE_TOP,i.paddingTop||0),e.setPadding(o.EDGE_BOTTOM,i.paddingBottom||0),e.setPadding(o.EDGE_LEFT,i.paddingLeft||0),e.setPadding(o.EDGE_RIGHT,i.paddingRight||0),e.setPositionType(Z(i.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof i.top!="undefined"&&e.setPosition(o.EDGE_TOP,i.top),typeof i.bottom!="undefined"&&e.setPosition(o.EDGE_BOTTOM,i.bottom),typeof i.left!="undefined"&&e.setPosition(o.EDGE_LEFT,i.left),typeof i.right!="undefined"&&e.setPosition(o.EDGE_RIGHT,i.right),typeof i.height!="undefined"?e.setHeight(i.height):e.setHeightAuto(),typeof i.width!="undefined"?e.setWidth(i.width):e.setWidthAuto(),[i,Ue(i)]}function fe({left:e,top:t,width:n,height:r},a,o,i){var u,g,m,d;let s;if(o)s=a;else{let p=(g=i==null?void 0:i.xAbsolute)!=null?g:((u=i==null?void 0:i.xRelative)!=null?u:50)*n/100,h=(d=i==null?void 0:i.yAbsolute)!=null?d:((m=i==null?void 0:i.yRelative)!=null?m:50)*r/100,l=e+p,f=t+h;s=me([1,0,0,1,l,f],me(a,[1,0,0,1,-l,-f])),a.__parent&&(s=me(a.__parent,s)),a.splice(0,6,...s)}return`matrix(${s.map(p=>p.toFixed(2)).join(",")})`}function At({left:e,top:t,width:n,height:r,isInheritingTransform:a},o){let i="",s=1;return o.transform&&(i=fe({left:e,top:t,width:n,height:r},o.transform,a,o.transformOrigin)),o.opacity&&(s=+o.opacity),{matrix:i,opacity:s}}function Je({id:e,content:t,filter:n,left:r,top:a,width:o,height:i,matrix:s,opacity:u,image:g,clipPathId:m,debug:d,shape:p,decorationShape:h},l){let f="";if(d&&(f=y("rect",{x:r,y:a-i,width:o,height:i,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:s||void 0,"clip-path":m?`url(#${m})`:void 0})),g){let x={href:g,x:r,y:a,width:o,height:i,transform:s||void 0,"clip-path":m?`url(#${m})`:void 0,style:l.filter?`filter:${l.filter}`:void 0};return[(n?`${n}<g filter="url(#satori_s-${e})">`:"")+y("image",se(D({},x),{opacity:u!==1?u:void 0}))+(h||"")+(n?"</g>":"")+f,""]}let b={x:r,y:a,width:o,height:i,"font-weight":l.fontWeight,"font-style":l.fontStyle,"font-size":l.fontSize,"font-family":l.fontFamily,"letter-spacing":l.letterSpacing||void 0,transform:s||void 0,"clip-path":m?`url(#${m})`:void 0,style:l.filter?`filter:${l.filter}`:void 0};return[(n?`${n}<g filter="url(#satori_s-${e})">`:"")+y("text",se(D({},b),{fill:l.color,opacity:u!==1?u:void 0}),t)+(h||"")+(n?"</g>":"")+f,p?y("text",b,t):""]}function ce({id:e,width:t,height:n},r){if(!r.shadowColor||!r.shadowOffset||typeof r.shadowRadius=="undefined")return"";let a=r.shadowRadius*r.shadowRadius/4,o=Math.min(r.shadowOffset.width-a,0),i=Math.max(r.shadowOffset.width+a+t,t),s=Math.min(r.shadowOffset.height-a,0),u=Math.max(r.shadowOffset.height+a+n,n);return`<defs><filter id="satori_s-${e}" x="${o/t*100}%" y="${s/n*100}%" width="${(i-o)/t*100}%" height="${(u-s)/n*100}%"><feDropShadow dx="${r.shadowOffset.width}" dy="${r.shadowOffset.height}" stdDeviation="${r.shadowRadius/2}" flood-color="${r.shadowColor}" flood-opacity="1"/></filter></defs>`}function qe({width:e,left:t,top:n,ascender:r,clipPathId:a},o){let{textDecorationColor:i,textDecorationStyle:s,textDecorationLine:u,fontSize:g}=o;if(!u||u==="none")return"";let m=Math.max(1,g*.1),d=u==="line-through"?n+r*.5:u==="underline"?n+r*1.1:n,p=s==="dashed"?`${m*1.2} ${m*2}`:s==="dotted"?`0 ${m*2}`:void 0;return y("line",{x1:t,y1:d,x2:t+e,y2:d,stroke:i,"stroke-width":m,"stroke-dasharray":p,"stroke-linecap":s==="dotted"?"round":"square","clip-path":a?`url(#${a})`:void 0})}var Ke=void 0;async function*Ze(e,t){var dt;let n=te(),{parentStyle:r,inheritedStyle:a,parent:o,font:i,id:s,isInheritingTransform:u,debug:g,embedFont:m,graphemeImages:d,canLoadAdditionalAssets:p}=t;r.textTransform==="uppercase"?e=e.toLocaleUpperCase(Ke):r.textTransform==="lowercase"?e=e.toLocaleLowerCase(Ke):r.textTransform==="capitalize"&&(e=le(e,"word").map(_=>le(_,"grapheme").map((I,L)=>L===0?I.toLocaleUpperCase(Ke):I).join("")).join(""));let h=Z(r.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),l=le(e,h),f=n.Node.create();f.setAlignItems(n.ALIGN_BASELINE),r.textAlign==="left"?f.setJustifyContent(n.JUSTIFY_FLEX_START):r.textAlign==="center"?f.setJustifyContent(n.JUSTIFY_CENTER):r.textAlign==="right"?f.setJustifyContent(n.JUSTIFY_FLEX_END):r.textAlign==="justify"&&f.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),o.insertChild(f,o.getChildCount());let{textAlign:b,textOverflow:x,whiteSpace:E,lineHeight:F,filter:P,_inheritedBackgroundClipTextPath:N}=r,W=r.fontSize,R=i.getEngine(W,F,r),J=p?l.filter(_=>!R.check(_)):[];yield J,J.length&&(R=i.getEngine(W,F,r));let A=[],v=[],M=[],G=[],z=new Map,k=_=>{let I=0;for(let L of _){if(z.has(L)){I+=z.get(L);continue}let Y=R.measure(L,r);z.set(L,Y),I+=Y}return I},O=0,q=[],c=0;for(let _ of l){let I=!1,L=d&&d[_];E==="pre"?I=_[0]===`
|
|
2
|
-
`:E!=="nowrap"&&(L||
|
|
3
|
-
`?" ":_)}O=Math.max(O,k(
|
|
4
|
-
`,V=ae?0:d&&d[B]?r.fontSize:k([B]);H||(L="",Y=0);let U=Y||",.!?:-@)>]}%#".indexOf(B[0])<0,K=!H||!!Y;if(ae||re&&U&&H+Y+V>_&&E!=="nowrap"&&E!=="pre")A.push(H),v.push(oe),I++,ie+=$,H=V,$=V?R.height(B):0,oe=V?R.baseline(B):0,M.push(1),j=-1,ae||(X=Math.max(X,_));else{H+=Y+V;let ge=R.height(B);ge>$&&($=ge,oe=R.baseline(B)),K&&M[M.length-1]++}L="",Y=0,K&&j++,X=Math.max(X,H),G[re]={y:ie,x:H-V,width:V,line:I,lineIndex:j}}}return H&&(I++,A.push(H),v.push(oe),ie+=$),{width:X,height:ie}});let[Nt,Gt]=yield,Pe="",Ee="",ne=a._inheritedClipPathId,{left:st,top:lt,width:ve,height:ut}=f.getComputedLayout(),Me=o.getComputedWidth()-o.getComputedPadding(n.EDGE_LEFT)-o.getComputedPadding(n.EDGE_RIGHT)-o.getComputedBorder(n.EDGE_LEFT)-o.getComputedBorder(n.EDGE_RIGHT),de=Nt+st,pe=Gt+lt,{matrix:ee,opacity:ke}=At({left:st,top:lt,width:ve,height:ut,isInheritingTransform:u},r),Se="";r.textShadowOffset&&(Se=ce({width:ve,height:ut,id:s},{shadowColor:r.textShadowColor,shadowOffset:r.textShadowOffset,shadowRadius:r.textShadowRadius}));let be="",Te="",ft="",We=-1,ct=x==="ellipsis"?k(["\u2026"]):0,Dt=x==="ellipsis"?k([" "]):0,Re={};for(let _=0;_<l.length;_++){if(!G[_])continue;let I=G[_],L=l[_],Y=null,H=d?d[L]:null,X=I.y,j=I.x,ie=I.width,$=I.line;if($===We)continue;let oe=!1;if(A.length>1){let U=ve-A[$];if(b==="right"||b==="end")j+=U;else if(b==="center")j+=U/2;else if(b==="justify"&&$<A.length-1){let K=M[$];j+=(K>1?U/(K-1):0)*I.lineIndex,oe=!0}}if(Re[$]||(Re[$]=[j,oe?ve:A[$]]),x==="ellipsis"&&A[$]>Me&&I.x+ie+ct+Dt>Me){let U=le(L,"grapheme"),K="",ge=0;for(let pt of U){let gt=I.x+k([K+pt]);if(K&>+ct>Me)break;K+=pt,ge=gt}L=K+"\u2026",We=$,Re[$][1]=ge}let re=v[$],B=R.baseline(L),ae=R.height(L),V=re-B;if(H?X+=0:m?(Y=R.getSVG(L,se(D({},r),{left:de+j,top:pe+X+B+V,letterSpacing:r.letterSpacing})),g&&(ft+=y("rect",{x:de+j,y:pe+X+V,width:I.width,height:ae,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:ee||void 0,"clip-path":ne?`url(#${ne})`:void 0})+y("line",{x1:de+j,x2:de+j+I.width,y1:pe+X+V+B,y2:pe+X+V+B,stroke:"#14c000","stroke-width":1,transform:ee||void 0,"clip-path":ne?`url(#${ne})`:void 0}))):X+=B+V,r.textDecorationLine&&($!==((dt=G[_+1])==null?void 0:dt.line)||We===$)){let U=Re[$];U&&!U[2]&&(be+=qe({left:de+U[0],top:pe+ae*+$,width:U[1],ascender:R.baseline(L),clipPathId:ne},r),U[2]=1)}if(Y!==null)Te+=Y+" ";else{let[U,K]=Je({content:L,filter:Se,id:s,left:de+j,top:pe+X,width:ie,height:ae,matrix:ee,opacity:ke,image:H,clipPathId:ne,debug:g,shape:!!N,decorationShape:be},r);Pe+=U,Ee+=K,be=""}}if(Te){let _=r.color!=="transparent"&&ke!==0?y("path",{fill:r.color,d:Te,transform:ee||void 0,opacity:ke!==1?ke:void 0,"clip-path":ne?`url(#${ne})`:void 0,style:P?`filter:${P}`:void 0}):"";N&&(Ee=y("path",{d:Te,transform:ee||void 0})),Pe+=(Se?Se+y("g",{filter:`url(#satori_s-${s})`},_+be):_+be)+ft}return Ee&&(r._inheritedBackgroundClipTextPath.value+=Ee),Pe}var Qe=Qe||{};Qe.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]+\.?))/},t="";function n(c){var w=new Error(t+": "+c);throw w.source=t,w}function r(){var c=a();return t.length>0&&n("Invalid input not EOF"),c}function a(){return F(o)}function o(){return i("linear-gradient",e.linearGradient,u)||i("repeating-linear-gradient",e.repeatingLinearGradient,u)||i("radial-gradient",e.radialGradient,d)||i("repeating-radial-gradient",e.repeatingRadialGradient,d)}function i(c,w,C){return s(w,function(Q){var he=C();return he&&(O(e.comma)||n("Missing comma before color stops")),{type:c,orientation:he,colorStops:F(P)}})}function s(c,w){var C=O(c);if(C){O(e.startCall)||n("Missing (");var Q=w(C);return O(e.endCall)||n("Missing )"),Q}}function u(){return g()||m()}function g(){return k("directional",e.sideOrCorner,1)}function m(){return k("angular",e.angleValue,1)}function d(){var c,w=p(),C;return w&&(c=[],c.push(w),C=t,O(e.comma)&&(w=p(),w?c.push(w):t=C)),c}function p(){var c=h()||l();if(c)c.at=b();else{var w=f();if(w){c=w;var C=b();C&&(c.at=C)}else{var Q=x();Q&&(c={type:"default-radial",at:Q})}}return c}function h(){var c=k("shape",/^(circle)/i,0);return c&&(c.style=z()||f()),c}function l(){var c=k("shape",/^(ellipse)/i,0);return c&&(c.style=M()||f()),c}function f(){return k("extent-keyword",e.extentKeywords,1)}function b(){if(k("position",/^at/,0)){var c=x();return c||n("Missing positioning value"),c}}function x(){var c=E();if(c.x||c.y)return{type:"position",value:c}}function E(){return{x:M(),y:M()}}function F(c){var w=c(),C=[];if(w)for(C.push(w);O(e.comma);)w=c(),w?C.push(w):n("One extra comma");return C}function P(){var c=N();return c||n("Expected color definition"),c.length=M(),c}function N(){return R()||A()||J()||W()}function W(){return k("literal",e.literalColor,0)}function R(){return k("hex",e.hexColor,1)}function J(){return s(e.rgbColor,function(){return{type:"rgb",value:F(v)}})}function A(){return s(e.rgbaColor,function(){return{type:"rgba",value:F(v)}})}function v(){return O(e.number)[1]}function M(){return k("%",e.percentageValue,1)||G()||z()}function G(){return k("position-keyword",e.positionKeywords,1)}function z(){return k("px",e.pixelValue,1)||k("em",e.emValue,1)}function k(c,w,C){var Q=O(w);if(Q)return{type:c,value:Q[C]}}function O(c){var w,C;return C=/^[\n\r\t\s]+/.exec(t),C&&q(C[0].length),w=c.exec(t),w&&q(w[0].length),w}function q(c){t=t.substr(c)}return function(c){return t=c.toString(),r()}}();var et=Qe;var Ot=vt(100),tt=new Map,yn=["image/png","image/jpeg","image/gif","image/svg+xml"];function xn(e){let t="",n=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)t+=String.fromCharCode(n[r]);return btoa(t)}async function Ae(e){if(e.startsWith("data:"))return e;if(!globalThis.fetch)throw new Error("`fetch` is required to be polyfilled to load images.");if(tt.has(e))return tt.get(e);let t=Ot.get(e);if(t)return t;let n=new Promise((r,a)=>{let o;fetch(e).then(i=>{if(o=i.headers.get("content-type").toLowerCase(),!yn.includes(o))throw new Error(`Unsupported image type: ${o}`);return i.arrayBuffer()}).then(i=>{let s=`data:${o};base64,${xn(i)}`;Ot.set(e,s),r(s)}).catch(a)});return tt.set(e,n),n}function wn(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 En(e,t){return typeof e=="string"&&e.endsWith("%")?t*parseFloat(e)/100:+e}function Ft(e,{x:t,y:n,defaultX:r,defaultY:a}){return(e?e.split(" ").map(o=>{try{let i=new ue(o);return i.type==="length"||i.type==="number"?i.value:i.value+i.unit}catch{return null}}).filter(o=>o!==null):[r,a]).map((o,i)=>En(o,[t,n][i]))}function $t(e,t){let n=[];for(let i of t){let s=wn(i);if(!n.length&&(n.push({offset:0,color:s}),typeof i.length=="undefined"||i.length.value==="0"))continue;let u=typeof i.length=="undefined"?void 0:i.length.type==="%"?i.length.value/100:i.length.value/e;n.push({offset:u,color:s})}n.length||n.push({offset:0,color:"transparent"});let r=n[n.length-1];r.offset!==1&&(typeof r.offset=="undefined"?r.offset=1:n.push({offset:1,color:r.color}));let a=0,o=1;for(let i=0;i<n.length;i++)if(typeof n[i].offset=="undefined"){for(o<i&&(o=i);typeof n[o].offset=="undefined";)o++;n[i].offset=(n[o].offset-n[a].offset)/(o-a)*(i-a)+n[a].offset}else a=i;return n}async function nt({id:e,width:t,height:n},{image:r,size:a,position:o,repeat:i}){i=i||"repeat";let s=i==="repeat-x"||i==="repeat",u=i==="repeat-y"||i==="repeat",g=Ft(a,{x:t,y:n,defaultX:t,defaultY:n}),m=Ft(o,{x:t,y:n,defaultX:0,defaultY:0});if(r.startsWith("linear-gradient(")){let d=et.parse(r)[0],p,h,l,f;if(d.orientation.type==="directional")[p,h,l,f]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[d.orientation.value];else if(d.orientation.type==="angular"){let x=+d.orientation.value/180*Math.PI-Math.PI/2,E=Math.cos(x),F=Math.sin(x);p=0,h=0,l=E,f=F,l<0&&(p-=l,l=0),f<0&&(h-=f,f=0)}let b=$t(t,d.colorStops);return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${p}" y1="${h}" x2="${l}" y2="${f}">${b.map(x=>`<stop offset="${x.offset*100}%" stop-color="${x.color}"/>`).join("")}</linearGradient>`]}if(r.startsWith("radial-gradient(")){let d=et.parse(r)[0],p=d.orientation[0],[h,l]=g,f="circle",b=h/2,x=l/2;if(p.type==="shape"){if(f=p.value,p.at)if(p.at.type==="position")b=p.at.value.x.value,x=p.at.value.y.value;else throw new Error("orientation.at.type not implemented: "+p.at.type)}else throw new Error("orientation.type not implemented: "+p.type);let E=$t(t,d.colorStops),F=`satori_radial_${e}`,P=`satori_pattern_${e}`,N={},W=Math.max(Math.abs(h-b),Math.abs(b)),R=Math.max(Math.abs(l-x),Math.abs(x));if(f==="circle")N.r=Math.sqrt(W*W+R*R);else if(f==="ellipse"){let v=R!==0?W/R:1;N.ry=Math.sqrt(W*W+R*R*v*v)/v,N.rx=N.ry*v}let J=y("pattern",{id:P,x:m[0],y:m[1],width:s?h:"100%",height:u?l:"100%",patternUnits:"userSpaceOnUse"},y("radialGradient",{id:F},E.map(v=>y("stop",{offset:v.offset,"stop-color":v.color})).join(""))+y(f,se(D({cx:b,cy:x,width:h,height:l},N),{fill:`url(#${F})`})));return[P,J]}if(r.startsWith("url(")){let d=await Ae(r.slice(4,-1));return[`satori_bi${e}`,y("pattern",{id:`satori_bi${e}`,patternContentUnits:"userSpaceOnUse",patternUnits:"userSpaceOnUse",x:m[0],y:m[1],width:s?g[0]:"100%",height:u?g[1]:"100%"},y("image",{x:0,y:0,width:g[0],height:g[1],href:d}))]}}function Oe(e,t,n){return n<e+t&&(n/2<e&&n/2<t?e=t=n/2:n/2<e?e=n-t:n/2<t&&(t=n-e)),[e,t]}function xe({left:e,top:t,width:n,height:r},a){let{borderTopLeftRadius:o,borderTopRightRadius:i,borderBottomLeftRadius:s,borderBottomRightRadius:u}=a;return o=Math.min(o||0,n,r),i=Math.min(i||0,n,r),s=Math.min(s||0,n,r),u=Math.min(u||0,n,r),!o&&!i&&!s&&!u?"":([o,i]=Oe(o,i,n),[o,s]=Oe(o,s,r),[i,u]=Oe(i,u,r),[s,u]=Oe(s,u,n),`M${e+o},${t} h${n-o-i} a${i},${i} 0 0 1 ${i},${i} v${r-i-u} a${u},${u} 0 0 1 ${-u},${u} h${u+s-n} a${s},${s} 0 0 1 ${-s},${-s} v${s+o-r} a${o},${o} 0 0 1 ${o},${-o}`)}function rt({left:e,top:t,width:n,height:r,path:a,id:o},i){return i.overflow!=="hidden"?"":a?y("clipPath",{id:`satori_cp-${o}`,"clip-path":i._inheritedClipPathId?`url(#${i._inheritedClipPathId})`:void 0},y("path",{x:e,y:t,width:n,height:r,d:a})):y("clipPath",{id:`satori_cp-${o}`,"clip-path":i._inheritedClipPathId?`url(#${i._inheritedClipPathId})`:void 0},y("rect",{x:e,y:t,width:n,height:r}))}async function it({id:e,left:t,top:n,width:r,height:a,isInheritingTransform:o,debug:i},s){if(s.display==="none")return"";let u="rect",g="transparent",m="",d=0,p="",h="",l=[],f=1,b="";s.backgroundColor&&l.push(s.backgroundColor),s.borderWidth&&(d=s.borderWidth,g=s.borderColor,s.borderStyle==="dashed"&&(m=d*2+" "+d)),s.opacity&&(f=+s.opacity),s.transform&&(p=fe({left:t,top:n,width:r,height:a},s.transform,o,s.transformOrigin));let x="";if(s.backgroundImage){let A=[];for(let v=0;v<s.backgroundImage.length;v++){let M=s.backgroundImage[v],G=await nt({id:e+"_"+v,width:r,height:a},M);G&&A.push(G)}for(let v of A)l.push(`url(#${v[0]})`),h+=v[1],v[2]&&(x+=v[2])}let E=xe({left:t,top:n,width:r,height:a},s);E&&(u="path");let F=rt({left:t,top:n,width:r,height:a,path:E,id:e},s),P=s._inheritedClipPathId,N=ce({width:r,height:a,id:e},s);i&&(b=y("rect",{x:t,y:n,width:r,height:a,fill:"transparent",stroke:"#ff5757","stroke-width":1,"stroke-dasharray":m||void 0,transform:p||void 0,"clip-path":P?`url(#${P})`:void 0})),l.length||l.push("transparent");let{backgroundClip:W,filter:R}=s,J=l.map((A,v)=>{if(A==="transparent"&&!(v===l.length-1&&d))return"";let M=!!d,G=v===l.length-1&&M&&W!=="text",z=W==="text"?`url(#satori_bct-${e})`:P?`url(#${P})`:void 0;return G&&(h+=y("clipPath",{id:`satori_bc-${e}`,"clip-path":z},y(u,{x:t,y:n,width:r,height:a,d:E||void 0})),z=`url(#satori_bc-${e})`),y(u,{x:t,y:n,width:r,height:a,fill:A,stroke:G||M?g:void 0,"stroke-width":G?d*2:M?1:void 0,"stroke-dasharray":m||void 0,d:E||void 0,transform:p||void 0,"clip-path":z,style:R?`filter:${R}`:void 0})}).join("");return W==="text"&&d&&(J=y(u,{x:t,y:n,width:r,height:a,fill:"transparent",stroke:g,"stroke-width":d*2,"stroke-dasharray":m||void 0,d:E||void 0,transform:p||void 0,"clip-path":P?`url(#${P})`:void 0})+J),(h?`<defs>${h}</defs>`:"")+F+(N?`${N}<g filter="url(#satori_s-${e})">`:"")+(f!==1?`<g opacity="${f}">`:"")+(x||J)+(f!==1?"</g>":"")+(N?"</g>":"")+b}function Fe({id:e,left:t,top:n,width:r,height:a,src:o,debug:i,isInheritingTransform:s},u){if(u.display==="none")return"";let g="",m=1,d="",p=u.objectFit==="contain"?"xMidYMid":u.objectFit==="cover"?"xMidYMid slice":"none",h=xe({left:t,top:n,width:r,height:a},u),l=u._inheritedClipPathId;h&&(g=y("clipPath",{id:`satori_c-${e}`,"clip-path":l?`url(#${l})`:void 0},y("path",{x:t,y:n,width:r,height:a,d:h}))),u.opacity&&(m=+u.opacity);let f=ce({width:r,height:a,id:e},u);return u.transform&&(d=fe({left:t,top:n,width:r,height:a},u.transform,s,u.transformOrigin)),f+(f?`<g filter="url(#satori_s-${e})">`:"")+g+y("image",{x:t,y:n,width:r,height:a,href:o,preserveAspectRatio:p,transform:d||void 0,"clip-path":g?`url(#satori_c-${e})`:l?`url(#${l})`:void 0})+(f?"</g>":"")}async function*we(e,t){var q;let n=te(),{id:r,inheritedStyle:a,parent:o,font:i,debug:s,embedFont:u=!0,graphemeImages:g,canLoadAdditionalAssets:m}=t;if(e===null||typeof e=="undefined")return yield,yield,"";if(!De(e)||typeof e.type=="function"){let c;if(!De(e))c=Ze(String(e),t),yield(await c.next()).value;else{if(wt(e.type))throw new Error("Class component is not supported.");c=we(e.type(e.props),t),yield(await c.next()).value}await c.next();let w=yield;return(await c.next(w)).value}let{type:d,props:p}=e,{style:h,children:l}=p||{},f=n.Node.create();o.insertChild(f,o.getChildCount());let[b,x]=Ve(f,d,a,h,p),E=b.transform===a.transform;if(E||(b.transform.__parent=a.transform),b.overflow==="hidden"&&(x._inheritedClipPathId=`satori_cp-${r}`),b.backgroundClip==="text"){let c={value:""};x._inheritedBackgroundClipTextPath=c,b._inheritedBackgroundClipTextPath=c}let F=typeof l=="undefined"?[]:[].concat(l).flat(1/0),P=[],N=0,W=[];for(let c of F){let w=we(c,{id:r+"-"+N++,parentStyle:b,inheritedStyle:x,isInheritingTransform:!0,parent:f,font:i,embedFont:u,debug:s,graphemeImages:g,canLoadAdditionalAssets:m});m?W.push(...(await w.next()).value||[]):await w.next(),P.push(w)}yield W;for(let c of P)await c.next();let[R,J]=yield,{left:A,top:v,width:M,height:G}=f.getComputedLayout();A+=R,v+=J;let z="",k="",O="";if(d==="img"){let c=await Ae(p.src);k=Fe({id:r,left:A,top:v,width:M,height:G,src:c,isInheritingTransform:E,debug:s},b)}else if(d==="svg"){let c=kt(e);k=Fe({id:r,left:A,top:v,width:M,height:G,src:c,isInheritingTransform:E,debug:s},b)}else{let c=(q=h==null?void 0:h.display)!=null?q:"block";if(d==="div"&&l&&typeof l!="string"&&c!=="flex"&&c!=="none")throw new Error(`Expected <div> to have style={{display: 'flex'}} but received style={{display: '${c}'}}`);k=await it({id:r,left:A,top:v,width:M,height:G,isInheritingTransform:E,debug:s},b)}for(let c of P)z+=(await c.next([A,v])).value;return b._inheritedBackgroundClipTextPath&&(O+=y("clipPath",{id:`satori_bct-${r}`,"clip-path":b._inheritedClipPathId?`url(#${b._inheritedClipPathId})`:void 0},b._inheritedBackgroundClipTextPath.value)),O+k+z}import vn from"@shuding/opentype.js";function kn(e,t,[n,r],[a,o]){if(n!==a)return n?!a||n===e?-1:a===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&a===500||e===500&&a===400?1:e<400?n<e&&a<e?a-n:n<e?-1:a<e?1:n-a:e<n&&e<a?n-a:e<n?-1:e<a?1:a-n:1;if(r!==o){if(r===t)return-1;if(o===t)return 1}return-1}var $e=class{constructor(t){this.fonts=new Map;this.addFonts(t)}get({name:t,weight:n,style:r}){if(!this.fonts.has(t))return null;n==="normal"&&(n=400),n==="bold"&&(n=700);let a=[...this.fonts.get(t)],o=a[0];for(let i=1;i<a.length;i++){let[,s,u]=o,[,g,m]=a[i];kn(n,r,[s,u],[g,m])>0&&(o=a[i])}return o[0]}addFonts(t){for(let n of t){let r=n.data,a=vn.parse("buffer"in r?r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength):r,{lowMemory:!0}),o=a.charToGlyphIndex;a.charToGlyphIndex=s=>{let u=o.call(a,s);return u===0&&a._trackBrokenChars&&a._trackBrokenChars.push(s),u},this.defaultFont||(this.defaultFont=a);let i=n.name.toLowerCase();this.fonts.has(i)||this.fonts.set(i,[]),this.fonts.get(i).push([a,n.weight,n.style])}}getEngine(t=16,n=1.2,{fontFamily:r,fontWeight:a=400,fontStyle:o="normal"}){r=Array.isArray(r)?r:[r];let i=r.map(l=>this.get({name:l,weight:a,style:o})).filter(Boolean),s=Array.from(this.fonts.keys());for(let l of s)r.includes(l)||i.push(this.get({name:l,weight:a,style:o}));let u=new Map,g=(l,f=!0)=>{let b=l.charCodeAt(0);if(u.has(b))return u.get(b);let x=i.find((E,F)=>!!E.charToGlyphIndex(l)||f&&F===i.length-1);return x&&u.set(b,x),x},m=(l,f=!1)=>{var x,E;return((f?(E=(x=l.tables)==null?void 0:x.os2)==null?void 0:E.sTypoAscender:0)||l.ascender)/l.unitsPerEm*t},d=(l,f=!1)=>{var x,E;return((f?(E=(x=l.tables)==null?void 0:x.os2)==null?void 0:E.sTypoDescender:0)||l.descender)/l.unitsPerEm*t},p=l=>g(l,!1),h={check:l=>{let f=p(l);return f?(f._trackBrokenChars=[],f.stringToGlyphs(l),f._trackBrokenChars.length?(f._trackBrokenChars=void 0,!1):!0):!1},baseline:(l,f=typeof l=="undefined"?i[0]:g(l))=>{let b=m(f,!0),x=d(f,!0),E=h.height(l,f),{yMax:F,yMin:P}=f.tables.head,N=b-x,W=(F/(F-P)-1)*N;return E*((1.2/n+1)/2)+W},height:(l,f=typeof l=="undefined"?i[0]:g(l))=>(m(f)-d(f))*(n/1.2),measure:(l,f)=>this.measure(g,l,f),getSVG:(l,f)=>this.getSVG(g,l,f)};return h}patchFontFallbackResolver(t,n){let r=[];t._trackBrokenChars=r;let a=t.stringToGlyphs;return t.stringToGlyphs=(o,...i)=>{let s=a.call(t,o,...i);for(let u=0;u<s.length;u++)if(s[u].unicode===void 0){let g=r.shift(),m=n(g);m!==t&&(s[u]=m.charToGlyph(g))}return s},()=>{t.stringToGlyphs=a,t._trackBrokenChars=void 0}}measure(t,n,{fontSize:r,letterSpacing:a=0}){let o=t(n),i=this.patchFontFallbackResolver(o,t);try{return o.getAdvanceWidth(n,r,{letterSpacing:a/r})}finally{i()}}getSVG(t,n,{fontSize:r,top:a,left:o,letterSpacing:i=0}){let s=t(n),u=this.patchFontFallbackResolver(s,t);try{return s.getPath(n,o,a,r,{letterSpacing:i/r}).toPathData(1)}finally{u()}}};function ot({width:e,height:t,content:n}){return y("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,xmlns:"http://www.w3.org/2000/svg"},n)}var Pt={emoji:/\p{RI}\p{RI}|\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})?(\u{200D}\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})?)+|\p{EPres}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})?|\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})/u,ja:/\p{scx=Hira}|\p{scx=Kana}|[,;:]/u,ko:/\p{scx=Hangul}/u,zh:/\p{scx=Han}/u,th:/\p{scx=Thai}/u,bn:/\p{scx=Bengali}/u,ar:/\p{scx=Arabic}/u,ta:/\p{scx=Tamil}/u,ml:/\p{scx=Malayalam}/u,he:/\p{scx=Hebrew}/u,te:/\p{scx=Telugu}/u,devanagari:/\p{scx=Devanagari}/u};function Mt(e){for(let t in Pt)if(Pt[t].test(e))return t;return"unknown"}var at=new WeakMap;async function Wt(e,t){let n=te();if(!n)throw new Error("Satori is not initialized.");let r;at.has(t.fonts)?r=at.get(t.fonts):at.set(t.fonts,r=new $e(t.fonts));let a=n.Node.create();a.setWidth(t.width),a.setHeight(t.height),a.setFlexDirection(n.FLEX_DIRECTION_ROW),a.setFlexWrap(n.WRAP_WRAP),a.setAlignContent(n.ALIGN_AUTO),a.setAlignItems(n.ALIGN_FLEX_START),a.setJustifyContent(n.JUSTIFY_FLEX_START),a.setOverflow(n.OVERFLOW_HIDDEN);let o=D({},t.graphemeImages),i=we(e,{id:"id",parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1,whiteSpace:"normal",_viewportWidth:t.width,_viewportHeight:t.height},parent:a,font:r,embedFont:t.embedFont,debug:t.debug,graphemeImages:o,canLoadAdditionalAssets:!!t.loadAdditionalAsset}),s=(await i.next()).value;if(t.loadAdditionalAsset&&s.length){s=Array.from(new Set(le(s.join(""),"grapheme")));let g={};s.forEach(p=>{let h=Mt(p);g[h]=g[h]||[],h==="emoji"?g[h].push(p):g[h][0]=(g[h][0]||"")+p});let m=[],d={};await Promise.all(Object.entries(g).flatMap(([p,h])=>h.map(l=>t.loadAdditionalAsset(p,l).then(f=>{typeof f=="string"?d[l]=f:f&&m.push(f)})))),r.addFonts(m),Object.assign(o,d)}await i.next(),a.calculateLayout(t.width,t.height,n.DIRECTION_LTR);let u=(await i.next([0,0])).value;return a.freeRecursive(),ot({width:t.width,height:t.height,content:u})}export{Wt as default,Ht as init};
|
|
1
|
+
import*as $t from"yoga-layout-prebuilt";var dt=$t;var $e;$e=dt.default;function Mt(e){$e=e}function ee(){return $e}function We(e){let t=typeof e;return!(t==="number"||t==="bigint"||t==="string"||t==="boolean")}function pt(e){return/^class\s/.test(Function.prototype.toString.call(e))}function pe(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function K(e,t,n){let i=t[e];return typeof i>"u"?n:i}var gt=void 0,Ne=typeof Intl<"u"&&"Segmenter"in Intl;if(!Ne)throw new Error("Intl.Segmenter does not exist, please use import a polyfill.");var Wt=Ne?new Intl.Segmenter(gt,{granularity:"word"}):null,Nt=Ne?new Intl.Segmenter(gt,{granularity:"grapheme"}):null,Re=[32,160,4961,65792,65793,4153,4241,10].map(e=>String.fromCodePoint(e));function ae(e,t){return t==="word"?[...Wt.segment(e)].map(n=>n.segment):[...Nt.segment(e)].map(n=>n.segment)}function y(e,t,n){let i="";for(let[a,o]of Object.entries(t))typeof o<"u"&&(i+=` ${a}="${o}"`);return n?`<${e}${i}>${n}</${e}>`:`<${e}${i}/>`}function mt(e=20){let t=new Map;function n(a,o){if(t.size>=e){let r=t.keys().next().value;t.delete(r)}t.set(a,o)}function i(a){if(!t.has(a))return;let r=t.get(a);return t.delete(a),t.set(a,r),r}return{set:n,get:i}}var ht={accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",allowReorder:"allowreorder",arabicForm:"arabic-form",attributeName:"attributename",attributeType:"attributetype",autoReverse:"autoreverse",baseFrequency:"basefrequency",baseProfile:"baseprofile",baselineShift:"baseline-shift",calcMode:"calcmode",capHeight:"cap-height",clipPath:"clip-path",clipPathUnits:"clippathunits",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",contentScriptType:"contentscripttype",contentStyleType:"contentstyletype",diffuseConstant:"diffuseconstant",dominantBaseline:"dominant-baseline",edgeMode:"edgemode",enableBackground:"enable-background",externalResourcesRequired:"externalresourcesrequired",fillOpacity:"fill-opacity",fillRule:"fill-rule",filterRes:"filterres",filterUnits:"filterunits",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",glyphRef:"glyphref",gradientTransform:"gradienttransform",gradientUnits:"gradientunits",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",imageRendering:"image-rendering",kernelMatrix:"kernelmatrix",kernelUnitLength:"kernelunitlength",keyPoints:"keypoints",keySplines:"keysplines",keyTimes:"keytimes",lengthAdjust:"lengthadjust",letterSpacing:"letter-spacing",lightingColor:"lighting-color",limitingConeAngle:"limitingconeangle",markerEnd:"marker-end",markerHeight:"markerheight",markerMid:"marker-mid",markerStart:"marker-start",markerUnits:"markerunits",markerWidth:"markerwidth",maskContentUnits:"maskcontentunits",maskUnits:"maskunits",numOctaves:"numoctaves",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pathLength:"pathlength",patternContentUnits:"patterncontentunits",patternTransform:"patterntransform",patternUnits:"patternunits",pointerEvents:"pointer-events",pointsAtX:"pointsatx",pointsAtY:"pointsaty",pointsAtZ:"pointsatz",preserveAlpha:"preservealpha",preserveAspectRatio:"preserveaspectratio",primitiveUnits:"primitiveunits",refX:"refx",refY:"refy",renderingIntent:"rendering-intent",repeatCount:"repeatcount",repeatDur:"repeatdur",requiredExtensions:"requiredextensions",requiredFeatures:"requiredfeatures",shapeRendering:"shape-rendering",specularConstant:"specularconstant",specularExponent:"specularexponent",spreadMethod:"spreadmethod",startOffset:"startoffset",stdDeviation:"stddeviation",stitchTiles:"stitchtiles",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeMiterlimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",suppressContentEditableWarning:"suppresscontenteditablewarning",suppressHydrationWarning:"suppresshydrationwarning",surfaceScale:"surfacescale",systemLanguage:"systemlanguage",tableValues:"tablevalues",targetX:"targetx",targetY:"targety",textAnchor:"text-anchor",textDecoration:"text-decoration",textLength:"textlength",textRendering:"text-rendering",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",viewBox:"viewbox",viewTarget:"viewtarget",wordSpacing:"word-spacing",writingMode:"writing-mode",xChannelSelector:"xchannelselector",xHeight:"x-height",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlLang:"xml:lang",xmlSpace:"xmlspace",xmlnsXlink:"xmlns:xlink",yChannelSelector:"ychannelselector",zoomAndPan:"zoomandpan"},Gt=/[\r\n%#()<>?[\\\]^`{|}"']/g;function Me(e){if(!e)return"";if(Array.isArray(e))return e.map(Me).join("");if(typeof e!="object")return String(e);let t=e.type;if(t==="text")throw new Error("<text> nodes are not currently supported, please convert them to <path>");let{children:n,...i}=e.props||{};return`<${t}${Object.entries(i).map(([a,o])=>` ${ht[a]||a}="${o}"`).join("")}>${Me(n)}</${t}>`}function bt(e){let{viewBox:t,viewbox:n,width:i,height:a,className:o,style:r,children:s,...l}=e.props||{};t||(t=n);let m=t.split(" ").map(p=>parseInt(p,10));return l.xmlns="http://www.w3.org/2000/svg",l.viewBox=t,l.width=m[2],l.height=m[3],`data:image/svg+xml;utf8,${`<svg${Object.entries(l).map(([p,d])=>` ${ht[p]||p}="${d}"`).join("")}>${Me(s)}</svg>`.replace(Gt,encodeURIComponent)}`}var yt={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 Dt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","textAlign","textTransform","textShadowOffset","textShadowColor","textShadowRadius","textDecorationLine","textDecorationStyle","textDecorationColor","whiteSpace","transform","wordBreak","opacity","filter","_viewportWidth","_viewportHeight","_inheritedClipPathId","_inheritedBackgroundClipTextPath"]);function Ge(e){let t={};for(let n in e)Dt.has(n)&&(t[n]=e[n]);return t}import{getPropertyName as en,getStylesForProperty as tn}from"css-to-react-native";import{parseElementStyle as nn}from"css-background-parser";var he=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bt=he((e,t)=>{t.exports=["em","ex","ch","rem","vh","vw","vmin","vmax","px","mm","cm","in","pt","pc","mozmm"]}),Ut=he((e,t)=>{t.exports=["deg","grad","rad","turn"]}),Yt=he((e,t)=>{t.exports=["dpi","dpcm","dppx"]}),zt=he((e,t)=>{t.exports=["Hz","kHz"]}),Ht=he((e,t)=>{t.exports=["s","ms"]}),Xt=Bt(),xt=Ut(),wt=Yt(),Et=zt(),vt=Ht();function Be(e){if(/\.\D?$/.test(e))throw new Error("The dot should be followed by a number");if(/^[+-]{2}/.test(e))throw new Error("Only one leading +/- is allowed");if(jt(e)>1)throw new Error("Only one dot is allowed");if(/%$/.test(e)){this.type="percentage",this.value=De(e),this.unit="%";return}var t=Jt(e);if(!t){this.type="number",this.value=De(e);return}this.type=Kt(t),this.value=De(e.substr(0,e.length-t.length)),this.unit=t}Be.prototype.valueOf=function(){return this.value};Be.prototype.toString=function(){return this.value+(this.unit||"")};function se(e){return new Be(e)}function jt(e){var t=e.match(/\./g);return t?t.length:0}function De(e){var t=parseFloat(e);if(isNaN(t))throw new Error("Invalid number: "+e);return t}var Vt=[].concat(xt,Et,Xt,wt,vt);function Jt(e){var t=e.match(/\D+$/),n=t&&t[0];if(n&&Vt.indexOf(n)===-1)throw new Error("Invalid unit: "+n);return n}var qt=Object.assign(_e(xt,"angle"),_e(Et,"frequency"),_e(wt,"resolution"),_e(vt,"time"));function _e(e,t){return Object.fromEntries(e.map(n=>[n,t]))}function Kt(e){return qt[e]||"length"}import Zt from"postcss-value-parser";function Qt(e,t){try{let n=new se(e);switch(n.unit){case"px":return{absolute:n.value};case"em":return{absolute:n.value*t};case"rem":return{absolute:n.value*16};case"%":return{relative:n.value};default:return{}}}catch{return{}}}function Ue(e,t,n){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=Qt(e,t);return i.absolute?{[n?"xAbsolute":"yAbsolute"]:i.absolute}:i.relative?{[n?"xRelative":"yRelative"]:i.relative}:{}}}function Ye(e,t){if(typeof e=="number")return{xAbsolute:e};let n;try{n=Zt(e).nodes.filter(i=>i.type==="word").map(i=>i.value)}catch{return{}}return n.length===1?Ue(n[0],t,!0):n.length===2?((n[0]==="top"||n[0]==="bottom"||n[1]==="left"||n[1]==="right")&&n.reverse(),{...Ue(n[0],t,!0),...Ue(n[1],t,!1)}):{}}var rn=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),on=new Set(["lineHeight"]),kt=[1,0,0,1,0,0];function an(e,t,n,i){return e==="border"&&!n.includes(t.borderColor)?t.borderColor=i:e==="borderColor"?t.borderColor=t.borderTopColor:e==="textDecoration"&&!n.includes(t.textDecorationColor)&&(t.textDecorationColor=i),t}function St(e,t){return typeof t=="number"?rn.has(e)?on.has(e)?t:String(t):t+"px":t}function sn(e,t){return e==="lineHeight"?{lineHeight:St(e,t)}:e==="fontFamily"?{fontFamily:t.split(",").map(n=>n.trim().replace(/(^['"])|(['"]$)/g,"").toLocaleLowerCase())}:null}function ze(e,t,n,{percentage:i}={percentage:!1}){if(typeof e=="number")return e;try{let a=new se(e);if(a.type==="length")switch(a.unit){case"em":return a.value*t;case"rem":return a.value*16;case"vw":return~~(a.value*n._viewportWidth/100);case"vh":return~~(a.value*n._viewportHeight/100);default:return a.value}else if(a.type==="angle")switch(a.unit){case"deg":return a.value;case"rad":return a.value*180/Math.PI;default:return a.value}else if(a.type==="percentage"&&i)return a.value/100*t}catch{}}function Ce(e,t){let n={};for(let a in e){if(a.startsWith("_")){n[a]=e[a];continue}let o=en(a);Object.assign(n,sn(o,e[a])||an(o,tn(o,St(o,e[a]),!0),e[a],e.color||t.color))}if(n.backgroundImage){let{backgrounds:a}=nn(n);n.backgroundImage=a}let i=n.fontSize||t.fontSize;if(typeof i=="string")try{let a=new se(i);switch(a.unit){case"em":i=a.value*t.fontSize;break;case"rem":i=a.value*16;break}}catch{i=16}typeof n.fontSize<"u"&&(n.fontSize=i),n.transformOrigin&&(n.transformOrigin=Ye(n.transformOrigin,i));for(let a in n){let o=n[a];if(a==="lineHeight")typeof o=="string"&&(o=n[a]=ze(o,i,t,{percentage:!0})/i);else if(typeof o=="string"){let r=ze(o,i,t);typeof r<"u"&&(n[a]=r),o=n[a]}if(a==="opacity"&&(o=n[a]=o*t.opacity),a==="transform"){let r=[...kt],s=o;for(let l of s){let m=Object.keys(l)[0],p=l[m],d=typeof p=="string"?ze(p,i,t):p,g=[...kt];switch(m){case"translateX":g[4]=d;break;case"translateY":g[5]=d;break;case"scale":g[0]=d,g[3]=d;break;case"scaleX":g[0]=d;break;case"scaleY":g[3]=d;break;case"rotate":let h=d*Math.PI/180,f=Math.cos(h),u=Math.sin(h);g[0]=f,g[1]=u,g[2]=-u,g[3]=f;break;case"skewX":g[2]=Math.tan(d*Math.PI/180);break;case"skewY":g[1]=Math.tan(d*Math.PI/180);break}r=pe(g,r)}n.transform=r}}return n}function He(e,t,n,i,a){let o=ee(),r={...n,...Ce(yt[t],n),...Ce(i,n)};if(t==="img"){let s=parseInt(a.width),m=parseInt(a.height)/s;r.width||(r.width=s),r.height||(r.height=m*r.width)}if(t==="svg"){let l=(a.viewBox||a.viewbox).split(" ").map(g=>parseInt(g,10)),m=l[3]/l[2],{width:p,height:d}=a;typeof p>"u"&&d?typeof d=="string"&&d.endsWith("%")?p=parseInt(d)/m+"%":p=parseInt(d)/m:typeof d>"u"&&p?typeof p=="string"&&p.endsWith("%")?d=parseInt(p)*m+"%":d=parseInt(p)*m:(p||(p=l[2]),d||(d=l[3])),r.width||(r.width=p),r.height||(r.height=d)}return e.setDisplay(K(r.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),e.setAlignContent(K(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(K(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(K(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(K(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(K(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(K(r.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof r.flexBasis<"u"&&e.setFlexBasis(r.flexBasis),e.setFlexGrow(typeof r.flexGrow>"u"?0:r.flexGrow),e.setFlexShrink(typeof r.flexShrink>"u"?0:r.flexShrink),typeof r.maxHeight<"u"&&e.setMaxHeight(r.maxHeight),typeof r.maxWidth<"u"&&e.setMaxWidth(r.maxWidth),typeof r.minHeight<"u"&&e.setMinHeight(r.minHeight),typeof r.minWidth<"u"&&e.setMinWidth(r.minWidth),e.setOverflow(K(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(K(r.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof r.top<"u"&&e.setPosition(o.EDGE_TOP,r.top),typeof r.bottom<"u"&&e.setPosition(o.EDGE_BOTTOM,r.bottom),typeof r.left<"u"&&e.setPosition(o.EDGE_LEFT,r.left),typeof r.right<"u"&&e.setPosition(o.EDGE_RIGHT,r.right),typeof r.height<"u"?e.setHeight(r.height):e.setHeightAuto(),typeof r.width<"u"?e.setWidth(r.width):e.setWidthAuto(),[r,Ge(r)]}function le({left:e,top:t,width:n,height:i},a,o,r){var l,m,p,d;let s;if(o)s=a;else{let g=(m=r==null?void 0:r.xAbsolute)!=null?m:((l=r==null?void 0:r.xRelative)!=null?l:50)*n/100,h=(d=r==null?void 0:r.yAbsolute)!=null?d:((p=r==null?void 0:r.yRelative)!=null?p:50)*i/100,f=e+g,u=t+h;s=pe([1,0,0,1,f,u],pe(a,[1,0,0,1,-f,-u])),a.__parent&&(s=pe(a.__parent,s)),a.splice(0,6,...s)}return`matrix(${s.map(g=>g.toFixed(2)).join(",")})`}function Tt({left:e,top:t,width:n,height:i,isInheritingTransform:a},o){let r="",s=1;return o.transform&&(r=le({left:e,top:t,width:n,height:i},o.transform,a,o.transformOrigin)),o.opacity&&(s=+o.opacity),{matrix:r,opacity:s}}function Xe({id:e,content:t,filter:n,left:i,top:a,width:o,height:r,matrix:s,opacity:l,image:m,clipPathId:p,debug:d,shape:g,decorationShape:h},f){let u="";if(d&&(u=y("rect",{x:i,y:a-r,width:o,height:r,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:s||void 0,"clip-path":p?`url(#${p})`:void 0})),m){let x={href:m,x:i,y:a,width:o,height:r,transform:s||void 0,"clip-path":p?`url(#${p})`:void 0,style:f.filter?`filter:${f.filter}`:void 0};return[(n?`${n}<g filter="url(#satori_s-${e})">`:"")+y("image",{...x,opacity:l!==1?l:void 0})+(h||"")+(n?"</g>":"")+u,""]}let b={x:i,y:a,width:o,height:r,"font-weight":f.fontWeight,"font-style":f.fontStyle,"font-size":f.fontSize,"font-family":f.fontFamily,"letter-spacing":f.letterSpacing||void 0,transform:s||void 0,"clip-path":p?`url(#${p})`:void 0,style:f.filter?`filter:${f.filter}`:void 0};return[(n?`${n}<g filter="url(#satori_s-${e})">`:"")+y("text",{...b,fill:f.color,opacity:l!==1?l:void 0},t)+(h||"")+(n?"</g>":"")+u,g?y("text",b,t):""]}function fe({id:e,width:t,height:n},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius>"u")return"";let a=i.shadowRadius*i.shadowRadius/4,o=Math.min(i.shadowOffset.width-a,0),r=Math.max(i.shadowOffset.width+a+t,t),s=Math.min(i.shadowOffset.height-a,0),l=Math.max(i.shadowOffset.height+a+n,n);return`<defs><filter id="satori_s-${e}" x="${o/t*100}%" y="${s/n*100}%" width="${(r-o)/t*100}%" height="${(l-s)/n*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}function je({width:e,left:t,top:n,ascender:i,clipPathId:a},o){let{textDecorationColor:r,textDecorationStyle:s,textDecorationLine:l,fontSize:m}=o;if(!l||l==="none")return"";let p=Math.max(1,m*.1),d=l==="line-through"?n+i*.5:l==="underline"?n+i*1.1:n,g=s==="dashed"?`${p*1.2} ${p*2}`:s==="dotted"?`0 ${p*2}`:void 0;return y("line",{x1:t,y1:d,x2:t+e,y2:d,stroke:r,"stroke-width":p,"stroke-dasharray":g,"stroke-linecap":s==="dotted"?"round":"square","clip-path":a?`url(#${a})`:void 0})}var Ve=void 0;async function*Je(e,t){var ft;let n=ee(),{parentStyle:i,inheritedStyle:a,parent:o,font:r,id:s,isInheritingTransform:l,debug:m,embedFont:p,graphemeImages:d,canLoadAdditionalAssets:g}=t;i.textTransform==="uppercase"?e=e.toLocaleUpperCase(Ve):i.textTransform==="lowercase"?e=e.toLocaleLowerCase(Ve):i.textTransform==="capitalize"&&(e=ae(e,"word").map(_=>ae(_,"grapheme").map((I,L)=>L===0?I.toLocaleUpperCase(Ve):I).join("")).join(""));let h=K(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),f=ae(e,h),u=n.Node.create();u.setAlignItems(n.ALIGN_BASELINE),i.textAlign==="left"?u.setJustifyContent(n.JUSTIFY_FLEX_START):i.textAlign==="center"?u.setJustifyContent(n.JUSTIFY_CENTER):i.textAlign==="right"?u.setJustifyContent(n.JUSTIFY_FLEX_END):i.textAlign==="justify"&&u.setJustifyContent(n.JUSTIFY_SPACE_BETWEEN),o.insertChild(u,o.getChildCount());let{textAlign:b,textOverflow:x,whiteSpace:E,lineHeight:F,filter:$,_inheritedBackgroundClipTextPath:N}=i,W=i.fontSize,R=r.getEngine(W,F,i),V=g?f.filter(_=>!R.check(_)):[];yield V,V.length&&(R=r.getEngine(W,F,i));let A=[],v=[],M=[],G=[],Y=new Map,k=_=>{let I=0;for(let L of _){if(Y.has(L)){I+=Y.get(L);continue}let U=R.measure(L,i);Y.set(L,U),I+=U}return I},O=0,J=[],c=0;for(let _ of f){let I=!1,L=d&&d[_];E==="pre"?I=_[0]===`
|
|
2
|
+
`:E!=="nowrap"&&(L||Re.includes(_[0]))&&(I=!0),I?(E==="nowrap"?c+=k(J)+i.fontSize:(O=Math.max(O,k(J)),L&&(O=Math.max(O,i.fontSize))),J=[]):(!Re.includes(_[0])||!J.length)&&J.push(_===`
|
|
3
|
+
`?" ":_)}O=Math.max(O,k(J)+c);let w=o.getMinWidth(),C=o.getMaxWidth(),Z=o.getWidth();isNaN(Z.value)&&(isNaN(w.value)||w.unit===1&&w.value>O)&&(isNaN(C.value)||C.unit===1&&(O=Math.min(O,C.value)),o.setMinWidth(O)),typeof i.flexShrink>"u"&&o.setFlexShrink(1);let ge=E==="pre-wrap"||E==="pre";u.setMeasureFunc(_=>{let I=0,L="",U=0,z=0,H=0,X=-1,re=0,P=0,ie=0;A=[],M=[0];for(let ne=0;ne<f.length;ne++){let D=f[ne];if(!ge&&Re.includes(D[0]))L||(L=" "),U=k([L]),G[ne]=null;else{let oe=ge&&D===`
|
|
4
|
+
`,j=oe?0:d&&d[D]?i.fontSize:k([D]);z||(L="",U=0);let B=U||",.!?:-@)>]}%#".indexOf(D[0])<0,q=!z||!!U;if(oe||ne&&B&&z+U+j>_&&E!=="nowrap"&&E!=="pre")A.push(z),v.push(ie),I++,re+=P,z=j,P=j?R.height(D):0,ie=j?R.baseline(D):0,M.push(1),X=-1,oe||(H=Math.max(H,_));else{z+=U+j;let de=R.height(D);de>P&&(P=de,ie=R.baseline(D)),q&&M[M.length-1]++}L="",U=0,q&&X++,H=Math.max(H,z),G[ne]={y:re,x:z-j,width:j,line:I,lineIndex:X}}}return z&&(I++,A.push(z),v.push(ie),re+=P),{width:H,height:re}});let[Ot,Ft]=yield,Oe="",we="",te=a._inheritedClipPathId,{left:it,top:ot,width:Ee,height:at}=u.getComputedLayout(),Fe=o.getComputedWidth()-o.getComputedPadding(n.EDGE_LEFT)-o.getComputedPadding(n.EDGE_RIGHT)-o.getComputedBorder(n.EDGE_LEFT)-o.getComputedBorder(n.EDGE_RIGHT),ue=Ot+it,ce=Ft+ot,{matrix:Q,opacity:ve}=Tt({left:it,top:ot,width:Ee,height:at,isInheritingTransform:l},i),ke="";i.textShadowOffset&&(ke=fe({width:Ee,height:at,id:s},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius}));let me="",Se="",st="",Pe=-1,lt=x==="ellipsis"?k(["\u2026"]):0,Pt=x==="ellipsis"?k([" "]):0,Te={};for(let _=0;_<f.length;_++){if(!G[_])continue;let I=G[_],L=f[_],U=null,z=d?d[L]:null,H=I.y,X=I.x,re=I.width,P=I.line;if(P===Pe)continue;let ie=!1;if(A.length>1){let B=Ee-A[P];if(b==="right"||b==="end")X+=B;else if(b==="center")X+=B/2;else if(b==="justify"&&P<A.length-1){let q=M[P];X+=(q>1?B/(q-1):0)*I.lineIndex,ie=!0}}if(Te[P]||(Te[P]=[X,ie?Ee:A[P]]),x==="ellipsis"&&A[P]>Fe&&I.x+re+lt+Pt>Fe){let B=ae(L,"grapheme"),q="",de=0;for(let ut of B){let ct=I.x+k([q+ut]);if(q&&ct+lt>Fe)break;q+=ut,de=ct}L=q+"\u2026",Pe=P,Te[P][1]=de}let ne=v[P],D=R.baseline(L),oe=R.height(L),j=ne-D;if(z?H+=0:p?(U=R.getSVG(L,{...i,left:ue+X,top:ce+H+D+j,letterSpacing:i.letterSpacing}),m&&(st+=y("rect",{x:ue+X,y:ce+H+j,width:I.width,height:oe,fill:"transparent",stroke:"#575eff","stroke-width":1,transform:Q||void 0,"clip-path":te?`url(#${te})`:void 0})+y("line",{x1:ue+X,x2:ue+X+I.width,y1:ce+H+j+D,y2:ce+H+j+D,stroke:"#14c000","stroke-width":1,transform:Q||void 0,"clip-path":te?`url(#${te})`:void 0}))):H+=D+j,i.textDecorationLine&&(P!==((ft=G[_+1])==null?void 0:ft.line)||Pe===P)){let B=Te[P];B&&!B[2]&&(me+=je({left:ue+B[0],top:ce+oe*+P,width:B[1],ascender:R.baseline(L),clipPathId:te},i),B[2]=1)}if(U!==null)Se+=U+" ";else{let[B,q]=Xe({content:L,filter:ke,id:s,left:ue+X,top:ce+H,width:re,height:oe,matrix:Q,opacity:ve,image:z,clipPathId:te,debug:m,shape:!!N,decorationShape:me},i);Oe+=B,we+=q,me=""}}if(Se){let _=i.color!=="transparent"&&ve!==0?y("path",{fill:i.color,d:Se,transform:Q||void 0,opacity:ve!==1?ve:void 0,"clip-path":te?`url(#${te})`:void 0,style:$?`filter:${$}`:void 0}):"";N&&(we=y("path",{d:Se,transform:Q||void 0})),Oe+=(ke?ke+y("g",{filter:`url(#satori_s-${s})`},_+me):_+me)+st}return we&&(i._inheritedBackgroundClipTextPath.value+=we),Oe}var qe=qe||{};qe.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]+\.?))/},t="";function n(c){var w=new Error(t+": "+c);throw w.source=t,w}function i(){var c=a();return t.length>0&&n("Invalid input not EOF"),c}function a(){return F(o)}function o(){return r("linear-gradient",e.linearGradient,l)||r("repeating-linear-gradient",e.repeatingLinearGradient,l)||r("radial-gradient",e.radialGradient,d)||r("repeating-radial-gradient",e.repeatingRadialGradient,d)}function r(c,w,C){return s(w,function(Z){var ge=C();return ge&&(O(e.comma)||n("Missing comma before color stops")),{type:c,orientation:ge,colorStops:F($)}})}function s(c,w){var C=O(c);if(C){O(e.startCall)||n("Missing (");var Z=w(C);return O(e.endCall)||n("Missing )"),Z}}function l(){return m()||p()}function m(){return k("directional",e.sideOrCorner,1)}function p(){return k("angular",e.angleValue,1)}function d(){var c,w=g(),C;return w&&(c=[],c.push(w),C=t,O(e.comma)&&(w=g(),w?c.push(w):t=C)),c}function g(){var c=h()||f();if(c)c.at=b();else{var w=u();if(w){c=w;var C=b();C&&(c.at=C)}else{var Z=x();Z&&(c={type:"default-radial",at:Z})}}return c}function h(){var c=k("shape",/^(circle)/i,0);return c&&(c.style=Y()||u()),c}function f(){var c=k("shape",/^(ellipse)/i,0);return c&&(c.style=M()||u()),c}function u(){return k("extent-keyword",e.extentKeywords,1)}function b(){if(k("position",/^at/,0)){var c=x();return c||n("Missing positioning value"),c}}function x(){var c=E();if(c.x||c.y)return{type:"position",value:c}}function E(){return{x:M(),y:M()}}function F(c){var w=c(),C=[];if(w)for(C.push(w);O(e.comma);)w=c(),w?C.push(w):n("One extra comma");return C}function $(){var c=N();return c||n("Expected color definition"),c.length=M(),c}function N(){return R()||A()||V()||W()}function W(){return k("literal",e.literalColor,0)}function R(){return k("hex",e.hexColor,1)}function V(){return s(e.rgbColor,function(){return{type:"rgb",value:F(v)}})}function A(){return s(e.rgbaColor,function(){return{type:"rgba",value:F(v)}})}function v(){return O(e.number)[1]}function M(){return k("%",e.percentageValue,1)||G()||Y()}function G(){return k("position-keyword",e.positionKeywords,1)}function Y(){return k("px",e.pixelValue,1)||k("em",e.emValue,1)}function k(c,w,C){var Z=O(w);if(Z)return{type:c,value:Z[C]}}function O(c){var w,C;return C=/^[\n\r\t\s]+/.exec(t),C&&J(C[0].length),w=c.exec(t),w&&J(w[0].length),w}function J(c){t=t.substr(c)}return function(c){return t=c.toString(),i()}}();var Ke=qe;var Rt=mt(100),Ze=new Map,ln=["image/png","image/jpeg","image/gif","image/svg+xml"];function fn(e){let t="",n=new Uint8Array(e);for(let i=0;i<n.byteLength;i++)t+=String.fromCharCode(n[i]);return btoa(t)}async function Ie(e){if(!e)throw new Error("Image URL is not provided");if(e.startsWith("data:"))return e;if(!globalThis.fetch)throw new Error("`fetch` is required to be polyfilled to load images.");if(Ze.has(e))return Ze.get(e);let t=Rt.get(e);if(t)return t;let n=new Promise((i,a)=>{let o;fetch(e).then(r=>{if(o=r.headers.get("content-type").toLowerCase(),!ln.includes(o))throw new Error(`Unsupported image type: ${o}`);return r.arrayBuffer()}).then(r=>{let s=`data:${o};base64,${fn(r)}`;Rt.set(e,s),i(s)}).catch(a)});return Ze.set(e,n),n}function un(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 cn(e,t){return typeof e=="string"&&e.endsWith("%")?t*parseFloat(e)/100:+e}function _t(e,{x:t,y:n,defaultX:i,defaultY:a}){return(e?e.split(" ").map(o=>{try{let r=new se(o);return r.type==="length"||r.type==="number"?r.value:r.value+r.unit}catch{return null}}).filter(o=>o!==null):[i,a]).map((o,r)=>cn(o,[t,n][r]))}function Ct(e,t){let n=[];for(let r of t){let s=un(r);if(!n.length&&(n.push({offset:0,color:s}),typeof r.length>"u"||r.length.value==="0"))continue;let l=typeof r.length>"u"?void 0:r.length.type==="%"?r.length.value/100:r.length.value/e;n.push({offset:l,color:s})}n.length||n.push({offset:0,color:"transparent"});let i=n[n.length-1];i.offset!==1&&(typeof i.offset>"u"?i.offset=1:n.push({offset:1,color:i.color}));let a=0,o=1;for(let r=0;r<n.length;r++)if(typeof n[r].offset>"u"){for(o<r&&(o=r);typeof n[o].offset>"u";)o++;n[r].offset=(n[o].offset-n[a].offset)/(o-a)*(r-a)+n[a].offset}else a=r;return n}async function Qe({id:e,width:t,height:n},{image:i,size:a,position:o,repeat:r}){r=r||"repeat";let s=r==="repeat-x"||r==="repeat",l=r==="repeat-y"||r==="repeat",m=_t(a,{x:t,y:n,defaultX:t,defaultY:n}),p=_t(o,{x:t,y:n,defaultX:0,defaultY:0});if(i.startsWith("linear-gradient(")){let d=Ke.parse(i)[0],g,h,f,u;if(d.orientation.type==="directional")[g,h,f,u]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[d.orientation.value];else if(d.orientation.type==="angular"){let x=+d.orientation.value/180*Math.PI-Math.PI/2,E=Math.cos(x),F=Math.sin(x);g=0,h=0,f=E,u=F,f<0&&(g-=f,f=0),u<0&&(h-=u,u=0)}let b=Ct(t,d.colorStops);return[`satori_bi${e}`,`<linearGradient id="satori_bi${e}" x1="${g}" y1="${h}" x2="${f}" y2="${u}">${b.map(x=>`<stop offset="${x.offset*100}%" stop-color="${x.color}"/>`).join("")}</linearGradient>`]}if(i.startsWith("radial-gradient(")){let d=Ke.parse(i)[0],g=d.orientation[0],[h,f]=m,u="circle",b=h/2,x=f/2;if(g.type==="shape"){if(u=g.value,g.at)if(g.at.type==="position")b=g.at.value.x.value,x=g.at.value.y.value;else throw new Error("orientation.at.type not implemented: "+g.at.type)}else throw new Error("orientation.type not implemented: "+g.type);let E=Ct(t,d.colorStops),F=`satori_radial_${e}`,$=`satori_pattern_${e}`,N={},W=Math.max(Math.abs(h-b),Math.abs(b)),R=Math.max(Math.abs(f-x),Math.abs(x));if(u==="circle")N.r=Math.sqrt(W*W+R*R);else if(u==="ellipse"){let v=R!==0?W/R:1;N.ry=Math.sqrt(W*W+R*R*v*v)/v,N.rx=N.ry*v}let V=y("pattern",{id:$,x:p[0],y:p[1],width:s?h:"100%",height:l?f:"100%",patternUnits:"userSpaceOnUse"},y("radialGradient",{id:F},E.map(v=>y("stop",{offset:v.offset,"stop-color":v.color})).join(""))+y(u,{cx:b,cy:x,width:h,height:f,...N,fill:`url(#${F})`}));return[$,V]}if(i.startsWith("url(")){let d=await Ie(i.slice(4,-1));return[`satori_bi${e}`,y("pattern",{id:`satori_bi${e}`,patternContentUnits:"userSpaceOnUse",patternUnits:"userSpaceOnUse",x:p[0],y:p[1],width:s?m[0]:"100%",height:l?m[1]:"100%"},y("image",{x:0,y:0,width:m[0],height:m[1],href:d}))]}}function Le(e,t,n){return n<e+t&&(n/2<e&&n/2<t?e=t=n/2:n/2<e?e=n-t:n/2<t&&(t=n-e)),[e,t]}function be({left:e,top:t,width:n,height:i},a){let{borderTopLeftRadius:o,borderTopRightRadius:r,borderBottomLeftRadius:s,borderBottomRightRadius:l}=a;return o=Math.min(o||0,n,i),r=Math.min(r||0,n,i),s=Math.min(s||0,n,i),l=Math.min(l||0,n,i),!o&&!r&&!s&&!l?"":([o,r]=Le(o,r,n),[o,s]=Le(o,s,i),[r,l]=Le(r,l,i),[s,l]=Le(s,l,n),`M${e+o},${t} h${n-o-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-l} a${l},${l} 0 0 1 ${-l},${l} h${l+s-n} a${s},${s} 0 0 1 ${-s},${-s} v${s+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function et({left:e,top:t,width:n,height:i,path:a,id:o},r){return r.overflow!=="hidden"?"":a?y("clipPath",{id:`satori_cp-${o}`,"clip-path":r._inheritedClipPathId?`url(#${r._inheritedClipPathId})`:void 0},y("path",{x:e,y:t,width:n,height:i,d:a})):y("clipPath",{id:`satori_cp-${o}`,"clip-path":r._inheritedClipPathId?`url(#${r._inheritedClipPathId})`:void 0},y("rect",{x:e,y:t,width:n,height:i}))}async function tt({id:e,left:t,top:n,width:i,height:a,isInheritingTransform:o,debug:r},s){if(s.display==="none")return"";let l="rect",m="transparent",p="",d=0,g="",h="",f=[],u=1,b="";s.backgroundColor&&f.push(s.backgroundColor),s.borderWidth&&(d=s.borderWidth,m=s.borderColor,s.borderStyle==="dashed"&&(p=d*2+" "+d)),s.opacity&&(u=+s.opacity),s.transform&&(g=le({left:t,top:n,width:i,height:a},s.transform,o,s.transformOrigin));let x="";if(s.backgroundImage){let A=[];for(let v=0;v<s.backgroundImage.length;v++){let M=s.backgroundImage[v],G=await Qe({id:e+"_"+v,width:i,height:a},M);G&&A.push(G)}for(let v of A)f.push(`url(#${v[0]})`),h+=v[1],v[2]&&(x+=v[2])}let E=be({left:t,top:n,width:i,height:a},s);E&&(l="path");let F=et({left:t,top:n,width:i,height:a,path:E,id:e},s),$=s._inheritedClipPathId,N=fe({width:i,height:a,id:e},s);r&&(b=y("rect",{x:t,y:n,width:i,height:a,fill:"transparent",stroke:"#ff5757","stroke-width":1,"stroke-dasharray":p||void 0,transform:g||void 0,"clip-path":$?`url(#${$})`:void 0})),f.length||f.push("transparent");let{backgroundClip:W,filter:R}=s,V=f.map((A,v)=>{if(A==="transparent"&&!(v===f.length-1&&d))return"";let M=!!d,G=v===f.length-1&&M&&W!=="text",Y=W==="text"?`url(#satori_bct-${e})`:$?`url(#${$})`:void 0;return G&&(h+=y("clipPath",{id:`satori_bc-${e}`,"clip-path":Y},y(l,{x:t,y:n,width:i,height:a,d:E||void 0})),Y=`url(#satori_bc-${e})`),y(l,{x:t,y:n,width:i,height:a,fill:A,stroke:G||M?m:void 0,"stroke-width":G?d*2:M?1:void 0,"stroke-dasharray":p||void 0,d:E||void 0,transform:g||void 0,"clip-path":Y,style:R?`filter:${R}`:void 0})}).join("");return W==="text"&&d&&(V=y(l,{x:t,y:n,width:i,height:a,fill:"transparent",stroke:m,"stroke-width":d*2,"stroke-dasharray":p||void 0,d:E||void 0,transform:g||void 0,"clip-path":$?`url(#${$})`:void 0})+V),(h?`<defs>${h}</defs>`:"")+F+(N?`${N}<g filter="url(#satori_s-${e})">`:"")+(u!==1?`<g opacity="${u}">`:"")+(x||V)+(u!==1?"</g>":"")+(N?"</g>":"")+b}function Ae({id:e,left:t,top:n,width:i,height:a,src:o,debug:r,isInheritingTransform:s},l){if(l.display==="none")return"";let m="",p=1,d="",g=l.objectFit==="contain"?"xMidYMid":l.objectFit==="cover"?"xMidYMid slice":"none",h=be({left:t,top:n,width:i,height:a},l),f=l._inheritedClipPathId;h&&(m=y("clipPath",{id:`satori_c-${e}`,"clip-path":f?`url(#${f})`:void 0},y("path",{x:t,y:n,width:i,height:a,d:h}))),l.opacity&&(p=+l.opacity);let u=fe({width:i,height:a,id:e},l);return l.transform&&(d=le({left:t,top:n,width:i,height:a},l.transform,s,l.transformOrigin)),u+(u?`<g filter="url(#satori_s-${e})">`:"")+m+y("image",{x:t,y:n,width:i,height:a,href:o,preserveAspectRatio:g,transform:d||void 0,"clip-path":m?`url(#satori_c-${e})`:f?`url(#${f})`:void 0})+(u?"</g>":"")}async function*ye(e,t){var J;let n=ee(),{id:i,inheritedStyle:a,parent:o,font:r,debug:s,embedFont:l=!0,graphemeImages:m,canLoadAdditionalAssets:p}=t;if(e===null||typeof e>"u")return yield,yield,"";if(!We(e)||typeof e.type=="function"){let c;if(!We(e))c=Je(String(e),t),yield(await c.next()).value;else{if(pt(e.type))throw new Error("Class component is not supported.");c=ye(e.type(e.props),t),yield(await c.next()).value}await c.next();let w=yield;return(await c.next(w)).value}let{type:d,props:g}=e,{style:h,children:f}=g||{},u=n.Node.create();o.insertChild(u,o.getChildCount());let[b,x]=He(u,d,a,h,g),E=b.transform===a.transform;if(E||(b.transform.__parent=a.transform),b.overflow==="hidden"&&(x._inheritedClipPathId=`satori_cp-${i}`),b.backgroundClip==="text"){let c={value:""};x._inheritedBackgroundClipTextPath=c,b._inheritedBackgroundClipTextPath=c}let F=typeof f>"u"?[]:[].concat(f).flat(1/0),$=[],N=0,W=[];for(let c of F){let w=ye(c,{id:i+"-"+N++,parentStyle:b,inheritedStyle:x,isInheritingTransform:!0,parent:u,font:r,embedFont:l,debug:s,graphemeImages:m,canLoadAdditionalAssets:p});p?W.push(...(await w.next()).value||[]):await w.next(),$.push(w)}yield W;for(let c of $)await c.next();let[R,V]=yield,{left:A,top:v,width:M,height:G}=u.getComputedLayout();A+=R,v+=V;let Y="",k="",O="";if(d==="img"){let c=await Ie(g.src);k=Ae({id:i,left:A,top:v,width:M,height:G,src:c,isInheritingTransform:E,debug:s},b)}else if(d==="svg"){let c=bt(e);k=Ae({id:i,left:A,top:v,width:M,height:G,src:c,isInheritingTransform:E,debug:s},b)}else{let c=(J=h==null?void 0:h.display)!=null?J:"block";if(d==="div"&&f&&typeof f!="string"&&c!=="flex"&&c!=="none")throw new Error(`Expected <div> to have style={{display: 'flex'}} but received style={{display: '${c}'}}`);k=await tt({id:i,left:A,top:v,width:M,height:G,isInheritingTransform:E,debug:s},b)}for(let c of $)Y+=(await c.next([A,v])).value;return b._inheritedBackgroundClipTextPath&&(O+=y("clipPath",{id:`satori_bct-${i}`,"clip-path":b._inheritedClipPathId?`url(#${b._inheritedClipPathId})`:void 0},b._inheritedBackgroundClipTextPath.value)),O+k+Y}import dn from"@shuding/opentype.js";function pn(e,t,[n,i],[a,o]){if(n!==a)return n?!a||n===e?-1:a===e?1:e===400&&n===500||e===500&&n===400?-1:e===400&&a===500||e===500&&a===400?1:e<400?n<e&&a<e?a-n:n<e?-1:a<e?1:n-a:e<n&&e<a?n-a:e<n?-1:e<a?1:a-n:1;if(i!==o){if(i===t)return-1;if(o===t)return 1}return-1}var xe=class{constructor(t){this.fonts=new Map;this.addFonts(t)}get({name:t,weight:n,style:i}){if(!this.fonts.has(t))return null;n==="normal"&&(n=400),n==="bold"&&(n=700);let a=[...this.fonts.get(t)],o=a[0];for(let r=1;r<a.length;r++){let[,s,l]=o,[,m,p]=a[r];pn(n,i,[s,l],[m,p])>0&&(o=a[r])}return o[0]}addFonts(t){for(let n of t){let i=n.data,a=dn.parse("buffer"in i?i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength):i,{lowMemory:!0}),o=a.charToGlyphIndex;a.charToGlyphIndex=s=>{let l=o.call(a,s);return l===0&&a._trackBrokenChars&&a._trackBrokenChars.push(s),l},this.defaultFont||(this.defaultFont=a);let r=n.name.toLowerCase();this.fonts.has(r)||this.fonts.set(r,[]),this.fonts.get(r).push([a,n.weight,n.style])}}getEngine(t=16,n=1.2,{fontFamily:i,fontWeight:a=400,fontStyle:o="normal"}){i=Array.isArray(i)?i:[i];let r=i.map(f=>this.get({name:f,weight:a,style:o})).filter(Boolean),s=Array.from(this.fonts.keys());for(let f of s)i.includes(f)||r.push(this.get({name:f,weight:a,style:o}));let l=new Map,m=(f,u=!0)=>{let b=f.charCodeAt(0);if(l.has(b))return l.get(b);let x=r.find((E,F)=>!!E.charToGlyphIndex(f)||u&&F===r.length-1);return x&&l.set(b,x),x},p=(f,u=!1)=>{var x,E;return((u?(E=(x=f.tables)==null?void 0:x.os2)==null?void 0:E.sTypoAscender:0)||f.ascender)/f.unitsPerEm*t},d=(f,u=!1)=>{var x,E;return((u?(E=(x=f.tables)==null?void 0:x.os2)==null?void 0:E.sTypoDescender:0)||f.descender)/f.unitsPerEm*t},g=f=>m(f,!1),h={check:f=>{let u=g(f);return u?(u._trackBrokenChars=[],u.stringToGlyphs(f),u._trackBrokenChars.length?(u._trackBrokenChars=void 0,!1):!0):!1},baseline:(f,u=typeof f>"u"?r[0]:m(f))=>{let b=p(u,!0),x=d(u,!0),E=h.height(f,u),{yMax:F,yMin:$}=u.tables.head,N=b-x,W=(F/(F-$)-1)*N;return E*((1.2/n+1)/2)+W},height:(f,u=typeof f>"u"?r[0]:m(f))=>(p(u)-d(u))*(n/1.2),measure:(f,u)=>this.measure(m,f,u),getSVG:(f,u)=>this.getSVG(m,f,u)};return h}patchFontFallbackResolver(t,n){let i=[];t._trackBrokenChars=i;let a=t.stringToGlyphs;return t.stringToGlyphs=(o,...r)=>{let s=a.call(t,o,...r);for(let l=0;l<s.length;l++)if(s[l].unicode===void 0){let m=i.shift(),p=n(m);p!==t&&(s[l]=p.charToGlyph(m))}return s},()=>{t.stringToGlyphs=a,t._trackBrokenChars=void 0}}measure(t,n,{fontSize:i,letterSpacing:a=0}){let o=t(n),r=this.patchFontFallbackResolver(o,t);try{return o.getAdvanceWidth(n,i,{letterSpacing:a/i})}finally{r()}}getSVG(t,n,{fontSize:i,top:a,left:o,letterSpacing:r=0}){let s=t(n),l=this.patchFontFallbackResolver(s,t);try{return s.getPath(n,o,a,i,{letterSpacing:r/i}).toPathData(1)}finally{l()}}};function nt({width:e,height:t,content:n}){return y("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,xmlns:"http://www.w3.org/2000/svg"},n)}var It={emoji:/\p{RI}\p{RI}|\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})?(\u{200D}\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})?)+|\p{EPres}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})?|\p{Emoji}(\p{EMod}+|\u{FE0F}\u{20E3}?|[\u{E0020}-\u{E007E}]+\u{E007F})/u,ja:/\p{scx=Hira}|\p{scx=Kana}|[,;:]/u,ko:/\p{scx=Hangul}/u,zh:/\p{scx=Han}/u,th:/\p{scx=Thai}/u,bn:/\p{scx=Bengali}/u,ar:/\p{scx=Arabic}/u,ta:/\p{scx=Tamil}/u,ml:/\p{scx=Malayalam}/u,he:/\p{scx=Hebrew}/u,te:/\p{scx=Telugu}/u,devanagari:/\p{scx=Devanagari}/u};function Lt(e){for(let t in It)if(It[t].test(e))return t;return"unknown"}var rt=new WeakMap;async function At(e,t){let n=ee();if(!n)throw new Error("Satori is not initialized.");let i;rt.has(t.fonts)?i=rt.get(t.fonts):rt.set(t.fonts,i=new xe(t.fonts));let a=n.Node.create();a.setWidth(t.width),a.setHeight(t.height),a.setFlexDirection(n.FLEX_DIRECTION_ROW),a.setFlexWrap(n.WRAP_WRAP),a.setAlignContent(n.ALIGN_AUTO),a.setAlignItems(n.ALIGN_FLEX_START),a.setJustifyContent(n.JUSTIFY_FLEX_START),a.setOverflow(n.OVERFLOW_HIDDEN);let o={...t.graphemeImages},r=ye(e,{id:"id",parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1,whiteSpace:"normal",_viewportWidth:t.width,_viewportHeight:t.height},parent:a,font:i,embedFont:t.embedFont,debug:t.debug,graphemeImages:o,canLoadAdditionalAssets:!!t.loadAdditionalAsset}),s=(await r.next()).value;if(t.loadAdditionalAsset&&s.length){s=Array.from(new Set(ae(s.join(""),"grapheme")));let m={};s.forEach(g=>{let h=Lt(g);m[h]=m[h]||[],h==="emoji"?m[h].push(g):m[h][0]=(m[h][0]||"")+g});let p=[],d={};await Promise.all(Object.entries(m).flatMap(([g,h])=>h.map(f=>t.loadAdditionalAsset(g,f).then(u=>{typeof u=="string"?d[f]=u:u&&p.push(u)})))),i.addFonts(p),Object.assign(o,d)}await r.next(),a.calculateLayout(t.width,t.height,n.DIRECTION_LTR);let l=(await r.next([0,0])).value;return a.freeRecursive(),nt({width:t.width,height:t.height,content:l})}export{At as default,Mt as init};
|
|
5
5
|
//# sourceMappingURL=index.js.map
|