moi-computer 0.10.1-next.4 → 0.10.1-next.5
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/README.md +2 -0
- package/client/features/chat/ChatPopup.tsx +2 -1
- package/dist/{chunk-gbp4m9p2.js → chunk-ewwv181c.js} +1 -1
- package/dist/{chunk-jpdn7nx7.js → chunk-r5y4gtdk.js} +1 -1
- package/dist/chunk-r8s1b672.css +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-4vyggdzq.css +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
THE UI FOR YOUR AI
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
[](https://www.npmjs.com/package/moi-computer) [](https://discord.gg/nydjacJrT)
|
|
10
|
+
|
|
9
11
|
An extendable visual workspace where your AI agents build their own UI.
|
|
10
12
|
See [moi.computer](https://moi.computer) for what it is and how it works.
|
|
11
13
|
|
|
@@ -66,11 +66,12 @@ export function ChatPopup({
|
|
|
66
66
|
preset={agent}
|
|
67
67
|
color="primary"
|
|
68
68
|
animated={loading}
|
|
69
|
+
size={loading ? 80 : 64}
|
|
69
70
|
expression={loading ? 'thinking' : undefined}
|
|
70
71
|
className={cn(
|
|
71
72
|
'drop-shadow-md drop-shadow-primary/25',
|
|
72
73
|
'group-hover:drop-shadow-lg group-hover:drop-shadow-primary/40',
|
|
73
|
-
'transition-[filter] duration-
|
|
74
|
+
'transition-[width,height,filter] duration-300 ease-in-out motion-reduce:transition-none'
|
|
74
75
|
)}
|
|
75
76
|
/>
|
|
76
77
|
</button>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_c as r}from"/chunk-v7wr1df4.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function o(a){let[{mount:t}]=await Promise.all([import("/chunk-
|
|
1
|
+
import{_c as r}from"/chunk-v7wr1df4.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function o(a){let[{mount:t}]=await Promise.all([import("/chunk-r5y4gtdk.js"),import("/chunk-kmbxhgwv.js").then((e)=>e.loadAppConfig())]);t(a)}globalThis.__init=o;
|
|
@@ -75,7 +75,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),T=k,c=b;if(v===void 0)
|
|
|
75
75
|
`)}function kv($,Z){let H=N70($,Z),B=L70(H,Z);return V70(B)}var lZ1={TokenTypes:vU,TokenMap:new Map(vU.map(($,Z)=>[$,Z]))};var fV=O(d(),1),D70=s("[--sh-identifier:#1f2937]","[--sh-keyword:#cf222e]","[--sh-string:#16a34a]","[--sh-class:#2d6e7e]","[--sh-property:#0550ae]","[--sh-entity:#6f42c1]","[--sh-jsxliterals:#6f42c1]","[--sh-sign:#8b949e]","[--sh-comment:#9ca3af]");function yv({code:$,className:Z}){let H=bv.useMemo(()=>kv($),[$]);return fV.jsx("pre",{className:s("overflow-auto font-mono text-xs leading-relaxed whitespace-pre",D70,Z),children:fV.jsx("code",{className:"font-mono",dangerouslySetInnerHTML:{__html:H}})})}var q70={ts:"ts",tsx:"tsx",js:"js",jsx:"jsx",mjs:"js",cjs:"js",json:"json",md:"md",mdx:"mdx",css:"css",scss:"scss",html:"html",py:"py",rb:"rb",go:"go",rs:"rs",java:"java",c:"c",h:"c",cpp:"cpp",sh:"sh",bash:"sh",yml:"yaml",yaml:"yaml",toml:"toml",sql:"sql",php:"php",swift:"swift",kt:"kt"};function M70($){let Z=$.split(/[\\/]/).pop()??"",H=Z.lastIndexOf("."),B=H>0?Z.slice(H+1).toLowerCase():"";return q70[B]??null}function P70($){let Z=$.trim();if(Z.length<2||!(Z.startsWith("{")||Z.startsWith("[")))return null;try{return JSON.stringify(JSON.parse(Z),null,2)}catch{return null}}function _70($){let Z=$.split(`
|
|
76
76
|
`);if(!Z.some((H)=>/^\s*\d+\t/.test(H)))return $;return Z.map((H)=>H.replace(/^\s*\d+\t/,"")).join(`
|
|
77
77
|
`)}function hv($,Z){let H=$.input??{},B=typeof H.file_path==="string"?H.file_path:typeof H.path==="string"?H.path:"",J=B?M70(B):null,Q=$.name==="Read"||$.name==="read",X=$.name==="Write"||$.name==="write";if(J&&Q&&Z)return{kind:"highlight",code:_70(Z),label:J};if(J&&X&&typeof H.content==="string"&&H.content)return{kind:"highlight",code:H.content,label:J};let z=P70(Z);if(z)return{kind:"highlight",code:z,label:"json"};return{kind:"plain"}}var B4=O(d(),1),mV="max-h-[280px] overflow-auto px-3 py-2.5 font-mono text-xs leading-relaxed";function xv({call:$,output:Z,isError:H}){let[B,J]=S7.useState(!1),Q=S7.useMemo(()=>H?{kind:"plain"}:hv($,Z),[$,Z,H]);if(Q.kind==="plain")return B4.jsx("div",{className:s("rounded-lg border",H?"border-destructive/30 bg-destructive/10":"border-border bg-muted"),children:B4.jsx("pre",{className:s(mV,"break-all whitespace-pre-wrap",H?"text-destructive":"text-muted-foreground"),children:Z||"(empty)"})});return B4.jsxs("div",{className:"overflow-hidden rounded-lg border border-border bg-muted",children:[B4.jsx(O70,{raw:B,onRaw:J,label:Q.label,copyText:B?Z:Q.code}),B?B4.jsx("pre",{className:s(mV,"break-all whitespace-pre-wrap text-muted-foreground"),children:Z||"(empty)"}):B4.jsx(yv,{code:Q.code,className:s(mV,"text-muted-foreground")})]})}function O70({raw:$,onRaw:Z,label:H,copyText:B}){return B4.jsxs("div",{className:"flex items-center gap-1 border-b border-border p-2",children:[[[!1,H],[!0,"raw"]].map(([Q,X])=>B4.jsx(T0,{type:"button",variant:$===Q?"outline":"ghost",size:"sm",onClick:()=>Z(Q),className:"rounded-full text-xs uppercase",children:X},X)),B4.jsx("div",{className:"flex-1"}),B4.jsx(j70,{text:B})]})}function j70({text:$}){let[Z,H]=S7.useState(!1);return S7.useEffect(()=>{if(!Z)return;let J=setTimeout(()=>H(!1),1500);return()=>clearTimeout(J)},[Z]),B4.jsx(T0,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>{navigator.clipboard?.writeText($).then(()=>H(!0)).catch(()=>{})},"aria-label":Z?"Copied":"Copy",children:Z?B4.jsx(A3,{stroke:1.75}):B4.jsx(sX,{stroke:1.75})})}var S1=O(d(),1);function fU({parts:$,cwd:Z=null,processing:H=!1}){let B=$.filter((J)=>J.type==="reasoning"||J.type==="tool-call");return S1.jsx("div",{className:"flex flex-col",children:B.map((J,Q)=>{let X=Q===B.length-1,z={isFirst:Q===0,isLast:X};if(J.type==="reasoning")return S1.jsx(T70,{text:J.text,durationMs:J.durationMs,inProgress:H&&X,...z},Q);return S1.jsx(C70,{call:J.call,cwd:Z,...z},J.call.toolCallId||Q)})})}function pV({isFirst:$,isLast:Z,call:H,leading:B,marker:J,name:Q,brief:X,preview:z}){let[G,F]=uV.useState(!1),U=H.state==="error",Y=H.state==="running"||H.state==="pending",K=U?H.errorText??"":typeof H.output==="string"?H.output:"",W=!!(K||U||z),N=X?`${Q}: ${X}`:Q;return S1.jsx(RZ,{isFirst:$,isLast:Z,marker:J,loading:Y,isError:U,children:S1.jsxs("div",{className:"min-w-0 flex-1",children:[S1.jsxs("button",{type:"button",title:N,onClick:()=>W&&F((L)=>!L),className:s(yU,W?"cursor-pointer":"cursor-default"),children:[B,S1.jsx("span",{className:"shrink-0 text-xs font-medium whitespace-nowrap",children:Q}),X&&S1.jsx("span",{className:"min-w-0 self-baseline truncate text-[12px] text-muted-foreground",children:X}),Y&&J&&S1.jsx(I5,{size:12,stroke:1.75,className:"shrink-0 animate-spin text-muted-foreground"}),W&&S1.jsx(DJ,{open:G})]}),W&&S1.jsx(AJ,{open:G,children:S1.jsxs("div",{className:"mt-1 mb-1 flex flex-col gap-1.5",children:[z,(K||U)&&S1.jsx(xv,{call:H,output:K,isError:U})]})})]})})}function T70({isFirst:$,isLast:Z,text:H,inProgress:B=!1,durationMs:J}){let[Q,X]=uV.useState(!1);if(!H){let F=J===void 0?"Thought":`Thought for ${E7(J)}`;return S1.jsx(RZ,{isFirst:$,isLast:Z,loading:B,children:S1.jsx("div",{className:s(yU,"min-w-0 flex-1 cursor-default"),children:S1.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:B?"Thinking":F})})})}let z=B?"Thinking":"Thought",G=B||Q;return S1.jsx(RZ,{isFirst:$,isLast:Z,loading:B,children:S1.jsxs("div",{className:"min-w-0 flex-1",children:[S1.jsxs("button",{type:"button","aria-expanded":G,onClick:()=>X((F)=>!F),className:s(yU,"cursor-pointer"),children:[S1.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:z}),S1.jsx(DJ,{open:G})]}),S1.jsx(AJ,{open:G,children:S1.jsx("div",{className:"mt-1 mb-1 pr-2 text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground",children:S1.jsx(dh,{content:H})})})]})})}function C70({call:$,cwd:Z,isFirst:H,isLast:B}){if($.caller==="subagent")return S1.jsx(Ov,{call:$,cwd:Z,isFirst:H,isLast:B,renderNestedParts:(X,z)=>S1.jsx(fU,{parts:X,cwd:z})});if($.name==="Skill"&&$.skill){let X=$.state==="success";return S1.jsx(pV,{isFirst:H,isLast:B,call:$,marker:X?S1.jsx(ax,{icon:vv,size:16,stroke:1.75}):void 0,name:"Loading skill",brief:$.skill.skillName})}let J=wV($)??EV($)??SV($);if(J){let X=IV(J.server,J.tool);return S1.jsx(pV,{isFirst:H,isLast:B,call:$,marker:S1.jsx(nx,{src:RU(J.server)}),name:kU(J.server),brief:J.rest?`${X} ${J.rest}`:X})}let Q=$.state==="error"?null:cx($,Z);return S1.jsx(pV,{isFirst:H,isLast:B,call:$,leading:S1.jsx(w70,{call:$}),name:Dv($),brief:qv($,Z),preview:Q?S1.jsx(dx,{relPath:Q}):void 0})}function w70({call:$}){if($.caller!=="mcp"&&$.caller!=="server-tool")return null;let Z=$.caller==="mcp"?`mcp${$.mcpServer?`:${$.mcpServer.slice(0,8)}`:""}`:"server";return S1.jsx("span",{className:"shrink-0 rounded border border-border px-1 text-[9px] text-muted-foreground uppercase",children:Z})}var I1=O(d(),1);function mv($){if($.type==="reasoning")return!0;if($.type==="tool-call")return!0;return!1}function E70($){let Z=[];for(let H of $)if(mv(H)){let B=Z[Z.length-1];if(B&&B.kind==="run")B.parts.push(H);else Z.push({kind:"run",parts:[H]})}else Z.push({kind:"single",part:H});return Z}function mU({parts:$,cwd:Z,processing:H=!1}){let B=E70($);return I1.jsx("div",{className:"flex flex-col",children:B.map((J,Q)=>{let X=Q===0?"":"mt-3",z=Q===B.length-1;return I1.jsx("div",{className:X,children:J.kind==="run"?I1.jsx(fU,{parts:J.parts,cwd:Z,processing:H&&z}):I1.jsx(b70,{part:J.part})},Q)})})}function S70($){return $.some((Z)=>Z.type!=="text"||Z.text.trim().length>0)}function I70($){let Z=-1;for(let B=$.length-1;B>=0;B--)if(mv($[B])){Z=B;break}if(Z<0)return null;let H=$.slice(Z+1);if(!S70(H))return null;return{work:$.slice(0,Z+1),response:H}}function R70({parts:$,cwd:Z,durationMs:H,defaultOpen:B}){let J=H===void 0?"Worked":`Worked for ${E7(H)}`;return I1.jsxs(QG,{defaultOpen:B,className:"group/collapsible",children:[I1.jsxs(XG,{className:"flex w-fit items-center gap-1 rounded-sm py-1 text-left text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[I1.jsx("span",{children:J}),I1.jsx(X7,{size:16,stroke:1.5,className:"shrink-0 transition-transform group-data-open/collapsible:rotate-90"})]}),I1.jsx(zG,{className:"overflow-hidden pt-2",children:I1.jsx(mU,{parts:$,cwd:Z})})]})}function k70({parts:$,cwd:Z,processing:H=!1,durationMs:B}){let J=H?null:I70($);return I1.jsx("div",{className:"w-full min-w-0",children:H?I1.jsx(mU,{parts:$,cwd:Z,processing:!0}):J?I1.jsxs("div",{className:"flex flex-col gap-3",children:[I1.jsx(R70,{parts:J.work,cwd:Z,durationMs:B}),I1.jsx(mU,{parts:J.response,cwd:Z})]}):I1.jsx(mU,{parts:$,cwd:Z})})}var pv=fv.memo(function({turn:Z,processing:H=!1}){let B=K5().cwd;if(Z.role==="user"&&Z.origin.kind==="user-input"){let J=Z.parts.filter((X)=>X.type==="file"),Q=Z.parts.filter((X)=>X.type==="text").map((X)=>X.type==="text"?X.text:"").join(`
|
|
78
|
-
`);if(!Q&&J.length===0)return null;return I1.jsxs("div",{className:"flex w-full min-w-0 flex-col items-end gap-1.5 pl-8",children:[J.map((X,z)=>I1.jsx(uv,{mediaType:X.mediaType,url:X.url,filename:X.filename},z)),Q&&I1.jsx("p",{className:s("max-w-full min-w-0 rounded-lg bg-primary px-3 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-primary-foreground","inset-shadow-[0_0_10px_color-mix(in_oklab,var(--color-white)_30%,transparent)]"),children:Q})]})}return I1.jsx(k70,{parts:Z.parts,cwd:B,processing:H,durationMs:Z.meta?.durationMs})});function b70({part:$}){switch($.type){case"text":return I1.jsx(ch,{content:$.text});case"tool-call":return I1.jsx(fU,{parts:[$],cwd:null});case"file":return I1.jsx(uv,{mediaType:$.mediaType,url:$.url,filename:$.filename});case"source-url":return I1.jsx(gv,{url:$.url,title:$.title});case"source-document":return I1.jsx(gv,{url:"#",title:$.title});case"data":return I1.jsx(y70,{name:$.name,data:$.data});case"reasoning":return null}}function uv({mediaType:$,url:Z,filename:H}){if($.startsWith("image/")&&Z)return I1.jsx("img",{src:Z,alt:H??"attachment",className:"max-h-64 max-w-full rounded-lg border border-border object-contain"});return I1.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-border bg-accent px-2.5 py-1.5 text-xs text-accent-foreground",children:[I1.jsx(YZ,{size:16,stroke:1.75}),I1.jsx("span",{className:"truncate",children:H??$})]})}function gv({url:$,title:Z}){return I1.jsx("a",{href:$,target:"_blank",rel:"noreferrer",className:"text-xs underline",children:Z??$})}function y70({name:$,data:Z}){return I1.jsxs("details",{children:[I1.jsxs("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:["data:",$]}),I1.jsx("pre",{className:"mt-1 overflow-auto rounded bg-muted p-2 font-mono text-xs text-muted-foreground",children:JSON.stringify(Z,null,2)})]})}var U5=O(d(),1),h70=[],x70=[];function pU({agent:$,active:Z=!0,focusRequest:H=0,docked:B=!1,chatLoaded:J,hasWorkspaceApplets:Q,view:X,previewTurn:z,sessionId:G,processing:F,composerBanner:U,agentAvailability:Y,annotation:K,send:W,stop:N,onNavigateFromWelcome:L,onClose:V,builderDraft:A}){let D=H5(),q=x4.useRef(null),_=x4.useRef(null),M=A?.sessionId??G??null,P=A?null:G??null,C=A?h70:X.turns,R=j5((p)=>p.hasSentMessageFromMoi),y=j5((p)=>(p.workspaceIdsPendingAnalysis??[]).includes(D)),w=_2((p)=>(p.attachments[t2(D,M)]??[]).some((X0)=>X0.status==="uploading")),h=!bB(!0,w,Y),E=A?null:z,I=A?x70:X.notices,j=x4.useMemo(()=>bE(E?[...C,E]:C),[C,E]),S=x4.useMemo(()=>hE(j,I),[j,I]),k=j.length>0?j[j.length-1].id:null,b=A?!1:F,v=!!A||J&&S.length===0&&!b,c=J&&!v,T=YR({isViewBuilderDraft:!!A,hasSentMessageFromMoi:R,isWorkspacePendingAnalysis:y}),{atBottom:e,scrollToBottom:Z0,scrollToTop:x}=kE(_,M);x4.useLayoutEffect(()=>{if(v&&T!=="empty")x()},[v,T,x]),x4.useEffect(()=>{if(Z)nN(q.current)},[Z,H]);let t=x4.useCallback(async(p,X0)=>{if(A)await A.onSubmit(p);else W(p,X0);Z0()},[A,W,Z0]),D0=x4.useCallback((p)=>{if(h)return;t(p.prompt,{directives:p.context})},[t,h]);return U5.jsxs("div",{className:"flex min-h-0 flex-1 flex-col pt-2 pb-3",children:[U5.jsxs("header",{className:"mx-auto flex w-full max-w-[calc(var(--chat-max-container)+40px)] items-center justify-between pr-2 pb-2 pl-2",children:[U5.jsx(VR,{isViewBuilder:!!A}),V&&B&&U5.jsxs(y1,{children:[U5.jsx(h1,{render:U5.jsx(T0,{variant:"ghost",size:"icon-sm",onClick:V,"aria-label":"Undock agent",children:U5.jsx(cv,{className:"size-5! text-muted-foreground",stroke:1.5})})}),U5.jsx(x1,{children:"Undock agent"})]}),!A&&V&&!B&&U5.jsx(T0,{variant:"ghost",size:"icon-sm",onClick:V,"aria-label":"Close chat",children:U5.jsx(S5,{stroke:2})})]}),U5.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[U5.jsx("div",{ref:_,className:"flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-8 [--scroll-fade-reveal:8px]",children:U5.jsxs("div",{className:"mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6",children:[v&&U5.jsx(KR,{agent:$,kind:T,hasWorkspaceApplets:Q,disabled:h,onSelectPrompt:D0,onNavigate:L}),c&&S.map((p)=>p.kind==="notice"?U5.jsx(v70,{notice:p.notice},`notice:${p.notice.id}`):U5.jsx(pv,{turn:p.turn,processing:b&&p.turn.id===k},p.turn.id)),c&&U5.jsx("div",{className:"mt-auto -ml-3 pt-2",children:U5.jsx(K9,{preset:$,color:"primary",animated:b,expression:b?"thinking":void 0})})]})}),c&&!e&&C.length>0&&U5.jsx(T0,{type:"button",variant:"outline",size:"icon",onClick:()=>Z0("smooth"),"aria-label":"Jump to latest",className:"absolute bottom-3 left-1/2 -translate-x-1/2 animate-in rounded-full fade-in slide-in-from-bottom-1",children:U5.jsx(hF,{stroke:1.5})})]}),U5.jsx("div",{className:"mx-auto flex w-full max-w-[calc(var(--chat-max-container)+24px)] flex-col px-3",children:U5.jsxs("div",{className:s("@container flex w-full flex-col transition-[padding]",U&&"gap-2 rounded-t-lg rounded-b-2xl p-2",U?.tone==="default"&&"bg-accent",U?.tone==="error"&&"bg-destructive/10"),children:[U?.content,U5.jsx(XR,{composerRef:q,onSend:t,onStop:N,processing:b,sessionId:M,modelSessionId:P,availability:Y,annotation:A?void 0:K,onRemoveDrawing:A?.onRemoveDrawing??K?.onRemove,allowFiles:!A,placeholder:A?"Drop in the details":void 0,draft:A?{id:A.builderId,initialValue:A.initialValue,onChange:A.onChange}:void 0})]})})]})}function v70({notice:$}){let Z=oN($);if(!Z)return null;return U5.jsx("div",{className:"flex justify-center",children:U5.jsx("span",{className:"max-w-full truncate text-xs text-muted-foreground",children:Z})})}var l9=O(d(),1);function dv({agent:$,loading:Z,open:H,onOpenChange:B,onOpenChangeComplete:J,children:Q}){let X=()=>B(!1);return l9.jsxs(DF,{open:H,onOpenChange:(G,F)=>{if(!G&&F.reason==="outside-press"){F.cancel();return}B(G)},onOpenChangeComplete:J,children:[l9.jsx(qF,{render:l9.jsx("div",{className:"fixed right-4 bottom-4 sm:right-4 sm:bottom-4",children:l9.jsx(B5.div,{variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"},invisible:{opacity:0,scale:1,filter:"blur(4px)"}},initial:"from",animate:H?"invisible":"to",transition:{type:"spring",duration:0.3,delay:0.2,bounce:0},children:l9.jsx("button",{type:"button",className:"group block cursor-pointer rounded-xl p-0 outline-none focus-visible:ring-3 focus-visible:ring-ring/50","aria-label":"Agent",children:l9.jsx(K9,{preset:$,color:"primary",animated:Z,expression:Z?"thinking":void 0,className:s("drop-shadow-md drop-shadow-primary/25","group-hover:drop-shadow-lg group-hover:drop-shadow-primary/40","transition-[filter] duration-400 ease-in-out motion-reduce:transition-none")})})})})}),l9.jsx(MF,{positionMethod:"fixed",side:"top",sideOffset:-56,align:"end",className:"flex h-[calc(100vh-2rem)] w-[min(440px,calc(100vw-1rem))] flex-col gap-0 rounded-3xl p-0 sm:h-[calc(100vh-8rem)] sm:w-[min(440px,calc(100vw-2rem))] sm:p-1",keepMounted:!0,children:Q(X)})]})}var s3=O(d(),1);function uU({className:$,title:Z,children:H,onClose:B,ref:J}){return s3.jsxs(B5.div,{ref:J,className:s("absolute inset-x-4 bottom-4 no-scrollbar flex max-h-full flex-col gap-4 overflow-y-auto rounded-2xl bg-card text-card-foreground shadow-md","mx-auto max-w-[calc(var(--chat-max-container)+var(--page-pad)*2)] p-(--page-pad) pb-0",$),variants:{hidden:{opacity:0,y:40,filter:"blur(4px)"},visible:{opacity:1,y:0,filter:"blur(0px)"}},initial:"hidden",animate:"visible",exit:"hidden",transition:{type:"spring",duration:0.25,bounce:0},children:[s3.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-4",children:[s3.jsx("p",{className:"text-sm font-medium",children:Z}),s3.jsx(T0,{type:"button",variant:"ghost",size:"icon-sm",onClick:B,"aria-label":"Close panel",children:s3.jsx(S5,{stroke:1.75})})]}),s3.jsx("div",{className:"flex-1 pb-(--page-pad)",children:H})]})}var $5=O(d(),1),g70=Object.entries(R3),f70=Object.entries(ez),m70=Object.entries(CB),p70=Object.entries(wB),u70="relative w-full rounded-lg bg-card text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50";function cU({children:$,className:Z,gridClassName:H,label:B}){return $5.jsxs("div",{className:s("flex flex-col gap-2",Z),children:[$5.jsx("p",{className:"text-xs font-medium",children:B}),$5.jsx("div",{role:"group","aria-label":B,className:s("grid grid-cols-4 gap-2 @4xl/workspace:grid-cols-2",H),children:$})]})}function dU({active:$,children:Z,className:H,onSelect:B,style:J}){return $5.jsxs("button",{type:"button","aria-pressed":$,onClick:B,className:s(u70,"flex items-center gap-2 p-3",H,!$&&"cursor-pointer pr-9 opacity-70 hover:opacity-100"),style:J,children:[$5.jsx("div",{className:"flex flex-1 flex-col justify-center",children:Z}),$&&$5.jsx(tX,{size:20,stroke:1.5,"aria-hidden":"true"})]})}function lv({onClose:$,ref:Z}){UG();let{layout:H,setLayout:B}=K5(),J=j8(H.theme);function Q(X){B({theme:{...J,...X}})}return $5.jsx(uU,{ref:Z,title:"Customize",onClose:$,className:"@4xl/workspace:max-w-5xl",children:$5.jsxs("div",{className:"grid grid-cols-1 gap-4 @4xl/workspace:grid-cols-[repeat(2,minmax(0,1fr))_0.5rem_repeat(2,minmax(0,1fr))_0.5rem_minmax(0,1fr)_0.5rem_minmax(0,1fr)] @4xl/workspace:gap-x-2",children:[$5.jsx(cU,{label:"Font",className:"@4xl/workspace:col-span-2 @4xl/workspace:col-start-1",children:g70.map(([X,z])=>$5.jsx(dU,{active:X===J.font,onSelect:()=>Q({font:X}),style:{fontFamily:z.sans},children:$5.jsx("span",{className:"text-sm font-medium",children:z.label})},X))}),$5.jsx(cU,{label:"Colors",className:"@4xl/workspace:col-span-2 @4xl/workspace:col-start-4",children:f70.map(([X,z])=>$5.jsx(dU,{active:X===J.color,className:z.primary&&"bg-background text-foreground",onSelect:()=>Q({color:X}),style:T8({...J,color:X}),children:$5.jsxs("div",{className:"flex gap-2",children:[$5.jsx("span",{className:s("flex size-5 shrink-0 items-center justify-center rounded-sm text-[9px] leading-none font-bold",z.primary?"bg-primary text-primary-foreground":"bg-foreground text-background"),children:"Aa"}),$5.jsx("span",{className:"text-sm font-medium",children:z.label})]})},X))}),$5.jsx(cU,{label:"Radius",className:"@4xl/workspace:col-start-7",gridClassName:"@4xl/workspace:grid-cols-1",children:m70.map(([X,z])=>$5.jsx(dU,{active:X===J.radius,onSelect:()=>Q({radius:X}),style:T8({...J,radius:X}),children:$5.jsxs("div",{className:"flex items-center gap-2",children:[$5.jsx("span",{className:"size-5 shrink-0 rounded-sm bg-card texture-checker-2.5 shadow-xs","aria-hidden":"true"}),$5.jsx("span",{className:"text-sm font-medium",children:z.label})]})},X))}),$5.jsx(cU,{label:"Agent",className:"@4xl/workspace:col-start-9",gridClassName:"@4xl/workspace:grid-cols-1",children:p70.map(([X,z])=>$5.jsx(dU,{active:X===J.agent,onSelect:()=>Q({agent:X}),children:$5.jsxs("div",{className:"flex items-center gap-2",children:[$5.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:$5.jsx(K9,{preset:X,color:"primary",size:28})}),$5.jsx("span",{className:"text-sm font-medium",children:z.label})]})},X))})]})})}var YY=O(g(),1);var xZ=O(g(),1);function iv($){return o1({queryKey:w0.appletThumbnails($),queryFn:async()=>(await V1(`/api/workspaces/${$}/applet-thumbnails`)).thumbnails,...y4})}function rv($){let Z=Z1();return s1({mutationFn:(H)=>S4(`/api/workspaces/${$}/applet-thumbnails`,n5("PUT",H),"Failed to save applet thumbnails"),onSuccess:()=>{Z.invalidateQueries({queryKey:w0.appletThumbnails($)}),Z.invalidateQueries({queryKey:w0.preview($)})}})}var c70=1000,d70=3,l70=10800000,i70=1000,r70="1000px-3x-webp-q80-v1",a70=5000,n70=1000,o70=1e4;function s70($){return Math.min(d70,c70/Math.max($.offsetWidth,$.offsetHeight))}function t70($){return`${r70}:${$??""}`}function e70($,Z,H=Date.now()){if(!$||$.revision!==Z)return!0;let B=Date.parse($.capturedAt);return!Number.isFinite(B)||H-B>=l70}function $$0($,Z){return $!==void 0&&$.revision===Z&&$.captureMs!==void 0&&$.captureMs>=i70}var Z$0=($)=>new Promise((Z)=>{setTimeout(()=>Z(null),$)});async function H$0($,Z){let{createContext:H,destroyContext:B,domToDataUrl:J}=await import("/chunk-c9pjqx9m.js"),Q=async()=>{let X=await H($,{scale:s70($),type:"image/webp",quality:0.8,backgroundColor:"#ffffff",timeout:n70,...Z&&{onCreateForeignObjectSvg:(z)=>{let G=document.createElement("style");G.textContent="[data-widget-chrome] { border-radius: 0 !important; box-shadow: none !important; }[data-widget-chrome]::after { display: none !important; }",z.append(G)}}});try{return await J(X)}finally{B(X)}};return Promise.race([Q(),Z$0(o70)])}async function B$0($,Z,H,B,J=H$0,Q=Date.now()){let X=[];for(let z of H){if(B())return null;let G=t70(z.revision),F=Z.find((W)=>W.kind===$&&W.id===z.id);if(!e70(F,G,Q)){X.push({id:z.id,revision:G});continue}if($$0(F,G)){X.push({id:z.id,revision:G});continue}if(!z.element){X.push({id:z.id,revision:G,image:null});continue}let U=performance.now(),Y=await J(z.element,$==="widget").catch(()=>null),K=Math.round(performance.now()-U);if(B())return null;X.push({id:z.id,revision:G,image:Y,captureMs:K})}return X}function lU({kind:$,enabled:Z,targets:H}){let B=H5(),J=iv(B).data,Q=rv(B),X=xZ.useRef(H);X.current=H;let z=xZ.useRef(J??[]);z.current=J??[];let G=xZ.useRef(Q.mutate);G.current=Q.mutate;let F=H.map((Y)=>`${Y.id}@${Y.revision??""}`).join(`
|
|
78
|
+
`);if(!Q&&J.length===0)return null;return I1.jsxs("div",{className:"flex w-full min-w-0 flex-col items-end gap-1.5 pl-8",children:[J.map((X,z)=>I1.jsx(uv,{mediaType:X.mediaType,url:X.url,filename:X.filename},z)),Q&&I1.jsx("p",{className:s("max-w-full min-w-0 rounded-lg bg-primary px-3 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-primary-foreground","inset-shadow-[0_0_10px_color-mix(in_oklab,var(--color-white)_30%,transparent)]"),children:Q})]})}return I1.jsx(k70,{parts:Z.parts,cwd:B,processing:H,durationMs:Z.meta?.durationMs})});function b70({part:$}){switch($.type){case"text":return I1.jsx(ch,{content:$.text});case"tool-call":return I1.jsx(fU,{parts:[$],cwd:null});case"file":return I1.jsx(uv,{mediaType:$.mediaType,url:$.url,filename:$.filename});case"source-url":return I1.jsx(gv,{url:$.url,title:$.title});case"source-document":return I1.jsx(gv,{url:"#",title:$.title});case"data":return I1.jsx(y70,{name:$.name,data:$.data});case"reasoning":return null}}function uv({mediaType:$,url:Z,filename:H}){if($.startsWith("image/")&&Z)return I1.jsx("img",{src:Z,alt:H??"attachment",className:"max-h-64 max-w-full rounded-lg border border-border object-contain"});return I1.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-border bg-accent px-2.5 py-1.5 text-xs text-accent-foreground",children:[I1.jsx(YZ,{size:16,stroke:1.75}),I1.jsx("span",{className:"truncate",children:H??$})]})}function gv({url:$,title:Z}){return I1.jsx("a",{href:$,target:"_blank",rel:"noreferrer",className:"text-xs underline",children:Z??$})}function y70({name:$,data:Z}){return I1.jsxs("details",{children:[I1.jsxs("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:["data:",$]}),I1.jsx("pre",{className:"mt-1 overflow-auto rounded bg-muted p-2 font-mono text-xs text-muted-foreground",children:JSON.stringify(Z,null,2)})]})}var U5=O(d(),1),h70=[],x70=[];function pU({agent:$,active:Z=!0,focusRequest:H=0,docked:B=!1,chatLoaded:J,hasWorkspaceApplets:Q,view:X,previewTurn:z,sessionId:G,processing:F,composerBanner:U,agentAvailability:Y,annotation:K,send:W,stop:N,onNavigateFromWelcome:L,onClose:V,builderDraft:A}){let D=H5(),q=x4.useRef(null),_=x4.useRef(null),M=A?.sessionId??G??null,P=A?null:G??null,C=A?h70:X.turns,R=j5((p)=>p.hasSentMessageFromMoi),y=j5((p)=>(p.workspaceIdsPendingAnalysis??[]).includes(D)),w=_2((p)=>(p.attachments[t2(D,M)]??[]).some((X0)=>X0.status==="uploading")),h=!bB(!0,w,Y),E=A?null:z,I=A?x70:X.notices,j=x4.useMemo(()=>bE(E?[...C,E]:C),[C,E]),S=x4.useMemo(()=>hE(j,I),[j,I]),k=j.length>0?j[j.length-1].id:null,b=A?!1:F,v=!!A||J&&S.length===0&&!b,c=J&&!v,T=YR({isViewBuilderDraft:!!A,hasSentMessageFromMoi:R,isWorkspacePendingAnalysis:y}),{atBottom:e,scrollToBottom:Z0,scrollToTop:x}=kE(_,M);x4.useLayoutEffect(()=>{if(v&&T!=="empty")x()},[v,T,x]),x4.useEffect(()=>{if(Z)nN(q.current)},[Z,H]);let t=x4.useCallback(async(p,X0)=>{if(A)await A.onSubmit(p);else W(p,X0);Z0()},[A,W,Z0]),D0=x4.useCallback((p)=>{if(h)return;t(p.prompt,{directives:p.context})},[t,h]);return U5.jsxs("div",{className:"flex min-h-0 flex-1 flex-col pt-2 pb-3",children:[U5.jsxs("header",{className:"mx-auto flex w-full max-w-[calc(var(--chat-max-container)+40px)] items-center justify-between pr-2 pb-2 pl-2",children:[U5.jsx(VR,{isViewBuilder:!!A}),V&&B&&U5.jsxs(y1,{children:[U5.jsx(h1,{render:U5.jsx(T0,{variant:"ghost",size:"icon-sm",onClick:V,"aria-label":"Undock agent",children:U5.jsx(cv,{className:"size-5! text-muted-foreground",stroke:1.5})})}),U5.jsx(x1,{children:"Undock agent"})]}),!A&&V&&!B&&U5.jsx(T0,{variant:"ghost",size:"icon-sm",onClick:V,"aria-label":"Close chat",children:U5.jsx(S5,{stroke:2})})]}),U5.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[U5.jsx("div",{ref:_,className:"flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-8 [--scroll-fade-reveal:8px]",children:U5.jsxs("div",{className:"mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6",children:[v&&U5.jsx(KR,{agent:$,kind:T,hasWorkspaceApplets:Q,disabled:h,onSelectPrompt:D0,onNavigate:L}),c&&S.map((p)=>p.kind==="notice"?U5.jsx(v70,{notice:p.notice},`notice:${p.notice.id}`):U5.jsx(pv,{turn:p.turn,processing:b&&p.turn.id===k},p.turn.id)),c&&U5.jsx("div",{className:"mt-auto -ml-3 pt-2",children:U5.jsx(K9,{preset:$,color:"primary",animated:b,expression:b?"thinking":void 0})})]})}),c&&!e&&C.length>0&&U5.jsx(T0,{type:"button",variant:"outline",size:"icon",onClick:()=>Z0("smooth"),"aria-label":"Jump to latest",className:"absolute bottom-3 left-1/2 -translate-x-1/2 animate-in rounded-full fade-in slide-in-from-bottom-1",children:U5.jsx(hF,{stroke:1.5})})]}),U5.jsx("div",{className:"mx-auto flex w-full max-w-[calc(var(--chat-max-container)+24px)] flex-col px-3",children:U5.jsxs("div",{className:s("@container flex w-full flex-col transition-[padding]",U&&"gap-2 rounded-t-lg rounded-b-2xl p-2",U?.tone==="default"&&"bg-accent",U?.tone==="error"&&"bg-destructive/10"),children:[U?.content,U5.jsx(XR,{composerRef:q,onSend:t,onStop:N,processing:b,sessionId:M,modelSessionId:P,availability:Y,annotation:A?void 0:K,onRemoveDrawing:A?.onRemoveDrawing??K?.onRemove,allowFiles:!A,placeholder:A?"Drop in the details":void 0,draft:A?{id:A.builderId,initialValue:A.initialValue,onChange:A.onChange}:void 0})]})})]})}function v70({notice:$}){let Z=oN($);if(!Z)return null;return U5.jsx("div",{className:"flex justify-center",children:U5.jsx("span",{className:"max-w-full truncate text-xs text-muted-foreground",children:Z})})}var l9=O(d(),1);function dv({agent:$,loading:Z,open:H,onOpenChange:B,onOpenChangeComplete:J,children:Q}){let X=()=>B(!1);return l9.jsxs(DF,{open:H,onOpenChange:(G,F)=>{if(!G&&F.reason==="outside-press"){F.cancel();return}B(G)},onOpenChangeComplete:J,children:[l9.jsx(qF,{render:l9.jsx("div",{className:"fixed right-4 bottom-4 sm:right-4 sm:bottom-4",children:l9.jsx(B5.div,{variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"},invisible:{opacity:0,scale:1,filter:"blur(4px)"}},initial:"from",animate:H?"invisible":"to",transition:{type:"spring",duration:0.3,delay:0.2,bounce:0},children:l9.jsx("button",{type:"button",className:"group block cursor-pointer rounded-xl p-0 outline-none focus-visible:ring-3 focus-visible:ring-ring/50","aria-label":"Agent",children:l9.jsx(K9,{preset:$,color:"primary",animated:Z,size:Z?80:64,expression:Z?"thinking":void 0,className:s("drop-shadow-md drop-shadow-primary/25","group-hover:drop-shadow-lg group-hover:drop-shadow-primary/40","transition-[width,height,filter] duration-300 ease-in-out motion-reduce:transition-none")})})})})}),l9.jsx(MF,{positionMethod:"fixed",side:"top",sideOffset:-56,align:"end",className:"flex h-[calc(100vh-2rem)] w-[min(440px,calc(100vw-1rem))] flex-col gap-0 rounded-3xl p-0 sm:h-[calc(100vh-8rem)] sm:w-[min(440px,calc(100vw-2rem))] sm:p-1",keepMounted:!0,children:Q(X)})]})}var s3=O(d(),1);function uU({className:$,title:Z,children:H,onClose:B,ref:J}){return s3.jsxs(B5.div,{ref:J,className:s("absolute inset-x-4 bottom-4 no-scrollbar flex max-h-full flex-col gap-4 overflow-y-auto rounded-2xl bg-card text-card-foreground shadow-md","mx-auto max-w-[calc(var(--chat-max-container)+var(--page-pad)*2)] p-(--page-pad) pb-0",$),variants:{hidden:{opacity:0,y:40,filter:"blur(4px)"},visible:{opacity:1,y:0,filter:"blur(0px)"}},initial:"hidden",animate:"visible",exit:"hidden",transition:{type:"spring",duration:0.25,bounce:0},children:[s3.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-4",children:[s3.jsx("p",{className:"text-sm font-medium",children:Z}),s3.jsx(T0,{type:"button",variant:"ghost",size:"icon-sm",onClick:B,"aria-label":"Close panel",children:s3.jsx(S5,{stroke:1.75})})]}),s3.jsx("div",{className:"flex-1 pb-(--page-pad)",children:H})]})}var $5=O(d(),1),g70=Object.entries(R3),f70=Object.entries(ez),m70=Object.entries(CB),p70=Object.entries(wB),u70="relative w-full rounded-lg bg-card text-left ring-1 ring-border transition-opacity outline-none focus-visible:ring-3 focus-visible:ring-ring/50";function cU({children:$,className:Z,gridClassName:H,label:B}){return $5.jsxs("div",{className:s("flex flex-col gap-2",Z),children:[$5.jsx("p",{className:"text-xs font-medium",children:B}),$5.jsx("div",{role:"group","aria-label":B,className:s("grid grid-cols-4 gap-2 @4xl/workspace:grid-cols-2",H),children:$})]})}function dU({active:$,children:Z,className:H,onSelect:B,style:J}){return $5.jsxs("button",{type:"button","aria-pressed":$,onClick:B,className:s(u70,"flex items-center gap-2 p-3",H,!$&&"cursor-pointer pr-9 opacity-70 hover:opacity-100"),style:J,children:[$5.jsx("div",{className:"flex flex-1 flex-col justify-center",children:Z}),$&&$5.jsx(tX,{size:20,stroke:1.5,"aria-hidden":"true"})]})}function lv({onClose:$,ref:Z}){UG();let{layout:H,setLayout:B}=K5(),J=j8(H.theme);function Q(X){B({theme:{...J,...X}})}return $5.jsx(uU,{ref:Z,title:"Customize",onClose:$,className:"@4xl/workspace:max-w-5xl",children:$5.jsxs("div",{className:"grid grid-cols-1 gap-4 @4xl/workspace:grid-cols-[repeat(2,minmax(0,1fr))_0.5rem_repeat(2,minmax(0,1fr))_0.5rem_minmax(0,1fr)_0.5rem_minmax(0,1fr)] @4xl/workspace:gap-x-2",children:[$5.jsx(cU,{label:"Font",className:"@4xl/workspace:col-span-2 @4xl/workspace:col-start-1",children:g70.map(([X,z])=>$5.jsx(dU,{active:X===J.font,onSelect:()=>Q({font:X}),style:{fontFamily:z.sans},children:$5.jsx("span",{className:"text-sm font-medium",children:z.label})},X))}),$5.jsx(cU,{label:"Colors",className:"@4xl/workspace:col-span-2 @4xl/workspace:col-start-4",children:f70.map(([X,z])=>$5.jsx(dU,{active:X===J.color,className:z.primary&&"bg-background text-foreground",onSelect:()=>Q({color:X}),style:T8({...J,color:X}),children:$5.jsxs("div",{className:"flex gap-2",children:[$5.jsx("span",{className:s("flex size-5 shrink-0 items-center justify-center rounded-sm text-[9px] leading-none font-bold",z.primary?"bg-primary text-primary-foreground":"bg-foreground text-background"),children:"Aa"}),$5.jsx("span",{className:"text-sm font-medium",children:z.label})]})},X))}),$5.jsx(cU,{label:"Radius",className:"@4xl/workspace:col-start-7",gridClassName:"@4xl/workspace:grid-cols-1",children:m70.map(([X,z])=>$5.jsx(dU,{active:X===J.radius,onSelect:()=>Q({radius:X}),style:T8({...J,radius:X}),children:$5.jsxs("div",{className:"flex items-center gap-2",children:[$5.jsx("span",{className:"size-5 shrink-0 rounded-sm bg-card texture-checker-2.5 shadow-xs","aria-hidden":"true"}),$5.jsx("span",{className:"text-sm font-medium",children:z.label})]})},X))}),$5.jsx(cU,{label:"Agent",className:"@4xl/workspace:col-start-9",gridClassName:"@4xl/workspace:grid-cols-1",children:p70.map(([X,z])=>$5.jsx(dU,{active:X===J.agent,onSelect:()=>Q({agent:X}),children:$5.jsxs("div",{className:"flex items-center gap-2",children:[$5.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center",children:$5.jsx(K9,{preset:X,color:"primary",size:28})}),$5.jsx("span",{className:"text-sm font-medium",children:z.label})]})},X))})]})})}var YY=O(g(),1);var xZ=O(g(),1);function iv($){return o1({queryKey:w0.appletThumbnails($),queryFn:async()=>(await V1(`/api/workspaces/${$}/applet-thumbnails`)).thumbnails,...y4})}function rv($){let Z=Z1();return s1({mutationFn:(H)=>S4(`/api/workspaces/${$}/applet-thumbnails`,n5("PUT",H),"Failed to save applet thumbnails"),onSuccess:()=>{Z.invalidateQueries({queryKey:w0.appletThumbnails($)}),Z.invalidateQueries({queryKey:w0.preview($)})}})}var c70=1000,d70=3,l70=10800000,i70=1000,r70="1000px-3x-webp-q80-v1",a70=5000,n70=1000,o70=1e4;function s70($){return Math.min(d70,c70/Math.max($.offsetWidth,$.offsetHeight))}function t70($){return`${r70}:${$??""}`}function e70($,Z,H=Date.now()){if(!$||$.revision!==Z)return!0;let B=Date.parse($.capturedAt);return!Number.isFinite(B)||H-B>=l70}function $$0($,Z){return $!==void 0&&$.revision===Z&&$.captureMs!==void 0&&$.captureMs>=i70}var Z$0=($)=>new Promise((Z)=>{setTimeout(()=>Z(null),$)});async function H$0($,Z){let{createContext:H,destroyContext:B,domToDataUrl:J}=await import("/chunk-c9pjqx9m.js"),Q=async()=>{let X=await H($,{scale:s70($),type:"image/webp",quality:0.8,backgroundColor:"#ffffff",timeout:n70,...Z&&{onCreateForeignObjectSvg:(z)=>{let G=document.createElement("style");G.textContent="[data-widget-chrome] { border-radius: 0 !important; box-shadow: none !important; }[data-widget-chrome]::after { display: none !important; }",z.append(G)}}});try{return await J(X)}finally{B(X)}};return Promise.race([Q(),Z$0(o70)])}async function B$0($,Z,H,B,J=H$0,Q=Date.now()){let X=[];for(let z of H){if(B())return null;let G=t70(z.revision),F=Z.find((W)=>W.kind===$&&W.id===z.id);if(!e70(F,G,Q)){X.push({id:z.id,revision:G});continue}if($$0(F,G)){X.push({id:z.id,revision:G});continue}if(!z.element){X.push({id:z.id,revision:G,image:null});continue}let U=performance.now(),Y=await J(z.element,$==="widget").catch(()=>null),K=Math.round(performance.now()-U);if(B())return null;X.push({id:z.id,revision:G,image:Y,captureMs:K})}return X}function lU({kind:$,enabled:Z,targets:H}){let B=H5(),J=iv(B).data,Q=rv(B),X=xZ.useRef(H);X.current=H;let z=xZ.useRef(J??[]);z.current=J??[];let G=xZ.useRef(Q.mutate);G.current=Q.mutate;let F=H.map((Y)=>`${Y.id}@${Y.revision??""}`).join(`
|
|
79
79
|
`),U=J!==void 0;xZ.useEffect(()=>{if(!Z||!U||F==="")return;let Y=!1,K=0,W,N=()=>{K+=1;let L=K;if(W!==void 0)clearTimeout(W);if(document.visibilityState!=="visible")return;W=setTimeout(async()=>{W=void 0;let V=await B$0($,z.current,X.current.map((A)=>({...A,element:document.querySelector(`[data-applet-thumbnail="${CSS.escape(`${$}:${A.id}`)}"]`)})),()=>Y||K!==L||document.visibilityState!=="visible");if(!V||Y||document.visibilityState!=="visible")return;G.current({kind:$,thumbnails:V})},a70)};return document.addEventListener("visibilitychange",N),N(),()=>{if(Y=!0,W!==void 0)clearTimeout(W);document.removeEventListener("visibilitychange",N)}},[Z,$,U,F])}function _J($,Z,H,B){let J=$.reduce((Q,X)=>Math.max(Q,X.y+X.h),0);for(let Q=0;Q<=J+H;Q++)for(let X=0;X<=B-Z;X++)if(!$.some((G)=>!(X+Z<=G.x||G.x+G.w<=X||Q+H<=G.y||G.y+G.h<=Q)))return{x:X,y:Q};return{x:0,y:J}}function OJ($,Z=[],H=4){let B=[];for(let J of $){let{x:Q,y:X}=J.x!==void 0&&J.y!==void 0?{x:J.x,y:J.y}:_J([...Z,...B],J.w,J.h,H);B.push({i:J.id,x:Q,y:X,w:J.w,h:J.h})}return B}var cV=O(g(),1),iU=new Map;function J$0($){let Z=window.__moiAppletCss?.get($)??"",H=iU.get($);if(!H){let Q=document.createElement("style");Q.dataset.appletStyle=$,document.head.appendChild(Q),H={el:Q,refs:0},iU.set($,H)}if(H.el.textContent!==Z)H.el.textContent=Z;H.refs++;let B=H,J=!1;return()=>{if(J)return;if(J=!0,B.refs--,B.refs<=0)B.el.remove(),iU.delete($)}}function Q$0($){let Z=iU.get($);if(!Z||Z.el===document.head.lastElementChild)return;document.head.appendChild(Z.el)}function rU($,Z,H=!1){cV.useInsertionEffect(()=>J$0($),[$,Z]),cV.useInsertionEffect(()=>{if(H)Q$0($)},[$,H,Z])}var nv=O(d(),1);function av({segment:$,name:Z,version:H,children:B}){let J=H5();return rU(qG($,J,Z),H),nv.jsx("div",{"data-applet":MG($,Z),className:"size-full",children:B})}var ov=O(g(),1);var vZ=O(d(),1);class jJ extends ov.Component{state={error:null};static getDerivedStateFromError($){return{error:$}}componentDidCatch($,Z){console.error(`[widget:${this.props.name}]`,$,Z.componentStack),q8(this.props.workspaceId,{source:"render",kind:this.props.kind,name:this.props.name,message:$.message||String($),stack:[$.stack,Z.componentStack].filter(Boolean).join(`
|
|
80
80
|
`)})}componentDidUpdate($){if($.resetKey!==this.props.resetKey&&this.state.error)this.setState({error:null})}render(){if(this.state.error)return vZ.jsxs("div",{className:"flex h-full w-full flex-col items-start justify-start gap-1.5 p-4 text-xs",children:[vZ.jsxs("div",{className:"flex items-center gap-1.5 font-semibold text-destructive",children:[vZ.jsx(YX,{size:16,stroke:1.75}),"Widget crashed"]}),vZ.jsx("div",{className:"font-mono break-words text-muted-foreground",children:this.state.error.message})]});return this.props.children}}var t3=O(d(),1);function sv({name:$}){let Z=H5(),H=HE($);return t3.jsxs(e2,{mode:"wait",initial:!1,children:[H.status==="ready"&&t3.jsx(B5.div,{className:"absolute inset-0",initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"},transition:{duration:0.45,ease:"easeInOut"},children:t3.jsx(jJ,{name:$,kind:"widget",workspaceId:Z,resetKey:H.version,children:t3.jsx(av,{segment:"widgets",name:$,version:H.version,children:t3.jsx(H.Component,{})})})},H.version),H.status==="error"&&t3.jsx(B5.p,{className:"absolute inset-0 p-4 text-xs text-destructive",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:0.45,ease:"easeInOut"},children:H.error},`err-${H.version}`)]})}var tv=O(d(),1);function gZ({className:$,...Z}){return tv.jsx("div",{"data-slot":"skeleton",className:s("animate-pulse rounded-lg bg-muted",$),...Z})}var $g=O(g(),1);var e3=O(d(),1);function aU({editing:$,hidden:Z,onRemove:H,children:B}){let J=LE();return e3.jsxs(B5.div,{variants:{idle:{rotate:0},wiggle:{rotate:[0.5,-0.5],transition:{rotate:{repeat:1/0,repeatType:"reverse",duration:0.15,ease:"easeInOut"}}}},animate:$?"wiggle":"idle",transition:{type:"spring",duration:0.35,bounce:0},className:"group/widget relative size-full",children:[e3.jsx("div",{"data-widget-chrome":!0,"data-vivid":!0,style:T8(J,"widget"),className:s("absolute inset-0 overflow-hidden rounded-2xl text-foreground [corner-shape:superellipse(1.2)]","shadow-[0_1px_2px_-1px_rgba(0,0,0,0.08),0_2px_4px_0_rgba(0,0,0,0.03)]","after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit]","after:content-[''] after:[corner-shape:inherit]","after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.05)]",$&&"pointer-events-none"),children:B}),$&&H&&e3.jsx("div",{className:"absolute -top-2 -right-2 opacity-0 transition-opacity group-hover/widget:opacity-100",children:e3.jsx(T0,{size:"icon-sm",variant:"outline",className:"rounded-full",onClick:H,children:Z?e3.jsx(W4,{stroke:1.75}):e3.jsx(ev,{stroke:1.75})})})]})}var fZ=O(d(),1),X$0={0:"col-start-1",1:"col-start-2",2:"col-start-3",3:"col-start-4"},z$0={0:"row-start-1",1:"row-start-2",2:"row-start-3",3:"row-start-4",4:"row-start-5",5:"row-start-6",6:"row-start-7",7:"row-start-8"},G$0={1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"},F$0={1:"row-span-1",2:"row-span-2",3:"row-span-3",4:"row-span-4"};function Zg({items:$,renderItem:Z,onClose:H,onRestore:B,ref:J}){let Q=$g.useMemo(()=>OJ($),[$]);return fZ.jsx(uU,{ref:J,title:"Hidden widgets",onClose:H,className:"max-h-[60vh]",children:fZ.jsx("div",{className:"grid auto-rows-[160px] grid-cols-4 gap-2",children:fZ.jsx(e2,{children:Q.map((X)=>fZ.jsx(B5.div,{layoutId:X.i,className:s(X$0[X.x],z$0[X.y],G$0[X.w],F$0[X.h]),transition:{type:"spring",duration:0.35,bounce:0},children:fZ.jsx(aU,{editing:!0,onRemove:()=>B(X.i),hidden:!0,children:Z(X.i)})},X.i))})})})}var gJ=O(g(),1);function Z6($){let{margin:Z,containerPadding:H,containerWidth:B,cols:J}=$;return(B-Z[0]*(J-1)-H[0]*2)/J}function S8($,Z,H){if(!Number.isFinite($))return $;return Math.round(Z*$+Math.max(0,$-1)*H)}function CJ($,Z,H,B,J,Q,X){let{margin:z,containerPadding:G,rowHeight:F}=$,U=Z6($),Y,K,W,N;if(X)Y=Math.round(X.width),K=Math.round(X.height);else Y=S8(B,U,z[0]),K=S8(J,F,z[1]);if(Q)W=Math.round(Q.top),N=Math.round(Q.left);else if(X)W=Math.round(X.top),N=Math.round(X.left);else W=Math.round((F+z[1])*H+G[1]),N=Math.round((U+z[0])*Z+G[0]);if(!Q&&!X){if(Number.isFinite(B)){let V=Math.round((U+z[0])*(Z+B)+G[0])-N-Y;if(V!==z[0])Y+=V-z[0]}if(Number.isFinite(J)){let V=Math.round((F+z[1])*(H+J)+G[1])-W-K;if(V!==z[1])K+=V-z[1]}}return{top:W,left:N,width:Y,height:K}}function Bg($,Z,H,B,J){let{margin:Q,containerPadding:X,cols:z,rowHeight:G,maxRows:F}=$,U=Z6($),Y=Math.round((H-X[0])/(U+Q[0])),K=Math.round((Z-X[1])/(G+Q[1]));return Y=TJ(Y,0,z-B),K=TJ(K,0,F-J),{x:Y,y:K}}function wJ($,Z,H){let{margin:B,containerPadding:J,rowHeight:Q}=$,X=Z6($),z=Math.round((H-J[0])/(X+B[0])),G=Math.round((Z-J[1])/(Q+B[1]));return{x:z,y:G}}function Jg($,Z,H){let{margin:B,rowHeight:J}=$,Q=Z6($),X=Math.max(1,Math.round((Z+B[0])/(Q+B[0]))),z=Math.max(1,Math.round((H+B[1])/(J+B[1])));return{w:X,h:z}}function TJ($,Z,H){return Math.max(Math.min($,H),Z)}function oU($,Z){if($.i===Z.i)return!1;if($.x+$.w<=Z.x)return!1;if($.x>=Z.x+Z.w)return!1;if($.y+$.h<=Z.y)return!1;if($.y>=Z.y+Z.h)return!1;return!0}function H6($,Z){for(let H=0;H<$.length;H++){let B=$[H];if(B!==void 0&&oU(B,Z))return B}return}function dV($,Z){return $.filter((H)=>oU(H,Z))}function U$0($,Z){if(Z==="horizontal")return lV($);if(Z==="vertical")return nU($);if(Z==="wrap")return nU($);return[...$]}function nU($){return[...$].sort((Z,H)=>{if(Z.y!==H.y)return Z.y-H.y;return Z.x-H.x})}function lV($){return[...$].sort((Z,H)=>{if(Z.x!==H.x)return Z.x-H.x;return Z.y-H.y})}function EJ($){let Z=0;for(let H=0;H<$.length;H++){let B=$[H];if(B!==void 0){let J=B.y+B.h;if(J>Z)Z=J}}return Z}function B6($,Z){for(let H=0;H<$.length;H++){let B=$[H];if(B!==void 0&&B.i===Z)return B}return}function SJ($){return $.filter((Z)=>Z.static===!0)}function i9($){return{i:$.i,x:$.x,y:$.y,w:$.w,h:$.h,minW:$.minW,maxW:$.maxW,minH:$.minH,maxH:$.maxH,moved:Boolean($.moved),static:Boolean($.static),isDraggable:$.isDraggable,isResizable:$.isResizable,resizeHandles:$.resizeHandles,constraints:$.constraints,isBounded:$.isBounded}}function mZ($){let Z=Array($.length);for(let H=0;H<$.length;H++){let B=$[H];if(B!==void 0)Z[H]=i9(B)}return Z}function Y$0($,Z){let H=Array($.length);for(let B=0;B<$.length;B++){let J=$[B];if(J!==void 0)if(Z.i===J.i)H[B]=Z;else H[B]=J}return H}function Qg($,Z,H){let B=B6($,Z);if(!B)return[[...$],null];return B=H(i9(B)),[Y$0($,B),B]}function iV($,Z){let H=SJ($);for(let B=0;B<$.length;B++){let J=$[B];if(J===void 0)continue;if(J.x+J.w>Z.cols)J.x=Z.cols-J.w;if(J.x<0)J.x=0,J.w=Z.cols;if(!J.static)H.push(J);else while(H6(H,J))J.y++}return $}function $6($,Z,H,B,J,Q,X,z,G){if(Z.static&&Z.isDraggable!==!0)return[...$];if(Z.y===B&&Z.x===H)return[...$];let{x:F,y:U}=Z;if(typeof H==="number")Z.x=H;if(typeof B==="number")Z.y=B;Z.moved=!0;let Y=U$0($,X);if(X==="vertical"&&typeof B==="number"?U>=B:X==="horizontal"&&typeof H==="number"?F>=H:!1)Y=Y.reverse();let W=dV(Y,Z),N=W.length>0;if(N&&G)return mZ($);if(N&&Q)return Z.x=F,Z.y=U,Z.moved=!1,$;let L=[...$];for(let V=0;V<W.length;V++){let A=W[V];if(A===void 0)continue;if(A.moved)continue;if(A.static)L=Hg(L,A,Z,J,X);else L=Hg(L,Z,A,J,X)}return L}function Hg($,Z,H,B,J,Q){let X=J==="horizontal",z=J==="vertical",G=Z.static;if(B){B=!1;let Y={x:X?Math.max(Z.x-H.w,0):H.x,y:z?Math.max(Z.y-H.h,0):H.y,w:H.w,h:H.h,i:"-1"},K=H6($,Y),W=K!==void 0&&K.y+K.h>Z.y,N=K!==void 0&&Z.x+Z.w>K.x;if(!K)return $6($,H,X?Y.x:void 0,z?Y.y:void 0,B,G,J);if(W&&z)return $6($,H,void 0,H.y+1,B,G,J);if(W&&J===null)return Z.y=H.y,H.y=H.y+H.h,[...$];if(N&&X)return $6($,Z,H.x,void 0,B,G,J)}let F=X?H.x+1:void 0,U=z?H.y+1:void 0;if(F===void 0&&U===void 0)return[...$];return $6($,H,F,U,B,G,J)}function pZ($,Z,H){return Math.max(Z,Math.min(H,$))}var K$0={name:"gridBounds",constrainPosition($,Z,H,{cols:B,maxRows:J}){return{x:pZ(Z,0,Math.max(0,B-$.w)),y:pZ(H,0,Math.max(0,J-$.h))}},constrainSize($,Z,H,B,{cols:J,maxRows:Q}){let X=B==="w"||B==="nw"||B==="sw"?$.x+$.w:J-$.x,z=B==="n"||B==="nw"||B==="ne"?$.y+$.h:Q-$.y;return{w:pZ(Z,1,Math.max(1,X)),h:pZ(H,1,Math.max(1,z))}}},W$0={name:"minMaxSize",constrainSize($,Z,H){return{w:pZ(Z,$.minW??1,$.maxW??1/0),h:pZ(H,$.minH??1,$.maxH??1/0)}}};var rV=[K$0,W$0];function IJ($,Z,H,B,J){let Q={x:H,y:B};for(let X of $)if(X.constrainPosition)Q=X.constrainPosition(Z,Q.x,Q.y,J);if(Z.constraints){for(let X of Z.constraints)if(X.constrainPosition)Q=X.constrainPosition(Z,Q.x,Q.y,J)}return Q}function Xg($,Z,H,B,J,Q){let X={w:H,h:B};for(let z of $)if(z.constrainSize)X=z.constrainSize(Z,X.w,X.h,J,Q);if(Z.constraints){for(let z of Z.constraints)if(z.constrainSize)X=z.constrainSize(Z,X.w,X.h,J,Q)}return X}function tU({top:$,left:Z,width:H,height:B}){let J=`translate(${Z}px,${$}px)`;return{transform:J,WebkitTransform:J,MozTransform:J,msTransform:J,OTransform:J,width:`${H}px`,height:`${B}px`,position:"absolute"}}function aV({top:$,left:Z,width:H,height:B}){return{top:`${$}px`,left:`${Z}px`,width:`${H}px`,height:`${B}px`,position:"absolute"}}function nV($){return $*100+"%"}function N$0($,Z,H,B){return $+H>B?Z:H}function zg($,Z,H){return $<0?Z:H}function L$0($){return Math.max(0,$)}function sU($){return Math.max(0,$)}var oV=($,Z,H)=>{let{left:B,height:J,width:Q}=Z,X=$.top-(J-$.height);return{left:B,width:Q,height:zg(X,$.height,J),top:sU(X)}},sV=($,Z,H)=>{let{top:B,left:J,height:Q,width:X}=Z;return{top:B,height:Q,width:N$0($.left,$.width,X,H),left:L$0(J)}},tV=($,Z,H)=>{let{top:B,height:J,width:Q}=Z,X=$.left+$.width-Q;if(X<0)return{height:J,width:$.left+$.width,top:sU(B),left:0};return{height:J,width:Q,top:sU(B),left:X}},eV=($,Z,H)=>{let{top:B,left:J,height:Q,width:X}=Z;return{width:X,left:J,height:zg(B,$.height,Q),top:sU(B)}},A$0=($,Z,H)=>oV($,sV($,Z,H)),V$0=($,Z,H)=>oV($,tV($,Z)),D$0=($,Z,H)=>eV($,sV($,Z,H)),q$0=($,Z,H)=>eV($,tV($,Z)),M$0={n:oV,ne:A$0,e:sV,se:D$0,s:eV,sw:q$0,w:tV,nw:V$0};function Gg($,Z,H,B){let J=M$0[$];if(!J)return H;return J(Z,{...Z,...H},B)}var P$0={type:"transform",scale:1,calcStyle($){return tU($)}};var Fg=P$0,Ug={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},Yg={enabled:!0,bounded:!1,threshold:3},Kg={enabled:!0,handles:["se"]},Wg={enabled:!1,defaultItem:{w:1,h:1}};function $D($,Z,H,B,J){let Q=B==="x"?"w":"h";Z[B]+=1;let X=$.findIndex((G)=>G.i===Z.i),z=J??SJ($).length>0;for(let G=X+1;G<$.length;G++){let F=$[G];if(F===void 0)continue;if(F.static)continue;if(!z&&F.y>Z.y+Z.h)break;if(oU(Z,F))$D($,F,H+Z[Q],B,z)}Z[B]=H}function _$0($,Z,H,B){Z.x=Math.max(Z.x,0),Z.y=Math.max(Z.y,0),Z.y=Math.min(B,Z.y);while(Z.y>0&&!H6($,Z))Z.y--;let J;while((J=H6($,Z))!==void 0)$D(H,Z,J.y+J.h,"y");return Z.y=Math.max(Z.y,0),Z}function O$0($,Z,H,B){Z.x=Math.max(Z.x,0),Z.y=Math.max(Z.y,0);while(Z.x>0&&!H6($,Z))Z.x--;let J;while((J=H6($,Z))!==void 0)if($D(B,Z,J.x+J.w,"x"),Z.x+Z.w>H){Z.x=H-Z.w,Z.y++;while(Z.x>0&&!H6($,Z))Z.x--}return Z.x=Math.max(Z.x,0),Z}var RJ={type:"vertical",allowOverlap:!1,compact($,Z){let H=SJ($),B=EJ(H),J=nU($),Q=Array($.length);for(let X=0;X<J.length;X++){let z=J[X];if(z===void 0)continue;let G=i9(z);if(!G.static)G=_$0(H,G,J,B),B=Math.max(B,G.y+G.h),H.push(G);let F=$.indexOf(z);Q[F]=G,G.moved=!1}return Q}},ZD={type:"horizontal",allowOverlap:!1,compact($,Z){let H=SJ($),B=lV($),J=Array($.length);for(let Q=0;Q<B.length;Q++){let X=B[Q];if(X===void 0)continue;let z=i9(X);if(!z.static)z=O$0(H,z,Z,B),H.push(z);let G=$.indexOf(X);J[G]=z,z.moved=!1}return J}},HD={type:null,allowOverlap:!1,compact($,Z){return mZ($)}},j$0={...RJ,allowOverlap:!0,compact($,Z){return mZ($)}},T$0={...ZD,allowOverlap:!0,compact($,Z){return mZ($)}},C$0={...HD,allowOverlap:!0};function BD($,Z=!1,H=!1){let B;if(Z)if($==="vertical")B=j$0;else if($==="horizontal")B=T$0;else B=C$0;else if($==="vertical")B=RJ;else if($==="horizontal")B=ZD;else B=HD;if(H)return{...B,preventCollision:H};return B}var I8=O(g(),1);function JD($={}){let{measureBeforeMount:Z=!1,initialWidth:H=1280}=$,[B,J]=I8.useState(H),[Q,X]=I8.useState(!Z),z=I8.useRef(null),G=I8.useRef(null),F=I8.useCallback(()=>{let U=z.current;if(U){let Y=U.offsetWidth;if(J(Y),!Q)X(!0)}},[Q]);return I8.useEffect(()=>{let U=z.current;if(!U)return;if(F(),typeof ResizeObserver<"u"){let Y=null;return G.current=new ResizeObserver((K)=>{let W=K[0];if(W){let N=W.contentRect.width;if(Y!==null)cancelAnimationFrame(Y);Y=requestAnimationFrame(()=>{J(N),Y=null})}}),G.current.observe(U),()=>{if(Y!==null)cancelAnimationFrame(Y);if(G.current)G.current.disconnect(),G.current=null}}return()=>{if(G.current)G.current.disconnect(),G.current=null}},[F]),{width:B,mounted:Q,containerRef:z,measureWidth:F}}var y0=O(g(),1),Yf=O(zY(),1),Kf=O(Gf(),1);var a9=O(d(),1),I7=O(Lg(),1);function jD($){let{children:Z,cols:H,containerWidth:B,margin:J,containerPadding:Q,rowHeight:X,maxRows:z,isDraggable:G,isResizable:F,isBounded:U,static:Y,useCSSTransforms:K=!0,usePercentages:W=!1,transformScale:N=1,positionStrategy:L,dragThreshold:V=0,droppingPosition:A,className:D="",style:q,handle:_="",cancel:M="",x:P,y:C,w:R,h:y,minW:w=1,maxW:h=1/0,minH:E=1,maxH:I=1/0,i:j,resizeHandles:S,resizeHandle:k,constraints:b=rV,layoutItem:v,layout:c=[],onDragStart:T,onDrag:e,onDragStop:Z0,onResizeStart:x,onResize:t,onResizeStop:D0}=$,[p,X0]=y0.useState(!1),[K0,Q0]=y0.useState(!1),z0=y0.useRef(null),L0=y0.useRef({left:0,top:0}),i=y0.useRef({top:0,left:0,width:0,height:0}),B0=y0.useRef(void 0),$0=y0.useRef(c);$0.current=c;let J0=y0.useRef(null),n=y0.useRef(null),f=y0.useRef(!1),l=y0.useRef({x:0,y:0}),m=y0.useRef(!1),a=y0.useMemo(()=>({cols:H,containerPadding:Q,containerWidth:B,margin:J,maxRows:z,rowHeight:X}),[H,Q,B,J,z,X]),o=y0.useMemo(()=>({cols:H,maxRows:z,containerWidth:B,containerHeight:0,rowHeight:X,margin:J,layout:[]}),[H,z,B,X,J]),V0=y0.useCallback(()=>({...o,layout:$0.current}),[o]),O0=y0.useMemo(()=>v??{i:j,x:P,y:C,w:R,h:y,minW:w,maxW:h,minH:E,maxH:I},[v,j,P,C,R,y,w,h,E,I]),k0=y0.useCallback((C0)=>{if(L?.calcStyle)return L.calcStyle(C0);if(K)return tU(C0);let I0=aV(C0);if(W)return{...I0,left:nV(C0.left/B),width:nV(C0.width/B)};return I0},[L,K,W,B]),r0=y0.useCallback((C0,{node:I0})=>{if(!T)return;let{offsetParent:g0}=I0;if(!g0)return;let $1=g0.getBoundingClientRect(),l0=I0.getBoundingClientRect(),L1=l0.left/N,u1=$1.left/N,c1=l0.top/N,M1=$1.top/N,q5;if(L?.calcDragPosition){let z1=C0;q5=L.calcDragPosition(z1.clientX,z1.clientY,z1.clientX-l0.left,z1.clientY-l0.top)}else q5={left:L1-u1+g0.scrollLeft,top:c1-M1+g0.scrollTop};if(L0.current=q5,V>0){let z1=C0;l.current={x:z1.clientX,y:z1.clientY},f.current=!0,m.current=!1,X0(!0);return}X0(!0);let p5=wJ(a,q5.top,q5.left),{x:i5,y:x0}=IJ(b,O0,p5.x,p5.y,V0());T(j,i5,x0,{e:C0,node:I0,newPosition:q5})},[T,N,a,L,V,b,O0,V0,j]),u=y0.useCallback((C0,{node:I0,deltaX:g0,deltaY:$1})=>{if(!e||!p)return;let l0=C0;if(f.current&&!m.current){let i5=l0.clientX-l.current.x,x0=l0.clientY-l.current.y;if(Math.hypot(i5,x0)<V)return;if(m.current=!0,f.current=!1,T){let u0=wJ(a,L0.current.top,L0.current.left),{x:A1,y:v1}=IJ(b,O0,u0.x,u0.y,V0());T(j,A1,v1,{e:C0,node:I0,newPosition:L0.current})}}let L1=L0.current.top+$1,u1=L0.current.left+g0;if(U){let{offsetParent:i5}=I0;if(i5){let x0=i5.clientHeight-S8(y,X,J[1]);L1=TJ(L1,0,x0);let z1=Z6(a),u0=B-S8(R,z1,J[0]);u1=TJ(u1,0,u0)}}let c1={top:L1,left:u1};L0.current=c1;let M1=wJ(a,L1,u1),{x:q5,y:p5}=IJ(b,O0,M1.x,M1.y,V0());e(j,q5,p5,{e:C0,node:I0,newPosition:c1})},[e,T,p,V,U,y,X,J,a,B,R,j,b,O0,V0]),r=y0.useCallback((C0,{node:I0})=>{if(!Z0||!p)return;let g0=f.current;if(f.current=!1,m.current=!1,l.current={x:0,y:0},g0){X0(!1),L0.current={left:0,top:0};return}let{left:$1,top:l0}=L0.current,L1={top:l0,left:$1};X0(!1),L0.current={left:0,top:0};let u1=wJ(a,l0,$1),{x:c1,y:M1}=IJ(b,O0,u1.x,u1.y,V0());Z0(j,c1,M1,{e:C0,node:I0,newPosition:L1})},[Z0,p,a,b,O0,V0,j]);J0.current=r0,n.current=u;let H0=y0.useCallback((C0,{node:I0,size:g0,handle:$1},l0,L1)=>{let u1=L1==="onResizeStart"?x:L1==="onResize"?t:D0;if(!u1)return;let c1;if(I0)c1=Gg($1,l0,g0,B);else c1={...g0,top:l0.top,left:l0.left};i.current=c1;let M1=Jg(a,c1.width,c1.height),{w:q5,h:p5}=Xg(b,O0,M1.w,M1.h,$1,V0());u1(j,q5,p5,{e:C0.nativeEvent,node:I0,size:c1,handle:$1})},[x,t,D0,B,a,j,b,O0,V0]),A0=y0.useCallback((C0,I0)=>{Q0(!0);let g0=CJ(a,P,C,R,y),$1={...I0,handle:I0.handle};H0(C0,$1,g0,"onResizeStart")},[H0,a,P,C,R,y]),j0=y0.useCallback((C0,I0)=>{let g0=CJ(a,P,C,R,y),$1={...I0,handle:I0.handle};H0(C0,$1,g0,"onResize")},[H0,a,P,C,R,y]),v0=y0.useCallback((C0,I0)=>{Q0(!1),i.current={top:0,left:0,width:0,height:0};let g0=CJ(a,P,C,R,y),$1={...I0,handle:I0.handle};H0(C0,$1,g0,"onResizeStop")},[H0,a,P,C,R,y]);y0.useEffect(()=>{if(!A)return;let C0=z0.current;if(!C0)return;let I0=B0.current||{left:0,top:0},g0=p&&(A.left!==I0.left||A.top!==I0.top);if(!p){let $1={node:C0,deltaX:A.left,deltaY:A.top,lastX:0,lastY:0,x:A.left,y:A.top};J0.current?.(A.e,$1)}else if(g0){let $1=A.left-L0.current.left,l0=A.top-L0.current.top,L1={node:C0,deltaX:$1,deltaY:l0,lastX:L0.current.left,lastY:L0.current.top,x:A.left,y:A.top};n.current?.(A.e,L1)}B0.current=A},[A,p,j]);let G1=CJ(a,P,C,R,y,p?L0.current:null,K0?i.current:null),K1=y0.default.Children.only(Z),c0=Z6(a),R0=[S8(w,c0,J[0]),S8(E,X,J[1])],d0=[S8(h,c0,J[0]),S8(I,X,J[1])],p0=K1.props,t0=p0.className,N0=p0.style,b0=y0.default.cloneElement(K1,{ref:z0,className:TD("react-grid-item",t0,D,{static:Y,resizing:K0,"react-draggable":G,"react-draggable-dragging":p,dropping:Boolean(A),cssTransforms:K}),style:{...q,...N0,...k0(G1)}}),W1=k;return b0=a9.jsx(Kf.Resizable,{draggableOpts:{disabled:!F},className:F?void 0:"react-resizable-hide",width:G1.width,height:G1.height,minConstraints:R0,maxConstraints:d0,onResizeStart:A0,onResize:j0,onResizeStop:v0,transformScale:N,resizeHandles:S,handle:W1,children:b0}),b0=a9.jsx(Yf.DraggableCore,{disabled:!G,onStart:r0,onDrag:u,onStop:r,handle:_,cancel:".react-resizable-handle"+(M?","+M:""),scale:N,nodeRef:z0,children:b0}),b0}var r9=()=>{},Ff="react-grid-layout",Wf=!1;try{Wf=/firefox/i.test(navigator.userAgent)}catch{}function fH0($,Z){let H=y0.default.Children.toArray($),B=y0.default.Children.toArray(Z);if(H.length!==B.length)return!1;for(let J=0;J<H.length;J++){let Q=H[J],X=B[J];if(Q?.key!==X?.key)return!1}return!0}function Uf($,Z,H,B){let J=[],Q=new Set;y0.default.Children.forEach(Z,(z)=>{if(!y0.default.isValidElement(z)||z.key===null)return;let G=String(z.key);Q.add(G);let F=$.find((U)=>U.i===G);if(F)J.push(i9(F));else{let Y=z.props["data-grid"];if(Y)J.push({i:G,x:Y.x??0,y:Y.y??0,w:Y.w??1,h:Y.h??1,minW:Y.minW,maxW:Y.maxW,minH:Y.minH,maxH:Y.maxH,static:Y.static,isDraggable:Y.isDraggable,isResizable:Y.isResizable,resizeHandles:Y.resizeHandles,isBounded:Y.isBounded});else J.push({i:G,x:0,y:EJ(J),w:1,h:1})}});let X=iV(J,{cols:H});return B.compact(X,H)}function vJ($){let{children:Z,width:H,gridConfig:B,dragConfig:J,resizeConfig:Q,dropConfig:X,positionStrategy:z=Fg,compactor:G,constraints:F=rV,layout:U=[],droppingItem:Y,autoSize:K=!0,className:W="",style:N={},innerRef:L,onLayoutChange:V=r9,onDragStart:A=r9,onDrag:D=r9,onDragStop:q=r9,onResizeStart:_=r9,onResize:M=r9,onResizeStop:P=r9,onDrop:C=r9,onDropDragOver:R=r9}=$,y=y0.useMemo(()=>({...Ug,...B}),[B]),w=y0.useMemo(()=>({...Yg,...J}),[J]),h=y0.useMemo(()=>({...Kg,...Q}),[Q]),E=y0.useMemo(()=>({...Wg,...X}),[X]),{cols:I,rowHeight:j,maxRows:S,margin:k,containerPadding:b}=y,{enabled:v,bounded:c,handle:T,cancel:e,threshold:Z0}=w,{enabled:x,handles:t,handleComponent:D0}=h,{enabled:p,defaultItem:X0,onDragOver:K0}=E,Q0=G??BD("vertical"),z0=Q0.type,L0=Q0.allowOverlap,i=Q0.preventCollision??!1,B0=y0.useMemo(()=>Y??{i:"__dropping-elem__",...X0},[Y,X0]),$0=z.type==="transform",J0=z.scale,n=b??k,[f,l]=y0.useState(!1),[m,a]=y0.useState(()=>Uf(U,Z,I,Q0)),[o,V0]=y0.useState(null),[O0,k0]=y0.useState(!1),[r0,u]=y0.useState(null),[r,H0]=y0.useState(),A0=y0.useRef(null),j0=y0.useRef(null),v0=y0.useRef(null),G1=y0.useRef(0),K1=y0.useRef(m),c0=y0.useRef(U),R0=y0.useRef(Z),d0=y0.useRef(z0),p0=y0.useRef(m);p0.current=m,y0.useEffect(()=>{if(l(!0),!I7.deepEqual(m,U))V(m)},[]),y0.useEffect(()=>{if(o)return;if(r0)return;let x0=!I7.deepEqual(U,c0.current),z1=!fH0(Z,R0.current),u0=z0!==d0.current;if(x0||z1||u0){let v1=Uf(x0?U:m,Z,I,Q0);if(!I7.deepEqual(v1,m))a(v1)}c0.current=U,R0.current=Z,d0.current=z0},[U,Z,I,z0,Q0,o,r0,m]),y0.useEffect(()=>{if(!o&&!I7.deepEqual(m,K1.current)){K1.current=m;let x0=m.filter((z1)=>z1.i!==B0.i);V(x0)}},[m,o,V,B0.i]);let t0=y0.useMemo(()=>{if(!K)return;let x0=EJ(m),z1=n[1];return x0*j+(x0-1)*k[1]+z1*2+"px"},[K,m,j,k,n]),N0=y0.useCallback((x0,z1,u0,A1)=>{let v1=p0.current,d1=B6(v1,x0);if(!d1)return;let M5={w:d1.w,h:d1.h,x:d1.x,y:d1.y,i:x0};A0.current=i9(d1),v0.current=v1,V0(M5),A(v1,d1,d1,null,A1.e,A1.node)},[A]),b0=y0.useCallback((x0,z1,u0,A1)=>{let v1=p0.current,d1=A0.current,M5=B6(v1,x0);if(!M5)return;let U2={w:M5.w,h:M5.h,x:M5.x,y:M5.y,i:x0},P5=$6(v1,M5,z1,u0,!0,i,z0,I,L0);D(P5,d1,M5,U2,A1.e,A1.node),a(Q0.compact(P5,I)),V0(U2)},[i,z0,I,L0,Q0,D]),W1=y0.useCallback((x0,z1,u0,A1)=>{if(!o)return;let v1=p0.current,d1=A0.current,M5=B6(v1,x0);if(!M5)return;let U2=$6(v1,M5,z1,u0,!0,i,z0,I,L0),P5=Q0.compact(U2,I);q(P5,d1,M5,null,A1.e,A1.node);let E2=v0.current;if(A0.current=null,v0.current=null,V0(null),a(P5),E2&&!I7.deepEqual(E2,P5))V(P5)},[o,i,z0,I,L0,Q0,q,V]),C0=y0.useCallback((x0,z1,u0,A1)=>{let v1=p0.current,d1=B6(v1,x0);if(!d1)return;j0.current=i9(d1),v0.current=v1,k0(!0),_(v1,d1,d1,null,A1.e,A1.node)},[_]),I0=y0.useCallback((x0,z1,u0,A1)=>{let v1=p0.current,d1=j0.current,{handle:M5}=A1,U2=!1,P5,E2,[nJ,I9]=Qg(v1,x0,(C5)=>{if(P5=C5.x,E2=C5.y,["sw","w","nw","n","ne"].includes(M5)){if(["sw","nw","w"].includes(M5))P5=C5.x+(C5.w-z1),z1=C5.x!==P5&&P5<0?C5.w:z1,P5=P5<0?0:P5;if(["ne","n","nw"].includes(M5))E2=C5.y+(C5.h-u0),u0=C5.y!==E2&&E2<0?C5.h:u0,E2=E2<0?0:E2;U2=!0}if(i&&!L0){if(dV(v1,{...C5,w:z1,h:u0,x:P5??C5.x,y:E2??C5.y}).filter((sJ)=>sJ.i!==C5.i).length>0)E2=C5.y,u0=C5.h,P5=C5.x,z1=C5.w,U2=!1}return C5.w=z1,C5.h=u0,C5});if(!I9)return;let JH=nJ;if(U2&&P5!==void 0&&E2!==void 0)JH=$6(nJ,I9,P5,E2,!0,i,z0,I,L0);let oJ={w:I9.w,h:I9.h,x:I9.x,y:I9.y,i:x0,static:!0};M(JH,d1,I9,oJ,A1.e,A1.node),a(Q0.compact(JH,I)),V0(oJ)},[i,z0,I,L0,Q0,M]),g0=y0.useCallback((x0,z1,u0,A1)=>{let v1=p0.current,d1=j0.current,M5=B6(v1,x0),U2=Q0.compact(v1,I);P(U2,d1,M5??null,null,A1.e,A1.node);let P5=v0.current;if(j0.current=null,v0.current=null,V0(null),k0(!1),a(U2),P5&&!I7.deepEqual(P5,U2))V(U2)},[I,Q0,P,V]),$1=y0.useCallback(()=>{let x0=p0.current;if(!x0.some((A1)=>A1.i===B0.i)){u(null),V0(null),H0(void 0);return}let u0=Q0.compact(x0.filter((A1)=>A1.i!==B0.i),I);a(u0),u(null),V0(null),H0(void 0)},[B0.i,I,Q0]),l0=y0.useCallback((x0)=>{if(x0.preventDefault(),x0.stopPropagation(),Wf&&!x0.nativeEvent.target?.classList.contains(Ff))return!1;let z1=K0?K0(x0.nativeEvent):R(x0);if(z1===!1){if(r0)$1();return!1}let{dragOffsetX:u0=0,dragOffsetY:A1=0,...v1}=z1??{},d1={...B0,...v1},M5=x0.currentTarget.getBoundingClientRect(),U2={cols:I,margin:k,maxRows:S,rowHeight:j,containerWidth:H,containerPadding:n},P5=Z6(U2),E2=S8(d1.w,P5,k[0]),nJ=S8(d1.h,j,k[1]),I9=E2/2,JH=nJ/2,oJ=x0.clientX-M5.left+u0-I9,C5=x0.clientY-M5.top+A1-JH,gY=Math.max(0,oJ),sJ=Math.max(0,C5),tJ={left:gY/J0,top:sJ/J0,e:x0.nativeEvent};if(!r0){let fY=Bg(U2,sJ,gY,d1.w,d1.h);u(a9.jsx("div",{},d1.i)),H0(tJ);let kc=p0.current.filter((bc)=>bc.i!==d1.i);a([...kc,{...d1,x:fY.x,y:fY.y,static:!1,isDraggable:!0}])}else if(r){if(r.left!==tJ.left||r.top!==tJ.top)H0(tJ)}},[r0,r,B0,K0,R,$1,J0,I,k,S,j,H,n]),L1=y0.useCallback((x0)=>{if(x0.preventDefault(),x0.stopPropagation(),G1.current--,G1.current<0)G1.current=0;if(G1.current===0)$1()},[$1]),u1=y0.useCallback((x0)=>{x0.preventDefault(),x0.stopPropagation(),G1.current++},[]),c1=y0.useCallback((x0)=>{x0.preventDefault(),x0.stopPropagation();let z1=p0.current,u0=z1.find((A1)=>A1.i===B0.i);G1.current=0,$1(),C(z1,u0,x0.nativeEvent)},[B0.i,$1,C]),M1=y0.useCallback((x0,z1)=>{if(!x0||!x0.key)return null;let u0=B6(m,String(x0.key));if(!u0)return null;let A1=typeof u0.isDraggable==="boolean"?u0.isDraggable:!u0.static&&v,v1=typeof u0.isResizable==="boolean"?u0.isResizable:!u0.static&&x,d1=u0.resizeHandles||[...t],M5=A1&&c&&u0.isBounded!==!1,U2=D0;return a9.jsx(jD,{containerWidth:H,cols:I,margin:k,containerPadding:n,maxRows:S,rowHeight:j,cancel:e,handle:T,onDragStart:N0,onDrag:b0,onDragStop:W1,onResizeStart:C0,onResize:I0,onResizeStop:g0,isDraggable:A1,isResizable:v1,isBounded:M5,useCSSTransforms:$0&&f,usePercentages:!f,transformScale:J0,positionStrategy:z,dragThreshold:Z0,w:u0.w,h:u0.h,x:u0.x,y:u0.y,i:u0.i,minH:u0.minH,minW:u0.minW,maxH:u0.maxH,maxW:u0.maxW,static:u0.static,droppingPosition:z1?r:void 0,resizeHandles:d1,resizeHandle:U2,constraints:F,layoutItem:u0,layout:m,children:x0},u0.i)},[m,H,I,k,n,S,j,e,T,N0,b0,W1,C0,I0,g0,v,x,c,$0,f,J0,z,Z0,r,t,D0,F]),q5=()=>{if(!o)return null;return a9.jsx(jD,{w:o.w,h:o.h,x:o.x,y:o.y,i:o.i,className:`react-grid-placeholder ${O0?"placeholder-resizing":""}`,containerWidth:H,cols:I,margin:k,containerPadding:n,maxRows:S,rowHeight:j,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:$0,transformScale:J0,constraints:F,layout:m,children:a9.jsx("div",{})})},p5=TD(Ff,W),i5={height:t0,...N};return a9.jsxs("div",{ref:L,className:p5,style:i5,onDrop:p?c1:void 0,onDragLeave:p?L1:void 0,onDragEnter:p?u1:void 0,onDragOver:p?l0:void 0,children:[y0.default.Children.map(Z,(x0)=>{if(!y0.default.isValidElement(x0))return null;return M1(x0)}),p&&r0&&M1(r0,!0),q5()]})}var R7=O(d(),1);function CD({items:$,editing:Z,renderItem:H,onLayoutChange:B}){let[J,Q]=gJ.useState(()=>OJ($,[])),[X,z]=gJ.useState($),{width:G,containerRef:F,mounted:U}=JD({measureBeforeMount:!0});if(X!==$)z($),Q((K)=>{let W=new Map(K.map((A)=>[A.i,A])),N=$.filter((A)=>W.has(A.id)).map((A)=>({...W.get(A.id),w:A.w,h:A.h})),L=new Set(N.map((A)=>A.i)),V=OJ($.filter((A)=>!L.has(A.id)),N);return[...N,...V]});let Y=gJ.useCallback((K)=>{Q(K),B?.(K.map((W)=>({id:W.i,w:W.w,h:W.h,x:W.x,y:W.y})))},[B]);return R7.jsx("div",{ref:F,className:"mx-auto w-full max-w-[var(--column-w)]",children:U&&R7.jsx(vJ,{width:G,layout:J,gridConfig:{cols:4,rowHeight:160,margin:[8,8],containerPadding:[0,0]},dragConfig:{enabled:!!Z},resizeConfig:{enabled:!1},compactor:RJ,onLayoutChange:Y,children:J.map((K)=>R7.jsx("div",{children:R7.jsx(B5.div,{layoutId:K.i,"data-applet-thumbnail":`widget:${K.i}`,className:"size-full",transition:{type:"spring",duration:0.35,bounce:0},children:H(K.i)})},K.i))})})}function Nf({items:$,editing:Z,renderItem:H,onLayoutChange:B,onRemove:J}){return R7.jsx(CD,{items:$,editing:Z,onLayoutChange:B,renderItem:(Q)=>R7.jsx(aU,{editing:Z,onRemove:J?()=>J(Q):void 0,children:H(Q)})})}var R1=O(d(),1);function Lf($){return R1.jsx(sv,{name:$})}var pH0=Array.from({length:10},($,Z)=>({id:`empty-widget-${Z}`,w:2,h:1}));function uH0(){return R1.jsx(gZ,{className:"size-full animate-none rounded-2xl texture-checker [corner-shape:superellipse(1.2)]"})}function cH0({onCreateWidget:$}){return R1.jsxs("div",{className:"relative min-h-0 flex-1 pt-7",children:[R1.jsx("div",{"aria-hidden":"true",children:R1.jsx(CD,{items:pH0,renderItem:uH0})}),R1.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6",children:R1.jsxs("div",{className:"flex h-full w-full max-w-(--column-w) flex-col items-center justify-center gap-4 bg-radial from-background from-30% to-transparent to-80% text-center",children:[R1.jsxs("div",{className:"flex flex-col gap-1.5",children:[R1.jsx("h2",{className:"font-medium",children:"A little empty here"}),R1.jsx("p",{className:"mx-auto max-w-xs text-sm text-muted-foreground",children:"Widgets are small apps that can read data, perform tasks, and surface important information"})]}),R1.jsxs(T0,{type:"button",variant:"secondary",onClick:$,children:[R1.jsx(W4,{"data-icon":"inline-start",stroke:1.5}),"Create widget"]})]})})]})}function dH0({editing:$,onCreateWidget:Z,onEditingChange:H}){return R1.jsxs("div",{className:"mx-auto mb-4 flex w-full max-w-(--column-w) shrink-0 items-center justify-end gap-2",children:[$&&R1.jsxs(T0,{type:"button",variant:"ghost",size:"sm",className:"mr-auto",onClick:Z,children:[R1.jsx(W4,{"data-icon":"inline-start",stroke:1.75}),"New widget"]}),R1.jsx(e2,{mode:"popLayout",initial:!1,children:R1.jsx(B5.div,{variants:{from:{opacity:0,scale:0.8,filter:"blur(4px)"},to:{opacity:1,scale:1,filter:"blur(0px)"}},initial:"from",animate:"to",exit:"from",transition:{type:"spring",duration:0.3,bounce:0},children:R1.jsx(T0,{type:"button",variant:$?"default":"ghost",size:"sm",className:s(!$&&"text-muted-foreground group-hover/widgets:opacity-100 [@media(hover:hover)]:opacity-0"),onClick:()=>H(!$),children:$?"Done":"Edit widgets"})},$?"done":"edit")})]})}function lH0(){return R1.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3",children:R1.jsx("p",{className:"text-sm text-muted-foreground",children:"No widgets added yet"})})}function iH0(){let[$,Z]=YY.useState(0);return[YY.useCallback((B)=>{if(!B)return;let J=new ResizeObserver(([Q])=>{let X=Q.borderBoxSize?.[0];Z(X?X.blockSize:Q.contentRect.height)});return J.observe(B),()=>J.disconnect()},[]),$]}function Vf({onCreateWidget:$,editing:Z,onEditingChange:H,widgets:B}){let{layout:J,setLayout:Q}=K5(),X=B.length>0,z=new Set(J.widgetGrid.map((L)=>L.i)),G=J.widgetGrid.filter((L)=>B.some((V)=>V.id===L.i)).map((L)=>{let V=B.find((A)=>A.id===L.i);return{id:L.i,w:V.config.colSpan,h:V.config.rowSpan,x:L.x,y:L.y}}),F=B.filter((L)=>!z.has(L.id)).map((L)=>({id:L.id,w:L.config.colSpan,h:L.config.rowSpan})),[U,Y]=iH0(),K=Z&&F.length>0;lU({kind:"widget",enabled:!Z,targets:G.map((L)=>({id:L.id,revision:B.find((V)=>V.id===L.id)?.revision}))});function W(L){Q({widgetGrid:J.widgetGrid.filter((V)=>V.i!==L)})}function N(L){let V=B.find((q)=>q.id===L);if(!V)return;let A=J.widgetGrid.map((q)=>{let _=B.find((M)=>M.id===q.i);return{...q,w:_?.config.colSpan??1,h:_?.config.rowSpan??1}}),D=_J(A,V.config.colSpan,V.config.rowSpan,4);Q({widgetGrid:[...J.widgetGrid,{i:L,x:D.x,y:D.y}]})}return R1.jsx("div",{className:"group/widgets relative min-h-0 flex-1",children:R1.jsxs(Af,{children:[R1.jsx("div",{className:s("relative flex h-full flex-col p-4",X?"overflow-y-auto":"overflow-hidden"),children:X?R1.jsxs(R1.Fragment,{children:[R1.jsx(dH0,{editing:Z,onCreateWidget:$,onEditingChange:H}),G.length===0?R1.jsx(B5.div,{className:"mx-auto flex min-h-0 w-full max-w-[var(--column-w)] flex-1 flex-col",animate:{paddingBottom:K?Y:0},transition:{type:"spring",duration:0.3,bounce:0},children:R1.jsx(lH0,{})}):R1.jsx(B5.div,{animate:{marginBottom:K?Y:0},transition:{type:"spring",duration:0.3,bounce:0},children:R1.jsx(Nf,{items:G,editing:Z,renderItem:Lf,onRemove:W,onLayoutChange:(L)=>Q({widgetGrid:L.map((V)=>({i:V.id,x:V.x??0,y:V.y??0}))})})})]}):R1.jsx(cH0,{onCreateWidget:$})}),R1.jsx(e2,{children:X&&Z&&F.length>0&&R1.jsx(Zg,{ref:U,items:F,renderItem:Lf,onClose:()=>H(!1),onRestore:N})})]})})}var qf=O(d(),1);function Df({children:$}){return qf.jsx("header",{className:s("@container relative flex shrink-0 items-center gap-2.5 py-2 pr-3 pl-4","after:absolute after:top-full after:left-0 after:h-px after:w-full after:bg-border"),children:$})}var pD=O(g(),1);var q2=O(d(),1);function rH0($){if($==="needs-auth")return"Needs auth";return $[0].toUpperCase()+$.slice(1)}function aH0({name:$,status:Z}){let H=RU($),B="size-full rounded-lg ring-2 ring-background";return q2.jsxs("span",{className:"relative size-10 shrink-0",children:[H?q2.jsx("img",{src:H,alt:"",className:"size-full rounded-lg ring-2 ring-background"}):q2.jsx("span",{className:"flex size-full items-center justify-center rounded-lg bg-muted text-muted-foreground ring-2 ring-background",children:q2.jsx(bU,{className:"size-5"})}),Z!=="connected"&&q2.jsx(Mf,{"aria-hidden":"true",size:16,stroke:1.75,className:"absolute -top-1 -right-1 rounded-full bg-card text-amber-400"})]})}function Pf($){return[...$].sort((Z,H)=>Number(H.status==="connected")-Number(Z.status==="connected"))}function _f({icon:$,children:Z}){return q2.jsxs("div",{className:"flex items-center gap-3 text-card-foreground",children:[$,q2.jsx("div",{className:"flex min-w-0 flex-1 flex-col justify-center gap-0.5",children:Z})]})}function Of({server:$}){return q2.jsxs(_f,{icon:q2.jsx(aH0,{name:$.name,status:$.status}),children:[q2.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:kU($.name)}),q2.jsx("span",{className:"text-sm text-muted-foreground",children:rH0($.status)})]})}function jf(){return q2.jsxs(_f,{icon:q2.jsx(gZ,{className:"size-10 shrink-0 rounded-lg"}),children:[q2.jsx(gZ,{className:"h-4 w-36 max-w-full"}),q2.jsx(gZ,{className:"h-4 w-20"})]})}function wD({children:$}){return q2.jsx("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2",children:$})}function Tf($,Z){return o1({queryKey:w0.mcp($),queryFn:()=>V1(`/api/workspaces/${$}/mcp`),enabled:Z,staleTime:1/0,gcTime:1/0,refetchOnMount:!1,refetchOnWindowFocus:!1})}var P4=O(d(),1);function iZ({title:$,description:Z,children:H}){return P4.jsxs("div",{className:"flex flex-col gap-6",children:[P4.jsxs("header",{className:"flex flex-col gap-0.5",children:[P4.jsx("h2",{className:"text-lg font-medium tracking-tight",children:$}),Z&&P4.jsx("p",{className:"text-sm text-muted-foreground",children:Z})]}),H]})}function rZ({label:$,children:Z}){return P4.jsxs("section",{className:"flex flex-col gap-2",children:[$&&P4.jsx("p",{className:"px-0.5 text-xs font-medium text-muted-foreground",children:$}),P4.jsx("div",{className:"flex flex-col divide-y divide-dashed divide-border overflow-hidden rounded-xl border border-border bg-card text-card-foreground",children:Z})]})}function aZ({title:$,description:Z,control:H}){return P4.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-3",children:[P4.jsxs("div",{className:"flex min-w-0 flex-col",children:[P4.jsx("span",{className:"text-sm font-medium",children:$}),Z&&P4.jsx("span",{className:"text-xs text-muted-foreground",children:Z})]}),H&&P4.jsx("div",{className:"ml-auto flex shrink-0 items-center pl-3",children:H})]})}var d2=O(d(),1),nH0=Array.from({length:4},($,Z)=>Z);function oH0({connectors:$}){if($.isPending)return d2.jsx("div",{role:"status","aria-label":"Loading connectors",children:d2.jsx(wD,{children:nH0.map((Z)=>d2.jsx(jf,{},Z))})});if($.isError)return d2.jsxs(Cf,{children:[d2.jsx("p",{className:"text-sm text-muted-foreground",children:"Could not load connectors."}),d2.jsx(T0,{variant:"outline",size:"sm",onClick:()=>$.refetch(),children:"Retry"})]});if($.data.length===0)return d2.jsxs(Cf,{children:[d2.jsx(KY,{size:24,stroke:1.5,className:"text-muted-foreground"}),d2.jsx("p",{className:"text-sm text-foreground",children:"No connectors configured."})]});return d2.jsx(wD,{children:Pf($.data).map((Z)=>d2.jsx(Of,{server:Z},Z.name))})}function Cf({children:$}){return d2.jsx("div",{className:"flex min-h-48 flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-border px-8 py-12 text-center",children:$})}function wf(){let{workspaceId:$}=K5(),Z=Tf($,!0);return d2.jsx(iZ,{title:"Connectors",description:"Connectors available to the agent in this workspace.",children:d2.jsx(oH0,{connectors:Z})})}var kD=O(g(),1);var mJ={};j4(mJ,{Thumb:()=>Rf,Root:()=>Sf});var X6=O(g(),1);var WY=O(g(),1),ED=WY.createContext(void 0);function Ef(){let $=WY.useContext(ED);if($===void 0)throw Error(E0(63));return $}var SD=function($){return $.checked="data-checked",$.unchecked="data-unchecked",$.disabled="data-disabled",$.readonly="data-readonly",$.required="data-required",$.valid="data-valid",$.invalid="data-invalid",$.touched="data-touched",$.dirty="data-dirty",$.filled="data-filled",$.focused="data-focused",$}({});var NY={...x2,checked($){if($)return{[SD.checked]:""};return{[SD.unchecked]:""}}};var fJ=O(d(),1),Sf=X6.forwardRef(function(Z,H){let{checked:B,className:J,defaultChecked:Q,id:X,inputRef:z,name:G,nativeButton:F=!1,onCheckedChange:U,readOnly:Y=!1,required:K=!1,disabled:W=!1,render:N,uncheckedValue:L,value:V,...A}=Z,{clearErrors:D}=s4(),{state:q,setTouched:_,setDirty:M,validityData:P,setFilled:C,setFocused:R,shouldValidateOnChange:y,validationMode:w,disabled:h,name:E,validation:I}=h5(),{labelId:j}=N2(),S=h||W,k=E??G,b=Y0(U),v=X6.useRef(null),c=C4(v,z,I.inputRef),T=X6.useRef(null),e=H1(),Z0=V$({id:X,implicit:!1,controlRef:T}),x=F?void 0:Z0,[t,D0]=t4({controlled:B,default:Boolean(Q),name:"Switch",state:"checked"});D$({id:e,commit:I.commit,value:t,controlRef:T,name:k,getValue:()=>t}),U0(()=>{if(v.current)C(v.current.checked)},[v,C]),PF(t,()=>{if(D(k),M(t!==P.initialValue),C(t),y())I.commit(t);else I.commit(t,!0)});let{getButtonProps:p,buttonRef:X0}=u5({disabled:S,native:F}),K0={id:F?Z0:e,role:"switch","aria-checked":t,"aria-readonly":Y||void 0,"aria-required":K||void 0,"aria-labelledby":j,onFocus(){if(!S)R(!0)},onBlur(){let i=v.current;if(!i||S)return;if(_(!0),R(!1),w==="onBlur")I.commit(i.checked)},onClick(i){if(Y||S)return;i.preventDefault(),v.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:i.shiftKey,ctrlKey:i.ctrlKey,altKey:i.altKey,metaKey:i.metaKey}))}},Q0=X6.useMemo(()=>K4({checked:t,disabled:S,id:x,name:k,required:K,style:k?nM:K8,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:c,onChange(i){if(i.nativeEvent.defaultPrevented)return;let B0=i.target.checked,$0=M0(G0.none,i.nativeEvent);if(b?.(B0,$0),$0.isCanceled)return;D0(B0)},onFocus(){T.current?.focus()}},I.getInputValidationProps,V!==void 0?{value:V}:b1),[t,S,c,x,k,b,K,D0,I,V]),z0=X6.useMemo(()=>({...q,checked:t,disabled:S,readOnly:Y,required:K}),[q,t,S,Y,K]),L0=F0("span",Z,{state:z0,ref:[H,T,X0],props:[K0,I.getValidationProps,A,p],stateAttributesMapping:NY});return fJ.jsxs(ED.Provider,{value:z0,children:[L0,!t&&k&&L!==void 0&&fJ.jsx("input",{type:"hidden",name:k,value:L}),fJ.jsx("input",{...Q0})]})});var If=O(g(),1);var Rf=If.forwardRef(function(Z,H){let{render:B,className:J,...Q}=Z,{state:X}=h5(),z=Ef(),G={...X,...z};return F0("span",Z,{state:G,ref:H,stateAttributesMapping:NY,props:Q})});var ID=O(d(),1);function kf({className:$,...Z}){return ID.jsx(mJ.Root,{"data-slot":"switch",className:s("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent shadow-xs transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-checked:bg-primary data-unchecked:bg-input",$),...Z,children:ID.jsx(mJ.Thumb,{"data-slot":"switch-thumb",className:"pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform data-checked:translate-x-4 data-unchecked:translate-x-0.5"})})}var RD=["app-settings"];function bf(){let $=Z1();return B2((Z)=>{if(Z.type==="settings:updated")$.setQueryData(RD,Z.settings)}),o1({queryKey:RD,queryFn:()=>V1("/api/settings"),staleTime:30000})}function yf(){let $=Z1();return s1({mutationFn:(Z)=>V1("/api/settings",n5("PATCH",Z),"Failed to save settings"),onSuccess:(Z)=>{$.setQueryData(RD,Z)}})}function hf($){return o1({queryKey:w0.env($),queryFn:()=>V1(`/api/workspaces/${$}/env`),...y4})}function xf($){let Z=Z1();return s1({mutationFn:(H)=>V1(`/api/workspaces/${$}/env`,n5("PUT",H)),onSuccess:(H)=>{Z.setQueryData(w0.env($),H)}})}function vf($){let Z=Z1();return s1({mutationFn:(H)=>S4(`/api/workspaces/${$}/config`,n5("PUT",{name:H}),"Failed to save name"),onSuccess:()=>{Z.invalidateQueries({queryKey:w0.layout($)}),Z.invalidateQueries({queryKey:w0.all})}})}function gf($){let Z=Z1();return s1({scope:{id:`workspace-icon:${$}`},mutationFn:(H)=>V1(`/api/workspaces/${$}/icon`,{method:"PUT",headers:{"Content-Type":H.type||"application/octet-stream"},body:H}),onSuccess:()=>{Z.invalidateQueries({queryKey:w0.layout($)}),Z.invalidateQueries({queryKey:w0.all})}})}function ff($){let Z=Z1();return s1({scope:{id:`workspace-icon:${$}`},mutationFn:()=>S4(`/api/workspaces/${$}/icon`,{method:"DELETE"},"Failed to reset icon"),onSuccess:()=>{Z.invalidateQueries({queryKey:w0.layout($)}),Z.invalidateQueries({queryKey:w0.all})}})}function mf($){let Z=Z1();return B2((H)=>{if(H.type==="env:updated"&&H.workspaceId===$)Z.invalidateQueries({queryKey:w0.env($)})}),{env:hf($),update:xf($)}}var k5=O(d(),1),sH0={dotenv:".env",custom:"secret",both:"override"},tH0=/^[A-Za-z_][A-Za-z0-9_]*$/;function uf(){let{workspaceId:$}=K5(),{env:Z,update:H}=mf($),[B,J]=kD.useState(""),[Q,X]=kD.useState(""),z=tH0.test(B),G=z&&Q.length>0&&!H.isPending,F=()=>{if(!G)return;H.mutate({set:{[B]:Q}},{onSuccess:()=>{J(""),X("")}})},U=Z.data?.vars??[],Y=Z.data?.files.reduce((W,N)=>W+N.count,0)??0,K=Z.data?.files.length??0;return k5.jsxs(iZ,{title:"Environment",description:"Secrets injected into widgets and the agent at run time. Values are write-only — they're never shown again once saved.",children:[k5.jsxs(rZ,{label:"Variables",children:[Z.isLoading?k5.jsx("div",{className:"flex items-center justify-center px-3.5 py-6 text-muted-foreground",children:k5.jsx(I5,{className:"size-4 animate-spin",stroke:1.75})}):U.length===0?k5.jsx("p",{className:"px-3.5 py-4 text-sm text-muted-foreground",children:"No variables yet."}):U.map((W)=>{let N=W.source!=="dotenv";return k5.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[k5.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:W.key}),k5.jsx("span",{className:"text-xs tracking-widest text-muted-foreground/60 select-none",children:"••••••"}),k5.jsx("span",{className:s("rounded-lg px-1.5 py-0.5 text-[11px] font-medium",W.source==="dotenv"?"bg-muted text-muted-foreground":"bg-primary/10 text-primary"),children:sH0[W.source]}),!N&&k5.jsx("span",{className:"text-right text-[11px] text-muted-foreground/60",children:"from file"}),k5.jsx(T0,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>H.mutate({remove:[W.key]}),disabled:!N,"aria-label":`Delete ${W.key}`,className:"disabled:invisible",children:k5.jsx(pf,{stroke:1.75})})]},W.key)}),k5.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5",children:[k5.jsx(L3,{value:B,onChange:(W)=>J(W.target.value),placeholder:"NEW_KEY","aria-invalid":B.length>0&&!z,className:"h-7 w-40 font-mono text-xs"}),k5.jsx(L3,{value:Q,onChange:(W)=>X(W.target.value),onKeyDown:(W)=>{if(W.key==="Enter")F()},type:"password",placeholder:"value",className:"h-7 flex-1 text-xs"}),k5.jsxs(T0,{variant:"outline",size:"sm",onClick:F,disabled:!G,children:[H.isPending?k5.jsx(I5,{stroke:1.75,className:"animate-spin"}):k5.jsx(W4,{stroke:1.75}),"Add"]})]})]}),k5.jsx(rZ,{label:"From .env files",children:k5.jsx(aZ,{title:"Inherit .env files",description:K>0?`Discovered ${Y} ${Y===1?"key":"keys"} across ${K} ${K===1?"file":"files"} in this space.`:"No .env files found in this space.",control:k5.jsx(kf,{checked:Z.data?.inheritDotenv??!0,disabled:Z.isLoading,onCheckedChange:(W)=>H.mutate({inheritDotenv:W})})})})]})}var ip=O(g(),1);var T2=O(g(),1);var n0=O(g(),1),nZ=O(g(),1),m4=O(g(),1),Ym=O(d(),1),AY=O(g(),1),VY=O(g(),1),j1=O(d(),1),eH0=Object.defineProperty,$B0=($,Z)=>{for(var H in Z)eH0($,H,{get:Z[H],enumerable:!0})},n9={};$B0(n9,{ActiveEmoji:()=>wm,Empty:()=>Cm,List:()=>Om,Loading:()=>Tm,Root:()=>Am,Search:()=>Vm,SkinTone:()=>Em,SkinToneSelector:()=>jm,Viewport:()=>Dm});var Qm="'Apple Color Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', 'Android Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', EmojiSymbols, sans-serif",hD=["none","light","medium-light","medium","medium-dark","dark"];function bD($){return $.charAt(0).toUpperCase()+$.slice(1)}var k8=2,l2=null;function cf($){try{l2??=document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{}if(!l2||(queueMicrotask(()=>{l2&&(l2=null)}),l2.canvas.width=k8,l2.canvas.height=k8,l2.font=`2px ${Qm}`,l2.textBaseline="middle",l2.measureText($).width>=k8*2))return!1;l2.fillStyle="#00f",l2.fillText($,0,0);let Z=l2.getImageData(0,0,k8,k8).data;l2.clearRect(0,0,k8,k8),l2.fillStyle="#f00",l2.fillText($,0,0);let H=l2.getImageData(0,0,k8,k8).data;for(let B=0;B<k8*k8*4;B+=4)if(Z[B]!==H[B]||Z[B+1]!==H[B+1]||Z[B+2]!==H[B+2])return!1;return!0}function df($,Z,H){try{let B=$.getItem(Z);if(!B)throw Error(`No value found for "${Z}".`);let J=JSON.parse(B);return H(J)}catch{return null}}function Xm($,Z,H){$.setItem(Z,JSON.stringify(H))}function lf($){return(Z)=>Z===void 0?void 0:$(Z)}function rf($){return(Z)=>Z===null?null:$(Z)}function j2($){if(typeof $!="string")throw Error();return $}function LY($){if(typeof $!="number")throw Error();return $}function zm($){if(typeof $!="boolean")throw Error();return $}function z6($){return(Z)=>{if(typeof Z!="object"||Z===null)throw Error();let H={};for(let B in $){let J=Z[B];J===void 0&&$[B](void 0),H[B]=$[B](J)}return H}}function yD($){return(Z)=>{if(!Array.isArray(Z))throw Error();return Z.length>0&&$(Z[0]),Z}}var Gm=($,Z)=>`${$}/${Z}/data.json`,Fm=($,Z)=>`${$}/${Z}/messages.json`,ZB0=["bn","da","de","en-gb","en","es-mx","es","et","fi","fr","hi","hu","it","ja","ko","lt","ms","nb","nl","pl","pt","ru","sv","th","uk","vi","zh-hant","zh"],af="en",Um=($)=>`frimousse/data/${$}`,nf="frimousse/metadata";async function of($,Z){try{return(await fetch($,{method:"HEAD",signal:Z})).headers.get("etag")}catch{return null}}async function HB0($,Z,H){let[{emojis:B,emojisEtag:J},{messages:Q,messagesEtag:X}]=await Promise.all([fetch(Gm($,Z),{signal:H}).then(async(z)=>({emojis:await z.json(),emojisEtag:z.headers.get("etag")})),fetch(Fm($,Z),{signal:H}).then(async(z)=>({messages:await z.json(),messagesEtag:z.headers.get("etag")}))]);return{emojis:B,messages:Q,emojisEtag:J,messagesEtag:X}}async function BB0($,Z,H){let[B,J]=await Promise.all([of(Gm($,Z),H),of(Fm($,Z),H)]);return{emojisEtag:B,messagesEtag:J}}function JB0($){return $.skins?$.skins.filter((Z)=>typeof Z.tone=="number").reduce((Z,H)=>{let B=hD[H.tone];return Z[B]=H.emoji,Z},{}):void 0}async function sf($,Z,H){let{emojis:B,emojisEtag:J,messages:Q,messagesEtag:X}=await HB0($,Z,H),z=Q.subgroups.find((N)=>N.key==="country-flag"||N.key==="subdivision-flag"),G=Q.groups.filter((N)=>N.key!=="component"),F=B.filter((N)=>("group"in N)),U=G.map((N)=>({index:N.order,label:bD(N.message)})),Y=Q.skinTones.reduce((N,L)=>(N[L.key]=bD(L.message),N),{}),K=F.map((N)=>({emoji:N.emoji,category:N.group,version:N.version,label:bD(N.label),tags:N.tags??[],countryFlag:z&&N.subgroup===z.order||void 0,skins:JB0(N)})),W={locale:Z,emojis:K,categories:U,skinTones:Y};return Xm(localStorage,Um(Z),{data:W,metadata:{emojisEtag:J,messagesEtag:X}}),W}function QB0($,Z){let H=new Map;for(let X of $)H.has(X.version)||H.set(X.version,X.emoji);let B=[...H.keys()].sort((X,z)=>z-X),J=B[0]??0,Q=cf("\uD83C\uDDEA\uD83C\uDDFA");if(typeof Z=="number")return{emojiVersion:Z,countryFlags:Q};for(let X of B){let z=H.get(X);if(cf(z))return{emojiVersion:X,countryFlags:Q}}return{emojiVersion:J,countryFlags:Q}}var XB0=z6({emojiVersion:LY,countryFlags:zm}),zB0=z6({data:z6({locale:j2,emojis:yD(z6({emoji:j2,category:LY,label:j2,version:LY,tags:yD(j2),countryFlag:lf(zm),skins:lf(z6({light:j2,"medium-light":j2,medium:j2,"medium-dark":j2,dark:j2}))})),categories:yD(z6({index:LY,label:j2})),skinTones:z6({light:j2,"medium-light":j2,medium:j2,"medium-dark":j2,dark:j2})}),metadata:z6({emojisEtag:rf(j2),messagesEtag:rf(j2)})});async function GB0({locale:$,emojiVersion:Z,emojibaseUrl:H,signal:B}){let J=typeof H=="string"?H:`https://cdn.jsdelivr.net/npm/emojibase-data@${typeof Z=="number"?Math.floor(Z):"latest"}`,Q=df(sessionStorage,nf,XB0),X=df(localStorage,Um($),zB0),z;if(!X)z=await sf(J,$,B);else if(Q)z=X.data;else try{let{emojisEtag:F,messagesEtag:U}=await BB0(J,$,B);z=!F||!U||F!==X.metadata.emojisEtag||U!==X.metadata.messagesEtag?await sf(J,$,B):X.data}catch{z=X.data}Q??=QB0(z.emojis,Z),Xm(sessionStorage,nf,Q);let G=z.emojis.filter((F)=>{let U=F.version<=Q.emojiVersion;return F.countryFlag?U&&Q.countryFlags:U});return{locale:$,emojis:G,categories:z.categories,skinTones:z.skinTones}}function tf($){return ZB0.includes($)?$:(console.warn(`Locale "${$}" is not supported, using "${af}" instead.`),af)}function ef($){return hD.includes($)?$:(console.warn(`Skin tone "${$}" is not valid, using "none" instead.`),"none")}function FB0($,Z){let H=[];if(Z<=0)return H;for(let B=0,J=$.length;B<J;B+=Z)H.push($.slice(B,B+Z));return H}function UB0($,Z){if(!Z)return $;let H=Z.toLowerCase().trim(),B=new WeakMap;return $.filter((J)=>{let Q=0;J.label.toLowerCase().includes(H)&&(Q+=10);for(let X of J.tags)X.toLowerCase().includes(H)&&(Q+=1);return Q>0?(B.set(J,Q),!0):!1}).sort((J,Q)=>(B.get(Q)??0)-(B.get(J)??0))}function YB0($,Z,H,B){let J=UB0($.emojis,B),Q=[],X=[],z=[],G={},F=0,U=0;for(let Y of J)G[Y.category]||(G[Y.category]=[]),G[Y.category].push({emoji:H&&H!=="none"&&Y.skins?Y.skins[H]:Y.emoji,label:Y.label});for(let Y of $.categories){let K=G[Y.index];if(!K||K.length===0)continue;let W=FB0(Array.from(K),Z).map((N)=>({categoryIndex:F,emojis:N}));Q.push(...W),X.push({label:Y.label,rowsCount:W.length,startRowIndex:U}),z.push(U),F++,U+=W.length}return{count:J.length,categories:X,categoriesStartRowIndices:z,rows:Q,skinTones:$.skinTones}}function KB0($){let Z={},H=null,B=null,J=new Set,Q=()=>{if(H){Z=H,H=null;for(let F of J)F(Z)}B=null},X=()=>H??Z,z=(F)=>{H??=Z,Object.assign(H,typeof F=="function"?F(X()):F),B||(B=requestAnimationFrame(Q))},G=(F)=>(J.add(F),()=>J.delete(F));return Z=$(z,X),{get:X,set:z,subscribe:G}}function WB0($){let[Z]=m4.useState($);return Z}function NB0($){let Z=m4.createContext(null);return{useStore:()=>{let H=m4.useContext(Z);if(!H)throw Error($);return H},Provider:({store:H,children:B})=>Ym.jsx(Z.Provider,{value:H,children:B})}}function f4($,Z,H=Object.is){let[B,J]=m4.useState(()=>Z($.get()));return m4.useEffect(()=>$.subscribe(()=>{let Q=Z($.get());J((X)=>H(X,Q)?X:Q)}),[$,Z,H]),m4.useDebugValue(B),B}function j9($,Z,H){let B=m4.useCallback((J)=>J[Z],[Z]);return f4($,B,H)}var $m=2;function LB0($,Z,H,B,J){let Q=0;return KB0((X,z)=>({locale:Z,columns:H,sticky:B,skinTone:J,onEmojiSelect:$,data:null,search:"",interaction:"none",activeColumnIndex:0,activeRowIndex:0,rowHeight:null,categoryHeaderHeight:null,viewportWidth:null,viewportHeight:null,viewportCurrentCategoryIndex:null,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0,rootRef:null,searchRef:null,viewportRef:null,listRef:null,updateViewportState:(G)=>{let F=z(),U=G?.data??F.data,Y=G?.categoryHeaderHeight??F.categoryHeaderHeight,K=G?.rowHeight??F.rowHeight,W=G?.viewportHeight??F.viewportHeight;if(!U||U.rows.length===0||!Y||!K||!W)return X({...G,viewportStartCategoryIndex:0,viewportStartRowIndex:0,viewportEndRowIndex:0});let N=0,L=0;for(let R of U.categories)if(L++*Y+R.startRowIndex*K<Q)N+=Y;else break;let V=U.categories.length*Y+U.rows.length*K,A=Math.floor($m*K/2),D=Math.ceil($m*K/2),q=Math.min(Q-N-A,V-W),_=q+W+D,M=Math.max(0,Math.floor(q/K)),P=Math.min(U.rows.length-1,Math.ceil(_/K)),C=U.rows[M]?.categoryIndex;return X(C===void 0&&G?G:{...G,viewportStartCategoryIndex:C,viewportStartRowIndex:M,viewportEndRowIndex:P})},onDataChange:(G)=>{z().updateViewportState({data:G,activeColumnIndex:0,activeRowIndex:0})},onSearchChange:(G)=>{X({search:G,interaction:G?"keyboard":"none"})},onActiveEmojiChange:(G,F,U)=>{if(X({interaction:G,activeColumnIndex:F,activeRowIndex:U}),G!=="keyboard")return;let{listRef:Y,viewportRef:K,sticky:W,rowHeight:N,viewportHeight:L,categoryHeaderHeight:V}=z(),A=Y?.current,D=K?.current;if(!A||!D||!N||!V||!L)return;let q=U;q===0&&D.scrollTo({top:0,behavior:"instant"});let _=A.querySelector(`[aria-rowindex="${q}"]`);if(!(_ instanceof HTMLElement))return;let M=_.offsetTop,P=getComputedStyle(_),C=Number.parseFloat(P.scrollMarginTop),R=Number.parseFloat(P.scrollMarginBottom),y=Q+C;W&&M<Q+L/2&&(y+=V);let w=y+L-R;(M<y||M+N>w)&&D.scrollTo({top:Math.max(M<y+V?M-Math.max(W?V:0,C):M-L+N+R,0),behavior:"instant"})},onActiveEmojiReset:()=>{X({interaction:"none",activeColumnIndex:0,activeRowIndex:0})},onRowHeightChange:(G)=>{z().updateViewportState({rowHeight:G})},onCategoryHeaderHeightChange:(G)=>{z().updateViewportState({categoryHeaderHeight:G})},onViewportSizeChange:(G,F)=>{z().updateViewportState({viewportWidth:G,viewportHeight:F})},onViewportScroll:(G)=>{Q=G,z().updateViewportState()}}))}var{useStore:_4,Provider:AB0}=NB0("EmojiPicker.Root is missing.");function VB0($){return $.search}function xD($){return $.interaction==="none"?void 0:$.data?.rows[$.activeRowIndex]?.emojis[$.activeColumnIndex]}function DB0($){return $.data===void 0||typeof $.data?.count=="number"&&$.data.count===0}function qB0($){return $.data===null||$.viewportHeight===null||$.rowHeight===null||$.categoryHeaderHeight===null}function Km($){return $.data?.rows.length}function MB0($){return $.data?.categories.length}function PB0($){return $.data?.categoriesStartRowIndices}function _B0($){return $.data?.skinTones}function Wm($,Z){return $?.emoji===Z?.emoji}function OB0($,Z){return $?.categoryIndex!==Z?.categoryIndex||$?.emojis.length!==Z?.emojis.length?!1:!!$?.emojis.every((H,B)=>Wm(H,Z?.emojis[B]))}var pJ="",Zm=/\p{Emoji_Modifier_Base}/u,jB0=/\uFE0F$/,TB0=/\u{1F3FB}|\u{1F3FC}|\u{1F3FD}|\u{1F3FE}|\u{1F3FF}/gu,CB0={light:"\uD83C\uDFFB","medium-light":"\uD83C\uDFFC",medium:"\uD83C\uDFFD","medium-dark":"\uD83C\uDFFE",dark:"\uD83C\uDFFF"};function wB0($,Z){if(!$.split(pJ).some((B)=>Zm.test(B)))return $;let H=$.split(pJ).map((B)=>B.replace(TB0,"")).join(pJ);return Z==="none"?H:H.split(pJ).map((B,J,Q)=>{let X=Q.length>1;return!Zm.test(B)||X&&B==="\uD83E\uDD1D"?B:B.replace(jB0,"")+CB0[Z]}).join(pJ)}function EB0($){return hD.map((Z)=>({skinTone:Z,emoji:wB0($,Z)}))}function Nm(){let $=_4(),Z=f4($,xD,Wm);return nZ.useDeferredValue(Z)}function Lm($="✋"){let Z=_4(),H=j9(Z,"skinTone"),B=nZ.useMemo(()=>EB0($),[$]),J=nZ.useCallback((Q)=>{Z.set({skinTone:Q})},[]);return[H,J,B]}function vD($,Z){if(Object.is($,Z))return!0;if(typeof $!="object"||typeof Z!="object"||$===null||Z===null||Array.isArray($)!==Array.isArray(Z))return!1;let H=Object.keys($),B=Object.keys(Z);return H.length!==B.length?!1:H.every((J)=>(J in Z)&&$[J]===Z[J])}function SB0(...$){}function IB0($,Z){let H=null;if(typeof window.requestIdleCallback=="function")H=window.requestIdleCallback($,Z);else{let B=Date.now();H=window.setTimeout(()=>{$({didTimeout:!1,timeRemaining:()=>Math.max(0,(Z?.timeout??50)-(Date.now()-B))})},10)}return()=>{typeof window.cancelIdleCallback=="function"?window.cancelIdleCallback(H):window.clearTimeout(H)}}var b8=typeof window<"u"?AY.useLayoutEffect:AY.useEffect;function RB0($){let Z=VY.useRef($);return b8(()=>{Z.current=$}),VY.useCallback((...H)=>Z.current(...H),[])}function kB0({emojiVersion:$,emojibaseUrl:Z}){let[H,B]=n0.useState(void 0),J=_4(),Q=j9(J,"locale"),X=j9(J,"columns"),z=j9(J,"skinTone"),G=j9(J,"search");return n0.useEffect(()=>{let F=new AbortController,U=F.signal;return GB0({locale:Q,emojiVersion:$,emojibaseUrl:Z,signal:U}).then((Y)=>{B(Y)}).catch((Y)=>{U.aborted||console.error(Y)}),()=>{F.abort()}},[$,Z,Q]),n0.useEffect(()=>{if(H)return IB0(()=>{J.get().onDataChange(YB0(H,X,z,G))},{timeout:100})},[H,X,z,G]),null}var Am=n0.forwardRef(({locale:$="en",columns:Z=9,skinTone:H="none",onEmojiSelect:B=SB0,emojiVersion:J,emojibaseUrl:Q,onFocusCapture:X,onBlurCapture:z,children:G,style:F,sticky:U=!0,...Y},K)=>{let W=RB0(B),N=WB0(()=>LB0(W,tf($),Z,U,ef(H))),[L,V]=n0.useState(!1),A=n0.useRef(null),D=n0.useCallback((M)=>{M&&(A.current=M,N.set({rootRef:A}))},[]);b8(()=>{N.set({locale:tf($)})},[$]),b8(()=>{N.set({columns:Z})},[Z]),b8(()=>{N.set({sticky:U})},[U]),b8(()=>{N.set({skinTone:ef(H)})},[H]);let q=n0.useCallback((M)=>{X?.(M);let{searchRef:P,viewportRef:C}=N.get(),R=M.target===P?.current||M.target.hasAttribute("frimousse-search"),y=M.target===C?.current||M.target.hasAttribute("frimousse-viewport");M.isDefaultPrevented()||(V(R||y),M.isDefaultPrevented()||(V(R||y),y?N.get().onActiveEmojiChange("keyboard",0,0):R&&N.get().search===""&&N.set({interaction:"none"})))},[X]),_=n0.useCallback((M)=>{z?.(M),!M.isDefaultPrevented()&&!M.currentTarget.contains(M.relatedTarget)&&V(!1)},[z]);return b8(()=>{L||N.get().onActiveEmojiReset()},[L]),n0.useImperativeHandle(K,()=>A.current),n0.useEffect(()=>{if(!L)return;function M(P){if(P.defaultPrevented||!P.key.startsWith("Arrow")&&P.key!=="Enter")return;let{data:C,onEmojiSelect:R,onActiveEmojiChange:y,interaction:w,activeColumnIndex:h,activeRowIndex:E}=N.get();if(P.key==="Enter"){let I=xD(N.get());I&&(P.preventDefault(),R(I))}if(P.key.startsWith("Arrow")){let I=h,j=E;if(P.preventDefault(),w!=="none"){if(C?.rows&&C.rows.length>0)switch(P.key){case"ArrowLeft":{if(I===0){let S=j-1,k=C.rows[S];k&&(j=S,I=k.emojis.length-1)}else I-=1;break}case"ArrowRight":{if(I===C.rows[j].emojis.length-1){let S=j+1;C.rows[S]&&(j=S,I=0)}else I+=1;break}case"ArrowUp":{let S=C.rows[j-1];S&&(j-=1,S.emojis[I]||(I=S.emojis.length-1));break}case"ArrowDown":{let S=C.rows[j+1];S&&(j+=1,S.emojis[I]||(I=S.emojis.length-1));break}}y("keyboard",I,j)}else y("keyboard",0,0)}}return document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}},[L]),b8(()=>{let M=null,P=null,C=null,R=null,y=N.subscribe((j)=>{A.current&&(M!==j.viewportWidth&&(M=j.viewportWidth,A.current.style.setProperty("--frimousse-viewport-width",`${j.viewportWidth}px`)),P!==j.viewportHeight&&(P=j.viewportHeight,A.current.style.setProperty("--frimousse-viewport-height",`${j.viewportHeight}px`)),C!==j.rowHeight&&(C=j.rowHeight,A.current.style.setProperty("--frimousse-row-height",`${j.rowHeight}px`)),R!==j.categoryHeaderHeight&&(R=j.categoryHeaderHeight,A.current.style.setProperty("--frimousse-category-header-height",`${j.categoryHeaderHeight}px`)))}),{viewportWidth:w,viewportHeight:h,rowHeight:E,categoryHeaderHeight:I}=N.get();return w&&A.current.style.setProperty("--frimousse-viewport-width",`${w}px`),h&&A.current.style.setProperty("--frimousse-viewport-height",`${h}px`),E&&A.current.style.setProperty("--frimousse-row-height",`${E}px`),I&&A.current.style.setProperty("--frimousse-category-header-height",`${I}px`),y},[]),j1.jsx("div",{"data-focused":L?"":void 0,"frimousse-root":"",onBlurCapture:_,onFocusCapture:q,...Y,ref:D,style:{"--frimousse-emoji-font":Qm,...F},children:j1.jsxs(AB0,{store:N,children:[j1.jsx(kB0,{emojiVersion:J,emojibaseUrl:Q}),G]})})}),Vm=n0.forwardRef(({value:$,defaultValue:Z,onChange:H,...B},J)=>{let Q=_4(),X=n0.useRef(null),z=n0.useCallback((Y)=>{Y&&(X.current=Y,Q.set({searchRef:X}))},[]),G=typeof $=="string",F=n0.useRef(G);n0.useEffect(()=>{F.current=G},[G]),b8(()=>{Q.set({search:typeof $=="string"?$:typeof Z=="string"?Z:""})},[]),b8(()=>{typeof $=="string"&&Q.get().onSearchChange($)},[$]);let U=n0.useCallback((Y)=>{H?.(Y),Y.isDefaultPrevented()||Q.get().onSearchChange(Y.target.value)},[H]);return n0.useImperativeHandle(J,()=>X.current),j1.jsx("input",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",enterKeyHint:"done","frimousse-search":"",placeholder:"Search…",spellCheck:!1,type:"search",...B,defaultValue:Z,onChange:U,ref:z,value:$})}),bB0=n0.memo(()=>{let $=Nm();return $?j1.jsx("div",{"aria-live":"polite",style:{border:0,clip:"rect(0, 0, 0, 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1,wordWrap:"normal"},children:$.label}):null}),Dm=n0.forwardRef(({children:$,onScroll:Z,onKeyDown:H,style:B,...J},Q)=>{let X=_4(),z=n0.useRef(null),G=n0.useCallback((K)=>{K&&(z.current=K,X.set({viewportRef:z}))},[]),F=f4(X,Km),U=f4(X,MB0),Y=n0.useCallback((K)=>{Z?.(K),X.get().onViewportScroll(K.currentTarget.scrollTop)},[Z]);return b8(()=>{if(!z.current)return;let K=new ResizeObserver(([W])=>{let N=W?.borderBoxSize[0]?.inlineSize??0,L=W?.borderBoxSize[0]?.blockSize??0,{onViewportSizeChange:V,viewportHeight:A,viewportWidth:D}=X.get();(A!==L||D!==N)&&V(N,L)});return K.observe(z.current),X.get().onViewportSizeChange(z.current.offsetWidth,z.current.clientHeight),()=>{K.disconnect()}},[]),n0.useImperativeHandle(Q,()=>z.current),j1.jsxs("div",{"frimousse-viewport":"",...J,onScroll:Y,ref:G,style:{position:"relative",boxSizing:"border-box",contain:"layout paint",containIntrinsicSize:typeof F=="number"&&typeof U=="number"?`var(--frimousse-viewport-width, auto) calc(${F} * var(--frimousse-row-height) + ${U} * var(--frimousse-category-header-height))`:void 0,overflowY:"auto",overscrollBehavior:"contain",scrollbarGutter:"stable",willChange:"scroll-position",...B},children:[j1.jsx(bB0,{}),$]})});function qm($,Z,H){return{emoji:{...$,isActive:H},role:"gridcell","aria-colindex":Z,"aria-selected":H||void 0,"aria-label":$.label,"data-active":H?"":void 0,"frimousse-emoji":"",style:{fontFamily:"var(--frimousse-emoji-font)"},tabIndex:-1}}function Mm($,Z=!1){return{role:Z?void 0:"row","aria-rowindex":Z?void 0:$,"frimousse-row":"",style:{contain:Z?void 0:"content",height:Z?void 0:"var(--frimousse-row-height)",display:"flex"}}}function Pm($,Z){return{"frimousse-category":"",style:{contain:"content",top:Z?`calc(${$} * var(--frimousse-category-header-height) + ${Z.startRowIndex} * var(--frimousse-row-height))`:void 0,height:Z?`calc(var(--frimousse-category-header-height) + ${Z.rowsCount} * var(--frimousse-row-height))`:void 0,width:"100%",pointerEvents:"none",position:"absolute"}}}function _m($,Z=!1,H=!0){return{category:$,"frimousse-category-header":"",style:{contain:Z?void 0:"layout paint",height:Z?void 0:"var(--frimousse-category-header-height)",pointerEvents:"auto",position:H?"sticky":void 0,top:0}}}function Hm($,Z,H,B){return{"frimousse-list-sizer":"",style:{position:"relative",boxSizing:"border-box",height:`calc(${$} * var(--frimousse-row-height) + ${Z} * var(--frimousse-category-header-height))`,paddingTop:`calc(${H} * var(--frimousse-row-height) + ${B} * var(--frimousse-category-header-height))`}}}function Bm($,Z,H){return{"aria-colcount":$,"aria-rowcount":Z,"frimousse-list":"",style:{"--frimousse-list-columns":$,...H},role:"grid"}}function yB0($){$.preventDefault()}var hB0=n0.memo(({Emoji:$,emoji:Z,columnIndex:H,rowIndex:B})=>{let J=_4(),Q=f4(J,(F)=>xD(F)?.emoji===Z.emoji),X=n0.useCallback(()=>{J.get().onEmojiSelect(Z)},[Z]),z=n0.useCallback(()=>{J.get().onActiveEmojiChange("pointer",H,B)},[H,B]),G=n0.useCallback(()=>{J.get().onActiveEmojiReset()},[]);return j1.jsx($,{...qm(Z,H,Q),onClick:X,onPointerDown:yB0,onPointerEnter:z,onPointerLeave:G})}),xB0=n0.memo(({Row:$,Emoji:Z,rowIndex:H})=>{let B=_4(),J=f4(B,(Q)=>Q.data?.rows[H],OB0);return J?j1.jsx($,{...Mm(H),children:J.emojis.map((Q,X)=>j1.jsx(hB0,{Emoji:Z,columnIndex:X,emoji:Q,rowIndex:H},Q.label))}):null}),vB0=n0.memo(({CategoryHeader:$,categoryIndex:Z})=>{let H=_4(),B=f4(H,(Q)=>Q.data?.categories[Z],vD),J=j9(H,"sticky");return B?j1.jsx("div",{...Pm(Z,B),children:j1.jsx($,{..._m({label:B.label},!1,J)})}):null}),Jm=n0.memo(({CategoryHeader:$,Row:Z,Emoji:H})=>{let B=n0.useRef(null),J=_4(),Q=j9(J,"columns"),X=n0.useMemo(()=>Array(Q).fill({emoji:"\uD83D\uDE42",label:""}),[Q]),z=n0.useMemo(()=>({label:"Category"}),[]),G=n0.useRef(null),F=n0.useRef(null);return b8(()=>{let U=B.current?.parentElement?.parentElement;if(!U||!G.current||!F.current)return;let Y=new ResizeObserver((N)=>{for(let L of N){let V=L.contentRect.height,{onRowHeightChange:A,onCategoryHeaderHeightChange:D,rowHeight:q,categoryHeaderHeight:_}=J.get();L.target===G.current&&q!==V&&A(V),L.target===F.current&&_!==V&&D(V)}});Y.observe(U),Y.observe(G.current),Y.observe(F.current);let{onRowHeightChange:K,onCategoryHeaderHeightChange:W}=J.get();return K(G.current.clientHeight),W(F.current.clientHeight),()=>{Y.disconnect()}},[]),j1.jsxs("div",{"aria-hidden":!0,ref:B,style:{height:0,visibility:"hidden"},children:[j1.jsx("div",{"frimousse-row-sizer":"",ref:G,children:j1.jsx(Z,{...Mm(-1,!0),children:X.map((U,Y)=>j1.jsx(H,{...qm(U,Y,!1)},Y))})}),j1.jsx("div",{...Pm(-1),children:j1.jsx("div",{"frimousse-category-header-sizer":"",ref:F,children:j1.jsx($,{..._m(z,!0)})})})]})});function gB0({category:$,...Z}){return j1.jsx("div",{...Z,children:$.label})}function fB0({emoji:$,...Z}){return j1.jsx("button",{type:"button",...Z,children:$.emoji})}function mB0({...$}){return j1.jsx("div",{...$})}var Om=n0.forwardRef(({style:$,components:Z,...H},B)=>{let J=_4(),Q=n0.useRef(null),X=n0.useCallback((A)=>{A&&(Q.current=A,J.set({listRef:Q}))},[]),z=Z?.CategoryHeader??gB0,G=Z?.Emoji??fB0,F=Z?.Row??mB0,U=j9(J,"columns"),Y=j9(J,"viewportStartRowIndex"),K=j9(J,"viewportEndRowIndex"),W=f4(J,Km),N=f4(J,PB0,vD),L=n0.useMemo(()=>N?.filter((A)=>A<Y).length??0,[N,Y]),V=N?.length??0;return n0.useImperativeHandle(B,()=>Q.current),!W||!N||V===0?j1.jsx("div",{...Bm(U,0,$),...H,children:j1.jsx("div",{...Hm(0,0,0,0),children:j1.jsx(Jm,{CategoryHeader:z,Emoji:G,Row:F})})}):j1.jsx("div",{...Bm(U,W,$),...H,ref:X,children:j1.jsxs("div",{...Hm(W,V,Y,L),children:[j1.jsx(Jm,{CategoryHeader:z,Emoji:G,Row:F}),Array.from({length:K-Y+1},(A,D)=>{let q=Y+D,_=N.indexOf(q);return j1.jsxs(n0.Fragment,{children:[_>=0&&j1.jsx("div",{style:{height:"var(--frimousse-category-header-height)"}}),j1.jsx(xB0,{Emoji:G,Row:F,rowIndex:q})]},q)}),Array.from({length:V},(A,D)=>j1.jsx(vB0,{CategoryHeader:z,categoryIndex:D},D))]})})}),jm=n0.forwardRef(({emoji:$,onClick:Z,"aria-label":H="Change skin tone",...B},J)=>{let Q=_4(),X=f4(Q,_B0,vD),[z,G,F]=Lm($),U=n0.useMemo(()=>Math.max(0,F.findIndex((V)=>V.skinTone===z)),[z,F]),Y=F[U],K=F[(U+1)%F.length].skinTone,W=z==="none"?void 0:X?.[z],N=K==="none"?void 0:X?.[K],L=n0.useCallback((V)=>{Z?.(V),V.isDefaultPrevented()||G(K)},[Z,G,K]);return j1.jsx("button",{type:"button",...B,"aria-label":H+(N?` (${N})`:""),"aria-live":"polite","aria-valuetext":W,"frimousse-skin-tone-selector":"",onClick:L,ref:J,children:Y.emoji})});function Tm({children:$,...Z}){let H=_4();return f4(H,qB0)?j1.jsx("span",{"frimousse-loading":"",...Z,children:$}):null}function pB0({children:$}){let Z=_4(),H=f4(Z,VB0);return $({search:H})}function Cm({children:$,...Z}){let H=_4();return f4(H,DB0)?j1.jsx("span",{"frimousse-empty":"",...Z,children:typeof $=="function"?j1.jsx(pB0,{children:$}):$}):null}function wm({children:$}){let Z=Nm();return $({emoji:Z})}function Em({children:$,emoji:Z}){let[H,B,J]=Lm(Z);return $({skinTone:H,setSkinTone:B,skinToneVariations:J})}Am.displayName="EmojiPicker.Root";Vm.displayName="EmojiPicker.Search";Dm.displayName="EmojiPicker.Viewport";Om.displayName="EmojiPicker.List";Tm.displayName="EmojiPicker.Loading";Cm.displayName="EmojiPicker.Empty";jm.displayName="EmojiPicker.SkinToneSelector";wm.displayName="EmojiPicker.ActiveEmoji";Em.displayName="EmojiPicker.SkinTone";var uJ=["rocket","sparkles","bolt","flame","star","heart","diamond","trophy","target","bulb","brain","robot","wand","atom","flask","cpu","code","terminal","api","database","cube","hexagon","plug","tool","settings","bug","activity","chart","briefcase","folder","file","book","message","mail","bell","paperclip","key","shield","user","home","globe","world","planet","compass","map","calendar","cloud","sun","moon","snowflake","leaf","mountain","feather","ghost","music","piano","camera","photo","palette","gamepad","gift","cart","chef"],uB0=new Set(uJ);function Sm($){return uB0.has($)}var bp={rocket:qp,sparkles:Op,bolt:uB,flame:tm,star:jp,heart:Jp,diamond:om,trophy:Sp,target:Cp,bulb:gm,brain:hm,robot:Dp,wand:Rp,atom:km,flask:em,cpu:im,code:dm,terminal:wp,api:Rm,database:am,cube:rm,hexagon:Qp,plug:Vp,tool:Ep,settings:cJ,bug:vm,activity:Im,chart:pm,briefcase:xm,folder:$p,file:YZ,book:ym,message:Up,mail:Gp,bell:bm,paperclip:kF,key:DY,shield:Mp,user:Ip,home:Xp,globe:Bp,world:kp,planet:Ap,compass:lm,map:Fp,calendar:fm,cloud:cm,sun:Tp,moon:Yp,snowflake:_p,leaf:zp,mountain:Kp,feather:sm,ghost:Zp,music:Wp,piano:bF,camera:mm,photo:Lp,palette:Np,gamepad:nm,gift:Hp,cart:Pp,chef:um},gD=uJ.map(($)=>({id:$,Icon:bp[$]}));function qY($){return $&&Sm($)?bp[$]:null}var mD=[{id:"sunrise",gradient:{angle:140,stops:["#FFE29F","#FFA99F","#FF719A"]}},{id:"ocean",gradient:{angle:135,stops:["#67E8F9","#3B82F6","#4F46E5"]}},{id:"meadow",gradient:{angle:135,stops:["#A7F3D0","#34D399","#059669"]}},{id:"dusk",gradient:{angle:120,stops:["#C471F5","#FA71CD"]}},{id:"midnight",gradient:{angle:135,stops:["#30CFD0","#330867"]}}];function fD($,Z,H){let B=H*Math.PI/180,J=Z*Math.cos(B),Q=Z*Math.sin(B),X=($+0.3963377774*J+0.2158037573*Q)**3,z=($-0.1055613458*J-0.0638541728*Q)**3,G=($-0.0894841775*J-1.291485548*Q)**3;return`#${[4.0767416621*X-3.3077115913*z+0.2309699292*G,-1.2684380046*X+2.6097574011*z-0.3413193965*G,-0.0041960863*X-0.7034186147*z+1.707614701*G].map((U)=>{let Y=Math.min(1,Math.max(0,U)),K=Y<=0.0031308?12.92*Y:1.055*Y**0.4166666666666667-0.055;return Math.round(K*255).toString(16).padStart(2,"0")}).join("")}`}function yp(){let $=Math.random()*360,Z=(35+Math.random()*55)*(Math.random()<0.5?-1:1),H=Math.round(115+Math.random()*55),B=fD(0.83+Math.random()*0.06,0.09+Math.random()*0.06,$),J=fD(0.5+Math.random()*0.14,0.17+Math.random()*0.07,$+Z);if(Math.random()<0.4){let Q=fD(0.7+Math.random()*0.05,0.15,$+Z/2);return{angle:H,stops:[B,Q,J]}}return{angle:H,stops:[B,J]}}var cB0="radial-gradient(120% 100% at 28% 12%, rgba(255,255,255,0.32), rgba(255,255,255,0) 58%)";function MY($){return`${cB0}, linear-gradient(${$.angle}deg, ${$.stops.join(", ")})`}var G2=256;function hp($,Z){let H=Z.angle*Math.PI/180,B=Math.sin(H),J=-Math.cos(H),Q=G2*(Math.abs(B)+Math.abs(J))/2,X=G2/2,z=$.createLinearGradient(X-B*Q,X-J*Q,X+B*Q,X+J*Q),G=Z.stops.length-1;Z.stops.forEach((U,Y)=>z.addColorStop(G===0?0:Y/G,U)),$.fillStyle=z,$.fillRect(0,0,G2,G2);let F=$.createRadialGradient(G2*0.28,G2*0.12,0,G2*0.28,G2*0.12,G2*1.1);F.addColorStop(0,"rgba(255,255,255,0.32)"),F.addColorStop(0.58,"rgba(255,255,255,0)"),$.fillStyle=F,$.fillRect(0,0,G2,G2)}function xp($){return new Promise((Z,H)=>{$.toBlob((B)=>B?Z(B):H(Error("Canvas is empty")),"image/png")})}function vp(){let $=document.createElement("canvas");$.width=G2,$.height=G2;let Z=$.getContext("2d");if(!Z)throw Error("2D canvas unavailable");return[$,Z]}var dB0=0.92,lB0=0.68;async function gp($,Z){let[H,B]=vp();if(Z)hp(B,Z);B.textAlign="center",B.textBaseline="middle";let J=Z?lB0:dB0;return B.font=`${Math.round(G2*J)}px "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`,B.fillText($,G2/2,G2/2+G2*0.04),xp(H)}function iB0($){return new Promise((Z,H)=>{let B=new Image;B.onload=()=>Z(B),B.onerror=()=>H(Error("Failed to load SVG")),B.src=$})}var rB0=0.78,aB0=0.6;async function fp($,Z){let[H,B]=vp();if(Z)hp(B,Z);let J=Z?"#ffffff":"#18181b",Q=$.replace(/currentColor/g,J),X=await iB0(`data:image/svg+xml;utf8,${encodeURIComponent(Q)}`),z=G2*(Z?aB0:rB0),G=(G2-z)/2;return B.drawImage(X,G,G,z,z),xp(H)}var mp=["\uD83D\uDE80","✨","\uD83D\uDD25","⚡","\uD83D\uDCA1","\uD83E\uDDE0","\uD83E\uDD16","\uD83E\uDE84","\uD83E\uDDEA","⚙️","\uD83D\uDEE0️","\uD83D\uDCBB","\uD83D\uDCE6","\uD83D\uDCCA","\uD83D\uDCC8","\uD83D\uDCDD","\uD83D\uDCDA","\uD83C\uDFAF","\uD83C\uDFC6","\uD83D\uDC8E","\uD83E\uDE90","\uD83C\uDF0D","\uD83E\uDDED","\uD83C\uDFA8","\uD83C\uDFAE","☕"],PY="font-[Apple_Color_Emoji,Segoe_UI_Emoji,Noto_Color_Emoji,sans-serif]";var e0=O(d(),1);function nB0({category:$,...Z}){return e0.jsx("div",{className:"bg-background px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",...Z,children:$.label})}function oB0({children:$,...Z}){return e0.jsx("div",{className:"scroll-my-1 px-1.5",...Z,children:$})}function sB0({emoji:$,...Z}){return e0.jsx("button",{className:s("flex size-9 items-center justify-center rounded-xl text-[22px] transition-colors duration-75 data-active:bg-muted",PY),...Z,children:$.emoji})}function lp({icon:$}){let{workspaceId:Z,provider:H}=K5(),{isPending:B,mutateAsync:J}=gf(Z),{isPending:Q,mutate:X}=ff(Z),[z,G]=T2.useState("emoji"),[F,U]=T2.useState({id:"sunrise",gradient:mD[0].gradient}),[Y,K]=T2.useState(null),[W,N]=T2.useState(null),[L,V]=T2.useState(""),[A,D]=T2.useState(null),[q,_]=T2.useState(null),[M,P]=T2.useState(!1),[C,R]=T2.useState(null),y=T2.useRef(null),w=T2.useRef(null),h=T2.useRef(null),E=gD.find((T)=>T.id===A),I=F.gradient!==null,j=B||Q,S=()=>{let T=yp();K(T),U({id:"shuffle",gradient:T})},k=(T)=>{R(null),h.current=T,G("upload"),_(URL.createObjectURL(T))};T2.useEffect(()=>{let T=!1,e=async()=>{let x;if(z==="upload"){if(!h.current)return;x=h.current}else if(z==="emoji"){if(!W)return;x=await gp(W,F.gradient)}else{let t=w.current?.querySelector("svg");if(!t)return;x=await fp(new XMLSerializer().serializeToString(t),F.gradient)}if(!T)await J(x)};R(null);let Z0=window.setTimeout(()=>{e().catch((x)=>{if(!T)R(x instanceof Error?x.message:"Failed to save icon")})},150);return()=>{T=!0,window.clearTimeout(Z0)}},[F.gradient,W,z,J,E,q]),T2.useEffect(()=>{return()=>{if(q)URL.revokeObjectURL(q)}},[q]);let b=()=>{h.current=null,N(null),D(null),_(null),R(null),X()},v=z==="emoji"&&W?"emoji":z==="icon"&&E?"glyph":"image",c=z==="upload"&&q?q:$??P8[H??"claude-code"];return e0.jsxs("div",{className:"flex gap-6",children:[e0.jsxs("div",{className:"flex w-24 shrink-0 flex-col items-center gap-2.5",children:[e0.jsx("div",{className:s("flex size-24 items-center justify-center overflow-hidden rounded-xl",v!=="image"&&!I&&"bg-[repeating-conic-gradient(#0000000d_0%_25%,transparent_0%_50%)] bg-size-[16px_16px]"),style:v!=="image"&&F.gradient?{background:MY(F.gradient)}:void 0,children:v==="emoji"?e0.jsx("span",{className:s("leading-none",PY,I?"text-[64px]":"text-[86px]"),children:W}):v==="glyph"&&E?e0.jsx(E.Icon,{stroke:1.5,className:s(I?"size-14 text-white":"size-18 text-foreground")}):e0.jsx("img",{src:c,alt:"",className:"size-full object-cover"})}),e0.jsx("button",{type:"button",onClick:b,disabled:j,className:"text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",children:"Reset to default"})]}),e0.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[e0.jsx("div",{className:"flex gap-1 self-start rounded-xl bg-muted p-0.5",children:["emoji","icon","upload"].map((T)=>e0.jsx("button",{type:"button",onClick:()=>G(T),className:s("rounded-lg px-3.5 py-1 text-xs font-medium capitalize transition-colors",z===T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:T},T))}),e0.jsxs("div",{className:s("flex items-center gap-2",z==="upload"&&"pointer-events-none opacity-35"),children:[e0.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Background"}),e0.jsxs("div",{className:"flex items-center gap-2",children:[e0.jsx("button",{type:"button","aria-label":"No background",onClick:()=>U({id:"none",gradient:null}),className:s("flex size-7 items-center justify-center rounded-full bg-muted ring-offset-2 ring-offset-card transition-shadow",F.id==="none"?"ring-2 ring-primary":"ring-1 ring-border hover:ring-muted-foreground/30"),children:e0.jsx(up,{size:16,stroke:1.75,className:"text-muted-foreground"})}),mD.map((T)=>e0.jsx("button",{type:"button","aria-label":`${T.id} background`,onClick:()=>U({id:T.id,gradient:T.gradient}),style:{background:MY(T.gradient)},className:s("size-7 rounded-full ring-offset-2 ring-offset-card transition-shadow",F.id===T.id?"ring-2 ring-primary":"hover:ring-2 hover:ring-muted-foreground/30")},T.id)),e0.jsx("button",{type:"button","aria-label":"Random background",title:"Surprise me",onClick:S,style:Y?{background:MY(Y)}:void 0,className:s("flex size-7 items-center justify-center rounded-full ring-offset-2 ring-offset-card transition-shadow",Y?"text-white":"bg-muted text-muted-foreground ring-1 ring-border",F.id==="shuffle"?"ring-2 ring-primary":"hover:ring-2 hover:ring-muted-foreground/30"),children:e0.jsx(pp,{size:16,stroke:1.75})})]})]}),z==="emoji"?e0.jsxs(n9.Root,{onEmojiSelect:(T)=>N(T.emoji),emojibaseUrl:"/vendor/emojibase",columns:13,className:"isolate flex h-72 flex-col overflow-hidden rounded-xl border border-border bg-background",children:[e0.jsxs("div",{className:"flex items-center gap-1.5 p-1.5 pb-0",children:[e0.jsx(n9.Search,{placeholder:"Search emoji…",onChange:(T)=>V(T.target.value),className:"h-8 min-w-0 flex-1 appearance-none rounded-lg bg-muted px-2.5 text-sm outline-none placeholder:text-muted-foreground"}),e0.jsx(n9.SkinToneSelector,{className:"size-8 shrink-0 rounded-lg text-lg hover:bg-accent"})]}),e0.jsxs(n9.Viewport,{className:"relative scrollbar-thin flex-1 overflow-y-auto outline-none",children:[e0.jsxs(n9.Loading,{className:"absolute inset-0 flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[e0.jsx(I5,{size:16,stroke:1.75,className:"animate-spin"}),"Loading emoji…"]}),L.trim()===""&&e0.jsxs("div",{className:"border-b border-dashed border-border pb-1.5",children:[e0.jsx("p",{className:"px-2.5 pt-2.5 pb-1 text-xs font-medium text-muted-foreground",children:"Favorites"}),e0.jsx("div",{className:"grid grid-cols-13 justify-items-start px-1.5",children:mp.map((T)=>e0.jsx("button",{type:"button",onClick:()=>N(T),className:s("flex size-9 items-center justify-center rounded-xl text-[22px] transition-colors duration-75",PY,W===T?"bg-primary/10":"hover:bg-accent"),children:T},T))})]}),e0.jsxs(n9.Empty,{className:"absolute inset-0 flex flex-col items-center justify-center gap-1 text-xs text-muted-foreground",children:[e0.jsx(cp,{size:20,stroke:1.5}),"No emoji found"]}),e0.jsx(n9.List,{className:"pb-1.5 select-none",components:{CategoryHeader:nB0,Row:oB0,Emoji:sB0}})]})]}):z==="icon"?e0.jsx("div",{className:"grid scrollbar-thin h-72 grid-cols-[repeat(auto-fill,minmax(2.25rem,1fr))] content-start gap-1 overflow-y-auto rounded-xl border border-border bg-background p-1.5",children:gD.map(({id:T,Icon:e})=>e0.jsx("button",{type:"button","aria-label":T,onClick:()=>D(T),className:s("flex aspect-square items-center justify-center rounded-xl text-muted-foreground transition-colors [&_svg]:size-5",A===T?"bg-primary/10 text-primary":"hover:bg-accent hover:text-accent-foreground"),children:e0.jsx(e,{stroke:1.5})},T))}):e0.jsxs("button",{type:"button",onClick:()=>y.current?.click(),onDragOver:(T)=>{T.preventDefault(),P(!0)},onDragLeave:()=>P(!1),onDrop:(T)=>{T.preventDefault(),P(!1);let e=T.dataTransfer.files?.[0];if(e)k(e)},className:s("flex h-72 flex-col items-center justify-center gap-2 rounded-xl border border-dashed transition-colors",M?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[e0.jsx(dp,{size:24,stroke:1.5}),e0.jsx("span",{className:"text-xs font-medium",children:"Click or drop an image"}),e0.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"PNG, JPG, GIF, or WebP"})]}),e0.jsx("div",{className:"min-h-4","aria-live":"polite",children:C?e0.jsx("p",{className:"text-xs text-destructive",children:C}):j?e0.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving…"}):null})]}),e0.jsx("input",{ref:y,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:(T)=>{let e=T.target.files?.[0];if(e)k(e);T.target.value=""}}),e0.jsx("span",{ref:w,"aria-hidden":!0,className:"hidden",children:E&&e0.jsx(E.Icon,{stroke:1.5})})]})}var M2=O(d(),1);function rp(){let{cloudDemo:$}=J9(),{name:Z,icon:H,cwd:B,workspaceId:J}=K5(),[,Q]=u4(),X=vf(J),z=FO(),[G,F]=ip.useState(Z??"");return M2.jsxs(iZ,{title:"General",description:"Basic details for this space.",children:[M2.jsxs(rZ,{children:[M2.jsx(aZ,{title:"Name",description:"Shown in the sidebar and the workspace header.",control:M2.jsx(L3,{value:G,onChange:(K)=>F(K.target.value),onBlur:()=>{let K=G.trim();if(K===(Z??""))return;X.mutate(K===""?null:K)},onKeyDown:(K)=>{if(K.key==="Enter")K.currentTarget.blur()},placeholder:"Space name",className:"w-56"})}),M2.jsx(aZ,{title:"Path",control:M2.jsx(L3,{value:B??"",readOnly:!0,"aria-label":"Workspace path",title:B??void 0,className:"w-56"})}),M2.jsxs("div",{className:"flex flex-col gap-4 px-3.5 py-3.5",children:[M2.jsxs("div",{className:"flex flex-col",children:[M2.jsx("span",{className:"text-sm font-medium",children:"Icon"}),M2.jsx("span",{className:"text-xs text-muted-foreground",children:"Pick an emoji or a glyph on a generated background, or upload an image."})]}),M2.jsx(lp,{icon:H})]})]}),!$&&M2.jsxs(rZ,{label:"Danger zone",children:[M2.jsx(aZ,{title:"Remove space",description:"Remove this space from moi. Its folder and sessions stay on disk.",control:M2.jsxs(T0,{type:"button",variant:"destructive",size:"sm",onClick:()=>{let W=`Remove "${Z??B??"this space"}" from your workspaces?
|
|
81
81
|
|