umang2191 commited on
Commit
00f15aa
·
verified ·
1 Parent(s): e67eb96

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +122 -0
  2. inject.js +4 -0
  3. packages.txt +22 -0
  4. requirements.txt +1 -0
  5. server.mjs +0 -0
app.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Web2Fig helper on a Hugging Face *Gradio* Space.
3
+
4
+ The Space's public address is the helper's API, which the Web2Fig Figma plugin calls. Inside, `server.mjs` (a Node
5
+ server) does the work on a private port, and this file is a thin front door:
6
+
7
+ * everything except /ui is forwarded as-is to the Node helper (/health, /capture, ...);
8
+ * /ui is a tiny Gradio page with one @spaces.GPU function. It is never used for real work. Accounts that can only
9
+ create *ZeroGPU* Spaces need such a function, otherwise the Space refuses to start ("No @spaces.GPU function").
10
+
11
+ Node and Chrome are fetched on first start if the machine does not already have them.
12
+ """
13
+ import os
14
+ import platform
15
+ import shutil
16
+ import subprocess
17
+ import sys
18
+ import tarfile
19
+ import threading
20
+ import time
21
+ import urllib.request
22
+
23
+ import gradio as gr
24
+ import httpx
25
+ import spaces
26
+ import uvicorn
27
+ from fastapi import FastAPI, Request
28
+ from starlette.background import BackgroundTask
29
+ from starlette.responses import StreamingResponse
30
+
31
+ HERE = os.path.dirname(os.path.abspath(__file__))
32
+ PUBLIC_PORT = int(os.environ.get("PORT") or os.environ.get("GRADIO_SERVER_PORT") or "7860")
33
+ NODE_PORT = 5810
34
+ NODE_VERSION = "20.18.0"
35
+ TOOLS = os.path.join("/tmp", "web2fig-tools")
36
+
37
+
38
+ def log(msg):
39
+ print(f"[web2fig] {msg}", flush=True)
40
+
41
+
42
+ def node_ok(path):
43
+ try:
44
+ out = subprocess.check_output([path, "--version"], text=True, timeout=20).strip()
45
+ return int(out.lstrip("v").split(".")[0]) >= 18
46
+ except Exception:
47
+ return False
48
+
49
+
50
+ def ensure_node():
51
+ """Use the system Node when it is new enough, otherwise download the official build once."""
52
+ found = shutil.which("node")
53
+ if found and node_ok(found):
54
+ return found
55
+ arch = {"x86_64": "x64", "amd64": "x64", "aarch64": "arm64", "arm64": "arm64"}.get(platform.machine().lower(), "x64")
56
+ name = f"node-v{NODE_VERSION}-linux-{arch}"
57
+ target = os.path.join(TOOLS, name, "bin", "node")
58
+ if os.path.exists(target) and node_ok(target):
59
+ return target
60
+ os.makedirs(TOOLS, exist_ok=True)
61
+ url = f"https://nodejs.org/dist/v{NODE_VERSION}/{name}.tar.xz"
62
+ archive = os.path.join(TOOLS, f"{name}.tar.xz")
63
+ log(f"downloading Node {NODE_VERSION} …")
64
+ urllib.request.urlretrieve(url, archive)
65
+ with tarfile.open(archive, "r:xz") as tar:
66
+ tar.extractall(TOOLS)
67
+ os.remove(archive)
68
+ return target
69
+
70
+
71
+ def run_node_forever():
72
+ node = ensure_node()
73
+ log(f"using Node at {node}")
74
+ env = dict(os.environ)
75
+ env.update(
76
+ {
77
+ "WEB2FIG_PUBLIC": "1",
78
+ "PORT": str(NODE_PORT),
79
+ "WEB2FIG_CACHE": os.path.join("/tmp", "web2fig-chrome"),
80
+ "HOME": os.environ.get("HOME", "/tmp"),
81
+ }
82
+ )
83
+ while True: # restart the helper if it ever exits
84
+ code = subprocess.call([node, "server.mjs"], cwd=HERE, env=env)
85
+ log(f"helper exited with code {code}; restarting in 3s")
86
+ time.sleep(3)
87
+
88
+
89
+ # ---- the ZeroGPU placeholder (never used for real work) ----
90
+ @spaces.GPU
91
+ def gpu_placeholder(text: str) -> str:
92
+ return text
93
+
94
+
95
+ demo = gr.Interface(fn=gpu_placeholder, inputs="text", outputs="text", title="Web2Fig helper", api_name=False)
96
+
97
+ app = FastAPI()
98
+ app = gr.mount_gradio_app(app, demo, path="/ui") # mounted first so the catch-all below does not shadow it
99
+
100
+ client = httpx.AsyncClient(base_url=f"http://127.0.0.1:{NODE_PORT}", timeout=None)
101
+ HOP = {"connection", "keep-alive", "transfer-encoding", "te", "trailer", "upgrade", "proxy-authenticate", "proxy-authorization"}
102
+
103
+
104
+ @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH"])
105
+ async def forward(path: str, request: Request):
106
+ headers = {k: v for k, v in request.headers.items() if k.lower() not in HOP and k.lower() != "host"}
107
+ if "x-forwarded-for" not in {k.lower() for k in headers} and request.client:
108
+ headers["x-forwarded-for"] = request.client.host
109
+ try:
110
+ upstream = await client.send(
111
+ client.build_request(request.method, "/" + path, params=request.query_params, headers=headers, content=request.stream()),
112
+ stream=True,
113
+ )
114
+ except httpx.ConnectError:
115
+ return StreamingResponse(iter([b'{"ok":false,"error":"The helper is still starting. Try again in a few seconds."}']), status_code=503, media_type="application/json")
116
+ out = {k: v for k, v in upstream.headers.items() if k.lower() not in HOP}
117
+ return StreamingResponse(upstream.aiter_raw(), status_code=upstream.status_code, headers=out, background=BackgroundTask(upstream.aclose))
118
+
119
+
120
+ if __name__ == "__main__":
121
+ threading.Thread(target=run_node_forever, daemon=True).start()
122
+ uvicorn.run(app, host="0.0.0.0", port=PUBLIC_PORT, log_level="warning")
inject.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ (()=>{var Be={lazy:!0,speed:"balanced",images:!0,responsive:!1};function Ie(e){let t=new Uint8Array(e),n="";for(let r=0;r<t.length;r+=32768)n+=String.fromCharCode(...t.subarray(r,r+32768));return btoa(n)}async function he(e,t){if(e.size>12582912)throw new Error("image too large");let n=(e.type||"").toLowerCase();if(n.includes("svg")||/\.svg(\?|#|$)/i.test(t))return{kind:"svg",svg:await e.text()};let r=await createImageBitmap(e);try{let i=Math.min(1,2048/Math.max(r.width,r.height)),s=Math.max(1,Math.round(r.width*i)),o=Math.max(1,Math.round(r.height*i));if(i===1&&(n==="image/png"||n==="image/jpeg")&&e.size<=3145728)return{kind:"raster",mime:n,data:Ie(await e.arrayBuffer()),w:s,h:o};let l=new OffscreenCanvas(s,o),u=l.getContext("2d");if(!u)throw new Error("no 2d context");u.drawImage(r,0,0,s,o);let c=n==="image/jpeg"?"image/jpeg":"image/png",f=await l.convertToBlob({type:c,quality:.92});return{kind:"raster",mime:c,data:Ie(await f.arrayBuffer()),w:s,h:o}}finally{r.close()}}var p=(e,t=2)=>{let n=10**t;return Math.round(e*n)/n};function V(e,t=","){let n=[],r=0,i="",s=null;for(let o of e){if(s){i+=o,o===s&&(s=null);continue}if(o==='"'||o==="'"){s=o,i+=o;continue}o==="("?r++:o===")"&&r--,o===t&&r===0?(n.push(i.trim()),i=""):i+=o}return i.trim()&&n.push(i.trim()),n}function I(e){let t=[],n=0,r="";for(let i of e)i==="("?n++:i===")"&&n--,/\s/.test(i)&&n===0?(r&&t.push(r),r=""):r+=i;return r&&t.push(r),t}var ne=e=>Math.min(1,Math.max(0,e));function K(e,t){return e.endsWith("%")?ne(parseFloat(e)/100):ne(parseFloat(e)/t)}function $e(e){let t=e.trim();if(t.endsWith("%"))return ne(parseFloat(t)/100);let n=parseFloat(t);return Number.isFinite(n)?ne(n):1}function re(e,t){let n=e.trim().toLowerCase();if(!n||n==="none")return null;if(n==="transparent")return{r:0,g:0,b:0,a:0};let r=/^#([0-9a-f]{3,8})$/.exec(n);if(r){let s=r[1];return(s.length===3||s.length===4)&&(s=[...s].map(o=>o+o).join("")),s.length===6||s.length===8?{r:parseInt(s.slice(0,2),16)/255,g:parseInt(s.slice(2,4),16)/255,b:parseInt(s.slice(4,6),16)/255,a:s.length===8?parseInt(s.slice(6,8),16)/255:1}:null}let i=/^(rgba?|color)\((.*)\)$/s.exec(n);if(i){let[s,o]=i[2].split("/"),a=o!==void 0?$e(o):1,l=s.replace(/,/g," ").trim().split(/\s+/);return i[1]==="color"?l[0]!=="srgb"?t?t(n):null:(l=l.slice(1),l.length<3?null:{r:K(l[0],1),g:K(l[1],1),b:K(l[2],1),a}):l.length<3?null:(l.length>=4&&(a=$e(l[3])),{r:K(l[0],255),g:K(l[1],255),b:K(l[2],255),a})}return t?t(n):null}function ke(e){let t=/^(-?[\d.]+)(px)?$/.exec(e.trim());return t?parseFloat(t[1]):null}function oe(e,t){if(!e||e==="none")return[];let n=[];for(let r of V(e)){let i=!1,s=null,o=[];for(let a of I(r))if(a==="inset")i=!0;else{let l=ke(a);if(l!==null)o.push(l);else{let u=re(a,t);u&&(s=u)}}o.length<2||n.push({inset:i,x:o[0],y:o[1],blur:Math.max(0,o[2]??0),spread:o[3]??0,color:s??{r:0,g:0,b:0,a:1}})}return n}function Ct(e){let t=/^(-?[\d.]+)(deg|grad|rad|turn)?$/.exec(e.trim());if(!t)return null;let n=parseFloat(t[1]);switch(t[2]){case"grad":return n*360/400;case"rad":return n*180/Math.PI;case"turn":return n*360;default:return n}}function Mt(e,t,n){let r=e.replace(/^to\s+/,"").trim().split(/\s+/),i=a=>r.includes(a),s=i("right")?1:i("left")?-1:0,o=i("bottom")?1:i("top")?-1:0;if(!s&&!o)return null;if(s&&o){let a=s*n,l=o*t;return Math.atan2(a,-l)*180/Math.PI}return o===-1?0:s===1?90:o===1?180:270}function Oe(e,t){let n=[];for(let r of e){let i=I(r),s=null,o=[];for(let a of i){let l=s?null:re(a,t);if(l){s=l;continue}let u=/^(-?[\d.]+)(%|px)?$/.exec(a);u&&o.push({v:parseFloat(u[1]),unit:u[2]==="%"?"%":"px"})}if(s){o.length===0&&n.push({color:s,pos:null,unit:null});for(let a of o.slice(0,2))n.push({color:s,pos:a.v,unit:a.unit})}}return n}function De(e,t){if(e.length<2)return[];let n=e.map(o=>o.pos===null?null:o.unit==="%"?o.pos/100:t>0?o.pos/t:0);n[0]===null&&(n[0]=0),n[n.length-1]===null&&(n[n.length-1]=1);let r=0;for(;r<n.length;){if(n[r]!==null){r++;continue}let o=r-1,a=r;for(;n[a]===null;)a++;let l=n[o],u=n[a];for(let c=o+1;c<a;c++)n[c]=l+(u-l)*(c-o)/(a-o);r=a}let i=0,s=e.map((o,a)=>{let l=Math.max(i,ne(n[a]));return i=l,{pos:l,color:{...o.color}}});return s.forEach((o,a)=>{if(o.color.a>0)return;let l=a>0?s[a-1]:void 0,u=a<s.length-1?s[a+1]:void 0,c=l&&l.color.a>0?l:u&&u.color.a>0?u:null;c&&(o.color={r:c.color.r,g:c.color.g,b:c.color.b,a:0})}),s}function ge(e,t){return e==="left"||e==="top"?0:e==="center"?t/2:e==="right"||e==="bottom"?t:e.endsWith("%")?parseFloat(e)/100*t:ke(e)??t/2}function kt(e,t,n){if(e.length===0)return{x:t/2,y:n/2};if(e.length===1){let s=e[0];return s==="top"||s==="bottom"?{x:t/2,y:ge(s,n)}:{x:ge(s,t),y:n/2}}let[r,i]=e;return(r==="top"||r==="bottom"||i==="left"||i==="right")&&([r,i]=[i,r]),{x:ge(r,t),y:ge(i,n)}}function J(e,t,n){let r=/^(repeating-)?(linear|radial)-gradient\((.*)\)$/s.exec(e.trim());if(!r||r[1])return null;let i=r[2],s=V(r[3]);if(s.length<2)return null;let{w:o,h:a}=t,l=s[0].replace(/\s+in\s+[a-z0-9 -]+$/i,"").trim(),u=I(l).some(S=>re(S,n));if(i==="linear"){let S=180,R=s;if(!u||/^to\s/.test(l)){let O=/^to\s/.test(l)?Mt(l,o,a):Ct(l);O!==null&&(S=O),R=s.slice(1)}let C=S*Math.PI/180,L=Math.abs(o*Math.sin(C))+Math.abs(a*Math.cos(C)),k=De(Oe(R,n),L);return k.length>=2?{type:"linear",angle:S,stops:k}:null}let c=s,f=o/2,d=a/2,h=0,m=0,g="farthest-corner",x=!1,v=[];if(!u){c=s.slice(1);let[S,R]=l.split(/\s+at\s+/);for(let C of I(S??""))if(C==="circle")x=!0;else if(C==="ellipse")x=!1;else if(/^(closest|farthest)-(side|corner)$/.test(C))g=C;else{let L=C.endsWith("%")?parseFloat(C)/100*o:ke(C);L!==null&&v.push(L)}if(R){let C=kt(I(R),o,a);f=C.x,d=C.y}v.length===1&&(x=!0)}let b=f,w=o-f,M=d,y=a-d;if(v.length>=2)h=v[0],m=v[1];else if(v.length===1)h=m=v[0];else if(x){let S=[Math.hypot(b,M),Math.hypot(w,M),Math.hypot(b,y),Math.hypot(w,y)],R=[b,w,M,y];h=m=g==="closest-side"?Math.min(...R):g==="farthest-side"?Math.max(...R):g==="closest-corner"?Math.min(...S):Math.max(...S)}else{let S=Math.min(b,w),R=Math.min(M,y),C=Math.max(b,w),L=Math.max(M,y),k=Math.SQRT2;g==="closest-side"?[h,m]=[S,R]:g==="farthest-side"?[h,m]=[C,L]:g==="closest-corner"?[h,m]=[S*k,R*k]:[h,m]=[C*k,L*k]}if(!(h>0)||!(m>0))return null;let E=De(Oe(c,n),h);return E.length>=2?{type:"radial",cx:f,cy:d,rx:h,ry:m,stops:E}:null}function ie(e,t,n){let r=I(e);if(r.length===0)return 0;let i=(a,l)=>a.endsWith("%")?parseFloat(a)/100*l:parseFloat(a)||0,s=i(r[0],t),o=r[1]?i(r[1],n):r[0].endsWith("%")?i(r[0],n):s;return Math.max(0,Math.min(s,o))}var _e="webframe";var Et=6,Rt=48*1024*1024,be=class{ids=new Map;queue=[];counter=0;used=0;resolved={};failed=new Set;request(t){let n=t;try{n=new URL(t,document.baseURI).href}catch{}let r=this.ids.get(n);return r||(r=`a${this.counter++}`,this.ids.set(n,r),this.queue.push({id:r,url:n})),r}addInline(t){let n=`a${this.counter++}`;return this.resolved[n]=t,this.used+=t.kind==="raster"?t.data.length:t.svg.length,n}natural=new Map;reserve(){return`a${this.counter++}`}set(t,n){this.resolved[t]=n}get(t){return this.resolved[t]}get pending(){return this.queue.length}async resolveAll(t){let n=this.queue.splice(0),r=n.length,i=0,s=async()=>{for(let o=n.shift();o;o=n.shift()){try{if(this.used>Rt)throw new Error("budget");if(/^(blob|data):/i.test(o.url)){let l=await he(await(await fetch(o.url)).blob(),o.url);this.resolved[o.id]=l,this.used+=l.kind==="raster"?l.data.length:l.svg.length,t(++i,r);continue}let a=await chrome.runtime.sendMessage({type:"webframe:fetchAsset",url:o.url});if(!a||!a.ok)throw new Error(a&&!a.ok?a.error:"no response");this.resolved[o.id]=a.asset,this.used+=a.asset.kind==="raster"?a.asset.data.length:a.asset.svg.length}catch{this.failed.add(o.id)}t(++i,r)}};await Promise.all(Array.from({length:Math.min(Et,n.length)},s))}};function P(e,t,n=1){e.warnings.set(t,(e.warnings.get(t)??0)+n)}function D(e,t){return re(t,e.resolveColor)}function He(){let e=document.createElement("canvas");e.width=e.height=1;let t=e.getContext("2d",{willReadFrequently:!0});return n=>{if(!t)return null;try{if(t.clearRect(0,0,1,1),t.fillStyle="#010203",t.fillStyle=n,t.fillStyle==="#010203"&&n.replace(/\s/g,"")!=="#010203")return null;t.fillRect(0,0,1,1);let r=t.getImageData(0,0,1,1).data;return{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:r[3]/255}}catch{return null}}}function Ge(e){return[...e.fonts.entries()].map(([t,n])=>({family:t,weights:[...n.weights].sort((r,i)=>r-i),italic:n.italic,count:n.count})).sort((t,n)=>n.count-t.count)}function Ue(e){return[...e.warnings.entries()].map(([t,n])=>n>1?`${n}\xD7 ${t}`:t)}var Lt="*,*::before,*::after{transform:none!important;translate:none!important;rotate:none!important;scale:none!important}[data-wf-nb]::before{content:none!important}[data-wf-na]::after{content:none!important}[data-wf-pseudo]::before,[data-wf-pseudo]::after{content:none!important}",Y=e=>parseFloat(e)||0;function ze(e){let t=e.transform!=="none"&&e.transform!=="",n=e.translate&&e.translate!=="none"?e.translate:"",r=e.rotate&&e.rotate!=="none"?e.rotate:"",i=e.scale&&e.scale!=="none"?e.scale:"";if(!t&&!n&&!r&&!i)return null;let s=new DOMMatrix;if(n){let[u="0",c="0"]=n.split(/\s+/);s=s.translate(Y(u),Y(c))}if(r){let u=r.split(/\s+/);s=s.rotate(Y(u[u.length-1]))}if(i){let[u="1",c=u]=i.split(/\s+/);s=s.scale(Y(u)||1,Y(c)||1)}if(t)try{s=s.multiply(new DOMMatrix(e.transform))}catch{}let o=(u,c)=>Math.abs(u-c)<1e-4;if(o(s.a,1)&&o(s.b,0)&&o(s.c,0)&&o(s.d,1)&&o(s.e,0)&&o(s.f,0))return null;let[a="0",l="0"]=e.transformOrigin.split(/\s+/);return{m:[s.a,s.b,s.c,s.d,s.e,s.f],ox:Y(a),oy:Y(l)}}function Ve(e,t,n){for(let r of Array.from(e.querySelectorAll("*")))r.namespaceURI==="http://www.w3.org/2000/svg"&&r.tagName.toLowerCase()!=="svg"||(t(r),r.shadowRoot&&(n.push(r.shadowRoot),Ve(r.shadowRoot,t,n)))}function ye(e,t){let n=e.defaultView??window,r=[];Ve(e,o=>{let a=n.getComputedStyle(o),l=ze(a);l&&t.xf.set(o,l);for(let u of["::before","::after"]){let c=n.getComputedStyle(o,u),f=c.content;if(!f||f==="none"||f==="normal")continue;let d=ze(c);if(!d)continue;let h=t.pxf.get(o)??{};h[u==="::before"?"before":"after"]=d,t.pxf.set(o,h)}},r);let i=[],s=o=>{let a=e.createElement("style");a.setAttribute("data-webframe-ui",""),a.textContent=Lt,o.appendChild(a),i.push(a)};s(e.head??e.documentElement);for(let o of r)s(o);return{restore(){for(let o of i)o.remove()}}}var We=/flex|grid/;function Ee(e,t,n,r){let i=t.position;if(i==="fixed"||i==="sticky")return!0;let s=t.zIndex!=="auto";if(s&&(i==="absolute"||i==="relative")||s&&n&&We.test(n.display)||parseFloat(t.opacity)<1||r.xf.has(e)||t.filter!=="none"||t.perspective!=="none"||t.clipPath!=="none")return!0;let o=t.getPropertyValue("backdrop-filter")||t.getPropertyValue("-webkit-backdrop-filter");if(o&&o!=="none")return!0;let a=t.getPropertyValue("mask-image")||t.getPropertyValue("-webkit-mask-image");if(a&&a!=="none"||t.mixBlendMode!=="normal"||t.isolation==="isolate"||/transform|opacity|filter|perspective|clip-path|mask|isolation/.test(t.willChange)||/layout|paint|strict|content/.test(t.getPropertyValue("contain")))return!0;let l=t.getPropertyValue("container-type");return!!l&&l!=="normal"}function Xe(e,t,n,r){let i=t.position!=="static",s=!!n&&We.test(n.display),o=t.zIndex==="auto"?NaN:parseInt(t.zIndex,10);return(i||s)&&Number.isFinite(o)&&o!==0?o:i||s&&Number.isFinite(o)||Ee(e,t,n,r)?.5:0}function se(e,t){let n=t.defaultView??window,r=D(e,n.getComputedStyle(t.documentElement).backgroundColor);if(r&&r.a>0)return{color:r,fromBody:!1};let i=t.body?D(e,n.getComputedStyle(t.body).backgroundColor):null;return i&&i.a>0?{color:i,fromBody:!0}:{color:{r:1,g:1,b:1,a:1},fromBody:!1}}var At={multiply:"MULTIPLY",screen:"SCREEN",overlay:"OVERLAY",darken:"DARKEN",lighten:"LIGHTEN","color-dodge":"COLOR_DODGE","color-burn":"COLOR_BURN","hard-light":"HARD_LIGHT","soft-light":"SOFT_LIGHT",difference:"DIFFERENCE",exclusion:"EXCLUSION",hue:"HUE",saturation:"SATURATION",color:"COLOR",luminosity:"LUMINOSITY"},we=e=>parseFloat(e)||0,Q=(e,t,n)=>e.length?e[t%e.length]:n;function Le(e){if(!e)return null;if(e.kind==="raster")return{w:e.w,h:e.h};let t=/viewBox=["']\s*[-\d.]+[ ,]+[-\d.]+[ ,]+([\d.]+)[ ,]+([\d.]+)/i.exec(e.svg);if(t)return{w:parseFloat(t[1]),h:parseFloat(t[2])};let n=/<svg[^>]*\swidth=["']([\d.]+)/i.exec(e.svg),r=/<svg[^>]*\sheight=["']([\d.]+)/i.exec(e.svg);return n&&r?{w:parseFloat(n[1]),h:parseFloat(r[1])}:null}function Ae(e,t){if(!e.endsWith("%")||!t.endsWith("%"))return;let n=parseFloat(e)/100,r=parseFloat(t)/100;return Math.abs(n-.5)<.005&&Math.abs(r-.5)<.005?void 0:[n,r]}function Ye(e,t){let n=/^calc\(\s*(-?[\d.]+)%\s*([+-])\s*([\d.]+)(?:px)?\s*\)$/.exec(e.trim());if(n)return parseFloat(n[1])/100*t+(n[2]==="-"?-1:1)*parseFloat(n[3]);if(e.endsWith("%"))return parseFloat(e)/100*t;let r=parseFloat(e);return Number.isFinite(r)?r:t/2}function Tt(e){let t=I(e);if(t[0]==="repeat-x")return["repeat","no-repeat"];if(t[0]==="repeat-y")return["no-repeat","repeat"];let n=r=>r==="no-repeat"||r==="space"||r==="round"?r:"repeat";return[n(t[0]),n(t[1]??t[0])]}function Se(e,t){return!e||e==="auto"?null:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)}var Ft=60;function Nt(e,t,n){let r=s=>s.map(o=>`<stop offset="${o.pos}" stop-color="rgb(${Math.round(o.color.r*255)},${Math.round(o.color.g*255)},${Math.round(o.color.b*255)})" stop-opacity="${o.color.a}"/>`).join(""),i;if(e.type==="linear"){let s=e.angle*Math.PI/180,o=Math.sin(s),a=-Math.cos(s),l=Math.abs(t*o)+Math.abs(n*a),u=t/2-o*l/2,c=n/2-a*l/2;i=`<linearGradient id="g" gradientUnits="userSpaceOnUse" x1="${u}" y1="${c}" x2="${u+o*l}" y2="${c+a*l}">${r(e.stops)}</linearGradient>`}else if(e.type==="radial")i=`<radialGradient id="g" gradientUnits="userSpaceOnUse" cx="${e.cx}" cy="${e.cy}" r="${e.rx}" gradientTransform="translate(${e.cx} ${e.cy}) scale(1 ${e.ry/e.rx}) translate(${-e.cx} ${-e.cy})">${r(e.stops)}</radialGradient>`;else return null;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}"><defs>${i}</defs><rect width="${t}" height="${n}" fill="url(#g)"/></svg>`}function Pt(e,t,n){let r=s=>s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;"),i=`width:${t}px;height:${n}px;background-image:${e.layer};background-size:${e.size};background-position:${e.pos};background-repeat:${e.rep}`;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}"><foreignObject width="${t}" height="${n}"><div xmlns="http://www.w3.org/1999/xhtml" style="${r(i)}"></div></foreignObject></svg>`}async function xe(e,t,n,r){let i=Math.max(1,Math.min(2048,Math.round(t*r))),s=Math.max(1,Math.min(2048,Math.round(n*r))),o=new Image;o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`;try{await o.decode();let a=document.createElement("canvas");a.width=i,a.height=s,a.getContext("2d")?.drawImage(o,0,0,i,s);let l=a.toDataURL("image/png");return{data:l.slice(l.indexOf(",")+1),w:i,h:s}}catch{return null}}function je(e,t,n){return e.replace(/<svg\b([^>]*)>/i,(r,i)=>{let s=i.replace(/\s(?:width|height)=["'][^"']*["']/gi,"");return/\sxmlns=/i.test(s)||(s+=' xmlns="http://www.w3.org/2000/svg"'),/\sviewBox=/i.test(s)||(s+=` viewBox="0 0 ${t} ${n}"`),`<svg${s} width="${t}" height="${n}">`})}function Re(e,t,n,r,i,s,o,a,l,u){let[c,f]=o;if(!(n>.5)||!(r>.5)||!Number.isFinite(n+r))return{type:"frame",name:e,x:p(a.x),y:p(a.y),w:p(a.w),h:p(a.h),clip:!0,children:[]};c==="round"&&n>0&&(n=a.w/Math.max(1,Math.round(a.w/n))),f==="round"&&r>0&&(r=a.h/Math.max(1,Math.round(a.h/r))),c==="space"&&a.w<n*2&&(c="no-repeat"),f==="space"&&a.h<r*2&&(f="no-repeat");let d=Math.floor(a.w/(n||1)),h=Math.floor(a.h/(r||1)),m=c==="space"?(a.w-d*n)/Math.max(1,d-1):0,g=f==="space"?(a.h-h*r)/Math.max(1,h-1):0,x=n+m,v=r+g,b=Ye(i,a.w-n),w=Ye(s,a.h-r);c==="space"&&(b=0),f==="space"&&(w=0);let M=c!=="no-repeat",y=f!=="no-repeat",E=M?b-Math.ceil(b/x)*x:b,S=y?w-Math.ceil(w/v)*v:w,R=M?Math.max(1,Math.ceil((a.w-E)/x)):1,C=y?Math.max(1,Math.ceil((a.h-S)/v)):1,L={type:"frame",name:e,x:p(a.x),y:p(a.y),w:p(a.w),h:p(a.h),clip:!0,children:[]};if(u&&t.type==="image"&&(R>1||C>1)&&c!=="space"&&f!=="space")return L.children.push({type:"frame",name:"tile",x:p(E),y:p(S),w:p(R*n),h:p(C*r),fills:[{...t,fit:"tile",tile:{w:p(n),h:p(r)}}],children:[]}),L;if(R*C>Ft)return P(l,"very dense repeated backgrounds are approximated"),L.children.push({type:"frame",name:"tile",x:0,y:0,w:p(a.w),h:p(a.h),fills:[{...t}],children:[]}),L;for(let k=0;k<C;k++)for(let O=0;O<R;O++)L.children.push({type:"frame",name:"tile",x:p(E+O*x),y:p(S+k*v),w:p(n),h:p(r),fills:[{...t}],children:[]});return L}function Bt(e,t,n,r,i,s,o,a){let l=[],u=[],c=e.getPropertyValue("background-clip").includes("text")||e.getPropertyValue("-webkit-background-clip")==="text",f=D(a,e.backgroundColor),d=e.backgroundImage,h=d&&d!=="none"?V(d):[];if(c){let S=h.map(R=>J(R,{w:t,h:n},a.resolveColor)).find(Boolean);return S&&"stops"in S&&(a.gradientText=S.stops[0].color,a.gradientPaint=S),{fills:l,bgFrames:u,clipText:c}}f&&f.a>0&&l.push({type:"solid",color:f});let m=Math.max(0,t-r-s),g=Math.max(0,n-i-o),x={x:r,y:i,w:m,h:g},v=V(e.backgroundSize),b=V(e.backgroundPosition),w=V(e.backgroundRepeat),M=[],y=!1;h.forEach((S,R)=>{let C=Q(v,R,"auto"),L=Tt(Q(w,R,"repeat")),k=I(Q(b,R,"0% 0%")),O=k[0]??"0%",G=k[1]??k[0]??"0%",z=I(C),B=J(S,{w:m,h:g},a.resolveColor);if(B||/^(repeating-)?(linear|radial|conic)-gradient\(/.test(S)){if(!B){let A=Math.min(2,Math.sqrt(6e6/Math.max(1,m*g)),2048/Math.max(1,m,g));if(!a.opts.images||m<1||g<1||A<.25){P(a,"conic / repeating gradients were skipped");return}let N=a.assets.reserve(),vt={layer:S,size:Q(v,R,"auto"),pos:Q(b,R,"0% 0%"),rep:Q(w,R,"repeat")};a.jobs.push(async()=>{let pe=await xe(Pt(vt,m,g),m,g,A);pe?(a.assets.set(N,{kind:"raster",mime:"image/png",data:pe.data,w:pe.w,h:pe.h}),a.assets.natural.set(N,{w:m,h:g})):a.assets.failed.add(N)}),M.push({fill:{type:"image",asset:N,fit:"stretch"}});return}let $=C==="cover"||C==="contain"?m:Se(z[0],m)??m,T=C==="cover"||C==="contain"?g:Se(z[1]??"auto",g)??g;if(Math.abs($-m)<.5&&Math.abs(T-g)<.5||$<=0||T<=0){M.push({fill:B});return}let H=J(S,{w:$,h:T},a.resolveColor)??B;y=!0;let _=(L[0]!=="no-repeat"||L[1]!=="no-repeat")&&a.opts.images?Nt(H,$,T):null;if(_){let A=a.assets.reserve();a.jobs.push(async()=>{let N=await xe(_,$,T,2);N?(a.assets.set(A,{kind:"raster",mime:"image/png",data:N.data,w:N.w,h:N.h}),a.assets.natural.set(A,{w:$,h:T})):a.assets.failed.add(A)}),M.push({frame:Re("background-gradient",{type:"image",asset:A,fit:"stretch"},$,T,O,G,L,x,a,!0)})}else M.push({frame:Re("background-gradient",H,$,T,O,G,L,x,a,!1)});return}let de=/url\((['"]?)(.*?)\1\)/.exec(S);if(!de||!a.opts.images)return;let W=a.assets.request(de[2]);if(C==="cover")return void M.push({fill:{type:"image",asset:W,fit:"fill",pos:Ae(O,G)}});let fe=/^(50%|center)$/;if(C==="contain"&&L[0]==="no-repeat"&&L[1]==="no-repeat"&&fe.test(O)&&fe.test(G))return void M.push({fill:{type:"image",asset:W,fit:"fit"}});y=!0,(L[0]!=="no-repeat"||L[1]!=="no-repeat")&&a.rasterSvgs.add(W);let me={type:"frame",name:"background-image",x:r,y:i,w:m,h:g,clip:!0,children:[]};a.deferred.push(()=>{let $=a.assets.get(W),T=a.assets.natural.get(W)??Le($),q=T&&T.h?T.w/T.h:1,H,U;if(C==="contain"||C==="cover"){let A=C==="contain"?Math.min(m/(T?.w||m),g/(T?.h||g)):Math.max(m/(T?.w||m),g/(T?.h||g));H=(T?.w??m)*A,U=(T?.h??g)*A}else H=Se(z[0],m),U=Se(z[1]??"auto",g),H===null&&U===null?(H=T?.w??m,U=T?.h??g):H===null?H=U*q:U===null&&(U=H/q);let _=Re("background-image",{type:"image",asset:W,fit:"stretch"},H,U,O,G,L,x,a,$?.kind==="raster");me.children=_.children}),M.push({frame:me})});let E=M.reverse();if(y)for(let S of E)"frame"in S?u.push(S.frame):u.push({type:"frame",name:"background-layer",x:r,y:i,w:m,h:g,fills:[S.fill],children:[]});else for(let S of E)"fill"in S&&l.push(S.fill);return{fills:l,bgFrames:u,clipText:c}}function qe(e,t,n,r,i){let s=we(t.borderTopWidth),o=we(t.borderRightWidth),a=we(t.borderBottomWidth),l=we(t.borderLeftWidth),{fills:u,bgFrames:c,clipText:f}=Bt(t,n,r,l,s,o,a,i),d,m=[["top",s,t.borderTopColor,t.borderTopStyle],["right",o,t.borderRightColor,t.borderRightStyle],["bottom",a,t.borderBottomColor,t.borderBottomStyle],["left",l,t.borderLeftColor,t.borderLeftStyle]].filter(([,E,,S])=>E>0&&S!=="none"&&S!=="hidden");if(m.length){let E=D(i,m[0][2]);if(E&&E.a>0){let S=C=>{let L=m.find(([k])=>k===C);return L?L[1]:0},R=m[0][3];d={top:S("top"),right:S("right"),bottom:S("bottom"),left:S("left"),color:E,dash:R==="dashed"?"dashed":R==="dotted"?"dotted":void 0}}}let g=[ie(t.borderTopLeftRadius,n,r),ie(t.borderTopRightRadius,n,r),ie(t.borderBottomRightRadius,n,r),ie(t.borderBottomLeftRadius,n,r)].map(E=>p(E)),x=g.some(E=>E>0)?g:void 0,v=oe(t.boxShadow,i.resolveColor);if(t.filter&&t.filter!=="none"){for(let E of t.filter.matchAll(/drop-shadow\(((?:[^()]|\([^()]*\))*)\)/g))v.push(...oe(E[1],i.resolveColor));/(brightness|contrast|grayscale|hue-rotate|invert|saturate|sepia)\(/.test(t.filter)&&P(i,"CSS colour filters (brightness, contrast, grayscale\u2026) are not applied")}let b=t.overflowX!=="visible"||t.overflowY!=="visible"||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,w=/blur\(([\d.]+)px\)/.exec(t.filter),M=t.getPropertyValue("backdrop-filter")||t.getPropertyValue("-webkit-backdrop-filter"),y=/blur\(([\d.]+)px\)/.exec(M);return{fills:u,bgFrames:c,stroke:d,radius:x,shadows:v,clip:b,blur:w?parseFloat(w[1]):void 0,bgBlur:y?parseFloat(y[1]):void 0,blend:At[t.mixBlendMode],clipText:f}}function Ke(e){return e.fills.length>0||!!e.stroke||e.shadows.length>0||e.bgFrames.length>0||!!e.blur||!!e.bgBlur}var X=(e,t)=>{let n=e.trim();return/^-?[\d.]+%$/.test(n)?parseFloat(n)/100*t:/^-?[\d.]+(px)?$/.test(n)?parseFloat(n):null};function It(e,t,n){let r=(f,d,h)=>f==="center"?d/2:h==="x"&&f==="left"?0:h==="x"&&f==="right"?d:h==="y"&&f==="top"?0:h==="y"&&f==="bottom"?d:X(f,d),[i="center",s="center"]=e,o=(i==="top"||i==="bottom")&&(s==="left"||s==="right"),[a,l]=o?[s,i]:[i,s],u=r(a,t,"x"),c=r(l,n,"y");return u===null||c===null?null:[u,c]}function $t(e,t,n){let r=e.map(u=>X(u,Math.min(t,n)));if(r.some(u=>u===null)||r.length===0)return null;let i=r,[s,o=s,a=s,l=o]=i;return[s,o,a,l].map(u=>Math.max(0,p(u)))}function Je(e,t,n){let r=e.clipPath;if(!r||r==="none")return null;let i=/^(inset|circle|ellipse|polygon|path)\(([\s\S]*)\)\s*(?:(?:border|padding|content|margin|fill|stroke|view)-box|\s)*$/i.exec(r.trim());if(!i)return null;let s=i[1].toLowerCase(),o=i[2].trim();if(s==="inset"){let[l,u]=o.split(/\s+round\s+/i),c=I(l).map(M=>X(M,0));if(c.length===0||c.some(M=>M===null))return null;let f=I(l),d=(M,y)=>{let E=f[M%f.length]??f[0];return X(E,y)??0},h=(f.length===1,d(0,n)),m=f.length>=2?d(1,t):d(0,t),g=f.length>=3?d(2,n):d(0,n),x=f.length>=4?d(3,t):f.length>=2?d(1,t):d(0,t),v=t-x-m,b=n-h-g;if(v<=.5||b<=.5)return"hidden";let w=u?$t(I(u.split("/")[0]),t,n):null;return{kind:"rect",x:p(x),y:p(h),w:p(v),h:p(b),r:w??[0,0,0,0]}}if(s==="circle"||s==="ellipse"){let[l,u]=o.split(/\s+at\s+/i),c=It(I(u??"center center"),t,n);if(!c)return null;let f=I(l??""),d=Math.min(c[0],t-c[0],c[1],n-c[1]),h=Math.max(c[0],t-c[0],c[1],n-c[1]),m=(v,b,w)=>!v||v==="closest-side"?w==="x"?Math.min(c[0],t-c[0]):Math.min(c[1],n-c[1]):v==="farthest-side"?w==="x"?Math.max(c[0],t-c[0]):Math.max(c[1],n-c[1]):X(v,b),g,x;if(s==="circle"){let v=Math.sqrt((t*t+n*n)/2),b=f[0];g=x=!b||b==="closest-side"?d:b==="farthest-side"?h:X(b,v)}else g=m(f[0],t,"x"),x=m(f[1]??f[0],n,"y");return g===null||x===null?null:g<=.5||x<=.5?"hidden":{kind:"ellipse",cx:p(c[0]),cy:p(c[1]),rx:p(g),ry:p(x)}}if(s==="polygon"){let l=V(o),u=!1;/^(nonzero|evenodd)$/i.test(l[0])&&(u=l.shift().toLowerCase()==="evenodd");let c=[];for(let d of l){let[h,m]=I(d),g=X(h??"",t),x=X(m??"",n);if(g===null||x===null)return null;c.push([p(g),p(x)])}if(c.length<3)return"hidden";let f=0;for(let d=0;d<c.length;d++){let[h,m]=c[d],[g,x]=c[(d+1)%c.length];f+=h*x-g*m}return Math.abs(f/2)<1?"hidden":{kind:"poly",pts:c,evenodd:u}}let a=/(['"])([\s\S]*?)\1/.exec(o);return a?{kind:"path",d:a[2],evenodd:/^\s*evenodd/i.test(o)}:null}function Qe(e,t,n,r){let i=e.getPropertyValue("mask-image")||e.getPropertyValue("-webkit-mask-image");if(!i||i==="none")return null;let s=V(i)[0],o=J(s,{w:t,h:n},r.resolveColor);return o&&(o.type==="linear"||o.type==="radial")?o:null}var Ot=["fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","fill-opacity","stroke-opacity","opacity","fill-rule","clip-rule"],Dt=new Set(["path","circle","rect","ellipse","line","polyline","polygon","text","tspan","g"]),Te="http://www.w3.org/2000/svg",_t=6e5;function Ht(e,t){let n=[e,...e.querySelectorAll("*")],r=[t,...t.querySelectorAll("*")],i=Math.min(n.length,r.length);for(let s=0;s<i;s++){let o=r[s].tagName.toLowerCase(),a=getComputedStyle(n[s]);if(a.display==="none"){r[s].setAttribute("display","none");continue}if(!(!Dt.has(o)&&s!==0))for(let l of Ot){if(o==="g"&&l!=="opacity"&&l!=="fill"&&l!=="stroke")continue;let u=a.getPropertyValue(l);u&&u!=="normal"&&r[s].setAttribute(l,u)}}}function Gt(e){for(let t of Array.from(e.querySelectorAll("use"))){let n=t.getAttribute("href")??t.getAttribute("xlink:href")??"";if(!n.startsWith("#"))continue;let r=n.slice(1);if(e.querySelector(`[id="${CSS.escape(r)}"]`))continue;let i=document.getElementById(r);if(!i)continue;let s=parseFloat(t.getAttribute("x")??"0")||0,o=parseFloat(t.getAttribute("y")??"0")||0,a=document.createElementNS(Te,"g"),l=t.getAttribute("transform");a.setAttribute("transform",`${l?l+" ":""}translate(${s} ${o})`);for(let u of["fill","stroke","opacity"]){let c=t.getAttribute(u);c&&a.setAttribute(u,c)}if(i.tagName.toLowerCase()==="symbol"){let u=document.createElementNS(Te,"svg"),c=i.getAttribute("viewBox");c&&u.setAttribute("viewBox",c);let f=t.getAttribute("width"),d=t.getAttribute("height");f&&u.setAttribute("width",f),d&&u.setAttribute("height",d);for(let h of Array.from(i.childNodes))u.appendChild(h.cloneNode(!0));a.appendChild(u)}else a.appendChild(i.cloneNode(!0));t.replaceWith(a)}}function Ze(e,t,n){let r=e.cloneNode(!0);if(Ht(e,r),Gt(r),r.setAttribute("xmlns",Te),!r.getAttribute("viewBox")){let o=e.width?.baseVal?.value||t,a=e.height?.baseVal?.value||n;r.setAttribute("viewBox",`0 0 ${o} ${a}`)}r.setAttribute("width",String(t)),r.setAttribute("height",String(n)),r.removeAttribute("style"),r.removeAttribute("class");let i=getComputedStyle(e).color,s=new XMLSerializer().serializeToString(r).replace(/currentColor/gi,i);return s.length>_t?null:s}var Ut=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-sans-serif","ui-serif","ui-monospace","-apple-system","blinkmacsystemfont"]);function zt(e){let t=[],n=0;for(let r of e)t.push({ch:r,i:n}),n+=r.length;return t}function tt(e,t){let n=e.fontFamily.split(",").map(l=>l.trim().replace(/^["']|["']$/g,"")).filter(Boolean),r=parseFloat(e.letterSpacing),i=e.textDecorationLine.includes("underline")?"underline":e.textDecorationLine.includes("line-through")?"line-through":"none",s=e.direction,o=e.textAlign,a=o==="center"?"center":o==="right"||o==="end"&&s!=="rtl"||o==="start"&&s==="rtl"?"right":"left";return{families:n,size:p(parseFloat(e.fontSize)||16),weight:parseInt(e.fontWeight,10)||400,italic:/italic|oblique/.test(e.fontStyle),lineHeight:p(t),letterSpacing:Number.isFinite(r)?p(r):0,align:a,decoration:i}}function nt(e,t){let n=t.families.find(i=>!Ut.has(i.toLowerCase()))??t.families[0]??"sans-serif",r=e.fonts.get(n)??{weights:new Set,italic:!1,count:0};r.weights.add(t.weight),r.italic||=t.italic,r.count++,e.fonts.set(n,r)}function rt(e,t){switch(t){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();case"capitalize":return e.replace(new RegExp(`(^|[\\s\\-"'(])(\\p{L})`,"gu"),(n,r,i)=>r+i.toUpperCase());default:return e}}function ot(e,t){let n=D(t,e.getPropertyValue("-webkit-text-fill-color"));return n&&n.a>0?n:n&&n.a===0&&t.gradientText?t.gradientText:D(t,e.color)??{r:0,g:0,b:0,a:1}}function et(e,t,n){return e.setStart(t,n),e.setEnd(t,n+1),e.getBoundingClientRect().width}function Vt(e,t,n,r){let i=[],s=null;for(let{ch:o,i:a}of zt(e.data)){if(o===`
2
+ `&&n){s=null;continue}t.setStart(e,a),t.setEnd(e,a+o.length);let l=t.getBoundingClientRect();if(l.width===0&&l.height===0)continue;let u=/\s/.test(o);if(!(u&&l.width<=.01&&!r)){if(!s||l.top>s.top+Math.max(2,s.height*.5)){if(u&&!s&&!r)continue;s={text:"",left:l.left,right:l.right,top:l.top,height:l.height},i.push(s)}s.text+=o,(s.rights??=[]).push(l.right),s.left=Math.min(s.left,l.left),s.right=Math.max(s.right,l.right)}}for(let o of i)r||(o.text=o.text.replace(/\s+$/,""));return i.filter(o=>o.text.length>0)}function it(e,t,n){let r=e.parentElement;if(!r||!e.data)return[];let i=getComputedStyle(r);if(i.visibility!=="visible")return[];let s=i.whiteSpace,o=s==="pre"||s==="pre-wrap"||s==="break-spaces",a=o||s==="pre-line";if(!/\S/.test(e.data))return[];if(i.writingMode&&i.writingMode!=="horizontal-tb")return P(t,"vertical text is not supported"),[];let l=Yt(r),u=document.createRange();u.selectNodeContents(e);let c=Array.from(u.getClientRects()).filter(y=>y.width>0||y.height>0);if(c.length===0)return[];let f;if(c.length===1&&!a&&!l){let y=e.data.replace(/[ \t\r\n\f]+/g," ");if(y.startsWith(" ")&&et(u,e,0)<=.01&&(y=y.slice(1)),y.endsWith(" ")&&y.length>0&&et(u,e,e.data.length-1)<=.01&&(y=y.slice(0,-1)),!y)return[];let E=c[0];f=[{text:y,left:E.left,right:E.right,top:E.top,height:E.height}]}else f=Vt(e,u,a,o);if(f.length===0)return[];let d=parseFloat(i.lineHeight),h=Number.isFinite(d)?d:f.length>1&&Math.abs(f[1].top-f[0].top)||f[0].height;if(f=jt(f,l,i),f.length===0)return[];if(n.t||(f=f.filter(y=>!(y.right+t.originX<-2||y.left+t.originX>t.bounds.w+2||y.top+y.height+t.originY<-2||y.top+t.originY>t.bounds.h+2))),f.length===0)return[];let m=tt(i,h),g=ot(i,t),x=Xt(i,t);if(g.a===0&&!x)return[];let v=D(t,i.getPropertyValue("-webkit-text-fill-color")),b=v&&v.a===0&&t.gradientPaint?.type==="linear"?t.gradientPaint:void 0;if(t.opts.images&&Qt(m,e.data)){let y=Zt(f,i,g,t,n);if(y.length)return y}nt(t,m);let w=oe(i.textShadow,t.resolveColor).filter(y=>!y.inset),M=y=>{let E=rt(y.map(k=>k.text).join(`
3
+ `),i.textTransform).replace(/[­​]/g,""),S=Math.min(...y.map(k=>k.left)),R=Math.max(...y.map(k=>k.right)),C=y[0],L=C.top+C.height/2-h/2;return t.stats.texts++,t.count++,{type:"text",name:E.slice(0,40),x:p(S+t.originX-n.x),y:p(L+t.originY-n.y),w:p(R-S),h:p(h*y.length),text:E,font:m,color:g,paint:b,href:Wt(r),stroke:x,shadows:w.length?w:void 0}};return qt(f,m.align).map(M)}function Wt(e){let t=e.closest("a[href]");if(!t)return;let n=t.getAttribute("href")??"";if(!n||n==="#"||/^javascript:/i.test(n))return;let r=t.href;return/^(https?:|mailto:|tel:)/i.test(r)?r.slice(0,2e3):void 0}function Xt(e,t){let n=parseFloat(e.getPropertyValue("-webkit-text-stroke-width"));if(!(n>0))return;let r=D(t,e.getPropertyValue("-webkit-text-stroke-color"));return r&&r.a>0?{w:p(n),color:r}:void 0}function Yt(e){for(let t=e,n=0;t&&n<8;t=t.parentElement,n++){let r=getComputedStyle(t),i=parseInt(r.getPropertyValue("-webkit-line-clamp"),10);if(Number.isFinite(i)&&i>0&&r.overflowY!=="visible")return{owner:t,kind:"clamp"};if(r.textOverflow==="ellipsis"&&r.overflowX!=="visible"&&t.scrollWidth>t.clientWidth+1)return{owner:t,kind:"ellipsis"};if(r.display!=="inline"&&r.display!=="contents")break}return null}function jt(e,t,n){if(!t)return e;let r=t.owner.getBoundingClientRect(),i=getComputedStyle(t.owner);if(t.kind==="clamp"){let a=r.bottom-parseFloat(i.paddingBottom||"0")-parseFloat(i.borderBottomWidth||"0"),l=e.filter(c=>c.top+c.height/2<=a);if(l.length===e.length||l.length===0)return e;let u={...l[l.length-1]};return u.text=u.text.replace(/[\s.,;:!?-]+$/,"")+"\u2026",l[l.length-1]=u,l}let s=r.right-parseFloat(i.paddingRight||"0")-parseFloat(i.borderRightWidth||"0"),o=(parseFloat(n.fontSize)||16)*.85;return e.map(a=>{if(a.right<=s+.5||!a.rights)return a;let l=Array.from(a.text),u=-1;for(let c=0;c<l.length;c++)(a.rights[c]??1/0)<=s-o&&(u=c);return u<0?a:{...a,text:l.slice(0,u+1).join("").replace(/\s+$/,"")+"\u2026",right:Math.min(a.right,s)}})}function qt(e,t){let r=s=>t==="center"?(s.left+s.right)/2:t==="right"?s.right:s.left,i=[];for(let s of e){let o=i[i.length-1];o&&Math.abs(r(o[o.length-1])-r(s))<=1.5?o.push(s):i.push([s])}return i}var Kt=/(^|\b)(font ?awesome|fa[srlbd]?|material( icons| symbols)[\w ]*|icon[\w -]*|glyphicons?[\w -]*|ionicons|feather|fontello|bootstrap-icons|remixicon|lucide|boxicons|themify|simple-line-icons|linearicons|eicons|dashicons|typicons|octicons|elusive|entypo|weathericons)(\b|$)/i,Jt=/[-]/;function Qt(e,t){return Jt.test(t)?!0:e.families.some(n=>Kt.test(n))}function Zt(e,t,n,r,i){let s=[];for(let a of e){let l=Math.max(1,Math.ceil(a.right-a.left)),u=Math.max(1,Math.ceil(a.height));if(l*u*3*3>4e6)continue;let c=document.createElement("canvas");c.width=Math.ceil(l*3),c.height=Math.ceil(u*3);let f=c.getContext("2d");if(!f)continue;f.scale(3,3),f.font=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`,f.textBaseline="middle",f.fillStyle=`rgba(${Math.round(n.r*255)},${Math.round(n.g*255)},${Math.round(n.b*255)},${n.a})`,f.fillText(a.text,0,u/2);let d;try{d=c.toDataURL("image/png")}catch{continue}let h=r.assets.addInline({kind:"raster",mime:"image/png",data:d.slice(d.indexOf(",")+1),w:c.width,h:c.height});r.count++,r.stats.images++,s.push({type:"frame",name:`icon: ${a.text.slice(0,24)}`,x:p(a.left+r.originX-i.x),y:p(a.top+r.originY-i.y),w:l,h:u,fills:[{type:"image",asset:h,fit:"stretch"}],children:[]})}return s}function Fe(e,t,n,r,i={}){let s=parseFloat(t.fontSize)||16,o=parseFloat(t.lineHeight),a=i.lineHeight??(Number.isFinite(o)?o:s*1.2),l=tt(t,a);i.align&&(l.align=i.align),nt(r,l);let u=e.split(`
4
+ `).length;return r.stats.texts++,r.count++,{type:"text",name:e.slice(0,40),x:p(n.x),y:p(n.y),w:p(n.w),h:p(a*u),text:rt(e,t.textTransform),font:l,color:i.color??ot(t,r)}}var en=new Set(["script","style","noscript","template","head","meta","link","title","base","source","track","param","area","map","br","wbr","datalist"]),tn=new Set(["img","canvas","video","iframe","embed","object"]),nn=new Set(["img","input","br","hr","canvas","video","audio","iframe","embed","object","textarea","select","meter","progress"]),Ne="http://www.w3.org/2000/svg",j={type:"solid",color:{r:.9,g:.91,b:.93,a:1}},rn=3,F=e=>parseFloat(e)||0,ee=e=>e.tagName.toLowerCase(),on=e=>e.namespaceURI===Ne&&ee(e)==="svg",Ce=e=>({items:[],x:e.x,y:e.y});function le(e){return e.slice().sort((t,n)=>t.key-n.key||t.order-n.order).map(t=>t.n)}function Pe(e,t,n){let r=Ce(t);return Z(e,t,r,r.items,n),le(r.items)}function dt(e,t,n){let r=Ce(t);return ft(e,t,r,r.items,n),le(r.items)}function sn(e){if(e instanceof Element&&ee(e)==="slot"){let t=e.assignedNodes({flatten:!0});return t.length?t:Array.from(e.childNodes)}return e instanceof Element&&e.shadowRoot?Array.from(e.shadowRoot.childNodes):Array.from(e.childNodes)}var an={header:"Header",nav:"Nav",main:"Main",footer:"Footer",section:"Section",article:"Article",aside:"Aside",ul:"List",ol:"List",li:"List item",a:"Link",button:"Button",form:"Form",label:"Label",input:"Input",textarea:"Textarea",select:"Select",img:"Image",picture:"Image",video:"Video",canvas:"Canvas",iframe:"Embed",figure:"Figure",figcaption:"Caption",table:"Table",tr:"Row",td:"Cell",th:"Cell",p:"Paragraph",blockquote:"Quote",dialog:"Dialog",details:"Details",summary:"Summary",hr:"Divider",svg:"Graphic",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6"},ln={button:"Button",link:"Link",navigation:"Nav",banner:"Header",contentinfo:"Footer",main:"Main",dialog:"Dialog",tab:"Tab",tablist:"Tabs",menu:"Menu",menuitem:"Menu item",list:"List",listitem:"List item",img:"Image",search:"Search"},un=new Set(["a","button","summary","label","h1","h2","h3","h4","h5","h6","th","figcaption"]);function cn(e){try{let t=new URL(e,document.baseURI),n=decodeURIComponent(t.pathname.split("/").filter(Boolean).pop()??"");return/^data:/.test(e)?"":n.replace(/\.[a-z0-9]{2,5}$/i,"").slice(0,28)}catch{return""}}function st(e,t){let n=e.getAttribute("data-wf-pseudo");if(n)return`${e.parentElement?ee(e.parentElement):""}::${n}`;let r=e.getAttribute("role"),i=an[t]??(r?ln[r]:void 0),s=e.getAttribute("aria-label"),o=e.id&&!/^\d|[0-9a-f]{8,}/i.test(e.id)?e.id:"",a=Array.from(e.classList).find(u=>u.length<=24&&!/^(css|sc|jsx|_)|[0-9a-f]{6,}|\d{3,}/i.test(u))??"";if(!i)return s?s.slice(0,48):o?`${t}#${o}`.slice(0,48):a?`${t}.${a}`:t;let l="";return s?l=s:t==="img"?l=e.getAttribute("alt")?.trim()||cn(e.currentSrc||e.getAttribute("src")||""):(un.has(t)||r==="button"||r==="link"||r==="tab")&&(l=(e.textContent??"").replace(/\s+/g," ").trim()),l||(l=o||(t==="input"?e.placeholder||e.type:"")||a.replace(/[-_]+/g," ")),l?`${i} \xB7 ${l}`.slice(0,56):i}function dn(e,t,n,r,i){return e+n<-1||t+r<-1||e>i.bounds.w+1||t>i.bounds.h+1}function fn(e,t,n,r,i,s,o){let a={type:"frame",name:e,x:p(t),y:p(n),w:p(r),h:p(i),children:o};return s&&(s.fills.length&&(a.fills=s.fills),s.stroke&&(a.stroke=s.stroke),s.radius&&(a.radius=s.radius),s.shadows.length&&(a.shadows=s.shadows),s.clip&&(a.clip=!0),s.blur&&(a.blur=s.blur),s.bgBlur&&(a.bgBlur=s.bgBlur),s.blend&&(a.blend=s.blend)),a}function at(e,t,n){let r=parseFloat(t.opacity);r<1&&(e.opacity=p(r,3)),n&&(e.abs=!0)}function mn(e,t,n,r){let[i,s,o,a,l,u]=t.m;e.rel=[p(i,5),p(s,5),p(o,5),p(a,5),p(n+t.ox-(i*t.ox+o*t.oy)+l),p(r+t.oy-(s*t.ox+a*t.oy)+u)]}function pn(e,t,n,r,i){for(let s of sn(e)){if(i.truncated)break;if(s.nodeType===Node.TEXT_NODE)for(let o of it(s,i,t))r.push({n:o,key:0,order:i.order++});else s.nodeType===Node.ELEMENT_NODE&&ft(s,t,n,r,i)}}function Z(e,t,n,r,i){let s=e instanceof Element?Sn(e,i):null;try{pn(e,t,n,r,i)}finally{s?.()}}function ft(e,t,n,r,i){if(i.count>=i.maxNodes){i.truncated||(i.truncated=!0,P(i,`capture stopped at ${i.maxNodes.toLocaleString()} layers (page is very large)`));return}let s=ee(e);if(en.has(s)||e.hasAttribute("data-webframe-ui"))return;let o=getComputedStyle(e);if(o.display==="none")return;if(o.display==="contents")return Z(e,t,n,r,i);if(parseFloat(o.opacity)===0)return;let a=on(e);if(e.namespaceURI===Ne&&!a)return;let l=e.getBoundingClientRect(),u=l.left+i.originX,c=l.top+i.originY,f=l.width,d=l.height;if(f===0&&o.overflowX!=="visible"||d===0&&o.overflowY!=="visible"||!t.t&&dn(u,c,f,d,i)&&!(f===0&&d===0)||f<2&&d<2&&(o.overflowX!=="visible"||o.clip!=="auto"))return;let h=i.xf.get(e);if(h&&Math.abs(h.m[0]*h.m[3]-h.m[1]*h.m[2])<1e-6)return;let m=o.visibility!=="visible";if(m&&tn.has(s))return;let g=o.position==="absolute"||o.position==="fixed",x=e.parentElement,v=x?getComputedStyle(x):null,b=Xe(e,o,v,i),w=b!==0&&r!==n.items&&(b!==.5||o.position==="fixed"||u<t.x-1||c<t.y-1||u+f>t.x+(t.w??1/0)+1||c+d>t.y+(t.h??1/0)+1),M=w?n:t,y=u-M.x,E=c-M.y,S={x:u,y:c,w:f,h:d,t:t.t||!!h},R=(A,N)=>{h&&mn(A,h,y,E),w?(A.abs=!0,n.items.push({n:A,key:b,order:N})):r.push({n:A,key:b,order:N})};if(a){if(m||f<=0||d<=0)return;let A=Ze(e,f,d);if(!A){P(i,"very large inline SVG skipped");return}i.stats.svgs++,i.count++;let N={type:"svg",name:st(e,"svg"),x:p(y),y:p(E),w:p(f),h:p(d),svg:A};at(N,o,g),R(N,i.order++);return}let C=i.gradientText,L=i.gradientPaint,k=m?null:qe(e,o,f,d,i);k&&e===e.ownerDocument.body&&se(i,e.ownerDocument).fromBody&&(k={...k,fills:k.fills.filter(A=>A.type!=="solid")});let O=k?Ke(k):!1,G=null,z=null;if(!m){let A=Je(o,f,d);if(A==="hidden"){i.gradientText=C,i.gradientPaint=L;return}G=A,z=Qe(o,f,d,i);let N=o.getPropertyValue("mask-image")||o.getPropertyValue("-webkit-mask-image");!z&&N&&N!=="none"&&P(i,"image masks (mask-image: url(...)) are not applied"),!G&&o.clipPath!=="none"&&P(i,"clip-path shapes other than inset / circle / ellipse / polygon / path are not applied")}let B=hn(e,s,o,f,d,S,i),de=o.display==="inline",W=!h&&!G&&!z&&b===0&&parseFloat(o.opacity)===1&&o.mixBlendMode==="normal"&&o.filter==="none";if(!B&&W&&(f===0||d===0||de&&!O)&&!O){Z(e,t,n,r,i),i.gradientText=C,i.gradientPaint=L;return}i.count++;let fe=i.order++,me=Ee(e,o,v,i)||!!k?.clip||!!B?.clip,$=[];if(B?.children)$=B.children;else if(!B?.leaf)if(me){let A=Ce(S);Z(e,S,A,A.items,i),$=le(A.items)}else{let A=[];Z(e,S,n,A,i),$=le(A)}i.gradientText=C,i.gradientPaint=L;let T=m?null:xn(e,o,S,l,i),q=k?[...k.fills]:[];B?.fills&&q.push(...B.fills);let H=k?{...k,fills:q}:null,U=k?.bgFrames??[],_=fn(st(e,s),y,E,f,d,H,[...U,...$,...T?[T]:[]]);B?.stroke&&!_.stroke&&(_.stroke=B.stroke),B?.radius&&!_.radius&&(_.radius=B.radius),(B?.clip||s==="input"||s==="textarea"||s==="select")&&(_.clip=!0),G&&(_.clipShape=G),z&&(_.mask=z),at(_,o,g),R(_,fe)}function lt(e){if(e.objectFit!=="cover")return;let[t="50%",n="50%"]=e.objectPosition.split(/\s+/);return Ae(t,n)}function ae(e){let t=e.objectFit;return t==="cover"?"fill":t==="contain"||t==="scale-down"?"fit":"stretch"}function ve(e,t,n="stretch"){let r=t.shots.get(e);return r?[j,{type:"image",asset:r,fit:n}]:[j]}function hn(e,t,n,r,i,s,o){if(t==="img"){let a=e,l=a.currentSrc||a.getAttribute("src")||"";if(o.stats.images++,!l||!o.opts.images)return{fills:[j],leaf:!0};if(/^blob:/i.test(l)&&a.complete&&a.naturalWidth>0)try{let u=Math.min(1,2048/Math.max(a.naturalWidth,a.naturalHeight)),c=document.createElement("canvas");c.width=Math.max(1,Math.round(a.naturalWidth*u)),c.height=Math.max(1,Math.round(a.naturalHeight*u)),c.getContext("2d")?.drawImage(a,0,0,c.width,c.height);let f=c.toDataURL("image/png");return{fills:[{type:"image",asset:o.assets.addInline({kind:"raster",mime:"image/png",data:f.slice(f.indexOf(",")+1),w:c.width,h:c.height}),fit:ae(n),pos:lt(n)}],leaf:!0}}catch{}return{fills:[{type:"image",asset:o.assets.request(l),fit:ae(n),pos:lt(n)}],leaf:!0}}if(t==="canvas"){let a=e;if(o.shots.get(e))return{fills:ve(e,o),leaf:!0};try{let u=a.toDataURL("image/png"),c=u.slice(u.indexOf(",")+1),f=o.assets.addInline({kind:"raster",mime:"image/png",data:c,w:a.width,h:a.height});return o.stats.images++,{fills:[{type:"image",asset:f,fit:"stretch"}],leaf:!0}}catch{return P(o,"canvas elements with cross-origin content became placeholders"),{fills:[j],leaf:!0}}}if(t==="video"){let a=e;o.stats.images++;try{if(a.readyState>=2&&a.videoWidth){let l=document.createElement("canvas");l.width=a.videoWidth,l.height=a.videoHeight,l.getContext("2d")?.drawImage(a,0,0);let u=l.toDataURL("image/jpeg",.85);return{fills:[{type:"image",asset:o.assets.addInline({kind:"raster",mime:"image/jpeg",data:u.slice(u.indexOf(",")+1),w:l.width,h:l.height}),fit:ae(n)}],leaf:!0}}}catch{}return o.shots.has(e)?{fills:ve(e,o,ae(n)),leaf:!0}:a.poster&&o.opts.images?{fills:[{type:"image",asset:o.assets.request(a.poster),fit:ae(n)}],leaf:!0}:(P(o,"video elements became placeholders"),{fills:[j],leaf:!0})}if(t==="iframe")return gn(e,n,r,i,s,o);if(t==="embed"||t==="object")return r<5||i<5?{leaf:!0}:o.shots.has(e)?{fills:ve(e,o),leaf:!0}:(P(o,"embedded objects became placeholders"),{fills:[j],leaf:!0});if(t==="input"||t==="textarea"||t==="select"){let a=e,l=t==="input"&&(a.type==="checkbox"||a.type==="radio")?bn(a,n,r,i,o):null;return l||{children:yn(a,n,r,i,o),leaf:!0}}return null}function gn(e,t,n,r,i,s){if(n<5||r<5)return{leaf:!0};let o=null;try{o=e.contentDocument}catch{o=null}let a=e.contentWindow;if(o?.documentElement&&o.body&&a&&s.depth<rn){let l=F(t.borderLeftWidth)+F(t.paddingLeft),u=F(t.borderTopWidth)+F(t.paddingTop),c={x:s.originX,y:s.originY,b:s.bounds},f=ye(o,s);s.originX=i.x+l,s.originY=i.y+u,s.bounds={w:i.x+l+a.innerWidth,h:i.y+u+a.innerHeight},s.depth++;try{let d=Ce(i);Z(o.documentElement,i,d,d.items,s);let h=se(s,o).color;return{children:le(d.items),fills:h&&h.a>0?[{type:"solid",color:h}]:[],leaf:!0,clip:!0}}finally{s.depth--,f.restore(),s.originX=c.x,s.originY=c.y,s.bounds=c.b}}return s.shots.has(e)?{fills:ve(e,s),leaf:!0}:(P(s,"cross-origin iframes became placeholders"),{fills:[j],leaf:!0})}function bn(e,t,n,r,i){if(t.appearance==="none"||n<4||r<4||F(t.borderTopWidth)>0&&t.borderTopStyle!=="none")return null;let s=D(i,t.accentColor==="auto"?"rgb(0, 117, 255)":t.accentColor)??{r:0,g:.46,b:1,a:1},o={r:.46,g:.46,b:.46,a:1},a={r:1,g:1,b:1,a:1},l=e.type==="radio",u=l?Math.min(n,r)/2:2,c=e.checked&&!l?s:a,f={top:1,right:1,bottom:1,left:1,color:e.checked?s:o},d=[];if(e.checked)if(i.count++,l){let m=Math.min(n,r)*.5;d.push({type:"frame",name:"dot",x:p((n-m)/2),y:p((r-m)/2),w:p(m),h:p(m),radius:[m/2,m/2,m/2,m/2],fills:[{type:"solid",color:s}],children:[]})}else{let m=Math.min(n,r)*.8,g=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="${m}" height="${m}"><path d="M5 12.5l4.5 4.5L19 7.5" stroke="#fff" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>`;d.push({type:"svg",name:"check",x:p((n-m)/2),y:p((r-m)/2),w:p(m),h:p(m),svg:g})}let h=[u,u,u,u];return{fills:[{type:"solid",color:l&&e.checked?a:c}],stroke:f,radius:h,children:d,leaf:!0}}function yn(e,t,n,r,i){let s="",o=D(i,t.color),a=ee(e),l=a==="input"?e.type:a==="textarea"?"textarea":"select";if(["checkbox","radio","range","file","color","image","hidden"].includes(l))return[];if(a==="select")s=e.selectedOptions[0]?.text??"";else{let w=e;s=w.value,l==="password"&&(s="\u2022".repeat(s.length)),!s&&w.placeholder&&(s=w.placeholder,o=D(i,getComputedStyle(e,"::placeholder").color)??o)}if(!s)return[];let u=F(t.borderLeftWidth)+F(t.paddingLeft),c=F(t.borderTopWidth)+F(t.paddingTop),f=Math.max(0,n-u-F(t.borderRightWidth)-F(t.paddingRight)),d=Math.max(0,r-c-F(t.borderBottomWidth)-F(t.paddingBottom)),h=parseFloat(t.fontSize)||16,m=parseFloat(t.lineHeight),g=Number.isFinite(m)?m:h*1.2,x=["button","submit","reset"].includes(l),v=l==="textarea"?c:c+(d-g)/2;return[Fe(s,t,{x:u,y:v,w:f},i,{color:o??void 0,align:x?"center":void 0,lineHeight:g})]}function wn(e,t){let n="",r=!1,i=Array.from(t.matchAll(/"((?:[^"\\]|\\.)*)"/g)).map(o=>o[1]),s=/"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|(open-quote|close-quote|no-open-quote|no-close-quote)|(counters?\([^)]*\)|url\([^)]*\)|image-set\([^)]*\)|attr\([^)]*\)|[a-z-]+\([^)]*\))/g;for(let o of e.matchAll(s))o[1]!==void 0||o[2]!==void 0?n+=(o[1]??o[2]).replace(/\\(["'\\])/g,"$1"):o[3]==="open-quote"?n+=i[0]??"\u201C":o[3]==="close-quote"?n+=i[1]??"\u201D":o[4]&&(r=!0);return{text:n,unsupported:r}}function ut(e){if(e.backgroundImage!=="none")return!0;let t=e.backgroundColor;return t&&t!=="transparent"&&!/rgba\([^)]*,\s*0\)$/.test(t)||F(e.borderTopWidth)>0&&e.borderTopStyle!=="none"||F(e.borderLeftWidth)>0&&e.borderLeftStyle!=="none"||F(e.borderBottomWidth)>0&&e.borderBottomStyle!=="none"||F(e.borderRightWidth)>0&&e.borderRightStyle!=="none"?!0:e.boxShadow!=="none"}function Sn(e,t){if(nn.has(ee(e))||e.namespaceURI===Ne||e.hasAttribute("data-wf-pseudo"))return null;let n=e.getBoundingClientRect(),r=e.ownerDocument,i=[];for(let s of["::before","::after"]){let o=getComputedStyle(e,s),a=o.content;if(!a||a==="none"||a==="normal"||o.display==="none")continue;let{text:l,unsupported:u}=wn(a,o.quotes);if(u&&(/counters?\(/.test(a)?P(t,"CSS counter() numbers in ::before/::after were not captured"):/url\(|image-set/.test(a)&&P(t,"images set through ::before/::after content: were not captured"),!l&&!ut(o))||!l.trim()&&!ut(o))continue;let c=r.createElement("span");c.setAttribute("data-wf-pseudo",s.slice(2));for(let g=0;g<o.length;g++){let x=o[g];x==="content"||x.startsWith("animation")||x.startsWith("transition")||c.style.setProperty(x,o.getPropertyValue(x),o.getPropertyPriority(x))}l&&(c.textContent=l);let f=t.pxf.get(e)?.[s==="::before"?"before":"after"];f&&t.xf.set(c,f);let d=s==="::before"?"data-wf-nb":"data-wf-na",h=()=>{c.remove(),e.removeAttribute(d)};e.setAttribute(d,""),s==="::before"?e.insertBefore(c,e.firstChild):e.appendChild(c);let m=e.getBoundingClientRect();if(Math.abs(m.width-n.width)>.5||Math.abs(m.height-n.height)>.5){h(),P(t,"some ::before/::after content was skipped (it changed the layout when measured)");continue}i.push(h)}return i.length?()=>i.forEach(s=>s()):null}function ct(e){let t=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],n="";for(let[r,i]of t)for(;e>=r;)n+=i,e-=r;return n}function xn(e,t,n,r,i){if(!(t.display==="list-item"&&t.listStyleType!=="none"&&t.listStylePosition!=="inside"))return null;let s=t.listStyleType,o=e.parentElement,a=1;if(o){let x=Array.from(o.children).filter(M=>getComputedStyle(M).display==="list-item"),v=parseInt(o.getAttribute("start")??"",10),b=o.hasAttribute("reversed"),w=x.indexOf(e);a=b?(Number.isFinite(v)?v:x.length)-w:(Number.isFinite(v)?v:1)+w}let l;switch(s){case"disc":l="\u2022";break;case"circle":l="\u25E6";break;case"square":l="\u25AA";break;case"decimal":l=`${a}.`;break;case"decimal-leading-zero":l=`${String(a).padStart(2,"0")}.`;break;case"lower-alpha":case"lower-latin":l=`${String.fromCharCode(96+(a-1)%26+1)}.`;break;case"upper-alpha":case"upper-latin":l=`${String.fromCharCode(64+(a-1)%26+1)}.`;break;case"lower-roman":l=`${ct(a)}.`;break;case"upper-roman":l=`${ct(a).toUpperCase()}.`;break;default:l="\u2022"}let u=parseFloat(t.fontSize)||16,c=parseFloat(t.lineHeight),f=Number.isFinite(c)?c:u*1.2,d=r.left+i.originX+F(t.borderLeftWidth)+F(t.paddingLeft),h=r.top+i.originY+F(t.borderTopWidth)+F(t.paddingTop),m=u*2.5,g=Fe(l,t,{x:d-m-u*.28-n.x,y:h-n.y,w:m},i,{align:"right",lineHeight:f});return g.name="marker",g}var Cn=3e4,te=e=>new Promise(t=>setTimeout(t,e));async function gt(e,t="balanced",n){let r=t==="thorough",i=()=>document.scrollingElement??document.documentElement,s=r?650:320,o=()=>Math.max(160,window.innerHeight*(r?.33:.5)),a=window.innerHeight*400,l=r?3:2,u=0,c=0;for(;u<=a;){window.scrollTo({top:u,behavior:"instant"});let d=Math.max(1,i().scrollHeight-window.innerHeight);e("Scrolling through the page",Math.min(.2,u/d*.2)),await ue(s);let h=i().scrollHeight-window.innerHeight;if(u>=h-2){if(++c>=l)break;await ue(s*2)}else c=0;u=Math.min(u+o(),Math.max(0,h))}await ue(r?1200:500);for(let d=i().scrollHeight;d>0;d-=o()*(r?1.4:2))window.scrollTo({top:d,behavior:"instant"}),e("Scrolling back up",.2),await ue(s*.5);window.scrollTo({top:0,behavior:"instant"});let f=Array.from(document.images).filter(d=>!d.complete);f.length&&await Promise.race([Promise.all(f.map(d=>d.decode().catch(()=>{}))),te(r?8e3:4e3)]),await ue(r?1200:700),n?.()}async function ue(e){await te(e);let t=Date.now()+1500;for(;Date.now()<t;){if((document.getAnimations?.()??[]).filter(r=>{if(r.playState!=="running")return!1;let i=r.effect?.getComputedTiming();return!!i&&Number.isFinite(i.endTime)}).length===0)return;await te(120)}}function Mn(){for(let e of document.getAnimations?.()??[])try{let t=e.effect?.getComputedTiming();t&&Number.isFinite(t.endTime)&&t.direction!=="reverse"&&e.finish()}catch{}}function Me(e,t){return Math.abs(e-t)<.6}function kn(e){return!e.fills?.length&&!e.stroke&&!e.shadows?.length&&!e.blur&&!e.bgBlur&&!e.blend&&!e.clip&&!e.rel}function bt(e){if(e.type!=="frame")return e;for(e.children=e.children.map(bt);kn(e)&&e.children.length===1;){let t=e.children[0];if(!(Me(t.x,0)&&Me(t.y,0)&&Me(t.w,e.w)&&Me(t.h,e.h)))break;return t.x=p(e.x+t.x),t.y=p(e.y+t.y),t.rel&&(t.rel=[t.rel[0],t.rel[1],t.rel[2],t.rel[3],p(t.rel[4]+e.x),p(t.rel[5]+e.y)]),e.opacity!==void 0&&(t.opacity=p((t.opacity??1)*e.opacity,3)),e.abs&&(t.abs=!0),t}return e}function yt(e,t,n){return e.type==="svg"?e.asset&&n.has(e.asset)?null:e:(e.type==="text"||(e.fills&&(e.fills=e.fills.filter(r=>!(r.type==="image"&&n.has(r.asset))),e.fills.length||delete e.fills),e.children=e.children.map(r=>yt(r,t,n)).filter(r=>r!==null).filter(r=>!(r.type==="frame"&&/^background-/.test(r.name)&&r.children.length===0&&!r.fills?.length))),e)}function wt(e){return e.type==="frame"?1+e.children.reduce((t,n)=>t+wt(n),0):1}function St(e,t){e.type==="svg"&&e.asset&&t.add(e.asset),e.type==="frame"&&(e.fills?.forEach(n=>n.type==="image"&&t.add(n.asset)),e.children.forEach(n=>St(n,t)))}function mt(e){return[{type:"solid",color:se(e,document).color??{r:1,g:1,b:1,a:1}}]}async function xt({mode:e,options:t,element:n,thumbnail:r,progress:i,hideUi:s}){let o=document.createElement("style");o.textContent="*,*::before,*::after{animation-duration:0s!important;animation-delay:0s!important;animation-iteration-count:1!important;transition:none!important;scroll-behavior:auto!important}",document.documentElement.appendChild(o);let a=window.scrollX,l=window.scrollY,u;try{i("Reading page",.2),Mn(),await te(60);let c=document.documentElement,f=new be,d={originX:0,originY:0,bounds:{w:0,h:0},opts:t,assets:f,fonts:new Map,warnings:new Map,count:0,maxNodes:Cn,truncated:!1,resolveColor:He(),gradientText:null,gradientPaint:null,order:0,xf:new WeakMap,pxf:new WeakMap,shots:new WeakMap,depth:0,rasterSvgs:new Set,jobs:[],stats:{texts:0,images:0,svgs:0},deferred:[]};t.images&&await Rn(d,e==="element"?n:e==="visible"?"visible":"full",s,i),u=ye(document,d);let h,m=document.title||location.hostname;if(e==="element"&&n){let b=n.getBoundingClientRect();d.originX=-b.left,d.originY=-b.top,d.bounds={w:b.width,h:b.height};let w=dt(n,{x:0,y:0},d);h={type:"frame",name:Ln(n),x:0,y:0,w:p(b.width),h:p(b.height),clip:!0,children:w}}else if(e==="visible"){d.originX=0,d.originY=0;let b=c.clientWidth,w=window.innerHeight;d.bounds={w:b,h:w},h={type:"frame",name:`${location.hostname} \u2014 viewport`,x:0,y:0,w:b,h:w,clip:!0,fills:mt(d),children:Pe(c,{x:0,y:0},d)}}else{window.scrollTo({top:0,left:0,behavior:"instant"}),d.originX=window.scrollX,d.originY=window.scrollY;let b=Math.max(c.scrollWidth,document.body?.scrollWidth??0,c.clientWidth),w=Math.max(c.scrollHeight,document.body?.scrollHeight??0,window.innerHeight);d.bounds={w:b,h:w},h={type:"frame",name:`${location.hostname} \u2014 ${m}`.slice(0,80),x:0,y:0,w:b,h:w,clip:!0,fills:mt(d),children:Pe(c,{x:0,y:0},d)}}u.restore(),u=void 0,i("Downloading images",.4),await f.resolveAll((b,w)=>i("Downloading images",.4+b/Math.max(1,w)*.45)),i("Preparing backgrounds",.86);for(let b of d.rasterSvgs){let w=f.get(b);w?.kind==="svg"&&d.jobs.push(async()=>{let M=Le(w)??{w:64,h:64},y=await xe(je(w.svg,M.w,M.h),M.w,M.h,Math.min(3,2048/Math.max(M.w,M.h)));y&&(f.set(b,{kind:"raster",mime:"image/png",data:y.data,w:y.w,h:y.h}),f.natural.set(b,M))})}for(let b of d.jobs)await b().catch(()=>{});d.deferred.forEach(b=>b()),f.failed.size&&d.warnings.set(`${f.failed.size} image(s) could not be downloaded and were left out`,1),i("Packaging",.9);let g=bt(h);g=yt(g,d,f.failed);let x=new Set;St(g,x);let v={};for(let b of x){let w=f.get(b);w&&(v[b]=w)}return{magic:_e,version:1,tool:{name:"web2fig-extension",version:chrome.runtime.getManifest().version},source:{url:location.href,title:m,capturedAt:new Date().toISOString(),mode:e,viewport:{w:window.innerWidth,h:window.innerHeight},dpr:window.devicePixelRatio},thumbnail:r,root:g,assets:v,fonts:Ge(d),stats:{layers:wt(g),texts:d.stats.texts,images:d.stats.images,svgs:d.stats.svgs},warnings:Ue(d)}}finally{u?.restore(),o.remove(),window.scrollTo({left:a,top:l,behavior:"instant"})}}var pt=10;function ht(e){try{let t=document.createElement("canvas");t.width=t.height=8;let n=t.getContext("2d",{willReadFrequently:!0});if(!n)return!1;n.drawImage(e,0,0,8,8);let r=n.getImageData(0,0,8,8).data;for(let i=3;i<r.length;i+=4)if(r[i]!==0)return!0;return!1}catch{return!1}}function En(e){let t=e.tagName.toLowerCase();if(t==="iframe")try{return!e.contentDocument}catch{return!0}return t==="canvas"||t==="video"?!ht(e):!0}async function Rn(e,t,n,r){let i=[];for(let o of Array.from(document.querySelectorAll("iframe,canvas,video,embed,object"))){if(t instanceof Element&&!t.contains(o))continue;let a=getComputedStyle(o),l=o.getBoundingClientRect();a.display==="none"||a.visibility==="hidden"||parseFloat(a.opacity)===0||l.width<24||l.height<24||t==="visible"&&(l.top<0||l.bottom>window.innerHeight||l.left<0||l.right>window.innerWidth)||En(o)&&i.push({el:o,top:l.top+window.scrollY})}if(i.length===0)return;i.sort((o,a)=>o.top-a.top);let s=0;for(let{el:o,top:a}of i.slice(0,pt)){if(r("Capturing embedded content",.3+s++/pt*.1),t!=="visible"){let u=o.getBoundingClientRect();if(u.height>window.innerHeight)continue;window.scrollTo({top:Math.max(0,a-Math.max(0,(window.innerHeight-u.height)/2)),behavior:"instant"})}n?.(),await te(260);let l=o.getBoundingClientRect();if(!(l.top<-1||l.bottom>window.innerHeight+1||l.left<-1||l.right>window.innerWidth+1)){try{let u=await chrome.runtime.sendMessage({type:"webframe:captureRegion",rect:{x:Math.max(0,l.left),y:Math.max(0,l.top),w:l.width,h:l.height},dpr:window.devicePixelRatio||1});u?.ok&&e.shots.set(o,e.assets.addInline({kind:"raster",mime:"image/png",data:u.data,w:u.w,h:u.h}))}catch{}await te(520)}}}function Ln(e){let t=e.tagName.toLowerCase(),n=Array.from(e.classList)[0];return e.id?`${t}#${e.id}`:n?`${t}.${n}`:t}var ce=window;function An(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}ce.chrome={runtime:{getManifest:()=>({version:"helper"}),sendMessage:async e=>{if(e.type==="webframe:fetchAsset"&&e.url){let t=await ce.__w2fFetch(e.url);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,asset:await he(new Blob([An(t.b64)],{type:t.type}),e.url)}}catch(n){return{ok:!1,error:String(n)}}}if(e.type==="webframe:captureRegion"&&e.rect){let t=await ce.__w2fShot({x:e.rect.x+window.scrollX,y:e.rect.y+window.scrollY,w:e.rect.w,h:e.rect.h});if(!t.ok)return{ok:!1};let n=new Image;n.src=`data:image/png;base64,${t.b64}`,await n.decode();let r=Math.min(1,2048/Math.max(n.naturalWidth,n.naturalHeight)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(n.naturalWidth*r)),i.height=Math.max(1,Math.round(n.naturalHeight*r)),i.getContext("2d")?.drawImage(n,0,0,i.width,i.height);let s=i.toDataURL("image/png");return{ok:!0,data:s.slice(s.indexOf(",")+1),w:i.width,h:i.height}}return{ok:!1}}}};ce.__w2fRun=async e=>{let t={...Be,...e.options},n=(i,s)=>ce.__w2fProgress(i,s);t.lazy&&await gt(n,t.speed);let r=await xt({mode:"full",options:t,element:null,thumbnail:e.thumbnail,progress:n});return JSON.stringify(r)};})();
packages.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ libnss3
2
+ libnspr4
3
+ libatk1.0-0
4
+ libatk-bridge2.0-0
5
+ libcups2
6
+ libdrm2
7
+ libxkbcommon0
8
+ libxcomposite1
9
+ libxdamage1
10
+ libxfixes3
11
+ libxrandr2
12
+ libgbm1
13
+ libasound2
14
+ libpango-1.0-0
15
+ libcairo2
16
+ libx11-6
17
+ libxcb1
18
+ libxext6
19
+ libxshmfence1
20
+ fonts-liberation
21
+ fonts-dejavu-core
22
+ fonts-noto-color-emoji
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ # No extra Python packages are needed: app.py only starts the Node helper.
server.mjs ADDED
The diff for this file is too large to render. See raw diff