foss-design 0.9.14 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +863 -281
- package/dist/runtime/index.js +223 -16
- package/dist/runtime/page.js +1 -0
- package/dist/viewer/assets/{index-xErZjcMe.js → index-BBL77yhi.js} +6 -4
- package/dist/viewer/assets/index-DscYGSGL.css +2 -0
- package/dist/viewer/index.html +2 -2
- package/dist/viewer-lib/index.js +94 -58
- package/dist/viewer-lib/styles.css +114 -7
- package/package.json +1 -1
- package/dist/viewer/assets/index-Dg5nDlgF.css +0 -2
|
@@ -122,12 +122,14 @@ ${e}</tr>
|
|
|
122
122
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
123
123
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${fD(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?fD(n,!0):this.parser.parseInline(r),o=mD(e);if(o===null)return a;e=fD(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+fD(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=mD(e);if(i===null)return fD(n);e=i;let a=`<img src="${fD(e)}" alt="${fD(n)}"`;return t&&(a+=` title="${fD(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:fD(e.text)}},DD=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},OD=class e{options;renderer;textRenderer;constructor(e){this.options=e||UT,this.options.renderer=this.options.renderer||new ED,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new DD}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},kD=class{options;block;constructor(e){this.options=e||UT}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?TD.lex:TD.lexInline}provideParser(e=this.block){return e?OD.parse:OD.parseInline}},AD=class{defaults=HT();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=OD;Renderer=ED;TextRenderer=DD;Lexer=TD;Tokenizer=wD;Hooks=kD;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ED(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new wD(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new kD;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=kD.passThroughHooks.has(n)?e=>{if(this.defaults.async&&kD.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return TD.lex(e,t??this.defaults)}parser(e,t){return OD.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?TD.lex:TD.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?OD.parse:OD.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?TD.lex:TD.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?OD.parse:OD.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
124
124
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+fD(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},jD=new AD;function MD(e,t){return jD.parse(e,t)}MD.options=MD.setOptions=function(e){return jD.setOptions(e),MD.defaults=jD.defaults,WT(MD.defaults),MD},MD.getDefaults=HT,MD.defaults=UT;function ND(...e){return jD.use(...e),MD.defaults=jD.defaults,WT(MD.defaults),MD}MD.use=ND,MD.walkTokens=function(e,t){return jD.walkTokens(e,t)},MD.parseInline=jD.parseInline,MD.Parser=OD,MD.parser=OD.parse,MD.Renderer=ED,MD.TextRenderer=DD,MD.Lexer=TD,MD.lexer=TD.lex,MD.Tokenizer=wD,MD.Hooks=kD,MD.parse=MD,MD.options,MD.setOptions,MD.walkTokens,MD.parseInline,OD.parse,TD.lex;var PD=new Set([`http:`,`https:`,`mailto:`]);function FD(e){try{return PD.has(new URL(e,`http://relative.invalid/`).protocol)}catch{return!1}}function ID(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var LD={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,colon:`:`,sol:`/`,period:`.`,num:`#`,quest:`?`,equals:`=`,percnt:`%`,tab:` `,newline:`
|
|
125
|
-
`,nbsp:`\xA0`};function RD(e){return e.replace(/&(?:#(\d{1,7})|#x([0-9a-f]{1,6})|([a-z]{2,8}));/gi,(e,t,n,r)=>{if(r)return LD[r.toLowerCase()]??e;let i=t?Number(t):Number.parseInt(n,16);return i>0&&i<=1114111&&(i<55296||i>57343)?String.fromCodePoint(i):`�`})}var zD=new AD({gfm:!0,breaks:!1},{renderer:{html:({text:e})=>ID(e),link(e){let t=this.parser.parseInline(e.tokens),n=RD(e.href);if(!FD(n))return t;let r=e.title?` title="${ID(RD(e.title))}"`:``;return`<a target="_blank" rel="noreferrer" href="${ID(n)}"${r}>${t}</a>`},image(e){let t=ID(RD(e.text)),n=RD(e.href);if(!FD(n))return t;let r=e.title?` title="${ID(RD(e.title))}"`:``;return`<img src="${ID(n)}" alt="${t}"${r}>`}}});function BD(e){return zD.parse(e,{async:!1})}function VD({text:e,className:t}){let n=(0,v.useMemo)(()=>BD(e),[e]);return(0,R.jsx)(`div`,{className:J(`prose`,t),dangerouslySetInnerHTML:{__html:n}})}var HD=1e5,UD=2e3,WD=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$=e=>typeof e==`string`,GD=e=>typeof e==`number`&&Number.isFinite(e),KD=e=>typeof e==`boolean`,qD=e=>t=>t===void 0||e(t),JD=e=>t=>Array.isArray(t)&&t.every(e),YD=e=>t=>WD(t)&&Object.entries(e).every(([e,n])=>n(t[e])),XD=e=>Array.isArray(e)&&e.length===2&&$(e[0])&&$(e[1]),ZD=e=>Array.isArray(e)&&e.length===4&&e.every(GD),QD=YD({ref:GD,label:$}),$D=YD({value:$,css:$,token:qD($)}),eO=YD({value:$,token:qD($)}),tO=YD({ref:GD,tag:$,label:$,text:qD($),classes:JD($),attributes:JD(XD),component:qD(YD({owners:JD($),file:qD($)})),rect:YD({x:GD,y:GD,w:GD,h:GD}),margin:ZD,border:ZD,padding:ZD,layout:JD(XD),typography:qD(YD({family:$,familyToken:qD($),size:$,sizeToken:qD($),weight:$,lineHeight:$,letterSpacing:$,color:$D,align:$,transform:qD($)})),appearance:YD({background:qD($D),backgroundImage:qD($),border:qD(YD({width:$,style:$,color:$D})),radius:qD(eO),shadow:qD(eO),opacity:qD($)}),path:JD(QD),children:JD(QD),css:$}),nO={ready:{},blur:{},updated:{},"inspect-escape":{},size:{width:GD,height:GD},error:{message:$},go:{target:$},link:{href:$,path:e=>e===null||$(e),form:KD,raw:qD($),pushed:qD(KD)},wheel:{deltaX:GD,deltaY:GD,x:GD,y:GD,zoom:KD},keydown:{code:$},pointer:{x:GD,y:GD,down:KD},key:{name:$,down:KD},inspect:{info:e=>e===null||tO(e)}},rO=e=>Math.min(HD,Math.max(0,e));function iO(e){if(!WD(e)||e.source!==`design-runtime`||!$(e.key)||!$(e.type))return null;let t=Object.hasOwn(nO,e.type)?nO[e.type]:null;if(!t||!YD(t)(e))return null;let n=e;return n.type===`size`?{...n,width:rO(n.width),height:rO(n.height)}:n.type===`error`?{...n,message:n.message.slice(0,UD)}:n}function aO(e,t){return e.includes(t)||e.length>=20?e:[...e,t]}var oO=new Map;window.addEventListener(`message`,e=>{let t=e.source?oO.get(e.source):void 0;if(!t)return;let n=iO(e.data);if(n)for(let e of t)e(n)});function sO(e,t){let n=null,r=()=>{if(!n)return;let e=oO.get(n);e?.delete(t),e?.size||oO.delete(n),n=null},i=()=>{if(r(),n=e.contentWindow,!n)return;let i=oO.get(n)??new Set;i.add(t),oO.set(n,i)};return i(),e.addEventListener(`load`,i),()=>{e.removeEventListener(`load`,i),r()}}function cO(e,t){e?.contentWindow?.postMessage({source:`design-viewer`,...t},`*`)}function lO(e){cO(e,{type:`canvas`})}function uO(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=getComputedStyle(n),r=e=>/(auto|scroll|overlay)/.test(e),i=r(e.overflowY)&&n.scrollHeight>n.clientHeight,a=r(e.overflowX)&&n.scrollWidth>n.clientWidth;if(i||a){n.scrollBy({left:a?t.deltaX:0,top:i?t.deltaY:0,behavior:`instant`});return}}window.scrollBy({left:t.deltaX,top:t.deltaY,behavior:`instant`})}function dO(e,t){cO(e,{type:`theme`,theme:t})}function fO(e){e&&(e.src=e.src)}var pO=(()=>{if(Fg)return``;let{protocol:e,hostname:t,port:n}=window.location,r=t===`localhost`?`127.0.0.1`:t===`127.0.0.1`?`localhost`:null;return r?`${e}//${r}${n?`:${n}`:``}`:``})();function mO(e,t,n){let[r=``,i=``]=e.split(`?`),a=new URLSearchParams(i);a.set(`theme`,t);for(let[e,t]of Object.entries(n??{}))a.set(e,t);return`${r.startsWith(`/`)?pO:``}${r}?${a.toString()}`}function hO(e){return new URL(e,document.baseURI).toString()}function gO(e,t,n,r,i){if(e.form){jT(`Forms are not sent from a screen`,void 0,`info`);return}if(e.path===null){if(!FD(e.href)||!/^(https?|mailto):/i.test(e.href.trim())){jT(`Link not opened`,e.href.slice(0,200),`info`);return}window.open(e.href,`_blank`,`noopener,noreferrer`)||jT(`Link to another site`,e.href,`info`);return}let a=Array.isArray(t)?t:t.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))),o=a.find(e=>e.id===r),s=e.raw===void 0?e.path:VT(e.raw,o?.routes?.[0]);if(s===null)return;let c=BT(a.map(e=>({routes:(e.routes??[]).map(LT),value:e.id})),s);if(c){c!==r&&n(c);return}let l=s.split(/[?#]/)[0].replace(/\/+$/,``),u=l.slice(l.lastIndexOf(`/`)+1).replace(/\.html?$/,``);try{u=decodeURIComponent(u)}catch{}if(u&&u!==r&&a.some(e=>e.id===u))n(u);else if(e.pushed)return;else i?i(s):jT(`No screen for this link`,s,`info`)}function _O(e,t,n){let r=r_().data,i=a_(!!r?.system).data?.tokens,[a,o]=(0,v.useState)(null),s=(0,v.useRef)({enabled:t,tokens:i,picked:null});s.current={enabled:t,tokens:i,picked:a?.frame??null};let c=(0,v.useRef)(n.onEscape);c.current=n.onEscape;let l=(0,v.useRef)(e);l.current=e;let u=(0,v.useRef)(new Map),d=(e,t=!1)=>{let{enabled:n,tokens:r}=s.current,i=u.current.get(e);(t||i?.on!==n||i.tokens!==r)&&(u.current.set(e,{on:n,tokens:r}),cO(e,{type:`inspect`,on:n,tokens:n?r??[]:void 0}))};(0,v.useEffect)(()=>{for(let t of e)d(t);for(let t of u.current.keys())e.includes(t)||u.current.delete(t)},[e,t,i]),(0,v.useEffect)(()=>{let t=e.map(e=>sO(e,t=>{if(t.type===`ready`)s.current.enabled?d(e,!0):u.current.set(e,{on:!1});else if(t.type===`inspect`){if(t.info&&(s.current.enabled||s.current.picked===e)){for(let t of l.current)t!==e&&cO(t,{type:`inspect-select`,ref:null});o({info:t.info,frame:e})}else o(t=>t?.frame===e?null:t)}else t.type===`inspect-escape`&&c.current()}));return()=>{for(let e of t)e()}},[e]);let f=a&&e.includes(a.frame)?a.frame:null;return{info:f?a.info:null,frame:f,select(e){if(e===null){for(let e of l.current)cO(e,{type:`inspect-select`,ref:null});o(null)}else a&&cO(a.frame,{type:`inspect-select`,ref:e})}}}function vO(e){let[t,n]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=e=>e===`Meta`||e===`Control`,r=!1,i=!1,a,o=()=>{r=!1,clearTimeout(a),n(!1)},s=e=>{if(t(e)){if(r)return;r=!0,i=!1,a=setTimeout(()=>{r&&!i&&n(!0)},150)}else r&&(i=!0,clearTimeout(a),n(!1))},c=e=>s(e.key),l=e=>{t(e.key)&&o()};window.addEventListener(`keydown`,c,!0),window.addEventListener(`keyup`,l,!0),window.addEventListener(`blur`,o);let u=e.map(e=>sO(e,e=>{e.type===`key`?e.down?s(e.name):t(e.name)&&o():e.type===`blur`&&o()}));return()=>{window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`keyup`,l,!0),window.removeEventListener(`blur`,o);for(let e of u)e();clearTimeout(a)}},[e]),t}function yO({title:e,children:t,right:n}){return(0,R.jsxs)(`section`,{className:`border-t border-rule pb-2 first:border-t-0`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center justify-between px-4 text-[12px] font-medium text-muted`,children:[e,n]}),t]})}function bO({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid min-h-7 grid-cols-[92px_minmax(0,1fr)] items-center gap-x-3 px-4 py-0.5 text-[12.5px]`,children:[(0,R.jsx)(`span`,{className:`text-muted`,children:e}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-ink`,children:t})]})}function xO({name:e}){return e?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void FT(`var(${e})`,`Token copied`),title:`Copy var()`,className:`shrink-0 cursor-pointer truncate rounded-[4px] border-0 bg-action-soft px-1.5 py-px font-mono text-[11px] text-action`,children:e}):null}function SO({children:e,title:t}){return(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:t,children:e})}function CO({label:e,color:t}){return(0,R.jsxs)(bO,{label:e,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:t.css}}),(0,R.jsx)(SO,{title:t.css,children:t.value}),(0,R.jsx)(xO,{name:t.token})]})}var wO=e=>e?String(e):`–`;function TO({label:e,values:t,className:n,children:r}){let[i,a,o,s]=t;return(0,R.jsxs)(`div`,{className:J(`relative grid grid-cols-[28px_minmax(0,1fr)_28px] grid-rows-[20px_auto_20px] rounded-[4px]`,n),children:[(0,R.jsx)(`span`,{className:`absolute top-1 left-1.5 text-[9.5px] tracking-wide text-muted uppercase`,children:e}),(0,R.jsx)(`span`,{className:`col-start-2 self-center text-center`,children:wO(i)}),(0,R.jsx)(`span`,{className:`row-start-2 self-center text-center`,children:wO(s)}),(0,R.jsx)(`div`,{className:`row-start-2 col-start-2`,children:r}),(0,R.jsx)(`span`,{className:`row-start-2 col-start-3 self-center text-center`,children:wO(a)}),(0,R.jsx)(`span`,{className:`row-start-3 col-start-2 self-center text-center`,children:wO(o)})]})}function EO({info:e}){let t={w:Math.max(0,e.rect.w-e.border[1]-e.border[3]-e.padding[1]-e.padding[3]),h:Math.max(0,e.rect.h-e.border[0]-e.border[2]-e.padding[0]-e.padding[2])};return(0,R.jsx)(`div`,{className:`px-4 pt-1 pb-2 font-mono text-[11px] text-ink2`,children:(0,R.jsx)(TO,{label:`margin`,values:e.margin,className:`border border-dashed border-rule-strong bg-[#f6b26b]/15`,children:(0,R.jsx)(TO,{label:`border`,values:e.border,className:`border border-rule-strong bg-[#f9e27d]/15`,children:(0,R.jsx)(TO,{label:`padding`,values:e.padding,className:`border border-rule-strong bg-[#93c47d]/20`,children:(0,R.jsxs)(`div`,{className:`flex h-8 items-center justify-center rounded-[3px] border border-rule-strong bg-[#6fa8dc]/25 text-ink`,children:[Math.round(t.w*100)/100,` × `,Math.round(t.h*100)/100]})})})})})}function DO({info:e,onSelect:t}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-4 pb-2`,children:[e.path.slice(-4).map((e,n)=>(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`cursor-pointer rounded-[4px] border-0 bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2 hover:text-ink`,children:e.label}),(0,R.jsx)(X,{name:`chevron-right`,size:11,className:`text-muted`})]},n)),(0,R.jsx)(`span`,{className:`rounded-[4px] bg-action-soft px-1.5 py-0.5 font-mono text-[11px] text-action`,children:e.label})]})}function OO({info:e,onSelect:t,onClose:n,active:r}){return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[320px] shrink-0 flex-col overflow-hidden border-l border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex h-[46px] shrink-0 items-center justify-between border-b border-rule pr-2 pl-4`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px] font-semibold`,children:[(0,R.jsx)(X,{name:`pointer`,size:15,className:`text-action`}),` Inspect`]}),(0,R.jsx)(N_,{icon:`x`,label:`Close inspector (I)`,onClick:n})]}),e?(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,R.jsxs)(yO,{title:`Element`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 pb-2`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:e.component?.owners[0]?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:[`<`,e.component.owners[0],`>`]}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[12px] text-muted`,children:e.tag})]}):(0,R.jsx)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:e.label})}),e.component&&e.component.owners.length>1?(0,R.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[`in `,e.component.owners.slice(1).join(` ← `)]}):null,e.component?.file?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void FT(e.component.file,`Path copied`),className:`w-fit max-w-full cursor-pointer truncate border-0 bg-transparent p-0 text-left font-mono text-[11.5px] text-muted hover:text-ink2`,title:`Copy path`,children:e.component.file}):null,e.text?(0,R.jsxs)(`span`,{className:`line-clamp-2 text-[12.5px] text-ink2`,children:[`“`,e.text,`”`]}):null]}),(0,R.jsx)(DO,{info:e,onSelect:t})]}),(0,R.jsxs)(yO,{title:`Box`,children:[(0,R.jsx)(EO,{info:e}),(0,R.jsx)(bO,{label:`Size`,children:(0,R.jsxs)(SO,{children:[e.rect.w,` × `,e.rect.h]})}),(0,R.jsx)(bO,{label:`Position`,children:(0,R.jsxs)(SO,{children:[`x `,e.rect.x,` · y `,e.rect.y]})})]}),e.layout.length?(0,R.jsx)(yO,{title:`Layout`,children:e.layout.map(([e,t])=>(0,R.jsx)(bO,{label:e,children:(0,R.jsx)(SO,{title:t,children:t})},e))}):null,e.typography?(0,R.jsxs)(yO,{title:`Typography`,children:[(0,R.jsxs)(bO,{label:`Font`,children:[(0,R.jsx)(SO,{title:e.typography.family,children:e.typography.family.split(`,`)[0]?.replace(/["']/g,``)}),(0,R.jsx)(xO,{name:e.typography.familyToken})]}),(0,R.jsxs)(bO,{label:`Size`,children:[(0,R.jsxs)(SO,{children:[e.typography.size,` / `,e.typography.lineHeight]}),(0,R.jsx)(xO,{name:e.typography.sizeToken})]}),(0,R.jsx)(bO,{label:`Weight`,children:(0,R.jsx)(SO,{children:e.typography.weight})}),e.typography.letterSpacing===`normal`?null:(0,R.jsx)(bO,{label:`Tracking`,children:(0,R.jsx)(SO,{children:e.typography.letterSpacing})}),(0,R.jsx)(CO,{label:`Color`,color:e.typography.color}),e.typography.align===`start`?null:(0,R.jsx)(bO,{label:`Align`,children:(0,R.jsx)(SO,{children:e.typography.align})}),e.typography.transform?(0,R.jsx)(bO,{label:`Transform`,children:(0,R.jsx)(SO,{children:e.typography.transform})}):null]}):null,Object.values(e.appearance).some(Boolean)?(0,R.jsxs)(yO,{title:`Appearance`,children:[e.appearance.background?(0,R.jsx)(CO,{label:`Background`,color:e.appearance.background}):null,e.appearance.backgroundImage?(0,R.jsx)(bO,{label:`Image`,children:(0,R.jsx)(SO,{title:e.appearance.backgroundImage,children:e.appearance.backgroundImage})}):null,e.appearance.border?(0,R.jsxs)(bO,{label:`Border`,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:e.appearance.border.color.css}}),(0,R.jsxs)(SO,{children:[e.appearance.border.width,` `,e.appearance.border.style,` `,e.appearance.border.color.value]}),(0,R.jsx)(xO,{name:e.appearance.border.color.token})]}):null,e.appearance.radius?(0,R.jsxs)(bO,{label:`Radius`,children:[(0,R.jsx)(SO,{children:e.appearance.radius.value}),(0,R.jsx)(xO,{name:e.appearance.radius.token})]}):null,e.appearance.shadow?(0,R.jsxs)(bO,{label:`Shadow`,children:[(0,R.jsx)(SO,{title:e.appearance.shadow.value,children:e.appearance.shadow.value}),(0,R.jsx)(xO,{name:e.appearance.shadow.token})]}):null,e.appearance.opacity?(0,R.jsx)(bO,{label:`Opacity`,children:(0,R.jsx)(SO,{children:e.appearance.opacity})}):null]}):null,e.classes.length?(0,R.jsx)(yO,{title:`Classes`,right:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void FT(e.classes.join(` `),`Classes copied`),className:`cursor-pointer border-0 bg-transparent text-[12px] text-muted hover:text-ink2`,children:`Copy`}),children:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 px-4 pb-1`,children:e.classes.map(e=>(0,R.jsx)(`span`,{className:`rounded-[4px] bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2`,children:e},e))})}):null,e.attributes.length?(0,R.jsx)(yO,{title:`Attributes`,children:e.attributes.map(([e,t])=>(0,R.jsx)(bO,{label:e,children:(0,R.jsx)(SO,{title:t,children:t})},e))}):null,e.children.length?(0,R.jsx)(yO,{title:`Children · ${e.children.length}`,children:(0,R.jsx)(`div`,{className:`flex flex-col px-2 pb-1`,children:e.children.map((e,n)=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`flex h-7 cursor-pointer items-center gap-2 rounded-[6px] border-0 bg-transparent px-2 text-left font-mono text-[12px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(X,{name:`chevron-right`,size:12,className:`text-muted`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},n))})}):null]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-10 text-center`,children:[(0,R.jsx)(X,{name:`pointer`,size:22,className:`text-muted`}),(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:r?`Click an element in any screen.`:`Hold ${av} to highlight, click to inspect.`}),(0,R.jsx)(`span`,{className:`text-[12.5px] leading-[1.5] text-muted`,children:`Hover shows margin, padding and content. Clicks go to the inspector, not the screen.`}),(0,R.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-[12px] text-muted`,children:[(0,R.jsx)(S_,{children:`I`}),` toggle · hold `,(0,R.jsx)(S_,{children:av}),` · `,(0,R.jsx)(S_,{children:`esc`}),` clear`]})]}),e?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-rule bg-soft px-4 py-2.5`,children:(0,R.jsx)(A_,{icon:`copy`,onClick:()=>void FT(e.css,`CSS copied`),className:`grow`,children:`Copy CSS`})}):null]})}function kO({issues:e,className:t}){return(0,R.jsx)(`div`,{className:J(`flex flex-col`,t),children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5 border-t border-rule px-4 py-2.5 text-[13px] first:border-t-0`,children:[(0,R.jsx)(X,{name:e.severity===`error`?`alert`:`info`,size:15,className:J(`mt-0.5`,e.severity===`error`?`text-danger-text`:`text-action`)}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-ink`,children:e.message}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] break-all text-muted`,children:[e.file,e.at?` · ${e.at}`:``]})]})]},t))})}function AO({issues:e,title:t=`Problems`}){if(!e.length)return null;let n=e.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(z_,{className:n?`border-danger/40`:void 0,children:[(0,R.jsx)(B_,{title:t,count:e.length,sub:n?`${n} blocking`:`warnings`}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(kO,{issues:e})})]})}var jO=[.2,.7,.2,1];function MO({open:e,side:t,width:n,children:r}){return(0,R.jsx)(ed,{initial:!1,children:e?(0,R.jsx)(Kf.div,{initial:{width:0,opacity:.6},animate:{width:n,opacity:1},exit:{width:0,opacity:.6},transition:{duration:.22,ease:jO},className:J(`flex min-h-0 shrink-0 overflow-hidden`,t===`right`?`justify-start`:`justify-end`),children:(0,R.jsx)(`div`,{className:`flex min-h-0 shrink-0`,style:{width:n},children:r})},`panel`):null})}var NO=8e3,PO=class{url;store=new d_({ready:!1,online:!1,canDraw:!1,drawings:{},ghosts:{}});socket=null;confirmed={};pending=new Map;nextId=1;delay=500;timer;sweep;closed=!1;constructor(e){this.url=e,this.connect(),this.sweep=setInterval(()=>this.dropStale(),2e3)}connect(){if(this.closed)return;let e;try{e=new WebSocket(this.url)}catch{this.retry();return}this.socket=e,e.onmessage=e=>{if(typeof e.data!=`string`)return;let t=OT(e.data);t&&this.receive(t)},e.onclose=()=>{this.socket===e&&(this.socket=null,this.store.set(e=>({...e,online:!1,ghosts:{}})),this.retry())}}retry(){this.closed||(clearTimeout(this.timer),this.timer=setTimeout(()=>this.connect(),this.delay),this.delay=Math.min(this.delay*2,1e4))}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}shown(e){let t=this.confirmed[e]??lT();for(let n of this.pending.values())n.key===e&&(t=_T(t,n.ops)??t);return t}show(e){this.store.set(t=>{let n={...t.drawings};for(let t of e)n[t]=this.shown(t);return{...t,drawings:n}})}receive(e){switch(e.type){case`hello`:{this.delay=500,this.confirmed=e.drawings;let t=new Set([...Object.keys(this.confirmed),...[...this.pending.values()].map(e=>e.key)]),n={};for(let e of t)n[e]=this.shown(e);if(this.store.set({ready:!0,online:!0,canDraw:e.canDraw,drawings:n,ghosts:{}}),e.canDraw)for(let[e,{key:t,ops:n}]of this.pending)this.send({type:`ops`,id:e,key:t,...n});else this.pending.clear();break}case`ops`:{let t=_T(this.confirmed[e.key]??lT(),e);t&&(this.confirmed={...this.confirmed,[e.key]:t});let n=new Set((e.add??[]).map(e=>e.id));this.store.set(r=>{let i=r.ghosts[e.key]?.filter(e=>!n.has(e.stroke.id));return{...r,drawings:t?{...r.drawings,[e.key]:this.shown(e.key)}:r.drawings,ghosts:i?{...r.ghosts,[e.key]:i}:r.ghosts}});break}case`ack`:{let t=this.pending.get(e.id);this.pending.delete(e.id),t&&this.show([t.key]);break}case`doc`:{let t=this.confirmed[e.key]??lT(),n=vT(e.drawing,t),r=n?_T(t,n):null;r&&(this.confirmed={...this.confirmed,[e.key]:r},this.show([e.key]));break}case`live`:this.store.set(t=>{let n=t.ghosts[e.key]??[],r=n.find(t=>t.stroke.id===e.stroke.id),{at:i,points:a,...o}=e.stroke,s={...o,points:i&&r?[...r.stroke.points.slice(0,i),...a]:a},c={peer:e.peer,name:e.name,stroke:s,seen:Date.now()},l=r?n.map(e=>e===r?c:e):[...n,c];return{...t,ghosts:{...t.ghosts,[e.key]:l}}});break;case`live-end`:this.dropGhosts((t,n)=>n===e.key&&t.stroke.id===e.id);break;case`gone`:this.dropGhosts(t=>t.peer===e.peer);break;case`error`:console.warn(`[design] drawings: ${e.message}`)}}dropGhosts(e){this.store.set(t=>{let n=!1,r={};for(let[i,a]of Object.entries(t.ghosts)){let t=a.filter(t=>!e(t,i));t.length!==a.length&&(n=!0),t.length&&(r[i]=t)}return n?{...t,ghosts:r}:t})}dropStale(){let e=Date.now();this.dropGhosts(t=>e-t.seen>NO)}apply(e,t){let n=this.store.get();if(!n.canDraw||!_T(n.drawings[e]??lT(),t))return;let r=this.nextId++;this.pending.set(r,{key:e,ops:t}),this.show([e]),this.send({type:`ops`,id:r,key:e,...t})}live(e,t,n){let{points:r,...i}=t;this.send({type:`live`,key:e,stroke:{...i,at:n,points:r.slice(n)}})}liveEnd(e,t){this.send({type:`live-end`,key:e,id:t})}close(){this.closed=!0,clearTimeout(this.timer),clearInterval(this.sweep);let e=this.socket;this.socket=null,e?.close()}};function FO(e,t=!0){let{source:n}=e_(),r=t?n.drawings?.(e)??null:null,[i,a]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!r)return;let e=new PO(r);return a(e),()=>{e.close(),a(null)}},[r]),i}var IO=[];function LO(e,t){return{drawing:Y(e.store,e=>e.drawings[t]),ghosts:Y(e.store,e=>e.ghosts[t]??IO)}}var RO=new d_({ready:!1,online:!1,canDraw:!1,drawings:{},ghosts:{}});function zO({title:e=`Nothing here`,text:t}){let n=!!e_().scope;return(0,R.jsx)(tv,{title:e,text:t??`This address does not match a canvas or a page of the design system.`,action:n?void 0:(0,R.jsx)(P_,{to:`/`,children:`All canvases`})})}var BO=.1,VO=(e,t=BO)=>Math.min(8,Math.max(t,e)),HO=class{camera={x:0,y:0,z:1};minZoom=BO;listeners=new Set;animation=0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}set(e){this.camera={x:e.x,y:e.y,z:VO(e.z,this.minZoom)};for(let e of this.listeners)e(this.camera)}interrupt(){cancelAnimationFrame(this.animation),this.animation=0}panBy(e,t){this.interrupt();let{x:n,y:r,z:i}=this.camera;this.set({x:n+e,y:r+t,z:i})}zoomAt(e,t,n){this.interrupt();let{x:r,y:i,z:a}=this.camera,o=VO(a*n,this.minZoom),s=(e-r)/a,c=(t-i)/a;this.set({x:e-s*o,y:t-c*o,z:o})}animateTo(e,t=320){this.interrupt();let n={...this.camera},r={...e,z:VO(e.z,this.minZoom)};if(t<=0||matchMedia(`(prefers-reduced-motion: reduce)`).matches){this.set(r);return}let i=performance.now(),a=e=>{let o=Math.min(1,(e-i)/t),s=1-(1-o)**3,c=n.z*(r.z/n.z)**s,l=n.z===r.z?s:(c-n.z)/(r.z-n.z);this.set({x:n.x+(r.x-n.x)*l,y:n.y+(r.y-n.y)*l,z:c}),this.animation=o<1?requestAnimationFrame(a):0};this.animation=requestAnimationFrame(a)}toWorld(e,t){let{x:n,y:r,z:i}=this.camera;return{x:(e-n)/i,y:(t-r)/i}}};function UO(e){try{let t=JSON.parse(sessionStorage.getItem(e)??`null`);if(t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.z))return t}catch{}return null}function WO(e,t,n,r=72,i=1,a=BO){let o=VO(Math.min((t-r*2)/Math.max(e.w,1),(n-r*2)/Math.max(e.h,1),i),a),s=(e,t,n)=>t*o<=n-r*2?n/2-(e+t/2)*o:r-e*o;return{z:o,x:s(e.x,e.w,t),y:s(e.y,e.h,n)}}var GO=14,KO=96;function qO(e){let t=0;return n=>{let r=24*n.z;for(;r<GO;)r*=4;for(;r>KO;)r/=4;r!==t&&(t=r,e.style.backgroundSize=`${r}px ${r}px`);let i=e=>((e+KO)%r+r)%r-r;e.style.transform=`translate3d(${i(n.x)}px, ${i(n.y)}px, 0)`}}function JO(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function YO(){return new d_({selected:null,active:null,hovered:null,sizes:{},frames:{},live:[],panning:!1,zoomTiny:!1,frameEls:{},inspecting:!1,markup:null})}function XO(e,t,n){e.set(e=>{let r=e.sizes[t];return r&&Math.abs(r.h-n.h)<1&&r.w===n.w?e:{...e,sizes:{...e.sizes,[t]:n}}})}function ZO(e,t,n){e.set(e=>{let r=e.frames[t]??{ready:!1,errors:[]};return{...e,frames:{...e.frames,[t]:{...r,...n}}}})}function QO(e,t,n){e.set(e=>e.frameEls[t]===n?e:{...e,frameEls:{...e.frameEls,[t]:n}})}function $O(e,t,n=!0){let r=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let i=r.current;if(!i||!n)return;let a=new ResizeObserver(()=>XO(e,t,{h:i.offsetHeight}));return a.observe(i),()=>a.disconnect()},[e,t,n]),r}function ek(e){return e<600?`smartphone`:e<1100?`tablet`:`monitor`}var tk=(0,v.memo)(function({placed:e,mode:t,thumb:n,theme:r,store:i,events:a,capture:o}){let{item:s,x:c,y:l,w:u,h:d}=e,f=(0,v.useRef)(null),{frameSandbox:p,frameAllow:m}=e_(),h=(0,v.useCallback)(e=>{f.current=e,QO(i,s.id,e)},[i,s.id]),g=Y(i,e=>e.frames[s.id]),_=Y(i,e=>e.active===s.id),y=Y(i,e=>e.inspecting&&s.kind===`screen`),b=s.frame.height===`auto`,x=s.kind===`screen`?s.theme??r:r,S=s.kind===`screen`?s.rev:s.url,[C]=(0,v.useState)(x),w=s.kind===`screen`?mO(s.url,C,o?{capture:`1`}:void 0):s.url,T=!!g?.ready,E=t===`off`,D=!E&&!(s.kind===`screen`&&s.missing)&&!!s.url;(0,v.useEffect)(()=>{E&&ZO(i,s.id,{ready:!1})},[E,i,s.id]),(0,v.useEffect)(()=>{let e=f.current;if(e&&!E&&s.kind===`screen`)return sO(e,t=>{switch(t.type){case`ready`:ZO(i,s.id,{ready:!0}),lO(e);break;case`size`:b&&XO(i,s.id,{h:Math.max(200,t.height)});break;case`error`:{let e=i.get().frames[s.id]?.errors??[],n=aO(e,t.message);n!==e&&ZO(i,s.id,{errors:n});break}case`updated`:ZO(i,s.id,{errors:[]});break;case`go`:a.onGo(s.id,t.target);break;case`link`:a.onLink(s.id,t);break;case`wheel`:a.onWheel(e,t);break;case`keydown`:t.code===`Escape`&&a.onEscape()}})},[E,s.id,s.kind,b,i,a,w,S]),(0,v.useEffect)(()=>{s.kind===`screen`&&dO(f.current,x)},[x,s.kind]);let O=x===`dark`?`light`:`dark`,k=e=>e?.[x]??e?.[O],A=s.kind===`screen`?k(s.snapshots):void 0,j=n&&s.kind===`screen`?k(s.thumbs)??A:A,M=t===`asleep`&&T&&!!j;return(0,R.jsxs)(`div`,{"data-item":s.id,className:`absolute overflow-clip bg-surface`,style:{left:c,top:l,width:u,height:d,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:[(!T||M)&&j?(0,R.jsx)(`img`,{src:j,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,className:`absolute inset-0 h-full w-full object-cover object-top select-none`}):null,!T&&!j?(0,R.jsx)(nk,{item:s,loading:D}):null,D?(0,R.jsx)(`div`,{className:`absolute inset-0`,style:{contentVisibility:M?`hidden`:`visible`},children:(0,R.jsx)(`iframe`,{ref:h,src:w,title:s.title,allow:m,sandbox:p,className:J(`absolute top-0 left-0 block border-0 transition-opacity duration-200`,T?`opacity-100`:`opacity-0`),style:{width:u,height:d,colorScheme:x},onLoad:()=>{s.kind===`url`?ZO(i,s.id,{ready:!0}):(dO(f.current,x),lO(f.current))}},S)}):null,_||y?null:(0,R.jsx)(`div`,{"data-shield":s.id,className:`absolute inset-0`})]})});function nk({item:e,loading:t}){let n=e.kind===`screen`&&e.missing;return(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-soft text-muted`,children:[(0,R.jsx)(X,{name:n?`alert`:e.kind===`url`?`globe`:ek(e.frame.width),size:Math.max(24,Math.min(96,e.frame.width/12)),strokeWidth:1.25,className:n?`text-danger-text`:void 0}),(0,R.jsx)(`div`,{className:`max-w-[80%] truncate text-center`,style:{fontSize:Math.max(14,e.frame.width/40)},children:n?`Missing file: ${e.kind===`screen`?e.src:``}`:t?`Loading…`:e.title})]})}var rk=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a}=e,o=$O(t,n.id),s=n.tone===`plain`;return(0,R.jsxs)(`div`,{ref:o,"data-item":n.id,className:J(`absolute`,s?``:`rounded-[10px] border border-note-line bg-note px-6 py-5 shadow-frame`),style:{left:r,top:i,width:a},children:[n.title?(0,R.jsx)(`div`,{className:`mb-2 font-semibold text-ink`,style:{fontSize:s?26:19},children:n.title}):null,(0,R.jsx)(VD,{text:n.text,className:s?`prose-plain`:`prose-note`})]})}),ik=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a,h:o}=e;return(0,R.jsx)(`div`,{"data-item":n.id,className:`absolute overflow-clip rounded-[6px] bg-surface`,style:{left:r,top:i,width:a,height:o,boxShadow:`0 0 0 1px var(--rule)`},children:n.missing?(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:20}),` Missing image`]}):(0,R.jsx)(`img`,{src:n.url,alt:n.title,draggable:!1,className:`block h-full w-full object-contain select-none`,onLoad:e=>{let r=e.currentTarget;XO(t,n.id,{w:r.naturalWidth,h:r.naturalHeight})}})})}),ak=(0,v.memo)(function({section:e,x:t,y:n,w:r,store:i}){let a=$O(i,`section:${e.id}`);return!e.title&&!e.description?null:(0,R.jsxs)(`div`,{ref:a,className:`canvas-section absolute`,style:{left:t,top:n,width:Math.min(Math.max(r,720),1400)},children:[e.title?(0,R.jsx)(`div`,{className:`text-[40px] leading-[1.15] font-semibold tracking-[-0.015em] text-ink`,children:e.title}):null,e.description?(0,R.jsx)(`div`,{className:`mt-3 max-w-[1100px]`,children:(0,R.jsx)(VD,{text:e.description,className:`prose-plain`})}):null]})}),ok=280,sk=96,ck=150,lk=110,uk=720,dk=e=>e.kind===`screen`||e.kind===`url`;function fk(e,t){let n=t[e.id];if(e.kind===`screen`||e.kind===`url`){let t=e.frame.width;if(e.frame.height!==`auto`)return{w:t,h:e.frame.height};let r=e.kind===`screen`?e.measuredHeight:void 0;return{w:t,h:n?.h??r??900}}if(e.kind===`note`)return{w:e.width,h:n?.h??Math.max(80,Math.ceil(e.text.length/38)*26+40)};let r=e.width??n?.w??480;return{w:r,h:n?.w?n.h/n.w*r:n?.h??r*.62}}function pk(e,t){return!e.title&&!e.description?0:t[`section:${e.id}`]?.h??(e.title?56:0)+(e.description?60:0)}function mk(e,t){let n=[],r=[];if(e.layout===`free`){let r=0;for(let i of e.sections)for(let e of i.items){let{w:a,h:o}=fk(e,t),s=e.x??r,c=e.y??0;r=Math.max(r,s+a+sk),n.push({item:e,section:i,x:s,y:c,w:a,h:o})}}else{let i=0;for(let a of e.sections){let e=pk(a,t),o=i,s=i+(e?e+lk:0),c=0,l=0,u=0,d=0;for(let e of a.items){a.columns&&d===a.columns&&(s+=l+ck,c=0,l=0,d=0);let{w:r,h:i}=fk(e,t);n.push({item:e,section:a,x:c,y:s,w:r,h:i}),c+=r+sk,u=Math.max(u,c-sk),l=Math.max(l,i),d++}let f=s+l;r.push({section:a,x:0,y:o,w:Math.max(u,e?uk:0),h:f-o,header:e,body:e?e+lk:0}),i=f+ok}}let i=0,a=0,o=0,s=0,c=[...n,...r];return c.length&&(i=Math.min(...c.map(e=>e.x)),a=Math.min(...c.map(e=>e.y)),o=Math.max(...c.map(e=>e.x+e.w)),s=Math.max(...c.map(e=>e.y+e.h))),{items:n,sections:r,bounds:{x:i,y:a,w:o-i,h:s-a}}}function hk(e){return e.items.filter(e=>dk(e.item))}var gk={phone:{width:390,height:844,label:`Phone`},"phone-sm":{width:375,height:667,label:`Phone S`},"phone-lg":{width:430,height:932,label:`Phone L`},tablet:{width:834,height:1194,label:`Tablet`},"tablet-landscape":{width:1194,height:834,label:`Tablet landscape`},laptop:{width:1280,height:800,label:`Laptop`},desktop:{width:1440,height:900,label:`Desktop`},wide:{width:1920,height:1080,label:`Wide`}};Object.keys(gk);var _k=e=>({"--x":e.x,"--y":e.y,"--w":e.w,"--h":e.h});function vk(e){let t=e.item;if(t.kind!==`screen`&&t.kind!==`url`)return``;let n=t.frame.device?gk[t.frame.device]?.label:void 0,r=`${t.frame.width} × ${t.frame.height===`auto`?`auto`:t.frame.height}`;return n?`${n} · ${r}`:r}var yk=(0,v.memo)(function({placed:e,store:t}){let n=e.item.id,r=Y(t,e=>e.selected===n),i=Y(t,e=>e.frames[n]?.errors.length??0);return(0,R.jsxs)(`div`,{"data-at":``,"data-label":n,style:_k(e),className:J(`frame-label pointer-events-auto flex cursor-default items-center gap-1.5 overflow-hidden pb-1.5 text-[12.5px] leading-none whitespace-nowrap select-none`,r?`text-ink`:`text-muted hover:text-ink2`),children:[i?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`,title:`${i} errors`}):null,(0,R.jsx)(`span`,{className:J(`min-w-[3ch] truncate`,r?`font-semibold`:`font-medium`),children:e.item.title}),(0,R.jsx)(`span`,{className:`frame-device min-w-0 shrink-[20] truncate text-[11.5px] text-muted opacity-80`,children:vk(e)})]})}),bk=(0,v.memo)(function({placed:e}){return(0,R.jsx)(`div`,{"data-at":``,style:{"--x":e.x,"--y":e.y,"--body":e.body},className:`section-title text-[15px] leading-none font-semibold whitespace-nowrap text-ink select-none`,children:e.section.title})});function xk({placed:e,kind:t}){return(0,R.jsx)(`div`,{"data-at":``,style:_k(e),className:J(`frame-outline rounded-[1px]`,t===`hover`?`outline outline-[1.5px] outline-action/60`:`outline-2 outline-action outline`)})}function Sk({layout:e,view:t,store:n,overlayRef:r}){let i=Y(n,e=>e.selected),a=Y(n,e=>e.active),o=Y(n,e=>e.hovered),s=Y(n,e=>e.zoomTiny),c=(0,v.useMemo)(()=>e.items.filter(e=>dk(e.item)),[e]),l=(0,v.useMemo)(()=>{if(!t||s)return[];let{x:e,y:n,z:r,w:i,h:a}=t,o={x:-e/r-i/r,y:-n/r-a/r,w:i/r*3,h:a/r*3};return c.filter(e=>JO(e,o))},[c,t,s]),u=(0,v.useMemo)(()=>e.sections.filter(e=>e.section.title),[e]),d=t=>t?e.items.find(e=>e.item.id===t):void 0,f=d(i),p=o&&o!==i?d(o):void 0;return(0,R.jsxs)(`div`,{ref:r,className:`canvas-overlay`,"data-tiny":s,children:[u.map(e=>(0,R.jsx)(bk,{placed:e},e.section.id)),l.map(e=>(0,R.jsx)(yk,{placed:e,store:n},e.item.id)),p?(0,R.jsx)(xk,{placed:p,kind:`hover`}):null,f?(0,R.jsx)(xk,{placed:f,kind:a===i?`active`:`selected`}):null]})}var Ck=12,wk=.4,Tk=20,Ek=110,Dk=.2,Ok=400,kk=.2,Ak=3,jk=8e3;function Mk({layout:e,theme:t,store:n,camera:r,events:i,capture:a,apiRef:o,onPlay:s,onSelect:c,over:l}){let u=(0,v.useRef)(null),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),[m,h]=(0,v.useState)(null),g=Y(n,e=>e.panning),_=Y(n,e=>e.selected),y=Y(n,e=>e.active),b=(0,v.useMemo)(()=>e.items.filter(e=>dk(e.item)),[e]);(0,v.useLayoutEffect)(()=>{let e=u.current,t=d.current,i=f.current,a,o,s=!1,c=qO(i),l=()=>h({...r.camera,w:e.clientWidth,h:e.clientHeight,moving:s}),m=e=>{t.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.z})`,s||(s=!0,t.classList.add(`moving`)),clearTimeout(a),a=setTimeout(()=>{s=!1,t.classList.remove(`moving`),l()},160);let r=p.current;r&&(r.style.setProperty(`--tx`,String(e.x)),r.style.setProperty(`--ty`,String(e.y)),r.style.setProperty(`--z`,String(e.z))),c(e);let i=e.z<.09;n.get().zoomTiny!==i&&n.set(e=>({...e,zoomTiny:i})),t.classList.toggle(`far`,e.z<.15);let u=e.z<wk;t.classList.toggle(`small-titles`,u),r&&(r.dataset.titles=u?`on`:`off`),o??=setTimeout(()=>{o=void 0,l()},90)};m(r.camera),l();let g=r.subscribe(m),_=e.getBoundingClientRect().left,v=new ResizeObserver(()=>{let t=e.getBoundingClientRect().left;if(t!==_){let e=r.camera;r.set({...e,x:e.x-(t-_)}),_=t}l()});return v.observe(e),()=>{g(),v.disconnect(),clearTimeout(a),clearTimeout(o)}},[r,n]),(0,v.useEffect)(()=>{let t=u.current,n=()=>{let{w:n,h:i}={w:t.clientWidth,h:t.clientHeight},o=e.bounds,s=o.w&&n?Math.min((n-160)/o.w,(i-160)/Math.max(o.h,1)):1;r.minZoom=a?.01:Math.min(.25,Math.max(BO,s*.5))};n();let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[r,e.bounds,a]),(0,v.useEffect)(()=>{let t=u.current,n=()=>({w:t.clientWidth,h:t.clientHeight});o.current={size:n,openView(){let{w:t,h:i}=n(),a=e.bounds;if(!a.w)return;if(Math.min((t-160)/a.w,(i-160)/Math.max(a.h,1))>=kk)return this.fitAll(!1);let o=e.sections[0]??a,s=Math.min(.5,Math.max(.25,(t-160)/Math.max(o.w,1)));r.set({z:s,x:80-a.x*s,y:80-a.y*s})},fitAll(t=!0){let{w:i,h:a}=n();if(!e.bounds.w)return;let o=WO(e.bounds,i,a,80,1,r.minZoom);t?r.animateTo(o):r.set(o)},fitItem(t,i=!0){let a=e.items.find(e=>e.item.id===t);if(!a)return;let{w:o,h:s}=n(),c=WO(a,o,s,64,1,r.minZoom);i?r.animateTo(c):r.set(c)},zoomBy(e){let{w:t,h:i}=n(),a=r.camera,o=a.z*e,s=(t/2-a.x)/a.z,c=(i/2-a.y)/a.z;r.animateTo({z:o,x:t/2-s*o,y:i/2-c*o},180)},zoomTo(e){let{w:t,h:i}=n(),a=r.camera,o=(t/2-a.x)/a.z,s=(i/2-a.y)/a.z;r.animateTo({z:e,x:t/2-o*e,y:i/2-s*e},220)}}},[o,r,e]);let x=(0,v.useRef)([]),S=(0,v.useRef)(new Map),[C,w]=(0,v.useState)(0),T=Y(n,e=>Nk(e.frames)),E=(0,v.useMemo)(()=>{let e=new Map;if(a){for(let t of b)e.set(t.item.id,`live`);return e}if(!m)return e;let{x:t,y:n,z:r,w:i,h:o}=m,s={x:-t/r,y:-n/r,w:i/r,h:o/r},c={x:s.x-s.w*.25,y:s.y-s.h*.25,w:s.w*1.5,h:s.h*1.5},l=s.x+s.w/2,u=s.y+s.h/2,d=e=>Math.max(0,Math.min(e.x+e.w,s.x+s.w)-Math.max(e.x,s.x))*Math.max(0,Math.min(e.y+e.h,s.y+s.h)-Math.max(e.y,s.y)),f=e=>Math.hypot(e.x+e.w/2-l,e.y+e.h/2-u),p=b.filter(e=>r>=Dk&&JO(e,c)&&e.w*r>=Ek).sort((e,t)=>d(t)-d(e)||f(e)-f(t)).slice(0,Ck).map(e=>e.item.id),h=[y,_].filter(e=>!!e),g=new Set(b.map(e=>e.item.id)),v=new Set(T.split(`
|
|
125
|
+
`,nbsp:`\xA0`};function RD(e){return e.replace(/&(?:#(\d{1,7})|#x([0-9a-f]{1,6})|([a-z]{2,8}));/gi,(e,t,n,r)=>{if(r)return LD[r.toLowerCase()]??e;let i=t?Number(t):Number.parseInt(n,16);return i>0&&i<=1114111&&(i<55296||i>57343)?String.fromCodePoint(i):`�`})}var zD=new AD({gfm:!0,breaks:!1},{renderer:{html:({text:e})=>ID(e),link(e){let t=this.parser.parseInline(e.tokens),n=RD(e.href);if(!FD(n))return t;let r=e.title?` title="${ID(RD(e.title))}"`:``;return`<a target="_blank" rel="noreferrer" href="${ID(n)}"${r}>${t}</a>`},image(e){let t=ID(RD(e.text)),n=RD(e.href);if(!FD(n))return t;let r=e.title?` title="${ID(RD(e.title))}"`:``;return`<img src="${ID(n)}" alt="${t}"${r}>`}}});function BD(e){return zD.parse(e,{async:!1})}function VD({text:e,className:t}){let n=(0,v.useMemo)(()=>BD(e),[e]);return(0,R.jsx)(`div`,{className:J(`prose`,t),dangerouslySetInnerHTML:{__html:n}})}var HD=1e5,UD=2e3,WD=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$=e=>typeof e==`string`,GD=e=>typeof e==`number`&&Number.isFinite(e),KD=e=>typeof e==`boolean`,qD=e=>t=>t===void 0||e(t),JD=e=>t=>Array.isArray(t)&&t.every(e),YD=e=>t=>WD(t)&&Object.entries(e).every(([e,n])=>n(t[e])),XD=e=>Array.isArray(e)&&e.length===2&&$(e[0])&&$(e[1]),ZD=e=>Array.isArray(e)&&e.length===4&&e.every(GD),QD=YD({ref:GD,label:$}),$D=YD({value:$,css:$,token:qD($)}),eO=YD({value:$,token:qD($)}),tO=YD({ref:GD,tag:$,label:$,text:qD($),classes:JD($),attributes:JD(XD),component:qD(YD({owners:JD($),file:qD($)})),rect:YD({x:GD,y:GD,w:GD,h:GD}),margin:ZD,border:ZD,padding:ZD,layout:JD(XD),typography:qD(YD({family:$,familyToken:qD($),size:$,sizeToken:qD($),weight:$,lineHeight:$,letterSpacing:$,color:$D,align:$,transform:qD($)})),appearance:YD({background:qD($D),backgroundImage:qD($),border:qD(YD({width:$,style:$,color:$D})),radius:qD(eO),shadow:qD(eO),opacity:qD($)}),path:JD(QD),children:JD(QD),css:$}),nO={ready:{},blur:{},updated:{},"inspect-escape":{},size:{width:GD,height:GD},error:{message:$},go:{target:$},link:{href:$,path:e=>e===null||$(e),form:KD,raw:qD($),pushed:qD(KD)},wheel:{deltaX:GD,deltaY:GD,x:GD,y:GD,zoom:KD},keydown:{code:$},pointer:{x:GD,y:GD,down:KD},key:{name:$,down:KD},inspect:{info:e=>e===null||tO(e)}},rO=e=>Math.min(HD,Math.max(0,e));function iO(e){if(!WD(e)||e.source!==`design-runtime`||!$(e.key)||!$(e.type))return null;let t=Object.hasOwn(nO,e.type)?nO[e.type]:null;if(!t||!YD(t)(e))return null;let n=e;return n.type===`size`?{...n,width:rO(n.width),height:rO(n.height)}:n.type===`error`?{...n,message:n.message.slice(0,UD)}:n}function aO(e,t){return e.includes(t)||e.length>=20?e:[...e,t]}var oO=new Map;window.addEventListener(`message`,e=>{let t=e.source?oO.get(e.source):void 0;if(!t)return;let n=iO(e.data);if(n)for(let e of t)e(n)});function sO(e,t){let n=null,r=()=>{if(!n)return;let e=oO.get(n);e?.delete(t),e?.size||oO.delete(n),n=null},i=()=>{if(r(),n=e.contentWindow,!n)return;let i=oO.get(n)??new Set;i.add(t),oO.set(n,i)};return i(),e.addEventListener(`load`,i),()=>{e.removeEventListener(`load`,i),r()}}function cO(e,t){e?.contentWindow?.postMessage({source:`design-viewer`,...t},`*`)}function lO(e){cO(e,{type:`canvas`})}function uO(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=getComputedStyle(n),r=e=>/(auto|scroll|overlay)/.test(e),i=r(e.overflowY)&&n.scrollHeight>n.clientHeight,a=r(e.overflowX)&&n.scrollWidth>n.clientWidth;if(i||a){n.scrollBy({left:a?t.deltaX:0,top:i?t.deltaY:0,behavior:`instant`});return}}window.scrollBy({left:t.deltaX,top:t.deltaY,behavior:`instant`})}function dO(e,t){cO(e,{type:`theme`,theme:t})}function fO(e){e&&(e.src=e.src)}var pO=(()=>{if(Fg)return``;let{protocol:e,hostname:t,port:n}=window.location,r=t===`localhost`?`127.0.0.1`:t===`127.0.0.1`?`localhost`:null;return r?`${e}//${r}${n?`:${n}`:``}`:``})();function mO(e,t,n){let[r=``,i=``]=e.split(`?`),a=new URLSearchParams(i);a.set(`theme`,t);for(let[e,t]of Object.entries(n??{}))a.set(e,t);return`${r.startsWith(`/`)?pO:``}${r}?${a.toString()}`}function hO(e){return new URL(e,document.baseURI).toString()}function gO(e,t,n,r,i){if(e.form){jT(`Forms are not sent from here`,void 0,`info`);return}if(e.path===null){if(!FD(e.href)||!/^(https?|mailto):/i.test(e.href.trim())){jT(`Link not opened`,e.href.slice(0,200),`info`);return}window.open(e.href,`_blank`,`noopener,noreferrer`)||jT(`Link to another site`,e.href,`info`);return}let a=Array.isArray(t)?t:t.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))),o=a.find(e=>e.id===r),s=e.raw===void 0?e.path:VT(e.raw,o?.routes?.[0]);if(s===null)return;let c=BT(a.map(e=>({routes:(e.routes??[]).map(LT),value:e.id})),s);if(c){c!==r&&n(c);return}let l=s.split(/[?#]/)[0].replace(/\/+$/,``),u=l.slice(l.lastIndexOf(`/`)+1).replace(/\.html?$/,``);try{u=decodeURIComponent(u)}catch{}if(u&&u!==r&&a.some(e=>e.id===u))n(u);else if(e.pushed)return;else i?i(s):jT(`No screen for this link`,s,`info`)}function _O(e,t,n){let r=r_().data,i=a_(!!r?.system).data?.tokens,[a,o]=(0,v.useState)(null),s=(0,v.useRef)({enabled:t,tokens:i,picked:null});s.current={enabled:t,tokens:i,picked:a?.frame??null};let c=(0,v.useRef)(n.onEscape);c.current=n.onEscape;let l=(0,v.useRef)(e);l.current=e;let u=(0,v.useRef)(new Map),d=(e,t=!1)=>{let{enabled:n,tokens:r}=s.current,i=u.current.get(e);(t||i?.on!==n||i.tokens!==r)&&(u.current.set(e,{on:n,tokens:r}),cO(e,{type:`inspect`,on:n,tokens:n?r??[]:void 0}))};(0,v.useEffect)(()=>{for(let t of e)d(t);for(let t of u.current.keys())e.includes(t)||u.current.delete(t)},[e,t,i]),(0,v.useEffect)(()=>{let t=e.map(e=>sO(e,t=>{if(t.type===`ready`)s.current.enabled?d(e,!0):u.current.set(e,{on:!1});else if(t.type===`inspect`){if(t.info&&(s.current.enabled||s.current.picked===e)){for(let t of l.current)t!==e&&cO(t,{type:`inspect-select`,ref:null});o({info:t.info,frame:e})}else o(t=>t?.frame===e?null:t)}else t.type===`inspect-escape`&&c.current()}));return()=>{for(let e of t)e()}},[e]);let f=a&&e.includes(a.frame)?a.frame:null;return{info:f?a.info:null,frame:f,select(e){if(e===null){for(let e of l.current)cO(e,{type:`inspect-select`,ref:null});o(null)}else a&&cO(a.frame,{type:`inspect-select`,ref:e})}}}function vO(e){let[t,n]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=e=>e===`Meta`||e===`Control`,r=!1,i=!1,a,o=()=>{r=!1,clearTimeout(a),n(!1)},s=e=>{if(t(e)){if(r)return;r=!0,i=!1,a=setTimeout(()=>{r&&!i&&n(!0)},150)}else r&&(i=!0,clearTimeout(a),n(!1))},c=e=>s(e.key),l=e=>{t(e.key)&&o()};window.addEventListener(`keydown`,c,!0),window.addEventListener(`keyup`,l,!0),window.addEventListener(`blur`,o);let u=e.map(e=>sO(e,e=>{e.type===`key`?e.down?s(e.name):t(e.name)&&o():e.type===`blur`&&o()}));return()=>{window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`keyup`,l,!0),window.removeEventListener(`blur`,o);for(let e of u)e();clearTimeout(a)}},[e]),t}function yO({title:e,children:t,right:n}){return(0,R.jsxs)(`section`,{className:`border-t border-rule pb-2 first:border-t-0`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center justify-between px-4 text-[12px] font-medium text-muted`,children:[e,n]}),t]})}function bO({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid min-h-7 grid-cols-[92px_minmax(0,1fr)] items-center gap-x-3 px-4 py-0.5 text-[12.5px]`,children:[(0,R.jsx)(`span`,{className:`text-muted`,children:e}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-ink`,children:t})]})}function xO({name:e}){return e?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void FT(`var(${e})`,`Token copied`),title:`Copy var()`,className:`shrink-0 cursor-pointer truncate rounded-[4px] border-0 bg-action-soft px-1.5 py-px font-mono text-[11px] text-action`,children:e}):null}function SO({children:e,title:t}){return(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:t,children:e})}function CO({label:e,color:t}){return(0,R.jsxs)(bO,{label:e,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:t.css}}),(0,R.jsx)(SO,{title:t.css,children:t.value}),(0,R.jsx)(xO,{name:t.token})]})}var wO=e=>e?String(e):`–`;function TO({label:e,values:t,className:n,children:r}){let[i,a,o,s]=t;return(0,R.jsxs)(`div`,{className:J(`relative grid grid-cols-[28px_minmax(0,1fr)_28px] grid-rows-[20px_auto_20px] rounded-[4px]`,n),children:[(0,R.jsx)(`span`,{className:`absolute top-1 left-1.5 text-[9.5px] tracking-wide text-muted uppercase`,children:e}),(0,R.jsx)(`span`,{className:`col-start-2 self-center text-center`,children:wO(i)}),(0,R.jsx)(`span`,{className:`row-start-2 self-center text-center`,children:wO(s)}),(0,R.jsx)(`div`,{className:`row-start-2 col-start-2`,children:r}),(0,R.jsx)(`span`,{className:`row-start-2 col-start-3 self-center text-center`,children:wO(a)}),(0,R.jsx)(`span`,{className:`row-start-3 col-start-2 self-center text-center`,children:wO(o)})]})}function EO({info:e}){let t={w:Math.max(0,e.rect.w-e.border[1]-e.border[3]-e.padding[1]-e.padding[3]),h:Math.max(0,e.rect.h-e.border[0]-e.border[2]-e.padding[0]-e.padding[2])};return(0,R.jsx)(`div`,{className:`px-4 pt-1 pb-2 font-mono text-[11px] text-ink2`,children:(0,R.jsx)(TO,{label:`margin`,values:e.margin,className:`border border-dashed border-rule-strong bg-[#f6b26b]/15`,children:(0,R.jsx)(TO,{label:`border`,values:e.border,className:`border border-rule-strong bg-[#f9e27d]/15`,children:(0,R.jsx)(TO,{label:`padding`,values:e.padding,className:`border border-rule-strong bg-[#93c47d]/20`,children:(0,R.jsxs)(`div`,{className:`flex h-8 items-center justify-center rounded-[3px] border border-rule-strong bg-[#6fa8dc]/25 text-ink`,children:[Math.round(t.w*100)/100,` × `,Math.round(t.h*100)/100]})})})})})}function DO({info:e,onSelect:t}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-4 pb-2`,children:[e.path.slice(-4).map((e,n)=>(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`cursor-pointer rounded-[4px] border-0 bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2 hover:text-ink`,children:e.label}),(0,R.jsx)(X,{name:`chevron-right`,size:11,className:`text-muted`})]},n)),(0,R.jsx)(`span`,{className:`rounded-[4px] bg-action-soft px-1.5 py-0.5 font-mono text-[11px] text-action`,children:e.label})]})}function OO({info:e,onSelect:t,onClose:n,active:r}){return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[320px] shrink-0 flex-col overflow-hidden border-l border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex h-[46px] shrink-0 items-center justify-between border-b border-rule pr-2 pl-4`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px] font-semibold`,children:[(0,R.jsx)(X,{name:`pointer`,size:15,className:`text-action`}),` Inspect`]}),(0,R.jsx)(N_,{icon:`x`,label:`Close inspector (I)`,onClick:n})]}),e?(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,R.jsxs)(yO,{title:`Element`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 pb-2`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:e.component?.owners[0]?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:[`<`,e.component.owners[0],`>`]}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[12px] text-muted`,children:e.tag})]}):(0,R.jsx)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:e.label})}),e.component&&e.component.owners.length>1?(0,R.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[`in `,e.component.owners.slice(1).join(` ← `)]}):null,e.component?.file?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void FT(e.component.file,`Path copied`),className:`w-fit max-w-full cursor-pointer truncate border-0 bg-transparent p-0 text-left font-mono text-[11.5px] text-muted hover:text-ink2`,title:`Copy path`,children:e.component.file}):null,e.text?(0,R.jsxs)(`span`,{className:`line-clamp-2 text-[12.5px] text-ink2`,children:[`“`,e.text,`”`]}):null]}),(0,R.jsx)(DO,{info:e,onSelect:t})]}),(0,R.jsxs)(yO,{title:`Box`,children:[(0,R.jsx)(EO,{info:e}),(0,R.jsx)(bO,{label:`Size`,children:(0,R.jsxs)(SO,{children:[e.rect.w,` × `,e.rect.h]})}),(0,R.jsx)(bO,{label:`Position`,children:(0,R.jsxs)(SO,{children:[`x `,e.rect.x,` · y `,e.rect.y]})})]}),e.layout.length?(0,R.jsx)(yO,{title:`Layout`,children:e.layout.map(([e,t])=>(0,R.jsx)(bO,{label:e,children:(0,R.jsx)(SO,{title:t,children:t})},e))}):null,e.typography?(0,R.jsxs)(yO,{title:`Typography`,children:[(0,R.jsxs)(bO,{label:`Font`,children:[(0,R.jsx)(SO,{title:e.typography.family,children:e.typography.family.split(`,`)[0]?.replace(/["']/g,``)}),(0,R.jsx)(xO,{name:e.typography.familyToken})]}),(0,R.jsxs)(bO,{label:`Size`,children:[(0,R.jsxs)(SO,{children:[e.typography.size,` / `,e.typography.lineHeight]}),(0,R.jsx)(xO,{name:e.typography.sizeToken})]}),(0,R.jsx)(bO,{label:`Weight`,children:(0,R.jsx)(SO,{children:e.typography.weight})}),e.typography.letterSpacing===`normal`?null:(0,R.jsx)(bO,{label:`Tracking`,children:(0,R.jsx)(SO,{children:e.typography.letterSpacing})}),(0,R.jsx)(CO,{label:`Color`,color:e.typography.color}),e.typography.align===`start`?null:(0,R.jsx)(bO,{label:`Align`,children:(0,R.jsx)(SO,{children:e.typography.align})}),e.typography.transform?(0,R.jsx)(bO,{label:`Transform`,children:(0,R.jsx)(SO,{children:e.typography.transform})}):null]}):null,Object.values(e.appearance).some(Boolean)?(0,R.jsxs)(yO,{title:`Appearance`,children:[e.appearance.background?(0,R.jsx)(CO,{label:`Background`,color:e.appearance.background}):null,e.appearance.backgroundImage?(0,R.jsx)(bO,{label:`Image`,children:(0,R.jsx)(SO,{title:e.appearance.backgroundImage,children:e.appearance.backgroundImage})}):null,e.appearance.border?(0,R.jsxs)(bO,{label:`Border`,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:e.appearance.border.color.css}}),(0,R.jsxs)(SO,{children:[e.appearance.border.width,` `,e.appearance.border.style,` `,e.appearance.border.color.value]}),(0,R.jsx)(xO,{name:e.appearance.border.color.token})]}):null,e.appearance.radius?(0,R.jsxs)(bO,{label:`Radius`,children:[(0,R.jsx)(SO,{children:e.appearance.radius.value}),(0,R.jsx)(xO,{name:e.appearance.radius.token})]}):null,e.appearance.shadow?(0,R.jsxs)(bO,{label:`Shadow`,children:[(0,R.jsx)(SO,{title:e.appearance.shadow.value,children:e.appearance.shadow.value}),(0,R.jsx)(xO,{name:e.appearance.shadow.token})]}):null,e.appearance.opacity?(0,R.jsx)(bO,{label:`Opacity`,children:(0,R.jsx)(SO,{children:e.appearance.opacity})}):null]}):null,e.classes.length?(0,R.jsx)(yO,{title:`Classes`,right:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void FT(e.classes.join(` `),`Classes copied`),className:`cursor-pointer border-0 bg-transparent text-[12px] text-muted hover:text-ink2`,children:`Copy`}),children:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 px-4 pb-1`,children:e.classes.map(e=>(0,R.jsx)(`span`,{className:`rounded-[4px] bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2`,children:e},e))})}):null,e.attributes.length?(0,R.jsx)(yO,{title:`Attributes`,children:e.attributes.map(([e,t])=>(0,R.jsx)(bO,{label:e,children:(0,R.jsx)(SO,{title:t,children:t})},e))}):null,e.children.length?(0,R.jsx)(yO,{title:`Children · ${e.children.length}`,children:(0,R.jsx)(`div`,{className:`flex flex-col px-2 pb-1`,children:e.children.map((e,n)=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`flex h-7 cursor-pointer items-center gap-2 rounded-[6px] border-0 bg-transparent px-2 text-left font-mono text-[12px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(X,{name:`chevron-right`,size:12,className:`text-muted`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},n))})}):null]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-10 text-center`,children:[(0,R.jsx)(X,{name:`pointer`,size:22,className:`text-muted`}),(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:r?`Click an element in any screen.`:`Hold ${av} to highlight, click to inspect.`}),(0,R.jsx)(`span`,{className:`text-[12.5px] leading-[1.5] text-muted`,children:`Hover shows margin, padding and content. Clicks go to the inspector, not the screen.`}),(0,R.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-[12px] text-muted`,children:[(0,R.jsx)(S_,{children:`I`}),` toggle · hold `,(0,R.jsx)(S_,{children:av}),` · `,(0,R.jsx)(S_,{children:`esc`}),` clear`]})]}),e?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-rule bg-soft px-4 py-2.5`,children:(0,R.jsx)(A_,{icon:`copy`,onClick:()=>void FT(e.css,`CSS copied`),className:`grow`,children:`Copy CSS`})}):null]})}function kO({issues:e,className:t}){return(0,R.jsx)(`div`,{className:J(`flex flex-col`,t),children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5 border-t border-rule px-4 py-2.5 text-[13px] first:border-t-0`,children:[(0,R.jsx)(X,{name:e.severity===`error`?`alert`:`info`,size:15,className:J(`mt-0.5`,e.severity===`error`?`text-danger-text`:`text-action`)}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-ink`,children:e.message}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] break-all text-muted`,children:[e.file,e.at?` · ${e.at}`:``]})]})]},t))})}function AO({issues:e,title:t=`Problems`}){if(!e.length)return null;let n=e.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(z_,{className:n?`border-danger/40`:void 0,children:[(0,R.jsx)(B_,{title:t,count:e.length,sub:n?`${n} blocking`:`warnings`}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(kO,{issues:e})})]})}var jO=[.2,.7,.2,1];function MO({open:e,side:t,width:n,children:r}){return(0,R.jsx)(ed,{initial:!1,children:e?(0,R.jsx)(Kf.div,{initial:{width:0,opacity:.6},animate:{width:n,opacity:1},exit:{width:0,opacity:.6},transition:{duration:.22,ease:jO},className:J(`flex min-h-0 shrink-0 overflow-hidden`,t===`right`?`justify-start`:`justify-end`),children:(0,R.jsx)(`div`,{className:`flex min-h-0 shrink-0`,style:{width:n},children:r})},`panel`):null})}var NO=8e3,PO=class{url;store=new d_({ready:!1,online:!1,canDraw:!1,drawings:{},ghosts:{}});socket=null;confirmed={};pending=new Map;nextId=1;delay=500;timer;sweep;closed=!1;constructor(e){this.url=e,this.connect(),this.sweep=setInterval(()=>this.dropStale(),2e3)}connect(){if(this.closed)return;let e;try{e=new WebSocket(this.url)}catch{this.retry();return}this.socket=e,e.onmessage=e=>{if(typeof e.data!=`string`)return;let t=OT(e.data);t&&this.receive(t)},e.onclose=()=>{this.socket===e&&(this.socket=null,this.store.set(e=>({...e,online:!1,ghosts:{}})),this.retry())}}retry(){this.closed||(clearTimeout(this.timer),this.timer=setTimeout(()=>this.connect(),this.delay),this.delay=Math.min(this.delay*2,1e4))}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}shown(e){let t=this.confirmed[e]??lT();for(let n of this.pending.values())n.key===e&&(t=_T(t,n.ops)??t);return t}show(e){this.store.set(t=>{let n={...t.drawings};for(let t of e)n[t]=this.shown(t);return{...t,drawings:n}})}receive(e){switch(e.type){case`hello`:{this.delay=500,this.confirmed=e.drawings;let t=new Set([...Object.keys(this.confirmed),...[...this.pending.values()].map(e=>e.key)]),n={};for(let e of t)n[e]=this.shown(e);if(this.store.set({ready:!0,online:!0,canDraw:e.canDraw,drawings:n,ghosts:{}}),e.canDraw)for(let[e,{key:t,ops:n}]of this.pending)this.send({type:`ops`,id:e,key:t,...n});else this.pending.clear();break}case`ops`:{let t=_T(this.confirmed[e.key]??lT(),e);t&&(this.confirmed={...this.confirmed,[e.key]:t});let n=new Set((e.add??[]).map(e=>e.id));this.store.set(r=>{let i=r.ghosts[e.key]?.filter(e=>!n.has(e.stroke.id));return{...r,drawings:t?{...r.drawings,[e.key]:this.shown(e.key)}:r.drawings,ghosts:i?{...r.ghosts,[e.key]:i}:r.ghosts}});break}case`ack`:{let t=this.pending.get(e.id);this.pending.delete(e.id),t&&this.show([t.key]);break}case`doc`:{let t=this.confirmed[e.key]??lT(),n=vT(e.drawing,t),r=n?_T(t,n):null;r&&(this.confirmed={...this.confirmed,[e.key]:r},this.show([e.key]));break}case`live`:this.store.set(t=>{let n=t.ghosts[e.key]??[],r=n.find(t=>t.stroke.id===e.stroke.id),{at:i,points:a,...o}=e.stroke,s={...o,points:i&&r?[...r.stroke.points.slice(0,i),...a]:a},c={peer:e.peer,name:e.name,stroke:s,seen:Date.now()},l=r?n.map(e=>e===r?c:e):[...n,c];return{...t,ghosts:{...t.ghosts,[e.key]:l}}});break;case`live-end`:this.dropGhosts((t,n)=>n===e.key&&t.stroke.id===e.id);break;case`gone`:this.dropGhosts(t=>t.peer===e.peer);break;case`error`:console.warn(`[design] drawings: ${e.message}`)}}dropGhosts(e){this.store.set(t=>{let n=!1,r={};for(let[i,a]of Object.entries(t.ghosts)){let t=a.filter(t=>!e(t,i));t.length!==a.length&&(n=!0),t.length&&(r[i]=t)}return n?{...t,ghosts:r}:t})}dropStale(){let e=Date.now();this.dropGhosts(t=>e-t.seen>NO)}apply(e,t){let n=this.store.get();if(!n.canDraw||!_T(n.drawings[e]??lT(),t))return;let r=this.nextId++;this.pending.set(r,{key:e,ops:t}),this.show([e]),this.send({type:`ops`,id:r,key:e,...t})}live(e,t,n){let{points:r,...i}=t;this.send({type:`live`,key:e,stroke:{...i,at:n,points:r.slice(n)}})}liveEnd(e,t){this.send({type:`live-end`,key:e,id:t})}close(){this.closed=!0,clearTimeout(this.timer),clearInterval(this.sweep);let e=this.socket;this.socket=null,e?.close()}};function FO(e,t=!0){let{source:n}=e_(),r=t?n.drawings?.(e)??null:null,[i,a]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!r)return;let e=new PO(r);return a(e),()=>{e.close(),a(null)}},[r]),i}var IO=[];function LO(e,t){return{drawing:Y(e.store,e=>e.drawings[t]),ghosts:Y(e.store,e=>e.ghosts[t]??IO)}}var RO=new d_({ready:!1,online:!1,canDraw:!1,drawings:{},ghosts:{}});function zO({title:e=`Nothing here`,text:t}){let n=!!e_().scope;return(0,R.jsx)(tv,{title:e,text:t??`This address does not match a canvas or a page of the design system.`,action:n?void 0:(0,R.jsx)(P_,{to:`/`,children:`All canvases`})})}var BO=.1,VO=(e,t=BO)=>Math.min(8,Math.max(t,e)),HO=class{camera={x:0,y:0,z:1};minZoom=BO;listeners=new Set;animation=0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}set(e){this.camera={x:e.x,y:e.y,z:VO(e.z,this.minZoom)};for(let e of this.listeners)e(this.camera)}interrupt(){cancelAnimationFrame(this.animation),this.animation=0}panBy(e,t){this.interrupt();let{x:n,y:r,z:i}=this.camera;this.set({x:n+e,y:r+t,z:i})}zoomAt(e,t,n){this.interrupt();let{x:r,y:i,z:a}=this.camera,o=VO(a*n,this.minZoom),s=(e-r)/a,c=(t-i)/a;this.set({x:e-s*o,y:t-c*o,z:o})}animateTo(e,t=320){this.interrupt();let n={...this.camera},r={...e,z:VO(e.z,this.minZoom)};if(t<=0||matchMedia(`(prefers-reduced-motion: reduce)`).matches){this.set(r);return}let i=performance.now(),a=e=>{let o=Math.min(1,(e-i)/t),s=1-(1-o)**3,c=n.z*(r.z/n.z)**s,l=n.z===r.z?s:(c-n.z)/(r.z-n.z);this.set({x:n.x+(r.x-n.x)*l,y:n.y+(r.y-n.y)*l,z:c}),this.animation=o<1?requestAnimationFrame(a):0};this.animation=requestAnimationFrame(a)}toWorld(e,t){let{x:n,y:r,z:i}=this.camera;return{x:(e-n)/i,y:(t-r)/i}}};function UO(e){try{let t=JSON.parse(sessionStorage.getItem(e)??`null`);if(t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.z))return t}catch{}return null}function WO(e,t,n,r=72,i=1,a=BO){let o=VO(Math.min((t-r*2)/Math.max(e.w,1),(n-r*2)/Math.max(e.h,1),i),a),s=(e,t,n)=>t*o<=n-r*2?n/2-(e+t/2)*o:r-e*o;return{z:o,x:s(e.x,e.w,t),y:s(e.y,e.h,n)}}var GO=14,KO=96;function qO(e){let t=0;return n=>{let r=24*n.z;for(;r<GO;)r*=4;for(;r>KO;)r/=4;r!==t&&(t=r,e.style.backgroundSize=`${r}px ${r}px`);let i=e=>((e+KO)%r+r)%r-r;e.style.transform=`translate3d(${i(n.x)}px, ${i(n.y)}px, 0)`}}function JO(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function YO(){return new d_({selected:null,active:null,hovered:null,sizes:{},frames:{},live:[],panning:!1,zoomTiny:!1,frameEls:{},inspecting:!1,markup:null})}function XO(e,t,n){e.set(e=>{let r=e.sizes[t];return r&&Math.abs(r.h-n.h)<1&&r.w===n.w?e:{...e,sizes:{...e.sizes,[t]:n}}})}function ZO(e,t,n){e.set(e=>{let r=e.frames[t]??{ready:!1,errors:[]};return{...e,frames:{...e.frames,[t]:{...r,...n}}}})}function QO(e,t,n){e.set(e=>e.frameEls[t]===n?e:{...e,frameEls:{...e.frameEls,[t]:n}})}function $O(e,t,n=!0){let r=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let i=r.current;if(!i||!n)return;let a=new ResizeObserver(()=>XO(e,t,{h:i.offsetHeight}));return a.observe(i),()=>a.disconnect()},[e,t,n]),r}function ek(e){return e<600?`smartphone`:e<1100?`tablet`:`monitor`}var tk=(0,v.memo)(function({placed:e,mode:t,thumb:n,theme:r,store:i,events:a,capture:o}){let{item:s,x:c,y:l,w:u,h:d}=e,f=(0,v.useRef)(null),{frameSandbox:p,frameAllow:m}=e_(),h=(0,v.useCallback)(e=>{f.current=e,QO(i,s.id,e)},[i,s.id]),g=Y(i,e=>e.frames[s.id]),_=Y(i,e=>e.active===s.id),y=Y(i,e=>e.inspecting&&s.kind===`screen`),b=s.frame.height===`auto`,x=s.kind===`screen`?s.theme??r:r,S=s.kind===`screen`?s.rev:s.url,[C]=(0,v.useState)(x),w=s.kind===`screen`?mO(s.url,C,o?{capture:`1`}:void 0):s.url,T=!!g?.ready,E=t===`off`,D=!E&&!(s.kind===`screen`&&s.missing)&&!!s.url;(0,v.useEffect)(()=>{E&&ZO(i,s.id,{ready:!1})},[E,i,s.id]),(0,v.useEffect)(()=>{let e=f.current;if(e&&!E&&s.kind===`screen`)return sO(e,t=>{switch(t.type){case`ready`:ZO(i,s.id,{ready:!0}),lO(e);break;case`size`:b&&XO(i,s.id,{h:Math.max(200,t.height)});break;case`error`:{let e=i.get().frames[s.id]?.errors??[],n=aO(e,t.message);n!==e&&ZO(i,s.id,{errors:n});break}case`updated`:ZO(i,s.id,{errors:[]});break;case`go`:a.onGo(s.id,t.target);break;case`link`:a.onLink(s.id,t);break;case`wheel`:a.onWheel(e,t);break;case`keydown`:t.code===`Escape`&&a.onEscape()}})},[E,s.id,s.kind,b,i,a,w,S]),(0,v.useEffect)(()=>{s.kind===`screen`&&dO(f.current,x)},[x,s.kind]);let O=x===`dark`?`light`:`dark`,k=e=>e?.[x]??e?.[O],A=s.kind===`screen`?k(s.snapshots):void 0,j=n&&s.kind===`screen`?k(s.thumbs)??A:A,M=t===`asleep`&&T&&!!j;return(0,R.jsxs)(`div`,{"data-item":s.id,className:`absolute overflow-clip bg-surface`,style:{left:c,top:l,width:u,height:d,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:[(!T||M)&&j?(0,R.jsx)(`img`,{src:j,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,className:`absolute inset-0 h-full w-full object-cover object-top select-none`}):null,!T&&!j?(0,R.jsx)(nk,{item:s,loading:D}):null,D?(0,R.jsx)(`div`,{className:`absolute inset-0`,style:{contentVisibility:M?`hidden`:`visible`},children:(0,R.jsx)(`iframe`,{ref:h,src:w,title:s.title,allow:m,sandbox:p,className:J(`absolute top-0 left-0 block border-0 transition-opacity duration-200`,T?`opacity-100`:`opacity-0`),style:{width:u,height:d,colorScheme:x},onLoad:()=>{s.kind===`url`?ZO(i,s.id,{ready:!0}):(dO(f.current,x),lO(f.current))}},S)}):null,_||y?null:(0,R.jsx)(`div`,{"data-shield":s.id,className:`absolute inset-0`})]})});function nk({item:e,loading:t}){let n=e.kind===`screen`&&e.missing;return(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-soft text-muted`,children:[(0,R.jsx)(X,{name:n?`alert`:e.kind===`url`?`globe`:ek(e.frame.width),size:Math.max(24,Math.min(96,e.frame.width/12)),strokeWidth:1.25,className:n?`text-danger-text`:void 0}),(0,R.jsx)(`div`,{className:`max-w-[80%] truncate text-center`,style:{fontSize:Math.max(14,e.frame.width/40)},children:n?`Missing file: ${e.kind===`screen`?e.src:``}`:t?`Loading…`:e.title})]})}var rk=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a}=e,o=$O(t,n.id),s=n.tone===`plain`;return(0,R.jsxs)(`div`,{ref:o,"data-item":n.id,className:J(`absolute`,s?``:`rounded-[10px] border border-note-line bg-note px-6 py-5 shadow-frame`),style:{left:r,top:i,width:a},children:[n.title?(0,R.jsx)(`div`,{className:`mb-2 font-semibold text-ink`,style:{fontSize:s?26:19},children:n.title}):null,(0,R.jsx)(VD,{text:n.text,className:s?`prose-plain`:`prose-note`})]})}),ik=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a,h:o}=e;return(0,R.jsx)(`div`,{"data-item":n.id,className:`absolute overflow-clip rounded-[6px] bg-surface`,style:{left:r,top:i,width:a,height:o,boxShadow:`0 0 0 1px var(--rule)`},children:n.missing?(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:20}),` Missing image`]}):(0,R.jsx)(`img`,{src:n.url,alt:n.title,draggable:!1,className:`block h-full w-full object-contain select-none`,onLoad:e=>{let r=e.currentTarget;XO(t,n.id,{w:r.naturalWidth,h:r.naturalHeight})}})})}),ak=(0,v.memo)(function({section:e,x:t,y:n,w:r,store:i}){let a=$O(i,`section:${e.id}`);return!e.title&&!e.description?null:(0,R.jsxs)(`div`,{ref:a,className:`canvas-section absolute`,style:{left:t,top:n,width:Math.min(Math.max(r,720),1400)},children:[e.title?(0,R.jsx)(`div`,{className:`text-[40px] leading-[1.15] font-semibold tracking-[-0.015em] text-ink`,children:e.title}):null,e.description?(0,R.jsx)(`div`,{className:`mt-3 max-w-[1100px]`,children:(0,R.jsx)(VD,{text:e.description,className:`prose-plain`})}):null]})}),ok=280,sk=96,ck=150,lk=110,uk=720,dk=e=>e.kind===`screen`||e.kind===`url`;function fk(e,t){let n=t[e.id];if(e.kind===`screen`||e.kind===`url`){let t=e.frame.width;if(e.frame.height!==`auto`)return{w:t,h:e.frame.height};let r=e.kind===`screen`?e.measuredHeight:void 0;return{w:t,h:n?.h??r??900}}if(e.kind===`note`)return{w:e.width,h:n?.h??Math.max(80,Math.ceil(e.text.length/38)*26+40)};let r=e.width??n?.w??480;return{w:r,h:n?.w?n.h/n.w*r:n?.h??r*.62}}function pk(e,t){return!e.title&&!e.description?0:t[`section:${e.id}`]?.h??(e.title?56:0)+(e.description?60:0)}function mk(e,t){let n=[],r=[];if(e.layout===`free`){let r=0;for(let i of e.sections)for(let e of i.items){let{w:a,h:o}=fk(e,t),s=e.x??r,c=e.y??0;r=Math.max(r,s+a+sk),n.push({item:e,section:i,x:s,y:c,w:a,h:o})}}else{let i=0;for(let a of e.sections){let e=pk(a,t),o=i,s=i+(e?e+lk:0),c=0,l=0,u=0,d=0;for(let e of a.items){a.columns&&d===a.columns&&(s+=l+ck,c=0,l=0,d=0);let{w:r,h:i}=fk(e,t);n.push({item:e,section:a,x:c,y:s,w:r,h:i}),c+=r+sk,u=Math.max(u,c-sk),l=Math.max(l,i),d++}let f=s+l;r.push({section:a,x:0,y:o,w:Math.max(u,e?uk:0),h:f-o,header:e,body:e?e+lk:0}),i=f+ok}}let i=0,a=0,o=0,s=0,c=[...n,...r];return c.length&&(i=Math.min(...c.map(e=>e.x)),a=Math.min(...c.map(e=>e.y)),o=Math.max(...c.map(e=>e.x+e.w)),s=Math.max(...c.map(e=>e.y+e.h))),{items:n,sections:r,bounds:{x:i,y:a,w:o-i,h:s-a}}}function hk(e){return e.items.filter(e=>dk(e.item))}var gk={phone:{width:390,height:844,label:`Phone`},"phone-sm":{width:375,height:667,label:`Phone S`},"phone-lg":{width:430,height:932,label:`Phone L`},tablet:{width:834,height:1194,label:`Tablet`},"tablet-landscape":{width:1194,height:834,label:`Tablet landscape`},laptop:{width:1280,height:800,label:`Laptop`},desktop:{width:1440,height:900,label:`Desktop`},wide:{width:1920,height:1080,label:`Wide`}};Object.keys(gk);var _k=e=>({"--x":e.x,"--y":e.y,"--w":e.w,"--h":e.h});function vk(e){let t=e.item;if(t.kind!==`screen`&&t.kind!==`url`)return``;let n=t.frame.device?gk[t.frame.device]?.label:void 0,r=`${t.frame.width} × ${t.frame.height===`auto`?`auto`:t.frame.height}`;return n?`${n} · ${r}`:r}var yk=(0,v.memo)(function({placed:e,store:t}){let n=e.item.id,r=Y(t,e=>e.selected===n),i=Y(t,e=>e.frames[n]?.errors.length??0);return(0,R.jsxs)(`div`,{"data-at":``,"data-label":n,style:_k(e),className:J(`frame-label pointer-events-auto flex cursor-default items-center gap-1.5 overflow-hidden pb-1.5 text-[12.5px] leading-none whitespace-nowrap select-none`,r?`text-ink`:`text-muted hover:text-ink2`),children:[i?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`,title:`${i} errors`}):null,(0,R.jsx)(`span`,{className:J(`min-w-[3ch] truncate`,r?`font-semibold`:`font-medium`),children:e.item.title}),(0,R.jsx)(`span`,{className:`frame-device min-w-0 shrink-[20] truncate text-[11.5px] text-muted opacity-80`,children:vk(e)})]})}),bk=(0,v.memo)(function({placed:e}){return(0,R.jsx)(`div`,{"data-at":``,style:{"--x":e.x,"--y":e.y,"--body":e.body},className:`section-title text-[15px] leading-none font-semibold whitespace-nowrap text-ink select-none`,children:e.section.title})});function xk({placed:e,kind:t}){return(0,R.jsx)(`div`,{"data-at":``,style:_k(e),className:J(`frame-outline rounded-[1px]`,t===`hover`?`outline outline-[1.5px] outline-action/60`:`outline-2 outline-action outline`)})}function Sk({layout:e,view:t,store:n,overlayRef:r}){let i=Y(n,e=>e.selected),a=Y(n,e=>e.active),o=Y(n,e=>e.hovered),s=Y(n,e=>e.zoomTiny),c=(0,v.useMemo)(()=>e.items.filter(e=>dk(e.item)),[e]),l=(0,v.useMemo)(()=>{if(!t||s)return[];let{x:e,y:n,z:r,w:i,h:a}=t,o={x:-e/r-i/r,y:-n/r-a/r,w:i/r*3,h:a/r*3};return c.filter(e=>JO(e,o))},[c,t,s]),u=(0,v.useMemo)(()=>e.sections.filter(e=>e.section.title),[e]),d=t=>t?e.items.find(e=>e.item.id===t):void 0,f=d(i),p=o&&o!==i?d(o):void 0;return(0,R.jsxs)(`div`,{ref:r,className:`canvas-overlay`,"data-tiny":s,children:[u.map(e=>(0,R.jsx)(bk,{placed:e},e.section.id)),l.map(e=>(0,R.jsx)(yk,{placed:e,store:n},e.item.id)),p?(0,R.jsx)(xk,{placed:p,kind:`hover`}):null,f?(0,R.jsx)(xk,{placed:f,kind:a===i?`active`:`selected`}):null]})}var Ck=12,wk=.4,Tk=20,Ek=110,Dk=.2,Ok=400,kk=.2,Ak=3,jk=8e3;function Mk({layout:e,theme:t,store:n,camera:r,events:i,capture:a,apiRef:o,onPlay:s,onSelect:c,over:l}){let u=(0,v.useRef)(null),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),[m,h]=(0,v.useState)(null),g=Y(n,e=>e.panning),_=Y(n,e=>e.selected),y=Y(n,e=>e.active),b=(0,v.useMemo)(()=>e.items.filter(e=>dk(e.item)),[e]);(0,v.useLayoutEffect)(()=>{let e=u.current,t=d.current,i=f.current,a,o,s=!1,c=qO(i),l=()=>h({...r.camera,w:e.clientWidth,h:e.clientHeight,moving:s}),m=e=>{t.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.z})`,s||(s=!0,t.classList.add(`moving`)),clearTimeout(a),a=setTimeout(()=>{s=!1,t.classList.remove(`moving`),l()},160);let r=p.current;r&&(r.style.setProperty(`--tx`,String(e.x)),r.style.setProperty(`--ty`,String(e.y)),r.style.setProperty(`--z`,String(e.z))),c(e);let i=e.z<.09;n.get().zoomTiny!==i&&n.set(e=>({...e,zoomTiny:i})),t.classList.toggle(`far`,e.z<.15);let u=e.z<wk;t.classList.toggle(`small-titles`,u),r&&(r.dataset.titles=u?`on`:`off`),o??=setTimeout(()=>{o=void 0,l()},90)};m(r.camera),l();let g=r.subscribe(m),_=e.getBoundingClientRect().left,v=new ResizeObserver(()=>{let t=e.getBoundingClientRect().left;if(t!==_){let e=r.camera;r.set({...e,x:e.x-(t-_)}),_=t}l()});return v.observe(e),()=>{g(),v.disconnect(),clearTimeout(a),clearTimeout(o)}},[r,n]),(0,v.useEffect)(()=>{let t=u.current,n=()=>{let{w:n,h:i}={w:t.clientWidth,h:t.clientHeight},o=e.bounds,s=o.w&&n?Math.min((n-160)/o.w,(i-160)/Math.max(o.h,1)):1;r.minZoom=a?.01:Math.min(.25,Math.max(BO,s*.5))};n();let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[r,e.bounds,a]),(0,v.useEffect)(()=>{let t=u.current,n=()=>({w:t.clientWidth,h:t.clientHeight});o.current={size:n,openView(){let{w:t,h:i}=n(),a=e.bounds;if(!a.w)return;if(Math.min((t-160)/a.w,(i-160)/Math.max(a.h,1))>=kk)return this.fitAll(!1);let o=e.sections[0]??a,s=Math.min(.5,Math.max(.25,(t-160)/Math.max(o.w,1)));r.set({z:s,x:80-a.x*s,y:80-a.y*s})},fitAll(t=!0){let{w:i,h:a}=n();if(!e.bounds.w)return;let o=WO(e.bounds,i,a,80,1,r.minZoom);t?r.animateTo(o):r.set(o)},fitItem(t,i=!0){let a=e.items.find(e=>e.item.id===t);if(!a)return;let{w:o,h:s}=n(),c=WO(a,o,s,64,1,r.minZoom);i?r.animateTo(c):r.set(c)},zoomBy(e){let{w:t,h:i}=n(),a=r.camera,o=a.z*e,s=(t/2-a.x)/a.z,c=(i/2-a.y)/a.z;r.animateTo({z:o,x:t/2-s*o,y:i/2-c*o},180)},zoomTo(e){let{w:t,h:i}=n(),a=r.camera,o=(t/2-a.x)/a.z,s=(i/2-a.y)/a.z;r.animateTo({z:e,x:t/2-o*e,y:i/2-s*e},220)}}},[o,r,e]);let x=(0,v.useRef)([]),S=(0,v.useRef)(new Map),[C,w]=(0,v.useState)(0),T=Y(n,e=>Nk(e.frames)),E=(0,v.useMemo)(()=>{let e=new Map;if(a){for(let t of b)e.set(t.item.id,`live`);return e}if(!m)return e;let{x:t,y:n,z:r,w:i,h:o}=m,s={x:-t/r,y:-n/r,w:i/r,h:o/r},c={x:s.x-s.w*.25,y:s.y-s.h*.25,w:s.w*1.5,h:s.h*1.5},l=s.x+s.w/2,u=s.y+s.h/2,d=e=>Math.max(0,Math.min(e.x+e.w,s.x+s.w)-Math.max(e.x,s.x))*Math.max(0,Math.min(e.y+e.h,s.y+s.h)-Math.max(e.y,s.y)),f=e=>Math.hypot(e.x+e.w/2-l,e.y+e.h/2-u),p=b.filter(e=>r>=Dk&&JO(e,c)&&e.w*r>=Ek).sort((e,t)=>d(t)-d(e)||f(e)-f(t)).slice(0,Ck).map(e=>e.item.id),h=[y,_].filter(e=>!!e),g=new Set(b.map(e=>e.item.id)),v=new Set(T.split(`
|
|
126
126
|
`)),C=new Set(x.current),w=performance.now(),E=e=>!v.has(e)&&w-(S.current.get(e)??0)<jk,D=Ak-[...C].filter(E).length,O=[];for(let e of new Set([...h,...p]))g.has(e)&&(C.has(e)?O.push(e):(h.includes(e)||!m.moving&&D>0)&&(O.push(e),S.current.set(e,w),D--));let k=[...new Set([...O,...x.current])].filter(e=>g.has(e)).slice(0,Tk);x.current=k;for(let e of S.current.keys())k.includes(e)||S.current.delete(e);for(let t of k)e.set(t,O.includes(t)?`live`:`asleep`);return e},[m,b,y,_,a,T,C]);(0,v.useEffect)(()=>{let e=performance.now(),t=new Set(T.split(`
|
|
127
127
|
`)),n=[...S.current].filter(([e])=>!t.has(e)).map(([,t])=>t+jk-e).filter(e=>e>0);if(!n.length)return;let r=setTimeout(()=>w(e=>e+1),Math.min(...n)+20);return()=>clearTimeout(r)},[E,T]);let D=(0,v.useRef)(null),O=(0,v.useRef)(new Map),k=(0,v.useRef)(null),A=(0,v.useRef)(!1),j=e=>{n.get().panning!==e&&n.set(t=>({...t,panning:e}))};(0,v.useEffect)(()=>{let e=e=>{e.code===`Space`&&!Pk(e.target)&&(A.current=!0,u.current?.classList.add(`cursor-grab`),e.preventDefault())},t=e=>{e.code===`Space`&&(A.current=!1,u.current?.classList.remove(`cursor-grab`))};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]);let M=e=>{let t=e;return(t?.closest(`[data-shield]`))?.dataset.shield??(t?.closest(`[data-label]`))?.dataset.label??(t?.closest(`[data-item]`))?.dataset.item??null},ee=e=>{if(e.target.closest(`[data-ui]`)||e.button!==0&&e.button!==1)return;if(u.current.setPointerCapture(e.pointerId),O.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),r.interrupt(),O.current.size===2){let[e,t]=[...O.current.values()];k.current={dist:Math.hypot(e.x-t.x,e.y-t.y),midX:(e.x+t.x)/2,midY:(e.y+t.y)/2},D.current=null,j(!0);return}let t=e.button===1||A.current;D.current={id:t?null:M(e.target),startX:e.clientX,startY:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:t},t&&j(!0)},N=e=>{if(O.current.has(e.pointerId)&&O.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),k.current&&O.current.size===2){let[e,t]=[...O.current.values()],n=Math.hypot(e.x-t.x,e.y-t.y),i=(e.x+t.x)/2,a=(e.y+t.y)/2,o=u.current.getBoundingClientRect();r.panBy(i-k.current.midX,a-k.current.midY),r.zoomAt(i-o.left,a-o.top,n/Math.max(k.current.dist,1)),k.current={dist:n,midX:i,midY:a};return}let t=D.current;if(!t){if(!n.get().panning){let t=M(e.target);n.get().hovered!==t&&n.set(e=>({...e,hovered:t}))}return}!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>3&&(t.moved=!0,j(!0)),t.moved&&r.panBy(e.clientX-t.lastX,e.clientY-t.lastY),t.lastX=e.clientX,t.lastY=e.clientY},P=e=>{O.current.delete(e.pointerId),O.current.size<2&&(k.current=null);let t=D.current;D.current=null,t&&!t.moved&&c(t.id,{x:e.clientX,y:e.clientY}),O.current.size||j(!1)};(0,v.useEffect)(()=>{let e=u.current,t=t=>{if(t.target.closest(`[data-ui]`))return;t.preventDefault();let n=e.getBoundingClientRect(),i=t.deltaMode===1?16:t.deltaMode===2?n.height:1;if(t.ctrlKey||t.metaKey){let e=t.deltaY*i,a=Math.abs(e)<40?.012:.0025;r.zoomAt(t.clientX-n.left,t.clientY-n.top,Math.exp(-e*a))}else r.panBy(-t.deltaX*i,-t.deltaY*i)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[r]);let te=e.sections;return(0,R.jsxs)(`div`,{ref:u,className:J(`canvas-root relative h-full w-full touch-none overflow-clip select-none animate-[q-fade-in_160ms_ease-out]`,g&&`canvas-panning cursor-grabbing`),onPointerDown:ee,onPointerMove:N,onPointerUp:P,onPointerCancel:P,onPointerLeave:()=>n.get().hovered&&n.set(e=>({...e,hovered:null})),onDoubleClick:t=>{let n=M(t.target),r=n?e.items.find(e=>e.item.id===n):void 0;r&&dk(r.item)&&s(r.item.id)},children:[(0,R.jsx)(`div`,{ref:f,className:`canvas-grid`}),(0,R.jsxs)(`div`,{ref:d,className:`canvas-world`,children:[te.map(e=>(0,R.jsx)(ak,{section:e.section,x:e.x,y:e.y,w:e.w,store:n},`section:${e.section.id}`)),e.items.map(e=>{let{item:r}=e;return r.kind===`screen`||r.kind===`url`?(0,R.jsx)(tk,{placed:e,mode:E.get(r.id)??`off`,thumb:!a&&!!m&&e.w*m.z*devicePixelRatio<=Ok,theme:t,store:n,events:i,capture:a},r.id):r.kind===`note`?(0,R.jsx)(rk,{placed:e,store:n},r.id):(0,R.jsx)(ik,{placed:e,store:n},r.id)}),l]}),(0,R.jsx)(Sk,{layout:e,view:m,store:n,overlayRef:p})]})}function Nk(e){return Object.keys(e).filter(t=>e[t].ready).sort().join(`
|
|
128
128
|
`)}function Pk(e){let t=e;return!!t&&(t.isContentEditable||/^(input|textarea|select)$/i.test(t.tagName))}var{PI:Fk}=Math,Ik=Fk+1e-4,Lk=.5,Rk=[1,1];function zk(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}var{min:Bk}=Math;function Vk(e,t,n){let r=Bk(1,t/n);return Bk(1,e+(Bk(1,1-r)-e)*(r*.275))}function Hk(e){return[-e[0],-e[1]]}function Uk(e,t){return[e[0]+t[0],e[1]+t[1]]}function Wk(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Gk(e,t){return[e[0]-t[0],e[1]-t[1]]}function Kk(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function qk(e,t){return[e[0]*t,e[1]*t]}function Jk(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function Yk(e,t){return[e[0]/t,e[1]/t]}function Xk(e){return[e[1],-e[0]]}function Zk(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function Qk(e,t){return e[0]*t[0]+e[1]*t[1]}function $k(e,t){return e[0]===t[0]&&e[1]===t[1]}function eA(e){return Math.hypot(e[0],e[1])}function tA(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function nA(e){return Yk(e,eA(e))}function rA(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function iA(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function aA(e,t,n,r){let i=Math.sin(r),a=Math.cos(r),o=t[0]-n[0],s=t[1]-n[1],c=o*a-s*i,l=o*i+s*a;return e[0]=c+n[0],e[1]=l+n[1],e}function oA(e,t,n){return Uk(e,qk(Gk(t,e),n))}function sA(e,t,n,r){let i=n[0]-t[0],a=n[1]-t[1];return e[0]=t[0]+i*r,e[1]=t[1]+a*r,e}function cA(e,t,n){return Uk(e,qk(t,n))}var lA=[0,0],uA=[0,0],dA=[0,0];function fA(e,t){let n=cA(e,nA(Xk(Gk(e,Uk(e,[1,1])))),-t),r=[],i=1/13;for(let t=i;t<=1;t+=i)r.push(iA(n,e,Ik*2*t));return r}function pA(e,t,n){let r=[],i=1/n;for(let n=i;n<=1;n+=i)r.push(iA(t,e,Ik*n));return r}function mA(e,t,n){let r=Gk(t,n),i=qk(r,.5),a=qk(r,.51);return[Gk(e,i),Gk(e,a),Uk(e,a),Uk(e,i)]}function hA(e,t,n,r){let i=[],a=cA(e,t,n),o=1/r;for(let t=o;t<1;t+=o)i.push(iA(a,e,Ik*3*t));return i}function gA(e,t,n){return[Uk(e,qk(t,n)),Uk(e,qk(t,n*.99)),Gk(e,qk(t,n*.99)),Gk(e,qk(t,n))]}function _A(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function vA(e,t,n){return e.slice(0,10).reduce((e,r)=>{let i=r.pressure;return t&&(i=Vk(e,r.distance,n)),(e+i)/2},e[0].pressure)}function yA(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=_A(s.taper,n,m),g=_A(c.taper,n,m),_=(n*r)**2,v=[],y=[],b=vA(e,a,n),x=zk(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,O=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t],f=t===e.length-1;if(!f&&m-u<3)continue;i?(a&&(r=Vk(b,l,n)),x=zk(n,i,r,o)):x=n/2,S===void 0&&(S=x);let k=u<h?d(u/h):1,A=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(k,A));let j=(f?e[t]:e[t+1]).vector,M=f?1:Qk(c,j),ee=Qk(c,C)<0&&!O,N=M!==null&&M<0;if(ee||N){Zk(lA,C),Jk(lA,lA,x);for(let e=0;e<=1;e+=.07692307692307693)Kk(uA,s,lA),aA(uA,uA,s,Ik*e),E=[uA[0],uA[1]],v.push(E),Wk(dA,s,lA),aA(dA,dA,s,Ik*-e),D=[dA[0],dA[1]],y.push(D);w=E,T=D,N&&(O=!0);continue}if(O=!1,f){Zk(lA,c),Jk(lA,lA,x),v.push(Gk(s,lA)),y.push(Uk(s,lA));continue}sA(lA,j,c,M),Zk(lA,lA),Jk(lA,lA,x),Kk(uA,s,lA),E=[uA[0],uA[1]],(t<=1||tA(w,E)>_)&&(v.push(E),w=E),Wk(dA,s,lA),D=[dA[0],dA[1]],(t<=1||tA(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let k=[e[0].point[0],e[0].point[1]],A=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:Uk(e[0].point,[1,1]),j=[],M=[];if(e.length===1){if(!(h||g)||l)return fA(k,S||x)}else{h||g&&e.length===1||(u?j.push(...pA(k,y[0],13)):j.push(...mA(k,v[0],y[0])));let t=Xk(Hk(e[e.length-1].vector));g||h&&e.length===1?M.push(A):f?M.push(...hA(A,t,x,29)):M.push(...gA(A,t,x))}return v.concat(M,y.reverse(),j)}var bA=[0,0];function xA(e){return e!=null&&e>=0}function SA(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=Lk})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(oA(o[0],e,t/4))}o.length===1&&(o=[...o,[...Uk(o[0],Rk),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:xA(o[0][2])?o[0][2]:.25,vector:[...Rk],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?[o[e][0],o[e][1]]:oA(u.point,o[e],a);if($k(u.point,t))continue;let n=rA(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}Kk(bA,u.point,t),u={point:t,pressure:xA(o[e][2])?o[e][2]:Lk,vector:nA(bA),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function CA(e,t={}){return yA(SA(e,t),t)}var wA={ink:`var(--draw-ink)`,red:`var(--draw-red)`,blue:`var(--draw-blue)`,green:`var(--draw-green)`},TA=e=>Math.round(e*100)/100;function EA(e,t){let n=[];for(let t=0;t+2<e.points.length;t+=3)n.push([e.points[t],e.points[t+1],e.points[t+2]]);let r=CA(n,{size:e.size,thinning:.55,smoothing:.5,streamline:.4,simulatePressure:n.every(e=>e[2]===.5),last:t});if(!r.length)return``;let i=[`M`,TA(r[0][0]),TA(r[0][1]),`Q`];return r.forEach(([e,t],n)=>{let[a,o]=r[(n+1)%r.length];i.push(TA(e),TA(t),TA((e+a)/2),TA((t+o)/2))}),i.push(`Z`),i.join(` `)}function DA([e,t,n,r],i){let a=Math.atan2(r-t,n-e),o=Math.max(10,i*4.5),s=e=>`${TA(n-o*Math.cos(a+e))} ${TA(r-o*Math.sin(a+e))}`;return`M ${TA(e)} ${TA(t)} L ${TA(n)} ${TA(r)} M ${s(.45)} L ${TA(n)} ${TA(r)} L ${s(-.45)}`}var OA=(0,v.memo)(function({stroke:e,done:t=!0}){let n=wA[e.ink],[r=0,i=0,a=0,o=0]=e.points;switch(e.kind){case`pen`:return(0,R.jsx)(`path`,{d:EA(e,t),fill:n});case`arrow`:return(0,R.jsx)(`path`,{d:DA(e.points,e.size),fill:`none`,stroke:n,strokeWidth:e.size,strokeLinecap:`round`,strokeLinejoin:`round`});case`rect`:return(0,R.jsx)(`rect`,{x:Math.min(r,a),y:Math.min(i,o),width:Math.abs(a-r),height:Math.abs(o-i),rx:Math.min(e.size*1.5,Math.abs(a-r)/2,Math.abs(o-i)/2),fill:`none`,stroke:n,strokeWidth:e.size,strokeLinejoin:`round`});case`text`:return(0,R.jsx)(`text`,{x:r,y:i,fill:n,fontSize:e.size,fontFamily:`var(--font-sans)`,fontWeight:500,dominantBaseline:`text-before-edge`,style:{whiteSpace:`pre`},children:(e.text??``).split(`
|
|
129
|
-
`).map((e,t)=>(0,R.jsx)(`tspan`,{x:r,dy:t?`${bT}em`:0,children:e||` `},t))})}});function kA({drawing:e,ghosts:t,draft:n}){return(0,R.jsxs)(R.Fragment,{children:[e?.strokes.map(e=>(0,R.jsx)(OA,{stroke:e},e.id)),t?.map(e=>(0,R.jsx)(`g`,{opacity:.8,children:(0,R.jsx)(OA,{stroke:e.stroke,done:!1})},`${e.peer}:${e.stroke.id}`)),n?(0,R.jsx)(OA,{stroke:n,done:!1}):null]})}function AA(e,t,n){let r=e.points,i=(e,r,i,a)=>{let o=i-e,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((t-e)*o+(n-r)*s)/c)):0;return Math.hypot(t-(e+l*o),n-(r+l*s))};if(e.kind===`text`){let r=xT(e),i=Math.max(r.x-t,0,t-(r.x+r.w)),a=Math.max(r.y-n,0,n-(r.y+r.h));return Math.hypot(i,a)}if(e.kind===`pen`){let e=1/0;if(r.length===3)return Math.hypot(t-r[0],n-r[1]);for(let t=0;t+5<r.length;t+=3)e=Math.min(e,i(r[t],r[t+1],r[t+3],r[t+4]));return e}let[a=0,o=0,s=0,c=0]=r;return e.kind===`arrow`?i(a,o,s,c):Math.min(i(a,o,s,o),i(s,o,s,c),i(s,c,a,c),i(a,c,a,o))}var jA=[{tool:`pen`,icon:`edit`,label:`Pen`,key:`P`},{tool:`arrow`,icon:`arrow-up-right`,label:`Arrow`,key:`A`},{tool:`rect`,icon:`square`,label:`Rectangle`,key:`R`},{tool:`text`,icon:`type`,label:`Text`,key:`T`},{tool:`eraser`,icon:`eraser`,label:`Eraser`,key:`E`}],MA={ink:`Ink`,red:`Red`,blue:`Blue`,green:`Green`},NA=e=>e.map(e=>({...e,id:uT()})),PA=e=>Math.round(e*10)/10;function FA(e,t,n=`ink`){let[r,i]=(0,v.useState)(`pen`),[a,o]=(0,v.useState)(n),s=(0,v.useRef)({undo:[],redo:[]}),[,c]=(0,v.useReducer)(e=>e+1,0);if((0,v.useEffect)(()=>{s.current={undo:[],redo:[]},c()},[t]),!e||!t)return null;let l=e=>{e.strokes.length&&(s.current.undo.push(e),s.current.redo=[],c())},u=n=>e.apply(t,{erase:n.map(e=>e.id)}),d=n=>{let r=s.current,i=r[n].pop();if(!i)return;let a=n===`undo`?r.redo:r.undo;if(i.kind===`add`==(n===`undo`))u(i.strokes),a.push(i);else{let n=NA(i.strokes);e.apply(t,{add:n}),a.push({kind:i.kind,strokes:n})}c()};return{client:e,drawingKey:t,tool:r,setTool:i,ink:a,setInk:o,record:l,eraseNow:u,add(n){e.apply(t,{add:n}),l({kind:`add`,strokes:n})},clear(){let n=e.store.get().drawings[t]?.strokes??[];u(n),l({kind:`erase`,strokes:n})},undo:()=>d(`undo`),redo:()=>d(`redo`),canUndo:s.current.undo.length>0,canRedo:s.current.redo.length>0}}function IA(){let e=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{let t=t=>{t.code===`Space`&&(e.current=!0)},n=t=>{t.code===`Space`&&(e.current=!1)};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n)}},[]),e}function LA(e,t){let n=(0,v.useRef)(e);n.current=e,(0,v.useEffect)(()=>{if(!t)return;let e=e=>{let t=n.current;if(!t||Pk(e.target))return;let r=e.metaKey||e.ctrlKey,i=e.key.toLowerCase();if(r&&i===`z`)e.preventDefault(),e.shiftKey?t.redo():t.undo();else if(r&&i===`y`)e.preventDefault(),t.redo();else if(!r&&!e.altKey){let n=jA.find(e=>e.key.toLowerCase()===i);n?t.setTool(n.tool):/^[1-4]$/.test(e.key)&&t.setInk(Qw[Number(e.key)-1])}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function RA({editor:e,end:t,compact:n=!1}){return(0,R.jsxs)(`div`,{"data-ui":!0,className:`flex items-center gap-0.5`,children:[jA.map(t=>(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t.label,` `,(0,R.jsx)(S_,{children:t.key})]}),children:(0,R.jsx)(`button`,{type:`button`,"aria-label":t.label,"aria-pressed":e.tool===t.tool,onClick:()=>e.setTool(t.tool),className:J(`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] border p-0 transition-[color,background-color,scale] duration-100 active:scale-[0.94]`,e.tool===t.tool?`border-action-line bg-action-soft text-action`:`border-transparent bg-transparent text-muted hover:bg-soft2 hover:text-ink2`),children:(0,R.jsx)(X,{name:t.icon,size:16})})},t.tool)),(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),n?(0,R.jsx)(ow,{side:`top`,align:`center`,width:170,trigger:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Ink: ${MA[e.ink]}`,className:`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-0 bg-transparent p-0 hover:bg-soft2`,children:(0,R.jsx)(`span`,{className:`size-[14px] rounded-full`,style:{background:wA[e.ink]}})}),children:Qw.map((t,n)=>(0,R.jsxs)(lw,{active:e.ink===t,onSelect:()=>e.setInk(t),hint:n+1,children:[(0,R.jsx)(`span`,{className:`size-[12px] rounded-full`,style:{background:wA[t]}}),MA[t]]},t))}):null,n?null:Qw.map((t,n)=>(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[MA[t],` `,(0,R.jsx)(S_,{children:n+1})]}),children:(0,R.jsx)(`button`,{type:`button`,"aria-label":MA[t],"aria-pressed":e.ink===t,onClick:()=>e.setInk(t),className:J(`inline-flex h-ctrl w-[26px] shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-0 bg-transparent p-0 hover:bg-soft2`),children:(0,R.jsx)(`span`,{className:J(`size-[14px] rounded-full`,e.ink===t&&`ring-2 ring-action ring-offset-2 ring-offset-surface`),style:{background:wA[t]}})})},t)),(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Undo `,(0,R.jsx)(S_,{children:`⌘Z`})]}),children:(0,R.jsx)(N_,{icon:`undo`,label:`Undo`,disabled:!e.canUndo,onClick:e.undo})}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Redo `,(0,R.jsx)(S_,{children:`⇧⌘Z`})]}),children:(0,R.jsx)(N_,{icon:`redo`,label:`Redo`,disabled:!e.canRedo,onClick:e.redo})}),(0,R.jsx)(kx,{content:`Erase everything`,children:(0,R.jsx)(N_,{icon:`trash`,label:`Erase everything`,onClick:e.clear})}),t]})}function zA({client:e,drawingKey:t,width:n,height:r,editor:i,sizes:a,className:o,camera:s,onPointerDownCapture:c}){let{drawing:l,ghosts:u}=LO(e,t);(0,v.useLayoutEffect)(()=>{let e=d.current;if(!s||!e)return;let t=()=>{let{x:t,y:n,z:r}=s.camera;e.setAttribute(`viewBox`,`${-t/r} ${-n/r} ${(e.clientWidth||1)/r} ${(e.clientHeight||1)/r}`)};t();let n=s.subscribe(t),r=new ResizeObserver(t);return r.observe(e),()=>{n(),r.disconnect()}},[s]);let d=(0,v.useRef)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),g=(0,v.useRef)(null),_=e=>{let t=d.current,n=t?.getScreenCTM();if(!t||!n)return null;let r=new DOMPoint(e.clientX,e.clientY).matrixTransform(n.inverse());return{x:r.x,y:r.y,scale:n.a||1}},y=(0,v.useRef)(null);y.current=m;let b=(0,v.useRef)(i);b.current=i;let x=(0,v.useCallback)(()=>{let e=y.current,t=b.current;y.current=null,h(null),e&&t&&e.value.trim()&&t.add([{id:uT(),kind:`text`,ink:t.ink,size:a.text,points:[PA(e.x),PA(e.y)],text:e.value.replace(/\s+$/,``)}])},[a.text]),S=i?.tool;(0,v.useEffect)(()=>{S!==`text`&&x()},[S,x]),(0,v.useEffect)(()=>x,[x]);let C=n=>{let r=g.current;if(!r?.stroke)return;let i=performance.now();if(!n&&i-r.lastSend<40)return;r.lastSend=i;let a=r.stroke.kind===`pen`?r.sent:0;e.live(t,r.stroke,a),r.sent=r.stroke.points.length},w=(n,r,a)=>{let o=g.current,s=e.store.get().drawings[t]?.strokes??[],c=8/a,l=s.filter(e=>AA(e,n,r)<=c+e.size/2);l.length&&i&&(i.eraseNow(l),o?.erased.push(...l))},T=e=>{if(!i||e.button!==0||c?.(e))return;e.stopPropagation(),e.preventDefault();let t=_(e);if(!t)return;if(m){x();return}d.current?.setPointerCapture(e.pointerId);let n={id:uT(),ink:i.ink},r=null;if(i.tool===`pen`){let i=e.pointerType===`pen`&&e.pressure||.5;r={...n,kind:`pen`,size:a.pen,points:[PA(t.x),PA(t.y),i]}}else(i.tool===`arrow`||i.tool===`rect`)&&(r={...n,kind:i.tool,size:a.line,points:[t.x,t.y,t.x,t.y]});g.current={stroke:r,sent:0,lastSend:0,frame:0,erased:[],startX:t.x,startY:t.y,pointer:e.pointerId},i.tool===`eraser`&&w(t.x,t.y,t.scale),p(r)},E=e=>{let t=g.current;if(!t||t.pointer!==e.pointerId||!i)return;let n=e.nativeEvent.getCoalescedEvents?.()??[e.nativeEvent];for(let r of n.length?n:[e.nativeEvent]){let e=_(r);if(e){if(i.tool===`eraser`)w(e.x,e.y,e.scale);else if(t.stroke?.kind===`pen`){let n=r.pointerType===`pen`&&r.pressure||.5;t.stroke.points.push(PA(e.x),PA(e.y),n)}else t.stroke&&(t.stroke.points=[t.stroke.points[0],t.stroke.points[1],e.x,e.y])}}t.stroke&&!t.frame&&(t.frame=requestAnimationFrame(()=>{t.frame=0,t.stroke&&p({...t.stroke,points:[...t.stroke.points]})})),C(!1)},D=n=>{let r=g.current;if(!r||r.pointer!==n.pointerId||!i)return;g.current=null,cancelAnimationFrame(r.frame),p(null);let o=_(n);if(i.tool===`eraser`){i.record({kind:`erase`,strokes:r.erased});return}if(i.tool===`text`){o&&Math.hypot(o.x-r.startX,o.y-r.startY)*o.scale<6&&h({x:r.startX,y:r.startY-a.text*.6,value:``});return}let s=r.stroke;if(s){if(r.sent&&e.liveEnd(t,s.id),s.kind!==`pen`){let[e=0,t=0,n=0,r=0]=s.points;if(Math.hypot(n-e,r-t)*(o?.scale??1)<4)return;s.points=s.points.map(PA)}i.add([s])}},O=n=>{let r=g.current;r&&r.pointer===n.pointerId&&(g.current=null,cancelAnimationFrame(r.frame),p(null),r.stroke&&r.sent&&e.liveEnd(t,r.stroke.id),r.erased.length&&i?.record({kind:`erase`,strokes:r.erased}))},k=i?i.tool===`text`?`text`:i.tool===`eraser`?`cell`:`crosshair`:void 0,A=(0,v.useMemo)(()=>m?xT({id:`draft`,kind:`text`,ink:`ink`,size:a.text,points:[m.x,m.y],text:m.value}):null,[m,a.text]);return(0,R.jsxs)(`svg`,{ref:d,viewBox:s?void 0:`0 0 ${n??0} ${r??0}`,preserveAspectRatio:s?`xMinYMin meet`:`xMidYMid meet`,role:`img`,"aria-label":i?`Drawing: draw here`:`Drawing`,className:J(`block touch-none select-none`,o),style:{cursor:k,pointerEvents:i?`auto`:`none`},onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,children:[(0,R.jsx)(kA,{drawing:l,ghosts:u,draft:f}),m&&A&&i?(0,R.jsx)(`foreignObject`,{x:m.x,y:m.y,width:Math.max(A.w+a.text*2,a.text*8),height:A.h+8,children:(0,R.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Text`,value:m.value,onChange:e=>h({...m,value:e.target.value}),onBlur:x,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`&&!e.shiftKey||e.key===`Escape`)&&(e.preventDefault(),x())},spellCheck:!1,className:`block h-full w-full resize-none overflow-hidden border-0 bg-transparent p-0 outline-none`,style:{font:`500 ${a.text}px/1.25 var(--font-sans)`,color:wA[i.ink],caretColor:wA[i.ink],whiteSpace:`pre`}})}):null]})}var BA={pen:5,line:3.5,text:28},VA=56,HA=(e,t)=>`foss-design.board.${e}.${t}`,UA=(e,t)=>`foss-design.board-camera.${e}.${t}`;function WA(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function GA({client:e,canvasId:t,page:n}){let r=oT(n.id),i=Y(e.store,e=>e.ready),a=Y(e.store,e=>e.canDraw),{drawing:o}=LO(e,r),s=HA(t,n.id),[c,l]=(0,v.useState)(()=>WA(s));if((0,v.useEffect)(()=>{try{c?sessionStorage.setItem(s,`1`):sessionStorage.removeItem(s)}catch{}},[c,s]),!i||!a&&yT(o))return null;let u=`board:${t}:${n.id}`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ed,{initial:!1,children:c?(0,R.jsx)(qA,{layoutId:u,client:e,canvasId:t,page:n,canDraw:a,onClose:()=>l(!1)},`panel`):null}),c?null:(0,R.jsx)(KA,{layoutId:u,client:e,page:n,onOpen:()=>l(!0)})]})}function KA({layoutId:e,client:t,page:n,onOpen:r}){let{drawing:i,ghosts:a}=LO(t,oT(n.id)),o=(0,v.useMemo)(()=>wT([...i?.strokes??[],...a.map(e=>e.stroke)]),[i,a]);return(0,R.jsx)(kx,{content:`Idea board`,side:`left`,children:(0,R.jsx)(Kf.button,{type:`button`,"data-ui":!0,layoutId:e,"aria-label":`Open the idea board`,onClick:r,style:{borderRadius:10},transition:{type:`spring`,duration:.34,bounce:.12},className:`absolute right-4 bottom-[76px] z-20 flex size-[92px] cursor-pointer flex-col items-center justify-center gap-1 overflow-hidden border border-rule bg-surface p-0 text-muted shadow-pop hover:text-ink2`,children:o?(0,R.jsx)(`svg`,{viewBox:`${o.x-VA} ${o.y-VA} ${o.w+112} ${o.h+112}`,className:`h-full w-full p-1.5`,"aria-hidden":`true`,children:(0,R.jsx)(kA,{drawing:i,ghosts:a})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{name:`lightbulb`,size:20}),(0,R.jsx)(`span`,{className:`text-[11.5px] font-medium`,children:`Ideas`})]})})})}function qA({layoutId:e,client:t,canvasId:n,page:r,canDraw:i,onClose:a}){let o=oT(r.id),s=FA(i?t:null,o),c=Y(t.store,e=>e.online),l=(0,v.useMemo)(()=>new HO,[]),u=(0,v.useRef)(null),d=(0,v.useCallback)((e=!0)=>{let n=u.current;if(!n)return;let r=wT(t.store.get().drawings[o]?.strokes??[]),i=r?WO(r,n.clientWidth,n.clientHeight,VA,1,l.minZoom):{x:VA,y:VA,z:1};e?l.animateTo(i):l.set(i)},[l,t,o]),f=UA(n,r.id);return(0,v.useLayoutEffect)(()=>{let e=UO(f);e?l.set(e):d(!1);let t,n=l.subscribe(e=>{clearTimeout(t),t=setTimeout(()=>{try{sessionStorage.setItem(f,JSON.stringify(e))}catch{}},250)});return()=>{n(),clearTimeout(t)}},[l,f,d]),LA(s,!0),(0,v.useEffect)(()=>{let e=e=>{Pk(e.target)||(e.key===`Escape`?a():e.shiftKey&&e.code===`Digit1`&&d())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,d]),(0,R.jsx)(Kf.div,{"data-ui":!0,role:`dialog`,"aria-label":`Idea board`,layoutId:e,style:{borderRadius:12},transition:{type:`spring`,duration:.34,bounce:.12},className:`absolute inset-4 z-30 flex flex-col overflow-hidden border border-rule bg-surface shadow-pop`,children:(0,R.jsxs)(Kf.div,{initial:{opacity:0},animate:{opacity:1,transition:{delay:.12,duration:.16}},exit:{opacity:0,transition:{duration:.08}},className:`flex min-h-0 grow flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex h-[52px] shrink-0 items-center gap-2 border-b border-rule pr-2 pl-4`,children:[(0,R.jsx)(X,{name:`lightbulb`,size:16,className:`text-muted`}),(0,R.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Ideas`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-muted`,children:r.title}),c?null:(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`· Reconnecting…`}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[s?(0,R.jsx)(RA,{editor:s}):(0,R.jsx)(`span`,{className:`px-2 text-[12.5px] text-muted`,children:`View only`}),(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Show all `,(0,R.jsx)(S_,{children:`⇧1`})]}),children:(0,R.jsx)(N_,{icon:`fit`,label:`Show all of the board`,onClick:()=>d()})}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Close `,(0,R.jsx)(S_,{children:`Esc`})]}),children:(0,R.jsx)(N_,{icon:`minimize`,label:`Close the idea board`,onClick:a})})]})]}),(0,R.jsx)(JA,{sheetRef:u,client:t,drawingKey:o,editor:s,camera:l})]})})}function JA({sheetRef:e,client:t,drawingKey:n,editor:r,camera:i}){let a=(0,v.useRef)(null),o=IA(),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(!1);(0,v.useLayoutEffect)(()=>{let e=qO(a.current);return e(i.camera),i.subscribe(e)},[i]),(0,v.useEffect)(()=>{let t=e.current,n=e=>{e.preventDefault();let n=t.getBoundingClientRect(),r=e.deltaMode===1?16:e.deltaMode===2?n.height:1;if(e.ctrlKey||e.metaKey){let t=e.deltaY*r,a=Math.abs(t)<40?.012:.0025;i.zoomAt(e.clientX-n.left,e.clientY-n.top,Math.exp(-t*a))}else i.panBy(-e.deltaX*r,-e.deltaY*r)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[i,e]);let u=e=>e.button===1||o.current===!0||!r&&e.button===0;return(0,R.jsxs)(`div`,{ref:e,className:J(`relative min-h-0 grow touch-none overflow-hidden bg-surface`,c&&`cursor-grabbing`),onPointerDown:e=>{u(e)&&(e.preventDefault(),i.interrupt(),e.currentTarget.setPointerCapture(e.pointerId),s.current={id:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=s.current;t&&t.id===e.pointerId&&(i.panBy(e.clientX-t.x,e.clientY-t.y),t.x=e.clientX,t.y=e.clientY)},onPointerUp:e=>{s.current?.id===e.pointerId&&(s.current=null,l(!1))},onPointerCancel:()=>{s.current=null,l(!1)},children:[(0,R.jsx)(`div`,{ref:a,className:`canvas-grid`}),(0,R.jsx)(zA,{client:t,drawingKey:n,editor:r,sizes:BA,camera:i,className:`absolute inset-0 h-full w-full`,onPointerDownCapture:u})]})}function YA({items:e,value:t,onChange:n,label:r,stretch:i,size:a=`ctrl`}){let o=(0,v.useId)();return(0,R.jsx)(`div`,{role:`group`,"aria-label":r,className:J(`shrink-0 items-center gap-0.5 rounded-[6px] bg-track p-[3px]`,a===`ctrl`?`h-ctrl`:`h-7`,i?`flex`:`inline-flex`),children:e.map(e=>{let r=e.value===t;return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":r,title:e.title,onClick:()=>n(e.value),className:J(`relative flex h-full cursor-pointer items-center justify-center whitespace-nowrap rounded-[4px] border-0 bg-transparent font-medium transition-colors`,a===`ctrl`?`px-2.5 text-ctrl`:`px-2 text-[12.5px]`,i&&`flex-1`,r?`text-ink`:`text-muted hover:text-ink2`),children:[r?(0,R.jsx)(Kf.span,{layoutId:o,className:`absolute inset-0 z-0 rounded-[4px] bg-surface shadow-[0_1px_2px_rgba(0,0,0,0.10)]`,transition:{type:`spring`,stiffness:520,damping:42}}):null,(0,R.jsx)(`span`,{className:`relative z-[1] flex items-center gap-1.5`,children:e.label})]},e.value)})})}var XA=new WeakMap,ZA=2200;function QA(e,t=`var(--action)`){clearTimeout(XA.get(e)),e.classList.remove(`target-ripple`),e.offsetWidth,e.style.setProperty(`--ripple-color`,t),e.classList.add(`target-ripple`),XA.set(e,setTimeout(()=>{e.classList.remove(`target-ripple`),e.style.removeProperty(`--ripple-color`)},ZA))}var $A=5500,ej=350,tj=(e,t)=>e>=window.innerWidth/2&&t<=window.innerHeight/2;function nj({frame:e,note:t,badge:n,children:r}){let[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(0),g=(0,v.useRef)(null),_=(0,v.useRef)(void 0),y=(0,v.useRef)(void 0),b=e=>{a(!0),clearTimeout(_.current),_.current=setTimeout(()=>a(!1),e)},x=(e,t)=>{let n=e>=0&&tj(e,t);clearTimeout(y.current),n?s(!0):y.current=setTimeout(()=>s(!1),ej)};(0,v.useEffect)(()=>{if(!e)return;let t=()=>{cO(e,{type:`pointer`}),b($A),h(e=>e+1)};e.addEventListener(`load`,t);let n=sO(e,t=>{if(t.type!==`pointer`)return;if(d(!0),t.x<0)return x(-1,-1);let n=e.getBoundingClientRect(),r=n.left+t.x,i=n.top+t.y;t.down&&tj(r,i)?b($A):x(r,i)});return()=>{e.removeEventListener(`load`,t),n()}},[e]),(0,v.useEffect)(()=>{let e=e=>x(e.clientX,e.clientY),t=e=>{e.relatedTarget||x(-1,-1)};return window.addEventListener(`pointermove`,e,{passive:!0}),document.addEventListener(`pointerout`,t),()=>{window.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerout`,t),clearTimeout(_.current),clearTimeout(y.current)}},[]),(0,v.useEffect)(()=>{if(u)return;let e=document.documentElement,t=()=>p(!0),n=()=>p(!1);return e.addEventListener(`pointerenter`,t),e.addEventListener(`pointerleave`,n),()=>{e.removeEventListener(`pointerenter`,t),e.removeEventListener(`pointerleave`,n)}},[u]);let S=i||o||c||!u&&f;return(0,v.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>g.current&&QA(g.current),200);return()=>clearTimeout(e)},[m]),(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsx)(Kf.button,{type:`button`,"aria-label":`Show the page's notice`,initial:!1,animate:S?{opacity:0,scale:.8}:{opacity:1,scale:1},transition:{duration:.2,delay:S?0:.25},onClick:()=>b($A),tabIndex:S?-1:0,className:J(`absolute top-3 right-3 inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-rule bg-surface/90 px-2.5 text-[11.5px] text-muted shadow-[0_1px_3px_rgb(0_0_0/0.08)] backdrop-blur-sm hover:text-ink2`,S&&`pointer-events-none`),children:n}):null,(0,R.jsx)(Kf.div,{ref:g,initial:{opacity:0,scale:.94,y:-4},animate:S?{opacity:1,scale:1,y:0}:{opacity:0,scale:.97,y:-2},transition:S?{type:`spring`,stiffness:420,damping:30}:{duration:.45,ease:`easeOut`},style:{transformOrigin:`top right`},className:J(`absolute top-3 right-3 flex max-w-[calc(100%-24px)] flex-col items-end rounded-[8px]`,!S&&`pointer-events-none`),"aria-hidden":!S||void 0,onFocus:()=>l(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},children:(0,R.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center justify-end gap-x-2 gap-y-1 rounded-[8px] border border-rule bg-surface p-1 shadow-pop`,children:[t?(0,R.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-[1_1_auto] items-center gap-1.5 pl-2 text-[12px] leading-snug text-muted`,children:[(0,R.jsx)(X,{name:`info`,size:13,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0`,children:t})]}):null,r?(0,R.jsx)(`div`,{className:`flex items-center gap-1`,children:r}):null]})})]})}var rj=(e,t,n)=>`/c/${encodeURIComponent(e)}/full/${encodeURIComponent(t)}?theme=${n}`;function ij(e,t,n){let{frameSandbox:r}=e_(),{base:i}=le();return t?t.kind===`url`?t.url:hO(r?`${i}${rj(e,t.id,t.theme??n)}`:mO(t.url,t.theme??n)):null}function aj({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=i_(e),[,a]=I(),{frameSandbox:o,frameAllow:s,slots:c}=e_(),l=b_(),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(null),p=(0,v.useCallback)(e=>{u.current=e,f(e)},[]),m=new URLSearchParams(window.location.search).get(`theme`),h=n?n.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))):[],g=h.find(e=>e.id===t),_=(g?.kind===`screen`?g.theme:void 0)??(m===`light`||m===`dark`?m:n?.theme??l),y=g?g.kind===`screen`?mO(g.url,_):g.url:``,b=`/c/${encodeURIComponent(e)}`;return(0,v.useEffect)(()=>{g&&(document.title=`${g.title} · ${n?.title??``}`)},[g,n?.title]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a(b)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,b]),(0,v.useEffect)(()=>{let r=u.current;if(r&&g?.kind===`screen`)return sO(r,r=>{if(r.type===`keydown`&&r.code===`Escape`)a(b);else if(r.type===`go`){let t=r.target.includes(`/`)?r.target.split(`/`)[1]:r.target;h.some(e=>e.id===t)&&a(rj(e,t,_),{replace:!0})}else r.type===`link`&&n&&gO(r,n,t=>a(rj(e,t,_),{replace:!0}),t)})},[y,g?.kind]),r?(0,R.jsx)(zO,{title:`Canvas not found`,text:r.message}):i||!n?(0,R.jsx)(`div`,{className:`h-dvh bg-surface`}):g?(0,R.jsxs)(`div`,{className:`fixed inset-0 bg-surface`,children:[(0,R.jsx)(`iframe`,{ref:p,src:y,title:g.title,allow:s,sandbox:o,className:`block h-full w-full border-0`,style:{colorScheme:_},onLoad:()=>g.kind===`screen`&&dO(u.current,_)},`${g.id}:${g.kind===`screen`?g.rev:g.url}`),(0,R.jsxs)(nj,{frame:d,note:c.fullPlate?.note,badge:c.fullPlate?.badge,children:[(0,R.jsxs)(ye,{href:b,className:`flex h-8 min-w-0 items-center gap-2 rounded-[6px] px-2 text-[12.5px] text-ink2 no-underline hover:bg-soft2 hover:text-ink`,children:[(0,R.jsx)(X,{name:`x`,size:14}),(0,R.jsxs)(`span`,{className:`truncate`,children:[`Back to `,n.title]}),(0,R.jsx)(S_,{children:`esc`})]}),c.fullPlate?.actions]})]}):(0,R.jsx)(zO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`})}function oj(e){return e.kind===`note`?`note`:e.kind===`image`?`image`:e.kind===`url`?`globe`:e.frame.width<600?`smartphone`:e.frame.width<1100?`tablet`:`monitor`}function sj(e,t){return`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(t.id)}`}function cj({canvas:e,page:t,store:n,onPick:r}){let i=Y(n,e=>e.selected),a=Y(n,e=>e.frames);return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[264px] shrink-0 flex-col overflow-hidden border-r border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-rule px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`truncate text-[14px] font-semibold`,children:e.title}),e.description?(0,R.jsx)(`div`,{className:`line-clamp-3 text-[12.5px] leading-[1.45] text-muted`,children:e.description}):null]}),(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto pb-4`,children:[e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:`Pages`}),(0,R.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2`,children:e.pages.map(n=>{let r=n.sections.reduce((e,t)=>e+t.items.filter(e=>e.kind===`screen`||e.kind===`url`).length,0);return(0,R.jsxs)(ye,{href:sj(e,n),className:J(`flex h-8 items-center gap-2 rounded-[6px] px-2.5 text-[13.5px] no-underline transition-colors focus-visible:outline-offset-[-2px]`,n.id===t.id?`bg-soft2 font-medium text-ink`:`text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:n.title}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted tabular`,children:r})]},n.id)})})]}):null,(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.pages.length>1?t.title:`Layers`}),(0,R.jsx)(`div`,{className:`flex flex-col px-2`,children:t.sections.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title?(0,R.jsxs)(`div`,{className:`flex h-7 items-center gap-2 px-2.5 pt-1 text-[12px] font-medium text-ink2`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.title}),(0,R.jsx)(R_,{value:e.items.length})]}):null,e.items.map(t=>{let n=(a[t.id]?.errors.length??0)>0||t.kind===`screen`&&t.missing;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.id),className:J(`flex h-8 w-full cursor-pointer items-center gap-2 rounded-[6px] border-0 px-2.5 text-left text-[13px] transition-colors focus-visible:outline-offset-[-2px]`,e.title&&`pl-4`,i===t.id?`bg-action-soft text-ink`:`bg-transparent text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:oj(t),size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:t.title||(t.kind===`note`?`Note`:t.id)}),n?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`}):null]},t.id)})]},e.id))})]})]})}function lj({canvas:e,page:t,theme:n,onTheme:r,sidebar:i,onSidebar:a,onPlay:o,canPlay:s,inspect:c,onInspect:l}){let[,u]=I(),{slots:d,scope:f}=e_(),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=vw(p,m,[e.title,t?.title,e.pages.length]);return(0,R.jsxs)(_w,{value:h,children:[(0,R.jsxs)(gw,{children:[d.barStart,d.brand?d.brand:f?(0,R.jsx)(mw,{}):(0,R.jsx)(kx,{content:`All canvases`,children:(0,R.jsx)(ye,{href:`/`,className:`flex items-center`,"aria-label":`All canvases`,children:(0,R.jsx)(mw,{})})}),(0,R.jsx)(N_,{icon:`panel-left`,label:i?`Hide sidebar (⌘\\)`:`Show sidebar (⌘\\)`,onClick:()=>a(!i)}),(0,R.jsxs)(`div`,{ref:p,className:`flex min-w-0 items-center gap-1.5 text-[14px]`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate font-semibold`,children:e.title}),t&&e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{name:`chevron-right`,size:14,className:`shrink-0 text-muted`}),(0,R.jsxs)(ow,{width:240,trigger:(0,R.jsxs)(`button`,{type:`button`,className:`flex h-ctrl cursor-pointer items-center gap-1 rounded-[6px] border-0 bg-transparent px-2 text-[14px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate`,children:t.title}),(0,R.jsx)(X,{name:`chevron-down`,size:14,className:`text-muted`})]}),children:[(0,R.jsx)(dw,{children:`Pages`}),e.pages.map(n=>(0,R.jsxs)(lw,{active:n.id===t.id,onSelect:()=>u(sj(e,n)),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),n.title]},n.id))]})]}):null]}),(0,R.jsxs)(`div`,{ref:m,className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(YA,{label:`Screen theme`,value:n,onChange:r,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light screens`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark screens`}]}),(0,R.jsx)(pj,{on:c,onChange:l,compact:h}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`P`})]}),children:(0,R.jsx)(A_,{kind:`secondary`,icon:`play`,onClick:o,disabled:!s,"aria-label":`Play`,className:h?`w-ctrl px-0`:void 0,children:h?null:`Play`})}),(0,R.jsx)(Mx,{width:180,label:`Search`,compact:h}),(0,R.jsx)(pw,{}),d.barEnd]})]}),d.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:d.belowBar}):null]})}function uj({children:e}){return(0,R.jsx)(`div`,{"data-ui":!0,className:`pointer-events-none absolute inset-x-4 bottom-5 z-20 grid grid-cols-[minmax(var(--dock-left,0px),1fr)_minmax(0,auto)_minmax(var(--dock-right,0px),1fr)]`,children:(0,R.jsx)(`div`,{className:`col-start-2 flex min-w-0 justify-center`,children:e})})}function dj({canvas:e,store:t,layoutItems:n,theme:r,onPlay:i,inspect:a,onMarkup:o}){let s=Y(t,e=>e.selected),c=n.find(e=>e.id===s);return(0,R.jsx)(uj,{children:(0,R.jsx)(ed,{children:c?(0,R.jsx)(fj,{canvas:e,store:t,item:c,theme:r,onPlay:i,inspect:a,onMarkup:o},`bar`):null})})}function fj({canvas:e,store:t,item:n,theme:r,onPlay:i,inspect:a,onMarkup:o}){let{slots:s}=e_(),c=Y(t,e=>e.frames[n.id]),l=ij(e.id,n.kind===`screen`||n.kind===`url`?n:void 0,r),u=n.kind===`screen`||n.kind===`url`,d=()=>fO(document.querySelector(`[data-item="${CSS.escape(n.id)}"] iframe`)),f=c?.errors??[];return(0,R.jsxs)(Kf.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,duration:.26,bounce:.12},className:`relative flex w-fit max-w-full min-w-0 flex-col`,children:[(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-5 bottom-full flex justify-center`,children:(0,R.jsx)(ed,{children:u&&a?(0,R.jsx)(Kf.div,{initial:{y:`100%`,opacity:0},animate:{y:0,opacity:.9},exit:{y:`100%`,opacity:0},transition:{type:`spring`,duration:.28,bounce:.15},className:`flex h-[22px] min-w-0 items-center rounded-t-[7px] border border-b-0 border-rule bg-surface/80 px-3 text-[11.5px] whitespace-nowrap text-muted backdrop-blur-md`,children:(0,R.jsx)(`span`,{className:`truncate`,children:`Click an element to inspect it`})},`inspect`):null})}),(0,R.jsxs)(`div`,{className:`pointer-events-auto relative flex max-w-full flex-col overflow-hidden rounded-[10px] border border-rule bg-surface shadow-pop`,children:[f.length?(0,R.jsxs)(`div`,{className:`flex max-h-40 items-start gap-2 overflow-y-auto border-b border-rule bg-danger-soft px-3.5 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px`}),(0,R.jsx)(`span`,{className:`min-w-0`,children:f.join(`
|
|
130
|
-
|
|
129
|
+
`).map((e,t)=>(0,R.jsx)(`tspan`,{x:r,dy:t?`${bT}em`:0,children:e||` `},t))})}});function kA({drawing:e,ghosts:t,draft:n}){return(0,R.jsxs)(R.Fragment,{children:[e?.strokes.map(e=>(0,R.jsx)(OA,{stroke:e},e.id)),t?.map(e=>(0,R.jsx)(`g`,{opacity:.8,children:(0,R.jsx)(OA,{stroke:e.stroke,done:!1})},`${e.peer}:${e.stroke.id}`)),n?(0,R.jsx)(OA,{stroke:n,done:!1}):null]})}function AA(e,t,n){let r=e.points,i=(e,r,i,a)=>{let o=i-e,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((t-e)*o+(n-r)*s)/c)):0;return Math.hypot(t-(e+l*o),n-(r+l*s))};if(e.kind===`text`){let r=xT(e),i=Math.max(r.x-t,0,t-(r.x+r.w)),a=Math.max(r.y-n,0,n-(r.y+r.h));return Math.hypot(i,a)}if(e.kind===`pen`){let e=1/0;if(r.length===3)return Math.hypot(t-r[0],n-r[1]);for(let t=0;t+5<r.length;t+=3)e=Math.min(e,i(r[t],r[t+1],r[t+3],r[t+4]));return e}let[a=0,o=0,s=0,c=0]=r;return e.kind===`arrow`?i(a,o,s,c):Math.min(i(a,o,s,o),i(s,o,s,c),i(s,c,a,c),i(a,c,a,o))}var jA=[{tool:`pen`,icon:`edit`,label:`Pen`,key:`P`},{tool:`arrow`,icon:`arrow-up-right`,label:`Arrow`,key:`A`},{tool:`rect`,icon:`square`,label:`Rectangle`,key:`R`},{tool:`text`,icon:`type`,label:`Text`,key:`T`},{tool:`eraser`,icon:`eraser`,label:`Eraser`,key:`E`}],MA={ink:`Ink`,red:`Red`,blue:`Blue`,green:`Green`},NA=e=>e.map(e=>({...e,id:uT()})),PA=e=>Math.round(e*10)/10;function FA(e,t,n=`ink`){let[r,i]=(0,v.useState)(`pen`),[a,o]=(0,v.useState)(n),s=(0,v.useRef)({undo:[],redo:[]}),[,c]=(0,v.useReducer)(e=>e+1,0);if((0,v.useEffect)(()=>{s.current={undo:[],redo:[]},c()},[t]),!e||!t)return null;let l=e=>{e.strokes.length&&(s.current.undo.push(e),s.current.redo=[],c())},u=n=>e.apply(t,{erase:n.map(e=>e.id)}),d=n=>{let r=s.current,i=r[n].pop();if(!i)return;let a=n===`undo`?r.redo:r.undo;if(i.kind===`add`==(n===`undo`))u(i.strokes),a.push(i);else{let n=NA(i.strokes);e.apply(t,{add:n}),a.push({kind:i.kind,strokes:n})}c()};return{client:e,drawingKey:t,tool:r,setTool:i,ink:a,setInk:o,record:l,eraseNow:u,add(n){e.apply(t,{add:n}),l({kind:`add`,strokes:n})},clear(){let n=e.store.get().drawings[t]?.strokes??[];u(n),l({kind:`erase`,strokes:n})},undo:()=>d(`undo`),redo:()=>d(`redo`),canUndo:s.current.undo.length>0,canRedo:s.current.redo.length>0}}function IA(){let e=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{let t=t=>{t.code===`Space`&&(e.current=!0)},n=t=>{t.code===`Space`&&(e.current=!1)};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n)}},[]),e}function LA(e,t){let n=(0,v.useRef)(e);n.current=e,(0,v.useEffect)(()=>{if(!t)return;let e=e=>{let t=n.current;if(!t||Pk(e.target))return;let r=e.metaKey||e.ctrlKey,i=e.key.toLowerCase();if(r&&i===`z`)e.preventDefault(),e.shiftKey?t.redo():t.undo();else if(r&&i===`y`)e.preventDefault(),t.redo();else if(!r&&!e.altKey){let n=jA.find(e=>e.key.toLowerCase()===i);n?t.setTool(n.tool):/^[1-4]$/.test(e.key)&&t.setInk(Qw[Number(e.key)-1])}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function RA({editor:e,end:t,compact:n=!1}){return(0,R.jsxs)(`div`,{"data-ui":!0,className:`flex items-center gap-0.5`,children:[jA.map(t=>(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t.label,` `,(0,R.jsx)(S_,{children:t.key})]}),children:(0,R.jsx)(`button`,{type:`button`,"aria-label":t.label,"aria-pressed":e.tool===t.tool,onClick:()=>e.setTool(t.tool),className:J(`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] border p-0 transition-[color,background-color,scale] duration-100 active:scale-[0.94]`,e.tool===t.tool?`border-action-line bg-action-soft text-action`:`border-transparent bg-transparent text-muted hover:bg-soft2 hover:text-ink2`),children:(0,R.jsx)(X,{name:t.icon,size:16})})},t.tool)),(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),n?(0,R.jsx)(ow,{side:`top`,align:`center`,width:170,trigger:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Ink: ${MA[e.ink]}`,className:`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-0 bg-transparent p-0 hover:bg-soft2`,children:(0,R.jsx)(`span`,{className:`size-[14px] rounded-full`,style:{background:wA[e.ink]}})}),children:Qw.map((t,n)=>(0,R.jsxs)(lw,{active:e.ink===t,onSelect:()=>e.setInk(t),hint:n+1,children:[(0,R.jsx)(`span`,{className:`size-[12px] rounded-full`,style:{background:wA[t]}}),MA[t]]},t))}):null,n?null:Qw.map((t,n)=>(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[MA[t],` `,(0,R.jsx)(S_,{children:n+1})]}),children:(0,R.jsx)(`button`,{type:`button`,"aria-label":MA[t],"aria-pressed":e.ink===t,onClick:()=>e.setInk(t),className:J(`inline-flex h-ctrl w-[26px] shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-0 bg-transparent p-0 hover:bg-soft2`),children:(0,R.jsx)(`span`,{className:J(`size-[14px] rounded-full`,e.ink===t&&`ring-2 ring-action ring-offset-2 ring-offset-surface`),style:{background:wA[t]}})})},t)),(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Undo `,(0,R.jsx)(S_,{children:`⌘Z`})]}),children:(0,R.jsx)(N_,{icon:`undo`,label:`Undo`,disabled:!e.canUndo,onClick:e.undo})}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Redo `,(0,R.jsx)(S_,{children:`⇧⌘Z`})]}),children:(0,R.jsx)(N_,{icon:`redo`,label:`Redo`,disabled:!e.canRedo,onClick:e.redo})}),(0,R.jsx)(kx,{content:`Erase everything`,children:(0,R.jsx)(N_,{icon:`trash`,label:`Erase everything`,onClick:e.clear})}),t]})}function zA({client:e,drawingKey:t,width:n,height:r,editor:i,sizes:a,className:o,camera:s,onPointerDownCapture:c}){let{drawing:l,ghosts:u}=LO(e,t);(0,v.useLayoutEffect)(()=>{let e=d.current;if(!s||!e)return;let t=()=>{let{x:t,y:n,z:r}=s.camera;e.setAttribute(`viewBox`,`${-t/r} ${-n/r} ${(e.clientWidth||1)/r} ${(e.clientHeight||1)/r}`)};t();let n=s.subscribe(t),r=new ResizeObserver(t);return r.observe(e),()=>{n(),r.disconnect()}},[s]);let d=(0,v.useRef)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),g=(0,v.useRef)(null),_=e=>{let t=d.current,n=t?.getScreenCTM();if(!t||!n)return null;let r=new DOMPoint(e.clientX,e.clientY).matrixTransform(n.inverse());return{x:r.x,y:r.y,scale:n.a||1}},y=(0,v.useRef)(null);y.current=m;let b=(0,v.useRef)(i);b.current=i;let x=(0,v.useCallback)(()=>{let e=y.current,t=b.current;y.current=null,h(null),e&&t&&e.value.trim()&&t.add([{id:uT(),kind:`text`,ink:t.ink,size:a.text,points:[PA(e.x),PA(e.y)],text:e.value.replace(/\s+$/,``)}])},[a.text]),S=i?.tool;(0,v.useEffect)(()=>{S!==`text`&&x()},[S,x]),(0,v.useEffect)(()=>x,[x]);let C=n=>{let r=g.current;if(!r?.stroke)return;let i=performance.now();if(!n&&i-r.lastSend<40)return;r.lastSend=i;let a=r.stroke.kind===`pen`?r.sent:0;e.live(t,r.stroke,a),r.sent=r.stroke.points.length},w=(n,r,a)=>{let o=g.current,s=e.store.get().drawings[t]?.strokes??[],c=8/a,l=s.filter(e=>AA(e,n,r)<=c+e.size/2);l.length&&i&&(i.eraseNow(l),o?.erased.push(...l))},T=e=>{if(!i||e.button!==0||c?.(e))return;e.stopPropagation(),e.preventDefault();let t=_(e);if(!t)return;if(m){x();return}d.current?.setPointerCapture(e.pointerId);let n={id:uT(),ink:i.ink},r=null;if(i.tool===`pen`){let i=e.pointerType===`pen`&&e.pressure||.5;r={...n,kind:`pen`,size:a.pen,points:[PA(t.x),PA(t.y),i]}}else(i.tool===`arrow`||i.tool===`rect`)&&(r={...n,kind:i.tool,size:a.line,points:[t.x,t.y,t.x,t.y]});g.current={stroke:r,sent:0,lastSend:0,frame:0,erased:[],startX:t.x,startY:t.y,pointer:e.pointerId},i.tool===`eraser`&&w(t.x,t.y,t.scale),p(r)},E=e=>{let t=g.current;if(!t||t.pointer!==e.pointerId||!i)return;let n=e.nativeEvent.getCoalescedEvents?.()??[e.nativeEvent];for(let r of n.length?n:[e.nativeEvent]){let e=_(r);if(e){if(i.tool===`eraser`)w(e.x,e.y,e.scale);else if(t.stroke?.kind===`pen`){let n=r.pointerType===`pen`&&r.pressure||.5;t.stroke.points.push(PA(e.x),PA(e.y),n)}else t.stroke&&(t.stroke.points=[t.stroke.points[0],t.stroke.points[1],e.x,e.y])}}t.stroke&&!t.frame&&(t.frame=requestAnimationFrame(()=>{t.frame=0,t.stroke&&p({...t.stroke,points:[...t.stroke.points]})})),C(!1)},D=n=>{let r=g.current;if(!r||r.pointer!==n.pointerId||!i)return;g.current=null,cancelAnimationFrame(r.frame),p(null);let o=_(n);if(i.tool===`eraser`){i.record({kind:`erase`,strokes:r.erased});return}if(i.tool===`text`){o&&Math.hypot(o.x-r.startX,o.y-r.startY)*o.scale<6&&h({x:r.startX,y:r.startY-a.text*.6,value:``});return}let s=r.stroke;if(s){if(r.sent&&e.liveEnd(t,s.id),s.kind!==`pen`){let[e=0,t=0,n=0,r=0]=s.points;if(Math.hypot(n-e,r-t)*(o?.scale??1)<4)return;s.points=s.points.map(PA)}i.add([s])}},O=n=>{let r=g.current;r&&r.pointer===n.pointerId&&(g.current=null,cancelAnimationFrame(r.frame),p(null),r.stroke&&r.sent&&e.liveEnd(t,r.stroke.id),r.erased.length&&i?.record({kind:`erase`,strokes:r.erased}))},k=i?i.tool===`text`?`text`:i.tool===`eraser`?`cell`:`crosshair`:void 0,A=(0,v.useMemo)(()=>m?xT({id:`draft`,kind:`text`,ink:`ink`,size:a.text,points:[m.x,m.y],text:m.value}):null,[m,a.text]);return(0,R.jsxs)(`svg`,{ref:d,viewBox:s?void 0:`0 0 ${n??0} ${r??0}`,preserveAspectRatio:s?`xMinYMin meet`:`xMidYMid meet`,role:`img`,"aria-label":i?`Drawing: draw here`:`Drawing`,className:J(`block touch-none select-none`,o),style:{cursor:k,pointerEvents:i?`auto`:`none`},onPointerDown:T,onPointerMove:E,onPointerUp:D,onPointerCancel:O,children:[(0,R.jsx)(kA,{drawing:l,ghosts:u,draft:f}),m&&A&&i?(0,R.jsx)(`foreignObject`,{x:m.x,y:m.y,width:Math.max(A.w+a.text*2,a.text*8),height:A.h+8,children:(0,R.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Text`,value:m.value,onChange:e=>h({...m,value:e.target.value}),onBlur:x,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`&&!e.shiftKey||e.key===`Escape`)&&(e.preventDefault(),x())},spellCheck:!1,className:`block h-full w-full resize-none overflow-hidden border-0 bg-transparent p-0 outline-none`,style:{font:`500 ${a.text}px/1.25 var(--font-sans)`,color:wA[i.ink],caretColor:wA[i.ink],whiteSpace:`pre`}})}):null]})}var BA={pen:5,line:3.5,text:28},VA=56,HA=(e,t)=>`foss-design.board.${e}.${t}`,UA=(e,t)=>`foss-design.board-camera.${e}.${t}`;function WA(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function GA({client:e,canvasId:t,page:n}){let r=oT(n.id),i=Y(e.store,e=>e.ready),a=Y(e.store,e=>e.canDraw),{drawing:o}=LO(e,r),s=HA(t,n.id),[c,l]=(0,v.useState)(()=>WA(s));if((0,v.useEffect)(()=>{try{c?sessionStorage.setItem(s,`1`):sessionStorage.removeItem(s)}catch{}},[c,s]),!i||!a&&yT(o))return null;let u=`board:${t}:${n.id}`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ed,{initial:!1,children:c?(0,R.jsx)(qA,{layoutId:u,client:e,canvasId:t,page:n,canDraw:a,onClose:()=>l(!1)},`panel`):null}),c?null:(0,R.jsx)(KA,{layoutId:u,client:e,page:n,onOpen:()=>l(!0)})]})}function KA({layoutId:e,client:t,page:n,onOpen:r}){let{drawing:i,ghosts:a}=LO(t,oT(n.id)),o=(0,v.useMemo)(()=>wT([...i?.strokes??[],...a.map(e=>e.stroke)]),[i,a]);return(0,R.jsx)(kx,{content:`Idea board`,side:`left`,children:(0,R.jsx)(Kf.button,{type:`button`,"data-ui":!0,layoutId:e,"aria-label":`Open the idea board`,onClick:r,style:{borderRadius:10},transition:{type:`spring`,duration:.34,bounce:.12},className:`absolute right-4 bottom-[76px] z-20 flex size-[92px] cursor-pointer flex-col items-center justify-center gap-1 overflow-hidden border border-rule bg-surface p-0 text-muted shadow-pop hover:text-ink2`,children:o?(0,R.jsx)(`svg`,{viewBox:`${o.x-VA} ${o.y-VA} ${o.w+112} ${o.h+112}`,className:`h-full w-full p-1.5`,"aria-hidden":`true`,children:(0,R.jsx)(kA,{drawing:i,ghosts:a})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{name:`lightbulb`,size:20}),(0,R.jsx)(`span`,{className:`text-[11.5px] font-medium`,children:`Ideas`})]})})})}function qA({layoutId:e,client:t,canvasId:n,page:r,canDraw:i,onClose:a}){let o=oT(r.id),s=FA(i?t:null,o),c=Y(t.store,e=>e.online),l=(0,v.useMemo)(()=>new HO,[]),u=(0,v.useRef)(null),d=(0,v.useCallback)((e=!0)=>{let n=u.current;if(!n)return;let r=wT(t.store.get().drawings[o]?.strokes??[]),i=r?WO(r,n.clientWidth,n.clientHeight,VA,1,l.minZoom):{x:VA,y:VA,z:1};e?l.animateTo(i):l.set(i)},[l,t,o]),f=UA(n,r.id);return(0,v.useLayoutEffect)(()=>{let e=UO(f);e?l.set(e):d(!1);let t,n=l.subscribe(e=>{clearTimeout(t),t=setTimeout(()=>{try{sessionStorage.setItem(f,JSON.stringify(e))}catch{}},250)});return()=>{n(),clearTimeout(t)}},[l,f,d]),LA(s,!0),(0,v.useEffect)(()=>{let e=e=>{Pk(e.target)||(e.key===`Escape`?a():e.shiftKey&&e.code===`Digit1`&&d())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,d]),(0,R.jsx)(Kf.div,{"data-ui":!0,role:`dialog`,"aria-label":`Idea board`,layoutId:e,style:{borderRadius:12},transition:{type:`spring`,duration:.34,bounce:.12},className:`absolute inset-4 z-30 flex flex-col overflow-hidden border border-rule bg-surface shadow-pop`,children:(0,R.jsxs)(Kf.div,{initial:{opacity:0},animate:{opacity:1,transition:{delay:.12,duration:.16}},exit:{opacity:0,transition:{duration:.08}},className:`flex min-h-0 grow flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex h-[52px] shrink-0 items-center gap-2 border-b border-rule pr-2 pl-4`,children:[(0,R.jsx)(X,{name:`lightbulb`,size:16,className:`text-muted`}),(0,R.jsx)(`span`,{className:`text-[14px] font-semibold`,children:`Ideas`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[13px] text-muted`,children:r.title}),c?null:(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`· Reconnecting…`}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[s?(0,R.jsx)(RA,{editor:s}):(0,R.jsx)(`span`,{className:`px-2 text-[12.5px] text-muted`,children:`View only`}),(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Show all `,(0,R.jsx)(S_,{children:`⇧1`})]}),children:(0,R.jsx)(N_,{icon:`fit`,label:`Show all of the board`,onClick:()=>d()})}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Close `,(0,R.jsx)(S_,{children:`Esc`})]}),children:(0,R.jsx)(N_,{icon:`minimize`,label:`Close the idea board`,onClick:a})})]})]}),(0,R.jsx)(JA,{sheetRef:u,client:t,drawingKey:o,editor:s,camera:l})]})})}function JA({sheetRef:e,client:t,drawingKey:n,editor:r,camera:i}){let a=(0,v.useRef)(null),o=IA(),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(!1);(0,v.useLayoutEffect)(()=>{let e=qO(a.current);return e(i.camera),i.subscribe(e)},[i]),(0,v.useEffect)(()=>{let t=e.current,n=e=>{e.preventDefault();let n=t.getBoundingClientRect(),r=e.deltaMode===1?16:e.deltaMode===2?n.height:1;if(e.ctrlKey||e.metaKey){let t=e.deltaY*r,a=Math.abs(t)<40?.012:.0025;i.zoomAt(e.clientX-n.left,e.clientY-n.top,Math.exp(-t*a))}else i.panBy(-e.deltaX*r,-e.deltaY*r)};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[i,e]);let u=e=>e.button===1||o.current===!0||!r&&e.button===0;return(0,R.jsxs)(`div`,{ref:e,className:J(`relative min-h-0 grow touch-none overflow-hidden bg-surface`,c&&`cursor-grabbing`),onPointerDown:e=>{u(e)&&(e.preventDefault(),i.interrupt(),e.currentTarget.setPointerCapture(e.pointerId),s.current={id:e.pointerId,x:e.clientX,y:e.clientY},l(!0))},onPointerMove:e=>{let t=s.current;t&&t.id===e.pointerId&&(i.panBy(e.clientX-t.x,e.clientY-t.y),t.x=e.clientX,t.y=e.clientY)},onPointerUp:e=>{s.current?.id===e.pointerId&&(s.current=null,l(!1))},onPointerCancel:()=>{s.current=null,l(!1)},children:[(0,R.jsx)(`div`,{ref:a,className:`canvas-grid`}),(0,R.jsx)(zA,{client:t,drawingKey:n,editor:r,sizes:BA,camera:i,className:`absolute inset-0 h-full w-full`,onPointerDownCapture:u})]})}function YA({items:e,value:t,onChange:n,label:r,stretch:i,size:a=`ctrl`}){let o=(0,v.useId)();return(0,R.jsx)(`div`,{role:`group`,"aria-label":r,className:J(`shrink-0 items-center gap-0.5 rounded-[6px] bg-track p-[3px]`,a===`ctrl`?`h-ctrl`:`h-7`,i?`flex`:`inline-flex`),children:e.map(e=>{let r=e.value===t;return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":r,title:e.title,onClick:()=>n(e.value),className:J(`relative flex h-full cursor-pointer items-center justify-center whitespace-nowrap rounded-[4px] border-0 bg-transparent font-medium transition-colors`,a===`ctrl`?`px-2.5 text-ctrl`:`px-2 text-[12.5px]`,i&&`flex-1`,r?`text-ink`:`text-muted hover:text-ink2`),children:[r?(0,R.jsx)(Kf.span,{layoutId:o,className:`absolute inset-0 z-0 rounded-[4px] bg-surface shadow-[0_1px_2px_rgba(0,0,0,0.10)]`,transition:{type:`spring`,stiffness:520,damping:42}}):null,(0,R.jsx)(`span`,{className:`relative z-[1] flex items-center gap-1.5`,children:e.label})]},e.value)})})}var XA=new WeakMap,ZA=2200;function QA(e,t=`var(--action)`){clearTimeout(XA.get(e)),e.classList.remove(`target-ripple`),e.offsetWidth,e.style.setProperty(`--ripple-color`,t),e.classList.add(`target-ripple`),XA.set(e,setTimeout(()=>{e.classList.remove(`target-ripple`),e.style.removeProperty(`--ripple-color`)},ZA))}var $A=5500,ej=350,tj=(e,t)=>e>=window.innerWidth/2&&t<=window.innerHeight/2;function nj({frame:e,note:t,badge:n,children:r}){let[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(0),g=(0,v.useRef)(null),_=(0,v.useRef)(void 0),y=(0,v.useRef)(void 0),b=e=>{a(!0),clearTimeout(_.current),_.current=setTimeout(()=>a(!1),e)},x=(e,t)=>{let n=e>=0&&tj(e,t);clearTimeout(y.current),n?s(!0):y.current=setTimeout(()=>s(!1),ej)};(0,v.useEffect)(()=>{if(!e)return;let t=()=>{cO(e,{type:`pointer`}),b($A),h(e=>e+1)};e.addEventListener(`load`,t);let n=sO(e,t=>{if(t.type!==`pointer`)return;if(d(!0),t.x<0)return x(-1,-1);let n=e.getBoundingClientRect(),r=n.left+t.x,i=n.top+t.y;t.down&&tj(r,i)?b($A):x(r,i)});return()=>{e.removeEventListener(`load`,t),n()}},[e]),(0,v.useEffect)(()=>{let e=e=>x(e.clientX,e.clientY),t=e=>{e.relatedTarget||x(-1,-1)};return window.addEventListener(`pointermove`,e,{passive:!0}),document.addEventListener(`pointerout`,t),()=>{window.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerout`,t),clearTimeout(_.current),clearTimeout(y.current)}},[]),(0,v.useEffect)(()=>{if(u)return;let e=document.documentElement,t=()=>p(!0),n=()=>p(!1);return e.addEventListener(`pointerenter`,t),e.addEventListener(`pointerleave`,n),()=>{e.removeEventListener(`pointerenter`,t),e.removeEventListener(`pointerleave`,n)}},[u]);let S=i||o||c||!u&&f;return(0,v.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>g.current&&QA(g.current),200);return()=>clearTimeout(e)},[m]),(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsx)(Kf.button,{type:`button`,"aria-label":`Show the page's notice`,initial:!1,animate:S?{opacity:0,scale:.8}:{opacity:1,scale:1},transition:{duration:.2,delay:S?0:.25},onClick:()=>b($A),tabIndex:S?-1:0,className:J(`absolute top-3 right-3 inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-rule bg-surface/90 px-2.5 text-[11.5px] text-muted shadow-[0_1px_3px_rgb(0_0_0/0.08)] backdrop-blur-sm hover:text-ink2`,S&&`pointer-events-none`),children:n}):null,(0,R.jsx)(Kf.div,{ref:g,initial:{opacity:0,scale:.94,y:-4},animate:S?{opacity:1,scale:1,y:0}:{opacity:0,scale:.97,y:-2},transition:S?{type:`spring`,stiffness:420,damping:30}:{duration:.45,ease:`easeOut`},style:{transformOrigin:`top right`},className:J(`absolute top-3 right-3 flex max-w-[calc(100%-24px)] flex-col items-end rounded-[8px]`,!S&&`pointer-events-none`),"aria-hidden":!S||void 0,onFocus:()=>l(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},children:(0,R.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center justify-end gap-x-2 gap-y-1 rounded-[8px] border border-rule bg-surface p-1 shadow-pop`,children:[t?(0,R.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-[1_1_auto] items-center gap-1.5 pl-2 text-[12px] leading-snug text-muted last:pr-2`,children:[(0,R.jsx)(X,{name:`info`,size:13,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0`,children:t})]}):null,r?(0,R.jsx)(`div`,{className:`flex items-center gap-1`,children:r}):null]})})]})}var rj=(e,t,n)=>`/c/${encodeURIComponent(e)}/full/${encodeURIComponent(t)}?theme=${n}`;function ij(e,t,n){let{frameSandbox:r}=e_(),{base:i}=le();return t?t.kind===`url`?t.url:hO(r?`${i}${rj(e,t.id,t.theme??n)}`:mO(t.url,t.theme??n)):null}function aj({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=i_(e),[,a]=I(),{frameSandbox:o,frameAllow:s,slots:c}=e_(),l=b_(),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(null),p=(0,v.useCallback)(e=>{u.current=e,f(e)},[]),m=new URLSearchParams(window.location.search).get(`theme`),h=n?n.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))):[],g=h.find(e=>e.id===t),_=(g?.kind===`screen`?g.theme:void 0)??(m===`light`||m===`dark`?m:n?.theme??l),y=g?g.kind===`screen`?mO(g.url,_):g.url:``,b=`/c/${encodeURIComponent(e)}`;return(0,v.useEffect)(()=>{g&&(document.title=`${g.title} · ${n?.title??``}`)},[g,n?.title]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a(b)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,b]),(0,v.useEffect)(()=>{let r=u.current;if(r&&g?.kind===`screen`)return sO(r,r=>{if(r.type===`keydown`&&r.code===`Escape`)a(b);else if(r.type===`go`){let t=r.target.includes(`/`)?r.target.split(`/`)[1]:r.target;h.some(e=>e.id===t)&&a(rj(e,t,_),{replace:!0})}else r.type===`link`&&n&&gO(r,n,t=>a(rj(e,t,_),{replace:!0}),t)})},[y,g?.kind]),r?(0,R.jsx)(zO,{title:`Canvas not found`,text:r.message}):i||!n?(0,R.jsx)(`div`,{className:`h-dvh bg-surface`}):g?(0,R.jsxs)(`div`,{className:`fixed inset-0 bg-surface`,children:[(0,R.jsx)(`iframe`,{ref:p,src:y,title:g.title,allow:s,sandbox:o,className:`block h-full w-full border-0`,style:{colorScheme:_},onLoad:()=>g.kind===`screen`&&dO(u.current,_)},`${g.id}:${g.kind===`screen`?g.rev:g.url}`),(0,R.jsxs)(nj,{frame:d,note:c.fullPlate?.note,badge:c.fullPlate?.badge,children:[(0,R.jsxs)(ye,{href:b,className:`flex h-8 min-w-0 items-center gap-2 rounded-[6px] px-2 text-[12.5px] text-ink2 no-underline hover:bg-soft2 hover:text-ink`,children:[(0,R.jsx)(X,{name:`x`,size:14}),(0,R.jsxs)(`span`,{className:`truncate`,children:[`Back to `,n.title]}),(0,R.jsx)(S_,{children:`esc`})]}),c.fullPlate?.actions]})]}):(0,R.jsx)(zO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`})}function oj(e){return e.kind===`note`?`note`:e.kind===`image`?`image`:e.kind===`url`?`globe`:e.frame.width<600?`smartphone`:e.frame.width<1100?`tablet`:`monitor`}function sj(e,t){return`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(t.id)}`}function cj({canvas:e,page:t,store:n,onPick:r}){let i=Y(n,e=>e.selected),a=Y(n,e=>e.frames);return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[264px] shrink-0 flex-col overflow-hidden border-r border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-rule px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`truncate text-[14px] font-semibold`,children:e.title}),e.description?(0,R.jsx)(`div`,{className:`line-clamp-3 text-[12.5px] leading-[1.45] text-muted`,children:e.description}):null]}),(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto pb-4`,children:[e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:`Pages`}),(0,R.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2`,children:e.pages.map(n=>{let r=n.sections.reduce((e,t)=>e+t.items.filter(e=>e.kind===`screen`||e.kind===`url`).length,0);return(0,R.jsxs)(ye,{href:sj(e,n),className:J(`flex h-8 items-center gap-2 rounded-[6px] px-2.5 text-[13.5px] no-underline transition-colors focus-visible:outline-offset-[-2px]`,n.id===t.id?`bg-soft2 font-medium text-ink`:`text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:n.title}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted tabular`,children:r})]},n.id)})})]}):null,(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.pages.length>1?t.title:`Layers`}),(0,R.jsx)(`div`,{className:`flex flex-col px-2`,children:t.sections.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title?(0,R.jsxs)(`div`,{className:`flex h-7 items-center gap-2 px-2.5 pt-1 text-[12px] font-medium text-ink2`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.title}),(0,R.jsx)(R_,{value:e.items.length})]}):null,e.items.map(t=>{let n=(a[t.id]?.errors.length??0)>0||t.kind===`screen`&&t.missing;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.id),className:J(`flex h-8 w-full cursor-pointer items-center gap-2 rounded-[6px] border-0 px-2.5 text-left text-[13px] transition-colors focus-visible:outline-offset-[-2px]`,e.title&&`pl-4`,i===t.id?`bg-action-soft text-ink`:`bg-transparent text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:oj(t),size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:t.title||(t.kind===`note`?`Note`:t.id)}),n?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`}):null]},t.id)})]},e.id))})]})]})}function lj({canvas:e,page:t,theme:n,onTheme:r,sidebar:i,onSidebar:a,onPlay:o,canPlay:s,inspect:c,onInspect:l}){let[,u]=I(),{slots:d,scope:f}=e_(),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=vw(p,m,[e.title,t?.title,e.pages.length]);return(0,R.jsxs)(_w,{value:h,children:[(0,R.jsxs)(gw,{children:[d.barStart,d.brand?d.brand:f?(0,R.jsx)(mw,{}):(0,R.jsx)(kx,{content:`All canvases`,children:(0,R.jsx)(ye,{href:`/`,className:`flex items-center`,"aria-label":`All canvases`,children:(0,R.jsx)(mw,{})})}),(0,R.jsx)(N_,{icon:`panel-left`,label:i?`Hide sidebar (⌘\\)`:`Show sidebar (⌘\\)`,onClick:()=>a(!i)}),(0,R.jsxs)(`div`,{ref:p,className:`flex min-w-0 items-center gap-1.5 text-[14px]`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate font-semibold`,children:e.title}),t&&e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{name:`chevron-right`,size:14,className:`shrink-0 text-muted`}),(0,R.jsxs)(ow,{width:240,trigger:(0,R.jsxs)(`button`,{type:`button`,className:`flex h-ctrl cursor-pointer items-center gap-1 rounded-[6px] border-0 bg-transparent px-2 text-[14px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate`,children:t.title}),(0,R.jsx)(X,{name:`chevron-down`,size:14,className:`text-muted`})]}),children:[(0,R.jsx)(dw,{children:`Pages`}),e.pages.map(n=>(0,R.jsxs)(lw,{active:n.id===t.id,onSelect:()=>u(sj(e,n)),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),n.title]},n.id))]})]}):null]}),(0,R.jsxs)(`div`,{ref:m,className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(YA,{label:`Screen theme`,value:n,onChange:r,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light screens`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark screens`}]}),(0,R.jsx)(pj,{on:c,onChange:l,compact:h}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`P`})]}),children:(0,R.jsx)(A_,{kind:`secondary`,icon:`play`,onClick:o,disabled:!s,"aria-label":`Play`,className:h?`w-ctrl px-0`:void 0,children:h?null:`Play`})}),(0,R.jsx)(Mx,{width:180,label:`Search`,compact:h}),(0,R.jsx)(pw,{}),d.barEnd]})]}),d.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:d.belowBar}):null]})}function uj({children:e}){return(0,R.jsx)(`div`,{"data-ui":!0,className:`pointer-events-none absolute inset-x-4 bottom-5 z-20 grid grid-cols-[minmax(var(--dock-left,0px),1fr)_minmax(0,auto)_minmax(var(--dock-right,0px),1fr)]`,children:(0,R.jsx)(`div`,{className:`col-start-2 flex min-w-0 justify-center`,children:e})})}function dj({canvas:e,store:t,layoutItems:n,theme:r,onPlay:i,inspect:a,onMarkup:o}){let s=Y(t,e=>e.selected),c=n.find(e=>e.id===s);return(0,R.jsx)(uj,{children:(0,R.jsx)(ed,{children:c?(0,R.jsx)(fj,{canvas:e,store:t,item:c,theme:r,onPlay:i,inspect:a,onMarkup:o},`bar`):null})})}function fj({canvas:e,store:t,item:n,theme:r,onPlay:i,inspect:a,onMarkup:o}){let{slots:s}=e_(),c=Y(t,e=>e.frames[n.id]),l=ij(e.id,n.kind===`screen`||n.kind===`url`?n:void 0,r),u=n.kind===`screen`||n.kind===`url`,d=()=>fO(document.querySelector(`[data-item="${CSS.escape(n.id)}"] iframe`)),f=c?.errors??[];return(0,R.jsxs)(Kf.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,duration:.26,bounce:.12},className:`relative flex w-fit max-w-full min-w-0 flex-col`,children:[(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-5 bottom-full flex flex-col items-center`,children:(0,R.jsxs)(ed,{initial:!1,children:[u&&a?(0,R.jsx)(Kf.div,{layout:`position`,initial:{y:`100%`,opacity:0},animate:{y:0,opacity:.9},exit:{y:`100%`,opacity:0},transition:{type:`spring`,duration:.28,bounce:.15},className:`flex h-[22px] max-w-full min-w-0 items-center rounded-t-[7px] border border-b-0 border-rule bg-surface/80 px-3 text-[11.5px] whitespace-nowrap text-muted backdrop-blur-md`,children:(0,R.jsx)(`span`,{className:`truncate`,children:`Click an element to inspect it`})},`inspect`):null,f.length?(0,R.jsx)(Kf.div,{layout:`position`,initial:{y:`100%`,opacity:0},animate:{y:0,opacity:1},exit:{y:`100%`,opacity:0},transition:{type:`spring`,duration:.28,bounce:.15},className:`pointer-events-auto flex max-w-full min-w-0`,children:(0,R.jsx)(kx,{content:(0,R.jsx)(`span`,{className:`block max-h-60 max-w-[560px] overflow-y-auto font-mono text-[11.5px] whitespace-pre-wrap`,children:f.join(`
|
|
130
|
+
|
|
131
|
+
`)}),children:(0,R.jsxs)(`div`,{className:`flex h-[22px] min-w-0 items-center gap-1.5 rounded-t-[7px] border border-b-0 border-danger/25 bg-danger-soft px-2.5 font-mono text-[11px] whitespace-nowrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:12,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:f[0].split(`
|
|
132
|
+
`)[0]}),f.length>1?(0,R.jsxs)(`span`,{className:`shrink-0 opacity-70`,children:[`+`,f.length-1]}):null]})})},`error`):null]})}),(0,R.jsx)(`div`,{className:`pointer-events-auto relative flex max-w-full flex-col overflow-hidden rounded-[10px] border border-rule bg-surface shadow-pop`,children:(0,R.jsxs)(`div`,{className:`flex h-[44px] items-center gap-1 pr-1.5 pl-3.5 [&>:not(:first-child)]:shrink-0`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate pr-2 text-[13.5px] font-medium`,children:n.title||n.id}),u?(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`↵`})]}),children:(0,R.jsx)(N_,{icon:`play`,label:`Play`,onClick:()=>i(n.id)})}):null,l?(0,R.jsx)(kx,{content:`Open in a new tab`,children:(0,R.jsx)(`a`,{href:l,target:`_blank`,rel:`noreferrer`,"aria-label":`Open in a new tab`,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,children:(0,R.jsx)(X,{name:`external`,size:16})})}):null,u?(0,R.jsx)(kx,{content:`Reload`,children:(0,R.jsx)(N_,{icon:`refresh`,label:`Reload`,onClick:d})}):null,n.kind===`screen`&&o?(0,R.jsx)(kx,{content:`Mark up`,children:(0,R.jsx)(N_,{icon:`edit`,label:`Mark up`,onClick:()=>o(n.id)})}):null,n.kind===`screen`?(0,R.jsx)(kx,{content:`Copy source path`,children:(0,R.jsx)(N_,{icon:`copy`,label:`Copy source path`,onClick:()=>void FT(n.file,`Path copied`)})}):null,s.selectionActions?.(e.id,n),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Zoom to `,(0,R.jsx)(S_,{children:`⇧2`})]}),children:(0,R.jsx)(N_,{icon:`fit`,label:`Zoom to`,onClick:()=>window.dispatchEvent(new CustomEvent(`design:focus`,{detail:{canvas:e.id,item:n.id}}))})})]})})]})}function pj({on:e,onChange:t,compact:n=!1}){return(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Inspect elements `,(0,R.jsx)(S_,{children:`I`})]}),children:(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e,"aria-label":`Inspect elements`,onClick:()=>t(!e),className:J(`inline-flex h-ctrl shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-[6px] border text-ctrl font-medium`,n?`w-ctrl px-0`:`px-ctrl`,e?`border-action-line bg-action-soft text-action`:`border-rule-strong bg-surface text-ink hover:bg-soft`),children:[(0,R.jsx)(X,{name:`pointer`,size:15}),n?null:`Inspect`]})})}var mj={pen:4,line:3,text:20},hj=600;function gj({layout:e,client:t,store:n,editor:r}){let i=Y(n,e=>e.markup),a=Y(t.store,e=>[...new Set([...Object.keys(e.drawings).filter(t=>e.drawings[t].strokes.length),...Object.keys(e.ghosts)])].sort().join(`
|
|
131
133
|
`)),o=(0,v.useMemo)(()=>new Set(a.split(`
|
|
132
134
|
`)),[a]),s=IA();return(0,R.jsx)(R.Fragment,{children:e.items.filter(e=>e.item.kind===`screen`&&(e.item.id===i||o.has(sT(e.item.id)))).map(e=>(0,R.jsx)(_j,{placed:e,client:t,editor:e.item.id===i?r:null,space:s},e.item.id))})}var _j=(0,v.memo)(function({placed:e,client:t,editor:n,space:r}){let{item:i,x:a,y:o,w:s,h:c}=e;return(0,R.jsx)(`div`,{className:`absolute`,style:{left:a,top:o,width:s,height:c,pointerEvents:n?`auto`:`none`},children:(0,R.jsx)(zA,{client:t,drawingKey:sT(i.id),width:s,height:c,editor:n,sizes:mj,className:`h-full w-full overflow-visible`,onPointerDownCapture:e=>e.button===1||r.current===!0})})});function vj({item:e,editor:t,onDone:n,room:r}){return(0,R.jsx)(uj,{children:(0,R.jsxs)(Kf.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{type:`spring`,duration:.26,bounce:.12},className:`pointer-events-auto flex h-[46px] max-w-full min-w-0 items-center gap-1 rounded-[10px] border border-rule bg-surface pr-1.5 pl-3.5 shadow-pop`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 truncate pr-2 text-[13.5px]`,children:[(0,R.jsx)(`span`,{className:`text-muted`,children:`Marking up`}),` `,(0,R.jsx)(`span`,{className:`font-medium`,children:e.title||e.id})]}),(0,R.jsx)(RA,{editor:t,compact:r<hj,end:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`mx-1 h-5 w-px bg-rule`}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Done `,(0,R.jsx)(S_,{children:`Esc`})]}),children:(0,R.jsx)(A_,{kind:`secondary`,onClick:n,children:`Done`})})]})})]})})}var yj=new URLSearchParams(window.location.search),bj=yj.has(`capture`),xj=(e,t)=>`foss-design.camera.${e}.${t}`;function Sj(e){let t=b_(),n=yj.get(`theme`),[r,i]=(0,v.useState)(n===`dark`||n===`light`?n:null);return[r??e?.theme??t,i]}function Cj({canvasId:e,pageId:t}){let{data:n,error:r,isLoading:i}=i_(e);if(r)return(0,R.jsx)(zO,{title:`Canvas not found`,text:r.message});if(i||!n)return(0,R.jsx)(`div`,{className:`canvas-dots grow`});let a=t??yj.get(`page`)??void 0,o=n.pages.find(e=>e.id===a)??n.pages[0];return(0,R.jsx)(wj,{canvas:n,page:o},`${n.id}/${o?.id??``}`)}function wj({canvas:e,page:t}){let[,n]=I(),r=(0,v.useMemo)(()=>YO(),[]),i=(0,v.useMemo)(()=>new HO,[]),a=(0,v.useRef)(null),[o,s]=Sj(e),[c,l]=(0,v.useState)(()=>!bj&&window.innerWidth>900),[u,d]=(0,v.useState)(!1),f=Y(r,e=>e.sizes),p=(0,v.useMemo)(()=>t?mk(t,f):{items:[],sections:[],bounds:{x:0,y:0,w:0,h:0}},[t,f]),m=Aj(Y(r,e=>e.frameEls),p),h=vO(m),g=u||h;(0,v.useEffect)(()=>{r.set(e=>e.inspecting===g?e:{...e,inspecting:g,active:null})},[g,r]);let _=_O(m,g,{onEscape:()=>d(!1)}),y=!!_.info;(0,v.useEffect)(()=>{y&&d(!0)},[y]);let b=_.info;(0,v.useEffect)(()=>{let e=_.frame;if(!e||!b)return;let t=Object.entries(r.get().frameEls).find(([,t])=>t===e)?.[0];t&&r.get().selected!==t&&r.set(e=>({...e,selected:t}))},[_.frame,b,r]);let x=(0,v.useMemo)(()=>hk(p),[p]),S=xj(e.id,t?.id??``),C=(0,v.useRef)(null),w=(0,v.useRef)(null),T=(0,v.useRef)(null),E=kj(C,w,T,e.issues.length>0),D=FO(e.id,!bj),O=Y(D?.store??RO,e=>e.ready&&e.canDraw),k=Y(r,e=>e.markup),A=k?p.items.find(e=>e.item.id===k)?.item:void 0,j=FA(A&&O?D:null,k?sT(k):null,`red`);LA(j,!!j);let M=(0,v.useCallback)(()=>r.set(e=>e.markup?{...e,markup:null}:e),[r]);(0,v.useEffect)(()=>{k&&(!A||!O||g)&&M()},[k,A,O,g,M]);let ee=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(ee.current||!p.bounds.w)return;ee.current=!0;let t=u_(e.id),n=bj?null:UO(S);t?(r.set(e=>({...e,selected:t})),requestAnimationFrame(()=>a.current?.fitItem(t,!1))):n&&n.z>=i.minZoom?i.set(n):requestAnimationFrame(()=>bj?a.current?.fitAll(!1):a.current?.openView())},[p,i,S,e.id,r]),(0,v.useEffect)(()=>{if(bj)return;let e,t=i.subscribe(t=>{clearTimeout(e),e=setTimeout(()=>sessionStorage.setItem(S,JSON.stringify(t)),250)});return()=>{t(),clearTimeout(e)}},[i,S]);let N=(0,v.useCallback)(e=>{let t=e?p.items.find(t=>t.item.id===e)?.item:void 0;r.set(e=>({...e,selected:t?t.id:null,active:t&&dk(t)?t.id:null,hovered:null,markup:t&&t.id===e.markup?e.markup:null}))},[p,r]),P=(0,v.useCallback)(e=>{d(!1),r.set(t=>({...t,selected:e,active:null,markup:e,hovered:null})),a.current?.fitItem(e)},[r]),te=(0,v.useCallback)(e=>{N(e),a.current?.fitItem(e)},[N]),ne=(0,v.useCallback)(r=>n(`/c/${encodeURIComponent(e.id)}/play/${encodeURIComponent(r)}${t?`?page=${encodeURIComponent(t.id)}`:``}`),[e.id,t,n]),F=(0,v.useCallback)(()=>{let e=r.get().selected,t=e&&x.find(t=>t.item.id===e)||x[0];t&&ne(t.item.id)},[r,x,ne]);(0,v.useEffect)(()=>{let t=t=>{let n=t.detail;n.canvas===e.id&&p.items.some(e=>e.item.id===n.item)&&(u_(e.id),te(n.item))};return window.addEventListener(`design:focus`,t),()=>window.removeEventListener(`design:focus`,t)},[e.id,p,te]);let re=(0,v.useMemo)(()=>({onGo(r,i){let[a,o]=i.includes(`/`)?i.split(`/`):[null,i],s=a?e.pages.filter(e=>e.id===a):[t,...e.pages.filter(e=>e!==t)];for(let r of s)if(r&&r.sections.some(e=>e.items.some(e=>e.id===o))){r===t?te(o):(n(sj(e,r)),window.dispatchEvent(new CustomEvent(`design:focus`,{detail:{canvas:e.id,item:o}})));return}console.warn(`[design] go("${i}"): no such screen`)},onLink(t,n){gO(n,e,e=>this.onGo(t,e),t)},onWheel(e,t){let n=e.closest(`.canvas-root`);if(!n)return;let r=n.getBoundingClientRect(),a=e.getBoundingClientRect(),o=i.camera.z;if(t.zoom){let e=Math.abs(t.deltaY)<40?.012:.0025;i.zoomAt(a.left-r.left+t.x*o,a.top-r.top+t.y*o,Math.exp(-t.deltaY*e))}else i.panBy(-t.deltaX,-t.deltaY)},onEscape(){r.set(e=>({...e,active:null,selected:null}))}}),[e,t,i,r,te,n]);return(0,v.useEffect)(()=>{if(!bj)return;let e=Date.now(),t=setInterval(()=>{let n=r.get().frames;(x.every(e=>n[e.item.id]?.ready||e.item.kind===`screen`&&e.item.missing)||Date.now()-e>6e4)&&(clearInterval(t),a.current?.fitAll(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>window.__DESIGN_CANVAS_READY__=!0)))},250);return()=>clearInterval(t)},[x,r]),(0,v.useEffect)(()=>{let i=i=>{if(Pk(i.target)||document.querySelector(`[role="dialog"]`))return;let o=a.current,s=r.get(),c=i.metaKey||i.ctrlKey;if(s.markup){i.key===`Escape`&&M();return}if(i.key===`Escape`)_.info?_.select(null):u?d(!1):(s.active||s.selected)&&r.set(e=>({...e,active:null,selected:null}));else if(i.key===`i`&&!c&&!i.altKey)d(e=>!e);else if(i.key===`p`&&!c&&!i.altKey)F();else if(i.shiftKey&&i.code===`Digit1`)o?.fitAll();else if(i.shiftKey&&i.code===`Digit2`&&s.selected)o?.fitItem(s.selected);else if(i.shiftKey&&i.code===`Digit0`)o?.zoomTo(1);else if((i.key===`=`||i.key===`+`)&&!i.altKey)i.preventDefault(),o?.zoomBy(1.4);else if(i.key===`-`&&!i.altKey)i.preventDefault(),o?.zoomBy(1/1.4);else if(c&&i.key===`0`)i.preventDefault(),o?.zoomTo(1);else if(c&&i.key===`\\`)i.preventDefault(),l(e=>!e);else if([`ArrowRight`,`ArrowDown`,`ArrowLeft`,`ArrowUp`].includes(i.key)&&x.length){i.preventDefault();let e=x.findIndex(e=>e.item.id===s.selected),t=i.key===`ArrowRight`||i.key===`ArrowDown`?1:-1,n=x[e===-1?0:(e+t+x.length)%x.length];r.set(e=>({...e,selected:n.item.id,active:null})),o?.fitItem(n.item.id)}else if(i.key===`Enter`&&s.selected){let e=p.items.find(e=>e.item.id===s.selected)?.item;e&&dk(e)&&ne(e.id)}else if(i.key===`]`||i.key===`[`){let r=t?e.pages.indexOf(t):-1,a=e.pages[r+(i.key===`]`?1:-1)];a&&n(sj(e,a))}};return window.addEventListener(`keydown`,i),()=>window.removeEventListener(`keydown`,i)},[r,x,p,ne,F,e,t,n,u,_,M]),bj?(0,R.jsx)(`div`,{className:`flex h-dvh`,children:(0,R.jsx)(Mk,{layout:p,theme:o,store:r,camera:i,events:re,capture:!0,apiRef:a,onPlay:()=>{},onSelect:()=>{}})}):(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(lj,{canvas:e,page:t,theme:o,onTheme:s,sidebar:c,onSidebar:l,inspect:u,onInspect:d,onPlay:F,canPlay:x.length>0}),(0,R.jsxs)(`div`,{className:`flex min-h-0 grow basis-0`,children:[(0,R.jsx)(MO,{open:c&&!!t,side:`left`,width:264,children:t?(0,R.jsx)(cj,{canvas:e,page:t,store:r,onPick:te}):null}),(0,R.jsxs)(`div`,{ref:C,className:`relative min-w-0 grow`,style:E.style,children:[t&&p.items.length?(0,R.jsx)(Mk,{layout:p,theme:o,store:r,camera:i,events:re,capture:!1,apiRef:a,onPlay:ne,over:D?(0,R.jsx)(gj,{layout:p,client:D,store:r,editor:j}):null,onSelect:e=>{e||(_.select(null),d(!1)),N(e)}}):(0,R.jsx)(`div`,{className:`canvas-dots flex h-full`,children:(0,R.jsx)(tv,{title:t?`This page is empty`:`This canvas has no pages`,text:(0,R.jsxs)(R.Fragment,{children:[`Add sections and screens to`,` `,(0,R.jsxs)(`code`,{className:`font-mono text-[13px]`,children:[`.design/canvas/`,e.id,`/canvas.json`]}),`.`]})})}),A&&j?(0,R.jsx)(vj,{item:A,editor:j,onDone:M,room:E.room}):(0,R.jsx)(dj,{canvas:e,store:r,layoutItems:p.items.map(e=>e.item),theme:o,onPlay:ne,inspect:g,onMarkup:O?P:void 0}),(0,R.jsx)(Ej,{ref:w,camera:i,apiRef:a}),D&&t?(0,R.jsx)(GA,{client:D,canvasId:e.id,page:t}):null,e.issues.length?(0,R.jsx)(Dj,{ref:T,canvas:e}):null]}),(0,R.jsx)(MO,{open:u,side:`right`,width:320,children:(0,R.jsx)(OO,{info:_.info,active:!0,onSelect:e=>_.select(e),onClose:()=>{d(!1),_.select(null)}})})]})]})}function Tj({camera:e}){let[t,n]=(0,v.useState)(e.camera.z);return(0,v.useEffect)(()=>{let t=0;return e.subscribe(e=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>n(e.z))})},[e]),(0,R.jsxs)(R.Fragment,{children:[Math.round(t*100),`%`]})}function Ej({ref:e,camera:t,apiRef:n}){return(0,R.jsxs)(`div`,{ref:e,"data-ui":!0,className:`absolute right-4 bottom-5 z-20 flex h-[46px] items-center gap-0.5 rounded-[10px] border border-rule bg-surface px-1.5 shadow-pop`,children:[(0,R.jsx)(N_,{icon:`zoom-out`,label:`Zoom out (−)`,onClick:()=>n.current?.zoomBy(1/1.4)}),(0,R.jsxs)(ow,{side:`top`,align:`end`,width:210,trigger:(0,R.jsx)(`button`,{type:`button`,className:`h-ctrl min-w-[56px] cursor-pointer rounded-[6px] border-0 bg-transparent px-1.5 text-[12.5px] font-medium text-ink2 tabular hover:bg-soft2`,children:(0,R.jsx)(Tj,{camera:t})}),children:[(0,R.jsx)(lw,{onSelect:()=>n.current?.fitAll(),hint:`⇧1`,children:`Zoom to fit`}),(0,R.jsx)(lw,{onSelect:()=>n.current?.zoomTo(1),hint:`⇧0`,children:`100%`}),(0,R.jsx)(uw,{}),[.25,.5,2].map(e=>(0,R.jsxs)(lw,{onSelect:()=>n.current?.zoomTo(e),children:[e*100,`%`]},e))]}),(0,R.jsx)(N_,{icon:`zoom-in`,label:`Zoom in (+)`,onClick:()=>n.current?.zoomBy(1.4)}),(0,R.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-rule`}),(0,R.jsx)(N_,{icon:`fit`,label:`Zoom to fit (⇧1)`,onClick:()=>n.current?.fitAll()})]})}function Dj({ref:e,canvas:t}){let n=t.issues.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(Jw,{children:[(0,R.jsx)(Yw,{asChild:!0,children:(0,R.jsxs)(`button`,{ref:e,type:`button`,"data-ui":!0,className:`absolute bottom-5 left-4 z-20 flex h-[46px] cursor-pointer items-center gap-2 rounded-[10px] border border-rule bg-surface px-3.5 text-[13px] font-medium shadow-pop hover:bg-soft`,children:[(0,R.jsx)(X,{name:`alert`,size:15,className:n?`text-danger-text`:`text-action`}),t.issues.length,` `,t.issues.length===1?`problem`:`problems`,` in canvas.json`]})}),(0,R.jsx)(Xw,{children:(0,R.jsx)(Zw,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onFocusOutside:sw,className:`z-50 max-h-[50vh] w-[460px] max-w-[calc(100vw-24px)] overflow-y-auto rounded-[10px] border border-rule bg-surface shadow-pop outline-none data-[state=open]:animate-[q-pop_120ms_ease-out]`,children:(0,R.jsx)(kO,{issues:t.issues})})})]})}var Oj=10;function kj(e,t,n,r){let[i,a]=(0,v.useState)({area:0,left:0,right:0});return(0,v.useLayoutEffect)(()=>{let r=()=>a(r=>{let i={area:e.current?.clientWidth??0,left:n.current?n.current.offsetWidth+Oj:0,right:t.current?t.current.offsetWidth+Oj:0};return i.area===r.area&&i.left===r.left&&i.right===r.right?r:i});r();let i=new ResizeObserver(r);for(let r of[e.current,n.current,t.current])r&&i.observe(r);return()=>i.disconnect()},[e,n,t,r]),{style:{"--dock-left":`${i.left}px`,"--dock-right":`${i.right}px`},room:Math.max(0,i.area-32-i.left-i.right)}}function Aj(e,t){let n=(0,v.useRef)([]);return(0,v.useMemo)(()=>{let r=new Set(t.items.filter(e=>e.item.kind===`screen`).map(e=>e.item.id)),i=Object.entries(e).filter(e=>!!e[1]&&r.has(e[0])).map(([,e])=>e);return i.length===n.current.length&&i.every((e,t)=>e===n.current[t])||(n.current=i),n.current},[e,t])}var jj=48,Mj=Math.max(0,Math.floor(Number(new URLSearchParams(window.location.search).get(`max`))||0));function Nj(e){let t=e<1e3?Math.min(2,1e3/e):1,n=Mj?Math.min(Mj,3200):3200;return e*t>n?n/e:t}var Pj=(e,t)=>Mj&&e&&t?Math.min(1,Mj/Math.max(e,t)):1;function Fj(e,t=0,n=0,r=1){(0,v.useEffect)(()=>{if(!e)return;window.__DESIGN_DRAWING_SIZE__=t&&n?{width:t,height:n}:void 0,window.__DESIGN_DRAWING_PARTS__=r;let i=requestAnimationFrame(()=>requestAnimationFrame(()=>{window.__DESIGN_DRAWING_READY__=!0}));return()=>cancelAnimationFrame(i)},[e,t,n,r])}function Ij({canvasId:e,pageId:t}){let n=FO(e),r=Y(n?.store??RO,e=>e.ready);return n?(0,R.jsx)(Lj,{client:n,pageId:t,ready:r}):null}function Lj({client:e,pageId:t,ready:n}){let{drawing:r}=LO(e,oT(t)),i=(0,v.useMemo)(()=>TT(r?.strokes??[]).map(({box:e,strokes:t})=>{let n={x:e.x-jj,y:e.y-jj,w:e.w+96,h:e.h+96},r=Nj(Math.max(n.w,n.h));return{crop:n,strokes:t,width:Math.ceil(n.w*r),height:Math.ceil(n.h*r)}}),[r]);return Fj(n,Math.max(0,...i.map(e=>e.width)),i.reduce((e,t)=>e+t.height,0),i.length),(0,R.jsx)(`div`,{className:`flex flex-col items-start`,children:i.map((e,t)=>(0,R.jsx)(`div`,{"data-part":t,className:`bg-surface`,style:{width:e.width,height:e.height},children:(0,R.jsx)(`svg`,{viewBox:`${e.crop.x} ${e.crop.y} ${e.crop.w} ${e.crop.h}`,width:e.width,height:e.height,"aria-hidden":`true`,children:(0,R.jsx)(kA,{drawing:{strokes:e.strokes,erased:[]}})})},e.strokes[0].id))})}var Rj={onGo(){},onLink(){},onWheel(){},onEscape(){}};function zj({canvasId:e,itemId:t}){let{data:n,error:r}=i_(e),i=FO(e),a=(0,v.useMemo)(()=>YO(),[]),o=Y(a,e=>e.sizes),s=(0,v.useMemo)(()=>{for(let e of n?.pages??[])for(let n of e.sections)for(let e of n.items)if(e.id===t&&e.kind===`screen`)return{item:e,section:n};return null},[n,t]),c=Y(a,e=>s?!!e.frames[s.item.id]?.ready:!1),l=Y(i?.store??RO,e=>e.ready),u=s?fk(s.item,o):{w:0,h:0},d=Pj(u.w,u.h);if(Fj(c&&l,Math.round(u.w*d),Math.ceil(u.h*d)),r)return(0,R.jsx)(zO,{title:`Canvas not found`,text:r.message});if(!n||!i)return null;if(!s)return(0,R.jsx)(zO,{title:`Screen not found`,text:`No screen "${t}" in "${e}".`});let f=new URLSearchParams(window.location.search).get(`theme`),p=f===`dark`||f===`light`?f:n.theme??`light`,m={item:s.item,section:s.section,x:0,y:0,w:u.w,h:u.h};return(0,R.jsx)(`div`,{className:`overflow-hidden`,style:{width:u.w*d,height:u.h*d},children:(0,R.jsxs)(`div`,{className:`relative origin-top-left`,style:{width:u.w,height:u.h,transform:d<1?`scale(${d})`:void 0},children:[(0,R.jsx)(tk,{placed:m,mode:`live`,thumb:!1,theme:p,store:a,events:Rj,capture:!0}),(0,R.jsx)(`div`,{className:`absolute inset-0`,children:(0,R.jsx)(zA,{client:i,drawingKey:sT(t),width:u.w,height:u.h,sizes:mj,className:`h-full w-full overflow-visible`})})]})})}function Bj({open:e,onOpenChange:t,title:n,children:r}){return(0,R.jsx)(gg,{open:e,onOpenChange:t,children:(0,R.jsx)(ed,{children:e?(0,R.jsxs)(bg,{forceMount:!0,children:[(0,R.jsx)(Sg,{asChild:!0,forceMount:!0,children:(0,R.jsx)(Kf.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},className:`fixed inset-0 z-50 bg-overlay`})}),(0,R.jsx)(Eg,{asChild:!0,forceMount:!0,"aria-describedby":void 0,children:(0,R.jsxs)(Kf.div,{initial:{y:`100%`},animate:{y:0},exit:{y:`100%`,transition:{duration:.18,ease:`easeIn`}},transition:{type:`spring`,stiffness:420,damping:40},className:`fixed inset-x-0 bottom-0 z-50 flex max-h-[82dvh] flex-col rounded-t-[14px] border-t border-rule bg-surface pb-[env(safe-area-inset-bottom)] shadow-pop outline-none`,children:[(0,R.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-9 rounded-full bg-rule-strong`})}),(0,R.jsxs)(`div`,{className:`flex min-h-[48px] items-center justify-between gap-3 pr-2 pl-4`,children:[(0,R.jsx)(jg,{className:`m-0 truncate text-[15px] font-semibold`,children:n}),(0,R.jsx)(Ng,{asChild:!0,children:(0,R.jsx)(N_,{icon:`x`,label:`Close`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain border-t border-rule`,children:r})]})})]}):null})})}function Vj(e,t){return(t?e.pages.filter(e=>e.id===t):e.pages).flatMap(t=>t.sections.flatMap(n=>n.items.filter(e=>e.kind===`screen`||e.kind===`url`).map(r=>({item:r,pageId:t.id,where:[e.pages.length>1?t.title:null,n.title].filter(Boolean).join(` · `)}))))}var Hj=(e,t,n)=>`/c/${encodeURIComponent(e)}/play/${encodeURIComponent(t)}?page=${encodeURIComponent(n)}`;function Uj({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=i_(e);return r?(0,R.jsx)(zO,{title:`Canvas not found`,text:r.message}):i||!n?null:(0,R.jsx)(Wj,{canvas:n,itemId:t})}function Wj({canvas:e,itemId:t}){let[,n]=I(),{frameSandbox:r,frameAllow:i,slots:a}=e_(),o=new URLSearchParams(window.location.search).get(`page`)??(window.location.hash.split(`?`)[1]?new URLSearchParams(window.location.hash.split(`?`)[1]).get(`page`):null),s=(0,v.useMemo)(()=>Vj(e,null),[e]),c=s.find(e=>e.item.id===t),l=o??c?.pageId??null,u=(0,v.useMemo)(()=>l?Vj(e,l):s,[e,l,s]),d=u.findIndex(e=>e.item.id===t),f=b_(),[p,m]=(0,v.useState)(e.theme??f),[h,g]=(0,v.useState)(`fit`),_=(0,v.useRef)(null),y=(0,v.useRef)(null),[b,x]=(0,v.useState)(null),S=(0,v.useCallback)(e=>{y.current=e,x(e)},[]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)({w:0,h:0}),[D,O]=(0,v.useState)([]),k=l?`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(l)}`:`/c/${encodeURIComponent(e.id)}`,A=t=>{if(!u.length)return;let r=u[(d+t+u.length)%u.length];n(Hj(e.id,r.item.id,r.pageId),{replace:!0})};(0,v.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let t=new ResizeObserver(()=>E({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]),(0,v.useEffect)(()=>{let e=e=>{Pk(e.target)||document.querySelector(`[role="dialog"]`)||(e.key===`ArrowRight`?A(1):e.key===`ArrowLeft`?A(-1):e.key===`i`&&!e.metaKey&&!e.ctrlKey&&!e.altKey?w(e=>!e):e.key===`Escape`&&(re.info?re.select(null):C?w(!1):n(k)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let j=u[d],M=j?.item,ee=M?.kind===`screen`?M.theme??p:p,N=ij(e.id,M,ee),[P]=(0,v.useState)(ee),te=M?M.kind===`screen`?mO(M.url,P):M.url:``,ne=(0,v.useMemo)(()=>b&&M?.kind===`screen`?[b]:[],[b,M?.kind]),F=vO(ne),re=_O(ne,C||F,{onEscape:()=>w(!1)}),ie=!!re.info;if((0,v.useEffect)(()=>{ie&&w(!0)},[ie]),(0,v.useEffect)(()=>{let t=y.current;if(t&&M?.kind===`screen`)return O([]),sO(t,t=>{if(t.type===`error`)O(e=>aO(e,t.message));else if(t.type===`updated`)O([]);else if(t.type===`keydown`&&t.code===`Escape`)n(k);else if(t.type===`go`){let[r,i]=t.target.includes(`/`)?t.target.split(`/`):[null,t.target],a=s.find(e=>e.item.id===i&&(!r||e.pageId===r));a&&n(Hj(e.id,a.item.id,a.pageId))}else t.type===`link`&&gO(t,e,t=>{let r=s.find(e=>e.item.id===t);r&&n(Hj(e.id,r.item.id,r.pageId))},M?.id)})},[M,te,s,e.id,n,k]),(0,v.useEffect)(()=>{M?.kind===`screen`&&dO(y.current,ee)},[ee,M]),!M)return(0,R.jsx)(zO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`});let ae=M.frame.width,oe=M.frame.height===`auto`?Math.max(T.h-48,400):M.frame.height,se=h===`fit`?Math.min(1,(T.w-48)/ae,(T.h-48)/oe):1,ce=ae<=T.w-48&&oe<=T.h-48;return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsxs)(gw,{children:[a.barStart,(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Back to canvas `,(0,R.jsx)(S_,{children:`esc`})]}),children:(0,R.jsx)(ye,{href:k,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,"aria-label":`Back to canvas`,children:(0,R.jsx)(X,{name:`arrow-left`,size:16})})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col leading-tight`,children:[(0,R.jsx)(`span`,{className:`truncate text-[14px] font-semibold`,children:M.title}),(0,R.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.title,j.where].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(`div`,{className:`mx-auto flex items-center gap-1`,children:[(0,R.jsx)(N_,{icon:`chevron-left`,label:`Previous screen (←)`,onClick:()=>A(-1),disabled:u.length<2}),(0,R.jsxs)(`span`,{className:`min-w-[52px] text-center text-[12.5px] text-muted tabular`,children:[d+1,` / `,u.length]}),(0,R.jsx)(N_,{icon:`chevron-right`,label:`Next screen (→)`,onClick:()=>A(1),disabled:u.length<2})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ce?null:(0,R.jsx)(YA,{label:`Scale`,value:h,onChange:g,items:[{value:`fit`,label:`Fit`},{value:`actual`,label:`100%`}]}),M.kind===`screen`&&!M.theme?(0,R.jsx)(YA,{label:`Screen theme`,value:p,onChange:m,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark`}]}):null,M.kind===`screen`?(0,R.jsx)(pj,{on:C,onChange:w}):null,(0,R.jsx)(N_,{icon:`refresh`,label:`Reload`,onClick:()=>fO(y.current)}),N?(0,R.jsx)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,title:`Open in a new tab`,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,children:(0,R.jsx)(X,{name:`external`,size:16})}):null,(0,R.jsx)(pw,{}),a.barEnd]})]}),a.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:a.belowBar}):null,(0,R.jsxs)(`div`,{className:`flex min-h-0 grow basis-0`,children:[(0,R.jsxs)(`div`,{ref:_,className:`canvas-dots relative min-w-0 grow overscroll-none ${h===`actual`?`overflow-auto`:`overflow-hidden`}`,children:[D.length?(0,R.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-10 flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px`}),D.join(`
|
|
133
135
|
`)]}):null,(0,R.jsx)(`div`,{className:`flex min-h-full min-w-full items-center justify-center p-6`,style:{width:h===`actual`?ae+48:void 0},children:(0,R.jsx)(`div`,{className:`shrink-0 animate-[q-fade-in_160ms_ease-out] overflow-clip bg-surface`,style:{width:ae*se,height:oe*se,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:(0,R.jsx)(`iframe`,{ref:S,src:te,title:M.title,allow:i,sandbox:r,className:`block border-0`,style:{width:ae,height:oe,transform:`scale(${se})`,transformOrigin:`0 0`,colorScheme:ee},onLoad:()=>M.kind===`screen`&&dO(y.current,ee)},`${M.id}:${M.kind===`screen`?M.rev:M.url}`)},M.id)})]}),(0,R.jsx)(MO,{open:C,side:`right`,width:320,children:(0,R.jsx)(OO,{info:re.info,active:!0,onSelect:e=>re.select(e),onClose:()=>{w(!1),re.select(null)}})})]})]})}var Gj=12;function Kj({canvasId:e,pageId:t,itemId:n}){let{data:r,error:i,isLoading:a}=i_(e);return i?(0,R.jsx)(zO,{title:`Canvas not found`,text:i.message}):a||!r?(0,R.jsx)(`div`,{className:`canvas-dots h-dvh`}):(0,R.jsx)(qj,{canvas:r,pageId:t,itemId:n})}function qj({canvas:e,pageId:t,itemId:n}){let[,r]=I(),{frameSandbox:i,frameAllow:a,slots:o,scope:s}=e_(),c=b_(),l=(0,v.useMemo)(()=>Vj(e,null),[e]),u=Math.max(0,n?l.findIndex(e=>e.item.id===n):t?l.findIndex(e=>e.pageId===t):0),d=l[u],f=d?.item,[p,m]=(0,v.useState)(e.theme??c),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(0),[E,D]=(0,v.useState)(!1),O=(0,v.useRef)(null),k=(0,v.useRef)(null),[A,j]=(0,v.useState)(null),M=(0,v.useCallback)(e=>{e&&(k.current=e,j(e))},[]),ee=(0,v.useCallback)((t,n=0)=>{T(n),r(Hj(e.id,t.item.id,t.pageId),{replace:!0})},[e.id,r]),N=e=>{l.length<2||ee(l[(u+e+l.length)%l.length],e)},P=e=>{let t=l.find(t=>t.item.id===e);t&&ee(t,l.indexOf(t)>u?1:-1)};(0,v.useLayoutEffect)(()=>{let e=O.current;if(!e)return;let t=new ResizeObserver(()=>x(e.clientWidth));return t.observe(e),()=>t.disconnect()},[]);let te=f?.kind===`screen`?f.theme??p:p,[ne]=(0,v.useState)(te),F=f?f.kind===`screen`?mO(f.url,ne):f.url:``,re=ij(e.id,f,te);(0,v.useEffect)(()=>{y([]),C(f?.kind===`screen`?f.measuredHeight??null:null),O.current?.scrollTo({top:0});let t=k.current;if(t&&f?.kind===`screen`)return sO(t,t=>{t.type===`size`?C(t.height):t.type===`error`?y(e=>aO(e,t.message)):t.type===`updated`?y([]):t.type===`go`?P(t.target.includes(`/`)?t.target.split(`/`)[1]:t.target):t.type===`link`&&gO(t,e,P,f.id)})},[A,F]),(0,v.useEffect)(()=>{f?.kind===`screen`&&dO(k.current,te)},[te,f]),(0,v.useEffect)(()=>{let e=e=>{document.querySelector(`[role="dialog"]`)||(e.key===`ArrowRight`?N(1):e.key===`ArrowLeft`&&N(-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let ie=(0,v.useRef)(null),ae=e=>{let t=e.touches[0];ie.current=t?{x:t.clientX,y:t.clientY}:null},oe=e=>{let t=ie.current,n=e.changedTouches[0];if(ie.current=null,!t||!n)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>56&&Math.abs(r)>Math.abs(i)*1.5&&N(r<0?1:-1)};if(!f||!d)return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(Yj,{canvas:e,title:e.title,sub:null}),(0,R.jsx)(zO,{title:`No screens here`,text:`This canvas has no screens to show yet.`})]});let se=f.frame.width,ce=b?Math.min(1,(b-24)/se):0,le=ce>0&&ce<.8,ue=le&&E?1:ce,de=f.frame.height===`auto`?Math.max(S??0,480):f.frame.height,fe=f.kind===`screen`&&!f.theme;return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(Yj,{canvas:e,title:f.title||f.id,sub:[e.title,d.where].filter(Boolean).join(` · `),back:s?void 0:`/`,end:(0,R.jsxs)(R.Fragment,{children:[le?(0,R.jsx)(N_,{icon:E?`zoom-out`:`zoom-in`,label:E?`Fit to width`:`Actual size`,onClick:()=>D(e=>!e)}):null,(0,R.jsxs)(ow,{align:`end`,width:220,trigger:(0,R.jsx)(N_,{icon:`more`,label:`Screen options`}),children:[fe?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(dw,{children:`Screen theme`}),(0,R.jsx)(Jj,{value:`light`,current:p,onPick:m}),(0,R.jsx)(Jj,{value:`dark`,current:p,onPick:m}),(0,R.jsx)(uw,{})]}):null,(0,R.jsxs)(lw,{onSelect:()=>fO(k.current),children:[(0,R.jsx)(X,{name:`refresh`,size:15,className:`text-ink2`}),`Reload screen`]}),re?(0,R.jsxs)(lw,{onSelect:()=>window.open(re,`_blank`,`noopener`),children:[(0,R.jsx)(X,{name:`external`,size:15,className:`text-ink2`}),`Open in a new tab`]}):null,(0,R.jsxs)(lw,{onSelect:()=>v_(c===`dark`?`light`:`dark`),children:[(0,R.jsx)(X,{name:c===`dark`?`sun`:`moon`,size:15,className:`text-ink2`}),c===`dark`?`Light appearance`:`Dark appearance`]})]}),o.barEnd]})}),o.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:o.belowBar}):null,(0,R.jsxs)(`div`,{ref:O,onTouchStart:ae,onTouchEnd:oe,className:J(`canvas-dots relative min-h-0 grow overflow-y-auto overscroll-contain`,le&&E?`overflow-x-auto`:`overflow-x-hidden`),children:[_.length?(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:_.join(`
|
|
@@ -160,4 +162,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
160
162
|
`,t-1)+1;if(n.slice(r,t).trim())return 0;let i=n.indexOf(`
|
|
161
163
|
`,t+2);return(i===-1?n.length:i)-t}function RF(e){return{...e,jsx:!1,regex:!1,templateStrings:!1}}function zF(){return{javascript:fP,typescript:EF,css:RF(mN),python:RF(nF),c:RF(aN),go:RF(PN),java:RF(EP),rust:RF(dF),json:RF(kP),diff:RF(DN),shell:RF(mF),cpp:RF(cN),csharp:RF(dN),sql:RF(gF),html:xP,vue:kF,svelte:OF,yaml:RF(AF),markdown:RF(VP),plaintext:RF(XP),ruby:RF(oF),kotlin:RF(jP),swift:RF(xF),php:RF(GP),toml:RF(wF),powershell:RF(QP),dockerfile:RF(MN),graphql:RF(LN),hcl:RF(BN),zig:RF(MF),lua:RF(PP)}}var BF=zF();function VF(e){return BF[e||`javascript`]}function HF(e,t){let{lang:n,cx:r,mark:i,markLine:a}=t||{};return qM(nN(e,VF(n)),{cx:r,mark:i,markLine:a})}function UF({code:e,path:t,className:n}){let r=e.replace(/\n$/,``),i=(0,v.useMemo)(()=>HF(r),[r]),a=r.split(`
|
|
162
164
|
`).length;return(0,R.jsxs)(`div`,{className:J(`flex min-w-0 flex-col`,n),children:[t?(0,R.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-3 border-b border-rule bg-soft pr-1.5 pl-4`,children:[(0,R.jsx)(Z,{size:12,className:`truncate text-muted`,title:t,children:t}),(0,R.jsx)(N_,{icon:`copy`,label:`Copy file`,size:15,onClick:()=>FT(e,`Copied the file`)})]}):null,(0,R.jsxs)(`div`,{className:`flex max-h-[640px] min-w-0 overflow-auto font-mono text-[12.5px] leading-[1.6]`,children:[(0,R.jsx)(`pre`,{"aria-hidden":`true`,className:`sticky left-0 m-0 shrink-0 select-none border-r border-rule bg-surface py-3 pr-3 pl-4 text-right text-muted`,children:Array.from({length:a},(e,t)=>t+1).join(`
|
|
163
|
-
`)}),(0,R.jsx)(`pre`,{className:`m-0 min-w-0 grow py-3 pr-6 pl-4 text-ink`,children:(0,R.jsx)(`code`,{dangerouslySetInnerHTML:{__html:i}})})]})]})}var WF={beta:`action`,experimental:`action`,draft:`action`,deprecated:`danger`,stable:`ok`},GF=`.design/system/components/`;function KF(e){return e.startsWith(GF)?`@system/components/${e.slice(26).replace(/\.(tsx|jsx|ts|js)$/,``).replace(/\/index$/,``)}`:null}function qF(e){let t=new Set;for(let n of e.matchAll(/export\s+(?:async\s+)?(?:function|const|class|let)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);for(let n of e.matchAll(/export\s*\{([^}]+)\}/g))for(let e of n[1].split(`,`)){let n=e.trim().split(/\s+as\s+/).pop()?.trim();n&&n!=="default"&&t.add(n)}return[...t].filter(e=>/^[A-Z]/.test(e))}function JF({path:e}){let t=KF(e),n=o_(t?e:null).data;if(!t)return null;let r=n?qF(n):[],i=`import { ${r.length?r.join(`, `):`…`} } from '${t}'`;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-rule py-1.5 pr-1.5 pl-4`,children:[(0,R.jsx)(Z,{size:12.5,className:`min-w-0 truncate text-ink2`,title:i,children:i}),(0,R.jsx)(N_,{icon:`copy`,label:`Copy the import`,size:14,className:`ml-auto`,onClick:()=>FT(i)})]})}function YF({component:e,theme:t,width:n}){return n===`fill`?(0,R.jsx)(jM,{src:e.url,theme:t,title:e.title,minHeight:160}):(0,R.jsx)(`div`,{className:`flex justify-center overflow-x-auto bg-soft p-6`,children:(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden rounded-[8px] border border-rule bg-surface shadow-frame`,children:(0,R.jsx)(jM,{src:e.url,theme:t,title:e.title,minHeight:160,width:Number(n)})})})}function XF({component:e}){let t=[...e.sources,e.specimen],[n,r]=(0,v.useState)(t[0]),i=t.includes(n)?n:t[0],{data:a,error:o,isLoading:s}=o_(i);return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[t.length>1?(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-rule px-4 py-2.5`,children:(0,R.jsx)(YA,{label:`File`,size:`sm`,value:i,onChange:r,items:t.map(t=>({value:t,label:t===e.specimen?`${ZF(t)} · specimen`:ZF(t),title:t}))})}):null,KF(i)?(0,R.jsx)(JF,{path:i}):null,o?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-6 text-[13px] text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:15}),o.message]}):s||a===void 0?(0,R.jsx)(`div`,{className:`flex items-center justify-center py-10 text-muted`,children:(0,R.jsx)(X,{name:`loader`,size:18})}):(0,R.jsx)(UF,{code:a,path:i})]})}function ZF(e){return e.split(`/`).pop()??e}function QF({system:e,id:t}){let n=e.components.find(e=>e.id===t),[r,i]=(0,v.useState)(`preview`),[a,o]=yM(),[s,c]=(0,v.useState)(`fill`),l=!e_().frameSandbox;if(!n)return(0,R.jsx)(zO,{title:`No such component`,text:`There is no specimen "${t}" in .design/system/specimens.`});let u=n.status?.toLowerCase();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,badge:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(L_,{children:n.group}),u?(0,R.jsx)(L_,{tone:WF[u]??`neutral`,children:n.status}):null]}),sub:n.description}),(0,R.jsxs)(z_,{children:[(0,R.jsx)(V_,{value:r,onChange:i,items:[{value:`preview`,label:`Preview`},{value:`code`,label:`Code`,count:n.sources.length+1}],right:r===`preview`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(YA,{label:`Width`,size:`sm`,value:s,onChange:c,items:[{value:`fill`,label:`Fill`},{value:`768`,label:`768`},{value:`390`,label:`390`}]}),(0,R.jsx)(bM,{value:a,onChange:o}),l?(0,R.jsx)(F_,{icon:`external`,href:hO(mO(n.url,a)),target:`_blank`,rel:`noreferrer`,children:`Open`}):null]}):null}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:r===`preview`?(0,R.jsx)(YF,{component:n,theme:a,width:s}):(0,R.jsx)(XF,{component:n})})]})]})}function $F(e,t){let n=/^\s*#\s+(.+)\r?\n/.exec(e);return n&&n[1].trim()===t?e.slice(n[0].length):e}function eI({system:e,slug:t}){let n=e.guidelines.find(e=>e.slug===t);if(!n)return(0,R.jsx)(zO,{title:`No such guideline`,text:`There is no guideline "${t}" in .design/system/guidelines.`});let r=$F(n.markdown,n.title).trim();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,sub:`Guideline`}),(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:r?(0,R.jsx)(VD,{text:r,className:`max-w-[760px]`}):(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`This guideline is empty. Write it in `,(0,R.jsx)(Z,{children:`.design/system/guidelines`}),`.`]})})})]})}var tI={linear:[0,0,1,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]};function nI(e){let t=e.trim();if(tI[t])return tI[t];let n=/^cubic-bezier\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)$/.exec(t);if(!n)return null;let r=n.slice(1).map(Number);return r.every(Number.isFinite)?r:null}function rI(e){let t=/^(-?[\d.]+)(ms|s)$/.exec(e.trim());return t?Number(t[1])*(t[2]===`s`?1e3:1):null}var iI=132,aI=22;function oI({bezier:e}){let[t,n,r,i]=e,a=Math.min(0,n,i),o=Math.max(1,n,i),s=88/(o-a),c=e=>aI+e*88,l=e=>aI+(o-e)*s;return(0,R.jsxs)(`svg`,{width:iI,height:iI,viewBox:`0 0 ${iI} ${iI}`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,R.jsx)(`rect`,{x:c(0),y:l(1),width:88,height:l(0)-l(1),className:`fill-none stroke-rule`}),(0,R.jsx)(`line`,{x1:c(0),y1:l(0),x2:c(t),y2:l(n),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`line`,{x1:c(1),y1:l(1),x2:c(r),y2:l(i),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`path`,{d:`M ${c(0)} ${l(0)} C ${c(t)} ${l(n)}, ${c(r)} ${l(i)}, ${c(1)} ${l(1)}`,className:`fill-none stroke-ink`,strokeWidth:2,strokeLinecap:`round`}),(0,R.jsx)(`circle`,{cx:c(t),cy:l(n),r:3,className:`fill-action`}),(0,R.jsx)(`circle`,{cx:c(r),cy:l(i),r:3,className:`fill-action`})]})}function sI({token:e,duration:t}){let[n,r]=(0,v.useState)(!1),i=e.light?.value??``,a=nI(i);return(0,R.jsxs)(`button`,{type:`button`,title:`Hover to play; click to copy the variable`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),onClick:()=>FT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col gap-3 rounded-[8px] border border-transparent bg-transparent p-3 text-left transition-colors hover:border-rule hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex h-[132px] items-center justify-center rounded-[6px] bg-soft`,children:a?(0,R.jsx)(oI,{bezier:a}):(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`No curve to draw`})}),(0,R.jsx)(`span`,{className:`relative mx-1 h-2 rounded-full bg-soft2`,children:(0,R.jsx)(`span`,{className:`absolute top-1/2 size-3.5 -translate-y-1/2 rounded-full bg-ink`,style:{left:n?`calc(100% - 14px)`:`0px`,transition:`left ${t}ms ${i||`ease`}`}})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:i}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function cI({system:e}){let t=hM(e.tokens,`ease`),n=hM(e.tokens,`duration`),r=hM(e.tokens,`animation`),i=`minmax(170px,1fr) 100px minmax(0,2fr)`,a=`minmax(170px,1fr) minmax(140px,0.7fr) minmax(0,2fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Motion`,sub:`Hover an easing to see it move.`}),!t.length&&!n.length&&!r.length?(0,R.jsxs)(SM,{title:`No motion tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--ease-*`}),` and `,(0,R.jsx)(Z,{children:`--animate-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block, and durations as`,` `,(0,R.jsx)(Z,{children:`--duration-*`}),`, in `,(0,R.jsx)(Z,{children:CM}),`.`]}):null,t.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Easing`,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(190px, 1fr))`},children:t.map(e=>(0,R.jsx)(sI,{token:e,duration:900},e.name))})]}):null,n.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Durations`,count:n.length}),(0,R.jsx)(W_,{cols:i,labels:[`Token`,`Value`,``]}),n.map(e=>{let t=e.light?rI(e.light.value):null;return(0,R.jsxs)(K_,{cols:i,minH:40,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),t===null?(0,R.jsx)(`span`,{}):(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(t/2,480))}})]},e.name)})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Animations`,count:r.length,sub:`keyframes live in the system stylesheet`}),(0,R.jsx)(W_,{cols:a,labels:[`Token`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:a,minH:40,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:e.light?.value})]},e.name))]}):null]})}function lI({system:e}){let t=Tw(),n=new Set(e.tokens.map(e=>e.kind)),r=[{to:`/system/colors`,label:`Colors`,hint:uI(e,`color`)},{to:`/system/typography`,label:`Typography`},{to:`/system/shape`,label:`Spacing & shape`}];(n.has(`ease`)||n.has(`duration`)||n.has(`animation`))&&r.push({to:`/system/motion`,label:`Motion`}),n.has(`other`)&&r.push({to:`/system/tokens`,label:`Other tokens`,hint:uI(e,`other`)}),e.assets.length&&r.push({to:`/system/assets`,label:`Assets`,hint:e.assets.length});let i=new Map;for(let t of e.components){let e=i.get(t.group)??[];e.push({to:`/system/components/${encodeURIComponent(t.id)}`,label:t.title,hint:t.status}),i.set(t.group,e)}let a=e.guidelines.filter(e=>e.slug!==`overview`);if(t){let e=[{label:``,items:[{to:`/system`,label:`Overview`}]},{label:`Foundations`,items:r},{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))},...[...i].map(([e,t])=>({label:e,items:t}))];return(0,R.jsx)(dI,{sections:e.filter(e=>e.items.length)})}return(0,R.jsxs)(`div`,{className:`flex flex-col max-lg:gap-1 max-lg:[&_nav]:flex-row max-lg:[&_nav]:flex-wrap`,children:[(0,R.jsx)(Q_,{label:`Overview`,items:[{to:`/system`,label:`Overview`}]}),(0,R.jsx)($_,{children:`Foundations`}),(0,R.jsx)(Q_,{label:`Foundations`,items:r}),a.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)($_,{children:`Guidelines`}),(0,R.jsx)(Q_,{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))})]}):null,[...i].map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsx)($_,{children:e}),(0,R.jsx)(Q_,{label:e,items:t})]},e))]})}function uI(e,t){return e.tokens.filter(e=>e.kind===t).length||void 0}function dI({sections:e}){let[t]=I(),[n,r]=(0,v.useState)(!1),i=e.flatMap(e=>e.items).find(e=>e.to===t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex h-11 w-full cursor-pointer items-center gap-2 rounded-[8px] border border-rule bg-surface px-3.5 text-left text-[14px] text-ink`,children:[(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`Section`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate font-medium`,children:i?.label??`Overview`}),(0,R.jsx)(X,{name:`chevron-down`,size:16,className:`shrink-0 text-muted`})]}),(0,R.jsx)(Bj,{open:n,onOpenChange:r,title:`Design system`,children:(0,R.jsx)(`nav`,{"aria-label":`Design system`,className:`flex flex-col pb-2`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.label?(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.label}):null,e.items.map(e=>{let n=e.to===t;return(0,R.jsxs)(ye,{href:e.to,onClick:()=>r(!1),"aria-current":n?`page`:void 0,className:J(`flex min-h-[46px] items-center gap-2 px-4 text-[14px] no-underline active:bg-soft2`,n?`font-medium text-ink`:`text-ink2`),children:[(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:e.hint}):null,n?(0,R.jsx)(X,{name:`check`,size:16,className:`shrink-0 text-action`}):null]},e.to)})]},e.label||`overview`))})})]})}function fI({system:e}){let t=hM(e.tokens,`other`),n=`minmax(170px,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1.3fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Other tokens`,sub:`Variables that are not colors, type, spacing, shape or motion.`}),t.length?gM(t).map(({group:e,tokens:t})=>(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(W_,{cols:n,labels:[`Token`,`Light`,`Dark`,`Description`]}),t.map(e=>(0,R.jsxs)(K_,{cols:n,minH:40,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(wM,{children:e.light?.value}),(0,R.jsx)(wM,{children:e.dark?.value??`—`}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:e.description})]},e.name))]},e)):(0,R.jsxs)(SM,{title:`No other tokens`,children:[`Variables in `,(0,R.jsx)(Z,{children:`:root`}),` of `,(0,R.jsx)(Z,{children:CM}),` that are not colors or lengths show here.`]})]})}function pI(e,...t){return e.tokens.filter(e=>t.includes(e.kind)).length}function mI(e){let t=[{to:`/system/colors`,icon:`palette`,title:`Colors`,text:nM(pI(e,`color`),`token`)},{to:`/system/typography`,icon:`type`,title:`Typography`,text:`${nM(pI(e,`font`),`family`,`families`)} · ${nM(pI(e,`text`),`size`)}`},{to:`/system/shape`,icon:`shape`,title:`Spacing & shape`,text:nM(pI(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),`token`)}],n=pI(e,`ease`,`duration`,`animation`);n&&t.push({to:`/system/motion`,icon:`motion`,title:`Motion`,text:nM(n,`token`)}),e.assets.length&&t.push({to:`/system/assets`,icon:`image`,title:`Assets`,text:nM(e.assets.length,`file`)});let r=e.components[0];return r&&t.push({to:`/system/components/${encodeURIComponent(r.id)}`,icon:`component`,title:`Components`,text:nM(e.components.length,`component`)}),t}function hI({system:e}){return(0,R.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`},children:mI(e).map(e=>(0,R.jsxs)(ye,{href:e.to,className:`flex items-center gap-3 rounded-[10px] border border-rule bg-surface px-4 py-3.5 text-inherit no-underline transition-colors hover:border-rule-strong hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[8px] bg-soft2 text-ink2`,children:(0,R.jsx)(X,{name:e.icon,size:17})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[14px] font-medium text-ink`,children:e.title}),(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.text})]})]},e.to))})}function gI({system:e}){let[,t]=I(),n=[{label:`Color tokens`,value:pI(e,`color`),to:`/system/colors`},{label:`Type tokens`,value:pI(e,`font`,`text`,`weight`,`leading`,`tracking`),to:`/system/typography`},{label:`Spacing & shape tokens`,value:pI(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),to:`/system/shape`},{label:`Motion tokens`,value:pI(e,`ease`,`duration`,`animation`),to:`/system/motion`},{label:`Other tokens`,value:pI(e,`other`),to:`/system/tokens`},{label:`Components`,value:e.components.length},{label:`Guidelines`,value:e.guidelines.length}];return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`At a glance`}),n.filter(e=>e.value||!e.to||e.to===`/system/colors`).map(e=>(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,onClick:e.to&&e.value?()=>t(e.to):void 0,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:e.label}),(0,R.jsx)(R_,{value:e.value})]},e.label)),e.fonts.length?(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:`Web fonts`}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5`,children:e.fonts.map(e=>(0,R.jsx)(Z,{size:12,className:`max-w-[260px] truncate text-muted`,title:e,children:_I(e)},e))})]}):null]})}function _I(e){try{let t=new URL(e),n=t.searchParams.getAll(`family`).map(e=>e.split(`:`)[0].replace(/\+/g,` `));return n.length?n.join(`, `):t.host}catch{return e}}function vI({system:e}){let t=e.guidelines.find(e=>e.slug===`overview`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:e.name,sub:e.description}),(0,R.jsx)(AO,{issues:e.issues,title:`Problems in the design system`}),(0,R.jsx)(hI,{system:e}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-xl:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 320px`},children:[t?(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:(0,R.jsx)(VD,{text:t.markdown})})}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Overview`}),(0,R.jsxs)(`div`,{className:`border-t border-rule px-4 py-5 text-[13px] text-muted`,children:[`Write the principles every screen follows in `,(0,R.jsx)(Z,{children:`.design/system/guidelines/01-overview.md`}),`; it shows here.`]})]}),(0,R.jsx)(gI,{system:e})]})]})}var yI=[1,2,3,4,6,8,12,16],bI=480;function xI({px:e}){return e===null?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`not a plain length`}):(0,R.jsxs)(`span`,{className:`flex h-3 items-center`,children:[(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(e,bI))},title:`${e}px`}),e>bI?(0,R.jsx)(`span`,{className:`ml-1.5 text-[12px] text-muted`,children:`…`}):null]})}function SI({tokens:e}){let t=e.find(e=>e.name===`--spacing`),n=e.filter(e=>e!==t),r=t?.light?_M(t.light.value):null,i=`minmax(150px,0.8fr) 110px minmax(0,2fr)`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Spacing`,count:e.length,sub:t?`base ${t.light?.value}`:void 0}),(0,R.jsx)(W_,{cols:i,labels:[`Class or token`,`Value`,``]}),t&&r!==null?yI.map(e=>(0,R.jsxs)(K_,{cols:i,minH:36,pad:`6px 16px`,children:[(0,R.jsxs)(Z,{size:12.5,className:`text-ink`,children:[`p-`,e,` · gap-`,e]}),(0,R.jsxs)(Z,{size:12,className:`text-muted`,children:[r*e,`px`]}),(0,R.jsx)(xI,{px:r*e})]},e)):null,n.map(e=>(0,R.jsxs)(K_,{cols:i,minH:40,pad:`6px 16px`,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(xI,{px:e.light?_M(e.light.value):null})]},e.name))]})}function CI({token:e,children:t}){return(0,R.jsxs)(`button`,{type:`button`,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col items-stretch gap-2.5 rounded-[8px] border border-transparent bg-transparent p-2 text-left transition-colors hover:border-rule hover:bg-soft`,children:[t,(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:e.light?.value}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function wI({title:e,tokens:t,min:n=170,children:r}){return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(${n}px, 1fr))`},children:t.map(e=>(0,R.jsx)(CI,{token:e,children:r(e)},e.name))})]})}function TI({tokens:e}){let t=`minmax(170px,1fr) minmax(90px,0.6fr) 110px 90px`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Breakpoints`,count:e.length}),(0,R.jsx)(W_,{cols:t,labels:[`Token`,`Variant`,`Value`,`Pixels`],align:`lllr`}),e.map(e=>{let n=e.light?_M(e.light.value):null;return(0,R.jsxs)(K_,{cols:t,align:`lllr`,minH:40,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:n===null?``:`${n}px`})]},e.name)})]})}function EI({system:e}){let t=b_(),n=hM(e.tokens,`spacing`),r=hM(e.tokens,`radius`),i=hM(e.tokens,`shadow`),a=hM(e.tokens,`blur`),o=hM(e.tokens,`breakpoint`),s=!n.length&&!r.length&&!i.length&&!a.length&&!o.length;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Spacing & shape`,sub:`Click a token to copy its variable.`}),s?(0,R.jsxs)(SM,{title:`No spacing or shape tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--spacing`}),` (the base step), `,(0,R.jsx)(Z,{children:`--spacing-*`}),`, `,(0,R.jsx)(Z,{children:`--radius-*`}),`,`,` `,(0,R.jsx)(Z,{children:`--shadow-*`}),` and `,(0,R.jsx)(Z,{children:`--breakpoint-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block in`,` `,(0,R.jsx)(Z,{children:CM}),`.`]}):null,n.length?(0,R.jsx)(SI,{tokens:n}):null,r.length?(0,R.jsx)(wI,{title:`Radii`,tokens:r,children:e=>(0,R.jsx)(`span`,{className:`flex h-[88px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`size-14 border border-rule-strong bg-surface`,style:{borderRadius:e.light?.value}})})}):null,i.length?(0,R.jsx)(wI,{title:`Shadows`,tokens:i,min:200,children:e=>(0,R.jsx)(`span`,{className:`flex h-[112px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`h-[60px] w-[108px] rounded-[8px] bg-surface`,style:{boxShadow:vM(e,t)}})})}):null,a.length?(0,R.jsx)(wI,{title:`Blur`,tokens:a,children:e=>(0,R.jsxs)(`span`,{className:`relative flex h-[88px] items-center justify-center overflow-hidden rounded-[6px] bg-soft`,children:[(0,R.jsx)(`span`,{className:`absolute left-5 top-4 size-10 rounded-full bg-action`}),(0,R.jsx)(`span`,{className:`absolute right-6 bottom-3 size-12 rounded-[6px] bg-ink2`}),(0,R.jsx)(`span`,{className:`absolute inset-x-6 inset-y-5 rounded-[6px] bg-surface/40`,style:{backdropFilter:`blur(${e.light?.value})`}})]})}):null,o.length?(0,R.jsx)(TI,{tokens:o}):null]})}var DI={font:`Family`,text:`Size`,weight:`Weight`,leading:`Line height`,tracking:`Letter spacing`};function OI(e){return e.kind===`text`?[e.light?.value,e.lineHeight].filter(Boolean).join(` / `):e.light?.value??``}function kI({system:e}){let[t,n]=yM(),r=hM(e.tokens,`font`,`text`,`weight`,`leading`,`tracking`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Typography`,sub:`Set in the design system's own stylesheet, with its fonts.`}),e.typographyUrl?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Specimen`,right:(0,R.jsx)(bM,{value:t,onChange:n})}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(jM,{src:e.typographyUrl,theme:t,title:`Typography specimen`,minHeight:200})})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Tokens`,count:r.length}),(0,R.jsx)(W_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,labels:[`Token`,`Kind`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,minH:42,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:DI[e.kind]}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:OI(e)})]},e.name))]}):(0,R.jsxs)(SM,{title:`No type tokens`,children:[`Add font families (`,(0,R.jsx)(Z,{children:`--font-*`}),`), sizes (`,(0,R.jsx)(Z,{children:`--text-*`}),` with`,` `,(0,R.jsx)(Z,{children:`--text-*--line-height`}),`) and weights (`,(0,R.jsx)(Z,{children:`--font-weight-*`}),`) to the `,(0,R.jsx)(Z,{children:`@theme`}),` `,`block in `,(0,R.jsx)(Z,{children:CM}),`. Web fonts go in `,(0,R.jsx)(Z,{children:`system.json`}),` `,(0,R.jsx)(Z,{children:`fonts`}),`.`]})]})}function AI({system:e}){let[t]=I();return(0,R.jsx)(`main`,{className:`mx-auto flex w-full max-w-[1440px] grow animate-[q-fade-in_160ms_ease-out] px-8 max-md:px-4`,children:(0,R.jsxs)(`div`,{className:`grid w-full items-start gap-6 max-lg:grid-cols-1! max-lg:gap-0`,style:{gridTemplateColumns:`232px minmax(0, 1fr)`},children:[(0,R.jsx)(`aside`,{className:`sticky top-[52px] flex max-h-[calc(100dvh-52px)] flex-col overflow-y-auto pt-6 pb-4 max-lg:static max-lg:max-h-none max-lg:overflow-visible max-lg:pb-0 max-md:pt-4`,children:(0,R.jsx)(lI,{system:e})}),(0,R.jsx)(`div`,{className:`flex min-w-0 animate-[q-fade-in_160ms_ease-out] flex-col gap-5 pt-6 pb-7`,children:(0,R.jsxs)(xe,{children:[(0,R.jsx)(L,{path:`/system`,children:(0,R.jsx)(vI,{system:e})}),(0,R.jsx)(L,{path:`/system/colors`,children:(0,R.jsx)(AM,{system:e})}),(0,R.jsx)(L,{path:`/system/typography`,children:(0,R.jsx)(kI,{system:e})}),(0,R.jsx)(L,{path:`/system/shape`,children:(0,R.jsx)(EI,{system:e})}),(0,R.jsx)(L,{path:`/system/motion`,children:(0,R.jsx)(cI,{system:e})}),(0,R.jsx)(L,{path:`/system/tokens`,children:(0,R.jsx)(fI,{system:e})}),(0,R.jsx)(L,{path:`/system/assets`,children:(0,R.jsx)(EM,{system:e})}),(0,R.jsx)(L,{path:`/system/guidelines/:slug`,children:t=>(0,R.jsx)(eI,{system:e,slug:decodeURIComponent(t.slug)})}),(0,R.jsx)(L,{path:`/system/components/:id`,children:t=>(0,R.jsx)(QF,{system:e,id:decodeURIComponent(t.id)})}),(0,R.jsx)(L,{children:(0,R.jsx)(zO,{title:`No such page`,text:`This page is not part of the design system.`})})]})},t)]})})}function jI(){return(0,R.jsx)(tv,{title:`No design system yet`,text:(0,R.jsxs)(R.Fragment,{children:[`Ask your agent to build one from the codebase, or run `,(0,R.jsx)(Z,{children:`design system init`}),` to start from a template in `,(0,R.jsx)(Z,{children:`.design/system`}),`.`]})})}function MI(){let e=r_().data,t=e?e.system!==null:void 0,{data:n,error:r,isLoading:i}=a_(t===!0);return t===!1||n===null||r instanceof Ig&&r.status===404?(0,R.jsx)(jI,{}):r?(0,R.jsx)(tv,{title:`Could not load the design system`,text:r.message}):i||!n?null:(0,R.jsx)(AI,{system:n})}function NI(){let{name:e,icon:t}=r_().data??{};return(0,v.useEffect)(()=>{e&&(document.title=`${e} · Design`)},[e]),(0,v.useEffect)(()=>{let e=document.querySelector(`link[rel="icon"]`);e&&(e.dataset.fallback??=e.getAttribute(`href`)??``,e.removeAttribute(`type`),e.href=t||e.dataset.fallback)},[t]),null}var PI=new URLSearchParams(window.location.search).has(`capture`);function FI(){let e=Tw()&&!PI;return{play:(t,n)=>e?(0,R.jsx)(Kj,{canvasId:t,itemId:n}):(0,R.jsx)(Uj,{canvasId:t,itemId:n}),canvas:(t,n)=>e?(0,R.jsx)(Kj,{canvasId:t,pageId:n}):(0,R.jsx)(Cj,{canvasId:t,pageId:n})}}function II(){let e=FI();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(L,{path:`/c/:canvas/full/:item`,children:e=>(0,R.jsx)(aj,{canvasId:e.canvas,itemId:e.item})}),(0,R.jsx)(L,{path:`/c/:canvas/play/:item`,children:t=>e.play(t.canvas,t.item)}),(0,R.jsx)(L,{path:`/c/:canvas/board/:page`,children:e=>(0,R.jsx)(Ij,{canvasId:e.canvas,pageId:e.page})}),(0,R.jsx)(L,{path:`/c/:canvas/markup/:item`,children:e=>(0,R.jsx)(zj,{canvasId:e.canvas,itemId:e.item})}),(0,R.jsx)(L,{path:`/c/:canvas/p/:page`,children:t=>e.canvas(t.canvas,t.page)}),(0,R.jsx)(L,{path:`/c/:canvas`,children:t=>e.canvas(t.canvas)}),(0,R.jsxs)(L,{path:`/system/*?`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(MI,{})]}),(0,R.jsxs)(L,{path:`/`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(pM,{})]}),(0,R.jsxs)(L,{children:[(0,R.jsx)(xw,{}),(0,R.jsx)(zO,{})]})]})}function LI({canvas:e}){let t=`/c/${encodeURIComponent(e)}`,n=(n,r)=>t_(n,e)?r:(0,R.jsx)(Se,{to:t,replace:!0}),r=FI();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(L,{path:`/c/:canvas/full/:item`,children:t=>n(t.canvas,(0,R.jsx)(aj,{canvasId:e,itemId:t.item}))}),(0,R.jsx)(L,{path:`/c/:canvas/play/:item`,children:t=>n(t.canvas,r.play(e,t.item))}),(0,R.jsx)(L,{path:`/c/:canvas/p/:page`,children:t=>n(t.canvas,r.canvas(e,t.page))}),(0,R.jsx)(L,{path:`/c/:canvas`,children:t=>n(t.canvas,r.canvas(e))}),(0,R.jsx)(L,{children:(0,R.jsx)(Se,{to:t,replace:!0})})]})}function RI({source:e,base:t=``,frameSandbox:n,frameAllow:r=Yg,slots:i,scope:a,queryClient:o}){let[s]=(0,v.useState)(()=>o??n_(e.live)),c=o??s,l=(0,v.useMemo)(()=>Jg(Qg(e)),[e]),u=a?.canvas,d=(0,v.useMemo)(()=>({source:e,keys:l,frameSandbox:n,frameAllow:r,slots:i??{},scope:u===void 0?null:{canvas:u}}),[e,l,n,r,i,u]);return(0,v.useEffect)(()=>e.live?s_(c,l):void 0,[e,c,l]),(0,R.jsx)(Ne,{client:c,children:(0,R.jsx)($g.Provider,{value:d,children:(0,R.jsx)(ad,{reducedMotion:`user`,children:(0,R.jsxs)(Dx,{children:[(0,R.jsx)(NI,{}),(0,R.jsxs)(ge,{base:t,children:[(0,R.jsx)(iv,{children:d.scope?(0,R.jsx)(LI,{canvas:d.scope.canvas}):(0,R.jsx)(II,{})}),(0,R.jsx)(D_,{})]}),(0,R.jsx)(PT,{})]})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(v.StrictMode,{children:Fg?(0,R.jsx)(ge,{hook:ke,hrefs:e=>`#${e}`,children:(0,R.jsx)(RI,{source:Ug})}):(0,R.jsx)(RI,{source:Vg})}));
|
|
165
|
+
`)}),(0,R.jsx)(`pre`,{className:`m-0 min-w-0 grow py-3 pr-6 pl-4 text-ink`,children:(0,R.jsx)(`code`,{dangerouslySetInnerHTML:{__html:i}})})]})]})}var WF={beta:`action`,experimental:`action`,draft:`action`,deprecated:`danger`,stable:`ok`},GF=`.design/system/components/`;function KF(e){return e.startsWith(GF)?`@system/components/${e.slice(26).replace(/\.(tsx|jsx|ts|js)$/,``).replace(/\/index$/,``)}`:null}function qF(e){let t=new Set;for(let n of e.matchAll(/export\s+(?:async\s+)?(?:function|const|class|let)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);for(let n of e.matchAll(/export\s*\{([^}]+)\}/g))for(let e of n[1].split(`,`)){let n=e.trim().split(/\s+as\s+/).pop()?.trim();n&&n!=="default"&&t.add(n)}return[...t].filter(e=>/^[A-Z]/.test(e))}function JF({path:e}){let t=KF(e),n=o_(t?e:null).data;if(!t)return null;let r=n?qF(n):[],i=`import { ${r.length?r.join(`, `):`…`} } from '${t}'`;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-rule py-1.5 pr-1.5 pl-4`,children:[(0,R.jsx)(Z,{size:12.5,className:`min-w-0 truncate text-ink2`,title:i,children:i}),(0,R.jsx)(N_,{icon:`copy`,label:`Copy the import`,size:14,className:`ml-auto`,onClick:()=>FT(i)})]})}function YF({component:e,theme:t,width:n}){return n===`fill`?(0,R.jsx)(jM,{src:e.url,theme:t,title:e.title,minHeight:160}):(0,R.jsx)(`div`,{className:`flex justify-center overflow-x-auto bg-soft p-6`,children:(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden rounded-[8px] border border-rule bg-surface shadow-frame`,children:(0,R.jsx)(jM,{src:e.url,theme:t,title:e.title,minHeight:160,width:Number(n)})})})}function XF({component:e}){let t=[...e.sources,e.specimen],[n,r]=(0,v.useState)(t[0]),i=t.includes(n)?n:t[0],{data:a,error:o,isLoading:s}=o_(i);return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[t.length>1?(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-rule px-4 py-2.5`,children:(0,R.jsx)(YA,{label:`File`,size:`sm`,value:i,onChange:r,items:t.map(t=>({value:t,label:t===e.specimen?`${ZF(t)} · specimen`:ZF(t),title:t}))})}):null,KF(i)?(0,R.jsx)(JF,{path:i}):null,o?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-6 text-[13px] text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:15}),o.message]}):s||a===void 0?(0,R.jsx)(`div`,{className:`flex items-center justify-center py-10 text-muted`,children:(0,R.jsx)(X,{name:`loader`,size:18})}):(0,R.jsx)(UF,{code:a,path:i})]})}function ZF(e){return e.split(`/`).pop()??e}function QF({system:e,id:t}){let n=e.components.find(e=>e.id===t),[r,i]=(0,v.useState)(`preview`),[a,o]=yM(),[s,c]=(0,v.useState)(`fill`),l=!e_().frameSandbox;if(!n)return(0,R.jsx)(zO,{title:`No such component`,text:`There is no specimen "${t}" in .design/system/specimens.`});let u=n.status?.toLowerCase();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,badge:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(L_,{children:n.group}),u?(0,R.jsx)(L_,{tone:WF[u]??`neutral`,children:n.status}):null]}),sub:n.description}),(0,R.jsxs)(z_,{children:[(0,R.jsx)(V_,{value:r,onChange:i,items:[{value:`preview`,label:`Preview`},{value:`code`,label:`Code`,count:n.sources.length+1}],right:r===`preview`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(YA,{label:`Width`,size:`sm`,value:s,onChange:c,items:[{value:`fill`,label:`Fill`},{value:`768`,label:`768`},{value:`390`,label:`390`}]}),(0,R.jsx)(bM,{value:a,onChange:o}),l?(0,R.jsx)(F_,{icon:`external`,href:hO(mO(n.url,a)),target:`_blank`,rel:`noreferrer`,children:`Open`}):null]}):null}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:r===`preview`?(0,R.jsx)(YF,{component:n,theme:a,width:s}):(0,R.jsx)(XF,{component:n})})]})]})}function $F(e,t){let n=/^\s*#\s+(.+)\r?\n/.exec(e);return n&&n[1].trim()===t?e.slice(n[0].length):e}function eI({system:e,slug:t}){let n=e.guidelines.find(e=>e.slug===t);if(!n)return(0,R.jsx)(zO,{title:`No such guideline`,text:`There is no guideline "${t}" in .design/system/guidelines.`});let r=$F(n.markdown,n.title).trim();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,sub:`Guideline`}),(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:r?(0,R.jsx)(VD,{text:r,className:`max-w-[760px]`}):(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`This guideline is empty. Write it in `,(0,R.jsx)(Z,{children:`.design/system/guidelines`}),`.`]})})})]})}var tI={linear:[0,0,1,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]};function nI(e){let t=e.trim();if(tI[t])return tI[t];let n=/^cubic-bezier\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)$/.exec(t);if(!n)return null;let r=n.slice(1).map(Number);return r.every(Number.isFinite)?r:null}function rI(e){let t=/^(-?[\d.]+)(ms|s)$/.exec(e.trim());return t?Number(t[1])*(t[2]===`s`?1e3:1):null}var iI=132,aI=22;function oI({bezier:e}){let[t,n,r,i]=e,a=Math.min(0,n,i),o=Math.max(1,n,i),s=88/(o-a),c=e=>aI+e*88,l=e=>aI+(o-e)*s;return(0,R.jsxs)(`svg`,{width:iI,height:iI,viewBox:`0 0 ${iI} ${iI}`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,R.jsx)(`rect`,{x:c(0),y:l(1),width:88,height:l(0)-l(1),className:`fill-none stroke-rule`}),(0,R.jsx)(`line`,{x1:c(0),y1:l(0),x2:c(t),y2:l(n),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`line`,{x1:c(1),y1:l(1),x2:c(r),y2:l(i),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`path`,{d:`M ${c(0)} ${l(0)} C ${c(t)} ${l(n)}, ${c(r)} ${l(i)}, ${c(1)} ${l(1)}`,className:`fill-none stroke-ink`,strokeWidth:2,strokeLinecap:`round`}),(0,R.jsx)(`circle`,{cx:c(t),cy:l(n),r:3,className:`fill-action`}),(0,R.jsx)(`circle`,{cx:c(r),cy:l(i),r:3,className:`fill-action`})]})}function sI({token:e,duration:t}){let[n,r]=(0,v.useState)(!1),i=e.light?.value??``,a=nI(i);return(0,R.jsxs)(`button`,{type:`button`,title:`Hover to play; click to copy the variable`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),onClick:()=>FT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col gap-3 rounded-[8px] border border-transparent bg-transparent p-3 text-left transition-colors hover:border-rule hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex h-[132px] items-center justify-center rounded-[6px] bg-soft`,children:a?(0,R.jsx)(oI,{bezier:a}):(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`No curve to draw`})}),(0,R.jsx)(`span`,{className:`relative mx-1 h-2 rounded-full bg-soft2`,children:(0,R.jsx)(`span`,{className:`absolute top-1/2 size-3.5 -translate-y-1/2 rounded-full bg-ink`,style:{left:n?`calc(100% - 14px)`:`0px`,transition:`left ${t}ms ${i||`ease`}`}})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:i}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function cI({system:e}){let t=hM(e.tokens,`ease`),n=hM(e.tokens,`duration`),r=hM(e.tokens,`animation`),i=`minmax(170px,1fr) 100px minmax(0,2fr)`,a=`minmax(170px,1fr) minmax(140px,0.7fr) minmax(0,2fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Motion`,sub:`Hover an easing to see it move.`}),!t.length&&!n.length&&!r.length?(0,R.jsxs)(SM,{title:`No motion tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--ease-*`}),` and `,(0,R.jsx)(Z,{children:`--animate-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block, and durations as`,` `,(0,R.jsx)(Z,{children:`--duration-*`}),`, in `,(0,R.jsx)(Z,{children:CM}),`.`]}):null,t.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Easing`,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(190px, 1fr))`},children:t.map(e=>(0,R.jsx)(sI,{token:e,duration:900},e.name))})]}):null,n.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Durations`,count:n.length}),(0,R.jsx)(W_,{cols:i,labels:[`Token`,`Value`,``]}),n.map(e=>{let t=e.light?rI(e.light.value):null;return(0,R.jsxs)(K_,{cols:i,minH:40,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),t===null?(0,R.jsx)(`span`,{}):(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(t/2,480))}})]},e.name)})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Animations`,count:r.length,sub:`keyframes live in the system stylesheet`}),(0,R.jsx)(W_,{cols:a,labels:[`Token`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:a,minH:40,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:e.light?.value})]},e.name))]}):null]})}function lI({system:e}){let t=Tw(),n=new Set(e.tokens.map(e=>e.kind)),r=[{to:`/system/colors`,label:`Colors`,hint:uI(e,`color`)},{to:`/system/typography`,label:`Typography`},{to:`/system/shape`,label:`Spacing & shape`}];(n.has(`ease`)||n.has(`duration`)||n.has(`animation`))&&r.push({to:`/system/motion`,label:`Motion`}),n.has(`other`)&&r.push({to:`/system/tokens`,label:`Other tokens`,hint:uI(e,`other`)}),e.assets.length&&r.push({to:`/system/assets`,label:`Assets`,hint:e.assets.length});let i=new Map;for(let t of e.components){let e=i.get(t.group)??[];e.push({to:`/system/components/${encodeURIComponent(t.id)}`,label:t.title,hint:t.status}),i.set(t.group,e)}let a=e.guidelines.filter(e=>e.slug!==`overview`);if(t){let e=[{label:``,items:[{to:`/system`,label:`Overview`}]},{label:`Foundations`,items:r},{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))},...[...i].map(([e,t])=>({label:e,items:t}))];return(0,R.jsx)(dI,{sections:e.filter(e=>e.items.length)})}return(0,R.jsxs)(`div`,{className:`flex flex-col max-lg:gap-1 max-lg:[&_nav]:flex-row max-lg:[&_nav]:flex-wrap`,children:[(0,R.jsx)(Q_,{label:`Overview`,items:[{to:`/system`,label:`Overview`}]}),(0,R.jsx)($_,{children:`Foundations`}),(0,R.jsx)(Q_,{label:`Foundations`,items:r}),a.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)($_,{children:`Guidelines`}),(0,R.jsx)(Q_,{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))})]}):null,[...i].map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsx)($_,{children:e}),(0,R.jsx)(Q_,{label:e,items:t})]},e))]})}function uI(e,t){return e.tokens.filter(e=>e.kind===t).length||void 0}function dI({sections:e}){let[t]=I(),[n,r]=(0,v.useState)(!1),i=e.flatMap(e=>e.items).find(e=>e.to===t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex h-11 w-full cursor-pointer items-center gap-2 rounded-[8px] border border-rule bg-surface px-3.5 text-left text-[14px] text-ink`,children:[(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`Section`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate font-medium`,children:i?.label??`Overview`}),(0,R.jsx)(X,{name:`chevron-down`,size:16,className:`shrink-0 text-muted`})]}),(0,R.jsx)(Bj,{open:n,onOpenChange:r,title:`Design system`,children:(0,R.jsx)(`nav`,{"aria-label":`Design system`,className:`flex flex-col pb-2`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.label?(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.label}):null,e.items.map(e=>{let n=e.to===t;return(0,R.jsxs)(ye,{href:e.to,onClick:()=>r(!1),"aria-current":n?`page`:void 0,className:J(`flex min-h-[46px] items-center gap-2 px-4 text-[14px] no-underline active:bg-soft2`,n?`font-medium text-ink`:`text-ink2`),children:[(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:e.hint}):null,n?(0,R.jsx)(X,{name:`check`,size:16,className:`shrink-0 text-action`}):null]},e.to)})]},e.label||`overview`))})})]})}function fI({system:e}){let t=hM(e.tokens,`other`),n=`minmax(170px,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1.3fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Other tokens`,sub:`Variables that are not colors, type, spacing, shape or motion.`}),t.length?gM(t).map(({group:e,tokens:t})=>(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(W_,{cols:n,labels:[`Token`,`Light`,`Dark`,`Description`]}),t.map(e=>(0,R.jsxs)(K_,{cols:n,minH:40,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(wM,{children:e.light?.value}),(0,R.jsx)(wM,{children:e.dark?.value??`—`}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:e.description})]},e.name))]},e)):(0,R.jsxs)(SM,{title:`No other tokens`,children:[`Variables in `,(0,R.jsx)(Z,{children:`:root`}),` of `,(0,R.jsx)(Z,{children:CM}),` that are not colors or lengths show here.`]})]})}function pI(e,...t){return e.tokens.filter(e=>t.includes(e.kind)).length}function mI(e){let t=[{to:`/system/colors`,icon:`palette`,title:`Colors`,text:nM(pI(e,`color`),`token`)},{to:`/system/typography`,icon:`type`,title:`Typography`,text:`${nM(pI(e,`font`),`family`,`families`)} · ${nM(pI(e,`text`),`size`)}`},{to:`/system/shape`,icon:`shape`,title:`Spacing & shape`,text:nM(pI(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),`token`)}],n=pI(e,`ease`,`duration`,`animation`);n&&t.push({to:`/system/motion`,icon:`motion`,title:`Motion`,text:nM(n,`token`)}),e.assets.length&&t.push({to:`/system/assets`,icon:`image`,title:`Assets`,text:nM(e.assets.length,`file`)});let r=e.components[0];return r&&t.push({to:`/system/components/${encodeURIComponent(r.id)}`,icon:`component`,title:`Components`,text:nM(e.components.length,`component`)}),t}function hI({system:e}){return(0,R.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`},children:mI(e).map(e=>(0,R.jsxs)(ye,{href:e.to,className:`flex items-center gap-3 rounded-[10px] border border-rule bg-surface px-4 py-3.5 text-inherit no-underline transition-colors hover:border-rule-strong hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[8px] bg-soft2 text-ink2`,children:(0,R.jsx)(X,{name:e.icon,size:17})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[14px] font-medium text-ink`,children:e.title}),(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.text})]})]},e.to))})}function gI({system:e}){let[,t]=I(),n=[{label:`Color tokens`,value:pI(e,`color`),to:`/system/colors`},{label:`Type tokens`,value:pI(e,`font`,`text`,`weight`,`leading`,`tracking`),to:`/system/typography`},{label:`Spacing & shape tokens`,value:pI(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),to:`/system/shape`},{label:`Motion tokens`,value:pI(e,`ease`,`duration`,`animation`),to:`/system/motion`},{label:`Other tokens`,value:pI(e,`other`),to:`/system/tokens`},{label:`Components`,value:e.components.length},{label:`Guidelines`,value:e.guidelines.length}];return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`At a glance`}),n.filter(e=>e.value||!e.to||e.to===`/system/colors`).map(e=>(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,onClick:e.to&&e.value?()=>t(e.to):void 0,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:e.label}),(0,R.jsx)(R_,{value:e.value})]},e.label)),e.fonts.length?(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:`Web fonts`}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5`,children:e.fonts.map(e=>(0,R.jsx)(Z,{size:12,className:`max-w-[260px] truncate text-muted`,title:e,children:_I(e)},e))})]}):null]})}function _I(e){try{let t=new URL(e),n=t.searchParams.getAll(`family`).map(e=>e.split(`:`)[0].replace(/\+/g,` `));return n.length?n.join(`, `):t.host}catch{return e}}function vI({system:e}){let t=e.guidelines.find(e=>e.slug===`overview`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:e.name,sub:e.description}),(0,R.jsx)(AO,{issues:e.issues,title:`Problems in the design system`}),(0,R.jsx)(hI,{system:e}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-xl:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 320px`},children:[t?(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:(0,R.jsx)(VD,{text:t.markdown})})}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Overview`}),(0,R.jsxs)(`div`,{className:`border-t border-rule px-4 py-5 text-[13px] text-muted`,children:[`Write the principles every screen follows in `,(0,R.jsx)(Z,{children:`.design/system/guidelines/01-overview.md`}),`; it shows here.`]})]}),(0,R.jsx)(gI,{system:e})]})]})}var yI=[1,2,3,4,6,8,12,16],bI=480;function xI({px:e}){return e===null?(0,R.jsx)(`span`,{className:`text-[12px] text-muted`,children:`not a plain length, so no bar`}):(0,R.jsx)(`span`,{className:J(`block h-3 rounded-[3px] bg-action/70`,e>bI&&`mask-r-from-80%`),style:{width:Math.max(2,Math.min(e,bI))},title:`${e}px`})}function SI({value:e}){return(0,R.jsx)(`span`,{className:`min-w-0 font-mono text-[12px] leading-snug text-muted [overflow-wrap:anywhere]`,title:e,children:e})}function CI({tokens:e}){let t=e.find(e=>e.name===`--spacing`),n=e.filter(e=>e!==t),r=t?.light?_M(t.light.value):null,i=`minmax(150px,0.8fr) minmax(0,160px) minmax(0,2fr)`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Spacing`,count:e.length,sub:t?`base ${t.light?.value}`:void 0}),(0,R.jsx)(W_,{cols:i,labels:[`Class or token`,`Value`,``]}),t&&r!==null?yI.map(e=>(0,R.jsxs)(K_,{cols:i,minH:36,pad:`6px 16px`,children:[(0,R.jsxs)(Z,{size:12.5,className:`text-ink`,children:[`p-`,e,` · gap-`,e]}),(0,R.jsxs)(Z,{size:12,className:`text-muted`,children:[r*e,`px`]}),(0,R.jsx)(xI,{px:r*e})]},e)):null,n.map(e=>(0,R.jsxs)(K_,{cols:i,minH:40,pad:`6px 16px`,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(SI,{value:e.light?.value}),(0,R.jsx)(xI,{px:e.light?_M(e.light.value):null})]},e.name))]})}function wI({token:e,children:t}){return(0,R.jsxs)(`button`,{type:`button`,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col items-stretch gap-2.5 rounded-[8px] border border-transparent bg-transparent p-2 text-left transition-colors hover:border-rule hover:bg-soft`,children:[t,(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:e.light?.value}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function TI({title:e,tokens:t,min:n=170,children:r}){return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(${n}px, 1fr))`},children:t.map(e=>(0,R.jsx)(wI,{token:e,children:r(e)},e.name))})]})}function EI({tokens:e}){let t=`minmax(170px,1fr) minmax(90px,0.6fr) 110px 90px`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Breakpoints`,count:e.length}),(0,R.jsx)(W_,{cols:t,labels:[`Token`,`Variant`,`Value`,`Pixels`],align:`lllr`}),e.map(e=>{let n=e.light?_M(e.light.value):null;return(0,R.jsxs)(K_,{cols:t,align:`lllr`,minH:40,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:n===null?``:`${n}px`})]},e.name)})]})}function DI({system:e}){let t=b_(),n=hM(e.tokens,`spacing`),r=hM(e.tokens,`radius`),i=hM(e.tokens,`shadow`),a=hM(e.tokens,`blur`),o=hM(e.tokens,`breakpoint`),s=!n.length&&!r.length&&!i.length&&!a.length&&!o.length;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Spacing & shape`,sub:`Click a token to copy its variable.`}),s?(0,R.jsxs)(SM,{title:`No spacing or shape tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--spacing`}),` (the base step), `,(0,R.jsx)(Z,{children:`--spacing-*`}),`, `,(0,R.jsx)(Z,{children:`--radius-*`}),`,`,` `,(0,R.jsx)(Z,{children:`--shadow-*`}),` and `,(0,R.jsx)(Z,{children:`--breakpoint-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block in`,` `,(0,R.jsx)(Z,{children:CM}),`.`]}):null,n.length?(0,R.jsx)(CI,{tokens:n}):null,r.length?(0,R.jsx)(TI,{title:`Radii`,tokens:r,children:e=>(0,R.jsx)(`span`,{className:`flex h-[88px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`size-14 border border-rule-strong bg-surface`,style:{borderRadius:e.light?.value}})})}):null,i.length?(0,R.jsx)(TI,{title:`Shadows`,tokens:i,min:200,children:e=>(0,R.jsx)(`span`,{className:`flex h-[112px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`h-[60px] w-[108px] rounded-[8px] bg-surface`,style:{boxShadow:vM(e,t)}})})}):null,a.length?(0,R.jsx)(TI,{title:`Blur`,tokens:a,children:e=>(0,R.jsxs)(`span`,{className:`relative flex h-[88px] items-center justify-center overflow-hidden rounded-[6px] bg-soft`,children:[(0,R.jsx)(`span`,{className:`absolute left-5 top-4 size-10 rounded-full bg-action`}),(0,R.jsx)(`span`,{className:`absolute right-6 bottom-3 size-12 rounded-[6px] bg-ink2`}),(0,R.jsx)(`span`,{className:`absolute inset-x-6 inset-y-5 rounded-[6px] bg-surface/40`,style:{backdropFilter:`blur(${e.light?.value})`}})]})}):null,o.length?(0,R.jsx)(EI,{tokens:o}):null]})}var OI={font:`Family`,text:`Size`,weight:`Weight`,leading:`Line height`,tracking:`Letter spacing`};function kI(e){return e.kind===`text`?[e.light?.value,e.lineHeight].filter(Boolean).join(` / `):e.light?.value??``}function AI({system:e}){let[t,n]=yM(),r=hM(e.tokens,`font`,`text`,`weight`,`leading`,`tracking`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Typography`,sub:`Set in the design system's own stylesheet, with its fonts.`}),e.typographyUrl?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Specimen`,right:(0,R.jsx)(bM,{value:t,onChange:n})}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(jM,{src:e.typographyUrl,theme:t,title:`Typography specimen`,minHeight:200})})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Tokens`,count:r.length}),(0,R.jsx)(W_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,labels:[`Token`,`Kind`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,minH:42,title:`Copy the variable`,onClick:()=>FT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:OI[e.kind]}),(0,R.jsx)(xM,{items:mM(e)}),(0,R.jsx)(wM,{children:kI(e)})]},e.name))]}):(0,R.jsxs)(SM,{title:`No type tokens`,children:[`Add font families (`,(0,R.jsx)(Z,{children:`--font-*`}),`), sizes (`,(0,R.jsx)(Z,{children:`--text-*`}),` with`,` `,(0,R.jsx)(Z,{children:`--text-*--line-height`}),`) and weights (`,(0,R.jsx)(Z,{children:`--font-weight-*`}),`) to the `,(0,R.jsx)(Z,{children:`@theme`}),` `,`block in `,(0,R.jsx)(Z,{children:CM}),`. Web fonts go in `,(0,R.jsx)(Z,{children:`system.json`}),` `,(0,R.jsx)(Z,{children:`fonts`}),`.`]})]})}function jI({system:e}){let[t]=I();return(0,R.jsx)(`main`,{className:`mx-auto flex w-full max-w-[1440px] grow animate-[q-fade-in_160ms_ease-out] px-8 max-md:px-4`,children:(0,R.jsxs)(`div`,{className:`grid w-full items-start gap-6 max-lg:grid-cols-1! max-lg:gap-0`,style:{gridTemplateColumns:`232px minmax(0, 1fr)`},children:[(0,R.jsx)(`aside`,{className:`sticky top-[52px] flex max-h-[calc(100dvh-52px)] flex-col overflow-y-auto pt-6 pb-4 max-lg:static max-lg:max-h-none max-lg:overflow-visible max-lg:pb-0 max-md:pt-4`,children:(0,R.jsx)(lI,{system:e})}),(0,R.jsx)(`div`,{className:`flex min-w-0 animate-[q-fade-in_160ms_ease-out] flex-col gap-5 pt-6 pb-7`,children:(0,R.jsxs)(xe,{children:[(0,R.jsx)(L,{path:`/system`,children:(0,R.jsx)(vI,{system:e})}),(0,R.jsx)(L,{path:`/system/colors`,children:(0,R.jsx)(AM,{system:e})}),(0,R.jsx)(L,{path:`/system/typography`,children:(0,R.jsx)(AI,{system:e})}),(0,R.jsx)(L,{path:`/system/shape`,children:(0,R.jsx)(DI,{system:e})}),(0,R.jsx)(L,{path:`/system/motion`,children:(0,R.jsx)(cI,{system:e})}),(0,R.jsx)(L,{path:`/system/tokens`,children:(0,R.jsx)(fI,{system:e})}),(0,R.jsx)(L,{path:`/system/assets`,children:(0,R.jsx)(EM,{system:e})}),(0,R.jsx)(L,{path:`/system/guidelines/:slug`,children:t=>(0,R.jsx)(eI,{system:e,slug:decodeURIComponent(t.slug)})}),(0,R.jsx)(L,{path:`/system/components/:id`,children:t=>(0,R.jsx)(QF,{system:e,id:decodeURIComponent(t.id)})}),(0,R.jsx)(L,{children:(0,R.jsx)(zO,{title:`No such page`,text:`This page is not part of the design system.`})})]})},t)]})})}function MI(){return(0,R.jsx)(tv,{title:`No design system yet`,text:(0,R.jsxs)(R.Fragment,{children:[`Ask your agent to build one from the codebase, or run `,(0,R.jsx)(Z,{children:`design system init`}),` to start from a template in `,(0,R.jsx)(Z,{children:`.design/system`}),`.`]})})}function NI(){let e=r_().data,t=e?e.system!==null:void 0,{data:n,error:r,isLoading:i}=a_(t===!0);return t===!1||n===null||r instanceof Ig&&r.status===404?(0,R.jsx)(MI,{}):r?(0,R.jsx)(tv,{title:`Could not load the design system`,text:r.message}):i||!n?null:(0,R.jsx)(jI,{system:n})}function PI(){let{name:e,icon:t}=r_().data??{};return(0,v.useEffect)(()=>{e&&(document.title=`${e} · Design`)},[e]),(0,v.useEffect)(()=>{let e=document.querySelector(`link[rel="icon"]`);e&&(e.dataset.fallback??=e.getAttribute(`href`)??``,e.removeAttribute(`type`),e.href=t||e.dataset.fallback)},[t]),null}var FI=new URLSearchParams(window.location.search).has(`capture`);function II(){let e=Tw()&&!FI;return{play:(t,n)=>e?(0,R.jsx)(Kj,{canvasId:t,itemId:n}):(0,R.jsx)(Uj,{canvasId:t,itemId:n}),canvas:(t,n)=>e?(0,R.jsx)(Kj,{canvasId:t,pageId:n}):(0,R.jsx)(Cj,{canvasId:t,pageId:n})}}function LI(){let e=II();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(L,{path:`/c/:canvas/full/:item`,children:e=>(0,R.jsx)(aj,{canvasId:e.canvas,itemId:e.item})}),(0,R.jsx)(L,{path:`/c/:canvas/play/:item`,children:t=>e.play(t.canvas,t.item)}),(0,R.jsx)(L,{path:`/c/:canvas/board/:page`,children:e=>(0,R.jsx)(Ij,{canvasId:e.canvas,pageId:e.page})}),(0,R.jsx)(L,{path:`/c/:canvas/markup/:item`,children:e=>(0,R.jsx)(zj,{canvasId:e.canvas,itemId:e.item})}),(0,R.jsx)(L,{path:`/c/:canvas/p/:page`,children:t=>e.canvas(t.canvas,t.page)}),(0,R.jsx)(L,{path:`/c/:canvas`,children:t=>e.canvas(t.canvas)}),(0,R.jsxs)(L,{path:`/system/*?`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(NI,{})]}),(0,R.jsxs)(L,{path:`/`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(pM,{})]}),(0,R.jsxs)(L,{children:[(0,R.jsx)(xw,{}),(0,R.jsx)(zO,{})]})]})}function RI({canvas:e}){let t=`/c/${encodeURIComponent(e)}`,n=(n,r)=>t_(n,e)?r:(0,R.jsx)(Se,{to:t,replace:!0}),r=II();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(L,{path:`/c/:canvas/full/:item`,children:t=>n(t.canvas,(0,R.jsx)(aj,{canvasId:e,itemId:t.item}))}),(0,R.jsx)(L,{path:`/c/:canvas/play/:item`,children:t=>n(t.canvas,r.play(e,t.item))}),(0,R.jsx)(L,{path:`/c/:canvas/p/:page`,children:t=>n(t.canvas,r.canvas(e,t.page))}),(0,R.jsx)(L,{path:`/c/:canvas`,children:t=>n(t.canvas,r.canvas(e))}),(0,R.jsx)(L,{children:(0,R.jsx)(Se,{to:t,replace:!0})})]})}function zI({source:e,base:t=``,frameSandbox:n,frameAllow:r=Yg,slots:i,scope:a,queryClient:o}){let[s]=(0,v.useState)(()=>o??n_(e.live)),c=o??s,l=(0,v.useMemo)(()=>Jg(Qg(e)),[e]),u=a?.canvas,d=(0,v.useMemo)(()=>({source:e,keys:l,frameSandbox:n,frameAllow:r,slots:i??{},scope:u===void 0?null:{canvas:u}}),[e,l,n,r,i,u]);return(0,v.useEffect)(()=>e.live?s_(c,l):void 0,[e,c,l]),(0,R.jsx)(Ne,{client:c,children:(0,R.jsx)($g.Provider,{value:d,children:(0,R.jsx)(ad,{reducedMotion:`user`,children:(0,R.jsxs)(Dx,{children:[(0,R.jsx)(PI,{}),(0,R.jsxs)(ge,{base:t,children:[(0,R.jsx)(iv,{children:d.scope?(0,R.jsx)(RI,{canvas:d.scope.canvas}):(0,R.jsx)(LI,{})}),(0,R.jsx)(D_,{})]}),(0,R.jsx)(PT,{})]})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(v.StrictMode,{children:Fg?(0,R.jsx)(ge,{hook:ke,hrefs:e=>`#${e}`,children:(0,R.jsx)(zI,{source:Ug})}):(0,R.jsx)(zI,{source:Vg})}));
|