nudge-canvas 0.0.1 → 0.4.0
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/LICENSE.md +51 -0
- package/README.md +51 -3
- package/THIRD_PARTY_NOTICES.md +2373 -0
- package/data/icon-catalog.json +1 -0
- package/data/licenses/Apache-2.0.txt +73 -0
- package/data/licenses/CC-BY-3.0.txt +319 -0
- package/data/licenses/CC-BY-4.0.txt +156 -0
- package/data/licenses/CC0-1.0.txt +121 -0
- package/data/licenses/ISC.txt +7 -0
- package/data/licenses/MIT.txt +18 -0
- package/data/licenses/OFL-1.1.txt +43 -0
- package/dist/chunk-D6z-TZJJ.js +1 -0
- package/dist/chunk-D_nbgLii.js +14 -0
- package/dist/chunk-DuSDpWhn.js +550 -0
- package/dist/chunk-Sq5RPyiX.js +1 -0
- package/dist/init.js +2 -0
- package/dist/mcp.js +151 -0
- package/editor/apple-touch-icon-180.png +0 -0
- package/editor/assets/main-Cmp_J2OR.js +45 -0
- package/editor/assets/main-D0fYiDhO.css +1 -0
- package/editor/assets/proto-q6SnqtFF.js +1 -0
- package/editor/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/editor/assets/src-C4_CxgrI.js +415 -0
- package/editor/favicon-16.png +0 -0
- package/editor/favicon-32.png +0 -0
- package/editor/favicon.svg +1 -0
- package/editor/fonts/pretendard/LICENSE.txt +94 -0
- package/editor/fonts/pretendard/PretendardVariable.woff2 +0 -0
- package/editor/fonts/pretendard.css +8 -0
- package/editor/index.html +20 -0
- package/editor/proto.html +15 -0
- package/icons/cib.LICENSE.txt +124 -0
- package/icons/cib.json.gz +0 -0
- package/icons/logos.LICENSE.txt +124 -0
- package/icons/logos.json.gz +0 -0
- package/icons/lucide.LICENSE.txt +46 -0
- package/icons/lucide.json.gz +0 -0
- package/icons/simple-icons.LICENSE.txt +86 -0
- package/icons/simple-icons.json.gz +0 -0
- package/package.json +55 -5
- package/not-yet.js +0 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{$ as r,$t as i,A as a,At as o,B as s,Bt as c,C as l,Ct as u,D as d,Dt as f,E as p,Et as m,F as h,Ft as g,G as _,H as v,Ht as y,I as b,It as x,J as S,Jt as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,Qt as I,R as L,Rt as ee,S as R,St as te,T as ne,Tt as re,U as ie,Ut as ae,V as oe,Vt as se,W as ce,Wt as le,X as ue,Y as de,Yt as fe,Z as z,Zt as pe,_ as me,_t as he,a as ge,at as _e,b as ve,bt as ye,c as be,ct as xe,d as Se,dt as Ce,et as we,f as Te,ft as Ee,g as De,gt as Oe,h as ke,ht as Ae,i as je,it as Me,j as Ne,jt as B,k as Pe,kt as Fe,l as Ie,lt as Le,m as Re,mt as ze,n as Be,nt as Ve,o as He,ot as Ue,p as We,pt as Ge,q as Ke,qt as qe,r as Je,rt as Ye,s as Xe,st as Ze,t as Qe,tt as $e,u as et,ut as tt,v as nt,vt as rt,w as it,wt as at,x as ot,xt as st,y as ct,yt as lt,z as ut,zt as dt}from"./src-C4_CxgrI.js";function ft(e,t){for(let n=t;n;n=e.nodes[n]?.parent??null){let t=e.nodes[n]?.source;if(t)return{link:t,from:n}}return null}function pt(e,t){let n=t?e.nodes[t]:void 0;if(!n||n.type!==`frame`||n.children.length>0)return!1;let r=(n.fills??[]).filter(e=>e.visible!==!1);return r.length>0&&r.every(e=>e.type===`image`||e.type===`video`)}function mt(e,t){let n=t;for(;n&&pt(e,n);)n=e.nodes[n]?.parent??null;return n}var ht=pe(),gt=null;function V(e){let t=document.documentElement,n=getComputedStyle(t).getPropertyValue(e).trim();return/^-?[\d.]+px$/.test(n)?parseFloat(n):(gt&>.parentNode===t||(gt=document.createElement(`div`),gt.setAttribute(`aria-hidden`,`true`),gt.style.cssText=`position:absolute;visibility:hidden;pointer-events:none;height:0;padding:0;border:0`,t.appendChild(gt)),gt.style.width=`var(${e})`,parseFloat(getComputedStyle(gt).width)||0)}var _t=new Map,vt=`stroke='white' stroke-width='1.5' stroke-linejoin='round' paint-order='stroke'`;function yt(e,t,n,r){let i=_t.get(e);if(!i){let a=`<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'>${t}</svg>`;i=`url("data:image/svg+xml,${encodeURIComponent(a)}") ${n[0]} ${n[1]}, ${r}`,_t.set(e,i)}return i}function bt(e){return{0:`ew-resize`,45:`nwse-resize`,90:`ns-resize`,135:`nesw-resize`}[(Math.round(e/45)*45%180+180)%180]}function xt(e){let t=(Math.round(e/5)*5%180+180)%180,n=`<g transform='rotate(${t} 12 12)'><path d='M3 12l4.5-4.5v3h9v-3L21 12l-4.5 4.5v-3h-9v3z' fill='black' ${vt}/></g>`;return yt(`r${t}`,n,[12,12],bt(t))}function St(e){let t=(Math.round(e/5)*5%180+180)%180,n=`<g transform='rotate(${t} 10 10)'><path d='M2.5 10l3.8-3.8v2.5h7.4V6.2l3.8 3.8-3.8 3.8v-2.5H6.3v2.5z' fill='black' ${vt}/></g>`;return yt(`s${t}`,n+`<rect x='15' y='15' width='8' height='8' rx='1.5' fill='white' stroke='black' stroke-width='1.2'/><rect x='16.8' y='18.6' width='2.6' height='2.6' rx='.5' fill='black'/><path d='M18.8 18.4l2.4-2.4M19.4 16h1.8v1.8' stroke='black' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/>`,[10,10],bt(t))}function Ct(e){let t=(Math.round(e/5)*5%360+360)%360,n=`M6.5 15.5A9 9 0 0 0 15.5 6.5`,r=`<g transform='rotate(${t-45} 12 12)'><path d='${n}' fill='none' stroke='white' stroke-width='4.5' stroke-linecap='round'/><path d='M3.6 13.2l2.9 4.6 3.6-3.9zM13.2 3.6l4.6 2.9-3.9 3.6z' fill='black' ${vt}/><path d='${n}' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/></g>`;return yt(`o${t}`,r,[12,12],`alias`)}var wt=()=>yt(`x`,`<path d='M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21' stroke='white' stroke-width='3.5' stroke-linecap='round'/><path d='M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21' stroke='black' stroke-width='1.4' stroke-linecap='round'/>`,[12,12],`crosshair`),Tt=()=>yt(`p`,`<path d='M3.5 20.5l2.2-8.2 7.6-7.6 6 6-7.6 7.6z' fill='black' ${vt}/><path d='M3.5 20.5l5.2-5.2' stroke='white' stroke-width='1.2' stroke-linecap='round'/><circle cx='9.6' cy='14.4' r='1.3' fill='white'/>`,[3,21],`crosshair`),Et={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};function Dt(e,t,n){let r=e.nodes[t];return!r||r.type!==`frame`||r.boolean||r.locked?!1:n||r.children.length>0||!r.parent}function Ot(e){return e.roots.filter(t=>{let n=e.nodes[t];return n?.type===`frame`&&!n.boolean&&!pt(e,t)})}var H=i();function kt(e,t){let n=[],r=t;for(;r;)n.unshift(r),r=e.nodes[r]?.parent??null;return n}function At(e){return e?.type===`frame`&&e.layout.mode===`free`&&e.sizeX===`hug`&&e.sizeY===`hug`&&!e.fills?.length&&!e.stroke&&!e.boolean&&!e.component&&e.children.length>0}function jt(e,t,n,r){if(!t||!e.nodes[t])return null;let i=kt(e,t).filter(t=>!e.nodes[t].locked);if(!i.length)return null;if(r.meta)return i[i.length-1];for(let t of n){let n=e.nodes[t]?.parent;if(!n)continue;let r=i.indexOf(n);if(r>=0&&r<i.length-1)return i[r+1]}let a=i.findIndex(t=>e.nodes[t].boolean),o=a>=0?i.slice(0,a+1):i,s=e.nodes[o[0]];return At(s)||s.instanceOf?o[0]:o.length===1?s.type===`frame`&&s.children.length&&!s.boolean?null:o[0]:o[1]}function Mt(e,t,n){if(!t)return null;let r=kt(e,t),i=r.indexOf(n);return i>=0&&i<r.length-1?r[i+1]:null}function Nt(e,t){let n=e.nodes[t];return n?!n.parent||n.absolute?!0:e.nodes[n.parent].layout.mode===`free`:!1}function Pt(e,t){let n=new Set(t.filter(t=>e.nodes[t]));return[...n].filter(t=>{let r=e.nodes[t].parent;for(;r;){if(n.has(r))return!1;r=e.nodes[r]?.parent??null}return!0})}function Ft(e,t,n,r){return r?t.includes(n)?{next:t,unselect:n}:{next:Pt(e,[...t,n])}:{next:t.includes(n)?t:[n]}}var It=(e,t,n)=>n.filter(n=>t.nodes[n]&&!e.removed?.[n]),Lt=e=>e!==`move`&&e!==`scale`,Rt=e=>e!==`pan`,zt=e=>e.kind===`marquee`?e.before??[]:null,Bt=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h;function Vt(e){if(!e.length)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.w)),i=Math.max(...e.map(e=>e.y+e.h));return{x:t,y:n,w:r-t,h:i-n}}function Ht(e,t,n,r){return(n?e.nodes[n].children:e.roots).filter(n=>{let i=e.nodes[n],a=t.get(n);return i&&!i.hidden&&!i.locked&&a&&Bt(a,r)})}function Ut(e){return!!e&&e.type===`frame`&&!e.children.length&&!!e.fills?.some(e=>e.type===`video`&&e.visible!==!1)}function Wt(e){return!!e&&e.type===`frame`&&!e.children.length&&!!e.fills?.some(e=>e.type===`image`&&e.visible!==!1)}var Gt=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`];function Kt(e,t,n,r,i={}){let a=t.includes(`e`),o=t.includes(`w`),s=t.includes(`s`),c=t.includes(`n`),l=i.alt?2:1,u=e.w+(a?n:o?-n:0)*l,d=e.h+(s?r:c?-r:0)*l;if(i.shift&&e.w>0&&e.h>0){let t=e.w/e.h,n=a||o,r=c||s;n&&!r?d=u/t:r&&!n?u=d*t:Math.abs(u/e.w)>Math.abs(d/e.h)?d=u/t:u=d*t}u=i.keepZero&&e.w===0?0:Math.max(1,Math.round(u)),d=i.keepZero&&e.h===0?0:Math.max(1,Math.round(d));let f=e.x,p=e.y;return i.alt?(f=Math.round(e.x+(e.w-u)/2),p=Math.round(e.y+(e.h-d)/2)):(o?f=e.x+e.w-u:!a&&i.shift&&(f=Math.round(e.x+(e.w-u)/2)),c?p=e.y+e.h-d:!s&&i.shift&&(p=Math.round(e.y+(e.h-d)/2))),{x:f,y:p,w:u,h:d}}var qt=[1,0,0,1],Jt=(e,t)=>[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]],Yt=e=>{let t=e[0]*e[3]-e[1]*e[2]||1;return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t]},Xt=(e,t,n)=>[e[0]*t+e[2]*n,e[1]*t+e[3]*n],Zt=e=>e[0]*e[3]-e[1]*e[2],Qt=e=>Math.abs(e[0]-1)<1e-9&&Math.abs(e[1])<1e-9&&Math.abs(e[2])<1e-9&&Math.abs(e[3]-1)<1e-9,$t=e=>e?.rotation??0;function en(e){if(!e)return qt;let t=$t(e)*Math.PI/180,n=Math.cos(t),r=Math.sin(t),i=e.flipX?-1:1,a=e.flipY?-1:1;return[n*i,r*i,-r*a,n*a]}function tn(e,t){let n=[];for(let r=t;r;r=e.nodes[r]?.parent??null){let t=e.nodes[r];t&&n.unshift(t)}return n.reduce((e,t)=>Jt(e,en(t)),qt)}var nn=(e,t)=>tn(e,e.nodes[t]?.parent??null),rn=(e,t)=>!Qt(tn(e,t));function an(e,t){let n=tn(e,t);return Math.round(Math.atan2(n[1],n[0])*180/Math.PI*100)/100||0}function on(e,t,n){let r=t.get(n),i=e.nodes[n];return r?.ow!==void 0&&r.oh!==void 0?{w:r.ow,h:r.oh}:i&&r&&!rn(e,n)?{w:r.w,h:r.h}:{w:i?.w??0,h:i?.h??0}}function sn(e,t,n,r){if(!n)return r;let i=t.get(n);if(!i)return null;let{w:a,h:o}=on(e,t,n),[s,c]=Xt(Yt(tn(e,n)),r.x-(i.x+i.w/2),r.y-(i.y+i.h/2));return{x:a/2+s,y:o/2+c}}function cn(e,t,n,r){return Xt(Yt(nn(e,t)),n,r)}function ln(e,t){let n=Zt(t)<0,r=n&&e.flipX&&!e.flipY?-1:1,i=n&&(!e.flipX||e.flipY)?-1:1,a=Math.atan2(t[1]/r,t[0]/r)*180/Math.PI,o=Math.round(((a%360+540)%360-180)*10)/10;return{rotation:o===-180?180:o,flipX:r<0,flipY:i<0}}function un(e,t,n,r,i){let a=sn(e,t,r,i);if(!a)return null;let{w:o,h:s}=on(e,t,n),c=e=>Math.round(e*100)/100,l={x:c(a.x-o/2),y:c(a.y-s/2)},u=e.nodes[n];if(u&&u.parent!==r&&!(u.type===`frame`&&u.boolean)){let t=ln(u,Jt(Yt(tn(e,r)),tn(e,n)));t.rotation!==$t(u)&&(l.rotation=t.rotation||null),t.flipX!==!!u.flipX&&(l.flipX=t.flipX||null),t.flipY!==!!u.flipY&&(l.flipY=t.flipY||null)}return l}var dn=(e,t,n)=>`matrix(${e[0]},${e[1]},${e[2]},${e[3]},${t-e[0]*t-e[2]*n},${n-e[1]*t-e[3]*n})`;function fn(e,t,n){let r=t.get(n);if(!r)return null;let i=e.nodes[n]?.parent;if(!i)return r;let a=t.get(i);if(!a)return null;if(!rn(e,i))return{...r,x:r.x-a.x,y:r.y-a.y};let o=sn(e,t,i,{x:r.x+r.w/2,y:r.y+r.h/2});if(!o)return null;let{w:s,h:c}=on(e,t,n),l=en(e.nodes[n]),u=Math.abs(l[0])*s+Math.abs(l[2])*c,d=Math.abs(l[1])*s+Math.abs(l[3])*c;return{x:o.x-u/2,y:o.y-d/2,w:u,h:d,ow:s,oh:c}}function pn(e,t,n){let r=new Map;for(let i of n){let n=fn(e,t,i);n&&r.set(i,n)}return r}function mn(e,t,n){let r=e.nodes[t];if(r&&$t(r)){let e=n.ow??r.w,t=n.oh??r.h;return{x:n.x+n.w/2-e/2,y:n.y+n.h/2-t/2}}return{x:n.x,y:n.y}}function hn(e,t,n,r,i){if(!i)return{x:e,y:t,w:n,h:r};let a=i*Math.PI/180,o=Math.abs(Math.cos(a)),s=Math.abs(Math.sin(a)),c=n*o+r*s,l=n*s+r*o;return{x:e+n/2-c/2,y:t+r/2-l/2,w:c,h:l}}var gn=(e,t)=>{let n=e.nodes[t].parent;return n?e.nodes[n].children:e.roots};function _n(e,t,n,r){return t.filter(t=>Nt(e,t)).map(t=>{let i=e.nodes[t];if(rn(e,i.parent)){let[a,o]=cn(e,t,n,r);return{op:`update`,id:t,set:{x:Math.round((i.x+a)*100)/100,y:Math.round((i.y+o)*100)/100}}}return{op:`update`,id:t,set:{x:Math.round(i.x+n),y:Math.round(i.y+r)}}})}function vn(e){return e.length?[{op:`delete`,ids:e}]:[]}function yn(e,t){let n=Math.max(0,...j(e).map(e=>e.x+e.w)),r=[],i=t.map((e,t)=>`dup${t}`),a=[];return t.forEach((t,o)=>{let s=e.nodes[t],c={...Pe(e,t,{copy:!0}),key:i[o]};if(!s.parent)r.push({op:`create`,parent:null,tree:{...c,x:n+80,y:s.y}}),n+=80+s.w;else{let n=gn(e,t).indexOf(t);a.push({i:o,at:n,op:{op:`create`,parent:s.parent,index:n+1,tree:c}})}}),a.sort((e,t)=>t.at-e.at).forEach(e=>r.push(e.op)),{ops:r,keys:i}}function bn(e,t,n){if(!n.length)return null;let r=e.nodes[n[0]].parent;if(n.some(t=>e.nodes[t].parent!==r))return null;let i=n.map(n=>fn(e,t,n));if(i.some(e=>!e))return null;let a=Vt(i),o=gn(e,n[0]),s=Math.max(...n.map(e=>o.indexOf(e)))+1,c=[...n].sort((e,t)=>o.indexOf(e)-o.indexOf(t)),l=[{op:`create`,parent:r,index:s,tree:{type:`frame`,key:`group`,name:`Group`,x:Math.round(a.x),y:Math.round(a.y),w:Math.round(a.w),h:Math.round(a.h),sizeX:`hug`,sizeY:`hug`}},{op:`move`,ids:c,parent:`group`}];for(let t of c){let r=i[n.indexOf(t)],o=e.nodes[t],s=mn(e,t,{...r,x:r.x-a.x,y:r.y-a.y}),c={x:Math.round(s.x),y:Math.round(s.y),absolute:!1};o.sizeX===`fill`&&Object.assign(c,{sizeX:`fixed`,w:Math.round(r.w)}),o.sizeY===`fill`&&Object.assign(c,{sizeY:`fixed`,h:Math.round(r.h)}),l.push({op:`update`,id:t,set:c})}return l}function xn(e,t,n){let r=[],i=[];for(let a of n){let n=e.nodes[a];if(!n||n.type!==`frame`||!n.children.length)continue;let o=gn(e,a).indexOf(a);r.push({op:`move`,ids:[...n.children],parent:n.parent,index:o});let s=!!n.rotation||!!n.flipX||!!n.flipY;for(let a of n.children){if(s){let o=t.get(a),s=o&&un(e,t,a,n.parent,{x:o.x+o.w/2,y:o.y+o.h/2});s&&r.push({op:`update`,id:a,set:s}),i.push(a);continue}let o=fn(e,t,a),c=o&&mn(e,a,{...o,x:n.x+o.x,y:n.y+o.y}),l=c?{x:Math.round(c.x),y:Math.round(c.y)}:{},u=e.nodes[a];o&&u.sizeX===`fill`&&Object.assign(l,{sizeX:`fixed`,w:Math.round(o.w)}),o&&u.sizeY===`fill`&&Object.assign(l,{sizeY:`fixed`,h:Math.round(o.h)}),Object.keys(l).length&&r.push({op:`update`,id:a,set:l}),i.push(a)}r.push({op:`delete`,ids:[a]})}return r.length?{ops:r,lifted:i}:null}function Sn(e,t,n){if(!t.length)return[];let r=e.nodes[t[0]].parent;if(t.some(t=>e.nodes[t].parent!==r))return[];let i=gn(e,t[0]),a=new Set(t),o=i.filter(e=>!a.has(e)),s=t.map(e=>i.indexOf(e)).sort((e,t)=>e-t),c;if(n===1/0)c=o.length;else if(n===-1/0)c=0;else{let e=i.slice(0,n>0?s[s.length-1]+1:s[0]).filter(e=>!a.has(e)).length;c=Math.max(0,Math.min(o.length,e+(n>0?1:-1)))}let l=i.filter(e=>a.has(e));if([...o.slice(0,c),...l,...o.slice(c)].every((e,t)=>e===i[t]))return[];let u=o[c];return[{op:`move`,ids:l,parent:r,index:u?i.indexOf(u):i.length}]}function Cn(e,t,n){let r=[];for(let i of new Set(n)){let n=e.nodes[i];if(!n||n.type!==`frame`||n.boolean||n.layout.mode!==`free`||n.sizeX!==`hug`||!n.children.length||rn(e,i))continue;let a=n.children.map(t);if(a.some(e=>!e))continue;let o=Vt(a),s=Math.round(o.x),c=Math.round(o.y),l=Math.round(o.w),u=Math.round(o.h);(s||c||l!==n.w||u!==n.h)&&(r.push({op:`update`,id:i,set:{x:n.x+s,y:n.y+c,w:l,h:u}}),(s||c)&&n.children.forEach((t,n)=>{let i=mn(e,t,a[n]);r.push({op:`update`,id:t,set:{x:Math.round(i.x)-s,y:Math.round(i.y)-c}})}))}return r}var wn=e=>({...e,...e.sizeX===`fill`?{sizeX:`fixed`}:{},...e.sizeY===`fill`?{sizeY:`fixed`}:{}});function Tn(e,t,n,r){if(r){let e=t.map(e=>e.tree.x??0),n=t.map(e=>e.tree.y??0),i=Math.min(...e),a=Math.min(...n),o=Math.max(...t.map(e=>(e.tree.x??0)+(e.tree.w??100))),s=Math.max(...t.map(e=>(e.tree.y??0)+(e.tree.h??100))),c=Math.round(r.x-(o-i)/2-i),l=Math.round(r.y-(s-a)/2-a),u=t.map((e,t)=>`paste${t}`);return{keys:u,ops:t.map((e,t)=>({op:`create`,parent:null,tree:{...e.tree,key:u[t],x:(e.tree.x??0)+c,y:(e.tree.y??0)+l,absolute:!1}}))}}let i=Math.max(0,...j(e).map(e=>e.x+e.w)),a=[];return{ops:t.map((t,r)=>{let o=`paste${r}`;a.push(o);let s=n&&e.nodes[n]?.type===`frame`?n:t.parent&&e.nodes[t.parent]?t.parent:null;if(s===null){let e={...t.tree,key:o,x:i+80};return i+=80+(t.tree.w??100),{op:`create`,parent:null,tree:e}}return{op:`create`,parent:s,tree:s===t.parent?{...t.tree,key:o}:{...wn(t.tree),key:o}}}),keys:a}}function En(e,t){let n=e.map(({r:e})=>e.x+e.w/2),r=e.map(({r:e})=>e.y+e.h/2),i=e=>e.length?Math.max(...e)-Math.min(...e):0,a=t??(e.length<2||i(n)>=i(r)?`row`:`column`),o=(e,t)=>t===`row`?[e.x,e.x+e.w]:[e.y,e.y+e.h],s=e=>o(e,a===`row`?`column`:`row`),c=t=>[...e].sort((e,n)=>o(e.r,t)[0]-o(n.r,t)[0]),l=e=>c(e).slice(1).map((t,n)=>o(t.r,e)[0]-o(c(e)[n].r,e)[1]),u=e=>l(e).some(e=>e<-1),d=a===`row`?`column`:`row`,f=e.length>1&&u(a)&&!u(d),p=f?d:a,m=c(p),h=l(p),g=h.length?Math.max(0,Math.round(h.reduce((e,t)=>e+t,0)/h.length)):0,_=e=>e.length>0&&i(e)<=1,v=e.length<2||f||_(m.map(e=>s(e.r)[0]))?`start`:_(m.map(e=>(s(e.r)[0]+s(e.r)[1])/2))?`center`:_(m.map(e=>s(e.r)[1]))?`end`:`start`;return{mode:a,ids:m.map(e=>e.id),gap:g,alignCross:v,restacked:f}}function Dn(e,t,n){if(!n.length)return null;let r=n.length===1?e.nodes[n[0]]:null;if(r?.type===`frame`&&r.boolean)return null;if(r&&r.type===`frame`&&r.layout.mode===`free`&&r.children.length){let n=On(e,t,r.id);return n?{ops:n,select:[r.id]}:null}let i=e.nodes[n[0]].parent;if(n.some(t=>e.nodes[t].parent!==i))return null;let a=n.map(n=>({id:n,r:fn(e,t,n)}));if(a.some(e=>!e.r))return null;let o=En(a),s=Vt(a.map(e=>e.r)),c=gn(e,n[0]);return{select:[`al`],ops:[{op:`create`,parent:i,index:Math.min(...n.map(e=>c.indexOf(e))),tree:{type:`frame`,key:`al`,name:`Frame`,x:Math.round(s.x),y:Math.round(s.y),w:Math.round(s.w),h:Math.round(s.h),sizeX:`hug`,sizeY:`hug`,layout:{mode:o.mode,gap:o.gap,pad:0,alignCross:o.alignCross}}},{op:`move`,ids:o.ids,parent:`al`},...n.filter(t=>e.nodes[t].absolute).map(e=>({op:`update`,id:e,set:{absolute:!1}}))]}}function On(e,t,n,r){let i=e.nodes[n],a=t.get(n);if(!i||i.type!==`frame`||!a)return null;let o=i.children.filter(t=>!e.nodes[t].absolute).map(n=>({id:n,r:fn(e,t,n)})).filter(e=>!!e.r);if(!o.length)return[{op:`update`,id:n,set:{layout:{mode:r??`column`}}}];let s=En(o,r),c=Vt(o.map(e=>e.r)),l=(s.restacked?[c.y,c.x,c.y,c.x]:[c.y,a.w-(c.x+c.w),a.h-(c.y+c.h),c.x]).map(e=>Math.max(0,Math.round(e))),u={layout:{mode:s.mode,gap:s.gap,pad:l,alignCross:s.alignCross}};i.parent&&Object.assign(u,{sizeX:`hug`,sizeY:`hug`});let d=[{op:`update`,id:n,set:u}],f=i.children.filter(e=>s.ids.includes(e));return s.ids.some((e,t)=>e!==f[t])&&d.push({op:`move`,ids:s.ids,parent:n}),d}function kn(e,t,n){let r=e.nodes[n],i=t.get(n);if(!r||r.type!==`frame`||!i)return null;let a={layout:{mode:`free`}};r.sizeX!==`fixed`&&Object.assign(a,{sizeX:`fixed`,w:Math.round(i.w)}),r.sizeY!==`fixed`&&Object.assign(a,{sizeY:`fixed`,h:Math.round(i.h)});let o=[{op:`update`,id:n,set:a}];for(let n of r.children){let r=fn(e,t,n),i=e.nodes[n];if(!r||i.absolute)continue;let a={x:Math.round(r.x),y:Math.round(r.y)};i.sizeX===`fill`&&Object.assign(a,{sizeX:`fixed`,w:Math.round(r.w)}),i.sizeY===`fill`&&Object.assign(a,{sizeY:`fixed`,h:Math.round(r.h)}),o.push({op:`update`,id:n,set:a})}return o}function An(e,t,n,r,i){let a=e.nodes[n],o=a.layout.mode===`row`,s=a.children.filter(t=>!r.includes(t)&&!e.nodes[t].absolute&&!e.nodes[t].hidden),c=e=>t.get(e),l=o?i.x:i.y,u=0;for(let e of s){let t=c(e);t&&l>(o?t.x+t.w/2:t.y+t.h/2)&&u++}let d=s[u],f=d?a.children.indexOf(d):a.children.length,p=c(n),[m,h,g,_]=a.layout.pad,v=u>0?c(s[u-1]):null,y=d?c(d):null,b=e=>o?e.x:e.y,x=e=>o?e.x+e.w:e.y+e.h,S=v&&y?(x(v)+b(y))/2:v?x(v)+2:y?b(y)-2:o?p.x+_:p.y+m;return{index:f,line:o?{x:S-1,y:p.y+m,w:2,h:Math.max(8,p.h-m-g)}:{x:p.x+_,y:S-1,w:Math.max(8,p.w-_-h),h:2},same:r.every(t=>e.nodes[t].parent===n)&&(()=>{let t=[...s.slice(0,u),...a.children.filter(e=>r.includes(e)),...s.slice(u)],n=a.children.filter(t=>!e.nodes[t].absolute&&!e.nodes[t].hidden);return t.every((e,t)=>e===n[t])})()}}function jn(e,t,n,r){let i=n.filter(n=>Nt(e,n)&&t.get(n));if(!i.length)return[];let a=e.nodes[n[0]]?.parent??null;if(a&&n.every(t=>e.nodes[t]?.parent===a)&&rn(e,a)){let o=pn(e,t,n),s=n.length>1?Vt([...o.values()]):{x:0,y:0,...on(e,t,a)};return s?i.filter(e=>o.has(e)).map(t=>{let n=o.get(t),i={};r===`left`&&(i.x=s.x),r===`right`&&(i.x=s.x+s.w-n.w),r===`hcenter`&&(i.x=s.x+(s.w-n.w)/2),r===`top`&&(i.y=s.y),r===`bottom`&&(i.y=s.y+s.h-n.h),r===`vcenter`&&(i.y=s.y+(s.h-n.h)/2);let a=mn(e,t,{...n,x:i.x??n.x,y:i.y??n.y});return i.x!==void 0&&(i.x=Math.round(a.x*100)/100),i.y!==void 0&&(i.y=Math.round(a.y*100)/100),{op:`update`,id:t,set:i}}):[]}let o;if(n.length>1)o=Vt(n.map(e=>t.get(e)).filter(e=>!!e))??void 0;else{let n=e.nodes[i[0]].parent;o=n?t.get(n):void 0}return o?i.map(n=>{let i=t.get(n),a=e.nodes[n],s=a.parent?t.get(a.parent):{x:0,y:0},c={};if(r===`left`&&(c.x=o.x),r===`right`&&(c.x=o.x+o.w-i.w),r===`hcenter`&&(c.x=o.x+(o.w-i.w)/2),r===`top`&&(c.y=o.y),r===`bottom`&&(c.y=o.y+o.h-i.h),r===`vcenter`&&(c.y=o.y+(o.h-i.h)/2),rn(e,a.parent)){let[t,r]=cn(e,n,(c.x??i.x)-i.x,(c.y??i.y)-i.y);return{op:`update`,id:n,set:{x:Math.round((a.x+t)*100)/100,y:Math.round((a.y+r)*100)/100}}}let l=mn(e,n,{...i,x:(c.x??i.x)-s.x,y:(c.y??i.y)-s.y});return c.x!==void 0&&(c.x=Math.round(l.x)),c.y!==void 0&&(c.y=Math.round(l.y)),{op:`update`,id:n,set:c}}):[]}function Mn(e,t,n,r){let i=e.nodes[n[0]]?.parent??null,a=!!i&&n.every(t=>e.nodes[t]?.parent===i)&&rn(e,i),o=a?pn(e,t,n):t,s=n.filter(t=>Nt(e,t)&&o.get(t)).map(e=>({id:e,b:o.get(e)}));if(s.length<3)return[];let c=e=>r===`x`?e.x:e.y,l=e=>r===`x`?e.w:e.h;s.sort((e,t)=>c(e.b)-c(t.b));let u=s[0].b,d=s[s.length-1].b,f=(c(d)+l(d)-c(u)-s.reduce((e,t)=>e+l(t.b),0))/(s.length-1),p=c(u);return s.map(({id:n,b:i})=>{let o=e.nodes[n],s=!a&&o.parent?t.get(o.parent):{x:0,y:0};if(!a&&rn(e,o.parent)){let[t,a]=cn(e,n,r===`x`?p-i.x:0,r===`y`?p-i.y:0);return p+=l(i)+f,{op:`update`,id:n,set:{x:Math.round((o.x+t)*100)/100,y:Math.round((o.y+a)*100)/100}}}let c=mn(e,n,{...i,x:(r===`x`?p:i.x)-s.x,y:(r===`y`?p:i.y)-s.y});return p+=l(i)+f,{op:`update`,id:n,set:r===`x`?{x:Math.round(c.x)}:{y:Math.round(c.y)}}})}function Nn(e,t,n){let r=bn(e,t,n);if(!r)return null;let i=r[0];return i.tree={...i.tree,key:`frame`,name:`Frame`,sizeX:`fixed`,sizeY:`fixed`},r.map(e=>e.op===`move`?{...e,parent:`frame`}:e)}var Pn=[`fills`,`stroke`,`radius`,`effects`,`opacity`,`blend`,`clip`],Fn=[`fills`,`stroke`,`radius`,`effects`,`opacity`,`blend`],In=[`style`,`fontFamily`,`fontSize`,`fontWeight`,`fontStyle`,`lineHeight`,`letterSpacing`,`textAlign`,`textDecoration`,`textCase`,`color`,`opacity`,`blend`];function Ln(e,t){let n=e.nodes[t];if(!n||n.type===`vector`)return null;let r=n.type===`frame`?Pn:n.type===`shape`?Fn:In,i={};for(let e of r)i[e]=structuredClone(n[e]??null);return{type:n.type,props:i}}function Rn(e,t,n){let r=e=>e===`frame`||e===`shape`;return t.flatMap(t=>{let i=e.nodes[t];if(!i)return[];let a=i.type===n.type;if(!a&&!(r(i.type)&&r(n.type)))return[];let o=a?{...n.props}:Object.fromEntries(Fn.map(e=>[e,n.props[e]??null]));return i.type===`frame`&&o.clip===null&&(o.clip=!1),(i.type===`shape`||i.type===`frame`&&i.boolean)&&Array.isArray(o.fills)&&(o.fills=o.fills.filter(e=>e.type!==`video`)),[{op:`update`,id:t,set:o}]})}var zn=[`fontFamily`,`fontSize`,`fontWeight`,`fontStyle`,`lineHeight`,`letterSpacing`,`textCase`];function Bn(e,t,n){let r=e.nodes[t];if(r.type!==`text`||!r.style||!Object.keys(n).some(e=>zn.includes(e)))return n;let i=e.styles.text[r.style.slice(1)],a={};for(let e of[...zn,`color`,`textAlign`]){let t=r[e]??i?.[e];t!==void 0&&(a[e]=t)}return{...a,...n,style:null}}function Vn(e,t){let n=e.nodes[t],r=n.style?e.styles.text[n.style.slice(1)]:void 0,i=e=>n[e]??r?.[e];return{fontFamily:i(`fontFamily`)??`Pretendard`,fontSize:i(`fontSize`)??16,fontWeight:i(`fontWeight`)??400,...i(`fontStyle`)===`italic`?{fontStyle:`italic`}:{},...i(`lineHeight`)===void 0?{}:{lineHeight:i(`lineHeight`)},...i(`letterSpacing`)===void 0?{}:{letterSpacing:i(`letterSpacing`)},...i(`textCase`)===void 0?{}:{textCase:i(`textCase`)},color:i(`color`)??`#000000`}}function Hn(e,t,n){return[{op:`styles`,text:{[n]:Vn(e,t[0])}},...t.map(e=>({op:`update`,id:e,set:{style:`$${n}`,...Object.fromEntries([...zn,`color`].map(e=>[e,null]))}}))]}function Un(e,t,n){let r=[];for(let i of n){let n=e.nodes[i];if(!n||n.type!==`frame`||!n.children.length)continue;if(n.layout.mode!==`free`){(n.sizeX!==`hug`||n.sizeY!==`hug`)&&r.push({op:`update`,id:i,set:{sizeX:`hug`,sizeY:`hug`}});continue}let a=n.children.filter(t=>!e.nodes[t].hidden),o=a.map(n=>fn(e,t,n));if(!o.length||o.some(e=>!e))continue;let s=Vt(o),c=Math.round(s.x),l=Math.round(s.y),u={w:Math.max(1,Math.round(s.w)),h:Math.max(1,Math.round(s.h)),sizeX:`fixed`,sizeY:`fixed`};Nt(e,i)&&Object.assign(u,{x:n.x+c,y:n.y+l}),(c||l||u.w!==n.w||u.h!==n.h||n.sizeX!==`fixed`||n.sizeY!==`fixed`)&&(r.push({op:`update`,id:i,set:u}),(c||l)&&a.forEach((e,t)=>r.push({op:`update`,id:e,set:{x:Math.round(o[t].x)-c,y:Math.round(o[t].y)-l}})))}return r}function Wn(e,t,n,r){let i=e.nodes[t];if(!i||i.type!==`frame`)return[];let a=[];for(let t of i.children){let o=e.nodes[t],s=o?.constraints;if(!o||!s||!(o.absolute||i.layout.mode===`free`))continue;let c=n-s.ref[0],l=r-s.ref[1];if(!c&&!l)continue;let u={constraints:{...s,ref:[Math.round(n),Math.round(r)]}};s.x===`right`?u.x=o.x+c:s.x===`center`?u.x=Math.round(o.x+c/2):s.x===`leftRight`&&(u.w=Math.max(1,o.w+c)),s.y===`bottom`?u.y=o.y+l:s.y===`center`?u.y=Math.round(o.y+l/2):s.y===`topBottom`&&(u.h=Math.max(1,o.h+l)),a.push({op:`update`,id:t,set:u})}return a}function Gn(e,t,n,r,i,a){let o=r.w?i.w/r.w:1,s=r.h?i.h/r.h:1,c=e=>Math.round(e*100)/100,l=[],u=new Map;for(let d of n){let n=e.nodes[d],f=t.get(d);if(!n||!f)continue;let p=$t(n),m=p*Math.PI/180,h=Math.abs(Math.cos(m)),g=Math.abs(Math.sin(m)),_=p?Math.hypot(o*h,s*g):o,v=p?Math.hypot(o*g,s*h):s,y=p||n.sizeX===`fixed`?n.w:f.w,b=p||n.sizeY===`fixed`?n.h:f.h,x=(e,t)=>e===0?0:Math.max(1,c(e*t)),S=a.x||!!p,C=a.y||!!p,w=S?x(y,_):y,T=C?x(b,v):b,E=i.x+(f.x+f.w/2-r.x)*o,D=i.y+(f.y+f.h/2-r.y)*s,O=n.parent?t.get(n.parent):void 0,k=c(E-w/2-(O?.x??0)),A=c(D-T/2-(O?.y??0)),j={};S&&Object.assign(j,{w,sizeX:`fixed`}),C&&Object.assign(j,{h:T,sizeY:`fixed`}),n.type===`text`&&a.x&&!a.y&&(j.sizeY=`hug`),Nt(e,d)&&Object.assign(j,{x:k,y:A}),l.push({op:`update`,id:d,set:j}),n.type===`frame`&&l.push(...Wn(e,d,w,T)),u.set(d,hn(k,A,w,T,p))}return{ops:l,rel:u}}function Kn(e,t,n){let r=e=>Math.round(e*100)/100,i={};if(t.type===`text`){let a=t.style?e.styles.text[t.style.slice(1)]:void 0,o=t.fontSize??a?.fontSize,s=t.lineHeight??a?.lineHeight,c=t.letterSpacing??a?.letterSpacing,l={};o&&(l.fontSize=Math.max(.01,r(o*n))),s&&(l.lineHeight=Math.max(.01,r(s*n))),c&&(l.letterSpacing=r(c*n)),Object.assign(i,Bn(e,t.id,l))}if((t.type===`frame`||t.type===`shape`)&&t.stroke){let e=t.stroke;i.stroke={...e,width:r(e.width*n),...e.sides?{sides:e.sides.map(e=>r(e*n))}:{}}}if((t.type===`frame`||t.type===`shape`)&&t.radius!==void 0){let a=Ee(e,t.radius);typeof a==`number`?i.radius=r(a*n):Array.isArray(a)&&(i.radius=a.map(e=>r(e*n)))}if(t.effects?.length&&(i.effects=t.effects.map(e=>e.type===`shadow`?{...e,x:r(e.x*n),y:r(e.y*n),blur:r(e.blur*n),spread:r(e.spread*n)}:e.type===`shader`?e:{...e,radius:r(e.radius*n)})),t.type===`frame`){let e=t.layout,a={pad:e.pad.map(e=>r(e*n))};a.gap=r(e.gap*n),e.gapCross!==void 0&&(a.gapCross=r(e.gapCross*n)),(e.mode!==`free`||e.pad.some(Boolean))&&(i.layout=a),t.grids?.length&&(i.grids=t.grids.map(e=>e.type===`grid`?{...e,size:r(e.size*n)}:{...e,gutter:r(e.gutter*n),margin:r(e.margin*n),...e.size===void 0?{}:{size:r(e.size*n)}}))}return i}function qn(e,t,n,r,i){let a=r.w?i.w/r.w:r.h?i.h/r.h:1,o=e=>Math.round(e*100)/100,s=e=>e===0?0:Math.max(.01,o(e*a)),c=[],l=new Map,u=t=>{let n=e.nodes[t];if(!n)return;let r={...Kn(e,n,a)};if(n.sizeX===`fixed`&&(r.w=s(n.w)),n.sizeY===`fixed`&&(r.h=s(n.h)),Nt(e,t)&&Object.assign(r,{x:o(n.x*a),y:o(n.y*a)}),n.constraints&&(r.constraints={...n.constraints,ref:n.constraints.ref.map(e=>Math.round(e*a))}),Object.keys(r).length&&c.push({op:`update`,id:t,set:r}),!(n.type===`frame`&&n.boolean))for(let e of n.children??[])u(e)};for(let d of n){let n=e.nodes[d],f=t.get(d);if(!n||!f)continue;let p=$t(n),m=p||n.sizeX===`fixed`?n.w:f.w,h=p||n.sizeY===`fixed`?n.h:f.h,g=s(m),_=s(h),v=i.x+(f.x+f.w/2-r.x)*a,y=i.y+(f.y+f.h/2-r.y)*a,b=n.parent?t.get(n.parent):void 0,x=o(v-g/2-(b?.x??0)),S=o(y-_/2-(b?.y??0)),C={...Kn(e,n,a),w:g,h:_};if(n.sizeX===`fill`&&(C.sizeX=`fixed`),n.sizeY===`fill`&&(C.sizeY=`fixed`),Nt(e,d)&&Object.assign(C,{x,y:S}),c.push({op:`update`,id:d,set:C}),!(n.type===`frame`&&n.boolean))for(let e of n.children??[])u(e);l.set(d,hn(x,S,g,_,p))}return{ops:c,rel:l}}function Jn(e,t,n){let r=e=>Math.round(e*100)/100;return!e.w||!e.h?t===`w`?{w:n,h:e.h}:{w:e.w,h:n}:t===`w`?{w:n,h:r(n*e.h/e.w)}:{w:r(n*e.w/e.h),h:n}}var Yn=e=>{let t=Math.round(((e%360+540)%360-180)*10)/10;return t===-180?180:t};function Xn(e,t,n){let r=n*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=e=>Math.round(e*100)/100;return e.map(e=>{let r=Yn(e.rot+n*(e.sign??1)),s=e.cx-t.x,c=e.cy-t.y,l=t.x+s*i-c*a,u=t.y+s*a+c*i,d=e.local({x:l,y:u});return{op:`update`,id:e.id,set:{rotation:r===0?null:r,...e.free?{x:o(d.x-e.w/2),y:o(d.y-e.h/2)}:{}}}})}var Zn=Yn;function Qn(e,t,n,r,i,a={}){let o={x:e.x+e.w/2,y:e.y+e.h/2},s=-t*Math.PI/180,c=Kt(e,n,r*Math.cos(s)-i*Math.sin(s),r*Math.sin(s)+i*Math.cos(s),a),l=c.x+c.w/2-o.x,u=c.y+c.h/2-o.y,d=t*Math.PI/180,f=o.x+l*Math.cos(d)-u*Math.sin(d),p=o.y+l*Math.sin(d)+u*Math.cos(d);return{x:f-c.w/2,y:p-c.h/2,w:c.w,h:c.h}}function $n(e,t,n,r){let i=n.map(t=>e.nodes[t]).filter(e=>!!e),a=r===`x`?`flipX`:`flipY`,o=i[0]?.parent??null,s=i.length>1&&i.every(t=>t.parent===o&&(!o||e.nodes[o].layout.mode===`free`||t.absolute)),c=s?i.map(n=>fn(e,t,n.id)):[],l=s?Math.min(...c.map(e=>e?r===`x`?e.x:e.y:1/0)):0,u=s?Math.max(...c.map(e=>e?r===`x`?e.x+e.w:e.y+e.h:-1/0)):0,d=(e,[t,n])=>{let i={...e,...r===`x`?{x:t-e.x}:{y:n-e.y}},a=e=>e&&(r===`x`?[-e[0],e[1]]:[e[0],-e[1]]);return e.in&&(i.in=a(e.in)),e.out&&(i.out=a(e.out)),i};return i.map((t,n)=>{let i={};if(t.type===`shape`){let e=t.shape;if(e.kind===`path`)i.shape={...e,points:e.points.map(t=>d(t,e.view)),...e.subpaths?{subpaths:e.subpaths.map(t=>({...t,points:t.points.map(t=>d(t,e.view))}))}:{}};else if(e.kind===`line`)i.shape={kind:`line`,...e.flip?{}:{flip:!0}};else if(e.kind===`ellipse`&&(e.sweep??1)<1){let t=e.start??0,n=(e.sweep??1)*360,a=(((r===`x`?180:0)-t-n)%360+360)%360;i.shape={...e,...a?{start:a}:{}},a||delete i.shape.start}else if(e.kind===`rect`&&Array.isArray(t.radius)){let[e,n,a,o]=t.radius;i.radius=r===`x`?[n,e,o,a]:[o,a,n,e]}else e.kind===`polygon`&&r===`y`&&(i[a]=!t[a]||null);t.rotation&&(i.rotation=-t.rotation)}else i[a]=!t[a]||null,t.rotation&&(i.rotation=-t.rotation);let o=c[n];if(s&&o){let n=mn(e,t.id,r===`x`?{...o,x:l+u-(o.x+o.w)}:{...o,y:l+u-(o.y+o.h)});r===`x`?i.x=Math.round(n.x):i.y=Math.round(n.y)}return{op:`update`,id:t.id,set:i}}).filter(e=>Object.keys(e.set).length)}var U=Te(),er=/viewBox="([^"]+)"/.exec(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 220"><path d="M88 30L88 10C88 7.24 88.98 4.88 90.93 2.93C92.88 0.98 95.24 0 98 0L210 0C212.76 0 215.12 0.98 217.07 2.93C219.02 4.88 220 7.24 220 10L220 30C220 33.87 221.37 37.17 224.1 39.9C226.83 42.63 230.13 44 234 44L254 44C256.76 44 259.12 44.98 261.07 46.93C263.02 48.88 264 51.24 264 54L264 220L220 220L220 58C220 54.13 218.63 50.83 215.9 48.1C213.17 45.37 209.87 44 206 44L102 44C98.13 44 94.83 45.37 92.1 48.1C89.37 50.83 88 54.13 88 58L88 78C88 80.76 87.02 83.12 85.07 85.07C83.12 87.02 80.76 88 78 88L58 88C54.13 88 50.83 89.37 48.1 92.1C45.37 94.83 44 98.13 44 102L44 220L0 220L0 98C0 95.24 0.98 92.88 2.93 90.93C4.88 88.98 7.24 88 10 88L30 88C33.87 88 37.17 86.63 39.9 83.9C42.63 81.17 44 77.87 44 74L44 58C44 54.13 42.63 50.83 39.9 48.1C37.17 45.37 33.87 44 30 44L0 44L0 0L34 0C36.76 0 39.12 0.98 41.07 2.93C43.02 4.88 44 7.24 44 10L44 30C44 33.87 45.37 37.17 48.1 39.9C50.83 42.63 54.13 44 58 44L74 44C77.87 44 81.17 42.63 83.9 39.9C86.63 37.17 88 33.87 88 30Z" fill="#0C0F12"/></svg>
|
|
2
|
+
`)?.[1]??`0 0 264 220`,tr=/\sd="([^"]+)"/.exec(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 264 220"><path d="M88 30L88 10C88 7.24 88.98 4.88 90.93 2.93C92.88 0.98 95.24 0 98 0L210 0C212.76 0 215.12 0.98 217.07 2.93C219.02 4.88 220 7.24 220 10L220 30C220 33.87 221.37 37.17 224.1 39.9C226.83 42.63 230.13 44 234 44L254 44C256.76 44 259.12 44.98 261.07 46.93C263.02 48.88 264 51.24 264 54L264 220L220 220L220 58C220 54.13 218.63 50.83 215.9 48.1C213.17 45.37 209.87 44 206 44L102 44C98.13 44 94.83 45.37 92.1 48.1C89.37 50.83 88 54.13 88 58L88 78C88 80.76 87.02 83.12 85.07 85.07C83.12 87.02 80.76 88 78 88L58 88C54.13 88 50.83 89.37 48.1 92.1C45.37 94.83 44 98.13 44 102L44 220L0 220L0 98C0 95.24 0.98 92.88 2.93 90.93C4.88 88.98 7.24 88 10 88L30 88C33.87 88 37.17 86.63 39.9 83.9C42.63 81.17 44 77.87 44 74L44 58C44 54.13 42.63 50.83 39.9 48.1C37.17 45.37 33.87 44 30 44L0 44L0 0L34 0C36.76 0 39.12 0.98 41.07 2.93C43.02 4.88 44 7.24 44 10L44 30C44 33.87 45.37 37.17 48.1 39.9C50.83 42.63 54.13 44 58 44L74 44C77.87 44 81.17 42.63 83.9 39.9C86.63 37.17 88 33.87 88 30Z" fill="#0C0F12"/></svg>
|
|
3
|
+
`)?.[1]??``;function nr(){return(0,U.jsx)(`svg`,{className:`brand-mark`,viewBox:er,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:tr,fill:`currentColor`})})}var rr=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function ir(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:rr(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var ar=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},or=e=>{let t=ar(e);return t.charAt(0).toUpperCase()+t.slice(1)},sr=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),cr={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function lr(e){return e!=null}function ur(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??cr.width,a=e.size??e.height??cr.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?sr(...c):sr(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??cr[`stroke-width`])*Number(e.size??e.width??cr.width)/Number(t.size??t.width??cr.width):t.strokeWidth??cr[`stroke-width`];return[`svg`,{...Object.entries(cr).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&lr(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&lr(t.width)&&{[r(`width`)]:t.width},...`height`in t&&lr(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function dr(e,t={}){return ur(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var fr=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},pr=(0,H.createContext)({}),mr=()=>(0,H.useContext)(pr),hr=(0,H.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:g=!1,color:_=`currentColor`,className:v=``}=mr()??{},y=!!c||fr(d),[b,x,S=[]]=dr(u,{color:e??_,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??g,className:sr(v,s),hasA11yProp:y,attributes:d});return(0,H.createElement)(b,{ref:f,...x},[...S.map(([e,t])=>(0,H.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function W(e,t=[],n=[]){let r=typeof e==`string`?ir(e,t,n):e,i=(0,H.forwardRef)(({className:e,...t},n)=>(0,H.createElement)(hr,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=or(r.name)),i}var gr={name:`align-center-horizontal`,size:24,node:[[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4`,key:`11f1s0`}],[`path`,{d:`M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4`,key:`t14dx9`}],[`path`,{d:`M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1`,key:`1w07xs`}],[`path`,{d:`M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1`,key:`1apec2`}]]};gr.node;var _r=W(gr),vr={name:`align-center-vertical`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4`,key:`14d6g8`}],[`path`,{d:`M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4`,key:`1e2lrw`}],[`path`,{d:`M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1`,key:`1fkdwx`}],[`path`,{d:`M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1`,key:`1euafb`}]]};vr.node;var yr=W(vr),br={name:`align-end-horizontal`,size:24,node:[[`rect`,{width:`6`,height:`16`,x:`4`,y:`2`,rx:`2`,key:`z5wdxg`}],[`rect`,{width:`6`,height:`9`,x:`14`,y:`9`,rx:`2`,key:`um7a8w`}],[`path`,{d:`M22 22H2`,key:`19qnx5`}]]};br.node;var xr=W(br),Sr={name:`align-end-vertical`,size:24,node:[[`rect`,{width:`16`,height:`6`,x:`2`,y:`4`,rx:`2`,key:`10wcwx`}],[`rect`,{width:`9`,height:`6`,x:`9`,y:`14`,rx:`2`,key:`4p5bwg`}],[`path`,{d:`M22 22V2`,key:`12ipfv`}]]};Sr.node;var Cr=W(Sr),wr={name:`align-horizontal-distribute-center`,size:24,node:[[`rect`,{width:`6`,height:`14`,x:`4`,y:`5`,rx:`2`,key:`1wwnby`}],[`rect`,{width:`6`,height:`10`,x:`14`,y:`7`,rx:`2`,key:`1fe6j6`}],[`path`,{d:`M17 22v-5`,key:`4b6g73`}],[`path`,{d:`M17 7V2`,key:`hnrr36`}],[`path`,{d:`M7 22v-3`,key:`1r4jpn`}],[`path`,{d:`M7 5V2`,key:`liy1u9`}]]};wr.node;var Tr=W(wr),G={name:`align-start-horizontal`,size:24,node:[[`rect`,{width:`6`,height:`16`,x:`4`,y:`6`,rx:`2`,key:`1n4dg1`}],[`rect`,{width:`6`,height:`9`,x:`14`,y:`6`,rx:`2`,key:`17khns`}],[`path`,{d:`M22 2H2`,key:`fhrpnj`}]]};G.node;var K=W(G),Er={name:`align-start-vertical`,size:24,node:[[`rect`,{width:`9`,height:`6`,x:`6`,y:`14`,rx:`2`,key:`lpm2y7`}],[`rect`,{width:`16`,height:`6`,x:`6`,y:`4`,rx:`2`,key:`rdj6ps`}],[`path`,{d:`M2 2v20`,key:`1ivd8o`}]]};Er.node;var Dr=W(Er),Or={name:`align-vertical-distribute-center`,size:24,node:[[`path`,{d:`M22 17h-3`,key:`1lwga1`}],[`path`,{d:`M22 7h-5`,key:`o2endc`}],[`path`,{d:`M5 17H2`,key:`1gx9xc`}],[`path`,{d:`M7 7H2`,key:`6bq26l`}],[`rect`,{x:`5`,y:`14`,width:`14`,height:`6`,rx:`2`,key:`1qrzuf`}],[`rect`,{x:`7`,y:`4`,width:`10`,height:`6`,rx:`2`,key:`we8e9z`}]]};Or.node;var kr=W(Or),Ar={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};Ar.node;var jr=W(Ar),Mr={name:`arrow-right-from-line`,size:24,node:[[`path`,{d:`M3 5v14`,key:`1nt18q`}],[`path`,{d:`M21 12H7`,key:`13ipq5`}],[`path`,{d:`m15 18 6-6-6-6`,key:`6tx3qv`}]]};Mr.node;var Nr=W(Mr),Pr={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Pr.node;var Fr=W(Pr),Ir={name:`arrow-up-to-line`,size:24,node:[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]};Ir.node;var Lr=W(Ir),q={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};q.node;var Rr=W(q),zr={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};zr.node;var Br=W(zr),Vr={name:`calendar-days`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M12 13h.01`,key:`y0uutt`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M8 17h.01`,key:`p3bg7i`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M16 17h.01`,key:`ql8jdd`}]]};Vr.node;var Hr=W(Vr),Ur={name:`case-lower`,size:24,node:[[`path`,{d:`M10 9v7`,key:`ylp826`}],[`path`,{d:`M14 6v10`,key:`1jy4vg`}],[`circle`,{cx:`17.5`,cy:`12.5`,r:`3.5`,key:`1a9481`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`3.5`,key:`2jlv1r`}]]};Ur.node;var Wr=W(Ur),Gr={name:`case-sensitive`,size:24,node:[[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M22 9v7`,key:`pvm9v3`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}],[`circle`,{cx:`18.5`,cy:`12.5`,r:`3.5`,key:`z97x68`}]]};Gr.node;var Kr=W(Gr),qr={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};qr.node;var Jr=W(qr),Yr={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};Yr.node;var Xr=W(Yr),Zr={name:`chart-pie`,size:24,node:[[`path`,{d:`M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]],aliases:[`pie-chart`]};Zr.node;var Qr=W(Zr),$r={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};$r.node;var ei=W($r),ti={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};ti.node;var ni=W(ti),ri={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};ri.node;var ii=W(ri),ai={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};ai.node;var oi=W(ai),si={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};si.node;var ci=W(si),li={name:`chevrons-down`,size:24,node:[[`path`,{d:`m7 6 5 5 5-5`,key:`1lc07p`}],[`path`,{d:`m7 13 5 5 5-5`,key:`1d48rs`}]]};li.node;var ui=W(li),di={name:`chevrons-up`,size:24,node:[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]};di.node;var fi=W(di),pi={name:`chevrons-up-down`,size:24,node:[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]};pi.node;var mi=W(pi),hi={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};hi.node;var gi=W(hi),_i={name:`code-xml`,size:24,node:[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],aliases:[`code-2`]};_i.node;var vi=W(_i),yi={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};yi.node;var bi=W(yi),xi={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};xi.node;var Si=W(xi),Ci={name:`combine`,size:24,node:[[`path`,{d:`M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`1l7d7l`}],[`path`,{d:`M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`9955pe`}],[`path`,{d:`m7 15 3 3`,key:`4hkfgk`}],[`path`,{d:`m7 21 3-3H5a2 2 0 0 1-2-2v-2`,key:`1xljwe`}],[`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1cdgtw`}],[`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`,key:`zi3rio`}]]};Ci.node;var wi=W(Ci),Ti={name:`component`,size:24,node:[[`path`,{d:`M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1uwlt4`}],[`path`,{d:`M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z`,key:`10291m`}],[`path`,{d:`M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z`,key:`1tqoq1`}],[`path`,{d:`M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1x6lto`}]]};Ti.node;var Ei=W(Ti),Di={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};Di.node;var Oi=W(Di),ki={name:`corner-up-right`,size:24,node:[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M4 20v-7a4 4 0 0 1 4-4h12`,key:`1lu4f8`}]]};ki.node;var Ai=W(ki),ji={name:`crop`,size:24,node:[[`path`,{d:`M6 2v14a2 2 0 0 0 2 2h14`,key:`ron5a4`}],[`path`,{d:`M18 22V8a2 2 0 0 0-2-2H2`,key:`7s9ehn`}]]};ji.node;var Mi=W(ji),Ni={name:`diamond`,size:24,node:[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]};Ni.node;var Pi=W(Ni),Fi={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};Fi.node;var Ii=W(Fi),Li={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Li.node;var Ri=W(Li),zi={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};zi.node;var Bi=W(zi),Vi={name:`eye-closed`,size:24,node:[[`path`,{d:`m15 18-.722-3.25`,key:`1j64jw`}],[`path`,{d:`M2 8a10.645 10.645 0 0 0 20 0`,key:`1e7gxb`}],[`path`,{d:`m20 15-1.726-2.05`,key:`1cnuld`}],[`path`,{d:`m4 15 1.726-2.05`,key:`1dsqqd`}],[`path`,{d:`m9 18 .722-3.25`,key:`ypw2yx`}]]};Vi.node;var Hi=W(Vi),Ui={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Ui.node;var Wi=W(Ui),Gi={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};Gi.node;var Ki=W(Gi),qi={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};qi.node;var Ji=W(qi),Yi={name:`fold-vertical`,size:24,node:[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]};Yi.node;var Xi=W(Yi),Zi={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};Zi.node;var Qi=W(Zi),$i={name:`frame`,size:24,node:[[`line`,{x1:`22`,x2:`2`,y1:`6`,y2:`6`,key:`15w7dq`}],[`line`,{x1:`22`,x2:`2`,y1:`18`,y2:`18`,key:`1ip48p`}],[`line`,{x1:`6`,x2:`6`,y1:`2`,y2:`22`,key:`a2lnyx`}],[`line`,{x1:`18`,x2:`18`,y1:`2`,y2:`22`,key:`8vb6jd`}]]};$i.node;var ea=W($i),ta={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};ta.node;var na=W(ta),ra={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};ra.node;var ia=W(ra),aa={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};aa.node;var oa=W(aa),sa={name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]};sa.node;var ca=W(sa),la={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};la.node;var ua=W(la),da={name:`import`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m8 11 4 4 4-4`,key:`1dohi6`}],[`path`,{d:`M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4`,key:`1ywtjm`}]]};da.node;var fa=W(da),pa={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};pa.node;var ma=W(pa),ha={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};ha.node;var ga=W(ha),_a={name:`library`,size:24,node:[[`path`,{d:`m16 6 4 14`,key:`ji33uf`}],[`path`,{d:`M12 6v14`,key:`1n7gus`}],[`path`,{d:`M8 8v12`,key:`1gg7y9`}],[`path`,{d:`M4 4v16`,key:`6qkkli`}]]};_a.node;var J=W(_a),va={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};va.node;var ya=W(va),ba={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};ba.node;var xa=W(ba),Sa={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};Sa.node;var Ca=W(Sa),wa={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};wa.node;var Ta=W(wa),Ea={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};Ea.node;var Da=W(Ea),Oa={name:`message-circle`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]};Oa.node;var ka=W(Oa),Aa={name:`minimize-2`,size:24,node:[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]};Aa.node;var ja=W(Aa),Ma={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Ma.node;var Na=W(Ma),Pa={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};Pa.node;var Fa=W(Pa),Ia={name:`mouse-pointer-2`,size:24,node:[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]};Ia.node;var La=W(Ia),Ra={name:`panel-left`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]],aliases:[`sidebar`]};Ra.node;var za=W(Ra),Ba={name:`panel-right`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]};Ba.node;var Va=W(Ba),Ha={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};Ha.node;var Ua=W(Ha),Wa={name:`pen-tool`,size:24,node:[[`path`,{d:`m18 13-.654-4.736a4 4 0 00-2.756-3.266l-9.163-2.9a2 2 0 00-2.017.493l-.82.819a2 2 0 00-.492 2.017l2.9 9.163a4 4 0 003.266 2.756L13 18`,key:`93nyr4`}],[`path`,{d:`M18.648 12.352a1.205 1.205 0 011.704 0l1.296 1.296a1.205 1.205 0 010 1.704l-6.296 6.296a1.205 1.205 0 01-1.704 0l-1.296-1.296a1.205 1.205 0 010-1.704z`,key:`lnux7s`}],[`path`,{d:`m3 3 6.586 6.586`,key:`1igwcn`}],[`circle`,{cx:`11`,cy:`11`,r:`2`,key:`xmgehs`}]]};Wa.node;var Ga=W(Wa),Ka={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};Ka.node;var qa=W(Ka),Ja={name:`pin`,size:24,node:[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]};Ja.node;var Ya=W(Ja),Xa={name:`pipette`,size:24,node:[[`path`,{d:`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`,key:`1y3wsu`}],[`path`,{d:`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`,key:`110lr1`}],[`path`,{d:`m2 22 .414-.414`,key:`jhxm08`}]]};Xa.node;var Za=W(Xa),Qa={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Qa.node;var $a=W(Qa),eo={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};eo.node;var to=W(eo),no={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};no.node;var ro=W(no),io={name:`refresh-cw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]};io.node;var ao=W(io),oo={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};oo.node;var so=W(oo),co={name:`rows-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]],aliases:[`rows`]};co.node;var lo=W(co),uo={name:`ruler`,size:24,node:[[`path`,{d:`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`,key:`icamh8`}],[`path`,{d:`m14.5 12.5 2-2`,key:`inckbg`}],[`path`,{d:`m11.5 9.5 2-2`,key:`fmmyf7`}],[`path`,{d:`m8.5 6.5 2-2`,key:`vc6u1g`}],[`path`,{d:`m17.5 15.5 2-2`,key:`wo5hmg`}]]};uo.node;var fo=W(uo),po={name:`scaling`,size:24,node:[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M14 15H9v-5`,key:`pi4jk9`}],[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M21 3 9 15`,key:`15kdhq`}]]};po.node;var mo=W(po),ho={name:`scan`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}]]};ho.node;var go=W(ho),_o={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};_o.node;var vo=W(_o),yo={name:`settings`,size:24,node:[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};yo.node;var bo=W(yo),xo={name:`shapes`,size:24,node:[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]};xo.node;var So=W(xo),Co={name:`share`,size:24,node:[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]};Co.node;var wo=W(Co),To={name:`shrink`,size:24,node:[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]};To.node;var Eo=W(To),Do={name:`slash`,size:24,node:[[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}]]};Do.node;var Oo=W(Do),ko={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};ko.node;var Ao=W(ko),jo={name:`sliders-vertical`,size:24,node:[[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M12 21v-9`,key:`17s77i`}],[`path`,{d:`M12 8V3`,key:`13r4qs`}],[`path`,{d:`M17 16h4`,key:`h1uq16`}],[`path`,{d:`M19 12V3`,key:`o1uvq1`}],[`path`,{d:`M19 21v-5`,key:`qua636`}],[`path`,{d:`M3 14h4`,key:`bcjad9`}],[`path`,{d:`M5 10V3`,key:`cb8scm`}],[`path`,{d:`M5 21v-7`,key:`1w1uti`}]],aliases:[`sliders`]};jo.node;var Mo=W(jo),No={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};No.node;var Po=W(No),Fo={name:`sparkle`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}]]};Fo.node;var Io=W(Fo),Lo={name:`spline`,size:24,node:[[`circle`,{cx:`19`,cy:`5`,r:`2`,key:`mhkx31`}],[`circle`,{cx:`5`,cy:`19`,r:`2`,key:`v8kfzx`}],[`path`,{d:`M5 17A12 12 0 0 1 17 5`,key:`1okkup`}]]};Lo.node;var Ro=W(Lo),zo={name:`square-arrow-up-left`,size:24,node:[[`path`,{d:`M15 15 9 9`,key:`qb9ybb`}],[`path`,{d:`M9 15V9h6`,key:`1pdr5l`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`arrow-up-left-square`]};zo.node;var Bo=W(zo),Vo={name:`square-dashed`,size:24,node:[[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M21 19a2 2 0 0 1-2 2`,key:`1j7049`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h1`,key:`15o7lz`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M14 21h1`,key:`v9vybs`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v1`,key:`mxsmne`}],[`path`,{d:`M3 14v1`,key:`vnatye`}],[`path`,{d:`M21 14v1`,key:`169vum`}]],aliases:[`box-select`]};Vo.node;var Ho=W(Vo),Uo={name:`square-menu`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 8h10`,key:`1jw688`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]],aliases:[`menu-square`]};Uo.node;var Wo=W(Uo),Go={name:`square-round-corner`,size:24,node:[[`path`,{d:`M21 11a8 8 0 0 0-8-8`,key:`1lxwo5`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1dv2y5`}]]};Go.node;var Ko=W(Go),qo={name:`square-split-horizontal`,size:24,node:[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3`,key:`saxlbk`}],[`path`,{d:`M8 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3`,key:`m1vog4`}]],aliases:[`split-square-horizontal`]};qo.node;var Jo=W(qo),Yo={name:`square-square`,size:24,node:[[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Yo.node;var Xo=W(Yo),Zo={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};Zo.node;var Qo=W(Zo),$o={name:`squares-exclude`,size:24,node:[[`path`,{d:`M16 12v2a2 2 0 0 1-2 2H9a1 1 0 0 0-1 1v3a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2h0`,key:`1mcohs`}],[`path`,{d:`M4 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v3a1 1 0 0 1-1 1h-5a2 2 0 0 0-2 2v2`,key:`1r1efp`}]]};$o.node;var es=W($o),ts={name:`squares-intersect`,size:24,node:[[`path`,{d:`M10 22a2 2 0 0 1-2-2`,key:`i7yj1i`}],[`path`,{d:`M14 2a2 2 0 0 1 2 2`,key:`170a0m`}],[`path`,{d:`M16 22h-2`,key:`18d249`}],[`path`,{d:`M2 10V8`,key:`7yj4fe`}],[`path`,{d:`M2 4a2 2 0 0 1 2-2`,key:`ddgnws`}],[`path`,{d:`M20 8a2 2 0 0 1 2 2`,key:`1770vt`}],[`path`,{d:`M22 14v2`,key:`iot8ja`}],[`path`,{d:`M22 20a2 2 0 0 1-2 2`,key:`qj8q6g`}],[`path`,{d:`M4 16a2 2 0 0 1-2-2`,key:`1dnafg`}],[`path`,{d:`M8 10a2 2 0 0 1 2-2h5a1 1 0 0 1 1 1v5a2 2 0 0 1-2 2H9a1 1 0 0 1-1-1z`,key:`ci6f0b`}],[`path`,{d:`M8 2h2`,key:`1gmkwm`}]]};ts.node;var ns=W(ts),rs={name:`squares-subtract`,size:24,node:[[`path`,{d:`M10 22a2 2 0 0 1-2-2`,key:`i7yj1i`}],[`path`,{d:`M16 22h-2`,key:`18d249`}],[`path`,{d:`M16 4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-5a2 2 0 0 1 2-2h5a1 1 0 0 0 1-1z`,key:`1njgbb`}],[`path`,{d:`M20 8a2 2 0 0 1 2 2`,key:`1770vt`}],[`path`,{d:`M22 14v2`,key:`iot8ja`}],[`path`,{d:`M22 20a2 2 0 0 1-2 2`,key:`qj8q6g`}]]};rs.node;var is=W(rs),as={name:`squares-unite`,size:24,node:[[`path`,{d:`M4 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v3a1 1 0 0 0 1 1h3a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2v-3a1 1 0 0 0-1-1z`,key:`17jnth`}]]};as.node;var os=W(as),ss={name:`strikethrough`,size:24,node:[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]};ss.node;var cs=W(ss),ls={name:`swatch-book`,size:24,node:[[`path`,{d:`M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z`,key:`1ldrpk`}],[`path`,{d:`M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7`,key:`11i5po`}],[`path`,{d:`M 7 17h.01`,key:`1euzgo`}],[`path`,{d:`m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8`,key:`o2gii7`}]]};ls.node;var us=W(ls),ds={name:`tablet`,size:24,node:[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]};ds.node;var fs=W(ds),ps={name:`text-align-center`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]],aliases:[`align-center`]};ps.node;var ms=W(ps),hs={name:`text-align-end`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]],aliases:[`align-right`]};hs.node;var gs=W(hs),_s={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};_s.node;var vs=W(_s),ys={name:`text-wrap`,size:24,node:[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]],aliases:[`wrap-text`]};ys.node;var bs=W(ys),xs={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};xs.node;var Ss=W(xs),Cs={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Cs.node;var ws=W(Cs),Ts={name:`triangle`,size:24,node:[[`path`,{d:`M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z`,key:`14u9p9`}]]};Ts.node;var Es=W(Ts),Ds={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Ds.node;var Os=W(Ds),ks={name:`underline`,size:24,node:[[`path`,{d:`M6 4v6a6 6 0 0 0 12 0V4`,key:`9kb039`}],[`line`,{x1:`4`,x2:`20`,y1:`20`,y2:`20`,key:`nun2al`}]]};ks.node;var As=W(ks),js={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};js.node;var Ms=W(js),Ns={name:`unlink`,size:24,node:[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]};Ns.node;var Ps=W(Ns),Fs={name:`upload`,size:24,node:[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]};Fs.node;var Is=W(Fs),Ls={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};Ls.node;var Rs=W(Ls),zs={name:`volume-2`,size:24,node:[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]};zs.node;var Bs=W(zs),Vs={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};Vs.node;var Hs=W(Vs),Us={name:`wand-sparkles`,size:24,node:[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]],aliases:[`wand-2`]};Us.node;var Ws=W(Us),Gs={name:`waves-horizontal`,size:24,node:[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]],aliases:[`waves`]};Gs.node;var Ks=W(Gs),qs={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};qs.node;var Js=W(qs),Ys={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};Ys.node;var Xs=W(Ys),Y=({icon:e})=>(0,U.jsx)(e,{size:16,strokeWidth:1.25,absoluteStrokeWidth:!0,"aria-hidden":!0}),Zs=({children:e,title:t})=>(0,U.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!t,role:t?`img`:void 0,children:[t&&(0,U.jsx)(`title`,{children:t}),e]}),X={frame:()=>(0,U.jsx)(Y,{icon:ea}),component:()=>(0,U.jsx)(Y,{icon:Ei}),instance:()=>(0,U.jsx)(Y,{icon:Pi}),branch:()=>(0,U.jsx)(Y,{icon:na}),play:()=>(0,U.jsx)(Y,{icon:$a}),pause:()=>(0,U.jsx)(Y,{icon:Ua}),volume:()=>(0,U.jsx)(Y,{icon:Bs}),volumeOff:()=>(0,U.jsx)(Y,{icon:Hs}),group:()=>(0,U.jsx)(Y,{icon:Ho}),row:()=>(0,U.jsx)(Y,{icon:bi}),column:()=>(0,U.jsx)(Y,{icon:lo}),text:()=>(0,U.jsx)(Y,{icon:Os}),vector:()=>(0,U.jsx)(Y,{icon:So}),rect:()=>(0,U.jsx)(Y,{icon:Qo}),rotate:()=>(0,U.jsx)(Y,{icon:so}),ellipse:()=>(0,U.jsx)(Y,{icon:gi}),arc:()=>(0,U.jsx)(Y,{icon:Qr}),line:()=>(0,U.jsx)(Y,{icon:Oo}),polygon:()=>(0,U.jsx)(Y,{icon:Es}),pen:()=>(0,U.jsx)(Y,{icon:Ga}),path:()=>(0,U.jsx)(Y,{icon:Ro}),flatten:()=>(0,U.jsx)(Y,{icon:wi}),media:()=>(0,U.jsx)(Y,{icon:ca}),boolUnion:()=>(0,U.jsx)(Y,{icon:os}),boolSubtract:()=>(0,U.jsx)(Y,{icon:is}),boolIntersect:()=>(0,U.jsx)(Y,{icon:ns}),boolExclude:()=>(0,U.jsx)(Y,{icon:es}),move:()=>(0,U.jsx)(Y,{icon:La}),scale:()=>(0,U.jsx)(Y,{icon:mo}),ratio:()=>(0,U.jsx)(Y,{icon:ya}),eye:()=>(0,U.jsx)(Y,{icon:Ki}),eyeOff:()=>(0,U.jsx)(Y,{icon:Wi}),lock:()=>(0,U.jsx)(Y,{icon:Ta}),unlock:()=>(0,U.jsx)(Y,{icon:Ca}),folder:()=>(0,U.jsx)(Y,{icon:Qi}),sidebar:()=>(0,U.jsx)(Y,{icon:za}),radius:()=>(0,U.jsx)(Y,{icon:Ko}),corners:()=>(0,U.jsx)(Y,{icon:go}),corner:()=>(0,U.jsx)(Zs,{children:(0,U.jsx)(`path`,{d:`M4 12V7.5A3.5 3.5 0 0 1 7.5 4H12`})}),sidebarRight:()=>(0,U.jsx)(Y,{icon:Va}),beside:()=>(0,U.jsx)(Y,{icon:Jo}),undo:()=>(0,U.jsx)(Y,{icon:Ms}),download:()=>(0,U.jsx)(Y,{icon:Ii}),back:()=>(0,U.jsx)(Y,{icon:ii}),reply:()=>(0,U.jsx)(Y,{icon:Ai}),forward:()=>(0,U.jsx)(Y,{icon:ci}),reload:()=>(0,U.jsx)(Y,{icon:ao}),external:()=>(0,U.jsx)(Y,{icon:Bi}),copy:()=>(0,U.jsx)(Y,{icon:Oi}),code:()=>(0,U.jsx)(Y,{icon:vi}),warn:()=>(0,U.jsx)(Y,{icon:ws}),zap:()=>(0,U.jsx)(Y,{icon:Xs}),close:()=>(0,U.jsx)(Y,{icon:Js}),globe:()=>(0,U.jsx)(Y,{icon:ia}),comment:()=>(0,U.jsx)(Y,{icon:ka}),check:()=>(0,U.jsx)(Y,{icon:ei}),trash:()=>(0,U.jsx)(Y,{icon:Ss}),fit:()=>(0,U.jsx)(Y,{icon:Eo}),sparkle:()=>(0,U.jsx)(Y,{icon:Io}),polish:()=>(0,U.jsx)(Y,{icon:Ws}),rename:()=>(0,U.jsx)(Y,{icon:qa}),shader:()=>(0,U.jsx)(Y,{icon:Ks}),arrowUp:()=>(0,U.jsx)(Y,{icon:Rr}),stop:()=>(0,U.jsx)(Y,{icon:Qo}),plus:()=>(0,U.jsx)(Y,{icon:ro}),popOut:()=>(0,U.jsx)(Y,{icon:Bo}),eyeClosed:()=>(0,U.jsx)(Y,{icon:Hi}),chevronUp:()=>(0,U.jsx)(Y,{icon:oi}),foldUp:()=>(0,U.jsx)(Y,{icon:fi}),foldDown:()=>(0,U.jsx)(Y,{icon:ui}),importPage:()=>(0,U.jsx)(Y,{icon:Ii}),importFile:()=>(0,U.jsx)(Y,{icon:fa}),exportFile:()=>(0,U.jsx)(Y,{icon:wo}),library:()=>(0,U.jsx)(Y,{icon:J}),alignLeft:()=>(0,U.jsx)(Y,{icon:Dr}),alignHCenter:()=>(0,U.jsx)(Y,{icon:yr}),alignRight:()=>(0,U.jsx)(Y,{icon:Cr}),alignTop:()=>(0,U.jsx)(Y,{icon:K}),alignVCenter:()=>(0,U.jsx)(Y,{icon:_r}),alignBottom:()=>(0,U.jsx)(Y,{icon:xr}),distH:()=>(0,U.jsx)(Y,{icon:Tr}),distV:()=>(0,U.jsx)(Y,{icon:kr}),lineHeight:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M2.5 2.5h11M2.5 13.5h11`}),(0,U.jsx)(`path`,{d:`M6 11l2-6 2 6M6.7 9h2.6`})]}),letterSpacing:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M2.5 3v10M13.5 3v10`}),(0,U.jsx)(`path`,{d:`M6 11l2-6 2 6M6.7 9h2.6`})]}),minus:()=>(0,U.jsx)(Y,{icon:Na}),paintSolid:()=>(0,U.jsx)(Y,{icon:Xo}),paintRadial:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.1`}),(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3.4`,strokeDasharray:`1 1.6`})]}),paintGradient:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,U.jsx)(`path`,{d:`M5.5 5.5h1M9.5 5.5h1M7.5 7.5h1M5.5 9.5h1M9.5 9.5h1M7.5 11.5h1`,strokeWidth:`1.6`})]}),upload:()=>(0,U.jsx)(Y,{icon:Is}),settings:()=>(0,U.jsx)(Y,{icon:bo}),eyedropper:()=>(0,U.jsx)(Y,{icon:Za}),image:()=>(0,U.jsx)(Y,{icon:ua}),strokeSides:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`rect`,{x:`5`,y:`5`,width:`6`,height:`6`,rx:`0.5`})]}),strokeTop:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M3 3.25h10`,strokeWidth:`2`}),(0,U.jsx)(`path`,{d:`M3 6v7h10V6`,strokeDasharray:`1.5 1.5`})]}),strokeRight:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M12.75 3v10`,strokeWidth:`2`}),(0,U.jsx)(`path`,{d:`M10 3H3v10h7`,strokeDasharray:`1.5 1.5`})]}),strokeBottom:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M3 12.75h10`,strokeWidth:`2`}),(0,U.jsx)(`path`,{d:`M3 10V3h10v7`,strokeDasharray:`1.5 1.5`})]}),strokeLeft:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M3.25 3v10`,strokeWidth:`2`}),(0,U.jsx)(`path`,{d:`M6 3h7v10H6`,strokeDasharray:`1.5 1.5`})]}),strokeWeight:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`path`,{d:`M3 4h10`,strokeWidth:`1`}),(0,U.jsx)(`path`,{d:`M3 8h10`,strokeWidth:`1.6`}),(0,U.jsx)(`path`,{d:`M3 12.25h10`,strokeWidth:`2.3`})]}),grid:()=>(0,U.jsx)(Y,{icon:Si}),viewGrid:()=>(0,U.jsx)(Y,{icon:ga}),viewList:()=>(0,U.jsx)(Y,{icon:xa}),ruler:()=>(0,U.jsx)(Y,{icon:fo}),underline:()=>(0,U.jsx)(Y,{icon:As}),caseUpper:()=>(0,U.jsx)(Y,{icon:Jr}),caseLower:()=>(0,U.jsx)(Y,{icon:Wr}),caseTitle:()=>(0,U.jsx)(Y,{icon:Kr}),strikethrough:()=>(0,U.jsx)(Y,{icon:cs}),crop:()=>(0,U.jsx)(Y,{icon:Mi}),textLeft:()=>(0,U.jsx)(Y,{icon:vs}),textCenter:()=>(0,U.jsx)(Y,{icon:ms}),textRight:()=>(0,U.jsx)(Y,{icon:gs}),vTop:()=>(0,U.jsx)(Y,{icon:Lr}),vMiddle:()=>(0,U.jsx)(Y,{icon:Xi}),vBottom:()=>(0,U.jsx)(Y,{icon:jr}),styles:()=>(0,U.jsx)(Y,{icon:us}),detach:()=>(0,U.jsx)(Y,{icon:Ps}),chevronDown:()=>(0,U.jsx)(Y,{icon:ni}),chevronsUpDown:()=>(0,U.jsx)(Y,{icon:mi}),sliders:()=>(0,U.jsx)(Y,{icon:Mo}),search:()=>(0,U.jsx)(Y,{icon:vo}),padLeft:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`path`,{d:`M5.5 5v6`})]}),padRight:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`path`,{d:`M10.5 5v6`})]}),padTop:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`path`,{d:`M5 5.5h6`})]}),padBottom:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`path`,{d:`M5 10.5h6`})]}),padH:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`path`,{d:`M5.5 5v6M10.5 5v6`})]}),padV:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`1.5`}),(0,U.jsx)(`path`,{d:`M5 5.5h6M5 10.5h6`})]}),padAll:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`11`,height:`11`,rx:`2`}),(0,U.jsx)(`rect`,{x:`5.5`,y:`5.5`,width:`5`,height:`5`,rx:`1`})]}),gapH:()=>(0,U.jsx)(Zs,{children:(0,U.jsx)(`path`,{d:`M3 3v10M13 3v10M8 6v4`})}),gapV:()=>(0,U.jsx)(Zs,{children:(0,U.jsx)(`path`,{d:`M3 3h10M3 13h10M6 8h4`})}),more:()=>(0,U.jsx)(Y,{icon:Ri}),grip:()=>(0,U.jsx)(Y,{icon:oa}),layoutFree:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`3`,width:`4`,height:`4`,rx:`1`}),(0,U.jsx)(`rect`,{x:`9.5`,y:`2.5`,width:`4`,height:`3.5`,rx:`1`}),(0,U.jsx)(`rect`,{x:`5`,y:`9.5`,width:`4`,height:`4`,rx:`1`})]}),layoutV:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`5`,height:`3.5`,rx:`1`}),(0,U.jsx)(`rect`,{x:`2.5`,y:`8`,width:`5`,height:`3.5`,rx:`1`}),(0,U.jsx)(`path`,{d:`M11.5 3v9.5M9.5 10.5l2 2 2-2`})]}),layoutH:()=>(0,U.jsxs)(Zs,{children:[(0,U.jsx)(`rect`,{x:`2.5`,y:`3`,width:`4`,height:`4`,rx:`1`}),(0,U.jsx)(`rect`,{x:`9.5`,y:`3`,width:`4`,height:`4`,rx:`1`}),(0,U.jsx)(`path`,{d:`M3 11.5h9.5M10.5 9.5l2 2-2 2`})]}),wrap:()=>(0,U.jsx)(Y,{icon:bs}),autoWidth:()=>(0,U.jsx)(Y,{icon:Nr}),fixedText:()=>(0,U.jsx)(Y,{icon:Wo}),constraintH:()=>(0,U.jsx)(Zs,{children:(0,U.jsx)(`path`,{d:`M3 5v6M13 5v6M3 8h10`})}),constraintV:()=>(0,U.jsx)(Zs,{children:(0,U.jsx)(`path`,{d:`M5 3h6M5 13h6M8 3v10`})}),pin:()=>(0,U.jsx)(Y,{icon:Ya}),adjust:()=>(0,U.jsx)(Y,{icon:Ao}),expand:()=>(0,U.jsx)(Y,{icon:Da}),collapse:()=>(0,U.jsx)(Y,{icon:ja}),monitor:()=>(0,U.jsx)(Y,{icon:Fa}),tablet:()=>(0,U.jsx)(Y,{icon:fs}),phone:()=>(0,U.jsx)(Y,{icon:Po}),plug:()=>(0,U.jsx)(Y,{icon:to}),caret:()=>(0,U.jsx)(Y,{icon:ci})},Qs=e=>e&&{tagName:e.tagName,type:e.type,isContentEditable:e.isContentEditable,role:e.getAttribute?.(`role`)},$s=new Set([``,`text`,`search`,`url`,`tel`,`email`,`password`,`number`,`date`,`datetime-local`,`month`,`time`,`week`]),ec=new Set([`button`,`radio`,`tab`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`switch`,`slider`,`checkbox`,`link`,`combobox`,`option`]),tc=new Set([`radio`,`tab`,`menuitem`,`menuitemcheckbox`,`menuitemradio`,`slider`]),nc=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`]),rc=e=>e.tagName===`BUTTON`||e.tagName===`A`||e.tagName===`SUMMARY`||!!e.role&&ec.has(e.role),ic=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`]),ac=e=>ic.has(e);function oc(e,t){if(!e)return!0;if(e.isContentEditable||e.tagName===`TEXTAREA`)return!1;if(e.tagName===`SELECT`)return(t.metaKey||t.ctrlKey)&&(t.code===`KeyZ`||t.key.toLowerCase()===`z`);let n=t.metaKey||t.ctrlKey;if(e.tagName!==`INPUT`)return n||!rc(e)?!0:!(t.key===`Tab`||t.key===`Enter`||t.code===`Space`||e.role&&tc.has(e.role)&&(nc.has(t.key)||e.role===`slider`&&ac(t.key)));let r=(e.type??``).toLowerCase();return!($s.has(r)||t.code===`Space`||t.key===`Enter`||t.key===`Tab`&&!n||r===`range`&&ac(t.key)||r===`radio`&&t.key.startsWith(`Arrow`))}function sc(e){return/^[a-z]$/i.test(e.key)?`Key${e.key.toUpperCase()}`:e.code}function cc(e){let t=sc(e);return/^Key[A-Z]$/.test(t)?t.slice(3).toLowerCase():e.key.toLowerCase()}var lc=new Set([`ArrowRight`,`ArrowDown`]),uc=new Set([`ArrowLeft`,`ArrowUp`]);function dc(e,t,n){return n<=0?null:lc.has(e)?(t+1)%n:uc.has(e)?(t-1+n)%n:e===`Home`?0:e===`End`?n-1:null}function fc(e,t){let n=e.getAttribute(`role`);if(n!==`radio`&&n!==`tab`)return!1;let r=`[role="radiogroup"], [role="tablist"]`,i=e.closest(r),a=i??e.parentElement;if(!a)return!1;let o=[...a.querySelectorAll(`[role="${n}"]`)].filter(e=>!e.disabled&&e.closest(r)===i),s=dc(t,o.indexOf(e),o.length);return s===null||!o[s]?!1:(o[s].focus(),n===`radio`&&o[s].click(),!0)}var pc=class extends H.Component{state={error:null,key:this.props.resetKey};static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return e.resetKey===t.key?null:{error:null,key:e.resetKey}}componentDidCatch(e){console.error(e)}render(){return this.state.error?this.props.fallback(()=>this.setState({error:null})):this.props.children}},mc=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)});function hc(e,t,n){let r=mc(e,t);return n?r.w>=1?{x:r.x,y:r.y,w:r.w}:{x:r.x,y:r.y}:{x:e.x,y:e.y}}var gc=class{id;version;send;onVersion;tail=Promise.resolve();constructor(e,t,n,r){this.id=e,this.version=t,this.send=n,this.onVersion=r}fold(e,t){return this.queue(async n=>{let r=await this.send(e,t,n);r!==void 0&&(this.version=r,this.onVersion?.(r))})}queue(e){let t=this.tail.then(()=>e(this.version));return this.tail=t.catch(()=>void 0),t}},_c=`nudge.newText`;function vc(e){if(!e)return null;try{let t=JSON.parse(e);return typeof t.id==`string`&&typeof t.version==`number`?{id:t.id,version:t.version}:null}catch{return null}}function yc(e,t){let n=t?e.nodes[t.id]:void 0;return t&&n?.type===`text`&&n.content===``?t.version:null}function bc(e){return e===``?`discard`:`keep`}function xc(e,t){return t?`take-back`:e.content?e.inInstance?`keep`:`delete`:`remove`}function Sc(e,t,n,r){let i=new Set([t,n]);for(let r of e??[])r.start>t&&r.start<n&&i.add(r.start),r.end>t&&r.end<n&&i.add(r.end);let a=[...i].sort((e,t)=>e-t);for(let t=0;t<a.length-1;t++){let n=a[t];if(!r((e??[]).find(e=>e.start<=n&&e.end>n)))return!1}return!0}function Cc(e,t,n,r,i){if(!e.meta||e.alt)return null;if(e.code===`KeyB`&&!e.shift)return{label:`Bold`,patch:{fontWeight:Sc(n,r,i,e=>(e?.fontWeight??t.fontWeight)>=600)?400:700}};if(e.code===`KeyI`&&!e.shift)return{label:`Italic`,patch:{fontStyle:Sc(n,r,i,e=>(e?.fontStyle??t.fontStyle)===`italic`)?t.fontStyle===`italic`?`normal`:null:`italic`}};let a=e.code===`KeyU`&&!e.shift?`underline`:e.code===`KeyX`&&e.shift?`line-through`:null;if(a){let e=Sc(n,r,i,e=>(e?.textDecoration??t.textDecoration)===a);return{label:a===`underline`?`Underline`:`Strikethrough`,patch:{textDecoration:e?t.textDecoration===a?`none`:null:a}}}return null}var wc={done:0,undone:0,text:``},Tc=(e,t)=>({done:e.done+1,undone:0,text:t});function Ec(e,t,n){return!e.meta||e.alt||e.code!==`KeyZ`||n!==t.text?null:!e.shift&&t.done>0?{kind:`undo`,next:{...t,done:t.done-1,undone:t.undone+1}}:e.shift&&t.undone>0?{kind:`redo`,next:{...t,done:t.done+1,undone:t.undone-1}}:null}var Dc=[void 0],Oc=(e,t,n)=>[...e.slice(0,t+1),n];function kc(e,t){if(!e)return()=>{};let n=!0,r=()=>{n&&t()};return e.ready.then(r,()=>{}),e.addEventListener(`loadingdone`,r),()=>{n=!1,e.removeEventListener(`loadingdone`,r)}}var Ac=`nudge.theme`,jc=()=>matchMedia(`(prefers-color-scheme: dark)`);function Mc(){try{let e=localStorage.getItem(Ac);return e===`light`||e===`dark`?e:`system`}catch{return`system`}}var Nc=e=>e===`system`?jc().matches?`dark`:`light`:e;function Pc(e=document){e.documentElement.dataset.theme=Nc(Mc())}function Fc(e){try{e===`system`?localStorage.removeItem(Ac):localStorage.setItem(Ac,e)}catch{}Pc(),dispatchEvent(new CustomEvent(`nudge-theme`))}function Ic(){Pc(),jc().addEventListener(`change`,()=>{Pc(),dispatchEvent(new CustomEvent(`nudge-theme`))}),addEventListener(`storage`,e=>{e.key===Ac&&(Pc(),dispatchEvent(new CustomEvent(`nudge-theme`)))})}function Lc(){let e=()=>({pref:Mc(),theme:Nc(Mc())}),[t,n]=(0,H.useState)(e);return(0,H.useEffect)(()=>{let t=()=>n(e());return addEventListener(`nudge-theme`,t),()=>removeEventListener(`nudge-theme`,t)},[]),t}var Rc=[{id:`rect`,label:`Rectangle`,key:`r`,hint:`R`},{id:`line`,label:`Line`,key:`l`,hint:`L`},{id:`ellipse`,label:`Ellipse`,key:`o`,hint:`O`},{id:`polygon`,label:`Polygon`,key:``,hint:``}],zc={rect:`Rectangle`,ellipse:`Ellipse`,line:`Line`,polygon:`Polygon`,path:`Path`},Bc={union:`Union`,subtract:`Subtract`,intersect:`Intersect`,exclude:`Exclude`},Vc=[{op:`union`,label:`Union selection`,kbd:`⌥⇧U`,code:`KeyU`},{op:`subtract`,label:`Subtract selection`,kbd:`⌥⇧S`,code:`KeyS`},{op:`intersect`,label:`Intersect selection`,kbd:`⌥⇧I`,code:`KeyI`},{op:`exclude`,label:`Exclude selection`,kbd:`⌥⇧E`,code:`KeyE`}];function Hc({kind:e}){let t={rect:X.rect,ellipse:X.ellipse,line:X.line,polygon:X.polygon,path:X.path}[e];return(0,U.jsx)(t,{})}function Uc({op:e}){let t={union:X.boolUnion,subtract:X.boolSubtract,intersect:X.boolIntersect,exclude:X.boolExclude}[e];return(0,U.jsx)(t,{})}function Wc(e,t,n,r,i,a){let o=e=>Math.round(e);if(e===`line`){let e=a.click?{x:r.x+100,y:r.y}:i;a.square&&!a.click&&(e=Gc(r,e));let s=$e(r,e);return[{op:`create`,parent:n,tree:{type:`shape`,id:t,key:`new`,x:o(s.x),y:o(s.y),w:o(s.w),h:o(s.h),shape:s.shape,stroke:{color:fe,width:1}}}]}let s=Math.abs(i.x-r.x),c=Math.abs(i.y-r.y);a.square&&(s=c=Math.max(s,c)),a.click&&(s=c=100);let l=a.click||i.x>=r.x?r.x:r.x-s,u=a.click||i.y>=r.y?r.y:r.y-c,d=e===`polygon`?{kind:`polygon`,count:3}:{kind:e};return[{op:`create`,parent:n,tree:{type:`shape`,id:t,key:`new`,x:o(l),y:o(u),w:Math.max(1,o(s)),h:Math.max(1,o(c)),shape:d,fill:C}}]}function Gc(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y),r=Math.round(Math.atan2(t.y-e.y,t.x-e.x)/(Math.PI/4))*(Math.PI/4);return{x:e.x+Math.cos(r)*n,y:e.y+Math.sin(r)*n}}function Kc(e,t){if(t.length<2)return!1;let n=e.nodes[t[0]]?.parent;return t.every(t=>{let r=e.nodes[t];return!!r&&r.parent===n&&(r.type===`shape`||r.type===`frame`&&!!r.boolean)})}function qc(e,t){if(t.length<2||Kc(e,t))return null;let n=t.map(t=>e.nodes[t]).filter(e=>!!e);if(n.some(e=>e.parent!==n[0].parent))return`Boolean groups need layers in the same parent`;let r=n.filter(e=>!(e.type===`shape`||e.type===`frame`&&e.boolean));return r.some(e=>e.type===`vector`)?`Boolean groups combine shapes: icons can’t be part of one`:`Boolean groups combine shapes: flatten ${[...new Set(r.map(e=>e.type===`text`?`text`:`frames`))].join(` and `)} first (${Yc.kbd})`}function Jc(e,t,n,r){if(n.length===1){let t=e.nodes[n[0]];return t?.type===`frame`&&t.boolean?[{op:`update`,id:t.id,set:{boolean:r,name:Bc[r]}}]:null}if(!Kc(e,n))return null;let i=e.nodes[n[0]].parent,a=i?e.nodes[i].children:e.roots,o=[...n].sort((e,t)=>a.indexOf(e)-a.indexOf(t)),s=i?t.get(i):null,c=e=>{let n=t.get(e);return n?s?{...n,x:n.x-s.x,y:n.y-s.y}:n:null};if(o.some(e=>!c(e)))return null;let l=Vt(o.map(c)),u=Math.round(l.x),d=Math.round(l.y),f=e.nodes[o[0]],p=f.type===`shape`||f.type===`frame`?{...f.fills?{fills:structuredClone(f.fills)}:{},...f.stroke?{stroke:structuredClone(f.stroke)}:{}}:{},m=[{op:`create`,parent:i,index:a.indexOf(o[o.length-1])+1,tree:{type:`frame`,key:`bool`,name:Bc[r],boolean:r,x:u,y:d,w:Math.round(l.w),h:Math.round(l.h),sizeX:`hug`,sizeY:`hug`,...p}},{op:`move`,ids:o,parent:`bool`}];for(let t of o){let n=e.nodes[t],r=c(t),i=r.x+r.w/2-(n.type===`shape`&&n.rotation?n.w/2:r.w/2),a=r.y+r.h/2-(n.type===`shape`&&n.rotation?n.h/2:r.h/2);m.push({op:`update`,id:t,set:{x:Math.round(i-u),y:Math.round(a-d),absolute:!1,...n.sizeX===`fill`?{sizeX:`fixed`}:{},...n.sizeY===`fill`?{sizeY:`fixed`}:{}}})}return m}var Yc={label:`Flatten`,kbd:`⌘E`};function Xc(e,t,n){let r=n.map(t=>e.nodes[t]);if(!r.length||r.some(e=>!e))return{error:`Select layers to flatten`};let i=r[0].parent;if(r.some(e=>e.parent!==i))return{error:`Flatten works on layers in the same parent`};if(r.some(e=>e.type===`vector`))return{error:`Flatten works on shapes, frames and text, not images or SVG layers`};if(r.some(e=>e.type===`frame`&&e.instanceOf))return{error:`Detach the instance to flatten it`};if(r.some(e=>e.type===`text`||e.type===`frame`&&!e.boolean))return{server:n};let a=i?e.nodes[i]:null,o=a?.type===`frame`&&a.layout.mode!==`free`?r.filter(e=>!e.absolute):[],s;if(o.length>1){let e=t.get(i);if(!e)return{error:`Flatten: the layout isn't measured yet`};s={};for(let n of o){let r=t.get(n.id);if(!r)return{error:`Flatten: the layout isn't measured yet`};let i=n.type===`shape`&&n.rotation,a=r.x-e.x,o=r.y-e.y;s[n.id]=i?{x:a+r.w/2-n.w/2,y:o+r.h/2-n.h/2,w:n.w,h:n.h}:{x:a,y:o,w:r.w,h:r.h}}}return{ops:[{op:`flatten`,ids:n,key:`flat`,...s?{at:s}:{}}]}}var Zc={label:`Outline stroke`,kbd:`⌥⌘O`};function Qc(e,t){return t.length>0&&t.every(t=>{let n=e.nodes[t];if(!n||!(n.type===`shape`||n.type===`frame`&&n.boolean))return!1;let r=n.parent?e.nodes[n.parent]:null;return!(r?.type===`frame`&&r.boolean)&&!!n.stroke&&n.stroke.width>0&&n.stroke.visible!==!1})}function $c(e,t){return Qc(e,t)?{ops:[{op:`outlineStroke`,ids:t,key:`ol`}],keys:t.map((e,t)=>`ol${t}`)}:{error:`Outline stroke works on shapes and boolean groups with a visible stroke`}}var el=typeof navigator<`u`?navigator:void 0,tl=!!el&&/Mac|iPhone|iPad|iPod/i.test(el.userAgentData?.platform||el.platform||el.userAgent),nl=!!el&&/Win/i.test(el.userAgentData?.platform||el.platform||el.userAgent),rl=e=>tl?e.metaKey:e.ctrlKey,il={"⌃⌥H":`Alt+Shift+H`,"⌃⌥V":`Alt+Shift+V`,"⌃⌥T":`Ctrl+Alt+Shift+T`,"⌃G":`Ctrl+Shift+4`},al=[[`⌃`,`Ctrl`],[`⌘`,`Ctrl`],[`⌥`,`Alt`],[`⇧`,`Shift`]];function ol(e){return tl||!e?e:e.replace(/⌫/g,`Delete`).replace(/[⌃⌥⇧⌘]+([A-Z0-9]|[^\sA-Za-z0-9⌃⌥⇧⌘-]|Enter|Tab|Esc)?/g,(e,t)=>il[e]?il[e]:[...new Set(al.filter(([t])=>e.includes(t)).map(([,e])=>e)),...t?[t]:[]].join(`+`))}function sl(e,t,n,r){return!n&&!r&&e.length>1&&e.includes(t)?t:null}var cl=(e,t)=>!t||e.nodes[t].layout.mode===`free`,ll=(e,t)=>{let n=t?e.nodes[t].children:e.roots;return cl(e,t)?[...n].reverse():n},ul=(e,t,n)=>{let r=e.nodes[n]?.parent??null;for(;r;){if(r===t)return!0;r=e.nodes[r]?.parent??null}return!1};function dl(e){return Ut(e)?(0,U.jsx)(X.media,{}):Wt(e)?(0,U.jsx)(X.image,{}):e.type===`text`?(0,U.jsx)(X.text,{}):e.type===`vector`?(0,U.jsx)(X.vector,{}):e.type===`shape`?(0,U.jsx)(Hc,{kind:e.shape.kind}):e.boolean?(0,U.jsx)(Uc,{op:e.boolean}):e.main||e.componentSet?(0,U.jsx)(X.component,{}):e.instanceOf?(0,U.jsx)(X.instance,{}):e.layout.mode===`row`?(0,U.jsx)(X.row,{}):e.layout.mode===`column`?(0,U.jsx)(X.column,{}):e.parent&&e.sizeX===`hug`||At(e)?(0,U.jsx)(X.group,{}):e.parent&&!e.children.length?(0,U.jsx)(X.rect,{}):(0,U.jsx)(X.frame,{})}var fl=()=>parseFloat(getComputedStyle(document.documentElement).getPropertyValue(`--layer-row-h`))||32,pl=4,ml=8;function hl({doc:e,selection:t,boxes:n,onSelect:r,onHover:i,onCommit:a,renameReq:o,onContextMenu:s,interactive:c}){let l=(0,H.useMemo)(fl,[]),[u,f]=(0,H.useState)(()=>new Set(e.roots)),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(null),_=(0,H.useRef)(null),v=(0,H.useRef)(null),y=(0,H.useRef)(``),b=e=>{y.current=e.join(`,`),r(e)};(0,H.useEffect)(()=>{t.join(`,`)!==y.current&&(v.current=null)},[t.join(`,`)]);let x=(0,H.useRef)(null);(0,H.useEffect)(()=>{o&&m(o.id)},[o]),(0,H.useEffect)(()=>{let n=new Set(u),r=!1;for(let i of t){let t=e.nodes[i]?.parent??null;for(;t;)n.has(t)||(n.add(t),r=!0),t=e.nodes[t]?.parent??null}r&&f(n),S.current=t[0]??null},[t.join(`,`)]);let S=(0,H.useRef)(null),[C,w]=(0,H.useState)({top:0,h:800});(0,H.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=()=>w(t=>t.top===e.scrollTop&&t.h===e.clientHeight?t:{top:e.scrollTop,h:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),e.addEventListener(`scroll`,t,{passive:!0}),()=>{n.disconnect(),e.removeEventListener(`scroll`,t)}},[]);let[T,E]=(0,H.useState)(!1),D=T&&!!c?.size,O=(0,H.useMemo)(()=>{if(!D)return null;let t=new Set;for(let n of c)for(let r=n;r&&e.nodes[r]&&!t.has(r);r=e.nodes[r].parent)t.add(r);return t},[D,c,e]),k=[],A=(t,n)=>{for(let r of ll(e,t)){let t=e.nodes[r];!t||O&&!O.has(r)||(k.push({n:t,depth:n}),t.type===`frame`&&t.children.length&&(O?t.children.some(e=>O.has(e)):u.has(r))&&A(r,n+1))}};A(null,0),(0,H.useEffect)(()=>{let e=x.current,t=S.current;if(!e||!t)return;let n=k.findIndex(e=>e.n.id===t);if(n<0)return;S.current=null;let r=pl+n*l;r<e.scrollTop?e.scrollTop=r:r+l>e.scrollTop+e.clientHeight&&(e.scrollTop=r+l-e.clientHeight)});let j=Math.max(0,Math.floor((C.top-pl)/l)-ml),M=Math.min(k.length,Math.ceil((C.top+C.h)/l)+ml),N=e=>f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=(t,n)=>{let r=document.elementFromPoint(n,t)?.closest(`[data-row]`);if(!r)return null;let i=r.dataset.row,a=r.getBoundingClientRect(),o=(t-a.top)/a.height;return e.nodes[i].type===`frame`&&o>.25&&o<.75?{id:i,pos:`inside`}:{id:i,pos:o<.5?`before`:`after`}},F=(t,r)=>{if(t.some(t=>t===r.id||ul(e,t,r.id)))return null;let i=e.nodes[r.id],a,o;if(r.pos===`inside`)a=i.id,o=cl(e,a)?void 0:0;else{a=i.parent;let t=(a?e.nodes[a].children:e.roots).indexOf(i.id),n=r.pos===`before`;o=cl(e,a)?n?t+1:t:n?t:t+1}let s=a?e.nodes[a]:void 0;if(s?.type===`frame`&&s.boolean&&t.some(t=>{let n=e.nodes[t];return!(n?.type===`shape`||n?.type===`frame`&&n.boolean)}))return null;let c=[{op:`move`,ids:t,parent:a,index:o}];if(cl(e,a)){let r=a?n.get(a):{x:0,y:0,w:0,h:0};for(let i of t){let t=n.get(i),a=t&&r&&mn(e,i,{...t,x:t.x-r.x,y:t.y-r.y});a&&c.push({op:`update`,id:i,set:{x:Math.round(a.x),y:Math.round(a.y)}})}}return c},I=(n,i)=>{if(n.target.closest(`button,input`))return;if(n.button===2){t.includes(i)||r([i]);return}let a=t.includes(i)?t:[i],o=v.current??t[t.length-1],s=k.findIndex(e=>e.n.id===o),c=k.findIndex(e=>e.n.id===i);if(n.shiftKey&&s>=0&&c>=0){let[t,n]=s<c?[s,c]:[c,s];b(Pt(e,k.slice(t,n+1).map(e=>e.n.id)))}else v.current=i,rl(n)||n.shiftKey?b(t.includes(i)?t.filter(e=>e!==i):Pt(e,[...t,i])):t.includes(i)||b([i]),_.current={ids:a,y:n.clientY,active:!1,narrow:sl(t,i,rl(n)||n.shiftKey,!1)},n.currentTarget.setPointerCapture(n.pointerId)},L=e=>{let t=_.current;if(!t||!t.active&&Math.abs(e.clientY-t.y)<4)return;t.active=!0;let n=P(e.clientY,e.clientX);g(n&&F(t.ids,n)?n:null)},ee=()=>{let e=_.current;_.current=null;let t=h;if(g(null),e&&!e.active&&e.narrow)return b([e.narrow]);if(!e?.active||!t)return;let n=F(e.ids,t);n&&a(n,`Move layer`)},R=(e,t)=>a([{op:`update`,id:e.id,set:{[t]:!e[t]}}],t===`hidden`?e.hidden?`Show`:`Hide`:e.locked?`Unlock`:`Lock`);return(0,U.jsxs)(U.Fragment,{children:[!!c?.size&&(0,U.jsx)(`div`,{className:`layers-filter`,children:(0,U.jsxs)(`button`,{className:`chip filter ${T?`on`:``}`,"aria-pressed":T,onClick:()=>E(!T),"data-tip":T?`Show all layers`:`Show only layers that move or react in a prototype`,children:[(0,U.jsx)(X.zap,{}),`Interactive`,(0,U.jsx)(`span`,{className:`layers-filter-n`,children:c.size})]})}),(0,U.jsxs)(`div`,{className:`layer-list`,ref:x,onPointerLeave:()=>i(null),children:[(0,U.jsx)(`div`,{style:{height:j*l},"aria-hidden":!0}),k.slice(j,M).map(({n,depth:r})=>{let o=t.includes(n.id),l=!o&&t.some(t=>ul(e,t,n.id)),f=n.type===`frame`&&n.children.length>0,g=h?.id===n.id?`drop-${h.pos}`:``;return(0,U.jsxs)(`div`,{"data-row":n.id,"data-id":n.id,className:`lrow ${o?`sel`:``} ${l?`insel`:``} ${n.hidden?`dim`:``} ${g} ${r===0?`root`:``} ${n.type===`frame`&&(n.main||n.componentSet||n.instanceOf)?`comp`:n.inInstance?`in-comp`:``}`,style:{"--depth":r},onPointerDown:e=>I(e,n.id),onPointerMove:L,onPointerUp:ee,onPointerEnter:()=>i(n.id),onContextMenu:e=>{e.preventDefault(),s?.(e,n.id)},onDoubleClick:e=>{e.target.closest(`button`)||m(n.id)},children:[(0,U.jsx)(`button`,{className:`caret ${f?``:`none`} ${u.has(n.id)?`open`:``}`,tabIndex:-1,onClick:()=>f&&N(n.id),"aria-label":u.has(n.id)?`Collapse`:`Expand`,children:(0,U.jsx)(X.caret,{})}),(0,U.jsx)(`span`,{className:`licon`,children:dl(n)}),p===n.id?(0,U.jsx)(`input`,{className:`lname-in`,autoFocus:!0,defaultValue:n.name,onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=n.name,e.currentTarget.blur()))},onBlur:e=>{m(null);let t=e.target.value.trim();t&&t!==n.name&&a([{op:`update`,id:n.id,set:{name:t}}],`Rename`)}}):(0,U.jsx)(`span`,{className:`lname`,children:d(n)}),c?.has(n.id)&&(0,U.jsx)(`span`,{className:`lbadge`,role:`img`,"aria-label":`Interactive`,"data-tip":`Moves or reacts in its prototype (motion.css)`,children:(0,U.jsx)(X.zap,{})}),(0,U.jsxs)(`span`,{className:`lacts`,children:[(0,U.jsx)(`button`,{className:n.locked?`on`:``,onClick:()=>R(n,`locked`),"aria-label":n.locked?`Unlock`:`Lock`,"data-tip":n.locked?`Unlock`:`Lock`,"data-kbd":`⇧⌘L`,children:n.locked?(0,U.jsx)(X.lock,{}):(0,U.jsx)(X.unlock,{})}),(0,U.jsx)(`button`,{className:n.hidden?`on`:``,onClick:()=>R(n,`hidden`),"aria-label":n.hidden?`Show`:`Hide`,"data-tip":n.hidden?`Show`:`Hide`,"data-kbd":`⇧⌘H`,children:n.hidden?(0,U.jsx)(X.eyeOff,{}):(0,U.jsx)(X.eye,{})})]})]},n.id)}),(0,U.jsx)(`div`,{style:{height:(k.length-M)*l},"aria-hidden":!0})]})]})}function gl(){let e=V(`--handle`);return{stroke:V(`--stroke-w`),handle:e,handleR:e/2,handleCorner:V(`--handle-corner`),handleOut:V(`--handle-out`),edgeInset:V(`--handle-edge-inset`),hideBelow:V(`--handle-hide-below`),rotateR:V(`--rotate-r`),rotateOffset:V(`--rotate-offset`),dotR:V(`--dot-r`),dotInset:V(`--dot-inset`),dotMinSide:V(`--dot-min-side`),dotRim:V(`--dot-rim`),penHandle:V(`--pen-handle`),pointerLabelX:V(`--pointer-label-x`),pointerLabelY:V(`--pointer-label-y`),badgeW:V(`--badge-w`),badgeH:V(`--badge-h`),badgeRadius:V(`--badge-radius`),badgeGap:V(`--badge-gap`),labelH:V(`--label-h`),labelBaseline:V(`--label-baseline`),labelCharW:V(`--label-char-w`),labelPad:V(`--label-pad`),snapMarkR:V(`--snap-mark-r`),rulerSize:V(`--ruler-size`),canvasTop:V(`--canvas-top`),rulerTick:V(`--ruler-tick`),rulerLabelGap:V(`--ruler-label-gap`),rulerTextY:V(`--ruler-text-y`),guideGrab:V(`--guide-grab`),smartBarLen:V(`--smart-bar-len`),indicator:V(`--indicator`),tidySize:V(`--tidy-size`),playBtn:V(`--play-btn`),playInset:V(`--play-inset`),cropCorner:V(`--crop-corner`),cropHintGap:V(`--crop-hint-gap`),gap:V(`--gap`)}}var _l=null;function vl(){if(_l)return _l;let e=gl();return e.handle>0&&(_l=e),e}var yl=(e,t)=>({x:e.x*t.z+t.x,y:e.y*t.z+t.y,w:e.w*t.z,h:e.h*t.z}),bl=(e,t,n=0)=>({x:e.includes(`w`)?t.x-n:e.includes(`e`)?t.x+t.w+n:t.x+t.w/2,y:e.includes(`n`)?t.y-n:e.includes(`s`)?t.y+t.h+n:t.y+t.h/2});function xl(e){let{view:t,hover:n,selected:r,bounds:i,size:a,resizable:o,marquee:s,turned:c}=e,l=vl(),u=t=>(e.scaling?St:xt)(Et[t]+(c?.deg??0)),d=c?yl(c.box,t):i&&yl(i,t),f=d&&{x:Math.round(d.x),y:Math.round(d.y),w:Math.round(d.x+d.w)-Math.round(d.x),h:Math.round(d.y+d.h)-Math.round(d.y)},p=f&&{x:f.x+.5,y:f.y+.5,w:Math.max(0,f.w-1),h:Math.max(0,f.h-1)},m=c&&f?`rotate(${c.deg} ${f.x+f.w/2} ${f.y+f.h/2})`:void 0;return(0,U.jsxs)(`svg`,{className:`overlay-svg ${e.selComp?`comp`:``}`,width:`100%`,height:`100%`,children:[n&&(()=>{let r=yl(n,t);return(0,U.jsx)(`rect`,{x:r.x+.5,y:r.y+.5,width:Math.max(0,r.w-1),height:Math.max(0,r.h-1),className:`ov-hover ${e.hoverComp?`comp`:``}`})})(),r.length>1&&r.map((n,r)=>{let i=e.memberTurns?.[r],a=yl(i?i.box:n,t);return(0,U.jsx)(`rect`,{x:a.x+.5,y:a.y+.5,width:Math.max(0,a.w-1),height:Math.max(0,a.h-1),className:`ov-member`,transform:i?`rotate(${i.deg} ${a.x+a.w/2} ${a.y+a.h/2})`:void 0},r)}),(0,U.jsxs)(`g`,{transform:m,children:[f&&(0,U.jsx)(`rect`,{x:f.x+.5,y:f.y+.5,width:Math.max(0,f.w-1),height:Math.max(0,f.h-1),className:`ov-select`}),f&&e.onRotateDown&&[`nw`,`ne`,`se`,`sw`].map(t=>{let n=bl(t,f,0),r=t.includes(`w`)?-1:1,i=t.includes(`n`)?-1:1;return(0,U.jsx)(`circle`,{className:`ov-rotate`,style:{cursor:Ct(Et[t]+(c?.deg??0))},cx:n.x+r*l.rotateOffset,cy:n.y+i*l.rotateOffset,r:l.rotateR,onPointerDown:e.onRotateDown},`rot-${t}`)}),f&&o&&Gt.map(t=>{let n=f.w<l.hideBelow||f.h<l.hideBelow,r=bl(t,p,n?l.handleOut:0);if(t.length!==2){if(n)return null;let i=t===`n`||t===`s`;return(0,U.jsx)(`rect`,{className:`ov-edge`,style:{cursor:u(t)},x:i?f.x+l.edgeInset:r.x-l.handleR,y:i?r.y-l.handleR:f.y+l.edgeInset,width:i?Math.max(0,f.w-2*l.edgeInset):l.handle,height:i?l.handle:Math.max(0,f.h-2*l.edgeInset),onPointerDown:n=>e.onHandleDown(t,n)},t)}return(0,U.jsx)(`rect`,{className:`ov-handle`,style:{cursor:u(t)},x:r.x-l.handleR,y:r.y-l.handleR,width:l.handle,height:l.handle,rx:l.handleCorner,onPointerDown:n=>e.onHandleDown(t,n)},t)})]}),f&&a&&(()=>{let n=i?yl(i,t):f,r=e.badge??`${Math.round(a.w)} × ${Math.round(a.h)}`;return(0,U.jsxs)(`g`,{transform:`translate(${n.x+n.w/2}, ${n.y+n.h+l.badgeGap})`,children:[(0,U.jsx)(`rect`,{x:-l.badgeW/2,y:0,width:l.badgeW,height:l.badgeH,rx:l.badgeRadius,className:`ov-badge`}),(0,U.jsx)(`text`,{x:0,y:l.badgeH/2+l.labelBaseline,textAnchor:`middle`,className:`ov-badge-text`,children:r})]})})(),s&&(()=>{let e=yl(s,t);return(0,U.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,className:`ov-marquee`})})()]})}var Sl=(e,t)=>e[t]??`off`,Cl=[{name:`Desktop`,w:1440,h:900},{name:`Tablet`,w:820,h:1180},{name:`Mobile`,w:390,h:844}],wl=`nudge.buildSize`,Tl=`nudge.buildBeside`,El={views:(()=>{try{return Object.fromEntries(Object.entries(JSON.parse(localStorage.getItem(Tl)??`{}`)).filter(([,e])=>e===`side`))}catch{return{}}})(),interacting:null,scrolling:null,reports:{},focus:null,reloads:{},sizes:(()=>{try{return JSON.parse(localStorage.getItem(wl)??`{}`)}catch{return{}}})()},Dl=new Set,Ol=e=>{El={...El,...e},Dl.forEach(e=>e())},kl=()=>(0,H.useSyncExternalStore)(e=>(Dl.add(e),()=>Dl.delete(e)),()=>El);function Al(e,t){let n={...El.views,[e]:t};t!==`side`&&delete n[e];try{localStorage.setItem(Tl,JSON.stringify(n))}catch{}Ol({views:n,interacting:t===`off`&&El.interacting===e?null:El.interacting})}function jl(e,t){let n={...El.sizes};t?n[e]=t:delete n[e];try{localStorage.setItem(wl,JSON.stringify(n))}catch{}Ol({sizes:n})}var Ml=e=>Ol({interacting:e}),Nl=e=>{El.scrolling!==e&&Ol({scrolling:e})},Pl=e=>Ol({focus:e}),Fl=e=>Ol({reloads:{...El.reloads,[e]:(El.reloads[e]??0)+1}}),Il=e=>{try{return Number(new URL(e).port)===Number(location.port)+2e3}catch{return!1}},Ll=null;function Rl(e){let t=new Map;for(let n of e.roots)t.set(n,e.nodes[n]?.build?.url??``);if(Ll)for(let[e,n]of t)Ll.has(e)&&Ll.get(e)===``&&Il(n)&&Al(e,`side`);Ll=t}async function zl(e,t,n){Ol({reports:{...El.reports,[e]:`running`},focus:null});try{let r=new URLSearchParams({id:e,url:t,...n?{selector:n}:{}}),i=await fetch(`/api/compare?${r}`),a=await i.json();Ol({reports:{...El.reports,[e]:a.report?{report:a.report,at:Date.now()}:{error:a.error??`Compare failed (${i.status})`,at:Date.now()}}})}catch{Ol({reports:{...El.reports,[e]:{error:`Couldn’t reach the canvas server`,at:Date.now()}}})}}var Bl=e=>e>=1024?900:e>=600?1180:844,Vl=I(),Hl=(e,t,n,r,i)=>(0,U.jsxs)(U.Fragment,{children:[i?(0,U.jsx)(`span`,{className:`ctx-icon`,children:e.checked?(0,U.jsx)(X.check,{}):e.icon}):(0,U.jsxs)(U.Fragment,{children:[t&&(0,U.jsx)(`span`,{className:`ctx-icon`,children:e.checked?(0,U.jsx)(X.check,{}):null}),n&&(0,U.jsx)(`span`,{className:`ctx-icon`,children:e.icon})]}),(0,U.jsx)(`span`,{className:`ctx-label`,children:e.label}),e.kbd&&(0,U.jsx)(`span`,{className:`ctx-kbd`,children:ol(e.kbd)}),e.hint&&(e.path?(0,U.jsx)(`span`,{className:`ctx-kbd ctx-hint ctx-path`,"data-tip":e.hint,children:`\u200e${e.hint}\u200e`}):(0,U.jsx)(`span`,{className:`ctx-kbd ctx-hint`,children:e.hint})),r&&(0,U.jsx)(`span`,{className:`ctx-caret`,children:(0,U.jsx)(X.caret,{})})]});function Ul({items:e,onDone:t,style:n,sub:r=!1,above:i=!1,alignRight:a=!1,fit:o=!1,onLeave:s}){let c=(0,H.useRef)(null),[l,u]=(0,H.useState)(n),[d,f]=(0,H.useState)(null),p=e.some(e=>`checked`in e&&e.checked!==void 0),m=e.some(e=>`icon`in e&&!!e.icon),h=p&&m&&!e.some(e=>`icon`in e&&!!e.icon&&e.checked!==void 0),g=n.left,_=n.top,v=n.width;return(0,H.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=e.ownerDocument.defaultView??window,o=()=>{let o=e.offsetWidth,s=e.offsetHeight,c=V(`--gap`),l=g,d=_;i&&(d=Math.max(c,_-s)),a&&(l=Math.max(c,g-o)),!a&&g+o>t.innerWidth-c&&(l=Math.max(c,r?g-o-(v??0):t.innerWidth-o-c)),!i&&_+s>t.innerHeight-c&&(d=Math.max(c,t.innerHeight-s-c)),u(e=>e.left===l&&e.top===d?e:{...n,left:l,top:d})};o();let s=new ResizeObserver(o);return s.observe(e),s.observe(e.ownerDocument.documentElement),t.addEventListener(`resize`,o),()=>{s.disconnect(),t.removeEventListener(`resize`,o)}},[g,_,v,i,a,r]),(0,H.useEffect)(()=>{if(r)return;let e=c.current;(e?.querySelector(`:scope > .ctx-row > .ctx-item[aria-checked="true"]`)??e)?.focus({preventScroll:!1})},[r]),(0,U.jsx)(`div`,{ref:c,className:`ctx-menu ${o?`fit`:``}`,role:`menu`,tabIndex:-1,style:l,onKeyDown:e=>{let t=c.current;if(!t||![`ArrowDown`,`ArrowUp`,`Home`,`End`,`ArrowRight`].includes(e.key))return;let n=[...t.querySelectorAll(`:scope > .ctx-row > .ctx-item:not(:disabled)`)];if(!n.length)return;e.preventDefault(),e.stopPropagation();let r=n.indexOf(t.ownerDocument.activeElement);e.key===`ArrowRight`?r>=0&&n[r].getAttribute(`aria-haspopup`)&&n[r].click():n[e.key===`Home`?0:e.key===`End`?n.length-1:e.key===`ArrowDown`?(r+1)%n.length:r<=0?n.length-1:r-1].focus()},onContextMenu:e=>e.preventDefault(),onMouseLeave:s,children:e.map((e,n)=>{if(`sep`in e)return(0,U.jsx)(`div`,{className:`ctx-sep`},n);if(`head`in e)return(0,U.jsx)(`div`,{className:`ctx-head`,role:`presentation`,children:e.head},n);if(`node`in e)return(0,U.jsx)(`div`,{className:`ctx-custom`,children:e.node},n);let r=!!e.items?.length;return(0,U.jsxs)(`div`,{className:`ctx-row`,onMouseEnter:()=>{f(r?n:null),e.onHover?.()},onFocus:()=>e.onHover?.(),children:[e.href&&!e.disabled?(0,U.jsx)(`a`,{role:e.checked===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":e.checked,href:e.href,className:`ctx-item ${e.danger?`danger`:``}`,"aria-label":e.label,draggable:!0,onClick:n=>{e.onClick?.(n),t()},onAuxClick:e=>{e.button===1&&t()},onContextMenu:e=>e.stopPropagation(),children:Hl(e,p,m,r,h)}):(0,U.jsx)(`button`,{role:e.checked!==void 0&&!r?`menuitemcheckbox`:`menuitem`,"aria-checked":e.checked!==void 0&&!r?e.checked:void 0,className:`ctx-item ${e.danger?`danger`:``} ${d===n?`open`:``}`,disabled:e.disabled,"aria-label":e.label,"aria-haspopup":r||void 0,onClick:i=>{if(r)return f(n);e.onClick?.(i),t()},children:Hl(e,p,m,r,h)}),e.trail&&(0,U.jsx)(`button`,{className:`ctx-trail`,"aria-label":e.trail.label,"data-tip":e.trail.label,onClick:t=>{t.stopPropagation(),e.trail.onClick()},children:(0,U.jsx)(X.close,{})}),r&&d===n&&(0,U.jsx)(Wl,{items:e.items,onDone:t,anchor:c,index:n,at:{left:l.left,top:l.top}})]},n)})})}function Wl({items:e,onDone:t,anchor:n,index:r,at:i}){let[a,o]=(0,H.useState)(null);return(0,H.useLayoutEffect)(()=>{let e=(n.current?.children[r])?.getBoundingClientRect(),t=n.current?.getBoundingClientRect();if(!e||!t)return;let i={left:t.right+V(`--gap-2xs`),top:e.top-V(`--surface-pad`),width:t.width};o(e=>e&&e.left===i.left&&e.top===i.top&&e.width===i.width?e:i)},[n,r,e,i.left,i.top]),a?(0,U.jsx)(Ul,{items:e,onDone:t,sub:!0,style:a}):null}function Gl({x:e,y:t,items:n,onClose:r,doc:i=document,above:a=!1,alignRight:o=!1,fit:s=!1,onLeave:c}){return(0,H.useEffect)(()=>{let e=i.defaultView??window,t=e.addEventListener.bind(e),n=e.removeEventListener.bind(e),a=e=>{e.target.closest?.(`.ctx-menu, [aria-haspopup="menu"][aria-expanded="true"]`)||r()},o=e=>{e.key===`Escape`&&(e.stopPropagation(),r())},s=e=>{e.target.closest?.(`.ctx-menu`)||r()};return t(`pointerdown`,a,!0),t(`keydown`,o,!0),t(`blur`,r),t(`wheel`,s,{passive:!0}),()=>{n(`pointerdown`,a,!0),n(`keydown`,o,!0),n(`blur`,r),n(`wheel`,s)}},[r,i]),(0,Vl.createPortal)((0,U.jsx)(Ul,{items:n,onDone:r,style:{left:e,top:t},above:a,alignRight:o,fit:s,onLeave:c}),i.body)}function Kl(e,t){let n=e.trim().replace(/^#/,``);if(!/^([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(n))return null;let r=n.toLowerCase();if(r.length<=4&&(r=[...r].map(e=>e+e).join(``)),r.length===6){let e=/^#[0-9a-f]{6}([0-9a-f]{2})$/i.exec(t);e&&(r+=e[1].toLowerCase())}return r.length===8&&r.endsWith(`ff`)?`#${r.slice(0,6)}`:`#${r}`}function ql(e,t,n){return e.of===t?e:{of:t,text:n}}var Jl=3;function Yl({from:e,step:t=1,clamp:n,onScrub:r,onDone:i,click:a}){let o=(0,H.useRef)(null),s=()=>document.documentElement.classList.remove(`scrubbing`);return(0,H.useEffect)(()=>s,[]),{onPointerDown:t=>{if(t.button!==0||a&&document.activeElement===t.currentTarget)return;let n=e();(n!==null||a)&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),o.current={x:t.clientX,start:n,last:n,moved:!a,el:t.currentTarget})},onPointerMove:e=>{let i=o.current;if(!i||i.start===null)return;let a=e.clientX-i.x;if(!i.moved){if(Math.abs(a)<Jl)return;i.moved=!0}document.documentElement.classList.add(`scrubbing`);let s=n(i.start+Math.round(a/2)*t*(e.shiftKey?10:1));s!==i.last&&(i.last=s,r(s))},onPointerUp:()=>{let e=o.current;o.current=null,e&&(s(),e.moved?i(e.last===e.start?null:e.last):a?.(e.el))},onPointerCancel:()=>{let e=o.current;o.current=null,s(),e?.moved&&i(null)}}}var Z=Symbol.for(`nudge.mixed`),Xl=e=>typeof e==`symbol`;function Zl(e,t){let n=e.trim();if(!n)return null;let r=/^[+\-*/]/.test(n)&&t!==null?`${t}${n}`:n;if(!/^[\d.\s+\-*/()]+$/.test(r))return null;try{let e=Function(`"use strict"; return (${r})`)();return typeof e==`number`&&Number.isFinite(e)?e:null}catch{return null}}function Ql({label:e,value:t,min:n=-1/0,max:r=1/0,step:i=1,digits:a=0,suffix:o,disabled:s,title:c,placeholder:l,base:u,onText:d,onPreview:f,onCommit:p}){let m=Xl(t)||t===void 0?``:String($l(t,a)),[h,g]=(0,H.useState)(m),[_,v]=(0,H.useState)(!1),y=(0,H.useRef)(!1);(0,H.useEffect)(()=>{_&&y.current||g(m)},[m,_]);let b=e=>$l(Math.min(r,Math.max(n,e)),a),x=typeof t==`number`?t:null,S=x??(t===void 0?u??null:null),C=()=>{if(!y.current)return g(m);if(y.current=!1,d?.(h.trim()))return;let e=Zl(h,x);if(e===null)return g(m);let t=b(e);t===x?g(m):p(t)},w={from:()=>s||Xl(t)?null:S??0,step:i,clamp:b,onScrub:e=>{g(String(e)),f?.(e)},onDone:e=>{f?.(null),e===null?g(m):p(e)}},T=Yl(w),E=Yl({...w,click:e=>e.focus()});return(0,U.jsxs)(`div`,{className:`num ${s?`disabled`:``}`,"data-tip":c,children:[(0,U.jsx)(`span`,{className:`num-label`,...T,children:e}),(0,U.jsx)(`input`,{value:h,disabled:s,placeholder:Xl(t)?`Mixed`:l??``,...s?{}:E,onFocus:e=>{v(!0),e.currentTarget.select()},onBlur:()=>{v(!1),C()},onChange:e=>{y.current=!0,g(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(C(),e.currentTarget.blur()):e.key===`Escape`?(y.current=!1,g(m),e.currentTarget.blur()):(e.key===`ArrowUp`||e.key===`ArrowDown`)&&S!==null&&(e.preventDefault(),p(b(S+(e.key===`ArrowUp`?1:-1)*i*(e.shiftKey?10:1)))))}}),o&&(0,U.jsx)(`span`,{className:`num-suffix`,children:o})]})}var $l=(e,t)=>Math.round(e*10**t)/10**t;function eu({value:e,options:t,onChange:n,icons:r=!1,label:i}){return(0,U.jsx)(`div`,{className:r?`seg icons`:`seg`,role:`radiogroup`,"aria-label":i,children:t.map(t=>(0,U.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===t.value,"data-tip":t.title,"aria-label":typeof t.label==`string`?void 0:t.title,className:e===t.value?`on`:``,disabled:t.disabled,onClick:()=>e!==t.value&&n(t.value),children:t.label},t.value))})}function tu({value:e,styles:t,onPreview:n,onCommit:r}){let i=typeof e==`string`?e.startsWith(`$`)?t[e.slice(1)]??`#ff00ff`:e:ae,a=Xl(e)?``:e??``,[o,s]=(0,H.useState)(a),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)(!1);(0,H.useEffect)(()=>{c&&u.current||s(a)},[a,c]);let[d,f]=(0,H.useState)(!1),p=()=>{if(!u.current)return s(a);u.current=!1;let n=o.trim(),c=Kl(n,i),l=/^\$[\w/.-]+$/.test(n)&&t[n.slice(1)]?n:null,d=c??l;d&&d!==e?r(d.toLowerCase().startsWith(`$`)?d:d.toLowerCase()):s(a)};return(0,U.jsxs)(`div`,{className:`color`,children:[(0,U.jsx)(`button`,{className:`swatch ${d?`on`:``} ${Xl(e)?`mixed`:``}`,"aria-label":`Pick color`,"aria-expanded":d,style:Xl(e)?void 0:{background:i},onClick:()=>f(!d)}),d&&(0,U.jsx)(Bd,{value:i,onClose:()=>f(!1),onPreview:e=>n?.(e),onCommit:e=>r(e)}),(0,U.jsx)(`input`,{className:`color-text`,value:o,placeholder:Xl(e)?`Mixed`:``,onFocus:e=>{l(!0),e.currentTarget.select()},onBlur:()=>{l(!1),p()},onChange:e=>{u.current=!0,s(e.target.value)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&(p(),e.currentTarget.blur()),e.key===`Escape`&&(u.current=!1,s(a),e.currentTarget.blur()))}}),Object.keys(t).length>0&&(0,U.jsxs)(`div`,{className:`select-wrap sm`,children:[(0,U.jsxs)(`select`,{className:`style-pick`,value:typeof e==`string`&&e.startsWith(`$`)?e:``,onChange:e=>e.target.value&&r(e.target.value),"aria-label":`Color style`,children:[(0,U.jsx)(`option`,{value:``,children:`Style`}),Object.entries(t).map(([e,t])=>(0,U.jsx)(`option`,{value:`$${e}`,children:`$${e} ${t}`},e))]}),(0,U.jsx)(X.chevronDown,{})]})]})}function nu({title:e,action:t,children:n}){return(0,U.jsxs)(`section`,{className:`psec`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsx)(`h3`,{children:e}),t]}),n]})}var ru=[[[`normal`,`Normal`]],[[`darken`,`Darken`],[`multiply`,`Multiply`],[`color-burn`,`Color burn`]],[[`lighten`,`Lighten`],[`screen`,`Screen`],[`plus-lighter`,`Plus lighter`],[`color-dodge`,`Color dodge`]],[[`overlay`,`Overlay`],[`soft-light`,`Soft light`],[`hard-light`,`Hard light`]],[[`difference`,`Difference`],[`exclusion`,`Exclusion`]],[[`hue`,`Hue`],[`saturation`,`Saturation`],[`color`,`Color`],[`luminosity`,`Luminosity`]]],iu=Object.fromEntries(ru.flat()),au=[`plus-lighter`],ou=()=>(0,U.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,"aria-hidden":!0,children:[(0,U.jsx)(`circle`,{cx:`6`,cy:`8`,r:`3.75`}),(0,U.jsx)(`circle`,{cx:`10`,cy:`8`,r:`3.75`})]});function su({value:e,label:t,layer:n=!1,onPick:r,onPreview:i}){let[a,o]=(0,H.useState)(null),s=(0,H.useRef)(!1),c=(0,H.useRef)(`normal`),l=e===Z?Z:e??`normal`,u=l===Z?`Mixed`:iu[l],d=[...l===Z?[{label:`Mixed`,disabled:!0,checked:!0},{sep:!0}]:[],...ru.flatMap((e,t)=>[...t?[{sep:!0}]:[],...e.filter(([e])=>n||!au.includes(e)).map(([e,t])=>({label:t,checked:(a?c.current:l)===e,onHover:()=>i?.(e===`normal`?void 0:e),onClick:()=>{s.current=!0,c.current!==e&&r(e===`normal`?void 0:e)}}))])];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:`icon-btn fit ${l!==`normal`||a?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":!!a,"aria-label":`${t}: ${u}`,"data-tip":`${t} · ${u}`,"data-blend":l===Z?`mixed`:l,onClick:e=>{if(a)return i?.(null),o(null);let t=e.currentTarget.getBoundingClientRect();s.current=!1,c.current=l,o({x:t.left,y:t.bottom+V(`--menu-gap`)})},children:(0,U.jsx)(ou,{})}),a&&(0,U.jsx)(Gl,{x:a.x,y:a.y,items:d,onLeave:()=>i?.(null),onClose:()=>{s.current||i?.(null),o(null)}})]})}function cu(e,t){let n=e.findIndex(e=>e.at>t.at),r=n<0?e.length:n;return{stops:[...e.slice(0,r),t,...e.slice(r)],index:r}}function lu(e,t){return t?`commit`:e?`revert`:`none`}function uu(e,t){let n=!1;return{preview:t=>{n=t!==null,e(t)},commit:(e,...r)=>{n=!1,t(e,...r)},dispose:()=>{n&&(n=!1,e(null))}}}function du(e,t,n,r,i){return Math.max(r,t?Math.min(e,n-t-i):e)}function fu(e,t){let{rotation:n,...r}=t,i={...e,...r};return n!==void 0&&(n%360?i.rotation=n:delete i.rotation),i}var pu=(0,H.createContext)([]);function mu({title:e,titleNode:t,actions:n,onClose:r,children:i,width:a=280,className:o=``,at:s,alignTop:c}){let l=(0,H.useRef)(null),u=(0,H.useContext)(pu),d=()=>u.length?[...document.querySelectorAll(`.floating`)].find(e=>e.dataset.chain?.split(` `).pop()===u[u.length-1])??null:null,f=()=>{let e=V(`--gap`),t=V(`--gap-l`),n=V(`--canvas-top`)+V(`--gap-xl`),r=l.current?.offsetHeight??0,i=t=>du(t,r,innerHeight,n,e);if(s)return{left:Math.max(e,Math.min(s.left,innerWidth-a-e)),top:i(s.top)};let o=d();if(o){let n=o.getBoundingClientRect();return{left:Math.max(e,n.left-a-t),top:i(n.top)}}let u=document.querySelector(`.panel.props`)?.getBoundingClientRect(),f=c?.()?.getBoundingClientRect().top;return u?{left:Math.max(e,u.left-a-t),top:i(f??u.top+e)}:{left:e,top:V(`--canvas-top`)+V(`--gap-2xl`)}},[p,m]=(0,H.useState)(f),h=(0,H.useRef)(f);h.current=f;let g=u.join(` `);(0,H.useLayoutEffect)(()=>{let e=()=>m(e=>{let t=h.current();return t.left===e.left&&t.top===e.top?e:t});e();let t=new ResizeObserver(e),n=document.querySelector(`.panel.props`);n&&t.observe(n),l.current&&t.observe(l.current),t.observe(document.body);let r=d(),i=r?new MutationObserver(e):null;return r&&(t.observe(r),i?.observe(r,{attributes:!0,attributeFilter:[`style`]})),addEventListener(`resize`,e),()=>{t.disconnect(),i?.disconnect(),removeEventListener(`resize`,e)}},[s?.left,s?.top,a,g]);let _=(0,H.useRef)(String(Math.random())),v=[...u,_.current];return(0,H.useEffect)(()=>{dispatchEvent(new CustomEvent(`nudge-floating`,{detail:{id:_.current,chain:v}}));let e=e=>{let t=e.detail;t.id!==_.current&&!t.chain.includes(_.current)&&r()};return addEventListener(`nudge-floating`,e),()=>removeEventListener(`nudge-floating`,e)},[]),(0,H.useEffect)(()=>{let e=e=>{let t=e.target;l.current?.contains(t)||t?.closest?.(`.panel.props`)||t?.closest?.(`.ctx-menu`)||t?.closest?.(`.gradient-handles`)||t?.closest?.(`[aria-expanded="true"]`)||(t?.closest?.(`.floating`))?.dataset.chain?.split(` `).includes(_.current)||r()},t=e=>{e.key===`Escape`&&!document.querySelector(`.floating[data-parent="${_.current}"]`)&&r()};return addEventListener(`pointerdown`,e,!0),addEventListener(`keydown`,t),()=>{removeEventListener(`pointerdown`,e,!0),removeEventListener(`keydown`,t)}},[r]),(0,Vl.createPortal)((0,U.jsxs)(`div`,{ref:l,className:`floating ${o}`,style:{...p,width:a},role:`dialog`,"aria-label":e||o,"data-chain":v.join(` `),"data-parent":u[u.length-1],children:[(0,U.jsxs)(`header`,{className:`floating-head`,children:[t??(0,U.jsx)(`strong`,{children:e}),(0,U.jsxs)(`span`,{className:`floating-actions`,children:[n,(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Close`,"data-tip":`Close`,onClick:r,children:(0,U.jsx)(X.close,{})})]})]}),(0,U.jsx)(`div`,{className:`floating-body`,children:(0,U.jsx)(pu.Provider,{value:v,children:i})})]}),document.body)}function hu({value:e,onChange:t,onEnter:n}){return(0,U.jsxs)(`label`,{className:`floating-search`,children:[(0,U.jsx)(X.search,{}),(0,U.jsx)(`input`,{autoFocus:!0,value:e,placeholder:`Search`,"aria-label":`Search`,onChange:e=>t(e.target.value),onKeyDown:e=>{!e.nativeEvent.isComposing&&e.key===`Enter`&&n?.()}})]})}function gu(e){let t=e.lastIndexOf(`/`);return t<0?{group:``,label:e}:{group:e.slice(0,t),label:e.slice(t+1)}}function _u(e){let t=new Map;for(let n of e){let e=gu(n[0]).group;t.set(e,[...t.get(e)??[],n])}return[...t].map(([e,t])=>({group:e,items:t}))}var vu=e=>e.trim().replace(/\s+/g,`-`).replace(/[^\w/.-]/g,``).replace(/\/+/g,`/`).replace(/^\/|\/$/g,``);function yu({name:e,color:t,on:n,onApply:r,trail:i}){return(0,U.jsxs)(`div`,{className:`style-item ${n?`on`:``}`,children:[(0,U.jsxs)(`button`,{className:`style-apply color`,onClick:r,"data-tip":t,children:[(0,U.jsx)(`span`,{className:`swatch sm`,style:{background:t}}),(0,U.jsx)(`span`,{className:`style-name`,children:e}),(0,U.jsx)(`span`,{className:`style-meta`,children:t.replace(`#`,``).toUpperCase()})]}),i]})}var bu=`image/*,video/mp4,video/webm,video/quicktime`,xu=`Only images (PNG, JPEG, GIF, WebP, AVIF, SVG) and videos (MP4, WebM, MOV) can be dropped.`,Su=[`video/mp4`,`video/webm`,`video/quicktime`],Cu={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,mp4:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`};function wu(e){return e.type?e.type:Cu[e.name.split(`.`).pop()?.toLowerCase()??``]??``}function Tu(e){let t=wu(e);return t.startsWith(`image/`)?`image`:Su.includes(t)?`video`:null}function Eu(e){let t=[],n=[];for(let r of e)(Tu(r)?t:n).push(r);return{media:t,skipped:n}}var Du=1440;function Ou(e,t){let n=Math.min(1,Du/e);return{w:Math.round(e*n),h:Math.round(t*n)}}var ku=6e4,Au=1e3,ju=class extends Error{constructor(){super(`Couldn’t read that video’s size in time. Try again.`)}};function Mu(e,t,n=ku,r=Au){return new Promise((i,a)=>{let o=t?setTimeout(t,r):void 0,s=setTimeout(()=>{clearTimeout(o),a(new ju)},n),c=e=>{clearTimeout(o),clearTimeout(s),i(e)};e.onloadedmetadata=()=>c(!0),e.onerror=()=>c(!1)})}var Nu=class extends Error{constructor(){super(`it isn’t a video Nudge can read.`)}};function Pu(e,t){return`Couldn’t place ${e}: ${t instanceof Error?t.message:`something went wrong.`}`}async function Fu(e,t,n){if(t){let t=document.createElement(`video`);t.preload=`metadata`,t.muted=!0;let r=URL.createObjectURL(e);try{let e=Mu(t,n);if(t.src=r,!await e||!t.videoWidth||!t.videoHeight)throw new Nu;return{w:t.videoWidth,h:t.videoHeight}}finally{URL.revokeObjectURL(r)}}try{let t=await createImageBitmap(e),n={w:t.width,h:t.height};return t.close(),n}catch{return{w:400,h:300}}}async function Iu(e,t){let n=Tu(e)??`image`,{w:r,h:i}=await Fu(e,n===`video`,t),a=await fetch(`/api/asset?w=${r}&h=${i}`,{method:`POST`,headers:{"content-type":wu(e)||e.type},body:e}),o=await a.json();if(!a.ok)throw Error(o.error??`Couldn’t place that file`);return{asset:o.asset,kind:o.asset.kind===`video`?`video`:`image`,name:e.name.replace(/\.\w+$/,``)||(n===`video`?`Video`:`Image`),w:r,h:i}}function Lu(e,t,n=24){let r=e.reduce((e,t)=>e+t.w,0)+n*Math.max(0,e.length-1),i=Math.max(0,...e.map(e=>e.h)),a=t.x-r/2;return e.map(e=>{let r={x:a,y:t.y-i/2};return a+=e.w+n,r})}function Ru(e,t,n,r){let i=mt(e,n),a=i?e.nodes[i]:void 0;if(!i||a?.type!==`frame`)return{parent:null,index:null,line:null,highlight:null};let o=t.get(i)??null;if(a.layout.mode===`free`)return{parent:i,index:null,line:null,highlight:o};let s=An(e,t,i,[],r);return{parent:i,index:s.index,line:s.line,highlight:o}}function zu(e,t){let n=t?e.nodes[t]:void 0;return!n||!pt(e,n.id)?null:{parent:mt(e,n.id),x:n.x,y:n.y}}function Bu(e){return e.length===1?e[0].kind===`video`?`Place video`:`Place image`:`Place ${e.length} ${e.every(e=>e.kind===`video`)?`videos`:e.every(e=>e.kind===`image`)?`images`:`files`}`}function Vu(e,t,n,r,i){let a=i.map(e=>Ou(e.w,e.h)),o=n.index!==null,s=Lu(a,r),c=[...new Map(i.filter(t=>!e.assets[t.asset.id]).map(e=>[e.asset.id,e.asset])).values()],l=[],u=c.length?[{op:`asset`,add:c}]:[];return i.forEach((r,i)=>{let c=`media${i}`;l.push(c);let d=o?{x:0,y:0}:sn(e,t,n.parent,s[i])??s[i];u.push({op:`create`,parent:n.parent,...o?{index:n.index+i}:{},tree:{type:`frame`,key:c,name:r.name,w:a[i].w,h:a[i].h,fills:[{type:r.kind,asset:r.asset.id,fit:`cover`}],x:Math.round(d.x),y:Math.round(d.y)}})}),{ops:u,keys:l}}function Hu(e,t){let n=t?10:1;switch(e){case`ArrowRight`:return{dx:n,dy:0};case`ArrowLeft`:return{dx:-n,dy:0};case`ArrowUp`:return{dx:0,dy:n};case`ArrowDown`:return{dx:0,dy:-n};default:return null}}function Uu(e,t){let n=null,r=!1,i=t=>{r=t!==null,e(t)};return{get grab(){return n},start(e,t){n={d:e,fill:t,moved:!1}},move(e,t){return!n||!t&&!n.moved?!1:(n.moved=!0,i(e),!0)},end(e,a,o){let s=n;n=null,s&&(s.moved&&e&&a?(r=!1,t(e,o)):s.moved&&i(null))},cancel(){n=null,r&&i(null)}}}var Wu=.01,Gu=e=>e*Math.PI/180,Ku=e=>e*180/Math.PI,qu=(e,t,n)=>Math.min(n,Math.max(t,e)),Ju=e=>Math.round(e*100)/100,Yu=(e,t)=>((t?Math.round(e/15)*15:Math.round(e))%360+360)%360;function Xu(e,t,n,r=0){let i=Gu(n.turn),a={x:Math.cos(i),y:Math.sin(i)},o={x:-Math.sin(i),y:Math.cos(i)},s={x:n.cx*e,y:n.cy*t};return{center:s,rx:{x:s.x+a.x*n.rx*e,y:s.y+a.y*n.rx*e},ry:{x:s.x+o.x*n.ry*t,y:s.y+o.y*n.ry*t},turn:{x:s.x+a.x*(n.rx*e+r),y:s.y+a.y*(n.rx*e+r)}}}function Zu(e,t,n,r,i,a=!1){let o={x:r.cx*t,y:r.cy*n},s=i.x-o.x,c=i.y-o.y;if(e===`center`)return{center:[Ju(qu(i.x/t,0,1)),Ju(qu(i.y/n,0,1))]};if(e===`turn`)return s||c?{rotation:Yu(Ku(Math.atan2(c,s)),a)}:{};let l=Gu(r.turn),u=s*Math.cos(l)+c*Math.sin(l),d=-s*Math.sin(l)+c*Math.cos(l);return e===`rx`?{radius:[Ju(qu(Math.abs(u)/t,Wu,3)),r.ry]}:{radius:[r.rx,Ju(qu(Math.abs(d)/n,Wu,3))]}}function Qu(e,t,n){let r=Gu(n),i={x:Math.sin(r),y:-Math.cos(r)},a=Math.abs(e*i.x)+Math.abs(t*i.y),o={x:e/2,y:t/2};return{dir:i,len:a,start:{x:o.x-i.x*a/2,y:o.y-i.y*a/2},end:{x:o.x+i.x*a/2,y:o.y+i.y*a/2}}}function $u(e,t){return{x:e.start.x+(e.end.x-e.start.x)*t,y:e.start.y+(e.end.y-e.start.y)*t}}function ed(e,t,n){let r=t===`end`?1:-1,i=e[t];return{x:i.x+e.dir.x*n*r,y:i.y+e.dir.y*n*r}}function td(e,t,n,r,i=!1){let a=e===`end`?1:-1,o=(r.x-t/2)*a,s=(r.y-n/2)*a;return o||s?Yu(Ku(Math.atan2(o,-s)),i):null}function nd(e,t){return e.len?Ju(qu(((t.x-e.start.x)*e.dir.x+(t.y-e.start.y)*e.dir.y)/e.len,0,1)):0}var rd=(e,t,n)=>({x:t.x+e.x*n,y:t.y+e.y*n});function id(e){return e&&e.w>0&&e.h>0?qu(e.w/e.h,.5,3):2}var ad=[{mode:`hex`,label:`Hex`},{mode:`rgb`,label:`RGB`},{mode:`hsb`,label:`HSB`}],od=(e,t=0,n=1)=>Math.min(n,Math.max(t,e)),sd=e=>Math.round(od(e,0,255)).toString(16).padStart(2,`0`);function cd(e){let t=e.replace(`#`,``);(t.length===3||t.length===4)&&(t=[...t].map(e=>e+e).join(``));let n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,a=t.length===8?parseInt(t.slice(6,8),16)/255:1,o=Math.max(n,r,i),s=o-Math.min(n,r,i),c=0;return s&&(c=o===n?(r-i)/s%6:o===r?(i-n)/s+2:(n-r)/s+4),{h:(c*60+360)%360,s:o?s/o:0,v:o,a:Number.isFinite(a)?a:1}}function ld(e,t){let n=cd(e);return ud({...t,a:1})===ud({...n,a:1})?{...t,a:n.a}:n}function ud({h:e,s:t,v:n,a:r}){let i=r=>{let i=(r+e/60)%6;return n-n*t*Math.max(0,Math.min(i,4-i,1))},a=`#${sd(i(5)*255)}${sd(i(3)*255)}${sd(i(1)*255)}`;return r>=.995?a:`${a}${sd(r*255)}`}function dd(e){let t=ud({...e,a:1});return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}}function fd(e,t,n=0,r=0){let i=cd(`#${sd(e.r)}${sd(e.g)}${sd(e.b)}`);return{...i,h:i.s===0||i.v===0?n:i.h,s:i.v===0?r:i.s,a:t}}function pd(e){return{h:Math.round(e.h)%360,s:Math.round(e.s*100),b:Math.round(e.v*100)}}function md(e,t){return{h:od(e.h,0,359.9),s:od(e.s/100),v:od(e.b/100),a:t}}function hd(e,t){let n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?Math.min(t,Math.max(0,Math.round(Number(n)))):null}var gd={rgb:[{key:`r`,label:`Red`,max:255},{key:`g`,label:`Green`,max:255},{key:`b`,label:`Blue`,max:255}],hsb:[{key:`h`,label:`Hue`,max:360},{key:`s`,label:`Saturation`,max:100},{key:`b`,label:`Brightness`,max:100}]},_d=(e,t=0,n=1)=>Math.min(n,Math.max(t,e)),vd=(0,H.createContext)({styles:{},used:[],assets:{}});function yd(e,t=24){let n=new Set,r=r=>{if(!r||r===`transparent`)return;let i=(r.startsWith(`$`)?e.styles.colors[r.slice(1)]:r)?.toLowerCase();i&&n.size<t&&n.add(i)};for(let i of Object.values(e.nodes)){if(i.type===`frame`){for(let e of i.fills??[])e.type===`solid`&&r(e.color);r(i.stroke?.color)}i.type===`text`&&r(i.color);for(let e of i.effects??[])e.type===`shadow`&&r(e.color);if(n.size>=t)break}return{styles:e.styles.colors,used:[...n],assets:e.assets}}async function bd(e){let t=0,n=0;try{let r=await createImageBitmap(e);t=r.width,n=r.height,r.close()}catch{}let r=await fetch(`/api/asset${t&&n?`?w=${t}&h=${n}`:``}`,{method:`POST`,headers:{"content-type":e.type},body:e});return r.ok?(await r.json()).asset:null}async function xd(e=!1){let t=document.createElement(`input`);return t.type=`file`,t.accept=e?bu:`image/*`,new Promise(e=>{t.onchange=()=>e(t.files?.[0]??null),t.oncancel=()=>e(null),t.click()})}async function Sd(e){let t=await fetch(`/api/asset/url`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({url:e})}),n=await t.json();if(!t.ok)throw Error(n.error??`Couldn’t load that link.`);return n.asset}function Cd({paint:e,onCommit:t,video:n=!1}){let r=(0,H.useContext)(vd),[i,a]=(0,H.useState)(e?.fit??`cover`),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=e=>{e&&t({type:`image`,asset:e.id,fit:i===`crop`?`cover`:i},e)},h=async e=>{d(!0),p(null);try{m(await e())}catch(e){p(e.message)}finally{d(!1)}},g=async e=>{if(!(n&&Tu(e)===`video`))return h(()=>bd(e));d(!0),p(null);try{let n=await Iu(e);t({type:`video`,asset:n.asset.id,fit:i===`crop`?`cover`:i},n.asset)}catch(e){p(e.message)}finally{d(!1)}},_=async()=>{let e=await xd(n);e&&await g(e)},v=n?`an image or video`:`an image`,y=e&&r.assets[e.asset]?.file;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsx)(`select`,{value:i,"aria-label":`Image scale`,onChange:n=>{let r=n.target.value;if(r===`crop`)window.dispatchEvent(new CustomEvent(Td));else if(a(r),e){let{crop:n,...i}=e;t({...i,fit:r})}},children:wd.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(`button`,{className:`cp-drop ${c?`over`:``} ${y?`has`:``}`,disabled:u,style:y?{backgroundImage:`url("/design/${y}")`,backgroundSize:i===`fill`?`100% 100%`:i===`crop`?`cover`:i}:void 0,onClick:()=>void _(),onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:e=>{e.preventDefault(),l(!1);let t=[...e.dataTransfer.files].find(e=>Tu(e)===`image`||n&&Tu(e)===`video`),r=e.dataTransfer.getData(`text/uri-list`)||e.dataTransfer.getData(`text/plain`);t?g(t):/^https?:\/\//.test(r)&&h(()=>Sd(r.trim()))},children:(0,U.jsx)(`span`,{className:`cp-drop-label`,children:u?`Loading…`:y?`Drop or click to replace`:`Drop ${v}, or click to choose`})}),(0,U.jsxs)(`div`,{className:`cp-url`,children:[(0,U.jsx)(`input`,{value:o,placeholder:`Image URL`,"aria-label":`Image URL`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&h(()=>Sd(o.trim()))}}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Upload from computer`,"data-tip":`Upload from computer`,disabled:u,onClick:()=>void _(),children:(0,U.jsx)(X.upload,{})})]}),f&&(0,U.jsx)(`p`,{className:`cp-error`,role:`alert`,children:f})]})}var wd=[[`cover`,`Fill`],[`contain`,`Fit`],[`fill`,`Stretch`],[`crop`,`Crop`]],Td=`nudge:crop`,Ed=[{kind:`solid`,label:`Solid`,icon:X.paintSolid},{kind:`linear`,label:`Linear gradient`,icon:X.paintGradient},{kind:`radial`,label:`Radial gradient`,icon:X.paintRadial},{kind:`image`,label:`Image`,icon:X.image},{kind:`shader`,label:`Shader`,icon:X.shader}];function Dd(){let e=(0,H.useRef)(!1);return{active:e,bind:(t,n)=>({onPointerDown:n=>{n.currentTarget.setPointerCapture(n.pointerId),e.current=!0,t(n,n.currentTarget.getBoundingClientRect())},onPointerMove:n=>{e.current&&t(n,n.currentTarget.getBoundingClientRect())},onPointerUp:()=>{e.current&&(e.current=!1,n())}})}}function Od(e,t){return n=>({tabIndex:0,role:`slider`,"aria-label":n.label,"aria-valuemin":n.min,"aria-valuemax":n.max,"aria-valuenow":n.now,"aria-valuetext":n.text,onKeyDown:t=>{let r=t.metaKey||t.ctrlKey||t.altKey?null:Hu(t.key,t.shiftKey);r&&(t.preventDefault(),e.current=!0,n.step(r.dx,r.dy))},onKeyUp:n=>{e.current&&ac(n.key)&&(e.current=!1,t())},onBlur:()=>{e.current&&(e.current=!1,t())}})}var kd=`hex`;function Ad({label:e,value:t,max:n,onLive:r,onCommit:i}){let[a,o]=(0,H.useState)(null),s=(0,H.useRef)(null),c=e=>{s.current=e,o(String(e)),r(e)},l=()=>{let e=s.current;s.current=null,o(null),e!==null&&i(e)},u=Yl({from:()=>t,clamp:e=>Math.min(n,Math.max(0,e)),onScrub:c,onDone:e=>{e!==null&&l()},click:e=>e.focus()});return(0,U.jsx)(`input`,{className:`cp-hex cp-chan cp-scrub`,value:a??String(t),"aria-label":e,inputMode:`numeric`,spellCheck:!1,...u,onFocus:e=>e.currentTarget.select(),onChange:e=>{o(e.target.value);let t=hd(e.target.value,n);t===null?s.current=null:(s.current=t,r(t))},onKeyDown:e=>{if(e.key===`Enter`){e.currentTarget.blur();return}let r=e.metaKey||e.ctrlKey||e.altKey?null:Hu(e.key,e.shiftKey);r&&r.dy&&(e.preventDefault(),c(Math.min(n,Math.max(0,(hd(a??String(t),n)??t)+r.dy))))},onKeyUp:e=>{s.current!==null&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&l()},onBlur:l})}function jd({color:e,onChange:t}){let[n,r]=(0,H.useState)(()=>cd(e)),[i,a]=(0,H.useState)(e.slice(1,7).toUpperCase()),[o,s]=(0,H.useState)(kd),c=Dd(),l=(0,H.useRef)(n),u=(0,H.useRef)(!1),d=(0,H.useRef)(!1),f=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(c.active.current||u.current||d.current)return;let t=ld(e,l.current);r(t),l.current=t,a(e.slice(1,7).toUpperCase())},[e]);let p=(e,n)=>{r(e),l.current=e,a(ud({...e,a:1}).slice(1).toUpperCase()),t(ud(e),n)},m=window.EyeDropper,h=ud({h:n.h,s:1,v:1,a:1}),g=ud({...n,a:1}),_=()=>t(ud(l.current),!0),v=Od(u,_),y=e=>Math.round(e*100),b=o===`rgb`?Object.values(dd(n)):o===`hsb`?Object.values(pd(n)):[],x=(e,t,n)=>{let r=b.map((n,r)=>r===e?t:n),i=l.current;p(o===`rgb`?fd({r:r[0],g:r[1],b:r[2]},i.a,i.h,i.s):md({h:r[0],s:r[1],b:r[2]},i.a),n)},S=Yl({from:()=>Math.round(l.current.a*100),clamp:e=>Math.min(100,Math.max(0,e)),onScrub:e=>p({...l.current,a:e/100},!1),onDone:e=>{e!==null&&_()},click:e=>e.focus()});return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`cp-sv`,style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${h})`},...v({label:`Saturation and brightness`,min:0,max:100,now:y(n.s),text:`Saturation ${y(n.s)}%, brightness ${y(n.v)}%`,step:(e,t)=>p({...l.current,s:_d(l.current.s+e/100),v:_d(l.current.v+t/100)},!1)}),...c.bind((e,t)=>p({...l.current,s:_d((e.clientX-t.left)/t.width),v:_d(1-(e.clientY-t.top)/t.height)},!1),_),children:(0,U.jsx)(`span`,{className:`cp-knob`,style:{left:`${n.s*100}%`,top:`${(1-n.v)*100}%`,background:g}})}),(0,U.jsxs)(`div`,{className:`cp-sliders`,children:[m?(0,U.jsx)(`button`,{className:`icon-btn fit cp-eye`,"aria-label":`Pick a color from the screen`,"data-tip":`Eyedropper`,"data-kbd":`I`,onClick:async()=>{try{let e=await new m().open();p({...cd(e.sRGBHex),a:l.current.a},!0)}catch{}},children:(0,U.jsx)(X.eyedropper,{})}):(0,U.jsx)(`span`,{}),(0,U.jsxs)(`div`,{className:`cp-tracks`,children:[(0,U.jsx)(`div`,{className:`cp-track cp-hue`,...v({label:`Hue`,min:0,max:360,now:Math.round(n.h),text:`${Math.round(n.h)}°`,step:(e,t)=>p({...l.current,h:Math.min(359.9,Math.max(0,l.current.h+(e||t)))},!1)}),...c.bind((e,t)=>p({...l.current,h:_d((e.clientX-t.left)/t.width)*359.9},!1),_),children:(0,U.jsx)(`span`,{className:`cp-knob`,style:{left:`${n.h/360*100}%`,background:h}})}),(0,U.jsx)(`div`,{className:`cp-track cp-alpha`,style:{"--solid":g},...v({label:`Opacity`,min:0,max:100,now:y(n.a),text:`${y(n.a)}%`,step:(e,t)=>p({...l.current,a:_d(l.current.a+(e||t)/100)},!1)}),...c.bind((e,t)=>p({...l.current,a:_d((e.clientX-t.left)/t.width)},!1),_),children:(0,U.jsx)(`span`,{className:`cp-knob`,style:{left:`${n.a*100}%`}})})]})]}),(0,U.jsxs)(`div`,{className:`cp-fields cp-mode-${o}`,onFocus:()=>{d.current=!0},onBlur:()=>{d.current=!1},children:[(0,U.jsxs)(`div`,{className:`select-wrap sm cp-mode`,children:[(0,U.jsx)(`select`,{value:o,"aria-label":`Color mode`,onChange:e=>{let t=e.target.value;kd=t,s(t)},children:ad.map(e=>(0,U.jsx)(`option`,{value:e.mode,children:e.label},e.mode))}),(0,U.jsx)(X.chevronDown,{})]}),o===`hex`?(0,U.jsx)(`input`,{className:`cp-hex`,value:i,"aria-label":`Hex`,spellCheck:!1,onChange:e=>{let t=e.target.value.toUpperCase();a(t);let n=/^#?([0-9A-F]{6}|[0-9A-F]{8})$/.test(t)?Kl(t,ud(l.current)):null;n&&(f.current=!0,p(cd(n),!1),a(t))},onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:()=>{let e=ud(l.current),t=Kl(i,e),n=f.current;f.current=!1,t&&(t!==e||n)?p(cd(t),!0):a(g.slice(1).toUpperCase())}}):gd[o].map((e,t)=>(0,U.jsx)(Ad,{label:e.label,max:e.max,value:b[t],onLive:e=>x(t,e,!1),onCommit:e=>x(t,e,!0)},`${o}${e.key}`)),(0,U.jsx)(`input`,{className:`cp-pct cp-scrub`,value:Math.round(n.a*100),"aria-label":`Opacity`,inputMode:`numeric`,...S,onChange:e=>{let t=Number(e.target.value);if(Number.isFinite(t)){let e={...n,a:_d(t/100)};r(e),l.current=e}},onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:()=>t(ud(l.current),!0)}),(0,U.jsx)(`span`,{className:`cp-unit`,children:`%`})]})]})}function Md({onPick:e}){let{used:t}=(0,H.useContext)(vd);return t.length?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`cp-caption`,children:`On this canvas`}),(0,U.jsx)(`div`,{className:`cp-swatches`,children:t.map(t=>(0,U.jsx)(`button`,{className:`cp-swatch`,style:{"--c":t},"aria-label":t,"data-tip":t,onClick:()=>e(t)},t))})]}):null}var Nd=e=>`linear-gradient(to right, ${[...e].sort((e,t)=>e.at-t.at).map(e=>`${e.color} ${e.at*100}%`).join(`, `)})`,Pd=(e,t)=>e.map(e=>({...e,color:e.color.startsWith(`$`)?t[e.color.slice(1)]??`#000000`:e.color})),Fd=e=>{let t=me(e);return{center:[t.cx,t.cy],radius:[t.rx,t.ry],rotation:ct(e)}},Id=e=>Math.round(e*100)/100;function Ld({stops:e,center:t,radius:n,rotation:r,aspect:i,onChange:a,onRevert:o}){let s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(!1),u=(0,H.useRef)({center:t,radius:n});!c.current&&!l.current&&(u.current={center:t,radius:n});let[d,f]=u.current.center,[p,m]=u.current.radius,h=(e,t)=>{u.current={center:e.center??u.current.center,radius:e.radius??u.current.radius},a(e,t)},g=Od(l,()=>a({center:u.current.center,radius:u.current.radius},!0)),_={cx:d,cy:f,rx:p,ry:m,turn:r},v=Xu(i,1,_),y=e=>{let t=s.current.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*i,y:(e.clientY-t.top)/t.height}},b=(e,t)=>Zu(e,i,1,_,y(t)),x=(0,H.useRef)({center:t,radius:n,moved:!1}),S=e=>(e.center??x.current.center).join()===x.current.center.join()&&(e.radius??x.current.radius).join()===x.current.radius.join(),C=e=>({onPointerDown:r=>{r.preventDefault(),r.currentTarget.setPointerCapture(r.pointerId),r.currentTarget.focus(),c.current=e,x.current={center:t,radius:n,moved:!1}},onPointerMove:t=>{if(c.current!==e)return;let n=b(e,t);S(n)||(x.current.moved=!0),x.current.moved&&h(n,!1)},onPointerUp:r=>{if(c.current!==e)return;c.current=null;let i=b(e,r),a=lu(x.current.moved,!S(i));a===`commit`?h(i,!0):a===`revert`&&(u.current={center:t,radius:n},o())}}),w=e=>({left:`${Id(_d(e.x/i))*100}%`,top:`${Id(_d(e.y))*100}%`}),T=e=>Math.round(e*100),E=ct({rotation:r})!==0,D=nt({type:`radial`,center:[d,f],radius:[p,m],rotation:r,stops:e},e=>e);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{ref:s,className:`cp-radial`,style:{aspectRatio:String(i),"--g":E?`none`:De({type:`radial`,center:t,radius:n,stops:e},e=>e)},children:[E&&(0,U.jsx)(`span`,{className:`cp-radial-clip`,style:{background:D.background},children:(0,U.jsx)(`span`,{className:`cp-radial-turned`,style:D.ellipse})}),(0,U.jsx)(`span`,{className:`cp-radial-clip`,children:(0,U.jsx)(`span`,{className:`cp-radial-ellipse`,style:{left:`${(d-p)*100}%`,top:`${(f-m)*100}%`,width:`${p*200}%`,height:`${m*200}%`,transform:`rotate(${r}deg)`}})}),(0,U.jsx)(`span`,{className:`cp-knob cp-radial-handle`,style:w(v.rx),...C(`rx`),...g({label:`Radius width`,min:1,max:300,now:T(p),text:`${T(p)}%`,step:e=>h({radius:[Id(_d(p+e/100,Wu,3)),m]},!1)})}),(0,U.jsx)(`span`,{className:`cp-knob cp-radial-handle`,style:w(v.ry),...C(`ry`),...g({label:`Radius height`,min:1,max:300,now:T(m),text:`${T(m)}%`,step:(e,t)=>h({radius:[p,Id(_d(m-t/100,Wu,3))]},!1)})}),(0,U.jsx)(`span`,{className:`cp-knob cp-radial-handle center`,style:w(v.center),...C(`center`),...g({label:`Center`,min:0,max:100,now:T(d),text:`${T(d)}% across, ${T(f)}% down`,step:(e,t)=>h({center:[Id(_d(d+e/100)),Id(_d(f-t/100))]},!1)})})]}),(0,U.jsxs)(`div`,{className:`cp-fields cp-pair`,children:[(0,U.jsx)(`span`,{className:`cp-label`,children:`Center`}),(0,U.jsx)(Ad,{label:`Center X`,max:100,value:T(d),onLive:e=>h({center:[e/100,f]},!1),onCommit:e=>h({center:[e/100,f]},!0)}),(0,U.jsx)(Ad,{label:`Center Y`,max:100,value:T(f),onLive:e=>h({center:[d,e/100]},!1),onCommit:e=>h({center:[d,e/100]},!0)}),(0,U.jsx)(`span`,{className:`cp-unit`,children:`%`})]}),(0,U.jsxs)(`div`,{className:`cp-fields cp-pair`,children:[(0,U.jsx)(`span`,{className:`cp-label`,children:`Radius`}),(0,U.jsx)(Ad,{label:`Radius X`,max:300,value:T(p),onLive:e=>h({radius:[Math.max(Wu,e/100),m]},!1),onCommit:e=>h({radius:[Math.max(Wu,e/100),m]},!0)}),(0,U.jsx)(Ad,{label:`Radius Y`,max:300,value:T(m),onLive:e=>h({radius:[p,Math.max(Wu,e/100)]},!1),onCommit:e=>h({radius:[p,Math.max(Wu,e/100)]},!0)}),(0,U.jsx)(`span`,{className:`cp-unit`,children:`%`})]}),(0,U.jsxs)(`div`,{className:`cp-fields cp-pair`,children:[(0,U.jsx)(`span`,{className:`cp-label`,children:`Rotation`}),(0,U.jsx)(Ad,{label:`Rotation`,max:359,value:Math.round(ct({rotation:r})),onLive:e=>a({rotation:e},!1),onCommit:e=>a({rotation:e},!0)}),(0,U.jsx)(`span`,{className:`cp-unit`,children:`°`})]})]})}function Rd({value:e,aspect:t,onChange:n,onRevert:r}){let i=e.stops,[a,o]=(0,H.useState)(0),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=(0,H.useRef)({at:0,moved:!1}),u=i[Math.min(a,i.length-1)],d=e.type===`linear`?e.angle:0,[f,p]=(0,H.useState)(String(d)),m=(0,H.useRef)(!1);(0,H.useEffect)(()=>{m.current||p(String(d))},[d]);let h=e=>(Math.round(e)%360+360)%360,g=Yl({from:()=>d,clamp:e=>e,onScrub:e=>{p(String(h(e))),n({angle:h(e)},!1)},onDone:e=>{e!==null&&n({angle:h(e)},!0)},click:e=>e.focus()}),_=e=>{let t=s.current.getBoundingClientRect();return _d((e.clientX-t.left)/t.width)},v=(e,t)=>i.map((n,r)=>r===e?{...n,at:Math.round(_(t)*100)/100}:n);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`cp-grad-row`,children:[(0,U.jsx)(`div`,{ref:s,className:`cp-grad-bar`,style:{"--g":Nd(i)},onPointerDown:e=>{if(e.target.closest(`.cp-stop`))return;let t=cu(i,{color:u.color,at:Math.round(_(e)*100)/100});o(t.index),n({stops:t.stops},!0)},children:i.map((e,t)=>(0,U.jsx)(`span`,{className:`cp-stop ${t===a?`on`:``}`,style:{left:`${e.at*100}%`,"--c":e.color},role:`button`,"aria-label":`Stop ${Math.round(e.at*100)}%`,onPointerDown:n=>{n.stopPropagation(),n.currentTarget.setPointerCapture(n.pointerId),o(t),c.current=t,l.current={at:e.at,moved:!1}},onPointerMove:e=>{if(c.current!==t)return;let r=v(t,e);r[t].at!==l.current.at&&(l.current.moved=!0),l.current.moved&&n({stops:r},!1)},onPointerUp:e=>{if(c.current!==t)return;c.current=null;let i=v(t,e),a=lu(l.current.moved,i[t].at!==l.current.at);a===`commit`?n({stops:i},!0):a===`revert`&&r()}},t))}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove stop`,"data-tip":`Remove stop`,disabled:i.length<=2,onClick:()=>{let e=i.filter((e,t)=>t!==a);o(0),n({stops:e},!0)},children:(0,U.jsx)(X.minus,{})})]}),e.type===`linear`?(0,U.jsxs)(`div`,{className:`cp-fields cp-angle`,children:[(0,U.jsx)(`span`,{className:`cp-label`,children:`Angle`}),(0,U.jsx)(`input`,{className:`cp-hex cp-scrub`,value:f,"aria-label":`Angle`,inputMode:`numeric`,...g,onFocus:e=>{m.current=!0,e.currentTarget.select()},onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:e=>{m.current=!1;let t=Number(e.target.value);Number.isFinite(t)&&h(t)!==d?n({angle:h(t)},!0):p(String(d))}}),(0,U.jsx)(`span`,{className:`cp-unit`,children:`°`}),(0,U.jsxs)(`span`,{className:`cp-unit`,children:[Math.round(u.at*100),`%`]})]}):(0,U.jsx)(Ld,{stops:i,center:e.center,radius:e.radius,rotation:e.rotation,aspect:t,onChange:n,onRevert:r}),(0,U.jsx)(jd,{color:u.color,onChange:(e,t)=>n({stops:i.map((t,n)=>n===a?{...t,color:e}:t)},t)}),(0,U.jsx)(Md,{onPick:e=>n({stops:i.map((t,n)=>n===a?{...t,color:e}:t)},!0)})]})}function zd({paint:e,style:t,kinds:n=[`solid`],video:r=!1,onPreview:i,onCommit:a,onClose:o,at:s,blend:c,shaderControls:l,box:u}){let d=(0,H.useContext)(vd),f=(0,H.useRef)({onPreviewProp:i,onCommitProp:a});f.current={onPreviewProp:i,onCommitProp:a};let p=(0,H.useRef)(null);p.current??=uu(e=>f.current.onPreviewProp(e),(e,t)=>f.current.onCommitProp(e,t)),(0,H.useEffect)(()=>()=>p.current?.dispose(),[]);let m=p.current.preview,h=p.current.commit,[g,_]=(0,H.useState)(`custom`),[v,y]=(0,H.useState)(n.includes(e.type)?e.type:`solid`),[b,x]=(0,H.useState)(``),S=(e,t)=>t?h(e):m(e),C=(0,H.useRef)(!1),[w,T]=(0,H.useState)(e.type===`shader`?e.shader.name:null),[E,D]=(0,H.useState)(!1);(0,H.useEffect)(()=>{C.current||T(e.type===`shader`?e.shader.name:null)},[e]);let O=e.type===`solid`?e.color:e.type===`linear`||e.type===`radial`?e.stops[0].color:ae,k=async t=>{if(y(t),t!==e.type){if(t===`solid`)return h({type:`solid`,color:O});if(t===`linear`||t===`radial`){let n=e.type===`linear`||e.type===`radial`?e.stops:(()=>{let e=O.startsWith(`$`)?d.styles[O.slice(1)]??`#000000`:O;return[{color:e.slice(0,7),at:0},{color:`${e.slice(0,7)}00`,at:1}]})();return h(t===`linear`?{type:`linear`,angle:180,stops:n}:{type:`radial`,stops:n})}if(t===`shader`)return h({type:`shader`,shader:structuredClone(Ie[0])})}},A=Object.entries(d.styles).filter(([e,t])=>!b||e.toLowerCase().includes(b.toLowerCase())||t.toLowerCase().includes(b.toLowerCase()));return(0,U.jsx)(mu,{title:``,titleNode:(0,U.jsxs)(`span`,{className:`text-tabs`,role:`tablist`,children:[(0,U.jsx)(`button`,{role:`tab`,"aria-selected":g===`custom`,className:g===`custom`?`on`:``,onClick:()=>_(`custom`),children:`Custom`}),(0,U.jsx)(`button`,{role:`tab`,"aria-selected":g===`styles`,className:g===`styles`?`on`:``,onClick:()=>_(`styles`),children:`Styles`})]}),onClose:o,width:248,className:`color-picker`,at:s,children:g===`styles`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{className:`floating-search`,children:[(0,U.jsx)(X.search,{}),(0,U.jsx)(`input`,{value:b,placeholder:`Search`,"aria-label":`Search styles`,onChange:e=>x(e.target.value)})]}),A.length?(0,U.jsx)(`div`,{className:`floating-list`,children:A.map(([e,n])=>(0,U.jsx)(yu,{name:e,color:n,on:t===e,onApply:()=>h({type:`solid`,color:`$${e}`})},e))}):(0,U.jsxs)(`p`,{className:`muted`,children:[`No color styles`,b?` match`:` yet`,`.`]})]}):(0,U.jsxs)(U.Fragment,{children:[(n.length>1||c)&&(0,U.jsxs)(`div`,{className:`cp-kinds`,children:[n.length>1&&(0,U.jsx)(`span`,{className:`cp-kind-list`,role:`radiogroup`,"aria-label":`Fill type`,children:Ed.filter(e=>n.includes(e.kind)).map(e=>(0,U.jsx)(`button`,{className:`icon-btn fit ${v===e.kind?`on`:``}`,role:`radio`,"aria-checked":v===e.kind,"aria-label":e.kind===`image`&&r?`Image or video`:e.label,"data-tip":e.kind===`image`&&r?`Image or video`:e.label,onClick:()=>void k(e.kind),children:(0,U.jsx)(e.icon,{})},e.kind))}),c&&(0,U.jsx)(su,{label:`Fill blend`,value:c.value,onPick:c.onPick,onPreview:c.onPreview})]}),v===`solid`&&e.type===`solid`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jd,{color:e.color.startsWith(`$`)?d.styles[e.color.slice(1)]??`#000000`:e.color,onChange:(t,n)=>S({...e,color:t},n)}),(0,U.jsx)(Md,{onPick:t=>h({...e,color:t})})]}),v===`linear`&&e.type===`linear`&&(0,U.jsx)(Rd,{aspect:id(u),value:{type:`linear`,angle:e.angle,stops:Pd(e.stops,d.styles)},onChange:(t,n)=>S(fu(e,t),n),onRevert:()=>m(null)}),v===`radial`&&e.type===`radial`&&(0,U.jsx)(Rd,{aspect:id(u),value:{type:`radial`,center:Fd(e).center,radius:Fd(e).radius,rotation:Fd(e).rotation,stops:Pd(e.stops,d.styles)},onChange:(t,n)=>S(fu(e,t),n),onRevert:()=>m(null)}),v===`image`&&(0,U.jsx)(Cd,{paint:e.type===`image`?e:null,onCommit:h,video:r}),v===`shader`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{className:`cp-shader-menu ${E?`open`:``}`,"aria-expanded":E,onClick:()=>D(!E),children:[e.type===`shader`&&(0,U.jsx)(`span`,{className:`cp-shader-thumb`,children:(0,U.jsx)(et,{shader:e.shader})}),(0,U.jsx)(`span`,{children:e.type===`shader`?e.shader.name:`Choose a shader`}),(0,U.jsx)(X.chevronDown,{})]}),E&&(0,U.jsxs)(`div`,{className:`cp-shaders`,role:`list`,children:[Ie.map(e=>(0,U.jsxs)(`button`,{role:`listitem`,className:`cp-shader ${w===e.name?`on`:``}`,"aria-current":w===e.name||void 0,onMouseEnter:()=>{C.current=!0,m({type:`shader`,shader:e})},onMouseLeave:()=>{C.current=!1,m(null)},onClick:()=>{C.current=!1,T(e.name),D(!1),h({type:`shader`,shader:structuredClone(e)})},children:[(0,U.jsx)(`span`,{className:`cp-shader-thumb`,children:(0,U.jsx)(et,{shader:e})}),(0,U.jsx)(`span`,{children:e.name})]},e.name)),(0,U.jsx)(`p`,{className:`muted cp-shader-hint`,children:`Or ask your agent for one: describe the look, it writes the shader.`})]}),!E&&e.type===`shader`&&l?.(e.shader,t=>m(t?{...e,shader:t}:null),t=>h({...e,shader:t}))]})]})})}function Bd({value:e,onPreview:t,onCommit:n,onClose:r,at:i}){return(0,U.jsx)(zd,{paint:{type:`solid`,color:e},at:i,style:e.startsWith(`$`)?e.slice(1):void 0,onPreview:e=>t(e&&e.type===`solid`?e.color:null),onCommit:e=>{e.type===`solid`&&n(e.color)},onClose:r})}function Vd(e,t,n=320){let[r,i]=(0,H.useState)();return(0,H.useLayoutEffect)(()=>{if(!e)return;let r=()=>{let e=t.current?.getBoundingClientRect();if(!e)return;let r=V(`--gap-l`),a=innerHeight-e.bottom-r,o=e.top-r;i(a<Math.min(n,200)&&o>a?{top:`auto`,bottom:`calc(100% + 4px)`,maxHeight:Math.min(n,o),overflowY:`auto`}:{maxHeight:Math.max(80,Math.min(n,a)),overflowY:`auto`})};return r(),addEventListener(`resize`,r),()=>removeEventListener(`resize`,r)},[e,t,n]),e?r:void 0}var Hd=`Pretendard.Pretendard Variable.Apple SD Gothic Neo.Noto Sans KR.Noto Serif KR.Nanum Gothic.Nanum Myeongjo.Spoqa Han Sans Neo.SUIT.Wanted Sans.Inter.SF Pro Display.SF Pro Text.Helvetica Neue.Helvetica.Arial.Roboto.Montserrat.Poppins.IBM Plex Sans.IBM Plex Mono.Georgia.Times New Roman.Menlo.Courier New.JetBrains Mono`.split(`.`),Ud=e=>e.split(`,`)[0].trim().replace(/^["']|["']$/g,``);function Wd(e){let t=document.createElement(`canvas`).getContext(`2d`),n=`mmmmmmmmmmlli 가나다라마바사`;return[`monospace`,`serif`].some(r=>{t.font=`72px ${r}`;let i=t.measureText(n).width;return t.font=`72px "${e}", ${r}`,t.measureText(n).width!==i})}var Gd=null,Kd=()=>Gd??=fetch(`/api/fonts`).then(e=>e.json()).then(e=>e.families??[]).catch(()=>[]),qd=40;function Jd({value:e,doc:t,onPick:n,onPreview:r}){let i=typeof e==`string`?Ud(e):``,[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(0),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(!1),h=(0,H.useRef)(null),g=Vd(a,h),_=(0,H.useMemo)(()=>{let e=new Set;for(let n of Object.values(t.assets))n.kind===`font`&&n.family&&e.add(n.family);for(let n of Object.values(t.nodes))n.type===`text`&&n.fontFamily&&e.add(Ud(n.fontFamily));for(let n of Object.values(t.styles.text))e.add(Ud(n.fontFamily));return[...e].sort()},[a]),v=(0,H.useMemo)(()=>a?Hd.filter(Wd):[],[a]),[y,b]=(0,H.useState)([]);(0,H.useEffect)(()=>{a&&!y.length&&Kd().then(b)},[a,y.length]);let x=(0,H.useMemo)(()=>{if(!a||!y.length)return new Set;let e=new Set(y);return new Set(_.filter(t=>!e.has(t)&&!Wd(t)))},[a,y,_]),S=(0,H.useMemo)(()=>{let e=e=>e.filter(e=>e.toLowerCase().includes(s.trim().toLowerCase())),t=new Set,n=n=>e(n).filter(e=>!t.has(e)&&t.add(e)),r=s.trim().toLowerCase(),i=r?n(y).sort((e,t)=>Number(!e.toLowerCase().startsWith(r))-Number(!t.toLowerCase().startsWith(r))).slice(0,qd):[];return[{title:`In this file`,items:n(_)},{title:`Installed`,items:n(d??v)},{title:`Google Fonts`,items:i}].filter(e=>e.items.length)},[s,_,v,d,y]),C=S.flatMap(e=>e.items),w=S.find(e=>e.title===`Google Fonts`)?.items.join(`|`)??``;(0,H.useEffect)(()=>{if(!w)return;let e=document.createElement(`link`);return e.rel=`stylesheet`,e.href=`/design/fonts.css?families=${encodeURIComponent(w)}`,document.head.appendChild(e),()=>e.remove()},[w]);let T=(0,H.useRef)(!1),E=(0,H.useRef)(i);(0,H.useEffect)(()=>{a?(T.current=!1,E.current=i):T.current||r?.(null)},[a]);let D=a?E.current:i;(0,H.useEffect)(()=>{if(!a)return;let e=e=>{h.current?.contains(e.target)||o(!1)};return addEventListener(`pointerdown`,e,!0),()=>removeEventListener(`pointerdown`,e,!0)},[a]);let O=e=>{T.current=e!==E.current,o(!1),c(``),e!==E.current&&n(e)},k=e=>{u(e);let t=C[e];t&&r?.(t)},A=async()=>{try{let e=await window.queryLocalFonts();if(!e.length)return m(!0);f([...new Set(e.map(e=>e.family))].sort())}catch{m(!0)}};return(0,U.jsxs)(`div`,{className:`font-picker`,ref:h,children:[(0,U.jsx)(`input`,{className:`full text-in`,"aria-label":`Font`,value:a?s:i,placeholder:e===Z?`Mixed`:a?D||`Search fonts`:`Pretendard`,style:!a&&i?{fontFamily:`"${i}", var(--font)`}:void 0,onFocus:()=>{o(!0),c(``),u(0)},onChange:e=>{c(e.target.value),u(0),o(!0)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`&&(e.preventDefault(),k(Math.min(C.length-1,l+1))),e.key===`ArrowUp`&&(e.preventDefault(),k(Math.max(0,l-1))),e.key===`Enter`){e.preventDefault();let t=C[l];t&&O(t),e.currentTarget.blur()}e.key===`Escape`&&(o(!1),e.currentTarget.blur())}}}),a&&(0,U.jsxs)(`div`,{className:`font-menu`,role:`listbox`,style:g,onMouseLeave:()=>r?.(null),children:[S.map(e=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`font-group`,children:e.title}),e.items.map(e=>{let t=C.indexOf(e);return(0,U.jsxs)(`button`,{role:`option`,"aria-selected":e===D,className:`${t===l?`hi`:``} ${e===D?`on`:``}`,style:{fontFamily:`"${e}", var(--font)`},onMouseEnter:()=>k(t),onClick:()=>O(e),children:[(0,U.jsx)(`span`,{className:`font-name`,children:e}),x.has(e)&&(0,U.jsx)(`span`,{className:`font-missing`,title:`Not installed here and not a web font: the canvas draws a fallback`,children:`Missing`}),e===D&&(0,U.jsx)(`span`,{className:`font-check`,children:(0,U.jsx)(X.check,{})})]},e)})]},e.title)),!C.length&&s.trim()&&(0,U.jsxs)(`div`,{className:`font-none`,children:[`No fonts match “`,s.trim(),`”`]}),p?(0,U.jsx)(`div`,{className:`font-none`,children:`This browser didn’t share the fonts installed on this computer. Allow fonts for this page, or open the canvas in a browser that can list them, to see them all.`}):!d&&`queryLocalFonts`in window&&(0,U.jsx)(`button`,{className:`font-more`,onClick:()=>void A(),children:`Show all installed fonts…`}),!p&&!(`queryLocalFonts`in window)&&(0,U.jsx)(`div`,{className:`font-none`,children:`This browser can’t list the fonts installed on this computer: open the canvas in a browser that can to see them all.`})]})]})}var Yd=[[100,`Thin`],[200,`Extra Light`],[300,`Light`],[400,`Regular`],[500,`Medium`],[600,`Semi Bold`],[700,`Bold`],[800,`Extra Bold`],[900,`Black`]].flatMap(([e,t])=>[[`${e}`,t],[`${e}i`,e===400?`Italic`:`${t} Italic`]]),Xd=(e,t)=>`${e}${t===`italic`?`i`:``}`,Zd=(e,t)=>Yd.find(([n])=>n===Xd(e,t))?.[1]??`${e}${t===`italic`?` Italic`:``}`,Qd=e=>({fontWeight:parseInt(e),fontStyle:e.endsWith(`i`)?`italic`:null}),$d=[{i:0,name:`Top left`,rot:0},{i:1,name:`Top right`,rot:90},{i:3,name:`Bottom left`,rot:270},{i:2,name:`Bottom right`,rot:180}];function ef({doc:e,values:t,label:n=(0,U.jsx)(X.radius,{}),single:r=!1,onPreview:i,onCommit:a}){let[o,s]=(0,H.useState)(!1),c=(0,H.useRef)(null),l=Vd(o,c,240);(0,H.useEffect)(()=>{if(!o)return;let e=e=>{c.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),s(!1))};return addEventListener(`pointerdown`,e,!0),addEventListener(`keydown`,t,!0),()=>{removeEventListener(`pointerdown`,e,!0),removeEventListener(`keydown`,t,!0)}},[o]);let u=t=>{let n=Ee(e,t)??0;return Array.isArray(n)?[...n]:[n,n,n,n]},d=e=>e.length?e.every(t=>JSON.stringify(t)===JSON.stringify(e[0]))?e[0]:Z:void 0,f=d(t.map(e=>e??0)),[p,m]=(0,H.useState)(()=>t.some(e=>Array.isArray(e))),h=p&&!r,g=Object.entries(e.styles.radius??{}),_=typeof f==`string`&&f.startsWith(`$`)?f:null,v=r&&t.length?d(t.map(e=>u(e)[0])):f===Z||f===void 0?f:d(u(f)),y=e=>d(t.map(t=>u(t)[e])),b=(e,t)=>n=>{let r=u(n);return r[e]=t,r.every(e=>e===r[0])?r[0]===0?null:r[0]:r},x=e=>e>=9999?`full`:String(e);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`radius-field`,ref:c,children:[_?(0,U.jsxs)(`button`,{className:`token-pill`,"aria-expanded":o,onClick:()=>s(!o),"data-tip":`${_.slice(1)} · click to change`,children:[(0,U.jsx)(X.radius,{}),(0,U.jsx)(`span`,{children:_.slice(1).replace(/^radius-/,``)}),(0,U.jsx)(`em`,{children:x(v)})]}):(0,U.jsx)(Ql,{label:n,title:`Corner radius`,value:v,min:0,digits:2,onPreview:e=>i(e===null?null:()=>e),onCommit:e=>a(`Corner radius`,()=>e===0?null:e)}),!r&&(0,U.jsx)(`button`,{className:`token-btn ${h?`on`:``}`,"aria-label":`Independent corners`,"aria-pressed":h,"data-tip":`Independent corners`,onClick:()=>m(!h),children:(0,U.jsx)(X.corners,{})}),g.length>0&&(_?(0,U.jsx)(`button`,{className:`token-btn`,"aria-label":`Detach token`,"data-tip":`Detach from the token (keep the px)`,onClick:()=>a(`Corner radius`,t=>Ee(e,t)??null),children:(0,U.jsx)(X.detach,{})}):(0,U.jsx)(`button`,{className:`token-btn`,"aria-label":`Radius tokens`,"data-tip":`Use a radius token`,"aria-expanded":o,onClick:()=>s(!o),children:(0,U.jsx)(X.styles,{})})),o&&(0,U.jsx)(`div`,{className:`token-menu`,role:`listbox`,style:l,children:g.map(([e,t])=>(0,U.jsxs)(`button`,{role:`option`,"aria-selected":_===`$${e}`,className:_===`$${e}`?`on`:``,onClick:()=>{s(!1),a(`Radius token`,()=>`$${e}`)},children:[(0,U.jsx)(`span`,{className:`token-sample`,style:{borderTopLeftRadius:Math.min(t,10)}}),(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(`em`,{children:x(t)})]},e))})]}),h&&(0,U.jsx)(`div`,{className:`radius-corners`,role:`group`,"aria-label":`Independent corners`,children:$d.map(({i:e,name:t,rot:n})=>(0,U.jsx)(Ql,{digits:2,label:(0,U.jsx)(`span`,{className:`corner-icon`,style:{transform:`rotate(${n}deg)`},children:(0,U.jsx)(X.corner,{})}),title:`${t} radius`,value:y(e),min:0,onPreview:t=>i(t===null?null:b(e,t)),onCommit:t=>a(`Corner radius`,b(e,t))},e))})]})}var tf=e=>!e||e===`none`?`original`:e;function nf(e,t){return e.textCase??(e.style?t[e.style.slice(1)]?.textCase:void 0)}function rf(e,t,n){if(n!==void 0)return tf(n);let r=tf(nf(e[0],t));return e.every(e=>tf(nf(e,t))===r)?r:null}function af(e,t){return e===`original`?t?`none`:null:e===t?null:e}var of=[10,11,12,13,14,15,16,18,20,24,28,32,36,40,48,56,64,72,96,128],sf=e=>/^[\w -]+$/.test(e)&&!/^\d/.test(e)?e:`"${e}"`,cf=e=>`${Ud(e.fontFamily)} · ${e.fontSize}/${e.lineHeight?Math.round(e.lineHeight):`Auto`}${e.fontWeight!==400||e.fontStyle===`italic`?` · ${Zd(e.fontWeight,e.fontStyle)}`:``}`,lf=[[`original`,X.minus,`Original case`],[`upper`,X.caseUpper,`Upper case`],[`lower`,X.caseLower,`Lower case`],[`title`,X.caseTitle,`Title case`]];function uf({now:e,onPick:t}){return(0,U.jsx)(`div`,{className:`seg icons`,role:`radiogroup`,"aria-label":`Case`,children:lf.map(([n,r,i])=>(0,U.jsx)(`button`,{className:e===n?`on`:``,role:`radio`,"aria-checked":e===n,"aria-label":i,"data-tip":i,onClick:()=>t(n,i),children:(0,U.jsx)(r,{})},n))})}function df(e,t){let n=e.toLowerCase();if(n===``||n===`auto`)return null;let r=n.match(/^([\d.]+)\s*px$/);if(r)return Math.round(Number(r[1])*100)/100}var ff=`The quick brown fox jumps over the lazy dog`,pf=(e,t)=>e===void 0?void 0:Math.round(e/t*1e3)/10,mf=(e,t)=>Math.round(t*e)/100;function hf({doc:e,value:t,onPreview:n,onCommit:r,onLine:i}){let[a,o]=(0,H.useState)(null),s=e=>e===0?null:Math.round(t.size*e)/100;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Jd,{value:t.fontFamily,doc:e,onPick:e=>r(`Font`,{fontFamily:sf(e)}),onPreview:e=>n(e===null?null:{fontFamily:sf(e)})}),(0,U.jsxs)(`div`,{className:`row2`,children:[(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(()=>{let e=t.fontWeight===Z||t.fontStyle===Z,n=e?``:Xd(typeof t.fontWeight==`number`?t.fontWeight:400,t.fontStyle);return(0,U.jsxs)(`select`,{value:n,"aria-label":`Font style`,onChange:e=>r(`Font style`,Qd(e.target.value)),children:[e&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),n&&!Yd.some(([e])=>e===n)&&(0,U.jsx)(`option`,{value:n,children:n.replace(`i`,` Italic`)}),Yd.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))]})})(),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsxs)(`div`,{className:`size-field`,children:[(0,U.jsx)(Ql,{label:``,title:`Font size`,value:t.fontSize,min:1,onPreview:e=>n(e===null?null:{fontSize:e}),onCommit:e=>r(`Font size`,{fontSize:e})}),(0,U.jsx)(`button`,{className:`size-drop`,"aria-label":`Font sizes`,"aria-haspopup":`menu`,"aria-expanded":!!a,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();o(a?null:{x:t.right,y:t.bottom+V(`--menu-gap`)})},children:(0,U.jsx)(X.chevronDown,{})}),a&&(0,U.jsx)(Gl,{x:a.x,y:a.y,alignRight:!0,fit:!0,onClose:()=>o(null),items:of.map(e=>({label:String(e),checked:t.fontSize===e,onClick:()=>r(`Font size`,{fontSize:e})}))})]})]}),(0,U.jsxs)(`div`,{className:`row2 labels`,children:[(0,U.jsx)(`span`,{children:`Line height`}),(0,U.jsx)(`span`,{children:`Letter spacing`})]}),(0,U.jsxs)(`div`,{className:`row2`,children:[(0,U.jsx)(Ql,{label:(0,U.jsx)(X.lineHeight,{}),title:`Line height (% of font size) · Auto · or type px`,value:t.lineHeightPct,digits:1,min:1,suffix:`%`,placeholder:`Auto`,base:120,onText:i,onPreview:e=>n(e===null?null:{lineHeight:mf(e,t.size)}),onCommit:e=>r(`Line height`,{lineHeight:mf(e,t.size)})}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.letterSpacing,{}),title:`Letter spacing (% of font size)`,value:t.letterSpacingPct,digits:1,step:.1,suffix:`%`,onPreview:e=>n(e===null?null:{letterSpacing:s(e)}),onCommit:e=>r(`Letter spacing`,{letterSpacing:s(e)})})]})]})}function gf({texts:e,doc:t,base:n,apply:r,preview:i,commit:a,range:o}){let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(!1),p=t.styles.text,m=t=>{let n=t(e[0]);return e.every(e=>JSON.stringify(t(e))===JSON.stringify(n))?n:Z},h=(e,t)=>e[t]??(e.style?p[e.style.slice(1)]?.[t]:void 0),g=e=>h(e,`fontSize`)??16,_=m(e=>e.style??``),v=typeof _==`string`&&_?_.slice(1):null,y=v?p[v]:void 0,b=o&&e.length===1?e[0].spans?.find(e=>e.start<=o.start&&e.end>=o.end):void 0,x=o&&e.length===1&&o.end>o.start?(()=>{let t=e[0].spans??[],n=[...new Set([o.start,o.end,...t.flatMap(e=>[e.start,e.end])])].filter(e=>e>=o.start&&e<=o.end).sort((e,t)=>e-t);return n.slice(0,-1).map((e,r)=>t.find(t=>t.start<=e&&t.end>=n[r+1]))})():null,S=e=>m(t=>{if(!x)return e(t);let n=x.map(n=>e(t,n));return n.every(e=>JSON.stringify(e)===JSON.stringify(n[0]))?n[0]:Z}),C=(e,t)=>t?.fontSize??g(e),w={fontFamily:S((e,t)=>t?.fontFamily??h(e,`fontFamily`)),fontWeight:S((e,t)=>t?.fontWeight??h(e,`fontWeight`)),fontStyle:S((e,t)=>(t?.fontStyle??h(e,`fontStyle`))===`italic`?`italic`:void 0),fontSize:S((e,t)=>C(e,t)),lineHeightPct:S((e,t)=>pf(t?.lineHeight??h(e,`lineHeight`),C(e,t))),letterSpacingPct:S((e,t)=>Math.round((t?.letterSpacing??h(e,`letterSpacing`)??0)/C(e,t)*1e3)/10),size:o&&b?.fontSize||g(e[0])},T=e=>e,E=rf(e,p,o&&e.length===1?b?.textCase:void 0),D=[`fontFamily`,`fontSize`,`fontWeight`,`fontStyle`,`lineHeight`,`letterSpacing`,`color`,`textDecoration`],O=e=>Object.keys(e).every(e=>D.includes(e)),k=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,e===`fontStyle`&&t===`normal`?null:t])),A=e=>r=>{let i={...e};for(let e of[`letterSpacing`,`lineHeight`])if(e in i&&i[e]!==null){let t=i[e]/w.size*100;i[e]=t===0&&e===`letterSpacing`?null:Math.round(g(T(r))*t)/100}let a=T(n?.nodes[r.id]??r);return i=dt(i,{fontSize:g(a),lineHeight:h(a,`lineHeight`),letterSpacing:h(a,`letterSpacing`)}),Bn(t,r.id,i)};return(0,U.jsxs)(nu,{title:`Typography`,action:(0,U.jsxs)(`div`,{className:`type-head-actions`,children:[(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Text styles`,"aria-expanded":s,"data-tip":`Text styles`,onClick:()=>c(!s),children:(0,U.jsx)(X.styles,{})}),s&&(0,U.jsx)(_f,{doc:t,current:v,creating:d,setCreating:f,onApply:e=>{c(!1),r(`Text style`,()=>({style:`$${e}`,...Object.fromEntries(zn.map(e=>[e,null]))}))},onCreate:n=>{let r=vu(n);return!r||p[r]?!1:(a(Hn(t,e.map(e=>e.id),r),`Create text style`),f(!1),c(!1),!0)},onEdit:e=>{c(!1),u(e)},onClose:()=>{c(!1),f(!1)}})]}),children:[y&&v?(0,U.jsxs)(`div`,{className:`style-row`,children:[(0,U.jsxs)(`button`,{className:`style-apply`,"aria-expanded":s,onClick:()=>c(!s),"data-tip":`${v} · click to change style`,children:[(0,U.jsx)(`span`,{className:`style-ag`,style:{fontFamily:`${y.fontFamily}, var(--font)`,fontWeight:y.fontWeight,fontStyle:y.fontStyle},children:`Ag`}),(0,U.jsx)(`span`,{className:`style-name`,children:v}),(0,U.jsxs)(`span`,{className:`style-meta`,children:[`· `,y.fontSize,`/`,y.lineHeight?Math.round(y.lineHeight):`Auto`]})]}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Detach style`,"data-tip":`Detach style`,onClick:()=>r(`Detach style`,e=>Bn(t,e.id,{fontSize:g(T(e))})),children:(0,U.jsx)(X.detach,{})})]}):(0,U.jsx)(hf,{doc:t,value:w,onPreview:e=>{if(o&&e&&O(e))return o.style(k(e),``,!0);o&&!e&&o.style(null,``),i(e?A(e):null)},onCommit:(e,t)=>o&&O(t)?o.style(k(t),e):r(e,A(t)),onLine:n=>{if(!/^(auto|)$|px$/i.test(n))return!1;if(o){let t=df(n,b?.fontSize??g(e[0]));return o.style({lineHeight:t??null},`Line height`),!0}return r(`Line height`,e=>{let r=df(n,g(T(e)));return r===void 0?null:Bn(t,e.id,{lineHeight:r})}),!0}}),(0,U.jsx)(`div`,{className:`row2 labels`,children:(0,U.jsx)(`span`,{children:`Alignment`})}),(0,U.jsxs)(`div`,{className:`align-text`,children:[(0,U.jsx)(`div`,{className:`seg icons`,role:`radiogroup`,"aria-label":`Horizontal alignment`,children:[[`left`,X.textLeft,`Align text left`],[`center`,X.textCenter,`Align text center`],[`right`,X.textRight,`Align text right`]].map(([e,t,n])=>(0,U.jsx)(`button`,{className:m(e=>h(e,`textAlign`)??`left`)===e?`on`:``,"aria-label":n,"data-tip":n,onClick:()=>r(`Text align`,()=>({textAlign:e===`left`?null:e})),children:(0,U.jsx)(t,{})},e))}),(0,U.jsx)(`div`,{className:`seg icons`,role:`radiogroup`,"aria-label":`Vertical alignment`,children:[[`top`,X.vTop,`Align text top`],[`center`,X.vMiddle,`Align text middle`],[`bottom`,X.vBottom,`Align text bottom`]].map(([t,n,i])=>(0,U.jsx)(`button`,{className:m(e=>e.textAlignV??`top`)===t?`on`:``,"aria-label":i,"data-tip":e.every(e=>e.sizeY!==`fixed`)?`${i} (shows in a fixed-height box)`:i,onClick:()=>r(`Text vertical align`,()=>({textAlignV:t===`top`?null:t})),children:(0,U.jsx)(n,{})},t))})]}),(0,U.jsxs)(`div`,{className:`row2 labels`,children:[(0,U.jsx)(`span`,{children:`Decoration`}),(0,U.jsx)(`span`,{children:`Case`})]}),(0,U.jsxs)(`div`,{className:`align-text`,children:[(0,U.jsx)(`div`,{className:`seg icons`,role:`radiogroup`,"aria-label":`Decoration`,children:[[`none`,X.minus,`No decoration`],[`underline`,X.underline,`Underline`],[`line-through`,X.strikethrough,`Strikethrough`]].map(([e,t,n])=>(0,U.jsx)(`button`,{className:m(e=>e.textDecoration??`none`)===e?`on`:``,"aria-label":n,"data-tip":n,"data-kbd":e===`underline`?`⌘U`:e===`line-through`?`⇧⌘X`:void 0,onClick:()=>r(n,()=>({textDecoration:e===`none`?null:e})),children:(0,U.jsx)(t,{})},e))}),(0,U.jsx)(uf,{now:E,onPick:(n,i)=>o&&e.length===1?o.style({textCase:af(n,nf(e[0],p))},i):r(i,e=>Bn(t,e.id,{textCase:n===`original`?null:n}))})]}),l&&p[l]&&(0,U.jsx)(vf,{doc:t,name:l,onClose:()=>u(null),commit:a,onRenamed:u})]})}function _f({doc:e,current:t,creating:n,setCreating:r,onApply:i,onCreate:a,onEdit:o,onClose:s}){let[c,l]=(0,H.useState)(``),u=te(e).map(t=>[t,e.styles.text[t]]).filter(([e])=>e.toLowerCase().includes(c.trim().toLowerCase())),d=_u(u.sort(([e],[t])=>e.localeCompare(t)));return(0,U.jsxs)(mu,{title:`Text styles`,onClose:s,actions:(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Create style`,"data-tip":`Create style from selection`,onClick:()=>r(!0),children:(0,U.jsx)(X.plus,{})}),children:[(0,U.jsx)(hu,{value:c,onChange:l,onEnter:()=>u[0]&&i(u[0][0])}),n&&(0,U.jsxs)(`div`,{className:`floating-create`,children:[(0,U.jsx)(`input`,{className:`full text-in`,autoFocus:!0,placeholder:`Name, e.g. heading/large`,"aria-label":`New style name`,onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&!a(e.currentTarget.value)&&e.currentTarget.select(),e.key===`Escape`&&(e.stopPropagation(),r(!1)))}}),(0,U.jsx)(`p`,{className:`muted-note`,children:`Uses the selected text’s values. “/” makes groups.`})]}),(0,U.jsxs)(`div`,{className:`floating-list`,children:[!u.length&&(0,U.jsx)(`p`,{className:`muted-note pad`,children:c?`No matching styles.`:`No text styles yet. Press + to make one from the selection.`}),d.map(e=>(0,U.jsxs)(`div`,{children:[e.group&&(0,U.jsx)(`div`,{className:`floating-group`,children:e.group}),e.items.map(([e,n])=>(0,U.jsxs)(`div`,{className:`style-item ${t===e?`on`:``}`,children:[(0,U.jsxs)(`button`,{className:`style-apply`,onClick:()=>i(e),"data-tip":cf(n),children:[(0,U.jsx)(`span`,{className:`style-ag`,style:{fontFamily:`${n.fontFamily}, var(--font)`,fontWeight:n.fontWeight,fontStyle:n.fontStyle},children:`Ag`}),(0,U.jsx)(`span`,{className:`style-name`,children:gu(e).label}),(0,U.jsxs)(`span`,{className:`style-meta`,children:[`· `,n.fontSize,`/`,n.lineHeight?Math.round(n.lineHeight):`Auto`]})]}),(0,U.jsx)(`button`,{className:`icon-btn fit style-edit`,"aria-label":`Edit ${e}`,"data-tip":`Edit style`,onClick:()=>o(e),children:(0,U.jsx)(X.sliders,{})})]},e))]},e.group||`_`))]})]})}function vf({doc:e,name:t,onClose:n,commit:r,onRenamed:i}){let a=e.styles.text[t],o=Object.values(e.nodes).filter(e=>e.type===`text`&&e.style===`$${t}`),s=(e,n)=>{let i={...a,...dt(n,a)};for(let e of Object.keys(i))(i[e]===null||i[e]===void 0)&&delete i[e];r([{op:`styles`,text:{[t]:i}}],`Style ${t}: ${e}`)},c=n=>{let a=vu(n);a&&a!==t&&!e.styles.text[a]&&(r([{op:`styles`,rename:{text:{[t]:a}}}],`Rename text style`),i(a))};return(0,U.jsx)(mu,{title:`Edit text style`,onClose:n,children:(0,U.jsxs)(`div`,{className:`style-editor-body`,children:[(0,U.jsx)(`input`,{className:`full text-in`,defaultValue:t,"aria-label":`Style name`,onKeyDown:e=>{!e.nativeEvent.isComposing&&e.key===`Enter`&&e.currentTarget.blur()},onBlur:e=>c(e.currentTarget.value)},t),(0,U.jsx)(`div`,{className:`style-preview`,style:{fontFamily:`${a.fontFamily}, var(--font)`,fontWeight:a.fontWeight,fontStyle:a.fontStyle,fontSize:Math.min(a.fontSize,28),letterSpacing:a.letterSpacing,textTransform:a.textCase?ee(a.textCase):void 0},children:ff}),(0,U.jsx)(hf,{doc:e,value:{fontFamily:a.fontFamily,fontWeight:a.fontWeight,fontStyle:a.fontStyle,fontSize:a.fontSize,lineHeightPct:pf(a.lineHeight,a.fontSize),letterSpacingPct:Math.round((a.letterSpacing??0)/a.fontSize*1e3)/10,size:a.fontSize},onPreview:()=>{},onCommit:(e,t)=>s(e,t),onLine:e=>{let t=df(e,a.fontSize);return t!==void 0&&(s(`Line height`,{lineHeight:t===null?void 0:t}),!0)}}),(0,U.jsx)(`div`,{className:`row2 labels`,children:(0,U.jsx)(`span`,{children:`Case`})}),(0,U.jsx)(`div`,{className:`align-text`,children:(0,U.jsx)(uf,{now:rf([a],{}),onPick:(e,t)=>s(t,{textCase:e===`original`?void 0:e})})}),(0,U.jsx)(tu,{value:a.color,styles:e.styles.colors,onCommit:e=>s(`Color`,{color:e})}),(0,U.jsxs)(`div`,{className:`style-editor-foot`,children:[(0,U.jsxs)(`span`,{className:`muted-note`,children:[o.length,` text layer`,o.length===1?``:`s`,` use this style`]}),(0,U.jsx)(`button`,{className:`link-btn danger`,onClick:()=>{r([{op:`styles`,text:{[t]:null}}],`Delete text style`),n()},children:`Delete style`})]})]})})}function yf(e){if(!e)return`all`;let t=e.map((e,t)=>e>0?t:-1).filter(e=>e>=0);return t.length===1?[`top`,`right`,`bottom`,`left`][t[0]]:`custom`}function bf(e,t){return t.length?[...e,...t]:[]}function xf(e,t,n){return!t||e[t]?[]:[{op:`styles`,colors:{[t]:n}}]}var Sf=null,Cf=new Set;function wf(e){if(e?.id!==Sf?.id||e?.index!==Sf?.index){Sf=e;for(let e of Cf)e()}}function Tf(){return(0,H.useSyncExternalStore)(e=>(Cf.add(e),()=>{Cf.delete(e)}),()=>Sf)}function Ef(e,t,n){let r=[...e];return t===n||t<0||n<0||t>=r.length||n>=r.length||r.splice(n,0,r.splice(t,1)[0]),r}function Df(e,t,n){return e===null?null:e===t?n:t<n&&e>t&&e<=n?e-1:t>n&&e>=n&&e<t?e+1:e}function Of(e,t){return e.filter(e=>e<t).length}function kf(e,t,n,r){let i=n>(r?e-1-t:t)?n-1:n,a=r?e-1-i:i;return a===t?null:a}function Af(e,t,n,r){let i=t+(n===`up`===r?1:-1);return i<0||i>=e?null:i}function jf(e,t,n,r){if(n===null)return null;let i=r?e-1-t:t;return n===i?`drop-before`:n===e&&i===e-1?`drop-after`:null}function Mf({count:e,reversed:t,movedTo:n,onMove:r,onSettled:i}){let a=(0,H.useRef)(null),[o,s]=(0,H.useState)(null),c=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{let e=c.current;e&&n!==null&&(c.current=null,i?.(e.from,e.to),e.focus&&a.current?.querySelector(`[data-reorder-row="${e.to}"] .reorder-grip`)?.focus())});let l=(e,t,n)=>{c.current={from:e,to:t,focus:n},r(e,t)},u=e=>Of([...a.current?.querySelectorAll(`[data-reorder-row]`)??[]].map(e=>{let t=e.getBoundingClientRect();return t.top+t.height/2}),e);return{rows:a,drag:o,gripProps:n=>({onPointerDown:t=>{t.button!==0||e<2||(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),s({from:n,slot:u(t.clientY)}))},onPointerMove:e=>{o?.from===n&&s({from:n,slot:u(e.clientY)})},onPointerUp:r=>{if(o?.from!==n)return;let i=kf(e,n,o.slot,t);s(null),i!==null&&l(n,i,!1),r.currentTarget.releasePointerCapture(r.pointerId)},onPointerCancel:()=>s(null),onKeyDown:r=>{if(r.key!==`ArrowUp`&&r.key!==`ArrowDown`)return;r.preventDefault(),r.stopPropagation();let i=Af(e,n,r.key===`ArrowUp`?`up`:`down`,t);i!==null&&l(n,i,!0)}}),dropClassOf:n=>o&&kf(e,o.from,o.slot,t)!==null?jf(e,n,o.slot,t):null}}var Nf=0;function Pf(e,t){return t===e.after?`apply`:t===e.before?`wait`:`drop`}function Ff(e,t=``){let n=(0,H.useRef)([]),r=(0,H.useRef)(null),i=n.current,a=null,o=r.current;if(o){let e=Pf(o,t);e===`apply`&&(i.splice(o.to,0,...i.splice(o.from,1)),a=o.to),e!==`wait`&&(r.current=null)}for(;i.length<e;)i.push(Nf++);return i.length>e&&(i.length=e),{keys:i,movedTo:a,remove:e=>{n.current.splice(e,1)},move:(e,t,n,i)=>{r.current=e===t?null:{from:e,to:t,before:n,after:i}}}}var If=(e,t)=>e===null||e===t?null:e>t?e-1:e;function Lf(e){return e&&e.type===`frame`?(e.fills??[]).findIndex(e=>e.type===`video`&&e.visible!==!1):-1}function Rf(e,t){for(let n=t??null;n&&e.nodes[n];n=e.nodes[n].parent)if(Lf(e.nodes[n])>=0)return n;return null}var zf=e=>e.paused||e.ended?`play`:`pause`;function Bf(e){let t=Number.isFinite(e)&&e>0?Math.floor(e):0;return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var Vf=(e,t)=>Number.isFinite(t)&&t>0?Math.min(1,Math.max(0,e/t)):0;function Hf(e,t,n,r){let i=e+n*(r?1:.1);return Math.min(Number.isFinite(t)&&t>0?t:0,Math.max(0,i))}var Uf=(e,t)=>Number.isFinite(t)&&t>0?Math.min(1,Math.max(0,e))*t:0;function Wf(e,t,n,r){let i=Math.max(e.x,t.x),a=Math.max(e.y,t.y),o=Math.min(e.x+e.w,t.x+t.w),s=Math.min(e.y+e.h,t.y+t.h);return o<=i||s<=a?null:o-i>=3*n&&s-a>=3*n?{left:i+r,top:s-n-r}:{left:i,top:Math.min(s+r,t.y+t.h-n)}}function Gf(e,t){return document.querySelector(`.world [data-node-id="${CSS.escape(e)}"] > video[data-nudge-video][data-fill-index="${t}"]`)}function Kf(e){zf(e)===`pause`?e.pause():e.play().catch(()=>{})}function qf(e,t){let[n,r]=(0,H.useState)(null);return(0,H.useLayoutEffect)(()=>{let i=e&&t>=0?Gf(e,t):null;i!==n&&r(i)}),n}var Jf=e=>({playing:!!e&&!e.paused&&!e.ended,time:e?.currentTime??0,duration:e?.duration||0,muted:!e||e.muted});function Yf(e){let[t,n]=(0,H.useState)(()=>Jf(e));return(0,H.useLayoutEffect)(()=>{if(n(Jf(e)),!e)return;let t=0,r=()=>n(t=>{let n=Jf(e);return t.playing===n.playing&&t.time===n.time&&t.duration===n.duration&&t.muted===n.muted?t:n}),i=()=>{r(),t=e.paused||e.ended?0:requestAnimationFrame(i)},a=()=>{r(),t||=requestAnimationFrame(i)},o=[`play`,`playing`,`pause`,`ended`,`seeked`,`timeupdate`,`loadedmetadata`,`durationchange`,`volumechange`];for(let t of o)e.addEventListener(t,t===`play`||t===`playing`?a:r);return e.paused||a(),()=>{cancelAnimationFrame(t);for(let t of o)e.removeEventListener(t,t===`play`||t===`playing`?a:r)}},[e]),t}var Xf=[{key:`autoplay`,label:`Autoplay`,tip:`Start playing when the page opens`},{key:`loop`,label:`Loop`,tip:`Start over when it ends`},{key:`muted`,label:`Muted`,tip:`Play without sound (browsers only autoplay muted video)`}];function Zf({id:e,index:t,fill:n,onSetting:r}){let i=Re(n);return(0,U.jsxs)(`div`,{className:`video-controls`,children:[e&&(0,U.jsx)(ep,{id:e,index:t}),(0,U.jsx)(Qf,{on:i,onSetting:r})]})}function Qf({on:e,onSetting:t}){return(0,U.jsx)(`div`,{className:`video-settings`,children:Xf.map(n=>(0,U.jsxs)(`label`,{className:`check tight`,"data-tip":n.tip,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e[n.key],onChange:e=>t(n.key,e.target.checked)}),n.label]},n.key))})}function $f({value:e,onChange:t}){return(0,U.jsxs)(`div`,{className:`select-wrap fill-video-fit`,children:[(0,U.jsxs)(`select`,{value:e,"aria-label":`Video fit`,onChange:e=>{e.target.value===`crop`?window.dispatchEvent(new CustomEvent(Td)):t(e.target.value)},children:[e===``&&(0,U.jsx)(`option`,{value:``,disabled:!0,children:`Mixed`}),(0,U.jsx)(`option`,{value:`cover`,children:`Video · Fill`}),(0,U.jsx)(`option`,{value:`contain`,children:`Video · Fit`}),(0,U.jsx)(`option`,{value:`fill`,children:`Video · Stretch`}),(0,U.jsx)(`option`,{value:`crop`,children:`Video · Crop`})]}),(0,U.jsx)(X.chevronDown,{})]})}function ep({id:e,index:t}){let n=qf(e,t),{playing:r,time:i,duration:a,muted:o}=Yf(n),s=r?`Pause video`:`Play video`;return(0,U.jsxs)(`div`,{className:`video-preview`,children:[(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":s,"data-tip":s,onClick:()=>n&&Kf(n),children:r?(0,U.jsx)(X.pause,{}):(0,U.jsx)(X.play,{})}),(0,U.jsx)(`input`,{type:`range`,className:`shader-slider`,"aria-label":`Playhead`,min:0,max:1,step:`any`,disabled:!n||!a,value:Vf(i,a),style:{"--pct":`${Vf(i,a)*100}%`},onChange:e=>{n&&(n.currentTime=Uf(Number(e.currentTarget.value),a))},onKeyDown:e=>{let t=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0;t&&n&&(e.preventDefault(),n.currentTime=Hf(n.currentTime,a,t,e.shiftKey))}}),(0,U.jsxs)(`span`,{className:`video-time`,children:[Bf(i),` / `,Bf(a)]}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":o?`Unmute video`:`Mute video`,"data-tip":o?`Unmute video`:`Mute video`,"aria-pressed":!o,onClick:()=>{n&&(n.muted=!n.muted)},children:o?(0,U.jsx)(X.volumeOff,{}):(0,U.jsx)(X.volume,{})})]})}function tp(e){let t=e.replace(`#`,``);(t.length===3||t.length===4)&&(t=[...t].map(e=>e+e).join(``));let n=t.length===8?Math.round(parseInt(t.slice(6),16)/255*100):100;return{hex:t.slice(0,6).toLowerCase(),alpha:n}}var np=(e,t)=>`#${e}${t>=100?``:Math.round(Math.max(0,t)/100*255).toString(16).padStart(2,`0`)}`;function rp({value:e,colors:t,onPreview:n,onCommit:r,onDetach:i,onOpenStyles:a,onSwatch:o,extra:s,opaque:c=!1}){let l=typeof e==`string`&&e.startsWith(`$`)?e.slice(1):null,u=typeof e==`string`?l?t[l]??`#ff00ff`:e:ae,{hex:d,alpha:f}=tp(u),[p,m]=(0,H.useState)({of:u,text:d}),h=ql(p,u,d);h!==p&&m(h);let g=h.text,_=e=>m({of:u,text:e}),[v,y]=(0,H.useState)(!1);return(0,U.jsxs)(`div`,{className:`fill-row`,children:[(0,U.jsxs)(`div`,{className:`fill-field ${c?`opaque`:``}`,children:[(0,U.jsx)(`button`,{className:`swatch ${v?`on`:``} ${e===Z?`mixed`:``}`,"aria-label":`Pick color`,"aria-expanded":v,style:e===Z?void 0:{background:u},onClick:()=>o?o():y(!v)}),v&&(0,U.jsx)(Bd,{value:np(d,f),onClose:()=>y(!1),onPreview:n,onCommit:e=>r(e,e.startsWith(`$`)?`Color style`:`Fill color`)}),l?(0,U.jsx)(`button`,{className:`fill-style-name`,onClick:a,"data-tip":`${l} · ${t[l]??`missing`} · click to change style`,children:gu(l).label}):(0,U.jsx)(`input`,{className:`fill-hex`,value:e===Z?``:g,placeholder:e===Z?`Mixed`:``,"aria-label":`Hex`,onChange:e=>_(e.target.value),onFocus:e=>e.currentTarget.select(),onBlur:()=>{let e=Kl(u,``)??u,t=Kl(g,e);t&&t!==e?r(t,`Fill color`):_(d)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(_(d),e.currentTarget.blur())}}),!l&&!c&&(0,U.jsx)(`div`,{className:`fill-alpha`,children:(0,U.jsx)(Ql,{label:``,title:`Opacity`,value:e===Z?Z:f,min:0,max:100,suffix:`%`,onPreview:e=>n(e===null?null:np(d,e)),onCommit:e=>r(np(d,e),`Fill opacity`)})})]}),l&&i&&(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Detach style`,"data-tip":`Detach style`,onClick:i,children:(0,U.jsx)(X.detach,{})}),s]})}function ip({doc:e,current:t,onApply:n,onClose:r,commit:i}){let[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),d=e.styles.colors,f=Object.entries(d).filter(([e])=>e.toLowerCase().includes(a.trim().toLowerCase())).sort(([e],[t])=>e.localeCompare(t)),p=e=>{let r=vu(e);if(!r||d[r])return!1;let i=t&&t.startsWith(`#`)?t:y;return n(r,xf(d,r,i)),c(!1),!0},m=(e,t)=>{let n=vu(t);n&&n!==e&&!d[n]&&(i([{op:`styles`,rename:{colors:{[e]:n}}}],`Rename color style`),u(n))},h=e=>{i([{op:`styles`,colors:{[e]:null}}],`Delete color style`),u(null)};return(0,U.jsxs)(mu,{title:`Color styles`,onClose:r,actions:(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Create color style`,"data-tip":`Save current color as a style`,onClick:()=>c(!0),children:(0,U.jsx)(X.plus,{})}),children:[(0,U.jsx)(hu,{value:a,onChange:o,onEnter:()=>f[0]&&n(f[0][0])}),s&&(0,U.jsxs)(`div`,{className:`floating-create`,children:[(0,U.jsx)(`input`,{className:`full text-in`,autoFocus:!0,placeholder:`Name, e.g. brand/primary`,"aria-label":`New color style name`,onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&!p(e.currentTarget.value)&&e.currentTarget.select(),e.key===`Escape`&&(e.stopPropagation(),c(!1)))}}),(0,U.jsx)(`p`,{className:`muted-note`,children:`Uses the selected color. “/” makes groups.`})]}),(0,U.jsxs)(`div`,{className:`floating-list`,children:[!f.length&&(0,U.jsx)(`p`,{className:`muted-note pad`,children:a?`No matching styles.`:`No color styles yet. Press + to save the current color.`}),_u(f).map(r=>(0,U.jsxs)(`div`,{children:[r.group&&(0,U.jsx)(`div`,{className:`floating-group`,children:r.group}),r.items.map(([r,a])=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(yu,{name:gu(r).label,color:a,on:t===`$${r}`,onApply:()=>n(r),trail:(0,U.jsx)(`button`,{className:`icon-btn fit style-edit`,"aria-label":`Edit ${r}`,"data-tip":`Edit style`,onClick:()=>u(l===r?null:r),children:(0,U.jsx)(X.sliders,{})})}),l===r&&(0,U.jsxs)(`div`,{className:`color-style-edit`,children:[(0,U.jsx)(`input`,{className:`full text-in`,defaultValue:r,"aria-label":`Style name`,onKeyDown:e=>{!e.nativeEvent.isComposing&&e.key===`Enter`&&e.currentTarget.blur()},onBlur:e=>m(r,e.currentTarget.value)},r),(0,U.jsx)(rp,{value:a,colors:d,onPreview:()=>{},onCommit:e=>i([{op:`styles`,colors:{[r]:e}}],`Style ${r}`)}),(0,U.jsxs)(`div`,{className:`style-editor-foot`,children:[(0,U.jsx)(`span`,{className:`muted-note`,children:(()=>{let t=ne(e,r);return`${t} use${t===1?``:`s`}`})()}),(0,U.jsx)(`button`,{className:`link-btn danger`,onClick:()=>h(r),children:`Delete style`})]})]})]},r))]},r.group||`_`))]})]})}function ap(e){if(e.length!==1)return;let t=document.querySelector(`[data-node-id="${CSS.escape(e[0].id)}"]`);return t&&t.offsetWidth&&t.offsetHeight?{w:t.offsetWidth,h:t.offsetHeight}:{w:e[0].w,h:e[0].h}}function op({nodes:e,doc:t,apply:n,preview:r,commit:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),d=t.styles.colors,f=e.every(e=>e.type===`text`),p=e.every(e=>e.type===`frame`||e.type===`shape`&&e.shape.kind!==`line`),m=s!==null&&e.length===1?e[0].id:null;(0,H.useEffect)(()=>(wf(m!==null&&s!==null?{id:m,index:s}:null),()=>wf(null)),[m,s]);let h=e.every(e=>e.type===`frame`&&!e.boolean),g=e.every(e=>e.type===`vector`),_=p&&e.every(t=>(t.fills??[]).length===(e[0].fills??[]).length)?(e[0].fills??[]).length:1,v=p?e[0].fills??[]:[],y=Ff(_,JSON.stringify(v)),b=Mf({count:_,reversed:!0,movedTo:y.movedTo,onMove:(e,t)=>{y.move(e,t,JSON.stringify(v),JSON.stringify(Ef(v,e,t))),n(`Reorder fills`,n=>{let r=n.fills;return r&&r.length>Math.max(e,t)?{fills:Ef(r,e,t)}:null})},onSettled:(e,t)=>{c(n=>Df(n,e,t)),u(n=>Df(n,e,t))}});if(!f&&!p&&!g)return null;let x=t=>{let n=t(e[0]);return e.every(e=>JSON.stringify(t(e))===JSON.stringify(n))?n:Z},S=e=>e.color??(e.style?t.styles.text[e.style.slice(1)]?.color:void 0)??`#000000`,C=e=>e.fills??[],w=p?x(e=>C(e).length):1,T=w===Z?[0]:Array.from({length:w??0},(e,t)=>w-1-t),E=w===Z?0:Math.max(0,(w??1)-1),D=(e,t)=>n=>{let r=C(n);if(!r[e]&&(e!==0||r.length))return null;let i=t(r[e]);return i?{fills:r.length?r.map((t,n)=>n===e?i:t):[i]}:null},O=(e,t)=>({...t,...e?.visible===!1?{visible:!1}:{},...e?.blend?{blend:e.blend}:{}}),k=(e,t)=>n=>t===null?null:n.type===`text`||n.type===`vector`?{color:t}:D(e,e=>e?.type===`solid`?{...e,color:t}:O(e,{type:`solid`,color:t}))(n),A=f?x(e=>S(e)):g?x(e=>e.color):void 0,j=g&&A===void 0,M=l??E,N=f||g?A:(()=>{let e=x(e=>C(e)[M]??null);return e&&e!==Z&&e.type===`solid`?e.color:void 0})(),P=(e,t)=>D(e,e=>{if(!e)return null;let{blend:n,...r}=e;return t?{...r,blend:t}:r}),F=p&&w!==Z&&(w??0)>1,I=a=>{let l=p?x(e=>C(e)[a]??null):null,m=f||g?A:l===Z?Z:l?.type===`solid`?l.color:void 0,_=p&&l&&l!==Z?l.visible!==!1:!0,v=p?x(e=>C(e)[a]?.blend):void 0,w=l&&l!==Z&&l.type!==`video`?l:{type:`solid`,color:ae},T=()=>c(s===a?null:a),E=p&&s===a&&!(l&&l!==Z&&l.type===`video`)&&(0,U.jsx)(zd,{paint:w,box:ap(e),kinds:h?[`solid`,`linear`,`radial`,`image`,`shader`]:[`solid`,`linear`,`radial`,`image`],video:h,onClose:()=>c(null),blend:{value:v,onPick:e=>n(`Fill blend: ${e?iu[e]:`Normal`}`,P(a,e)),onPreview:e=>r(e===null?null:P(a,e))},shaderControls:(e,t,n)=>(0,U.jsx)(pp,{shader:e,colors:d,onPreview:t,onCommit:e=>n(e,``)}),style:w.type===`solid`&&w.color.startsWith(`$`)?w.color.slice(1):void 0,onPreview:e=>r(e?D(a,t=>O(t,e)):null),onCommit:(t,n)=>{let r=t.type===`shader`?`Shader fill`:t.type===`image`?`Image fill`:t.type===`video`?`Video fill`:t.type===`linear`||t.type===`radial`?`Gradient fill`:t.type===`solid`&&t.color.startsWith(`$`)?`Color style`:`Fill color`,o=e.flatMap(e=>{let n=D(a,e=>O(e,t))(e);return n?[{op:`update`,id:e.id,set:n}]:[]});i([...n?[{op:`asset`,add:[n]}]:[],...o],r)}}),j=p?(0,U.jsx)(sp,{visible:_,apply:n,index:a,blend:v,onRemove:()=>{y.remove(a),c(e=>If(e,a)),u(e=>If(e,a))},onBlend:e=>n(`Fill blend: ${e?iu[e]:`Normal`}`,P(a,e)),onBlendPreview:e=>r(e===null?null:P(a,e))}):void 0;return(0,U.jsxs)(`div`,{"data-fill-index":a,"data-reorder-row":a,className:`reorder-row ${b.dropClassOf(a)??``}`,children:[F&&(0,U.jsx)(`button`,{className:`reorder-grip`,"aria-label":`Reorder fill`,"data-tip":`Drag to reorder`,...b.gripProps(a),children:(0,U.jsx)(X.grip,{})}),E,l&&l!==Z&&l.type===`video`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`fill-row`,children:[(0,U.jsxs)(`div`,{className:`fill-field image`,children:[(0,U.jsx)(`video`,{className:`fill-thumb`,src:t.assets[l.asset]?`/design/${t.assets[l.asset].file}`:void 0,muted:!0,playsInline:!0,preload:`metadata`,"aria-hidden":!0}),(0,U.jsx)($f,{value:l.fit,onChange:e=>n(`Video fit`,D(a,t=>{if(t?.type!==`video`)return null;let{crop:n,...r}=t;return{...r,fit:e}}))})]}),j]}),(0,U.jsx)(Zf,{id:e.length===1?e[0].id:null,index:a,fill:l,onSetting:(e,t)=>n(`Video ${e}`,D(a,n=>{if(n?.type!==`video`)return null;let{[e]:r,...i}=n;return t?i:{...i,[e]:!1}}))})]}):l&&l!==Z&&l.type===`shader`?(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(`div`,{className:`fill-row`,children:[(0,U.jsxs)(`div`,{className:`fill-field image`,children:[(0,U.jsx)(`button`,{className:`fill-thumb shader ${s===a?`on`:``}`,"aria-label":`Edit fill`,"aria-expanded":s===a,onClick:T,children:(0,U.jsx)(et,{shader:l.shader})}),(0,U.jsxs)(`button`,{className:`fill-kind-btn`,"aria-expanded":s===a,onClick:T,children:[`Shader · `,l.shader.name]})]}),j]})}):l&&l!==Z&&l.type!==`solid`?(0,U.jsxs)(`div`,{className:`fill-row`,children:[(0,U.jsxs)(`div`,{className:`fill-field image`,children:[(0,U.jsx)(`button`,{className:`fill-thumb ${s===a?`on`:``}`,"aria-label":`Edit fill`,"aria-expanded":s===a,style:l.type===`image`?{backgroundImage:t.assets[l.asset]?`url("/design/${t.assets[l.asset].file}")`:void 0}:{background:ke(l,e=>e.startsWith(`$`)?d[e.slice(1)]??`#000000`:e)},onClick:T}),(0,U.jsx)(`button`,{className:`fill-kind-btn`,"aria-expanded":s===a,onClick:T,children:l.type===`image`?`Image · ${{cover:`Fill`,contain:`Fit`,fill:`Stretch`,crop:`Crop`}[l.fit]}`:l.type===`radial`?`Radial gradient`:`Linear gradient`})]}),j]}):(0,U.jsx)(rp,{value:m,colors:d,onPreview:e=>r(e===null?null:k(a,e)),onCommit:(e,t)=>n(t,k(a,e)),onOpenStyles:()=>{u(a),o(!0)},onSwatch:p?T:void 0,onDetach:()=>n(`Detach color style`,e=>{let t=e.type===`text`?S(e):e.type===`vector`?e.color:C(e)[a]?.color;return t?.startsWith(`$`)?k(a,d[t.slice(1)]??`#000000`)(e):null}),extra:j??(g?(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove fill`,"data-tip":`Remove fill (back to the icon's own colors)`,onClick:()=>n(`Remove fill`,()=>({color:null})),children:(0,U.jsx)(X.minus,{})}):void 0)})]},y.keys[a]??`i${a}`)};return(0,U.jsx)(nu,{title:`Fill`,action:(0,U.jsxs)(`span`,{className:`section-actions`,children:[(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Color styles`,"aria-expanded":a,"data-tip":`Color styles`,onClick:()=>{u(null),o(!a)},children:(0,U.jsx)(X.styles,{})}),j&&(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Add fill`,"data-tip":`Add fill (one color over the icon)`,onClick:()=>n(`Add fill`,()=>({color:`#000000`})),children:(0,U.jsx)(X.plus,{})}),p&&(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Add fill`,"data-tip":`Add fill`,onClick:()=>n(`Add fill`,e=>{let t=C(e);return{fills:[...t,{type:`solid`,color:t.length?`#00000033`:`#ffffff`}]}}),children:(0,U.jsx)(X.plus,{})}),a&&(0,U.jsx)(ip,{doc:t,current:typeof N==`string`?N:null,commit:i,onClose:()=>o(!1),onApply:(e,t)=>n(t?`Create color style`:`Color style`,k(M,`$${e}`),void 0,t)})]}),children:j?(0,U.jsx)(`div`,{className:`fill-original`,children:`Original colors`}):f||g?I(0):(0,U.jsx)(`div`,{className:`fill-rows`,ref:b.rows,children:T.map(I)})})}function sp({visible:e,apply:t,index:n,blend:r,onRemove:i,onBlend:a,onBlendPreview:o}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(su,{value:r,label:`Fill blend`,onPick:a,onPreview:o}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":e?`Hide fill`:`Show fill`,"data-tip":e?`Hide fill`:`Show fill`,onClick:()=>t(e?`Hide fill`:`Show fill`,t=>{let r=t;return r.fills?.[n]?{fills:r.fills.map((t,r)=>r===n?{...t,visible:!e&&void 0}:t)}:null}),children:e?(0,U.jsx)(X.eye,{}):(0,U.jsx)(X.eyeClosed,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove fill`,"data-tip":`Remove fill`,"data-kbd":`⌥/`,onClick:()=>{i(),t(`Remove fill`,e=>{let t=e;if(!t.fills?.[n])return null;let r=t.fills.filter((e,t)=>t!==n);return{fills:r.length?r:null}})},children:(0,U.jsx)(X.minus,{})})]})}var cp={top:0,right:1,bottom:2,left:3},lp={all:`All`,top:`Top`,bottom:`Bottom`,left:`Left`,right:`Right`},up={all:X.strokeSides,top:X.strokeTop,bottom:X.strokeBottom,left:X.strokeLeft,right:X.strokeRight},dp=[[`inside`,`Inside`],[`center`,`Center`],[`outside`,`Outside`]];function fp({frames:e,doc:t,apply:n,preview:i,commit:a}){let o=e.some(e=>e.type===`shape`),s=e.every(e=>e.type===`shape`&&!r(e.shape)),c=e.some(e=>e.type===`shape`&&!r(e.shape)),[l,u]=(0,H.useState)(!1),d=t.styles.colors,f=t=>{let n=t(e[0]);return e.every(e=>JSON.stringify(t(e))===JSON.stringify(n))?n:Z},p=e.some(e=>e.stroke),m=e=>e.type===`frame`||e.type===`shape`,h=e=>t=>m(t)?{stroke:{color:fe,width:1,...t.stroke,...e}}:null,g=f(e=>e.stroke?.cap??`none`),_=f(e=>e.stroke?.dash??null),v=e.every(e=>e.type===`shape`),y=e=>e.stroke?.dash??[Math.max(2,(e.stroke?.width??1)*4),Math.max(2,(e.stroke?.width??1)*4)],b=(e,t)=>n=>{let r=[...y(n)];return r[e]=e===0?Math.max(1,t):t,h({dash:r})(n)},x=f(e=>e.stroke?.color??`#000000`),S=f(e=>e.stroke?.width??1),C=f(e=>e.stroke?.align??`inside`),w=f(e=>e.stroke?.visible!==!1),T=e=>{let t=e.stroke?.width??1;return e.stroke?.sides??[t,t,t,t]},E=e.some(e=>e.stroke?.sides),D=f(e=>yf(e.stroke?.sides)),[O,k]=(0,H.useState)(!1),A=e.map(e=>e.id).join(`,`);(0,H.useEffect)(()=>k(!1),[A]);let[j,M]=(0,H.useState)(null),N=D===`custom`||D===Z||O,P=e=>f(t=>T(t)[e]),F=e=>t=>{if(t.type!==`frame`)return null;let n=Math.max(...T(t))||1;if(e===`all`)return h({width:n,sides:void 0})(t);let r=cp[e];return h({width:n,sides:[0,1,2,3].map(e=>e===r?n:0)})(t)},I=(e,t)=>n=>{if(n.type!==`frame`)return null;let r=[...T(n)];r[e]=t;let i=r.every(e=>e===r[0]);return h(i?{width:r[0],sides:void 0}:{width:Math.max(...r),sides:r})(n)},L=E?f(e=>{let t=T(e).filter(e=>e>0);return t.length&&t.every(e=>e===t[0])?t[0]:null}):S,ee=e=>t=>{if(!m(t))return null;let n=yf(t.stroke?.sides);if(n===`all`||n===`custom`)return h({width:e,sides:void 0})(t);let r=cp[n];return h({width:e,sides:[0,1,2,3].map(t=>t===r?e:0)})(t)},R=D===Z||D===`custom`||D===void 0?X.sliders:up[D];return(0,U.jsx)(nu,{title:`Stroke`,action:(0,U.jsxs)(`span`,{className:`section-actions`,children:[(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Stroke color styles`,"aria-expanded":l,"data-tip":`Color styles`,onClick:()=>u(!l),children:(0,U.jsx)(X.styles,{})}),!p&&(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Add stroke`,"data-tip":`Add stroke`,onClick:()=>n(`Add stroke`,()=>({stroke:{color:`#000000`,width:1}}),m),children:(0,U.jsx)(X.plus,{})}),l&&(0,U.jsx)(ip,{doc:t,current:typeof x==`string`?x:null,commit:a,onClose:()=>u(!1),onApply:(e,t)=>n(t?`Create color style`:`Stroke style`,h({color:`$${e}`}),m,t)})]}),children:p&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rp,{value:x,colors:d,onPreview:e=>i(e===null?null:h({color:e}),m),onCommit:(e,t)=>n(t.replace(`Fill`,`Stroke`),h({color:e}),m),onOpenStyles:()=>u(!0),onDetach:()=>n(`Detach stroke style`,e=>{let t=e.stroke?.color;return t?.startsWith(`$`)?h({color:d[t.slice(1)]??`#000000`})(e):null},m),extra:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":w===!1?`Show stroke`:`Hide stroke`,"data-tip":w===!1?`Show stroke`:`Hide stroke`,onClick:()=>n(w===!1?`Show stroke`:`Hide stroke`,h({visible:w===!1&&void 0}),m),children:w===!1?(0,U.jsx)(X.eyeClosed,{}):(0,U.jsx)(X.eye,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove stroke`,"data-tip":`Remove stroke`,onClick:()=>n(`Remove stroke`,()=>({stroke:null}),m),children:(0,U.jsx)(X.minus,{})})]})}),(0,U.jsxs)(`div`,{className:`row2 stroke-grid labels`,children:[(0,U.jsx)(`span`,{children:s?`Caps`:`Position`}),(0,U.jsx)(`span`,{children:`Weight`})]}),(0,U.jsxs)(`div`,{className:`row2 stroke-grid`,children:[s?(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:g===Z?``:g,"aria-label":`Stroke caps`,onChange:e=>n(`Stroke caps`,h({cap:e.target.value===`none`?void 0:e.target.value}),m),children:[g===Z&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),(0,U.jsx)(`option`,{value:`none`,children:`None`}),(0,U.jsx)(`option`,{value:`round`,children:`Round`}),(0,U.jsx)(`option`,{value:`square`,children:`Square`})]}),(0,U.jsx)(X.chevronDown,{})]}):(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:C===Z?``:C,"aria-label":`Stroke position`,onChange:e=>n(`Stroke position`,h({align:e.target.value===`inside`?void 0:e.target.value}),m),children:[C===Z&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),dp.map(([e,t])=>(0,U.jsx)(`option`,{value:e,disabled:c&&e!==`center`,children:t},e))]}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.strokeWeight,{}),title:`Stroke weight`,value:L===null?Z:L,min:0,digits:2,onPreview:e=>i(e===null?null:ee(e),m),onCommit:e=>n(`Stroke weight`,ee(e),m)}),!o&&(0,U.jsx)(`button`,{className:`icon-btn fit ${D!==`all`||O||j?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":!!j,"aria-label":`Stroke sides`,"data-tip":`Stroke sides`,onClick:e=>{if(j)return M(null);let t=e.currentTarget.getBoundingClientRect();M({x:t.left,y:t.bottom+V(`--menu-gap`)})},children:(0,U.jsx)(R,{})}),j&&(0,U.jsx)(Gl,{x:j.x,y:j.y,onClose:()=>M(null),items:[...[`all`,`top`,`bottom`,`left`,`right`].map(e=>{let t=up[e];return{label:lp[e],icon:(0,U.jsx)(t,{}),checked:D===e&&!O,onClick:()=>{k(!1),D!==e&&n(`Stroke: ${lp[e]}`,F(e),m)}}}),{sep:!0},{label:`Custom`,icon:(0,U.jsx)(X.sliders,{}),checked:N,onClick:()=>k(!0)}]})]}),(0,U.jsxs)(`div`,{className:`row2 stroke-style ${_&&v?`dashed`:``}`,children:[(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:_===Z?``:_?`dashed`:`solid`,"aria-label":`Stroke style`,onChange:e=>n(e.target.value===`dashed`?`Dashed stroke`:`Solid stroke`,t=>h({dash:e.target.value===`dashed`?y(t):void 0})(t),m),children:[_===Z&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),(0,U.jsx)(`option`,{value:`solid`,children:`Solid`}),(0,U.jsx)(`option`,{value:`dashed`,children:`Dashed`})]}),(0,U.jsx)(X.chevronDown,{})]}),_&&v&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ql,{label:`Dash`,title:`Dash length`,value:f(e=>y(e)[0]),min:1,digits:2,onPreview:e=>i(e===null?null:b(0,e),m),onCommit:e=>n(`Dash length`,b(0,e),m)}),(0,U.jsx)(Ql,{label:`Gap`,title:`Gap length`,value:f(e=>y(e)[1]),min:0,digits:2,onPreview:e=>i(e===null?null:b(1,e),m),onCommit:e=>n(`Gap length`,b(1,e),m)})]})]}),N&&(0,U.jsx)(`div`,{className:`stroke-sides`,children:[[3,`Left`,X.strokeLeft],[0,`Top`,X.strokeTop],[1,`Right`,X.strokeRight],[2,`Bottom`,X.strokeBottom]].map(([e,t,r])=>(0,U.jsx)(Ql,{label:(0,U.jsx)(r,{}),title:`${t} stroke`,value:P(e),min:0,digits:2,onPreview:t=>i(t===null?null:I(e,t),m),onCommit:r=>n(`${t} stroke`,I(e,r),m)},t))})]})})}function pp({shader:e,colors:t,onPreview:n,onCommit:r}){let i=Se(e),a=(t,n)=>({...e,params:(e.params??[]).map(e=>e.id===t?{...e,value:n}:e)});return(0,U.jsxs)(`div`,{className:`shader-controls`,children:[i&&(0,U.jsx)(`p`,{className:`shader-error`,role:`alert`,children:i.split(`
|
|
4
|
+
`)[0]}),(e.params??[]).map(e=>(0,U.jsxs)(`div`,{className:`shader-param ${e.kind===`number`?`with-slider`:``}`,children:[(0,U.jsx)(`span`,{className:`shader-param-label`,title:e.label,children:e.label}),e.kind===`number`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`range`,className:`shader-slider`,"aria-label":e.label,min:e.min,max:e.max,step:e.step??(e.max-e.min)/100,value:e.value,style:{"--pct":`${(e.value-e.min)/(e.max-e.min||1)*100}%`},onChange:t=>n(a(e.id,Number(t.currentTarget.value))),onPointerUp:t=>r(a(e.id,Number(t.currentTarget.value)),e.label),onKeyUp:t=>{ac(t.key)&&r(a(e.id,Number(t.currentTarget.value)),e.label)}}),(0,U.jsx)(Ql,{label:``,title:e.label,value:e.value,min:e.min,max:e.max,step:e.step??(e.max-e.min)/100,digits:2,onPreview:t=>n(t===null?null:a(e.id,t)),onCommit:t=>r(a(e.id,t),e.label)})]}):(0,U.jsx)(rp,{value:e.value,colors:t,opaque:!0,onPreview:t=>n(t===null||t.startsWith(`$`)?null:a(e.id,t.slice(0,7))),onCommit:n=>{let i=n.startsWith(`$`)?t[n.slice(1)]??e.value:n;r(a(e.id,i.slice(0,7)),e.label)}})]},e.id))]})}function mp(e){return{alignMain:e?`between`:`start`}}function hp(e){return e.length>0&&e.every(e=>e.layout.mode!==`free`)}function gp(e,t){let n=t.parent?e.nodes[t.parent]:void 0;return n?.type===`frame`&&n.layout.mode!==`free`}function _p(e,t,n){let r=[`start`,`center`,`end`],[i,a]=e===`row`?[r[t],r[n]]:[r[n],r[t]];return{main:i,cross:a}}var vp=[[`left`,`Left`],[`right`,`Right`],[`leftRight`,`Left & right`],[`center`,`Center`]],yp=[[`top`,`Top`],[`bottom`,`Bottom`],[`topBottom`,`Top & bottom`],[`center`,`Center`]];function bp({x:e,y:t,onChange:n}){let r=e===Z?null:e??`left`,i=t===Z?null:t??`top`,a=e=>e?`on`:``,o=(e,t,a,o,s)=>{let c=e===`x`?r:i,l=s.shiftKey&&(c===a||c===o)?o:t;n(e===`x`?{x:l}:{y:l},`Constraints`)};return(0,U.jsxs)(`div`,{className:`constraints`,children:[(0,U.jsxs)(`div`,{className:`constraint-selects`,children:[(0,U.jsxs)(`div`,{className:`select-wrap with-icon`,children:[(0,U.jsx)(X.constraintH,{}),(0,U.jsxs)(`select`,{value:r??``,"aria-label":`Horizontal constraint`,onChange:e=>n({x:e.target.value},`Constraints`),children:[e===Z&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),vp.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))]}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsxs)(`div`,{className:`select-wrap with-icon`,children:[(0,U.jsx)(X.constraintV,{}),(0,U.jsxs)(`select`,{value:i??``,"aria-label":`Vertical constraint`,onChange:e=>n({y:e.target.value},`Constraints`),children:[t===Z&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),yp.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))]}),(0,U.jsx)(X.chevronDown,{})]})]}),(0,U.jsxs)(`div`,{className:`constraint-box`,role:`group`,"aria-label":`Constraints`,"data-tip":`Click an edge to pin to it · ⇧-click the opposite edge for both`,children:[(0,U.jsx)(`button`,{className:`c-top ${a(i===`top`||i===`topBottom`)}`,"aria-label":`Pin top`,onClick:e=>o(`y`,`top`,`bottom`,`topBottom`,e)}),(0,U.jsx)(`button`,{className:`c-bottom ${a(i===`bottom`||i===`topBottom`)}`,"aria-label":`Pin bottom`,onClick:e=>o(`y`,`bottom`,`top`,`topBottom`,e)}),(0,U.jsx)(`button`,{className:`c-left ${a(r===`left`||r===`leftRight`)}`,"aria-label":`Pin left`,onClick:e=>o(`x`,`left`,`right`,`leftRight`,e)}),(0,U.jsx)(`button`,{className:`c-right ${a(r===`right`||r===`leftRight`)}`,"aria-label":`Pin right`,onClick:e=>o(`x`,`right`,`left`,`leftRight`,e)}),(0,U.jsxs)(`div`,{className:`c-inner`,children:[(0,U.jsx)(`button`,{className:`c-cx ${a(r===`center`)}`,"aria-label":`Center horizontally`,onClick:()=>n({x:`center`},`Constraints`)}),(0,U.jsx)(`button`,{className:`c-cy ${a(i===`center`)}`,"aria-label":`Center vertically`,onClick:()=>n({y:`center`},`Constraints`)})]})]})]})}function xp(e,t,n){if(!n)return null;let r=e.constraints,i=t.x??r?.x??`left`,a=t.y??r?.y??`top`;return i===`left`&&a===`top`?null:{x:i,y:a,ref:[Math.round(n.w),Math.round(n.h)]}}var Sp={snapObjects:!0,wheelZoom:!1,nudgeSmall:1,nudgeBig:10,agentModel:`default`,agentRunner:`auto`,codexModel:`default`,claudeEffort:`default`,codexEffort:`default`,mcpServers:[],checkUpdates:!0,dismissedUpdate:``},Cp=`nudge.prefs`,wp=null,Tp=new Set;function Ep(){if(wp)return wp;let e={};try{e=JSON.parse(localStorage.getItem(Cp)??`{}`)}catch{}return wp={...Sp,...e},wp}function Dp(e,t){wp={...Ep(),[e]:t};let n=Object.fromEntries(Object.entries(wp).filter(([e,t])=>Sp[e]!==t));try{localStorage.setItem(Cp,JSON.stringify(n))}catch{}Tp.forEach(e=>e())}function Op(e){Tp.add(e);let t=t=>{t.key===Cp&&(wp=null,e())};return addEventListener(`storage`,t),()=>{Tp.delete(e),removeEventListener(`storage`,t)}}var kp=()=>(0,H.useSyncExternalStore)(Op,Ep),Ap=null,jp=new Set;function Mp(){return Ap=fetch(`/api/env`).then(e=>e.ok?e.json():null).catch(()=>null),jp.forEach(e=>e()),Ap}function Np(e=!1){let[t,n]=(0,H.useState)(`loading`);return(0,H.useEffect)(()=>{let t=!0,r=()=>{(Ap??Mp()).then(e=>t&&n(e??`unavailable`))};return e&&Mp(),r(),jp.add(r),()=>{t=!1,jp.delete(r)}},[e]),t}function Pp(){let{agentRunner:e}=kp(),t=Np();return e===`auto`?(typeof t==`object`?t.preferred:null)===`codex`?`codex`:`claude`:e}function Fp(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Ip=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Lp=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rp={};function zp(e,t){return((t||Rp).jsx?Lp:Ip).test(e)}var Bp=/[ \t\n\f\r]/g;function Vp(e){return typeof e==`object`?e.type===`text`&&Hp(e.value):Hp(e)}function Hp(e){return e.replace(Bp,``)===``}var Up=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Up.prototype.normal={},Up.prototype.property={},Up.prototype.space=void 0;function Wp(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Up(n,r,t)}function Gp(e){return e.toLowerCase()}var Kp=class{constructor(e,t){this.attribute=t,this.property=e}};Kp.prototype.attribute=``,Kp.prototype.booleanish=!1,Kp.prototype.boolean=!1,Kp.prototype.commaOrSpaceSeparated=!1,Kp.prototype.commaSeparated=!1,Kp.prototype.defined=!1,Kp.prototype.mustUseProperty=!1,Kp.prototype.number=!1,Kp.prototype.overloadedBoolean=!1,Kp.prototype.property=``,Kp.prototype.spaceSeparated=!1,Kp.prototype.space=void 0;var qp=e({boolean:()=>Yp,booleanish:()=>Xp,commaOrSpaceSeparated:()=>em,commaSeparated:()=>$p,number:()=>Q,overloadedBoolean:()=>Zp,spaceSeparated:()=>Qp}),Jp=0,Yp=tm(),Xp=tm(),Zp=tm(),Q=tm(),Qp=tm(),$p=tm(),em=tm();function tm(){return 2**++Jp}var nm=Object.keys(qp),rm=class extends Kp{constructor(e,t,n,r){let i=-1;if(super(e,t),im(this,`space`,r),typeof n==`number`)for(;++i<nm.length;){let e=nm[i];im(this,nm[i],(n&qp[e])===qp[e])}}};rm.prototype.defined=!0;function im(e,t,n){n&&(e[t]=n)}function am(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new rm(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Gp(r)]=r,n[Gp(a.attribute)]=r}return new Up(t,n,e.space)}var om=am({properties:{ariaActiveDescendant:null,ariaAtomic:Xp,ariaAutoComplete:null,ariaBusy:Xp,ariaChecked:Xp,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:Qp,ariaCurrent:null,ariaDescribedBy:Qp,ariaDetails:null,ariaDisabled:Xp,ariaDropEffect:Qp,ariaErrorMessage:null,ariaExpanded:Xp,ariaFlowTo:Qp,ariaGrabbed:Xp,ariaHasPopup:null,ariaHidden:Xp,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qp,ariaLevel:Q,ariaLive:null,ariaModal:Xp,ariaMultiLine:Xp,ariaMultiSelectable:Xp,ariaOrientation:null,ariaOwns:Qp,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Xp,ariaReadOnly:Xp,ariaRelevant:null,ariaRequired:Xp,ariaRoleDescription:Qp,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Xp,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function sm(e,t){return t in e?e[t]:t}function cm(e,t){return sm(e,t.toLowerCase())}var lm=am({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:$p,acceptCharset:Qp,accessKey:Qp,action:null,allow:null,allowFullScreen:Yp,allowPaymentRequest:Yp,allowUserMedia:Yp,alpha:Yp,alt:null,as:null,async:Yp,autoCapitalize:null,autoComplete:Qp,autoFocus:Yp,autoPlay:Yp,blocking:Qp,capture:null,charSet:null,checked:Yp,cite:null,className:Qp,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:Xp,controls:Yp,controlsList:Qp,coords:Q|$p,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Yp,defer:Yp,dir:null,dirName:null,disabled:Yp,download:Zp,draggable:Xp,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Yp,formTarget:null,headers:Qp,height:Q,hidden:Zp,high:Q,href:null,hrefLang:null,htmlFor:Qp,httpEquiv:Qp,id:null,imageSizes:null,imageSrcSet:null,inert:Yp,inputMode:null,integrity:null,is:null,isMap:Yp,itemId:null,itemProp:Qp,itemRef:Qp,itemScope:Yp,itemType:Qp,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Yp,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Yp,muted:Yp,name:null,nonce:null,noModule:Yp,noValidate:Yp,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Yp,optimum:Q,pattern:null,ping:Qp,placeholder:null,playsInline:Yp,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Yp,referrerPolicy:null,rel:Qp,required:Yp,reversed:Yp,rows:Q,rowSpan:Q,sandbox:Qp,scope:null,scoped:Yp,seamless:Yp,selected:Yp,shadowRootClonable:Yp,shadowRootCustomElementRegistry:Yp,shadowRootDelegatesFocus:Yp,shadowRootMode:null,shadowRootSerializable:Yp,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Xp,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Yp,useMap:null,value:Xp,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qp,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Yp,declare:Yp,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Yp,noHref:Yp,noShade:Yp,noWrap:Yp,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Xp,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Yp,disablePictureInPicture:Yp,disableRemotePlayback:Yp,exportParts:$p,part:Qp,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:cm}),um=am({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,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`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,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`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,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`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:em,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:Qp,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Yp,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$p,g2:$p,glyphName:$p,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:em,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qp,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:em,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:em,rev:em,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:em,requiredFeatures:em,requiredFonts:em,requiredFormats:em,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:em,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:em,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:em,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:sm}),dm=am({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),fm=am({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:cm}),pm=am({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),mm={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},hm=/[A-Z]/g,gm=/-[a-z]/g,_m=/^data[-\w.:]+$/i;function vm(e,t){let n=Gp(t),r=t,i=Kp;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&_m.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(gm,bm);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!gm.test(e)){let n=e.replace(hm,ym);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=rm}return new i(r,t)}function ym(e){return`-`+e.toLowerCase()}function bm(e){return e.charAt(1).toUpperCase()}var xm=Wp([om,lm,dm,fm,pm],`html`),Sm=Wp([om,um,dm,fm,pm],`svg`);function Cm(e){return e.join(` `).trim()}var wm=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
5
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Tm=n(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var i=r(wm());function a(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=(0,i.default)(e),a=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:i}=e;a?t(r,i,e):i&&(n||={},n[r]=i)}),n}})),Em=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Dm=n(((e,t,n)=>{var r=(n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Tm()),i=Em();function a(e,t){var n={};return!e||typeof e!=`string`||(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}a.default=a,t.exports=a})),Om=Am(`end`),km=Am(`start`);function Am(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function jm(e){let t=km(e),n=Om(e);if(t&&n)return{start:t,end:n}}function Mm(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Pm(e.position):`start`in e||`end`in e?Pm(e):`line`in e||`column`in e?Nm(e):``}function Nm(e){return Fm(e&&e.line)+`:`+Fm(e&&e.column)}function Pm(e){return Nm(e&&e.start)+`-`+Nm(e&&e.end)}function Fm(e){return e&&typeof e==`number`?e:1}var Im=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Mm(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Im.prototype.file=``,Im.prototype.name=``,Im.prototype.reason=``,Im.prototype.message=``,Im.prototype.stack=``,Im.prototype.column=void 0,Im.prototype.line=void 0,Im.prototype.ancestors=void 0,Im.prototype.cause=void 0,Im.prototype.fatal=void 0,Im.prototype.place=void 0,Im.prototype.ruleId=void 0,Im.prototype.source=void 0;var Lm=t(Dm(),1),Rm={}.hasOwnProperty,zm=new Map,Bm=/[A-Z]/g,Vm=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Hm=new Set([`td`,`th`]),Um=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Wm(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=th(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=eh(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Sm:xm,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Gm(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Gm(e,t,n){if(t.type===`element`)return Km(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return qm(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Ym(e,t,n);if(t.type===`mdxjsEsm`)return Jm(e,t);if(t.type===`root`)return Xm(e,t,n);if(t.type===`text`)return Zm(e,t)}function Km(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Sm,e.schema=i),e.ancestors.push(t);let a=sh(e,t.tagName,!1),o=nh(e,t),s=ih(e,t);return Vm.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!Vp(e)})),Qm(e,o,a,t),$m(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qm(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}ch(e,t.position)}function Jm(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ch(e,t.position)}function Ym(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Sm,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:sh(e,t.name,!0),o=rh(e,t),s=ih(e,t);return Qm(e,o,a,t),$m(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Xm(e,t,n){let r={};return $m(r,ih(e,t)),e.create(t,e.Fragment,r,n)}function Zm(e,t){return t.value}function Qm(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function $m(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function eh(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function th(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=km(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function nh(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Rm.call(t.properties,i)){let a=ah(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Hm.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function rh(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ch(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else ch(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function ih(e,t){let n=[],r=-1,i=e.passKeys?new Map:zm;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Gm(e,a,o);s!==void 0&&n.push(s)}return n}function ah(e,t,n){let r=vm(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Fp(n):Cm(n)),r.property===`style`){let t=typeof n==`object`?n:oh(e,String(n));return e.stylePropertyNameCase===`css`&&(t=lh(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?mm[r.property]||r.property:r.attribute,n]}}function oh(e,t){try{return(0,Lm.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Im("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Um+`#cannot-parse-style-attribute`,r}}function sh(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=zp(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=zp(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Rm.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);ch(e)}function ch(e,t){let n=new Im("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Um+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function lh(e){let t={},n;for(n in e)Rm.call(e,n)&&(t[uh(n)]=e[n]);return t}function uh(e){let t=e.replace(Bm,dh);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function dh(e){return`-`+e.toLowerCase()}var fh={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},ph={};function mh(e,t){let n=t||ph;return hh(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function hh(e,t,n){if(_h(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return gh(e.children,t,n)}return Array.isArray(e)?gh(e,t,n):``}function gh(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=hh(e[i],t,n);return r.join(``)}function _h(e){return!!(e&&typeof e==`object`)}var vh=document.createElement(`i`);function yh(e){let t=`&`+e+`;`;vh.innerHTML=t;let n=vh.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function bh(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function xh(e,t){return e.length>0?(bh(e,e.length,0,t),e):t}var Sh={}.hasOwnProperty;function Ch(e){let t={},n=-1;for(;++n<e.length;)wh(t,e[n]);return t}function wh(e,t){let n;for(n in t){let r=(Sh.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Sh.call(r,a)||(r[a]=[]);let e=i[a];Th(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Th(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);bh(e,0,0,r)}function Eh(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function Dh(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Oh=zh(/[A-Za-z]/),kh=zh(/[\dA-Za-z]/),Ah=zh(/[#-'*+\--9=?A-Z^-~]/);function jh(e){return e!==null&&(e<32||e===127)}var Mh=zh(/\d/),Nh=zh(/[\dA-Fa-f]/),Ph=zh(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function Fh(e){return e!==null&&(e<0||e===32)}function Ih(e){return e===-2||e===-1||e===32}var Lh=zh(/\p{P}|\p{S}/u),Rh=zh(/\s/);function zh(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Bh(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&kh(e.charCodeAt(n+1))&&kh(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function Vh(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Ih(r)?(e.enter(n),s(r)):t(r)}function s(r){return Ih(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function Hh(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&Ih(t)?(e.enter(r),c(t)):l(t)}function c(t){return Ih(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var Uh={tokenize:Wh};function Wh(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Vh(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Gh=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){Kh(this,e,t,n,!1)}addBefore(e,t,n){Kh(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Kh(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var qh={tokenize:Yh},Jh={tokenize:Xh};function Yh(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new Gh;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Jh,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Jh,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return $(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new Gh;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Xh(e,t,n){return Vh(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Zh(e){if(e===null||Fh(e)||Rh(e))return 1;if(Lh(e))return 2}function Qh(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var $h={name:`attention`,resolveAll:eg,tokenize:tg};function eg(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};ng(o,-a),ng(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=xh(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=xh(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=xh(r,Qh(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=xh(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=xh(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),bh(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function tg(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Zh(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Zh(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function ng(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var rg={name:`autolink`,tokenize:ig};function ig(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Oh(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||kh(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||kh(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||jh(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Ah(t)?(e.consume(t),l):n(t)}function u(e){return kh(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||kh(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var ag={partial:!0,tokenize:og};function og(e,t,n){return r;function r(t){return Ih(t)?Vh(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var sg={continuation:{tokenize:lg},exit:ug,name:`blockQuote`,tokenize:cg};function cg(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Ih(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function lg(e,t,n){let r=this;return i;function i(t){return Ih(t)?Vh(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(sg,t,n)(r)}}function ug(e){e.exit(`blockQuote`)}var dg={name:`characterEscape`,tokenize:fg};function fg(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Ph(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var pg={name:`characterReference`,tokenize:mg};function mg(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=kh,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Nh,u):(e.enter(`characterReferenceValue`),a=7,o=Mh,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===kh&&!yh(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var hg={partial:!0,tokenize:gg};function gg(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var _g={concrete:!0,name:`codeFenced`,tokenize:vg};function vg(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Ih(t)?Vh(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(hg,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Ih(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),Vh(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Ih(t)?Vh(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(hg,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Ih(t)?Vh(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Ih(t)?Vh(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var yg={name:`codeIndented`,tokenize:xg},bg={partial:!0,tokenize:Sg};function xg(e,t,n){return r;function r(t){return e.enter(`codeIndented`),Hh(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):$(t)?e.attempt(bg,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||$(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function Sg(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):$(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):Hh(e,t,a,`linePrefix`,4,4)(o)}function a(e){return $(e)?i(e):n(e)}}var Cg={name:`codeText`,previous:Tg,resolve:wg,tokenize:Eg};function wg(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Tg(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Eg(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Dg=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Og(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Og(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Og(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Og(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Og(this.left,t.reverse())}}}};function Og(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function kg(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Dg(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Ag(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return bh(e,0,1/0,u.slice(0)),!l}function Ag(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var jg={resolve:Ng,tokenize:Pg},Mg={partial:!0,tokenize:Fg};function Ng(e){return kg(e),e}function Pg(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$(t)?e.check(Mg,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Fg(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Vh(e,a,`linePrefix`)}function a(i){if(i===null||$(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Ig(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||jh(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Fh(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||jh(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Lg(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Ih(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Rg(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),Vh(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function zg(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Ih(i)?Vh(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Bg={name:`definition`,tokenize:Hg},Vg={partial:!0,tokenize:Ug};function Hg(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Lg.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Dh(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Fh(t)?zg(e,l)(t):l(t)}function l(t){return Ig(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Vg,d,d)(t)}function d(t){return Ih(t)?Vh(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Ug(e,t,n){return r;function r(t){return Fh(t)?zg(e,i)(t):n(t)}function i(t){return Rg(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Ih(t)?Vh(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var Wg={name:`hardBreakEscape`,tokenize:Gg};function Gg(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Kg={name:`headingAtx`,resolve:qg,tokenize:Jg};function qg(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};bh(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function Jg(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Fh(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):Ih(n)?Vh(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Fh(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Yg=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Xg=[`pre`,`script`,`style`,`textarea`],Zg={concrete:!0,name:`htmlFlow`,resolveTo:$g,tokenize:e_},Qg={partial:!0,tokenize:t_};function $g(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function e_(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):Oh(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Oh(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return Oh(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Fh(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Xg.includes(l)?(i=1,r.interrupt?t(s):O(s)):Yg.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||kh(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Ih(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Oh(t)?(e.consume(t),b):Ih(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||kh(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Ih(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Ih(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Fh(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Ih(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):Ih(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Qg,ee,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(hg,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Xg.includes(n)?(e.consume(t),L):O(t)}return Oh(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||$(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function t_(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(ag,t,n)}}var n_={name:`htmlText`,tokenize:r_};function r_(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Oh(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Oh(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return Oh(t)?(e.consume(t),S):n(t)}function S(t){return t===45||kh(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):Ih(t)?(e.consume(t),C):M(t)}function w(t){return t===45||kh(t)?(e.consume(t),w):t===47||t===62||Fh(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||Oh(t)?(e.consume(t),E):$(t)?(o=T,N(t)):Ih(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||kh(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):Ih(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$(t)?(o=O,N(t)):Ih(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Fh(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||Fh(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return Ih(t)?Vh(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var i_={name:`labelEnd`,resolveAll:c_,resolveTo:l_,tokenize:u_},a_={tokenize:d_},o_={tokenize:f_},s_={tokenize:p_};function c_(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&bh(e,0,e.length,n),e}function l_(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=xh(o,e.slice(i+1,i+r+3)),o=xh(o,[[`enter`,l,t]]),o=xh(o,Qh(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=xh(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=xh(o,e.slice(a+1)),o=xh(o,[[`exit`,s,t]]),bh(e,i,e.length,o),e}function u_(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Dh(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(a_,u,o?u:d)(t):t===91?e.attempt(o_,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(s_,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function d_(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Fh(t)?zg(e,a)(t):a(t)}function a(t){return t===41?u(t):Ig(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Fh(t)?zg(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Rg(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Fh(t)?zg(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function f_(e,t,n){let r=this;return i;function i(t){return Lg.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Dh(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function p_(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var m_={name:`labelStartImage`,resolveAll:i_.resolveAll,tokenize:h_};function h_(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var g_={name:`labelStartLink`,resolveAll:i_.resolveAll,tokenize:__};function __(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var v_={name:`lineEnding`,tokenize:y_};function y_(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),Vh(e,t,`linePrefix`)}}var b_={name:`thematicBreak`,tokenize:x_};function x_(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Ih(t)?Vh(e,s,`whitespace`)(t):s(t))}}var S_={continuation:{tokenize:E_},exit:O_,name:`list`,tokenize:T_},C_={partial:!0,tokenize:k_},w_={partial:!0,tokenize:D_};function T_(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Mh(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(b_,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Mh(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(ag,r.interrupt?n:u,e.attempt(C_,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Ih(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function E_(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(ag,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Vh(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Ih(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(w_,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,Vh(e,e.attempt(S_,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function D_(e,t,n){let r=this;return Vh(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function O_(e){e.exit(this.containerState.type)}function k_(e,t,n){let r=this;return Vh(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Ih(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var A_={name:`setextUnderline`,resolveTo:j_,tokenize:M_};function j_(e,t){let n=new Gh,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function M_(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Ih(t)?Vh(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var N_={tokenize:P_};function P_(e){let t=this,n=e.attempt(ag,r,e.attempt(this.parser.constructs.flowInitial,i,Vh(e,e.attempt(this.parser.constructs.flow,i,e.attempt(jg,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var F_={resolveAll:z_()},I_=R_(`string`),L_=R_(`text`);function R_(e){return{resolveAll:z_(e===`text`?B_:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function z_(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function B_(e,t){let n=new Gh,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var V_=e({attentionMarkers:()=>Y_,contentInitial:()=>U_,disable:()=>X_,document:()=>H_,flow:()=>G_,flowInitial:()=>W_,insideSpan:()=>J_,string:()=>K_,text:()=>q_}),H_={42:S_,43:S_,45:S_,48:S_,49:S_,50:S_,51:S_,52:S_,53:S_,54:S_,55:S_,56:S_,57:S_,62:sg},U_={91:Bg},W_={[-2]:yg,[-1]:yg,32:yg},G_={35:Kg,42:b_,45:[A_,b_],60:Zg,61:A_,95:b_,96:_g,126:_g},K_={38:pg,92:dg},q_={[-5]:v_,[-4]:v_,[-3]:v_,33:m_,38:pg,42:$h,60:[rg,n_],91:g_,92:[Wg,dg],93:i_,95:$h,96:Cg},J_={null:[$h,F_]},Y_={null:[42,95]},X_={null:[]};function Z_(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=xh(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Qh(a,l.events,l),l.events):[]}function f(e,t){return $_(p(e),t)}function p(e){return Q_(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){$(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&bh(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Q_(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function $_(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
6
|
+
`;break;case-3:o=`\r
|
|
7
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function ev(e){let t={constructs:Ch([V_,...(e||{}).extensions||[]]),content:n(Uh),defined:[],document:n(qh),flow:n(N_),lazy:{},string:n(I_),text:n(L_)};return t;function n(e){return n;function n(n){return Z_(t,e,n)}}}function tv(e){for(;!kg(e););return e}var nv=/[\0\t\n\r]/g;function rv(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){nv.lastIndex=c;let n=nv.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var iv=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function av(e){return e.replace(iv,ov)}function ov(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return Eh(n.slice(t?2:1),t?16:10)}return yh(n)||e}var sv={}.hasOwnProperty;function cv(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),lv(n)(tv(ev(n).document().write(rv()(e,t,!0))))}function lv(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(ge),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(z),blockQuote:o(ce),characterEscape:E,characterReference:E,codeFenced:o(le),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(le,s),codeText:o(ue,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(de),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(fe),hardBreakEscape:o(pe),hardBreakTrailing:o(pe),htmlFlow:o(me,s),htmlFlowData:E,htmlText:o(me,s),htmlTextData:E,image:o(he),label:s,link:o(ge),listItem:o(ve),listItemValue:p,listOrdered:o(_e,f),listUnordered:o(_e),paragraph:o(ye),reference:te,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(z),strong:o(be),thematicBreak:o(Se)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:se,autolinkProtocol:oe,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ie,characterReference:ae,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:I,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:L,resourceTitleString:ee,resource:R,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};dv(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),sv.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||pv).call(o,void 0,e[0])}for(r.position={start:uv(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:uv(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:uv(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+Mm({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||pv).call(this,e,r[0])),n.position.end=uv(e.end)}function d(){return mh(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Dh(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=xe(),n.position={start:uv(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=uv(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=uv(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=av(t),n.identifier=Dh(t).toLowerCase()}function I(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Dh(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function ie(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=Eh(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=yh(t);let i=this.stack[this.stack.length-1];i.value+=r}function ae(e){let t=this.stack.pop();t.position.end=uv(e.end)}function oe(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function se(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ce(){return{type:`blockquote`,children:[],position:void 0}}function le(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function ue(){return{type:`inlineCode`,value:``,position:void 0}}function de(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function fe(){return{type:`emphasis`,children:[],position:void 0}}function z(){return{type:`heading`,depth:0,children:[],position:void 0}}function pe(){return{type:`break`,position:void 0}}function me(){return{type:`html`,value:``,position:void 0}}function he(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function ge(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function _e(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function ve(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function ye(){return{type:`paragraph`,children:[],position:void 0}}function be(){return{type:`strong`,children:[],position:void 0}}function xe(){return{type:`text`,value:``,position:void 0}}function Se(){return{type:`thematicBreak`,position:void 0}}}function uv(e){return{line:e.line,column:e.column,offset:e.offset}}function dv(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?dv(e,r):fv(e,r)}}function fv(e,t){let n;for(n in t)if(sv.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function pv(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Mm({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Mm({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Mm({start:t.start,end:t.end})+`) is still open`)}function mv(e){let t=this;t.parser=n;function n(n){return cv(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function hv(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function gv(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
8
|
+
`}]}function _v(e,t){let n=t.value?t.value+`
|
|
9
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function vv(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yv(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bv(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=Bh(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function xv(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Sv(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Cv(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function wv(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Cv(e,t);let i={src:Bh(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function Tv(e,t){let n={src:Bh(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Ev(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Dv(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Cv(e,t);let i={href:Bh(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Ov(e,t){let n={href:Bh(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function kv(e,t,n){let r=e.all(t),i=n?Av(n):jv(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
10
|
+
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
11
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Av(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=jv(n[r])}return t}function jv(e){return e.spread??e.children.length>1}function Mv(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function Nv(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Pv(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Fv(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Iv(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=km(t.children[1]),o=Om(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Lv(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Rv(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var zv=9,Bv=32;function Vv(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Hv(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Hv(t.slice(i),i>0,!1)),a.join(``)}function Hv(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===zv||t===Bv;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===zv||t===Bv;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Uv(e,t){let n={type:`text`,value:Vv(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Wv(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Gv={blockquote:hv,break:gv,code:_v,delete:vv,emphasis:yv,footnoteReference:bv,heading:xv,html:Sv,imageReference:wv,image:Tv,inlineCode:Ev,linkReference:Dv,link:Ov,listItem:kv,list:Mv,paragraph:Nv,root:Pv,strong:Fv,table:Iv,tableCell:Rv,tableRow:Lv,text:Uv,thematicBreak:Wv,toml:Kv,yaml:Kv,definition:Kv,footnoteDefinition:Kv};function Kv(){}var{defineProperty:qv}=Object,Jv=typeof self==`object`?self:globalThis,Yv=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Jv[e](t)},Xv=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?qv(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof Jv[e]==`function`?Yv(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(Yv(a,o),i)};return r},Zv=e=>Xv(new Map,e)(0),Qv=``,{toString:$v}={},{keys:ey,is:ty}=Object,ny=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=$v.call(e).slice(8,-1);switch(n){case`Array`:return[1,Qv];case`Object`:return[2,Qv];case`Date`:return[3,Qv];case`RegExp`:return[4,Qv];case`Map`:return[5,Qv];case`Set`:return[6,Qv];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},ry=([e,t])=>e===0&&(t===`function`||t===`symbol`),iy=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=ny(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&ty(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of ey(o))(e||!ry(ny(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?Qv:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(ry(ny(n))||ry(ny(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!ry(ny(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},ay=(e,{json:t,lossy:n}={})=>{let r=[];return iy(!(t||n),!!t,new Map,r)(e),r},oy=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?Zv(ay(e,t)):structuredClone(e):(e,t)=>Zv(ay(e,t));function sy(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function cy(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function ly(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||sy,r=e.options.footnoteBackLabel||cy,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=Bh(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...oy(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
12
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
13
|
+
`}]}}var uy=(function(e){if(e==null)return hy;if(typeof e==`function`)return my(e);if(typeof e==`object`)return Array.isArray(e)?dy(e):fy(e);if(typeof e==`string`)return py(e);throw Error(`Expected function, string, or object as test`)});function dy(e){let t=[],n=-1;for(;++n<e.length;)t[n]=uy(e[n]);return my(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function fy(e){let t=e;return my(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function py(e){return my(t);function t(t){return t&&t.type===e}}function my(e){return t;function t(t,n,r){return!!(gy(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function hy(){return!0}function gy(e){return typeof e==`object`&&!!e&&`type`in e}function _y(e){return e}var vy=[];function yy(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=uy(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+_y(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=vy,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=by(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function by(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?vy:[e]}function xy(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),yy(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var Sy={}.hasOwnProperty,Cy={};function wy(e,t){let n=t||Cy,r=new Map,i=new Map,a={all:s,applyData:Ey,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Gv,...n.handlers},one:o,options:n,patch:Ty,wrap:Oy};return xy(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(Sy.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=oy(n);return r.children=a.all(e),r}return oy(e)}return(a.options.unknownHandler||Dy)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=ky(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=ky(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Ty(e,t){e.position&&(t.position=jm(e))}function Ey(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,oy(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Dy(e,t){let n=t.data||{},r=`value`in t&&!(Sy.call(n,`hProperties`)||Sy.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Oy(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
14
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
15
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
16
|
+
`}),n}function ky(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ay(e,t){let n=wy(e,t),r=n.one(e,void 0),i=ly(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
17
|
+
`},i)),a}function jy(e,t){return e&&`run`in e?async function(n,r){let i=Ay(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Ay(n,{file:r,...e||t})}}function My(e){if(e)throw e}var Ny=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Py(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Fy(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Iy(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Iy(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Ly={basename:Ry,dirname:zy,extname:By,join:Vy,sep:`/`};function Ry(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Wy(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function zy(e){if(Wy(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function By(e){Wy(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Vy(...e){let t=-1,n;for(;++t<e.length;)Wy(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Hy(n)}function Hy(e){Wy(e);let t=e.codePointAt(0)===47,n=Uy(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Uy(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Wy(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Gy={cwd:Ky};function Ky(){return`/`}function qy(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Jy(e){if(typeof e==`string`)e=new URL(e);else if(!qy(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Yy(e)}function Yy(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var Xy=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Zy=class{constructor(e){let t;t=e?qy(e)?{path:e}:typeof e==`string`||tb(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Gy.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Xy.length;){let e=Xy[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Xy.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Ly.basename(this.path):void 0}set basename(e){$y(e,`basename`),Qy(e,`basename`),this.path=Ly.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Ly.dirname(this.path):void 0}set dirname(e){eb(this.basename,`dirname`),this.path=Ly.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Ly.extname(this.path):void 0}set extname(e){if(Qy(e,`extname`),eb(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Ly.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){qy(e)&&(e=Jy(e)),$y(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Ly.basename(this.path,this.extname):void 0}set stem(e){$y(e,`stem`),Qy(e,`stem`),this.path=Ly.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Im(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Qy(e,t){if(e&&e.includes(Ly.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Ly.sep+"`")}function $y(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function eb(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function tb(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var nb=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),rb=t(Ny(),1),ib={}.hasOwnProperty,ab=new class e extends nb{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Fy()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,rb.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(cb(`data`,this.frozen),this.namespace[e]=t,this):ib.call(this.namespace,e)&&this.namespace[e]||void 0:e?(cb(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=db(e),n=this.parser||this.Parser;return ob(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),ob(`process`,this.parser||this.Parser),sb(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=db(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);pb(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),ob(`processSync`,this.parser||this.Parser),sb(`processSync`,this.compiler||this.Compiler),this.process(e,r),ub(`processSync`,`process`,t),n;function r(e,r){t=!0,My(e),n=r}}run(e,t,n){lb(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=db(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),ub(`runSync`,`run`,n),r;function i(e,t){My(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=db(t),r=this.compiler||this.Compiler;return sb(`stringify`,r),lb(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(cb(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,rb.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Py(o)&&Py(r)&&(r=(0,rb.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function ob(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function sb(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function cb(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function lb(e){if(!Py(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function ub(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function db(e){return fb(e)?e:new Zy(e)}function fb(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function pb(e){return typeof e==`string`||mb(e)}function mb(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var hb=[],gb={allowDangerousHtml:!0},_b=/^(https?|ircs?|mailto|xmpp)$/i,vb=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function yb(e){let t=bb(e),n=xb(e);return Sb(t.runSync(t.parse(n),n),e)}function bb(e){let t=e.rehypePlugins||hb,n=e.remarkPlugins||hb,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gb}:gb;return ab().use(mv).use(n).use(jy,r).use(t)}function xb(e){let t=e.children||``,n=new Zy;return typeof t==`string`?n.value=t:``+t,n}function Sb(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Cb;for(let e of vb)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return xy(e,l),Wm(e,{Fragment:U.Fragment,components:i,ignoreInvalidStyle:!0,jsx:U.jsx,jsxs:U.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in fh)if(Object.hasOwn(fh,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=fh[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Cb(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||_b.test(e.slice(0,t))?e:``}function wb(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Tb(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Eb(e,t,n){let r=uy((n||{}).ignore||[]),i=Db(t),a=-1;for(;++a<i.length;)yy(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1)r.lastIndex=n+1;else{if(s!==n&&f({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a))for(let e of a)f(e);else a&&f(a);s=n+d[0].length,l=!0}if(!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&f({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length;function f(e){let t=u[u.length-1];t&&t.type===`text`&&e.type===`text`?t.value+=e.value:u.push(e)}}}function Db(e){if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let t=[],n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ob(e[0]),kb(e[1])])}return t}function Ob(e){return typeof e==`string`?new RegExp(Tb(e),`g`):e}function kb(e){return typeof e==`function`?e:function(){return e}}var Ab=`phrasing`,jb=[`autolink`,`link`,`image`,`label`];function Mb(){return{transforms:[Bb],enter:{literalAutolink:Pb,literalAutolinkEmail:Fb,literalAutolinkHttp:Fb,literalAutolinkWww:Fb},exit:{literalAutolink:zb,literalAutolinkEmail:Rb,literalAutolinkHttp:Ib,literalAutolinkWww:Lb}}}function Nb(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Ab,notInConstruct:jb},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Ab,notInConstruct:jb},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Ab,notInConstruct:jb}]}}function Pb(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Fb(e){this.config.enter.autolinkProtocol.call(this,e)}function Ib(e){this.config.exit.autolinkProtocol.call(this,e)}function Lb(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Rb(e){this.config.exit.autolinkEmail.call(this,e)}function zb(e){this.exit(e)}function Bb(e){Eb(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Vb],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Hb]],{ignore:[`link`,`linkReference`]})}function Vb(e,t,n,r,i){let a=``;if(!Gb(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Ub(n)))return!1;let o=Wb(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Hb(e,t,n,r){return!Gb(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Ub(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Wb(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=wb(e,`(`),a=wb(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Gb(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Rh(n)||Lh(n))&&(!t||n!==47)}tx.peek=ex;function Kb(){this.buffer()}function qb(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Jb(){this.buffer()}function Yb(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Xb(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Dh(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Zb(e){this.exit(e)}function Qb(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Dh(this.sliceSerialize(e)).toLowerCase(),n.label=t}function $b(e){this.exit(e)}function ex(){return`[`}function tx(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function nx(){return{enter:{gfmFootnoteCallString:Kb,gfmFootnoteCall:qb,gfmFootnoteDefinitionLabelString:Jb,gfmFootnoteDefinition:Yb},exit:{gfmFootnoteCallString:Xb,gfmFootnoteCall:Zb,gfmFootnoteDefinitionLabelString:Qb,gfmFootnoteDefinition:$b}}}function rx(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:tx},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
18
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?ax:ix))),s(),o}}function ix(e,t,n){return t===0?e:ax(e,t,n)}function ax(e,t,n){return(n?``:` `)+e}var ox=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];dx.attention=fx,dx.peek=px;function sx(){return{canContainEols:[`delete`],enter:{strikethrough:lx},exit:{strikethrough:ux}}}function cx(){return{handlers:{delete:dx},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:ox}]}}function lx(e){this.enter({type:`delete`,children:[],position:void 0},e)}function ux(e){this.exit(e)}function dx(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,{...i.current(),before:s,after:`~`}),s+=i.move(a),o(),s}function fx(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function px(){return`~`}function mx(e){return e.length}function hx(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||mx,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=gx(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=_x(r[d]);else{let e=_x(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding===!1||n.alignDelimiters===!1&&i===``||n.delimiterStart===!1&&!d||r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
19
|
+
`)}function gx(e){return e==null?``:String(e)}function _x(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}var vx=uy([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function yx(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),bx);return i(),o}function bx(e,t,n){return`>`+(n?``:` `)+e}function xx(e,t){return Sx(e,t.inConstruct,!0)&&!Sx(e,t.notInConstruct,!1)}function Sx(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Cx(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
|
|
20
|
+
`&&!e.before&&!e.after&&xx(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
|
|
21
|
+
`}function wx(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Tx(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function Ex(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Dx(e,t,n,r){let i=Ex(n),a=e.value||``;if(Tx(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Ox);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(wx(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,{before:u,after:`
|
|
22
|
+
`,encode:["`"],...o.current()})),t()}return u+=o.move(`
|
|
23
|
+
`),a&&(u+=o.move(a+`
|
|
24
|
+
`)),u+=o.move(s),c(),u}function Ox(e,t,n){return(n?``:` `)+e}function kx(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Ax(e,t,n,r){let i=kx(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
25
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function jx(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}Mx.attention=Nx,Mx.peek=Px;function Mx(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function Nx(e,t){return{construct:`emphasis`,markers:jx(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function Px(e,t,n){return n.options.emphasis||`*`}function Fx(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Ix(e,t){let n=!1;return xy(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&mh(e)&&(t.options.setext||n))}function Lx(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Ix(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
26
|
+
`,after:`
|
|
27
|
+
`});return r(),t(),o+`
|
|
28
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
29
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
30
|
+
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=Fx(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Rx.peek=zx;function Rx(e){return e.value||``}function zx(){return`<`}Bx.peek=Vx;function Bx(e,t,n,r){let i=kx(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Vx(){return`!`}Hx.peek=Ux;function Hx(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Ux(){return`!`}Wx.peek=Gx;function Wx(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Gx(){return"`"}function Kx(e,t){let n=mh(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}qx.peek=Jx;function qx(e,t,n,r){let i=kx(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(Kx(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Jx(e,t,n){return Kx(e,n)?`<`:`[`}Yx.peek=Xx;function Yx(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Xx(){return`[`}function Zx(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Qx(e){let t=Zx(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function $x(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function eS(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function tS(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?$x(n):Zx(n),s=e.ordered?o===`.`?`)`:`.`:Qx(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if(o!==`*`&&o!==`-`||!t||t.children&&t.children[0]||n.stack[n.stack.length-1]!==`list`||n.stack[n.stack.length-2]!==`listItem`||n.stack[n.stack.length-3]!==`list`||n.stack[n.stack.length-4]!==`listItem`||n.indexStack[n.indexStack.length-1]!==0||n.indexStack[n.indexStack.length-2]!==0||n.indexStack[n.indexStack.length-3]!==0||(c=!0),eS(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function nS(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rS(e,t,n,r){let i=nS(n),a=n.bulletCurrent||Zx(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function iS(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function aS(e,t,n,r){if(!e.children.some(function(e){return vx(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function oS(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}sS.attention=cS,sS.peek=lS;function sS(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function cS(e,t){return{construct:`strong`,markers:oS(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function lS(e,t,n){return n.options.strong||`*`}function uS(e,t,n,r){let i=t?t.children:[],a=i.indexOf(e);return n.safe(e.value,{...r,afterNode:i[a+1],beforeNode:i[a-1]})}function dS(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function fS(e,t,n){let r=(eS(n)+(n.options.ruleSpaces?` `:``)).repeat(dS(n));return n.options.ruleSpaces?r.slice(0,-1):r}var pS={blockquote:yx,break:Cx,code:Dx,definition:Ax,emphasis:Mx,hardBreak:Cx,heading:Lx,html:Rx,image:Bx,imageReference:Hx,inlineCode:Wx,link:qx,linkReference:Yx,list:tS,listItem:rS,paragraph:iS,root:aS,strong:sS,text:uS,thematicBreak:fS};function mS(){return{enter:{table:hS,tableData:yS,tableHeader:yS,tableRow:_S},exit:{codeText:bS,table:gS,tableData:vS,tableHeader:vS,tableRow:vS}}}function hS(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function gS(e){this.exit(e),this.data.inTable=void 0}function _S(e){this.enter({type:`tableRow`,children:[]},e)}function vS(e){this.exit(e)}function yS(e){this.enter({type:`tableCell`,children:[]},e)}function bS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,xS));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function xS(e,t){return t===`|`?t:e}function SS(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
31
|
+
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
32
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return hx(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=pS.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function CS(){return{exit:{taskListCheckValueChecked:TS,taskListCheckValueUnchecked:TS,paragraph:ES}}}function wS(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:DS}}}function TS(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function ES(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function DS(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=pS.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function OS(){return[Mb(),nx(),sx(),mS(),CS()]}function kS(e){return{extensions:[Nb(),rx(e),cx(),SS(e),wS()]}}var AS={tokenize:WS,partial:!0},jS={tokenize:GS,partial:!0},MS={tokenize:KS,partial:!0},NS={tokenize:qS,partial:!0},PS={tokenize:JS,partial:!0},FS={name:`wwwAutolink`,tokenize:HS,previous:YS},IS={name:`protocolAutolink`,tokenize:US,previous:XS},LS={name:`emailAutolink`,tokenize:VS,previous:ZS},RS={};function zS(){return{text:RS}}for(var BS=48;BS<123;)RS[BS]=LS,BS++,BS===58?BS=65:BS===91&&(BS=97);RS[43]=LS,RS[45]=LS,RS[46]=LS,RS[95]=LS,RS[72]=[LS,IS],RS[104]=[LS,IS],RS[87]=[LS,FS],RS[119]=[LS,FS];function VS(e,t,n){let r=this,i,a;return o;function o(t){return!QS(t)||!ZS.call(r,r.previous)||$S(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return QS(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(PS,u,l)(t):t===45||t===95||kh(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Oh(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function HS(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!YS.call(r,r.previous)||$S(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(AS,e.attempt(jS,e.attempt(MS,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function US(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&XS.call(r,r.previous)&&!$S(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Oh(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||jh(t)||Fh(t)||Rh(t)||Lh(t)?n(t):e.attempt(jS,e.attempt(MS,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function WS(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function GS(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(NS,c,s)(t):t===null||Fh(t)||Rh(t)||t!==45&&Lh(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function KS(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(NS,t,a)(o):o===null||Fh(o)||Rh(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function qS(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Fh(o)||Rh(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Fh(e)||Rh(e)?t(e):r(e)}function a(e){return Oh(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Oh(t)?(e.consume(t),o):n(t)}}function JS(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return kh(e)?n(e):t(e)}}function YS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Fh(e)}function XS(e){return!Oh(e)}function ZS(e){return!(e===47||QS(e))}function QS(e){return e===43||e===45||e===46||e===95||kh(e)}function $S(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var eC={tokenize:cC,partial:!0};function tC(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:aC,continuation:{tokenize:oC},exit:sC}},text:{91:{name:`gfmFootnoteCall`,tokenize:iC},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:nC,resolveTo:rC}}}}function nC(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Dh(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function rC(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function iC(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Fh(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Dh(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Fh(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function aC(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Fh(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Dh(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Fh(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),Vh(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function oC(e,t,n){return e.check(ag,t,e.attempt(eC,t,n))}function sC(e){e.exit(`gfmFootnoteDefinition`)}function cC(e,t,n){let r=this;return Vh(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function lC(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&bh(o,o.length,0,Qh(s,e.slice(r+1,n),t)),bh(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),bh(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Zh(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Zh(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var uC=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){dC(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function dC(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function fC(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function pC(){return{flow:{null:{name:`table`,tokenize:mC,resolveAll:hC}}}}function mC(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Ih(t)?Vh(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Fh(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Ih(t)?Vh(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Ih(t)?Vh(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Ih(t)?Vh(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):Ih(n)?Vh(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Fh(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function hC(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new uC;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(_C(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=gC(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=gC(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=gC(f,t,o,i,n,d)):(o[0]=o[1],d=gC(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&_C(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=fC(t.events,n))}return e}function gC(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},vC(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=vC(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=vC(t.events,n[2]),a=vC(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},vC(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function _C(e,t,n,r,i){let a=[],o=vC(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function vC(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var yC={name:`tasklistCheck`,tokenize:xC};function bC(){return{text:{91:yC}}}function xC(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Fh(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):Ih(r)?e.check({tokenize:SC},t,n)(r):n(r)}}function SC(e,t,n){return Vh(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function CC(e){return Ch([zS(),tC(),lC(e),pC(),bC()])}var wC={};function TC(e){let t=this,n=e||wC,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(CC(n)),a.push(OS()),o.push(kS(n))}function EC(e,t){let n=[],r=t=>{let i=e.nodes[t];if(i){n.push(i);for(let e of i.children??[])r(e)}};return r(t),n}function DC({doc:e,id:t,size:n}){let r=e.nodes[t],i=(0,H.useMemo)(()=>r?{...e,roots:[t],comments:void 0,nodes:{...e.nodes,[t]:{...r,x:0,y:0}}}:null,[e,t,r]);if(!i||!r||!r.w||!r.h)return null;let a=Math.min(n/r.w,n/r.h);return(0,U.jsx)(`span`,{className:`frame-thumb`,"aria-hidden":!0,style:{width:n,height:n},children:(0,U.jsx)(`span`,{style:{position:`absolute`,left:(n-r.w*a)/2,top:(n-r.h*a)/2,width:r.w,height:r.h,transform:`scale(${a})`,transformOrigin:`0 0`,pointerEvents:`none`},children:(0,U.jsx)(He,{doc:i})})})}var OC=(0,H.memo)(DC,(e,t)=>{if(e.id!==t.id||e.size!==t.size)return!1;if(e.doc===t.doc)return!0;if(e.doc.styles!==t.doc.styles||e.doc.system!==t.doc.system||e.doc.assets!==t.doc.assets)return!1;let n=EC(e.doc,e.id),r=EC(t.doc,t.id);return n.length===r.length&&n.every((e,t)=>e===r[t])});function kC({title:e,onBack:t,backLabel:n=`Back`,end:r,sub:i}){return(0,U.jsxs)(`div`,{className:`lib-top`,children:[(0,U.jsxs)(`div`,{className:`lib-head`,children:[t&&(0,U.jsx)(`button`,{className:`icon-btn fit page-back`,"aria-label":n,"data-tip":n,onClick:t,children:(0,U.jsx)(X.back,{})}),e,(0,U.jsx)(`span`,{className:`tabs-fill`}),r]}),i]})}var AC=new Set([`x`,`y`,`w`,`h`,`sizeX`,`sizeY`,`absolute`,`constraints`,`name`,`variantOf`,`build`,`note`,`locked`,`hidden`,`children`,`type`,`key`]),jC=[`fills`,`stroke`,`radius`,`effects`,`opacity`,`blend`,`grids`];function MC(e,t){for(let n=e.nodes[e.nodes[t]?.parent??``];n;n=n.parent?e.nodes[n.parent]:void 0)if(n.type===`frame`&&n.fills?.length)return n.fills}function NC(e,t){let n=e.nodes[t],r=n?.type===`frame`&&n.parent===null&&n.variantOf?e.nodes[n.variantOf]:void 0;return r&&r.parent?r:void 0}function PC(e,t){let n=e.nodes[t],r=NC(e,t);if(!n||n.type!==`frame`||!r)return null;if(r.type===`frame`){let t=Pe(e,n.id),i={};for(let[e,n]of Object.entries(t))AC.has(e)||(i[e]=n);for(let e of jC)n[e]===void 0&&r[e]!==void 0&&(i[e]=null);return!r.fills?.length&&i.fills&&JSON.stringify(i.fills)===JSON.stringify(MC(e,r.id))&&delete i.fills,r.sizeY===`fixed`&&n.h!==r.h&&(i.h=n.h),[{op:`update`,id:r.id,set:i},...r.children.length?[{op:`delete`,ids:[...r.children]}]:[],...n.children.map((t,n)=>({op:`create`,parent:r.id,index:n,tree:Pe(e,t)}))]}let i=n.children[0];if(!i||!r.parent)return null;let a=e.nodes[r.parent],o=a?.type===`frame`?a.children.indexOf(r.id):void 0,s={};for(let e of[`x`,`y`,`w`,`h`,`sizeX`,`sizeY`,`absolute`,`constraints`,`name`])r[e]!==void 0&&(s[e]=r[e]);return[{op:`create`,parent:r.parent,index:o,tree:{...Pe(e,i),...s}},{op:`delete`,ids:[r.id]}]}var FC=[{name:`Phone`,presets:[{name:`iPhone 16`,w:393,h:852},{name:`iPhone 16 Pro`,w:402,h:874},{name:`iPhone 16 Pro Max`,w:440,h:956},{name:`iPhone 14`,w:390,h:844},{name:`iPhone 13 mini`,w:375,h:812},{name:`iPhone SE`,w:375,h:667},{name:`Android Compact`,w:412,h:917},{name:`Android Small`,w:360,h:800}]},{name:`Tablet`,presets:[{name:`iPad Air`,w:820,h:1180},{name:`iPad mini`,w:744,h:1133},{name:`iPad Pro 11"`,w:834,h:1194},{name:`iPad Pro 13"`,w:1032,h:1376},{name:`Galaxy Tab S9`,w:800,h:1280}]},{name:`Desktop`,presets:[{name:`Desktop`,w:1440,h:900},{name:`MacBook Air`,w:1280,h:832},{name:`MacBook Pro 14"`,w:1512,h:982},{name:`MacBook Pro 16"`,w:1728,h:1117},{name:`Full HD`,w:1920,h:1080},{name:`Laptop`,w:1366,h:768}]},{name:`Social media`,presets:[{name:`Feed post (4:5)`,w:1080,h:1350},{name:`Story / Reels`,w:1080,h:1920},{name:`Square post`,w:1080,h:1080},{name:`Link preview`,w:1200,h:630},{name:`X post`,w:1600,h:900},{name:`YouTube thumbnail`,w:1280,h:720}]},{name:`Presentation`,presets:[{name:`Slide 16:9`,w:1920,h:1080},{name:`Slide 4:3`,w:1024,h:768}]},{name:`Watch`,presets:[{name:`Apple Watch 41mm`,w:176,h:215},{name:`Apple Watch 45mm`,w:198,h:242},{name:`Apple Watch Ultra`,w:205,h:251}]},{name:`Paper`,presets:[{name:`A4`,w:595,h:842},{name:`A5`,w:420,h:595},{name:`Letter`,w:612,h:792},{name:`Business card`,w:255,h:153}]}],IC=[[`default`,`Default`],[`fable`,`Fable`],[`opus`,`Opus`],[`sonnet`,`Sonnet`],[`haiku`,`Haiku`]],LC=[[`claude-fable-5-1`,`Fable 5.1`],[`claude-opus-5-5`,`Opus 5.5`],[`claude-opus-5`,`Opus 5`],[`claude-sonnet-5-5`,`Sonnet 5.5`],[`claude-sonnet-5`,`Sonnet 5`],[`claude-haiku-5-5`,`Haiku 5.5`],[`claude-haiku-4-5-20251001`,`Haiku 4.5`]],RC=[`low`,`medium`,`high`,`xhigh`,`max`],zC=new Set([...IC,...LC].map(([e])=>e)),BC=e=>e===`xhigh`?`Extra high`:e.charAt(0).toUpperCase()+e.slice(1),VC=e=>[...IC,...LC].find(([t])=>t===e)?.[1]??`Default`;function HC({chatRunner:e,compact:t}){let n=kp(),r=Np(),[i,a]=(0,H.useState)(null);if(typeof r!=`object`)return null;let o=r.agents.filter(e=>e.runs);if(!o.length)return null;let s=o.find(e=>e.id===r.preferred)??o[0],c=n.agentRunner===`auto`?s:o.find(e=>e.id===n.agentRunner)??s,l=c.id===`codex`,u=c.models??[],d=u.find(e=>e.id===n.codexModel),f=d??u.find(e=>e.id===c.defaultModel),p=u.find(e=>e.id===c.defaultModel)?.name??c.defaultModel,m=l?d?.name??p??`Default`:VC(zC.has(n.agentModel)?n.agentModel:`default`),h=l?f?.efforts??[]:RC.map(e=>({id:e,description:void 0})),g=l?n.codexEffort:n.claudeEffort,_=h.some(e=>e.id===g)?g:`default`,v=l?c.defaultEffort??f?.defaultEffort:void 0,y=e=>t=>{let n=t.currentTarget.getBoundingClientRect();a(i?.what===e?null:{what:e,x:n.left,y:n.top-V(`--menu-gap`),doc:t.currentTarget.ownerDocument})},b=e=>()=>{e(),a(null)},x=e=>({head:e}),S=(e=i?.what)=>{if(e===`all`)return[{label:`Agent`,hint:c.name,items:S(`agent`)},{label:`Model`,hint:m,items:S(`model`)},...h.length>0||v?[{label:`Effort`,hint:T,items:S(`effort`)}]:[]];if(e===`agent`)return[{label:`Automatic · ${s.name}`,checked:n.agentRunner===`auto`,hint:s.lastSeen?`last connected`:void 0,onClick:b(()=>Dp(`agentRunner`,`auto`))},{sep:!0},...o.map(e=>({label:e.name,hint:e.version?.replace(/^[^\d]*/,``).split(`-`)[0]||void 0,checked:n.agentRunner===e.id,onClick:b(()=>Dp(`agentRunner`,e.id))}))];if(e===`model`){if(l)return[{label:p?`Default (${p})`:`Default`,checked:!d,onClick:b(()=>C(`default`))},{sep:!0},...u.map(e=>({label:e.name,checked:d?.id===e.id,onClick:b(()=>C(e.id))}))];let e=zC.has(n.agentModel)?n.agentModel:`default`,t=([t,n])=>({label:n,checked:e===t,onClick:b(()=>Dp(`agentModel`,t))});return[x(`Latest`),...IC.map(t),{sep:!0},x(`Specific version`),...LC.map(t)]}let t=e=>Dp(l?`codexEffort`:`claudeEffort`,e);return[{label:v?`Default (${v})`:`Default`,checked:_==="default",onClick:b(()=>t(`default`))},...h.length?[{sep:!0}]:[],...h.map(e=>({label:BC(e.id),checked:_===e.id,onClick:b(()=>t(e.id))}))]},C=e=>{Dp(`codexModel`,e);let t=u.find(t=>t.id===e)??u.find(e=>e.id===c.defaultModel);n.codexEffort!=="default"&&!t?.efforts?.some(e=>e.id===n.codexEffort)&&Dp(`codexEffort`,`default`)},w=e&&e!==c.id,T=_==="default"?v?BC(v):`Default`:BC(_),E=w?`This chat ran with ${e===`codex`?`Codex`:`Claude Code`}: the next message starts a new conversation with ${c.name}`:`The agent that runs your requests`;return t?(0,U.jsxs)(`div`,{className:`agent-bar`,children:[(0,U.jsxs)(`button`,{className:`agent-chip ${i?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":!!i,onClick:y(`all`),"data-tip":i?void 0:w?E:`${c.name} · ${m} · ${T} effort`,children:[(0,U.jsxs)(`span`,{children:[m===`Default`?c.name:m,_==="default"?``:` · ${BC(_)}`]}),(0,U.jsx)(X.chevronDown,{})]}),i&&(0,U.jsx)(Gl,{x:i.x,y:i.y,doc:i.doc,above:!0,items:S(),onClose:()=>a(null)})]}):(0,U.jsxs)(`div`,{className:`agent-bar`,children:[(0,U.jsxs)(`button`,{className:`agent-chip ${i?.what===`agent`?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":i?.what===`agent`,onClick:y(`agent`),"data-tip":E,children:[(0,U.jsx)(`span`,{children:c.name}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsxs)(`button`,{className:`agent-chip ${i?.what===`model`?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":i?.what===`model`,onClick:y(`model`),"data-tip":l?d?.description??`Default is what Codex is set to`:`Latest follows each new release. A version stays fixed.`,children:[(0,U.jsx)(`span`,{children:m}),(0,U.jsx)(X.chevronDown,{})]}),(h.length>0||v)&&(0,U.jsxs)(`button`,{className:`agent-chip ${i?.what===`effort`?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":i?.what===`effort`,onClick:y(`effort`),"data-tip":h.find(e=>e.id===_)?.description??`How long the model thinks before it acts`,children:[(0,U.jsx)(`span`,{children:T===`Default`?`Effort`:T}),(0,U.jsx)(X.chevronDown,{})]}),i&&(0,U.jsx)(Gl,{x:i.x,y:i.y,doc:i.doc,above:!0,items:S(),onClose:()=>a(null)})]})}var UC=[TC],WC={a:({href:e,children:t})=>(0,U.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t})},GC=(0,H.createContext)(null),KC=null,qC=()=>KC??=fetch(`/api/project`).then(e=>e.json()).then(e=>!!e.app,()=>!1);function JC(){let[e,t]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let e=()=>void qC().then(t),n=()=>{KC=null,e()};return e(),addEventListener(`focus`,n),()=>removeEventListener(`focus`,n)},[]),e}var YC=[{id:`variations-layout`,label:`Layout`,icon:`layoutV`,tip:`Different arrangement and hierarchy, same content and style`},{id:`variations-style`,label:`Style`,icon:`styles`,tip:`Different shape, density and type treatment, same layout`},{id:`variations-color`,label:`Color`,icon:`paintSolid`,tip:`Different palette and accent use, same everything else`}],XC=`nudge.variationCount`,ZC=`nudge.variationAxes`,QC=()=>{try{let e=JSON.parse(localStorage.getItem(ZC)??`null`);if(Array.isArray(e)&&e.length)return e.filter(e=>YC.some(t=>t.id===e))}catch{}return[`variations-layout`]},$C=()=>{try{let e=Number(localStorage.getItem(XC));return e>=1&&e<=6?e:3}catch{return 3}},ew=[{id:`desktop`,w:1440,h:900,label:`Desktop`,icon:`monitor`,group:`Screens`},{id:`tablet`,w:820,h:1180,label:`Tablet`,icon:`tablet`,group:`Screens`},{id:`mobile`,w:390,h:844,label:`Mobile`,icon:`phone`,group:`Screens`},{id:`feed`,w:1080,h:1350,label:`Feed post`,icon:`image`,group:`Marketing`},{id:`story`,w:1080,h:1920,label:`Story`,icon:`phone`,group:`Marketing`},{id:`square`,w:1080,h:1080,label:`Square`,icon:`frame`,group:`Marketing`},{id:`link`,w:1200,h:630,label:`Link preview`,icon:`external`,group:`Marketing`}].map(e=>({...e,kind:e.group===`Screens`?`screen`:`marketing`})),tw=new Set([`Phone`,`Tablet`,`Desktop`]),nw=(e,t)=>{let n=ew.find(e=>e.w===t.w&&e.h===t.h);return n?n.id:`c:${t.w}x${t.h}:${tw.has(e)?`screen`:`marketing`}:${encodeURIComponent(t.name)}`},rw=e=>{let t=ew.find(t=>t.id===e);if(t)return t;let n=/^c:(\d+)x(\d+):(screen|marketing):(.+)$/.exec(e);if(!n)return;let r=n[3];return{id:e,w:+n[1],h:+n[2],label:decodeURIComponent(n[4]),icon:r===`screen`?`monitor`:`image`,group:`Recent`,kind:r}},iw=e=>e.group===`Screens`?`${e.label} ${e.w}`:`${e.label} ${e.w}×${e.h}`,aw=e=>`Other sizes · ${e.map(rw).filter(e=>!!e).map(iw).join(`, `)}`,ow=`nudge.recentSizes`,sw=()=>{try{let e=JSON.parse(localStorage.getItem(ow)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`&&rw(e)):[]}catch{return[]}};function cw(e,t){let[n,r]=(0,H.useState)({pending:0,live:!1});return(0,H.useEffect)(()=>{if(!t?.build){r({pending:0,live:!1});return}let e=!0,n=setTimeout(()=>{fetch(`/api/frame-changes?id=${encodeURIComponent(t.id)}`).then(e=>e.json()).then(t=>{e&&r({pending:t.lines?.length??0,live:!!t.auto})},()=>{})},300);return()=>{e=!1,clearTimeout(n)}},[t?.id,t?.build?.url,e]),n}function lw({doc:e,selection:t,tagged:n=0,active:r,onPick:i,onUse:a}){let[o,s]=(0,H.useState)(()=>r===`variations`),[c,l]=(0,H.useState)($C),[u,d]=(0,H.useState)(QC),f=(e,t)=>{if(!e.length)return i({quick:`variations`,label:``,icon:`group`});i({quick:`variations`,label:`Variations · ${YC.filter(t=>e.includes(t.id)).map(e=>e.label).join(` + `)} × ${t}`,icon:`group`,count:t,axes:e})},p=e=>{l(e);try{localStorage.setItem(XC,String(e))}catch{}r===`variations`&&f(u,e)},m=e=>{d(e);try{localStorage.setItem(ZC,JSON.stringify(e))}catch{}f(e,c)},h=JC(),g=t.length===1?e.nodes[t[0]]:void 0,_=g?.type===`frame`&&g.parent===null?g:void 0,{pending:v,live:y}=cw(e,_),b=_?_.build?y?{id:`prototype`,label:`Edit motion`,icon:`play`,tip:`Change the prototype's motion and interactions (the screen itself follows the design)`}:v?{id:`update-build`,label:`Update build`,icon:`reload`,tip:`Apply the ${v} design change${v>1?`s`:``} not in the build yet`}:{id:`fix-differences`,label:`Fix differences`,icon:`adjust`,tip:`Compare with the build and fix the build until it matches`}:h?{id:`implement`,label:`Implement in app`,icon:`plug`,tip:`Build this screen in your app and link it (runs in your agent session)`}:{id:`prototype`,label:`Prototype`,icon:`play`,tip:`A working page with motion and interactions, linked as this screen's build`}:null,x=_?ew.find(e=>Math.abs(e.w-_.w)<1&&(e.kind===`screen`||Math.abs(e.h-_.h)<1))?.id:void 0,[S,C]=(0,H.useState)(()=>r===`other-sizes`),w=ew.find(e=>e.id===x)?.kind??`screen`,[T,E]=(0,H.useState)(()=>ew.filter(e=>e.kind===w&&e.id!==x).map(e=>e.id)),[D,O]=(0,H.useState)(sw),[k,A]=(0,H.useState)(!1),[j,M]=(0,H.useState)(()=>new Set),N=e=>{if(!ew.some(t=>t.id===e)&&!D.includes(e)){let t=[e,...D].slice(0,4);O(t);try{localStorage.setItem(ow,JSON.stringify(t))}catch{}}P(T.includes(e)?T.filter(t=>t!==e):[...T,e])},P=e=>{E(e),e.length?i({quick:`other-sizes`,label:aw(e),icon:`tablet`,sizes:e}):r===`other-sizes`&&i({quick:`other-sizes`,label:``,icon:`tablet`,sizes:[]})},F=[...n?[{id:`apply-design-system`,label:`Apply design system`,icon:`styles`,tip:`Restyle copies of the screens with the design system sheet among these frames (either side can be the sheet)`}]:e.system?[{id:`apply-system`,label:`Apply design system`,icon:`styles`,tip:`Restyle copies of these screens with ${B(e.system)}`}]:[],`variations`,..._?[`sizes`]:[],{id:`states`,label:`States`,icon:`column`,tip:`Empty, loading and error; hover, pressed and disabled`},..._?[{id:`next-screen`,label:`Next screen`,icon:`forward`,tip:`The screen a user most likely reaches next`}]:[],{id:`real-content`,label:`Real content`,icon:`text`,tip:`Realistic copy and data instead of placeholders`},...b?[b]:[]],I=(e,t=!1)=>{let n=X[e.icon];return(0,U.jsxs)(`button`,{className:`quick ${t?`sub`:``} ${r===e.id?`on`:``}`,"aria-pressed":r===e.id,"data-tip":e.tip,onClick:()=>i(t?{quick:e.id,label:`Variations · ${e.label} × ${c}`,icon:e.icon,count:c}:{quick:e.id,label:e.label,icon:e.icon}),children:[(0,U.jsx)(n,{}),e.label]},e.id)},L=_?NC(e,_.id):void 0,ee=L;for(;ee?.parent;)ee=e.nodes[ee.parent];return(0,U.jsxs)(`div`,{className:`quick-list`,children:[L&&ee&&a&&(0,U.jsxs)(`button`,{className:`quick use`,onClick:()=>a(_.id),"data-tip":`Replace ${L.name} in ${ee.name} with this version (one undo step)`,children:[(0,U.jsx)(X.check,{}),`Use this in `,ee.name]}),F.map(e=>e===`sizes`?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsxs)(`button`,{className:`quick ${r===`other-sizes`?`on`:``}`,"aria-expanded":S,"data-tip":`This screen at other standard widths, laid out again for each`,onClick:()=>{let e=!S;C(e),e&&T.length&&r!==`other-sizes`&&P(T)},children:[(0,U.jsx)(X.tablet,{}),`Other sizes`,(0,U.jsx)(`span`,{className:`quick-caret ${S?`open`:``}`,children:(0,U.jsx)(X.chevronDown,{})})]}),S&&(()=>{let e=[...D.map(rw).filter(e=>!!e),...ew];return e.map((t,n)=>{let r=X[t.icon],i=t.id===x,a=!i&&T.includes(t.id);return(0,U.jsxs)(H.Fragment,{children:[e[n-1]?.group!==t.group&&(0,U.jsx)(`div`,{className:`quick-group`,children:t.group}),(0,U.jsxs)(`label`,{className:`quick sub size ${i?`mine`:``}`,"data-tip":i?`This frame is already this size`:t.kind===`marketing`?`Composed for this format from the screen's message and styles`:void 0,children:[(0,U.jsx)(r,{}),t.label,(0,U.jsx)(`span`,{className:`size-dim`,children:t.group===`Screens`?t.w:`${t.w}×${t.h}`}),i&&(0,U.jsx)(`small`,{children:`This frame`}),(0,U.jsx)(`input`,{type:`checkbox`,checked:a,disabled:i,onChange:()=>P(a?T.filter(e=>e!==t.id):e.map(e=>e.id).filter(e=>e===t.id||T.includes(e)))})]})]},t.id)})})(),S&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{className:`quick sub more`,"aria-expanded":k,onClick:()=>A(!k),children:[(0,U.jsx)(X.more,{}),`More sizes`,(0,U.jsx)(`span`,{className:`quick-caret ${k?`open`:``}`,children:(0,U.jsx)(X.chevronDown,{})})]}),k&&FC.map(e=>(0,U.jsxs)(H.Fragment,{children:[(0,U.jsxs)(`button`,{className:`quick sub more-group`,"aria-expanded":j.has(e.name),onClick:()=>M(t=>{let n=new Set(t);return n.has(e.name)?n.delete(e.name):n.add(e.name),n}),children:[(0,U.jsx)(`span`,{className:`preset-caret ${j.has(e.name)?`open`:``}`,"aria-hidden":!0,children:(0,U.jsx)(X.caret,{})}),e.name]}),j.has(e.name)&&e.presets.map(t=>{let n=nw(e.name,t),r=n===x||tw.has(e.name)&&_&&Math.abs(t.w-_.w)<1&&Math.abs(t.h-_.h)<1;return(0,U.jsxs)(`label`,{className:`quick sub size deep ${r?`mine`:``}`,children:[t.name,(0,U.jsxs)(`span`,{className:`size-dim`,children:[t.w,`×`,t.h]}),(0,U.jsx)(`input`,{type:`checkbox`,checked:!r&&T.includes(n),disabled:!!r,onChange:()=>N(n)})]},t.name)})]},e.name))]})]},`s`):e===`variations`?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsxs)(`button`,{className:`quick ${r===`variations`?`on`:``}`,"aria-expanded":o,"data-tip":`Alternatives next to the selection, made at the same time`,onClick:()=>{let e=!o;s(e),e&&u.length&&r!==`variations`&&f(u,c)},children:[(0,U.jsx)(X.group,{}),`Variations`,(0,U.jsx)(`span`,{className:`quick-caret ${o?`open`:``}`,children:(0,U.jsx)(X.chevronDown,{})})]}),o&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`quick-count`,role:`radiogroup`,"aria-label":`How many variations`,children:[(0,U.jsx)(`span`,{children:`How many`}),[1,2,3,4,5,6].map(e=>(0,U.jsx)(`button`,{role:`radio`,"aria-checked":c===e,className:c===e?`on`:``,onClick:()=>p(e),children:e},e))]}),YC.map(e=>{let t=X[e.icon],n=u.includes(e.id);return(0,U.jsxs)(`label`,{className:`quick sub size`,"data-tip":e.tip,children:[(0,U.jsx)(t,{}),e.label,(0,U.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>m(n?u.filter(t=>t!==e.id):YC.map(e=>e.id).filter(t=>t===e.id||u.includes(t)))})]},e.id)})]})]},`v`):I(e))]})}function uw(e,t){let n={left:e.x+e.w+12,top:e.y},r=n.left,i=(t.l??0)+8,a=t.w-8-340;return{badge:n,pop:{left:r<=a?r:e.x-340-8>=i?e.x-340-8:Math.max(i,a),top:Math.max((t.t??0)+8,Math.min(e.y,t.h-420))}}}function dw({chat:e,onNotice:t}){if(e.compacting)return(0,U.jsx)(`span`,{className:`ctx-meter`,children:`Compacting…`});let n=e.context;if(!n||!n.window)return null;let r=Math.min(100,Math.round(n.used/n.window*100));if(r<20)return null;let i=async()=>{let n=await(await fetch(`/api/agent/compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({chatId:e.id})})).json();n.ok||t(n.reason??`Couldn’t compact`)};return(0,U.jsxs)(`span`,{className:`ctx-meter ${r>=80?`high`:``}`,"data-tip":`${Math.round(n.used/1e3)}k of ${Math.round(n.window/1e3)}k tokens in this conversation`,children:[r,`%`,r>=50&&e.status!==`running`&&(0,U.jsx)(`button`,{onClick:()=>void i(),"data-tip":`Summarize the conversation so far and continue from the summary (faster, cheaper)`,children:`Compact`})]})}var fw=e=>e===`codex`?`Codex`:`Claude`,pw=()=>({runner:Ep().agentRunner,claudeModel:zC.has(Ep().agentModel)?Ep().agentModel:`default`,codexModel:Ep().codexModel,claudeEffort:Ep().claudeEffort,codexEffort:Ep().codexEffort,servers:Ep().mcpServers});async function mw(e,t,n,r,i,a,o,s,c){return(await fetch(`/api/agent/ask`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e,selection:t,chatId:n,...pw(),...r?{quick:r,lang:navigator.language}:{},...i?{count:i}:{},...a?.length?{attachments:a}:{},...o?.length?{tagged:o}:{},...s?.length?{sizes:s}:{},...c?.length?{axes:c}:{}})})).json()}function hw(e){let t=Math.max(0,(Date.now()-e)/1e3);return t<60?`now`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}async function gw(e){try{return await(await fetch(`/api/attachments?name=${encodeURIComponent(e.name||`pasted`)}`,{method:`POST`,headers:{"content-type":e.type||`application/octet-stream`},body:e})).json()}catch{return{error:`Couldn’t upload the file`}}}var _w={frame:X.frame,text:X.text,shape:X.rect,vector:X.vector};function vw(e,t){return t.map(t=>e?.nodes[t]).filter(e=>!!e).map(e=>({id:e.id,name:e.name,kind:e.type}))}function yw({placeholder:e,initial:t,seed:n,autoFocus:r,disabled:i,attach:a,frames:o,exclude:s,selected:c,onDropSelected:l,onPickFrame:u,onTagged:d,command:f,onClearCommand:p,onStop:m,onSubmit:h,onCancel:g}){let[_,v]=(0,H.useState)(t??``),[y,b]=(0,H.useState)([]),[x,S]=(0,H.useState)([]),C=(0,H.useRef)(d);C.current=d,(0,H.useEffect)(()=>{C.current?.(x.map(e=>e.id))},[x]),(0,H.useEffect)(()=>{n&&(v(n.text),requestAnimationFrame(()=>{let e=ee.current;e?.focus(),e?.setSelectionRange(n.text.length,n.text.length)}))},[n?.n]),(0,H.useEffect)(()=>{f&&ee.current?.focus()},[f?.quick,f?.label]);let w=e=>S(t=>t.some(t=>t.id===e.id)||s?.includes(e.id)?t:[...t,e]),[T,E]=(0,H.useState)(null),D=T&&o?o.filter(e=>!s?.includes(e.id)&&!x.some(t=>t.id===e.id)&&e.name.toLowerCase().includes(T.query.toLowerCase())).slice(0,6):[],O=e=>{if(!o)return;let t=e.value.slice(0,e.selectionStart??e.value.length),n=/(^|\s)@([^@\n]{0,40})$/.exec(t);E(e=>{if(!n)return null;let r=t.length-n[2].length-1;return e&&e.start===r&&e.query===n[2]?e:{start:r,query:n[2],at:0}})},k=e=>{if(!T)return;let t=ee.current,n=t?.selectionStart??_.length,r=_.slice(0,T.start)+_.slice(n);v(r),E(null),w(e),requestAnimationFrame(()=>{t?.focus(),t?.setSelectionRange(T.start,T.start)})},[A,j]=(0,H.useState)(0),[M,N]=(0,H.useState)(null),[P,F]=(0,H.useState)(null),I=(0,H.useRef)(null),L=async e=>{let t=[...e];if(t.length){F(null),j(e=>e+t.length);for(let e of t){let t=await gw(e);j(e=>e-1),`error`in t?F(t.error):b(e=>[...e,t])}}},ee=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=ee.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(160,e.scrollHeight)}px`)},[_]);let R=(0,H.useRef)(!1),te=(0,H.useRef)(!1),ne=async()=>{let e=(ee.current?.value??_).trim();if(!(!e&&!y.length&&!f||i||te.current||A)){te.current=!0;try{await h(e,y,x.map(e=>e.id)),v(``),b([]),S([])}finally{te.current=!1}}};return(0,U.jsxs)(`div`,{className:`askbox ${a?`with-attach`:``}`,onDragOver:a?e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&e.preventDefault()}:void 0,onDrop:a?e=>{e.dataTransfer.files.length&&(e.preventDefault(),L(e.dataTransfer.files))}:void 0,children:[(x.length>0||f||!!c?.length)&&(0,U.jsxs)(`div`,{className:`tag-row`,children:[c?.map(e=>{let t=_w[e.kind];return(0,U.jsxs)(`span`,{className:`tag-chip sel`,"data-tip":`Selected on the canvas · goes with this request`,children:[(0,U.jsx)(t,{}),(0,U.jsx)(`span`,{children:e.name}),l&&(0,U.jsx)(`button`,{"aria-label":`Leave out ${e.name}`,"data-tip":`Leave out`,onClick:()=>l(e.id),children:(0,U.jsx)(X.close,{})})]},e.id)}),f&&(()=>{let e=X[f.icon];return(0,U.jsxs)(`span`,{className:`tag-chip cmd`,"data-tip":`Add details, or send as is`,children:[(0,U.jsx)(e,{}),(0,U.jsx)(`span`,{children:f.label}),(0,U.jsx)(`button`,{"aria-label":`Remove ${f.label}`,onClick:()=>p?.(),children:(0,U.jsx)(X.close,{})})]})})(),x.map(e=>(0,U.jsxs)(`span`,{className:`tag-chip`,"data-tip":e.name,children:[(0,U.jsx)(X.frame,{}),(0,U.jsx)(`span`,{children:e.name}),(0,U.jsx)(`button`,{"aria-label":`Remove ${e.name}`,onClick:()=>S(t=>t.filter(t=>t.id!==e.id)),children:(0,U.jsx)(X.close,{})})]},e.id))]}),T&&D.length>0&&(0,U.jsx)(`div`,{className:`mention-list`,role:`listbox`,"aria-label":`Frames`,children:D.map((e,t)=>(0,U.jsxs)(`button`,{role:`option`,"aria-selected":t===T.at,className:t===T.at?`on`:``,onPointerDown:e=>e.preventDefault(),onClick:()=>k(e),children:[(0,U.jsx)(X.frame,{}),(0,U.jsx)(`span`,{children:e.name}),e.hint&&(0,U.jsx)(`small`,{children:e.hint})]},e.id))}),a&&(y.length>0||A>0||P)&&(0,U.jsxs)(`div`,{className:`attach-row`,children:[y.map((e,t)=>(0,U.jsxs)(`span`,{className:`attach-thumb`,"data-tip":e.name,children:[e.kind===`image`?(0,U.jsx)(`img`,{src:e.url,alt:``}):e.kind===`video`?(0,U.jsx)(`video`,{src:e.url,muted:!0}):(0,U.jsx)(`span`,{className:`attach-file`,children:e.name.split(`.`).pop()?.toUpperCase()}),e.kind===`video`&&(0,U.jsx)(`span`,{className:`attach-kind`,children:(0,U.jsx)(X.play,{})}),(0,U.jsx)(`button`,{"aria-label":`Remove ${e.name}`,onClick:()=>b(e=>e.filter((e,n)=>n!==t)),children:(0,U.jsx)(X.close,{})})]},e.path)),A>0&&(0,U.jsx)(`span`,{className:`attach-thumb loading`,"aria-label":`Uploading`}),P&&(0,U.jsx)(`span`,{className:`attach-error`,children:P})]}),a&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:`attach-plus`,"aria-label":`Add`,"aria-haspopup":`menu`,"aria-expanded":!!M,"data-tip":u?`Add frames, images and files`:`Add images and files`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();N(M?null:{x:t.left,y:t.bottom+V(`--menu-gap`),doc:e.currentTarget.ownerDocument})},children:(0,U.jsx)(X.plus,{})}),(0,U.jsx)(`input`,{ref:I,type:`file`,accept:`image/*,video/*,.pdf,.md,.markdown,.txt,.csv,.json,.html`,multiple:!0,hidden:!0,onChange:e=>{e.target.files&&L(e.target.files),e.target.value=``}}),M&&(0,U.jsx)(Gl,{x:M.x,y:M.y,doc:M.doc,onClose:()=>N(null),items:[...u?[{label:`Add frame`,icon:(0,U.jsx)(X.frame,{}),onClick:()=>{N(null),u(w)}}]:[],{label:`Add images and files`,icon:(0,U.jsx)(X.image,{}),onClick:()=>{N(null),I.current?.click()}}]})]}),(0,U.jsx)(`textarea`,{onPaste:a?e=>{let t=[...e.clipboardData.files];t.length&&(e.preventDefault(),L(t))}:void 0,ref:ee,rows:1,value:_,placeholder:e,autoFocus:r,"aria-label":e,onChange:e=>{v(e.target.value),O(e.target)},onSelect:e=>O(e.currentTarget),onBlur:()=>E(null),onCompositionEnd:()=>{R.current&&(R.current=!1,setTimeout(()=>void ne(),0))},onKeyDown:e=>{if(e.nativeEvent.isComposing||e.keyCode===229)e.key===`Enter`&&!e.shiftKey&&(R.current=!0);else{if(T&&D.length){let t=D.length;if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),E({...T,at:(T.at+(e.key===`ArrowDown`?1:t-1))%t});return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),k(D[Math.min(T.at,t-1)]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),E(null);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),R.current=!1,ne()),e.key===`Backspace`&&f&&!e.currentTarget.value&&e.currentTarget.selectionStart===0&&(e.preventDefault(),p?.()),e.key===`Escape`&&(e.preventDefault(),g?.())}}}),m?(0,U.jsx)(`button`,{className:`send stop`,onClick:m,"aria-label":`Stop`,"data-tip":`Stop`,children:(0,U.jsx)(X.stop,{})}):(0,U.jsx)(`button`,{className:`send`,disabled:!_.trim()&&!y.length&&!f||!!A||i,onClick:()=>void ne(),"aria-label":`Send`,"data-tip":`Send`,"data-kbd":`Enter`,children:(0,U.jsx)(X.arrowUp,{})})]})}function bw(e){let t=e.toLowerCase();return t===`get_context`||t===`outline`||t===`get`?`Reading the canvas`:t===`render`||t===`screenshot`?`Checking the result`:t===`update`||t===`create`||t===`delete`||t===`move`||t===`ops`||t===`styles`?`Editing the canvas`:t===`bash`?`Running a command`:t===`grep`||t===`glob`?`Searching files`:t===`read`?`Reading a file`:t===`edit`||t===`write`?`Editing a file`:t===`toolsearch`?`Getting tools ready`:t===`reply`?`Replying to a comment`:t===`skill`?`Using a skill`:t===`webfetch`||t===`websearch`?`Looking it up`:e.replace(/_/g,` `).replace(/^./,e=>e.toUpperCase())}function xw({steps:e,live:t}){let[n,r]=(0,H.useState)(!1),i=e[e.length-1],a=`${e.length} step${e.length>1?`s`:``}`;return(0,U.jsxs)(`div`,{className:`msg steps`,children:[(0,U.jsxs)(`button`,{className:`steps-head`,"aria-expanded":n,onClick:()=>r(!n),children:[t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`tool-dot run`}),bw(i.name),`…`,(0,U.jsx)(`span`,{className:`steps-count`,children:a})]}):(0,U.jsx)(`span`,{children:a}),(0,U.jsx)(`span`,{className:`steps-caret ${n?`open`:``}`,children:(0,U.jsx)(X.caret,{})})]}),n&&(0,U.jsx)(`ol`,{className:`steps-list`,children:e.map((e,t)=>(0,U.jsxs)(`li`,{className:e.ok===!1?`bad`:``,children:[bw(e.name),e.detail&&(0,U.jsx)(`em`,{children:e.detail}),e.ok===!1&&(0,U.jsx)(`span`,{className:`steps-retry`,children:` · failed`})]},t))})]})}var Sw=e=>e.status===`running`?e.waiting?`Waiting on your terminal session`:`${fw(e.runner)} is working`:`Open chat`;function Cw(e){let t=Math.max(1,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}var ww=e=>fetch(`/api/agent/cancel`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({chatId:e})});function Tw({msg:e,chat:t,onNotice:n}){let[r,i]=(0,H.useState)(null),a=e.picked??r,o=!!a||t.status===`running`;return(0,U.jsxs)(`div`,{className:`msg assistant choices`,children:[(0,U.jsx)(`p`,{children:e.question}),(0,U.jsx)(`div`,{className:`choice-list`,role:`group`,"aria-label":e.question,children:e.choices.map(e=>(0,U.jsx)(`button`,{className:`chip choice ${a===e?`on`:``}`,disabled:o,"aria-pressed":a===e,onClick:async()=>{i(e);let r=await mw(e,[],t.id);r.error&&(i(null),n(r.error))},children:e},e))})]})}function Ew({chat:e,doc:t,onFrame:n,onNotice:r}){let i=(0,H.useRef)(null);(0,H.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e.messages.length,e.status]);let a=e.run,o=(0,H.useContext)(GC),s=kl(),c=t??o?.doc,l=e.messages.map(e=>e.role).lastIndexOf(`user`),u=e.messages.findIndex(e=>e.role===`user`),d=async()=>{let t=await(await fetch(`/api/agent/undo`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({chatId:e.id})})).json();t.ok||r(t.reason??`Couldn’t undo`)};return(0,U.jsxs)(`div`,{className:`chat-log`,children:[e.messages.map((t,i)=>{if(t.role===`tool`&&e.messages[i-1]?.role===`tool`)return null;let o=[];if(t.role===`tool`){let t=i;for(;e.messages[t]?.role===`tool`;)t++;o=e.messages.slice(i,t)}let s=t.role===`tool`&&i+o.length===e.messages.length;return(0,U.jsxs)(H.Fragment,{children:[t.role===`user`&&i===u&&(e.via===`fork`||e.via===`live`)&&(0,U.jsx)(`div`,{className:`msg via`,"data-tip":e.via===`live`?`Sent into your Claude Code conversation in the terminal`:`Started from your Claude Code conversation, so it knows what you discussed there`,children:`Continues your Claude Code conversation`}),t.role===`user`?(0,U.jsxs)(`div`,{className:`msg user`,children:[t.attachments?.length?(0,U.jsx)(`span`,{className:`msg-attach`,children:t.attachments.map(e=>e.kind===`image`?(0,U.jsx)(`img`,{src:e.url,alt:e.name},e.url):e.kind===`video`?(0,U.jsx)(`video`,{src:e.url,muted:!0,controls:!0},e.url):(0,U.jsx)(`a`,{className:`msg-file`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.name},e.url))}):null,(()=>{let e=vw(c,(t.selection??[]).filter(e=>!t.tagged?.some(t=>t.id===e)));return!e.length&&!t.tagged?.length?null:(0,U.jsxs)(`span`,{className:`msg-tags`,children:[e.map(e=>{let t=_w[e.kind];return(0,U.jsxs)(`button`,{className:`tag-chip`,onClick:()=>n(e.id),"data-tip":`Go to layer`,children:[(0,U.jsx)(t,{}),(0,U.jsx)(`span`,{children:e.name})]},e.id)}),t.tagged?.map(e=>(0,U.jsxs)(`button`,{className:`tag-chip`,onClick:()=>n(e.id),"data-tip":`Go to frame`,children:[(0,U.jsx)(X.frame,{}),(0,U.jsx)(`span`,{children:e.name})]},e.id))]})})(),t.text]}):t.role===`assistant`?(0,U.jsx)(`div`,{className:`msg assistant md`,children:(0,U.jsx)(yb,{remarkPlugins:UC,components:WC,children:t.text})}):t.role===`choices`?(0,U.jsx)(Tw,{msg:t,chat:e,onNotice:r}):(0,U.jsx)(xw,{steps:o,live:e.status===`running`&&s}),i===l&&a?.endedAt&&e.status!==`running`&&(0,U.jsxs)(`div`,{className:`msg worked`,children:[`Worked for `,Cw(a.endedAt-a.startedAt)]})]},i)}),e.status===`running`&&e.messages[e.messages.length-1]?.role!==`tool`&&(0,U.jsxs)(`div`,{className:`msg working`,children:[fw(e.runner),` is working…`]}),e.status===`running`&&e.waiting&&(0,U.jsx)(`div`,{className:`msg waiting`,children:(0,U.jsxs)(`span`,{children:[`Waiting on your terminal session. If it’s asking for permission, approve it there.`,(0,U.jsxs)(`span`,{className:`waiting-tip`,children:[`To skip this next time, allow `,(0,U.jsx)(`code`,{children:`mcp__nudge`}),` in your Claude Code permissions.`]})]})}),e.status===`error`&&(0,U.jsx)(`div`,{className:`msg error`,children:e.error??`Something went wrong.`}),e.status===`cancelled`&&(0,U.jsx)(`div`,{className:`msg working`,children:`Stopped.`}),e.status!==`running`&&a&&a.frames.length>0&&(0,U.jsx)(`div`,{className:`run-result`,children:(0,U.jsxs)(`div`,{className:`run-card`,children:[a.frames.map(e=>{let t=o?.doc?.nodes[e.id],r=t?.type===`frame`?t.build:void 0,i=Sl(s.views,e.id)!==`off`;return(0,U.jsxs)(`div`,{className:`run-row`,children:[(0,U.jsxs)(`button`,{className:`run-frame`,onClick:()=>n(e.id),"data-tip":`Go to frame`,children:[(0,U.jsx)(X.frame,{}),(0,U.jsx)(`span`,{children:e.name})]}),r&&o&&t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:`run-icon ${i?`on`:``}`,"aria-pressed":i,"aria-label":`Show beside frame`,onClick:()=>Al(e.id,i?`off`:`side`),"data-tip":i?`Hide the live page from beside the frame`:`Show the live page beside the frame`,children:(0,U.jsx)(X.beside,{})}),(0,U.jsx)(`button`,{className:`run-icon`,"aria-label":`Open in browser`,onClick:()=>o.open(r.url,t.w),"data-tip":`Open in Nudge’s browser panel`,children:(0,U.jsx)(X.globe,{})})]})]},e.id)}),(0,U.jsx)(`div`,{className:`run-foot`,children:a.undone?(0,U.jsx)(`span`,{className:`run-undone`,children:`Changes undone`}):(0,U.jsxs)(`button`,{className:`run-undo`,onClick:()=>void d(),"data-tip":`Undo everything this run changed`,children:[(0,U.jsx)(X.undo,{}),`Undo`]})})]})}),(0,U.jsx)(`div`,{ref:i})]})}function Dw(e,t){if(!e?.roots.length)return`empty`;if(!t.length)return`screens`;let n=t.length===1?e.nodes[t[0]]:void 0;return n?.type===`frame`&&n.parent===null?`screen`:`part`}function Ow(e,t){let n=e=>t.system?[e]:[],r=e=>t.app?[e]:[],i={empty:{Create:[`Main screens for this app`,`Landing page for this project`,`Screen from the attached image`,`Design system for this project`],Explore:[`Three style directions for this app`]},screens:{Create:[`Another screen in the same style`,`Landing page for this project`,`Screen from the attached image`,...t.system?[]:[`Design system from these screens`]],Polish:[`Tidy spacing on every screen`,`Real content on every screen`,...n(`Use the design system's styles`)],Explore:[`Three style directions for these screens`,`Adapt every screen for mobile`],Build:[`Turn repeats into components`,`Export assets for development`,...r(`Implement these screens in my app`)]},screen:{Create:[`Next screen after this one`,`A dark version of this screen`,`Screen from the attached image`,...t.system?[]:[`Design system from this screen`]],Polish:[`Fill in missing states`,`Fill in real content`,`Tidy spacing, type and alignment`,...n(`Use the design system's styles`)],Explore:[`Three layout variations of this`,`Try a bolder visual style`,`Adapt for mobile and desktop`],Build:[t.build===`behind`?`Update the build`:t.build===`current`?`Fix differences with the build`:`Prototype with motion`,...t.build===`none`?r(`Implement this screen in my app`):[],`Export this screen`]},part:{Create:[`More items like this`,`An icon for this`],Polish:[`Tidy spacing and alignment`,`Fill in real content`,`Match the rest of the screen`],Explore:[`Three variations of this part`,`A different layout for this part`],Build:[`Make this a component`,`Export this as an image`,`Add hover and press motion`]}},a={Create:`sparkle`,Polish:`polish`,Explore:`branch`,Build:`code`};return Object.entries(i[e]).map(([e,t])=>({kind:e,icon:a[e],asks:t}))}function kw({chats:e,openId:t,setOpenId:n,selection:r,onNotice:i,onFrame:a,onPopOut:o,doc:s,frames:c,onPickFrame:l}){let u=t?e.find(e=>e.id===t):void 0,[d,f]=(0,H.useState)(!1),p=!u&&(d||!e.length),[m,h]=(0,H.useState)([]),g=r.join();(0,H.useEffect)(()=>h([]),[g]);let _=r.filter(e=>!m.includes(e)),v=vw(s,_),[y,b]=(0,H.useState)(),[x,S]=(0,H.useState)(null),C=Dw(s,_),w=JC(),T=C===`screen`?s.nodes[_[0]]:void 0,E=cw(s,T).pending>0,D=Ow(C,{system:!!s?.system,app:w,build:T?.build?E?`behind`:`current`:`none`}),[O,k]=(0,H.useState)(null),A=async e=>{k(null),(await(await fetch(`/api/agent/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({chatId:e})})).json()).ok?i(`Chat deleted · canvas changes stay`):i(`Couldn’t delete the chat`)},j=async(e,t,r,a)=>{let o=await mw(e,_,t,void 0,void 0,r,a);if(o.error)return i(o.error);f(!1),S(null),o.chatId&&n(o.chatId)},M=e=>{let t=e?.status===`running`;return(0,U.jsxs)(`div`,{className:`chat-foot`,children:[(0,U.jsx)(yw,{attach:!0,placeholder:t?`Working…`:e?`Ask a follow-up`:`Ask for changes`,disabled:t,seed:e?void 0:y,autoFocus:!e&&p,selected:v,onDropSelected:e=>h(t=>[...t,e]),frames:c,exclude:r,onPickFrame:l,onStop:t?()=>void ww(e.id):void 0,onSubmit:(t,n,r)=>j(t,e?.id,n,r)}),(0,U.jsx)(HC,{chatRunner:e?e.runner??`claude`:void 0})]})};if(u)return(0,U.jsxs)(`div`,{className:`agents`,children:[(0,U.jsx)(kC,{title:(0,U.jsx)(`strong`,{children:u.title}),onBack:()=>n(null),backLabel:`All chats`,end:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dw,{chat:u,onNotice:i}),o&&(0,U.jsx)(`button`,{className:`icon-btn fit`,onClick:o,"aria-label":`Pop out`,"data-tip":`Pop out · stays on top of other windows`,children:(0,U.jsx)(X.popOut,{})})]})}),(0,U.jsx)(Ew,{chat:u,doc:s,onFrame:a,onNotice:i}),M(u)]});let N=o&&(0,U.jsx)(`button`,{className:`icon-btn fit`,onClick:o,"aria-label":`Pop out`,"data-tip":`Pop out · stays on top of other windows`,children:(0,U.jsx)(X.popOut,{})});return p?(0,U.jsxs)(`div`,{className:`agents`,children:[(0,U.jsx)(kC,{title:(0,U.jsx)(`strong`,{children:`New chat`}),onBack:e.length?()=>f(!1):void 0,backLabel:`All chats`,end:N}),(0,U.jsx)(`div`,{className:`agent-start`,children:(0,U.jsxs)(`div`,{className:`starter-list`,children:[(0,U.jsx)(`h2`,{className:`starter-title`,children:`What should we work on?`}),D.map(e=>{let t=X[e.icon];return(0,U.jsxs)(`div`,{className:`starter-box`,children:[(0,U.jsxs)(`button`,{className:`starter-head`,"aria-expanded":x===e.kind,onClick:()=>S(x===e.kind?null:e.kind),children:[(0,U.jsx)(t,{}),e.kind,(0,U.jsx)(`span`,{className:`quick-caret ${x===e.kind?`open`:``}`,children:(0,U.jsx)(X.chevronDown,{})})]}),x===e.kind&&(0,U.jsx)(`div`,{className:`starter-chips`,children:e.asks.map(e=>(0,U.jsx)(`button`,{className:`chip starter`,onClick:()=>b(t=>({text:e,n:(t?.n??0)+1})),children:e},e))})]},e.kind)})]})}),M()]}):(0,U.jsxs)(`div`,{className:`agents`,children:[(0,U.jsx)(kC,{title:(0,U.jsx)(`strong`,{children:`Chats`}),end:(0,U.jsxs)(U.Fragment,{children:[N,(0,U.jsx)(`button`,{className:`icon-btn fit`,onClick:()=>f(!0),"aria-label":`New chat`,"data-tip":`New chat`,children:(0,U.jsx)(X.plus,{})})]})}),(0,U.jsx)(`ul`,{className:`chat-list`,children:e.map(e=>{let t=e.messages.find(e=>e.role===`user`),r=s?Mw(s,e):null;return(0,U.jsxs)(`li`,{className:O?.id===e.id?`menu-open`:``,children:[(0,U.jsx)(`button`,{className:`panel-btn chat-more`,"aria-label":`More`,"aria-expanded":O?.id===e.id,"data-tip":`More`,onClick:t=>{t.stopPropagation();let n=t.currentTarget.getBoundingClientRect();k(O?.id===e.id?null:{id:e.id,x:n.left,y:n.bottom+V(`--menu-gap`),doc:t.currentTarget.ownerDocument})},children:(0,U.jsx)(X.more,{})}),(0,U.jsxs)(`button`,{onClick:()=>n(e.id),children:[r?(0,U.jsx)(`span`,{className:`chat-icon has-thumb ${e.status}`,"data-tip":s.nodes[r].name,children:(0,U.jsx)(OC,{doc:s,id:r,size:38})}):(0,U.jsx)(`span`,{className:`chat-icon ${e.status}`,children:(0,U.jsx)(X.sparkle,{})}),(0,U.jsxs)(`span`,{className:`chat-main`,children:[(0,U.jsx)(`span`,{className:`chat-title`,children:(0,U.jsx)(`b`,{children:e.title})}),t&&(0,U.jsx)(`span`,{className:`chat-preview`,children:t.text})]}),(0,U.jsx)(`time`,{className:`chat-trail`,children:hw(e.updatedAt)})]})]},e.id)})}),O&&(0,U.jsx)(Gl,{x:O.x,y:O.y,doc:O.doc,onClose:()=>k(null),items:[{label:`Delete chat`,danger:!0,onClick:()=>void A(O.id)}]})]})}function Aw(){let[e,t]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let e=!0,n=()=>fetch(`/api/sessions`).then(e=>e.json()).then(n=>{e&&t(n)},()=>{});n();let r=setInterval(n,5e3);return()=>{e=!1,clearInterval(r)}},[]),e}function jw({chat:e,anchorIds:t,anchor:n,open:r,onToggle:i,onCollapse:a,onPopOut:o,onFrame:s,onNotice:c,bounds:l,frames:u,onPickFrame:d}){let{badge:{left:f,top:p},pop:{left:m,top:h}}=uw(n,l),g=e.status===`running`?(0,U.jsx)(X.sparkle,{}):e.status===`done`?(0,U.jsx)(X.check,{}):e.status===`error`?(0,U.jsx)(`span`,{children:`!`}):(0,U.jsx)(X.stop,{});return(0,U.jsxs)(U.Fragment,{children:[!r&&(0,U.jsx)(`button`,{className:`chat-badge ${e.status}`,style:{left:f,top:p},onPointerDown:e=>e.stopPropagation(),onClick:i,"aria-label":Sw(e),"data-tip":e.status===`running`?Sw(e):e.title,children:g}),r&&(0,U.jsxs)(`div`,{className:`canvas-chat`,"data-own-scroll":!0,style:{left:m,top:h,width:340},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,U.jsxs)(`div`,{className:`chat-head`,children:[(0,U.jsx)(`strong`,{children:e.title}),(0,U.jsx)(dw,{chat:e,onNotice:c}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:o,"aria-label":`Show in Agents panel`,"data-tip":`Show in Agents panel`,children:(0,U.jsx)(X.popOut,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:a,"aria-label":`Collapse`,"data-tip":`Collapse`,children:(0,U.jsx)(X.chevronUp,{})})]}),(0,U.jsx)(Ew,{chat:e,onFrame:s,onNotice:c}),(0,U.jsxs)(`div`,{className:`chat-foot`,children:[(0,U.jsx)(yw,{attach:!0,placeholder:e.status===`running`?`Working…`:`Ask for changes`,disabled:e.status===`running`,frames:u,exclude:t,onPickFrame:d,onStop:e.status===`running`?()=>void ww(e.id):void 0,onSubmit:async(n,r,i)=>{let a=await mw(n,t,e.id,void 0,void 0,r,i);a.error&&c(a.error)}}),(0,U.jsx)(HC,{compact:!0,chatRunner:e.runner??`claude`})]})]})]})}function Mw(e,t){let n=t=>{let n=e.nodes[t];for(;n?.parent;)n=e.nodes[n.parent];return n?.type===`frame`?n.id:null};for(let e of t.run?.frames??[]){let t=n(e.id);if(t)return t}for(let e of t.messages)if(e.role===`user`)for(let t of[...e.selection??[],...e.tagged?.map(e=>e.id)??[]]){let e=n(t);if(e)return e}return null}var Nw=Il;function Pw(e){let[t,n]=(0,H.useState)(`checking`);return(0,H.useEffect)(()=>{if(!e)return;let t=!0;n(`checking`);let r=()=>fetch(`/api/embeddable?url=${encodeURIComponent(e)}`).then(e=>e.json()).then(e=>{t&&n(e.ok?`ok`:`down`)},()=>{t&&n(`down`)});r();let i=setInterval(r,5e3);return()=>{t=!1,clearInterval(i)}},[e]),t}function Fw(e,t){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t)return;let n=!0;o.current=null;let i=()=>fetch(`/api/frame-changes?id=${encodeURIComponent(e)}`).then(e=>e.json()).then(e=>{if(!n)return;a(!!e.auto);let i=e.lines?.length??0;o.current&&!i&&Fl(t),o.current=i,r(i)},()=>{});i();let s=setInterval(i,4e3);return()=>{n=!1,clearInterval(s)}},[e,t]),{n,auto:i}}function Iw({frame:e,onCommit:t,onOpenTab:n}){let r=kl(),i=Pp(),a=e.build,o=Pw(a?.url),{n:s,auto:c}=Fw(e.id,a?.url),[l,u]=(0,H.useState)(!1);(0,H.useEffect)(()=>{s===0&&u(!1)},[s]);let[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(!d?.chat||a)return;let e=setInterval(async()=>{try{let{chats:e}=await(await fetch(`/api/agent/chats`)).json();e.find(e=>e.id===d.chat)?.status!==`running`&&f(null)}catch{}},3e3);return()=>clearInterval(e)},[d,a]);let h=Sl(r.views,e.id)!==`off`,g=r.reports[e.id];return a?(0,U.jsxs)(nu,{title:`Build`,children:[(0,U.jsxs)(`div`,{className:`build-status`,children:[(0,U.jsx)(`span`,{className:`build-dot ${o}`}),(0,U.jsx)(`span`,{className:`build-state`,children:o===`ok`?`Connected`:o===`down`?`Not reachable`:`Checking…`}),(0,U.jsxs)(`span`,{className:`build-addr`,"data-tip":a.url,children:[a.url.replace(/^https?:\/\//,``),a.selector?` · ${a.selector}`:``]}),(0,U.jsx)(`button`,{className:`build-reload`,onClick:()=>Fl(a.url),"aria-label":`Reload`,"data-tip":`Reload the live page (beside the frame and in the browser)`,children:(0,U.jsx)(X.reload,{})}),n&&(0,U.jsx)(`button`,{className:`build-reload`,disabled:o===`down`,onClick:()=>n(a.url,e.w),"aria-label":`Open in browser`,"data-tip":`Open in Nudge’s browser panel, like the running app`,children:(0,U.jsx)(X.globe,{})})]}),!!s&&(0,U.jsxs)(`div`,{className:`build-pending`,children:[(0,U.jsx)(`span`,{children:l?`Updating the build…`:`${s} design change${s>1?`s`:``} not in the build`}),(0,U.jsx)(`button`,{disabled:l,onClick:async()=>{u(!0),(await mw(`Update build`,[e.id],void 0,`update-build`)).error&&u(!1)},"data-tip":`Ask the agent to apply just these changes to the build`,children:`Update build`})]}),Nw(a.url)&&(0,U.jsxs)(`div`,{className:`build-branch label`,"data-tip":`A prototype page the agent wrote in design/builds/ (not your app). Ask it to implement the frame in your app when you have one.`,children:[(0,U.jsx)(X.play,{}),(0,U.jsx)(`span`,{children:c?`Prototype · follows the design`:`Prototype`})]}),a.branch&&(0,U.jsxs)(`div`,{className:`build-branch`,"data-tip":`A variant: implemented on its own git branch and dev server. Ask the agent to merge or discard it.`,children:[(0,U.jsx)(X.branch,{}),(0,U.jsx)(`span`,{children:a.branch})]}),o===`down`&&(0,U.jsxs)(`p`,{className:`build-hint`,children:[`The page doesn’t answer. Its dev server may be stopped — ask `,fw(i),` to start it.`]}),(0,U.jsxs)(`button`,{className:`btn primary block build-open ${h?`on`:``}`,"aria-pressed":h,onClick:()=>Al(e.id,h?`off`:`side`),"data-tip":h?`Hide the live page from beside the frame`:`Show the live page beside the frame, to compare`,children:[(0,U.jsx)(X.beside,{}),h?`Hide beside frame`:`Show beside frame`]}),(0,U.jsxs)(`div`,{className:`build-actions`,children:[(0,U.jsx)(`button`,{className:`btn`,disabled:g===`running`||o!==`ok`,onClick:()=>void zl(e.id,a.url,a.selector),children:g===`running`?`Comparing…`:`Compare with design`}),(0,U.jsx)(`button`,{className:`btn ghost danger`,onClick:()=>t([{op:`update`,id:e.id,set:{build:null}}],`Disconnect build`),"data-tip":`Unlink the build from this frame (the page itself keeps running)`,children:`Disconnect`})]}),g&&g!==`running`&&(`error`in g?(0,U.jsx)(`p`,{className:`build-error`,children:g.error}):(0,U.jsx)(Lw,{frame:e.id,report:g.report}))]}):(0,U.jsxs)(nu,{title:`Build`,children:[(0,U.jsx)(`p`,{className:`build-hint`,children:`Not built yet. A prototype is this frame as a working page, with its motion, served on localhost; it opens beside the frame when it's ready.`}),(0,U.jsxs)(`button`,{className:`btn primary block build-open`,disabled:d?.frame===e.id,onClick:async()=>{m(null),f({frame:e.id});let t=await mw(`Prototype`,[e.id],void 0,`prototype`);t.error?(f(null),m(t.error)):f({frame:e.id,chat:t.chatId})},children:[(0,U.jsx)(X.play,{}),d?.frame===e.id?`${fw(i)} is making the prototype…`:`Prototype`]}),p&&(0,U.jsx)(`p`,{className:`build-error`,children:p})]})}function Lw({frame:e,report:t}){let n=kl(),r=t.texts,i=!r.off.length&&!r.missing.length&&t.pixels.ratio<.005,a=t.size.design.w!==t.size.built.w||t.size.design.h!==t.size.built.h;return(0,U.jsxs)(`div`,{className:`build-report`,children:[(0,U.jsx)(`div`,{className:`build-sum ${i?`ok`:``}`,children:i?`Matches the design`:`${r.off.length} off · ${r.missing.length} missing · ${(t.pixels.ratio*100).toFixed(1)}% pixels differ`}),a&&(0,U.jsxs)(`div`,{className:`build-row dim`,children:[`Page `,t.size.built.w,`×`,t.size.built.h,` vs frame `,t.size.design.w,`×`,t.size.design.h]}),r.off.slice(0,12).map((t,r)=>{let i=[`dx`,`dy`,`dw`,`dh`].filter(e=>t[e]!==0).map(e=>`${e.slice(1)} ${t[e]>0?`+`:``}${t[e]}`),a=n.focus?.frame===e&&n.focus.x===t.at.x&&n.focus.y===t.at.y;return(0,U.jsxs)(`button`,{className:`build-row ${a?`on`:``}`,onClick:()=>Pl(a?null:{frame:e,...t.at}),"data-tip":t.style.map(e=>`${e.prop}: ${e.design} → ${e.built}`).join(`
|
|
33
|
+
`)||void 0,children:[(0,U.jsx)(`span`,{className:`build-text`,children:t.text}),(0,U.jsx)(`span`,{className:`build-delta`,children:[...i,...t.style.map(e=>e.prop)].join(` · `)})]},r)}),r.off.length>12&&(0,U.jsxs)(`div`,{className:`build-row dim`,children:[`+`,r.off.length-12,` more`]}),r.missing.length>0&&(0,U.jsxs)(`div`,{className:`build-row dim`,children:[`Missing in build: `,r.missing.slice(0,4).join(`, `),r.missing.length>4?`…`:``]})]})}async function Rw(e){let t=await fetch(`/api/icons/asset`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json();if(!t.ok||!n.asset)throw Error(n.error??`Couldn’t place the icon`);return n}async function zw(e){let t=await Rw(e);return{assetOp:{op:`asset`,add:[t.asset]},value:{icon:{pack:t.pack,name:t.name,...t.palette?{multicolor:!0}:{}},asset:t.asset.id},credit:t.credit}}async function Bw(e,t,n,r=24){let i=await Rw(t),a=i.palette?void 0:lt(e).text,o=Math.round(r*i.w/i.h*100)/100;return{credit:i.credit,ops:[{op:`asset`,add:[i.asset]},{op:`create`,parent:n.parent,...n.index===void 0?{}:{index:n.index},tree:{type:`vector`,key:`icon`,name:`icon/${i.name}`,asset:i.asset.id,w:o,h:r,x:Math.round(n.x-(o-r)/2),y:Math.round(n.y),...a?{color:a}:{},icon:{pack:i.pack,name:i.name,...i.palette?{multicolor:!0}:{}}}}]}}var Vw=`application/x-nudge-icon`,Hw=[[`all`,`All`],[`line`,`Line`],[`fill`,`Fill`],[`brand`,`Brand`],[`flag`,`Flags`]];function Uw({system:e,onClose:t,onUse:n,onNotice:r}){let[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(``),[c,l]=(0,H.useState)(`all`),[u,d]=(0,H.useState)(null);(0,H.useEffect)(()=>{fetch(`/api/icons/catalog`).then(e=>e.json()).then(e=>a(e.sets),()=>r(`Couldn’t read the icon sets`))},[]),(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return addEventListener(`keydown`,e,!0),()=>removeEventListener(`keydown`,e,!0)},[t]);let f=(0,H.useMemo)(()=>{let e=o.toLowerCase().split(/[\s-]+/).filter(Boolean);return(i??[]).filter(t=>{if(c!==`all`&&t.group!==c)return!1;let n=`${t.name} ${t.id} ${t.category} ${t.author?.name??``}`.toLowerCase();return e.every(e=>n.includes(e))})},[i,o,c]),p=async e=>{d(e.id);try{let t=await fetch(`/api/icons/download`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pack:e.id})}),n=await t.json();if(!t.ok)throw Error(n.error);a(t=>t?.map(t=>t.id===e.id?{...t,ready:!0}:t)??null),r(`${e.name}: ${n.icons?.toLocaleString(`en`)} icons ready${e.credit?`. ${e.license.title}: credit ${e.author?.name??`the author`} where you publish`:``}`)}catch(t){r(t instanceof Error&&t.message?t.message:`Couldn’t get ${e.name}`)}finally{d(null)}};return(0,U.jsxs)(`div`,{className:`libs-browse-packs`,role:`dialog`,"aria-label":`Browse icon sets`,children:[(0,U.jsx)(kC,{title:(0,U.jsx)(`strong`,{children:`Icon sets`}),onBack:t}),(0,U.jsxs)(`label`,{className:`libs-search`,children:[(0,U.jsx)(X.search,{}),(0,U.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:`Search sets`,"aria-label":`Search sets`})]}),(0,U.jsx)(`div`,{className:`libs-chips`,children:Hw.map(([e,t])=>(0,U.jsx)(`button`,{className:`chip filter ${c===e?`on`:``}`,"aria-pressed":c===e,onClick:()=>l(e),children:t},e))}),(0,U.jsxs)(`div`,{className:`libs-sets`,children:[!i&&(0,U.jsx)(`p`,{className:`muted-note`,children:`Loading…`}),f.map((t,r)=>(0,U.jsxs)(H.Fragment,{children:[(r===0||f[r-1].popular!==t.popular)&&f.some(e=>e.popular)&&(0,U.jsx)(`h4`,{className:`libs-sets-head`,children:t.popular?`Popular`:`All sets`}),(0,U.jsxs)(`div`,{className:`libs-set`,children:[(0,U.jsxs)(`div`,{className:`libs-set-head`,children:[(0,U.jsx)(`strong`,{children:t.name}),t.id===e?(0,U.jsx)(`span`,{className:`libs-state use`,children:`In use`}):t.ready?(0,U.jsx)(`button`,{className:`btn sm`,onClick:()=>n(t),children:`Use`}):(0,U.jsx)(`button`,{className:`btn sm`,disabled:u===t.id,onClick:()=>void p(t),"data-tip":`Download ${t.size} from npm, once`,children:u===t.id?`Getting…`:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X.download,{}),`Get`]})})]}),(0,U.jsx)(`div`,{className:`libs-set-samples`,children:t.samples?.map(e=>(0,U.jsx)(`img`,{src:`data:image/svg+xml;utf8,${encodeURIComponent(e.svg)}`,alt:e.name,className:t.palette?`palette`:``},e.name))}),(0,U.jsxs)(`small`,{children:[t.total.toLocaleString(`en`),` · `,gE(t),t.author&&t.credit?` · by ${t.author.name}`:``,t.included?` · included`:t.ready?` · downloaded`:` · ${t.size}`,t.palette?` · multicolor`:``]})]})]},t.id)),i&&!f.length&&(0,U.jsx)(`p`,{className:`muted-note`,children:`No set matches`})]})]})}var Ww=24,Gw={min:.25,max:4,step:.25},Kw=/stroke-width="([^"]*)"/g;function qw({icon:e,onPlace:t,onClose:n,alignTop:r}){let[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(Ww),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)([]),[m,h]=(0,H.useState)(e.name);(0,H.useEffect)(()=>{let t=!0;return fetch(`/api/icons/styles?pack=${encodeURIComponent(e.pack)}&name=${encodeURIComponent(e.name)}`).then(e=>e.json()).then(e=>{t&&p(e.styles??[])},()=>{}),()=>{t=!1}},[e.pack,e.name]),(0,H.useEffect)(()=>{let t=!0;return a(null),fetch(`/api/icons/svg?pack=${encodeURIComponent(e.pack)}&name=${encodeURIComponent(m)}`).then(e=>e.text()).then(e=>{if(!t)return;let n=/stroke-width="([\d.]+)"/.exec(e),r=n?Number(n[1]):null;a(e),l(r),d(e=>r===null?null:e??r)},()=>{}),()=>{t=!1}},[e.pack,m]);let g=i&&u!==null?i.replace(Kw,`stroke-width="${u}"`):i,_={pack:e.pack,name:m,...u!==null&&u!==c?{stroke:u}:{}},v=u===null?0:(u-Gw.min)/(Gw.max-Gw.min)*100;return(0,U.jsxs)(mu,{title:e.name,width:240,className:`icon-preview`,onClose:n,alignTop:r,children:[(0,U.jsx)(`div`,{className:`icon-preview-stage`,draggable:!!i,"data-tip":`Drag onto the canvas`,onDragStart:e=>{e.dataTransfer.setData(Vw,JSON.stringify({..._,size:o})),e.dataTransfer.effectAllowed=`copy`},children:g&&(0,U.jsx)(`img`,{src:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(g)}`,alt:e.name,draggable:!1})}),(0,U.jsxs)(`div`,{className:`icon-preview-fields`,children:[f.length>1&&(0,U.jsxs)(`div`,{className:`shader-param`,children:[(0,U.jsx)(`span`,{className:`shader-param-label`,children:`Style`}),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsx)(`select`,{value:m,"aria-label":`Icon style`,onChange:e=>h(e.target.value),children:f.map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.label},e.name))}),(0,U.jsx)(X.chevronDown,{})]})]}),(0,U.jsxs)(`div`,{className:`shader-param`,children:[(0,U.jsx)(`span`,{className:`shader-param-label`,children:`Size`}),(0,U.jsx)(Ql,{label:``,title:`Size`,value:o,min:1,max:2048,onCommit:e=>s(e)})]}),u!==null&&(0,U.jsxs)(`div`,{className:`shader-param with-slider`,children:[(0,U.jsx)(`span`,{className:`shader-param-label`,children:`Stroke`}),(0,U.jsx)(`input`,{type:`range`,className:`shader-slider`,"aria-label":`Stroke weight`,min:Gw.min,max:Gw.max,step:Gw.step,value:u,style:{"--pct":`${v}%`},onChange:e=>d(Number(e.currentTarget.value))}),(0,U.jsx)(Ql,{label:``,title:`Stroke weight`,value:u,min:Gw.min,max:Gw.max,step:Gw.step,digits:2,onCommit:e=>d(e)})]})]}),(0,U.jsxs)(`button`,{className:`btn primary block`,disabled:!i,onClick:()=>t(_,o),children:[(0,U.jsx)(X.plus,{}),`Insert`]})]})}var Jw=`application/x-nudge-component`,Yw=`file`;function Xw(e,t){return[{op:`doc`,libraries:{kits:[...new Set([...e.libraries?.kits??[],t])]}}]}var Zw=e=>Object.values(e.nodes).filter(t=>t.type===`frame`&&!t.inInstance&&!b(t.id)&&!e.removed?.[t.id]&&(!!t.componentSet||!!t.main&&!ce(e,t.id)));function Qw(e,t){if(t===`file`)return Zw(e).map(t=>({key:t.id,name:t.name,ids:[t.id],note:T(e,t.id)?.name}));let n=[];for(let e of N[t]?.components??[]){let t=n[n.length-1];t?.name===e.group?t.ids.push(e.id):n.push({key:e.group,name:e.group,ids:[e.id]})}return n}var $w=(e,t)=>{let n=e.nodes[t];return n?n.componentSet?S(e,t):[n]:[]};function eT(e,t){try{return D(it(e,Xw(e,t)).doc)}catch{return e}}function tT({doc:e,items:t,list:n,picked:r,onPick:i}){return(0,U.jsx)(`div`,{className:n?`lib-comp-rows`:`comp-tiles`,children:t.map(t=>{let a=e.nodes[t.id]?.name??t.variant.name;return(0,U.jsxs)(`button`,{className:`${n?`lib-comp-row`:`comp-tile`} ${r===t.id?`on`:``}`,draggable:!0,"data-tip":n?void 0:a,onClick:e=>i(t,e.currentTarget),onDragStart:e=>{e.dataTransfer.setData(Jw,t.variant.id),e.dataTransfer.effectAllowed=`copy`},children:[(0,U.jsx)(nT,{doc:e,main:t.variant,size:n?`row`:`tile`}),(0,U.jsx)(`span`,{className:`comp-tile-name`,children:a})]},t.id)})})}var nT=(0,H.memo)(function({doc:e,main:t,size:n=`tile`,values:r}){let i=(0,H.useMemo)(()=>{let n=`n_thumb-${t.id.slice(2)}`.slice(0,34),i={type:`frame`,id:n,name:t.name,parent:null,x:0,y:0,w:t.w,h:t.h,sizeX:`fixed`,sizeY:`fixed`,children:[],layout:t.layout,clip:!1,instanceOf:t.id,...r&&Object.keys(r).length?{values:r}:{}};return{...e,roots:[n],comments:void 0,nodes:{...e.nodes,[n]:i}}},[e.styles,e.assets,e.libraries,t,r]),a=(0,H.useRef)(null),o=(0,H.useRef)(null),[s,c]=(0,H.useState)(null);return(0,H.useLayoutEffect)(()=>{let e=a.current,t=o.current?.querySelector(`[data-node-id]`);if(!e||!t)return;let n=()=>{let n=t.offsetWidth,r=t.offsetHeight;n&&r&&c({w:n,h:r,k:Math.min(1,(e.clientWidth-20)/n,(e.clientHeight-20)/r)})};n();let r=new ResizeObserver(n);return r.observe(t),r.observe(e),()=>r.disconnect()},[i]),(0,U.jsx)(`span`,{className:`comp-thumb ${n}`,ref:a,"aria-hidden":!0,children:(0,U.jsx)(`span`,{ref:o,style:{position:`absolute`,left:`50%`,top:`50%`,width:s?.w,height:s?.h,transform:`translate(-50%, -50%) scale(${s?.k??1})`,pointerEvents:`none`,visibility:s?`visible`:`hidden`},children:(0,U.jsx)(He,{doc:i})})})}),rT=240,iT=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t}return null};function aT({view:e,depth:t,children:n}){let r=(0,H.useRef)(null),[i,a]=(0,H.useState)({view:e,depth:t}),[o,s]=(0,H.useState)(null),c=(0,H.useRef)(n);if(i.view!==e){if(t!==i.depth){let e=iT(r.current),n=e&&r.current?r.current.getBoundingClientRect().top-e.getBoundingClientRect().top:0;s({view:i.view,node:c.current,dir:t>i.depth?`fwd`:`back`,top:Math.min(0,n)})}a({view:e,depth:t})}return(0,H.useLayoutEffect)(()=>{c.current=n}),(0,H.useLayoutEffect)(()=>{if(!o)return;let e=iT(r.current);e&&(e.scrollTop=0);let t=setTimeout(()=>s(null),rT);return()=>clearTimeout(t)},[o]),(0,U.jsxs)(`div`,{ref:r,className:`slide ${o?`sliding ${o.dir}`:``}`,children:[o&&(0,U.jsx)(`div`,{className:`slide-view out`,style:{top:o.top},"aria-hidden":!0,inert:!0,children:o.node},o.view),(0,U.jsx)(`div`,{className:`slide-view ${o?`in`:``}`,children:n},e)]})}var oT=320,sT=180,cT=e=>e.includes(`,`)?`${e}, var(--font)`:`"${e}", var(--font)`;function lT({look:e}){let t=e.colors,n=e.fonts,r=(0,H.useRef)(null),[i,a]=(0,H.useState)(0);(0,H.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.clientWidth/oT);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let o={"radius-sm":e.radius.sm,"radius-md":e.radius.md,"radius-lg":e.radius.lg,"radius-full":e.radius.full};(0,H.useEffect)(()=>{let e=document.createElement(`link`);return e.rel=`stylesheet`,e.href=`/design/fonts.css?families=${encodeURIComponent([n.display,n.body].join(`|`))}`,document.head.appendChild(e),()=>e.remove()},[n.display,n.body]);let s=e=>e>=9999?`999px`:`${e}px`,c=s(e.radius.button),l=s(o[`radius-sm`]),u=s(o[`radius-lg`]>=9999?o[`radius-md`]:o[`radius-lg`]),d={background:t.background,boxShadow:`inset 0 0 0 1px ${t.border}`,borderRadius:u},f={size:14,strokeWidth:1.75,absoluteStrokeWidth:!0},p={color:t[`muted-foreground`]},m=(e,n,r=!1)=>(0,U.jsxs)(`span`,{className:`sc-item`,style:r?{background:t.muted,borderRadius:l}:void 0,children:[e,n]}),h={background:t.primary,color:t[`primary-foreground`],borderRadius:c},g=s(Math.min(o[`radius-sm`],4)),_=[[(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsxs)(`span`,{className:`sc-btn`,style:h,children:[`Button `,(0,U.jsx)(Fr,{...f,size:12})]}),(0,U.jsx)(`span`,{className:`sc-btn`,style:{background:t.muted,borderRadius:c},children:`Secondary`})]}),(0,U.jsxs)(`span`,{className:`sc-input`,style:{background:t.muted,...p,borderRadius:l},children:[`Search`,(0,U.jsx)(vo,{...f})]}),(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsx)(`span`,{className:`sc-badge`,style:{background:t.primary,color:t[`primary-foreground`]},children:`Badge`}),(0,U.jsx)(`span`,{className:`sc-badge`,style:{background:t.muted},children:`Draft`}),(0,U.jsx)(`span`,{className:`sc-badge`,style:{boxShadow:`inset 0 0 0 1px ${t.border}`},children:`Archived`})]}),(0,U.jsxs)(`span`,{className:`sc-row sc-spread`,children:[`Notifications`,(0,U.jsx)(`span`,{className:`sc-switch`,style:{background:t.primary},children:(0,U.jsx)(`i`,{style:{background:t[`primary-foreground`]}})})]}),(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsx)(`span`,{className:`sc-check`,style:{background:t.primary,color:t[`primary-foreground`],borderRadius:g},children:`✓`}),`Remember me`]}),(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsx)(`span`,{className:`sc-btn`,style:{boxShadow:`inset 0 0 0 1px ${t.border}`,borderRadius:c},children:`Outline`}),(0,U.jsx)(`span`,{className:`sc-btn`,children:`Ghost`})]})],[(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`sc-label`,style:p,children:`Monthly revenue`}),(0,U.jsx)(`span`,{className:`sc-big`,style:{fontFamily:cT(n.display)},children:`$48,210`})]}),(0,U.jsxs)(`span`,{className:`sc-tabs`,style:{background:t.muted,borderRadius:c},children:[(0,U.jsx)(`span`,{style:{background:t.background,borderRadius:c},children:`Day`}),(0,U.jsx)(`span`,{style:p,children:`Week`}),(0,U.jsx)(`span`,{style:p,children:`Month`})]}),(0,U.jsx)(`span`,{className:`sc-bars`,children:[.55,.8,.62,.95,.7,1].map((e,n)=>(0,U.jsx)(`i`,{style:{height:`${e*100}%`,background:n===5?t.primary:t.muted,borderRadius:g}},n))}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`sc-row sc-spread`,children:[(0,U.jsx)(`span`,{children:`Storage`}),(0,U.jsx)(`span`,{style:p,children:`64%`})]}),(0,U.jsx)(`span`,{className:`sc-track`,style:{background:t.muted},children:(0,U.jsx)(`i`,{style:{width:`64%`,background:t.primary}})})]}),(0,U.jsxs)(`span`,{className:`sc-row sc-spread`,children:[(0,U.jsx)(`span`,{className:`sc-avatars`,children:[t.primary,t[`muted-foreground`],t.border].map((e,n)=>(0,U.jsx)(`i`,{style:{background:e,boxShadow:`0 0 0 2px ${t.background}`}},n))}),(0,U.jsx)(`span`,{style:p,children:`+12`})]}),(0,U.jsx)(`span`,{className:`sc-btn wide`,style:{background:t.foreground,color:t.background,borderRadius:c},children:`View report`})],[(0,U.jsxs)(U.Fragment,{children:[m((0,U.jsx)(ma,{...f}),`Overview`,!0),m((0,U.jsx)(Xr,{...f}),`Analytics`)]}),(0,U.jsxs)(U.Fragment,{children:[m((0,U.jsx)(Qi,{...f}),`Projects`),m((0,U.jsx)(Rs,{...f}),`Team`)]}),(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsx)(`span`,{className:`sc-radio`,style:{boxShadow:`inset 0 0 0 1.5px ${t.primary}`},children:(0,U.jsx)(`i`,{style:{background:t.primary}})}),`Monthly`,(0,U.jsx)(`span`,{className:`sc-radio`,style:{boxShadow:`inset 0 0 0 1.5px ${t.border}`,marginLeft:10}}),(0,U.jsx)(`span`,{children:`Yearly`})]}),(0,U.jsx)(`span`,{className:`sc-pages`,children:[`1`,`2`,`3`,`…`].map((e,t)=>(0,U.jsx)(`span`,{style:t===0?h:{borderRadius:c},children:e},e))}),(0,U.jsxs)(U.Fragment,{children:[m((0,U.jsx)(Br,{...f}),`Notifications`),m((0,U.jsx)(Hr,{...f}),`Calendar`)]}),(0,U.jsxs)(U.Fragment,{children:[m((0,U.jsx)(Ji,{...f}),`Billing`,!0),m((0,U.jsx)(bo,{...f}),`Settings`)]})],[(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`sc-label`,style:p,children:`Email`}),(0,U.jsx)(`span`,{className:`sc-input`,style:{background:t.muted,...p,borderRadius:l},children:`name@company.com`})]}),(0,U.jsx)(`span`,{className:`sc-btn wide`,style:h,children:`Send invite`}),(0,U.jsxs)(`span`,{className:`sc-row sc-spread`,children:[`Dark mode`,(0,U.jsx)(`span`,{className:`sc-switch`,style:{background:t.muted},children:(0,U.jsx)(`i`,{style:{background:t.background,right:`auto`,left:2}})})]}),(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsx)(`span`,{className:`sc-check`,style:{boxShadow:`inset 0 0 0 1.5px ${t.border}`,borderRadius:g}}),`Subscribe`]}),(0,U.jsxs)(`span`,{className:`sc-input`,style:{background:t.muted,...p,borderRadius:l},children:[`Select a plan`,(0,U.jsx)(Fr,{...f})]}),(0,U.jsxs)(`span`,{className:`sc-row`,children:[(0,U.jsx)(`span`,{className:`sc-btn`,style:h,children:`Save`}),(0,U.jsx)(`span`,{className:`sc-btn`,style:{boxShadow:`inset 0 0 0 1px ${t.border}`,borderRadius:c},children:`Cancel`})]})]];return(0,U.jsx)(`span`,{className:`sys-cover`,ref:r,"aria-hidden":!0,style:{aspectRatio:`${oT} / ${sT}`,background:t.muted},children:(0,U.jsx)(`span`,{className:`sys-cover-art`,style:{width:oT,height:sT,transform:`scale(${i})`,visibility:i?void 0:`hidden`,color:t.foreground,fontFamily:cT(n.body)},children:(0,U.jsx)(`span`,{className:`sc-sheet`,children:[..._,_[0].slice(3).concat(_[0].slice(0,3))].map(e=>[...e,...e.slice(0,3)]).map((e,t)=>(0,U.jsx)(`span`,{className:`sc-col`,children:e.map((e,t)=>(0,U.jsx)(`span`,{className:`sc-card`,style:d,children:e},t))},t))})})})}var uT=e=>({value:`custom`,label:`Custom`,title:e?`Set by hand. Pick one to go back to it`:`Set a value by hand to make it custom`,disabled:!e}),dT=[{value:`sharp`,label:`Sharp`,title:`0 — square corners`},{value:`precise`,label:`Precise`,title:`4 · 6 · 8 · 12 — technical, exact`},{value:`friendly`,label:`Friendly`,title:`8 · 12 · 16 · 24 — community, product`}],fT=999;function pT({options:e,value:t,onChange:n}){return(0,U.jsx)(`div`,{className:`tok-filter`,role:`group`,"aria-label":`Show`,children:e.map(e=>(0,U.jsx)(`button`,{className:`chip filter ${t===e.value?`on`:``}`,"aria-pressed":t===e.value,"data-tip":e.title===e.label?void 0:e.title,onClick:()=>n(e.value),children:e.label},e.value))})}function mT({name:e,children:t}){return(0,U.jsxs)(`span`,{className:`sys-name`,children:[(0,U.jsx)(`span`,{className:`sys-name-text`,onPointerOver:t=>{let n=t.currentTarget;n.scrollWidth>n.clientWidth?n.dataset.tip=e:delete n.dataset.tip},children:e}),t]})}function hT({sys:e,edit:t,theme:n,themeControl:r,parts:i=!1,textEditor:a,only:o}){let[s,c]=(0,H.useState)(e.theme),l=n??s,[u,d]=(0,H.useState)(``),[p,m]=(0,H.useState)(`all`),[h,_]=(0,H.useState)(null),v=f(e),y=v?.prefix??e.tokens?.css?.group??``,b=e=>y&&e.startsWith(`${y}/`)?e.slice(y.length+1):e,x=Fe(e,l),S=g(e),C=O(e),w=v?v.space?A(e):null:A(e),T=ot(e),E=e=>t=>T.has(`overrides.${e}.${t}`)||T.has(`tokens.${e}.${t}`),D=E(`colors`),k=E(`text`),j=E(`radius`),M=E(`space`),N=(e,n,r)=>T.has(`overrides.${e}.${n}`)?t?.revertKey?()=>t.revertKey(`overrides.${e}.${n}`):r:null,F=u.trim().toLowerCase(),I=Object.keys(x).filter(e=>!F||b(e).toLowerCase().includes(F)||x[e].toLowerCase().includes(F)),L=e=>(0,U.jsx)(`button`,{className:`sys-reset`,"aria-label":`Back to ${v?.name??`the system`}'s value`,"data-tip":`Back to ${v?.name??`the system`}'s value`,onClick:e,children:`↺`}),ee=n?(0,U.jsx)(`span`,{className:`muted-note`,children:n===`light`?`Light`:`Dark`}):(0,U.jsx)(eu,{value:l,options:Oe.map(e=>({value:e,label:e===`light`?`Light`:`Dark`,title:`Show the ${e} theme`})),onChange:c}),R=(0,U.jsxs)(`label`,{className:`libs-search`,children:[(0,U.jsx)(X.search,{}),(0,U.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`Search colors`,"aria-label":`Search colors`})]}),te=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`sys-colors ${i?``:`tokens`}`,children:[I.map(e=>(0,U.jsxs)(`div`,{className:`sys-color ${D(e)?`changed`:``}`,children:[t?(0,U.jsx)(`button`,{className:`sys-sw ${h?.name===e?`on`:``}`,style:{background:x[e]},"aria-label":`Edit ${b(e)}`,onClick:t=>{let n=t.currentTarget.getBoundingClientRect();_(h?.name===e?null:{name:e,at:{left:n.left-260,top:n.top-8}})}}):(0,U.jsx)(`span`,{className:`sys-sw`,style:{background:x[e]}}),(0,U.jsx)(mT,{name:b(e),children:t&&(()=>{let n=N(`colors`,e,()=>t.revertColor(e));return n&&L(n)})()}),(0,U.jsx)(`span`,{className:`sys-val`,children:x[e]})]},e)),!I.length&&(0,U.jsxs)(`p`,{className:`muted-note`,children:[`Nothing for “`,u.trim(),`”`]})]}),t&&h&&(0,U.jsx)(Bd,{value:x[h.name],at:h.at,onClose:()=>_(null),onPreview:()=>{},onCommit:e=>{/^#[0-9a-f]{6}/i.test(e)&&t.color(h.name,l,e.length>7&&!e.toLowerCase().endsWith(`ff`)?e.slice(0,9):e.slice(0,7))}})]}),ne=a??(0,U.jsx)(`div`,{className:`sys-type`,children:Object.entries(S).map(([e,n])=>(0,U.jsxs)(`div`,{className:`sys-trow ${k(e)?`changed`:``}`,children:[(0,U.jsx)(`span`,{className:`sys-ag`,style:{fontFamily:`${n.fontFamily.includes(`,`)?n.fontFamily:`"${n.fontFamily}"`}, var(--font)`,fontWeight:n.fontWeight},children:`Ag`}),(0,U.jsx)(mT,{name:b(e),children:t&&(()=>{let n=N(`text`,e,()=>t.revertText(e));return n&&L(n)})()}),(0,U.jsxs)(`span`,{className:`sys-val`,children:[n.fontSize,`/`,Math.round(n.lineHeight??n.fontSize*1.2)]})]},e))}),re=e.overrides?.space??{},ie=v?.space?Object.entries(v.space).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]).map(([e,t])=>({name:e,key:String(t),v:re[String(t)]??t})):P(e).filter(Boolean).map(e=>({name:`space-${e}`,key:String(e),v:re[String(e)]??e})),ae=w?(0,U.jsx)(`div`,{className:`tok-space`,children:ie.map(e=>(0,U.jsxs)(`div`,{className:`tok-space-row ${M(e.key)?`changed`:``}`,children:[(0,U.jsx)(mT,{name:e.name,children:t&&(()=>{let n=N(`space`,e.key,()=>t.revertSpace(e.key));return n&&L(n)})()}),(0,U.jsx)(`span`,{className:`tok-space-track`,children:(0,U.jsx)(`i`,{style:{width:e.v}})}),t?(0,U.jsx)(`span`,{className:`tok-num`,children:(0,U.jsx)(Ql,{label:``,value:e.v,min:0,max:fT,title:`${e.name} in px`,onCommit:n=>n!==e.v&&t.space(e.key,n)})}):(0,U.jsx)(`span`,{className:`sys-val`,children:e.v})]},e.name))}):(0,U.jsxs)(`p`,{className:`muted-note`,children:[v?.name,` publishes no spacing scale.`]}),oe=t?.corners&&e.tokens&&Object.keys(C).length?(0,U.jsx)(eu,{value:he(C)??`custom`,options:[...dT,uT(!he(C))],onChange:e=>e!==`custom`&&t.corners(e)}):null,se=Object.keys(C).length?(0,U.jsx)(`div`,{className:`sys-colors`,children:Object.entries(C).map(([e,n])=>(0,U.jsxs)(`div`,{className:`sys-color ${j(e)?`changed`:``}`,children:[(0,U.jsx)(`span`,{className:`sys-corner`,style:{borderTopLeftRadius:Math.min(n,12)}}),(0,U.jsx)(mT,{name:b(e),children:t&&(()=>{let n=N(`radius`,e,()=>t.revertRadius(e));return n&&L(n)})()}),t&&n<9999?(0,U.jsx)(`span`,{className:`tok-num`,children:(0,U.jsx)(Ql,{label:``,value:n,min:0,title:`${b(e)} in px`,onCommit:r=>r!==n&&t.radius(e,r)})}):(0,U.jsx)(`span`,{className:`sys-val`,children:n>=9999?`full`:n})]},e))}):(0,U.jsxs)(`p`,{className:`muted-note`,children:[v?.name,` publishes no corner tokens.`]});if(i){let e=[{value:`colors`,label:`Colors`,title:`Colors`,body:(0,U.jsxs)(U.Fragment,{children:[r??(!n&&ee),te]})},{value:`text`,label:`Text`,title:`Text styles`,body:ne},{value:`space`,label:`Spacing`,title:`Spacing`,body:ae},{value:`corners`,label:`Corners`,title:`Corners`,body:(0,U.jsxs)(U.Fragment,{children:[oe,se]})}],t=[{value:`all`,label:`All`,title:`All`},...e];return(0,U.jsxs)(`div`,{className:`tok-parts`,children:[(0,U.jsx)(pT,{options:t,value:p,onChange:e=>{m(e),_(null)}}),e.filter(e=>p===`all`||p===e.value).map(e=>(0,U.jsxs)(`section`,{className:`tok-group`,children:[p===`all`&&(0,U.jsx)(`div`,{className:`libs-sys-head`,children:e.title}),e.body]},e.value))]})}return o?(0,U.jsxs)(U.Fragment,{children:[o.includes(`space`)&&(0,U.jsx)(nu,{title:`Spacing`,children:ae}),o.includes(`corners`)&&(0,U.jsxs)(nu,{title:`Corners`,children:[oe,se]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(nu,{title:`Colors · ${Object.keys(x).length}`,action:ee,children:[Object.keys(x).length>24&&R,te]}),(0,U.jsx)(nu,{title:`Text styles · ${Object.keys(S).length}`,children:ne}),(0,U.jsx)(nu,{title:`Spacing`,children:ae}),(0,U.jsxs)(nu,{title:`Corners`,children:[oe,se]})]})}var gT=e=>({op:`system`,set:e}),_T=(e,t)=>n=>{let r=R(e).find(e=>e.key===n);r?.revert&&t(r.revert.map(gT),`${r.label}: back to ${r.from}`)},vT=({on:e,from:t})=>(0,U.jsx)(`button`,{className:`sys-reset`,"aria-label":`Back to ${t}`,"data-tip":`Back to ${t}`,onClick:e,children:`↺`}),yT=(e,t,n)=>e===`light`?{slots:{[t]:n}}:{slots:{dark:{[t]:n}}};function bT({doc:e,s:t,commit:n}){let r=Fe(t),i=(e,t)=>r=>n([gT({slots:{[e]:r}})],t),a=R(t),o=_T(t,n),s=(e,t)=>{let n=a.find(t=>(Array.isArray(e)?e:[e]).includes(t.key));return(0,U.jsxs)(`span`,{className:n?`changed`:void 0,children:[t,n?.revert&&(0,U.jsx)(vT,{on:()=>o(n.key),from:n.from})]})},c=e=>t.theme===`light`?`slots.${e}`:`slots.dark.${e}`,l=!!t.slots.radii||Object.keys(t.overrides?.radius??{}).length>0;return(0,U.jsxs)(nu,{title:`Foundation`,children:[(0,U.jsxs)(`div`,{className:`row2 labels`,children:[s(`slots.fontDisplay`,`Display font`),s(`slots.fontBody`,`Body font`)]}),(0,U.jsxs)(`div`,{className:`row2`,children:[(0,U.jsx)(Jd,{value:t.slots.fontDisplay,doc:e,onPick:i(`fontDisplay`,`Display font`)}),(0,U.jsx)(Jd,{value:t.slots.fontBody,doc:e,onPick:i(`fontBody`,`Body font`)})]}),(0,U.jsx)(`div`,{className:`sys-base`,children:[[`bg`,`Background`,r.background],[`fg`,`Text`,r.foreground],[`accent`,`Accent`,r.primary]].map(([e,r,i])=>(0,U.jsxs)(`label`,{className:`sys-base-row`,children:[s(c(e),r),(0,U.jsx)(tu,{value:i,styles:{},onCommit:i=>n([gT(yT(t.theme,e,i.slice(0,7)))],`${r} (${t.theme})`)})]},e))}),(0,U.jsx)(`div`,{className:`row2 labels`,children:s([`slots.radius`,`slots.radii`],`Corners${t.slots.radii?` · ${t.slots.radii.join(` · `)}, as ${t.name} has them`:``}`)}),(0,U.jsx)(eu,{value:l?`custom`:t.slots.radius,options:[...dT,uT(l)],onChange:e=>e!==`custom`&&n([gT({slots:{radius:e},overrides:{radius:Object.fromEntries(Object.keys(t.overrides?.radius??{}).map(e=>[e,null]))}})],`Corners`)})]})}var xT=e=>[...Ge.map(e=>({name:e.name,usage:e.usage})),...e.owned.colors.filter(e=>!Ge.some(t=>t.name===e)).map(e=>({name:e,usage:`A brand color of this system.`}))];function ST(e,t){let n=f(e),r=n?`${n.name}'s value`:`its value`;return{color:(e,n,r)=>t([gT({overrides:{colors:{[e]:{[n]:r}}}})],`${e} (${n})`),revertColor:e=>t([gT({overrides:{colors:{[e]:null}}})],`${e}: back to ${r}`),revertText:e=>t([gT({overrides:{text:{[e]:null}}})],`${e}: back to ${r}`),radius:(e,n)=>t([gT({overrides:{radius:{[e]:n}}})],`${e}: ${n}`),revertRadius:e=>t([gT({overrides:{radius:{[e]:null}}})],`${e}: back to ${r}`),space:(e,n)=>t([gT({overrides:{space:{[e]:n}}})],`space-${e}: ${n}`),revertSpace:e=>t([gT({overrides:{space:{[e]:null}}})],`space-${e}: back to ${r}`),revertKey:_T(e,t),...e.tokens?{corners:e=>t([gT({corners:e})],`Corners: ${e}`)}:{}}}function CT({s:e,commit:t,onOpen:n}){let[r,i]=(0,H.useState)(null);return(0,U.jsxs)(`div`,{className:`sys`,children:[(0,U.jsx)(kC,{title:(0,U.jsx)(MT,{s:e,commit:t}),end:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(kT,{from:TT(e),owning:r!==null,onOwn:()=>i(r===null?`${TT(e)} (mine)`:null)}),(0,U.jsx)(jT,{onOpen:n})]}),sub:(0,U.jsx)(`div`,{className:`lib-sub`,children:(0,U.jsx)(`small`,{className:`lib-sub-note`,children:AT(e)})})}),(0,U.jsx)(OT,{s:e,commit:t}),(0,U.jsxs)(`div`,{className:`sys-tokens`,children:[TT(e)&&r!==null&&(0,U.jsx)(NT,{s:e,commit:t,onDone:()=>i(null)}),(0,U.jsx)(hT,{sys:e,edit:ST(e,t),theme:e.theme,themeControl:(0,U.jsx)(wT,{s:e,commit:t}),parts:!0})]})]})}function wT({s:e,commit:t}){return(0,U.jsx)(eu,{value:e.theme,options:Oe.map(e=>({value:e,label:e===`light`?`Light`:`Dark`,title:`Show the ${e} theme on the canvas`})),onChange:e=>t([gT({theme:e})],`Theme: ${e}`)})}var TT=e=>f(e)?.name??u(e)?.name,ET=e=>e.saved?`the saved version`:u(e)?e.name:f(e)?f(e).name:null;function DT({c:e,onBack:t}){let n=e=>e&&/^#/.test(e)?(0,U.jsx)(`span`,{className:`change-sw`,style:{background:e}}):null;return(0,U.jsxs)(`div`,{className:`change-row`,children:[(0,U.jsx)(`span`,{className:`change-name`,children:e.label}),(0,U.jsxs)(`span`,{className:`change-val`,children:[n(e.fromColor),e.from,(0,U.jsx)(`span`,{"aria-label":`to`,children:`→`}),n(e.toColor),(0,U.jsx)(`b`,{children:e.to})]}),t?(0,U.jsx)(vT,{on:t,from:e.from}):(0,U.jsx)(`span`,{className:`change-none`})]})}function OT({s:e,commit:t,onSaved:n}){let r=R(e),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(!1);if((0,H.useEffect)(()=>{r.length||a(!1)},[r.length]),!r.length)return null;let c=_T(e,t),l=()=>e.saved?t([gT({revert:!0})],`Revert ${e.name}`):t(r.flatMap(e=>(e.revert??[]).map(gT)),`Revert ${B(e)}`),u=async()=>{s(!0);try{await fetch(`/api/systems/mine/save`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}),n?.()}finally{s(!1)}},d=r.length;return(0,U.jsxs)(`div`,{className:`change-sec`,children:[(0,U.jsxs)(`div`,{className:`change-bar`,children:[(0,U.jsxs)(`button`,{className:`change-count`,"aria-expanded":i,onClick:()=>a(!i),"data-tip":i?`Hide changes`:`Show what changed`,children:[d,` change`,d===1?``:`s`,(0,U.jsx)(`span`,{className:`change-caret ${i?`open`:``}`,children:(0,U.jsx)(X.chevronDown,{})})]}),(0,U.jsx)(`button`,{className:`btn ghost sm`,onClick:l,"data-tip":ET(e)?`Back to ${ET(e)}`:`Back to the values the choices make`,children:`Revert all`}),e.saved&&(0,U.jsx)(`button`,{className:`btn sm primary`,disabled:o,onClick:()=>void u(),"data-tip":`Save to your library; every file using it follows`,children:`Save`})]}),i&&(0,U.jsxs)(`div`,{className:`change-list`,role:`region`,"aria-label":`Changes`,children:[(0,U.jsx)(`h4`,{children:ET(e)?`Changed from ${ET(e)}`:`Set by hand`}),r.map(e=>(0,U.jsx)(DT,{c:e,onBack:e.revert?()=>c(e.key):void 0},e.key))]})]})}function kT({from:e,inFile:t=!0,owning:n,onOwn:r}){return(0,U.jsx)(`span`,{className:`comp-actions`,children:e&&(0,U.jsx)(`button`,{className:`btn ghost`,"aria-expanded":n,onClick:r,"data-tip":t?`Fork: make these values this file's own system; it stops following ${e}`:`Fork: use these values in this file as your own system; it won't follow ${e}`,children:`Fork`})})}var AT=e=>`${Object.keys(Fe(e)).length} colors · ${Object.keys(g(e)).length} text styles`,jT=({onOpen:e})=>(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Open system`,"data-tip":`Open system`,onClick:e,children:(0,U.jsx)(X.expand,{})});function MT({s:e,commit:t}){let[n,r]=(0,H.useState)(null),i=B(e),a=()=>{let e=n?.trim().slice(0,80);e&&e!==i&&t([gT({name:e})],`Rename system: ${e}`),r(null)};return n===null?(0,U.jsx)(`button`,{type:`button`,className:`sys-name-btn`,"data-tip":`Rename`,onClick:()=>r(i),children:(0,U.jsx)(`strong`,{children:i})}):(0,U.jsx)(`input`,{className:`sys-name-in`,autoFocus:!0,value:n,"aria-label":`System name`,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a(),e.key===`Escape`&&r(null)}})}function NT({s:e,commit:t,onDone:n,onCancel:r=n,use:i}){let a=TT(e),[o,s]=(0,H.useState)(`${a} (mine)`);return(0,U.jsxs)(`form`,{className:`sys-own`,onSubmit:r=>{r.preventDefault();let s=o.trim()||`${a} (mine)`;t([...i?.ops??[],gT(e.published?{own:!0,name:s}:{name:s})],`Fork system: ${s}`),n()},children:[(0,U.jsxs)(`label`,{className:`sys-own-name`,children:[(0,U.jsx)(`span`,{children:`Name`}),(0,U.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),"aria-label":`Name of your system`})]}),(0,U.jsx)(`p`,{className:`comp-hint`,children:i?`Its values become this file's own system; it won't follow ${a}.${i.replaces?` It replaces ${i.replaces}; ⌘Z brings it back.`:``}`:`Its values${ye(e)?`, with your changes,`:``} become this file's own system. It is no longer ${a}: no Changed mark, nothing to put back.`}),(0,U.jsxs)(`div`,{className:`sys-own-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn`,onClick:r,children:`Cancel`}),(0,U.jsx)(`button`,{type:`submit`,className:`btn primary`,children:`Fork`})]})]})}function PT({doc:e,commit:t,onOpen:n,head:r=!0}){let[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(`all`),c=e=>o===`all`||o===e,l=e.system;if(l&&(l.published||l.tokens))return(0,U.jsx)(CT,{s:l,commit:t,onOpen:n});if(!l)return(0,U.jsxs)(`div`,{className:`sys-empty`,children:[(0,U.jsx)(`strong`,{children:`No design system yet`}),(0,U.jsx)(`p`,{children:`Start from a few choices (two fonts, three colors and corners) and get color roles, text styles and spacing that follow from them.`}),(0,U.jsxs)(`button`,{className:`btn block`,onClick:()=>void fetch(`/api/systems/mine/new`,{method:`POST`,headers:{"content-type":`application/json`},body:`{}`}),children:[(0,U.jsx)(X.styles,{}),`Create design system`]}),(0,U.jsx)(`p`,{className:`muted-note`,children:`Or ask your agent to build one from your code.`})]});let u=Fe(l),d=g(l),f=ot(l),p=R(l),m=_T(l,t),h=e=>{let t=p.find(t=>t.key===e);return t?.revert?(0,U.jsx)(vT,{on:()=>m(e),from:t.from}):null};return(0,U.jsxs)(`div`,{className:`sys`,children:[r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(kC,{title:(0,U.jsx)(MT,{s:l,commit:t}),end:(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(jT,{onOpen:n})}),sub:(0,U.jsx)(`div`,{className:`lib-sub`,children:(0,U.jsx)(`small`,{className:`lib-sub-note`,children:AT(l)})})}),(0,U.jsx)(OT,{s:l,commit:t}),(0,U.jsx)(`div`,{className:`tok-theme`,children:(0,U.jsx)(wT,{s:l,commit:t})})]}),(0,U.jsx)(bT,{doc:e,s:l,commit:t}),(0,U.jsx)(`div`,{className:`sys-filter`,children:(0,U.jsx)(pT,{options:FT,value:o,onChange:e=>{s(e),a(null)}})}),c(`colors`)&&(0,U.jsxs)(nu,{title:`Colors`,children:[(0,U.jsx)(`div`,{className:`sys-colors`,children:xT(l).map(e=>(0,U.jsxs)(`div`,{className:`sys-color ${f.has(`overrides.colors.${e.name}`)?`changed`:``}`,"data-tip":e.usage,children:[(0,U.jsx)(`button`,{className:`sys-sw ${i?.name===e.name?`on`:``}`,style:{background:u[e.name]},"aria-label":`Edit ${e.name}`,onClick:t=>{let n=t.currentTarget.getBoundingClientRect();a(i?.name===e.name?null:{name:e.name,at:{left:n.left-260,top:n.top-8}})}}),(0,U.jsxs)(`span`,{className:`sys-name`,children:[e.name,h(`overrides.colors.${e.name}`)]}),(0,U.jsx)(`span`,{className:`sys-val`,children:u[e.name]})]},e.name))}),i&&(0,U.jsx)(Bd,{value:u[i.name]??`#000000`,at:i.at,onClose:()=>a(null),onPreview:()=>{},onCommit:e=>{/^#[0-9a-f]{6}/i.test(e)&&t([gT({overrides:{colors:{[i.name]:{[l.theme]:e.slice(0,7)}}}})],`${i.name} (${l.theme})`)}})]}),c(`text`)&&(0,U.jsx)(nu,{title:`Text styles`,children:(0,U.jsx)(`div`,{className:`sys-type`,children:Ae.map(e=>{let t=d[e.name];return(0,U.jsxs)(`div`,{className:`sys-trow ${f.has(`overrides.text.${e.name}`)?`changed`:``}`,"data-tip":e.usage,children:[(0,U.jsx)(`span`,{className:`sys-ag`,style:{fontFamily:`${t.fontFamily}, var(--font)`,fontWeight:t.fontWeight},children:`Ag`}),(0,U.jsxs)(`span`,{className:`sys-name`,children:[e.name,h(`overrides.text.${e.name}`)]}),(0,U.jsxs)(`span`,{className:`sys-val`,children:[t.fontSize,`/`,Math.round(t.lineHeight??t.fontSize*1.2)]})]},e.name)})})}),(c(`space`)||c(`corners`))&&(0,U.jsx)(hT,{sys:l,edit:ST(l,t),only:[`space`,`corners`].filter(c)})]})}var FT=[{value:`all`,label:`All`,title:`All`},{value:`colors`,label:`Colors`,title:`Colors`},{value:`text`,label:`Text`,title:`Text styles`},{value:`space`,label:`Spacing`,title:`Spacing`},{value:`corners`,label:`Corners`,title:`Corners`}];function IT({doc:e,commit:t,onClose:n}){let r=e.system,i=(0,H.useRef)(n);i.current=n,(0,H.useEffect)(()=>{let e=e=>{e.key!==`Escape`||document.querySelector(`.floating, .font-menu`)||(e.stopPropagation(),i.current())};return addEventListener(`keydown`,e,!0),()=>removeEventListener(`keydown`,e,!0)},[]);let[a,o]=(0,H.useState)(r?.theme??`light`),[s,c]=(0,H.useState)(`all`),l=e=>s===`all`||s===e;if(!r)return null;if(r.published||r.tokens)return(0,U.jsx)(LT,{s:r,commit:t,onClose:n,preview:a,setPreview:o});let u=Fe(r,`light`),d=Fe(r,`dark`),f=g(r),p=O(r),m=r.overrides?.colors??{},h=a===`light`?u:d;return(0,U.jsx)(`div`,{className:`sheet-backdrop`,onPointerDown:e=>{e.target===e.currentTarget&&n()},children:(0,U.jsxs)(`div`,{className:`sheet sys-sheet`,role:`dialog`,"aria-label":`Design system`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsx)(`h2`,{children:B(r)}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:n,"aria-label":`Close`,"data-tip":`Close`,children:(0,U.jsx)(X.close,{})})]}),(0,U.jsxs)(`div`,{className:`sys-sheet-body`,children:[(0,U.jsxs)(`div`,{className:`sys-edit`,children:[(0,U.jsx)(bT,{doc:e,s:r,commit:t}),(0,U.jsx)(`div`,{className:`sys-filter`,children:(0,U.jsx)(pT,{options:FT,value:s,onChange:c})}),l(`colors`)&&(0,U.jsx)(nu,{title:`Colors`,children:(0,U.jsxs)(`div`,{className:`sys-table`,children:[(0,U.jsxs)(`div`,{className:`sys-th`,children:[(0,U.jsx)(`span`,{children:`Role`}),(0,U.jsx)(`span`,{children:`Light`}),(0,U.jsx)(`span`,{children:`Dark`})]}),xT(r).map(e=>(0,U.jsxs)(`div`,{className:`sys-tr`,"data-tip":e.usage,children:[(0,U.jsxs)(`span`,{className:`sys-name`,children:[e.name,m[e.name]&&(0,U.jsx)(`button`,{className:`sys-reset`,"aria-label":`Back to derived`,"data-tip":`Back to the derived color`,onClick:()=>t([gT({overrides:{colors:{[e.name]:null}}})],`Reset ${e.name}`),children:`↺`})]}),[`light`,`dark`].map(n=>(0,U.jsx)(tu,{value:(n===`light`?u:d)[e.name]??u[e.name],styles:{},onCommit:r=>t([gT({overrides:{colors:{[e.name]:{[n]:r.slice(0,7)}}}})],`${e.name} (${n})`)},n))]},e.name))]})}),l(`text`)&&(0,U.jsx)(nu,{title:`Text styles`,children:(0,U.jsxs)(`div`,{className:`sys-table`,children:[(0,U.jsxs)(`div`,{className:`sys-th t`,children:[(0,U.jsx)(`span`,{children:`Style`}),(0,U.jsx)(`span`,{children:`Size`}),(0,U.jsx)(`span`,{children:`Line`}),(0,U.jsx)(`span`,{children:`Weight`})]}),Ae.map(e=>(0,U.jsx)(WT,{name:e.name,t:f[e.name],changed:!!r.overrides?.text?.[e.name],tip:e.usage,onSet:(n,r)=>t([gT({overrides:{text:{[e.name]:n}}})],`${e.name}: ${r}`),onRevert:()=>t([gT({overrides:{text:{[e.name]:null}}})],`Reset ${e.name}`)},e.name))]})}),(l(`space`)||l(`corners`))&&(0,U.jsx)(hT,{sys:r,edit:ST(r,t),only:[`space`,`corners`].filter(l)})]}),(0,U.jsx)(UT,{pc:h,preview:a,setPreview:o,text:Ae.map(e=>[e.name,f[e.name],`${BT(f[e.name].fontFamily)} ${f[e.name].fontSize}`]),sample:{title:f[`heading-s`],body:f[`body-m`],label:f.label,card:p[`radius-lg`]??0,button:p[`radius-md`]??0},space:M(r),radii:Object.entries(p).map(([e,t])=>[e.replace(`radius-`,``),t])})]})]})})}function LT({s:e,commit:t,onClose:n,preview:r,setPreview:i}){let a=f(e),o=g(e),s=rt(e,r),c=s.colors,l=O(e),u=a&&!a.space?null:A(e),d=a?.prefix??e.tokens?.css?.group??``,p=e=>d&&e.startsWith(`${d}/`)?e.slice(d.length+1):e;return(0,U.jsx)(`div`,{className:`sheet-backdrop`,onPointerDown:e=>{e.target===e.currentTarget&&n()},children:(0,U.jsxs)(`div`,{className:`sheet sys-sheet`,role:`dialog`,"aria-label":`Design system`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`h2`,{children:[B(e),ye(e)&&(0,U.jsx)(`span`,{className:`badge`,children:`Changed`})]}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:n,"aria-label":`Close`,"data-tip":`Close`,children:(0,U.jsx)(X.close,{})})]}),(0,U.jsxs)(`div`,{className:`sys-sheet-body`,children:[(0,U.jsxs)(`div`,{className:`sys-edit`,children:[a&&(0,U.jsxs)(`p`,{className:`comp-hint sys-source`,children:[a.name,` as published · `,a.license,` · `,a.url.replace(/^https?:\/\//,``)]}),(0,U.jsx)(hT,{sys:e,edit:ST(e,t),theme:r,parts:!0,textEditor:(0,U.jsxs)(`div`,{className:`sys-table`,children:[(0,U.jsxs)(`div`,{className:`sys-th t`,children:[(0,U.jsx)(`span`,{children:`Style`}),(0,U.jsx)(`span`,{children:`Size`}),(0,U.jsx)(`span`,{children:`Line`}),(0,U.jsx)(`span`,{children:`Weight`})]}),Object.entries(o).map(([n,r])=>(0,U.jsx)(WT,{name:p(n),t:r,changed:!!e.overrides?.text?.[n],onSet:(e,r)=>t([gT({overrides:{text:{[n]:e}}})],`${p(n)}: ${r}`),onRevert:()=>t([gT({overrides:{text:{[n]:null}}})],`${p(n)}: back to the system's value`)},n))]})})]}),(0,U.jsx)(UT,{pc:c,preview:r,setPreview:i,text:Object.entries(o).map(([e,t])=>[p(e),t,`${BT(t.fontFamily)} ${t.fontSize}`]),sample:{title:{fontFamily:s.fonts.display,fontSize:18,fontWeight:600},body:{fontFamily:s.fonts.body,fontSize:14},label:{fontFamily:s.fonts.body},card:s.radius.lg,button:s.radius.button},space:u?M(e):null,spaceNote:`${a?.name} publishes no spacing scale.`,radii:Object.entries(l).map(([e,t])=>[p(e),t])})]})]})})}var RT=e=>e?`${e.includes(`,`)?e:`"${e}"`}, var(--font)`:void 0,zT=e=>({fontFamily:RT(e.fontFamily),fontSize:e.fontSize,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,textTransform:e.textCase?ee(e.textCase):void 0}),BT=e=>e.split(`,`)[0].trim().replace(/^["']|["']$/g,``),VT=(e,t)=>e>=9999?999:Math.min(e,t),HT=[[`Base`,[`background`,`foreground`,`card`,`muted`,`muted-foreground`,`border`,`input`,`ring`]],[`Accent`,[`primary`,`primary-foreground`,`primary-subtle`,`primary-subtle-foreground`]],...[`destructive`,`success`,`warning`,`info`].map(e=>[e.charAt(0).toUpperCase()+e.slice(1),[e,`${e}-subtle`,`${e}-subtle-foreground`]])];function UT({pc:e,preview:t,setPreview:n,text:r,sample:i,space:a,spaceNote:o,radii:s}){let c={color:e[`muted-foreground`]},l={borderColor:e.border},u=HT.map(([t,n])=>[t,n.filter(t=>e[t])]).filter(([,e])=>e.length),d={...zT(i.label),borderRadius:VT(i.button,999)};return(0,U.jsxs)(`div`,{className:`sys-page`,style:{background:e.background,color:e.foreground},children:[(0,U.jsx)(`div`,{className:`sys-page-head`,style:{background:e.background,boxShadow:`0 1px 0 ${e.border}`},children:(0,U.jsx)(eu,{value:t,options:Oe.map(e=>({value:e,label:e===`light`?`Light`:`Dark`})),onChange:n})}),(0,U.jsxs)(`div`,{className:`sys-page-body`,children:[(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`h4`,{style:c,children:`In use`}),(0,U.jsxs)(`div`,{className:`sys-sample`,style:{background:e.card,borderRadius:VT(i.card,24),boxShadow:`inset 0 0 0 1px ${e.border}`},children:[(0,U.jsx)(`div`,{style:zT(i.title),children:`Card title`}),(0,U.jsx)(`div`,{style:{...zT(i.body),...c},children:`Secondary text sits in muted-foreground, readable on the card.`}),(0,U.jsxs)(`div`,{className:`sys-sample-row`,children:[(0,U.jsx)(`span`,{style:{...d,background:e.primary,color:e[`primary-foreground`]},children:`Primary action`}),(0,U.jsx)(`span`,{style:{...d,boxShadow:`inset 0 0 0 1px ${e.input??e.border}`},children:`Secondary`})]})]})]}),(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`h4`,{style:c,children:`Colors`}),u.map(([t,n])=>(0,U.jsxs)(`div`,{className:`sys-color-group`,style:l,children:[(0,U.jsx)(`h5`,{children:t}),(0,U.jsx)(`div`,{className:`sys-swatches ${n.length<=4?`few`:``}`,children:n.map(t=>(0,U.jsxs)(`div`,{className:`sys-swatch`,children:[(0,U.jsx)(`span`,{style:{background:e[t],boxShadow:`inset 0 0 0 1px ${e.border}`}}),(0,U.jsx)(`b`,{"data-tip":t,children:t}),(0,U.jsx)(`em`,{style:c,children:e[t]})]},t))})]},t))]}),(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`h4`,{style:c,children:`Type`}),[...r].sort((e,t)=>(e[1].fontSize??0)-(t[1].fontSize??0)).map(([e,t,n])=>(0,U.jsxs)(`div`,{className:`sys-spec`,style:l,children:[(0,U.jsxs)(`div`,{className:`sys-spec-meta`,children:[(0,U.jsx)(`b`,{children:e}),(0,U.jsxs)(`em`,{style:c,children:[t.fontSize,`/`,Math.round(t.lineHeight??(t.fontSize??16)*1.2),` · `,t.fontWeight]})]}),(0,U.jsx)(`div`,{className:`sys-spec-sample`,style:zT(t),children:n})]},e))]}),(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`h4`,{style:c,children:`Spacing`}),a?(0,U.jsx)(`div`,{className:`sys-space`,children:a.map(([t,n])=>(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`sys-meta`,children:[(0,U.jsx)(`b`,{children:t}),(0,U.jsx)(`em`,{style:c,children:n})]}),(0,U.jsx)(`span`,{style:{width:Math.min(n,192),background:e.primary}})]},t))}):(0,U.jsx)(`p`,{style:c,children:o})]}),(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`h4`,{style:c,children:`Corners`}),(0,U.jsx)(`div`,{className:`sys-radii`,children:s.map(([t,n])=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{style:{borderRadius:VT(n,40),background:e.card,boxShadow:`inset 0 0 0 1px ${e.border}`}}),(0,U.jsx)(`b`,{children:t}),(0,U.jsx)(`em`,{style:c,children:n>=9999?`full`:n})]},t))})]})]})]})}function WT({name:e,t,changed:n,tip:r,onSet:i,onRevert:a}){let o=Xd(t.fontWeight,t.fontStyle===`italic`?`italic`:void 0);return(0,U.jsxs)(`div`,{className:`sys-tr t ${n?`changed`:``}`,"data-tip":r,children:[(0,U.jsx)(mT,{name:e,children:n&&(0,U.jsx)(`button`,{className:`sys-reset`,"aria-label":`Back to the system's value`,"data-tip":`Back to the system's value`,onClick:a,children:`↺`})}),(0,U.jsx)(Ql,{label:``,title:`Size`,value:t.fontSize,min:1,onCommit:e=>i({fontSize:e,lineHeight:Math.round(e*(t.lineHeight??e*1.2)/t.fontSize*100)/100},`size`)}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.lineHeight,{}),title:`Line height (% of font size)`,value:pf(t.lineHeight,t.fontSize),digits:1,min:50,suffix:`%`,onCommit:e=>i({lineHeight:Math.round(t.fontSize*e)/100},`line height`)}),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:o,"aria-label":`Font style`,onChange:e=>i({fontWeight:parseInt(e.target.value),fontStyle:e.target.value.endsWith(`i`)?`italic`:`normal`},`font style`),children:[!Yd.some(([e])=>e===o)&&(0,U.jsx)(`option`,{value:o,children:o.replace(`i`,` Italic`)}),Yd.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))]}),(0,U.jsx)(X.chevronDown,{})]})]})}var GT=`this-file`,KT=`shadcn`,qT=`nudge.libs.view`,JT=()=>{try{return localStorage.getItem(qT)===`list`?`list`:`grid`}catch{return`grid`}},YT=e=>({op:`system`,set:e}),XT=e=>({...st(e.name),slots:e.base.slots,...e.base.published?{published:e.base.published}:{},...e.base.tokens?{tokens:e.base.tokens}:{},...e.base.overrides?{overrides:e.base.overrides}:{}}),ZT=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)||`design-system`;function QT(e,t,n){let r=document.createElement(`a`);r.href=URL.createObjectURL(new Blob([t],{type:n})),r.download=e,document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e4)}function $T(e,t){if(t?.kit)return t.kit;let n=f(e);if(n?.kit)return n.kit;let r=e?.tokens?.css?.group??(e?.tokens?``:void 0);return(r===void 0?void 0:Object.values(E).find(e=>e.prefix===r))?.kit??KT}var eE=e=>e?e.published&&ze.find(t=>t.published===e.published)?.id||u(e)?.id||GT:null,tE=e=>`by ${e?.by??`you`}`;function nE({doc:e,commit:t,onOpenSystem:n,onPlace:r,onNotice:i}){let a=e.system,[s,c]=(0,H.useState)(null),[d,p]=(0,H.useState)(null),[h,g]=(0,H.useState)(!1),[_,v]=(0,H.useState)(``),[y,b]=(0,H.useState)(JT),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(!1),[O,k]=(0,H.useState)(null),A=(0,H.useRef)(null),j=(0,H.useRef)(null),M=y===`list`,P=e=>{b(e);try{localStorage.setItem(qT,e)}catch{}},F=eE(a),I=Zw(e),[L,ee]=(0,H.useState)(null),[R,te]=(0,H.useState)([]),ne=(0,H.useRef)(null);(0,H.useEffect)(()=>{fetch(`/api/system/found`).then(e=>e.json()).then(e=>te(e.files??[])).catch(()=>{})},[]);let ie=(e,t)=>{let n=l(e,t);if(`error`in n)return i(`${n.error} Ask Claude to import it instead.`);ee(n)},ae=e=>fetch(`/api/system/file?path=${encodeURIComponent(e)}`).then(e=>e.json()).then(t=>t.text===void 0?i(t.error??`The file can't be read`):ie(t.text,e)),oe=(e,n)=>{let r={...e.fonts.body?{fontBody:e.fonts.body}:{},...e.fonts.display??e.fonts.body?{fontDisplay:e.fonts.display??e.fonts.body}:{}};t([YT({name:n,tokens:e.tokens,...Object.keys(r).length?{slots:r}:{}})],`Import system: ${n}`),ee(null),Oe(GT),g(!0)},[se,ce]=(0,H.useState)(!1),[le,ue]=(0,H.useState)(null),[de,fe]=(0,H.useState)([]),z=()=>fetch(`/api/systems/mine`).then(e=>e.json()).then(e=>fe(e.systems??[]),()=>{});(0,H.useEffect)(()=>{z();let e=()=>void z();return addEventListener(`focus`,e),()=>removeEventListener(`focus`,e)},[]);let pe=async()=>{if(ce(!1),!(await fetch(`/api/systems/mine/new`,{method:`POST`}).then(e=>e.json()).catch(()=>null))?.system)return i?.(`Couldn’t make a new system`);z(),Oe(GT)},me=e=>t([YT({useSaved:{id:e.id,version:e.version,name:e.name,base:e.base}})],`Use ${e.name}`),[he,ge]=(0,H.useState)(null),_e=async e=>{ge(null),await fetch(`/api/systems/mine/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e.id})}).catch(()=>{}),z(),i?.(`${e.name} removed from your library`)},[ve,be]=(0,H.useState)(null),[xe,Se]=(0,H.useState)(null),Ce=(e,t)=>fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json()).catch(()=>null),we=e=>!!e&&(!!e.saved||!u(e)&&!e.published||ye(e)),Te=e=>{if(a&&e!==B(a)){if(a.saved)return void Ce(`/api/systems/mine/rename`,{id:a.saved.id,name:e}).then(()=>z());t([YT(a.published?{own:!0,name:e}:{name:e})],`Rename system: ${e}`)}},Ee=(e,t)=>{t!==e.name&&Ce(`/api/systems/mine/rename`,{id:e.id,name:t}).then(()=>z())},De=e=>void Ce(`/api/systems/mine/duplicate`,e).then(e=>{z(),e?.system&&i?.(`${e.system.name} added to your library`)}),Oe=e=>{c(e),p(null),g(!1),v(``),k(null),T(null),D(!1)},ke=(0,H.useRef)(F);(0,H.useEffect)(()=>{let e=ke.current;ke.current=F,e!==F&&s===e&&(F?c(F):Oe(null))},[F]);let Ae=s&&s!==GT&&s!==`file`?ze.find(e=>e.id===s):void 0,je=!!s&&s!==`file`&&s===F,Me=je?a:Ae?m(Ae):void 0,Ne=s===`file`?Yw:s?$T(Me,Ae):null,Pe=(0,H.useMemo)(()=>!Ne||Ne===`file`||e.libraries?.kits?.includes(Ne)?e:eT(e,Ne),[e,Ne]),Fe=t=>[YT(re(t)),...t.kit&&!e.libraries?.kits?.includes(t.kit)?Xw(e,t.kit):[]],Ie=e=>{t(Fe(e),`Design system: ${e.name}`),T(null),a&&i(`${e.name} is now this file's design system. ⌘Z to undo`)},Le=e=>{a&&!at(a)?T(e.id):Ie(e)},Re=()=>{a&&(t([{op:`system`,remove:!0}],`Turn off ${B(a)}`),at(a)||i?.(`${B(a)} is off. ⌘Z brings it back`))},Be=(e,t,n=!1)=>(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":`Use ${t?.name??(a?B(a):`this system`)} in this file`,className:`switch ${e?`on`:``}`,"data-tip":e?`In use in this file. Turn off to keep its styles without the system`:`Use in this file, following ${t?.name??`it`}${a?` (replaces ${B(a)})`:``}`,onClick:()=>{if(e)return Re();t&&(n&&a&&!at(a)?(Oe(t.id),T(t.id)):Le(t))},children:(0,U.jsx)(`span`,{})}),Ve=(0,U.jsxs)(`span`,{className:`lib-view`,role:`group`,"aria-label":`View`,children:[(0,U.jsx)(`button`,{className:`icon-btn fit ${M?``:`on`}`,"aria-pressed":!M,"aria-label":`Grid`,"data-tip":`Grid`,onClick:()=>P(`grid`),children:(0,U.jsx)(X.viewGrid,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit ${M?`on`:``}`,"aria-pressed":M,"aria-label":`List`,"data-tip":`List`,onClick:()=>P(`list`),children:(0,U.jsx)(X.viewList,{})})]}),He=(e,t,n)=>(0,U.jsx)(`section`,{className:`psec libs-system`,ref:A,children:(0,U.jsx)(aT,{view:e,depth:t,children:n})});if(!s||s===`file`&&!I.length||s!==`file`&&!Me){let e=(e,t,n,r)=>{let i=ze.find(t=>t.id===e);return r?[{label:`Use in this file`,icon:(0,U.jsx)(X.styles,{}),onClick:()=>me(r)},{sep:!0},{label:`Rename`,icon:(0,U.jsx)(X.rename,{}),onClick:()=>Se(e)},{label:`Duplicate`,icon:(0,U.jsx)(X.copy,{}),onClick:()=>De({id:r.id})},{sep:!0},{label:`Remove from library`,icon:(0,U.jsx)(X.trash,{}),danger:!0,onClick:()=>ge(r)}]:n&&a?[...we(a)?[{label:`Rename`,icon:(0,U.jsx)(X.rename,{}),onClick:()=>Se(e)},{sep:!0}]:[],{label:`Export tokens`,icon:(0,U.jsx)(X.exportFile,{}),hint:`.json`,onClick:()=>QT(`${ZT(B(a))}.tokens.json`,JSON.stringify(x(a),null,2),`application/json`)},{label:`Export CSS variables`,icon:(0,U.jsx)(X.exportFile,{}),hint:`.css`,onClick:()=>QT(`${ZT(B(a))}.css`,o(a),`text/css`)},{sep:!0},{label:`Remove from this file`,icon:(0,U.jsx)(X.detach,{}),onClick:Re}]:i?[{label:`Use in this file`,icon:(0,U.jsx)(X.styles,{}),onClick:()=>{a&&!at(a)?(Oe(i.id),T(i.id)):Le(i)}},{label:`Add a copy to library`,icon:(0,U.jsx)(X.copy,{}),onClick:()=>De({preset:i.id})}]:[]},t=(t,r,i,a,o,s,c,l)=>(0,U.jsxs)(`div`,{className:`sys-item ${M?`row`:``}`,onContextMenu:n=>{let r=e(t,i,o,l);r.length&&(n.preventDefault(),be({x:n.clientX,y:n.clientY,items:r}))},children:[xe===t?(0,U.jsxs)(`div`,{className:`sys-card ${M?`row`:``} ${o?`used`:``}`,children:[(0,U.jsx)(lT,{name:r,look:rt(i)}),(0,U.jsx)(`span`,{className:`sys-card-text`,children:(0,U.jsx)(oE,{value:r,onDone:e=>{Se(null),e&&(l?Ee(l,e):Te(e))}})})]}):(0,U.jsxs)(`button`,{className:`sys-card ${M?`row`:``} ${o?`used`:``}`,onClick:()=>l?me(l):Oe(t),"data-tip":s,children:[(0,U.jsx)(lT,{name:r,look:rt(i)}),(0,U.jsxs)(`span`,{className:`sys-card-text`,children:[(0,U.jsx)(`strong`,{className:`sys-card-name`,children:r}),M?a??(0,U.jsx)(`small`,{"aria-hidden":`true`}):(0,U.jsxs)(`span`,{className:`sys-card-meta`,children:[a,c]})]})]}),l?(0,U.jsx)(`span`,{className:`sys-side`,children:n(l)}):M?(0,U.jsxs)(`span`,{className:`sys-side`,children:[Be(o,ze.find(e=>e.id===t),!0),c||(0,U.jsx)(`span`,{className:`sys-side-line`})]}):Be(o,ze.find(e=>e.id===t),!0)]},t),n=e=>(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":!1,"aria-label":`Use ${e.name} in this file`,className:`switch`,"data-tip":`Use in this file${a?` (replaces ${B(a)})`:``}`,onClick:()=>me(e),children:(0,U.jsx)(`span`,{})});return He(`systems`,0,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`libs-sys-head lib-head-row`,children:[`In this file`,Ve]}),a?t(F,B(a),a,(0,U.jsx)(`small`,{children:tE(ze.find(e=>e.id===F))}),!0,void 0,ye(a)?(0,U.jsx)(`small`,{className:`badge`,children:`Changed`}):null):(0,U.jsx)(`p`,{className:`muted-note`,children:`No design system yet. Turn one on, make a new one or import one below.`}),I.length>0&&(0,U.jsxs)(`button`,{className:`lib-row`,onClick:()=>Oe(`file`),children:[(0,U.jsxs)(`span`,{className:`lib-row-text`,children:[(0,U.jsx)(`strong`,{children:`This file's components`}),(0,U.jsxs)(`small`,{children:[I.length,` component`,I.length===1?``:`s`]})]}),(0,U.jsx)(X.forward,{})]}),(0,U.jsxs)(`div`,{className:`libs-sys-head lib-head-row`,children:[`Design systems`,(0,U.jsxs)(`span`,{className:`lib-view`,children:[(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`New design system`,"aria-expanded":se,onClick:()=>a?ce(!se):void pe(),"data-tip":`New design system from a few choices: two fonts, three colors and corners`,children:(0,U.jsx)(X.plus,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Import and export`,"aria-haspopup":`menu`,"aria-expanded":!!le,"data-tip":le?void 0:`Import and export`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();ue(le?null:{x:t.right,y:t.bottom+V(`--menu-gap`)})},children:(0,U.jsx)(X.more,{})})]}),le&&(0,U.jsx)(Gl,{x:le.x,y:le.y,alignRight:!0,onClose:()=>ue(null),items:[{label:`Import…`,icon:(0,U.jsx)(X.importFile,{}),hint:`.css · .json · .html`,onClick:()=>{ue(null),ne.current?.click()}},{sep:!0},{label:`Export tokens`,icon:(0,U.jsx)(X.exportFile,{}),hint:`.json`,disabled:!a,onClick:()=>{ue(null),a&&QT(`${ZT(B(a))}.tokens.json`,JSON.stringify(x(a),null,2),`application/json`)}},{label:`Export CSS variables`,icon:(0,U.jsx)(X.exportFile,{}),hint:`.css`,disabled:!a,onClick:()=>{ue(null),a&&QT(`${ZT(B(a))}.css`,o(a),`text/css`)}}]}),(0,U.jsx)(`input`,{ref:ne,type:`file`,accept:`.css,.json,.html,.htm`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&t.text().then(e=>ie(e,t.name))}})]}),se&&a&&(0,U.jsxs)(`div`,{className:`lib-confirm`,role:`alertdialog`,"aria-label":`Replace ${B(a)}`,children:[(0,U.jsxs)(`p`,{children:[`A new system replaces `,B(a),`. ⌘Z brings it back.`]}),(0,U.jsxs)(`div`,{className:`sys-own-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ce(!1),children:`Cancel`}),(0,U.jsx)(`button`,{type:`button`,className:`btn primary`,autoFocus:!0,onClick:()=>void pe(),children:`Create`})]})]}),L&&(0,U.jsx)(rE,{r:L,replaces:a&&!at(a)?B(a):void 0,onImport:e=>oe(L,e),onCancel:()=>ee(null)}),he&&(0,U.jsxs)(`div`,{className:`lib-confirm`,role:`alertdialog`,"aria-label":`Remove ${he.name} from library`,children:[(0,U.jsxs)(`p`,{children:[he.name,` is removed from your library in every project. Files using it keep its values.`]}),(0,U.jsxs)(`div`,{className:`sys-own-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ge(null),children:`Cancel`}),(0,U.jsx)(`button`,{type:`button`,className:`btn primary`,autoFocus:!0,onClick:()=>void _e(he),children:`Remove`})]})]}),ve&&(0,U.jsx)(Gl,{x:ve.x,y:ve.y,items:ve.items,onClose:()=>be(null)}),de.filter(e=>a?.saved?.id!==e.id).map(e=>{let n=XT(e);return t(e.id,e.name,n,(0,U.jsx)(`small`,{children:tE(void 0)}),!1,`Use in this file`,void 0,e)}),!L&&!a?.tokens&&R.slice(0,1).map(e=>(0,U.jsxs)(`button`,{className:`lib-row`,onClick:()=>void ae(e.path),"data-tip":`Import the design system in this file`,children:[(0,U.jsx)(X.styles,{}),(0,U.jsxs)(`span`,{className:`lib-row-text`,children:[(0,U.jsx)(`strong`,{children:e.path}),(0,U.jsxs)(`small`,{children:[`Found in this project · `,e.colors,` colors`]})]}),(0,U.jsx)(`span`,{className:`btn sm`,children:`Import`})]},e.path)),ze.filter(e=>e.id!==F).map(e=>t(e.id,e.name,m(e),(0,U.jsx)(`small`,{children:tE(e)}),!1,e.note||void 0))]}))}let Ue=Ne&&Ne!==`file`?N[Ne]:void 0,We=Qw(Pe,Ne),Ge=s===`file`?`This file's components`:je?B(a):Ae.name,Ke=f(Me),qe=je&&ye(a)?(0,U.jsx)(`small`,{className:`badge`,children:`Changed`}):null,Je=Me?AT(Me):``,Ye=()=>O?k(null):d||h?(p(null),g(!1)):Oe(null),Xe=(e,t)=>{if(O?.pick.id===e.id)return k(null);k({pick:e,top:t.getBoundingClientRect().top})},Ze=(e,t)=>{r(e,t),k(null)},Qe=e=>{let t=$w(Pe,e)[0];return t?{id:e,variant:t}:null},$e=e=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{className:`lib-crumb`,"data-tip":`Back to ${Ge}`,onClick:()=>{p(null),g(!1),k(null)},children:Ge}),(0,U.jsx)(`span`,{className:`lib-crumb-sep`,"aria-hidden":!0,children:`/`}),(0,U.jsx)(`strong`,{children:e})]}),et=(e,n=Ve,r)=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(kC,{title:e,onBack:Ye,end:n,sub:r}),h&&je&&a&&(0,U.jsx)(OT,{s:a,commit:t,onSaved:()=>void z()})]});if(h&&Me){let r=!!(Me.published||Me.tokens);return He(`${s}/tokens`,2,(0,U.jsxs)(U.Fragment,{children:[et($e(`Tokens`),(0,U.jsxs)(U.Fragment,{children:[je?(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(kT,{from:TT(a),owning:E,onOwn:()=>D(!E)})}):Ae?(0,U.jsx)(kT,{from:Ae.name,inFile:!1,owning:E,onOwn:()=>D(!E)}):null,je&&n&&(0,U.jsx)(jT,{onOpen:n})]}),(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`div`,{className:`lib-sub`,children:(0,U.jsx)(`small`,{className:`lib-sub-note`,children:Je})})})),je&&E&&TT(a)&&(0,U.jsx)(NT,{s:a,commit:t,onDone:()=>D(!1)}),!je&&Ae&&E&&(0,U.jsx)(NT,{s:Me,commit:t,onDone:()=>{Oe(GT),g(!0)},onCancel:()=>D(!1),use:{ops:Fe(Ae),replaces:a&&!at(a)?B(a):void 0}}),je&&!r?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`tok-theme`,children:(0,U.jsx)(wT,{s:a,commit:t})}),(0,U.jsx)(PT,{doc:e,commit:t,onOpen:n,head:!1})]}):(0,U.jsx)(hT,{sys:Me,edit:je?ST(a,t):void 0,theme:je?a.theme:void 0,themeControl:je?(0,U.jsx)(wT,{s:a,commit:t}):void 0,parts:!0})]}))}let tt=_.trim().toLowerCase(),nt=tt?We.flatMap(e=>e.ids.flatMap(t=>{let n=Pe.nodes[t],r=$w(Pe,t).find(t=>`${e.name} ${n?.name??``} ${t.name}`.toLowerCase().includes(tt));return r?[{id:t,variant:r}]:[]})):null,it=d?We.find(e=>e.key===d):null,ot=O&&Pe.nodes[O.pick.id]&&(0,U.jsx)(aE,{doc:Pe,pick:O.pick,top:O.top,from:Ue?Ue.name:`This file`,license:Ue?.license,onInsert:Ze,onClose:()=>k(null)},O.pick.id);if(it)return He(`${s}/${it.key}`,2,(0,U.jsxs)(U.Fragment,{children:[et($e(it.name),(0,U.jsxs)(U.Fragment,{children:[it.note&&(0,U.jsx)(`small`,{className:`lib-cat-note`,children:it.note}),Ve]})),(0,U.jsx)(tT,{doc:Pe,items:it.ids.flatMap(e=>Qe(e)??[]),list:M,picked:O?.pick.id,onPick:Xe}),ot]}));let st=(e,t,n)=>({label:t,hint:n,checked:e===s,onClick:()=>{C(null),e!==s&&Oe(e)}});return He(s,1,(0,U.jsxs)(U.Fragment,{children:[et(s===`file`?(0,U.jsx)(`strong`,{children:Ge}):(0,U.jsxs)(U.Fragment,{children:[xe===`title`&&je?(0,U.jsx)(oE,{value:Ge,title:!0,onDone:e=>{Se(null),e&&Te(e)}}):(0,U.jsxs)(`button`,{ref:j,className:`lib-title ${S?`open`:``}`,"aria-haspopup":`menu`,"aria-expanded":!!S,"data-tip":S?void 0:je&&we(a)?`Switch design system · double-click to rename`:`Switch design system`,onClick:e=>{if(e.detail>1){C(null),je&&we(a)&&Se(`title`);return}let t=e.currentTarget.getBoundingClientRect();C(S?null:{x:t.left,y:t.bottom+V(`--menu-gap`)})},children:[(0,U.jsx)(`strong`,{children:Ge}),(0,U.jsx)(X.chevronsUpDown,{})]}),S&&(0,U.jsx)(Gl,{x:S.x,y:S.y,onClose:()=>{C(null),j.current?.focus()},items:[...a&&F===GT?[{head:`In this file`},st(GT,B(a))]:[],{head:`Design systems`},...ze.map(e=>st(e.id,e.name,F===e.id?`In this file`:void 0))]})]}),s!==`file`&&Me?(0,U.jsx)(U.Fragment,{children:Be(je,Ae)}):null),s!==`file`&&Me&&(0,U.jsx)(U.Fragment,{children:w===Ae?.id&&a&&(0,U.jsxs)(`div`,{className:`lib-confirm`,role:`alertdialog`,"aria-label":`Replace ${B(a)}`,children:[(0,U.jsxs)(`p`,{children:[ye(a)&&!a.tokens?`Your changes to ${B(a)} go away.`:`${B(a)} is your own system; it is replaced.`,` ⌘Z brings it back.`]}),(0,U.jsxs)(`div`,{className:`sys-own-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>T(null),children:`Cancel`}),(0,U.jsx)(`button`,{type:`button`,className:`btn primary`,autoFocus:!0,onClick:()=>Ie(Ae),children:`Replace`})]})]})}),s!==`file`&&Me&&(0,U.jsxs)(`button`,{className:`lib-row`,onClick:()=>{g(!0),k(null)},children:[(0,U.jsx)(X.styles,{}),(0,U.jsxs)(`span`,{className:`lib-row-text`,children:[(0,U.jsxs)(`span`,{className:`lib-row-title`,children:[(0,U.jsx)(`strong`,{children:`Tokens`}),qe]}),(0,U.jsx)(`small`,{children:Je})]}),(0,U.jsx)(X.forward,{})]}),Ue&&Me&&!Ae?.kit&&!Ke&&(0,U.jsxs)(`div`,{className:`libs-sys-head`,children:[`Components from `,Ue.name]}),(0,U.jsxs)(`div`,{className:`lib-search-row`,children:[(0,U.jsxs)(`label`,{className:`libs-search`,children:[(0,U.jsx)(X.search,{}),(0,U.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:`Search components`,"aria-label":`Search components`})]}),Ve]}),nt?nt.length?(0,U.jsx)(tT,{doc:Pe,items:nt,list:M,picked:O?.pick.id,onPick:Xe}):(0,U.jsxs)(`p`,{className:`muted-note`,children:[`Nothing for “`,_.trim(),`”`]}):(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(`div`,{className:M?`lib-cat-rows`:`lib-cat-grid`,children:We.map(e=>(0,U.jsx)(iE,{doc:Pe,cat:e,list:M,onOpen:()=>{p(e.key),k(null)}},e.key))})}),ot]}))}function rE({r:e,replaces:t,onImport:n,onCancel:r}){let[i,a]=(0,H.useState)(e.name),o=(e,t)=>`${e} ${t}${e===1?``:`s`}`,s=e.tokens,c=[o(Object.keys(s.colors).length,`color`),o(Object.keys(s.text).length,`text style`),...Object.keys(s.radius).length?[o(Object.keys(s.radius).length,`corner`)]:[]].join(` · `);return(0,U.jsxs)(`form`,{className:`sys-own`,onSubmit:t=>{t.preventDefault(),n(i.trim()||e.name)},children:[(0,U.jsxs)(`label`,{className:`sys-own-name`,children:[(0,U.jsx)(`span`,{children:`Name`}),(0,U.jsx)(`input`,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),"aria-label":`Name of the imported system`})]}),(0,U.jsxs)(`p`,{className:`comp-hint`,children:[c,e.skipped.length?(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsxs)(`span`,{"data-tip":e.skipped.slice(0,12).join(`
|
|
34
|
+
`)+(e.skipped.length>12?`
|
|
35
|
+
…`:``),children:[o(e.skipped.length,`token`),` skipped`]})]}):null,`.`,` `,`It becomes this file's own system`,t?`, replacing ${t}; ⌘Z brings it back`:``,`.`]}),(0,U.jsxs)(`div`,{className:`sys-own-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`btn`,onClick:r,children:`Cancel`}),(0,U.jsx)(`button`,{type:`submit`,className:`btn primary`,children:`Import`})]})]})}function iE({doc:e,cat:t,list:n,onOpen:r}){let i=$w(e,t.ids[0])[0];return(0,U.jsxs)(`button`,{className:n?`lib-cat row`:`lib-cat`,onClick:r,children:[i?(0,U.jsx)(nT,{doc:e,main:i,size:n?`row`:`big`}):(0,U.jsx)(`span`,{className:`comp-thumb ${n?`row`:`big`}`}),(0,U.jsxs)(`span`,{className:`lib-cat-name`,children:[(0,U.jsxs)(`span`,{className:`lib-cat-text`,children:[(0,U.jsx)(`strong`,{children:t.name}),t.note&&(0,U.jsx)(`small`,{children:t.note})]}),(0,U.jsx)(X.forward,{})]})]})}function aE({doc:e,pick:t,top:n,from:r,license:i,onInsert:a,onClose:o}){let c=(0,H.useRef)(null),l=(0,H.useRef)(o);l.current=o,(0,H.useEffect)(()=>{let e=()=>l.current(),t=t=>{t.key===`Escape`&&(t.stopPropagation(),e())},n=t=>{let n=t.target;!c.current?.contains(n)&&!n.closest(`.comp-tile, .lib-comp-row`)&&e()};return window.addEventListener(`keydown`,t,!0),window.addEventListener(`pointerdown`,n,!0),()=>{window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`pointerdown`,n,!0)}},[]);let[u,d]=(0,H.useState)(t.variant),[f,p]=(0,H.useState)({}),m=ie(e,u.id),h=(0,H.useMemo)(()=>{let t=`n_detail-pick`;return{...e,nodes:{...e.nodes,[t]:{type:`frame`,id:t,name:u.name,parent:null,x:0,y:0,w:u.w,h:u.h,sizeX:`fixed`,sizeY:`fixed`,children:[],layout:u.layout,clip:!1,instanceOf:u.id,values:f}}}},[e,u,f]),g=e=>s(h,`n_detail-pick`,e),_=ut(h,`n_detail-pick`),v=(t,n)=>{let r=oe(e,u.id,{[t]:n});r&&d(r)},y=(e,t)=>p(n=>({...n,[e]:t})),[b,x]=(0,H.useState)(null);(0,H.useEffect)(()=>{let e=c.current?.closest(`.libs`)?.getBoundingClientRect(),t=c.current?.offsetHeight??0;e&&x({right:window.innerWidth-e.left+8,top:Math.max(8,Math.min(n,window.innerHeight-t-8))})},[n,u.id]);let S=e.nodes[t.id]?.name??u.name,C=Object.keys(f).length?f:void 0;return(0,U.jsxs)(`div`,{ref:c,className:`comp-detail`,role:`dialog`,"aria-label":`${S} details`,style:b?{right:b.right,top:b.top}:{visibility:`hidden`},children:[(0,U.jsxs)(`div`,{className:`comp-detail-head`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`strong`,{children:`Details`}),(0,U.jsx)(`small`,{children:r})]}),(0,U.jsx)(`button`,{className:`panel-btn`,"aria-label":`Close`,"data-tip":`Close`,onClick:o,children:(0,U.jsx)(X.close,{})})]}),(0,U.jsx)(`div`,{className:`comp-detail-drag`,draggable:!0,"data-tip":`Drag to the canvas`,onDragStart:e=>{e.dataTransfer.setData(Jw,C?JSON.stringify({main:u.id,values:C}):u.id),e.dataTransfer.effectAllowed=`copy`},children:(0,U.jsx)(nT,{doc:e,main:u,values:C,size:`detail`})}),(0,U.jsxs)(`div`,{className:`comp-detail-body`,children:[(0,U.jsx)(`strong`,{className:`comp-detail-name`,children:S}),i&&(0,U.jsx)(`small`,{children:i}),(0,U.jsx)(`button`,{className:`btn primary`,autoFocus:!0,onClick:()=>a(u.id,C),children:`Insert instance`})]}),m.length>0&&(0,U.jsxs)(`div`,{className:`comp-detail-props`,children:[(0,U.jsx)(`strong`,{children:`Properties`}),m.filter(e=>!_.has(e.name)).map(t=>{let n=g(t.name);if(t.type===`variant`&&t.values.length===2&&t.values.every(e=>/^(true|false)$/i.test(e))){let e=String(n).toLowerCase()===`true`,r=t.values.find(t=>t.toLowerCase()===String(!e));return(0,U.jsxs)(`div`,{className:`comp-detail-prop`,children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":t.name,className:`switch ${e?`on`:``}`,onClick:()=>v(t.name,r),children:(0,U.jsx)(`span`,{})})]},t.name)}if(t.type===`variant`)return(0,U.jsxs)(`label`,{className:`comp-detail-prop`,children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsxs)(`span`,{className:`select-wrap`,children:[(0,U.jsx)(`select`,{value:String(n??``),"aria-label":t.name,onChange:e=>v(t.name,e.target.value),children:t.values.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(X.chevronDown,{})]})]},t.name);if(t.type===`boolean`){let e=n!==!1;return(0,U.jsxs)(`div`,{className:`comp-detail-prop`,children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":t.name,className:`switch ${e?`on`:``}`,onClick:()=>y(t.name,!e),children:(0,U.jsx)(`span`,{})})]},t.name)}if(t.type===`text`)return(0,U.jsxs)(`label`,{className:`comp-detail-prop`,children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsx)(`input`,{className:`text-in`,defaultValue:String(n??``),spellCheck:!1,"aria-label":t.name,onKeyDown:e=>e.stopPropagation(),onChange:e=>y(t.name,e.target.value)})]},t.name);let r=typeof n==`object`&&n?n.icon.name:typeof n==`string`?e.nodes[n]?.name??n:`None`;return(0,U.jsxs)(`div`,{className:`comp-detail-prop`,"data-tip":`Change it on the placed instance`,children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsx)(`span`,{className:`comp-detail-held`,children:r})]},t.name)})]})]})}function oE({value:e,title:t=!1,onDone:n}){let[r,i]=(0,H.useState)(e),a=(0,H.useRef)(!1),o=e=>{a.current||(a.current=!0,n(e?.trim().slice(0,80)||null))};return(0,U.jsx)(`input`,{className:t?`sys-name-in`:`sys-name-in card`,autoFocus:!0,value:r,"aria-label":`System name`,onFocus:e=>e.currentTarget.select(),onChange:e=>i(e.target.value),onBlur:()=>o(r),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Enter`&&o(r),e.key===`Escape`&&(e.stopPropagation(),o(null))}})}var sE=`brands`,cE=`brands-color`,lE=[`simple-icons`,`cib`,`logos`];function uE({doc:e,commit:t,onOpenSystem:n,onPlace:r,onPlaceComponent:i,onNotice:a}){let[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(`system`),g=Ce(e),_=e.libraries?.icons,v=()=>fetch(`/api/icons/packs`).then(e=>e.json()).then(s,()=>a(`Couldn’t read the icon sets`));(0,H.useEffect)(()=>{v()},[g,_?.join()]);let y=(e,n)=>t([{op:`doc`,libraries:{pack:e===`lucide`?null:e}}],`Icons: ${n}`),b=async()=>{l(`folder`);try{let e=await fetch(`/api/icons/folder`,{method:`POST`}),n=await e.json();if(n.cancelled)return;if(!e.ok||!n.id)throw Error(n.error);t([{op:`doc`,libraries:{icons:[..._??[],n.id]}}],`Add icons: ${n.name}`)}catch(e){a(e instanceof Error&&e.message?e.message:`Couldn’t add the folder`)}finally{l(null)}},x=o?.ready.find(e=>e.id===g),S=o?.folders.find(e=>e.id===g);return(0,U.jsxs)(`div`,{className:`panel props libs`,children:[(0,U.jsx)(`div`,{className:`text-tabs libs-tabs`,role:`tablist`,children:dE.map(([e,t])=>(0,U.jsx)(`button`,{role:`tab`,"aria-selected":m===e,className:m===e?`on`:``,onClick:()=>h(e),children:t},e))}),m===`system`&&(0,U.jsx)(nE,{doc:e,commit:t,onOpenSystem:n,onPlace:i,onNotice:a}),m===`icons`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`section`,{className:`psec libs-set-bar`,children:(0,U.jsx)(`div`,{className:`libs-pack on`,children:(0,U.jsxs)(`button`,{className:`libs-pack-main ${f?`open`:``}`,"aria-haspopup":`menu`,"aria-expanded":!!f,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();p(f?null:{x:t.left,y:t.bottom+V(`--menu-gap`)})},"data-tip":f?void 0:`Switch icon set — the one your agent uses`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`strong`,{children:x?.name??S?.name??g}),(0,U.jsx)(`small`,{children:x?`${x.total.toLocaleString(`en`)} · ${gE(x)}`:S?`${S.total} SVGs in this project`:``})]}),(0,U.jsx)(X.chevronDown,{})]})})}),(0,U.jsx)(fE,{system:g,show:`icons`,onPlace:r,preview:!0})]}),m===`logos`&&(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(fE,{system:g,show:`logos`,onPlace:r,preview:!0})}),f&&(0,U.jsx)(Gl,{x:f.x,y:f.y,items:[...(o?.ready??[]).filter(e=>!lE.includes(e.id)).map(e=>({label:e.name,hint:e.total.toLocaleString(`en`),checked:e.id===g,onClick:()=>{p(null),e.id!==g&&y(e.id,e.name)}})),...o?.folders.length?[{sep:!0},...o.folders.map(e=>({label:e.name,hint:`${e.total}`,checked:e.id===g,disabled:e.missing,onClick:()=>{p(null),e.id!==g&&y(e.id,e.name)}}))]:[],{sep:!0},{label:`Browse packs…`,onClick:()=>{p(null),d(!0)}},{label:c===`folder`?`Choosing…`:`Add SVG folder…`,disabled:c===`folder`,onClick:()=>{p(null),b()}},...o?.folders.length?[{sep:!0},...o.folders.map(e=>({label:`Remove ${e.name}`,onClick:()=>{p(null),t([{op:`doc`,libraries:{icons:(_??[]).filter(t=>t!==e.id)}}],`Remove icons: ${e.name}`)}}))]:[]],onClose:()=>p(null)}),u&&(0,U.jsx)(Uw,{system:g,onClose:()=>{d(!1),v()},onUse:e=>{y(e.id,e.name),d(!1)},onNotice:a})]})}var dE=[[`system`,`Design systems`],[`icons`,`Icons`],[`logos`,`Logos`]];function fE({system:e,show:t=`all`,onPlace:n,preview:r}){let[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(null),c=(0,H.useRef)(null),[l,u]=(0,H.useState)(t===`logos`?`brands`:`set`),[d,f]=(0,H.useState)(`mono`),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),y=t!==`logos`,b=t!==`icons`,[x,S]=(0,H.useState)({set:``,brands:``,color:``});(0,H.useEffect)(()=>{t===`all`&&u(`set`)},[e,t]),(0,H.useEffect)(()=>s(null),[e,l,d]),(0,H.useEffect)(()=>{let t=!0,n=e=>fetch(`/api/icons/search?pack=${encodeURIComponent(e)}&q=${encodeURIComponent(i)}`).then(e=>e.json()),r=(e,r,a)=>void n(e).then(e=>{t&&(r(e.hits?e:null),S(e=>({...e,[a]:i})))},()=>{}),a=setTimeout(()=>{y&&r(e,m,`set`),b&&(r(sE,g,`brands`),r(cE,v,`color`))},i?120:0);return()=>{t=!1,clearTimeout(a)}},[i,e,y,b]);let C=[y&&p&&{label:p.name,hits:p.hits},b&&h&&{label:t===`logos`?`Mono`:`Brand logos`,hits:h.hits},b&&_&&{label:t===`logos`?`Color`:`Brand logos · Color`,hits:_.hits}].filter(e=>!!e),w=i?C.length>1?C:C.map(e=>({...e,label:``})):[l===`brands`?d===`color`?_:h:p].filter(e=>!!e).map(e=>({label:``,hits:e.hits})),T=w.reduce((e,t)=>e+t.hits.length,0),E=(h?.total??0)+(_?.total??0),D=(y?p?.total??0:0)+(b?E:0),O=t===`icons`?`icons`:t===`logos`?`logos`:`icons and logos`,k=(!y||x.set===i)&&(!b||x.brands===i&&x.color===i);return(0,U.jsxs)(`section`,{className:`psec libs-browse`,ref:c,children:[(0,U.jsxs)(`label`,{className:`libs-search`,children:[(0,U.jsx)(X.search,{}),(0,U.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`Search ${D.toLocaleString(`en`)} ${O}`,"aria-label":`Search ${O}`}),i&&k&&(0,U.jsx)(`span`,{className:`libs-count`,children:T.toLocaleString(`en`)})]}),!i&&t===`all`&&(0,U.jsxs)(`div`,{className:`seg libs-seg`,role:`tablist`,children:[(0,U.jsxs)(`button`,{role:`tab`,"aria-selected":l===`set`,className:l===`set`?`on`:``,onClick:()=>u(`set`),children:[p?.name??`Icons`,` `,(0,U.jsx)(`span`,{children:(p?.total??0).toLocaleString(`en`)})]}),(0,U.jsxs)(`button`,{role:`tab`,"aria-selected":l===`brands`,className:l===`brands`?`on`:``,onClick:()=>u(`brands`),children:[`Brand logos `,(0,U.jsx)(`span`,{children:E.toLocaleString(`en`)})]})]}),!i&&l===`brands`&&(0,U.jsxs)(`div`,{className:`seg libs-seg libs-tone`,role:`tablist`,"aria-label":`Logo color`,children:[(0,U.jsxs)(`button`,{role:`tab`,"aria-selected":d===`mono`,className:d===`mono`?`on`:``,onClick:()=>f(`mono`),"data-tip":`One color: follows the text color`,children:[`Mono `,(0,U.jsx)(`span`,{children:(h?.total??0).toLocaleString(`en`)})]}),(0,U.jsxs)(`button`,{role:`tab`,"aria-selected":d===`color`,className:d===`color`?`on`:``,onClick:()=>f(`color`),"data-tip":`The brand's own colors, kept as they are`,children:[`Color `,(0,U.jsx)(`span`,{children:(_?.total??0).toLocaleString(`en`)})]})]}),(0,U.jsx)(hE,{groups:w,empty:i?`Nothing for “${i}”`:`Loading…`,picked:o,onPick:r?e=>s(t=>t?.pack===e.pack&&t.name===e.name?null:e):n},`${i}|${l}|${d}|${e}`),o&&(0,U.jsx)(qw,{icon:o,onPlace:n,onClose:()=>s(null),alignTop:()=>c.current?.querySelector(`.libs-grid`)??null},`${o.pack}/${o.name}`)]})}var pE=6,mE=28;function hE({groups:e,onPick:t,picked:n,empty:r}){let i=(0,H.useRef)(null),[a,o]=(0,H.useState)(0),[s,c]=(0,H.useState)(0),[l,u]=(0,H.useState)(0);(0,H.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let t=()=>{o(e.clientWidth),u(e.clientHeight)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let d=a?a/pE:40,f=(0,H.useMemo)(()=>{let t=[],n=0;for(let r of e){r.label&&r.hits.length&&(t.push({kind:`head`,label:r.label,at:n}),n+=mE);for(let e=0;e<r.hits.length;e+=pE)t.push({kind:`icons`,items:r.hits.slice(e,e+pE),at:n}),n+=d}return{out:t,height:n}},[e,d]),p=s-l,m=s+2*l,h=f.out.filter(e=>e.at+(e.kind===`head`?mE:d)>=p&&e.at<=m);return(0,U.jsxs)(`div`,{className:`libs-grid`,ref:i,onScroll:e=>c(e.currentTarget.scrollTop),children:[!f.out.length&&(0,U.jsx)(`p`,{className:`muted-note`,children:r}),(0,U.jsx)(`div`,{style:{height:f.height,position:`relative`},children:h.map(e=>e.kind===`head`?(0,U.jsx)(`div`,{className:`libs-head`,style:{top:e.at,height:mE},children:e.label},`h${e.at}`):(0,U.jsx)(`div`,{className:`libs-row`,style:{top:e.at,height:d},children:e.items.map(e=>(0,U.jsx)(`button`,{className:`libs-icon`,style:{width:d,height:d},draggable:!0,"data-tip":e.name,"aria-expanded":n?n.pack===e.pack&&n.name===e.name:void 0,onDragStart:t=>{t.dataTransfer.setData(Vw,JSON.stringify({pack:e.pack,name:e.name})),t.dataTransfer.effectAllowed=`copy`},onClick:()=>t({pack:e.pack,name:e.name}),children:(0,U.jsx)(`img`,{src:`/api/icons/svg?pack=${encodeURIComponent(e.pack)}&name=${encodeURIComponent(e.name)}`,alt:e.name,draggable:!1})},`${e.pack}/${e.name}`))},`r${e.at}`))})]})}var gE=e=>`${_E[e.license.spdx]??e.license.title}${e.credit?` · credit needed`:``}`,_E={"CC0-1.0":`CC0`,"Apache-2.0":`Apache 2.0`,"CC-BY-4.0":`CC BY 4.0`,"CC-BY-3.0":`CC BY 3.0`};function vE(e,t,n){let r=t=>t?.type===`frame`&&!!t.main&&!t.inInstance&&!e.removed?.[t.id],i=n=>r(e.nodes[n])&&!_(e,t,n),a=n.filter(i);return[...a,...Object.keys(e.nodes).filter(e=>i(e)&&!a.includes(e))]}var yE=(e,t)=>typeof e==`string`&&t.includes(e)?e:``,bE={content:`Text`,style:`Text style`,fontFamily:`Font`,fontSize:`Font size`,fontWeight:`Weight`,fontStyle:`Italic`,lineHeight:`Line height`,letterSpacing:`Letter spacing`,textDecoration:`Decoration`,textCase:`Case`,color:`Color`,fills:`Fill`,stroke:`Stroke`,effects:`Effects`,name:`Name`,hidden:`Visibility`,w:`Width`,h:`Height`,sizeX:`Width resizing`,sizeY:`Height resizing`},xE=e=>bE[e]??e,SE={variant:`Variant`,boolean:`Boolean`,text:`Text`,swap:`Instance swap`};function CE(e){return e.inInstance??(e.type===`frame`&&e.instanceOf?e.id:void 0)}function wE({doc:e,node:t,onCommit:n,onSelect:r,onNotice:i}){if(t.type===`frame`&&t.componentSet)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(DE,{doc:e,set:t,onCommit:n,onSelect:r}),(0,U.jsx)(AE,{doc:e,host:t,onCommit:n,onNotice:i})]});if(t.type===`frame`&&t.main){let a=ce(e,t.id);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TE,{doc:e,main:t,set:a,onCommit:n,onSelect:r}),a?(0,U.jsx)(OE,{doc:e,variant:t,set:a,onCommit:n,onNotice:i}):(0,U.jsx)(AE,{doc:e,host:t,onCommit:n,onNotice:i})]})}let o=CE(t);if(o)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(NE,{doc:e,node:t,instId:o,onCommit:n,onSelect:r}),o===t.id&&(0,U.jsx)(IE,{doc:e,inst:t,onCommit:n,onNotice:i})]});let s=a(e,t.id);return s&&s!==t.id?(0,U.jsx)(ME,{doc:e,node:t,main:s,onCommit:n}):null}function TE({doc:e,main:t,set:n,onCommit:r,onSelect:i}){let a=Ne(e,t.id);return(0,U.jsxs)(nu,{title:n?`Variant`:`Main component`,action:a.length?(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>i?.(a),"aria-label":`Select instances`,"data-tip":`Select its instances`,children:(0,U.jsx)(X.fit,{})}):void 0,children:[(0,U.jsx)(`p`,{className:`comp-hint`,children:a.length?`${a.length} instance${a.length>1?`s`:``}. A change here reaches every one, except what an instance changed itself.`:`No instances yet. Duplicate it or copy and paste it to place one.`}),(0,U.jsx)(`div`,{className:`comp-row one`,children:(0,U.jsxs)(`button`,{className:`btn`,onClick:()=>r(n?[{op:`addVariant`,id:t.id}]:[{op:`combine`,ids:[t.id],key:`set`},{op:`addVariant`,id:`set`}],`Add variant`),"data-tip":n?`A copy of this variant, with a new value`:`Make it a component set with a second variant`,children:[(0,U.jsx)(X.plus,{}),` Add variant`]})})]})}var EE=(e,t)=>`${t.reduce((e,t)=>e+t.length,0)} variants share values: ${t.map(t=>`${t.length} × ${e.nodes[t[0]]?.name??`?`}`).join(`, `)}. Give each one its own values, or add back a property that tells them apart.`;function DE({doc:e,set:t,onCommit:n,onSelect:r}){let i=S(e,t.id),a=i.flatMap(t=>Ne(e,t.id)),o=Ke(e,t.id);return(0,U.jsxs)(nu,{title:`Component set`,action:a.length?(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>r?.(a),"aria-label":`Select instances`,"data-tip":`Select its instances`,children:(0,U.jsx)(X.fit,{})}):void 0,children:[(0,U.jsxs)(`p`,{className:`comp-hint`,children:[i.length,` variant`,i.length===1?``:`s`,`, `,a.length,` instance`,a.length===1?``:`s`,`. A new instance is the first variant.`]}),o.length>0&&(0,U.jsx)(`p`,{className:`comp-warn`,children:EE(e,o)}),(0,U.jsx)(`div`,{className:`comp-row one`,children:(0,U.jsxs)(`button`,{className:`btn`,onClick:()=>n([{op:`addVariant`,id:t.id}],`Add variant`),"data-tip":`A copy of the first variant, with a new value`,children:[(0,U.jsx)(X.plus,{}),` Add variant`]})})]})}function OE({doc:e,variant:t,set:n,onCommit:r,onNotice:i}){let a=t.variant??{},o=Ke(e,n.id).some(e=>e.includes(t.id));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(nu,{title:`Variant values`,children:[(0,U.jsx)(`div`,{className:`comp-props`,children:Object.entries(a).map(([e,n])=>(0,U.jsxs)(`label`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(`input`,{className:`text-in full`,defaultValue:n,spellCheck:!1,"aria-label":e,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&e.currentTarget.blur()},onBlur:i=>{let o=i.currentTarget.value.trim();o&&o!==n?r([{op:`update`,id:t.id,set:{variant:{...a,[e]:o}}}],`${e}: ${o}`):i.currentTarget.value=n}})]},`${e}|${n}`))}),o&&(0,U.jsx)(`p`,{className:`comp-warn`,children:`Another variant has the same values.`})]}),(0,U.jsx)(AE,{doc:e,host:n,onCommit:r,onNotice:i})]})}function kE(e,t){let n=1;for(;v(e,t,`Property ${n}`);)n++;return`Property ${n}`}function AE({doc:e,host:t,onCommit:n,onNotice:r}){let i=t.componentSet?S(e,t.id)[0]:t,a=i?ie(e,i.id):[],o=r=>{r&&n([{op:`prop`,id:t.id,name:kE(e,t),type:r}],`Add ${SE[r].toLowerCase()} property`)};return(0,U.jsxs)(nu,{title:`Properties`,children:[a.length>0&&(0,U.jsx)(`div`,{className:`comp-props`,children:a.map(i=>(0,U.jsxs)(`div`,{className:`comp-prop def`,children:[(0,U.jsx)(`input`,{className:`text-in full`,defaultValue:i.name,spellCheck:!1,"aria-label":`Property name`,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&e.currentTarget.blur()},onBlur:a=>{let o=a.currentTarget.value.trim();if(o&&o!==i.name&&v(e,t,o))r?.(`${d(t)} already has a property named “${o}”`);else if(o&&o!==i.name)return n([{op:`prop`,id:t.id,name:i.name,rename:o}],`Rename property`);a.currentTarget.value=i.name}}),(0,U.jsxs)(`small`,{"data-tip":i.values?i.values.join(`, `):void 0,children:[SE[i.type],i.values?` · ${i.values.length}`:``]}),(0,U.jsx)(`button`,{className:`panel-btn`,"aria-label":`Remove ${i.name}`,"data-tip":`Remove property`,onClick:()=>n([{op:`prop`,id:t.id,name:i.name,remove:!0}],`Remove property`),children:(0,U.jsx)(X.minus,{})})]},`${i.name}|${i.type}`))}),!a.length&&(0,U.jsx)(`p`,{className:`comp-hint`,children:`What an instance can change: its variant, a label (Text), whether a layer shows (Boolean), which icon or component it holds (Instance swap).`}),(0,U.jsxs)(`div`,{className:`select-wrap comp-add`,children:[(0,U.jsxs)(`select`,{value:``,"aria-label":`Add property`,onChange:e=>o(e.target.value),children:[(0,U.jsx)(`option`,{value:``,children:`Add property…`}),t.componentSet&&(0,U.jsx)(`option`,{value:`variant`,children:`Variant`}),(0,U.jsx)(`option`,{value:`boolean`,children:`Boolean`}),(0,U.jsx)(`option`,{value:`text`,children:`Text`}),(0,U.jsx)(`option`,{value:`swap`,children:`Instance swap`})]}),(0,U.jsx)(X.chevronDown,{})]})]})}var jE={content:`text`,visible:`boolean`,swap:`swap`};function ME({doc:e,node:t,main:n,onCommit:r}){let i=L(e,n);if(!i)return null;let a=[`content`,`visible`,`swap`].filter(e=>e===`content`?t.type===`text`:e!==`swap`||!!w(t)),o={content:`Text`,visible:`Visibility`,swap:`Swap`},s=(n,a)=>{if(a===`__new`){let a=kE(e,i);return r([{op:`prop`,id:i.id,name:a,type:jE[n]},{op:`bind`,id:t.id,[n]:a}],`Connect to ${a}`)}r([{op:`bind`,id:t.id,[n]:a||null}],a?`Connect to ${a}`:`Disconnect property`)};return(0,U.jsx)(nu,{title:`Component property`,children:(0,U.jsx)(`div`,{className:`comp-props`,children:a.map(e=>(0,U.jsxs)(`label`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:o[e]}),(0,U.jsxs)(`span`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:t.bind?.[e]??``,"aria-label":`${o[e]} property`,onChange:t=>s(e,t.target.value),children:[(0,U.jsx)(`option`,{value:``,children:`None`}),Object.entries(i.props??{}).filter(([,t])=>t.type===jE[e]).map(([e])=>(0,U.jsx)(`option`,{value:e,children:e},e)),(0,U.jsxs)(`option`,{value:`__new`,children:[`New `,SE[jE[e]],` property`]})]}),(0,U.jsx)(X.chevronDown,{})]})]},e))})})}function NE({doc:e,node:t,instId:n,onCommit:r,onSelect:i}){let a=e.nodes[n],o=a?.instanceOf?e.nodes[a.instanceOf]:void 0;if(!a||!o)return null;let s=(t.overridden??[]).filter(e=>!(e===`content`&&t.bind?.content)&&!(e===`hidden`&&t.bind?.visible)),c=t.id===n,l=!c&&t.type===`frame`&&!!t.instanceOf,u=Object.keys(a.overrides??{}).length,f=k(t.id)?.rel,p=f?f.split(`/`)[0]:o.id,m=ce(e,o.id)??o,h=b(o.id),g=!!e.removed?.[o.id];return(0,U.jsxs)(nu,{title:c?`Instance`:`In an instance`,action:(0,U.jsxs)(`span`,{className:`comp-actions`,children:[!h&&!g&&(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>i?.([p]),"aria-label":`Go to main component`,"data-tip":`Go to main component`,children:(0,U.jsx)(X.component,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>r([{op:`detach`,ids:[n]}],`Detach instance`),"aria-label":`Detach instance`,"data-tip":`Detach instance`,"data-kbd":`⌥⌘B`,children:(0,U.jsx)(X.detach,{})})]}),children:[(0,U.jsxs)(`p`,{className:`comp-hint`,children:[c?`Of ${d(m)}${h?`, from ${h.name} ${h.version}`:``}.`:`Part of ${d(a)}, an instance of ${d(m)}.`,l?` It is an instance itself, but its properties are set in the main component, not on this copy.`:``,` `,g?`Its main component was deleted. `:``,s.length?`Changed here:`:c&&u?`${u} layer${u>1?`s`:``} changed inside.`:g?``:`Follows the main component.`]}),s.length>0&&(0,U.jsx)(`ul`,{className:`comp-changes`,children:s.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{children:xE(e)}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>r([{op:`reset`,id:t.id,keys:[e]}],`Reset ${xE(e).toLowerCase()}`),"aria-label":`Reset ${xE(e)}`,"data-tip":`Reset to the main component`,children:(0,U.jsx)(X.undo,{})})]},e))}),c&&h&&(0,U.jsx)(`div`,{className:`comp-row one`,children:(0,U.jsx)(`button`,{className:`btn`,onClick:()=>r([{op:`adopt`,id:n}],`Bring into this file`),"data-tip":`Copy ${d(m)} into this file as its own component, to edit it; this file's instances of it move to the copy`,children:`Bring into this file`})}),c&&g&&(0,U.jsx)(`div`,{className:`comp-row one`,children:(0,U.jsx)(`button`,{className:`btn`,onClick:()=>r([{op:`restore`,id:n}],`Restore main component`),"data-tip":`Put ${d(m)} back on the canvas, beside this instance`,children:`Restore main component`})}),c&&u>0&&!h&&(0,U.jsxs)(`div`,{className:g?`comp-row one`:`comp-row`,children:[(0,U.jsx)(`button`,{className:`btn`,onClick:()=>r([{op:`reset`,id:n}],`Reset all changes`),"data-tip":`Put back everything this instance changed`,children:`Reset all changes`}),!g&&(0,U.jsx)(`button`,{className:`btn`,onClick:()=>r([{op:`push`,id:n}],`Push changes to main`),"data-tip":`Make this instance's changes the main component's, for every instance`,children:`Push changes to main`})]})]})}var PE=e=>e.length===2&&e.every(e=>/^(true|false)$/i.test(e)),FE=(e,t)=>typeof t==`string`?d(e.nodes[t]??{name:t}):t&&typeof t==`object`?t.icon.name:`None`;function IE({doc:e,inst:t,onCommit:n,onNotice:r}){return LE(e,t)?(0,U.jsx)(nu,{title:`Properties`,children:(0,U.jsx)(RE,{doc:e,inst:t,onCommit:n,onNotice:r})}):null}var LE=(e,t)=>{let n=ut(e,t.id);return ie(e,t.instanceOf).filter(e=>!n.has(e.name)).length};function RE({doc:e,inst:t,onCommit:n,onNotice:r}){let[i,a]=(0,H.useState)(null),o=ut(e,t.id),c=ie(e,t.instanceOf).filter(e=>!o.has(e.name));if(!c.length)return null;let l=(e,r,i=e)=>n([{op:`update`,id:t.id,set:{values:{[e]:r}}}],i),u=async(e,i)=>{try{let o=await zw(i);n([o.assetOp,{op:`update`,id:t.id,set:{values:{[e]:o.value}}}],`${e}: ${i.name}`),o.credit&&r?.(o.credit),a(null)}catch(e){r?.(e instanceof Error?e.message:`Couldn’t swap the icon`)}};return(0,U.jsx)(`div`,{className:`comp-props`,children:c.map(n=>{let r=s(e,t.id,n.name),o=t.values&&n.name in t.values?(0,U.jsx)(`button`,{className:`panel-btn`,"aria-label":`Reset ${n.name}`,"data-tip":`Back to the main component`,onClick:()=>l(n.name,null,`Reset ${n.name}`),children:(0,U.jsx)(X.undo,{})}):(0,U.jsx)(`span`,{});if(n.type===`variant`&&PE(n.values)){let e=String(r).toLowerCase()===`true`,t=n.values.find(t=>t.toLowerCase()===String(!e));return(0,U.jsxs)(`div`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:n.name}),(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n.name,className:`switch ${e?`on`:``}`,onClick:()=>l(n.name,t,`${n.name}: ${t}`),children:(0,U.jsx)(`span`,{})}),(0,U.jsx)(`span`,{})]},n.name)}if(n.type===`variant`)return(0,U.jsxs)(`label`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:n.name}),(0,U.jsxs)(`span`,{className:`select-wrap`,children:[(0,U.jsx)(`select`,{value:String(r??``),"aria-label":n.name,onChange:e=>l(n.name,e.target.value,`${n.name}: ${e.target.value}`),children:n.values.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(`span`,{})]},n.name);if(n.type===`boolean`){let e=r!==!1;return(0,U.jsxs)(`div`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:n.name}),(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n.name,className:`switch ${e?`on`:``}`,onClick:()=>l(n.name,!e,`${n.name}: ${e?`off`:`on`}`),children:(0,U.jsx)(`span`,{})}),o]},n.name)}if(n.type===`text`)return(0,U.jsxs)(`label`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:n.name}),(0,U.jsx)(`input`,{className:`text-in full`,defaultValue:String(r??``),spellCheck:!1,"aria-label":n.name,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&e.currentTarget.blur()},onBlur:e=>{let t=e.currentTarget.value;t!==r&&l(n.name,t,`${n.name}: ${t}`)}},String(r)),o]},n.name);let c=r!==void 0&&typeof r==`object`,d=(n.def?.preferred??[]).filter(e=>typeof e==`string`),f=c?[]:vE(e,t.id,d),p=yE(r,f);return(0,U.jsxs)(`div`,{className:`comp-prop-wrap`,children:[(0,U.jsxs)(`div`,{className:`comp-prop`,children:[(0,U.jsx)(`span`,{children:n.name}),c?(0,U.jsxs)(`button`,{className:`comp-swap ${i===n.name?`on`:``}`,"aria-expanded":i===n.name,onClick:()=>a(i===n.name?null:n.name),children:[(0,U.jsx)(`img`,{src:`/api/icons/svg?pack=${encodeURIComponent(r.icon.pack)}&name=${encodeURIComponent(r.icon.name)}`,alt:``}),(0,U.jsx)(`span`,{children:FE(e,r)}),(0,U.jsx)(X.chevronDown,{})]}):(0,U.jsxs)(`span`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:p,"aria-label":n.name,onChange:t=>l(n.name,t.target.value,`${n.name}: ${FE(e,t.target.value)}`),children:[!p&&(0,U.jsx)(`option`,{value:``,disabled:!0,children:`Choose…`}),f.map(t=>(0,U.jsx)(`option`,{value:t,children:FE(e,t)},t))]}),(0,U.jsx)(X.chevronDown,{})]}),o]}),c&&i===n.name&&(0,U.jsx)(`div`,{className:`comp-icons`,children:(0,U.jsx)(fE,{system:Ce(e),onPlace:e=>void u(n.name,e)})})]},n.name)})})}var zE=[`0.5x`,`0.75x`,`1x`,`1.5x`,`2x`,`3x`,`4x`,`512w`,`512h`],BE=[{value:`png`,label:`PNG`},{value:`jpg`,label:`JPG`},{value:`svg`,label:`SVG`},{value:`pdf`,label:`PDF`}],VE=/^(\d+(\.\d+)?x|\d+(\.\d+)?[wh])$/;function HE(e){let t=e.trim().toLowerCase().replace(/\s+/g,``).replace(/^(\d+(\.\d+)?)$/,`$1x`).replace(/^\.(\d)/,`0.$1`);return VE.test(t)&&parseFloat(t)>0?t:null}function UE(e){let t=e[e.length-1];if(!t)return{format:`png`,scale:`1x`};let n=t.scale?.endsWith(`x`)?Math.floor(parseFloat(t.scale))+1:e.length+1;return t.format===`png`||t.format===`jpg`?{format:t.format,scale:`${n}x`}:{format:t.format}}var WE={format:`png`,scale:`2x`};function GE(e){return e.map(e=>{let t=!!e.exports?.length;return{id:e.id,name:e.name,settings:t?e.exports:[WE],custom:t}})}function KE(e){return qE(GE(e).map(e=>e.id),void 0,[WE])}async function qE(e,t,n){let r=await fetch(`/api/export`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,...t?{settings:t}:{},...n?{fallback:n}:{}})});if(!r.ok)return(await r.json().catch(()=>({error:r.statusText}))).error??`Export failed`;let i=decodeURIComponent(r.headers.get(`x-nudge-filename`)??`export`),a=await r.blob(),o=document.createElement(`a`);return o.href=URL.createObjectURL(a),o.download=i.split(`/`).pop(),document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(o.href),1e4),null}function JE({nodes:e,apply:t,onNotice:n}){let r=JSON.stringify(e[0]?.exports??[]),i=e.every(e=>JSON.stringify(e.exports??[])===r)?e[0]?.exports??[]:Z,[a,o]=(0,H.useState)(!1),s=(e,n)=>t(e,()=>({exports:n.length?n:null})),c=(e,t)=>{if(i===Z)return;let n=i.map((n,r)=>{if(r!==e)return n;let i={...n,...t};return i.format===`svg`||i.format===`pdf`?delete i.scale:i.scale||=`1x`,i.suffix||delete i.suffix,i});s(`Export settings`,n)},l=e.length===1?`Export ${e[0].name}`:`Export ${e.length} layers`,u=async()=>{o(!0),n(null);try{let t=await qE(e.map(e=>e.id));t&&n(`Couldn’t export: ${t}`)}finally{o(!1)}};return(0,U.jsxs)(nu,{title:`Export`,action:(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Add export setting`,"data-tip":`Add export setting`,onClick:()=>s(`Add export setting`,i===Z?[UE([])]:[...i,UE(i)]),children:(0,U.jsx)(X.plus,{})}),children:[i===Z&&(0,U.jsx)(`p`,{className:`muted-note`,children:`Mixed export settings. Press + to replace them with one PNG at 1x.`}),i!==Z&&i.length>0&&(0,U.jsxs)(`div`,{className:`export-rows`,children:[i.map((e,t)=>{let n=e.format===`png`||e.format===`jpg`;return(0,U.jsxs)(`div`,{className:`export-row`,children:[n?(0,U.jsx)(`input`,{className:`text-in`,"aria-label":`Export scale`,list:`nudge-export-scales`,defaultValue:e.scale??`1x`,spellCheck:!1,onKeyDown:t=>{t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&(t.currentTarget.value=e.scale??`1x`,t.currentTarget.blur())},onBlur:n=>{let r=HE(n.currentTarget.value);r?r!==e.scale&&c(t,{scale:r}):n.currentTarget.value=e.scale??`1x`}}):(0,U.jsx)(`span`,{className:`export-fixed`,"data-tip":`${e.format.toUpperCase()} exports at 1x`,children:`1x`}),(0,U.jsx)(`input`,{className:`text-in`,"aria-label":`Export suffix`,placeholder:`Suffix`,defaultValue:e.suffix??``,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:n=>{let r=n.currentTarget.value;r!==(e.suffix??``)&&c(t,{suffix:r})}}),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsx)(`select`,{"aria-label":`Export format`,value:e.format,onChange:e=>c(t,{format:e.target.value}),children:BE.map(e=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove export setting`,"data-tip":`Remove export setting`,onClick:()=>s(`Remove export setting`,i.filter((e,n)=>n!==t)),children:(0,U.jsx)(X.minus,{})})]},`${t}-${e.format}-${e.scale}-${e.suffix}`)}),(0,U.jsx)(`datalist`,{id:`nudge-export-scales`,children:zE.map(e=>(0,U.jsx)(`option`,{value:e},e))})]}),(i===Z||i.length>0)&&(0,U.jsx)(`button`,{className:`btn block export-btn`,disabled:a,onClick:()=>void u(),children:a?`Exporting…`:l})]})}var YE=[[0,0],[.5,0],[1,0],[0,.5],[.5,.5],[1,.5],[0,1],[.5,1],[1,1]],XE=[`Top left`,`Top`,`Top right`,`Left`,`Center`,`Right`,`Bottom left`,`Bottom`,`Bottom right`],ZE=[.5,.75,1.5,2,3,4];function QE({doc:e,selection:t,boxes:n,onPreview:r,onCommit:i,onClose:a}){let[o,s]=(0,H.useState)([.5,.5]),[c,l]=(0,H.useState)(null),u=Vt(t.map(e=>n.get(e)).filter(e=>!!e));if(!u||t.some(t=>e.nodes[t]?.locked))return null;let d=e=>Math.round(e*100)/100,f=r=>{if(!(r>0)||r===1)return null;let i=u.w*r,a=u.h*r,s={x:u.x+(u.w-i)*o[0],y:u.y+(u.h-a)*o[1],w:i,h:a};return qn(e,n,t,u,s).ops},p=e=>{let t=f(e);r(null),t?.length&&i(t,`Scale`)},m=(e,t,n,i,a,o)=>(0,U.jsx)(Ql,{label:e,title:t,value:n,min:.01,digits:a,step:a?.1:1,suffix:o,onPreview:e=>r(e===null?null:f(i(e))),onCommit:e=>p(i(e))}),h=(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Close Scale`,"data-tip":`Close (back to Move)`,"data-kbd":`V`,onClick:a,children:(0,U.jsx)(X.close,{})});return(0,U.jsxs)(nu,{title:`Scale`,action:h,children:[(0,U.jsxs)(`div`,{className:`row2 labels`,children:[(0,U.jsx)(`span`,{children:`Width`}),(0,U.jsx)(`span`,{children:`Height`})]}),(0,U.jsxs)(`div`,{className:`row2`,children:[m(`W`,`Width (scales proportionally)`,d(u.w),e=>e/u.w,0),m(`H`,`Height (scales proportionally)`,d(u.h),e=>e/u.h,0)]}),(0,U.jsxs)(`div`,{className:`row2 labels`,children:[(0,U.jsx)(`span`,{children:`Scale`}),(0,U.jsx)(`span`,{children:`Anchor point`})]}),(0,U.jsxs)(`div`,{className:`row2 scale-row`,children:[(0,U.jsxs)(`div`,{className:`scale-factor`,children:[m(`×`,`Scale factor`,1,e=>e,2),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Scale presets`,"aria-haspopup":`menu`,"aria-expanded":!!c,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();l(c?null:{x:t.right,y:t.bottom+V(`--menu-gap`)})},children:(0,U.jsx)(X.chevronDown,{})})]}),(0,U.jsx)(`div`,{className:`anchor-box`,role:`radiogroup`,"aria-label":`Anchor point`,children:YE.map((e,t)=>(0,U.jsx)(`button`,{role:`radio`,"aria-checked":e[0]===o[0]&&e[1]===o[1],"aria-label":XE[t],"data-tip":XE[t],className:e[0]===o[0]&&e[1]===o[1]?`on`:``,onClick:()=>s(e)},t))})]}),c&&(0,U.jsx)(Gl,{x:c.x,y:c.y,alignRight:!0,onClose:()=>l(null),items:ZE.map(e=>({label:`${e}x`,onClick:()=>p(e)}))})]})}var $E={width:`Auto width`,height:`Auto height`,fixed:`Fixed size`};function eD(e,t){if(!e.length)return;let n=t(e[0]);return e.every(e=>JSON.stringify(t(e))===JSON.stringify(n))?n:Z}var tD=(e,t)=>{let n=t.parent?e.nodes[t.parent]:null;return!!n&&n.layout.mode!==`free`&&!t.absolute};function nD({doc:e,base:t,selection:n,boxes:r,onPreview:i,onCommit:a,onOpenBuild:o,onSelect:s,onNotice:c,scaleTool:l,onExitScale:u,textRange:d}){let f=n.map(t=>e.nodes[t]).filter(e=>!!e),p=e.styles.colors;e.styles.text;let m=(0,H.useCallback)((e,t=()=>!0)=>f.filter(t).map(t=>({op:`update`,id:t.id,set:e(t)})).filter(e=>e.set),[f]),h=(e,t,n,r=[])=>{let i=bf(r,m(t,n));i.length&&a(i,e)},g=(e,t)=>i(e?m(e,t):null),_=(0,H.useMemo)(()=>yd(e),[e.nodes,e.styles]);if(!f.length)return null;let v=f.filter(e=>e.type===`frame`),y=f.filter(e=>e.type===`text`),b=v.length===f.length,x=y.length===f.length,S=f.filter(e=>e.type===`shape`),C=S.length===f.length,w=f.every(e=>!(e.type===`frame`&&e.boolean)),T=f.filter(e=>e.type===`frame`||e.type===`shape`),E=T.length===f.length,D=T.filter(e=>e.type===`frame`||e.type===`shape`&&(e.shape.kind===`rect`||e.shape.kind===`polygon`||e.shape.kind===`path`)),O=D.length===f.length,k=e=>D.includes(e),A=(e,t)=>{let n=r.get(e.id),i=n&&(t===`w`?n.ow??n.w:n.oh??n.h);return(t===`w`?e.sizeX:e.sizeY)===`fixed`?e[t]:e.type===`text`&&t===`w`?Math.ceil(i??e[t]):Math.round(i??e[t])},j=eD(f,e=>!!e.lockRatio),M=(e,t,n)=>{if(e.type===`text`&&!e.lockRatio)return t===`h`?{h:n,sizeY:`fixed`,...e.sizeX===`hug`?{w:A(e,`w`),sizeX:`fixed`}:{}}:{w:n,sizeX:`fixed`,...e.sizeY===`fixed`?{}:{sizeY:`hug`}};if(!e.lockRatio)return t===`w`?{w:n,sizeX:`fixed`}:{h:n,sizeY:`fixed`};let r=Jn({w:A(e,`w`),h:A(e,`h`)},t,n);return{w:r.w,h:r.h,sizeX:`fixed`,sizeY:`fixed`}},N=f.some(t=>!tD(e,t)),P=f.filter(t=>gp(e,t)),F=t=>{let n=f.every(e=>e.type===`text`||e.type===`frame`&&e.layout.mode!==`free`||(t===`x`?e.sizeX:e.sizeY)===`hug`),r=f.every(t=>tD(e,t));return[{value:`fixed`,label:`Fixed`,title:`Fixed size`},{value:`hug`,label:`Hug`,title:`Hug contents`,disabled:!n},{value:`fill`,label:`Fill`,title:`Fill container (auto layout only)`,disabled:!r}]},I=(t,n)=>{let r=t===`x`?`sizeX`:`sizeY`,i=t===`x`?`w`:`h`,o=m(e=>n===`fixed`?{[r]:n,[i]:A(e,i)}:{[r]:n});if(n===`fill`)for(let n of new Set(f.map(e=>e.parent).filter(e=>!!e))){let a=e.nodes[n];a&&(t===`x`?a.sizeX:a.sizeY)===`hug`&&o.push({op:`update`,id:n,set:{[r]:`fixed`,[i]:A(a,i)}})}o.length&&a(o,`${t===`x`?`Width`:`Height`} ${n}`)},L=f.length===1?rD(f[0]):`${f.length} selected`;return(0,U.jsx)(vd.Provider,{value:_,children:(0,U.jsxs)(`aside`,{className:`panel props`,"data-keeps-text-editing":!0,children:[(0,U.jsx)(`div`,{className:`props-head`,children:(0,U.jsx)(`strong`,{children:L})}),f.length===1&&(0,U.jsx)(wE,{doc:e,node:f[0],onCommit:a,onSelect:s,onNotice:e=>c?.(e)},n[0]),(0,U.jsx)(hD,{count:f.length,onAlign:t=>{let i=jn(e,r,n,t);i.length&&a(i,`Align`)},onDistribute:t=>{let i=Mn(e,r,n,t);i.length&&a(i,`Distribute`)}}),f.length>1&&(Kc(e,n)||f.some(e=>e.type===`shape`||e.type===`frame`&&!!e.boolean))&&(()=>{let t=qc(e,n);return(0,U.jsxs)(nu,{title:`Boolean`,children:[(0,U.jsxs)(`div`,{className:`bool-ops`,role:`toolbar`,"aria-label":`Boolean operations`,children:[Vc.map(i=>(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":Bc[i.op],"data-tip":t??i.label,"data-kbd":t?void 0:i.kbd,disabled:!!t,onClick:()=>{let t=Jc(e,r,n,i.op);t&&a(t,Bc[i.op],[`bool`])},children:(0,U.jsx)(Uc,{op:i.op})},i.op)),!t&&(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":Yc.label,"data-tip":Yc.label,"data-kbd":Yc.kbd,onClick:()=>{let t=Xc(e,r,n);`ops`in t&&a(t.ops,Yc.label,[`flat`])},children:(0,U.jsx)(X.flatten,{})})]}),t&&(0,U.jsx)(`p`,{className:`muted-note`,children:t})]})})(),(0,U.jsxs)(nu,{title:`Position`,children:[N&&(0,U.jsxs)(`div`,{className:`row2`,children:[(0,U.jsx)(Ql,{label:`X`,title:`X position`,value:eD(f.filter(t=>!tD(e,t)),e=>e.x),onPreview:t=>g(t===null?null:()=>({x:t}),t=>!tD(e,t)),onCommit:t=>h(`X`,()=>({x:t}),t=>!tD(e,t))}),(0,U.jsx)(Ql,{label:`Y`,title:`Y position`,value:eD(f.filter(t=>!tD(e,t)),e=>e.y),onPreview:t=>g(t===null?null:()=>({y:t}),t=>!tD(e,t)),onCommit:t=>h(`Y`,()=>({y:t}),t=>!tD(e,t))})]}),w&&(0,U.jsx)(`div`,{className:`row2`,children:(0,U.jsx)(Ql,{label:(0,U.jsx)(X.rotate,{}),title:`Rotation`,suffix:`°`,digits:1,value:eD(f,e=>-(e.rotation??0)||0),onPreview:e=>g(e===null?null:()=>({rotation:-e})),onCommit:e=>h(`Rotation`,()=>({rotation:e%360?-e:null}))})}),P.length>0&&(0,U.jsxs)(`label`,{className:`check`,"data-tip":`Take it out of the auto layout flow (badges, floating buttons)`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:P.every(e=>!!e.absolute),onChange:t=>h(`Absolute position`,e=>{let n=r.get(e.id),i=e.parent?r.get(e.parent):void 0;return t.target.checked&&n&&i?{absolute:!0,x:Math.round(n.x-i.x),y:Math.round(n.y-i.y)}:{absolute:t.target.checked}},t=>gp(e,t))}),`Absolute position`]}),f.every(t=>t.parent&&(t.absolute||e.nodes[t.parent]?.layout?.mode===`free`))&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`row2 labels`,children:(0,U.jsx)(`span`,{children:`Constraints`})}),(0,U.jsx)(bp,{x:eD(f,e=>e.constraints?.x??`left`),y:eD(f,e=>e.constraints?.y??`top`),onChange:(e,t)=>h(t,t=>{let n=t.parent?r.get(t.parent):void 0,i=r.get(t.id);return{...i&&n?{x:Math.round(i.x-n.x),y:Math.round(i.y-n.y)}:{},constraints:xp(t,e,n)}})})]})]}),(()=>{let t=(0,U.jsxs)(U.Fragment,{children:[y.length===f.length&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`row2 labels`,children:(0,U.jsx)(`span`,{children:`Resizing`})}),(0,U.jsx)(eu,{icons:!0,label:`Resizing`,value:eD(f,e=>e.sizeY===`hug`?e.sizeX===`hug`?`width`:`height`:`fixed`),onChange:e=>h($E[e],t=>e===`width`?{sizeX:`hug`,sizeY:`hug`}:e===`height`?{...t.sizeX===`fill`?{}:{sizeX:`fixed`,w:A(t,`w`)},sizeY:`hug`}:{...t.sizeX===`fill`?{}:{sizeX:`fixed`,w:A(t,`w`)},sizeY:t.sizeY===`fill`?`fill`:`fixed`,h:A(t,`h`)}),options:[{value:`width`,label:(0,U.jsx)(X.autoWidth,{}),title:`Auto width`},{value:`height`,label:(0,U.jsx)(X.wrap,{}),title:`Auto height`},{value:`fixed`,label:(0,U.jsx)(X.fixedText,{}),title:`Fixed size`}]})]}),(0,U.jsxs)(`div`,{className:`row2 labels lockable`,children:[(0,U.jsx)(`span`,{children:`Width`}),(0,U.jsx)(`span`,{children:`Height`}),(0,U.jsx)(`span`,{})]}),(0,U.jsxs)(`div`,{className:`row2 lockable`,children:[(0,U.jsx)(Ql,{label:`W`,title:`Width`,value:eD(f,e=>A(e,`w`)),min:1,onPreview:e=>g(e===null?null:t=>M(t,`w`,e)),onCommit:e=>h(`Width`,t=>M(t,`w`,e))}),(0,U.jsx)(Ql,{label:`H`,title:`Height`,value:eD(f,e=>A(e,`h`)),min:1,onPreview:e=>g(e===null?null:t=>M(t,`h`,e)),onCommit:e=>h(`Height`,t=>M(t,`h`,e))}),(0,U.jsx)(`button`,{className:`icon-btn fit${j===!0?` on`:``}`,"aria-pressed":j===!0,"aria-label":j===!0?`Unlock aspect ratio`:`Lock aspect ratio`,"data-tip":j===!0?`Unlock aspect ratio`:`Lock aspect ratio`,onClick:()=>h(j===!0?`Unlock aspect ratio`:`Lock aspect ratio`,()=>({lockRatio:j!==!0||null})),children:(0,U.jsx)(X.ratio,{})})]}),(0,U.jsxs)(`div`,{className:`row2`,children:[(0,U.jsx)(eu,{value:eD(f,e=>e.sizeX),options:F(`x`),onChange:e=>I(`x`,e)}),(0,U.jsx)(eu,{value:eD(f,e=>e.sizeY),options:F(`y`),onChange:e=>I(`y`,e)})]})]}),i=v.some(e=>e.children.length)?(0,U.jsx)(`button`,{className:`icon-btn fit`,"data-tip":`Resize to fit`,"data-kbd":`⌥⇧⌘R`,"aria-label":`Resize to fit`,onClick:()=>{let t=Un(e,r,n);t.length&&a(t,`Resize to fit`)},children:(0,U.jsx)(X.fit,{})}):void 0;return b&&!v.some(e=>e.boolean)?(0,U.jsx)(iD,{frames:v,apply:h,preview:g,sizing:t,action:i,setMode:t=>{let n=v.flatMap(n=>n.layout.mode===t?[]:t===`free`?kn(e,r,n.id)??[]:n.layout.mode===`free`?On(e,r,n.id,t)??[]:[{op:`update`,id:n.id,set:{layout:{mode:t}}}]);n.length&&a(n,`Layout ${t}`)}}):(0,U.jsx)(nu,{title:`Layout`,children:t})})(),l?(0,U.jsx)(QE,{doc:e,selection:n,boxes:r,onPreview:i,onCommit:a,onClose:()=>u?.()}):(0,U.jsxs)(U.Fragment,{children:[e.system&&b&&!v.some(e=>e.boolean)&&(()=>{let t=eD(v,e=>e.theme??`auto`),n=t=>t.theme??e.system.theme,i=v.every(e=>n(e)===`light`)?`dark`:`light`;return(0,U.jsx)(nu,{title:`Theme`,action:(0,U.jsxs)(`button`,{className:`btn sm ghost`,"data-tip":`Copy beside it, in ${i}`,onClick:()=>{let t=yn(e,v.map(e=>e.id));t.ops.forEach((t,n)=>{if(t.op!==`create`)return;let a=t.tree;a.theme=i,a.name=`${a.name??`Frame`} — ${i===`dark`?`Dark`:`Light`}`;let o=v[n],s=r.get(o.id);if(t.parent!==null||!s)return;let c={x:s.x+s.w+80,y:s.y,w:s.w,h:s.h};e.roots.some(e=>{let t=r.get(e);return t&&e!==o.id&&t.x<c.x+c.w&&c.x<t.x+t.w&&t.y<c.y+c.h&&c.y<t.y+t.h})||(a.x=Math.round(c.x),a.y=Math.round(c.y))}),a(t.ops,i===`dark`?`Dark copy`:`Light copy`)},children:[(0,U.jsx)(X.plus,{}),i===`dark`?`Dark copy`:`Light copy`]}),children:(0,U.jsx)(eu,{value:t,options:[{value:`auto`,label:`Auto`,title:`Follow the canvas theme`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:e=>h(e===`auto`?`Theme: auto`:`Theme: ${e}`,()=>({theme:e===`auto`?null:e}),e=>e.type===`frame`)})})})(),(0,U.jsx)(nu,{title:`Appearance`,action:(0,U.jsx)(`span`,{className:`section-actions`,children:(0,U.jsx)(su,{label:`Layer blend`,layer:!0,value:eD(f,e=>e.blend),onPreview:e=>g(e===null?null:()=>({blend:e??null})),onPick:e=>h(`Layer blend: ${e?iu[e]:`Normal`}`,()=>({blend:e??null}))})}),children:(0,U.jsxs)(`div`,{className:`row2`,children:[(0,U.jsx)(Ql,{label:`Opacity`,title:`Opacity (1–9, 0)`,suffix:`%`,value:eD(f,e=>Math.round((e.opacity??1)*100)),min:0,max:100,onPreview:e=>g(e===null?null:()=>({opacity:e/100})),onCommit:e=>h(`Opacity`,()=>({opacity:e===100?null:e/100}))}),O&&(0,U.jsx)(ef,{doc:e,label:`R`,values:D.map(e=>e.radius),single:D.some(e=>e.type===`shape`&&e.shape.kind!==`rect`||e.type===`frame`&&!!e.boolean),onPreview:e=>g(e&&(t=>({radius:e(t.radius)})),k),onCommit:(e,t)=>h(e,e=>({radius:t(e.radius)}),k)},D.map(e=>e.id).join())]})}),C&&(0,U.jsx)(oD,{shapes:S,apply:h,preview:g}),v.length===1&&f.length===1&&v[0].boolean&&(0,U.jsx)(nu,{title:`Boolean`,children:(0,U.jsx)(eu,{value:v[0].boolean,onChange:e=>h(Bc[e],()=>({boolean:e,name:Bc[e]})),options:Vc.map(e=>({value:e.op,label:(0,U.jsx)(Uc,{op:e.op}),title:`${Bc[e.op]} · ${e.kbd}`}))})}),x&&(0,U.jsx)(gf,{texts:y,doc:e,base:t,apply:h,preview:g,commit:(e,t)=>a(e,t),range:d&&y.length===1&&y[0].id===d.id?d:void 0}),(E||x||f.every(e=>e.type===`vector`))&&(0,U.jsx)(op,{nodes:f,doc:e,apply:h,preview:g,commit:(e,t)=>a(e,t)}),E&&(0,U.jsx)(fp,{frames:T,doc:e,apply:h,preview:g,commit:(e,t)=>a(e,t)}),(0,U.jsx)(uD,{nodes:f,colors:p,apply:h,preview:g}),b&&(0,U.jsx)(pD,{frames:v,colors:p,apply:h,preview:g}),(0,U.jsx)(JE,{nodes:f,apply:h,onNotice:e=>c?.(e)},n.join()),v.length===1&&f.length===1&&v[0].parent===null&&(0,U.jsx)(Iw,{frame:v[0],doc:e,onCommit:a,onOpenTab:o})]})]})})}function rD(e){return Ut(e)?`Video`:Wt(e)?`Image`:e.type===`text`?`Text`:e.type===`vector`?`Icon`:e.type===`shape`?zc[e.shape.kind]:e.boolean?Bc[e.boolean]:e.componentSet?`Component set`:e.main?e.variant?`Variant`:`Component`:e.instanceOf?`Instance`:e.layout.mode===`free`&&e.parent&&e.sizeX===`hug`?`Group`:`Frame`}function iD({frames:e,apply:t,preview:n,setMode:r,sizing:i,action:a}){let o=eD(e,e=>e.layout.mode),s=hp(e),c=eD(e,e=>e.layout.gap),l=eD(e,e=>e.layout.alignMain===`between`),u=eD(e,e=>!!e.layout.wrap&&e.layout.mode===`row`),d=eD(e,e=>e.layout.gapCross??e.layout.gap),f=eD(e,e=>e.layout.pad),[p,m]=(0,H.useState)(!1),h=Array.isArray(f)?f:null,g=h&&h[0]===h[2]&&h[1]===h[3],_=(e,r)=>({commit:n=>t(`Padding ${e}`,e=>({layout:{pad:r(e.layout.pad,n)}})),prev:e=>n(e===null?null:t=>({layout:{pad:r(t.layout.pad,e)}}))}),v=_(`horizontal`,(e,t)=>[e[0],t,e[2],t]),y=_(`vertical`,(e,t)=>[t,e[1],t,e[3]]),b=(e,t)=>_(t,(t,n)=>t.map((t,r)=>r===e?n:t)),x=(e,t,n)=>_p(e.layout.mode,t,n),S=(t,n)=>e.every(e=>{let r=x(e,t,n);return e.layout.alignCross===r.cross&&(e.layout.alignMain===`between`||e.layout.alignMain===r.main)});return(0,U.jsxs)(nu,{title:`Layout`,action:a,children:[(0,U.jsxs)(`div`,{className:`layout-mode`,children:[(0,U.jsx)(eu,{value:o,onChange:r,options:[{value:`free`,label:(0,U.jsx)(X.layoutFree,{}),title:`Freeform (x/y) · position: absolute`},{value:`column`,label:(0,U.jsx)(X.layoutV,{}),title:`Vertical auto layout · flex-direction: column`},{value:`row`,label:(0,U.jsx)(X.layoutH,{}),title:`Horizontal auto layout · flex-direction: row`}]}),(0,U.jsx)(`button`,{className:`icon-btn fit wrap-toggle ${u===!0?`on`:``}`,disabled:o!==`row`,"aria-pressed":u===!0,"aria-label":`Wrap`,"data-tip":o===`row`?`Wrap onto new lines · flex-wrap: wrap`:`Wrap works with horizontal auto layout`,onClick:()=>t(u===!0?`No wrap`:`Wrap`,()=>({layout:{wrap:u!==!0}})),children:(0,U.jsx)(X.wrap,{})})]}),i,s&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`align-row`,children:[(0,U.jsx)(`div`,{className:`align-grid`,role:`grid`,"aria-label":`Align`,children:[0,1,2].map(e=>[0,1,2].map(n=>(0,U.jsx)(`button`,{className:S(n,e)?`on`:``,"data-tip":`Align ${[`top`,`middle`,`bottom`][e]} ${[`left`,`center`,`right`][n]}`,onClick:()=>t(`Align`,t=>{let r=x(t,n,e);return{layout:t.layout.alignMain===`between`?{alignCross:r.cross}:{alignMain:r.main,alignCross:r.cross}}}),children:(0,U.jsx)(`span`,{})},`${n}${e}`)))}),(0,U.jsxs)(`div`,{className:`gap-fields`,children:[(0,U.jsx)(Ql,{label:e.every(e=>e.layout.mode===`row`)?(0,U.jsx)(X.gapH,{}):(0,U.jsx)(X.gapV,{}),title:`Gap between items`,value:l===!0?void 0:c,min:0,disabled:l===!0,placeholder:`Auto`,onPreview:e=>n(e===null?null:()=>({layout:{gap:e}})),onCommit:e=>t(`Gap`,()=>({layout:{gap:e}}))}),u===!0&&(0,U.jsx)(Ql,{label:(0,U.jsx)(X.gapV,{}),title:`Gap between lines · row-gap`,value:d,min:0,onPreview:e=>n(e===null?null:()=>({layout:{gapCross:e}})),onCommit:e=>t(`Line gap`,()=>({layout:{gapCross:e}}))}),(0,U.jsxs)(`label`,{className:`check tight`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:l===!0,onChange:e=>t(`Space between`,()=>({layout:mp(e.target.checked)}))}),`Space between`]})]})]}),(0,U.jsx)(`div`,{className:`row2 labels`,children:(0,U.jsx)(`span`,{children:`Padding`})}),(0,U.jsxs)(`div`,{className:`pad-grid`,children:[!p&&(g||!h)?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padH,{}),title:`Horizontal padding`,value:h?h[1]:Z,min:0,onPreview:v.prev,onCommit:v.commit}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padV,{}),title:`Vertical padding`,value:h?h[0]:Z,min:0,onPreview:y.prev,onCommit:y.commit})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padLeft,{}),title:`Left padding`,value:h?.[3]??Z,min:0,onPreview:b(3,`left`).prev,onCommit:b(3,`left`).commit}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padTop,{}),title:`Top padding`,value:h?.[0]??Z,min:0,onPreview:b(0,`top`).prev,onCommit:b(0,`top`).commit})]}),(0,U.jsx)(`button`,{className:`icon-btn fit pad-toggle ${p||h&&!g?`on`:``}`,"aria-pressed":p,"aria-label":`Individual padding`,"data-tip":p?`Horizontal & vertical padding`:`Individual padding`,onClick:()=>m(!p),children:(0,U.jsx)(X.padAll,{})}),(p||h&&!g)&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padRight,{}),title:`Right padding`,value:h?.[1]??Z,min:0,onPreview:b(1,`right`).prev,onCommit:b(1,`right`).commit}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padBottom,{}),title:`Bottom padding`,value:h?.[2]??Z,min:0,onPreview:b(2,`bottom`).prev,onCommit:b(2,`bottom`).commit})]})]})]}),(0,U.jsxs)(`label`,{className:`check`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:e.every(e=>e.clip),onChange:e=>t(`Clip content`,()=>({clip:e.target.checked}))}),`Clip content`]})]})}function aD(e){let t={kind:`ellipse`};return e.start&&(t.start=e.start),e.sweep!==void 0&&e.sweep<1&&(t.sweep=e.sweep),e.ratio&&(t.ratio=e.ratio),t}function oD({shapes:e,apply:t,preview:n}){if(new Set(e.map(e=>e.shape.kind)).size!==1)return null;let r=e[0].shape.kind,i=e=>t=>({shape:e(t.shape)}),a=(r,a,o,s,c,l={})=>(0,U.jsx)(Ql,{label:r,title:a,value:eD(e,e=>s(e.shape)),min:l.min,max:l.max,suffix:l.suffix,digits:l.digits,onPreview:e=>n(e===null?null:i(t=>c(t,e))),onCommit:e=>t(a,i(t=>c(t,e)))},o);if(r===`ellipse`){let e=aD;return(0,U.jsxs)(nu,{title:`Arc`,children:[(0,U.jsxs)(`div`,{className:`row3 labels`,children:[(0,U.jsx)(`span`,{children:`Start`}),(0,U.jsx)(`span`,{children:`Sweep`}),(0,U.jsx)(`span`,{children:`Ratio`})]}),(0,U.jsxs)(`div`,{className:`row3`,children:[a(``,`Arc start`,`start`,e=>e.start??0,(t,n)=>e({...t,start:(n%360+360)%360}),{suffix:`°`,digits:1}),a(``,`Arc sweep`,`sweep`,e=>Math.round((e.sweep??1)*1e3)/10,(t,n)=>e({...t,sweep:Math.max(.1,n)/100}),{min:.1,max:100,suffix:`%`,digits:1}),a(``,`Inner radius ratio`,`ratio`,e=>Math.round((e.ratio??0)*1e3)/10,(t,n)=>e({...t,ratio:Math.min(99,n)/100}),{min:0,max:99,suffix:`%`,digits:1})]})]})}return r===`polygon`?(0,U.jsx)(nu,{title:`Polygon`,children:(0,U.jsx)(`div`,{className:`row2`,children:a(`Count`,`Point count`,`count`,e=>e.count,(e,t)=>({kind:`polygon`,count:Math.round(t)}),{min:3,max:60})})}):null}var sD=[{value:`drop`,label:`Drop shadow`},{value:`inner`,label:`Inner shadow`},{value:`layerBlur`,label:`Layer blur`},{value:`backdropBlur`,label:`Background blur`},{value:`shader`,label:`Shader`}],cD=e=>e.type===`shadow`?e.inset?`inner`:`drop`:e.type,lD=(e,t)=>{let n=t?.visible===!1?{visible:!1}:{};if(e===`shader`)return{type:`shader`,shader:t?.type===`shader`?t.shader:structuredClone(be[0]),...n};let r=t?.type===`layerBlur`||t?.type===`backdropBlur`?t.radius:t?.type===`shadow`?t.blur:4;if(e===`layerBlur`||e===`backdropBlur`)return{type:e,radius:e===`backdropBlur`&&!t?20:r,...n};let i=t?.type===`shadow`?t:{x:0,y:4,blur:r,spread:0,color:qe};return{type:`shadow`,x:i.x,y:i.y,blur:i.blur,spread:i.spread,color:i.color,...e===`inner`?{inset:!0}:{},...n}};function uD({nodes:e,colors:t,apply:n,preview:r}){let i=eD(e,e=>e.effects??[]),[a,o]=(0,H.useState)(null),s=i===Z||i===void 0?null:i,c=Ff(s?.length??0,JSON.stringify(s??[])),l=Mf({count:s?.length??0,reversed:!1,movedTo:c.movedTo,onMove:(e,t)=>{c.move(e,t,JSON.stringify(s??[]),JSON.stringify(Ef(s??[],e,t))),u(`Reorder effects`,n=>Ef(n,e,t))},onSettled:(e,t)=>o(n=>Df(n,e,t))}),u=(e,t)=>n(e,e=>{let n=t([...e.effects??[]]);return{effects:n.length?n:null}}),d=e=>r(e?t=>{let n=e([...t.effects??[]]);return{effects:n.length?n:null}}:null),f=(e,t)=>n=>n.map((n,r)=>r===e?t:n),p=e.every(e=>e.type===`text`),m=e.some(e=>e.type===`frame`&&(e.fills??[]).some(e=>e.type===`image`&&e.visible!==!1));return(0,U.jsxs)(nu,{title:`Effects`,action:(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Add effect`,"data-tip":`Add effect`,onClick:()=>{u(`Add effect`,e=>[...s?e:[],lD(`drop`)]),o(s?s.length:0)},children:(0,U.jsx)(X.plus,{})}),children:[i===Z&&(0,U.jsx)(`p`,{className:`muted-note`,children:`Mixed effects. Press + to replace them with one drop shadow.`}),(0,U.jsx)(`div`,{className:`reorder-list`,ref:l.rows,children:s?.map((e,n)=>{let r=e.type===`shadow`?e:null,i=(e,t,i)=>r&&(0,U.jsx)(Ql,{label:e,title:{x:`X offset`,y:`Y offset`,blur:`Blur`,spread:`Spread`}[t],value:r[t],min:i,onPreview:e=>d(e===null?null:f(n,{...r,[t]:e})),onCommit:e=>u(`Shadow ${t}`,f(n,{...r,[t]:e}))});return(0,U.jsxs)(`div`,{"data-reorder-row":n,className:`fx-row reorder-row ${e.visible===!1?`off`:``} ${l.dropClassOf(n)??``}`,children:[s.length>1&&(0,U.jsx)(`button`,{className:`reorder-grip`,"aria-label":`Reorder effect`,"data-tip":`Drag to reorder`,...l.gripProps(n),children:(0,U.jsx)(X.grip,{})}),(0,U.jsxs)(`div`,{className:`fx-head`,children:[(0,U.jsx)(`button`,{className:`fx-toggle`,"aria-expanded":a===n,onClick:()=>o(a===n?null:n),"data-tip":`Effect settings`,children:(0,U.jsx)(`span`,{className:`fx-swatch ${cD(e)}`})}),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsx)(`select`,{value:cD(e),"aria-label":`Effect type`,onChange:t=>u(`Effect type`,f(n,lD(t.target.value,e))),children:sD.filter(t=>(!p||t.value!==`inner`)&&(t.value!==`shader`||m||e.type===`shader`)).map(e=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":e.visible===!1?`Show effect`:`Hide effect`,"data-tip":e.visible===!1?`Show effect`:`Hide effect`,onClick:()=>u(e.visible===!1?`Show effect`:`Hide effect`,f(n,{...e,visible:e.visible===!1&&void 0})),children:e.visible===!1?(0,U.jsx)(X.eyeClosed,{}):(0,U.jsx)(X.eye,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove effect`,"data-tip":`Remove effect`,onClick:()=>{c.remove(n),u(`Remove effect`,e=>e.filter((e,t)=>t!==n)),o(null)},children:(0,U.jsx)(X.minus,{})})]}),a===n&&(r?(0,U.jsxs)(`div`,{className:`fx-body`,children:[(0,U.jsxs)(`div`,{className:`row2`,children:[i(`X`,`x`),i(`Y`,`y`)]}),(0,U.jsxs)(`div`,{className:`row2`,children:[i(`Blur`,`blur`,0),!p&&i(`Spread`,`spread`)]}),(0,U.jsx)(tu,{value:r.color,styles:t,onPreview:e=>d(e===null?null:f(n,{...r,color:e})),onCommit:e=>u(`Shadow color`,f(n,{...r,color:e}))})]}):e.type===`shader`?(0,U.jsx)(dD,{shader:e.shader,colors:t,hasImage:m,onClose:()=>o(null),onPreview:t=>d(t?f(n,{...e,shader:t}):null),onCommit:(t,r)=>u(r,f(n,{...e,shader:t}))}):e.type!==`shadow`&&(0,U.jsx)(`div`,{className:`fx-body`,children:(0,U.jsx)(Ql,{label:`Blur`,title:`Blur radius`,value:e.radius,min:0,onPreview:t=>d(t===null?null:f(n,{...e,radius:t})),onCommit:t=>u(`Blur`,f(n,{...e,radius:t}))})}))]},c.keys[n]??`i${n}`)})})]})}function dD({shader:e,colors:t,hasImage:n,onPreview:r,onCommit:i,onClose:a}){let[o,s]=(0,H.useState)(!1);return(0,U.jsxs)(mu,{title:`Shader effect`,onClose:a,width:248,className:`shader-effect`,children:[!n&&(0,U.jsx)(`p`,{className:`muted-note`,children:`Shader effects draw over an image fill. Add an image to this frame to see it.`}),(0,U.jsxs)(`button`,{className:`cp-shader-menu ${o?`open`:``}`,"aria-expanded":o,onClick:()=>s(!o),children:[(0,U.jsx)(`span`,{className:`cp-shader-thumb fx-effect-icon`,children:(0,U.jsx)(X.shader,{})}),(0,U.jsx)(`span`,{children:e.name}),(0,U.jsx)(X.chevronDown,{})]}),o?(0,U.jsx)(`div`,{className:`cp-shaders`,role:`list`,children:be.map(t=>(0,U.jsxs)(`button`,{role:`listitem`,className:`cp-shader ${t.name===e.name?`on`:``}`,onMouseEnter:()=>r(t),onMouseLeave:()=>r(null),onClick:()=>{s(!1),i(structuredClone(t),`Shader effect: ${t.name}`)},children:[(0,U.jsx)(`span`,{className:`cp-shader-thumb fx-effect-icon`,children:(0,U.jsx)(X.shader,{})}),(0,U.jsx)(`span`,{children:t.name})]},t.name))}):(0,U.jsx)(pp,{shader:e,colors:t,onPreview:r,onCommit:(e,t)=>i(e,t)})]})}var fD={grid:{type:`grid`,size:10,color:le},columns:{type:`columns`,count:5,gutter:20,margin:0,align:`stretch`,color:le},rows:{type:`rows`,count:5,gutter:20,margin:0,align:`stretch`,color:le}};function pD({frames:e,colors:t,apply:n,preview:r}){let i=eD(e,e=>e.grids??[]),[a,o]=(0,H.useState)(null),s=i===Z||i===void 0?null:i,c=Ff(s?.length??0),l=(e,t)=>n(e,e=>{let n=t([...e.grids??[]]);return{grids:n.length?n:null}}),u=e=>r(e?t=>{let n=e([...t.grids??[]]);return{grids:n.length?n:null}}:null),d=(e,t)=>n=>n.map((n,r)=>r===e?t:n);return(0,U.jsxs)(nu,{title:`Layout grid`,action:(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Add layout grid`,"data-tip":`Add layout grid`,onClick:()=>{l(`Add layout grid`,e=>[...s?e:[],fD.grid]),o(s?s.length:0)},children:(0,U.jsx)(X.plus,{})}),children:[i===Z&&(0,U.jsx)(`p`,{className:`muted-note`,children:`Mixed grids. Press + to replace them with a 10px grid.`}),s?.map((e,n)=>{let r=(t,r,i,a)=>(0,U.jsx)(Ql,{label:t,title:a,value:e[r],min:i,onPreview:t=>u(t===null?null:d(n,{...e,[r]:t})),onCommit:t=>l(`Grid ${r}`,d(n,{...e,[r]:t}))}),i=e.type===`grid`?`Grid (${e.size}px)`:`${e.count} ${e.type===`columns`?`columns`:`rows`}`;return(0,U.jsxs)(`div`,{className:`fx-row ${e.visible===!1?`off`:``}`,children:[(0,U.jsxs)(`div`,{className:`fx-head`,children:[(0,U.jsx)(`button`,{className:`fx-toggle`,"aria-expanded":a===n,onClick:()=>o(a===n?null:n),"data-tip":`Grid settings`,children:(0,U.jsx)(X.grid,{})}),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:e.type,"aria-label":i,onChange:t=>l(`Grid type`,d(n,{...fD[t.target.value],color:e.color,...e.visible===!1?{visible:!1}:{}})),children:[(0,U.jsx)(`option`,{value:`grid`,children:`Grid`}),(0,U.jsx)(`option`,{value:`columns`,children:`Columns`}),(0,U.jsx)(`option`,{value:`rows`,children:`Rows`})]}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":e.visible===!1?`Show grid`:`Hide grid`,"data-tip":e.visible===!1?`Show grid`:`Hide grid`,onClick:()=>l(e.visible===!1?`Show grid`:`Hide grid`,d(n,{...e,visible:e.visible===!1&&void 0})),children:e.visible===!1?(0,U.jsx)(X.eyeClosed,{}):(0,U.jsx)(X.eye,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Remove grid`,"data-tip":`Remove grid`,onClick:()=>{c.remove(n),l(`Remove layout grid`,e=>e.filter((e,t)=>t!==n)),o(null)},children:(0,U.jsx)(X.minus,{})})]}),a===n&&(0,U.jsxs)(`div`,{className:`fx-body`,children:[e.type===`grid`?r(`Size`,`size`,1,`Grid size`):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`row2`,children:[r(`Count`,`count`,1,e.type===`columns`?`Columns`:`Rows`),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:e.align,"aria-label":`Type`,onChange:t=>{let r=t.target.value;l(`Grid type`,d(n,{...e,align:r,...r!==`stretch`&&!e.size?{size:64}:{}}))},children:[(0,U.jsx)(`option`,{value:`stretch`,children:`Stretch`}),(0,U.jsx)(`option`,{value:`start`,children:e.type===`columns`?`Left`:`Top`}),(0,U.jsx)(`option`,{value:`center`,children:`Center`}),(0,U.jsx)(`option`,{value:`end`,children:e.type===`columns`?`Right`:`Bottom`})]}),(0,U.jsx)(X.chevronDown,{})]})]}),(0,U.jsxs)(`div`,{className:`row2`,children:[e.align===`stretch`?r(`Margin`,`margin`,0,`Margin`):r(e.type===`columns`?`Width`:`Height`,`size`,1,e.type===`columns`?`Column width`:`Row height`),r(`Gutter`,`gutter`,0,`Gutter`)]}),e.align!==`stretch`&&e.align!==`center`&&r(`Offset`,`margin`,0,`Offset`)]}),(0,U.jsx)(rp,{value:e.color,colors:t,onPreview:t=>u(t===null?null:d(n,{...e,color:t})),onCommit:t=>l(`Grid color`,d(n,{...e,color:t}))})]})]},c.keys[n]??`i${n}`)})]})}var mD=[{edge:`left`,icon:`alignLeft`,tip:`Align left`,kbd:`⌥A`},{edge:`hcenter`,icon:`alignHCenter`,tip:`Align horizontal centers`,kbd:`⌥H`},{edge:`right`,icon:`alignRight`,tip:`Align right`,kbd:`⌥D`},{edge:`top`,icon:`alignTop`,tip:`Align top`,kbd:`⌥W`},{edge:`vcenter`,icon:`alignVCenter`,tip:`Align vertical centers`,kbd:`⌥V`},{edge:`bottom`,icon:`alignBottom`,tip:`Align bottom`,kbd:`⌥S`}];function hD({count:e,onAlign:t,onDistribute:n}){return(0,U.jsxs)(`div`,{className:`align-bar`,role:`toolbar`,"aria-label":`Alignment`,children:[mD.map(n=>{let r=X[n.icon];return(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":n.tip,"data-tip":e>1?n.tip:`${n.tip} to parent`,"data-kbd":n.kbd,onClick:()=>t(n.edge),children:(0,U.jsx)(r,{})},n.edge)}),(0,U.jsx)(`span`,{className:`align-sep`}),(0,U.jsx)(`button`,{className:`icon-btn fit`,disabled:e<3,"aria-label":`Distribute horizontal spacing`,"data-tip":`Distribute horizontal spacing`,"data-kbd":`⌃⌥H`,onClick:()=>n(`x`),children:(0,U.jsx)(X.distH,{})}),(0,U.jsx)(`button`,{className:`icon-btn fit`,disabled:e<3,"aria-label":`Distribute vertical spacing`,"data-tip":`Distribute vertical spacing`,"data-kbd":`⌃⌥V`,onClick:()=>n(`y`),children:(0,U.jsx)(X.distV,{})})]})}function gD({doc:e,base:t,ids:n,at:i,boxes:a,onCommit:o,onPreview:s,onAsk:c,onOpenPanel:l,onCrop:u,cropLabel:d}){let[f,p]=(0,H.useState)(null),m=kl(),h=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{let e=h.current,t=e?.offsetParent;if(!e||!t)return;let n=V(`--gap`);e.style.left=`${Math.max(n,Math.min(i.x,t.clientWidth-e.offsetWidth-n))}px`;let r=(parseFloat(getComputedStyle(t).getPropertyValue(`--covered-top`))||V(`--canvas-top`))+n,a=i.y-e.offsetHeight-n;e.style.top=`${a>=r?a:i.y+i.h+n}px`});let g=n.map(t=>e.nodes[t]).filter(e=>!!e),_=g.every(e=>e.type===`text`)?g:[],v=g.every(e=>e.type===`frame`)?g:[],b=g.every(e=>e.type===`vector`)?g:[],x=g.every(e=>e.type===`shape`)?g:[],S=g.every(e=>e.type===`frame`||e.type===`shape`)?g:[],C=S.length>0&&S.every(e=>e.type===`shape`&&!r(e.shape)),w=!C&&S.every(e=>e.type===`frame`?!Ut(e):e.shape.kind!==`line`),T=v.length&&v.every(e=>Ut(e))?v:[],E=g.length===1&&g[0].type===`frame`&&g[0].instanceOf&&LE(e,g[0])?g[0]:null,D=!C&&S.every(e=>e.type===`frame`||e.shape.kind===`rect`||e.shape.kind===`polygon`||e.shape.kind===`path`),O=S.some(e=>e.type===`shape`&&e.shape.kind!==`rect`||e.type===`frame`&&!!e.boolean),k=x.length&&x.every(e=>e.shape.kind===x[0].shape.kind)?x[0].shape.kind:null,A=v.map(t=>t.children.map(t=>e.nodes[t]).filter(e=>e?.type===`text`)),j=A.length&&A.every(e=>e.length===1)?A.map(e=>e[0]):[],M=(e,t)=>{if(!e.length)return;let n=t(e[0]);return e.every(e=>JSON.stringify(t(e))===JSON.stringify(n))?n:Z},N=(t,n)=>t[n]??(t.style?e.styles.text[t.style.slice(1)]?.[n]:void 0),P=t=>typeof t==`string`?t.startsWith(`$`)?e.styles.colors[t.slice(1)]??`#000000`:t:`transparent`,F=(e,t)=>e.flatMap(e=>{let n=t(e);return n?[{op:`update`,id:e.id,set:n}]:[]}),I=(e,t,n)=>{s(null),o(F(e,n),t)},L=(e,t)=>s(t?F(e,t):null),ee=n=>r=>{let i=t?.nodes[r.id]??r;return Bn(e,r.id,dt(n,{fontSize:N(i,`fontSize`)??16,lineHeight:N(i,`lineHeight`),letterSpacing:N(i,`letterSpacing`)}))},R=e=>t=>{let n=t.currentTarget.getBoundingClientRect();p(f?.kind===e?null:{kind:e,at:{left:n.left,top:n.bottom+V(`--gap`)}})},ne=()=>{p(null),s(null)},re=e=>({onClick:R(e),"aria-expanded":f?.kind===e}),ie=e=>t=>{let n=Lf(t),r=[...t.fills??[]];return r[n]=e(r[n]),{fills:r}},ae=(e,t)=>ie(n=>{let{[e]:r,...i}=n;return t?i:{...i,[e]:!1}}),oe=e=>t=>({stroke:{color:fe,width:1,...t.stroke,...e}}),se=t=>{if(t.type===`solid`)return{background:P(t.color)};if(t.type===`linear`||t.type===`radial`)return{background:ke(t,P)};if(t.type===`shader`)return{background:`var(--field)`};let n=e.assets[t.asset];return n?{background:`center / cover url("/design/${n.file}")`}:{background:`var(--field)`}},ce=te(e),le=t=>{if(!ce.length)return null;let n=M(t,e=>e.style??``);return(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{className:`sel-style`,value:n===Z?`~`:n,"aria-label":`Text style`,"data-tip":`Text style`,onChange:n=>{let r=n.target.value;r===``?I(t,`Detach style`,t=>Bn(e,t.id,{fontSize:N(t,`fontSize`)??16})):I(t,`Text style`,()=>({style:r,...Object.fromEntries(zn.map(e=>[e,null]))}))},children:[n===Z&&(0,U.jsx)(`option`,{value:`~`,disabled:!0,children:`Mixed`}),(0,U.jsx)(`option`,{value:``,children:`No style`}),ce.map(e=>(0,U.jsx)(`option`,{value:`$${e}`,children:e},e))]}),(0,U.jsx)(X.chevronDown,{})]})},ue=[];if(_.length){let t=_[0];ue.push((0,U.jsxs)(`div`,{className:`sel-mod`,children:[le(_),(0,U.jsx)(`div`,{className:`sel-font`,children:(0,U.jsx)(Jd,{value:M(_,e=>N(e,`fontFamily`)??`Pretendard`),doc:e,onPick:e=>I(_,`Font`,ee({fontFamily:e})),onPreview:e=>L(_,e===null?null:ee({fontFamily:e}))})}),(()=>{let e=Xd(N(t,`fontWeight`)??400,N(t,`fontStyle`));return(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:e,"aria-label":`Font style`,"data-tip":`Font style`,onChange:e=>I(_,`Font style`,ee(Qd(e.target.value))),children:[!Yd.some(([t])=>t===e)&&(0,U.jsx)(`option`,{value:e,children:e.replace(`i`,` Italic`)}),Yd.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))]}),(0,U.jsx)(X.chevronDown,{})]})})(),(0,U.jsx)(`div`,{className:`sel-num`,"data-tip":`Font size`,children:(0,U.jsx)(Ql,{label:``,title:`Font size`,value:M(_,e=>N(e,`fontSize`)??16),min:1,onPreview:e=>L(_,e===null?null:ee({fontSize:e})),onCommit:e=>I(_,`Font size`,ee({fontSize:e}))})}),(0,U.jsx)(`button`,{className:`sel-swatch`,"aria-label":`Text color`,"data-tip":`Text color`,...re(`text-color`),children:(0,U.jsx)(`span`,{style:{background:P(M(_,e=>N(e,`color`)??`#000000`))}})})]},`type`),(0,U.jsx)(`div`,{className:`sel-mod`,children:[[`left`,X.textLeft,`Align left`],[`center`,X.textCenter,`Align center`],[`right`,X.textRight,`Align right`]].map(([e,t,n])=>{let r=M(_,e=>N(e,`textAlign`)??`left`)===e;return(0,U.jsx)(`button`,{className:r?`on`:``,"aria-label":n,"data-tip":n,"aria-pressed":r,onClick:()=>I(_,`Text align`,ee({textAlign:e===`left`?null:e})),children:(0,U.jsx)(t,{})},e)})},`align`))}if(v.length&&j.length&&ue.push((0,U.jsxs)(`div`,{className:`sel-mod`,children:[le(j)??(0,U.jsx)(`span`,{className:`sel-label`,"aria-hidden":!0,children:(0,U.jsx)(X.text,{})}),(0,U.jsx)(`div`,{className:`sel-num`,"data-tip":`Text size`,children:(0,U.jsx)(Ql,{label:``,title:`Text size`,value:M(j,e=>N(e,`fontSize`)??16),min:1,onPreview:e=>L(j,e===null?null:ee({fontSize:e})),onCommit:e=>I(j,`Font size`,ee({fontSize:e}))})}),(0,U.jsx)(`button`,{className:`sel-swatch`,"aria-label":`Text color`,"data-tip":`Text color`,...re(`text-color`),children:(0,U.jsx)(`span`,{style:{background:P(M(j,e=>N(e,`color`)??`#000000`))}})})]},`inner`)),S.length&&!C){let e=w?M(S,e=>e.fills?.[0]??null):void 0,t=v.length>0&&v.every(e=>e.layout.mode!==`free`&&!e.boolean);ue.push((0,U.jsxs)(`div`,{className:`sel-mod`,children:[w&&(0,U.jsx)(`button`,{className:`sel-swatch`,"aria-label":`Fill`,"data-tip":`Fill`,...re(`fill`),children:(0,U.jsx)(`span`,{className:e===null?`none`:``,style:e&&e!==Z?se(e):void 0})}),(0,U.jsx)(`button`,{"aria-label":`Stroke`,"data-tip":`Stroke`,className:S.some(e=>e.stroke)?`on-soft`:``,...re(`stroke`),children:(0,U.jsx)(X.strokeWeight,{})}),D&&(0,U.jsx)(`button`,{"aria-label":`Corner radius`,"data-tip":`Corner radius`,...re(`radius`),children:(0,U.jsx)(X.radius,{})}),t&&(0,U.jsx)(`button`,{"aria-label":`Padding`,"data-tip":`Padding`,...re(`pad`),children:(0,U.jsx)(X.padAll,{})}),u&&(0,U.jsx)(`button`,{"aria-label":d??`Crop image`,"data-tip":d??`Crop image`,onClick:u,children:(0,U.jsx)(X.crop,{})})]},`paint`))}if(T.length){let e=M(T,e=>e.fills[Lf(e)].fit);ue.push((0,U.jsxs)(`div`,{className:`sel-mod sel-video`,children:[T.length===1&&(0,U.jsx)(ep,{id:T[0].id,index:Lf(T[0])}),(0,U.jsx)($f,{value:typeof e==`string`?e:``,onChange:e=>I(T,`Video fit`,ie(t=>({...t,fit:e})))}),(0,U.jsx)(`button`,{"aria-label":`Playback`,"data-tip":`Playback: autoplay, loop, sound`,...re(`video`),children:(0,U.jsx)(X.sliders,{})})]},`video`))}if(E&&ue.push((0,U.jsx)(`div`,{className:`sel-mod`,children:(0,U.jsx)(`button`,{"aria-label":`Properties`,"data-tip":`Properties`,...re(`props`),children:(0,U.jsx)(X.instance,{})})},`props`)),k===`ellipse`&&ue.push((0,U.jsx)(`div`,{className:`sel-mod`,children:(0,U.jsx)(`button`,{"aria-label":`Arc`,"data-tip":`Arc`,className:x.some(e=>{let t=e.shape;return!!t.ratio||(t.sweep??1)<1})?`on-soft`:``,...re(`arc`),children:(0,U.jsx)(X.arc,{})})},`arc`)),k===`polygon`){let e=e=>()=>({shape:{kind:`polygon`,count:Math.round(e)}});ue.push((0,U.jsx)(`div`,{className:`sel-mod`,children:(0,U.jsx)(`div`,{className:`sel-num`,"data-tip":`Point count`,children:(0,U.jsx)(Ql,{label:(0,U.jsx)(X.polygon,{}),title:`Point count`,value:M(x,e=>e.shape.kind===`polygon`?e.shape.count:3),min:3,max:60,onPreview:t=>L(x,t===null?null:e(t)),onCommit:t=>I(x,`Point count`,e(t))})})},`count`))}if(C){let e=M(S,e=>e.stroke?.cap??`none`);ue.push((0,U.jsxs)(`div`,{className:`sel-mod`,children:[(0,U.jsx)(`button`,{className:`sel-swatch`,"aria-label":`Stroke color`,"data-tip":`Stroke color`,...re(`stroke-color`),children:(0,U.jsx)(`span`,{className:S.every(e=>!e.stroke)?`none`:``,style:{background:P(M(S,e=>e.stroke?.color??`transparent`))}})}),(0,U.jsx)(`div`,{className:`sel-num`,"data-tip":`Stroke weight`,children:(0,U.jsx)(Ql,{label:(0,U.jsx)(X.strokeWeight,{}),title:`Stroke weight`,value:M(S,e=>e.stroke?.width??0),min:0,digits:2,onPreview:e=>L(S,e===null?null:oe({width:e})),onCommit:e=>I(S,`Stroke weight`,e===0?()=>({stroke:null}):oe({width:e}))})}),(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{value:e===Z?``:e,"aria-label":`Stroke caps`,"data-tip":`Stroke caps`,onChange:e=>I(S,`Stroke caps`,oe({cap:e.target.value===`none`?void 0:e.target.value})),children:[e===Z&&(0,U.jsx)(`option`,{value:``,children:`Mixed`}),(0,U.jsx)(`option`,{value:`none`,children:`No caps`}),(0,U.jsx)(`option`,{value:`round`,children:`Round`}),(0,U.jsx)(`option`,{value:`square`,children:`Square`})]}),(0,U.jsx)(X.chevronDown,{})]})]},`line`))}b.length&&ue.push((0,U.jsx)(`div`,{className:`sel-mod`,children:(0,U.jsx)(`button`,{className:`sel-swatch`,"aria-label":`Color`,"data-tip":`Color`,...re(`text-color`),children:(0,U.jsx)(`span`,{style:{background:P(M(b,e=>e.color??`#000000`))}})})},`vector`)),g.length>1&&ue.push((0,U.jsxs)(`div`,{className:`sel-mod`,children:[(0,U.jsx)(`button`,{"aria-label":`Align`,"data-tip":`Align`,...re(`align`),children:(0,U.jsx)(X.alignLeft,{})}),Kc(e,n)&&(0,U.jsx)(`button`,{"aria-label":`Boolean`,"data-tip":`Boolean`,...re(`bool`),children:(0,U.jsx)(X.boolUnion,{})})]},`multi`));let de=g.length===1&&g[0].type===`frame`&&g[0].parent===null&&g[0].build?g[0].id:null,z=de?Sl(m.views,de)===`side`:!1;ue.push((0,U.jsxs)(`div`,{className:`sel-mod`,children:[de&&(0,U.jsx)(`button`,{className:z?`on`:``,"aria-pressed":z,"aria-label":z?`Hide the live page`:`Show the live page`,"data-tip":z?`Hide the live page`:`Show the live page beside it`,onClick:()=>Al(de,z?`off`:`side`),children:(0,U.jsx)(X.play,{})}),(0,U.jsx)(`button`,{"aria-label":`Ask for changes`,"data-tip":`Ask for changes`,onClick:c,children:(0,U.jsx)(X.sparkle,{})}),(0,U.jsx)(`button`,{"aria-label":`Open the Design panel`,"data-tip":`Open the Design panel`,"data-kbd":`⌘\\`,onClick:l,children:(0,U.jsx)(X.more,{})})]},`tail`));let pe=_.length?_:b.length?b:j,me=pe[0]?(pe[0].type===`text`?N(pe[0],`color`):pe[0].color)??`#000000`:y,he=(e,t)=>[{...t,...e.fills?.[0]?.visible===!1?{visible:!1}:{}},...e.fills?.slice(1)??[]],ge=S[0]?.fills?.[0],_e=M(v,e=>e.layout.pad[0]),ve=S.some(e=>e.stroke),ye=e=>t=>n=>({shape:aD(e(n.shape,t))}),be=(e,t,n,r)=>(0,U.jsx)(Ql,{label:``,title:e,value:M(x,e=>t(e.shape)),min:r.min,max:r.max,suffix:r.suffix,digits:1,onPreview:e=>L(x,e===null?null:ye(n)(e)),onCommit:t=>I(x,e,ye(n)(t))});return(0,U.jsxs)(`div`,{className:`sel-bar`,ref:h,style:{left:Math.max(V(`--gap`),i.x)},role:`toolbar`,"aria-label":`Selection`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[ue,f?.kind===`text-color`&&(0,U.jsx)(Bd,{value:me,at:f.at,onClose:ne,onPreview:t=>L(pe,t===null?null:n=>n.type===`text`?Bn(e,n.id,{color:t}):{color:t}),onCommit:t=>I(pe,`Color`,n=>n.type===`text`?Bn(e,n.id,{color:t}):{color:t})}),f?.kind===`fill`&&(0,U.jsx)(zd,{paint:ge&&ge.type!==`video`?ge:{type:`solid`,color:`#ffffff`},kinds:[`solid`,`linear`,`radial`,`image`],at:f.at,onClose:ne,style:ge?.type===`solid`&&ge.color.startsWith(`$`)?ge.color.slice(1):void 0,onPreview:e=>L(S,e?t=>({fills:he(t,e)}):null),onCommit:(e,t)=>{s(null);let n=e.type===`image`?`Image fill`:e.type===`linear`||e.type===`radial`?`Gradient fill`:`Fill color`;o([...t?[{op:`asset`,add:[t]}]:[],...F(S,t=>({fills:he(t,e)}))],n)}}),f?.kind===`stroke`&&(0,U.jsx)(mu,{title:`Stroke`,width:220,at:f.at,onClose:ne,actions:ve?(0,U.jsx)(`button`,{className:`icon-btn`,"aria-label":`Remove stroke`,"data-tip":`Remove stroke`,onClick:()=>{I(S,`Remove stroke`,()=>({stroke:null})),p(null)},children:(0,U.jsx)(X.minus,{})}):void 0,children:(0,U.jsxs)(`div`,{className:`sel-pop`,children:[(0,U.jsx)(tu,{value:M(S,e=>e.stroke?.color??`#000000`),styles:e.styles.colors,onCommit:e=>I(S,`Stroke color`,t=>({stroke:{width:1,...t.stroke,color:e}}))}),(0,U.jsx)(Ql,{label:(0,U.jsx)(X.strokeWeight,{}),title:`Stroke weight`,value:M(S,e=>e.stroke?.width??0),min:0,digits:2,onPreview:e=>L(S,e===null?null:t=>({stroke:{color:`#000000`,...t.stroke,width:e}})),onCommit:e=>I(S,`Stroke weight`,t=>e===0?{stroke:null}:{stroke:{color:`#000000`,...t.stroke,width:e}})})]})}),f?.kind===`radius`&&(0,U.jsx)(mu,{title:`Corner radius`,width:180,at:f.at,onClose:ne,children:(0,U.jsx)(`div`,{className:`sel-pop`,children:(0,U.jsx)(ef,{doc:e,values:S.map(e=>e.radius),single:O,onPreview:e=>L(S,e&&(t=>({radius:e(t.radius)}))),onCommit:(e,t)=>I(S,e,e=>({radius:t(e.radius)}))},S.map(e=>e.id).join())})}),f?.kind===`pad`&&(0,U.jsx)(mu,{title:`Padding`,width:180,at:f.at,onClose:ne,children:(0,U.jsx)(`div`,{className:`sel-pop`,children:(0,U.jsx)(Ql,{label:(0,U.jsx)(X.padAll,{}),title:`Padding, all sides`,value:_e,min:0,onPreview:e=>L(v,e===null?null:()=>({layout:{pad:[e,e,e,e]}})),onCommit:e=>I(v,`Padding`,()=>({layout:{pad:[e,e,e,e]}}))})})}),f?.kind===`stroke-color`&&(0,U.jsx)(Bd,{value:P(M(S,e=>e.stroke?.color??`#000000`)),at:f.at,onClose:ne,onPreview:e=>L(S,e===null?null:oe({color:e})),onCommit:e=>I(S,`Stroke color`,oe({color:e}))}),f?.kind===`arc`&&(0,U.jsx)(mu,{title:`Arc`,width:264,at:f.at,onClose:ne,children:(0,U.jsxs)(`div`,{className:`sel-pop`,children:[(0,U.jsxs)(`div`,{className:`row3 labels`,children:[(0,U.jsx)(`span`,{children:`Start`}),(0,U.jsx)(`span`,{children:`Sweep`}),(0,U.jsx)(`span`,{children:`Ratio`})]}),(0,U.jsxs)(`div`,{className:`row3`,children:[be(`Arc start`,e=>e.start??0,(e,t)=>({...e,start:(t%360+360)%360}),{suffix:`°`}),be(`Arc sweep`,e=>Math.round((e.sweep??1)*1e3)/10,(e,t)=>({...e,sweep:Math.max(.1,t)/100}),{min:.1,max:100,suffix:`%`}),be(`Inner radius ratio`,e=>Math.round((e.ratio??0)*1e3)/10,(e,t)=>({...e,ratio:Math.min(99,t)/100}),{min:0,max:99,suffix:`%`})]})]})}),f?.kind===`align`&&(0,U.jsx)(mu,{title:`Align`,width:260,at:f.at,onClose:ne,children:(0,U.jsx)(`div`,{className:`sel-pop`,children:(0,U.jsx)(hD,{count:g.length,onAlign:t=>{let r=jn(e,a,n,t);r.length&&o(r,`Align`)},onDistribute:t=>{let r=Mn(e,a,n,t);r.length&&o(r,`Distribute`)}})})}),f?.kind===`video`&&(0,U.jsx)(mu,{title:`Playback`,width:200,at:f.at,onClose:ne,children:(0,U.jsx)(`div`,{className:`sel-pop`,children:(0,U.jsx)(Qf,{on:Re(T[0].fills[Lf(T[0])]),onSetting:(e,t)=>I(T,`Video ${e}`,ae(e,t))})})}),f?.kind===`props`&&E&&(0,U.jsx)(mu,{title:`Properties`,width:260,at:f.at,onClose:ne,children:(0,U.jsx)(`div`,{className:`sel-pop`,children:(0,U.jsx)(RE,{doc:e,inst:E,onCommit:o})})}),f?.kind===`bool`&&(0,U.jsx)(mu,{title:`Boolean`,width:200,at:f.at,onClose:ne,children:(0,U.jsx)(`div`,{className:`sel-pop`,children:(0,U.jsxs)(`div`,{className:`bool-ops`,role:`toolbar`,"aria-label":`Boolean operations`,children:[Vc.map(t=>(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":Bc[t.op],"data-tip":t.label,"data-kbd":t.kbd,onClick:()=>{let r=Jc(e,a,n,t.op);r&&(p(null),o(r,Bc[t.op],[`bool`]))},children:(0,U.jsx)(Uc,{op:t.op})},t.op)),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":Yc.label,"data-tip":Yc.label,"data-kbd":Yc.kbd,onClick:()=>{let t=Xc(e,a,n);`ops`in t&&(p(null),o(t.ops,Yc.label,[`flat`]))},children:(0,U.jsx)(X.flatten,{})})]})})})]})}var _D=`hello@nudgecanvas.com`,vD=`https://docs.nudgecanvas.com`,yD=`${vD}/changelog`,bD=[],xD=e=>{let t=e.replace(/\s+/g,` `).slice(0,1e3);bD.push(`${new Date().toISOString().slice(11,19)} ${t}`),bD.length>20&&bD.shift()};if(typeof window<`u`){addEventListener(`error`,e=>xD(e.message||String(e.error))),addEventListener(`unhandledrejection`,e=>xD(`Unhandled: ${e.reason instanceof Error?e.reason.message:String(e.reason)}`));let e=console.error.bind(console);console.error=(...t)=>{xD(t.map(e=>e instanceof Error?e.message:String(e)).join(` `)),e(...t)}}var SD=[];typeof window<`u`&&addEventListener(`keydown`,e=>{if(!e.isTrusted||!e.ctrlKey&&!e.metaKey&&!e.altKey||[`Control`,`Meta`,`Alt`,`Shift`].includes(e.key))return;let t=[e.ctrlKey&&`Ctrl`,e.metaKey&&`Meta`,e.altKey&&`Alt`,e.shiftKey&&`Shift`].filter(Boolean).join(`+`),n=e.target?.tagName?.toLowerCase()??`?`;setTimeout(()=>{let r=(e.ctrlKey||e.metaKey)&&!e.altKey&&[`KeyC`,`KeyX`,`KeyV`].includes(e.code);SD.push(`${t}+${e.code} (key ${e.key.length===1?`char`:e.key}, in ${n}, ${r?`clipboard`:e.defaultPrevented?`taken`:`not taken`}${e.isComposing?`, composing`:``})`),SD.length>8&&SD.shift()})},!0);var CD=e=>[`Nudge: ${e.version}`,`System: ${e.os}`,`Node: ${e.node}`,`Agent: ${e.agent}`,`Browser: ${navigator.userAgent}`,``,`Recent errors:`,...e.errors.length?e.errors:[`(none)`],``,`Editor errors:`,...e.editorErrors?.length?e.editorErrors:[`(none)`],``,`Recent shortcuts:`,...SD.length?SD:[`(none)`]].join(`
|
|
36
|
+
`),wD=e=>`mailto:${_D}?subject=${encodeURIComponent(`Nudge ${e.version}: feedback`)}&body=${encodeURIComponent(`What happened, or what you'd like:\n\n\n---\n${CD(e)}\n`)}`,TD=()=>fetch(`/api/diagnostics`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({errors:bD.slice(-5)})}).then(e=>e.json());function ED({onClose:e}){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(null);(0,H.useEffect)(()=>{TD().then(n,()=>{})},[]);let a=(e,t)=>void navigator.clipboard.writeText(t).then(()=>i(e),()=>{}),o={left:Math.max(16,innerWidth/2-170),top:Math.max(64,innerHeight/2-200)};return(0,U.jsxs)(mu,{title:`Send feedback`,onClose:e,width:340,at:o,className:`feedback`,children:[(0,U.jsxs)(`p`,{className:`muted-note`,children:[`Tell us what happened, or what you’d like, at `,_D,`. The details below help us find it; nothing of your design is in them.`]}),(0,U.jsx)(`pre`,{className:`feedback-details`,children:t?CD(t):`Reading the details…`}),(0,U.jsxs)(`div`,{className:`feedback-actions`,children:[(0,U.jsx)(`a`,{className:`btn primary`,href:t?wD(t):`mailto:${_D}`,children:`Open mail app`}),(0,U.jsx)(`button`,{className:`btn`,onClick:()=>a(`address`,_D),children:r===`address`?`Copied`:`Copy address`}),(0,U.jsx)(`button`,{className:`btn`,disabled:!t,onClick:()=>t&&a(`details`,CD(t)),children:r===`details`?`Copied`:`Copy details`})]})]})}function DD(){let[e,t]=(0,H.useState)(null);return(0,H.useEffect)(()=>{fetch(`/api/diagnostics`).then(e=>e.json()).then(e=>t(e.version),()=>{})},[]),e?(0,U.jsx)(`div`,{className:`set-nav-foot`,children:(0,U.jsxs)(`span`,{className:`set-version`,children:[`Nudge `,e]})}):null}var OD=`npm install -g nudge-canvas@latest`;function kD(){let e=kp(),[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!e.checkUpdates)return n(null);let t=!0;return fetch(`/api/update`).then(e=>e.json()).then(e=>{t&&n(e.newer&&e.latest?e.latest:null)},()=>{}),()=>{t=!1}},[e.checkUpdates]),(0,H.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t)}},[r]),!t||e.dismissedUpdate===t?null:(0,U.jsxs)(`div`,{className:`update`,ref:s,children:[(0,U.jsxs)(`button`,{className:`badge`,"aria-expanded":r,onClick:()=>i(!r),children:[`Update available: `,t]}),r&&(0,U.jsxs)(`div`,{className:`update-pop`,role:`dialog`,"aria-label":`Update Nudge`,children:[(0,U.jsxs)(`p`,{children:[`Nudge `,t,` is out. Install it, then restart your agent session. `,(0,U.jsx)(`a`,{href:`https://docs.nudgecanvas.com/changelog`,target:`_blank`,rel:`noreferrer`,children:`What's new`})]}),(0,U.jsxs)(`div`,{className:`update-cmd`,children:[(0,U.jsx)(`code`,{children:OD}),(0,U.jsx)(`button`,{className:`panel-btn`,"aria-label":`Copy the command`,"data-tip":a?`Copied`:`Copy`,onClick:()=>{navigator.clipboard?.writeText(OD).then(()=>{o(!0),setTimeout(()=>o(!1),1500)},()=>{})},children:a?(0,U.jsx)(X.check,{}):(0,U.jsx)(X.copy,{})})]}),(0,U.jsxs)(`button`,{className:`btn`,onClick:()=>{Dp(`dismissedUpdate`,t),i(!1)},children:[`Don't show for `,t]})]})]})}function AD(e){return e===`frame`?void 0:`allow-scripts allow-same-origin allow-forms allow-popups allow-modals`}var jD={desktop:{label:`Desktop`,w:1440,h:900},mobileS:{label:`Mobile S`,w:360,h:800},mobile:{label:`Mobile`,w:390,h:844},mobileL:{label:`Mobile L`,w:430,h:932},tablet:{label:`Tablet`,w:820,h:1180}},MD=Object.keys(jD),ND=[jD.desktop,jD.tablet,jD.mobile],PD=e=>e>=1024,FD=320,ID=ND,LD=`nudge.browser.tabs`,RD=`nudge.browser.recent`,zD=()=>{try{return JSON.parse(localStorage.getItem(RD)??`[]`)}catch{return[]}},BD=jD,VD=()=>`t`+Math.random().toString(36).slice(2,8),HD=(e,t,n)=>({id:VD(),kind:`web`,stack:e?[e]:[],at:e?0:-1,reload:0,device:t,zoom:n});function UD(e){let t=e.trim();return t?/^https?:\/\//i.test(t)?t:/^(localhost|127\.0\.0\.1)(:\d+)?/i.test(t)?`http://${t}`:/^[\w-]+(\.[\w-]+)+(:\d+)?(\/.*)?$/.test(t)?`https://${t}`:null:null}var WD=e=>e.kind===`web`&&e.at>=0?e.stack[e.at]:null,GD=e=>{try{return new URL(e).host}catch{return e}};function KD(){try{let e=JSON.parse(localStorage.getItem(LD)??`null`);if(e?.tabs?.length){let t=e.tabs.map(e=>e.kind===`frame`?{id:VD(),kind:`frame`,frame:e.frame??null,reload:0,device:e.device,fit:e.fit}:HD(e.url,e.device,e.zoom));return{tabs:t,active:t[Math.min(e.active,t.length-1)].id}}}catch{}let e=HD();return{tabs:[e],active:e.id}}function qD({previewFrame:e,frameName:t,onClose:n,onImported:r,onNotice:i,frameTabReq:a,openUrlReq:o,full:s=!1,onFull:c}){let l=kl(),[u,d]=(0,H.useState)(()=>{try{return Number(localStorage.getItem(`nudge.browser.w`))||440}catch{return 440}}),[{tabs:f,active:p},m]=(0,H.useState)(KD),h=f.find(e=>e.id===p)??f[0],[g,_]=(0,H.useState)(``),[v,y]=(0,H.useState)({}),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)(null),w=(e,t)=>m(n=>({...n,tabs:n.tabs.map(n=>n.id===e?t(n):n)})),T=e=>m(t=>({...t,active:e})),E=(e,t)=>m(n=>{let r=n.tabs.filter(t=>t.id!==e);return r.splice(t,0,n.tabs.find(t=>t.id===e)),{...n,tabs:r}}),D=(0,H.useRef)(null),[O,k]=(0,H.useState)(null),A=(0,H.useRef)(null),[j,M]=(0,H.useState)(null),[N,P]=(0,H.useState)({w:0,h:0}),F=(0,H.useRef)(null),I=(0,H.useCallback)(e=>{if(F.current?.disconnect(),F.current=null,!e)return;let t=()=>P({w:e.clientWidth,h:e.clientHeight});t();let n=new ResizeObserver(t);n.observe(e),F.current=n},[]),L=e=>{let t=D.current,n=t&&A.current?.querySelector(`[data-tab-id="${t.id}"]`);if(!t||!n)return;let r=t.id,i=e-t.x0;if(!t.on&&Math.abs(i)<4)return;t.on=!0;let a=[...n.parentElement.querySelectorAll(`.browser-tab`)],o=a.indexOf(n),s=a.filter(e=>e!==n),c=n.offsetLeft+n.offsetWidth/2+i,l=s.filter(e=>e.offsetLeft+e.offsetWidth/2<c).length;if(l!==o){let e=a.length>1?a[1].offsetLeft-a[0].offsetLeft-a[0].offsetWidth:0,o=a[0].offsetLeft+s.slice(0,l).reduce((t,n)=>t+n.offsetWidth+e,0)-n.offsetLeft;t.x0+=o,i-=o,(0,Vl.flushSync)(()=>E(r,l))}k({id:r,dx:i})},ee=(e,t)=>{D.current={id:e,x0:t,on:!1};let n=e=>L(e.clientX),r=e=>{L(e.clientX),D.current=null,k(null),removeEventListener(`pointermove`,n),removeEventListener(`pointerup`,r),removeEventListener(`pointercancel`,r)};addEventListener(`pointermove`,n),addEventListener(`pointerup`,r),addEventListener(`pointercancel`,r)};(0,H.useEffect)(()=>{try{localStorage.setItem(LD,JSON.stringify({tabs:f.map(e=>e.kind===`frame`?{kind:`frame`,frame:e.frame,device:e.device,fit:e.fit}:{kind:`web`,url:WD(e)??void 0,device:e.device,zoom:e.zoom}),active:f.findIndex(e=>e.id===p)}))}catch{}},[f,p]),(0,H.useEffect)(()=>{e&&m(t=>({...t,tabs:t.tabs.map(t=>t.kind===`frame`&&t.frame!==e?{...t,frame:e}:t)}))},[e]);let R=e=>e.kind===`frame`?e.frame?t(e.frame)??`Deleted frame`:`Frame`:WD(e)?GD(WD(e)):`New tab`,te=WD(h),ne=h.kind===`frame`?h.frame?`Frame · ${R(h)}`:``:te??``;(0,H.useEffect)(()=>{_(ne)},[ne]);let[re,ie]=(0,H.useState)(zD),ae=e=>{let t=[e,...zD().filter(t=>t!==e)].slice(0,6);ie(t);try{localStorage.setItem(RD,JSON.stringify(t))}catch{}},oe=()=>{ie([]);try{localStorage.removeItem(RD)}catch{}},se=e=>{ae(e),ce(e)},ce=e=>w(h.id,t=>{if(t.kind===`frame`)return{id:t.id,kind:`web`,stack:[e],at:0,reload:0};let n=[...t.stack.slice(0,t.at+1),e];return{...t,stack:n,at:n.length-1}}),le=e=>m(t=>({tabs:[...t.tabs,e],active:e.id})),ue=e=>{if(f.length===1&&f[0].id===e){let e=HD();m({tabs:[e],active:e.id}),n()}else m(t=>{let n=t.tabs.findIndex(t=>t.id===e),r=t.tabs.filter(t=>t.id!==e);return{tabs:r,active:t.active===e?r[Math.max(0,n-1)].id:t.active}})},de=(0,H.useRef)(null),fe=(t=e)=>{let n=f.find(e=>e.kind===`frame`);if(!n)return le({id:VD(),kind:`frame`,frame:t,reload:0});t&&n.frame!==t&&m(e=>({...e,tabs:e.tabs.map(e=>e.id===n.id&&e.kind===`frame`?{...e,frame:t}:e)})),T(n.id)};(0,H.useEffect)(()=>{a?.n&&fe(a.frame??e)},[a]),(0,H.useEffect)(()=>{if(!o)return;let e=f.find(e=>WD(e)===o.url);if(e)return T(e.id);let t=MD.find(e=>jD[e].w===o.w);le(HD(o.url,t))},[o?.n]);let z=[...new Set(f.map(WD).filter(e=>!!e))],pe=(0,H.useRef)(new Set);(0,H.useEffect)(()=>{for(let e of z)pe.current.has(e)||(pe.current.add(e),fetch(`/api/embeddable?url=${encodeURIComponent(e)}`).then(e=>e.json()).then(t=>{t.ok||y(n=>({...n,[e]:t.reason??`This site doesn’t allow embedding.`}))}).catch(()=>{}))},[z.join(`
|
|
37
|
+
`)]);let me=e=>e.kind===`frame`?e.frame?`/?mode=frame&id=${encodeURIComponent(e.frame)}${e.device?`&w=vw`:e.fit?`&fit=1`:``}`:null:WD(e),he=me(h),ge=async e=>{if(x(null),!te||S)return;let t=GD(te);C({host:t,w:e});try{let n=await fetch(`/api/import`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({url:te,width:e})}),a=await n.json();if(!n.ok)return i(a.error??`Couldn’t import ${t}`);r(a)}catch{i(`Couldn’t import ${t}`)}finally{C(null)}},_e=(0,H.useRef)(null),ve=()=>{let e=_e.current?.getBoundingClientRect();e&&x({x:e.right,y:e.bottom+V(`--menu-gap`)})},ye=(0,H.useRef)(null),be=e=>{e.target.setPointerCapture(e.pointerId),ye.current={x:e.clientX,w:u}},xe=e=>{ye.current&&d(Math.max(FD,Math.min(innerWidth*.7,ye.current.w+ye.current.x-e.clientX)))},Se=()=>{ye.current=null;try{localStorage.setItem(`nudge.browser.w`,String(Math.round(u)))}catch{}},Ce=h.kind===`web`?h:null,we=h.device&&h.device!==`responsive`?BD[h.device]:null,Te=h.kind===`web`?`Viewport: ${we?`${we.label} ${we.w} × ${we.h}`:`Responsive`} · ${(e=>e===void 0||e===`fit`?`Fit width`:`${e*100}%`)(h.zoom)}`:`${h.fit&&h.device!==`responsive`?`Fit width`:`Actual size`} · ${we?`${we.label} ${we.w}`:h.device===`responsive`?`Responsive`:`Frame width`}`;return(0,U.jsxs)(`aside`,{className:`panel browser ${s?`full`:``}`,style:s?void 0:{width:u},children:[(0,U.jsx)(`div`,{className:`browser-edge`,onPointerDown:be,onPointerMove:xe,onPointerUp:Se}),(0,U.jsxs)(`div`,{className:`browser-tabs`,role:`tablist`,"aria-label":`Browser tabs`,ref:A,children:[f.map(e=>(0,U.jsxs)(`div`,{"data-tab-id":e.id,role:`tab`,"aria-selected":e.id===h.id,tabIndex:0,className:`browser-tab ${e.id===h.id?`on`:``} ${O?.id===e.id?`dragging`:``}`,style:O?.id===e.id?{transform:`translateX(${O.dx}px)`}:void 0,onPointerDown:t=>{t.button===1?(t.preventDefault(),ue(e.id)):t.button!==0||t.target.closest(`.tab-close`)||(T(e.id),ee(e.id,t.clientX))},onClick:()=>T(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&T(e.id)},"data-tip":e.kind===`frame`?`Shows the selected frame`:WD(e)??void 0,children:[(0,U.jsx)(`span`,{className:`tab-icon`,children:e.kind===`frame`?(0,U.jsx)(X.frame,{}):(0,U.jsx)(X.globe,{})}),(0,U.jsx)(`span`,{className:`tab-label`,children:R(e)}),(0,U.jsx)(`button`,{className:`tab-close`,"aria-label":`Close tab`,onClick:t=>{t.stopPropagation(),ue(e.id)},children:(0,U.jsx)(X.close,{})})]},e.id)),(0,U.jsx)(`button`,{className:`panel-btn tab-new`,onClick:()=>le(HD()),"aria-label":`New tab`,"data-tip":`New tab`,children:(0,U.jsx)(X.plus,{})}),(0,U.jsx)(`span`,{className:`tabs-fill`}),c&&(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>c(!s),"aria-label":s?`Exit full screen`:`Full screen`,"data-tip":s?`Exit full screen`:`Full screen (covers the canvas)`,"data-kbd":s?`Esc`:void 0,children:s?(0,U.jsx)(X.collapse,{}):(0,U.jsx)(X.expand,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:n,"aria-label":`Close browser`,"data-tip":`Close browser`,"data-kbd":`⇧⌘B`,children:(0,U.jsx)(X.close,{})})]}),(0,U.jsxs)(`div`,{className:`browser-bar`,children:[(0,U.jsx)(`button`,{className:`panel-btn`,disabled:!Ce||Ce.at<=0,onClick:()=>Ce&&w(Ce.id,e=>({...e,at:e.at-1})),"aria-label":`Back`,"data-tip":`Back`,children:(0,U.jsx)(X.back,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,disabled:!Ce||Ce.at>=Ce.stack.length-1,onClick:()=>Ce&&w(Ce.id,e=>({...e,at:e.at+1})),"aria-label":`Forward`,"data-tip":`Forward`,children:(0,U.jsx)(X.forward,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,disabled:!he,onClick:()=>{te&&(pe.current.delete(te),y(e=>{let{[te]:t,...n}=e;return n})),w(h.id,e=>({...e,reload:e.reload+1}))},"aria-label":`Reload`,"data-tip":`Reload`,children:(0,U.jsx)(X.reload,{})}),(0,U.jsx)(`input`,{ref:de,className:`browser-url`,value:g,placeholder:h.kind===`frame`?`Select a frame, or type a URL`:`localhost:3000 or a URL`,"aria-label":`Address`,onChange:e=>_(e.target.value),onFocus:e=>{_(te??``),e.currentTarget.select()},onBlur:e=>{_(ne);let t=e.currentTarget;requestAnimationFrame(()=>{t.scrollLeft=0})},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){let t=UD(g);t&&(se(t),e.currentTarget.blur())}e.key===`Escape`&&e.currentTarget.blur()}}}),(0,U.jsx)(`button`,{className:`panel-btn ${h.kind===`frame`?`on`:``}`,onClick:()=>fe(),"aria-label":`Frame tab`,"data-tip":f.some(e=>e.kind===`frame`)?`Go to the Frame tab (follows the selection)`:`Open a Frame tab (1:1, live, follows the selection)`,children:(0,U.jsx)(X.frame,{})}),(0,U.jsx)(`button`,{className:`panel-btn ${j?`on`:``}`,"aria-label":`Viewport`,"aria-haspopup":`menu`,"aria-expanded":!!j,"data-tip":Te,onClick:e=>{if(j)return M(null);let t=e.currentTarget.getBoundingClientRect();M({x:t.right,y:t.bottom+V(`--menu-gap`)})},children:(0,U.jsx)(X.adjust,{})}),j&&(0,U.jsx)(Gl,{x:j.x,y:j.y,alignRight:!0,onClose:()=>M(null),items:h.kind===`web`?[{head:`Scale`},...[`fit`,1,.75,.5].map(e=>({label:e===`fit`?`Fit width`:`${e*100}%`,checked:(h.zoom??`fit`)===e,disabled:e===`fit`&&(!h.device||h.device===`responsive`),onClick:()=>w(h.id,t=>t.kind===`web`?{...t,zoom:e}:t)})),{sep:!0},{head:`Viewport`},{label:`Responsive`,icon:(0,U.jsx)(X.monitor,{}),checked:!h.device||h.device===`responsive`,onClick:()=>w(h.id,e=>({...e,device:void 0}))},...MD.map(e=>({label:jD[e].label,kbd:`${jD[e].w} × ${jD[e].h}`,icon:e===`desktop`?(0,U.jsx)(X.monitor,{}):e===`tablet`?(0,U.jsx)(X.tablet,{}):(0,U.jsx)(X.phone,{}),checked:h.device===e,onClick:()=>w(h.id,t=>({...t,device:e}))}))]:[{head:`Scale`},{label:`Actual size (100%)`,checked:!h.fit,onClick:()=>w(h.id,e=>({...e,fit:void 0}))},{label:`Fit width`,checked:!!h.fit,disabled:h.device===`responsive`,onClick:()=>w(h.id,e=>({...e,fit:!0}))},{sep:!0},{head:`Width`},...[[void 0,`Frame width`,void 0],[`responsive`,`Responsive`,`panel`]].map(([e,t,n])=>({label:t,kbd:n,checked:h.device===e,onClick:()=>w(h.id,t=>({...t,device:e}))})),...MD.map(e=>({label:jD[e].label,kbd:String(jD[e].w),checked:h.device===e,onClick:()=>w(h.id,t=>({...t,device:e}))}))]}),(0,U.jsxs)(`div`,{className:`import-wrap`,children:[(0,U.jsxs)(`button`,{ref:_e,className:`btn`,disabled:!te||!!S,onClick:()=>b?x(null):ve(),"aria-label":`Import to canvas`,"aria-haspopup":`menu`,"aria-expanded":!!b,"data-tip":te?`Import to canvas as editable layers`:`Open a page to import it`,children:[S?`Importing…`:`Import`,(0,U.jsx)(X.chevronDown,{})]}),b&&(0,U.jsx)(Gl,{x:b.x,y:b.y,alignRight:!0,onClose:()=>x(null),items:[{head:`Import as editable layers`},...ID.map(e=>({label:e.label,hint:String(e.w),onClick:()=>void ge(e.w)}))]})]}),(0,U.jsx)(`button`,{className:`panel-btn`,disabled:!he,onClick:()=>he&&window.open(he,`_blank`,`noopener`),"aria-label":`Open in new tab`,"data-tip":`Open in new window`,children:(0,U.jsx)(X.external,{})})]}),S&&(0,U.jsxs)(`div`,{className:`import-status`,role:`status`,children:[(0,U.jsx)(`span`,{className:`import-bar`}),`Importing `,S.host,` at `,S.w,`px…`]}),(0,U.jsx)(`div`,{className:`browser-view`,ref:I,children:f.map(e=>{let t=me(e),n=e.id===h.id,r=e.kind===`web`&&t?v[t]:void 0;if(!t)return n?(0,U.jsx)(`div`,{className:`browser-empty ${e.kind===`web`?`start-wrap`:``}`,children:e.kind===`frame`?(0,U.jsx)(`p`,{children:`Select a frame on the canvas. This tab shows it 1:1 in a real browser and follows your selection.`}):(0,U.jsx)(JD,{recent:re,onOpen:se,onClear:oe,onAddress:()=>de.current?.focus(),onFrame:()=>fe()})},e.id):null;if(r)return n?(0,U.jsxs)(`div`,{className:`browser-empty`,children:[(0,U.jsx)(`p`,{children:r}),(0,U.jsx)(`p`,{children:`You can still bring it onto the canvas as editable layers.`}),(0,U.jsxs)(`div`,{className:`row-gap`,children:[(0,U.jsx)(`button`,{className:`chip`,onClick:ve,children:`Import to canvas`}),(0,U.jsx)(`button`,{className:`chip`,onClick:()=>window.open(t,`_blank`,`noopener`),children:`Open in new window`})]})]},e.id):null;let i=(0,U.jsx)(`iframe`,{src:t,title:R(e),className:`browser-frame`,style:n?void 0:{display:`none`},sandbox:AD(e.kind)},`${e.id}:${t}#${e.reload}.${l.reloads[t]??0}`),a=e.device&&e.device!==`responsive`?BD[e.device]:null,o=e.kind===`web`?e.zoom??`fit`:`fit`;if(e.kind===`web`&&N.w&&(!a&&o!==`fit`&&o!==1||a&&PD(a.w))){let t=a?a.w:N.w/o,r=o===`fit`?Math.min(1,N.w/t):o;return(0,U.jsx)(`div`,{className:`page-zoom`,style:n?void 0:{display:`none`},children:(0,U.jsx)(`div`,{style:{width:t*r,height:N.h,overflow:`hidden`,margin:`0 auto`},children:(0,U.jsx)(`div`,{style:{width:t,height:N.h/r,transform:r===1?void 0:`scale(${r})`,transformOrigin:`top left`},children:i})})},e.id)}if(!a)return i;let s=N.w?Math.max(.1,Math.min(1,(N.w-32)/a.w,(N.h-56)/a.h)):1,c=e.kind===`frame`?e.fit?s:1:o===`fit`?s:o;return(0,U.jsx)(`div`,{className:`device`,style:n?void 0:{display:`none`},children:(0,U.jsxs)(`div`,{className:`device-sizer`,style:{width:a.w*c+32,height:a.h*c+56},children:[(0,U.jsx)(`div`,{className:`device-screen`,style:{width:a.w,height:a.h,transform:c<1?`scale(${c})`:void 0},children:i}),(0,U.jsxs)(`div`,{className:`device-caption`,style:{top:16+a.h*c+8},children:[a.label,` · `,a.w,` × `,a.h,c<1?` · ${Math.round(c*100)}%`:``]})]})},e.id)})})]})}function JD({recent:e,onOpen:t,onClear:n,onAddress:r,onFrame:i}){return(0,U.jsxs)(`div`,{className:`start`,children:[(0,U.jsx)(`h2`,{children:`Check your design in a real browser`}),(0,U.jsx)(`p`,{className:`start-lead`,children:`Open your local prototype or a live site, or see a frame from the canvas exactly as a browser draws it.`}),(0,U.jsxs)(`div`,{className:`start-actions`,children:[(0,U.jsxs)(`button`,{className:`start-card`,onClick:r,children:[(0,U.jsx)(`span`,{className:`start-ico`,children:(0,U.jsx)(X.globe,{})}),(0,U.jsx)(`strong`,{children:`Open a page`}),(0,U.jsx)(`span`,{children:`localhost or any site that allows embedding. Import brings it onto the canvas as layers.`})]}),(0,U.jsxs)(`button`,{className:`start-card`,onClick:i,children:[(0,U.jsx)(`span`,{className:`start-ico`,children:(0,U.jsx)(X.frame,{})}),(0,U.jsx)(`strong`,{children:`Preview a frame`}),(0,U.jsx)(`span`,{children:`The selected screen at 1:1, live, at its own width or a device's.`})]})]}),e.length>0&&(0,U.jsxs)(`div`,{className:`start-recent`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsx)(`h3`,{children:`Recent`}),(0,U.jsx)(`button`,{className:`start-clear`,onClick:n,children:`Clear`})]}),e.map(e=>(0,U.jsxs)(`button`,{className:`start-row`,onClick:()=>t(e),"data-tip":e,children:[(0,U.jsx)(X.globe,{}),(0,U.jsx)(`span`,{className:`start-host`,children:GD(e)}),(0,U.jsx)(`span`,{className:`start-path`,children:e.replace(/^https?:\/\/[^/]+/,``)||`/`})]},e))]})]})}function YD(e,t,n,r=8){let i=(e,t,n)=>Math.max(t,Math.min(e,n)),a=n.l+r,o=n.r-r-t.w,s=n.t+r,c=n.b-r-t.h,l=e.x+20;l>o&&(l=e.x-t.w-12);let u=e.y-8;return u>c&&(u=e.y+8-t.h),{left:i(l,a,Math.max(a,o)),top:i(u,s,Math.max(s,c))}}var XD=(e,t)=>fetch(`/api/${e}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json()),ZD=e=>XD(`comments`,e);function QD(e,t){let n=e.node?t.get(e.node):void 0;return n?{x:n.x+e.x,y:n.y+e.y}:{x:e.cx,y:e.cy}}var $D=e=>Object.values(e.comments??{}).filter(e=>e.status===`queued`).sort((e,t)=>e.at-t.at);function eO({doc:e,boxes:t,view:n,insets:r,chats:i,runner:a,draft:o,setDraft:s,openId:c,setOpenId:l,showResolved:u,onNotice:d,onOpenChat:f}){let p=Object.values(e.comments??{}).sort((e,t)=>e.at-t.at).filter(e=>e.status!==`resolved`||u||e.id===c),m=$D(e).map(e=>e.id),h=c?e.comments?.[c]:void 0,g=fw(a),_=async e=>{if(!o)return;let t=await ZD({action:`add`,text:e,...o});if(t.error)return d(`Couldn’t add the comment: ${t.error}`);s(null)};return(0,U.jsxs)(U.Fragment,{children:[p.map(e=>{let r=yl({...QD(e,t),w:0,h:0},n),a=e.chatId?i.find(t=>t.id===e.chatId):void 0,o=e.status===`sent`&&!e.reply&&a?.status===`running`,u=e.status===`queued`?`Queued · not sent yet`:e.status===`resolved`?`Resolved`:e.reply?`${g} replied`:o?`${g} is working on it`:`Sent to ${g}`;return(0,U.jsx)(`button`,{className:`pin ${e.status}${e.reply?` replied`:``}${o?` working`:``}${c===e.id?` on`:``}`,style:{left:r.x,top:r.y},onPointerDown:e=>e.stopPropagation(),onClick:()=>{s(null),l(c===e.id?null:e.id)},"aria-label":`Comment: ${u}`,"data-tip":u,"data-comment-id":e.id,children:e.status===`queued`?m.indexOf(e.id)+1:e.status===`resolved`?(0,U.jsx)(X.check,{}):(0,U.jsx)(X.sparkle,{})},e.id)}),o&&(()=>{let e=yl({...QD(o,t),w:0,h:0},n);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`pin draft`,style:{left:e.x,top:e.y}}),(0,U.jsx)(nO,{x:e.x,y:e.y,insets:r,children:(0,U.jsx)(yw,{placeholder:`Add a comment`,autoFocus:!0,onSubmit:_,onCancel:()=>s(null)})})]})})(),h&&(()=>{let o=yl({...QD(h,t),w:0,h:0},n),s=h.node?e.nodes[h.node]:void 0,c=h.chatId?i.find(e=>e.id===h.chatId):void 0,u=h.status===`resolved`;return(0,U.jsxs)(nO,{x:o.x,y:o.y,insets:r,children:[(0,U.jsxs)(`header`,{className:`thread-head`,children:[(0,U.jsx)(`span`,{children:s?s.name:`Canvas`}),(0,U.jsx)(`em`,{className:`comment-status ${h.status}`,children:h.status===`queued`?`Queued`:h.status===`sent`?`Sent`:`Resolved`}),h.status!==`queued`&&(0,U.jsx)(`button`,{className:`panel-btn`,"data-tip":u?`Reopen (back to the queue)`:`Back to the queue`,"aria-label":`Reopen`,onClick:()=>void ZD({action:`resolve`,id:h.id,resolved:!1}),children:(0,U.jsx)(X.reload,{})}),!u&&(0,U.jsx)(`button`,{className:`panel-btn`,"data-tip":`Resolve`,"aria-label":`Resolve`,onClick:()=>{ZD({action:`resolve`,id:h.id,resolved:!0}),l(null)},children:(0,U.jsx)(X.check,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,"data-tip":`Delete comment`,"aria-label":`Delete comment`,onClick:()=>{ZD({action:`delete`,id:h.id}),l(null)},children:(0,U.jsx)(X.trash,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,"data-tip":`Close`,"aria-label":`Close`,onClick:()=>l(null),children:(0,U.jsx)(X.close,{})})]}),h.status===`queued`?(0,U.jsx)(`div`,{className:`comment-edit`,children:(0,U.jsx)(yw,{placeholder:`Edit comment`,initial:h.text,onCancel:()=>l(null),onSubmit:async e=>{if(e===h.text)return l(null);let t=await ZD({action:`edit`,id:h.id,text:e});if(t.error)return d(t.error);l(null)}},h.id)}):(0,U.jsxs)(`ol`,{className:`thread`,children:[(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`div`,{className:`msg-meta`,children:(0,U.jsx)(`b`,{children:`You`})}),(0,U.jsx)(`p`,{children:h.text})]}),h.reply&&(0,U.jsxs)(`li`,{className:`agent`,children:[(0,U.jsx)(`div`,{className:`msg-meta`,children:(0,U.jsx)(`b`,{children:fw(c?.runner??a)})}),(0,U.jsx)(`p`,{children:h.reply.text})]})]}),c&&(0,U.jsxs)(`button`,{className:`comment-chat`,onClick:()=>f(c.id),"data-tip":`Open the chat this was sent in`,children:[(0,U.jsx)(X.sparkle,{}),(0,U.jsx)(`span`,{children:c.title})]})]})})()]})}function tO({doc:e,runner:t,active:n,showResolved:r,onShowResolved:i,onNotice:a,onSent:o}){let[s,c]=(0,H.useState)(!1),l=$D(e),u=Object.values(e.comments??{}).filter(e=>e.status===`resolved`).length;if(!l.length&&!n)return null;let d=l.length,f=async()=>{c(!0);try{let e=await XD(`comments/send`,pw());if(e.error||!e.chatId)return a(e.error??`Couldn’t send the comments`);a(`Sent ${e.sent} comment${e.sent===1?``:`s`} to ${fw(t)}`),o(e.chatId)}finally{c(!1)}};return(0,U.jsxs)(`div`,{className:`comments-bar`,role:`toolbar`,"aria-label":`Comments`,onPointerDown:e=>e.stopPropagation(),children:[(0,U.jsx)(`span`,{className:`comments-count`,children:d?`${d} comment${d>1?`s`:``} queued`:`Click a layer or the canvas to comment`}),u>0&&(0,U.jsx)(`button`,{className:`btn ghost`,"aria-pressed":r,onClick:()=>i(!r),children:r?`Hide resolved`:`Show resolved (${u})`}),d>0&&(0,U.jsxs)(`button`,{className:`btn primary comments-send`,disabled:s,onClick:()=>void f(),"data-tip":`One ${fw(t)} run for all of them`,children:[(0,U.jsx)(X.sparkle,{}),s?`Sending…`:`Send ${d} to ${fw(t)}`]})]})}function nO({x:e,y:t,insets:n,children:r}){let i=(0,H.useRef)(null),[a,o]=(0,H.useState)({left:e+20,top:t-8});return(0,H.useEffect)(()=>{let r=i.current,a=r?.parentElement;if(!r||!a)return;let s=()=>{let i=YD({x:e,y:t},{w:r.offsetWidth,h:r.offsetHeight},{l:n.l,r:a.clientWidth-n.r,t:n.t,b:a.clientHeight});o(e=>e.left===i.left&&e.top===i.top?e:i)};s();let c=new ResizeObserver(s);return c.observe(a),c.observe(r),()=>c.disconnect()},[e,t,n.l,n.r,n.t]),(0,U.jsx)(`div`,{ref:i,className:`popover comment-pop`,style:a,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:r})}async function rO(e,t,n=!1,r,i=`/api/projects/open`,a){let o=n?window.open(``,`_blank`):null;r?.(!0);let s=await fetch(i,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}).finally(()=>r?.(!1)),c=await s.json().catch(()=>({error:s.statusText}));if(c.error||!c.url)return o?.close(),c.error&&t(c.error);c.path&&a?.({path:c.path,url:c.url}),o?o.location.href=c.url:c.url!==location.origin&&(location.href=c.url)}function iO(e,t,n=null){return t?{text:`Can’t save: file is from a newer Nudge`,blocked:!0}:n?{text:`Couldn’t save: ${n}. Trying again…`,blocked:!0}:e===null?null:{text:e?`Saving…`:`Saved`,blocked:!1}}function aO(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null);(0,H.useEffect)(()=>{fetch(`/api/projects`).then(e=>e.json()).then(e=>{o(!!e.temp),c(e.savedTo??null)},()=>{})},[]);let l=t=>void rO({pick:!0},e,!!t&&rl(t),i,`/api/projects/save`,c),u=e=>fetch(`/api/projects/forget`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e.path})}).then(e=>e.json()).then(e=>e.projects&&n(t=>t&&{...t,list:e.projects}),()=>{}),d=e=>{let t=e.getBoundingClientRect();n({x:t.left,y:t.bottom+V(`--menu-gap`),list:null}),fetch(`/api/projects`).then(e=>e.json()).then(e=>n(t=>t&&{...t,list:e.projects}),()=>n(e=>e&&{...e,list:[]}))},f=e=>({label:e.name,hint:e.parent,path:!0,checked:e.current,href:`/api/projects/go?path=${encodeURIComponent(e.path)}`,onClick:t=>{e.current&&!rl(t)&&!t.shiftKey&&t.preventDefault()},...e.from===`nudge`&&!e.current?{trail:{label:`Remove from recent projects`,onClick:()=>void u(e)}}:{}});return{menu:t,picking:r,temp:a,savedTo:s,keep:l,show:d,close:()=>n(null),element:t&&(0,U.jsx)(Gl,{x:t.x,y:t.y,items:(t=>{let n=t?.filter(e=>e.from===`nudge`)??[],o=t?.filter(e=>e.from===`claude`)??[],c=t?.find(e=>e.current);return[...t===null?[{label:`Loading projects…`,disabled:!0}]:[],...n.length?[{head:`Recent projects`},...n.map(f)]:[],...o.length?[{head:`From Claude Code sessions`},...o.map(f)]:[],...t?.length?[{sep:!0}]:[],r?{label:`Choosing a folder…`,disabled:!0}:{label:`Open folder…`,onClick:t=>void rO({pick:!0},e,rl(t),i)},...a&&!s&&!r?[{label:`Save project to folder…`,onClick:e=>l(e)}]:[],...c?[{label:tl?`Show in Finder`:nl?`Show in File Explorer`:`Show folder`,hint:c.path,path:!0,onClick:()=>void fetch(`/api/projects/reveal`,{method:`POST`}).then(e=>e.json()).then(t=>{t.ok||e(`Couldn’t open the folder: ${c.path}`)},()=>{})}]:[],...t?.length?[{node:(0,U.jsxs)(`div`,{className:`ctx-foot`,children:[ol(`⌘`),`-click to open in a new browser tab`]})}]:[]]})(t.list),onClose:()=>n(null)})}}function oO({name:e,folder:t,saving:n,blocked:r=!1,saveError:i=null,state:a,status:o,onRename:s,onError:c}){let[l,u]=(0,H.useState)(!1),d=aO(c),{menu:f,picking:p,temp:m,savedTo:h,keep:g}=d,_=e??t,v=iO(n,r,i);return(0,U.jsxs)(`div`,{className:`project`,children:[(0,U.jsx)(`button`,{className:`project-icon ${a} ${f?`on`:``}`,"aria-label":`Switch project · ${o}`,"aria-haspopup":`menu`,"aria-expanded":!!f,onClick:e=>f?d.close():d.show(e.currentTarget),"data-tip":f?void 0:`Switch project · ${o}`,children:(0,U.jsx)(X.folder,{})}),l?(0,U.jsx)(`input`,{className:`project-in`,autoFocus:!0,defaultValue:_,"aria-label":`Project name`,placeholder:t,onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=_,e.currentTarget.blur()))},onBlur:e=>{u(!1);let n=e.target.value.trim();n!==_&&s(!n||n===t?null:n)}}):(0,U.jsx)(`button`,{className:`project-name`,onClick:()=>{d.close(),u(!0)},"data-tip":e?`Folder: ${t}`:`Rename project`,children:_||`Untitled`}),d.element,v&&(0,U.jsxs)(`span`,{className:`project-save${v.blocked?` blocked`:``}`,role:v.blocked?`status`:void 0,children:[`— `,v.text]}),m&&h&&(0,U.jsxs)(`a`,{className:`project-temp saved`,href:h.url,"data-tip":`Copied to ${h.path}. Keep working there; this copy stays as it was.`,children:[`Copied to `,h.path.split(/[\\/]/).filter(Boolean).pop(),` · Open`]}),m&&!h&&(0,U.jsx)(`button`,{className:`project-temp`,onClick:()=>g(),disabled:p,"data-tip":`This project is in a temporary folder the system may clear. Save it to a folder to keep it.`,children:p?`Choosing a folder…`:`Temporary folder · Save…`})]})}var sO=`application/x-nudge-tab`;function cO({current:e,onError:t}){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),o=(0,H.useRef)(null),s=aO(t);(0,H.useEffect)(()=>{let e=e=>fetch(`/api/tabs${e?`?open=1`:``}`).then(e=>e.json()).then(e=>e.tabs&&r(e.tabs),()=>{});e(!0);let t=()=>{document.visibilityState===`visible`&&e(!1)},n=()=>void e(!1);return addEventListener(`focus`,n),document.addEventListener(`visibilitychange`,t),()=>{removeEventListener(`focus`,n),document.removeEventListener(`visibilitychange`,t)}},[]);let c=async e=>{let n=await(await fetch(`/api/tabs/close`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e.path})})).json().catch(()=>({}));if(n.error)return t(n.error);e.current&&n.next?location.href=n.next:n.tabs&&r(n.tabs)},l=(e,t)=>{if(!i||!e.dataTransfer.types.includes(sO)||(e.preventDefault(),i===t.path||!o.current))return;let n=e.currentTarget.getBoundingClientRect(),a=e.clientX>n.left+n.width/2,s=o.current.filter(e=>e.path!==i),c=o.current.find(e=>e.path===i),l=s.findIndex(e=>e.path===t.path)+ +!!a,u=[...s.slice(0,l),c,...s.slice(l)];u.some((e,t)=>e.path!==o.current[t].path)&&(o.current=u,r(u))},u=()=>{let e=o.current;a(null),o.current=null,e&&fetch(`/api/tabs/order`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({paths:e.map(e=>e.path)})}).then(e=>e.json()).then(e=>e.tabs&&r(e.tabs),()=>{})},d=n??[],f=d.length>1,p=e=>f&&e.path&&(0,U.jsx)(`button`,{className:`icon-btn ptab-close`,"aria-label":`Close ${e.name}`,"data-tip":`Close tab`,draggable:!1,onClick:()=>void c(e),children:(0,U.jsx)(X.close,{})}),m=t=>(0,U.jsxs)(`div`,{className:`ptab${t.current?` on`:``}${i===t.path?` dragging`:``}`,role:`tab`,"aria-selected":t.current,draggable:f&&!!t.path,onDragStart:e=>{e.dataTransfer.setData(sO,t.path),e.dataTransfer.effectAllowed=`move`,o.current=d,a(t.path)},onDragOver:e=>l(e,t),onDrop:e=>{e.preventDefault(),u()},onDragEnd:u,children:[t.current?e:(0,U.jsxs)(`a`,{className:`ptab-link`,href:t.url,draggable:!1,"data-tip":t.path,children:[(0,U.jsx)(`span`,{className:`ptab-icon`,children:(0,U.jsx)(X.folder,{})}),t.name]}),p(t)]},t.path),h=d.some(e=>e.current)?d:[...d,{path:``,name:``,url:``,current:!0}];return(0,U.jsxs)(`div`,{className:`ptabs`,role:`tablist`,"aria-label":`Projects`,children:[h.map(m),(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Open project`,"aria-haspopup":`menu`,"aria-expanded":!!s.menu,"data-tip":s.menu?void 0:`Open project`,onClick:e=>s.menu?s.close():s.show(e.currentTarget),children:(0,U.jsx)(X.plus,{})}),s.element]})}function lO(e){let t=e.checking?` · checking…`:``;return e.state===`live`?`Live prototype · drawn from the design`:e.state===`ahead`?`Design ahead · ${e.changes} change${e.changes===1?``:`s`} not in code yet${t}`:e.state===`code`?`Code ahead · its page changed, the design didn't${t}`:e.state===`sync`?(e.reviewed?`In sync · its differences were reviewed`:`In sync · matches its built page`)+t:e.checking?`Checking its built page…`:`Not verified · not compared with its built page yet`}function uO(e,t){let[n,r]=(0,H.useState)({});return(0,H.useEffect)(()=>{if(e<0)return;let t=setTimeout(()=>{fetch(`/api/sync`).then(e=>e.json()).then(e=>r(e.frames??{}),()=>{})},400);return()=>clearTimeout(t)},[e,t]),n}var dO=(e,t)=>{let n=t;for(;e.nodes[n]?.parent;)n=e.nodes[n].parent;return n},fO=e=>e.replace(/#n_[\w/-]+(?=:)/,``).replace(/ \(in (.+)\)$/,` · in $1`);function pO({doc:e,version:t,selection:n,sync:r,interactive:i,onNotice:a,onSelect:o}){let s=n.length===1&&e.nodes[n[0]]?n[0]:null,c=s?dO(e,s):null,[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)([]),y=(0,H.useMemo)(()=>{let t=new Set,n=r=>{let i=e.nodes[r];i&&(i.type===`vector`&&i.icon&&!i.icon.pack.startsWith(`folder:`)&&t.add(i.icon.pack),i.type===`frame`&&i.children.forEach(n))};return s&&n(s),[...t]},[e,s]);(0,H.useEffect)(()=>{y.length&&fetch(`/api/licenses`).then(e=>e.json()).then(e=>v(e.sets),()=>{})},[y.join()]);let b=()=>{let e=_.filter(e=>y.some(t=>t===e.id||{phosphor:`ph`,material:`material-symbols`}[t]===e.id));return e.length?`<!-- Icons: ${e.map(e=>`${e.name} (${e.license}${e.credit?`, credit required`:``})`).join(`, `)}. Licenses: design/LICENSES.md -->\n`:``},[x,S]=(0,H.useState)(new Set),[C,w]=(0,H.useState)(``),[T,E]=(0,H.useState)(null),D=s?ft(e,s):null,O=D?JSON.stringify(D):``,k=(0,H.useRef)(0);(0,H.useEffect)(()=>{if(!s){u(null);return}let e=++k.current,t=setTimeout(()=>{fetch(`/api/source?id=${encodeURIComponent(s)}`).then(e=>e.json()).then(t=>{k.current===e&&u(t)},()=>{})},150);return()=>clearTimeout(t)},[s,O,p]);let A=c?r[c]:void 0,j=A?.state===`live`,M=(0,H.useMemo)(()=>s&&e.nodes[s]?Be(e,s):null,[e,s]);(0,H.useEffect)(()=>{if(!s||!j||!M){E(null);return}let e=!1,t=e=>fetch(`/api/motion-code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}).then(e=>e.json()),n=setTimeout(()=>{(async()=>{let{each:n}=await t({id:s,each:[...M.classes.keys()]}),{sels:r,extra:i}=je(M.classes,n??{}),{code:a}=await t({id:s,classes:r});e||E({code:a??``,extra:i})})().catch(()=>{e||E(null)})},150);return()=>{e=!0,clearTimeout(n)}},[s,j,M,i]);let N=(0,H.useMemo)(()=>c&&e.nodes[c]?Be(e,c):null,[e,c]),P=s?N?.classes.get(s)??``:``;(0,H.useEffect)(()=>{S(new Set)},[s]),(0,H.useEffect)(()=>{if(!s||!j||!P){w(``);return}let e=!1,t=setTimeout(()=>{fetch(`/api/motion-code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:s,classes:{[s]:P}})}).then(e=>e.json()).then(t=>{e||w((t.code??``).replace(/^\/\* Motion \*\/\n/,``))},()=>{e||w(``)})},150);return()=>{e=!0,clearTimeout(t)}},[s,j,P,t,i]);let F=(0,H.useMemo)(()=>{if(!s||!e.nodes[s])return null;let t=T?.extra.size?Be(e,s,{svg:Je,extra:T.extra}):Be(e,s,{svg:Je});return{html:t.html,css:[t.css,T?.code].filter(Boolean).join(`
|
|
38
|
+
|
|
39
|
+
`)}},[e,s,T]);if((0,H.useEffect)(()=>{if(!c||!A||A.state===`live`){f(null);return}let e=setTimeout(()=>{fetch(`/api/frame-changes?id=${encodeURIComponent(c)}`).then(e=>e.json()).then(f,()=>f(null))},300);return()=>clearTimeout(e)},[c,t,A?.state]),(0,H.useEffect)(()=>m(null),[c]),!s)return(0,U.jsx)(`div`,{className:`panel props code-panel`,children:(0,U.jsx)(`p`,{className:`code-empty`,children:n.length>1?`Select one layer to see its code.`:`Select a layer to see its code.`})});let I=e.nodes[s],L=(e,t)=>{navigator.clipboard.writeText(t).then(()=>{g(e),setTimeout(()=>g(null),1200)},()=>a(`Couldn’t copy`))},ee=()=>{m(`running`),fetch(`/api/source-check?id=${encodeURIComponent(s)}`).then(e=>e.json()).then(e=>m(e),()=>{m(null),a(`Couldn’t check the source links`)})},R=e=>{fetch(`/api/sync/review`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e})}).then(e=>e.json()).then(e=>{e.error&&a(e.error)},()=>a(`Couldn’t mark it as reviewed`))},te=e=>{fetch(`/api/sync/update-code`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:e})}).then(e=>e.json()).then(e=>{if(e.error)return a(e.error);if(e.sent)return a(`Sent to your agent session`);e.prompt&&navigator.clipboard.writeText(e.prompt).then(()=>a(`No agent session is connected. Copied the request: paste this into your agent`),()=>a(`Couldn’t copy the request`))},()=>a(`Couldn’t send it`))};return(0,U.jsxs)(`div`,{className:`panel props code-panel`,children:[(0,U.jsx)(_O,{doc:e,id:s,root:c??s,classes:N?.classes,opened:x,setOpened:S,onSelect:o}),(0,U.jsxs)(`section`,{className:`psec code-el`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`h3`,{children:[(0,U.jsxs)(`span`,{className:`code-tag`,children:[`<`,mO(I),`>`]}),P&&(0,U.jsxs)(`span`,{className:`code-cls`,children:[`.`,P]})]}),(0,U.jsxs)(`span`,{className:`section-actions`,children:[(0,U.jsx)(`button`,{className:`panel-btn`,"aria-label":`Copy CSS`,"data-tip":h===`css`?`Copied`:`Copy this element's CSS`,onClick:()=>L(`css`,[`.${P||`layer`} {\n${Qe(ge(e,s))}\n}`,C].filter(Boolean).join(`
|
|
40
|
+
|
|
41
|
+
`)),children:h===`css`?(0,U.jsx)(X.check,{}):(0,U.jsx)(X.copy,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,"aria-label":`Copy code`,"data-tip":h===`all`?`Copied`:`Copy the HTML and CSS of it and everything in it`,onClick:()=>F&&L(`all`,`${b()}<style>\n${F.css}\n</style>\n\n${F.html}`),children:h===`all`?(0,U.jsx)(X.check,{}):(0,U.jsx)(X.code,{})})]})]}),(0,U.jsx)(`pre`,{className:`code-block code-css code-decls`,children:Qe(ge(e,s)).replace(/^ {2}/gm,``)||`/* no styles of its own */`}),C&&(0,U.jsx)(`pre`,{className:`code-block code-css code-decls`,children:C}),I.type===`text`&&I.style&&(0,U.jsxs)(`div`,{className:`code-from`,children:[`Text style `,(0,U.jsx)(`span`,{children:I.style.slice(1)})]})]}),!D&&(0,U.jsx)(nu,{title:`Source`,children:(0,U.jsx)(`p`,{className:`code-muted`,children:`Not linked to code. When your agent implements this frame in your project, it links each part here.`})}),D&&(0,U.jsx)(nu,{title:`Source`,action:l?.linked?(0,U.jsxs)(`span`,{className:`section-actions`,children:[(0,U.jsx)(`button`,{className:`panel-btn`,onClick:ee,disabled:p===`running`,"aria-label":`Check links`,"data-tip":`Check every link in this frame: files, components and selectors on the built page`,children:(0,U.jsx)(X.reload,{})}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:()=>{l?.linked&&fetch(`/api/open-source`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({file:l.link.file,line:l.line})}).then(e=>e.json()).then(e=>a(e.error??(e.editor===`explorer`?`Shown in File Explorer: ${l.link.file}. If you don't see it, it may be behind this window: check the taskbar`:e.editor===`folder`?`Showed ${l.link.file} in its folder`:`Opened ${l.link.file}${e.editor===`text`?` as text`:e.editor?` in ${e.editor[0].toUpperCase()}${e.editor.slice(1)}`:``}`)),()=>a(`Couldn’t open the file`))},"aria-label":`Open in editor`,"data-tip":`Open in editor`,children:(0,U.jsx)(X.external,{})})]}):void 0,children:!l||!l.linked?(0,U.jsx)(`p`,{className:`code-muted`,children:`Reading…`}):(0,U.jsxs)(`div`,{className:`code-src`,children:[(0,U.jsxs)(`div`,{className:`code-file`,children:[(0,U.jsx)(`span`,{className:`code-path`,"data-tip":l.link.file,children:l.link.file}),l.link.symbol&&(0,U.jsxs)(`span`,{className:`code-sym`,children:[l.link.symbol,l.line?(0,U.jsxs)(`span`,{className:`code-line`,children:[`:`,l.line]}):null]})]}),l.link.selector&&(0,U.jsxs)(`div`,{className:`code-meta`,children:[`Selector `,(0,U.jsx)(`code`,{children:l.link.selector})]}),l.from!==s&&(0,U.jsxs)(`div`,{className:`code-meta`,children:[`Inherited from `,(0,U.jsx)(`button`,{className:`code-link`,onClick:()=>o([l.from]),children:l.fromName})]}),l.problems.map(e=>(0,U.jsxs)(`div`,{className:`code-problem`,children:[(0,U.jsx)(X.warn,{}),e]},e)),p===`running`&&(0,U.jsx)(`div`,{className:`code-meta`,children:`Checking links…`}),p&&p!==`running`&&(0,U.jsxs)(`div`,{className:`code-meta`,children:[p.broken.length?`${p.broken.length} of ${p.checked} links in this frame are broken`:`All ${p.checked} links in this frame check out`,p.note?` · ${p.note}`:``]}),l.snippet&&l.snippet.lines.length>0&&(0,U.jsx)(`pre`,{className:`code-block code-snippet`,children:l.snippet.lines.map((e,t)=>(0,U.jsxs)(`div`,{className:l.snippet.from+t===l.line?`hit`:``,children:[(0,U.jsx)(`span`,{className:`ln`,children:l.snippet.from+t}),e||` `]},t))})]})}),c&&A&&(0,U.jsx)(nu,{title:`Sync`,children:(0,U.jsxs)(`div`,{className:`code-sync`,children:[(0,U.jsxs)(`div`,{className:`sync-row ${A.state}`,children:[(0,U.jsx)(`span`,{className:`sync-dot`}),lO(A)]}),A.state===`ahead`&&d?.lines.length?(0,U.jsxs)(`ul`,{className:`code-changes`,children:[d.lines.slice(0,12).map(e=>(0,U.jsx)(`li`,{children:fO(e)},e)),d.lines.length>12&&(0,U.jsxs)(`li`,{className:`code-muted`,children:[`and `,d.lines.length-12,` more`]})]}):null,A.state===`ahead`&&A.compare&&!A.compare.ok&&A.compare.summary?.length?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`code-meta`,children:`Its page also differs from the design:`}),(0,U.jsx)(`ul`,{className:`code-changes`,children:A.compare.summary.map(e=>(0,U.jsx)(`li`,{children:e},e))})]}):null,A.state===`code`&&(0,U.jsxs)(U.Fragment,{children:[A.compare?.summary?.length?(0,U.jsx)(`ul`,{className:`code-changes`,children:A.compare.summary.map(e=>(0,U.jsx)(`li`,{children:e},e))}):null,(0,U.jsxs)(`div`,{className:`sync-actions`,children:[(0,U.jsx)(`button`,{className:`chip`,onClick:()=>te(c),"data-tip":`Ask your agent session to bring the code back to the design`,children:`Update code`}),(0,U.jsx)(`button`,{className:`chip`,onClick:()=>R(c),"data-tip":`The differences are fine: show In sync until they or the design change`,children:`Mark as reviewed`})]})]})]})}),i.has(s)&&!j&&(0,U.jsx)(nu,{title:`Interaction`,children:(0,U.jsx)(`p`,{className:`code-muted`,children:`Its prototype’s motion layer (motion.css) styles this layer: hover, press or animation.`})})]})}function mO(e){return e.type===`text`?`span`:e.type===`vector`||e.type===`frame`&&e.boolean?`svg`:e.type===`shape`?e.shape.kind===`rect`||e.shape.kind===`ellipse`&&(e.shape.sweep??1)>=1&&!e.shape.ratio?`div`:`svg`:`div`}function hO(e){return e.type===`text`?`Text`:e.type===`vector`?`Icon`:e.type===`shape`?e.shape.kind===`rect`?`Rectangle`:e.shape.kind===`ellipse`?`Ellipse`:e.shape.kind===`line`?`Line`:`Shape`:e.boolean?`Boolean`:!e.children.length&&e.fills?.some(e=>e.type===`image`)?`Image`:e.layout.mode===`row`?`Row`:e.layout.mode===`column`?`Column`:`Frame`}var gO={Row:X.row,Column:X.column,Frame:X.frame,Text:X.text,Icon:X.vector,Rectangle:X.rect,Ellipse:X.ellipse,Image:X.image,Shape:X.vector,Line:X.vector,Boolean:X.vector};function _O({doc:e,id:t,root:n,classes:r,opened:i,setOpened:a,onSelect:o}){let s=new Set;for(let n=t;n;n=e.nodes[n]?.parent??null)s.add(n);let c=[],l=(n,r)=>{let a=e.nodes[n];if(!a||a.hidden||c.length>400)return;let o=a.children??[],u=o.length>0&&(n===t?!i.has(n):s.has(n)||i.has(n));if(c.push({n:a,depth:r,open:u}),u)for(let e of o)l(e,r+1)};l(n,0);let u=(0,H.useRef)(null);return(0,H.useEffect)(()=>{u.current?.querySelector(`.code-tree-row.on`)?.scrollIntoView({block:`nearest`})},[t]),(0,U.jsx)(`div`,{className:`code-tree`,role:`tree`,ref:u,children:c.map(({n:e,depth:n,open:c})=>{let l=hO(e),u=(e.children??[]).length>0,f=e.type===`text`?`“${e.content.length>28?e.content.slice(0,27)+`…`:e.content}”`:r?.get(e.id)?`.${r.get(e.id)}`:``,p=gO[l]??X.frame;return(0,U.jsxs)(`div`,{role:`treeitem`,"aria-selected":e.id===t,className:`code-tree-row ${e.id===t?`on`:``} ${n===0?`root`:``}`,style:{"--depth":n},onClick:()=>o([e.id]),"data-tip":d(e),children:[(0,U.jsx)(`button`,{className:`code-tree-caret ${c?`open`:``}`,"aria-label":c?`Collapse`:`Expand`,disabled:!u||s.has(e.id)&&e.id!==t,onClick:t=>{t.stopPropagation();let n=new Set(i);n.has(e.id)?n.delete(e.id):n.add(e.id),a(n)},children:u?(0,U.jsx)(X.caret,{}):null}),(0,U.jsx)(`span`,{className:`code-tree-icon`,children:(0,U.jsx)(p,{})}),(0,U.jsx)(`span`,{className:`code-tree-kind`,children:l}),f&&(0,U.jsx)(`span`,{className:`code-tree-label`,children:f})]},e.id)})})}var vO=`nudge:notice`,yO=e=>dispatchEvent(new CustomEvent(vO,{detail:e})),bO=vO,xO=null;function SO(){let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n);if(r.status!==428)return r;let i=await r.clone().json().catch(()=>null);return i?.browser?.missing?(xO??=(async()=>{let{download:t=100,disk:n=200}=i.browser;if(!confirm(`This Mac has no Chrome, and Nudge needs a browser to render, compare and import pages.\n\nDownload Chromium now? About ${t} MB (${n} MB on disk), once.`))return!1;yO(`Downloading Chromium (about ${t} MB)…`);let r=await e(`/api/browser/install`,{method:`POST`});return yO(r.ok?`Chromium is ready`:`Couldn’t download Chromium`),r.ok})().finally(()=>{xO=null}),await xO?e(t,n):r):r}}var CO=[{group:`Tools`,items:[{action:`Move`,keys:`V`},{action:`Scale (the layer and everything inside)`,keys:`K`},{action:`Frame`,keys:`F or A`},{action:`Text`,keys:`T`},{action:`Text box with a fixed width`,keys:`T, then drag`},{action:`Rectangle / Ellipse / Line`,keys:`R / O / L`},{action:`Square, circle, 45° line`,keys:`⇧ + drag`},{action:`Pen`,keys:`P`},{action:`Edit path points`,keys:`Enter or double-click`},{action:`Place image or video`,keys:`⇧⌘K`},{action:`Place images or videos from your computer`,keys:`Drag files in`},{action:`Comment (collect, then send all to the agent)`,keys:`C`},{action:`Ask Claude about the selection`,keys:`✦ next to selection`},{action:`Pan`,keys:`Space + drag`}]},{group:`Selection`,items:[{action:`Select all (same level)`,keys:`⌘A`},{action:`Select inverse`,keys:`⇧⌘A`},{action:`Select none`,keys:`Esc`},{action:`Deep select`,keys:`⌘ + click`},{action:`Select children`,keys:`Enter`},{action:`Select parent`,keys:`⇧Enter`},{action:`Next / previous sibling`,keys:`Tab / ⇧Tab`}]},{group:`Edit`,items:[{action:`Copy / Cut / Paste`,keys:`⌘C ⌘X ⌘V`},{action:`Paste over selection / Paste to replace`,keys:`⇧⌘V / ⌥⇧⌘V`},{action:`Duplicate`,keys:`⌘D`},{action:`Duplicate while dragging`,keys:`⌥ + drag`},{action:`Delete`,keys:`⌫`},{action:`Rename`,keys:`⌘R`},{action:`Copy / paste properties`,keys:`⌥⌘C / ⌥⌘V`},{action:`Undo / Redo`,keys:`⌘Z / ⇧⌘Z`}]},{group:`Layout`,items:[{action:`Add auto layout`,keys:`⇧A`},{action:`Remove auto layout`,keys:`⌥⇧A`},{action:`Frame selection`,keys:`⌥⌘G`},{action:`Resize to fit`,keys:`⌥⇧⌘R`},{action:`Group / Ungroup`,keys:`⌘G / ⇧⌘G`},{action:`Create component / Detach instance`,keys:`⌥⌘K / ⌥⌘B`},{action:`Union / Subtract / Intersect / Exclude`,keys:`⌥⇧U ⌥⇧S ⌥⇧I ⌥⇧E`},{action:`Flatten`,keys:`⌘E`},{action:`Outline stroke`,keys:`⌥⌘O`},{action:`Export selection (its settings, else PNG 2x)`,keys:`⇧⌘E`},{action:`Tidy up (a row, column or grid)`,keys:`⌃⌥T`},{action:`Reorder in auto layout`,keys:`Arrows along the flow`},{action:`Nudge`,keys:`Arrows (⇧ ×10)`}]},{group:`Arrange`,items:[{action:`Align left / right`,keys:`⌥A / ⌥D`},{action:`Align top / bottom`,keys:`⌥W / ⌥S`},{action:`Align centers (horizontal / vertical)`,keys:`⌥H / ⌥V`},{action:`Distribute horizontal / vertical`,keys:`⌃⌥H / ⌃⌥V`},{action:`Bring forward / Send backward`,keys:`⌘] / ⌘[`},{action:`Bring to front / Send to back`,keys:`] / [`}]},{group:`Appearance`,items:[{action:`Opacity 10–90% / 100%`,keys:`1–9 / 0`},{action:`Remove fill`,keys:`⌥/`},{action:`Swap fill and stroke`,keys:`⇧X`},{action:`Flip horizontal / vertical`,keys:`⇧H / ⇧V`},{action:`Eyedropper (fill / text color)`,keys:`I`},{action:`Show / hide`,keys:`⇧⌘H`},{action:`Lock / unlock`,keys:`⇧⌘L`}]},{group:`Text`,items:[{action:`Edit text`,keys:`Enter or double-click`},{action:`Bold / Italic`,keys:`⌘B / ⌘I`},{action:`Underline / Strikethrough`,keys:`⌘U / ⇧⌘X`},{action:`Align left / center / right`,keys:`⌥⌘L / ⌥⌘T / ⌥⌘R`},{action:`Font size −/+`,keys:`⇧⌘, / ⇧⌘.`},{action:`Letter spacing −/+`,keys:`⌥, / ⌥.`},{action:`Line height −/+`,keys:`⌥⇧, / ⌥⇧.`}]},{group:`View`,items:[{action:`Zoom in / out`,keys:`+ / −`},{action:`Zoom to 100% / fit / selection`,keys:`⌘0 or ⇧0 / ⇧1 / ⇧2`},{action:`Next / previous frame`,keys:`N / ⇧N`},{action:`Show / hide layers`,keys:`⌘\\`},{action:`Show / hide browser`,keys:`⇧⌘B`},{action:`Show / hide rulers`,keys:`⇧R`},{action:`Show / hide layout grids`,keys:`⌃G`},{action:`Show / hide pixel grid (from 400%)`,keys:`⇧'`},{action:`Measure to layer (hold)`,keys:`⌥`},{action:`Move without snapping (hold)`,keys:`⌘`},{action:`Keyboard shortcuts`,keys:`⌘/`}]}],wO=`Not in Nudge: pencil, masks, pages.`;function TO(){let[e,t]=(0,H.useState)(null);(0,H.useEffect)(()=>{let e,n=null,r=()=>{clearTimeout(e),n=null,t(null),i(0)},a=i=>{let a=i.target.closest?.(`[data-tip]`);a!==n&&(r(),a&&(n=a,e=setTimeout(()=>{let e=a.getBoundingClientRect(),n=e.bottom+40<innerHeight;t({text:a.dataset.tip,kbd:a.dataset.kbd,x:e.left+e.width/2,y:n?e.bottom+10:e.top-10,below:n})},450)))};return document.addEventListener(`pointerover`,a),document.addEventListener(`pointerdown`,r,!0),document.addEventListener(`keydown`,r,!0),()=>{clearTimeout(e),document.removeEventListener(`pointerover`,a),document.removeEventListener(`pointerdown`,r,!0),document.removeEventListener(`keydown`,r,!0)}},[]);let n=(0,H.useRef)(null),[r,i]=(0,H.useState)(0);return(0,H.useLayoutEffect)(()=>{let t=n.current;if(!t||!e)return;let r=t.offsetWidth,a=e.x-r/2;i(Math.min(Math.max(a,8),Math.max(8,innerWidth-8-r))-a)},[e]),e?(0,U.jsxs)(`div`,{ref:n,className:`tooltip ${e.below?`below`:`above`}`,style:{left:e.x+r,top:e.y,"--tail":`${-r}px`},role:`tooltip`,children:[ol(e.text),e.kbd&&(0,U.jsx)(`kbd`,{children:ol(e.kbd)})]}):null}function EO({onClose:e}){return(0,H.useEffect)(()=>{let t=t=>{(t.key===`Escape`||(t.metaKey||t.ctrlKey)&&t.key===`/`)&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]),(0,U.jsx)(`div`,{className:`sheet-backdrop`,onPointerDown:e,children:(0,U.jsxs)(`div`,{className:`sheet`,role:`dialog`,"aria-label":`Keyboard shortcuts`,onPointerDown:e=>e.stopPropagation(),children:[(0,U.jsxs)(`header`,{children:[(0,U.jsx)(`h2`,{children:`Keyboard shortcuts`}),(0,U.jsx)(`button`,{className:`icon-btn`,onClick:e,"aria-label":`Close`,children:`×`})]}),(0,U.jsx)(`div`,{className:`sheet-grid`,children:CO.map(e=>(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`h3`,{children:e.group}),(0,U.jsx)(`dl`,{children:e.items.map(e=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:e.action}),(0,U.jsx)(`dd`,{children:ol(e.keys)})]},e.action))})]},e.group))}),(0,U.jsx)(`p`,{className:`sheet-foot`,children:wO})]})})}function DO(e){if(!e||e.type!==`frame`&&e.type!==`shape`)return null;let t=e.fills??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if((n.type===`image`||n.type===`video`)&&n.visible!==!1)return{i:e,p:n}}return null}function OO(e,t){let n=e.nodes[t];return!!DO(n)&&!n?.locked}var kO=(e,t)=>DO(e.nodes[t])?.p.type===`video`?`Crop video`:`Crop image`,AO=new Map;function jO(e,t){if(!e)return;if(e.w&&e.h)return{w:e.w,h:e.h};let n=`/design/${e.file}`,r=AO.get(n);if(r!==void 0)return r??void 0;if(AO.set(n,null),e.kind===`video`){let e=document.createElement(`video`);e.preload=`metadata`,e.onloadedmetadata=()=>{AO.set(n,{w:e.videoWidth,h:e.videoHeight}),t?.()},e.src=n;return}let i=new Image;i.onload=()=>{AO.set(n,{w:i.naturalWidth,h:i.naturalHeight}),t?.()},i.src=n}function MO(e,t,n,r,i,a=1){let{x:o,y:s}=e,c=e.x+e.w,l=e.y+e.h;return n.includes(`w`)&&(o=Math.min(c-a,Math.max(t.x,o+r))),n.includes(`e`)&&(c=Math.max(o+a,Math.min(t.x+t.w,c+r))),n.includes(`n`)&&(s=Math.min(l-a,Math.max(t.y,s+i))),n.includes(`s`)&&(l=Math.max(s+a,Math.min(t.y+t.h,l+i))),{x:o,y:s,w:c-o,h:l-s}}function NO(e,t,n,r){return{...t,x:Math.min(e.x,Math.max(e.x+e.w-t.w,t.x+n)),y:Math.min(e.y,Math.max(e.y+e.h-t.h,t.y+r))}}function PO(e,t,n,r){let i=n.includes(`w`),a=n.includes(`n`),o=i?t.x+t.w:t.x,s=a?t.y+t.h:t.y,c=Math.max(Math.abs(r.x-o)/t.w,Math.abs(r.y-s)/t.h),l=Math.max(i?(o-e.x)/t.w:(e.x+e.w-o)/t.w,a?(s-e.y)/t.h:(e.y+e.h-s)/t.h),u=Math.max(c,l),d=t.w*u,f=t.h*u;return{x:i?o-d:o,y:a?s-f:s,w:d,h:f}}var FO=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],IO={n:`ns-resize`,s:`ns-resize`,e:`ew-resize`,w:`ew-resize`,ne:`nesw-resize`,sw:`nesw-resize`,nw:`nwse-resize`,se:`nwse-resize`};function LO({doc:e,id:t,box:n,view:r,host:i,onPreview:a,onCommit:o,onDone:s}){let c=e.nodes[t],l=DO(c),u=l?e.assets[l.p.asset]:void 0,d=jO(u),[f,p]=(0,H.useState)(null),m=(0,H.useRef)(null),h=(0,H.useRef)(null),g=l?.p.type===`video`?l.i:null;if((0,H.useEffect)(()=>{if(g===null)return;let e=Gf(t,g);if(!e)return;let n=!e.paused;return e.pause(),h.current&&(h.current.currentTime=e.currentTime),()=>{n&&e.play().catch(()=>{})}},[t,g]),!c||!l)return null;let _=rn(e,t),v=tn(e,t),y=Yt(v),b=_?(()=>{let{w:r,h:i}=on(e,new Map([[t,n]]),t);return{x:n.x+n.w/2-r/2,y:n.y+n.h/2-i/2,w:r,h:i}})():n,x=f?.box??b,S=f?.img??tt(b,Le(l.p,b,d)),C=Nt(e,t),w=C?FO:[`e`,`se`,`s`],T=(e,t=x)=>{let n=i.getBoundingClientRect(),a={x:(e.clientX-n.left-r.x)/r.z,y:(e.clientY-n.top-r.y)/r.z};if(!_)return a;let o=t.x+t.w/2,s=t.y+t.h/2,[c,l]=Xt(y,a.x-o,a.y-s);return{x:o+c,y:s+l}},E=(e,n,r,i)=>{let{crop:a,...o}=l.p;`pos`in o&&delete o.pos;let s={...o,fit:`crop`,crop:xe(e,n)},u={fills:(c.fills??[]).map((e,t)=>t===l.i?s:e)};Math.round(e.w)!==Math.round(r.w)&&Object.assign(u,{w:Math.round(e.w),sizeX:`fixed`}),Math.round(e.h)!==Math.round(r.h)&&Object.assign(u,{h:Math.round(e.h),sizeY:`fixed`});let[d,f]=Xt(en(c),e.x+e.w/2-(r.x+r.w/2),e.y+e.h/2-(r.y+r.h/2)),p=i.x+r.w/2+d-e.w/2,m=i.y+r.h/2+f-e.h/2;return C&&Math.abs(p-i.x)>=.005&&(u.x=Math.round(p*100)/100),C&&Math.abs(m-i.y)>=.005&&(u.y=Math.round(m*100)/100),[{op:`update`,id:t,set:u}]},D=e=>t=>{if(t.button!==0)return;t.stopPropagation(),t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId);let n=T(t);m.current={d:e,x:n.x,y:n.y,box:x,img:S,at:{x:c.x,y:c.y},ops:null}},O=e=>{let t=m.current;if(!t)return;e.stopPropagation();let n=T(e,t.box),r=n.x-t.x,i=n.y-t.y,o=t.box,s=t.img;t.d.kind===`edge`?o=MO(t.box,t.img,t.d.h,r,i):s=t.d.kind===`pan`?NO(t.box,t.img,r,i):PO(t.box,t.img,t.d.corner,n),t.ops=E(o,s,t.box,t.at),p({box:o,img:s}),a(t.ops)},k=e=>{let t=m.current;m.current=null,t&&(e.stopPropagation(),p(null),t.ops?o(t.ops,t.d.kind===`edge`?`Crop`:t.d.kind===`pan`?`Move ${l.p.type}`:`Scale ${l.p.type}`):a(null))},A={onPointerMove:O,onPointerUp:k,onPointerCancel:k},j=yl(x,r),M=yl(S,r),N=e=>({left:e.includes(`w`)?j.x:e.includes(`e`)?j.x+j.w:j.x+j.w/2,top:e.includes(`n`)?j.y:e.includes(`s`)?j.y+j.h:j.y+j.h/2}),P=_?{transform:dn(v,j.x+j.w/2,j.y+j.h/2),transformOrigin:`0 0`}:void 0,F=yl(n,r);return(0,U.jsxs)(`div`,{className:`crop-mode`,onPointerDown:e=>{e.stopPropagation(),s()},children:[(0,U.jsxs)(`div`,{className:`crop-turn`,style:P,children:[u&&(l.p.type===`video`?(0,U.jsx)(`video`,{ref:h,className:`crop-ghost`,src:`/design/${u.file}`,muted:!0,playsInline:!0,preload:`auto`,style:{left:M.x,top:M.y,width:M.w,height:M.h,objectFit:`fill`}}):(0,U.jsx)(`img`,{className:`crop-ghost`,src:`/design/${u.file}`,alt:``,draggable:!1,style:{left:M.x,top:M.y,width:M.w,height:M.h}})),(0,U.jsx)(`div`,{className:`crop-image-outline`,style:{left:M.x,top:M.y,width:M.w,height:M.h}}),(0,U.jsx)(`div`,{className:`crop-box`,style:{left:j.x,top:j.y,width:j.w,height:j.h},"data-tip":`Drag to move the ${l.p.type}`,onPointerDown:D({kind:`pan`}),...A}),[`nw`,`ne`,`sw`,`se`].map(e=>(0,U.jsx)(`span`,{className:`crop-corner`,"data-tip":`Scale the ${l.p.type}`,style:{left:e.includes(`w`)?M.x:M.x+M.w,top:e.includes(`n`)?M.y:M.y+M.h,cursor:IO[e]},onPointerDown:D({kind:`scale`,corner:e}),...A},e)),w.map(e=>(0,U.jsx)(`span`,{className:`crop-edge`,"data-tip":`Crop`,style:{...N(e),cursor:IO[e]},onPointerDown:D({kind:`edge`,h:e}),...A},e))]}),(0,U.jsx)(`div`,{className:`crop-hint`,style:{left:F.x+F.w/2,top:F.y+F.h+vl().cropHintGap},children:`Crop · Enter to finish`})]})}function RO(e,t,n){if(!t)return;let r=(e,t)=>!!e&&Object.prototype.hasOwnProperty.call(e,t),i=e=>{if(Array.isArray(e)){e.forEach(i);return}if(!e||typeof e!=`object`)return;let a=e;if(typeof a.style==`string`&&a.style.startsWith(`$`)){let e=a.style.slice(1),i=t.text?.[e];if(!r(n.text,e)&&i){delete a.style;for(let[e,t]of Object.entries(i))a[e]===void 0&&(a[e]=t)}}for(let[e,o]of Object.entries(a))if(typeof o==`string`&&o.startsWith(`$`)&&e!==`style`){let i=o.slice(1);e===`radius`?!r(n.radius,i)&&r(t.radius,i)&&(a[e]=t.radius[i]):!r(n.colors,i)&&r(t.colors,i)&&(a[e]=t.colors[i])}else i(o)};i(e)}function zO(e,t){let n=`“${e}” didn’t apply. Nothing was changed.`;if(/op\[\d+\]|Invalid (string|input|type)|must match pattern|Expected |Unrecognized key/i.test(t))return`${n} If it keeps happening, send feedback from Help.`;let r=t.replace(/^(n_[\w-]+(, ?n_[\w-]+)*):\s*/,``).trim();return r?`${n} ${r.charAt(0).toUpperCase()}${r.slice(1)}`:n}function BO(){let[e,t]=(0,H.useState)({doc:null,version:-1,connected:!1,last:null,project:``,saved:-1,chats:[],interactions:{},motion:{},syncTick:0,newer:null,saveError:null,notice:null});return(0,H.useEffect)(()=>{let e=null,n,r=!1,i=()=>{e=new WebSocket(`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`),e.onopen=()=>{t(e=>({...e,connected:!0})),fetch(`/api/health`).then(e=>e.json()).then(e=>{let n=e.project?.split(`/`).filter(Boolean).pop()??``;t(e=>e.project?e:{...e,project:n})}).catch(()=>{}),fetch(`/api/interactions`).then(e=>e.json()).then(e=>t(t=>({...t,interactions:e.frames??{},motion:e.motion??{}}))).catch(()=>{})},e.onclose=()=>{t(e=>({...e,connected:!1})),r||(n=setTimeout(i,800))},e.onmessage=e=>{let n=JSON.parse(e.data);if(n.type===`hello`)return t(e=>({...e,project:n.project}));if(n.type===`saved`)return t(e=>({...e,saved:Math.max(e.saved,n.version)}));if(n.type===`newer`)return t(e=>({...e,newer:n.message}));if(n.type===`saveError`)return t(e=>({...e,saveError:n.message}));if(n.type===`disconnected`)return t(e=>({...e,disconnected:!0}));if(n.type===`chats`)return t(e=>({...e,chats:n.chats}));if(n.type===`chat`)return t(e=>({...e,chats:[n.chat,...e.chats.filter(e=>e.id!==n.chat.id)]}));if(n.type===`interactions`)return t(e=>{let t={...e.interactions},r={...e.motion};return n.nodes.length?t[n.frame]=n.nodes:delete t[n.frame],n.moving?r[n.frame]=n.moving:delete r[n.frame],{...e,interactions:t,motion:r}});if(n.type===`notice`)return t(e=>({...e,notice:{text:n.text,at:Date.now()}}));if(n.type===`sync`)return t(e=>({...e,syncTick:e.syncTick+1}));if(n.type===`chatRemoved`)return t(e=>({...e,chats:e.chats.filter(e=>e.id!==n.id)}));if(n.type===`systemFiles`)return n.urls.forEach(Fl);let r=e=>e.label===`load`?null:{actor:e.actor,label:e.label,touched:e.touched,at:Date.now(),...e.selection?{selection:e.selection}:{}};if(n.type===`delta`){let e=!1;t(t=>{if(!t.doc||t.version!==n.base)return e=!0,t;let i={...t.doc.nodes,...n.nodes};for(let e of n.removed)delete i[e];let a={...t.doc,nodes:i};for(let[e,t]of Object.entries(n.top))t===null?delete a[e]:a[e]=t;return{...t,doc:a,version:n.version,connected:!0,last:r(n)}}),e&&fetch(`/api/doc`).then(e=>e.json()).then(e=>t(t=>e.version>=t.version?{...t,doc:e.doc,version:e.version,last:r(n)}:t))}else n.type===`doc`&&t(e=>({...e,doc:n.doc,version:n.version,connected:!0,last:r(n)}))}};return i(),()=>{r=!0,clearTimeout(n),e?.close()}},[]),e}var VO=()=>window.documentPictureInPicture;function HO({floating:e=!1}={}){let t=BO(),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=f.current=new BroadcastChannel(`nudge`);return e.onmessage=e=>{e.data?.type===`selection`&&Array.isArray(e.data.ids)&&s(e.data.ids)},e.postMessage({type:`selection?`}),()=>f.current?.close()},[]),(0,H.useEffect)(()=>{e||(document.title=`Agents · ${t.doc?.name??t.project??`Nudge`}`)},[t.doc?.name,t.project,e]),(0,H.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>a(null),2500);return()=>clearTimeout(e)},[i]);let p=async()=>{let e=VO(),t=u.current;if(!e||!t)return a(`Pinning needs Chrome 116 or newer`);try{let n=await e.requestWindow({width:Math.max(320,innerWidth),height:Math.max(420,innerHeight)});for(let e of document.head.querySelectorAll(`style, link[rel=stylesheet]`))n.document.head.appendChild(e.cloneNode(!0));n.document.documentElement.dataset.mode=`agents`,Pc(n.document),n.document.title=document.title,n.document.body.appendChild(t),d.current=n,l(!0),n.addEventListener(`pagehide`,()=>{document.getElementById(`agents-home`)?.appendChild(t),d.current=null,l(!1)})}catch{a(`Couldn’t pin the window`)}};return(0,U.jsxs)(`div`,{id:`agents-home`,className:`agents-window-home`,children:[(0,U.jsxs)(`div`,{className:`agents-pinned-note`,hidden:!c,children:[(0,U.jsx)(`p`,{children:`Agents is pinned on top.`}),(0,U.jsx)(`button`,{className:`chip`,onClick:()=>d.current?.close(),children:`Unpin`})]}),(0,U.jsxs)(`div`,{ref:u,className:`agents-window`,children:[(0,U.jsxs)(`div`,{className:`panel-title tabs`,children:[(0,U.jsxs)(`strong`,{className:`agents-window-title`,children:[`Agents`,t.chats.some(e=>e.status===`running`)&&(0,U.jsx)(`span`,{className:`run-dot`,"aria-label":`working`})]}),(0,U.jsx)(`span`,{className:`tabs-fill`}),e?null:(0,U.jsx)(`button`,{className:`panel-btn ${c?`on`:``}`,"aria-pressed":c,onClick:()=>c?d.current?.close():void p(),"aria-label":c?`Unpin`:`Pin on top`,"data-tip":c?`Unpin`:VO()?`Keep on top of other windows`:`Pinning needs Chrome 116 or newer`,children:(0,U.jsx)(X.pin,{})})]}),(0,U.jsx)(kw,{doc:t.doc,chats:t.chats,openId:n,setOpenId:r,selection:o,onNotice:a,onFrame:e=>f.current?.postMessage({type:`goFrame`,id:e})}),i&&(0,U.jsx)(`div`,{className:`agents-window-notice`,role:`status`,children:i}),!t.connected&&(0,U.jsx)(`div`,{className:`agents-window-notice`,role:`status`,children:`Disconnected · reconnecting`})]})]})}var UO=e=>[e.x,e.x+e.w/2,e.x+e.w],WO=e=>[e.y,e.y+e.h/2,e.y+e.h];function GO(e,t,n){let r=null;for(let i of e)for(let e of t){let t=e.v-i;Math.abs(t)>n||(!r||Math.abs(t)<Math.abs(r.d)-.01?r={d:t,at:e.v,lines:[e.r]}:Math.abs(t-r.d)<.01&&e.v===r.at&&r.lines.push(e.r))}return r}function KO(e,t,n,r={}){let i=r.axes??{x:!0,y:!0},a=[...t.flatMap(e=>UO(e).map(t=>({v:t,r:e}))),...(r.lines?.x??[]).map(t=>({v:t,r:{x:t,y:e.y,w:0,h:e.h}}))],o=[...t.flatMap(e=>WO(e).map(t=>({v:t,r:e}))),...(r.lines?.y??[]).map(t=>({v:t,r:{x:e.x,y:t,w:e.w,h:0}}))],s=i.x?GO(r.edges?.x??UO(e),a,n):null,c=i.y?GO(r.edges?.y??WO(e),o,n):null,l=(e,t,n)=>e?{start:e.includes(t),end:e.includes(n)}:{start:!0,end:!0},u=r.spacing??[],d=i.x&&u.length?QO(e,u,n,l(r.edges?.x,e.x,e.x+e.w)):null,f=i.y&&u.length?QO(JO(e),u.map(JO),n,l(r.edges?.y,e.y,e.y+e.h)):null,p=!!d&&(!s||Math.abs(d.d)<=Math.abs(s.d)+.01),m=!!f&&(!c||Math.abs(f.d)<=Math.abs(c.d)+.01),h=p?d.d:s?.d??0,g=m?f.d:c?.d??0;p&&s&&Math.abs(s.d-h)>.01&&(s=null),m&&c&&Math.abs(c.d-g)>.01&&(c=null);let _=r.edges?.x?qO(e.x,e.w,h,l(r.edges.x,e.x,e.x+e.w)):{x:e.x+h,w:e.w},v=r.edges?.y?qO(e.y,e.h,g,l(r.edges.y,e.y,e.y+e.h)):{x:e.y+g,w:e.h},y={x:_.x,y:v.x,w:_.w,h:v.w},b=[],x=(e,t)=>{let n=e=>t===`x`?Math.max(0,e.y-(y.y+y.h),y.y-(e.y+e.h)):Math.max(0,e.x-(y.x+y.w),y.x-(e.x+e.w));return[...e].sort((e,t)=>n(e)-n(t)).slice(0,1)};if(s){let e=[y,...x(s.lines,`x`)],t=e.flatMap(e=>e.h?[{x:s.at,y:e.y},{x:s.at,y:e.y+e.h}]:[{x:s.at,y:e.y}]);b.push({x1:s.at,x2:s.at,y1:Math.min(...e.map(e=>e.y)),y2:Math.max(...e.map(e=>e.y+e.h)),marks:t})}if(c){let e=[y,...x(c.lines,`y`)],t=e.flatMap(e=>e.w?[{x:e.x,y:c.at},{x:e.x+e.w,y:c.at}]:[{x:e.x,y:c.at}]);b.push({y1:c.at,y2:c.at,x1:Math.min(...e.map(e=>e.x)),x2:Math.max(...e.map(e=>e.x+e.w)),marks:t})}return u.length&&(i.x&&b.push(...$O(y,u,p?d.gap:null)),i.y&&b.push(...$O(JO(y),u.map(JO),m?f.gap:null).map(YO))),{dx:h,dy:g,guides:b}}var qO=(e,t,n,r)=>r.start&&r.end?{x:e+n,w:t}:r.start?{x:e+n,w:t-n}:{x:e,w:t+n},JO=e=>({x:e.y,y:e.x,w:e.h,h:e.w}),YO=e=>({...e,x1:e.y1,y1:e.x1,x2:e.y2,y2:e.x2}),XO=(e,t)=>Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y);function ZO(e,t){let n=t.filter(t=>XO(t,e)>0&&!(t.x<=e.x&&t.x+t.w>=e.x+e.w)),r=e.x+e.w/2,i=n.filter(e=>e.x+e.w<=r).sort((e,t)=>t.x+t.w-(e.x+e.w))[0],a=n.filter(e=>e.x>=r).sort((e,t)=>e.x-t.x)[0],o=[];for(let e of n)for(let t of n){let r=t.x-(e.x+e.w);r<=0||XO(e,t)<=0||n.some(n=>n!==e&&n!==t&&n.x<t.x&&n.x+n.w>e.x+e.w)||o.push({a:e,b:t,gap:r})}return{left:i,right:a,pairs:o}}function QO(e,t,n,r){let{left:i,right:a,pairs:o}=ZO(e,t),s=[...new Set(o.map(e=>e.gap))],c=[];if(i&&r.start)for(let t of s)c.push({d:i.x+i.w+t-e.x,gap:t});if(a&&r.end)for(let t of s)c.push({d:a.x-t-(e.x+e.w),gap:t});if(i&&a&&r.start&&r.end){let t=(a.x-(i.x+i.w)-e.w)/2;t>0&&c.push({d:i.x+i.w+t-e.x,gap:t})}let l=null;for(let e of c)Math.abs(e.d)<=n&&(!l||Math.abs(e.d)<Math.abs(l.d))&&(l=e);return l}function $O(e,t,n){let{left:r,right:i,pairs:a}=ZO(e,t),o=(t,n,r)=>{let i=n.x-(t.x+t.w);if(i<=.5)return null;let a=Math.max(t.y,n.y),o=Math.min(t.y+t.h,n.y+n.h),s=o>a?(a+o)/2:e.y+e.h/2,c={x1:t.x+t.w,y1:s,x2:n.x,y2:s,value:Math.round(i)};return r&&(c.equal=!0),c},s=[r&&o(r,e,n!==null),i&&o(e,i,n!==null)];if(n===null)return s.filter(e=>!!e);let c=e=>Math.abs(e-n)<.5,l=s.filter(e=>!!e&&c(e.x2-e.x1)),u=a.filter(e=>c(e.gap)).map(e=>o(e.a,e.b,!0)).filter(e=>!!e);return[...l,...u]}function ek(e,t,n,r){let i=KO({x:e.x,y:e.y,w:0,h:0},t,n,{edges:{x:[e.x],y:[e.y]},lines:r});return{x:e.x+i.dx,y:e.y+i.dy,guides:i.guides}}function tk(e,t){let n=[],r=(e,t,r,i)=>{let a=Math.round(Math.hypot(r-e,i-t));a>0&&n.push({x1:e,y1:t,x2:r,y2:i,value:a})},i=e.x+e.w,a=e.y+e.h,o=t.x+t.w,s=t.y+t.h,c=Math.max(e.x,t.x),l=Math.min(i,o),u=Math.max(e.y,t.y),d=Math.min(a,s);if(l>c&&d>u){let f=(c+l)/2,p=(u+d)/2;return r(f,Math.min(e.y,t.y),f,Math.max(e.y,t.y)),r(f,Math.min(a,s),f,Math.max(a,s)),r(Math.min(e.x,t.x),p,Math.max(e.x,t.x),p),r(Math.min(i,o),p,Math.max(i,o),p),n}let f=d>u?(u+d)/2:e.y+e.h/2;t.x>=i?r(i,f,t.x,f):e.x>=o&&r(o,f,e.x,f);let p=l>c?(c+l)/2:e.x+e.w/2;return t.y>=a?r(p,a,p,t.y):e.y>=s&&r(p,s,p,e.y),n}var nk=new Map,rk=1024,ik=3;function ak(e,t){try{let n=Math.min(1,rk/Math.max(t.naturalWidth||1,t.naturalHeight||1)),r=Math.max(1,Math.round((t.naturalWidth||300)*n)),i=Math.max(1,Math.round((t.naturalHeight||150)*n)),a=document.createElement(`canvas`);a.width=r,a.height=i;let o=a.getContext(`2d`,{willReadFrequently:!0});o.drawImage(t,0,0,r,i),nk.set(e,{data:o.getImageData(0,0,r,i).data,w:r,h:i})}catch{nk.set(e,`failed`)}}function ok(e,t){if(t instanceof HTMLImageElement&&t.complete&&t.naturalWidth>0)return ak(e,t);let n=new Image;if(n.src=e,n.complete&&n.naturalWidth>0)return ak(e,n);nk.set(e,`loading`),n.onload=()=>ak(e,n),n.onerror=()=>nk.set(e,`failed`)}function sk(e){if(e instanceof HTMLImageElement)return e.currentSrc||e.src;let t=(e.style.maskImage||e.style.webkitMaskImage||``).match(/url\("?([^")]+)"?\)/);return t?t[1]:null}function ck(e,t,n){let r=sk(e);if(!r)return!0;nk.has(r)||ok(r,e);let i=nk.get(r);if(i===void 0||i===`loading`||i===`failed`)return!0;let a=e.getBoundingClientRect();if(a.width<1||a.height<1)return!0;let o=i.w/a.width,s=i.h/a.height,c=Math.floor((t-a.left)*o),l=Math.floor((n-a.top)*s),u=Math.ceil(ik*o),d=Math.ceil(ik*s),f=Math.max(1,Math.floor(u/2)),p=Math.max(1,Math.floor(d/2));for(let e=Math.max(0,l-d);e<=Math.min(i.h-1,l+d);e+=p)for(let t=Math.max(0,c-u);t<=Math.min(i.w-1,c+u);t+=f)if(i.data[(e*i.w+t)*4+3]>8)return!0;return!1}function lk(e,t,n,r){if(r<=0)return!1;let i=t>=e.left+r&&t<=e.right-r&&n>=e.top+r&&n<=e.bottom-r;return t>=e.left-r&&t<=e.right+r&&n>=e.top-r&&n<=e.bottom+r&&!i}function uk(e){let t=60/e,n=10**Math.floor(Math.log10(t));return[1,2,5,10].map(e=>e*n).find(e=>e>=t)}function dk({view:e,width:t,height:n,sel:r,left:i=0}){let{rulerSize:a,rulerTick:o,rulerLabelGap:s,rulerTextY:c}=vl(),l=uk(e.z),u=(t,n)=>{let r=[],i=Math.floor(-n/e.z/l)*l;for(let a=i;a*e.z+n<=t;a+=l)r.push(a);return r},d=t=>t*e.z+e.x,f=t=>t*e.z+e.y,p=e=>String(Math.round(e));return(0,U.jsxs)(`svg`,{className:`rulers`,width:Math.max(0,t),height:n,style:{left:i},"aria-hidden":!0,children:[(0,U.jsx)(`rect`,{className:`ruler-bg`,x:0,y:0,width:t,height:a}),(0,U.jsx)(`rect`,{className:`ruler-bg`,x:0,y:0,width:a,height:n}),r&&(0,U.jsx)(`rect`,{className:`ruler-sel`,x:d(r.x),y:0,width:r.w*e.z,height:a}),r&&(0,U.jsx)(`rect`,{className:`ruler-sel`,x:0,y:f(r.y),width:a,height:r.h*e.z}),u(t,e.x).map(e=>{let t=Math.round(d(e))+.5;return t>a&&(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`line`,{x1:t,y1:a-o,x2:t,y2:a}),(0,U.jsx)(`text`,{x:t+s,y:c,children:p(e)})]},`x${e}`)}),u(n,e.y).map(e=>{let t=Math.round(f(e))+.5;return t>a&&(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`line`,{x1:a-o,y1:t,x2:a,y2:t}),(0,U.jsx)(`text`,{x:c,y:t-s,transform:`rotate(-90 ${c} ${t-s})`,children:p(e)})]},`y${e}`)}),r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`text`,{className:`ruler-val`,x:d(r.x)-s,y:c,textAnchor:`end`,children:p(r.x)}),(0,U.jsx)(`text`,{className:`ruler-val`,x:d(r.x+r.w)+s,y:c,children:p(r.x+r.w)}),(0,U.jsx)(`text`,{className:`ruler-val`,x:c,y:f(r.y)-s,transform:`rotate(-90 ${c} ${f(r.y)-s})`,textAnchor:`start`,children:p(r.y)}),(0,U.jsx)(`text`,{className:`ruler-val`,x:c,y:f(r.y+r.h)+s,transform:`rotate(-90 ${c} ${f(r.y+r.h)+s})`,textAnchor:`end`,children:p(r.y+r.h)})]}),(0,U.jsx)(`rect`,{className:`ruler-corner`,x:0,y:0,width:a,height:a}),(0,U.jsx)(`line`,{className:`ruler-edge`,x1:a,y1:a-.5,x2:t,y2:a-.5}),(0,U.jsx)(`line`,{className:`ruler-edge`,x1:a-.5,y1:a,x2:a-.5,y2:n})]})}var fk=6;function pk({guides:e,view:t,host:n,boxes:r,inset:i={l:0,r:0,t:0},onCommit:a}){let o=(0,H.useRef)(null),[s,c]=(0,H.useState)(null),l=n.clientWidth,u=n.clientHeight,{rulerSize:d,guideGrab:f}=vl(),p=(e,r)=>{let a=n.getBoundingClientRect(),s=e.clientX-a.left,c=e.clientY-a.top,l=r===`x`?(s-t.x)/t.z:(c-t.y)/t.z,u=Math.round(l),f=fk/t.z;for(let e of o.current?.snaps??[])Math.abs(e-l)<=f&&(f=Math.abs(e-l),u=Math.round(e));let p=s<i.l+d||c<i.t+d||s>n.clientWidth-i.r||c>n.clientHeight;return{at:u,off:p}},m=(e,t,n)=>{if(e.stopPropagation(),e.button!==0)return;e.target.setPointerCapture(e.pointerId);let i=[];for(let e of r.values())n===`x`?i.push(e.x,e.x+e.w/2,e.x+e.w):i.push(e.y,e.y+e.h/2,e.y+e.h);o.current={index:t,axis:n,at:0,off:!0,snaps:i};let a=p(e,n);Object.assign(o.current,a,{off:t===null||a.off}),c({index:t,axis:n,at:a.at,off:o.current.off})},h=e=>{let t=o.current;t&&(e.stopPropagation(),Object.assign(t,p(e,t.axis)),c({index:t.index,axis:t.axis,at:t.at,off:t.off}))},g=t=>{let n=o.current;if(o.current=null,c(null),!n)return;let r=n;if(t.stopPropagation(),t.type===`lostpointercapture`||t.type===`pointercancel`)return;let i=e.filter((e,t)=>t!==n.index);r.off?n.index!==null&&a(i.length?i:null,`Remove guide`):(n.index===null||e[n.index].at!==r.at)&&a([...i,{axis:n.axis,at:r.at}],n.index===null?`Add guide`:`Move guide`)},_=e.map((e,t)=>s&&s.index===t?{...e,at:s.at,off:s.off}:{...e,off:!1});s&&s.index===null&&_.push({axis:s.axis,at:s.at,off:s.off});let v=e=>e.axis===`x`?e.at*t.z+t.x:e.at*t.z+t.y;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`guide-pull x`,style:{left:i.l+d,top:i.t,width:Math.max(0,l-i.l-i.r-d),height:d},onPointerDown:e=>m(e,null,`y`),onPointerMove:h,onPointerUp:g,onPointerCancel:g}),(0,U.jsx)(`div`,{className:`guide-pull y`,style:{left:i.l,top:i.t+d,width:d,height:u-i.t-d},onPointerDown:e=>m(e,null,`x`),onPointerMove:h,onPointerUp:g,onPointerCancel:g}),_.map((t,n)=>{let r=t.axis===`x`,a=!!s&&(s.index===n||s.index===null&&n===_.length-1),c=v(t),p=r?i.l+d:i.t+d,y=r?l-i.r:u;if(!a&&(c<p||c>y))return null;let b=Math.min(Math.max(c,p),y);return(0,U.jsxs)(`div`,{className:`ruler-guide ${r?`v`:`h`} ${a?`on`:``} ${t.off?`off`:``}`,style:r?{left:b-f,top:i.t+d,width:f*2,height:u-i.t-d}:{left:i.l+d,top:b-f,width:Math.max(0,l-i.l-i.r-d),height:f*2},onPointerDown:r=>n<e.length&&m(r,n,t.axis),onPointerMove:h,onPointerUp:g,onPointerCancel:g,onLostPointerCapture:e=>{o.current&&g(e)},onDoubleClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`span`,{className:`ruler-guide-line`}),a&&!t.off&&(0,U.jsx)(`span`,{className:`ruler-guide-value`,children:t.at})]},n)})]})}var mk=e=>{e.preventDefault(),window.open(e.currentTarget.href,`_blank`,`noreferrer`)},hk=()=>getComputedStyle(document.documentElement).getPropertyValue(`--ed-grey-100`).trim();function gk(e){let t=e.replace(`#`,``),n=[0,2,4].map(e=>parseInt(t.slice(e,e+2),16)/255).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*n[0]+.7152*n[1]+.0722*n[2]<.35}function _k(e){let t=Ep(),n=Mc();return[...e.sections.slice(0,2),{label:`View`,items:[{label:`Layers`,kbd:`⌘\\`,checked:e.layers,onClick:e.toggleLayers},{label:`Rulers`,kbd:`⇧R`,checked:e.rulers,onClick:e.toggleRulers},{label:`Layout grids`,kbd:`⌃G`,checked:e.grids,onClick:e.toggleGrids},{label:`Pixel grid`,kbd:`⇧'`,checked:e.pixelGrid,onClick:e.togglePixelGrid},{label:`Browser`,kbd:`⇧⌘B`,checked:e.browser,onClick:e.toggleBrowser},{sep:!0},{label:`Zoom in`,kbd:`⌘+`,onClick:e.zoomIn},{label:`Zoom out`,kbd:`⌘−`,onClick:e.zoomOut},{label:`Zoom to 100%`,kbd:`⌘0`,onClick:e.zoom100},{label:`Zoom to fit`,kbd:`⇧1`,onClick:e.fitAll},{label:`Zoom to selection`,kbd:`⇧2`,disabled:!e.fitSelection,onClick:e.fitSelection},{sep:!0},{label:`Zoom to previous frame`,kbd:`⇧N`,onClick:e.previousFrame},{label:`Zoom to next frame`,kbd:`N`,onClick:e.nextFrame}]},...e.sections.slice(2),{sep:!0},{label:`Preferences`,items:[{label:`Snap to objects`,checked:t.snapObjects,onClick:()=>Dp(`snapObjects`,!t.snapObjects)},{sep:!0},{label:`Scroll wheel zooms`,checked:t.wheelZoom,onClick:()=>Dp(`wheelZoom`,!t.wheelZoom)},{sep:!0},{label:`Theme`,items:[`system`,`light`,`dark`].map(e=>({label:e===`system`?`System`:e===`light`?`Light`:`Dark`,checked:n===e,onClick:()=>Fc(e)}))},{label:`Nudge amount…`,onClick:()=>e.settings(`canvas`)}]},{label:`Help`,items:[{label:`Help page`,href:vD,onClick:mk},{label:`Keyboard shortcuts`,kbd:`⌘/`,onClick:e.shortcuts},{label:`Changelog`,href:yD,onClick:mk},{sep:!0},{label:`Send feedback…`,onClick:e.feedback}]},{sep:!0},{label:`Settings…`,kbd:`⌘,`,onClick:()=>e.settings(`general`)}]}var vk=[{id:`general`,label:`General`,icon:X.settings},{id:`canvas`,label:`Canvas`,icon:X.grid},{id:`agent`,label:`Agent`,icon:X.sparkle},{id:`connect`,label:`Connect`,icon:X.plug}];function yk({tab:e,onTab:t,onClose:n,color:r}){(0,H.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!document.querySelector(`.floating`)&&(e.stopPropagation(),n())};return addEventListener(`keydown`,e,!0),()=>removeEventListener(`keydown`,e,!0)},[n]);let i=vk.find(t=>t.id===e);return(0,U.jsx)(`div`,{className:`set-backdrop`,onPointerDown:n,children:(0,U.jsxs)(`div`,{className:`set-win`,role:`dialog`,"aria-label":`Settings`,onPointerDown:e=>e.stopPropagation(),children:[(0,U.jsxs)(`nav`,{className:`set-nav`,"aria-label":`Settings sections`,children:[(0,U.jsx)(`div`,{className:`set-nav-head`,children:`Settings`}),vk.map(n=>(0,U.jsxs)(`button`,{className:`set-tab ${n.id===e?`on`:``}`,"aria-current":n.id===e?`page`:void 0,onClick:()=>t(n.id),children:[(0,U.jsx)(n.icon,{}),n.label]},n.id)),(0,U.jsx)(DD,{})]}),(0,U.jsxs)(`section`,{className:`set-main`,children:[(0,U.jsxs)(`header`,{className:`set-head`,children:[(0,U.jsx)(`h2`,{children:i.label}),(0,U.jsx)(`button`,{className:`panel-btn`,onClick:n,"aria-label":`Close settings`,"data-tip":`Close`,"data-kbd":`Esc`,children:(0,U.jsx)(X.close,{})})]}),(0,U.jsxs)(`div`,{className:`set-body`,children:[e===`general`&&(0,U.jsx)(wk,{color:r}),e===`canvas`&&(0,U.jsx)(Tk,{}),e===`agent`&&(0,U.jsx)(jk,{}),e===`connect`&&(0,U.jsx)(Bk,{})]})]})]})})}function bk({title:e,note:t,children:n}){return(0,U.jsxs)(`div`,{className:`set-group`,children:[(0,U.jsx)(`h3`,{children:e}),t&&(0,U.jsx)(`p`,{className:`set-note`,children:t}),n]})}function xk({label:e,desc:t,children:n}){return(0,U.jsxs)(`div`,{className:`set-row`,children:[(0,U.jsxs)(`div`,{className:`set-label`,children:[(0,U.jsx)(`span`,{children:e}),t&&(0,U.jsx)(`small`,{children:t})]}),n&&(0,U.jsx)(`div`,{className:`set-ctl`,children:n})]})}function Sk({on:e,onChange:t,label:n}){return(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,className:`switch ${e?`on`:``}`,onClick:()=>t(!e),children:(0,U.jsx)(`span`,{})})}function Ck({k:e,label:t,desc:n,p:r}){return(0,U.jsx)(xk,{label:t,desc:n,children:(0,U.jsx)(Sk,{on:r[e],label:t,onChange:t=>Dp(e,t)})})}function wk({color:e}){let{pref:t}=Lc(),n=kp();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(bk,{title:`This file`,children:(0,U.jsx)(xk,{label:`Canvas color`,desc:`Saved with the file. Default follows the theme.`,children:(0,U.jsx)(Vk,{...e})})}),(0,U.jsx)(bk,{title:`Appearance`,children:(0,U.jsx)(xk,{label:`Theme`,desc:`System follows your Mac’s light or dark setting.`,children:(0,U.jsx)(eu,{value:t,onChange:e=>Fc(e),options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}]})})}),(0,U.jsx)(bk,{title:`Updates`,children:(0,U.jsx)(Ck,{p:n,k:`checkUpdates`,label:`Check for updates`,desc:`Once a day, Nudge asks npm for the newest version number and tells you when there is one. Nothing else is sent.`})})]})}function Tk(){let e=kp();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(bk,{title:`Snapping`,children:(0,U.jsx)(Ck,{p:e,k:`snapObjects`,label:`Snap to objects`,desc:`Edges and centers of other layers. Hold ⌘ while dragging to skip it once. Ruler guides always snap.`})}),(0,U.jsx)(bk,{title:`Zoom`,children:(0,U.jsx)(Ck,{p:e,k:`wheelZoom`,label:`Scroll wheel zooms`,desc:`For a mouse. Off, the wheel pans and ⌘ + wheel zooms (a trackpad).`})}),(0,U.jsxs)(bk,{title:`Nudge amount`,note:`How far the arrow keys move the selection.`,children:[(0,U.jsx)(xk,{label:`Small nudge`,children:(0,U.jsx)(`div`,{className:`set-num`,children:(0,U.jsx)(Ql,{label:null,value:e.nudgeSmall,min:.1,max:1e3,digits:1,suffix:`px`,onCommit:e=>Dp(`nudgeSmall`,e)})})}),(0,U.jsx)(xk,{label:`Big nudge`,desc:`With ⇧`,children:(0,U.jsx)(`div`,{className:`set-num`,children:(0,U.jsx)(Ql,{label:null,value:e.nudgeBig,min:.1,max:1e3,digits:1,suffix:`px`,onCommit:e=>Dp(`nudgeBig`,e)})})})]})]})}function Ek({tone:e,children:t}){return(0,U.jsxs)(`span`,{className:`set-status ${e}`,children:[(0,U.jsx)(`i`,{}),t]})}function Dk({env:e,children:t}){return e===`loading`?(0,U.jsx)(`p`,{className:`set-note`,children:`Checking this computer…`}):e===`unavailable`?(0,U.jsx)(`p`,{className:`set-note`,children:`The canvas server is older than this window. Restart it to see this section.`}):(0,U.jsx)(U.Fragment,{children:t(e)})}var Ok=e=>e.match(/\/([^/]+\.app)\//)?.[1]?.replace(/^/,`in `)??e.replace(/^\/Users\/[^/]+/,`~`);function kk(e){let t=Math.round((Date.now()-e)/6e4);return t<1?`just now`:t<60?`${t}m ago`:t<2880?`${Math.round(t/60)}h ago`:`${Math.round(t/1440)}d ago`}function Ak(){let e=Aw(),[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(null);if(!e)return null;let a=e.live?`Your Claude Code conversation in the terminal (live): requests go straight into it.`:e.last?`Your Claude Code conversation (connected ${kk(e.last.at)}): requests start from it, so they know what you discussed there.`:`This project's instructions, skills and MCP servers. When you use Nudge from a Claude Code conversation, requests pick up that conversation too, on their own.`,o=e.size?Math.round(e.size/1e3):null,s=async()=>{n(!0),i(null);let e=await(await fetch(`/api/sessions/compact`,{method:`POST`})).json().catch(()=>({ok:!1}));n(!1),e.ok||i(e.reason??`Couldn’t compact`)};return(0,U.jsxs)(bk,{title:`What requests know`,children:[(0,U.jsx)(`p`,{className:`set-note`,children:a}),e.last&&!e.live&&o!==null&&(0,U.jsxs)(`div`,{className:`set-row`,children:[(0,U.jsxs)(`div`,{className:`set-label`,children:[(0,U.jsx)(`span`,{children:e.last.base?`New chats start from a compacted copy (made ${kk(e.last.base.at)})`:`Each new chat reads about ${o}k tokens of it`}),(0,U.jsx)(`small`,{children:e.last.base?`Compact again to bring in what you discussed since.`:`A compacted copy (its /compact) makes new chats faster and cheaper; your own conversation stays as it is.`}),r&&(0,U.jsx)(`small`,{className:`set-error`,children:r})]}),(0,U.jsx)(`button`,{className:`btn`,disabled:t,onClick:()=>void s(),children:t?`Compacting…`:e.last.base?`Compact again`:`Compact a copy`})]})]})}function jk(){let e=kp(),t=Np(!0);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`set-lead`,children:[`Nudge has no AI of its own. Requests from the canvas run `,(0,U.jsx)(`b`,{children:`your`}),` agent on this computer, with your own sign-in, instructions, skills and MCP servers.`]}),(0,U.jsx)(Dk,{env:t,children:t=>{let n=t.agents.find(e=>e.id===t.preferred),r=t.agents.filter(e=>e.runs);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ak,{}),(0,U.jsxs)(bk,{title:`Runs requests with`,children:[(0,U.jsxs)(`label`,{className:`set-row set-choice`,children:[(0,U.jsx)(`input`,{type:`radio`,name:`runner`,checked:e.agentRunner===`auto`,onChange:()=>Dp(`agentRunner`,`auto`)}),(0,U.jsxs)(`div`,{className:`set-label`,children:[(0,U.jsxs)(`span`,{children:[`Automatic`,n?` · ${n.name}`:``]}),(0,U.jsx)(`small`,{children:n?.lastSeen?`The agent you last connected to Nudge over MCP.`:`No agent has connected over MCP yet: the first one ready on this computer.`})]})]}),t.agents.map(t=>(0,U.jsxs)(`label`,{className:`set-row set-choice ${t.runs?``:`off`}`,children:[(0,U.jsx)(`input`,{type:`radio`,name:`runner`,checked:e.agentRunner===t.id,disabled:!t.runs,onChange:()=>Dp(`agentRunner`,t.id)}),(0,U.jsxs)(`div`,{className:`set-label`,children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsx)(`small`,{children:[t.version,t.lastSeen?`connected ${kk(t.lastSeen)}`:null,t.path?Ok(t.path):t.lastSeen?`seen over MCP`:null].filter(Boolean).join(` · `)})]}),(0,U.jsx)(`div`,{className:`set-ctl`,children:t.runs?(0,U.jsx)(Ek,{tone:`ok`,children:`Ready`}):t.path||t.lastSeen?(0,U.jsx)(Ek,{tone:`off`,children:`Detected · not supported yet`}):(0,U.jsx)(Ek,{tone:`off`,children:`Not installed`})})]},t.id))]}),(0,U.jsx)(Mk,{runner:e.agentRunner===`auto`?n?.id===`codex`?`codex`:`claude`:e.agentRunner}),(0,U.jsx)(bk,{title:`Models`,children:r.map(t=>t.id===`codex`?(0,U.jsx)(Nk,{agent:t},t.id):(0,U.jsxs)(xk,{label:t.name,desc:`Latest follows each new release. A version stays fixed.`,children:[(0,U.jsx)(Fk,{value:e.agentModel,onChange:e=>Dp(`agentModel`,e)}),(0,U.jsx)(Pk,{value:e.claudeEffort,levels:RC.map(e=>({id:e})),onChange:e=>Dp(`claudeEffort`,e)})]},t.id))})]})}})]})}function Mk({runner:e}){let t=kp(),[n,r]=(0,H.useState)(null);(0,H.useEffect)(()=>{let t=!0;return r(null),fetch(`/api/agent/servers?runner=${e}`).then(e=>e.json()).then(e=>{t&&r(e.servers??[])},()=>{t&&r([])}),()=>{t=!1}},[e]);let i=(e,n)=>Dp(`mcpServers`,n?[...new Set([...t.mcpServers,e])]:t.mcpServers.filter(t=>t!==e));return(0,U.jsxs)(bk,{title:`Your MCP servers`,children:[(0,U.jsx)(`p`,{className:`set-note`,children:`Requests from the canvas always use Nudge's own tools. A server you turn on here is also called without asking each time. Turn on only servers you trust.`}),n===null?(0,U.jsx)(`p`,{className:`set-note`,children:`Reading your MCP servers…`}):n.length?n.map(e=>(0,U.jsx)(xk,{label:e,children:(0,U.jsx)(Sk,{on:t.mcpServers.includes(e),label:`Let requests use ${e}`,onChange:t=>i(e,t)})},e)):(0,U.jsxs)(`p`,{className:`set-note`,children:[`No MCP servers set up in `,e===`codex`?`Codex`:`Claude Code`,`.`]})]})}function Nk({agent:e}){let t=kp(),n=e.models??[],r=n.find(t=>t.id===e.defaultModel)?.name??e.defaultModel,i=n.find(e=>e.id===t.codexModel),a=i??n.find(t=>t.id===e.defaultModel),o=e.defaultEffort??a?.defaultEffort;return(0,U.jsxs)(xk,{label:e.name,desc:i?.description??(r?`Default is what Codex is set to: ${r}.`:`Default is what Codex is set to.`),children:[(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{className:`set-select`,"aria-label":`Codex model`,value:i?t.codexModel:`default`,onChange:r=>{let i=r.target.value;Dp(`codexModel`,i);let a=n.find(e=>e.id===i)??n.find(t=>t.id===e.defaultModel);t.codexEffort!=="default"&&!a?.efforts?.some(e=>e.id===t.codexEffort)&&Dp(`codexEffort`,`default`)},children:[(0,U.jsx)(`option`,{value:`default`,children:r?`Default (${r})`:`Default`}),n.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(Pk,{value:t.codexEffort,levels:a?.efforts??[],fallback:o,onChange:e=>Dp(`codexEffort`,e)})]})}function Pk({value:e,levels:t,fallback:n,onChange:r}){let i=t.some(t=>t.id===e);return(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{className:`set-select set-effort`,"aria-label":`Effort`,value:i?e:`default`,onChange:e=>r(e.target.value),"data-tip":t.find(t=>t.id===e)?.description,children:[(0,U.jsx)(`option`,{value:`default`,children:n?`Effort: Default (${BC(n)})`:`Effort: Default`}),t.map(e=>(0,U.jsx)(`option`,{value:e.id,children:`Effort: ${BC(e.id)}`},e.id))]}),(0,U.jsx)(X.chevronDown,{})]})}function Fk({value:e,onChange:t}){return(0,U.jsxs)(`div`,{className:`select-wrap`,children:[(0,U.jsxs)(`select`,{className:`set-select`,value:zC.has(e)?e:`default`,"aria-label":`Model`,onChange:e=>t(e.target.value),children:[(0,U.jsx)(`optgroup`,{label:`Latest`,children:IC.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))}),(0,U.jsx)(`optgroup`,{label:`Specific version`,children:LC.map(([e,t])=>(0,U.jsx)(`option`,{value:e,children:t},e))})]}),(0,U.jsx)(X.chevronDown,{})]})}function Ik({text:e,label:t}){let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(0);return(0,H.useEffect)(()=>()=>clearTimeout(i.current),[]),(0,U.jsx)(`button`,{className:`btn`,onClick:()=>void navigator.clipboard.writeText(e).then(()=>{r(!0),clearTimeout(i.current),i.current=window.setTimeout(()=>r(!1),1500)}),children:n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X.check,{}),`Copied`]}):t})}function Lk({client:e}){let[t,n]=(0,H.useState)(e),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),s=async e=>{i(!0),o(null);try{let r=await(await fetch(`/api/mcp`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({client:t.id,on:e})})).json();r.error?o({tone:`error`,text:r.error}):(n(r.client),o({tone:`done`,text:e?`Restart ${t.name} to load Nudge.`:`Removed. Restart ${t.name} to unload it.`}))}catch{o({tone:`error`,text:`Couldn’t reach the canvas server.`})}i(!1)},c=t.installed?a?(0,U.jsx)(`span`,{className:a.tone===`error`?`set-error`:void 0,children:a.text}):t.elsewhere&&!t.configured?`Added in a project only. Turn on for all projects.`:t.file.replace(/^\/Users\/[^/]+/,`~`):`Not installed on this computer`;return(0,U.jsx)(xk,{label:t.name,desc:c,children:t.installed?(0,U.jsx)(Sk,{on:t.configured,label:`Use Nudge in ${t.name}`,onChange:e=>{r||s(e)}}):(0,U.jsx)(Ek,{tone:`off`,children:`Not installed`})})}var Rk=`https://mcp.figma.com/mcp`,zk=`claude mcp add --transport http --scope user figma ${Rk}`;function Bk(){let e=Np(!0);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`set-lead`,children:`Work on this canvas from your agent in the terminal or another app. Nudge connects as an MCP server; the canvas starts on its own when the agent needs it.`}),(0,U.jsx)(Dk,{env:e,children:e=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(bk,{title:`Use Nudge in`,note:`Adds Nudge to the app’s MCP servers for all your projects. Turning it off removes only Nudge.`,children:e.clients.map(e=>(0,U.jsx)(Lk,{client:e},e.id))}),(0,U.jsxs)(bk,{title:`Other apps`,note:`For an app not listed above, paste this config into its MCP servers list. The command adds Nudge to Claude Code by hand.`,children:[(0,U.jsx)(`pre`,{className:`set-code`,children:e.command}),(0,U.jsxs)(`div`,{className:`set-actions`,children:[(0,U.jsx)(Ik,{text:e.command,label:`Copy command`}),(0,U.jsx)(Ik,{text:JSON.stringify(e.config,null,2),label:`Copy MCP config`})]})]}),(0,U.jsxs)(bk,{title:`Recommended MCP servers`,note:`Add these to your agent next to Nudge. Nudge doesn't connect to them; your agent uses both.`,children:[(0,U.jsx)(xk,{label:`Figma`,desc:(0,U.jsx)(U.Fragment,{children:`Send a frame to Figma, or read a Figma file to build from it. Ask your agent “send this Nudge frame to Figma”: it opens the frame as a page and Figma’s tool brings it into your file.`})}),(0,U.jsx)(`pre`,{className:`set-code`,children:zk}),(0,U.jsxs)(`div`,{className:`set-actions`,children:[(0,U.jsx)(Ik,{text:zk,label:`Copy for Claude Code`}),(0,U.jsx)(Ik,{text:Rk,label:`Copy server URL`}),(0,U.jsx)(`a`,{className:`btn`,href:`https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/`,target:`_blank`,rel:`noreferrer`,children:`Setup for other agents`})]}),(0,U.jsx)(`p`,{className:`set-note`,children:`Sending to Figma has no limit. Reading Figma files is limited by your Figma seat: 20 a month on View and Collab seats, 200 a day on Professional (more on Organization and Enterprise).`})]}),(0,U.jsxs)(bk,{title:`This canvas`,children:[(0,U.jsx)(xk,{label:`Address`,desc:`http://localhost:${e.port}`}),(0,U.jsx)(xk,{label:`Project`,desc:e.project.replace(/^\/Users\/[^/]+/,`~`)})]})]})})]})}function Vk({canvas:e,styles:t,onPreview:n,onCommit:r}){let[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(null),s=hk(),c=e?e.startsWith(`$`)?t[e.slice(1)]??s:e:s,l=i?o.current?.getBoundingClientRect():void 0;return(0,U.jsxs)(`div`,{className:`page-bg`,children:[e&&(0,U.jsx)(`button`,{className:`icon-btn fit`,"aria-label":`Reset canvas color`,"data-tip":`Reset to default`,onClick:()=>r(null),children:(0,U.jsx)(X.reload,{})}),(0,U.jsx)(`span`,{className:`page-bg-val`,children:e?.startsWith(`$`)?e.slice(1):e?c.replace(`#`,``).toUpperCase():`Default`}),(0,U.jsx)(`button`,{ref:o,className:`swatch ${i?`on`:``}`,"aria-label":`Canvas color`,"aria-expanded":i,style:{background:c},onClick:()=>a(!i)}),i&&(0,U.jsx)(Bd,{value:e??s,at:l?{left:l.right-248,top:l.bottom+8}:void 0,onClose:()=>a(!1),onPreview:n,onCommit:e=>r(e)})]})}var Hk=(e,t)=>e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h;function Uk(e,t,n,r){let i=e=>n.find(t=>Hk(e,t));if(!i(e))return e;let a={...e,x:t.x,y:t.y+t.h+r};if(!i(a))return a;let o=e;for(let e=0,t=i(o);t&&e<64;e++,t=i(o))o={...o,x:t.x+t.w+r};return o}var Wk=80;function Gk(e,t,n,r=[]){let i=t??{x:e.x,y:e.y,w:e.w,h:e.h},a=i.h>Bl(i.w)*1.25?Bl(i.w):i.h,o=e.build?.beside??{x:0,y:0},s={x:i.x+i.w+Wk+o.x,y:i.y+o.y,w:Math.round(n?.w??i.w),h:Math.round(n?.h??a)};return{frame:i,page:e.build?.beside?s:Uk(s,i,r,Wk)}}var Kk={w:240,h:320},qk={w:2560,h:2e3};function Jk({frame:e,page:t,z:n}){if(t.y>=e.y+e.h){let r=e.x+e.w/2,i=e.y+e.h,a=t.x+t.w/2,o=t.y,s=Math.max(40/n,(o-i)/2);return(0,U.jsxs)(`g`,{className:`beside-link`,children:[(0,U.jsx)(`path`,{d:`M ${r} ${i} C ${r} ${i+s}, ${a} ${o-s}, ${a} ${o}`,strokeWidth:1.5/n,strokeDasharray:`${4/n} ${3/n}`}),(0,U.jsx)(`circle`,{cx:r,cy:i,r:3/n}),(0,U.jsx)(`circle`,{cx:a,cy:o,r:3/n})]})}let r=t.x>=e.x+e.w/2,i=r?e.x+e.w:e.x,a=r?t.x:t.x+t.w,o=e.y+Math.min(e.h,t.h)/2,s=t.y+Math.min(e.h,t.h)/2,c=Math.max(40/n,Math.abs(a-i)/2)*(r?1:-1),l=`M ${i} ${o} C ${i+c} ${o}, ${a-c} ${s}, ${a} ${s}`;return(0,U.jsxs)(`g`,{className:`beside-link`,children:[(0,U.jsx)(`path`,{d:l,strokeWidth:1.5/n,strokeDasharray:`${4/n} ${3/n}`}),(0,U.jsx)(`circle`,{cx:i,cy:o,r:3/n}),(0,U.jsx)(`circle`,{cx:a,cy:s,r:3/n})]})}function Yk({doc:e,view:t,boxes:n,selection:r,hover:i,onOpen:a,onCommit:o}){let s=kl(),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=(0,H.useRef)(null),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(!v)return;let t=e.nodes[v.id]?.type===`frame`?e.nodes[v.id].build?.beside:void 0;if(t&&t.x===v.x&&t.y===v.y)return y(null);let n=setTimeout(()=>y(null),3e3);return()=>clearTimeout(n)},[e,v]),(0,H.useEffect)(()=>{if(!s.scrolling)return;let e=e=>{e.target?.closest?.(`.build-live[data-frame="${s.scrolling}"]`)||Nl(null)};return addEventListener(`pointermove`,e,!0),addEventListener(`pointerdown`,e,!0),()=>{removeEventListener(`pointermove`,e,!0),removeEventListener(`pointerdown`,e,!0)}},[s.scrolling]);let b=e.roots.map(t=>e.nodes[t]).filter(e=>e?.type===`frame`&&!!e.build&&Sl(s.views,e.id)!==`off`);if(!b.length)return null;let x=new Set(r.map(t=>{let n=e.nodes[t];for(;n?.parent;)n=e.nodes[n.parent];return n?.id})),S=e=>t=>{t.stopPropagation(),t.target.closest(`button`)||t.button!==0||(t.currentTarget.setPointerCapture(t.pointerId),f.current={id:e.id,x:t.clientX,y:t.clientY,moved:!1})},C=e=>{let n=f.current;if(!n)return;let r=(e.clientX-n.x)/t.z,i=(e.clientY-n.y)/t.z;!n.moved&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<3||(n.moved=!0,d({id:n.id,dx:r,dy:i}))},w=e=>()=>{let t=f.current;if(f.current=null,!t?.moved||!u||!e.build)return d(null);let n=e.build.beside??{x:0,y:0},r={x:Math.round(n.x+u.dx),y:Math.round(n.y+u.dy)};y({id:e.id,...r}),d(null),o([{op:`update`,id:e.id,set:{build:{...e.build,beside:r}}}],`Move beside page`)},T=e=>o([{op:`update`,id:e.id,set:{build:{...e.build,beside:void 0}}}],`Reset beside page`),E=(e,t,n)=>r=>{r.stopPropagation(),r.button===0&&(r.currentTarget.setPointerCapture(r.pointerId),h.current={id:e.id,edge:n,x:r.clientX,y:r.clientY,w:t.w,h:t.h},m({id:e.id,w:t.w,h:t.h}))},D=e=>{let n=h.current;if(!n)return;let r=(e,t,n)=>Math.round(Math.min(n,Math.max(t,e))),i=n.edge===`s`?n.w:r(n.w+(e.clientX-n.x)/t.z,Kk.w,qk.w),a=n.edge===`e`?n.h:r(n.h+(e.clientY-n.y)/t.z,Kk.h,qk.h);m({id:n.id,w:i,h:a})},O=()=>{let e=h.current;h.current=null,e&&p&&(p.w!==e.w||p.h!==e.h)&&jl(e.id,{w:p.w,h:p.h}),m(null)},k=[];for(let t of b){let r=v?.id===t.id?{...t,build:{...t.build,beside:{x:v.x,y:v.y}}}:t,i=[...e.roots.filter(e=>e!==t.id).map(e=>n.get(e)).filter(e=>!!e),...k.map(e=>e.page)],{frame:a,page:o}=Gk(r,n.get(t.id),p?.id===t.id?p:s.sizes[t.id],i);u?.id===t.id&&(o.x+=u.dx,o.y+=u.dy),k.push({f:t,frame:a,page:o})}let A=e=>x.has(e)||i===e||c===e||u?.id===e||v?.id===e||s.interacting===e||p?.id===e;return(0,U.jsxs)(`div`,{className:`builds`,children:[g&&(0,U.jsx)(`div`,{onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(0,U.jsx)(Gl,{x:g.x,y:g.y,items:((e,t)=>{let n=s.sizes[e];return[{label:`Frame width`,kbd:String(t),checked:!n,onClick:()=>jl(e,null)},...Cl.map(t=>({label:t.name,kbd:`${t.w} × ${t.h}`,checked:n?.w===t.w&&n?.h===t.h,onClick:()=>jl(e,{w:t.w,h:t.h})}))]})(g.id,g.frameW),onClose:()=>_(null)})}),(0,U.jsx)(`svg`,{className:`beside-links`,"aria-hidden":!0,children:k.filter(e=>A(e.f.id)).map(e=>(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(Jk,{frame:e.frame,page:e.page,z:t.z}),(c===e.f.id||u?.id===e.f.id)&&!x.has(e.f.id)&&(0,U.jsx)(`rect`,{className:`beside-pair`,x:e.frame.x,y:e.frame.y,width:e.frame.w,height:e.frame.h,strokeWidth:1.5/t.z})]},e.f.id))}),k.map(({f:n,frame:r,page:i})=>{let o=i.h,c=n.build.url,d=s.interacting===n.id,f=i.w*t.z,m=f>=320?`full`:f>=140?`compact`:`tiny`;return(0,U.jsxs)(`div`,{"data-frame":n.id,className:`build-live ${d?`live`:``} ${s.scrolling===n.id?`scrolling`:``} ${A(n.id)&&!d?`paired`:``} ${u?.id===n.id?`dragging`:``} ${p?.id===n.id?`resizing`:``} bar-${m}`,style:{left:i.x,top:i.y,width:i.w,height:o},onPointerEnter:()=>l(n.id),onPointerLeave:()=>l(e=>e===n.id?null:e),children:[(0,U.jsxs)(`div`,{className:`build-bar`,style:{transform:`scale(${1/t.z})`,maxWidth:f},onPointerDown:S(n),onPointerMove:C,onPointerUp:w(n),onPointerCancel:w(n),onDoubleClick:e=>{e.stopPropagation(),n.build?.beside&&!e.target.closest(`button`)&&T(n)},children:[(0,U.jsxs)(`span`,{className:`build-host`,"data-tip":`${c.replace(/^https?:\/\//,``)} · drag to move`,children:[(0,U.jsx)(X.frame,{}),(0,U.jsx)(`span`,{children:n.name})]}),(0,U.jsx)(`button`,{className:`build-size ${g?.id===n.id?`on`:``}`,"aria-haspopup":`menu`,"aria-expanded":g?.id===n.id,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();_(g?.id===n.id?null:{id:n.id,x:t.left,y:t.bottom+V(`--menu-gap`),frameW:r.w})},"data-tip":g?.id===n.id?void 0:`Page size · or drag its edges`,children:m===`full`?`${i.w} × ${o}`:i.w}),n.build?.beside&&(0,U.jsx)(`button`,{onClick:()=>T(n),"aria-label":`Reset position`,"data-tip":`Back beside the frame · or double-click the bar`,children:(0,U.jsx)(X.beside,{})}),(0,U.jsx)(`button`,{className:`opt`,onClick:()=>Fl(c),"aria-label":`Reload`,"data-tip":`Reload the page`,children:(0,U.jsx)(X.reload,{})}),(0,U.jsx)(`button`,{onClick:()=>Ml(d?null:n.id),className:d?`on`:``,"aria-label":d?`Done`:`Interact`,"data-tip":m===`full`?void 0:d?`Done`:`Interact with the page`,children:m===`full`?d?`Done`:`Interact`:(0,U.jsx)(X.move,{})}),a&&(0,U.jsx)(`button`,{className:`opt`,onClick:()=>a(c,i.w),"aria-label":`Open in browser panel`,"data-tip":`Open in Nudge’s browser panel`,children:(0,U.jsx)(X.globe,{})}),(0,U.jsx)(`button`,{className:`opt`,onClick:()=>window.open(c,`_blank`,`noopener`),"aria-label":`Open in new window`,"data-tip":`Open in a new browser window`,children:(0,U.jsx)(X.external,{})}),(0,U.jsx)(`button`,{onClick:()=>Al(n.id,`off`),"aria-label":`Hide build`,"data-tip":`Hide from beside the frame`,children:(0,U.jsx)(X.close,{})})]}),(0,U.jsx)(Qk,{url:c,frame:n.id,doc:e,title:`Build of ${n.name}`,width:i.w,height:o},`${c}#${s.reloads[c]??0}`),[`e`,`s`,`se`].map(e=>(0,U.jsx)(`div`,{className:`build-resize ${e}`,style:{"--k":1/t.z},onPointerDown:E(n,i,e),onPointerMove:D,onPointerUp:O,onPointerCancel:O,onDoubleClick:e=>e.stopPropagation()},e)),p?.id===n.id&&(0,U.jsxs)(`div`,{className:`build-size-tip`,style:{transform:`translateX(-50%) scale(${1/t.z})`},children:[i.w,` × `,o]})]},n.id)})]})}var Xk=new Map,Zk=e=>{let t=Xk.get(e);return t||(t=fetch(`/api/live/url?url=${encodeURIComponent(e)}`).then(e=>e.json()).then(t=>t.url??e,()=>e),Xk.set(e,t)),t};function Qk({url:e,frame:t,doc:n,title:r,width:i,height:a}){let[o,s]=(0,H.useState)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=!0;return Zk(e).then(e=>{t&&s(e)}),()=>{t=!1}},[e]);let u=e=>{let t=c.current?.contentWindow;if(t&&o)try{t.postMessage({type:`nudge-preview`,preview:e},new URL(o).origin)}catch{}};return(0,H.useEffect)(()=>{if(!o||o===e)return;let n=!0,r=setTimeout(()=>{fetch(`/api/live/preview?id=${encodeURIComponent(t)}`).then(e=>e.json()).then(e=>{n&&(l.current=e.preview,u(e.preview))},()=>{})},120);return()=>{n=!1,clearTimeout(r)}},[n,o]),(0,H.useEffect)(()=>{let e=e=>{e.source===c.current?.contentWindow&&e.data?.type===`nudge-preview-ready`&&u(l.current)};return addEventListener(`message`,e),()=>removeEventListener(`message`,e)},[o]),o?(0,U.jsx)(`iframe`,{ref:c,src:o,title:r,width:i,height:a,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-modals`}):null}var $k=`nudge.presetGroups`;function eA({onPick:e}){let[t,n]=(0,H.useState)(()=>{try{let e=JSON.parse(localStorage.getItem($k)??`null`);if(Array.isArray(e))return new Set(e)}catch{}return new Set([`Phone`])}),r=e=>n(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem($k,JSON.stringify([...n]))}catch{}return n});return(0,U.jsxs)(`aside`,{className:`panel props presets`,"aria-label":`Frame presets`,children:[(0,U.jsxs)(`div`,{className:`props-head`,children:[(0,U.jsx)(`strong`,{children:`Frame`}),(0,U.jsx)(`span`,{children:`Draw on the canvas, or pick a size`})]}),FC.map(n=>(0,U.jsxs)(`section`,{className:`preset-group`,children:[(0,U.jsxs)(`button`,{className:`preset-group-head`,"aria-expanded":t.has(n.name),onClick:()=>r(n.name),children:[(0,U.jsx)(`span`,{className:`preset-caret ${t.has(n.name)?`open`:``}`,"aria-hidden":!0,children:(0,U.jsx)(X.caret,{})}),n.name]}),t.has(n.name)&&n.presets.map(t=>(0,U.jsxs)(`button`,{className:`preset`,onClick:()=>e(t),children:[(0,U.jsx)(`span`,{children:t.name}),(0,U.jsxs)(`span`,{className:`preset-dim`,children:[t.w,`×`,t.h]})]},t.name))]},n.name))]})}function tA(e,t){let n=t===`x`?`w`:`h`,r=[...e].sort((e,n)=>e.r[t]-n.r[t]),i=[],a=new Map;for(let e of r){let r=e.r[t]+e.r[n]/2,o=i.findIndex(e=>r>=e.lo&&r<=e.hi);o<0&&(i.push({lo:e.r[t],hi:e.r[t]+e.r[n]}),o=i.length-1),a.set(e.id,o)}return a}function nA(e,t,n,r,i=!1){let a=r===`x`?`w`:`h`,o=Array(n).fill(1/0),s=Array(n).fill(-1/0);for(let n of e){let e=t.get(n.id);o[e]=Math.min(o[e],n.r[r]),s[e]=Math.max(s[e],n.r[r]+n.r[a])}let c=Array.from({length:n-1},(e,t)=>o[t+1]-s[t]);return i?c:c.some(e=>Math.abs(e-c[0])>1)?null:c}function rA(e,t,n,r=!1){if(t.length<2)return null;let i=e.nodes[t[0]]?.parent,a=[];for(let r of t){let t=e.nodes[r],o=n.get(r);if(!t||!o||t.parent!==i||t.locked||t.hidden||!Nt(e,r))return null;a.push({id:r,r:o})}let o=tA(a,`y`),s=tA(a,`x`),c=e=>new Map([...e.keys()].map(e=>[e,0])),l=e=>{let t=e===`y`?`x`:`y`,n=t===`x`?`w`:`h`,r=[...a].sort((t,n)=>t.r[e]-n.r[e]);return r.every((e,i)=>i===0||e.r[t]<r[i-1].r[t]+r[i-1].r[n]&&r[i-1].r[t]<e.r[t]+e.r[n])};new Set(o.values()).size===a.length&&new Set(s.values()).size>1&&l(`y`)?s=c(s):new Set(s.values()).size===a.length&&new Set(o.values()).size>1&&l(`x`)&&(o=c(o));let u=Math.max(...o.values())+1,d=Math.max(...s.values())+1,f=new Set,p=Array(u).fill(0);for(let e of a){let t=`${o.get(e.id)},${s.get(e.id)}`;if(f.has(t))return null;f.add(t),p[o.get(e.id)]++}for(let e=0;e<u;e++){let t=e<u-1?d:p[e];for(let n=0;n<d;n++)if(f.has(`${e},${n}`)!==n<t)return null}let m=d>1?nA(a,s,d,`x`,r):[],h=u>1?nA(a,o,u,`y`,r):[];if(!m||!h)return null;let g=r?e=>{if(!e.length)return 0;let t=e[0],n=0;for(let r of e){let i=e.filter(e=>Math.abs(e-r)<=1).length;i>n&&(n=i,t=r)}return t}:e=>e.length?e.reduce((e,t)=>e+t,0)/e.length:0,_=[...a].sort((e,t)=>o.get(e.id)-o.get(t.id)||s.get(e.id)-s.get(t.id));return{ids:_.map(e=>e.id),slots:_.map(e=>e.r),row:o,col:s,rows:u,cols:d,gapX:g(m),gapY:g(h)}}function iA(e,t,n){let r=new Map,i=e.rows===1?`x`:e.cols===1?`y`:null;if(!i)return t.forEach((t,n)=>r.set(t,{x:e.slots[n].x,y:e.slots[n].y})),r;let a=i===`x`?`w`:`h`,o=i===`x`?e.gapX:e.gapY,s=e.slots[0][i];return t.forEach((t,c)=>{let l=e.slots[c];r.set(t,i===`x`?{x:s,y:l.y}:{x:l.x,y:s}),s+=n.get(t)[a]+o}),r}function aA(e,t,n,r){let i=0,a=1/0;e.slots.forEach((e,t)=>{let o=Math.hypot(e.x+e.w/2-n,e.y+e.h/2-r);o<a&&(a=o,i=t)});let o=e.ids.filter(e=>e!==t);return[...o.slice(0,i),t,...o.slice(i)]}function oA(e,t){let n=Array(e.cols).fill(0),r=Array(e.rows).fill(0),i=1/0,a=1/0;for(let o of e.ids){let s=t.get(o);n[e.col.get(o)]=Math.max(n[e.col.get(o)],s.w),r[e.row.get(o)]=Math.max(r[e.row.get(o)],s.h),i=Math.min(i,s.x),a=Math.min(a,s.y)}let o=Math.round(e.gapX),s=Math.round(e.gapY),c=n.map((e,t)=>i+n.slice(0,t).reduce((e,t)=>e+t+o,0)),l=r.map((e,t)=>a+r.slice(0,t).reduce((e,t)=>e+t+s,0));if(e.rows===1||e.cols===1){let n=e.rows===1?`x`:`y`,r=n===`x`?`w`:`h`,c=n===`x`?o:s,l=n===`x`?i:a;return new Map(e.ids.map(e=>{let i=t.get(e),a=n===`x`?{x:l,y:i.y}:{x:i.x,y:l};return l+=i[r]+c,[e,a]}))}return new Map(e.ids.map(t=>[t,{x:c[e.col.get(t)],y:l[e.row.get(t)]}]))}function sA(e,t,n){if(t.length<2)return null;let r=e.nodes[t[0]]?.parent,i=[];for(let a of t){let t=e.nodes[a],o=n.get(a);if(!t||!o||t.parent!==r||t.locked||t.hidden||!Nt(e,a))return null;i.push({id:a,r:o})}let a=tA(i,`y`),o=Math.max(...a.values())+1,s=[...i].sort((e,n)=>a.get(e.id)-a.get(n.id)||e.r.x-n.r.x||t.indexOf(e.id)-t.indexOf(n.id)),c=Array.from({length:o},()=>[]);for(let e of s)c[a.get(e.id)].push(e.id);let l=[];for(let e of c)for(let t=1;t<e.length;t++){let r=n.get(e[t-1]),i=n.get(e[t]);l.push(i.x-(r.x+r.w))}for(let e=1;e<o;e++){let t=Math.min(...c[e].map(e=>n.get(e).y)),r=Math.max(...c[e-1].map(e=>n.get(e).y+n.get(e).h));l.push(t-r)}let u=l.filter(e=>e>.5),d=0,f=0;for(let e of u){let t=u.filter(t=>Math.abs(t-e)<=1).length;t>f&&(f=t,d=e)}d=Math.round(d);let p=new Map,m=new Map,h,g;o===1?(g=Math.ceil(Math.sqrt(i.length)),h=Math.ceil(i.length/g),s.forEach((e,t)=>{p.set(e.id,Math.floor(t/g)),m.set(e.id,t%g)})):(h=o,g=Math.max(...c.map(e=>e.length)),c.forEach((e,t)=>e.forEach((e,n)=>{p.set(e,t),m.set(e,n)})));let _=[...i].sort((e,t)=>p.get(e.id)-p.get(t.id)||m.get(e.id)-m.get(t.id));return{ids:_.map(e=>e.id),slots:_.map(e=>e.r),row:p,col:m,rows:h,cols:g,gapX:d,gapY:d}}function cA(e,t,n){return rA(e,t,n,!0)??sA(e,t,n)}function lA(e,t,n){let r=cA(e,t,n);return r?uA(new Map(r.ids.map(t=>[t,{x:e.nodes[t].x,y:e.nodes[t].y}])),r,n,oA(r,n)).filter(t=>{let n=t.set,r=e.nodes[t.id];return n.x!==r.x||n.y!==r.y}):[]}function uA(e,t,n,r,i){let a=[];for(let o of t.ids){let t=e.get(o),s=n.get(o),c=r.get(o),l=c.x-s.x,u=c.y-s.y;i?.id===o&&(l=i.dx,u=i.dy),Math.abs(l)<.01&&Math.abs(u)<.01||a.push({op:`update`,id:o,set:{x:Math.round(t.x+l),y:Math.round(t.y+u)}})}return a}function dA(e,t,n,r){let i=r-(n===`x`?t.gapX:t.gapY),a=[];for(let r of t.ids){let o=(n===`x`?t.col:t.row).get(r),s=Math.round(o*i);if(!s)continue;let c=e.get(r);a.push({op:`update`,id:r,set:n===`x`?{x:c.x+s}:{y:c.y+s}})}return a}function fA({doc:e,selection:t,boxes:n,view:r,onPreview:i,onCommit:a}){let o=(0,H.useRef)(null),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=o.current?.grid??rA(e,t,n),m=o.current||s||l?[]:lA(e,t,n),h=()=>{m.length&&a(m,`Tidy up`)},g=m.length?cA(e,t,n):null,_=g&&Vt(t.map(e=>n.get(e)).filter(e=>!!e)),v=g&&_&&(()=>{let e=yl(_,r),{tidySize:t,gap:n}=vl(),i=e.w>=3*t&&e.h>=3*t,a=i?e.x+e.w-t-n:e.x+e.w+n,o=i?e.y+e.h-t-n:e.y+e.h-t,s=g.rows===1?`row`:g.cols===1?`col`:`grid`;return(0,U.jsx)(`button`,{className:`tidy-up`,style:{left:a,top:o},"aria-label":`Tidy up`,"data-tip":`Tidy up`,"data-kbd":`⌃⌥T`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:h,children:(0,U.jsxs)(`svg`,{viewBox:`0 0 14 14`,fill:`currentColor`,children:[s===`col`&&[2,6,10].map(e=>(0,U.jsx)(`rect`,{x:`1.5`,y:e,width:`11`,height:`2`,rx:`1`},e)),s===`row`&&[2,6,10].map(e=>(0,U.jsx)(`rect`,{x:e,y:`1.5`,width:`2`,height:`11`,rx:`1`},e)),s===`grid`&&[[2,2],[8,2],[2,8],[8,8]].map(([e,t])=>(0,U.jsx)(`rect`,{x:e,y:t,width:`4`,height:`4`,rx:`1`},`${e}${t}`))]})})})();if(!p)return v||null;let y=o.current?.boxes??n,b=t=>({grid:p,sx:t.clientX,sy:t.clientY,boxes:new Map(n),base:new Map(p.ids.map(t=>[t,{x:e.nodes[t].x,y:e.nodes[t].y}]))}),x=new Map(p.ids.map(e=>[`${p.row.get(e)},${p.col.get(e)}`,e])),S=[];for(let e of p.ids){let t=p.row.get(e),n=p.col.get(e),r=y.get(e),i=x.get(`${t},${n+1}`),a=x.get(`${t+1},${n}`);if(i){let e=y.get(i),a=Math.max(r.y,e.y),o=Math.min(r.y+r.h,e.y+e.h),s=o>a?a:Math.min(r.y,e.y),c=o>a?o:Math.max(r.y+r.h,e.y+e.h);S.push({axis:`x`,key:`x${t},${n}`,r:{x:r.x+r.w,y:s,w:e.x-(r.x+r.w),h:c-s}})}if(a){let e=y.get(a),i=Math.max(r.x,e.x),o=Math.min(r.x+r.w,e.x+e.w),s=o>i?i:Math.min(r.x,e.x),c=o>i?o:Math.max(r.x+r.w,e.x+e.w);S.push({axis:`y`,key:`y${t},${n}`,r:{x:s,y:r.y+r.h,w:c-s,h:e.y-(r.y+r.h)}})}}let C=e=>Math.round(e===`x`?p.gapX:p.gapY);return(0,U.jsxs)(U.Fragment,{children:[v,s?.to&&(()=>{let e=y.get(s.id),t=yl({x:s.to.x,y:s.to.y,w:e.w,h:e.h},r);return(0,U.jsx)(`div`,{className:`smart-slot`,style:{left:t.x,top:t.y,width:t.w,height:t.h}})})(),!s&&S.map(e=>{let t=yl(e.r,r),n=e.axis===`x`,s=n?t.w:t.h,c=(n?t.x:t.y)+s/2,m=vl().handle,h=s>=m?t:n?{...t,x:c-m/2,w:m}:{...t,y:c-m/2,h:m},g=d===e.key||l?.key===e.key;return(0,U.jsxs)(`div`,{className:`smart-gap ${g?`on`:``}`,style:{left:h.x,top:h.y,width:h.w,height:h.h,cursor:xt(n?0:90)},onPointerEnter:()=>f(e.key),onPointerLeave:()=>f(t=>t===e.key?null:t),onPointerDown:t=>{t.stopPropagation(),t.button===0&&(t.target.setPointerCapture(t.pointerId),o.current={kind:`gap`,...b(t),axis:e.axis,gap:n?p.gapX:p.gapY},u({key:e.key,value:C(e.axis)}))},onPointerMove:t=>{let n=o.current;if(!n||n.kind!==`gap`)return;t.stopPropagation();let a=(n.axis===`x`?t.clientX-n.sx:t.clientY-n.sy)/r.z,s=Math.min(...n.grid.ids.map(e=>n.boxes.get(e)[n.axis===`x`?`w`:`h`]));n.gap=Math.max(Math.ceil(-s/2)+1,Math.round((n.axis===`x`?n.grid.gapX:n.grid.gapY)+a)),u({key:e.key,value:n.gap}),i(dA(n.base,n.grid,n.axis,n.gap))},onPointerUp:e=>{let t=o.current;if(o.current=null,u(null),!t||t.kind!==`gap`)return;e.stopPropagation();let n=dA(t.base,t.grid,t.axis,t.gap);n.length?a(n,`Spacing`):i(null)},onDoubleClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`span`,{className:`smart-gap-bar`,style:n?{width:vl().indicator,height:Math.min(vl().smartBarLen,h.h)}:{width:Math.min(vl().smartBarLen,h.w),height:vl().indicator}}),g&&(0,U.jsx)(`span`,{className:`spacing-value`,children:l?.key===e.key?l.value:C(e.axis)})]},e.key)}),p.ids.map(e=>{let t=yl(y.get(e),r);if(t.w<24||t.h<24)return null;let n=s?.id===e?s:null;if(s&&!n)return null;let l=t.x+t.w/2+(n?.dx??0),u=t.y+t.h/2+(n?.dy??0);return(0,U.jsx)(`div`,{className:`smart-dot ${n?`on`:``}`,style:{left:l,top:u},role:`button`,"aria-label":`Drag to reorder`,onPointerDown:t=>{t.stopPropagation(),t.button===0&&(t.target.setPointerCapture(t.pointerId),o.current={kind:`ring`,...b(t),id:e,order:p.ids},c({id:e,dx:0,dy:0,to:null}))},onPointerMove:t=>{let n=o.current;if(!n||n.kind!==`ring`||n.id!==e)return;t.stopPropagation();let a=(t.clientX-n.sx)/r.z,s=(t.clientY-n.sy)/r.z,l=n.boxes.get(e);n.order=aA(n.grid,e,l.x+l.w/2+a,l.y+l.h/2+s);let u=iA(n.grid,n.order,n.boxes);c({id:e,dx:t.clientX-n.sx,dy:t.clientY-n.sy,to:u.get(e)}),i(uA(n.base,n.grid,n.boxes,u,{id:e,dx:a,dy:s}))},onPointerUp:t=>{let n=o.current;if(o.current=null,c(null),!n||n.kind!==`ring`||n.id!==e)return;t.stopPropagation();let r=uA(n.base,n.grid,n.boxes,iA(n.grid,n.order,n.boxes));i(r.length?r:null),r.length&&a(r,`Reorder`)},onDoubleClick:e=>e.stopPropagation()},e)})]})}function pA({doc:e,id:t,box:n,view:r,viewport:i}){let a=qf(t,Lf(e.nodes[t])),{playing:o}=Yf(a),{playBtn:s,playInset:c}=vl(),l=a&&Wf(yl(n,r),i,s,c);if(!l)return null;let u=o?`Pause video`:`Play video`;return(0,U.jsx)(`button`,{className:`video-play`,style:l,"aria-label":u,"data-tip":u,"data-video-play":t,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.code===`Space`)&&e.stopPropagation()},onClick:()=>Kf(a),children:o?(0,U.jsx)(X.pause,{}):(0,U.jsx)(X.play,{})})}function mA(e,t,n,r){let[i,a,o,s]=e.layout.pad,c=vl().handle/r,l=[{kind:`pad`,side:0,r:{x:t.x,y:t.y,w:t.w,h:Math.max(i,c)}},{kind:`pad`,side:2,r:{x:t.x,y:t.y+t.h-Math.max(o,c),w:t.w,h:Math.max(o,c)}},{kind:`pad`,side:3,r:{x:t.x,y:t.y+i,w:Math.max(s,c),h:Math.max(0,t.h-i-o)},fill:{x:t.x,y:t.y,w:Math.max(s,c),h:t.h}},{kind:`pad`,side:1,r:{x:t.x+t.w-Math.max(a,c),y:t.y+i,w:Math.max(a,c),h:Math.max(0,t.h-i-o)},fill:{x:t.x+t.w-Math.max(a,c),y:t.y,w:Math.max(a,c),h:t.h}}],u=e.layout.mode===`row`;for(let e=0;e<n.length-1;e++){let r=n[e],d=n[e+1],f=u?r.x+r.w:r.y+r.h,p=u?d.x:d.y,m=Math.max(p-f,c),h=(f+p)/2;l.push({kind:`gap`,i:e,r:u?{x:h-m/2,y:t.y+i,w:m,h:Math.max(0,t.h-i-o)}:{x:t.x+s,y:h-m/2,w:Math.max(0,t.w-s-a),h:m}})}return l}function hA({doc:e,id:t,boxes:n,view:r,onPreview:i,onCommit:a}){let[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(null),u=(0,H.useRef)(null),d=e.nodes[t],f=n.get(t);if(!d||d.type!==`frame`||d.layout.mode===`free`||!f)return null;let p=mA(d,f,d.children.map(t=>e.nodes[t]).filter(e=>e&&!e.hidden&&!e.absolute).map(e=>n.get(e.id)).filter(e=>!!e),r.z),m=d.layout.alignMain===`between`,h=(e,n,r,i,a,o,s)=>{let c=p[e];if(c.kind===`gap`){let e=d.layout.mode===`row`?n:r,i=Math.max(0,Math.round(s+e));return{ops:[{op:`update`,id:t,set:{layout:{gap:i}}}],value:i}}let l=[r,-n,-r,n][c.side],u=Math.max(0,Math.round(o[c.side]+l)),f=[...o];return a?f.fill(u):(f[c.side]=u,i&&(f[(c.side+2)%4]=u)),{ops:[{op:`update`,id:t,set:{layout:{pad:f}}}],value:u}},g=e=>e.kind===`gap`?m?`Auto`:String(d.layout.gap):String(d.layout.pad[e.side]),_=c?.i??o;return(0,U.jsx)(U.Fragment,{children:p.map((e,t)=>{let n=yl(e.r,r);if(n.w<1||n.h<1)return null;let o=e.kind===`gap`?d.layout.mode===`row`:e.side===1||e.side===3,f=e.kind===`gap`&&m,v=_===t,y=e.kind===`pad`&&e.fill?yl(e.fill,r):null,b=(0,U.jsx)(`span`,{className:`spacing-value`,children:c&&c.i===t?c.value:g(e)});return(0,U.jsxs)(H.Fragment,{children:[v&&y&&(0,U.jsx)(`div`,{className:`spacing-zone on pad`,style:{left:y.x,top:y.y,width:y.w,height:y.h,pointerEvents:`none`},children:b}),(0,U.jsx)(`div`,{className:`spacing-zone ${v&&!y?`on`:``} ${e.kind}`,style:{left:n.x,top:n.y,width:n.w,height:n.h,cursor:f?`default`:xt(o?0:90)},onPointerEnter:()=>s(t),onPointerLeave:()=>s(e=>e===t?null:e),onPointerDown:e=>{e.stopPropagation(),f||e.button!==0||(e.target.setPointerCapture(e.pointerId),u.current={i:t,sx:e.clientX,sy:e.clientY,pad:[...d.layout.pad],gap:d.layout.gap,ops:null})},onPointerMove:e=>{let t=u.current;if(!t)return;e.stopPropagation();let n=h(t.i,(e.clientX-t.sx)/r.z,(e.clientY-t.sy)/r.z,e.altKey,e.shiftKey,t.pad,t.gap);t.ops=n.ops,l({i:t.i,value:n.value}),i(n.ops)},onPointerUp:e=>{let t=u.current;u.current=null,l(null),t&&(e.stopPropagation(),t.ops?a(t.ops,p[t.i].kind===`gap`?`Gap`:`Padding`):i(null))},onDoubleClick:e=>e.stopPropagation(),children:v&&!y&&b})]},t)})})}function gA(e,t){let n=e.count;if(e.align===`stretch`){let r=(t-2*e.margin-e.gutter*(n-1))/n;return r<=0?[]:Array.from({length:n},(t,n)=>[e.margin+n*(r+e.gutter),r])}let r=e.size??64,i=n*r+(n-1)*e.gutter,a=e.align===`start`?e.margin:e.align===`end`?t-e.margin-i:(t-i)/2;return Array.from({length:n},(t,n)=>[a+n*(r+e.gutter),r])}function _A({doc:e,boxes:t,view:n}){let r=Object.values(e.nodes).filter(e=>e.type===`frame`&&e.grids?.some(e=>e.visible!==!1)&&!e.hidden);return r.length?(0,U.jsx)(`svg`,{className:`layout-grids`,width:`100%`,height:`100%`,children:r.map(r=>{let i=t.get(r.id);if(r.type!==`frame`||!i)return null;let a=yl(i,n),o=`lg-${r.id.replace(/[^\w-]/g,`_`)}`;return(0,U.jsxs)(`g`,{clipPath:`url(#${o})`,children:[(0,U.jsx)(`clipPath`,{id:o,children:(0,U.jsx)(`rect`,{x:a.x,y:a.y,width:a.w,height:a.h})}),(r.grids??[]).filter(e=>e.visible!==!1).map((t,r)=>{let o=We(e,t.color)??`#ff000019`;if(t.type===`grid`){let e=t.size*n.z;if(e<3)return null;let s=Array.from({length:Math.floor(i.w/t.size)},(t,n)=>a.x+(n+1)*e),c=Array.from({length:Math.floor(i.h/t.size)},(t,n)=>a.y+(n+1)*e);return(0,U.jsxs)(`g`,{stroke:o,strokeWidth:1,shapeRendering:`crispEdges`,children:[s.map(e=>(0,U.jsx)(`line`,{x1:e,y1:a.y,x2:e,y2:a.y+a.h},`x${e}`)),c.map(e=>(0,U.jsx)(`line`,{x1:a.x,y1:e,x2:a.x+a.w,y2:e},`y${e}`))]},r)}let s=t.type===`columns`;return(0,U.jsx)(`g`,{fill:o,children:gA(t,s?i.w:i.h).map(([e,t],r)=>s?(0,U.jsx)(`rect`,{x:a.x+e*n.z,y:a.y,width:t*n.z,height:a.h},r):(0,U.jsx)(`rect`,{x:a.x,y:a.y+e*n.z,width:a.w,height:t*n.z},r))},r)})]},r.id)})}):null}function vA({doc:e,id:t,box:n,view:r,host:i,onPreview:a,onCommit:o}){let[s,c]=(0,H.useState)(null),l=(0,H.useRef)(null),u=e.nodes[t];if(!u||u.locked)return null;let d=vl(),f=rn(e,t),p=tn(e,t),m=Yt(p),h=n.ow??u.w,g=n.oh??u.h,_=f?{x:n.x+n.w/2-h/2,y:n.y+n.h/2-g/2,w:h,h:g}:n,v=yl(_,r),y=u.type===`frame`&&!u.boolean||u.type===`shape`&&u.shape.kind===`rect`,b=u.type===`shape`&&u.shape.kind===`ellipse`?u.shape:null,x=u.type===`shape`&&u.shape.kind===`line`&&!f;if(!y&&!b&&!x)return null;let S=(e,t)=>{let n=i.getBoundingClientRect(),a=(e.clientX-n.left-r.x)/r.z,o=(e.clientY-n.top-r.y)/r.z;if(f){let e=t.x+t.w/2,n=t.y+t.h/2,[r,i]=Xt(m,a-e,o-n);a=e+r,o=n+i}return{x:a-t.x,y:o-t.y}},C=(n,r,i,a)=>{let o=S(r,i),s=i.w,c=i.h;if(n.kind===`radius`){let r=n.i===0||n.i===3?1:-1,i=n.i<2?1:-1,l=r>0?0:s,u=i>0?0:c,d=((o.x-l)*r+(o.y-u)*i)/2,f=Math.max(0,Math.min(Math.round(d),Math.floor(Math.min(s,c)/2))),p=Ee(e,a.radius)??0,m=Array.isArray(p)?[...p]:[p,p,p,p],h;return n.alt?(m[n.i]=f,h=m.every(e=>e===m[0])?m[0]:m):h=f,{ops:[{op:`update`,id:t,set:{radius:h===0?null:h}}],text:`Radius ${f}`}}if(b&&(n.kind===`end`||n.kind===`start`||n.kind===`ratio`)){let e=(o.x-s/2)/(s/2||1),i=(o.y-c/2)/(c/2||1),a=Math.atan2(i,e)*180/Math.PI;r.shiftKey&&(a=Math.round(a/15)*15),a=(a%360+360)%360;let l=b.start??0,u=b.sweep??1,d=b.ratio??0,f={kind:`ellipse`},p=``,m=l,h=u,g=d;if(n.kind===`end`){let e=((a-l)%360+360)%360/360;e<.01&&u>.5&&(e=1),h=Math.max(.001,Math.round(e*1e3)/1e3),p=`Sweep ${Math.round(h*1e3)/10}%`}else if(n.kind===`start`){let e=l+u*360;m=Math.round(a*10)/10,h=Math.round(((e-m)%360+360)%360/360*1e3)/1e3||u,p=`Start ${Math.round(m)}°`}else g=Math.round(Math.max(0,Math.min(.99,Math.hypot(e,i)))*100)/100,p=`Ratio ${Math.round(g*100)}%`;return m&&(f.start=m),h<1&&(f.sweep=h),g&&(f.ratio=g),{ops:[{op:`update`,id:t,set:{shape:f}}],text:p}}if(n.kind===`line`&&a.type===`shape`){let e=we({x:0,y:0,w:s,h:c,shape:a.shape})[+(n.end===0)],i={x:Math.round(a.x+o.x)-a.x,y:Math.round(a.y+o.y)-a.y},l=r.shiftKey?Gc(e,i):i,u=$e(n.end===0?l:e,n.end===0?e:l),d=Math.round(Math.hypot(u.w,u.h));return{ops:[{op:`update`,id:t,set:{x:Math.round((a.x+u.x)*100)/100,y:Math.round((a.y+u.y)*100)/100,w:u.w,h:u.h,shape:u.shape}}],text:`${d}`}}return null},w=(e,t)=>{t.stopPropagation(),t.preventDefault(),t.target.setPointerCapture(t.pointerId),l.current={d:e,ops:null,box:_,node:u}},T=e=>{let t=l.current;if(!t)return;e.stopPropagation();let n=t.d.kind===`radius`?{...t.d,alt:t.d.alt||e.altKey}:t.d,r=C(n,e,t.box,t.node);if(!r)return;t.ops=r.ops,a(r.ops);let o=i.getBoundingClientRect();c({x:e.clientX-o.left+d.pointerLabelX,y:e.clientY-o.top+d.pointerLabelY,text:r.text})},E=e=>{let t=l.current;l.current=null,c(null),t&&(e.stopPropagation(),t.ops?o(t.ops,t.d.kind===`radius`?`Corner radius`:t.d.kind===`line`?`Line`:`Arc`):a(null))},D=_.w,O=_.h,k={onPointerMove:T,onPointerUp:E,onPointerCancel:E},A=[],j=d.dotMinSide;if(y&&v.w>=j&&v.h>=j){let t=Ee(e,u.radius)??0,n=Array.isArray(t)?t:[t,t,t,t],i=Math.min(D,O)/2;n.forEach((e,t)=>{let n=t===0||t===3?1:-1,a=t<2?1:-1,o=Math.max(Math.min(e,i)*r.z,d.dotInset),s=(n>0?v.x:v.x+v.w)+n*Math.min(o,v.w/2),c=(a>0?v.y:v.y+v.h)+a*Math.min(o,v.h/2);A.push((0,U.jsx)(`circle`,{className:`sh-dot`,cx:s,cy:c,r:d.dotR,"data-tip":`Corner radius · ⌥ one corner`,onPointerDown:e=>w({kind:`radius`,i:t,alt:e.altKey},e),...k},`r${t}`))})}if(b&&v.w>=j/2&&v.h>=j/2){let e=(e,t)=>{let n=e*Math.PI/180;return{x:v.x+v.w/2+v.w/2*t*Math.cos(n),y:v.y+v.h/2+v.h/2*t*Math.sin(n)}},t=Math.max(.5,1-d.dotRim/Math.min(v.w/2,v.h/2)),n=b.start??0,r=b.sweep??1,i=b.ratio??0,a=e(n+r*360,t);if(A.push((0,U.jsx)(`circle`,{className:`sh-dot`,cx:a.x,cy:a.y,r:d.dotR,"data-tip":`Arc`,onPointerDown:e=>w({kind:`end`},e),...k},`end`)),r<1){let r=e(n,t);A.push((0,U.jsx)(`circle`,{className:`sh-dot`,cx:r.x,cy:r.y,r:d.dotR,"data-tip":`Arc start`,onPointerDown:e=>w({kind:`start`},e),...k},`start`))}let o=e(n+r*360/2,i);A.push((0,U.jsx)(`circle`,{className:`sh-dot`,cx:o.x,cy:o.y,r:d.dotR,"data-tip":`Ratio`,onPointerDown:e=>w({kind:`ratio`},e),...k},`ratio`))}return x&&u.type===`shape`&&we({x:0,y:0,w:D,h:O,shape:u.shape}).forEach((e,t)=>{A.push((0,U.jsx)(`rect`,{className:`sh-end`,x:v.x+e.x*r.z-d.handleR,y:v.y+e.y*r.z-d.handleR,width:d.handle,height:d.handle,rx:d.handleCorner,onPointerDown:e=>w({kind:`line`,end:t},e),...k},`l${t}`))}),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`svg`,{className:`shape-handles`,width:`100%`,height:`100%`,children:(0,U.jsx)(`g`,{transform:f?dn(p,v.x+v.w/2,v.y+v.h/2):void 0,children:A})}),s&&(0,U.jsx)(`div`,{className:`shape-handle-label`,style:{left:s.x,top:s.y},children:s.text})]})}function yA(e){return e?.type===`shape`&&e.shape.kind===`line`&&!e.rotation}function bA({doc:e,id:t,index:n,box:r,view:i,host:a,onPreview:o,onCommit:s}){let[c,l]=(0,H.useState)(null),u=(0,H.useRef)({onPreview:o,onCommit:s});u.current={onPreview:o,onCommit:s};let d=(0,H.useRef)(null);d.current??=Uu(e=>u.current.onPreview(e),(e,t)=>u.current.onCommit(e,t)),(0,H.useEffect)(()=>()=>d.current?.cancel(),[]);let f=e.nodes[t],p=f&&`fills`in f?f.fills?.[n]:void 0;if(!f||f.locked||!p||p.type!==`linear`&&p.type!==`radial`)return null;let m=vl(),h=rn(e,t),g=tn(e,t),_=Yt(g),v=r.ow??f.w,y=r.oh??f.h,b=h?{x:r.x+r.w/2-v/2,y:r.y+r.h/2-y/2,w:v,h:y}:r,x=yl(b,i),S={x:x.x,y:x.y},C=b.w,w=b.h;if(!C||!w)return null;let T=e=>{let t=a.getBoundingClientRect(),n=(e.clientX-t.left-i.x)/i.z,r=(e.clientY-t.top-i.y)/i.z;if(h){let e=b.x+b.w/2,t=b.y+b.h/2,[i,a]=Xt(_,n-e,r-t);n=e+i,r=t+a}return{x:n-b.x,y:r-b.y}},E=e=>rd(e,S,i.z),D=e=>e/i.z,O=p.type===`radial`?(()=>{let e=me(p);return{cx:e.cx,cy:e.cy,rx:e.rx,ry:e.ry,turn:ct(p)}})():null,k=p.type===`linear`?Qu(C,w,p.angle):null,A=(e,r,i)=>{if(r.type!==`linear`&&r.type!==`radial`)return null;let a=T(i),o,s=``,c=!0;if(r.type===`linear`&&e.kind===`stop`){let t=nd(Qu(C,w,r.angle),a);o={...r,stops:r.stops.map((n,r)=>r===e.index?{...n,at:t}:n)},s=`Stop ${Math.round(t*100)}%`,c=t!==r.stops[e.index].at}else if(r.type===`linear`&&e.kind===`grip`){let t=td(e.which,C,w,a,i.shiftKey);if(t===null)return null;o={...r,angle:t},s=`Angle ${t}°`,c=t!==r.angle}else if(r.type===`radial`&&(e.kind===`center`||e.kind===`rx`||e.kind===`ry`||e.kind===`turn`)){let t=me(r),n={cx:t.cx,cy:t.cy,rx:t.rx,ry:t.ry,turn:ct(r)};o=fu(r,Zu(e.kind,C,w,n,a,i.shiftKey));let l=me(o);s=e.kind===`turn`?`Rotation ${Math.round(ct(o))}°`:e.kind===`center`?`Center ${Math.round(l.cx*100)}%, ${Math.round(l.cy*100)}%`:`Radius ${Math.round(l.rx*100)}% × ${Math.round(l.ry*100)}%`,c=JSON.stringify(o)!==JSON.stringify(r)}else return null;return{ops:[{op:`update`,id:t,set:{fills:f.fills.map((e,t)=>t===n?o:e)}}],text:s,changed:c}},j=(e,t)=>{t.stopPropagation(),t.preventDefault(),t.target.setPointerCapture(t.pointerId),d.current.start(e,p)},M=e=>{let t=d.current.grab;if(!t)return;e.stopPropagation();let n=A(t.d,t.fill,e);if(!n||!d.current.move(n.ops,n.changed))return;let r=a.getBoundingClientRect();l({x:e.clientX-r.left+m.pointerLabelX,y:e.clientY-r.top+m.pointerLabelY,text:n.text})},N=e=>{let t=d.current.grab;if(l(null),!t)return;e.stopPropagation();let n=A(t.d,t.fill,e);d.current.end(n?.ops??null,!!n?.changed,`Gradient fill`)},P={onPointerMove:M,onPointerUp:N,onPointerCancel:N},F=(e,t,n,r,i)=>{let a=E(t);return(0,U.jsxs)(`g`,{className:`gh-dot`,"data-tip":r,onPointerDown:e=>j(n,e),...P,children:[(0,U.jsx)(`circle`,{className:`gh-dot-ring`,cx:a.x,cy:a.y,r:m.dotR+m.stroke}),i&&(0,U.jsx)(`circle`,{cx:a.x,cy:a.y,r:m.dotR-m.stroke,style:{fill:i}})]},e)},I=[];if(k&&p.type===`linear`){let t=E(k.start),n=E(k.end);I.push((0,U.jsx)(`line`,{className:`gh-line`,x1:t.x,y1:t.y,x2:n.x,y2:n.y},`line`));let r=D(m.dotR+m.handle);for(let e of[`start`,`end`]){let t=E(ed(k,e,r));I.push((0,U.jsx)(`rect`,{className:`sh-end gh-grip`,x:t.x-m.handleR,y:t.y-m.handleR,width:m.handle,height:m.handle,rx:m.handleCorner,"data-tip":`Angle · ⇧ 15° steps`,onPointerDown:t=>j({kind:`grip`,which:e},t),...P},e))}p.stops.forEach((t,n)=>I.push(F(`s${n}`,$u(k,t.at),{kind:`stop`,index:n},`Stop`,We(e,t.color))))}if(O&&p.type===`radial`){let t=Xu(C,w,O,D(m.dotR*2+m.rotateR)),n=E(t.center);I.push((0,U.jsx)(`ellipse`,{className:`gh-line gh-outline`,cx:n.x,cy:n.y,rx:O.rx*C*i.z,ry:O.ry*w*i.z,transform:`rotate(${O.turn} ${n.x} ${n.y})`},`outline`));let r=E(t.turn),a=E(t.rx);I.push((0,U.jsx)(`line`,{className:`gh-line`,x1:a.x,y1:a.y,x2:r.x,y2:r.y},`arm`)),I.push(F(`rx`,t.rx,{kind:`rx`},`Radius width`),F(`ry`,t.ry,{kind:`ry`},`Radius height`)),I.push((0,U.jsx)(`circle`,{className:`sh-dot gh-turn`,cx:r.x,cy:r.y,r:m.dotR,"data-tip":`Rotation · ⇧ 15° steps`,onPointerDown:e=>j({kind:`turn`},e),...P},`turn`)),I.push(F(`center`,t.center,{kind:`center`},`Center`,We(e,ve(p.stops)[0].color)))}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`svg`,{className:`shape-handles gradient-handles`,width:`100%`,height:`100%`,children:(0,U.jsx)(`g`,{transform:h?dn(g,x.x+x.w/2,x.y+x.h/2):void 0,children:I})}),c&&(0,U.jsx)(`div`,{className:`shape-handle-label`,style:{left:c.x,top:c.y},children:c.text})]})}var xA=3,SA=7,CA=(e,t)=>({x:e.x*t.z+t.x,y:e.y*t.z+t.y}),wA=e=>Math.round(e*100)/100,TA=e=>({x:Math.round(e.x),y:Math.round(e.y)}),EA=(e,t,n)=>{let r=t.getBoundingClientRect();return{x:(e.clientX-r.left-n.x)/n.z,y:(e.clientY-r.top-n.y)/n.z}};function DA({pts:e,view:t,sel:n,shown:r}){let i=[],a=vl();return e.forEach((e,n)=>{if(r(n))for(let r of[`in`,`out`]){let o=e[r];if(!o)continue;let s=CA(e,t),c=CA({x:e.x+o[0],y:e.y+o[1]},t);i.push((0,U.jsx)(`line`,{className:`pen-handle-line`,x1:s.x,y1:s.y,x2:c.x,y2:c.y},`l${n}${r}`)),i.push((0,U.jsx)(`rect`,{className:`pen-handle`,x:c.x-a.penHandle/2,y:c.y-a.penHandle/2,width:a.penHandle,height:a.penHandle,transform:`rotate(45 ${c.x} ${c.y})`},`h${n}${r}`))}}),e.forEach((e,r)=>{let o=CA(e,t);i.push((0,U.jsx)(`circle`,{className:`pen-anchor ${n.has(r)?`on`:``}`,cx:o.x,cy:o.y,r:a.dotR},`a${r}`))}),(0,U.jsx)(U.Fragment,{children:i})}function OA({view:e,host:t,onCommit:n,onCancel:r}){let[i,a]=(0,H.useState)([]),[o,s]=(0,H.useState)(null),c=(0,H.useRef)(null),l=(0,H.useRef)(i);l.current=i;let u=e=>{let t=l.current;a([]),t.length>=2?n(t,e&&t.length>=3):r()},d=(0,H.useRef)(u);d.current=u,(0,H.useEffect)(()=>{let e=e=>{e.target?.closest?.(`input, textarea, select, [contenteditable]`)||(e.key===`Enter`||e.key===`Escape`?(e.preventDefault(),e.stopImmediatePropagation(),d.current(!1)):(e.key===`Backspace`||e.key===`Delete`)&&l.current.length&&(e.preventDefault(),e.stopImmediatePropagation(),a(e=>e.slice(0,-1))))};return addEventListener(`keydown`,e,!0),()=>removeEventListener(`keydown`,e,!0)},[]);let f=n=>{if(n.button!==0||t.classList.contains(`panning`))return;n.stopPropagation(),n.currentTarget.setPointerCapture(n.pointerId);let r=TA(EA(n,t,e)),o=i[0];if(o&&i.length>=2){let t=CA(o,e),i=CA(r,e);if(Math.hypot(t.x-i.x,t.y-i.y)<=SA){c.current={i:0,sx:n.clientX,sy:n.clientY,closing:!0,pulled:!1};return}}let s=i[i.length-1];n.shiftKey&&s&&(r=Gc(s,r)),a([...i,TA(r)]),c.current={i:i.length,sx:n.clientX,sy:n.clientY,closing:!1,pulled:!1}},p=n=>{n.stopPropagation();let r=EA(n,t,e),o=c.current;if(o)!o.pulled&&Math.hypot(n.clientX-o.sx,n.clientY-o.sy)<xA||(o.pulled=!0,a(e=>e.map((e,t)=>{if(t!==o.i)return e;let n=wA(r.x-e.x),i=wA(r.y-e.y);return{x:e.x,y:e.y,in:[-n,-i],out:[n,i]}})));else{let e=i[i.length-1];s(n.shiftKey&&e?Gc(e,r):r)}},m=e=>{e.stopPropagation();let t=c.current;c.current=null,t?.closing&&u(!0)},h=i.map(t=>({...t,...CA(t,e),in:t.in&&[t.in[0]*e.z,t.in[1]*e.z],out:t.out&&[t.out[0]*e.z,t.out[1]*e.z]})),g=h[h.length-1],_=o&&CA(o,e),v=!!(_&&h.length>=2&&Math.hypot(h[0].x-_.x,h[0].y-_.y)<=SA);return(0,U.jsx)(`div`,{className:`pen-layer ${v?`closing`:``}`,onPointerDown:f,onPointerMove:p,onPointerUp:m,onPointerCancel:m,onPointerLeave:()=>s(null),onDoubleClick:e=>e.stopPropagation(),children:(0,U.jsxs)(`svg`,{width:`100%`,height:`100%`,children:[h.length>0&&(0,U.jsx)(`path`,{className:`pen-path`,d:Ye(h,!1)}),g&&_&&!c.current&&(0,U.jsx)(`path`,{className:`pen-rubber`,d:Ye([g,v?{x:h[0].x,y:h[0].y,in:h[0].in}:{x:_.x,y:_.y}],!1)}),(0,U.jsx)(DA,{pts:i,view:e,sel:new Set([i.length-1]),shown:()=>!0})]})})}function kA(e,t,n,r){let i=t===`in`?`out`:`in`,a=r||e.mirror===`none`;return{...e,[t]:n,...a||!e[i]?{}:{[i]:[-n[0],-n[1]]},...a&&e[i]?{mirror:`none`}:{}}}function AA({doc:e,id:t,box:n,m:r=qt,own:i=qt,view:a,host:o,onPreview:s,onCommit:c,onExit:l}){let u=e.nodes[t],[d,f]=(0,H.useState)(new Set),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null),g=(0,H.useRef)(null),_=u?.type===`shape`?u.shape.kind===`path`?null:de(e,u):null,v=u?.type===`shape`?u.shape.kind===`path`?u.shape:_&&!(`error`in _)?{kind:`path`,..._}:null:null,y=v&&u?ue(v).map(e=>({closed:e.closed,points:_e(e.points,v.view,u.w,u.h)})):[],b=y.flatMap(e=>e.points),x=y.reduce((e,t,n)=>(e.push(n?e[n-1]+y[n-1].points.length:0),e),[]),S=e=>{let t=0;for(;t+1<x.length&&x[t+1]<=e;)t++;return{c:t,k:e-x[t]}},C=e=>y.map((t,n)=>({closed:t.closed,points:e.slice(x[n],x[n]+t.points.length)})),w=e=>{if(d.has(e))return!0;let{c:t,k:n}=S(e),r=y[t].points.length,i=x[t],a=n>0?n-1:y[t].closed?r-1:-1,o=n<r-1?n+1:y[t].closed?0:-1;return a>=0&&d.has(i+a)||o>=0&&d.has(i+o)},T=r[0]!==1||r[1]!==0||r[2]!==0||r[3]!==1,E=Yt(r),D=n.x+n.w/2,O=n.y+n.h/2,k=e=>Xt(r,e[0],e[1]),A=(e,t)=>{let[n,r]=k([e-D,t-O]);return{x:D+n,y:O+r}},j=(e,t=n)=>{let r=t.x+t.w/2,i=t.y+t.h/2,a=e.x-r,o=e.y-i,[s,c]=Xt(E,a,o);return{x:r+s,y:i+c}},M=(e,t=n)=>j(EA(e,o,a),t),N=b.map(e=>({...e,...A(e.x+n.x,e.y+n.y),in:e.in&&k(e.in),out:e.out&&k(e.out)})),P=(n,r)=>{let a=z(r),o=e=>Math.round(e*100)/100,[s,c]=Xt(i,a.x+a.w/2-n.w/2,a.y+a.h/2-n.h/2),l=T?n.x+n.w/2+s-a.w/2:n.x+a.x,u=T?n.y+n.h/2+c-a.h/2:n.y+a.y,d=n.shape.kind===`path`?null:de(e,n),f=d&&!(`error`in d)?{radius:d.radius}:{};return[{op:`update`,id:t,set:{x:o(l),y:o(u),w:o(a.w),h:o(a.h),shape:Me(a.contours,[o(a.w),o(a.h)]),...f}}]},F=(e,t,n)=>{if(!T)return{x:Math.round(e.x+t.x)-e.x,y:Math.round(e.y+t.y)-e.y};let r=n.x+n.w/2,i=n.y+n.h/2,[a,o]=k([n.x+t.x-r,n.y+t.y-i]),s=j({x:Math.round(r+a),y:Math.round(i+o)},n);return{x:wA(s.x-n.x),y:wA(s.y-n.y)}};if((0,H.useEffect)(()=>{let n=n=>{if(n.target?.closest?.(`input, textarea, [contenteditable]`))return;if(n.key===`Escape`||n.key===`Enter`){n.preventDefault(),n.stopImmediatePropagation(),l();return}let r={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[n.key];if(r&&u&&v){if(n.preventDefault(),n.stopImmediatePropagation(),!d.size)return;let t=n.shiftKey?10:1,i=[...d].sort().join(),a=h.current,o=e=>e.kind===`path`?JSON.stringify(ue(e).map(e=>e.points.map(e=>[e.x,e.y,e.in??null,e.out??null]))):e.kind;(!a||a.key!==i||u!==a.base&&!a.sent.has(o(u.shape)))&&(h.current={base:u,key:i,dx:0,dy:0,sent:new Set});let s=h.current,l=r[0]*t,f=r[1]*t,[p,m]=Xt(E,l,f);s.dx+=p,s.dy+=m;let g=s.base,_=g.shape.kind===`path`?g.shape:de(e,g);if(`error`in _)return;let v=0,y=ue(_).map(e=>({closed:e.closed,points:_e(e.points,_.view,g.w,g.h).map(e=>d.has(v++)?{...e,x:e.x+s.dx,y:e.y+s.dy}:e)})),b=P(g,y);s.sent.add(o(b[0].set.shape)),c(b,`Nudge point`)}else if(n.key===`Backspace`||n.key===`Delete`){if(n.preventDefault(),n.stopImmediatePropagation(),!d.size||!u||!v)return;let e=y.map((e,t)=>{let n=e.points.filter((e,n)=>!d.has(x[t]+n));return{points:n,closed:e.closed&&n.length>=3}}).filter(e=>e.points.length>=2);if(f(new Set),!e.length){c([{op:`delete`,ids:[t]}],`Delete path`),l();return}c(P(u,e),`Delete point`)}};return addEventListener(`keydown`,n,!0),()=>removeEventListener(`keydown`,n,!0)}),!u||!v)return null;let I=e=>{if(e.button!==0||o.classList.contains(`panning`))return;e.stopPropagation();let t={x:e.clientX-o.getBoundingClientRect().left,y:e.clientY-o.getBoundingClientRect().top},r=e=>{let n=CA(e,a);return Math.hypot(n.x-t.x,n.y-t.y)<=SA},i=()=>e.currentTarget.setPointerCapture(e.pointerId);for(let t=0;t<N.length;t++)if(w(t))for(let a of[`in`,`out`]){let o=N[t][a];if(o&&r({x:N[t].x+o[0],y:N[t].y+o[1]})){i(),g.current={d:{kind:`handle`,i:t,side:a,base:b},node:u,box:n,ops:null,moved:!1,sx:e.clientX,sy:e.clientY};return}}let s=N.findIndex(r);if(s>=0){let t=e.shiftKey?new Set(d):d.has(s)?d:new Set([s]);if(e.shiftKey&&(t.has(s)?t.delete(s):t.add(s)),f(t),!t.has(s))return;i(),g.current={d:{kind:`anchor`,start:M(e),base:b,ids:[...t]},node:u,box:n,ops:null,moved:!1,sx:e.clientX,sy:e.clientY};return}let l=M(e),p=null;y.forEach((e,t)=>{let r=Ve(e.points,e.closed,{x:l.x-n.x,y:l.y-n.y});r&&(!p||r.dist<p.dist)&&(p={c:t,...r})});let m=p;if(m&&m.dist*a.z<=SA){let e=y[m.c],[t,n]=Ue(e.points,e.closed)[m.seg],[r,i,a]=Ze(t,n,m.t),o=m.seg,s=(m.seg+1)%e.points.length,l=e.points.map((e,t)=>t===o?r:t===s?a:e);l.splice(m.seg+1,0,i),f(new Set([x[m.c]+m.seg+1])),c(P(u,y.map((e,t)=>t===m.c?{closed:e.closed,points:l}:e)),`Add point`)}else i(),g.current={d:{kind:`marquee`,base:e.shiftKey?new Set(d):new Set,add:e.shiftKey},node:u,box:n,ops:null,moved:!1,sx:e.clientX,sy:e.clientY}},L=e=>{let t=g.current;if(!t||(e.stopPropagation(),!t.moved&&Math.hypot(e.clientX-t.sx,e.clientY-t.sy)<xA))return;if(t.moved=!0,t.d.kind===`marquee`){let n=o.getBoundingClientRect(),r={x:Math.min(t.sx,e.clientX)-n.left,y:Math.min(t.sy,e.clientY)-n.top,w:Math.abs(e.clientX-t.sx),h:Math.abs(e.clientY-t.sy)};m(r);let i=new Set(t.d.base);N.forEach((e,t)=>{let n=CA(e,a);n.x>=r.x&&n.x<=r.x+r.w&&n.y>=r.y&&n.y<=r.y+r.h&&i.add(t)}),f(i);return}let n=M(e,t.box),r;if(t.d.kind===`anchor`){let i=n.x-t.d.start.x,a=n.y-t.d.start.y;e.shiftKey&&(Math.abs(i)>Math.abs(a)?a=0:i=0);let o=new Set(t.d.ids);r=t.d.base.map((e,n)=>o.has(n)?{...e,...F(t.node,{x:e.x+i,y:e.y+a},t.box)}:e)}else{let{i,side:a}=t.d,o=t.d.base[i],s=F(t.node,{x:n.x-t.box.x,y:n.y-t.box.y},t.box),c=kA(o,a,[wA(s.x-o.x),wA(s.y-o.y)],e.altKey);r=t.d.base.map((e,t)=>t===i?c:e)}t.ops=P(t.node,C(r)),s(t.ops)},ee=e=>{let t=g.current;if(g.current=null,t){if(e.stopPropagation(),t.d.kind===`marquee`){if(m(null),t.moved||t.d.add)return;let r=M(e);r.x>=n.x&&r.x<=n.x+n.w&&r.y>=n.y&&r.y<=n.y+n.h&&d.size?f(new Set):l()}else t.ops&&c(t.ops,t.d.kind===`anchor`?`Move point`:`Bend`)}},R=C(N.map(e=>({...e,...CA(e,a),in:e.in&&[e.in[0]*a.z,e.in[1]*a.z],out:e.out&&[e.out[0]*a.z,e.out[1]*a.z]}))).map(e=>Ye(e.points,e.closed)).join(``);return(0,U.jsx)(`div`,{className:`pen-layer edit`,onPointerDown:I,onPointerMove:L,onPointerUp:ee,onPointerCancel:ee,onDoubleClick:e=>{e.stopPropagation(),l()},children:(0,U.jsxs)(`svg`,{width:`100%`,height:`100%`,children:[(0,U.jsx)(`path`,{className:`pen-path`,d:R}),(0,U.jsx)(DA,{pts:N,view:a,sel:d,shown:w}),p&&(0,U.jsx)(`rect`,{className:`ov-marquee`,x:p.x,y:p.y,width:p.w,height:p.h})]})})}var jA=(e,t)=>{let n=e?.nodes[t];return!!n&&(!!n.inInstance||n.type===`frame`&&(!!n.main||!!n.componentSet||!!n.instanceOf))},MA=(e,t)=>{let n=e.nodes[t],r=n?.parent?e.nodes[n.parent]:void 0;return!!n&&!!r&&r.type===`frame`&&r.layout.mode!==`free`&&!n.absolute},NA=(e,t)=>Object.fromEntries(t.flatMap(t=>{let n=e.get(t);return n?[[t,{w:Math.round(n.w),h:Math.round(n.h)}]]:[]})),PA=.05,FA=256,IA=280,LA=.002,RA=3,zA=6,BA=4,VA=[{id:`move`,key:`v`,label:`Move`,hint:`V`,icon:X.move},{id:`scale`,key:`k`,label:`Scale`,hint:`K`,icon:X.scale},{id:`frame`,key:`f`,label:`Frame`,hint:`F`,icon:X.frame},{id:`text`,key:`t`,label:`Text`,hint:`T`,icon:X.text},{id:`comment`,key:`c`,label:`Comment`,hint:`C`,icon:X.comment}],HA=VA.filter(e=>e.id===`move`||e.id===`scale`),UA=[...VA.map(e=>({key:e.key,id:e.id})),...Rc.filter(e=>e.key).map(e=>({key:e.key,id:e.id})),{key:`p`,id:`pen`}],WA=e=>Rc.some(t=>t.id===e),GA=`.canvas-chat, .sel-bar, .ask-pop, .ask-thread, .mention-list, .chat-badge, .ai-btn, .build-bar, .pin, .popover, .thread, .pick-hint, .ctx-menu, .pen-layer, .shape-handles circle, .shape-handles rect`,KA=256,qA=480;function JA(e,t){let n=new Set(t);return t.filter(t=>{let r=e.nodes[t]?.parent;for(;r;){if(n.has(r))return!1;r=e.nodes[r]?.parent}return!0})}var YA=(e,t,n)=>{for(let r=e.nodes[n]?.parent??null;r;r=e.nodes[r]?.parent??null)if(r===t)return!0;return!1},XA=.18,ZA=(e,t)=>Math.min(.8,Math.max(.15,e.share+(t-e.y)/e.h));function QA(){let e=BO(),t=uO(e.version,e.syncTick),n=(0,H.useMemo)(()=>new Set(Object.values(e.interactions).flat()),[e.interactions]),r=(0,H.useRef)(null),[i,a]=(0,H.useState)({x:80,y:80,z:1}),[o,s]=(0,H.useState)(1);(0,H.useEffect)(()=>{let e=setTimeout(()=>s(i.z),150);return()=>clearTimeout(e)},[i.z]);let l=(0,H.useRef)(i);l.current=i;let[u,f]=(0,H.useState)([]),m=(0,H.useRef)(u);m.current=u;let[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)([]),[x,S]=(0,H.useState)(!1),[w,T]=(0,H.useState)(null),[E,O]=(0,H.useState)(null),k=(0,H.useRef)(null),[A,M]=(0,H.useState)(null),[N,P]=(0,H.useState)(null),[I,L]=(0,H.useState)(null),ee=(0,H.useRef)(null);ee.current=e.newer,(0,H.useEffect)(()=>{e.notice&&L(e.notice.text)},[e.notice]),(0,H.useEffect)(()=>{let e=e=>L(e.detail);return addEventListener(bO,e),()=>removeEventListener(bO,e)},[]);let[R,te]=(0,H.useState)(new Map),ne=(0,H.useRef)(R);ne.current=R;let[re,ie]=(0,H.useState)(null),[oe,ce]=(0,H.useState)(0),[le,ue]=(0,H.useState)(!1),[z,pe]=(0,H.useState)(`move`),me=Lt(z),[he,_e]=(0,H.useState)(`rect`),[ve,ye]=(0,H.useState)(`move`),[be,Se]=(0,H.useState)(null),[Ce,we]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.tools`)===`folded`}catch{return!1}}),Te=e=>{we(e);try{localStorage.setItem(`nudge.tools`,e?`folded`:`open`)}catch{}},[Ee,De]=(0,H.useState)(null),[Oe,ke]=(0,H.useState)(null),[Ae,je]=(0,H.useState)(null),Me=(0,H.useRef)(null),[B,Fe]=(0,H.useState)(null),[Ie,Re]=(0,H.useState)(null),[ze,Be]=(0,H.useState)(0),[Ve,Ue]=(0,H.useState)(!1),[We,Ge]=(0,H.useState)(!1),[Ke,qe]=(0,H.useState)(!1),[Je,Ye]=(0,H.useState)(`design`),[Ze,Qe]=(0,H.useState)(null),[$e,et]=(0,H.useState)(!1),[nt,rt]=(0,H.useState)(!1),[at,ot]=(0,H.useState)(!1),[st,ct]=(0,H.useState)(null),[ut,dt]=(0,H.useState)(null),ft=(0,H.useRef)(null),pt=e=>`${e.id}@${e.run?.startedAt??0}`,[gt,_t]=(0,H.useState)(()=>{try{return new Set(JSON.parse(localStorage.getItem(`nudge.seenRuns`)??`[]`))}catch{return new Set}}),vt=e=>!gt.has(pt(e)),yt=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=yt.current;yt.current=st;let n=t&&t!==st?e.chats.find(e=>e.id===t):void 0;n&&n.status!==`running`&&_t(e=>{let t=new Set([...e,pt(n)].slice(-200));try{localStorage.setItem(`nudge.seenRuns`,JSON.stringify([...t]))}catch{}return t})},[st]);let bt=t=>{let n=e.chats.find(e=>e.id===t);n&&_t(e=>{let t=new Set(e);t.delete(pt(n));try{localStorage.setItem(`nudge.seenRuns`,JSON.stringify([...t]))}catch{}return t}),ct(t)},[xt,St]=(0,H.useState)(null),[Ct,Et]=(0,H.useState)(null),[kt,At]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.showResolved`)===`1`}catch{return!1}}),Bt=e=>{At(e);try{localStorage.setItem(`nudge.showResolved`,e?`1`:`0`)}catch{}},Ut=(0,H.useCallback)(e=>{pe(e),e!==`comment`&&St(null),WA(e)&&_e(e),(e===`move`||e===`scale`)&&ye(e),e!==`move`&&ke(null)},[]),[Wt,Gt]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.rulers`)===`shown`}catch{return!1}}),qt=(0,H.useCallback)(()=>Gt(e=>{try{localStorage.setItem(`nudge.rulers`,e?`hidden`:`shown`)}catch{}return!e}),[]),[Jt,Yt]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.grids`)!==`hidden`}catch{return!0}}),Xt=(0,H.useCallback)(()=>Yt(e=>{try{localStorage.setItem(`nudge.grids`,e?`hidden`:`shown`)}catch{}return!e}),[]),[Qt,ln]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.pixelgrid`)!==`hidden`}catch{return!0}}),dn=(0,H.useCallback)(()=>ln(e=>{try{localStorage.setItem(`nudge.pixelgrid`,e?`hidden`:`shown`)}catch{}return!e}),[]),[gn,wn]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.browser`)===`shown`}catch{return!1}}),En=(0,H.useCallback)(()=>wn(e=>{try{localStorage.setItem(`nudge.browser`,e?`hidden`:`shown`)}catch{}return!e}),[]),[On,Pn]=(0,H.useState)({n:0,frame:null}),[Fn,In]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(!Fn)return;let e=e=>{e.key===`Escape`&&!document.querySelector(`.ctx-menu`)&&(e.stopPropagation(),In(!1))};return addEventListener(`keydown`,e,!0),()=>removeEventListener(`keydown`,e,!0)},[Fn]);let zn=(0,H.useCallback)(e=>{wn(!0);try{localStorage.setItem(`nudge.browser`,`shown`)}catch{}Pn(t=>({n:t.n+1,frame:e}))},[]),[Vn,Hn]=(0,H.useState)(),Kn=(0,H.useCallback)((e,t)=>{wn(!0);try{localStorage.setItem(`nudge.browser`,`shown`)}catch{}Hn(n=>({n:(n?.n??0)+1,url:e,w:t}))},[]),[Jn,Yn]=(0,H.useState)(null),er=(0,H.useRef)(null),[tr,rr]=(0,H.useState)(null),[ir,ar]=(0,H.useState)(()=>{try{return Math.min(qA,Math.max(KA,Number(localStorage.getItem(`nudge.panel.w`))||IA))}catch{return IA}}),or=(0,H.useRef)(ir);or.current=ir;let sr=(0,H.useRef)(null),[cr,lr]=(0,H.useState)(()=>{try{return Math.min(.8,Math.max(.15,Number(localStorage.getItem(`nudge.panel.split`))||XA))}catch{return XA}}),ur=(0,H.useRef)(null),[dr,fr]=(0,H.useState)(null),[pr,mr]=(0,H.useState)(null),hr=Pp(),W=kl(),[gr,_r]=(0,H.useState)(null);Lc(),(0,H.useEffect)(()=>{gr!==null&&e.doc?.canvas===gr&&_r(null)},[e.doc?.canvas]);let vr=(0,H.useRef)({l:0,r:0,t:0}),[yr,br]=(0,H.useState)(()=>{try{return localStorage.getItem(`nudge.layers`)!==`hidden`}catch{return!0}}),xr=(0,H.useCallback)(()=>{br(e=>{let t=!e;try{localStorage.setItem(`nudge.layers`,t?`shown`:`hidden`)}catch{}return t})},[]),Sr=(0,H.useRef)(null),Cr=(0,H.useRef)(null),wr=(0,H.useRef)(!1),Tr=(0,H.useRef)(!1),G=(0,H.useMemo)(()=>e.doc?D(e.doc):e.doc,[e.doc]),K=(0,H.useMemo)(()=>{if(!e.doc||!A)return G;try{return D(it(e.doc,A).doc)}catch{return G}},[e.doc,G,A]);(0,H.useEffect)(()=>{G&&Rl(G)},[G]);let Er=(0,H.useMemo)(()=>({doc:K,open:Kn}),[K,Kn]),Dr=(0,H.useRef)(K);Dr.current=K,(0,H.useEffect)(()=>{G&&f(t=>{let n=It(e.doc??G,G,t);return n.length===t.length?t:n})},[G]),(0,H.useEffect)(()=>{Cr.current!==null&&e.version>=Cr.current&&(Cr.current=null,M(null))},[e.version]);let Or=(0,H.useRef)(!1);(0,H.useEffect)(()=>{Or.current?Or.current=!1:rt(!1)},[u]),(0,H.useEffect)(()=>{Oe&&(u.length!==1||u[0]!==Oe)&&ke(null)},[u,Oe]),(0,H.useEffect)(()=>{if(!nt&&!st||at)return;let e=e=>{e.target?.closest?.(`.ask-pop, .ask-thread, .canvas-chat, .chat-badge, .ai-btn, .ctx-menu, .floating`)||(rt(!1),ct(null))};return addEventListener(`pointerdown`,e,!0),()=>removeEventListener(`pointerdown`,e,!0)},[nt,st,at]),(0,H.useEffect)(()=>{let e=setTimeout(()=>{fetch(`/api/selection`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:u})})},120);return()=>clearTimeout(e)},[u]);let kr=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{let e=r.current;if(!e||!K)return;let t=e.getBoundingClientRect(),n=l.current,i=kr.current;kr.current={doc:K,tick:ze};let a=(e,t)=>{let n=e.nodes[t];for(;n?.parent;)n=e.nodes[n.parent];return n?.id??null},o=null,s=new Map;if(i&&i.tick===ze&&i.doc!==K){o=new Set;let e=new Map;for(let t in K.nodes)if(K.nodes[t]!==i.doc.nodes[t]){let n=a(K,t);n&&e.set(n,[...e.get(n)??[],t])}for(let t in i.doc.nodes)if(!K.nodes[t]){let n=a(i.doc,t);n&&K.nodes[n]&&e.set(n,[...e.get(n)??[],t])}for(let[t,n]of e){let e=i.doc.nodes[t],r=K.nodes[t];n.length===1&&n[0]===t&&!r.rotation&&Xe(e,r)?s.set(t,{dx:r.x-e.x,dy:r.y-e.y}):o.add(t)}}let c=new Map;if(o)for(let[e,t]of ne.current){let n=a(K,e);if(!n||o.has(n))continue;let r=s.get(n);c.set(e,r?{...t,x:t.x+r.dx,y:t.y+r.dy}:t)}let u=e=>{let r=e.getBoundingClientRect();if(!r.width&&!r.height&&getComputedStyle(e).display===`none`)return;let i=e.dataset.nodeId,a={x:(r.left-t.left-n.x)/n.z,y:(r.top-t.top-n.y)/n.z,w:r.width/n.z,h:r.height/n.z};if(rn(K,i)){let t=getComputedStyle(e);a.ow=parseFloat(t.width)||0,a.oh=parseFloat(t.height)||0}c.set(i,a)};if(!o)e.querySelectorAll(`.world [data-node-id]`).forEach(u);else for(let t of o){let n=e.querySelector(`.world [data-node-id="${CSS.escape(t)}"]`);n&&(u(n),n.querySelectorAll(`[data-node-id]`).forEach(u))}te(c)},[K,ze]),(0,H.useEffect)(()=>kc(document.fonts,()=>Be(e=>e+1)),[]);let Ar=(0,H.useRef)(new WeakMap);(0,H.useEffect)(()=>{let e=r.current?.querySelectorAll(`.world [data-nudge-slot]`);if(!e?.length)return;let t=new ResizeObserver(e=>{let t=!1;for(let n of e){let e=`${Math.round(n.contentRect.width*100)}x${Math.round(n.contentRect.height*100)}`;Ar.current.get(n.target)!==e&&(Ar.current.set(n.target,e),t=!0)}t&&Be(e=>e+1)});return e.forEach(e=>t.observe(e)),()=>t.disconnect()},[K,R]),(0,H.useEffect)(()=>{let t=e.last?.selection;t&&G&&f(It(e.doc??G,G,t))},[e.last]),(0,H.useEffect)(()=>{let t=e.last,n=G;if(!n||!t||t.actor!==`claude`||Date.now()-t.at>1500)return;let r=new Set(JA(n,t.touched).filter(e=>n.nodes[e])),i=[],a=e=>{if(r.has(e)){i.push(e);return}let t=n.nodes[e];t?.type===`frame`&&t.children.forEach(a)};if(n.roots.forEach(a),!i.length)return;let o=Math.ceil(i.length/10),s=[];if(i.length<=3)s.push(i);else for(let e=0;e<i.length;e+=o)s.push(i.slice(e,e+o));let c=e.chats.find(e=>e.status===`running`)?.runner;ie({steps:s,key:e.version,name:fw(c)}),ce(0)},[e.last]);let jr=re&&re.steps.length>1?Math.max(110,Math.min(260,1100/re.steps.length)):420;(0,H.useEffect)(()=>{if(!re)return;ue(!0);let e=setTimeout(()=>ue(!1),jr+40),t=oe<re.steps.length-1?setTimeout(()=>ce(oe+1),jr):setTimeout(()=>ie(null),2800);return()=>{clearTimeout(t),clearTimeout(e)}},[re,oe]),(0,H.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>L(null),Math.min(8e3,Math.max(2500,I.length*60)));return()=>clearTimeout(e)},[I]),(0,H.useEffect)(()=>{let e=e=>!!e.dataTransfer?.types.includes(`Files`),t=t=>{e(t)&&!t.defaultPrevented&&(t.preventDefault(),t.dataTransfer.dropEffect=`none`)},n=t=>{e(t)&&t.preventDefault(),rr(null)},r=e=>{e.relatedTarget||rr(null)};return window.addEventListener(`dragover`,t),window.addEventListener(`drop`,n),window.addEventListener(`dragleave`,r),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`drop`,n),window.removeEventListener(`dragleave`,r)}},[]);let Mr=(0,H.useCallback)((e,t=1)=>{let n=r.current;if(!n||!e||!e.w&&!e.h)return;let{l:i,r:o,t:s}=vr.current,c=n.clientWidth-i-o,l=n.clientHeight-s,u=Math.min(FA,Math.max(PA,Math.min(e.w?(c-160)/e.w:1/0,e.h?(l-160)/e.h:1/0,t)));a({z:u,x:i+(c-e.w*u)/2-e.x*u,y:s+(l-e.h*u)/2-e.y*u})},[]),Nr=(0,H.useCallback)((e=FA)=>{Dr.current&&Mr(Vt(j(Dr.current).map(e=>ne.current.get(e.id)??{x:e.x,y:e.y,w:e.w,h:e.h})),e)},[Mr]);(0,H.useEffect)(()=>{});let Pr=(0,H.useRef)(null),Fr=(0,H.useCallback)((e,t,n=!0)=>{let i=r.current;if(!i)return;let o=Pr.current??{z:1,mx:0,my:0,raf:0};o.z=Math.min(FA,Math.max(PA,e));let{l:s,r:c,t:u}=vr.current;o.mx=t?.x??s+(i.clientWidth-s-c)/2,o.my=t?.y??u+(i.clientHeight-u)/2;let d=(e,t)=>({z:t,x:o.mx-(o.mx-e.x)*t/e.z,y:o.my-(o.my-e.y)*t/e.z}),f=e=>{l.current=e,a(e)};if(!n||matchMedia(`(prefers-reduced-motion: reduce)`).matches){Pr.current&&cancelAnimationFrame(Pr.current.raf),Pr.current=null,f(d(l.current,o.z));return}if(Pr.current)return;Pr.current=o;let p=performance.now(),m=e=>{let t=l.current,n=Math.log(o.z)-Math.log(t.z),r=1-.72**(Math.max(0,e-p)/16.7);p=e;let i=Math.abs(n*(1-r))<.004;f(d(t,i?o.z:Math.exp(Math.log(t.z)+n*r))),i?Pr.current=null:o.raf=requestAnimationFrame(m)};o.raf=requestAnimationFrame(m)},[]),Ir=()=>Pr.current?.z??l.current.z;(0,H.useEffect)(()=>()=>{Pr.current&&cancelAnimationFrame(Pr.current.raf)},[]),(0,H.useEffect)(()=>{K&&!Tr.current&&K.roots.length&&(Tr.current=!0,Nr(1))},[K,Nr]),(0,H.useEffect)(()=>{let e=r.current;if(!e)return;let t=t=>{if(!t.ctrlKey&&!t.metaKey&&t.target?.closest?.(`[data-own-scroll]`))return;if(!t.ctrlKey&&!t.metaKey)for(let n=t.target;n&&n!==e&&!n.hasAttribute(`data-nudge-world`);n=n.parentElement){let e=getComputedStyle(n).overflowY;if((e===`auto`||e===`scroll`)&&n.scrollHeight>n.clientHeight)return}t.preventDefault();let n=!t.ctrlKey&&!t.metaKey?[...e.querySelectorAll(`.build-live:not(.live)`)].find(e=>{let n=e.getBoundingClientRect();return t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top&&t.clientY<=n.bottom})??null:null;if(n?.dataset.frame)return Nl(n.dataset.frame);let r=e.getBoundingClientRect();if(t.ctrlKey||t.metaKey||Ep().wheelZoom){let n={x:t.clientX-r.left,y:t.clientY-r.top},i=t.deltaMode===1?t.deltaY*16:t.deltaMode===2?t.deltaY*e.clientHeight:t.deltaY;t.deltaMode!==0||Math.abs(i)>=40?Fr(Ir()*Math.exp(-Math.max(-300,Math.min(300,i))*LA),n):Fr(l.current.z*Math.exp(-i*.01),n,!1)}else a(e=>({...e,x:e.x-t.deltaX,y:e.y-t.deltaY}))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let Lr=(0,H.useRef)(0),q=(0,H.useCallback)(async(t,n,r,i)=>{if(!t.length){M(null);return}if(ee.current){M(null),L(`Editing is paused: ${ee.current}`);return}let a=await fetch(`/api/ops`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ops:t,label:n,actor:`designer`,selection:m.current,...i===void 0?{}:{amend:i}})}),o=await a.json();if(!a.ok){M(null),L(zO(n,String(o.error??a.statusText))),console.error(`${n}: ${o.error??a.statusText}`);return}Lr.current=o.version;let s=r?.map(e=>o.ids[e]).filter(Boolean);return s&&f(s),Cr.current=o.version,e.version>=o.version&&(Cr.current=null,M(null)),s},[e.version]),Rr=(0,H.useCallback)(async e=>{L(`Rasterizing…`);let t=await fetch(`/api/rasterize`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,actor:`designer`})}),n=await t.json();if(!t.ok)return L(`Couldn’t rasterize: ${String(n.error).replace(/^rasterize: /,``)}`);L(null),n.ids?.img&&f([n.ids.img])},[]),zr=(0,H.useCallback)(async e=>{L(`Flattening…`);let t=await fetch(`/api/flatten`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e,label:Yc.label,actor:`designer`})}),n=await t.json();if(!t.ok)return L(`Couldn’t flatten: ${String(n.error).replace(/^flatten: /,``)}`);L(n.warnings?.[0]??null),n.created?.[0]&&f([n.created[0]])},[]),Br=(e,t)=>{let n=r.current.getBoundingClientRect(),i=l.current;return{x:(e-n.left-i.x)/i.z,y:(t-n.top-i.y)/i.z}},Vr=(e,t,n,r)=>{let i=G?.nodes[e.dataset.nodeId];return i?.type===`vector`?!ck(e,t,n):i?.type===`shape`||i?.type===`frame`&&i.boolean?!r||r===e||r.tagName===`svg`||r.dataset?.nudgeOperands!==void 0:i?.type===`frame`&&i.parent&&!i.children.length&&!i.fills?.some(e=>e.visible!==!1)&&!i.effects?.some(e=>e.visible!==!1)?!lk(e.getBoundingClientRect(),t,n,i.stroke?.width?3:0):!1},Hr=(e,t)=>{for(let n of document.elementsFromPoint(e,t)){if(n.closest?.(GA))return null;let r=n.closest?.(`.world [data-node-id]`);if(!(r&&Vr(r,e,t,n))){if(r)return r.dataset.nodeId;if(n.classList?.contains(`canvas`))return null}}return null},Ur=(e,t,n,r,i)=>{let a=n.map(t=>e.nodes[t]?.parent).filter(e=>!!e),o=(()=>{try{return it(e,t).doc}catch{return e}})(),s=t=>i(t)??fn(e,r,t);return[...t,...Cn(o,s,a)]},Wr=(e,t,n)=>{let r=G,i=new Set(n),a=e=>{let t=e;for(;t;){if(i.has(t))return!0;t=r.nodes[t]?.parent??null}return!1};for(let i of document.elementsFromPoint(e,t)){let o=i.closest?.(`.world [data-node-id]`);if(!o){if(i.classList?.contains(`canvas`))return null;continue}if(Vr(o,e,t,i)||!r.nodes[o.dataset.nodeId]||a(o.dataset.nodeId))continue;let s=new Set(n.map(e=>r.nodes[e]?.parent).filter(e=>!!e)),c=null,l=o.dataset.nodeId;for(;l;){let e=r.nodes[l];if(s.has(l))return c&&e.layout.mode===`free`?c:l;!c&&e&&!a(l)&&Dt(r,l,n.length>0)&&(c=l),l=e?.parent??null}return c}return null},Gr=(e,t)=>{let n=new Map,r=0,i=t=>t.forEach(t=>{n.set(t,r++);let a=e.nodes[t];a?.type===`frame`&&i(a.children)});return i(e.roots),[...t].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))},Kr=(0,H.useRef)(null),qr=(e,t)=>{let n=yn(e,t),r=Kr.current,i=r&&t.length===r.copies.length&&t.map(t=>{let n=r.copies.indexOf(t),i=e.nodes[t],a=n<0?void 0:e.nodes[r.src[n]];return!i||!a||i.parent!==a.parent||!Nt(e,t)||!Nt(e,a.id)?null:i.x!==r.at[n].x||i.y!==r.at[n].y?{dx:i.x-a.x,dy:i.y-a.y}:r.steps?.[n]??null}),a=i&&i.every(Boolean)?i:null,o=t.map((t,r)=>{let i=e.nodes[t],o=n.ops.find(e=>e.op===`create`&&e.tree.key===n.keys[r])?.tree??{};return a&&(o.x=i.x+a[r].dx,o.y=i.y+a[r].dy),{x:o.x??i.x,y:o.y??i.y}});q(n.ops,`Duplicate`,n.keys).then(e=>{Kr.current=e&&e.length===t.length?{src:[...t],copies:e,at:o,steps:a}:null})},Jr=(e,t,n,r,i,a)=>(t.dup??=Object.fromEntries(n.map(e=>[e,p()])),n.map((n,o)=>{let s=i(n),c={...Pe(e,n,{copy:!0}),id:t.dup[n],key:`dup${o}`,...s?{...s,absolute:!1}:{}},l=e.nodes[n],u=t.boxes.get(n);return l.parent!==r&&MA(e,n)&&(c.sizeX===`fill`&&Object.assign(c,{sizeX:`fixed`,...u?{w:Math.round(u.w)}:{}}),c.sizeY===`fill`&&Object.assign(c,{sizeY:`fixed`,...u?{h:Math.round(u.h)}:{}})),{op:`create`,parent:r,index:a?.(o),tree:c}})),Yr=(e,t,n,r)=>{let i=n.map(t=>e.nodes[t]?.parent).filter(e=>!!e),a=(()=>{try{return it(e,t).doc}catch{return e}})();return[...t,...Cn(a,t=>fn(e,r,t),i)]},Xr=e=>{if(!K||e.button===2)return;if(r.current.setPointerCapture(e.pointerId),e.button===1||wr.current){Sr.current={kind:`pan`,sx:e.clientX,sy:e.clientY,view:i};return}let t=Hr(e.clientX,e.clientY),n=t?K.nodes[t]:void 0;if(t&&n?.type===`frame`&&n.boolean&&u.some(e=>{for(let n=K.nodes[e]?.parent??null;n;n=K.nodes[n]?.parent??null)if(n===t)return!0;return!1})&&(t=Ta(e.clientX,e.clientY,t)??t),ee.current){let n=jt(K,t,u,{shift:e.shiftKey,meta:rl(e)});f(n?Ft(K,u,n,e.shiftKey).next:[]);return}if(z===`comment`){let n=Br(e.clientX,e.clientY),r=t?R.get(t):void 0;Et(null),St({node:r?t:null,x:r?n.x-r.x:n.x,y:r?n.y-r.y:n.y,cx:n.x,cy:n.y});return}if(me)return ti(e,t);let a=jt(K,t,u,{shift:e.shiftKey,meta:rl(e)});if(!a){let n=t?ij(K,t):null;Sr.current={kind:`marquee`,sx:e.clientX,sy:e.clientY,scope:n,additive:e.shiftKey?u:[],before:u,boxes:R},e.shiftKey||f([]);return}if(!e.shiftKey&&!rl(e)&&t&&!u.includes(a)&&u.find(e=>e===t||YA(K,e,t))){Sr.current={kind:`move`,sx:e.clientX,sy:e.clientY,ids:u,started:!1,boxes:R,clicked:a};return}let{next:o,unselect:s}=Ft(K,u,a,e.shiftKey);f(o);let c=!e.shiftKey&&u.length>1&&u.includes(a)?a:void 0;o.includes(a)&&(Sr.current={kind:`move`,sx:e.clientX,sy:e.clientY,ids:o,started:!1,boxes:R,clicked:c,unselect:s})},Zr=e=>{let t=e;for(;t;){let e=K.nodes[t];if(e&&e.type===`frame`&&!e.boolean&&!e.locked&&!e.instanceOf&&!e.inInstance&&G?.nodes[t])return t;t=e?.parent??null}return null},Qr=async(e,t,n=24)=>{let i=G;if(!i||!r.current)return;let a=null,o,s=n;if(t){a=Zr(Hr(t.cx,t.cy));let e=Br(t.cx,t.cy);o=ei(a,{x:e.x-s/2,y:e.y-s/2})}else{let e=u.length===1?i.nodes[u[0]]:void 0;a=e?Zr(e.id):null;let t=a?R.get(a):void 0,n=r.current.getBoundingClientRect(),c=Br(n.left+n.width/2,n.top+n.height/2);o=t?{x:t.w/2-s/2,y:t.h/2-s/2}:{x:c.x-s/2,y:c.y-s/2};let l=(a?i.nodes[a].children??[]:i.roots).map(e=>i.nodes[e]).filter(e=>!!e);for(o={x:Math.round(o.x),y:Math.round(o.y)};l.some(e=>Math.abs(e.x-o.x)<1&&Math.abs(e.y-o.y)<1);)o={x:o.x+s+8,y:o.y}}try{let t=await Bw(i,e,{parent:a,...o},s);await q(t.ops,`Place icon`,[`icon`]),t.credit&&L(t.credit)}catch(e){L(e instanceof Error?e.message:`Couldn’t place the icon`)}},$r=async(e,t,n)=>{let i=G,a=b(e),o=i&&a&&!i.libraries?.kits?.includes(a.id)?Xw(i,a.id):[],s=i?.nodes[e]??a?.nodes[e];if(!i||!s||!r.current)return;let c=null,l;if(t)c=Zr(Hr(t.cx,t.cy)),l=ei(c,Br(t.cx,t.cy));else{let e=u.length===1?i.nodes[u[0]]:void 0;c=e?Zr(e.id):null;let t=r.current.getBoundingClientRect(),n=Br(t.left+t.width/2,t.top+t.height/2);l=c?{x:0,y:0}:{x:n.x-s.w/2,y:n.y-s.h/2}}let f=n&&Object.keys(n).length?[{op:`update`,id:`inst`,set:{values:n}}]:[];await q([...o,{op:`instance`,main:e,parent:c,x:Math.round(l.x),y:Math.round(l.y),key:`inst`},...f],`Place ${d(s)}`,[`inst`])},ei=(e,t)=>{let n=e?R.get(e):null;return n?{x:t.x-n.x,y:t.y-n.y}:t},ti=(e,t)=>{let n=Br(e.clientX,e.clientY),r=Zr(t);z===`text`?Sr.current={kind:`draw`,sx:e.clientX,sy:e.clientY,parent:r,origin:n,id:p(),text:!0}:z!==`pen`&&(Sr.current={kind:`draw`,sx:e.clientX,sy:e.clientY,parent:r,origin:n,id:p(),...WA(z)?{shape:z}:{}})},ni=(e,t,n,r)=>{let i=Br(t,n);return!r&&G?ek(i,da(G,e.parent,[],R),zA/l.current.z,la()):i},ri=(e,t)=>{let n=ei(e,t),r=lt(K),i=r.textStyle?{style:r.textStyle}:{fontSize:16,color:r.text},a=t.w===void 0?{}:{sizeX:`fixed`,w:Math.round(t.w)},o={type:`text`,id:p(),key:`new`,name:`Text`,content:``,x:Math.round(n.x),y:Math.round(n.y),...a,...i};q([{op:`create`,parent:e,tree:o}],`Add text`,[`new`]).then(e=>{if(!e?.[0])return;let t=t=>{try{sessionStorage.setItem(_c,JSON.stringify({id:e[0],version:t}))}catch{}};ii.current=new gc(e[0],Lr.current,ai,t),t(Lr.current),Zi.current=``,oi.current=wc,si.current=Dc,$i(null),Yi.current=Xi(e[0]),Fe(e[0])})},ii=(0,H.useRef)(null),ai=async(e,t,n)=>{let r=Lr.current;return await q(e,t,void 0,n),Lr.current===r?void 0:Lr.current},oi=(0,H.useRef)(wc),si=(0,H.useRef)(Dc);(0,H.useEffect)(()=>{let e=()=>{let e=ii.current;if(!e)return;let t=Zi.current,n={"content-type":`application/json`};bc(t)===`keep`?fetch(`/api/ops`,{method:`POST`,keepalive:!0,headers:n,body:JSON.stringify({ops:[{op:`update`,id:e.id,set:{content:t}}],label:`Add text`,actor:`designer`,amend:e.version})}):fetch(`/api/undo`,{method:`POST`,keepalive:!0,headers:n,body:JSON.stringify({discard:e.version})})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let ci=(0,H.useRef)(!1);(0,H.useEffect)(()=>{if(ci.current||!e.doc)return;ci.current=!0;let t=null;try{t=sessionStorage.getItem(_c),sessionStorage.removeItem(_c)}catch{}let n=yc(e.doc,vc(t));n!==null&&qi(n)});let li=(e,t,n,r,i=!1)=>{let a=Br(t,n),o=G,s=!i&&o?ek(a,da(o,e.parent,[],R),zA/l.current.z,la()):a;if(e.shape){let i=Math.hypot(t-e.sx,n-e.sy)<RA;return Wc(e.shape,e.id,e.parent,ei(e.parent,e.origin),ei(e.parent,s),{square:r,click:i})}let c=Math.abs(s.x-e.origin.x),u=Math.abs(s.y-e.origin.y);r&&(c=u=Math.max(c,u));let d=Math.hypot(t-e.sx,n-e.sy)<RA;d&&(c=u=100);let f=d||s.x>=e.origin.x?e.origin.x:e.origin.x-c,p=d||s.y>=e.origin.y?e.origin.y:e.origin.y-u,m=ei(e.parent,{x:f,y:p}),h={type:`frame`,id:e.id,key:`new`,name:`Frame`,x:Math.round(m.x),y:Math.round(m.y),w:Math.max(1,Math.round(c)),h:Math.max(1,Math.round(u)),fill:ae,...e.parent?{}:{clip:!0}},g=e.parent?o?.nodes[e.parent]:null,_=g?.type===`frame`&&g.layout.mode!==`free`,v=(!o||d||_?[]:e.parent?g.children:o.roots).filter(t=>{let n=o.nodes[t],r=R.get(t);return!!n&&!!r&&!n.locked&&t!==e.id&&r.x>=f&&r.y>=p&&r.x+r.w<=f+c&&r.y+r.h<=p+u});return v.length?[{op:`create`,parent:e.parent,tree:h},{op:`move`,ids:v,parent:e.id},...v.map(e=>{let t=o.nodes[e];return{op:`update`,id:e,set:{x:Math.round(t.x-h.x),y:Math.round(t.y-h.y)}}})]:[{op:`create`,parent:e.parent,tree:h}]},ui=e=>{let t=e.messages.find(e=>e.role===`user`),n=t&&`selection`in t?t.selection??[]:[];return n.length>0&&n.length===u.length&&n.every(e=>u.includes(e))},di=e.chats.filter(e=>e.status!==`running`&&ui(e)).sort((e,t)=>t.updatedAt-e.updatedAt)[0],[fi,pi]=(0,H.useState)(!1);(0,H.useEffect)(()=>{nt||pi(!1)},[nt]);let mi=()=>fi?void 0:di?.id,hi=async(e,t,n,r,i,a,o)=>mw(e,u,mi(),t,n,r,i,a,o),[gi,_i]=(0,H.useState)([]),[vi,yi]=(0,H.useState)(null);(0,H.useEffect)(()=>{nt||(_i([]),yi(null))},[nt]);let bi=(K?.roots??[]).map(e=>K.nodes[e]).filter(e=>e?.type===`frame`).map(e=>({id:e.id,name:e.name,hint:e.type===`frame`?`${Math.round(e.w)} × ${Math.round(e.h)}`:void 0})),xi=(0,H.useRef)(null),[Si,Ci]=(0,H.useState)(null),wi=e=>{xi.current=e,ot(!0)};(0,H.useEffect)(()=>{if(!at){Ci(null);return}let e=e=>{let t=r.current;if(!t||!K||!t.contains(e.target)||e.target.closest?.(`.ask-pop, .ask-thread, .canvas-chat`))return;let n=t.getBoundingClientRect(),i=e.clientX-n.left,a=e.clientY-n.top;return[...K.roots].reverse().find(e=>{let t=K.nodes[e]?.type===`frame`?R.get(e):void 0;if(!t)return!1;let n=yl(t,l.current);return i>=n.x&&i<=n.x+n.w&&a>=n.y&&a<=n.y+n.h})??null},t=t=>{let n=e(t);Ci(n??null)},n=t=>{let n=t.target.closest?.(`.lrow[data-id]`);if(n&&K){t.preventDefault(),t.stopPropagation();let e=K.nodes[n.dataset.id];for(;e&&e.parent;)e=K.nodes[e.parent];e?.type===`frame`&&xi.current?.({id:e.id,name:e.name}),ot(!1);return}let r=e(t);if(r===void 0){t.target.closest?.(`.ask-pop, .ask-thread, .canvas-chat`)||ot(!1);return}t.preventDefault(),t.stopPropagation();let i=r?K.nodes[r]:void 0;i&&xi.current?.({id:i.id,name:i.name}),ot(!1)},i=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ot(!1))};return addEventListener(`pointermove`,t,!0),addEventListener(`pointerdown`,n,!0),addEventListener(`keydown`,i,!0),()=>{removeEventListener(`pointermove`,t,!0),removeEventListener(`pointerdown`,n,!0),removeEventListener(`keydown`,i,!0)}},[at,K,R]),(0,H.useEffect)(()=>{!nt&&!st&&ot(!1)},[nt,st]);let Ti=e.chats.some(e=>{if(!vt(e))return!1;let t=e.messages.find(e=>e.role===`user`),n=t&&`selection`in t?t.selection??[]:[];return n.length>0&&n.length===u.length&&n.every(e=>u.includes(e))}),[Ei,Di]=(0,H.useState)(null);(0,H.useEffect)(()=>{let e=Ei?R.get(Ei):void 0;Ei&&e&&(f([Ei]),Mr(e),Di(null))},[Ei,R]);let[Oi,ki]=(0,H.useState)(!1),Ai=(0,H.useRef)(null),ji=async()=>{let e=window.documentPictureInPicture;if(!e)window.open(`/?mode=agents`,`nudge-agents`,`popup,width=380,height=720`)||L(`Allow pop-ups to open the Agents window`);else try{let t=await Promise.race([e.requestWindow({width:380,height:640}),new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),3e3))]);for(let e of document.head.querySelectorAll(`style, link[rel=stylesheet]`))t.document.head.appendChild(e.cloneNode(!0));t.document.documentElement.dataset.mode=`agents`,Pc(t.document),t.document.title=`Agents`;let n=t.document.createElement(`div`);n.id=`root`,t.document.body.appendChild(n);let r=(0,ht.createRoot)(n);r.render((0,U.jsx)(HO,{floating:!0})),Ai.current=t,ki(!0),Je===`agents`&&Ye(`design`),t.addEventListener(`pagehide`,()=>{r.unmount(),Ai.current=null,ki(!1)})}catch{L(`This browser can’t open floating windows. Open the canvas in another web browser to pop out Agents.`)}},Mi=(0,H.useRef)(null),Ni=(0,H.useRef)(u);Ni.current=u,(0,H.useEffect)(()=>{let e=Mi.current=new BroadcastChannel(`nudge`);return e.onmessage=t=>{t.data?.type===`goFrame`&&Pi.current?.(t.data.id),t.data?.type===`selection?`&&e.postMessage({type:`selection`,ids:Ni.current})},()=>e.close()},[]),(0,H.useEffect)(()=>{Mi.current?.postMessage({type:`selection`,ids:u})},[u]);let Pi=(0,H.useRef)(null),Fi=e=>{yr||xr(),Ye(`agents`),Qe(e)},Ii=e=>{if(!Dr.current?.nodes[e])return L(`That frame no longer exists`);f([e]),Mr(R.get(e)??null)};Pi.current=Ii;let Li=e=>{let t=G?.nodes[e];if(t?.type===`shape`){if(t.shape.kind!==`path`){let e=de(G,t);if(`error`in e)return L(`Can’t edit points: ${e.error}`)}ke(e)}},Ri=e=>{let t=G;if(!t)return null;let n=null,r=-1;for(let[i,a]of R){let o=t.nodes[i];if(o?.type!==`frame`||o.boolean||o.locked||o.hidden||e.x<a.x||e.x>a.x+a.w||e.y<a.y||e.y>a.y+a.h)continue;let s=0;for(let e=o.parent;e;e=t.nodes[e]?.parent??null)s++;s>r&&(r=s,n=i)}return n},zi=(e,t)=>{let n=Ri(e[0]),r=n?R.get(n):null,i=e.map(e=>({...e,x:e.x-(r?.x??0),y:e.y-(r?.y??0)})),a=F(i,t),o=e=>Math.round(e*100)/100,s={type:`shape`,id:p(),key:`new`,x:o(a.x),y:o(a.y),w:o(a.w),h:o(a.h),shape:{kind:`path`,points:a.points,closed:t,view:[o(a.w),o(a.h)]},stroke:{color:fe,width:1},...t?{fill:C}:{}};Ut(`move`),q([{op:`create`,parent:n,tree:s}],`Add path`,[`new`])},Bi=async e=>{let t=G;if(!t||!r.current)return;let n,i=!1;try{n=await Iu(e,()=>{i=!0,L(`Reading video…`)})}catch(t){L(Pu(e.name,t));return}i&&L(null);let{w:a,h:o}=Ou(n.w,n.h),s=u.length===1?t.nodes[u[0]]:void 0,c=zu(t,s?.id),l=c?c.parent:s?.type===`frame`&&!s.boolean?mt(t,s.id):null,d=r.current.getBoundingClientRect(),f=Br(d.left+(d.width-vr.current.r)/2,d.top+(d.height+vr.current.t)/2),p={type:`frame`,key:`media`,name:n.name,w:a,h:o,fills:[{type:n.kind,asset:n.asset.id,fit:`cover`}],...c?{x:c.x,y:c.y}:l?{x:0,y:0}:{x:Math.round(f.x-a/2),y:Math.round(f.y-o/2)}};Ut(`move`),q([{op:`asset`,add:[n.asset]},{op:`create`,parent:l,tree:p}],Bu([n]),[`media`])},Vi=e=>e.types.includes(`Files`),Hi=e=>!!e?.closest?.(`.tools, .view-tile, .help-btn, ${GA}`),Ui=(e,t)=>{let n=G;if(!n||!r.current)return null;let i=Wr(e,t,[]);for(;i;){let e=n.nodes[i];if(!e?.instanceOf&&!e?.inInstance)break;i=e.parent}let a=Br(e,t);return{world:a,plan:Ru(n,R,i,a)}},Wi=e=>{let t=Ui(e.clientX,e.clientY),n=t?.plan.highlight?{line:t.plan.line,ghost:t.plan.highlight}:null;rr(e=>JSON.stringify(e)===JSON.stringify(n)?e:n)},Gi=async(e,t,n)=>{let r=G,i=Ui(t,n);if(!r||!i)return;let{media:a,skipped:o}=Eu(e);if(!a.length)return L(xu);let s=!1,c=await Promise.allSettled(a.map(e=>Iu(e,()=>{s=!0,L(`Reading video…`)})));s&&L(null);let l=c.flatMap(e=>e.status===`fulfilled`?[e.value]:[]),u=c.flatMap((e,t)=>e.status===`rejected`?[Pu(a[t].name,e.reason)]:[]);if(l.length){let{ops:e,keys:t}=Vu(r,R,i.plan,i.world,l);Ut(`move`),await q(e,Bu(l),t)}u.length?L(u.join(` `)):o.length&&L(`${o.length===1?o[0].name:`${o.length} files`} skipped. ${xu}`)},Ki=(e,t)=>{Fe(null);let n=ii.current?.id===e?ii.current:null;ii.current=null;try{n&&sessionStorage.removeItem(_c)}catch{}let r=G?.nodes[e];if(r&&r.type===`text`){if(t===null||t===``){let t=xc(r,!!n);t===`take-back`?n.queue(qi).then(t=>{t||q([{op:`delete`,ids:[e]}],`Remove empty text`)}):t===`remove`?q([{op:`delete`,ids:[e]}],`Remove empty text`):t===`delete`?q([{op:`delete`,ids:[e]}],`Delete text`):M(null)}else{if(t===r.content)return M(null);n?n.queue(n=>q([{op:`update`,id:e,set:{content:t}}],`Add text`,void 0,n)):q([{op:`update`,id:e,set:{content:t}}],`Edit text`)}}},qi=async e=>{let t=await fetch(`/api/undo`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({discard:e})}),n=await t.json().catch(()=>({}));return M(null),t.ok&&n.label!==null&&n.label!==void 0},Ji=e=>{ii.current=null,oi.current=wc,f([e]),Fe(e);let t=G?.nodes[e];Zi.current=t?.type===`text`?t.content:``,$i(null),Yi.current=Xi(e)},Yi=(0,H.useRef)(!1),Xi=t=>{let n=e.doc;if(!n?.nodes[t])return!1;for(let e=n.nodes[t].parent;e;e=n.nodes[e]?.parent??null)if(n.nodes[e]?.main&&Ne(n,e).length)return!0;return!1},Zi=(0,H.useRef)(``),[Qi,$i]=(0,H.useState)(null),ea=(e,t,n=!1,r=Qi)=>{let i=B?G?.nodes[B]:void 0;if(!i||i.type!==`text`||!r||r.end<=r.start)return;let a=Zi.current||i.content;if(!e)return M(Yi.current?[{op:`update`,id:i.id,set:{content:a}}]:null);let o=se(c(i.content,a,i.spans),a.length,r.start,r.end,e),s=[{op:`update`,id:i.id,set:{content:a,spans:o.length?o:null}}];if(n)return M(s);let l=ii.current?.id===i.id?ii.current:null;si.current=Oc(si.current,oi.current.done,o.length?o:void 0),oi.current=Tc(oi.current,a),l?l.fold(s,`Add text`):q(s,t)},ta=e=>{let t=R.get(e);if(!K||!t||!rn(K,e))return null;let n=an(K,e),{w:r,h:i}=on(K,R,e);return{box:{x:t.x+t.w/2-r/2,y:t.y+t.h/2-i/2,w:r,h:i},deg:n}},na=Tf(),[ra,ia]=(0,H.useState)(null),aa=!!K&&u.length>0&&u.every(e=>{let t=K.nodes[e];return!!t&&!t.locked&&!(t.type===`frame`&&t.boolean)}),oa=e=>{if(e.stopPropagation(),!K||!aa)return;let t=Vt(u.map(e=>R.get(e)).filter(e=>!!e));if(!t)return;r.current.setPointerCapture(e.pointerId);let n={x:t.x+t.w/2,y:t.y+t.h/2},i=Br(e.clientX,e.clientY),a=u.filter(e=>R.has(e)).map(e=>{let t=K.nodes[e],n=R.get(e),{w:r,h:i}=on(K,R,e);return{id:e,rot:$t(t),sign:Zt(nn(K,e))<0?-1:1,cx:n.x+n.w/2,cy:n.y+n.h/2,w:r,h:i,local:e=>sn(K,R,t.parent,e)??e,free:Nt(K,e)}});Sr.current={kind:`rotate`,sx:e.clientX,sy:e.clientY,ids:a.map(e=>e.id),c:n,a0:Math.atan2(i.y-n.y,i.x-n.x),items:a}},sa=(e,t)=>{if(t.stopPropagation(),!K||!u.length)return;if(z===`scale`){let n=Vt(u.map(e=>R.get(e)).filter(e=>!!e));if(!n||u.some(e=>K.nodes[e]?.locked))return;r.current.setPointerCapture(t.pointerId),Sr.current={kind:`kscale`,sx:t.clientX,sy:t.clientY,ids:[...u],handle:e,base:n,boxes:R};return}if(u.length>1){let n=Vt(u.map(e=>R.get(e)).filter(e=>!!e));if(!n||u.some(e=>K.nodes[e]?.locked))return;r.current.setPointerCapture(t.pointerId),Sr.current={kind:`scale`,sx:t.clientX,sy:t.clientY,ids:[...u],handle:e,base:n,boxes:R};return}let n=u[0],i=fn(K,R,n);if(!i)return;for(let e of K.nodes[n].fills??[])(e.type===`image`||e.type===`video`)&&jO(K.assets[e.asset]);r.current.setPointerCapture(t.pointerId);let a=K.nodes[n],o=ta(n);if(o){let r=K,i=R;Sr.current={kind:`tresize`,sx:t.clientX,sy:t.clientY,id:n,handle:e,base:o.box,deg:o.deg,c:{x:o.box.x+o.box.w/2,y:o.box.y+o.box.h/2},local:e=>sn(r,i,a.parent,e)??e};return}let s=Nt(K,n)?{x:a.x,y:a.y,w:i.w,h:i.h}:i;Sr.current={kind:`resize`,sx:t.clientX,sy:t.clientY,id:n,handle:e,base:s,boxes:R}},ca=(e,t)=>{let n=Vt(u.map(e=>R.get(e)).filter(e=>!!e));if(!n||B)return $e&&et(!1);let i=r.current.getBoundingClientRect(),a=yl(n,l.current),o=e-i.left,s=t-i.top,c=o>=a.x-4&&o<=a.x+a.w+56&&s>=a.y-4&&s<=a.y+a.h+4;c!==$e&&et(c)},la=()=>{let e=G?.guides;if(Wt&&e?.length)return{x:e.filter(e=>e.axis===`x`).map(e=>e.at),y:e.filter(e=>e.axis===`y`).map(e=>e.at)}},ua=(e,t,n,r)=>Ep().snapObjects?(t?e.nodes[t]?.children??[]:e.roots).filter(e=>!n.includes(e)).flatMap(e=>{let t=r.get(e);return t?[t]:[]}):[],da=(e,t,n,i)=>{if(!Ep().snapObjects)return[];let a=r.current,o=l.current,s=a?{x:-o.x/o.z,y:-o.y/o.z,w:a.clientWidth/o.z,h:a.clientHeight/o.z}:null,c=new Set(n),u=t=>{for(let n=t;n;n=e.nodes[n]?.parent??null)if(c.has(n))return!0;return!1},d=[];for(let[t,n]of i)e.nodes[t]&&!u(t)&&(s&&(n.x>s.x+s.w||n.x+n.w<s.x||n.y>s.y+s.h||n.y+n.h<s.y)||d.push(n));return d},fa=e=>{ca(e.clientX,e.clientY);let t=Sr.current;if(!G)return;if(!t){if(!K)return;if(e.target?.closest?.(GA)){g&&_(null);return}let t=Hr(e.clientX,e.clientY);_(jt(K,t,u,{shift:!1,meta:rl(e)})),T(t),k.current=Br(e.clientX,e.clientY),e.altKey&&O(k.current);return}let n=l.current.z,r=(e.clientX-t.sx)/n,i=(e.clientY-t.sy)/n;if(t.kind===`pan`)a({...t.view,x:t.view.x+(e.clientX-t.sx),y:t.view.y+(e.clientY-t.sy)});else if(t.kind===`move`){if(!t.started&&Math.hypot(e.clientX-t.sx,e.clientY-t.sy)<RA)return;t.started=!0,_(null);let a=G;e.shiftKey&&(Math.abs(r)>Math.abs(i)?i=0:r=0);let o=Wr(e.clientX,e.clientY,t.ids),s=new Set(t.ids.map(e=>a.nodes[e].parent)),c=o?a.nodes[o]:null,l=!(s.size===1&&s.has(o)&&t.ids.every(e=>Nt(a,e)))&&!!c&&c.layout.mode!==`free`,u=Vt(t.ids.map(e=>t.boxes.get(e)).filter(e=>!!e));if(!l&&u&&!(e.metaKey||e.ctrlKey)){let s=KO({...u,x:u.x+r,y:u.y+i},da(a,o,e.altKey?[]:t.ids,t.boxes),zA/n,{lines:la(),axes:{x:!(e.shiftKey&&r===0),y:!(e.shiftKey&&i===0)},spacing:ua(a,o,e.altKey?[]:t.ids,t.boxes)});r+=s.dx,i+=s.dy,y(s.guides)}else y([]);let d=e.altKey;if(d||(t.dup=void 0),s.size===1&&s.has(o)&&t.ids.every(e=>Nt(a,e))){if(d){let e=o?a.nodes[o].children:a.roots,n=Gr(a,t.ids),s=Jr(a,t,n,o,e=>{let[t,n]=cn(a,e,r,i);return{x:Math.round(a.nodes[e].x+t),y:Math.round(a.nodes[e].y+n)}},t=>e.indexOf(n[n.length-1])+1+t);t.plan={kind:`ops`,ops:s},rr(null),M(s);return}let e=_n(a,t.ids,Math.round(r),Math.round(i));t.plan=null,rr(null),M(Ur(a,e,t.ids,t.boxes,e=>{if(!t.ids.includes(e))return null;let n=fn(a,t.boxes,e);return n&&{...n,x:n.x+Math.round(r),y:n.y+Math.round(i)}}));return}if(c&&c.layout.mode!==`free`){let n=An(a,t.boxes,o,t.ids,Br(e.clientX,e.clientY)),s=Vt(t.ids.map(e=>t.boxes.get(e)).filter(e=>!!e));M(null),rr({line:n.same?null:n.line,ghost:s&&{...s,x:s.x+r,y:s.y+i}}),t.plan=n.same&&!d?null:{kind:`flow`,container:o,index:n.index};return}if(o&&!t.boxes.get(o))return;let f=Gr(a,t.ids);if(d){let e=Jr(a,t,f,o,e=>{let n=t.boxes.get(e),s=n&&un(a,t.boxes,e,o,{x:n.x+n.w/2+r,y:n.y+n.h/2+i});return s?{...s,x:Math.round(s.x),y:Math.round(s.y)}:null});t.plan={kind:`ops`,ops:e},rr(null),M(e);return}let p=[{op:`move`,ids:f,parent:o,sizes:NA(t.boxes,f)}];for(let e of f){let n=t.boxes.get(e);if(!n)continue;let s=un(a,t.boxes,e,o,{x:n.x+n.w/2+r,y:n.y+n.h/2+i});s&&p.push({op:`update`,id:e,set:{...s,x:Math.round(s.x),y:Math.round(s.y),absolute:!1}})}let m=Yr(a,p,t.ids,t.boxes);t.plan={kind:`ops`,ops:m},rr(null),M(m)}else if(t.kind===`resize`){let a=G.nodes[t.id],o=a.fills??[],s=rl(e)&&!a.locked?o.flatMap((e,t)=>(e.type===`image`||e.type===`video`)&&e.visible!==!1?[{p:e,i:t}]:[]):[];if(s.length){let e=s.map(({p:e})=>tt(t.base,Le(e,t.base,jO(G.assets[e.asset])))),n=Math.max(...e.map(e=>e.x)),a=Math.max(...e.map(e=>e.y)),c={x:n,y:a,w:Math.min(...e.map(e=>e.x+e.w))-n,h:Math.min(...e.map(e=>e.y+e.h))-a},l=MO(t.base,c,t.handle,r,i),u={fills:o.map((t,n)=>{let r=s.findIndex(e=>e.i===n);if(r<0||t.type!==`image`&&t.type!==`video`)return t;let{crop:i,...a}=t;return`pos`in a&&delete a.pos,{...a,fit:`crop`,crop:xe(l,e[r])}})},d=e=>Math.round(e*100)/100;d(l.w)!==d(t.base.w)&&Object.assign(u,{w:d(l.w),sizeX:`fixed`}),d(l.h)!==d(t.base.h)&&Object.assign(u,{h:d(l.h),sizeY:`fixed`}),Nt(G,t.id)&&Object.assign(u,{x:d(l.x),y:d(l.y)}),y([]);let f=[{op:`update`,id:t.id,set:u}];M(Ur(G,f,[t.id],t.boxes,e=>e===t.id?{x:l.x,y:l.y,w:l.w,h:l.h}:null));return}let c=e.shiftKey||!!a.lockRatio,l=Kt(t.base,t.handle,r,i,{shift:c,alt:e.altKey}),u=/[ew]/.test(t.handle),d=/[ns]/.test(t.handle),f=t.boxes.get(t.id);if(f&&!c&&!e.altKey&&!(e.metaKey||e.ctrlKey)){let e=f.x-t.base.x,r=f.y-t.base.y,i={x:l.x+e,y:l.y+r,w:l.w,h:l.h},o={x:t.handle.includes(`e`)?[i.x+i.w]:t.handle.includes(`w`)?[i.x]:[],y:t.handle.includes(`s`)?[i.y+i.h]:t.handle.includes(`n`)?[i.y]:[]},s=KO(i,da(G,a.parent,[t.id],t.boxes),zA/n,{edges:o,lines:la(),spacing:ua(G,a.parent,[t.id],t.boxes)});t.handle.includes(`e`)&&(l.w+=s.dx),t.handle.includes(`w`)&&(l.x+=s.dx,l.w-=s.dx),t.handle.includes(`s`)&&(l.h+=s.dy),t.handle.includes(`n`)&&(l.y+=s.dy,l.h-=s.dy),y(s.guides)}else if(f&&c&&!e.altKey&&!(e.metaKey||e.ctrlKey)&&t.base.w>0&&t.base.h>0){let e=f.x-t.base.x,r=f.y-t.base.y,i={x:l.x+e,y:l.y+r,w:l.w,h:l.h},o={x:t.handle.includes(`e`)?[i.x+i.w]:t.handle.includes(`w`)?[i.x]:[],y:t.handle.includes(`s`)?[i.y+i.h]:t.handle.includes(`n`)?[i.y]:[]},s=KO(i,da(G,a.parent,[t.id],t.boxes),zA/n,{edges:o,lines:la()}),c=o.x.length>0&&s.guides.some(e=>e.x1===e.x2),u=o.y.length>0&&s.guides.some(e=>e.y1===e.y2),d=c&&(!u||Math.abs(s.dx)<=Math.abs(s.dy));if(d||!d&&u){let e=t.base.w/t.base.h,n=t.handle.includes(`e`),r=t.handle.includes(`s`),i=d?l.w+(n?s.dx:-s.dx):(l.h+(r?s.dy:-s.dy))*e,a=i/e,o=(i-t.base.w)*(n?1:t.handle.includes(`w`)?-1:0),c=(a-t.base.h)*(r?1:t.handle.includes(`n`)?-1:0);l=Kt(t.base,t.handle,o,c,{shift:!0}),y(s.guides.filter(e=>d?e.x1===e.x2:e.y1===e.y2))}else y([])}else y([]);for(let e of[`x`,`y`,`w`,`h`])l[e]=Math.round(l[e]*100)/100;let p={};(u||c)&&Object.assign(p,{w:l.w,sizeX:`fixed`}),(d||c)&&Object.assign(p,{h:l.h,sizeY:`fixed`}),Nt(G,t.id)&&Object.assign(p,{x:l.x,y:l.y}),a.type===`text`&&u&&!d&&!c&&(p.sizeY=`hug`),a.type===`text`&&d&&!u&&a.sizeX!==`fixed`&&Object.assign(p,{w:l.w,sizeX:`fixed`});let m=[{op:`update`,id:t.id,set:p},...Wn(G,t.id,l.w,l.h)];M(Ur(G,m,[t.id],t.boxes,e=>e===t.id?{x:l.x,y:l.y,w:l.w,h:l.h}:null))}else if(t.kind===`rotate`){let n=Br(e.clientX,e.clientY),r=(Math.atan2(n.y-t.c.y,n.x-t.c.x)-t.a0)*180/Math.PI,i=t.items.length===1?t.items[0]:null;e.shiftKey&&(r=i?Math.round((i.rot+r)/15)*15-i.rot:Math.round(r/15)*15);let a=Xn(t.items,t.c,r);ia(`${i?-Zn(i.rot+r)||0:-Math.round(r*10)/10||0}°`);let o=new Map(a.map(e=>{let n=e.set,r=t.items.find(t=>t.id===e.id),i=G.nodes[r.id];return[r.id,hn(n.x??i.x,n.y??i.y,r.w,r.h,n.rotation??0)]}));M(Ur(G,a,t.ids,R,e=>o.get(e)??null))}else if(t.kind===`tresize`){let n=G.nodes[t.id],a=n?.type===`shape`&&n.shape.kind===`line`,o=Qn(t.base,t.deg,t.handle,r,i,{shift:e.shiftKey||!!n?.lockRatio,alt:e.altKey,keepZero:a}),s=e=>Math.round(e*100)/100,c={w:o.w,h:o.h,sizeX:`fixed`,sizeY:`fixed`},l=t.local({x:o.x+o.w/2,y:o.y+o.h/2}),u=s(l.x-o.w/2),d=s(l.y-o.h/2);Nt(G,t.id)&&Object.assign(c,{x:u,y:d}),M(Ur(G,[{op:`update`,id:t.id,set:c}],[t.id],R,e=>e===t.id?hn(u,d,o.w,o.h,t.deg):null))}else if(t.kind===`kscale`){let n=G,a=Kt(t.base,t.handle,r,i,{shift:!0,alt:e.altKey}),{ops:o,rel:s}=qn(n,t.boxes,t.ids,t.base,a);ia(`${Math.round((t.base.w?a.w/t.base.w:a.h/t.base.h)*100)/100}×`),M(Ur(n,o,t.ids,t.boxes,e=>s.get(e)??null))}else if(t.kind===`scale`){let n=G,a=Kt(t.base,t.handle,r,i,{shift:e.shiftKey,alt:e.altKey}),o={x:/[ew]/.test(t.handle)||e.shiftKey,y:/[ns]/.test(t.handle)||e.shiftKey},{ops:s,rel:c}=Gn(n,t.boxes,t.ids,t.base,a,o);M(Ur(n,s,t.ids,t.boxes,e=>c.get(e)??null))}else if(t.kind===`draw`){if(Math.hypot(e.clientX-t.sx,e.clientY-t.sy)<RA)return;if(t.text){let r=ni(t,e.clientX,e.clientY,e.metaKey||e.ctrlKey);P(mc(t.origin,r)),y(e.metaKey||e.ctrlKey?[]:ek(Br(e.clientX,e.clientY),da(G,t.parent,[],R),zA/n,la()).guides);return}M(li(t,e.clientX,e.clientY,e.shiftKey,e.metaKey||e.ctrlKey));let r=G;y(e.metaKey||e.ctrlKey?[]:ek(Br(e.clientX,e.clientY),da(r,t.parent,[],R),zA/n,la()).guides)}else if(t.kind===`marquee`){let n=Br(t.sx,t.sy),r=Br(e.clientX,e.clientY),i={x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),w:Math.abs(r.x-n.x),h:Math.abs(r.y-n.y)};P(i);let a=Ht(G,t.boxes,t.scope,i);f(Pt(G,[...t.additive,...a]))}},[pa,ma]=(0,H.useState)(null),[ha,ga]=(0,H.useState)(null),_a=()=>{let e=Vt(u.map(e=>R.get(e)).filter(e=>!!e));return[{node:(0,U.jsx)(aj,{z:i.z,onSet:e=>{Fr(e),ga(null)}})},{sep:!0},{label:`Zoom in`,kbd:`⌘+`,onClick:()=>Fr(Ir()*2)},{label:`Zoom out`,kbd:`⌘−`,onClick:()=>Fr(Ir()/2)},{label:`Zoom to fit`,kbd:`⇧1`,onClick:()=>Nr()},{label:`Zoom to selection`,kbd:`⇧2`,disabled:!e,onClick:()=>Mr(e,FA)},{label:`Zoom to 50%`,onClick:()=>Fr(.5)},{label:`Zoom to 100%`,kbd:`⌘0`,onClick:()=>Fr(1)},{label:`Zoom to 200%`,onClick:()=>Fr(2)},{sep:!0},{label:`Rulers`,kbd:`⇧R`,checked:Wt,onClick:qt},{label:`Layout grids`,kbd:`⌃G`,checked:Jt,onClick:Xt}]},J=(e,t={},n=e.replace(/^Key/,``).toLowerCase())=>window.dispatchEvent(new KeyboardEvent(`keydown`,{code:e,key:n,metaKey:tl&&!!t.meta,shiftKey:!!t.shift,altKey:!!t.alt,ctrlKey:tl?!!t.ctrl:!!t.meta,bubbles:!0})),va=e=>{if(e.preventDefault(),!K)return;let t=Hr(e.clientX,e.clientY);if(t){let e=[];for(let n=t;n;n=K.nodes[n]?.parent??null)e.push(n);e.some(e=>u.includes(e))||f([jt(K,t,u,{shift:!1,meta:!1})??e[e.length-1]])}else f([]);let n=[...new Set(document.elementsFromPoint(e.clientX,e.clientY).map(e=>e.closest?.(`.world [data-node-id]`)).filter(e=>!!e).map(e=>e.dataset.nodeId))];ma({x:e.clientX,y:e.clientY,layers:n,...t?{hit:t}:{}})},ya=async()=>{let e=await navigator.clipboard.read(),t={},n=[];for(let r of e)for(let e of r.types){let i=await r.getType(e);e.startsWith(`image/`)?n.push(new File([i],`image.png`,{type:e})):t[e]=await i.text()}return{get:e=>t[e]??``,files:n}},ba=async(e,t)=>{try{let n=await ya();await Da.current?.(n.get,n.files,{x:e,y:t})}catch{L(`Allow clipboard access to paste here, or use ⌘V`)}},xa=async e=>{let t=null;try{t=await ya()}catch{t=Oa.current?{get:e=>e===`text/html`?Oa.current:``,files:[]}:null}if(!t)return L(`Allow clipboard access to paste over or replace, or use ⌘V`);await Da.current?.(t.get,t.files,void 0,e)},Sa=()=>{let e=Dr.current,t=e?u.filter(t=>e.nodes[t]):[],n=!t.length,r=!e||!t.some(t=>e.nodes[t].type===`text`),i=(e,t)=>()=>J(e,tl?{ctrl:!0,alt:!0}:t),a=(e,t,r,i=n)=>({label:e,kbd:t,onClick:r,disabled:i});return[{label:`File`,items:[a(`Place image or video…`,`⇧⌘K`,()=>Me.current?.click(),!1),a(`Export selection`,`⇧⌘E`,()=>J(`KeyE`,{meta:!0,shift:!0}))]},{label:`Edit`,items:[a(`Undo`,`⌘Z`,()=>J(`KeyZ`,{meta:!0}),!1),a(`Redo`,`⇧⌘Z`,()=>J(`KeyZ`,{meta:!0,shift:!0}),!1),{sep:!0},a(`Copy`,`⌘C`,()=>document.execCommand(`copy`)),a(`Paste over selection`,`⇧⌘V`,()=>void xa(`over`)),a(`Paste to replace`,`⌥⇧⌘V`,()=>void xa(`replace`)),a(`Duplicate`,`⌘D`,()=>J(`KeyD`,{meta:!0})),a(`Delete`,`⌫`,()=>J(`Backspace`,{},`Backspace`)),{sep:!0},a(`Copy properties`,`⌥⌘C`,()=>J(`KeyC`,{meta:!0,alt:!0})),a(`Paste properties`,`⌥⌘V`,()=>J(`KeyV`,{meta:!0,alt:!0})),{sep:!0},a(`Pick color`,`I`,()=>J(`KeyI`)),{sep:!0},a(`Select all`,`⌘A`,()=>J(`KeyA`,{meta:!0}),!1),a(`Select inverse`,`⇧⌘A`,()=>J(`KeyA`,{meta:!0,shift:!0})),a(`Select none`,`Esc`,()=>f([]))]},{label:`Object`,items:[a(`Frame selection`,`⌥⌘G`,()=>J(`KeyG`,{meta:!0,alt:!0})),a(`Group selection`,`⌘G`,()=>J(`KeyG`,{meta:!0})),a(`Ungroup selection`,`⇧⌘G`,()=>J(`KeyG`,{meta:!0,shift:!0})),{sep:!0},a(`Add auto layout`,`⇧A`,()=>J(`KeyA`,{shift:!0})),{label:`More layout options`,disabled:n,items:[a(`Remove auto layout`,`⌥⇧A`,()=>J(`KeyA`,{alt:!0,shift:!0})),a(`Resize to fit`,`⌥⇧⌘R`,()=>J(`KeyR`,{meta:!0,alt:!0,shift:!0}))]},{sep:!0},a(`Create component`,`⌥⌘K`,()=>J(`KeyK`,{meta:!0,alt:!0})),a(`Detach instance`,`⌥⌘B`,()=>J(`KeyB`,{meta:!0,alt:!0})),{sep:!0},a(`Bring to front`,`]`,()=>J(`BracketRight`,{},`]`)),a(`Bring forward`,`⌘]`,()=>J(`BracketRight`,{meta:!0},`]`)),a(`Send backward`,`⌘[`,()=>J(`BracketLeft`,{meta:!0},`[`)),a(`Send to back`,`[`,()=>J(`BracketLeft`,{},`[`)),{sep:!0},a(`Flip horizontal`,`⇧H`,()=>J(`KeyH`,{shift:!0})),a(`Flip vertical`,`⇧V`,()=>J(`KeyV`,{shift:!0})),{sep:!0},a(`Flatten`,`⌘E`,()=>J(`KeyE`,{meta:!0})),a(`Outline stroke`,`⌥⌘O`,()=>J(`KeyO`,{meta:!0,alt:!0})),{label:`Boolean groups`,disabled:n,items:[a(`Union`,`⌥⇧U`,()=>J(`KeyU`,{alt:!0,shift:!0})),a(`Subtract`,`⌥⇧S`,()=>J(`KeyS`,{alt:!0,shift:!0})),a(`Intersect`,`⌥⇧I`,()=>J(`KeyI`,{alt:!0,shift:!0})),a(`Exclude`,`⌥⇧E`,()=>J(`KeyE`,{alt:!0,shift:!0}))]},{sep:!0},a(`Show/Hide selection`,`⇧⌘H`,()=>J(`KeyH`,{meta:!0,shift:!0})),a(`Lock/Unlock selection`,`⇧⌘L`,()=>J(`KeyL`,{meta:!0,shift:!0})),{sep:!0},a(`Remove fill`,`⌥/`,()=>J(`Slash`,{alt:!0},`/`)),a(`Swap fill and stroke`,`⇧X`,()=>J(`KeyX`,{shift:!0}))]},{label:`Text`,items:[a(`Bold`,`⌘B`,()=>J(`KeyB`,{meta:!0}),r),a(`Italic`,`⌘I`,()=>J(`KeyI`,{meta:!0}),r),a(`Underline`,`⌘U`,()=>J(`KeyU`,{meta:!0}),r),a(`Strikethrough`,`⇧⌘X`,()=>J(`KeyX`,{meta:!0,shift:!0}),r),{sep:!0},{label:`Alignment`,disabled:r,items:[a(`Text align left`,`⌥⌘L`,()=>J(`KeyL`,{meta:!0,alt:!0}),r),a(`Text align center`,`⌥⌘T`,()=>J(`KeyT`,{meta:!0,alt:!0}),r),a(`Text align right`,`⌥⌘R`,()=>J(`KeyR`,{meta:!0,alt:!0}),r)]},{label:`Adjust`,disabled:r,items:[a(`Increase font size`,`⇧⌘.`,()=>J(`Period`,{meta:!0,shift:!0},`.`),r),a(`Decrease font size`,`⇧⌘,`,()=>J(`Comma`,{meta:!0,shift:!0},`,`),r),a(`Increase line height`,`⌥⇧.`,()=>J(`Period`,{alt:!0,shift:!0},`.`),r),a(`Decrease line height`,`⌥⇧,`,()=>J(`Comma`,{alt:!0,shift:!0},`,`),r),a(`Increase letter spacing`,`⌥.`,()=>J(`Period`,{alt:!0},`.`),r),a(`Decrease letter spacing`,`⌥,`,()=>J(`Comma`,{alt:!0},`,`),r)]}]},{label:`Arrange`,items:[a(`Align left`,`⌥A`,()=>J(`KeyA`,{alt:!0})),a(`Align horizontal centers`,`⌥H`,()=>J(`KeyH`,{alt:!0})),a(`Align right`,`⌥D`,()=>J(`KeyD`,{alt:!0})),a(`Align top`,`⌥W`,()=>J(`KeyW`,{alt:!0})),a(`Align vertical centers`,`⌥V`,()=>J(`KeyV`,{alt:!0})),a(`Align bottom`,`⌥S`,()=>J(`KeyS`,{alt:!0})),{sep:!0},a(`Tidy up`,`⌃⌥T`,i(`KeyT`,{meta:!0,alt:!0,shift:!0})),{sep:!0},a(`Distribute horizontal spacing`,`⌃⌥H`,i(`KeyH`,{alt:!0,shift:!0})),a(`Distribute vertical spacing`,`⌃⌥V`,i(`KeyV`,{alt:!0,shift:!0}))]}]},Ca=()=>{let e=K;if(!e||!pa)return[];let t=u.filter(t=>e.nodes[t]),n={x:pa.x,y:pa.y};if(!t.length)return[{label:`Paste here`,onClick:()=>void ba(n.x,n.y)},{label:`Select all`,kbd:`⌘A`,onClick:()=>J(`KeyA`,{meta:!0})},{sep:!0},{label:`Zoom to fit`,kbd:`⇧1`,onClick:()=>J(`Digit1`,{shift:!0},`!`)},{label:Wt?`Hide rulers`:`Show rulers`,kbd:`⇧R`,onClick:()=>J(`KeyR`,{shift:!0})},{label:Jt?`Hide layout grids`:`Show layout grids`,kbd:`⌃G`,onClick:Xt}];let r=t.map(t=>e.nodes[t]),i=r.every(e=>e.type===`frame`),a=i&&r.some(e=>e.type===`frame`&&e.layout.mode!==`free`),o=r.every(e=>e.hidden),s=r.every(e=>e.locked),c=pa.layers.slice(0,12).map(t=>({label:d(e.nodes[t]),icon:(()=>{let n=e.nodes[t];return n.type===`text`?(0,U.jsx)(X.text,{}):n.type===`vector`?(0,U.jsx)(X.vector,{}):n.type===`shape`?(0,U.jsx)(Hc,{kind:n.shape.kind}):(0,U.jsx)(X.frame,{})})(),onClick:()=>f([t])}));return[{label:`Copy`,kbd:`⌘C`,onClick:()=>document.execCommand(`copy`)},...pa.fromLayers?[]:[{label:`Paste here`,onClick:()=>void ba(n.x,n.y)}],{label:`Paste over selection`,kbd:`⇧⌘V`,onClick:()=>void xa(`over`)},{label:`Paste to replace`,kbd:`⌥⇧⌘V`,onClick:()=>void xa(`replace`)},{label:`Copy as`,items:[{label:`Copy as CSS`,onClick:()=>{navigator.clipboard.writeText(t.map(t=>ge(e,t)).join(`
|
|
42
|
+
|
|
43
|
+
`)).then(()=>L(`CSS copied`))}},{label:`Copy as SVG`,onClick:()=>{let e=t.flatMap(e=>{let t=R.get(e);return t?[{id:e,x:t.x,y:t.y}]:[]}),n=fetch(`/api/copy-svg`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({items:e})}).then(async e=>{if(!e.ok)throw Error((await e.json().catch(()=>null))?.error??`Couldn’t make the SVG`);return e.text()});navigator.clipboard.write([new ClipboardItem({"text/plain":n.then(e=>new Blob([e],{type:`text/plain`}))})]).then(()=>L(`SVG copied — paste it into Figma`),e=>L(e instanceof Error?e.message:`Couldn’t copy the SVG`))}},{label:`Copy as PNG`,onClick:()=>{let e=fetch(`/api/render?id=${t[0]}&scale=2`).then(e=>e.blob());navigator.clipboard.write([new ClipboardItem({"image/png":e})]).then(()=>L(`PNG copied`),()=>L(`Couldn’t copy the image`))}},{sep:!0},{label:`Copy properties`,kbd:`⌥⌘C`,onClick:()=>J(`KeyC`,{meta:!0,alt:!0})},{label:`Paste properties`,kbd:`⌥⌘V`,onClick:()=>J(`KeyV`,{meta:!0,alt:!0})}]},{sep:!0},{label:`Ask ${fw(hr)}`,icon:(0,U.jsx)(X.sparkle,{}),onClick:()=>rt(!0)},{sep:!0},...c.length>1?[{label:`Select layer`,items:c}]:[],{label:`Bring to front`,kbd:`]`,onClick:()=>J(`BracketRight`,{},`]`)},{label:`Send to back`,kbd:`[`,onClick:()=>J(`BracketLeft`,{},`[`)},{sep:!0},...Kc(e,t)?[{label:`Boolean groups`,icon:(0,U.jsx)(Uc,{op:`union`}),items:Vc.map(e=>({label:e.label,kbd:e.kbd,onClick:()=>J(e.code,{alt:!0,shift:!0})}))}]:[],...t.every(t=>{let n=e.nodes[t];return n.type===`shape`||n.type===`text`||n.type===`frame`&&!n.instanceOf})?[{label:Yc.label,kbd:Yc.kbd,icon:(0,U.jsx)(X.flatten,{}),onClick:()=>J(`KeyE`,{meta:!0})}]:[],...t.length&&t.every(n=>e.nodes[n].parent===e.nodes[t[0]].parent)?[{label:`Rasterize selection`,onClick:()=>void Rr(t)}]:[],...Qc(e,t)?[{label:Zc.label,kbd:Zc.kbd,onClick:()=>J(`KeyO`,{meta:!0,alt:!0})}]:[],...oj(e,t,J,f,(e,t,n)=>void q(e,t,n)),{label:`Group selection`,kbd:`⌘G`,onClick:()=>J(`KeyG`,{meta:!0})},{label:`Frame selection`,kbd:`⌥⌘G`,onClick:()=>J(`KeyG`,{meta:!0,alt:!0})},{label:`Ungroup`,kbd:`⇧⌘G`,disabled:!i,onClick:()=>J(`KeyG`,{meta:!0,shift:!0})},a?{label:`Remove auto layout`,kbd:`⌥⇧A`,onClick:()=>J(`KeyA`,{alt:!0,shift:!0})}:{label:`Add auto layout`,kbd:`⇧A`,onClick:()=>J(`KeyA`,{shift:!0})},...i&&r.some(e=>e.type===`frame`&&e.children.length)?[{label:`Resize to fit`,kbd:`⌥⇧⌘R`,onClick:()=>J(`KeyR`,{meta:!0,alt:!0,shift:!0})}]:[],{sep:!0},{label:`Rename`,kbd:`⌘R`,disabled:t.length!==1,onClick:()=>J(`KeyR`,{meta:!0})},{label:`Duplicate`,kbd:`⌘D`,onClick:()=>J(`KeyD`,{meta:!0})},...t.length===1&&OO(e,t[0])?[{label:kO(e,t[0]),onClick:()=>je(t[0])}]:[],{label:`Flip horizontal`,kbd:`⇧H`,onClick:()=>J(`KeyH`,{shift:!0})},{label:`Flip vertical`,kbd:`⇧V`,onClick:()=>J(`KeyV`,{shift:!0})},{label:o?`Show`:`Hide`,kbd:`⇧⌘H`,onClick:()=>J(`KeyH`,{meta:!0,shift:!0})},{label:s?`Unlock`:`Lock`,kbd:`⇧⌘L`,onClick:()=>J(`KeyL`,{meta:!0,shift:!0})},{label:`Export…`,kbd:`⇧⌘E`,onClick:()=>J(`KeyE`,{meta:!0,shift:!0})},...(()=>{let n=pa.hit??t[0],r=ij(e,n);return e.nodes[r??``]?.type===`frame`?[{label:`Preview in browser`,onClick:()=>zn(r)}]:[]})(),{sep:!0},{label:`Delete`,kbd:`⌫`,danger:!0,onClick:()=>J(`Backspace`,{},`Backspace`)}]},wa=e=>{let t=Sr.current;if(Sr.current=null,P(null),y([]),ia(null),t?.kind===`draw`&&t.text){Ut(`move`);let n=Math.hypot(e.clientX-t.sx,e.clientY-t.sy)>=RA;ri(t.parent,hc(t.origin,ni(t,e.clientX,e.clientY,e.metaKey||e.ctrlKey),n))}else if(t?.kind===`draw`)Ut(`move`),y([]),q(li(t,e.clientX,e.clientY,e.shiftKey,e.metaKey||e.ctrlKey),t.shape?`Add ${zc[t.shape].toLowerCase()}`:`Add frame`,[`new`]);else if(rr(null),t?.kind===`move`&&!t.started&&t.clicked&&f([t.clicked]),t?.kind===`move`&&!t.started&&t.unselect&&f(e=>e.filter(e=>e!==t.unselect)),t?.kind===`move`&&t.started&&t.plan&&G){let n=t.plan;if(n.kind===`flow`&&e.altKey){let e=G,r=Gr(e,t.ids),i=Jr(e,t,r,n.container,()=>null,e=>n.index+e);q(i,`Duplicate`,r.map((e,t)=>`dup${t}`))}else if(n.kind===`flow`){let e=G,r=Gr(e,t.ids),i=r.every(t=>e.nodes[t].parent===n.container),a=[{op:`move`,ids:r,parent:n.container,index:n.index,sizes:NA(t.boxes,r)},...r.filter(t=>e.nodes[t].absolute).map(e=>({op:`update`,id:e,set:{absolute:!1}}))];q(Yr(e,a,t.ids,t.boxes),i?`Reorder`:`Move into ${e.nodes[n.container].name}`)}else if(t.dup){let e=Object.keys(t.dup),r=G;q(n.ops,`Duplicate`,e.map((e,t)=>`dup${t}`)).then(t=>{Kr.current=t&&t.length===e.length?{src:e,copies:t,at:e.map(e=>({x:r.nodes[e].x,y:r.nodes[e].y})),steps:null}:null})}else q(n.ops,`Move`)}else t&&A&&(t.kind===`move`&&t.started?q(A,`Move`):t.kind===`resize`||t.kind===`scale`||t.kind===`tresize`?q(A,`Resize`):t.kind===`kscale`?q(A,`Scale`):t.kind===`rotate`?(ia(null),q(A,`Rotate`)):M(null))},Ta=(e,t,n)=>{let r=K;if(!r)return null;let i=[],a=e=>{let t=r.nodes[e];t?.type===`shape`?i.push(e):t?.type===`frame`&&t.children.forEach(a)};r.nodes[n].children.forEach(a);for(let n of i.reverse()){let r=document.querySelector(`.world [data-node-id="${n}"] path[data-nudge-hit]`),i=r?.getScreenCTM()?.inverse();if(!r||!i)continue;let a=new DOMPoint(e,t).matrixTransform(i);if(r.isPointInFill(a)||r.isPointInStroke(a))return n}return null},Ea=e=>{if(!K||u.length!==1||B)return;let t=u[0],n=Hr(e.clientX,e.clientY),r=n?K.nodes[n]:void 0,i=!1;for(let e=t;e;e=K.nodes[e]?.parent??null)e===n&&(i=!0);if(n&&r?.type===`frame`&&r.boolean&&i&&(n=Ta(e.clientX,e.clientY,n)??n),n&&K.nodes[n]?.type===`text`&&!K.nodes[n].locked&&(n===t||K.nodes[n].parent===t))return Ji(n);if(n===t&&tj(K,t))return Li(t);let a=Mt(K,n,t);a&&f([a])};(0,H.useEffect)(()=>{let e=e=>{if(e.isComposing)return;let t=e.target;if(!oc(Qs(t),e)){t&&!e.metaKey&&!e.ctrlKey&&fc(t,e.key)&&e.preventDefault();return}let n=Dr.current;if(!n)return;let i=e.metaKey||e.ctrlKey,a=cc(e),o=u.filter(e=>n.nodes[e]),s=(t,n,r)=>{e.preventDefault(),t&&t.length&&q(t,n,r)};if(e.code===`Space`&&!e.repeat){wr.current=!0,r.current?.classList.add(`panning`);return}let c=e.altKey,l=e.shiftKey,d=rl(e),p=tl&&e.ctrlKey,h=sc(e);if(i&&e.key===`/`){e.preventDefault(),Ue(e=>!e);return}if(i&&e.key===`,`){e.preventDefault(),fr(e=>e?null:`general`);return}if(d&&l&&h===`KeyB`){e.preventDefault(),En();return}if(l&&!i&&!c&&h===`KeyR`){e.preventDefault(),qt();return}if(l&&!i&&!c&&h===`Quote`){e.preventDefault(),dn();return}if(tl?p&&!d&&!c&&!l&&h===`KeyG`:d&&l&&!c&&h===`Digit4`){e.preventDefault(),Xt(),L(Jt?`Layout grids hidden`:`Layout grids shown`);return}if(!c&&(e.key===`+`||e.key===`=`||e.key===`-`||e.key===`_`||h===`Equal`||h===`Minus`||h===`NumpadAdd`||h===`NumpadSubtract`)){e.preventDefault();let t=e.key===`+`||e.key===`=`||h===`Equal`||h===`NumpadAdd`;Fr(t?Ir()*2:Ir()/2);return}if(!i&&!c&&a===`n`){e.preventDefault();let t=n.roots.filter(e=>n.nodes[e]?.type===`frame`);if(!t.length)return;let r=t[((o.length?t.indexOf(o[0]):-1)+(l?-1:1)+t.length)%t.length];f([r]),Mr(R.get(r)??null);return}if(h===`Tab`&&!i&&!c){if(e.preventDefault(),!o.length){n.roots[0]&&f([n.roots[0]]);return}let t=n.nodes[o[0]].parent,r=t?n.nodes[t].children:n.roots,i=r.indexOf(o[0]);f([r[(i+(l?-1:1)+r.length)%r.length]]);return}if(!i&&!c&&!l&&a===`a`){e.preventDefault(),Ut(`frame`);return}if(i&&e.code===`Backslash`){e.preventDefault(),xr();return}if(i&&a===`z`){if(e.preventDefault(),ee.current)return L(`Editing is paused: ${ee.current}`);fetch(`/api/${e.shiftKey?`redo`:`undo`}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({selection:m.current})});return}if(e.shiftKey&&e.code===`Digit1`){Nr();return}if(e.shiftKey&&e.code===`Digit2`){Mr(Vt(o.map(e=>R.get(e)).filter(e=>!!e)),FA);return}if((e.shiftKey||i)&&e.code===`Digit0`){e.preventDefault(),Fr(1);return}if(Ae&&(e.key===`Escape`||e.key===`Enter`)){e.preventDefault(),je(null);return}if(e.key===`Escape`){if(document.querySelector(`.floating, .font-menu`))return;let t=Sr.current;if(t&&Rt(t.kind)){e.preventDefault(),Sr.current=null;let n=t?zt(t):null;n&&f(n),M(null),rr(null),P(null),y([]),ia(null);return}if(nt){rt(!1);return}if(st){ct(null);return}if(xt||Ct){St(null),Et(null);return}Ut(`move`),f([]);return}if(!i&&!c&&!l&&h===`KeyI`&&!e.repeat){let t=document.querySelector(`.cp-eye`);if(t){e.preventDefault(),t.click();return}let n=window.EyeDropper;if(!o.length)return;if(e.preventDefault(),!n)return L(`This browser has no eyedropper. Open the canvas in a browser that has one to pick colors from the screen`);let r=[...o];new n().open().then(({sRGBHex:e})=>{let t=Dr.current;if(!t)return;let n=e.toLowerCase(),i=r.flatMap(e=>{let r=t.nodes[e];if(r?.type===`text`||r?.type===`vector`)return[{op:`update`,id:e,set:{color:n}}];if(r?.type!==`frame`&&r?.type!==`shape`)return[];let i=r.fills??[],a=i.length-1,o=i[a],s=o?.type===`solid`?{...o,color:n}:{type:`solid`,color:n,...o?.visible===!1?{visible:!1}:{},...o?.blend?{blend:o.blend}:{}};return[{op:`update`,id:e,set:{fills:i.length?i.map((e,t)=>t===a?s:e):[s]}}]});i.length?q(i,`Eyedropper`):L(`The eyedropper colors frames, shapes, text and icons`)},()=>{});return}if(d&&l&&!c&&h===`KeyK`){e.preventDefault(),Me.current?.click();return}if(d&&l&&h===`KeyV`){e.preventDefault(),xa(c?`replace`:`over`);return}if(!i&&!e.altKey&&!l){let t=UA.find(e=>e.key===a);if(t){e.preventDefault(),Ut(t.id);return}}if(i&&l&&h===`KeyA`){e.preventDefault();let t=o.length?n.nodes[o[0]].parent:null,r=t?n.nodes[t].children:n.roots;f(r.filter(e=>!o.includes(e)));return}if(i&&a===`a`){e.preventDefault();let t=o.length?n.nodes[o[0]].parent:null;f(t?[...n.nodes[t].children]:[...n.roots]);return}if(e.key===`Enter`&&o.length===1&&!e.shiftKey&&tj(n,o[0])){e.preventDefault(),Li(o[0]);return}if(e.key===`Enter`&&o.length===1&&n.nodes[o[0]].type===`text`&&!e.shiftKey){e.preventDefault(),Ji(o[0]);return}if(e.key===`Enter`&&o.length){if(e.preventDefault(),e.shiftKey){let e=n.nodes[o[0]].parent;e&&f([e])}else{let e=o.flatMap(e=>n.nodes[e].type===`frame`?n.nodes[e].children:[]);e.length&&f(e)}return}if(!o.length)return;let g=c&&l&&!i?Vc.find(e=>e.code===h):void 0;if(g&&qc(n,o))return L(qc(n,o));if(g)return s(Jc(n,R,o,g.op),g.label.replace(` selection`,``),o.length>1?[`bool`]:void 0);if(d&&l&&!c&&!p&&h===`KeyE`){e.preventDefault();let t=o.map(e=>n.nodes[e]);L(t.length>1?`Exporting ${t.length} layers…`:`Exporting…`),KE(t).then(e=>L(e?`Couldn’t export: ${e}`:null))}else{if(d&&!l&&!c&&!p&&h===`KeyE`){e.preventDefault();let t=Xc(n,R,o);return`error`in t?L(t.error):`server`in t?void zr(t.server):s(t.ops,Yc.label,[`flat`])}if(d&&c&&!l&&!p&&h===`KeyO`){e.preventDefault();let t=$c(n,o);return`error`in t?L(t.error):s(t.ops,Zc.label,t.keys)}if(c&&l&&!i&&h===`KeyA`)return s(o.flatMap(e=>{let t=n.nodes[e];return t.type===`frame`&&t.layout.mode!==`free`?kn(n,R,e)??[]:[]}),`Remove auto layout`);if(c&&d&&h===`KeyG`)return s(Nn(n,R,o),`Frame selection`,[`frame`]);if(c&&d&&!l&&h===`KeyK`){if(o.some(e=>n.nodes[e]?.inInstance))return e.preventDefault(),L(`A layer inside an instance can't become a component; detach the instance first`);let t=o.length===1?n.nodes[o[0]]:void 0;if(t?.type===`frame`&&!t.boolean&&!t.instanceOf)return s([{op:`component`,ids:o}],`Create component`);let r=Nn(n,R,o);return s(r&&[...r,{op:`component`,ids:[`frame`]}],`Create component`,[`frame`])}if(c&&d&&!l&&h===`KeyB`){let t=[...new Set(o.map(e=>n.nodes[e]?.inInstance??(n.nodes[e]?.type===`frame`&&n.nodes[e].instanceOf?e:null)).filter(e=>!!e))];return t.length?s([{op:`detach`,ids:t}],`Detach instance`):(e.preventDefault(),L(`Select an instance to detach`))}if((tl?p&&c&&!d:c&&l&&!d)&&(h===`KeyH`||h===`KeyV`))return s(Mn(n,R,o,h===`KeyH`?`x`:`y`),`Distribute`);if((tl?p&&c&&!d:d&&c&&l)&&h===`KeyT`){let e=n.nodes[o[0]]?.parent??null;return s(lA(n,o,e&&o.every(t=>n.nodes[t]?.parent===e)&&rn(n,e)?pn(n,R,o):R),`Tidy up`)}if(c&&!i&&!l){let e={KeyA:`left`,KeyD:`right`,KeyW:`top`,KeyS:`bottom`,KeyH:`hcenter`,KeyV:`vcenter`}[h];if(e)return s(jn(n,R,o,e),`Align`);if(h===`Slash`)return s(o.filter(e=>n.nodes[e].type===`frame`||n.nodes[e].type===`shape`).map(e=>({op:`update`,id:e,set:{fill:null}})),`Remove fill`);if(h===`Comma`||h===`Period`)return s(ej(n,o,`letterSpacing`,h===`Period`?.1:-.1),`Letter spacing`)}if(c&&l&&!i&&(h===`Comma`||h===`Period`))return s(ej(n,o,`lineHeight`,h===`Period`?1:-1),`Line height`);if(d&&l&&!c&&(h===`Comma`||h===`Period`))return s(ej(n,o,`fontSize`,h===`Period`?1:-1),`Font size`);if(d&&c&&!l&&(h===`KeyL`||h===`KeyT`||h===`KeyR`)){let e=h===`KeyL`?`left`:h===`KeyT`?`center`:`right`;return s(o.filter(e=>n.nodes[e].type===`text`).map(t=>({op:`update`,id:t,set:{textAlign:e}})),`Text align`)}if(d&&c&&h===`KeyC`)e.preventDefault(),er.current=Ln(n,o[0]),L(er.current?`Properties copied`:null);else{if(d&&c&&!l&&h===`KeyV`)return s(er.current?Rn(n,o,er.current):[],`Paste properties`);if(d&&l&&h===`KeyH`)return s(o.map(e=>({op:`update`,id:e,set:{hidden:!o.every(e=>n.nodes[e].hidden)}})),`Show/hide`);if(d&&l&&h===`KeyL`)return s(o.map(e=>({op:`update`,id:e,set:{locked:!o.every(e=>n.nodes[e].locked)}})),`Lock/unlock`);if(d&&l&&c&&h===`KeyR`)return s(Un(n,R,o),`Resize to fit`);if(d&&!l&&!c&&h===`KeyR`)e.preventDefault(),yr||xr(),Yn(e=>({id:o[0],n:(e?.n??0)+1}));else{if(d&&!l&&!c&&h===`KeyI`){let e=o.filter(e=>n.nodes[e].type===`text`),t=e.every(e=>{let t=n.nodes[e];return(t.fontStyle??(t.style?n.styles.text[t.style.slice(1)]?.fontStyle:void 0))===`italic`}),r=e=>{let t=n.nodes[e];return!!t.style&&n.styles.text[t.style.slice(1)]?.fontStyle===`italic`};return s(e.map(e=>({op:`update`,id:e,set:Bn(n,e,{fontStyle:t?r(e)?`normal`:null:`italic`})})),`Italic`)}if(d&&(!l&&!c&&h===`KeyU`||l&&!c&&h===`KeyX`)){let e=h===`KeyU`?`underline`:`line-through`,t=o.filter(e=>n.nodes[e].type===`text`),r=t.every(t=>n.nodes[t].textDecoration===e);return s(t.map(t=>({op:`update`,id:t,set:{textDecoration:r?null:e}})),e===`underline`?`Underline`:`Strikethrough`)}if(d&&!l&&!c&&h===`KeyB`){let e=o.filter(e=>n.nodes[e].type===`text`),t=e.every(e=>$A(n,e,`fontWeight`)>=600);return s(e.map(e=>({op:`update`,id:e,set:Bn(n,e,{fontWeight:t?400:700})})),`Bold`)}if(l&&!i&&!c&&(h===`KeyH`||h===`KeyV`))return s($n(n,R,o,h===`KeyH`?`x`:`y`),h===`KeyH`?`Flip horizontal`:`Flip vertical`);if(l&&!i&&!c&&h===`KeyX`)return s(o.flatMap(e=>{let t=n.nodes[e];if(t.type!==`frame`&&t.type!==`shape`)return[];let r=t.fills?.[0]?.type===`solid`?t.fills[0].color:null;return[{op:`update`,id:e,set:{fill:t.stroke?.color??null,stroke:r?{...t.stroke,color:r,width:t.stroke?.width??1}:null}}]}),`Swap fill and stroke`);if(!i&&!c&&!l&&/^Digit\d$/.test(h)){let e=Number(h.slice(5));return s(o.map(t=>({op:`update`,id:t,set:{opacity:e===0?null:e/10}})),`Opacity`)}if(e.shiftKey&&!i&&a===`a`){let t=Dn(n,R,o);if(!t)return;e.preventDefault();let r=t.select[0]===`al`;q(t.ops,`Add auto layout`,r?[`al`]:void 0)}else{if(e.key===`Backspace`||e.key===`Delete`)return s(vn(o),`Delete`);if(i&&a===`d`)return e.preventDefault(),qr(n,o);if(i&&a===`g`&&!e.shiftKey)return s(bn(n,R,o),`Group`,[`group`]);if(i&&a===`g`&&e.shiftKey){let t=xn(n,R,o);t&&(e.preventDefault(),q(t.ops,`Ungroup`).then(()=>f(t.lifted)))}else{if(!i&&!c&&!l&&(e.code===`BracketRight`||e.code===`BracketLeft`))return s(Sn(n,o,e.code===`BracketRight`?1/0:-1/0),`Reorder`);if(i&&(e.code===`BracketRight`||e.code===`BracketLeft`)){let t=e.code===`BracketRight`;return s(Sn(n,o,e.altKey||e.shiftKey?t?1/0:-1/0:t?1:-1),`Reorder`)}if((!i||a!==`c`&&a!==`x`&&a!==`v`)&&e.key.startsWith(`Arrow`)){let t=e.shiftKey?Ep().nudgeBig:Ep().nudgeSmall,r=e.key===`ArrowLeft`?-t:e.key===`ArrowRight`?t:0,i=e.key===`ArrowUp`?-t:e.key===`ArrowDown`?t:0,a=o.filter(e=>Nt(n,e));if(!a.length){e.preventDefault();let t=n.nodes[o[0]].parent,r=t?n.nodes[t]:null;if(!r||r.type!==`frame`||o.some(e=>n.nodes[e].parent!==t))return;let i=r.layout.mode===`row`?e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:0:e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;i&&s(Sn(n,o,i),`Reorder`);return}let c=_n(n,a,r,i);return s(Ur(n,c,a,R,e=>{if(!a.includes(e))return null;let t=fn(n,R,e);return t&&{...t,x:t.x+r,y:t.y+i}}),`Nudge`)}}}}}}},t=()=>{wr.current=!1,r.current?.classList.remove(`panning`)},n=e=>{e.code===`Space`&&t()},i=()=>{document.hidden&&t()};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,n),window.addEventListener(`blur`,t),document.addEventListener(`visibilitychange`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,n),window.removeEventListener(`blur`,t),document.removeEventListener(`visibilitychange`,i)}},[u,R,q,Nr,Mr,xr,yr,En,qt,Xt,Jt,nt,st,xt,Ct]),(0,H.useEffect)(()=>{let e=e=>{e.key===`Alt`&&(S(!0),O(k.current))},t=e=>{e.key===`Alt`&&S(!1)},n=()=>S(!1);return addEventListener(`keydown`,e),addEventListener(`keyup`,t),addEventListener(`blur`,n),()=>{removeEventListener(`keydown`,e),removeEventListener(`keyup`,t),removeEventListener(`blur`,n)}},[]);let Da=(0,H.useRef)(null),Oa=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=`data-nudge-clip`,t=e=>e instanceof HTMLElement&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)),n=e=>{let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)},i=e=>new TextDecoder().decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0))),a=()=>{let e=Dr.current;return e?{d:e,sel:u.filter(t=>e.nodes[t])}:null},o=0,s=null,c=e=>{s={x:e.clientX,y:e.clientY},e.detail>=2&&(o=Date.now())},l=e=>{s&&Math.hypot(e.clientX-s.x,e.clientY-s.y)>3&&(o=Date.now()),s=null};document.addEventListener(`mousedown`,c,!0),document.addEventListener(`mouseup`,l,!0);let d=(e,t)=>{try{f(e,t)}catch(t){if(!e.clipboardData)return;e.clipboardData.setData(`text/plain`,``),e.preventDefault(),L(`Couldn’t copy: ${t instanceof Error?t.message:t}`)}},f=(r,i)=>{let s=a();if(!s||!s.sel.length||t(r.target)||B||!r.clipboardData||window.getSelection()?.toString()||Date.now()-o<1e3)return;let{d:c,sel:l}=s,u=l.map(e=>{let t=Pe(c,e,{copy:!0}),n=Nt(c,e)?null:fn(c,ne.current,e);if(n){let r=mn(c,e,n);t.x=Math.round(r.x),t.y=Math.round(r.y)}n&&t.sizeX===`fill`&&(t.w=Math.round(n.w)),n&&t.sizeY===`fill`&&(t.h=Math.round(n.h));let r=[],i=e=>{let t=c.nodes[e];t&&(t.type===`frame`&&t.instanceOf&&!b(t.instanceOf)&&r.push(e),t.type===`frame`&&t.children.forEach(i))};i(e);let a=r.length?(()=>{try{return{...Pe(it(c,[{op:`detach`,ids:r}]).doc,e,{copy:!0}),x:t.x,y:t.y,w:t.w,h:t.h}}catch{return}})():void 0;return{tree:t,parent:c.nodes[e].parent,...a?{detached:a}:{}}}),d=new Set,f=[],m=e=>{let t=c.nodes[e];if(t.type===`text`&&f.push(t.content),t.type===`vector`&&d.add(t.asset),t.type===`frame`||t.type===`shape`)for(let e of t.fills??[])(e.type===`image`||e.type===`video`)&&d.add(e.asset);t.type===`frame`&&t.children.forEach(m)};l.forEach(m);let g=[...d].map(e=>c.assets[e]).filter(e=>!!e&&!h(e.id)),_=n(JSON.stringify({v:1,items:u,assets:g,from:location.origin,styles:{colors:c.styles.colors,text:c.styles.text,radius:c.styles.radius}})),v=`<meta charset="utf-8"><span ${e}="${_}"></span>${f.map(e=>`<p>${e.replace(/[<&]/g,e=>e===`<`?`<`:`&`)}</p>`).join(``)}`;Oa.current=v,r.clipboardData.setData(`text/html`,v),r.clipboardData.setData(`text/plain`,f.join(`
|
|
44
|
+
`)),r.preventDefault();let y=l.some(e=>c.nodes[e].type!==`text`)?p(l,_):null;i?(y??Promise.resolve()).finally(()=>q(vn(l),`Cut`)):L(`Copied ${l.length} layer${l.length>1?`s`:``}`)},p=(t,n)=>{let r=t.flatMap(e=>{let t=ne.current.get(e);return t?[{id:e,x:t.x,y:t.y}]:[]}),i=fetch(`/api/copy-svg`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({items:r})}).then(e=>e.ok?e.text():Promise.reject(Error(`no svg`))).then(t=>t.replace(/<svg[^>]*>/,t=>`${t}<!--${e}:${n}-->`));return navigator.clipboard.write([new ClipboardItem({"text/plain":i.then(e=>new Blob([e],{type:`text/plain`}))})]).catch(()=>{})},m=e=>d(e,!1),g=e=>d(e,!0),_=async(t,n,o,s)=>{let c=a();if(!c)return;let{d:l,sel:u}=c,d=s&&u.length?(e,t,n)=>{let r=(s===`replace`?u:[u[0]]).map(e=>{let t=l.nodes[e];return{n:t,at:(t.parent?l.nodes[t.parent].children:l.roots).indexOf(e)}});r.sort((e,t)=>e.n.parent===t.n.parent?t.at-e.at:0);let i=Math.min(...e.map(e=>e.x??0)),a=Math.min(...e.map(e=>e.y??0)),o=[...t],c=[];return r.forEach(({n:t,at:n},r)=>e.forEach((e,s)=>{let l=`paste${r}_${s}`;c.push(l),o.push({op:`create`,parent:t.parent,index:n+1+s,tree:{...e,key:l,x:t.x+((e.x??0)-i),y:t.y+((e.y??0)-a),absolute:!!t.absolute}})})),s===`replace`&&o.push(...vn(u)),q(o,n,c),!0}:null,f=s===`replace`?`Paste to replace`:`Paste over selection`,p=u.length===1?l.nodes[u[0]]:void 0,m=o?Wr(o.x,o.y,[]):p?.type===`frame`?p.boolean?p.parent:p.id:null,g=!t(`text/html`).includes(e)&&n.some(e=>e.type.startsWith(`image/`)),_=g&&!o?zu(l,p?.id):null,v=g?mt(l,m):m,y=r.current.getBoundingClientRect(),x=o?Br(o.x,o.y):Br(y.left+y.width/2,y.top+y.height/2),S=v?R.get(v):void 0,C=S?{x:Math.round(x.x-S.x),y:Math.round(x.y-S.y)}:{x:Math.round(x.x),y:Math.round(x.y)},w=t(`text/html`).match(RegExp(`${e}="([^"]+)"`))??t(`text/plain`).match(RegExp(`<!--${e}:([A-Za-z0-9+/=]+)-->`));if(w){let e;try{e=JSON.parse(i(w[1]))}catch{return L(`Couldn’t read the clipboard`)}let t=!!e.from&&e.from!==location.origin,n=[];if(t){let t=(e,n=[])=>{if(e&&typeof e==`object`){typeof e.instanceOf==`string`&&n.push(e.instanceOf);for(let r of e.children??[])t(r,n)}return n};e.items=e.items.map(e=>{let r=t(e.tree).filter(e=>!l.nodes[e]).some(e=>!b(e))&&e.detached?{...e,tree:e.detached}:e;for(let e of t(r.tree).filter(e=>!l.nodes[e])){let t=b(e)?.id;t&&!n.includes(t)&&!(l.libraries?.kits??[]).includes(t)&&n.push(t)}return r}),RO(e.items.map(e=>e.tree),e.styles,l.styles)}let a=o||v&&!e.items.some(e=>e.parent===l.nodes[v].parent)?v:null,s=r.current.getBoundingClientRect(),c=!o&&!u.length?Br(s.left+(s.width-vr.current.r)/2,s.top+(s.height+vr.current.t)/2):void 0,p=Tn(l,e.items,a,c);if(o){let t=e.items[0].tree;for(let n of p.ops){if(n.op!==`create`||!n.tree)continue;let r=e.items[p.ops.indexOf(n)]?.tree??t;n.tree.x=C.x+((r.x??0)-(t.x??0)),n.tree.y=C.y+((r.y??0)-(t.y??0))}}let m=e.assets.filter(e=>!l.assets[e.id]&&!h(e.id)),g=e.assets.filter(e=>!h(e.id)).map(e=>e.file);if(t&&g.length){let t=await fetch(`/api/assets/copy`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({from:e.from,files:g})}).then(e=>e.json(),()=>({failed:g}));t.failed?.length&&L(`${t.failed.length} picture${t.failed.length>1?`s`:``} couldn’t be brought over: open the project it came from and paste again`)}let _=[...m.length?[{op:`asset`,add:m}]:[],...n.length?[{op:`doc`,libraries:{kits:[...l.libraries?.kits??[],...n]}}]:[]];if(d?.(e.items.map(e=>e.tree),_,f))return;q([..._,...p.ops],`Paste`,p.keys);return}let T=n.find(e=>e.type.startsWith(`image/`));if(T){let e;try{e=await Iu(T)}catch(e){return L(e instanceof Error?e.message:`Couldn’t paste the image`)}let{w:t,h:n}=Ou(e.w,e.h),r={type:`frame`,key:`img`,name:T.name&&T.name!==`image.png`?e.name:`Image`,w:t,h:n,fills:[{type:`image`,asset:e.asset.id,fit:`cover`}],...o?C:_?{x:_.x,y:_.y}:v?{x:0,y:0}:{x:C.x-Math.round(t/2),y:C.y-Math.round(n/2)}};if(d?.([{...r,x:0,y:0}],[{op:`asset`,add:[e.asset]}],f))return;q([{op:`asset`,add:[e.asset]},{op:`create`,parent:v,tree:r}],`Paste image`,[`img`]);return}let E=t(`text/plain`),D=nj(E);if(D){let e=rj(D),t=await fetch(`/api/asset?w=${e.w}&h=${e.h}`,{method:`POST`,headers:{"content-type":`image/svg+xml`},body:D}).catch(()=>null),n=t?.ok?await t.json():null;if(!n?.asset)return L(`Couldn’t paste the SVG`);let r={type:`vector`,key:`svg`,name:`Vector`,asset:n.asset.id,w:e.w,h:e.h,...o?C:v?{x:0,y:0}:{x:C.x-Math.round(e.w/2),y:C.y-Math.round(e.h/2)}};if(d?.([{...r,x:0,y:0}],[{op:`asset`,add:[n.asset]}],f))return;q([{op:`asset`,add:[n.asset]},{op:`create`,parent:v,tree:r}],`Paste SVG`,[`svg`])}else if(E.trim()){let e={type:`text`,key:`txt`,content:E.replace(/\r\n/g,`
|
|
45
|
+
`).trimEnd(),...v&&!o?{x:0,y:0}:C};if(d?.([{...e,x:0,y:0}],[],f))return;q([{op:`create`,parent:v,tree:e}],`Paste text`,[`txt`])}};Da.current=_;let v=n=>{if(!a()||t(n.target)||B||!n.clipboardData)return;let r=n.clipboardData,i=[...r.files];if(!r.getData(`text/html`).includes(e)&&!i.some(e=>e.type.startsWith(`image/`))&&!r.getData(`text/plain`).trim()){/\(figm(a|eta)\)/.test(r.getData(`text/html`))&&(n.preventDefault(),L(`Figma layers paste here as SVG: in Figma, right-click → Copy/Paste as → Copy as SVG`));return}n.preventDefault();let o=r.getData(`text/html`),s=r.getData(`text/plain`);_(e=>e===`text/html`?o:e===`text/plain`?s:``,i)};return document.addEventListener(`copy`,m),document.addEventListener(`cut`,g),document.addEventListener(`paste`,v),()=>{document.removeEventListener(`copy`,m),document.removeEventListener(`mousedown`,c,!0),document.removeEventListener(`mouseup`,l,!0),document.removeEventListener(`cut`,g),document.removeEventListener(`paste`,v)}},[u,B,q]);let ka=u.filter(e=>R.has(e)),Aa=ka.map(e=>R.get(e)),ja=Vt(Aa);(0,H.useEffect)(()=>{Ae&&(u.length!==1||u[0]!==Ae)&&je(null)},[u,Ae]),(0,H.useEffect)(()=>{let e=()=>{let e=m.current.length===1?m.current[0]:null;e&&Dr.current&&OO(Dr.current,e)&&je(e)};return window.addEventListener(Td,e),()=>window.removeEventListener(Td,e)},[]);let Ma=u.length===1?K?.nodes[u[0]]:void 0,Na=Ie??g,Pa=Na&&!u.includes(Na)&&!Sr.current?R.get(Na)??null:null,Fa=(K?Ot(K):[]).map(e=>({id:e,box:R.get(e)})).filter(e=>!!e.box),Ia=e.chats.some(e=>e.status===`running`),La=e.connected?Ia?`working`:`ready`:`offline`,Ra=e.connected?Ia?`${fw(e.chats.find(e=>e.status===`running`)?.runner)} is working`:e.last?`Connected · last: ${e.last.actor===`claude`?fw():`You`} · ${e.last.label}`:`Connected`:`Disconnected · reconnecting`,za=!!K&&z===`frame`,Ba=Wt?vl().rulerSize:0,Va={l:0,r:K&&yr?ir:0,t:Ba+vl().canvasTop},Ha=e=>{if(!K||!r.current)return;let t=l.current,n=(Va.l+(r.current.clientWidth-Va.r-Va.l)/2-t.x)/t.z,i=(Va.t+(r.current.clientHeight-Va.t)/2-t.y)/t.z,a={x:Math.round(n-e.w/2),y:Math.round(i-e.h/2),w:e.w,h:e.h};for(let e=!0,t=0;e&&t<200;t++){e=!1;for(let t of j(K)){let n=R.get(t.id)??t;a.x<n.x+n.w+40&&n.x-40<a.x+a.w&&a.y<n.y+n.h+40&&n.y-40<a.y+a.h&&(a.x=Math.round(n.x+n.w+80),e=!0)}}let o={type:`frame`,key:`new`,name:e.name,...a,fill:ae,clip:!0};q([{op:`create`,parent:null,tree:o}],`Frame · ${e.name}`,[`new`]).then(()=>{Ut(`move`),Mr({x:a.x-80,y:a.y-80,w:a.w+160,h:a.h+160})})};vr.current=Va;let Ua=vl().gap,Wa=vl().rulerSize,Ga=e=>(0,U.jsx)(`button`,{className:e,"aria-pressed":yr,onClick:xr,"aria-label":yr?`Hide panel`:`Show panel`,"data-tip":yr?`Hide panel`:`Show panel`,"data-kbd":`⌘\\\\`,children:(0,U.jsx)(X.sidebarRight,{})}),Ka=(0,U.jsxs)(`button`,{className:`zoom ${ha?`on`:``}`,"aria-label":`Zoom`,"aria-haspopup":`menu`,"aria-expanded":!!ha,onClick:e=>{if(ha)return ga(null);let t=e.currentTarget.getBoundingClientRect();ga({x:t.right,y:t.bottom+V(`--menu-gap`)})},children:[Math.round(i.z*100),`%`,(0,U.jsx)(X.chevronDown,{})]}),qa=()=>{if(!K)return null;let e=u.length?ij(K,u[0]):null;return e&&K.nodes[e]?.type===`frame`?e:K.roots.find(e=>K.nodes[e]?.type===`frame`)??null},Ja=e=>(0,U.jsx)(`button`,{className:e,onClick:()=>zn(qa()),"aria-label":`Preview`,"data-tip":`Preview in the browser, 1:1 and live`,children:(0,U.jsx)(X.play,{})}),Ya=e=>(0,U.jsx)(`button`,{className:`${e} ${gn?`on`:``}`,onClick:En,"aria-label":`Browser`,"aria-pressed":gn,"data-tip":gn?`Hide browser`:`Browser`,"data-kbd":`⇧⌘B`,children:(0,U.jsx)(X.globe,{})}),Xa={"--tools-l":`${Wt?Va.l+Wa+Ua:Va.l||Ua}px`,"--tools-t":`${Va.t+Ua}px`,"--bar-top":`${Ba+Ua}px`,"--bar-left":`${Va.l+(Wt?Wa:0)+Ua}px`,"--covered-top":`${Va.t}px`,"--corner-r":`${Va.r+Ua}px`},Za=gr??G?.canvas,Qa=hk(),$a=Za?Za.startsWith(`$`)?K?.styles.colors[Za.slice(1)]??Qa:Za:Qa,eo=gk($a.slice(0,7)),to=B?{id:B,range:Qi,onInput:e=>{Zi.current=e,Be(e=>e+1),Yi.current&&M([{op:`update`,id:B,set:{content:e}}])},onRange:e=>$i(t=>t&&t.start===e.start&&t.end===e.end?t:e),onKey:(e,t)=>{let n=G?.nodes[B];if(!G||n?.type!==`text`)return!1;let r=Ec({code:sc(e),shift:e.shiftKey,alt:e.altKey,meta:rl(e)},oi.current,Zi.current);if(r){oi.current=r.next;let e=ii.current?.id===n.id?ii.current:null;if(e){let t=si.current[r.next.done];return e.fold([{op:`update`,id:n.id,set:{content:Zi.current,spans:t?.length?t:null}}],`Add text`),!0}return fetch(`/api/${r.kind}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({selection:m.current})}),!0}let i=n.style?G.styles.text[n.style.slice(1)]:void 0,a=Zi.current||n.content,o=Cc({code:sc(e),shift:e.shiftKey,alt:e.altKey,meta:rl(e)},{fontWeight:$A(G,n.id,`fontWeight`),fontStyle:n.fontStyle??i?.fontStyle,textDecoration:n.textDecoration},c(n.content,a,n.spans),t.start,t.end);return o?(ea(o.patch,o.label,!1,t),!0):!1},onDone:e=>Ki(B,e)}:null;return(0,U.jsxs)(`div`,{className:`app`,children:[Ve&&(0,U.jsx)(EO,{onClose:()=>Ue(!1)}),We&&(0,U.jsx)(ED,{onClose:()=>Ge(!1)}),pa&&(0,U.jsx)(Gl,{x:pa.x,y:pa.y,items:Ca(),onClose:()=>ma(null)}),ha&&(0,U.jsx)(Gl,{x:ha.x,y:ha.y,alignRight:!0,items:_a(),onClose:()=>ga(null)}),be&&(0,U.jsx)(Gl,{x:be.x,y:be.y,onClose:()=>Se(null),items:HA.map(e=>({label:e.label,kbd:e.hint,icon:(0,U.jsx)(e.icon,{}),checked:ve===e.id,onClick:()=>Ut(e.id)}))}),Ee&&(0,U.jsx)(Gl,{x:Ee.x,y:Ee.y,onClose:()=>De(null),items:[...Rc.map(e=>({label:e.label,kbd:e.hint||void 0,icon:(0,U.jsx)(Hc,{kind:e.id}),checked:he===e.id,onClick:()=>Ut(e.id)})),{sep:!0},{label:`Image/video…`,kbd:`⇧⌘K`,icon:(0,U.jsx)(X.media,{}),onClick:()=>Me.current?.click()}]}),(0,U.jsxs)(`div`,{className:`app-main`,style:{"--inset-l":`${Va.l}px`,"--inset-r":`${Va.r}px`,...Xa},children:[(0,U.jsxs)(`header`,{className:`bar`,children:[(0,U.jsxs)(`button`,{className:`brand ${pr?`on`:``}`,"aria-label":`Main menu`,"aria-haspopup":`menu`,"aria-expanded":!!pr,onClick:e=>{if(pr)return mr(null);let t=e.currentTarget.getBoundingClientRect();mr({x:t.left,y:t.bottom+V(`--menu-gap`)})},children:[(0,U.jsx)(nr,{}),(0,U.jsx)(`span`,{className:`beta`,children:`Beta`}),(0,U.jsx)(`span`,{className:`brand-caret`,children:(0,U.jsx)(X.chevronDown,{})})]}),(0,U.jsx)(`span`,{className:`bar-sep`}),K&&(0,U.jsx)(cO,{onError:L,current:(0,U.jsx)(oO,{name:K.name,folder:e.project,saving:e.saved<0?null:e.saved<e.version,blocked:!!e.newer,saveError:e.saveError,state:La,status:Ra,onRename:e=>void q([{op:`doc`,name:e}],`Rename project`),onError:L})}),(0,U.jsx)(kD,{})]}),pr&&(0,U.jsx)(Gl,{x:pr.x,y:pr.y,onClose:()=>mr(null),items:_k({rulers:Wt,grids:Jt,pixelGrid:Qt,toggleRulers:qt,toggleGrids:Xt,togglePixelGrid:dn,browser:gn,toggleBrowser:En,zoomIn:()=>Fr(Ir()*2),zoomOut:()=>Fr(Ir()/2),zoom100:()=>Fr(1),fitAll:()=>Nr(),fitSelection:Aa.length?()=>Mr(ja,FA):void 0,shortcuts:()=>Ue(!0),settings:e=>fr(e),feedback:()=>Ge(!0),sections:Sa(),layers:yr,toggleLayers:xr,nextFrame:()=>J(`KeyN`,{},`n`),previousFrame:()=>J(`KeyN`,{shift:!0},`N`)})}),dr&&K&&(0,U.jsx)(vd.Provider,{value:yd(K),children:(0,U.jsx)(yk,{tab:dr,onTab:fr,onClose:()=>{fr(null),_r(null)},color:{canvas:G?.canvas,styles:K.styles.colors,onPreview:_r,onCommit:e=>{q([{op:`doc`,canvas:e}],e?`Canvas color`:`Reset canvas color`),_r(e)}}})}),Ke&&K&&(0,U.jsx)(IT,{doc:K,commit:(e,t)=>void q(e,t),onClose:()=>qe(!1)}),I&&(0,U.jsx)(`div`,{className:`toast`,role:`status`,children:ol(I)}),e.disconnected&&(0,U.jsx)(`div`,{className:`sheet-backdrop`,children:(0,U.jsxs)(`div`,{className:`sheet closed-sheet`,role:`alertdialog`,"aria-labelledby":`closed-title`,children:[(0,U.jsx)(`h2`,{id:`closed-title`,children:`Nudge was disconnected`}),(0,U.jsx)(`p`,{children:`Nudge was taken out of your agents, so this canvas closed. Your work is saved in the project’s design folder.`}),(0,U.jsxs)(`p`,{children:[`To use Nudge again, run `,(0,U.jsx)(`code`,{children:`nudge-canvas init`}),` and start a new agent session.`]})]})}),e.newer&&(0,U.jsxs)(`div`,{className:`refused-bar`,role:`alert`,children:[`Editing is paused and nothing is saved. `,e.newer,` This canvas opens the file again as soon as this version can read it.`]}),(0,U.jsx)(`div`,{className:`body`,children:(0,U.jsxs)(`div`,{className:`stage`,children:[(0,U.jsxs)(`div`,{className:`canvas tool-${z}${x?` measuring`:``}${at?` picking`:``}${eo?` dark`:``}`,ref:r,style:{background:$a,cursor:z===`frame`||WA(z)?wt():z===`pen`?Tt():void 0},onPointerDown:Xr,onPointerMove:fa,onPointerUp:wa,onPointerCancel:wa,onContextMenu:va,onPointerLeave:()=>_(null),onDoubleClick:Ea,onScroll:e=>{e.currentTarget.scrollLeft=0,e.currentTarget.scrollTop=0},onDragOver:e=>{Vi(e.dataTransfer)&&!e.defaultPrevented&&!Hi(e.target)?(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Wi(e)):(e.dataTransfer.types.includes(`application/x-nudge-icon`)||e.dataTransfer.types.includes(`application/x-nudge-component`))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||rr(null)},onDrop:e=>{if(Vi(e.dataTransfer)&&!e.defaultPrevented&&!Hi(e.target)){e.preventDefault(),rr(null),Gi([...e.dataTransfer.files],e.clientX,e.clientY);return}let t=e.dataTransfer.getData(Jw);if(t){e.preventDefault();let n=t.startsWith(`{`)?(()=>{try{return JSON.parse(t)}catch{return null}})():null;$r(n?.main??t,{cx:e.clientX,cy:e.clientY},n?.values);return}let n=e.dataTransfer.getData(Vw);if(!n)return;e.preventDefault();let{size:r,...i}=JSON.parse(n);Qr(i,{cx:e.clientX,cy:e.clientY},r)},children:[K&&(0,U.jsxs)(`div`,{className:`world`,style:{transform:`translate(${i.x}px, ${i.y}px) scale(${i.z})`,"--z":o},children:[(0,U.jsx)(He,{doc:K,editing:to}),(0,U.jsx)(Yk,{doc:K,view:i,boxes:R,selection:u,onOpen:Kn,onCommit:(e,t)=>void q(e,t),hover:(()=>{let e=Na?K.nodes[Na]:void 0;for(;e?.parent;)e=K.nodes[e.parent];return e?.id??null})()})]}),(0,U.jsxs)(`div`,{className:`overlay`,children:[W.focus&&(()=>{let e=K?.nodes[W.focus.frame];if(!e)return null;let t=yl({x:e.x+W.focus.x-3,y:e.y+W.focus.y-3,w:W.focus.w+6,h:W.focus.h+6},i);return(0,U.jsx)(`div`,{className:`build-focus`,style:{left:t.x,top:t.y,width:t.w,height:t.h}})})(),Fa.map(({id:e,box:n})=>{let a=yl(n,i);return(0,U.jsx)(`div`,{className:`frame-label ${u.includes(e)?`on`:``} ${K?.nodes[e]?.componentSet?`set`:``} ${jA(K,e)?`comp`:``}`,style:{left:a.x,top:a.y-20,maxWidth:Math.max(a.w,40)},onPointerDown:t=>{if(t.stopPropagation(),ut===e)return;if(t.button!==0){u.includes(e)||f([e]);return}let n=ft.current,i=performance.now();if(ft.current={id:e,t:i,x:t.clientX,y:t.clientY},t.detail>=2||n&&n.id===e&&i-n.t<500&&Math.hypot(t.clientX-n.x,t.clientY-n.y)<5){ft.current=null,t.preventDefault(),Sr.current=null,f([e]),dt(e);return}r.current.setPointerCapture(t.pointerId);let a=t.shiftKey?Pt(K,[...u,e]):[e];f(a),Sr.current={kind:`move`,sx:t.clientX,sy:t.clientY,ids:a,started:!1,boxes:R}},onDoubleClick:e=>e.stopPropagation(),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ut!==e&&(u.includes(e)||f([e]),ma({x:t.clientX,y:t.clientY,layers:[e],hit:e}))},"data-tip":ut===e?void 0:`Double-click to rename`,children:ut===e?(0,U.jsx)(`input`,{className:`frame-label-in`,autoFocus:!0,defaultValue:K?.nodes[e]?.name,"aria-label":`Frame name`,onFocus:e=>e.currentTarget.select(),onKeyDown:t=>{t.stopPropagation(),t.nativeEvent.isComposing||(t.key===`Enter`&&t.currentTarget.blur(),t.key===`Escape`&&(t.currentTarget.value=K?.nodes[e]?.name??``,t.currentTarget.blur()))},onBlur:t=>{dt(null);let n=t.currentTarget.value.trim();n&&n!==K?.nodes[e]?.name&&q([{op:`update`,id:e,set:{name:n}}],`Rename`)}}):(0,U.jsxs)(U.Fragment,{children:[t[e]&&(0,U.jsx)(`span`,{className:`sync-dot ${t[e].state}`,role:`img`,"aria-label":lO(t[e]),"data-tip":lO(t[e])}),jA(K,e)&&(0,U.jsx)(`span`,{className:`frame-label-icon`,"aria-hidden":!0,children:(K?.nodes[e]).instanceOf?(0,U.jsx)(X.instance,{}):(0,U.jsx)(X.component,{})}),(0,U.jsx)(`span`,{className:`frame-label-name`,children:K?.nodes[e]?.name}),K?.nodes[e]?.build&&(()=>{let t=Sl(W.views,e)===`side`;return(0,U.jsx)(`button`,{className:`frame-play-btn ${t?`on`:``}`,"aria-pressed":t,"aria-label":t?`Hide the live page`:`Show the live page`,"data-tip":t?`Hide the live page`:`Show the live page beside it`,onPointerDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),Al(e,t?`off`:`side`)},children:(0,U.jsx)(X.play,{})})})()]})},e)}),K&&u.length===1&&(()=>{let e=K.nodes[u[0]],t=e?.type===`frame`?e.main?e.id:e.instanceOf:void 0;return t?[t,...Ne(K,t)].filter(e=>e!==u[0]):[]})().map(e=>{let t=R.get(e);if(!t)return null;let n=yl(t,i);return(0,U.jsx)(`div`,{className:`comp-member`,style:{left:n.x,top:n.y,width:n.w,height:n.h},"aria-hidden":!0},`cm-${e}`)}),K&&Object.values(K.nodes).filter(e=>e.type===`frame`&&e.componentSet&&!e.inInstance&&!e.hidden).map(e=>{let t=R.get(e.id);if(!t)return null;let n=yl(t,i);return(0,U.jsx)(`div`,{className:`set-outline`,style:{left:n.x,top:n.y,width:n.w,height:n.h},"aria-hidden":!0},`set-${e.id}`)}),re&&(()=>{let e=re.steps[Math.min(oe,re.steps.length-1)],t=Vt(e.map(e=>R.get(e)).filter(e=>!!e));if(!t)return null;let n=yl(t,i);return(0,U.jsxs)(U.Fragment,{children:[e.map(e=>{let t=R.get(e);if(!t)return null;let n=yl(t,i);return(0,U.jsx)(`div`,{className:`agent-flash`,style:{left:n.x,top:n.y,width:n.w,height:n.h},"aria-hidden":!0},`${re.key}-${oe}-${e}`)}),(0,U.jsx)(`div`,{className:`agent-cursor ${le?`moving`:``}`,"aria-hidden":!0,style:{transform:`translate(${n.x-3}px, ${n.y-3}px)`,width:n.w+6,height:n.h+6,"--move":`${jr}ms`},children:(0,U.jsx)(`i`,{children:re.name})})]})})(),tr?.ghost&&(()=>{let e=yl(tr.ghost,i);return(0,U.jsx)(`div`,{className:`drop-ghost`,style:{left:e.x,top:e.y,width:e.w,height:e.h}})})(),tr?.line&&(()=>{let e=yl(tr.line,i);return(0,U.jsx)(`div`,{className:`drop-line`,style:{left:e.x,top:e.y,width:Math.max(2,e.w),height:Math.max(2,e.h)}})})(),e.chats.filter(e=>e.status===`running`).flatMap(e=>{let t=[...e.messages].reverse().find(e=>e.role===`user`&&`selection`in e&&e.selection?.length);return(t&&`selection`in t?t.selection??[]:[]).map(t=>{let n=R.get(t);if(!n)return null;let r=yl(n,i);return(0,U.jsxs)(`div`,{className:`scan`,style:{left:r.x,top:r.y,width:r.w,height:r.h},"aria-hidden":!0,children:[(0,U.jsx)(`span`,{className:`scan-body`}),!re&&(0,U.jsxs)(`span`,{className:`scan-label`,children:[(0,U.jsx)(X.sparkle,{}),fw(e.runner)]})]},`${e.id}-${t}`)})}),e.chats.filter(vt).map(e=>{let t=e.messages.find(e=>e.role===`user`),n=(t&&`selection`in t?t.selection??[]:[]).filter(e=>R.has(e)),a=Vt(n.map(e=>R.get(e)));return!a||!r.current?null:(0,U.jsx)(GC.Provider,{value:Er,children:(0,U.jsx)(jw,{chat:e,anchorIds:n,anchor:yl(a,i),open:st===e.id,bounds:{w:r.current.clientWidth-Va.r,h:r.current.clientHeight,l:Va.l,t:Va.t},onToggle:()=>ct(st===e.id?null:e.id),onCollapse:()=>{ct(null),e.status!==`running`&&(Or.current=!0,f([...n]),rt(!0))},onPopOut:()=>{Fi(e.id),ct(null)},onFrame:Ii,onNotice:L,frames:bi,onPickFrame:wi})},e.id)}),K&&!yr&&!Sr.current&&!nt&&!Ae&&(()=>{let e=B?[B]:u.filter(e=>K.nodes[e]),t=Vt(e.map(e=>R.get(e)).filter(e=>!!e));return e.length&&t?(0,U.jsx)(pc,{resetKey:e.join(),fallback:()=>null,children:(0,U.jsx)(vd.Provider,{value:yd(K),children:(0,U.jsx)(gD,{doc:K,base:G??void 0,ids:e,at:yl(t,i),boxes:R,onPreview:M,onCommit:(e,t,n)=>void q(e,t,n),onAsk:()=>rt(!0),onOpenPanel:xr,onCrop:e.length===1&&OO(K,e[0])?()=>je(e[0]):void 0,cropLabel:e.length===1?kO(K,e[0]):void 0},e.join())})}):null})(),ja&&!B&&!Oe&&!Ae&&!Sr.current&&($e||nt)&&!Ti&&(()=>{let e=uw(yl(ja,i),{w:(r.current?.clientWidth??0)-Va.r,h:r.current?.clientHeight??0,l:Va.l,t:Va.t});return(0,U.jsxs)(U.Fragment,{children:[!nt&&!me&&(0,U.jsx)(`button`,{className:`ai-btn`,style:e.badge,onPointerDown:e=>e.stopPropagation(),onPointerEnter:()=>et(!0),onClick:()=>rt(!0),"aria-label":`Ask ${fw(hr)}`,"data-tip":`Ask ${fw(hr)}`,children:(0,U.jsx)(X.sparkle,{})}),nt&&di&&!fi&&(()=>{let t=[...di.messages].reverse().find(e=>e.role===`user`);return(0,U.jsxs)(`div`,{className:`ask-thread`,style:{left:e.pop.left+10,top:e.pop.top-34},onPointerDown:e=>e.stopPropagation(),children:[(0,U.jsxs)(`button`,{className:`ask-thread-open`,onClick:()=>{rt(!1),bt(di.id)},"data-tip":`Continues “${di.title}” · ${hw(di.updatedAt)}`,children:[(0,U.jsx)(X.reply,{}),(0,U.jsx)(`span`,{children:t&&`text`in t?t.text:di.title}),(0,U.jsx)(X.chevronDown,{})]}),(0,U.jsx)(`button`,{className:`ask-thread-new`,onClick:()=>pi(!0),"aria-label":`Start a new chat`,"data-tip":`Start a new chat instead`,children:(0,U.jsx)(X.close,{})})]})})(),nt&&(0,U.jsxs)(`div`,{className:`ask-pop`,style:e.pop,onPointerDown:e=>e.stopPropagation(),children:[(0,U.jsx)(yw,{attach:!0,placeholder:vi?`Add details (optional)`:`Ask for changes`,autoFocus:!0,onCancel:()=>rt(!1),frames:bi,exclude:u,onPickFrame:wi,onTagged:_i,command:vi,onClearCommand:()=>yi(null),onSubmit:async(e,t,n)=>{let r=vi?await hi(e?`${vi.label}: ${e}`:vi.label,vi.quick,vi.count,t,n,vi.sizes,vi.axes):await hi(e,void 0,void 0,t,n);if(r.error)return L(r.error);rt(!1),ct(r.chatId??null)}}),(0,U.jsx)(HC,{compact:!0,chatRunner:di&&!fi?di.runner??`claude`:void 0}),K&&(0,U.jsx)(lw,{doc:K,selection:u,tagged:gi.length,active:vi?.quick,onUse:e=>{let t=PC(K,e);if(!t)return L(`This version's layer isn't in a screen anymore`);let n=K.nodes[e].variantOf;rt(!1),q(t,`Use this`).then(()=>{f([n]),L(`Swapped into the screen · ⌘Z to undo`)})},onPick:e=>yi(t=>!e.label||t?.quick===e.quick&&t.label===e.label&&!e.sizes&&!e.axes?null:e)})]})]})})(),at&&(()=>{let e=Si?R.get(Si):void 0,t=e?yl(e,i):null;return(0,U.jsxs)(U.Fragment,{children:[t&&(0,U.jsx)(`div`,{className:`pick-hover`,style:{left:t.x,top:t.y,width:t.w,height:t.h},"aria-hidden":!0}),(0,U.jsxs)(`div`,{className:`pick-hint`,role:`status`,children:[`Click a frame or its layer to add it`,(0,U.jsx)(`kbd`,{children:`Esc`})]})]})})(),Qt&&i.z>=BA&&(0,U.jsx)(`div`,{className:`pixel-grid`,"aria-hidden":!0,style:{backgroundSize:`${i.z}px ${i.z}px`,backgroundPosition:`${(i.x%i.z+i.z)%i.z}px ${(i.y%i.z+i.z)%i.z}px`}}),Jt&&K&&(0,U.jsx)(_A,{doc:K,boxes:R,view:i}),Wt&&r.current&&(0,U.jsx)(dk,{view:{...i,x:i.x-Va.l},left:Va.l,width:r.current.clientWidth-Va.l-Va.r,height:r.current.clientHeight,sel:Vt(u.map(e=>R.get(e)).filter(e=>!!e))}),Wt&&K&&r.current&&(0,U.jsx)(pk,{guides:G?.guides??[],view:i,host:r.current,boxes:R,inset:{...Va,t:0},onCommit:(e,t)=>void q([{op:`doc`,guides:e}],t)}),(()=>{let e=Vt(u.map(e=>R.get(e)).filter(e=>!!e)),t=[],n;if(x&&!Sr.current&&e&&K){let r=K.nodes[u[0]]?.parent??null,i=[];for(let e=w;e&&K.nodes[e];e=K.nodes[e].parent)i.unshift(e);let a=i.find(e=>K.nodes[e].parent===r&&!u.includes(e)),o=i.some(e=>u.includes(e)),s=[];for(let e=r;e&&K.nodes[e];e=K.nodes[e].parent)s.push(e);let c=E?s.find(e=>{let t=R.get(e);return!!t&&E.x>=t.x&&E.x<=t.x+t.w&&E.y>=t.y&&E.y<=t.y+t.h}):void 0,l=g&&!u.includes(g)&&!o&&!s.includes(g)?g:null,d=l&&(!c||YA(K,c,l)),f=a??(d?l:c??(g&&!u.includes(g)&&!o?g:r));n=f?R.get(f):void 0,n&&(t=tk(e,n))}if(!v.length&&!t.length)return null;let r=(e,t)=>({x:e*i.z+i.x,y:t*i.z+i.y}),a=vl().snapMarkR,{labelH:o,labelCharW:s,labelPad:c,badgeRadius:l,badgeGap:d,labelBaseline:f}=vl();return(0,U.jsxs)(`svg`,{className:`guides`,width:`100%`,height:`100%`,children:[v.map((e,t)=>{if(e.value!==void 0)return null;let n=r(e.x1,e.y1),i=r(e.x2,e.y2);return(0,U.jsx)(`line`,{x1:n.x,y1:n.y,x2:i.x,y2:i.y},t)}),v.flatMap((e,t)=>(e.marks??[]).map((e,n)=>{let i=r(e.x,e.y);return(0,U.jsx)(`path`,{className:`snap-mark`,d:`M${i.x-a} ${i.y-a}L${i.x+a} ${i.y+a}M${i.x+a} ${i.y-a}L${i.x-a} ${i.y+a}`},`m${t}-${n}`)})),n&&(()=>{let e=yl(n,i);return(0,U.jsx)(`rect`,{className:`measure-target`,x:e.x,y:e.y,width:e.w,height:e.h})})(),[...v.flatMap(e=>e.value===void 0?[]:[{...e,value:e.value}]),...t].map((e,t)=>{let n=r(e.x1,e.y1),i=r(e.x2,e.y2),a=String(e.value),u=a.length*s+2*c,p=n.y===i.y,m=Math.hypot(i.x-n.x,i.y-n.y)<(p?u:o),h=(n.x+i.x)/2+(m&&!p?u/2+d:0),g=(n.y+i.y)/2+(m&&p?o/2+d:0);return(0,U.jsxs)(`g`,{children:[(0,U.jsx)(`line`,{x1:n.x,y1:n.y,x2:i.x,y2:i.y}),(0,U.jsx)(`rect`,{className:`measure-pill`,x:h-u/2,y:g-o/2,width:u,height:o,rx:l}),(0,U.jsx)(`text`,{x:h,y:g+f,children:a})]},t)})]})})(),K&&u.length>=2&&!B&&z===`move`&&!x&&!u.some(e=>rn(K,K.nodes[e]?.parent??null))&&(0,U.jsx)(fA,{doc:K,selection:u,boxes:R,view:i,onPreview:e=>M(e),onCommit:(e,t)=>void q(e,t)}),K&&Oe&&K.nodes[Oe]&&r.current&&R.get(Oe)&&(0,U.jsx)(AA,{doc:K,id:Oe,box:ta(Oe)?.box??R.get(Oe),m:tn(K,Oe),own:en(K.nodes[Oe]),view:i,host:r.current,onPreview:e=>M(e),onCommit:(e,t)=>void q(e,t),onExit:()=>ke(null)},Oe),z===`pen`&&r.current&&(0,U.jsx)(OA,{view:i,host:r.current,onCommit:zi,onCancel:()=>Ut(`move`)}),K&&u.length===1&&!B&&!Oe&&z===`move`&&!x&&(0,U.jsx)(hA,{doc:K,id:u[0],boxes:R,view:i,onPreview:e=>M(e),onCommit:(e,t)=>void q(e,t)}),K&&(0,U.jsx)(eO,{doc:K,boxes:R,view:i,insets:Va,chats:e.chats,runner:hr,draft:xt,setDraft:St,openId:Ct,setOpenId:Et,showResolved:kt,onNotice:L,onOpenChat:Fi}),(0,U.jsx)(xl,{view:i,hover:Oe||Ae?null:Pa,selected:Oe||Ae?[]:Aa,bounds:Oe||Ae?null:ja,size:B||Oe||Ae?null:u.length===1&&ta(u[0])?.box||ja&&{w:ja.w,h:ja.h},resizable:Ae?!1:u.length>1?!B&&u.every(e=>K?.nodes[e]&&!K.nodes[e].locked):!!Ma&&!Ma.locked&&!B&&!Oe&&!yA(Ma),marquee:N,onHandleDown:sa,turned:u.length===1&&!Oe?ta(u[0]):null,onRotateDown:aa&&!B&&!Oe&&z===`move`?oa:void 0,badge:ra,scaling:z===`scale`,hoverComp:!!Na&&jA(K,Na),selComp:u.length>0&&u.every(e=>jA(K,e)),memberTurns:ka.map(e=>ta(e))}),K&&z===`move`&&!B&&!Oe&&!Ae&&!Sr.current&&r.current&&(()=>{let e=!yr&&!nt,t=new Set(e?[]:u.filter(e=>Lf(K.nodes[e])>=0)),n=Rf(K,Ie)??(g?Rf(K,w):null);n&&!(e&&u.includes(n))&&t.add(n);let a={x:Va.l,y:Va.t,w:r.current.clientWidth-Va.l-Va.r,h:r.current.clientHeight-Va.t};return[...t].map(e=>R.get(e)&&(0,U.jsx)(pA,{doc:K,id:e,box:R.get(e),view:i,viewport:a},e))})(),K&&u.length===1&&!B&&!Oe&&!Ae&&z===`move`&&!Sr.current&&r.current&&R.get(u[0])&&(0,U.jsx)(vA,{doc:K,id:u[0],box:R.get(u[0]),view:i,host:r.current,onPreview:e=>M(e),onCommit:(e,t)=>void q(e,t)}),K&&na&&u.length===1&&u[0]===na.id&&!B&&!Oe&&!Ae&&z===`move`&&!Sr.current&&r.current&&R.get(na.id)&&(0,U.jsx)(bA,{doc:K,id:na.id,index:na.index,box:R.get(na.id),view:i,host:r.current,onPreview:e=>M(e),onCommit:(e,t)=>void q(e,t)}),K&&Ae&&r.current&&R.get(Ae)&&(0,U.jsx)(LO,{doc:K,id:Ae,box:R.get(Ae),view:i,host:r.current,onPreview:e=>M(e),onCommit:(e,t)=>void q(e,t),onDone:()=>je(null)})]}),K&&(0,U.jsx)(tO,{doc:K,runner:hr,active:z===`comment`,showResolved:kt,onShowResolved:Bt,onNotice:L,onSent:Fi}),K&&!K.roots.length&&(0,U.jsxs)(`div`,{className:`empty`,children:[(0,U.jsx)(`p`,{children:`Empty canvas`}),(0,U.jsxs)(`p`,{children:[`Press F to draw a frame, or ask `,fw(hr),` for a screen.`]})]}),(0,U.jsxs)(`div`,{className:`tools ${Wt?`with-rulers`:``}`,onPointerDown:e=>e.stopPropagation(),children:[(0,U.jsx)(`div`,{className:`toolbar`,role:`toolbar`,"aria-label":`Tools`,"aria-orientation":`vertical`,children:(()=>{let e=e=>(0,U.jsx)(`button`,{className:z===e.id?`on`:``,"data-tip":e.label,"data-kbd":e.hint,"aria-label":e.label,"aria-pressed":z===e.id,onClick:()=>Ut(e.id),children:(0,U.jsx)(e.icon,{})},e.id),t=e=>VA.find(t=>t.id===e),n=(e,t,n,r,i,a,o)=>(0,U.jsxs)(`div`,{className:`tool-split ${n?`on`:``}`,children:[(0,U.jsx)(`button`,{className:n?`on`:``,"data-tip":r.label,"data-kbd":r.hint||void 0,"aria-label":r.label,"aria-pressed":n,onClick:i,children:r.icon}),(0,U.jsx)(`button`,{className:`tool-caret`,"aria-label":t,"aria-haspopup":`menu`,"aria-expanded":a,"data-tip":t,onClick:e=>o(e.currentTarget.parentElement.getBoundingClientRect()),children:(0,U.jsx)(X.chevronDown,{})})]},e),r=t(ve),i=Rc.find(e=>e.id===he);if(Ce){let e=WA(z)?{label:i.label,icon:(0,U.jsx)(Hc,{kind:z})}:z===`pen`?{label:`Pen`,icon:(0,U.jsx)(X.pen,{})}:(()=>{let e=t(z);return{label:e.label,icon:(0,U.jsx)(e.icon,{})}})();return[(0,U.jsx)(`button`,{className:`on`,"data-tip":`${e.label} · Show tools`,"aria-label":`${e.label}, show tools`,onClick:()=>Te(!1),children:e.icon},`cur`),(0,U.jsx)(`button`,{className:`tool-caret tool-fold`,"aria-label":`Show tools`,"aria-expanded":!1,"data-tip":`Show tools`,onClick:()=>Te(!1),children:(0,U.jsx)(X.foldDown,{})},`fold`)]}return[n(`move`,`Move tools`,z===`move`||z===`scale`,{label:r.label,hint:r.hint,icon:(0,U.jsx)(r.icon,{})},()=>Ut(ve),!!be,e=>Se(be?null:{x:e.right+V(`--menu-gap`),y:e.top})),e(t(`frame`)),n(`shape`,`Shape tools`,WA(z),{label:i.label,hint:i.hint,icon:(0,U.jsx)(Hc,{kind:he})},()=>Ut(he),!!Ee,e=>De(Ee?null:{x:e.right+V(`--menu-gap`),y:e.top})),(0,U.jsx)(`button`,{className:z===`pen`?`on`:``,"data-tip":`Pen`,"data-kbd":`P`,"aria-label":`Pen`,"aria-pressed":z===`pen`,onClick:()=>Ut(`pen`),children:(0,U.jsx)(X.pen,{})},`pen`),e(t(`text`)),e(t(`comment`)),(0,U.jsx)(`button`,{className:`tool-caret tool-fold`,"aria-label":`Hide tools`,"aria-expanded":!0,"data-tip":`Hide tools`,onClick:()=>Te(!0),children:(0,U.jsx)(X.foldUp,{})},`fold`)]})()}),(0,U.jsx)(`input`,{ref:Me,type:`file`,accept:bu,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Bi(t)}})]}),(0,U.jsx)(`button`,{className:`help-btn`,"data-tip":`Keyboard shortcuts`,"data-kbd":`⌘/`,"aria-label":`Keyboard shortcuts`,onPointerDown:e=>e.stopPropagation(),onClick:()=>Ue(!0),children:`?`}),!(K&&yr)&&(0,U.jsxs)(`div`,{className:`view-tile`,onPointerDown:e=>e.stopPropagation(),children:[Ga(`bar-btn`),(0,U.jsx)(`span`,{className:`view-sep`}),Ka,(0,U.jsx)(`span`,{className:`view-sep`}),Ja(`bar-btn`),Ya(`bar-btn`)]})]}),K&&yr&&(0,U.jsxs)(`aside`,{className:`panel side`,style:{width:ir},"aria-label":`Panel`,children:[(0,U.jsx)(`div`,{className:`panel-edge ${sr.current?`on`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,onPointerDown:e=>{e.target.setPointerCapture(e.pointerId),sr.current={x:e.clientX,w:ir}},onPointerMove:e=>{let t=sr.current;if(!t)return;let n=Math.round(Math.min(qA,Math.max(KA,t.w-(e.clientX-t.x))));n!==or.current&&ar(n)},onPointerUp:()=>{sr.current=null;try{localStorage.setItem(`nudge.panel.w`,String(or.current))}catch{}},onDoubleClick:()=>{ar(IA);try{localStorage.setItem(`nudge.panel.w`,String(IA))}catch{}},"data-tip":`Drag to resize · double-click to reset`}),(0,U.jsxs)(`div`,{className:`panel-top`,children:[Ga(`bar-btn`),(0,U.jsx)(`span`,{className:`view-sep`}),Ka,(0,U.jsx)(`span`,{className:`tabs-fill`}),Ja(`bar-btn`),Ya(`bar-btn`)]}),(0,U.jsxs)(`div`,{className:`panel-title tabs`,role:`tablist`,children:[(0,U.jsx)(`button`,{role:`tab`,"aria-selected":Je===`design`,className:Je===`design`?`on`:``,onClick:()=>Ye(`design`),children:`Design`}),(0,U.jsx)(`button`,{role:`tab`,"aria-selected":Je===`code`,className:Je===`code`?`on`:``,onClick:()=>Ye(`code`),children:`Code`}),(0,U.jsxs)(`button`,{role:`tab`,"aria-selected":Je===`agents`,className:Je===`agents`?`on`:``,onClick:()=>Ye(`agents`),children:[`Agents`,e.chats.some(e=>e.status===`running`)&&(0,U.jsx)(`span`,{className:`run-dot`,"aria-label":`working`})]}),(0,U.jsx)(`button`,{role:`tab`,"aria-selected":Je===`libraries`,className:Je===`libraries`?`on`:``,onClick:()=>Ye(`libraries`),children:`Libraries`})]}),Je===`design`?(()=>{let e=K.roots.length>0;return(0,U.jsxs)(`div`,{className:`side-design`,children:[e&&(0,U.jsx)(`div`,{className:`side-layers`,style:{flex:`0 0 ${Math.round(cr*100)}%`},children:(0,U.jsx)(hl,{doc:K,selection:u,boxes:R,onSelect:f,onHover:Re,renameReq:Jn,interactive:n,onContextMenu:(e,t)=>{u.includes(t)||f([t]),ma({x:e.clientX,y:e.clientY,layers:[],hit:t,fromLayers:!0})},onCommit:(e,t)=>void q(e,t)})}),e&&(0,U.jsx)(`div`,{className:`side-split ${ur.current?`on`:``}`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize layers`,onPointerDown:e=>{e.target.setPointerCapture(e.pointerId),ur.current={y:e.clientY,share:cr,h:e.currentTarget.parentElement.clientHeight}},onPointerMove:e=>{let t=ur.current;t&&lr(ZA(t,e.clientY))},onPointerUp:e=>{let t=ur.current;if(ur.current=null,t)try{localStorage.setItem(`nudge.panel.split`,String(ZA(t,e.clientY)))}catch{}},onDoubleClick:()=>{lr(XA);try{localStorage.removeItem(`nudge.panel.split`)}catch{}},"data-tip":`Drag to resize · double-click to reset`}),za?(0,U.jsx)(eA,{onPick:Ha}):u.length?(0,U.jsx)(pc,{resetKey:u.join(`,`),fallback:e=>(0,U.jsx)(`div`,{className:`panel props`,children:(0,U.jsxs)(`p`,{className:`muted-note`,role:`alert`,children:[`This panel couldn’t be drawn. `,(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:e,children:`Try again`})]})}),children:(0,U.jsx)(nD,{doc:K,base:G??void 0,selection:u,boxes:R,scaleTool:z===`scale`,onExitScale:()=>Ut(`move`),onOpenBuild:Kn,onSelect:f,onNotice:L,textRange:B&&Qi&&Qi.end>Qi.start?{id:B,...Qi,style:ea}:void 0,onPreview:M,onCommit:(e,t,n)=>void q(e,t,n)})}):(0,U.jsx)(`div`,{className:`panel props sys-wrap`,children:(0,U.jsx)(PT,{doc:K,commit:(e,t)=>void q(e,t),onOpen:()=>qe(!0)})})]})})():Je===`libraries`?K&&(0,U.jsx)(`div`,{className:`side-design`,children:(0,U.jsx)(uE,{doc:K,commit:(e,t)=>void q(e,t),onOpenSystem:()=>qe(!0),onPlace:(e,t)=>void Qr(e,void 0,t),onPlaceComponent:(e,t)=>void $r(e,void 0,t),onNotice:L})}):Je===`code`?(0,U.jsx)(`div`,{className:`side-design`,children:(0,U.jsx)(pO,{doc:K,version:e.version,selection:u,sync:t,interactive:n,onNotice:L,onSelect:f})}):Oi?(0,U.jsxs)(`div`,{className:`agents-pinned-note`,children:[(0,U.jsx)(`p`,{children:`Agents is in a floating window.`}),(0,U.jsx)(`button`,{className:`chip`,onClick:()=>Ai.current?.close(),children:`Bring it back`})]}):(0,U.jsx)(GC.Provider,{value:Er,children:(0,U.jsx)(kw,{doc:K,chats:e.chats,openId:Ze,setOpenId:Qe,selection:u,onNotice:L,onFrame:Ii,onPopOut:()=>void ji(),frames:bi,onPickFrame:wi})})]})]})})]}),K&&gn&&(0,U.jsx)(qD,{frameTabReq:On,openUrlReq:Vn,full:Fn,onFull:In,previewFrame:u.length?ij(K,u[0]):null,frameName:e=>K.nodes[e]?.name,onClose:()=>{In(!1),En()},onNotice:L,onImported:e=>{Di(e.id),L(`Imported ${e.title} · ${e.stats.nodes} layers${e.linked?` · linked to your app`:``}${e.stats.truncated?` (page was cut off)`:``}${e.stats.failedAssets?` · ${e.stats.failedAssets} files couldn’t load`:``}`)}})]})}function $A(e,t,n){let r=e.nodes[t],i=r.style?e.styles.text[r.style.slice(1)]:void 0,a=r[n]??i?.[n];if(a!==void 0)return a;let o=r.fontSize??i?.fontSize??16;return n===`fontSize`?16:n===`fontWeight`?400:n===`lineHeight`?Math.round(o*1.2):0}function ej(e,t,n,r){return t.filter(t=>e.nodes[t]?.type===`text`).map(t=>{let i=Math.round(($A(e,t,n)+r)*10)/10,a={[n]:n===`letterSpacing`?i:Math.max(1,i)};if(n!==`fontSize`)return{op:`update`,id:t,set:Bn(e,t,a)};let o=e.nodes[t],s=o.style?e.styles.text[o.style.slice(1)]:void 0,c=e=>o[e]??s?.[e];return{op:`update`,id:t,set:Bn(e,t,dt(a,{fontSize:$A(e,t,`fontSize`),lineHeight:c(`lineHeight`),letterSpacing:c(`letterSpacing`)}))}})}function tj(e,t){let n=e.nodes[t];return n?.type===`shape`&&!n.locked}function nj(e){let t=e.trim();return/^(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*|<!DOCTYPE[^>]*>\s*)*<svg[\s>]/i.test(t)&&/<\/svg>$/i.test(t)?t:null}function rj(e){let t=e.match(/<svg[^>]*>/i)?.[0]??``,n=e=>{let n=t.match(RegExp(`\\s${e}\\s*=\\s*["']\\s*([\\d.]+)(px)?\\s*["']`,`i`));return n?Number(n[1]):void 0},r=t.match(/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)/i),i=n(`width`)??(r?Number(r[1]):void 0),a=n(`height`)??(r?Number(r[2]):void 0);return i&&a?{w:Math.round(i*100)/100,h:Math.round(a*100)/100}:{w:100,h:100}}function ij(e,t){let n=t;for(;n&&e.nodes[n]?.parent;)n=e.nodes[n].parent;return n}function aj({z:e,onSet:t}){let[n,r]=(0,H.useState)(`${Math.round(e*100)}%`);return(0,U.jsx)(`input`,{className:`ctx-field`,"aria-label":`Zoom level`,autoFocus:!0,value:n,onFocus:e=>e.currentTarget.select(),onChange:e=>r(e.target.value),onKeyDown:e=>{if(e.key!==`Enter`||e.nativeEvent.isComposing)return;let r=parseFloat(n.replace(/[^\d.]/g,``));r>0&&t(r/100)}})}function oj(e,t,n,r,i){let a={label:`Create component`,kbd:`⌥⌘K`,onClick:()=>n(`KeyK`,{meta:!0,alt:!0})};if(t.length!==1){if(!t.length)return[];let n=t.map(t=>e.nodes[t]);return[a,...n.every(t=>t?.type===`frame`&&!t.instanceOf&&!t.inInstance&&!t.componentSet&&!t.boolean&&!ce(e,t.id)&&t.parent===n[0].parent)?[{label:`Combine as variants`,icon:(0,U.jsx)(X.component,{}),onClick:()=>i([{op:`combine`,ids:t,key:`set`}],`Combine as variants`,[`set`])}]:[],{sep:!0}]}let o=e.nodes[t[0]];if(!o)return[];let s=o.inInstance??(o.type===`frame`&&o.instanceOf?o.id:null);if(!s)return o.type===`frame`&&(o.componentSet||ce(e,o.id))?[{label:`Add variant`,icon:(0,U.jsx)(X.plus,{}),onClick:()=>i([{op:`addVariant`,id:o.id,key:`variant`}],`Add variant`,[`variant`])},{sep:!0}]:o.type===`frame`&&o.main?[{label:`Add variant`,icon:(0,U.jsx)(X.plus,{}),onClick:()=>i([{op:`combine`,ids:[o.id],key:`set`},{op:`addVariant`,id:`set`,key:`variant`}],`Add variant`,[`variant`])},{sep:!0}]:[a,{sep:!0}];let c=e.nodes[s].instanceOf,l=!!e.nodes[s].overrides,u=b(c),d=!!e.removed?.[c];return[...u?[]:d?[{label:`Restore main component`,icon:(0,U.jsx)(X.component,{}),onClick:()=>i([{op:`restore`,id:s}],`Restore main component`)}]:[{label:`Go to main component`,icon:(0,U.jsx)(X.component,{}),onClick:()=>r([c])}],{label:`Reset all changes`,disabled:!l,onClick:()=>i([{op:`reset`,id:s}],`Reset all changes`)},...u||d?[]:[{label:`Push changes to main`,disabled:!l||o.id!==s,onClick:()=>i([{op:`push`,id:s}],`Push changes to main`)}],{label:`Detach instance`,kbd:`⌥⌘B`,onClick:()=>n(`KeyB`,{meta:!0,alt:!0})},...u?[{label:`Bring into this file`,onClick:()=>i([{op:`adopt`,id:s}],`Bring into this file`)}]:[],{sep:!0}]}function sj({id:e}){let t=new URLSearchParams(location.search),n=t.get(`w`)===`vw`,r=t.get(`fit`)===`1`,{doc:i}=BO(),[a,o]=(0,H.useState)(()=>document.documentElement.clientWidth);(0,H.useEffect)(()=>{n&&(document.documentElement.style.scrollbarWidth=`none`,o(document.documentElement.clientWidth))},[n]),(0,H.useEffect)(()=>{let e=()=>o(document.documentElement.clientWidth);return addEventListener(`resize`,e),()=>removeEventListener(`resize`,e)},[]);let s=(0,H.useMemo)(()=>{let t=i?.nodes[e];if(!i||!t)return null;let r=n&&t.type===`frame`?{sizeX:`fixed`,w:a}:{};return{...i,roots:[e],nodes:{...i.nodes,[e]:{...t,x:0,y:0,...r}}}},[i,e,n,a]),c=(0,H.useRef)(null),[l,u]=(0,H.useState)(null);if((0,H.useLayoutEffect)(()=>{let t=c.current?.querySelector(`[data-node-id="${CSS.escape(e)}"]`);if(!t)return;let n=()=>u(t.offsetHeight);n();let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[e,s]),!i)return null;if(!s)return(0,U.jsx)(`p`,{className:`preview-missing`,children:`This frame no longer exists.`});let d=s.nodes[e],f=r&&!n?Math.min(1,a/d.w):1,p=l??d.h;return(0,U.jsx)(`div`,{className:`preview-page ${n?`to-page`:``}`,children:(0,U.jsx)(`div`,{style:{position:`relative`,width:d.w*f,height:p*f,margin:`0 auto`},children:(0,U.jsx)(`div`,{ref:c,style:{position:`absolute`,left:0,top:0,width:d.w,height:p,transform:f<1?`scale(${f})`:void 0,transformOrigin:`top left`},children:(0,U.jsx)(He,{doc:s})})})})}function cj(){let{doc:e,version:t}=BO();if((0,H.useLayoutEffect)(()=>{if(!e)return;let n=window;n.__nudgeNames=Object.fromEntries(Object.values(e.nodes).map(e=>[e.id,e.name])),n.__nudgeVersion=t},[e,t]),!e)return null;let n=e.roots.map(t=>e.nodes[t]).filter(e=>!!e),r=Math.max(0,-Math.min(0,...n.map(e=>e.x))),i=Math.max(0,-Math.min(0,...n.map(e=>e.y)));return(0,U.jsx)(`div`,{style:{position:`absolute`,left:r,top:i},children:(0,U.jsx)(He,{doc:e})})}addEventListener(`vite:preloadError`,e=>{e.preventDefault(),location.reload()});var lj=new URLSearchParams(location.search),uj=lj.get(`mode`);uj&&(document.documentElement.dataset.mode=uj),uj!==`render`&&Ic(),uj!==`render`&&SO(),(0,ht.createRoot)(document.getElementById(`root`)).render(uj===`render`?(0,U.jsx)(cj,{}):uj===`frame`?(0,U.jsx)(sj,{id:lj.get(`id`)??``}):uj===`agents`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(HO,{}),(0,U.jsx)(TO,{})]}):(0,U.jsxs)(pc,{fallback:()=>(0,U.jsxs)(`p`,{className:`muted-note`,role:`alert`,children:[`Something went wrong drawing the canvas. `,(0,U.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>location.reload(),children:`Reload`})]}),children:[(0,U.jsx)(QA,{}),(0,U.jsx)(TO,{})]}));
|