rivet-design 0.17.1 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/library/projects.d.ts.map +1 -1
- package/dist/routes/library/projects.js +24 -0
- package/dist/routes/library/projects.js.map +1 -1
- package/dist/services/ProjectLibrary.d.ts +1 -0
- package/dist/services/ProjectLibrary.d.ts.map +1 -1
- package/dist/services/ProjectLibrary.js +21 -8
- package/dist/services/ProjectLibrary.js.map +1 -1
- package/dist/services/ProjectRegistry.d.ts +22 -2
- package/dist/services/ProjectRegistry.d.ts.map +1 -1
- package/dist/services/ProjectRegistry.js +31 -3
- package/dist/services/ProjectRegistry.js.map +1 -1
- package/dist/services/TelemetryService.d.ts +1 -1
- package/dist/services/TelemetryService.d.ts.map +1 -1
- package/dist/services/TelemetryService.js.map +1 -1
- package/dist/storage/library/ProjectRecords.d.ts +17 -0
- package/dist/storage/library/ProjectRecords.d.ts.map +1 -1
- package/dist/storage/library/ProjectRecords.js +42 -0
- package/dist/storage/library/ProjectRecords.js.map +1 -1
- package/dist/storage/library/database.d.ts +2 -1
- package/dist/storage/library/database.d.ts.map +1 -1
- package/dist/storage/library/database.js +14 -6
- package/dist/storage/library/database.js.map +1 -1
- package/dist/storage/library/migrations.d.ts +3 -1
- package/dist/storage/library/migrations.d.ts.map +1 -1
- package/dist/storage/library/migrations.js +9 -2
- package/dist/storage/library/migrations.js.map +1 -1
- package/dist/storage/library/schema/registry.d.ts +32 -0
- package/dist/storage/library/schema/registry.d.ts.map +1 -1
- package/dist/storage/library/schema/registry.js +2 -0
- package/dist/storage/library/schema/registry.js.map +1 -1
- package/dist/types/project-library.d.ts +5 -0
- package/dist/types/project-library.d.ts.map +1 -1
- package/dist/types/project-library.js +2 -0
- package/dist/types/project-library.js.map +1 -1
- package/package.json +1 -1
- package/src/ui/dist/assets/LibraryApp-DXPBLgDE.js +21 -0
- package/src/ui/dist/assets/main-BUZjlAHd.css +1 -0
- package/src/ui/dist/assets/{main-BluMFKVI.js → main-CQ8l2PxN.js} +2 -2
- package/src/ui/dist/index.html +2 -2
- package/src/ui/dist/assets/LibraryApp-Bkawuvcq.js +0 -16
- package/src/ui/dist/assets/main-DY9LzvZT.css +0 -1
|
@@ -141,7 +141,7 @@ ${s}`:s},pX=({groups:t,pinned:e,pinnedKeys:n,draggedRowKey:r,onDropPin:s,onDropU
|
|
|
141
141
|
<body>
|
|
142
142
|
<div class="panel">${qk}</div>
|
|
143
143
|
</body>
|
|
144
|
-
</html>`,cM=(t="editor_gate")=>{const e=Zl(),[n,r]=g.useState(!1),[s,i]=g.useState(null);return{startLogin:g.useCallback(async()=>{var p;const l=globalThis.crypto.randomUUID(),u=Date.now();r(!0),i(null);const d=fy({outcome:"started",authAttemptId:l,entryPoint:t,startedAt:u,now:u});e==null||e.capture(d.event,d.properties);let f=null;try{if(f=window.open("","_blank"),!f)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{f.document.open(),f.document.write(NX),f.document.close()}catch(w){Zk.warn("Failed to render loading state in auth popup:",w)}const m=await fetch(`${Gk}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"core"})}),v=await m.json();if(!m.ok||!v.success||!v.authUrl||!v.sessionId||!v.pollSecret)throw new Error(v.error||v.message||"Failed to start Google login");if(f.closed)throw new Error("Sign-in window was closed before Google login started.");f.location.href=v.authUrl;for(let w=0;w<DX;w+=1){if(f.closed)throw new Error("Sign-in window was closed before authentication completed.");const x=await(await fetch(`${Gk}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:v.sessionId,pollSecret:v.pollSecret})})).json();if(x.success&&x.token&&((p=x.user)!=null&&p.email)){if(!(await Wl("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:x.user.email,token:x.token,refreshToken:x.refreshToken,userId:x.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");f.close(),window.sessionStorage.setItem(wm,"1");const k=fy({outcome:"completed",authAttemptId:l,entryPoint:t,startedAt:u,now:Date.now()});e==null||e.capture(k.event,k.properties),window.location.reload();return}if(x.error&&x.error!=="Pending")throw new Error(x.error||"Google login failed");await new Promise(b=>setTimeout(b,LX))}throw new Error("Authentication timed out. Please try again.")}catch(m){f&&!f.closed&&f.close();const v=m instanceof Error?m.message:"Failed to start login flow";Zk.warn("Login failed:",v);const w=fy({outcome:"failed",authAttemptId:l,entryPoint:t,startedAt:u,now:Date.now(),failureReason:OX(v)});e==null||e.capture(w.event,w.properties),i(v),r(!1)}},[e,t]),isStartingLogin:n,loginError:s}},Kk="/assets/arena-Db0j1set.png",$X=ps("useIntegrations"),hy=["integrations"],jX="rivet:connect-result",FX=t=>typeof t=="object"&&t!==null&&t.type===jX,VX=ot(null),Yk=async()=>{const t=await Wl("/api/integrations");if(!t.ok)throw new Error(`Failed to load integrations (${t.status})`);return(await t.json()).integrations??[]},HX=()=>{const t=JC(),[e,n]=D5(VX),r=M0({queryKey:hy,queryFn:Yk,staleTime:1e4}),s=g.useCallback(async()=>(await t.invalidateQueries({queryKey:hy,refetchType:"none"}),t.fetchQuery({queryKey:hy,queryFn:Yk})),[t]),i=g.useCallback(async l=>{const u=window.open("","_blank","width=560,height=720");if(!u)throw new Error("Popup blocked. Allow popups to connect.");n(l);try{const d=await Wl(`/api/integrations/${l}/connect`,{method:"POST"}),f=await d.json().catch(()=>({}));if(!d.ok||!f.authUrl)throw u.close(),new Error(f.error||`Could not connect ${l}`);return u.location.href=f.authUrl,await new Promise(p=>{let m=!1,v=null;const w=async(x,b=!1)=>{if(!m){m=!0,window.removeEventListener("message",_),v&&clearInterval(v);try{const C=(await s()).some(T=>T.provider===l&&T.status==="connected");p(b&&C?"connected":x)}catch{p(x)}}},_=x=>{if(FX(x.data)&&x.data.provider===l){if(x.data.status==="error"){$X.warn(`Connect failed for ${l}:`,x.data.message),w("failed");return}w("connected")}};window.addEventListener("message",_),v=setInterval(()=>{u.closed&&w("closed",!0)},500)})}finally{n(null)}},[s,n]),o=g.useCallback(async l=>{n(l);try{const u=await Wl(`/api/integrations/${l}`,{method:"DELETE"});if(!u.ok){const d=await u.json().catch(()=>({}));throw new Error(d.error||`Could not disconnect ${l}`)}await s()}finally{n(null)}},[s,n]);return{integrations:r.data??[],isLoading:r.isPending,error:r.error instanceof Error?r.error.message:null,pendingProvider:e,connect:i,disconnect:o,refetch:s}},ll=({action:t,outcome:e,provider:n,entryPoint:r,durationMs:s,failureReason:i})=>({event:`visual_editor_reference_${t==="connect"?"connection":"disconnection"}_${e}`,properties:{provider:n,entry_point:r,...s!==void 0?{duration_ms:s}:{},...i?{failure_reason:i}:{}}}),Xk=ps("ConnectorsModal"),zX=()=>S.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6","aria-hidden":"true",children:S.jsx("path",{fill:"currentColor",d:"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.781c0-1.669.967-2.915 2.171-2.915 1.024 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.132 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.137.893 2.739.098.119.112.223.083.344-.091.379-.293 1.194-.333 1.361-.052.22-.174.266-.401.16-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.36-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146A12.004 12.004 0 0 0 12 24c6.627 0 12-5.373 12-12C24 5.372 18.627 0 12 0z"})}),BX=()=>S.jsx("span",{"aria-hidden":"true",className:"h-6 w-6 bg-[#b1b1b1]",style:{WebkitMaskImage:`url(${Kk})`,maskImage:`url(${Kk})`,WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"}}),UX=[{provider:"pinterest",name:"Pinterest",description:"Pull boards and pins in as visual references.",tileClassName:"bg-[#e60023] text-white",icon:S.jsx(zX,{})},{provider:"arena",name:"Are.na",description:"Connect channels of collected blocks and links.",tileClassName:"bg-[#18181b] text-content",icon:S.jsx(BX,{})}],WX=({meta:t,integration:e,isPending:n,isHighlighted:r,onConnect:s,onDisconnect:i})=>{const o=(e==null?void 0:e.status)==="connected",l=e!=null&&e.externalUsername?`@${e.externalUsername}`:null;return S.jsxs("article",{className:`bg-main-light flex flex-col rounded-xl p-[18px] ${r?"ring-secondary ring-2":""}`,children:[S.jsx("span",{className:`grid h-[52px] w-[52px] flex-none place-items-center rounded-xl ${t.tileClassName}`,"aria-hidden":"true",children:t.icon}),S.jsxs("div",{className:"mt-4 flex-1",children:[S.jsxs("h2",{className:"text-content flex items-center gap-1.5 text-[15px] font-semibold",children:[t.name,o?S.jsx(fR,{className:"h-3.5 w-3.5",weight:"bold","aria-hidden":"true"}):null]}),S.jsx("p",{className:"text-content-subtle mt-1 text-[13px] leading-relaxed",children:t.description}),o&&l?S.jsx("p",{className:"text-content-muted mt-2.5 text-xs font-medium",children:l}):null]}),o?S.jsx("button",{type:"button",onClick:i,disabled:n,className:"active-push bg-main-input text-content-muted mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors hover:bg-red-500/10 hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-50",children:n?"Disconnecting…":"Disconnect"}):S.jsx("button",{type:"button",onClick:s,disabled:n,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:n?"Connecting…":"Connect"})]})},S2=({isOpen:t,onClose:e,context:n="menu",highlightProvider:r=null})=>{const{integrations:s,isLoading:i,error:o,pendingProvider:l,connect:u,disconnect:d}=HX(),f=Zl(),[p,m]=g.useState(null),v=b=>s.find(k=>k.provider===b),w=g.useCallback(b=>{const k=Date.now(),C=ll({action:"connect",outcome:"started",provider:b,entryPoint:n});f==null||f.capture(C.event,C.properties),u(b).then(T=>{const A=Date.now()-k;if(T==="connected"){const R=ll({action:"connect",outcome:"completed",provider:b,entryPoint:n,durationMs:A});f==null||f.capture(R.event,R.properties);return}const M=ll({action:"connect",outcome:"failed",provider:b,entryPoint:n,durationMs:A,failureReason:T==="closed"?"popup_closed":"provider_failed"});f==null||f.capture(M.event,M.properties)}).catch(T=>{const A=T instanceof Error?T.message:"Could not connect.",M=ll({action:"connect",outcome:"failed",provider:b,entryPoint:n,durationMs:Date.now()-k,failureReason:A.includes("Popup blocked")?"popup_blocked":"request_failed"});f==null||f.capture(M.event,M.properties),Xk.warn(`Connect error for ${b}:`,A),xt.error(A)})},[u,n,f]),_=g.useCallback(b=>{const k=Date.now(),C=ll({action:"disconnect",outcome:"started",provider:b,entryPoint:n});f==null||f.capture(C.event,C.properties),d(b).then(()=>{const T=ll({action:"disconnect",outcome:"completed",provider:b,entryPoint:n,durationMs:Date.now()-k});f==null||f.capture(T.event,T.properties)}).catch(T=>{const A=T instanceof Error?T.message:"Could not disconnect.",M=ll({action:"disconnect",outcome:"failed",provider:b,entryPoint:n,durationMs:Date.now()-k,failureReason:"request_failed"});f==null||f.capture(M.event,M.properties),Xk.warn(`Disconnect error for ${b}:`,A),xt.error(A)})},[n,d,f]),x=n==="onboarding";return S.jsx(_x,{open:t,onOpenChange:b=>!b&&e(),children:S.jsxs(wx,{children:[S.jsx(xx,{className:"z-max fixed inset-0 bg-black/40"}),S.jsx(bx,{ref:m,className:"z-max border-main-border bg-main font-main fixed top-1/2 left-1/2 w-[560px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-2xl outline-none",children:S.jsxs(DI,{value:p,children:[S.jsxs("div",{className:"border-main-border bg-main-light flex items-center justify-between rounded-t-lg border-b px-4 py-2",children:[S.jsx(Sx,{className:"text-content text-base font-medium",children:"Connect design references"}),S.jsx(mo,{onClick:e,title:"Close","aria-label":"Close",variant:"ghost",size:"icon-compact",children:S.jsx(OR,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[S.jsx(Ex,{className:"text-content-subtle text-sm",children:"Connect your design references to use them with Rivet’s MCP."}),o?S.jsx("p",{className:"rounded-lg bg-red-500/10 px-4 py-3 text-[13px] font-medium text-red-300",children:o}):null,S.jsx("div",{className:"grid grid-cols-2 gap-4",children:UX.map(b=>S.jsx(WX,{meta:b,integration:v(b.provider),isPending:i||l===b.provider,isHighlighted:r===b.provider,onConnect:()=>w(b.provider),onDisconnect:()=>_(b.provider)},b.provider))}),x?S.jsxs("div",{className:"flex items-center justify-between gap-4",children:[S.jsx("p",{className:"text-content-subtle text-xs",children:"You can always do this later from the account menu."}),S.jsx("button",{type:"button",onClick:e,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent flex-none rounded-lg px-3.5 py-2 text-[13px] font-medium transition-colors",children:"Skip for now"})]}):null]})]})})]})})},Qk=({className:t=""})=>S.jsx("span",{"aria-hidden":"true",className:`rivet-skeleton block rounded ${t}`.trim()}),ZX=ps("SupportTicketModal"),Jk=5e3,py="feedback",qX=t=>{var r;if(!t)return null;const e=(r=t.formErrors)==null?void 0:r[0];if(e)return e;const n=t.fieldErrors??{};for(const s of Object.values(n)){const i=s==null?void 0:s[0];if(i)return i}return null},GX=async t=>{let e;try{e=await t.json()}catch{e=void 0}if(t.status===400){if(typeof(e==null?void 0:e.details)=="string"&&e.details.trim())return e.details;if(typeof(e==null?void 0:e.details)=="object"&&e.details!==null){const n=qX(e.details);if(n)return n}return"Please check your feedback and try again."}return t.status>=500?typeof(e==null?void 0:e.details)=="string"&&e.details.trim()?e.details:"Could not send feedback right now. Please try again later.":typeof(e==null?void 0:e.error)=="string"&&e.error.trim()?e.error:`HTTP ${t.status}`},KX=({isOpen:t,onClose:e,contactEmail:n})=>{const r=Zl(),[s,i]=g.useState(""),[o,l]=g.useState(!1),[u,d]=g.useState(null),f=g.useCallback(()=>{i("")},[]),p=g.useCallback(()=>{o||(f(),e())},[o,e,f]),m=g.useCallback(async()=>{const x=s.trim();if(!(!x||o)){l(!0);try{const b=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,k=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,C=n==null?void 0:n.trim(),T=await Wl("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:py,message:x,contactEmail:C||void 0,metadata:{posthogSessionId:b??void 0,posthogDistinctId:k??void 0,appVersion:"0.17.1",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!T.ok){const A=await GX(T);throw new Error(A)}r==null||r.capture("support_ticket_submitted",{ticket_type:py,has_posthog_session_id:!!b}),xt.success("Feedback sent",{description:"Thanks for sharing this."}),f(),e()}catch(b){const k=b instanceof Error?b.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:py,error:k}),ZX.error("Failed to submit support ticket:",k),xt.error("Could not send feedback",{description:k})}finally{l(!1)}}},[n,o,s,e,r,f]),v=g.useCallback(x=>{x.key==="Enter"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),m())},[m]),w=Jk-s.length,_=o||s.trim().length===0;return S.jsx(_x,{open:t,onOpenChange:x=>!x&&p(),children:S.jsxs(wx,{children:[S.jsx(xx,{className:"z-max fixed inset-0 bg-black/40"}),S.jsx(bx,{ref:d,className:"z-max border-main-border bg-main font-main fixed top-1/2 left-1/2 w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-2xl outline-none",children:S.jsxs(DI,{value:u,children:[S.jsxs("div",{className:"border-main-border bg-main-light flex items-center justify-between rounded-t-lg border-b px-4 py-2",children:[S.jsx(Sx,{className:"text-content text-base font-medium",children:"Send feedback"}),S.jsx(mo,{onClick:p,disabled:o,title:"Close","aria-label":"Close",variant:"ghost",size:"icon-compact",children:S.jsx(OR,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[S.jsx(Ex,{className:"text-content-subtle text-sm",children:"Tell us what happened or what we can improve."}),S.jsxs("div",{className:"bg-main-input rounded-lg outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[S.jsx("textarea",{id:"support-ticket-message","aria-label":"Your feedback",value:s,onChange:x=>i(x.target.value),onKeyDown:v,maxLength:Jk,rows:6,disabled:o,placeholder:"What happened?",className:"text-content placeholder-content-subtle max-h-64 w-full resize-none overflow-y-auto bg-transparent pt-3 pr-3 pb-1 pl-3 text-sm focus:outline-none disabled:opacity-50"}),S.jsxs("div",{className:"flex items-center justify-between px-3 pt-1 pb-3",children:[S.jsx("span",{className:"text-content-subtle text-xs",children:"Context details are included automatically."}),S.jsxs("div",{className:"flex items-center gap-2",children:[w<=500&&S.jsx("span",{className:"text-content-subtle text-xs",children:w}),S.jsx(mo,{onClick:m,disabled:_,title:"Send feedback",shortcut:"⌘↵","aria-label":"Send feedback",size:"icon-compact",children:o?S.jsx(Xm,{className:"h-5 w-5 animate-spin",weight:"bold"}):S.jsx(eY,{className:"h-5 w-5",weight:"bold"})})]})]})]})]})]})})]})})},YX=ps("ProfileAvatar"),uM=(t,e)=>{const n=(t??"").trim();if(n)return n.split(/\s+/).filter(Boolean)[0]??"";const s=((e??"").split("@")[0]??"").split(/[._\-+]/).filter(Boolean)[0]??"";return s?s[0].toUpperCase()+s.slice(1):""},XX=(t,e)=>uM(t,e).charAt(0).toUpperCase(),QX=({className:t="",side:e="bottom",align:n="end"})=>{var Q,q,G;const r=MX(),s=((Q=r.data)==null?void 0:Q.name)??null,i=((q=r.data)==null?void 0:q.email)??null,o=((G=r.data)==null?void 0:G.isAuthenticated)===!0,l=Zl(),{startLogin:u,isStartingLogin:d,loginError:f}=cM("account_menu"),[p,m]=g.useState(!1),[v,w]=g.useState(!1),[_,x]=g.useState(!1),[b,k]=g.useState(!1),{containerRef:C,onKeyDown:T,onCloseAutoFocus:A}=DR({onDismiss:()=>V(!1)}),M=XX(s,i);if(r.isPending)return S.jsxs("span",{"data-testid":"profile-avatar-skeleton","aria-hidden":"true",className:`flex shrink-0 items-center gap-2 ${t}`.trim(),children:[S.jsx(Qk,{className:"h-8 w-8 rounded-full"}),S.jsx(Qk,{className:"h-3.5 w-16"})]});const R=uM(s,i),I=(s==null?void 0:s.trim())||null,L=(i==null?void 0:i.trim())||null,N=async()=>{k(!0);try{const W=await Wl("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!W.ok)throw new Error(`Logout failed: ${W.status}`)}catch(W){YX.warn("Logout request failed",W),xt.error("Could not log out. Please try again."),k(!1);return}window.location.reload()};let j="Log in";o&&(j=R||"Account"),r.error&&!r.data&&(j="Account unavailable");const V=W=>{m(W),l==null||l.capture(`visual_editor_account_menu_${W?"opened":"closed"}`,{is_authenticated:o})};return S.jsxs(S.Fragment,{children:[S.jsxs(Ax,{open:p,onOpenChange:V,children:[S.jsx(Ix,{asChild:!0,children:S.jsxs("button",{type:"button","aria-label":"Account","data-rivet-private":!0,className:`ph-no-capture text-content-muted hover:text-content flex shrink-0 items-center gap-2 transition-colors select-none ${t}`,children:[S.jsx("span",{className:"border-main-border bg-main-input flex h-8 w-8 items-center justify-center rounded-full border text-xs leading-none font-semibold",children:M||S.jsx(fY,{className:"h-4 w-4",weight:"bold"})}),S.jsx("span",{className:"max-w-[8rem] truncate text-sm font-medium",children:j})]})}),S.jsx(Rx,{children:S.jsxs(Mx,{"data-rivet-private":!0,ref:C,onKeyDown:T,onCloseAutoFocus:A,role:"menu",className:"ph-no-capture bg-popover shadow-surface-4 z-[60] min-w-[180px] rounded-lg p-1",side:e,sideOffset:6,align:n,children:[I||L?S.jsxs("div",{className:"border-main-border border-b px-3 py-2",children:[I?S.jsx("div",{className:"text-content truncate text-sm font-medium",children:I}):null,L?S.jsx("div",{className:"text-content-muted truncate text-xs",children:L}):null]}):null,S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{V(!1),w(!0)},disabled:!o,className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(TR,{className:"h-4 w-4",weight:"bold"}),"Connect design references"]}),S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{V(!1),x(!0)},className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm transition-colors focus:outline-none",children:[S.jsx(rY,{className:"h-4 w-4",weight:"bold"}),"Share feedback"]}),o?S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:N,disabled:b,className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(uY,{className:"h-4 w-4",weight:"bold"}),b?"Logging out…":"Log out"]}):null,!o&&!r.error?S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{u()},disabled:d,className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm focus:outline-none disabled:opacity-50",children:[S.jsx(cY,{className:"h-4 w-4",weight:"bold"}),d?"Logging in…":"Log in"]}):null,r.error?S.jsx("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{r.refetch()},className:"text-content mt-1 px-3 py-1.5 text-sm",children:"Retry account"}):null,f?S.jsx("p",{role:"alert",className:"max-w-64 px-3 py-2 text-sm text-red-300",children:f}):null]})})]}),v?S.jsx(S2,{isOpen:!0,onClose:()=>w(!1)}):null,S.jsx(KX,{isOpen:_,onClose:()=>x(!1),contactEmail:i??void 0})]})},JX=({onClose:t})=>S.jsxs("div",{className:"bg-main font-main scrollbar-hide relative flex h-full w-full cursor-auto flex-col overflow-hidden shadow-2xl","data-cy":"element-inspector",children:[S.jsx(IX,{onClose:t}),S.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:S.jsx(lX,{})}),S.jsx("div",{className:"border-main-border bg-main-light flex flex-shrink-0 items-center border-t px-2.5 py-2.5",children:S.jsx(QX,{side:"top",align:"start"})})]});async function eQ(t,e){const{delaysMs:n,shouldRetry:r,onRetry:s}=e;for(let i=1;;i++)try{return await t(i)}catch(o){const l=n[i-1];if(l===void 0||r&&!r(o))throw o;s==null||s(o,i,l),await new Promise(u=>setTimeout(u,l))}}const eC=ps("useServerConfig"),dM=[250,500,1e3,2e3,4e3],tC=dM.length+1,tQ=async()=>{var n;const t=await fetch("/api/health");if(!t.ok)throw new Error(`Failed to fetch config: ${t.status}`);const e=await t.json();if(!e.framework)throw new Error("Server did not return framework information");return{userPort:((n=e.ports)==null?void 0:n.userDevServer)||3e3,framework:e.framework}},nQ=()=>{const[t,e]=g.useState(null),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{r(!0),i(null);const l=await eQ(tQ,{delaysMs:dM,onRetry:(u,d,f)=>{eC.warn(`Server config fetch failed (attempt ${d}); retrying in ${f}ms`,u)}});return e(l),l}catch(l){const u=l instanceof Error?l.message:"Failed to fetch server config";throw i(u),eC.warn("Error fetching server config:",l),l}finally{r(!1)}},[]);return{config:t,fetchConfig:o,isLoading:n,error:s}},rQ="#1C1C20",Ki=[118,118,124],nC=.85,sQ=3,iQ=.15,Yp=36,oQ=4.4,aQ=.7,lQ=3.5,cQ=.8,rC=9,uQ=11,dQ=[1.35,1.12,.95,.85],fQ=[0,1.1,2.3,3.1],hQ=[0,.35,.16,.13],pQ=[.9,.5,.4,.35],cl=3,my=[[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.23,level:1},{x1:.14,y1:.28,x2:.3,y2:.87,level:1},{x1:.34,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.155,x2:.225,y2:.205,level:2},{x1:.7,y1:.155,x2:.755,y2:.205,level:2},{x1:.775,y1:.155,x2:.83,y2:.205,level:2},{x1:.165,y1:.32,x2:.275,y2:.375,level:2},{x1:.165,y1:.415,x2:.275,y2:.47,level:2},{x1:.165,y1:.51,x2:.275,y2:.565,level:2},{x1:.37,y1:.32,x2:.585,y2:.56,level:2},{x1:.615,y1:.32,x2:.83,y2:.56,level:2},{x1:.37,y1:.61,x2:.83,y2:.83,level:2},{hline:!0,x1:.39,x2:.81,y:.685,level:3},{hline:!0,x1:.39,x2:.75,y:.755,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.16,y1:.17,x2:.52,y2:.45,level:1},{x1:.58,y1:.17,x2:.685,y2:.29,level:1},{x1:.715,y1:.17,x2:.84,y2:.29,level:1},{x1:.58,y1:.33,x2:.685,y2:.45,level:1},{x1:.715,y1:.33,x2:.84,y2:.45,level:1},{x1:.16,y1:.55,x2:.84,y2:.85,level:1},{x1:.19,y1:.21,x2:.36,y2:.33,level:2},{hline:!0,x1:.19,x2:.48,y:.37,level:3},{hline:!0,x1:.19,x2:.42,y:.42,level:3},{x1:.19,y1:.6,x2:.49,y2:.8,level:2},{hline:!0,x1:.53,x2:.8,y:.63,level:3},{hline:!0,x1:.53,x2:.76,y:.7,level:3},{hline:!0,x1:.53,x2:.79,y:.77,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.22,level:1},{x1:.14,y1:.28,x2:.36,y2:.87,level:1},{x1:.39,y1:.28,x2:.61,y2:.87,level:1},{x1:.64,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.15,x2:.225,y2:.2,level:2},{x1:.165,y1:.32,x2:.335,y2:.52,level:2},{x1:.415,y1:.32,x2:.585,y2:.52,level:2},{x1:.665,y1:.32,x2:.835,y2:.52,level:2},{hline:!0,x1:.165,x2:.335,y:.6,level:3},{hline:!0,x1:.165,x2:.3,y:.67,level:3},{hline:!0,x1:.415,x2:.585,y:.6,level:3},{hline:!0,x1:.415,x2:.55,y:.67,level:3},{hline:!0,x1:.665,x2:.835,y:.6,level:3},{hline:!0,x1:.665,x2:.8,y:.67,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.3,y1:.22,x2:.7,y2:.74,level:1},{x1:.34,y1:.27,x2:.55,y2:.34,level:2},{hline:!0,x1:.36,x2:.64,y:.42,level:3},{hline:!0,x1:.36,x2:.6,y:.49,level:3},{hline:!0,x1:.36,x2:.62,y:.56,level:3},{x1:.5,y1:.63,x2:.575,y2:.69,level:2},{x1:.595,y1:.63,x2:.66,y2:.69,level:2}]],Xp=t=>{let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),e^=e>>>16,(e>>>0)/4294967296},S0=t=>{const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)},ul=(t,e)=>(Math.round(t/e-.5)+.5)*e,mQ=Math.sin(Math.PI/3),sC=(t,e,n,r,s)=>{if(t.beginPath(),e===0)t.arc(n,r,s,0,Math.PI*2);else if(e===1){const i=s*mQ;t.moveTo(n,r-s),t.lineTo(n+i,r+s/2),t.lineTo(n-i,r+s/2),t.closePath()}else{const i=s*.85;t.rect(n-i,r-i,i*2,i*2)}t.fill()},gQ=(t,e,n)=>{let r;if(n.hline){const s=Math.max(n.x1-t,t-n.x2,0),i=Math.abs(e-n.y1);r=Math.hypot(s,i)-rC}else{const s=Math.max(n.x1-t,t-n.x2,0),i=Math.max(n.y1-e,e-n.y2,0);s===0&&i===0?r=-Math.min(t-n.x1,n.x2-t,e-n.y1,n.y2-e):r=Math.hypot(s,i),r=Math.abs(r)-rC}return S0(.5-r/(2*uQ))},fM=({className:t="",trackGlobalLoaderCount:e=!0})=>{const n=dt(BR),r=g.useRef(null),s=g.useCallback(i=>{var N;if((N=r.current)==null||N.call(r),r.current=null,!i)return;const o=i.getContext("2d");if(!o)return;e&&n(j=>j+1);const l=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let u=[],d=0,f=0,p=Yp,m=Yp,v=null,w=null,_=0,x=-1;const b=new Array(33),k=j=>{const V=Math.round(j*32);let Q=b[V];if(!Q){const q=V/32,G=Math.round(Ki[0]+(255-Ki[0])*q),W=Math.round(Ki[1]+(255-Ki[1])*q),Y=Math.round(Ki[2]+(255-Ki[2])*q);Q=`rgba(${G}, ${W}, ${Y}, ${nC})`,b[V]=Q}return Q},C=j=>{const V=1-.35*j,Q=Math.round(Ki[0]*V),q=Math.round(Ki[1]*V),G=Math.round(Ki[2]*V);return`rgba(${Q}, ${q}, ${G}, ${nC})`},T=j=>{let V=Math.floor(Math.random()*my.length);V===x&&(V=(V+1)%my.length),x=V;const Q=[0,0,0,0],q=my[V].map((D,X)=>{const ce=D.level,se=Q[ce]++,re=fQ[ce]+se*hQ[ce],de=pQ[ce]+Xp(V*131+X*17+5)*.2;if(D.hline){const oe=ul((D.y??0)*f,m);return{hline:!0,x1:ul(D.x1*d,p),x2:ul(D.x2*d,p),y1:oe,y2:oe,level:ce,start:re,dur:de}}const _e=ul(D.x1*d,p),fe=ul((D.y1??0)*f,m);return{hline:!1,x1:_e,y1:fe,x2:Math.max(ul(D.x2*d,p),_e+p),y2:Math.max(ul((D.y2??0)*f,m),fe+m),level:ce,start:re,dur:de}}),G=q.reduce((D,X)=>Math.max(D,X.start+X.dur),0),W=u.length,Y=new Float32Array(W*cl),z=new Int16Array(W*cl).fill(-1),ee=new Uint8Array(W),B=q[0];for(let D=0;D<W;D++){const X=u[D];X.x>B.x1&&X.x<B.x2&&X.y>B.y1&&X.y<B.y2&&(ee[D]=1);const ce=D*cl;for(let se=0;se<q.length;se++){const re=gQ(X.x,X.y,q[se]);if(re<=.02)continue;let de=ce;for(let _e=ce;_e<ce+cl;_e++){if(z[_e]===-1){de=_e;break}Y[_e]<Y[de]&&(de=_e)}(z[de]===-1||re>Y[de])&&(Y[de]=re,z[de]=se)}}return{startT:j,buildEnd:G,els:q,frame:B,cellQ:Y,cellEl:z,inFrame:ee}},A=()=>{const j=i.getBoundingClientRect();d=Math.max(1,j.width),f=Math.max(1,j.height);const V=Math.min(2,window.devicePixelRatio||1);i.width=Math.round(d*V),i.height=Math.round(f*V),o.setTransform(V,0,0,V,0,0);const Q=Math.max(8,Math.round(d/Yp)),q=Math.max(6,Math.round(f/Yp));p=d/Q,m=f/q,u=[];for(let G=0;G<q;G++){const W=q>1?G/(q-1):.5,Y=oQ*(1+aQ*.4*(W*2-1));for(let z=0;z<Q;z++){const ee=G*8191+z*131+1,B={x:(z+.5)*p,y:(G+.5)*m,size:Y,seed:ee,phase:Xp(ee),kind:0};B.kind=Math.floor(Xp(ee*97)*3),u.push(B)}}w=null,v=null},M=new Float32Array(32),R=j=>{o.fillStyle=rQ,o.fillRect(0,0,d,f),v||(v=T(j+.2)),j>=v.startT+v.buildEnd+lQ&&(w=v,_=j,v=T(j+.2));let V=0;w&&(V=1-S0((j-_)/cQ),V<=0&&(w=null));const Q=v;for(let B=0;B<Q.els.length;B++){const D=Q.els[B];M[B]=S0(Math.min(1,Math.max(0,(j-Q.startT-D.start)/D.dur)))}const q=M[0],G=C(0),W=C(q),Y=V>0?C(V):G,z=V>0?C(Math.max(q,V)):W,ee=u.length;for(let B=0;B<ee;B++){const D=u[B];let X=0,ce=0;const se=B*cl;for(let Ce=se;Ce<se+cl;Ce++){const Ue=Q.cellEl[Ce];if(Ue<0)break;const rt=Q.cellQ[Ce]*M[Ue];rt>X&&(X=rt,ce=Q.els[Ue].level)}if(w)for(let Ce=se;Ce<se+cl;Ce++){const Ue=w.cellEl[Ce];if(Ue<0)break;const rt=w.cellQ[Ce]*V;rt>X&&(X=rt,ce=w.els[Ue].level)}const re=j/sQ+D.phase,de=Math.floor(re),_e=re-de,fe=S0(Math.min(_e,1-_e)/iQ),oe=Math.floor(Xp(D.seed*97+de*7919)*3);oe!==D.kind&&X<.02&&fe<.05&&(D.kind=oe);const je=Math.max(fe*(1-X),X);if(!(je<.01))if(X<.02){const Ce=Q.inFrame[B]===1,Ue=w?w.inFrame[B]===1:!1;Ce?o.fillStyle=Ue?z:W:o.fillStyle=Ue?Y:G;const rt=Math.max(Ce?q:0,Ue?V:0);sC(o,D.kind,D.x,D.y,D.size*je*(1-.2*rt))}else{o.fillStyle=k(X);const Ce=1+(dQ[ce]-1)*X;sC(o,D.kind,D.x,D.y,D.size*je*Ce)}}};A();let I=0;if(l)v=T(-100),R(0);else{const j=performance.now(),V=Q=>{R((Q-j)/1e3),I=requestAnimationFrame(V)};I=requestAnimationFrame(V)}const L=new ResizeObserver(()=>{A(),l&&(v=T(-100),R(0))});L.observe(i),r.current=()=>{cancelAnimationFrame(I),L.disconnect(),e&&n(j=>j-1)}},[e,n]);return S.jsx("canvas",{ref:s,"aria-hidden":"true",className:`h-full w-full ${t}`.trim()})},vQ=async(t=null)=>{if(t)return yQ(t);let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return Qp();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null};let r;try{r=await e.json()}catch{return Qp()}const s=r.devServerHealth;return s?s.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable",upstreamStatus:null}:s.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable",upstreamStatus:null}:{isOk:!1,unavailableReason:s.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable",upstreamStatus:null}:Qp()},hM=async t=>{try{const e=await fetch(t);return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable",upstreamStatus:e.status}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}},yQ=t=>hM(t),Qp=()=>hM("/"),gy=ps("usePreviewUpstreamHealth"),_Q=500,wQ=4e3,xQ=15e3,bQ=3,SQ=(t,e={})=>{const n=g.useRef(null),r=g.useRef(null),s=e.probeMsWhileDown??_Q,i=e.probeMsWhileUp??wQ,o=e.firstUnreachableCaptureAfterMs??xQ,l=e.rerunProbeImmediatelyOnVersion,u=e.probePath??null,d=e.skip??!1,f=g.useRef(e.onPersistentUpstreamServerErrors);f.current=e.onPersistentUpstreamServerErrors;const[p,m]=g.useState(t==="static"),[v,w]=g.useState(0),[_,x]=g.useState(null),[b,k]=g.useState(0),[C,T]=g.useState(!1),[A,M]=g.useState(!1),[R,I]=g.useState(t==="static"?null:"upstream_unreachable");return g.useEffect(()=>{if(t==="static"){m(!0),x(null),k(0),T(!1),M(!0),I(null);return}if(d){m(!1),x(null),k(0),T(!1),M(!0),I("upstream_unreachable"),n.current=null;return}let L=!0;const N=Date.now();x(N),k(0),T(!1),m(!1),M(!1),I("upstream_unreachable");const j={current:!1},V={current:!1},Q={current:!1},q={current:null},G={current:!1},W={current:!1},Y={current:0},z={current:!1},ee={current:null};let B=null;const D=()=>{Q.current||(Q.current=!0,L&&M(!0))},X=()=>{B!==null&&(clearTimeout(B),B=null)},ce=(re,de)=>{X(),B=setTimeout(de,re)},se=async()=>{var rt;if(!L)return;k(st=>st+1);const{isOk:re,unavailableReason:de,upstreamStatus:_e}=await vQ(u);if(!L)return;D(),ee.current=_e;const fe=re&&_e!==null&&_e>=500;fe&&W.current?Y.current+=1:re&&!fe&&(Y.current=0);const oe=Y.current>=bQ;if(oe&&!z.current&&_e!==null&&(z.current=!0,Ee==null||Ee.capture("preview_upstream_error_responses",{framework:t,upstream_status:_e,consecutive_count:Y.current}),gy.warn(`Preview upstream is listening but has served ${Y.current} consecutive ${_e} responses`),(rt=f.current)==null||rt.call(f,{upstreamStatus:_e,consecutiveCount:Y.current})),re&&!oe){fe||(W.current=!0,z.current=!1);const st=!G.current;G.current=!0,m(!0),I(null),q.current=null,V.current=!1,T(!1),j.current?st&&(Ee==null||Ee.capture("preview_upstream_restored",{framework:t})):(j.current=!0,Ee==null||Ee.capture("preview_dev_server_ready",{framework:t,ready_after_ms:Date.now()-N})),ce(i,se);return}const Ce=G.current;G.current=!1,m(!1),I(de),q.current===null&&(q.current=Date.now(),V.current=!1,T(!1)),Ce&&(Ee==null||Ee.capture("preview_upstream_lost",{framework:t,upstream_status:_e}),w(st=>st+1),gy.warn("Preview upstream became unavailable after it was ready"));const Ue=Date.now()-q.current;Ue>=o&&!V.current&&(V.current=!0,T(!0),Ee==null||Ee.capture("preview_dev_server_unreachable",{framework:t,elapsed_ms:Ue,upstream_status:ee.current}),gy.warn("Dev server did not become ready within timeout window")),ce(s,se)};return n.current=()=>ce(0,se),ce(0,se),()=>{L=!1,n.current=null,X()}},[t,s,i,o,u,d]),g.useEffect(()=>{var N;if(t==="static"||l===void 0)return;const L=r.current;r.current=l,L!==null&&L!==l&&((N=n.current)==null||N.call(n))},[t,l]),{isUpstreamReady:p,iframeRemountKey:v,probeStartedAt:_,probeAttemptCount:b,isFirstUnreachableWindowExceeded:C,initialProbeComplete:A,unavailableReason:R}};function EQ(t){return t.enteringSplit&&t.isExistingSession&&t.hasActiveVariantProxy}const pM=t=>{var e;return t!=="embedded"||typeof window>"u"?"":((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.previewOrigin)??`${window.location.protocol}//localhost:${window.location.port}`},mM=({agentApplyMode:t,url:e})=>e.startsWith("/")?`${pM(t)}${e}`:e,kQ="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",CQ=t=>kQ,PQ=ps("PreviewSurface"),iC=(t,e)=>t==="about:blank"?"blank":t.includes("/api/variants/")?"static_artifact":e.kind==="variant"?"dev_server":"original",gM=({target:t,src:e,framework:n,remountKey:r})=>(it(Jm),S.jsx("div",{className:"relative h-full w-full",children:S.jsx("iframe",{src:e,className:"h-full w-full border-none",title:"Project Preview",sandbox:CQ(),onLoad:()=>{Ee==null||Ee.capture("preview_iframe_loaded",{framework:n,src:e}),t.kind==="variant"&&(Ee==null||Ee.capture("variants_panel.preview_displayed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:iC(e,t),framework:n}))},onError:()=>{Ee==null||Ee.capture("preview_iframe_load_failed",{framework:n,src:e}),t.kind==="variant"&&(Ee==null||Ee.capture("variants_panel.preview_display_failed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:iC(e,t),framework:n})),PQ.warn("Preview iframe failed to load",{framework:n,src:e})}},r)})),TQ=g.lazy(()=>XC(()=>Promise.resolve().then(()=>cee),void 0)),AQ={surface:"relative flex h-full w-full items-center justify-center bg-main px-6",overlay:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",page:"relative flex h-screen w-full items-center justify-center bg-main px-6"},IQ={sm:"text-lg font-semibold text-content",md:"text-2xl font-semibold text-content",lg:"text-3xl font-semibold text-content"},RQ={neutral:"rounded-md border border-divider bg-transparent px-5 py-2 text-sm font-medium text-content transition-colors hover:bg-surface-3",ghost:"rounded-md px-5 py-2 text-sm font-medium text-content-muted transition-colors hover:text-content"},tu=({backdrop:t,media:e,title:n,description:r,actions:s,tone:i="neutral",fill:o="surface",size:l="md",children:u,state:d,role:f="status",busy:p=!1,className:m=""})=>{const v=g.useCallback(_=>{_&&d&&(Ee==null||Ee.capture("status_surface_shown",{state:d,tone:i,fill:o}))},[d,i,o]),w=!!(e||n||r||u||s!=null&&s.length);return S.jsxs("div",{ref:v,className:`${AQ[o]} ${m}`.trim(),role:f,"aria-live":"polite","aria-busy":p||void 0,"data-state":d,children:[t?S.jsx("div",{className:"absolute inset-0",children:t}):null,w?S.jsxs("div",{className:"relative z-10 flex max-w-sm flex-col items-center gap-5 text-center",children:[e,n?S.jsx("h2",{className:IQ[l],children:n}):null,r?S.jsx("p",{className:"text-content-muted text-base leading-relaxed",children:r}):null,u,s!=null&&s.length?S.jsx("div",{className:"flex flex-row items-center gap-3",children:s.map(_=>S.jsx("button",{type:"button",onClick:_.onClick,className:RQ[_.variant??"neutral"],children:_.label},_.label))}):null]}):null]})},E2=({loader:t="coalesce",trackGlobalLoaderCount:e,size:n="lg",...r})=>t==="coalesce"?S.jsx(tu,{...r,size:n,busy:!0,backdrop:S.jsx(fM,{trackGlobalLoaderCount:e})}):t==="logo"?S.jsx(tu,{...r,size:n,busy:!0,backdrop:S.jsx(g.Suspense,{fallback:null,children:S.jsx(TQ,{className:"absolute inset-0"})})}):S.jsx(tu,{...r,size:n,busy:!0,media:S.jsx(Xm,{"aria-hidden":!0,className:"text-content h-8 w-8 shrink-0 animate-spin",weight:"bold"})}),vM=({icon:t,...e})=>S.jsx(tu,{...e,tone:"neutral",media:t?S.jsx("div",{className:"text-content-muted",children:t}):void 0}),$x=t=>S.jsx(tu,{...t,tone:"error",role:"alert"}),oC="/static/",MQ=t=>{try{return new URL(t,"http://localhost").pathname.endsWith(oC)}catch{return t.endsWith(oC)}},OQ=t=>t==="spawn_error"?"The direction is saved, but its preview process didn’t start.":t==="exited"?"The direction is saved, but its preview stopped before it was ready.":t==="timeout"?"The direction is saved, but its preview took too long to become ready.":t==="missing_dev_script"?"The direction is saved, but Rivet couldn’t find a dev script to preview it.":t==="missing_static_entry"?"The direction is saved, but Rivet couldn’t find an HTML entry to preview it.":"The direction is saved, but Rivet couldn’t prepare its preview.",LQ=t=>t.status==="failed"&&t.errorCode==="VARIANT_VERIFICATION_UNAVAILABLE"?{state:"variant_verification_unavailable",title:"Rivet couldn’t verify this direction",description:"The worker completed, but Rivet couldn’t inspect its generated files.",detail:t.errorMessage??t.errorCode,isError:!0}:t.status==="failed"&&t.errorCode==="VARIANT_QA_FAILED"?{state:"variant_output_integrity_failed",title:"This direction couldn’t be verified",description:"The worker completed, but Rivet found a structural problem in the generated files.",detail:t.errorMessage??t.errorCode,isError:!0}:t.status==="failed"?{state:"variant_worker_failed",title:"This direction didn’t complete",description:"The worker stopped before producing a usable result.",detail:t.errorMessage??t.errorCode,isError:!0}:t.status==="cancelled"?{state:"variant_cancelled",title:"Direction was cancelled",description:"Rivet stopped before a preview was ready. Your other directions are unchanged.",isError:!1}:t.status==="succeeded"&&t.previewUnavailable&&t.previewUnavailable.reason!=="idle_timeout"?{state:"preview_unavailable",title:"Rivet couldn’t preview this direction",description:OQ(t.previewUnavailable.reason),detail:t.previewUnavailable.portInUse?"The preview port was already in use.":void 0,isError:!0}:null,DQ=({issue:t})=>S.jsx(tu,{fill:"overlay",size:"sm",state:t.state,role:t.isError?"alert":"status",tone:t.isError?"error":"neutral",title:t.title,description:t.description,children:t.detail?S.jsx("p",{className:"text-content-subtle text-xs leading-relaxed break-words",children:t.detail}):null}),NQ=({isInteractionDisabled:t=!1,framework:e,userPort:n})=>{const r=it(p2),s=dt(p2),i=it(ym),o=dt(ym),l=it(hh),u=it(Jm),d=it(m2),f=it(g2),p=it(UR),m=it(WR),v=dt(g2),w=it(yo),_=it(y2),x=dt(m2),b=l.active&&l.projectContext.kind==="fresh",k=it(v2),C=l.active?l.variants.find(De=>De.workItemId===k&&(De.status==="pending"||De.status==="running"||De.status==="succeeded"&&!De.preview&&typeof De.port!="number"&&(!De.previewUnavailable||De.previewUnavailable.reason==="idle_timeout")))??null:null,T=l.active&&l.variants.some(De=>De.status==="pending"||De.status==="running"),A=b||T,M=l.active?l.variants.find(De=>De.workItemId===k)??null:null,R=M?LQ(M):null,I=e==="static"&&i!==null&&MQ(i);g.useEffect(()=>{l.active||x(!1)},[l.active,x]);const L=g.useRef(!1);g.useEffect(()=>{const De=!!(w!=null&&w.left||w!=null&&w.right),Je=De&&!L.current;L.current=De;const ut=l.active?l.sessionId:null;!ut||!EQ({enteringSplit:Je,isExistingSession:l.active&&l.projectContext.kind==="existing",hasActiveVariantProxy:d&&f!==null})||(x(!1),v(null),s(Pt=>Pt+1),fetch(`/api/variants/${encodeURIComponent(ut)}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(()=>{}))},[w,l,d,f,x,v,s]);const j=g.useMemo(()=>{var He;if(d||i&&!I||!l.active)return null;const{stage:De,variants:Je}=l,ut=De==="ready"||De==="degraded",Pt=Je.some(St=>{var pt,ke;return((pt=St.refinement)==null?void 0:pt.status)==="pending"||((ke=St.refinement)==null?void 0:ke.status)==="running"});if(!ut&&!Pt)return null;const be=Je.find(St=>{var pt;return St.status==="succeeded"&&((pt=St.preview)==null?void 0:pt.kind)==="static_artifact"});return((He=be==null?void 0:be.preview)==null?void 0:He.kind)==="static_artifact"?be.preview.url:null},[I,i,d,l])??i,V=g.useMemo(()=>!l.active||!j?null:l.variants.find(De=>{var Je;return((Je=De.preview)==null?void 0:Je.kind)==="static_artifact"&&j.startsWith(De.preview.url)})??null,[j,l]),Q=g.useMemo(()=>{if((_==null?void 0:_.previewKind)==="static")return{kind:"variant",sessionId:_.sessionId,variantId:_.variantId};if(!l.active)return vm;if(V)return{kind:"variant",sessionId:l.sessionId,variantId:V.workItemId};if(j){const Je=j.match(/\/__rivet\/preview\/variant\/([^/]+)\/([^/?#]+)/),ut=Je!=null&&Je[1]?decodeURIComponent(Je[1]):null,Pt=Je!=null&&Je[2]?decodeURIComponent(Je[2]):null;if(ut===l.sessionId&&Pt&&l.variants.some(St=>St.workItemId===Pt))return{kind:"variant",sessionId:l.sessionId,variantId:Pt};const be=j.match(/\/api\/variants\/[^/]+\/static\/([^/?#]+)/),He=be!=null&&be[1]?decodeURIComponent(be[1]):null;if(He&&l.variants.some(St=>St.workItemId===He))return{kind:"variant",sessionId:l.sessionId,variantId:He}}const De=!!(w!=null&&w.left||w!=null&&w.right);return(!De||b)&&!j&&d&&f&&l.variants.some(Je=>Je.workItemId===f)?{kind:"variant",sessionId:l.sessionId,variantId:f}:(!De||b)&&!j&&k&&l.variants.some(Je=>Je.workItemId===k)?{kind:"variant",sessionId:l.sessionId,variantId:k}:vm},[_,V,l,d,f,j,w,b,k]),q=g.useRef(null);g.useEffect(()=>{var Pt,be;if(!V||((Pt=V.preview)==null?void 0:Pt.kind)!=="static_artifact"||((be=V.refinement)==null?void 0:be.status)!=="succeeded")return;const De=`${V.workItemId}:${V.refinement.workItemId}`;if(q.current===De)return;q.current=De;const Je=V.preview.url.includes("?")?"&":"?",ut=`${V.preview.url}${Je}refinement=${encodeURIComponent(V.refinement.workItemId)}`;j!==ut&&(o(ut),s(He=>He+1))},[j,V,s,o,l]);const G=j!==null&&JY(j),W=j!==null&&!G||b&&!d&&!G,{isUpstreamReady:Y,iframeRemountKey:z,probeAttemptCount:ee,initialProbeComplete:B}=SQ(e,{rerunProbeImmediatelyOnVersion:r,probePath:G?j:null,skip:W}),[D,X]=g.useState(()=>p&&Y?r:null),ce=g.useRef(null);g.useEffect(()=>{if(!p){ce.current=null,X(null);return}if(D===r){ce.current=null;return}const De=ce.current;if(!De||De.remountKey!==r){ce.current={remountKey:r,probeAttemptCount:ee};return}Y&&ee>De.probeAttemptCount&&(ce.current=null,X(r))},[D,r,p,ee,Y]);const re=j!==null&&!G||Y,_e=m||p&&D!==r||p&&!re,fe=`${z}:${r}`,oe=XR(window.location.pathname),je=e==="static"?`/static${oe??"/"}`:oe??"/",Ce=pM(u);let Ue=null;j&&(Ue=mM({agentApplyMode:u,url:j}));const st=C||R||_e?"about:blank":(G&&!re?"about:blank":Ue)??(re?`${Ce}${je}`:"about:blank"),It=!!C||!!R||!re&&B;let ft=null;return _e?ft=S.jsx(E2,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"preview_replay_boot"}):C?ft=S.jsx(E2,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"variant_building",children:S.jsx("span",{className:"sr-only",children:"Building your direction"})}):R?ft=S.jsx(DQ,{issue:R}):It&&(ft=A?S.jsx(vM,{fill:"overlay",state:"preview_no_selection",title:"Nothing to preview yet",description:"Pick a direction from the panel."}):S.jsx($x,{fill:"overlay",state:"preview_offline",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]})),S.jsxs("div",{className:"relative h-full w-full",children:[ft,S.jsx(gM,{target:Q,src:st,framework:e,remountKey:fe})]})};function aC({side:t,sessionId:e,variantId:n,url:r,label:s,source:i,isFallback:o=!1}){var C;const l=it(yo),u=dt(yo),d=Zl(),f=it(hh),p=it(Jm),m=g.useRef(!1),v=g.useCallback(()=>{m.current||(m.current=!0,Pu({source:i,sessionId:e,variantId:n}))},[i,e,n]),w=g.useCallback(()=>{if(o){u(null);const R=_m("ended",l);d==null||d.capture(R.event,R.properties);return}v();const T={...l};delete T[t];const A=T.left||T.right?T:null;u(A);const M=_m(A?"updated":"ended",A??l);d==null||d.capture(M.event,M.properties)},[o,d,u,t,l,v]),_=g.useMemo(()=>({kind:"variant",sessionId:e,variantId:n}),[e,n]),x=g.useMemo(()=>!f.active||f.sessionId!==e?null:f.variants.find(T=>T.workItemId===n)??null,[e,n,f]),b=g.useMemo(()=>{var A,M;let T=r;if(((A=x==null?void 0:x.preview)==null?void 0:A.kind)==="static_artifact"&&((M=x.refinement)==null?void 0:M.status)==="succeeded"){const R=x.preview.url.includes("?")?"&":"?";T=`${x.preview.url}${R}refinement=${encodeURIComponent(x.refinement.workItemId)}`}return mM({agentApplyMode:p,url:T})},[p,x,r]),k=((C=x==null?void 0:x.refinement)==null?void 0:C.status)==="succeeded"?`${n}:${x.refinement.workItemId}`:n;return S.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[S.jsxs("div",{className:"variant-split-secondary-toolbar",children:[S.jsx("span",{className:"variant-split-secondary-label",title:s,children:s}),S.jsx(Ul,{label:"Collapse",children:S.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:w,"aria-label":"Collapse split view",children:S.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:S.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),S.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:S.jsx(gM,{target:_,src:b,framework:"static",remountKey:k})})]})}function $Q(){const t=it(Cu),e=it(Ox);return!t||!e?null:ch.createPortal(S.jsx("div",{"aria-hidden":"true",className:"border-main-border bg-main pointer-events-none fixed top-0 left-0 z-[70] flex max-w-60 items-center gap-2 rounded-md border px-3 py-1.5 shadow-lg",style:{transform:`translate3d(${e.x+12}px, ${e.y+12}px, 0)`},children:S.jsx("span",{className:"text-content truncate text-sm font-medium",children:t.label})}),document.body)}function jQ(){const t=it(Cu),e=it(Ox),n=it(yo),r=dt(Cu),s=dt(yo),i=Zl(),o=g.useRef(null),[l,u]=g.useState(null),[d,f]=g.useState("hidden");g.useEffect(()=>{t||(f("hidden"),u(null))},[t]);const p=g.useCallback((v,w)=>{const _=o.current;if(!_)return null;const x=_.getBoundingClientRect();return v<x.left||v>x.right||w<x.top||w>x.bottom?null:v<(x.left+x.right)/2?"left":"right"},[]);if(g.useEffect(()=>{if(!t||!e)return;const v=p(e.x,e.y);u(w=>w===v?w:v),f(w=>{if(w==="exiting")return w;const _=v!==null?"visible":"hidden";return w===_?w:_})},[t,e,p]),g.useEffect(()=>{if(!t)return;const v=w=>{const _=p(w.clientX,w.clientY);if(_&&t.url){const x={sessionId:t.sessionId,variantId:t.variantId,label:t.label,url:t.url,source:t.source},b=n==null?void 0:n[_];b&&(b.sessionId!==x.sessionId||b.variantId!==x.variantId)&&Pu(b);const k={...n??{},[_]:x};s(k);const C=_m(n?"updated":"started",k);i==null||i.capture(C.event,C.properties),f("exiting"),window.setTimeout(()=>r(null),220)}else Pu(t),f("exiting"),window.setTimeout(()=>r(null),220)};return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[t,p,i,r,s,n]),!t)return null;const m=["variant-drop-zones",d==="visible"&&"is-visible",d==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return S.jsxs("div",{ref:o,className:m,"aria-hidden":"true",children:[S.jsx(lC,{side:"left",hovered:l==="left",canDrop:!!t.url,label:t.label}),S.jsx(lC,{side:"right",hovered:l==="right",canDrop:!!t.url,label:t.label})]})}function lC({side:t,hovered:e,canDrop:n,label:r}){return S.jsxs("div",{className:["variant-drop-zone",`is-${t}`,e&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[S.jsxs("div",{className:"variant-drop-zone-inner",children:[S.jsx("div",{className:`variant-drop-zone-icon is-${t}`}),S.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${t} split`:"Split unavailable for this direction"})]}),S.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:S.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),S.jsx("div",{className:"variant-drop-zone-border"})]})}const yM=(t,e,n)=>{var i,o;if(!t.active||t.sessionId!==e)return null;const r=t.variants.find(l=>l.workItemId===n);if(((i=r==null?void 0:r.preview)==null?void 0:i.kind)!=="static_artifact")return null;if(((o=r.refinement)==null?void 0:o.status)!=="succeeded")return r.preview.url;const s=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${s}refinement=${encodeURIComponent(r.refinement.workItemId)}`},cC=(t,e)=>{if(!t)return;const n=yM(e,t.sessionId,t.variantId);return!n||n===t.url?t:{...t,url:n}},FQ=()=>S.jsx("div",{"data-testid":"preview-boot-skeleton",role:"status","aria-busy":"true","aria-label":"Loading preview",className:"bg-main flex h-full min-h-0 w-full flex-1 flex-col p-3",children:S.jsx("div",{className:"border-main-border relative min-h-0 flex-1 overflow-hidden rounded-lg border",children:S.jsx(fM,{trackGlobalLoaderCount:!1})})}),VQ=({isLoading:t=!1,isInteractionDisabled:e=!1})=>{const{config:n,fetchConfig:r,isLoading:s,error:i}=nQ();return g.useEffect(()=>{r().catch(o=>{Ee==null||Ee.capture("preview_config_load_failed",{message:o instanceof Error?o.message:"unknown_error",attempts:tC})})},[r]),s?S.jsx(FQ,{}):i||!n?S.jsx($x,{fill:"surface",size:"sm",state:"preview_config_error",title:"Couldn't load preview",description:"We couldn't load the preview configuration.",actions:[{label:"Retry",onClick:()=>{Ee==null||Ee.capture("preview_config_retry_clicked"),r().catch(o=>{Ee==null||Ee.capture("preview_config_load_failed",{message:o instanceof Error?o.message:"unknown_error",attempts:tC})})}}]}):S.jsx(HQ,{isLoading:t,isInteractionDisabled:e,framework:n.framework,userPort:n.userPort})};function HQ(t){const e=it(yo),n=it(Cu),r=it(hh),s=it(ym),i=e==null?void 0:e.left,o=e==null?void 0:e.right,l=g.useMemo(()=>{var A,M;if(!r.active||r.projectContext.kind!=="fresh"||!(!!i!=!!o))return;const _=(A=i??o)==null?void 0:A.variantId,x=r.variants.filter(R=>{var I;return R.status==="succeeded"&&((I=R.preview)==null?void 0:I.kind)==="static_artifact"&&R.workItemId!==_}),b=s==null?void 0:s.replace(/[?&]refinement=[^&]*$/,""),C=x.find(R=>{var I;return((I=R.preview)==null?void 0:I.kind)==="static_artifact"&&R.preview.url===b})??x[0];if(((M=C==null?void 0:C.preview)==null?void 0:M.kind)!=="static_artifact")return;const T=yM(r,r.sessionId,C.workItemId);if(T)return{sessionId:r.sessionId,variantId:C.workItemId,label:C.label,url:T,source:"live"}},[r,i,o,s]),u=cC(i,r)??(o?l:void 0),d=cC(o,r)??(i?l:void 0),f=!i&&!!u,p=!o&&!!d,m=!!(u||d),v=S.jsx(NQ,{isInteractionDisabled:t.isInteractionDisabled,framework:t.framework,userPort:t.userPort});return S.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:S.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${m?"is-split":""}`,children:[S.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[u&&S.jsx(aC,{side:"left",sessionId:u.sessionId,variantId:u.variantId,url:u.url,label:u.label,source:u.source,isFallback:f},`left-${u.sessionId}:${u.variantId}:${u.url}`),!(u&&d)&&S.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:v}),d&&S.jsx(aC,{side:"right",sessionId:d.sessionId,variantId:d.variantId,url:d.url,label:d.label,source:d.source,isFallback:p},`right-${d.sessionId}:${d.variantId}:${d.url}`)]}),S.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),S.jsx(jQ,{}),S.jsx($Q,{})]})})}function no(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _M(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}/*!
|
|
144
|
+
</html>`,cM=(t="editor_gate")=>{const e=Zl(),[n,r]=g.useState(!1),[s,i]=g.useState(null);return{startLogin:g.useCallback(async()=>{var p;const l=globalThis.crypto.randomUUID(),u=Date.now();r(!0),i(null);const d=fy({outcome:"started",authAttemptId:l,entryPoint:t,startedAt:u,now:u});e==null||e.capture(d.event,d.properties);let f=null;try{if(f=window.open("","_blank"),!f)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{f.document.open(),f.document.write(NX),f.document.close()}catch(w){Zk.warn("Failed to render loading state in auth popup:",w)}const m=await fetch(`${Gk}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"core"})}),v=await m.json();if(!m.ok||!v.success||!v.authUrl||!v.sessionId||!v.pollSecret)throw new Error(v.error||v.message||"Failed to start Google login");if(f.closed)throw new Error("Sign-in window was closed before Google login started.");f.location.href=v.authUrl;for(let w=0;w<DX;w+=1){if(f.closed)throw new Error("Sign-in window was closed before authentication completed.");const x=await(await fetch(`${Gk}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:v.sessionId,pollSecret:v.pollSecret})})).json();if(x.success&&x.token&&((p=x.user)!=null&&p.email)){if(!(await Wl("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:x.user.email,token:x.token,refreshToken:x.refreshToken,userId:x.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");f.close(),window.sessionStorage.setItem(wm,"1");const k=fy({outcome:"completed",authAttemptId:l,entryPoint:t,startedAt:u,now:Date.now()});e==null||e.capture(k.event,k.properties),window.location.reload();return}if(x.error&&x.error!=="Pending")throw new Error(x.error||"Google login failed");await new Promise(b=>setTimeout(b,LX))}throw new Error("Authentication timed out. Please try again.")}catch(m){f&&!f.closed&&f.close();const v=m instanceof Error?m.message:"Failed to start login flow";Zk.warn("Login failed:",v);const w=fy({outcome:"failed",authAttemptId:l,entryPoint:t,startedAt:u,now:Date.now(),failureReason:OX(v)});e==null||e.capture(w.event,w.properties),i(v),r(!1)}},[e,t]),isStartingLogin:n,loginError:s}},Kk="/assets/arena-Db0j1set.png",$X=ps("useIntegrations"),hy=["integrations"],jX="rivet:connect-result",FX=t=>typeof t=="object"&&t!==null&&t.type===jX,VX=ot(null),Yk=async()=>{const t=await Wl("/api/integrations");if(!t.ok)throw new Error(`Failed to load integrations (${t.status})`);return(await t.json()).integrations??[]},HX=()=>{const t=JC(),[e,n]=D5(VX),r=M0({queryKey:hy,queryFn:Yk,staleTime:1e4}),s=g.useCallback(async()=>(await t.invalidateQueries({queryKey:hy,refetchType:"none"}),t.fetchQuery({queryKey:hy,queryFn:Yk})),[t]),i=g.useCallback(async l=>{const u=window.open("","_blank","width=560,height=720");if(!u)throw new Error("Popup blocked. Allow popups to connect.");n(l);try{const d=await Wl(`/api/integrations/${l}/connect`,{method:"POST"}),f=await d.json().catch(()=>({}));if(!d.ok||!f.authUrl)throw u.close(),new Error(f.error||`Could not connect ${l}`);return u.location.href=f.authUrl,await new Promise(p=>{let m=!1,v=null;const w=async(x,b=!1)=>{if(!m){m=!0,window.removeEventListener("message",_),v&&clearInterval(v);try{const C=(await s()).some(T=>T.provider===l&&T.status==="connected");p(b&&C?"connected":x)}catch{p(x)}}},_=x=>{if(FX(x.data)&&x.data.provider===l){if(x.data.status==="error"){$X.warn(`Connect failed for ${l}:`,x.data.message),w("failed");return}w("connected")}};window.addEventListener("message",_),v=setInterval(()=>{u.closed&&w("closed",!0)},500)})}finally{n(null)}},[s,n]),o=g.useCallback(async l=>{n(l);try{const u=await Wl(`/api/integrations/${l}`,{method:"DELETE"});if(!u.ok){const d=await u.json().catch(()=>({}));throw new Error(d.error||`Could not disconnect ${l}`)}await s()}finally{n(null)}},[s,n]);return{integrations:r.data??[],isLoading:r.isPending,error:r.error instanceof Error?r.error.message:null,pendingProvider:e,connect:i,disconnect:o,refetch:s}},ll=({action:t,outcome:e,provider:n,entryPoint:r,durationMs:s,failureReason:i})=>({event:`visual_editor_reference_${t==="connect"?"connection":"disconnection"}_${e}`,properties:{provider:n,entry_point:r,...s!==void 0?{duration_ms:s}:{},...i?{failure_reason:i}:{}}}),Xk=ps("ConnectorsModal"),zX=()=>S.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6","aria-hidden":"true",children:S.jsx("path",{fill:"currentColor",d:"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.781c0-1.669.967-2.915 2.171-2.915 1.024 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.132 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.137.893 2.739.098.119.112.223.083.344-.091.379-.293 1.194-.333 1.361-.052.22-.174.266-.401.16-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.36-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146A12.004 12.004 0 0 0 12 24c6.627 0 12-5.373 12-12C24 5.372 18.627 0 12 0z"})}),BX=()=>S.jsx("span",{"aria-hidden":"true",className:"h-6 w-6 bg-[#b1b1b1]",style:{WebkitMaskImage:`url(${Kk})`,maskImage:`url(${Kk})`,WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskPosition:"center",maskPosition:"center"}}),UX=[{provider:"pinterest",name:"Pinterest",description:"Pull boards and pins in as visual references.",tileClassName:"bg-[#e60023] text-white",icon:S.jsx(zX,{})},{provider:"arena",name:"Are.na",description:"Connect channels of collected blocks and links.",tileClassName:"bg-[#18181b] text-content",icon:S.jsx(BX,{})}],WX=({meta:t,integration:e,isPending:n,isHighlighted:r,onConnect:s,onDisconnect:i})=>{const o=(e==null?void 0:e.status)==="connected",l=e!=null&&e.externalUsername?`@${e.externalUsername}`:null;return S.jsxs("article",{className:`bg-main-light flex flex-col rounded-xl p-[18px] ${r?"ring-secondary ring-2":""}`,children:[S.jsx("span",{className:`grid h-[52px] w-[52px] flex-none place-items-center rounded-xl ${t.tileClassName}`,"aria-hidden":"true",children:t.icon}),S.jsxs("div",{className:"mt-4 flex-1",children:[S.jsxs("h2",{className:"text-content flex items-center gap-1.5 text-[15px] font-semibold",children:[t.name,o?S.jsx(fR,{className:"h-3.5 w-3.5",weight:"bold","aria-hidden":"true"}):null]}),S.jsx("p",{className:"text-content-subtle mt-1 text-[13px] leading-relaxed",children:t.description}),o&&l?S.jsx("p",{className:"text-content-muted mt-2.5 text-xs font-medium",children:l}):null]}),o?S.jsx("button",{type:"button",onClick:i,disabled:n,className:"active-push bg-main-input text-content-muted mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors hover:bg-red-500/10 hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-50",children:n?"Disconnecting…":"Disconnect"}):S.jsx("button",{type:"button",onClick:s,disabled:n,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent mt-[18px] inline-flex min-h-[38px] w-full items-center justify-center rounded-lg px-3.5 text-[13px] font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:n?"Connecting…":"Connect"})]})},S2=({isOpen:t,onClose:e,context:n="menu",highlightProvider:r=null})=>{const{integrations:s,isLoading:i,error:o,pendingProvider:l,connect:u,disconnect:d}=HX(),f=Zl(),[p,m]=g.useState(null),v=b=>s.find(k=>k.provider===b),w=g.useCallback(b=>{const k=Date.now(),C=ll({action:"connect",outcome:"started",provider:b,entryPoint:n});f==null||f.capture(C.event,C.properties),u(b).then(T=>{const A=Date.now()-k;if(T==="connected"){const R=ll({action:"connect",outcome:"completed",provider:b,entryPoint:n,durationMs:A});f==null||f.capture(R.event,R.properties);return}const M=ll({action:"connect",outcome:"failed",provider:b,entryPoint:n,durationMs:A,failureReason:T==="closed"?"popup_closed":"provider_failed"});f==null||f.capture(M.event,M.properties)}).catch(T=>{const A=T instanceof Error?T.message:"Could not connect.",M=ll({action:"connect",outcome:"failed",provider:b,entryPoint:n,durationMs:Date.now()-k,failureReason:A.includes("Popup blocked")?"popup_blocked":"request_failed"});f==null||f.capture(M.event,M.properties),Xk.warn(`Connect error for ${b}:`,A),xt.error(A)})},[u,n,f]),_=g.useCallback(b=>{const k=Date.now(),C=ll({action:"disconnect",outcome:"started",provider:b,entryPoint:n});f==null||f.capture(C.event,C.properties),d(b).then(()=>{const T=ll({action:"disconnect",outcome:"completed",provider:b,entryPoint:n,durationMs:Date.now()-k});f==null||f.capture(T.event,T.properties)}).catch(T=>{const A=T instanceof Error?T.message:"Could not disconnect.",M=ll({action:"disconnect",outcome:"failed",provider:b,entryPoint:n,durationMs:Date.now()-k,failureReason:"request_failed"});f==null||f.capture(M.event,M.properties),Xk.warn(`Disconnect error for ${b}:`,A),xt.error(A)})},[n,d,f]),x=n==="onboarding";return S.jsx(_x,{open:t,onOpenChange:b=>!b&&e(),children:S.jsxs(wx,{children:[S.jsx(xx,{className:"z-max fixed inset-0 bg-black/40"}),S.jsx(bx,{ref:m,className:"z-max border-main-border bg-main font-main fixed top-1/2 left-1/2 w-[560px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-2xl outline-none",children:S.jsxs(DI,{value:p,children:[S.jsxs("div",{className:"border-main-border bg-main-light flex items-center justify-between rounded-t-lg border-b px-4 py-2",children:[S.jsx(Sx,{className:"text-content text-base font-medium",children:"Connect design references"}),S.jsx(mo,{onClick:e,title:"Close","aria-label":"Close",variant:"ghost",size:"icon-compact",children:S.jsx(OR,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[S.jsx(Ex,{className:"text-content-subtle text-sm",children:"Connect your design references to use them with Rivet’s MCP."}),o?S.jsx("p",{className:"rounded-lg bg-red-500/10 px-4 py-3 text-[13px] font-medium text-red-300",children:o}):null,S.jsx("div",{className:"grid grid-cols-2 gap-4",children:UX.map(b=>S.jsx(WX,{meta:b,integration:v(b.provider),isPending:i||l===b.provider,isHighlighted:r===b.provider,onConnect:()=>w(b.provider),onDisconnect:()=>_(b.provider)},b.provider))}),x?S.jsxs("div",{className:"flex items-center justify-between gap-4",children:[S.jsx("p",{className:"text-content-subtle text-xs",children:"You can always do this later from the account menu."}),S.jsx("button",{type:"button",onClick:e,className:"active-push bg-secondary text-secondary-foreground hover:bg-accent flex-none rounded-lg px-3.5 py-2 text-[13px] font-medium transition-colors",children:"Skip for now"})]}):null]})]})})]})})},Qk=({className:t=""})=>S.jsx("span",{"aria-hidden":"true",className:`rivet-skeleton block rounded ${t}`.trim()}),ZX=ps("SupportTicketModal"),Jk=5e3,py="feedback",qX=t=>{var r;if(!t)return null;const e=(r=t.formErrors)==null?void 0:r[0];if(e)return e;const n=t.fieldErrors??{};for(const s of Object.values(n)){const i=s==null?void 0:s[0];if(i)return i}return null},GX=async t=>{let e;try{e=await t.json()}catch{e=void 0}if(t.status===400){if(typeof(e==null?void 0:e.details)=="string"&&e.details.trim())return e.details;if(typeof(e==null?void 0:e.details)=="object"&&e.details!==null){const n=qX(e.details);if(n)return n}return"Please check your feedback and try again."}return t.status>=500?typeof(e==null?void 0:e.details)=="string"&&e.details.trim()?e.details:"Could not send feedback right now. Please try again later.":typeof(e==null?void 0:e.error)=="string"&&e.error.trim()?e.error:`HTTP ${t.status}`},KX=({isOpen:t,onClose:e,contactEmail:n})=>{const r=Zl(),[s,i]=g.useState(""),[o,l]=g.useState(!1),[u,d]=g.useState(null),f=g.useCallback(()=>{i("")},[]),p=g.useCallback(()=>{o||(f(),e())},[o,e,f]),m=g.useCallback(async()=>{const x=s.trim();if(!(!x||o)){l(!0);try{const b=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,k=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,C=n==null?void 0:n.trim(),T=await Wl("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:py,message:x,contactEmail:C||void 0,metadata:{posthogSessionId:b??void 0,posthogDistinctId:k??void 0,appVersion:"0.17.2",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!T.ok){const A=await GX(T);throw new Error(A)}r==null||r.capture("support_ticket_submitted",{ticket_type:py,has_posthog_session_id:!!b}),xt.success("Feedback sent",{description:"Thanks for sharing this."}),f(),e()}catch(b){const k=b instanceof Error?b.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:py,error:k}),ZX.error("Failed to submit support ticket:",k),xt.error("Could not send feedback",{description:k})}finally{l(!1)}}},[n,o,s,e,r,f]),v=g.useCallback(x=>{x.key==="Enter"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),m())},[m]),w=Jk-s.length,_=o||s.trim().length===0;return S.jsx(_x,{open:t,onOpenChange:x=>!x&&p(),children:S.jsxs(wx,{children:[S.jsx(xx,{className:"z-max fixed inset-0 bg-black/40"}),S.jsx(bx,{ref:d,className:"z-max border-main-border bg-main font-main fixed top-1/2 left-1/2 w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-lg border shadow-2xl outline-none",children:S.jsxs(DI,{value:u,children:[S.jsxs("div",{className:"border-main-border bg-main-light flex items-center justify-between rounded-t-lg border-b px-4 py-2",children:[S.jsx(Sx,{className:"text-content text-base font-medium",children:"Send feedback"}),S.jsx(mo,{onClick:p,disabled:o,title:"Close","aria-label":"Close",variant:"ghost",size:"icon-compact",children:S.jsx(OR,{className:"h-4 w-4",weight:"bold"})})]}),S.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[S.jsx(Ex,{className:"text-content-subtle text-sm",children:"Tell us what happened or what we can improve."}),S.jsxs("div",{className:"bg-main-input rounded-lg outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[S.jsx("textarea",{id:"support-ticket-message","aria-label":"Your feedback",value:s,onChange:x=>i(x.target.value),onKeyDown:v,maxLength:Jk,rows:6,disabled:o,placeholder:"What happened?",className:"text-content placeholder-content-subtle max-h-64 w-full resize-none overflow-y-auto bg-transparent pt-3 pr-3 pb-1 pl-3 text-sm focus:outline-none disabled:opacity-50"}),S.jsxs("div",{className:"flex items-center justify-between px-3 pt-1 pb-3",children:[S.jsx("span",{className:"text-content-subtle text-xs",children:"Context details are included automatically."}),S.jsxs("div",{className:"flex items-center gap-2",children:[w<=500&&S.jsx("span",{className:"text-content-subtle text-xs",children:w}),S.jsx(mo,{onClick:m,disabled:_,title:"Send feedback",shortcut:"⌘↵","aria-label":"Send feedback",size:"icon-compact",children:o?S.jsx(Xm,{className:"h-5 w-5 animate-spin",weight:"bold"}):S.jsx(eY,{className:"h-5 w-5",weight:"bold"})})]})]})]})]})]})})]})})},YX=ps("ProfileAvatar"),uM=(t,e)=>{const n=(t??"").trim();if(n)return n.split(/\s+/).filter(Boolean)[0]??"";const s=((e??"").split("@")[0]??"").split(/[._\-+]/).filter(Boolean)[0]??"";return s?s[0].toUpperCase()+s.slice(1):""},XX=(t,e)=>uM(t,e).charAt(0).toUpperCase(),QX=({className:t="",side:e="bottom",align:n="end"})=>{var Q,q,G;const r=MX(),s=((Q=r.data)==null?void 0:Q.name)??null,i=((q=r.data)==null?void 0:q.email)??null,o=((G=r.data)==null?void 0:G.isAuthenticated)===!0,l=Zl(),{startLogin:u,isStartingLogin:d,loginError:f}=cM("account_menu"),[p,m]=g.useState(!1),[v,w]=g.useState(!1),[_,x]=g.useState(!1),[b,k]=g.useState(!1),{containerRef:C,onKeyDown:T,onCloseAutoFocus:A}=DR({onDismiss:()=>V(!1)}),M=XX(s,i);if(r.isPending)return S.jsxs("span",{"data-testid":"profile-avatar-skeleton","aria-hidden":"true",className:`flex shrink-0 items-center gap-2 ${t}`.trim(),children:[S.jsx(Qk,{className:"h-8 w-8 rounded-full"}),S.jsx(Qk,{className:"h-3.5 w-16"})]});const R=uM(s,i),I=(s==null?void 0:s.trim())||null,L=(i==null?void 0:i.trim())||null,N=async()=>{k(!0);try{const W=await Wl("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!W.ok)throw new Error(`Logout failed: ${W.status}`)}catch(W){YX.warn("Logout request failed",W),xt.error("Could not log out. Please try again."),k(!1);return}window.location.reload()};let j="Log in";o&&(j=R||"Account"),r.error&&!r.data&&(j="Account unavailable");const V=W=>{m(W),l==null||l.capture(`visual_editor_account_menu_${W?"opened":"closed"}`,{is_authenticated:o})};return S.jsxs(S.Fragment,{children:[S.jsxs(Ax,{open:p,onOpenChange:V,children:[S.jsx(Ix,{asChild:!0,children:S.jsxs("button",{type:"button","aria-label":"Account","data-rivet-private":!0,className:`ph-no-capture text-content-muted hover:text-content flex shrink-0 items-center gap-2 transition-colors select-none ${t}`,children:[S.jsx("span",{className:"border-main-border bg-main-input flex h-8 w-8 items-center justify-center rounded-full border text-xs leading-none font-semibold",children:M||S.jsx(fY,{className:"h-4 w-4",weight:"bold"})}),S.jsx("span",{className:"max-w-[8rem] truncate text-sm font-medium",children:j})]})}),S.jsx(Rx,{children:S.jsxs(Mx,{"data-rivet-private":!0,ref:C,onKeyDown:T,onCloseAutoFocus:A,role:"menu",className:"ph-no-capture bg-popover shadow-surface-4 z-[60] min-w-[180px] rounded-lg p-1",side:e,sideOffset:6,align:n,children:[I||L?S.jsxs("div",{className:"border-main-border border-b px-3 py-2",children:[I?S.jsx("div",{className:"text-content truncate text-sm font-medium",children:I}):null,L?S.jsx("div",{className:"text-content-muted truncate text-xs",children:L}):null]}):null,S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{V(!1),w(!0)},disabled:!o,className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(TR,{className:"h-4 w-4",weight:"bold"}),"Connect design references"]}),S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{V(!1),x(!0)},className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm transition-colors focus:outline-none",children:[S.jsx(rY,{className:"h-4 w-4",weight:"bold"}),"Share feedback"]}),o?S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:N,disabled:b,className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm transition-colors focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[S.jsx(uY,{className:"h-4 w-4",weight:"bold"}),b?"Logging out…":"Log out"]}):null,!o&&!r.error?S.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{u()},disabled:d,className:"text-content hover:bg-hover focus-visible:bg-hover mt-1 flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm focus:outline-none disabled:opacity-50",children:[S.jsx(cY,{className:"h-4 w-4",weight:"bold"}),d?"Logging in…":"Log in"]}):null,r.error?S.jsx("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>{r.refetch()},className:"text-content mt-1 px-3 py-1.5 text-sm",children:"Retry account"}):null,f?S.jsx("p",{role:"alert",className:"max-w-64 px-3 py-2 text-sm text-red-300",children:f}):null]})})]}),v?S.jsx(S2,{isOpen:!0,onClose:()=>w(!1)}):null,S.jsx(KX,{isOpen:_,onClose:()=>x(!1),contactEmail:i??void 0})]})},JX=({onClose:t})=>S.jsxs("div",{className:"bg-main font-main scrollbar-hide relative flex h-full w-full cursor-auto flex-col overflow-hidden shadow-2xl","data-cy":"element-inspector",children:[S.jsx(IX,{onClose:t}),S.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:S.jsx(lX,{})}),S.jsx("div",{className:"border-main-border bg-main-light flex flex-shrink-0 items-center border-t px-2.5 py-2.5",children:S.jsx(QX,{side:"top",align:"start"})})]});async function eQ(t,e){const{delaysMs:n,shouldRetry:r,onRetry:s}=e;for(let i=1;;i++)try{return await t(i)}catch(o){const l=n[i-1];if(l===void 0||r&&!r(o))throw o;s==null||s(o,i,l),await new Promise(u=>setTimeout(u,l))}}const eC=ps("useServerConfig"),dM=[250,500,1e3,2e3,4e3],tC=dM.length+1,tQ=async()=>{var n;const t=await fetch("/api/health");if(!t.ok)throw new Error(`Failed to fetch config: ${t.status}`);const e=await t.json();if(!e.framework)throw new Error("Server did not return framework information");return{userPort:((n=e.ports)==null?void 0:n.userDevServer)||3e3,framework:e.framework}},nQ=()=>{const[t,e]=g.useState(null),[n,r]=g.useState(!0),[s,i]=g.useState(null),o=g.useCallback(async()=>{try{r(!0),i(null);const l=await eQ(tQ,{delaysMs:dM,onRetry:(u,d,f)=>{eC.warn(`Server config fetch failed (attempt ${d}); retrying in ${f}ms`,u)}});return e(l),l}catch(l){const u=l instanceof Error?l.message:"Failed to fetch server config";throw i(u),eC.warn("Error fetching server config:",l),l}finally{r(!1)}},[]);return{config:t,fetchConfig:o,isLoading:n,error:s}},rQ="#1C1C20",Ki=[118,118,124],nC=.85,sQ=3,iQ=.15,Yp=36,oQ=4.4,aQ=.7,lQ=3.5,cQ=.8,rC=9,uQ=11,dQ=[1.35,1.12,.95,.85],fQ=[0,1.1,2.3,3.1],hQ=[0,.35,.16,.13],pQ=[.9,.5,.4,.35],cl=3,my=[[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.23,level:1},{x1:.14,y1:.28,x2:.3,y2:.87,level:1},{x1:.34,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.155,x2:.225,y2:.205,level:2},{x1:.7,y1:.155,x2:.755,y2:.205,level:2},{x1:.775,y1:.155,x2:.83,y2:.205,level:2},{x1:.165,y1:.32,x2:.275,y2:.375,level:2},{x1:.165,y1:.415,x2:.275,y2:.47,level:2},{x1:.165,y1:.51,x2:.275,y2:.565,level:2},{x1:.37,y1:.32,x2:.585,y2:.56,level:2},{x1:.615,y1:.32,x2:.83,y2:.56,level:2},{x1:.37,y1:.61,x2:.83,y2:.83,level:2},{hline:!0,x1:.39,x2:.81,y:.685,level:3},{hline:!0,x1:.39,x2:.75,y:.755,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.16,y1:.17,x2:.52,y2:.45,level:1},{x1:.58,y1:.17,x2:.685,y2:.29,level:1},{x1:.715,y1:.17,x2:.84,y2:.29,level:1},{x1:.58,y1:.33,x2:.685,y2:.45,level:1},{x1:.715,y1:.33,x2:.84,y2:.45,level:1},{x1:.16,y1:.55,x2:.84,y2:.85,level:1},{x1:.19,y1:.21,x2:.36,y2:.33,level:2},{hline:!0,x1:.19,x2:.48,y:.37,level:3},{hline:!0,x1:.19,x2:.42,y:.42,level:3},{x1:.19,y1:.6,x2:.49,y2:.8,level:2},{hline:!0,x1:.53,x2:.8,y:.63,level:3},{hline:!0,x1:.53,x2:.76,y:.7,level:3},{hline:!0,x1:.53,x2:.79,y:.77,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.14,y1:.13,x2:.86,y2:.22,level:1},{x1:.14,y1:.28,x2:.36,y2:.87,level:1},{x1:.39,y1:.28,x2:.61,y2:.87,level:1},{x1:.64,y1:.28,x2:.86,y2:.87,level:1},{x1:.165,y1:.15,x2:.225,y2:.2,level:2},{x1:.165,y1:.32,x2:.335,y2:.52,level:2},{x1:.415,y1:.32,x2:.585,y2:.52,level:2},{x1:.665,y1:.32,x2:.835,y2:.52,level:2},{hline:!0,x1:.165,x2:.335,y:.6,level:3},{hline:!0,x1:.165,x2:.3,y:.67,level:3},{hline:!0,x1:.415,x2:.585,y:.6,level:3},{hline:!0,x1:.415,x2:.55,y:.67,level:3},{hline:!0,x1:.665,x2:.835,y:.6,level:3},{hline:!0,x1:.665,x2:.8,y:.67,level:3}],[{x1:.1,y1:.08,x2:.9,y2:.92,level:0},{x1:.3,y1:.22,x2:.7,y2:.74,level:1},{x1:.34,y1:.27,x2:.55,y2:.34,level:2},{hline:!0,x1:.36,x2:.64,y:.42,level:3},{hline:!0,x1:.36,x2:.6,y:.49,level:3},{hline:!0,x1:.36,x2:.62,y:.56,level:3},{x1:.5,y1:.63,x2:.575,y2:.69,level:2},{x1:.595,y1:.63,x2:.66,y2:.69,level:2}]],Xp=t=>{let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),e^=e>>>16,(e>>>0)/4294967296},S0=t=>{const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)},ul=(t,e)=>(Math.round(t/e-.5)+.5)*e,mQ=Math.sin(Math.PI/3),sC=(t,e,n,r,s)=>{if(t.beginPath(),e===0)t.arc(n,r,s,0,Math.PI*2);else if(e===1){const i=s*mQ;t.moveTo(n,r-s),t.lineTo(n+i,r+s/2),t.lineTo(n-i,r+s/2),t.closePath()}else{const i=s*.85;t.rect(n-i,r-i,i*2,i*2)}t.fill()},gQ=(t,e,n)=>{let r;if(n.hline){const s=Math.max(n.x1-t,t-n.x2,0),i=Math.abs(e-n.y1);r=Math.hypot(s,i)-rC}else{const s=Math.max(n.x1-t,t-n.x2,0),i=Math.max(n.y1-e,e-n.y2,0);s===0&&i===0?r=-Math.min(t-n.x1,n.x2-t,e-n.y1,n.y2-e):r=Math.hypot(s,i),r=Math.abs(r)-rC}return S0(.5-r/(2*uQ))},fM=({className:t="",trackGlobalLoaderCount:e=!0})=>{const n=dt(BR),r=g.useRef(null),s=g.useCallback(i=>{var N;if((N=r.current)==null||N.call(r),r.current=null,!i)return;const o=i.getContext("2d");if(!o)return;e&&n(j=>j+1);const l=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let u=[],d=0,f=0,p=Yp,m=Yp,v=null,w=null,_=0,x=-1;const b=new Array(33),k=j=>{const V=Math.round(j*32);let Q=b[V];if(!Q){const q=V/32,G=Math.round(Ki[0]+(255-Ki[0])*q),W=Math.round(Ki[1]+(255-Ki[1])*q),Y=Math.round(Ki[2]+(255-Ki[2])*q);Q=`rgba(${G}, ${W}, ${Y}, ${nC})`,b[V]=Q}return Q},C=j=>{const V=1-.35*j,Q=Math.round(Ki[0]*V),q=Math.round(Ki[1]*V),G=Math.round(Ki[2]*V);return`rgba(${Q}, ${q}, ${G}, ${nC})`},T=j=>{let V=Math.floor(Math.random()*my.length);V===x&&(V=(V+1)%my.length),x=V;const Q=[0,0,0,0],q=my[V].map((D,X)=>{const ce=D.level,se=Q[ce]++,re=fQ[ce]+se*hQ[ce],de=pQ[ce]+Xp(V*131+X*17+5)*.2;if(D.hline){const oe=ul((D.y??0)*f,m);return{hline:!0,x1:ul(D.x1*d,p),x2:ul(D.x2*d,p),y1:oe,y2:oe,level:ce,start:re,dur:de}}const _e=ul(D.x1*d,p),fe=ul((D.y1??0)*f,m);return{hline:!1,x1:_e,y1:fe,x2:Math.max(ul(D.x2*d,p),_e+p),y2:Math.max(ul((D.y2??0)*f,m),fe+m),level:ce,start:re,dur:de}}),G=q.reduce((D,X)=>Math.max(D,X.start+X.dur),0),W=u.length,Y=new Float32Array(W*cl),z=new Int16Array(W*cl).fill(-1),ee=new Uint8Array(W),B=q[0];for(let D=0;D<W;D++){const X=u[D];X.x>B.x1&&X.x<B.x2&&X.y>B.y1&&X.y<B.y2&&(ee[D]=1);const ce=D*cl;for(let se=0;se<q.length;se++){const re=gQ(X.x,X.y,q[se]);if(re<=.02)continue;let de=ce;for(let _e=ce;_e<ce+cl;_e++){if(z[_e]===-1){de=_e;break}Y[_e]<Y[de]&&(de=_e)}(z[de]===-1||re>Y[de])&&(Y[de]=re,z[de]=se)}}return{startT:j,buildEnd:G,els:q,frame:B,cellQ:Y,cellEl:z,inFrame:ee}},A=()=>{const j=i.getBoundingClientRect();d=Math.max(1,j.width),f=Math.max(1,j.height);const V=Math.min(2,window.devicePixelRatio||1);i.width=Math.round(d*V),i.height=Math.round(f*V),o.setTransform(V,0,0,V,0,0);const Q=Math.max(8,Math.round(d/Yp)),q=Math.max(6,Math.round(f/Yp));p=d/Q,m=f/q,u=[];for(let G=0;G<q;G++){const W=q>1?G/(q-1):.5,Y=oQ*(1+aQ*.4*(W*2-1));for(let z=0;z<Q;z++){const ee=G*8191+z*131+1,B={x:(z+.5)*p,y:(G+.5)*m,size:Y,seed:ee,phase:Xp(ee),kind:0};B.kind=Math.floor(Xp(ee*97)*3),u.push(B)}}w=null,v=null},M=new Float32Array(32),R=j=>{o.fillStyle=rQ,o.fillRect(0,0,d,f),v||(v=T(j+.2)),j>=v.startT+v.buildEnd+lQ&&(w=v,_=j,v=T(j+.2));let V=0;w&&(V=1-S0((j-_)/cQ),V<=0&&(w=null));const Q=v;for(let B=0;B<Q.els.length;B++){const D=Q.els[B];M[B]=S0(Math.min(1,Math.max(0,(j-Q.startT-D.start)/D.dur)))}const q=M[0],G=C(0),W=C(q),Y=V>0?C(V):G,z=V>0?C(Math.max(q,V)):W,ee=u.length;for(let B=0;B<ee;B++){const D=u[B];let X=0,ce=0;const se=B*cl;for(let Ce=se;Ce<se+cl;Ce++){const Ue=Q.cellEl[Ce];if(Ue<0)break;const rt=Q.cellQ[Ce]*M[Ue];rt>X&&(X=rt,ce=Q.els[Ue].level)}if(w)for(let Ce=se;Ce<se+cl;Ce++){const Ue=w.cellEl[Ce];if(Ue<0)break;const rt=w.cellQ[Ce]*V;rt>X&&(X=rt,ce=w.els[Ue].level)}const re=j/sQ+D.phase,de=Math.floor(re),_e=re-de,fe=S0(Math.min(_e,1-_e)/iQ),oe=Math.floor(Xp(D.seed*97+de*7919)*3);oe!==D.kind&&X<.02&&fe<.05&&(D.kind=oe);const je=Math.max(fe*(1-X),X);if(!(je<.01))if(X<.02){const Ce=Q.inFrame[B]===1,Ue=w?w.inFrame[B]===1:!1;Ce?o.fillStyle=Ue?z:W:o.fillStyle=Ue?Y:G;const rt=Math.max(Ce?q:0,Ue?V:0);sC(o,D.kind,D.x,D.y,D.size*je*(1-.2*rt))}else{o.fillStyle=k(X);const Ce=1+(dQ[ce]-1)*X;sC(o,D.kind,D.x,D.y,D.size*je*Ce)}}};A();let I=0;if(l)v=T(-100),R(0);else{const j=performance.now(),V=Q=>{R((Q-j)/1e3),I=requestAnimationFrame(V)};I=requestAnimationFrame(V)}const L=new ResizeObserver(()=>{A(),l&&(v=T(-100),R(0))});L.observe(i),r.current=()=>{cancelAnimationFrame(I),L.disconnect(),e&&n(j=>j-1)}},[e,n]);return S.jsx("canvas",{ref:s,"aria-hidden":"true",className:`h-full w-full ${t}`.trim()})},vQ=async(t=null)=>{if(t)return yQ(t);let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return Qp();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null};let r;try{r=await e.json()}catch{return Qp()}const s=r.devServerHealth;return s?s.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable",upstreamStatus:null}:s.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable",upstreamStatus:null}:{isOk:!1,unavailableReason:s.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable",upstreamStatus:null}:Qp()},hM=async t=>{try{const e=await fetch(t);return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable",upstreamStatus:e.status}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable",upstreamStatus:null}}},yQ=t=>hM(t),Qp=()=>hM("/"),gy=ps("usePreviewUpstreamHealth"),_Q=500,wQ=4e3,xQ=15e3,bQ=3,SQ=(t,e={})=>{const n=g.useRef(null),r=g.useRef(null),s=e.probeMsWhileDown??_Q,i=e.probeMsWhileUp??wQ,o=e.firstUnreachableCaptureAfterMs??xQ,l=e.rerunProbeImmediatelyOnVersion,u=e.probePath??null,d=e.skip??!1,f=g.useRef(e.onPersistentUpstreamServerErrors);f.current=e.onPersistentUpstreamServerErrors;const[p,m]=g.useState(t==="static"),[v,w]=g.useState(0),[_,x]=g.useState(null),[b,k]=g.useState(0),[C,T]=g.useState(!1),[A,M]=g.useState(!1),[R,I]=g.useState(t==="static"?null:"upstream_unreachable");return g.useEffect(()=>{if(t==="static"){m(!0),x(null),k(0),T(!1),M(!0),I(null);return}if(d){m(!1),x(null),k(0),T(!1),M(!0),I("upstream_unreachable"),n.current=null;return}let L=!0;const N=Date.now();x(N),k(0),T(!1),m(!1),M(!1),I("upstream_unreachable");const j={current:!1},V={current:!1},Q={current:!1},q={current:null},G={current:!1},W={current:!1},Y={current:0},z={current:!1},ee={current:null};let B=null;const D=()=>{Q.current||(Q.current=!0,L&&M(!0))},X=()=>{B!==null&&(clearTimeout(B),B=null)},ce=(re,de)=>{X(),B=setTimeout(de,re)},se=async()=>{var rt;if(!L)return;k(st=>st+1);const{isOk:re,unavailableReason:de,upstreamStatus:_e}=await vQ(u);if(!L)return;D(),ee.current=_e;const fe=re&&_e!==null&&_e>=500;fe&&W.current?Y.current+=1:re&&!fe&&(Y.current=0);const oe=Y.current>=bQ;if(oe&&!z.current&&_e!==null&&(z.current=!0,Ee==null||Ee.capture("preview_upstream_error_responses",{framework:t,upstream_status:_e,consecutive_count:Y.current}),gy.warn(`Preview upstream is listening but has served ${Y.current} consecutive ${_e} responses`),(rt=f.current)==null||rt.call(f,{upstreamStatus:_e,consecutiveCount:Y.current})),re&&!oe){fe||(W.current=!0,z.current=!1);const st=!G.current;G.current=!0,m(!0),I(null),q.current=null,V.current=!1,T(!1),j.current?st&&(Ee==null||Ee.capture("preview_upstream_restored",{framework:t})):(j.current=!0,Ee==null||Ee.capture("preview_dev_server_ready",{framework:t,ready_after_ms:Date.now()-N})),ce(i,se);return}const Ce=G.current;G.current=!1,m(!1),I(de),q.current===null&&(q.current=Date.now(),V.current=!1,T(!1)),Ce&&(Ee==null||Ee.capture("preview_upstream_lost",{framework:t,upstream_status:_e}),w(st=>st+1),gy.warn("Preview upstream became unavailable after it was ready"));const Ue=Date.now()-q.current;Ue>=o&&!V.current&&(V.current=!0,T(!0),Ee==null||Ee.capture("preview_dev_server_unreachable",{framework:t,elapsed_ms:Ue,upstream_status:ee.current}),gy.warn("Dev server did not become ready within timeout window")),ce(s,se)};return n.current=()=>ce(0,se),ce(0,se),()=>{L=!1,n.current=null,X()}},[t,s,i,o,u,d]),g.useEffect(()=>{var N;if(t==="static"||l===void 0)return;const L=r.current;r.current=l,L!==null&&L!==l&&((N=n.current)==null||N.call(n))},[t,l]),{isUpstreamReady:p,iframeRemountKey:v,probeStartedAt:_,probeAttemptCount:b,isFirstUnreachableWindowExceeded:C,initialProbeComplete:A,unavailableReason:R}};function EQ(t){return t.enteringSplit&&t.isExistingSession&&t.hasActiveVariantProxy}const pM=t=>{var e;return t!=="embedded"||typeof window>"u"?"":((e=window.__RIVET_BOOTSTRAP__)==null?void 0:e.previewOrigin)??`${window.location.protocol}//localhost:${window.location.port}`},mM=({agentApplyMode:t,url:e})=>e.startsWith("/")?`${pM(t)}${e}`:e,kQ="allow-scripts allow-same-origin allow-forms allow-popups allow-modals",CQ=t=>kQ,PQ=ps("PreviewSurface"),iC=(t,e)=>t==="about:blank"?"blank":t.includes("/api/variants/")?"static_artifact":e.kind==="variant"?"dev_server":"original",gM=({target:t,src:e,framework:n,remountKey:r})=>(it(Jm),S.jsx("div",{className:"relative h-full w-full",children:S.jsx("iframe",{src:e,className:"h-full w-full border-none",title:"Project Preview",sandbox:CQ(),onLoad:()=>{Ee==null||Ee.capture("preview_iframe_loaded",{framework:n,src:e}),t.kind==="variant"&&(Ee==null||Ee.capture("variants_panel.preview_displayed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:iC(e,t),framework:n}))},onError:()=>{Ee==null||Ee.capture("preview_iframe_load_failed",{framework:n,src:e}),t.kind==="variant"&&(Ee==null||Ee.capture("variants_panel.preview_display_failed",{sessionId:t.sessionId,variantId:t.variantId,renderedTarget:"variant",iframeSrcKind:iC(e,t),framework:n})),PQ.warn("Preview iframe failed to load",{framework:n,src:e})}},r)})),TQ=g.lazy(()=>XC(()=>Promise.resolve().then(()=>cee),void 0)),AQ={surface:"relative flex h-full w-full items-center justify-center bg-main px-6",overlay:"absolute inset-0 z-10 flex items-center justify-center bg-main/90 px-6",page:"relative flex h-screen w-full items-center justify-center bg-main px-6"},IQ={sm:"text-lg font-semibold text-content",md:"text-2xl font-semibold text-content",lg:"text-3xl font-semibold text-content"},RQ={neutral:"rounded-md border border-divider bg-transparent px-5 py-2 text-sm font-medium text-content transition-colors hover:bg-surface-3",ghost:"rounded-md px-5 py-2 text-sm font-medium text-content-muted transition-colors hover:text-content"},tu=({backdrop:t,media:e,title:n,description:r,actions:s,tone:i="neutral",fill:o="surface",size:l="md",children:u,state:d,role:f="status",busy:p=!1,className:m=""})=>{const v=g.useCallback(_=>{_&&d&&(Ee==null||Ee.capture("status_surface_shown",{state:d,tone:i,fill:o}))},[d,i,o]),w=!!(e||n||r||u||s!=null&&s.length);return S.jsxs("div",{ref:v,className:`${AQ[o]} ${m}`.trim(),role:f,"aria-live":"polite","aria-busy":p||void 0,"data-state":d,children:[t?S.jsx("div",{className:"absolute inset-0",children:t}):null,w?S.jsxs("div",{className:"relative z-10 flex max-w-sm flex-col items-center gap-5 text-center",children:[e,n?S.jsx("h2",{className:IQ[l],children:n}):null,r?S.jsx("p",{className:"text-content-muted text-base leading-relaxed",children:r}):null,u,s!=null&&s.length?S.jsx("div",{className:"flex flex-row items-center gap-3",children:s.map(_=>S.jsx("button",{type:"button",onClick:_.onClick,className:RQ[_.variant??"neutral"],children:_.label},_.label))}):null]}):null]})},E2=({loader:t="coalesce",trackGlobalLoaderCount:e,size:n="lg",...r})=>t==="coalesce"?S.jsx(tu,{...r,size:n,busy:!0,backdrop:S.jsx(fM,{trackGlobalLoaderCount:e})}):t==="logo"?S.jsx(tu,{...r,size:n,busy:!0,backdrop:S.jsx(g.Suspense,{fallback:null,children:S.jsx(TQ,{className:"absolute inset-0"})})}):S.jsx(tu,{...r,size:n,busy:!0,media:S.jsx(Xm,{"aria-hidden":!0,className:"text-content h-8 w-8 shrink-0 animate-spin",weight:"bold"})}),vM=({icon:t,...e})=>S.jsx(tu,{...e,tone:"neutral",media:t?S.jsx("div",{className:"text-content-muted",children:t}):void 0}),$x=t=>S.jsx(tu,{...t,tone:"error",role:"alert"}),oC="/static/",MQ=t=>{try{return new URL(t,"http://localhost").pathname.endsWith(oC)}catch{return t.endsWith(oC)}},OQ=t=>t==="spawn_error"?"The direction is saved, but its preview process didn’t start.":t==="exited"?"The direction is saved, but its preview stopped before it was ready.":t==="timeout"?"The direction is saved, but its preview took too long to become ready.":t==="missing_dev_script"?"The direction is saved, but Rivet couldn’t find a dev script to preview it.":t==="missing_static_entry"?"The direction is saved, but Rivet couldn’t find an HTML entry to preview it.":"The direction is saved, but Rivet couldn’t prepare its preview.",LQ=t=>t.status==="failed"&&t.errorCode==="VARIANT_VERIFICATION_UNAVAILABLE"?{state:"variant_verification_unavailable",title:"Rivet couldn’t verify this direction",description:"The worker completed, but Rivet couldn’t inspect its generated files.",detail:t.errorMessage??t.errorCode,isError:!0}:t.status==="failed"&&t.errorCode==="VARIANT_QA_FAILED"?{state:"variant_output_integrity_failed",title:"This direction couldn’t be verified",description:"The worker completed, but Rivet found a structural problem in the generated files.",detail:t.errorMessage??t.errorCode,isError:!0}:t.status==="failed"?{state:"variant_worker_failed",title:"This direction didn’t complete",description:"The worker stopped before producing a usable result.",detail:t.errorMessage??t.errorCode,isError:!0}:t.status==="cancelled"?{state:"variant_cancelled",title:"Direction was cancelled",description:"Rivet stopped before a preview was ready. Your other directions are unchanged.",isError:!1}:t.status==="succeeded"&&t.previewUnavailable&&t.previewUnavailable.reason!=="idle_timeout"?{state:"preview_unavailable",title:"Rivet couldn’t preview this direction",description:OQ(t.previewUnavailable.reason),detail:t.previewUnavailable.portInUse?"The preview port was already in use.":void 0,isError:!0}:null,DQ=({issue:t})=>S.jsx(tu,{fill:"overlay",size:"sm",state:t.state,role:t.isError?"alert":"status",tone:t.isError?"error":"neutral",title:t.title,description:t.description,children:t.detail?S.jsx("p",{className:"text-content-subtle text-xs leading-relaxed break-words",children:t.detail}):null}),NQ=({isInteractionDisabled:t=!1,framework:e,userPort:n})=>{const r=it(p2),s=dt(p2),i=it(ym),o=dt(ym),l=it(hh),u=it(Jm),d=it(m2),f=it(g2),p=it(UR),m=it(WR),v=dt(g2),w=it(yo),_=it(y2),x=dt(m2),b=l.active&&l.projectContext.kind==="fresh",k=it(v2),C=l.active?l.variants.find(De=>De.workItemId===k&&(De.status==="pending"||De.status==="running"||De.status==="succeeded"&&!De.preview&&typeof De.port!="number"&&(!De.previewUnavailable||De.previewUnavailable.reason==="idle_timeout")))??null:null,T=l.active&&l.variants.some(De=>De.status==="pending"||De.status==="running"),A=b||T,M=l.active?l.variants.find(De=>De.workItemId===k)??null:null,R=M?LQ(M):null,I=e==="static"&&i!==null&&MQ(i);g.useEffect(()=>{l.active||x(!1)},[l.active,x]);const L=g.useRef(!1);g.useEffect(()=>{const De=!!(w!=null&&w.left||w!=null&&w.right),Je=De&&!L.current;L.current=De;const ut=l.active?l.sessionId:null;!ut||!EQ({enteringSplit:Je,isExistingSession:l.active&&l.projectContext.kind==="existing",hasActiveVariantProxy:d&&f!==null})||(x(!1),v(null),s(Pt=>Pt+1),fetch(`/api/variants/${encodeURIComponent(ut)}/preview-port`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({variantId:null})}).catch(()=>{}))},[w,l,d,f,x,v,s]);const j=g.useMemo(()=>{var He;if(d||i&&!I||!l.active)return null;const{stage:De,variants:Je}=l,ut=De==="ready"||De==="degraded",Pt=Je.some(St=>{var pt,ke;return((pt=St.refinement)==null?void 0:pt.status)==="pending"||((ke=St.refinement)==null?void 0:ke.status)==="running"});if(!ut&&!Pt)return null;const be=Je.find(St=>{var pt;return St.status==="succeeded"&&((pt=St.preview)==null?void 0:pt.kind)==="static_artifact"});return((He=be==null?void 0:be.preview)==null?void 0:He.kind)==="static_artifact"?be.preview.url:null},[I,i,d,l])??i,V=g.useMemo(()=>!l.active||!j?null:l.variants.find(De=>{var Je;return((Je=De.preview)==null?void 0:Je.kind)==="static_artifact"&&j.startsWith(De.preview.url)})??null,[j,l]),Q=g.useMemo(()=>{if((_==null?void 0:_.previewKind)==="static")return{kind:"variant",sessionId:_.sessionId,variantId:_.variantId};if(!l.active)return vm;if(V)return{kind:"variant",sessionId:l.sessionId,variantId:V.workItemId};if(j){const Je=j.match(/\/__rivet\/preview\/variant\/([^/]+)\/([^/?#]+)/),ut=Je!=null&&Je[1]?decodeURIComponent(Je[1]):null,Pt=Je!=null&&Je[2]?decodeURIComponent(Je[2]):null;if(ut===l.sessionId&&Pt&&l.variants.some(St=>St.workItemId===Pt))return{kind:"variant",sessionId:l.sessionId,variantId:Pt};const be=j.match(/\/api\/variants\/[^/]+\/static\/([^/?#]+)/),He=be!=null&&be[1]?decodeURIComponent(be[1]):null;if(He&&l.variants.some(St=>St.workItemId===He))return{kind:"variant",sessionId:l.sessionId,variantId:He}}const De=!!(w!=null&&w.left||w!=null&&w.right);return(!De||b)&&!j&&d&&f&&l.variants.some(Je=>Je.workItemId===f)?{kind:"variant",sessionId:l.sessionId,variantId:f}:(!De||b)&&!j&&k&&l.variants.some(Je=>Je.workItemId===k)?{kind:"variant",sessionId:l.sessionId,variantId:k}:vm},[_,V,l,d,f,j,w,b,k]),q=g.useRef(null);g.useEffect(()=>{var Pt,be;if(!V||((Pt=V.preview)==null?void 0:Pt.kind)!=="static_artifact"||((be=V.refinement)==null?void 0:be.status)!=="succeeded")return;const De=`${V.workItemId}:${V.refinement.workItemId}`;if(q.current===De)return;q.current=De;const Je=V.preview.url.includes("?")?"&":"?",ut=`${V.preview.url}${Je}refinement=${encodeURIComponent(V.refinement.workItemId)}`;j!==ut&&(o(ut),s(He=>He+1))},[j,V,s,o,l]);const G=j!==null&&JY(j),W=j!==null&&!G||b&&!d&&!G,{isUpstreamReady:Y,iframeRemountKey:z,probeAttemptCount:ee,initialProbeComplete:B}=SQ(e,{rerunProbeImmediatelyOnVersion:r,probePath:G?j:null,skip:W}),[D,X]=g.useState(()=>p&&Y?r:null),ce=g.useRef(null);g.useEffect(()=>{if(!p){ce.current=null,X(null);return}if(D===r){ce.current=null;return}const De=ce.current;if(!De||De.remountKey!==r){ce.current={remountKey:r,probeAttemptCount:ee};return}Y&&ee>De.probeAttemptCount&&(ce.current=null,X(r))},[D,r,p,ee,Y]);const re=j!==null&&!G||Y,_e=m||p&&D!==r||p&&!re,fe=`${z}:${r}`,oe=XR(window.location.pathname),je=e==="static"?`/static${oe??"/"}`:oe??"/",Ce=pM(u);let Ue=null;j&&(Ue=mM({agentApplyMode:u,url:j}));const st=C||R||_e?"about:blank":(G&&!re?"about:blank":Ue)??(re?`${Ce}${je}`:"about:blank"),It=!!C||!!R||!re&&B;let ft=null;return _e?ft=S.jsx(E2,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"preview_replay_boot"}):C?ft=S.jsx(E2,{fill:"overlay",loader:"coalesce",trackGlobalLoaderCount:!1,state:"variant_building",children:S.jsx("span",{className:"sr-only",children:"Building your direction"})}):R?ft=S.jsx(DQ,{issue:R}):It&&(ft=A?S.jsx(vM,{fill:"overlay",state:"preview_no_selection",title:"Nothing to preview yet",description:"Pick a direction from the panel."}):S.jsx($x,{fill:"overlay",state:"preview_offline",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>window.location.reload()}]})),S.jsxs("div",{className:"relative h-full w-full",children:[ft,S.jsx(gM,{target:Q,src:st,framework:e,remountKey:fe})]})};function aC({side:t,sessionId:e,variantId:n,url:r,label:s,source:i,isFallback:o=!1}){var C;const l=it(yo),u=dt(yo),d=Zl(),f=it(hh),p=it(Jm),m=g.useRef(!1),v=g.useCallback(()=>{m.current||(m.current=!0,Pu({source:i,sessionId:e,variantId:n}))},[i,e,n]),w=g.useCallback(()=>{if(o){u(null);const R=_m("ended",l);d==null||d.capture(R.event,R.properties);return}v();const T={...l};delete T[t];const A=T.left||T.right?T:null;u(A);const M=_m(A?"updated":"ended",A??l);d==null||d.capture(M.event,M.properties)},[o,d,u,t,l,v]),_=g.useMemo(()=>({kind:"variant",sessionId:e,variantId:n}),[e,n]),x=g.useMemo(()=>!f.active||f.sessionId!==e?null:f.variants.find(T=>T.workItemId===n)??null,[e,n,f]),b=g.useMemo(()=>{var A,M;let T=r;if(((A=x==null?void 0:x.preview)==null?void 0:A.kind)==="static_artifact"&&((M=x.refinement)==null?void 0:M.status)==="succeeded"){const R=x.preview.url.includes("?")?"&":"?";T=`${x.preview.url}${R}refinement=${encodeURIComponent(x.refinement.workItemId)}`}return mM({agentApplyMode:p,url:T})},[p,x,r]),k=((C=x==null?void 0:x.refinement)==null?void 0:C.status)==="succeeded"?`${n}:${x.refinement.workItemId}`:n;return S.jsxs("div",{className:"variant-split-secondary","data-cy":"variant-split-pane","data-variant-id":n,children:[S.jsxs("div",{className:"variant-split-secondary-toolbar",children:[S.jsx("span",{className:"variant-split-secondary-label",title:s,children:s}),S.jsx(Ul,{label:"Collapse",children:S.jsx("button",{type:"button",className:"variant-split-secondary-close",onClick:w,"aria-label":"Collapse split view",children:S.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",focusable:"false",children:S.jsx("path",{d:"M2.5 2.5 L9.5 9.5 M9.5 2.5 L2.5 9.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})})]}),S.jsx("div",{className:"variant-split-secondary-body relative min-h-0 flex-1",children:S.jsx(gM,{target:_,src:b,framework:"static",remountKey:k})})]})}function $Q(){const t=it(Cu),e=it(Ox);return!t||!e?null:ch.createPortal(S.jsx("div",{"aria-hidden":"true",className:"border-main-border bg-main pointer-events-none fixed top-0 left-0 z-[70] flex max-w-60 items-center gap-2 rounded-md border px-3 py-1.5 shadow-lg",style:{transform:`translate3d(${e.x+12}px, ${e.y+12}px, 0)`},children:S.jsx("span",{className:"text-content truncate text-sm font-medium",children:t.label})}),document.body)}function jQ(){const t=it(Cu),e=it(Ox),n=it(yo),r=dt(Cu),s=dt(yo),i=Zl(),o=g.useRef(null),[l,u]=g.useState(null),[d,f]=g.useState("hidden");g.useEffect(()=>{t||(f("hidden"),u(null))},[t]);const p=g.useCallback((v,w)=>{const _=o.current;if(!_)return null;const x=_.getBoundingClientRect();return v<x.left||v>x.right||w<x.top||w>x.bottom?null:v<(x.left+x.right)/2?"left":"right"},[]);if(g.useEffect(()=>{if(!t||!e)return;const v=p(e.x,e.y);u(w=>w===v?w:v),f(w=>{if(w==="exiting")return w;const _=v!==null?"visible":"hidden";return w===_?w:_})},[t,e,p]),g.useEffect(()=>{if(!t)return;const v=w=>{const _=p(w.clientX,w.clientY);if(_&&t.url){const x={sessionId:t.sessionId,variantId:t.variantId,label:t.label,url:t.url,source:t.source},b=n==null?void 0:n[_];b&&(b.sessionId!==x.sessionId||b.variantId!==x.variantId)&&Pu(b);const k={...n??{},[_]:x};s(k);const C=_m(n?"updated":"started",k);i==null||i.capture(C.event,C.properties),f("exiting"),window.setTimeout(()=>r(null),220)}else Pu(t),f("exiting"),window.setTimeout(()=>r(null),220)};return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)}},[t,p,i,r,s,n]),!t)return null;const m=["variant-drop-zones",d==="visible"&&"is-visible",d==="exiting"&&"is-exiting"].filter(Boolean).join(" ");return S.jsxs("div",{ref:o,className:m,"aria-hidden":"true",children:[S.jsx(lC,{side:"left",hovered:l==="left",canDrop:!!t.url,label:t.label}),S.jsx(lC,{side:"right",hovered:l==="right",canDrop:!!t.url,label:t.label})]})}function lC({side:t,hovered:e,canDrop:n,label:r}){return S.jsxs("div",{className:["variant-drop-zone",`is-${t}`,e&&"is-hover",!n&&"is-disabled"].filter(Boolean).join(" "),children:[S.jsxs("div",{className:"variant-drop-zone-inner",children:[S.jsx("div",{className:`variant-drop-zone-icon is-${t}`}),S.jsx("div",{className:"variant-drop-zone-caption",children:n?`Add ${t} split`:"Split unavailable for this direction"})]}),S.jsx("div",{className:"variant-drop-zone-preview","aria-hidden":"true",children:S.jsx("div",{className:"variant-drop-zone-preview-label",children:r})}),S.jsx("div",{className:"variant-drop-zone-border"})]})}const yM=(t,e,n)=>{var i,o;if(!t.active||t.sessionId!==e)return null;const r=t.variants.find(l=>l.workItemId===n);if(((i=r==null?void 0:r.preview)==null?void 0:i.kind)!=="static_artifact")return null;if(((o=r.refinement)==null?void 0:o.status)!=="succeeded")return r.preview.url;const s=r.preview.url.includes("?")?"&":"?";return`${r.preview.url}${s}refinement=${encodeURIComponent(r.refinement.workItemId)}`},cC=(t,e)=>{if(!t)return;const n=yM(e,t.sessionId,t.variantId);return!n||n===t.url?t:{...t,url:n}},FQ=()=>S.jsx("div",{"data-testid":"preview-boot-skeleton",role:"status","aria-busy":"true","aria-label":"Loading preview",className:"bg-main flex h-full min-h-0 w-full flex-1 flex-col p-3",children:S.jsx("div",{className:"border-main-border relative min-h-0 flex-1 overflow-hidden rounded-lg border",children:S.jsx(fM,{trackGlobalLoaderCount:!1})})}),VQ=({isLoading:t=!1,isInteractionDisabled:e=!1})=>{const{config:n,fetchConfig:r,isLoading:s,error:i}=nQ();return g.useEffect(()=>{r().catch(o=>{Ee==null||Ee.capture("preview_config_load_failed",{message:o instanceof Error?o.message:"unknown_error",attempts:tC})})},[r]),s?S.jsx(FQ,{}):i||!n?S.jsx($x,{fill:"surface",size:"sm",state:"preview_config_error",title:"Couldn't load preview",description:"We couldn't load the preview configuration.",actions:[{label:"Retry",onClick:()=>{Ee==null||Ee.capture("preview_config_retry_clicked"),r().catch(o=>{Ee==null||Ee.capture("preview_config_load_failed",{message:o instanceof Error?o.message:"unknown_error",attempts:tC})})}}]}):S.jsx(HQ,{isLoading:t,isInteractionDisabled:e,framework:n.framework,userPort:n.userPort})};function HQ(t){const e=it(yo),n=it(Cu),r=it(hh),s=it(ym),i=e==null?void 0:e.left,o=e==null?void 0:e.right,l=g.useMemo(()=>{var A,M;if(!r.active||r.projectContext.kind!=="fresh"||!(!!i!=!!o))return;const _=(A=i??o)==null?void 0:A.variantId,x=r.variants.filter(R=>{var I;return R.status==="succeeded"&&((I=R.preview)==null?void 0:I.kind)==="static_artifact"&&R.workItemId!==_}),b=s==null?void 0:s.replace(/[?&]refinement=[^&]*$/,""),C=x.find(R=>{var I;return((I=R.preview)==null?void 0:I.kind)==="static_artifact"&&R.preview.url===b})??x[0];if(((M=C==null?void 0:C.preview)==null?void 0:M.kind)!=="static_artifact")return;const T=yM(r,r.sessionId,C.workItemId);if(T)return{sessionId:r.sessionId,variantId:C.workItemId,label:C.label,url:T,source:"live"}},[r,i,o,s]),u=cC(i,r)??(o?l:void 0),d=cC(o,r)??(i?l:void 0),f=!i&&!!u,p=!o&&!!d,m=!!(u||d),v=S.jsx(NQ,{isInteractionDisabled:t.isInteractionDisabled,framework:t.framework,userPort:t.userPort});return S.jsx("div",{className:"relative flex h-full min-h-0 w-full flex-1 flex-col",children:S.jsxs("div",{className:`variant-preview-region relative flex h-full min-h-0 w-full flex-1 flex-col ${n?"is-dragging":""} ${m?"is-split":""}`,children:[S.jsxs("div",{className:"variant-preview-row flex h-full min-h-0 w-full flex-1",children:[u&&S.jsx(aC,{side:"left",sessionId:u.sessionId,variantId:u.variantId,url:u.url,label:u.label,source:u.source,isFallback:f},`left-${u.sessionId}:${u.variantId}:${u.url}`),!(u&&d)&&S.jsx("div",{className:"variant-preview-primary flex h-full min-h-0 flex-1 flex-col",children:v}),d&&S.jsx(aC,{side:"right",sessionId:d.sessionId,variantId:d.variantId,url:d.url,label:d.label,source:d.source,isFallback:p},`right-${d.sessionId}:${d.variantId}:${d.url}`)]}),S.jsx("div",{className:"variant-preview-atmosphere","aria-hidden":"true"}),S.jsx(jQ,{}),S.jsx($Q,{})]})})}function no(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _M(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}/*!
|
|
145
145
|
* GSAP 3.15.0
|
|
146
146
|
* https://gsap.com
|
|
147
147
|
*
|
|
@@ -435,4 +435,4 @@ ${s}`:s},pX=({groups:t,pinned:e,pinnedKeys:n,draggedRowKey:r,onDropPin:s,onDropU
|
|
|
435
435
|
*
|
|
436
436
|
* This source code is licensed under the ISC license.
|
|
437
437
|
* See the LICENSE file in the root directory of this source tree.
|
|
438
|
-
*/const vL={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};vL.node;const Pne=Qe(vL),Tne={"chevron-right":Bte,"chevron-down":zte,pipette:fne,x:Pne,copy:Zte,menu:sne,dot:qte,monitor:one,sun:Ene,moon:ane,"rectangle-horizontal":mne,circle:Ute,"square-library":bne,clock:Wte,star:Sne,settings:_ne,plus:pne,"arrow-left":Nte,"arrow-right":$te,"arrow-up":jte,search:yne,loader:tne,users:Cne,lock:nne,mail:rne,bell:Fte,shield:wne,palette:cne,lightbulb:Jte,rocket:gne,heart:Kte,paintbrush:lne,brain:Vte,globe:Gte,user:kne,image:Xte,link:ene,check:Hte,"rotate-ccw":vne,play:hne,pause:une,home:Yte,"message-circle":ine,inbox:Qte,pencil:dne,"skip-forward":xne},DC={lucide:Tne},yL=g.createContext(null);function Ane(t){const e=g.useContext(yL);return e?DC[e.iconLibrary][t]:DC.lucide[t]}function Ine({children:t,defaultLibrary:e="lucide"}){const[n,r]=g.useState(e),s=g.useCallback(i=>{r(i)},[]);return S.jsx(yL.Provider,{value:{iconLibrary:n,setIconLibrary:s},children:t})}const _L=g.createContext(null);function fb(){return g.useContext(_L)}const wL=g.createContext(null);function xL(){const t=g.useContext(wL);if(!t)throw new Error("AccordionTrigger/AccordionContent must be used within an AccordionItem");return t}const Rne=g.forwardRef((t,e)=>{const{children:n,type:r="single",className:s,...i}=t,o=g.useRef(null),l=g.useRef(new Map),[u,d]=g.useState(new Map),{activeIndex:f,setActiveIndex:p,itemRects:m,sessionRef:v,handlers:w,registerItem:_,measureItems:x}=LR(o),b=g.useCallback((fe,oe)=>{oe?l.current.set(fe,oe):l.current.delete(fe)},[]),k=g.useCallback(()=>{if(!o.current)return;const fe=new Map;l.current.forEach((oe,je)=>{fe.set(je,{top:oe.offsetTop,left:oe.offsetLeft,width:oe.offsetWidth,height:oe.offsetHeight})}),d(fe)},[]),[C,T]=g.useState(()=>r==="single"?t.defaultValue??"":""),[A,M]=g.useState(()=>r==="multiple"?t.defaultValue??[]:[]),R=t.onValueChange,I=t.onValueChange,L=t.value,N=new Set(r==="multiple"?t.value??A:(()=>{const fe=t.value??C;return fe?[fe]:[]})()),j=g.useCallback(fe=>{const oe=t;oe.onValueChange?oe.onValueChange(fe):T(fe)},[R]),V=g.useCallback(fe=>{const oe=t;oe.onValueChange?oe.onValueChange(fe):M(fe)},[I]),Q=g.useCallback(fe=>{if(r==="multiple"){const oe=t.value??A;V(oe.filter(je=>je!==fe))}else j("")},[r,j,V,A,L]);g.useEffect(()=>{x(),k()},[x,k,n]);const q=[...N].join(",");g.useEffect(()=>{x(),k()},[x,k,q]);const[G,W]=g.useState(null),Y=f!==null?m[f]:null,z=G!==null?m[G]:null,ee=f!==null&&!u.has(f),B=uh(),{value:D,defaultValue:X,onValueChange:ce,collapsible:se,type:re,...de}=i,_e=r==="multiple"?{type:"multiple",value:t.value??A,onValueChange:V}:{type:"single",collapsible:t.collapsible??!0,value:t.value??C,onValueChange:j};return S.jsx(_L.Provider,{value:{registerItem:_,registerFullItem:b,activeIndex:f,grouped:!0,remeasure:()=>{x(),k()},openValues:N,openItemRects:u,toggleValue:Q},children:S.jsx(kO,{..._e,asChild:!0,children:S.jsxs("div",{ref:fe=>{o.current=fe,typeof e=="function"?e(fe):e&&(e.current=fe)},onMouseEnter:w.onMouseEnter,onMouseMove:fe=>{const oe=o.current;if(oe){const je=oe.getBoundingClientRect(),Ce=oe.offsetHeight,Ue=je.height,rt=Ce>0?Ue/Ce:1,st=(fe.clientY-je.top)/rt+oe.scrollTop;for(const[It,ft]of u){const De=m[It];if(!De)continue;const Je=De.top+De.height,ut=ft.top+ft.height;if(st>=Je&&st<=ut){p(null);return}}}w.onMouseMove(fe)},onMouseLeave:w.onMouseLeave,onFocus:fe=>{var je;const oe=(je=fe.target.closest("[data-proximity-index]"))==null?void 0:je.getAttribute("data-proximity-index");if(oe!=null){const Ce=Number(oe);p(Ce),W(fe.target.matches(":focus-visible")?Ce:null)}},onBlur:fe=>{var oe;(oe=o.current)!=null&&oe.contains(fe.relatedTarget)||(W(null),p(null))},className:mn("relative flex flex-col gap-0.5 w-72 max-w-full",s),...de,children:[S.jsx(cs,{children:[...u.entries()].map(([fe,oe])=>S.jsx(fo.div,{className:`absolute ${B.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:!1,animate:{top:oe.top,left:oe.left,width:oe.width,height:oe.height,opacity:ee?.7:1},exit:{opacity:0,transition:{duration:.12}},transition:{top:{duration:0},left:{duration:0},width:{duration:0},height:{duration:0},opacity:{duration:.08}}},`expanded-${fe}`))}),S.jsx(cs,{children:Y&&S.jsx(fo.div,{className:`absolute ${B.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:Y.top,left:Y.left,width:Y.width,height:Y.height},animate:{opacity:1,top:Y.top,left:Y.left,width:Y.width,height:Y.height},exit:{opacity:0,transition:{duration:.06}},transition:{...jf.fast,opacity:{duration:.08}}},v.current)}),S.jsx(cs,{children:z&&S.jsx(fo.div,{className:`absolute ${B.focusRing} pointer-events-none z-20 border border-[#6B97FF]`,initial:!1,animate:{left:z.left-2,top:z.top-2,width:z.width+4,height:z.height+4},exit:{opacity:0,transition:{duration:.06}},transition:{...jf.fast,opacity:{duration:.08}}})}),n]})})})});Rne.displayName="AccordionGroup";const bL=g.forwardRef(({children:t,type:e="single",collapsible:n=!0,defaultValue:r,value:s,onValueChange:i,className:o,...l},u)=>{const[d,f]=g.useState(()=>e==="single"?r??"":""),[p,m]=g.useState(()=>e==="multiple"?r??[]:[]),v=new Set(e==="multiple"?s??p:(()=>{const k=s??d;return k?[k]:[]})()),w=g.useCallback(k=>{i?i(k):f(k)},[i]),_=g.useCallback(k=>{i?i(k):m(k)},[i]),x=g.useCallback(k=>{e==="multiple"?_((s??p).filter(T=>T!==k)):w("")},[e,s,p,w,_]),b=e==="multiple"?{type:"multiple",value:s??p,defaultValue:r,onValueChange:_}:{type:"single",collapsible:n,value:s??d,defaultValue:r,onValueChange:w};return S.jsx(kO,{...b,asChild:!0,children:S.jsx("div",{ref:u,className:mn("w-72 max-w-full flex flex-col gap-0.5",o),...l,children:S.jsx(SL.Provider,{value:v,children:S.jsx(EL.Provider,{value:x,children:t})})})})});bL.displayName="Accordion";const SL=g.createContext(new Set),EL=g.createContext(()=>{}),kL=g.forwardRef(({value:t,index:e,disabled:n,children:r,className:s,...i},o)=>{const l=g.useRef(null),u=fb(),d=g.useContext(SL),f=g.useContext(EL),p=uh(),m=u!=null&&u.grouped?u.openValues.has(t):d.has(t),v=g.useRef(null),w=g.useCallback(()=>{u!=null&&u.grouped?u.toggleValue(t):f(t)},[u,f,t]);return g.useEffect(()=>{if(u!=null&&u.grouped&&e!==void 0)return u.registerItem(e,v.current),()=>u.registerItem(e,null)},[e,u]),g.useEffect(()=>{if(u!=null&&u.grouped&&e!==void 0)return m?u.registerFullItem(e,l.current):u.registerFullItem(e,null),()=>u.registerFullItem(e,null)},[e,u,m]),S.jsx(wL.Provider,{value:{index:e,value:t,isOpen:m,onToggle:w,triggerRef:v},children:S.jsxs(bte,{ref:_=>{l.current=_,typeof o=="function"?o(_):o&&(o.current=_)},value:t,disabled:n,"data-proximity-index":e,className:mn(!(u!=null&&u.grouped)&&"relative",s),...i,children:[!(u!=null&&u.grouped)&&S.jsx(cs,{children:m&&S.jsx(fo.div,{className:`absolute inset-0 ${p.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),r]})})});kL.displayName="AccordionItem";const CL=g.forwardRef(({children:t,className:e,...n},r)=>{const s=Ane("chevron-right"),i=fb(),{index:o,isOpen:l,triggerRef:u}=xL(),d=uh(),[f,p]=g.useState(!1),m=i!=null&&i.grouped?i.activeIndex===o:f,v=S.jsx(Ste,{asChild:!0,children:S.jsx("div",{children:S.jsxs(Ete,{ref:r,className:mn(`relative z-10 flex items-center gap-2.5 ${d.item} px-3 py-2 w-full cursor-pointer outline-none select-none`,!(i!=null&&i.grouped)&&"focus-visible:ring-1 focus-visible:ring-[#6B97FF] focus-visible:ring-offset-0",e),...n,children:[S.jsxs("span",{className:"inline-grid text-[13px] flex-1 text-left",children:[S.jsx("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:ff.semibold},"aria-hidden":"true",children:t}),S.jsx("span",{className:mn("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80",l||m?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:l?ff.semibold:ff.normal},children:t})]}),S.jsx(fo.span,{className:"shrink-0 inline-flex items-center justify-center",animate:{rotate:l?90:0},transition:jf.fast,children:S.jsx(s,{size:16,strokeWidth:l||m?2:1.5,className:mn("transition-[color,stroke-width] duration-80",l||m?"text-foreground":"text-muted-foreground")})})]})})});return i!=null&&i.grouped?S.jsx("div",{ref:u,children:v}):S.jsxs("div",{className:"relative",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[S.jsx(cs,{children:f&&S.jsx(fo.div,{className:`absolute inset-0 ${d.bg} bg-hover pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),v]})});CL.displayName="AccordionTrigger";const PL=g.forwardRef(({children:t,className:e,...n},r)=>{const s=fb(),{isOpen:i}=xL();return S.jsx(cs,{initial:!1,children:i&&S.jsx(kte,{forceMount:!0,asChild:!0,...n,children:S.jsx(fo.div,{ref:r,className:mn("overflow-hidden",e),initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{...jf.moderate,bounce:0},onUpdate:()=>{s==null||s.remeasure()},onAnimationComplete:()=>{s==null||s.remeasure()},children:S.jsx("div",{className:"px-3 pb-3 pt-1 text-[13px] text-muted-foreground",children:t})})})})});PL.displayName="AccordionContent";const A0=({children:t,defaultValue:e=[],className:n=""})=>S.jsx(bL,{type:"multiple",defaultValue:e,className:mn("w-full",n),children:t}),Mne=({value:t,title:e,description:n,dataCy:r,icon:s,children:i,className:o=""})=>{const l=o.includes("first-item");return S.jsxs(kL,{value:t,className:mn("w-full",!l&&"border-t border-main-border"),children:[S.jsxs(CL,{"data-cy":r,children:[s?S.jsx("span",{className:"mr-1 inline-flex items-center",children:s}):null,e]}),S.jsxs(PL,{children:[n?S.jsx("p",{className:"pb-2 text-sm text-content-subtle",children:n}):null,i]})]})};A0.Item=Mne;const One=({message:t,isLoading:e=!0})=>S.jsxs("div",{className:"flex items-center gap-2 text-sm text-content",children:[e?S.jsx(Xm,{className:"h-4 w-4 shrink-0 animate-spin text-primary",weight:"bold"}):null,S.jsx("span",{className:"whitespace-pre-wrap font-sans",children:t})]}),Lne=()=>{const t=g.useRef(Date.now()),[e,n]=g.useState(0);return g.useEffect(()=>{const r=()=>n(Math.max(0,Math.floor((Date.now()-t.current)/1e3)));r();const s=setInterval(r,1e3);return()=>clearInterval(s)},[]),e},Dne=t=>{const e=Math.floor(t/60),n=t%60;return`${e}:${n.toString().padStart(2,"0")}`},NC="M 12 8 C 14.21 8 16 9.79 16 12 C 16 14.21 14.21 16 12 16 C 9.79 16 8 14.21 8 12 C 8 9.79 9.79 8 12 8 Z",$C="M 12 12 C 14 8.5 19 8.5 19 12 C 19 15.5 14 15.5 12 12 C 10 8.5 5 8.5 5 12 C 5 15.5 10 15.5 12 12 Z",Nne="M 12 16 C 14.21 16 16 14.21 16 12 C 16 9.79 14.21 8 12 8 C 9.79 8 8 9.79 8 12 C 8 14.21 9.79 16 12 16 Z",I0=["Applying","Thinking","Planning","Crafting"],$ne=I0.reduce((t,e)=>t.length>=e.length?t:e),jne=20,Fne="Still working — runs can take a few minutes.",Vne=({hint:t,showElapsed:e=!0})=>{const[n,r]=g.useState(0),s=Lne();g.useEffect(()=>{const o=setInterval(()=>{r(l=>(l+1)%I0.length)},4e3);return()=>clearInterval(o)},[]);const i=t??(e&&s>=jne?Fne:null);return S.jsxs("div",{role:"status",className:"flex items-center gap-2 px-3 py-1","data-cy":"thinking-indicator",children:[S.jsx(ei.svg,{"aria-hidden":!0,width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-muted-foreground",children:S.jsx(ei.path,{animate:{d:[NC,$C,Nne,$C,NC]},transition:{d:{duration:6,ease:"easeInOut",repeat:1/0,times:[0,.25,.5,.75,1]}}})}),S.jsxs("span",{className:"inline-grid overflow-hidden text-sm font-medium",style:{fontVariationSettings:ff.medium},children:[S.jsx("span",{className:"shimmer-text invisible col-start-1 row-start-1","aria-hidden":"true",children:$ne}),S.jsx(cs,{mode:"popLayout",initial:!1,children:S.jsx(ei.span,{className:"shimmer-text col-start-1 row-start-1",initial:{y:"80%",opacity:0},animate:{y:0,opacity:1,transition:{duration:.24,ease:[.4,0,.2,1]}},exit:{y:"-80%",opacity:0,transition:{duration:.16,ease:[.4,0,.2,1]}},children:I0[n]},I0[n])})]}),e?S.jsx("span",{className:"text-xs tabular-nums text-content-subtle","data-cy":"thinking-elapsed",children:Dne(s)}):null,i?S.jsx("span",{className:"text-xs text-content-subtle",children:i}):null]})};var Hne=Object.defineProperty,zne=(t,e)=>Hne(t,"name",{value:e,configurable:!0});function hb(t,[e,n]){return Math.min(n,Math.max(e,t))}zne(hb,"clamp");var Bne=Object.defineProperty,Une=(t,e)=>Bne(t,"name",{value:e,configurable:!0});function TL(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}Une(TL,"usePrevious");var Wne=Object.defineProperty,kt=(t,e)=>Wne(t,"name",{value:e,configurable:!0}),AL=["PageUp","PageDown"],IL=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],RL={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gh="Slider",[B2,Zne,qne]=rb(gh),[pb,$re]=Di(gh,[qne]),[Gne,vh]=pb(gh),Kne=g.forwardRef(kt(function(e,n){const{name:r,min:s=0,max:i=100,step:o=1,orientation:l="horizontal",disabled:u=!1,minStepsBetweenThumbs:d=0,defaultValue:f=[s],value:p,onValueChange:m=kt(()=>{},"onValueChange"),onValueCommit:v=kt(()=>{},"onValueCommit"),inverted:w=!1,form:_,...x}=e,b=g.useRef(new Set),k=g.useRef(0),C=g.useRef(!1),A=l==="horizontal"?Yne:Xne,[M,R]=g.useState(null),I=qt(n,R),[L=[],N]=Da({prop:p,defaultProp:f,onChange:kt(Y=>{var ee;(ee=[...b.current][k.current])==null||ee.focus({preventScroll:!0,focusVisible:C.current}),C.current=!1,m(Y)},"onChange")}),j=g.useRef(L),V=g.useRef(L);g.useEffect(()=>{const Y=_?M==null?void 0:M.ownerDocument.getElementById(_):M==null?void 0:M.closest("form");if(Y instanceof HTMLFormElement){const z=kt(()=>N(V.current),"reset");return Y.addEventListener("reset",z),()=>Y.removeEventListener("reset",z)}},[M,_,N]);function Q(Y){const z=FL(L,Y);W(Y,z)}kt(Q,"handleSlideStart");function q(Y){W(Y,k.current)}kt(q,"handleSlideMove");function G(){String(L)!==String(j.current)&&v(L)}kt(G,"handleSlideEnd");function W(Y,z,{commit:ee}={commit:!1}){const B=gb(o),D=vf(Math.round((Y-s)/o)*o+s,B),X=hb(D,[s,i]);N((ce=[])=>{const se=$L(ce,X,z);if(zL(se,d*o)){k.current=se.indexOf(X);const re=String(se)!==String(ce);return re&&ee&&v(se),re?se:ce}else return ce})}return kt(W,"updateValues"),S.jsx(Gne,{scope:e.__scopeSlider,name:r,disabled:u,min:s,max:i,valueIndexToChangeRef:k,thumbs:b.current,values:L,orientation:l,form:_,children:S.jsx(B2.Provider,{scope:e.__scopeSlider,children:S.jsx(B2.Slot,{scope:e.__scopeSlider,children:S.jsx(A,{"aria-disabled":u,"data-disabled":u?"":void 0,...x,ref:I,onPointerDown:Wt(x.onPointerDown,()=>{u||(j.current=L,C.current=!1)}),min:s,max:i,inverted:w,onSlideStart:u?void 0:Q,onSlideMove:u?void 0:q,onSlideEnd:u?void 0:G,onHomeKeyDown:()=>{u||(C.current=!0,W(s,0,{commit:!0}))},onEndKeyDown:()=>{u||(C.current=!0,W(i,L.length-1,{commit:!0}))},onStepKeyDown:({event:Y,direction:z})=>{if(!u){C.current=!0;const D=AL.includes(Y.key)||Y.shiftKey&&IL.includes(Y.key)?10:1,X=k.current,ce=L[X],se=BL(ce,{min:s,step:o,direction:z,multiplier:D});W(se,X,{commit:!0})}}})})})})},"Slider")),[ML,OL]=pb(gh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Yne=g.forwardRef(kt(function(e,n){const{min:r,max:s,dir:i,inverted:o,onSlideStart:l,onSlideMove:u,onSlideEnd:d,onStepKeyDown:f,...p}=e,[m,v]=g.useState(null),w=qt(n,v),_=g.useRef(void 0),x=ab(i),b=x==="ltr",k=b&&!o||!b&&o;function C(T){const A=_.current||m.getBoundingClientRect(),M=[0,A.width],I=ag(M,k?[r,s]:[s,r]);return _.current=A,I(T-A.left)}return kt(C,"getValueFromPointer"),S.jsx(ML,{scope:e.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:S.jsx(LL,{dir:x,"data-orientation":"horizontal",...p,ref:w,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const A=C(T.clientX);l==null||l(A)},onSlideMove:T=>{const A=C(T.clientX);u==null||u(A)},onSlideEnd:()=>{_.current=void 0,d==null||d()},onStepKeyDown:T=>{const M=RL[k?"from-left":"from-right"].includes(T.key);f==null||f({event:T,direction:M?-1:1})}})})},"SliderHorizontal")),Xne=g.forwardRef(kt(function(e,n){const{min:r,max:s,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:u,onStepKeyDown:d,...f}=e,p=g.useRef(null),m=qt(n,p),v=g.useRef(void 0),w=!i;function _(x){const b=v.current||p.current.getBoundingClientRect(),k=[0,b.height],T=ag(k,w?[s,r]:[r,s]);return v.current=b,T(x-b.top)}return kt(_,"getValueFromPointer"),S.jsx(ML,{scope:e.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:S.jsx(LL,{"data-orientation":"vertical",...f,ref:m,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const b=_(x.clientY);o==null||o(b)},onSlideMove:x=>{const b=_(x.clientY);l==null||l(b)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:x=>{const k=RL[w?"from-bottom":"from-top"].includes(x.key);d==null||d({event:x,direction:k?-1:1})}})})},"SliderVertical")),LL=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,onSlideStart:s,onSlideMove:i,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:u,onStepKeyDown:d,...f}=e,p=vh(gh,r);return S.jsx(xn.span,{...f,ref:n,onKeyDown:Wt(e.onKeyDown,m=>{m.key==="Home"?(l(m),m.preventDefault()):m.key==="End"?(u(m),m.preventDefault()):AL.concat(IL).includes(m.key)&&(d(m),m.preventDefault())}),onPointerDown:Wt(e.onPointerDown,m=>{const v=m.target;v.setPointerCapture(m.pointerId),m.preventDefault(),p.thumbs.has(v)?v.focus({preventScroll:!0,focusVisible:!1}):s(m)}),onPointerMove:Wt(e.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&i(m)}),onPointerUp:Wt(e.onPointerUp,m=>{const v=m.target;v.hasPointerCapture(m.pointerId)&&(v.releasePointerCapture(m.pointerId),o(m))})})},"SliderImpl")),Qne="SliderTrack",Jne=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,...s}=e,i=vh(Qne,r);return S.jsx(xn.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...s,ref:n})},"SliderTrack")),jC="SliderRange",ere=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,...s}=e,i=vh(jC,r),o=OL(jC,r),l=g.useRef(null),u=qt(n,l),d=i.values.length,f=i.values.map(v=>mb(v,i.min,i.max)),p=d>1?Math.min(...f):0,m=100-Math.max(...f);return S.jsx(xn.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...s,ref:u,style:{...e.style,[o.startEdge]:p+"%",[o.endEdge]:m+"%"}})},"SliderRange")),tre="SliderThumb",[nre,DL]=pb(tre),rre="SliderThumbProvider";function NL(t){const{__scopeSlider:e,name:n,children:r,internal_do_not_use_render:s}=t,i=vh(rre,e),o=Zne(e),[l,u]=g.useState(null),d=g.useMemo(()=>l?o().findIndex(x=>x.ref.current===l):-1,[o,l]),f=cx(l),p=l?!!i.form||!!l.closest("form"):!0,m=i.values[d],v=n??(i.name?i.name+(i.values.length>1?"[]":""):void 0),w=m===void 0?0:mb(m,i.min,i.max);g.useEffect(()=>{if(l)return i.thumbs.add(l),()=>{i.thumbs.delete(l)}},[l,i.thumbs]);const _={value:m,name:v,form:i.form,isFormControl:p,index:d,thumb:l,onThumbChange:u,percent:w,size:f};return S.jsx(nre,{scope:e,..._,children:UL(s)?s(_):r})}kt(NL,"SliderThumbProvider");var Ry="SliderThumbTrigger",sre=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,...s}=e,i=vh(Ry,r),o=OL(Ry,r),{index:l,value:u,percent:d,size:f,onThumbChange:p}=DL(Ry,r),m=qt(n,p),v=jL(l,i.values.length),w=f==null?void 0:f[o.size],_=w?VL(w,d,o.direction):0;return S.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[o.startEdge]:`calc(${d}% + ${_}px)`},children:S.jsx(B2.ItemSlot,{scope:r,children:S.jsx(xn.span,{role:"slider","aria-label":e["aria-label"]||v,"aria-valuemin":i.min,"aria-valuenow":u,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:m,style:u===void 0?{display:"none"}:e.style,onFocus:Wt(e.onFocus,()=>{i.valueIndexToChangeRef.current=l})})})})},"SliderThumbTrigger")),ire=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,name:s,...i}=e;return S.jsx(NL,{__scopeSlider:r,name:s,internal_do_not_use_render:({index:o,isFormControl:l})=>S.jsxs(S.Fragment,{children:[S.jsx(sre,{...i,ref:n,__scopeSlider:r}),l?S.jsx(are,{__scopeSlider:r},o):null]})})},"SliderThumb")),ore="SliderBubbleInput",are=g.forwardRef(kt(function({__scopeSlider:e,...n},r){const{value:s,name:i,form:o}=DL(ore,e),l=g.useRef(null),u=qt(l,r),d=TL(s);return g.useEffect(()=>{const f=l.current;if(!f)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"value").set;if(d!==s&&v){const w=new Event("input",{bubbles:!0});v.call(f,s),f.dispatchEvent(w)}},[d,s]),S.jsx(xn.input,{style:{display:"none"},name:i,form:o,...n,ref:u,defaultValue:s})},"SliderBubbleInput"));function $L(t=[],e,n){const r=[...t];return r[n]=e,r.sort((s,i)=>s-i)}kt($L,"getNextSortedValues");function mb(t,e,n){const i=100/(n-e)*(t-e);return hb(i,[0,100])}kt(mb,"convertValueToPercentage");function jL(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}kt(jL,"getLabel");function FL(t,e){if(t.length===1)return 0;const n=t.map(s=>Math.abs(s-e)),r=Math.min(...n);return n.indexOf(r)}kt(FL,"getClosestValueIndex");function VL(t,e,n){const r=t/2,i=ag([0,50],[0,r]);return(r-i(e)*n)*n}kt(VL,"getThumbInBoundsOffset");function HL(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}kt(HL,"getStepsBetweenValues");function zL(t,e){if(e>0){const n=HL(t);return Math.min(...n)>=e}return!0}kt(zL,"hasMinStepsBetweenValues");function ag(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}kt(ag,"linearScale");function gb(t){if(!Number.isFinite(t))return 0;const e=t.toString();if(e.includes("e")){const[r,s]=e.split("e"),i=r.split(".")[1]||"",o=Number(s);return Math.max(0,i.length-o)}const n=e.split(".")[1];return n?n.length:0}kt(gb,"getDecimalCount");function vf(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}kt(vf,"roundValue");function BL(t,{min:e,step:n,direction:r,multiplier:s}){const i=gb(n),o=(t-e)/n,l=Math.round(o),u=vf(l*n+e,i)===vf(t,i);let d;return u?d=l+s*r:r>0?d=Math.ceil(o):d=Math.floor(o),vf(d*n+e,i)}kt(BL,"getNextStepValue");function UL(t){return typeof t=="function"}kt(UL,"isFunction");const U2=g.forwardRef(({className:t,...e},n)=>S.jsxs(Kne,{ref:n,className:mn("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",t),...e,children:[S.jsx(Jne,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-input",children:S.jsx(ere,{className:"absolute h-full bg-primary"})}),S.jsx(ire,{className:mn("block h-3.5 w-3.5 rounded-full border border-border bg-foreground shadow-sm","transition-transform hover:scale-110 active:scale-95","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6B97FF]","disabled:pointer-events-none")})]}));U2.displayName="Slider";const lre=[{name:"surface-1",utility:"bg-surface-1",className:"bg-surface-1"},{name:"surface-2",utility:"bg-surface-2",className:"bg-surface-2"},{name:"surface-3",utility:"bg-surface-3",className:"bg-surface-3"},{name:"surface-4",utility:"bg-surface-4",className:"bg-surface-4"},{name:"surface-5",utility:"bg-surface-5",className:"bg-surface-5"},{name:"surface-6",utility:"bg-surface-6",className:"bg-surface-6"}],cre=[{name:"primary",utility:"bg-primary",className:"bg-primary"},{name:"selected",utility:"bg-selected",className:"bg-selected"},{name:"accent",utility:"bg-accent",className:"bg-accent"},{name:"success",utility:"bg-accent-success",className:"bg-accent-success"},{name:"warning",utility:"bg-accent-warning",className:"bg-accent-warning"},{name:"error",utility:"bg-accent-error",className:"bg-accent-error"}],ure=[{name:"gap-1",className:"w-1"},{name:"gap-2",className:"w-2"},{name:"gap-3",className:"w-3"},{name:"gap-4",className:"w-4"},{name:"gap-6",className:"w-6"},{name:"gap-8",className:"w-8"}],t0=[{name:"Accordion",path:"components/Accordion.tsx",status:"showcased",note:"Reusable primitive shown with local item composition."},{name:"AgentVariantsPanel",path:"components/AgentVariantsPanel.tsx",status:"feature-only",note:"Requires live variant session state and editor atoms."},{name:"AuthProgressScreen",path:"components/AuthProgressScreen.tsx",status:"feature-only",note:"Auth flow surface; represented through progress treatment."},{name:"AuthScreenView",path:"components/AuthScreenView.tsx",status:"feature-only",note:"Auth flow surface that depends on sign-in actions."},{name:"Button",path:"components/Button.tsx",status:"showcased",note:"Reusable tooltip-wrapped button shown in multiple states."},{name:"CommentCarouselLayer",path:"components/CommentCarouselLayer.tsx",status:"feature-only",note:"Preview overlay layer tied to iframe geometry."},{name:"CommentMarker",path:"components/CommentMarker.tsx",status:"feature-only",note:"Preview overlay marker tied to comment positions."},{name:"CommentMarkerLayer",path:"components/CommentMarkerLayer.tsx",status:"feature-only",note:"Preview overlay layer tied to comment collections."},{name:"CommentPopover",path:"components/CommentPopover.tsx",status:"feature-only",note:"Comment workflow popover tied to editor state."},{name:"CommentReferenceChip",path:"components/CommentReferenceChip.tsx",status:"feature-only",note:"Comment workflow chip tied to selected references."},{name:"CommentReferencePicker",path:"components/CommentReferencePicker.tsx",status:"feature-only",note:"Comment workflow picker tied to preview elements."},{name:"ElementInspector",path:"components/ElementInspector.tsx",status:"feature-only",note:"Primary editor surface with many app-level dependencies."},{name:"GitHome",path:"components/GitHome.tsx",status:"feature-only",note:"Git dashboard tied to repository state."},{name:"IframePreview",path:"components/IframePreview.tsx",status:"unsuitable",note:"Needs live iframe target and cross-window integration."},{name:"PreviewFrame",path:"components/PreviewFrame.tsx",status:"unsuitable",note:"Requires proxied app URL and iframe lifecycle."},{name:"PreviewSurface",path:"components/PreviewSurface.tsx",status:"unsuitable",note:"Requires preview iframe and overlay orchestration."},{name:"ProfileAvatar",path:"components/ProfileAvatar.tsx",status:"feature-only",note:"Account chrome tied to user identity data."},{name:"Progress",path:"components/Progress.tsx",status:"showcased",note:"Reusable inline loading/status primitive."},{name:"SecondaryVariantIframe",path:"components/SecondaryVariantIframe.tsx",status:"unsuitable",note:"Requires variant preview iframe lifecycle."},{name:"SparkleLoader",path:"components/SparkleLoader.tsx",status:"showcased",note:"Reusable loading animation shown in feedback states."},{name:"SplitButton",path:"components/SplitButton.tsx",status:"showcased",note:"Reusable compound action button shown with dropdown."},{name:"StatusSurface",path:"components/StatusSurface.tsx",status:"showcased",note:"Unified full-surface primitive: LoadingSurface / EmptyState / ErrorState."},{name:"SupportTicketModal",path:"components/SupportTicketModal.tsx",status:"feature-only",note:"Support workflow modal tied to form submission."},{name:"ThinkingIndicator",path:"components/ThinkingIndicator.tsx",status:"showcased",note:"Reusable thinking/loading indicator shown in feedback states."},{name:"Tooltip",path:"components/Tooltip.tsx",status:"showcased",note:"Reusable tooltip API shown with hover target."},{name:"VariantDragGhost",path:"components/VariantDragGhost.tsx",status:"feature-only",note:"Drag visual tied to variant split interactions."},{name:"VariantSplitDropZones",path:"components/VariantSplitDropZones.tsx",status:"feature-only",note:"Drop-zone visual tied to variant split interactions."},{name:"ui/accordion",path:"components/ui/accordion.tsx",status:"showcased",note:"Radix accordion primitive backing the local Accordion showcase."},{name:"ui/slider",path:"components/ui/slider.tsx",status:"showcased",note:"Radix slider primitive shown in enabled and disabled states."},{name:"ui/tooltip",path:"components/ui/tooltip.tsx",status:"showcased",note:"Radix tooltip primitive shown with forced-open preview."}],dre=()=>{window.location.hash=""},Yi=({title:t,eyebrow:e,description:n,children:r})=>S.jsxs("section",{className:"border-border bg-card shadow-surface-3 rounded-2xl border p-5",children:[S.jsxs("div",{className:"mb-5 max-w-2xl",children:[S.jsx("p",{className:"text-primary text-xs font-semibold tracking-[0.18em] uppercase",children:e}),S.jsx("h2",{className:"text-foreground mt-2 text-xl font-semibold",children:t}),S.jsx("p",{className:"text-muted-foreground mt-2 text-sm leading-6",children:n})]}),r]}),FC=({swatches:t})=>S.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:t.map(e=>S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-3",children:[S.jsx("div",{className:`h-16 rounded-lg ${e.className}`}),S.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[S.jsx("span",{className:"text-foreground text-sm font-medium",children:e.name}),S.jsx("code",{className:"bg-muted text-muted-foreground rounded px-2 py-1 text-xs",children:e.utility})]})]},e.name))}),fre=t=>t==="showcased"?"border-accent-success/40 bg-accent-success/10 text-accent-success":t==="cataloged"?"border-primary/40 bg-primary/10 text-primary":t==="generated"?"border-accent/40 bg-accent/10 text-accent":t==="unsuitable"?"border-accent-warning/40 bg-accent-warning/10 text-accent-warning":"border-border bg-surface-4 text-content-muted",hre=()=>{const t=t0.filter(n=>n.status==="showcased").length,e=t0.filter(n=>n.status==="cataloged").length;return S.jsx("main",{className:"bg-main font-main text-content h-screen overflow-y-auto",children:S.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-6 px-6 py-6 lg:px-8",children:[S.jsxs("header",{className:"border-border bg-surface-2 shadow-surface-4 rounded-3xl border p-6",children:[S.jsxs("button",{type:"button",onClick:dre,className:"text-content-subtle hover:text-content mb-6 inline-flex items-center gap-2 text-sm transition-colors",children:[S.jsx(QK,{className:"h-4 w-4",weight:"bold"}),"Back to editor"]}),S.jsxs("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between",children:[S.jsxs("div",{className:"max-w-3xl",children:[S.jsx("p",{className:"text-primary text-xs font-semibold tracking-[0.22em] uppercase",children:"Local component gallery"}),S.jsx("h1",{className:"text-foreground mt-3 text-4xl font-semibold tracking-tight",children:"Rivet design system"}),S.jsx("p",{className:"text-muted-foreground mt-3 text-base leading-7",children:"A Storybook-like route for checking the current UI primitives, tokens, and interaction states inside the Vite app."})]}),S.jsx("div",{className:"border-border bg-surface-3 rounded-2xl border p-4",children:S.jsxs("div",{className:"text-content-muted flex items-center gap-3 text-sm",children:[S.jsx(TR,{className:"text-primary h-5 w-5",weight:"bold"}),"Open with ",S.jsx("code",{className:"text-content",children:"#/design-system"})]})})]})]}),S.jsx(Yi,{eyebrow:"Controls",title:"Button, split button, and tooltip",description:"Rivet's shared Button exposes variants and sizes backed by Fluid Functionalism, alongside the split button and tooltip controls.",children:S.jsxs("div",{className:"grid gap-4 lg:grid-cols-[1fr_1fr]",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-3 text-sm font-medium",children:"Rivet Button"}),S.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[S.jsx(mo,{title:"Primary action",shortcut:"D",variant:"primary",children:"Design action"}),S.jsx(mo,{title:"Secondary action",variant:"secondary",children:"Secondary"}),S.jsx(mo,{title:"Disabled action",disabled:!0,variant:"tertiary",children:"Disabled"}),S.jsx(KR,{primaryLabel:"Ship",primaryIcon:oy,primaryAction:()=>{},dropdownItems:[{label:"Create PR",onClick:()=>{}},{label:"Copy branch",onClick:()=>{}}]})]})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-3 text-sm font-medium",children:"Tooltip states"}),S.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[S.jsx(Ul,{label:"Rivet tooltip API",side:"bottom",children:S.jsx("button",{className:"border-border bg-surface-4 text-content rounded-lg border px-4 py-2 text-sm",children:"Hover target"})}),S.jsx(px,{content:"Forced open preview",forceOpen:!0,side:"right",children:S.jsx("button",{className:"bg-selected text-content rounded-lg px-4 py-2 text-sm",children:"UI tooltip"})})]})]})]})}),S.jsx(Yi,{eyebrow:"Tokens",title:"Surface ladder",description:"Surface tokens move from the base app background toward raised panels without leaving the dark Rivet palette.",children:S.jsx(FC,{swatches:lre})}),S.jsx(Yi,{eyebrow:"Tokens",title:"Color roles",description:"Named roles should communicate purpose: brand, selection, neutral accent, and outcome colors.",children:S.jsx(FC,{swatches:cre})}),S.jsx(Yi,{eyebrow:"Type",title:"Typography",description:"Satoshi remains the default UI voice with clear hierarchy and muted support text.",children:S.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-primary text-xs tracking-[0.18em] uppercase",children:"Display"}),S.jsx("p",{className:"text-foreground mt-2 text-3xl font-semibold tracking-tight",children:"Visual edits, quickly"})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground text-sm font-semibold",children:"Panel heading"}),S.jsx("p",{className:"text-muted-foreground mt-2 text-sm leading-6",children:"Body copy uses compact line height and muted contrast for dense inspector panels."})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs font-medium tracking-[0.16em] uppercase",children:"Micro label"}),S.jsx("code",{className:"bg-muted text-muted-foreground mt-3 block rounded-lg px-3 py-2 text-xs",children:"font-main text-content"})]})]})}),S.jsx(Yi,{eyebrow:"Layout",title:"Spacing rhythm",description:"A compact spacing scale keeps editor chrome dense while preserving scannable groupings.",children:S.jsx("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:S.jsx("div",{className:"flex flex-col gap-3",children:ure.map(n=>S.jsxs("div",{className:"flex items-center gap-4",children:[S.jsx("code",{className:"text-muted-foreground w-16 text-xs",children:n.name}),S.jsx("div",{className:`${n.className} bg-primary h-4 rounded`}),S.jsx("div",{className:"bg-border h-px flex-1"})]},n.name))})})}),S.jsx(Yi,{eyebrow:"Primitives",title:"Accordion and slider",description:"Representative Radix primitives styled through the local component layer.",children:S.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[S.jsxs(A0,{defaultValue:["foundations"],className:"border-border bg-surface-2 rounded-xl border p-2",children:[S.jsx(A0.Item,{value:"foundations",title:"Foundations",description:"Tokens, surfaces, type, and spacing.",className:"first-item",icon:S.jsx(oy,{className:"text-primary h-4 w-4"}),children:S.jsx("p",{children:"Use these pieces before adding one-off visual rules."})}),S.jsx(A0.Item,{value:"components",title:"Components",description:"Buttons, tooltips, accordions, sliders.",children:S.jsx("p",{children:"Keep states visible in this route as the system evolves."})})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-5",children:[S.jsx("p",{className:"text-foreground mb-5 text-sm font-medium",children:"Slider states"}),S.jsxs("div",{className:"space-y-6",children:[S.jsx(U2,{defaultValue:[64],max:100,step:1}),S.jsx(U2,{defaultValue:[36],max:100,step:1,disabled:!0})]})]})]})}),S.jsx(Yi,{eyebrow:"Feedback",title:"Motion and loading",description:"Loading states use existing CSS animation utilities and avoid per-frame React work where possible.",children:S.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-4 text-sm font-medium",children:"Progress"}),S.jsx(One,{message:"Applying visual change..."})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-4 text-sm font-medium",children:"Sparkle strip"}),S.jsx(Dx,{className:"text-primary text-xl"})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-4 text-sm font-medium",children:"Shimmer text"}),S.jsx("span",{className:"shimmer-text text-sm font-medium",children:"Generating variants"})]}),S.jsx("div",{className:"border-border bg-surface-2 rounded-xl border p-4 sm:col-span-3",children:S.jsx(Vne,{hint:"Reading selected elements"})})]})}),S.jsx(Yi,{eyebrow:"Feedback",title:"Status surfaces",description:"The unified full-surface system: one StatusSurface primitive with LoadingSurface / EmptyState / ErrorState wrappers. Every full-page loading, empty, and error state routes through these so they share layout, copy tone, and a single status_surface_shown impression event. Inline loaders (Sparkle, ThinkingIndicator, above) stay inline and are deliberately not part of this system.",children:S.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[S.jsx("div",{className:"border-border relative h-56 overflow-hidden rounded-xl border",children:S.jsx(E2,{fill:"surface",loader:"coalesce",trackGlobalLoaderCount:!1})}),S.jsx("div",{className:"border-border relative h-56 overflow-hidden rounded-xl border",children:S.jsx(vM,{icon:S.jsx(oy,{size:32}),title:"Nothing to preview yet",description:"Pick a direction from the panel."})}),S.jsx("div",{className:"border-border relative h-56 overflow-hidden rounded-xl border",children:S.jsx($x,{fill:"surface",size:"sm",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>{}}]})})]})}),S.jsxs(Yi,{eyebrow:"Inventory",title:"Component coverage",description:"Every current component file is accounted for here. Reusable primitives are rendered above; app surfaces that need live editor, git, auth, iframe, or generated state are cataloged instead of mounted unsafely.",children:[S.jsxs("div",{className:"mb-4 grid gap-3 sm:grid-cols-3",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs tracking-[0.16em] uppercase",children:"Total components"}),S.jsx("p",{className:"text-foreground mt-2 text-2xl font-semibold",children:t0.length})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs tracking-[0.16em] uppercase",children:"Showcased"}),S.jsx("p",{className:"text-accent-success mt-2 text-2xl font-semibold",children:t})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs tracking-[0.16em] uppercase",children:"Cataloged"}),S.jsx("p",{className:"text-primary mt-2 text-2xl font-semibold",children:e})]})]}),S.jsxs("div",{className:"border-border overflow-hidden rounded-xl border",children:[S.jsxs("div",{className:"border-border bg-surface-3 text-content-subtle grid grid-cols-[minmax(140px,1fr)_minmax(110px,auto)_minmax(220px,2fr)] border-b px-4 py-3 text-xs font-semibold tracking-[0.14em] uppercase",children:[S.jsx("span",{children:"Component"}),S.jsx("span",{children:"Status"}),S.jsx("span",{children:"Coverage note"})]}),S.jsx("div",{className:"divide-border bg-surface-2 divide-y",children:t0.map(n=>S.jsxs("div",{className:"grid grid-cols-[minmax(140px,1fr)_minmax(110px,auto)_minmax(220px,2fr)] gap-3 px-4 py-3 text-sm",children:[S.jsxs("div",{children:[S.jsx("p",{className:"text-foreground font-medium",children:n.name}),S.jsx("code",{className:"text-muted-foreground text-xs",children:n.path})]}),S.jsx("div",{children:S.jsx("span",{className:`inline-flex rounded-full border px-2 py-1 text-xs font-medium ${fre(n.status)}`,children:n.status})}),S.jsx("p",{className:"text-muted-foreground",children:n.note})]},n.path))})]})]})]})})},pre=t=>(t.startsWith("#/")?t.slice(2):t.slice(1)).split("?")[0]==="design-system"?"design-system":"editor",W2=274,Am=395,My=Math.min(Am,Math.round((W2+Am)/2*1.1)),VC="rivet:panelWidth:v2",mre=t=>{if(!(t instanceof HTMLElement))return!1;const e=t.tagName.toLowerCase();return t.isContentEditable||e==="input"||e==="textarea"||e==="select"},gre=({projectPath:t})=>{const e=it(BR)>0,[n,r]=D5(HR),s=PU(),[i,o]=g.useState(()=>{if(typeof window>"u")return My;const T=Number(window.localStorage.getItem(VC));return Number.isFinite(T)&&T>=W2&&T<=Am?T:My}),[l,u]=g.useState(!1),[d,f]=g.useState(Cee),p=n?i:0,[m,v]=g.useState(n);g.useEffect(()=>{if(!n){v(!1);return}f(T=>kee({position:T,boundsLeftPx:i}))},[n,i]),g.useEffect(()=>{window.localStorage.setItem(VC,String(i))},[i]),g.useEffect(()=>{if(!n)return;const T=A=>{A.key==="Escape"&&(mre(A.target)||(A.preventDefault(),r(!1)))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n,r]);const w=g.useCallback(T=>{T.preventDefault(),T.stopPropagation();const A=T.clientX,M=i;u(!0);const R=L=>{const N=Math.min(Am,Math.max(W2,M+(L.clientX-A)));o(N)},I=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I),window.removeEventListener("pointercancel",I),u(!1)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",I),window.addEventListener("pointercancel",I)},[i]),_=g.useCallback(()=>o(My),[]),x=Fee(),b=it(Qm);zee({enabled:!b});const k=x.isProcessing?"Completing authentication...":null,C=dt(Lx);return g.useEffect(()=>{C(t??null)},[t,C]),S.jsxs(ei.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[k!==null?S.jsx("div",{className:"absolute inset-0 z-50",children:S.jsx(fee,{message:k})}):null,S.jsx("div",{className:"relative flex min-w-0 flex-1 flex-col",children:S.jsx(VQ,{})}),S.jsx(S.Fragment,{children:e?null:S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"relative order-first h-full flex-shrink-0",style:{width:m?i:0},children:S.jsxs(ei.div,{className:"absolute inset-y-0 left-0 z-30",initial:!1,animate:{x:n?0:-i},transition:s?{duration:0}:{duration:.2,ease:[.22,1,.36,1]},onAnimationComplete:()=>{n&&v(!0)},style:{width:i,willChange:"transform"},children:[S.jsx(JX,{onClose:()=>r(!1)}),S.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panel",onPointerDown:w,onDoubleClick:_,className:"group/resize absolute inset-y-0 right-0 z-20 flex w-3 cursor-col-resize touch-none justify-end",children:S.jsx("span",{className:`h-full transition-all duration-150 ${l?"bg-content-muted w-0.5":"bg-divider group-hover/resize:bg-content-muted w-px group-hover/resize:w-0.5"}`})})]})}),l&&S.jsx("div",{className:"fixed inset-0 z-[100] cursor-col-resize"}),S.jsx(Aee,{isVisible:!0,isPanelOpen:n,isReducedMotion:!!s,position:d,dragBoundsLeftPx:p,onPositionChange:f,onToggle:()=>r(T=>!T)})]})}),S.jsx(rW,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},Z2="rivet_connect_deep_link",vre=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),e=t.get("connect"),n=e??window.sessionStorage.getItem(Z2);if(n!=="pinterest"&&n!=="arena")return null;if(window.sessionStorage.setItem(Z2,n),e){t.delete("connect");const r=t.toString();window.history.replaceState(null,document.title,window.location.pathname+(r?`?${r}`:"")+window.location.hash)}return n},yre=vre(),_re=()=>{const[t,e]=g.useState(window.location.hash),[n]=g.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(wm)==="1"),[r,s]=g.useState(!1),[i,o]=g.useState(yre);g.useEffect(()=>{n&&window.sessionStorage.removeItem(wm)},[n]);const{config:l,refetchConfig:u,loading:d,error:f}=$ee(),p=dt(Qm),{startLogin:m,isStartingLogin:v,loginError:w}=cM(),[_,x]=g.useState(!1);g.useEffect(()=>{l!=null&&l.userId?(Ee.identify(l.userId,{...l.email?{email:l.email}:{}}),l.email&&Ee.alias(l.email,l.userId)):l!=null&&l.email&&Ee.identify(l.email,{email:l.email})},[l==null?void 0:l.userId,l==null?void 0:l.email]),g.useEffect(()=>{l&&Ee.register({source:"visual_editor",surface:"visual_editor"})},[l]);const b=l!=null&&l.agentModeAvailable!==!0,k=pre(t),C=g.useCallback(async()=>{x(!0),p(!0);try{await u()}finally{p(!1),x(!1)}},[u,p]);if(g.useEffect(()=>{const R=()=>{const I=window.location.hash;e(I)};return window.addEventListener("hashchange",R),()=>window.removeEventListener("hashchange",R)},[]),k==="design-system")return S.jsx(hre,{});if(!d&&l===null&&!_){const R=f||"Could not load Rivet configuration.";return S.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:S.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[S.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),S.jsx("p",{className:"text-content-dim mt-2 text-xs",children:R}),S.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{C()},children:"Retry"})]})})}if(b)return S.jsx(uee,{isSigningIn:v,onStartSignIn:()=>{m()},errorMessage:w,displayMode:"full"});const A=(l==null?void 0:l.agentModeAvailable)===!0&&i!==null,M=(l==null?void 0:l.agentModeAvailable)===!0&&n&&!r&&!A;return S.jsxs(S.Fragment,{children:[S.jsx(gre,{projectPath:l==null?void 0:l.projectPath}),S.jsx(S2,{context:"onboarding",isOpen:M,onClose:()=>s(!0)}),S.jsx(S2,{context:"menu",isOpen:A,highlightProvider:i,onClose:()=>{window.sessionStorage.removeItem(Z2),o(null)}})]})};Zj();const wre=g.lazy(()=>XC(()=>import("./LibraryApp-Bkawuvcq.js"),[])),xre=window.location.pathname.startsWith("/rivet/library"),bre="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",Sre=new QD,Ere={session_recording:{maskAllInputs:!0,maskTextSelector:"[data-rivet-private]"}},kre=()=>S.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:S.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});Qj.createRoot(document.getElementById("root")).render(S.jsx(we.StrictMode,{children:S.jsx(Fj,{apiKey:bre,options:{api_host:"https://rivet-proxy.onrender.com/ingest",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",...Ere,mask_all_text:!1,mask_all_element_attributes:!1,loaded:t=>{t.register({source:"visual_editor",surface:"visual_editor",telemetry_version:2,rivet_version:"0.17.1",env:"production"})}},children:S.jsx(Uj,{fallback:S.jsx(kre,{}),children:S.jsx(CD,{client:Sre,children:S.jsx(QW,{defaultShape:"rounded",children:S.jsx(Ine,{defaultLibrary:"lucide",children:xre?S.jsx(g.Suspense,{fallback:S.jsx("div",{className:"bg-background h-screen"}),children:S.jsx(wre,{})}):S.jsx(_re,{})})})})})})}));export{Nte as A,mo as B,TX as C,QX as P,ZD as Q,nh as S,rW as T,JD as a,nN as b,g as c,rN as d,oN as e,sN as f,KD as g,yf as h,$r as i,aN as j,lN as k,iN as l,s3 as m,nr as n,Qe as o,S as p,hee as q,n3 as r,Zv as s,yne as t,JC as u,Zl as v,Ire as w,M0 as x,Tre as y,Rre as z};
|
|
438
|
+
*/const vL={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};vL.node;const Pne=Qe(vL),Tne={"chevron-right":Bte,"chevron-down":zte,pipette:fne,x:Pne,copy:Zte,menu:sne,dot:qte,monitor:one,sun:Ene,moon:ane,"rectangle-horizontal":mne,circle:Ute,"square-library":bne,clock:Wte,star:Sne,settings:_ne,plus:pne,"arrow-left":Nte,"arrow-right":$te,"arrow-up":jte,search:yne,loader:tne,users:Cne,lock:nne,mail:rne,bell:Fte,shield:wne,palette:cne,lightbulb:Jte,rocket:gne,heart:Kte,paintbrush:lne,brain:Vte,globe:Gte,user:kne,image:Xte,link:ene,check:Hte,"rotate-ccw":vne,play:hne,pause:une,home:Yte,"message-circle":ine,inbox:Qte,pencil:dne,"skip-forward":xne},DC={lucide:Tne},yL=g.createContext(null);function Ane(t){const e=g.useContext(yL);return e?DC[e.iconLibrary][t]:DC.lucide[t]}function Ine({children:t,defaultLibrary:e="lucide"}){const[n,r]=g.useState(e),s=g.useCallback(i=>{r(i)},[]);return S.jsx(yL.Provider,{value:{iconLibrary:n,setIconLibrary:s},children:t})}const _L=g.createContext(null);function fb(){return g.useContext(_L)}const wL=g.createContext(null);function xL(){const t=g.useContext(wL);if(!t)throw new Error("AccordionTrigger/AccordionContent must be used within an AccordionItem");return t}const Rne=g.forwardRef((t,e)=>{const{children:n,type:r="single",className:s,...i}=t,o=g.useRef(null),l=g.useRef(new Map),[u,d]=g.useState(new Map),{activeIndex:f,setActiveIndex:p,itemRects:m,sessionRef:v,handlers:w,registerItem:_,measureItems:x}=LR(o),b=g.useCallback((fe,oe)=>{oe?l.current.set(fe,oe):l.current.delete(fe)},[]),k=g.useCallback(()=>{if(!o.current)return;const fe=new Map;l.current.forEach((oe,je)=>{fe.set(je,{top:oe.offsetTop,left:oe.offsetLeft,width:oe.offsetWidth,height:oe.offsetHeight})}),d(fe)},[]),[C,T]=g.useState(()=>r==="single"?t.defaultValue??"":""),[A,M]=g.useState(()=>r==="multiple"?t.defaultValue??[]:[]),R=t.onValueChange,I=t.onValueChange,L=t.value,N=new Set(r==="multiple"?t.value??A:(()=>{const fe=t.value??C;return fe?[fe]:[]})()),j=g.useCallback(fe=>{const oe=t;oe.onValueChange?oe.onValueChange(fe):T(fe)},[R]),V=g.useCallback(fe=>{const oe=t;oe.onValueChange?oe.onValueChange(fe):M(fe)},[I]),Q=g.useCallback(fe=>{if(r==="multiple"){const oe=t.value??A;V(oe.filter(je=>je!==fe))}else j("")},[r,j,V,A,L]);g.useEffect(()=>{x(),k()},[x,k,n]);const q=[...N].join(",");g.useEffect(()=>{x(),k()},[x,k,q]);const[G,W]=g.useState(null),Y=f!==null?m[f]:null,z=G!==null?m[G]:null,ee=f!==null&&!u.has(f),B=uh(),{value:D,defaultValue:X,onValueChange:ce,collapsible:se,type:re,...de}=i,_e=r==="multiple"?{type:"multiple",value:t.value??A,onValueChange:V}:{type:"single",collapsible:t.collapsible??!0,value:t.value??C,onValueChange:j};return S.jsx(_L.Provider,{value:{registerItem:_,registerFullItem:b,activeIndex:f,grouped:!0,remeasure:()=>{x(),k()},openValues:N,openItemRects:u,toggleValue:Q},children:S.jsx(kO,{..._e,asChild:!0,children:S.jsxs("div",{ref:fe=>{o.current=fe,typeof e=="function"?e(fe):e&&(e.current=fe)},onMouseEnter:w.onMouseEnter,onMouseMove:fe=>{const oe=o.current;if(oe){const je=oe.getBoundingClientRect(),Ce=oe.offsetHeight,Ue=je.height,rt=Ce>0?Ue/Ce:1,st=(fe.clientY-je.top)/rt+oe.scrollTop;for(const[It,ft]of u){const De=m[It];if(!De)continue;const Je=De.top+De.height,ut=ft.top+ft.height;if(st>=Je&&st<=ut){p(null);return}}}w.onMouseMove(fe)},onMouseLeave:w.onMouseLeave,onFocus:fe=>{var je;const oe=(je=fe.target.closest("[data-proximity-index]"))==null?void 0:je.getAttribute("data-proximity-index");if(oe!=null){const Ce=Number(oe);p(Ce),W(fe.target.matches(":focus-visible")?Ce:null)}},onBlur:fe=>{var oe;(oe=o.current)!=null&&oe.contains(fe.relatedTarget)||(W(null),p(null))},className:mn("relative flex flex-col gap-0.5 w-72 max-w-full",s),...de,children:[S.jsx(cs,{children:[...u.entries()].map(([fe,oe])=>S.jsx(fo.div,{className:`absolute ${B.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:!1,animate:{top:oe.top,left:oe.left,width:oe.width,height:oe.height,opacity:ee?.7:1},exit:{opacity:0,transition:{duration:.12}},transition:{top:{duration:0},left:{duration:0},width:{duration:0},height:{duration:0},opacity:{duration:.08}}},`expanded-${fe}`))}),S.jsx(cs,{children:Y&&S.jsx(fo.div,{className:`absolute ${B.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:Y.top,left:Y.left,width:Y.width,height:Y.height},animate:{opacity:1,top:Y.top,left:Y.left,width:Y.width,height:Y.height},exit:{opacity:0,transition:{duration:.06}},transition:{...jf.fast,opacity:{duration:.08}}},v.current)}),S.jsx(cs,{children:z&&S.jsx(fo.div,{className:`absolute ${B.focusRing} pointer-events-none z-20 border border-[#6B97FF]`,initial:!1,animate:{left:z.left-2,top:z.top-2,width:z.width+4,height:z.height+4},exit:{opacity:0,transition:{duration:.06}},transition:{...jf.fast,opacity:{duration:.08}}})}),n]})})})});Rne.displayName="AccordionGroup";const bL=g.forwardRef(({children:t,type:e="single",collapsible:n=!0,defaultValue:r,value:s,onValueChange:i,className:o,...l},u)=>{const[d,f]=g.useState(()=>e==="single"?r??"":""),[p,m]=g.useState(()=>e==="multiple"?r??[]:[]),v=new Set(e==="multiple"?s??p:(()=>{const k=s??d;return k?[k]:[]})()),w=g.useCallback(k=>{i?i(k):f(k)},[i]),_=g.useCallback(k=>{i?i(k):m(k)},[i]),x=g.useCallback(k=>{e==="multiple"?_((s??p).filter(T=>T!==k)):w("")},[e,s,p,w,_]),b=e==="multiple"?{type:"multiple",value:s??p,defaultValue:r,onValueChange:_}:{type:"single",collapsible:n,value:s??d,defaultValue:r,onValueChange:w};return S.jsx(kO,{...b,asChild:!0,children:S.jsx("div",{ref:u,className:mn("w-72 max-w-full flex flex-col gap-0.5",o),...l,children:S.jsx(SL.Provider,{value:v,children:S.jsx(EL.Provider,{value:x,children:t})})})})});bL.displayName="Accordion";const SL=g.createContext(new Set),EL=g.createContext(()=>{}),kL=g.forwardRef(({value:t,index:e,disabled:n,children:r,className:s,...i},o)=>{const l=g.useRef(null),u=fb(),d=g.useContext(SL),f=g.useContext(EL),p=uh(),m=u!=null&&u.grouped?u.openValues.has(t):d.has(t),v=g.useRef(null),w=g.useCallback(()=>{u!=null&&u.grouped?u.toggleValue(t):f(t)},[u,f,t]);return g.useEffect(()=>{if(u!=null&&u.grouped&&e!==void 0)return u.registerItem(e,v.current),()=>u.registerItem(e,null)},[e,u]),g.useEffect(()=>{if(u!=null&&u.grouped&&e!==void 0)return m?u.registerFullItem(e,l.current):u.registerFullItem(e,null),()=>u.registerFullItem(e,null)},[e,u,m]),S.jsx(wL.Provider,{value:{index:e,value:t,isOpen:m,onToggle:w,triggerRef:v},children:S.jsxs(bte,{ref:_=>{l.current=_,typeof o=="function"?o(_):o&&(o.current=_)},value:t,disabled:n,"data-proximity-index":e,className:mn(!(u!=null&&u.grouped)&&"relative",s),...i,children:[!(u!=null&&u.grouped)&&S.jsx(cs,{children:m&&S.jsx(fo.div,{className:`absolute inset-0 ${p.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),r]})})});kL.displayName="AccordionItem";const CL=g.forwardRef(({children:t,className:e,...n},r)=>{const s=Ane("chevron-right"),i=fb(),{index:o,isOpen:l,triggerRef:u}=xL(),d=uh(),[f,p]=g.useState(!1),m=i!=null&&i.grouped?i.activeIndex===o:f,v=S.jsx(Ste,{asChild:!0,children:S.jsx("div",{children:S.jsxs(Ete,{ref:r,className:mn(`relative z-10 flex items-center gap-2.5 ${d.item} px-3 py-2 w-full cursor-pointer outline-none select-none`,!(i!=null&&i.grouped)&&"focus-visible:ring-1 focus-visible:ring-[#6B97FF] focus-visible:ring-offset-0",e),...n,children:[S.jsxs("span",{className:"inline-grid text-[13px] flex-1 text-left",children:[S.jsx("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:ff.semibold},"aria-hidden":"true",children:t}),S.jsx("span",{className:mn("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80",l||m?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:l?ff.semibold:ff.normal},children:t})]}),S.jsx(fo.span,{className:"shrink-0 inline-flex items-center justify-center",animate:{rotate:l?90:0},transition:jf.fast,children:S.jsx(s,{size:16,strokeWidth:l||m?2:1.5,className:mn("transition-[color,stroke-width] duration-80",l||m?"text-foreground":"text-muted-foreground")})})]})})});return i!=null&&i.grouped?S.jsx("div",{ref:u,children:v}):S.jsxs("div",{className:"relative",onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[S.jsx(cs,{children:f&&S.jsx(fo.div,{className:`absolute inset-0 ${d.bg} bg-hover pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),v]})});CL.displayName="AccordionTrigger";const PL=g.forwardRef(({children:t,className:e,...n},r)=>{const s=fb(),{isOpen:i}=xL();return S.jsx(cs,{initial:!1,children:i&&S.jsx(kte,{forceMount:!0,asChild:!0,...n,children:S.jsx(fo.div,{ref:r,className:mn("overflow-hidden",e),initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{...jf.moderate,bounce:0},onUpdate:()=>{s==null||s.remeasure()},onAnimationComplete:()=>{s==null||s.remeasure()},children:S.jsx("div",{className:"px-3 pb-3 pt-1 text-[13px] text-muted-foreground",children:t})})})})});PL.displayName="AccordionContent";const A0=({children:t,defaultValue:e=[],className:n=""})=>S.jsx(bL,{type:"multiple",defaultValue:e,className:mn("w-full",n),children:t}),Mne=({value:t,title:e,description:n,dataCy:r,icon:s,children:i,className:o=""})=>{const l=o.includes("first-item");return S.jsxs(kL,{value:t,className:mn("w-full",!l&&"border-t border-main-border"),children:[S.jsxs(CL,{"data-cy":r,children:[s?S.jsx("span",{className:"mr-1 inline-flex items-center",children:s}):null,e]}),S.jsxs(PL,{children:[n?S.jsx("p",{className:"pb-2 text-sm text-content-subtle",children:n}):null,i]})]})};A0.Item=Mne;const One=({message:t,isLoading:e=!0})=>S.jsxs("div",{className:"flex items-center gap-2 text-sm text-content",children:[e?S.jsx(Xm,{className:"h-4 w-4 shrink-0 animate-spin text-primary",weight:"bold"}):null,S.jsx("span",{className:"whitespace-pre-wrap font-sans",children:t})]}),Lne=()=>{const t=g.useRef(Date.now()),[e,n]=g.useState(0);return g.useEffect(()=>{const r=()=>n(Math.max(0,Math.floor((Date.now()-t.current)/1e3)));r();const s=setInterval(r,1e3);return()=>clearInterval(s)},[]),e},Dne=t=>{const e=Math.floor(t/60),n=t%60;return`${e}:${n.toString().padStart(2,"0")}`},NC="M 12 8 C 14.21 8 16 9.79 16 12 C 16 14.21 14.21 16 12 16 C 9.79 16 8 14.21 8 12 C 8 9.79 9.79 8 12 8 Z",$C="M 12 12 C 14 8.5 19 8.5 19 12 C 19 15.5 14 15.5 12 12 C 10 8.5 5 8.5 5 12 C 5 15.5 10 15.5 12 12 Z",Nne="M 12 16 C 14.21 16 16 14.21 16 12 C 16 9.79 14.21 8 12 8 C 9.79 8 8 9.79 8 12 C 8 14.21 9.79 16 12 16 Z",I0=["Applying","Thinking","Planning","Crafting"],$ne=I0.reduce((t,e)=>t.length>=e.length?t:e),jne=20,Fne="Still working — runs can take a few minutes.",Vne=({hint:t,showElapsed:e=!0})=>{const[n,r]=g.useState(0),s=Lne();g.useEffect(()=>{const o=setInterval(()=>{r(l=>(l+1)%I0.length)},4e3);return()=>clearInterval(o)},[]);const i=t??(e&&s>=jne?Fne:null);return S.jsxs("div",{role:"status",className:"flex items-center gap-2 px-3 py-1","data-cy":"thinking-indicator",children:[S.jsx(ei.svg,{"aria-hidden":!0,width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-muted-foreground",children:S.jsx(ei.path,{animate:{d:[NC,$C,Nne,$C,NC]},transition:{d:{duration:6,ease:"easeInOut",repeat:1/0,times:[0,.25,.5,.75,1]}}})}),S.jsxs("span",{className:"inline-grid overflow-hidden text-sm font-medium",style:{fontVariationSettings:ff.medium},children:[S.jsx("span",{className:"shimmer-text invisible col-start-1 row-start-1","aria-hidden":"true",children:$ne}),S.jsx(cs,{mode:"popLayout",initial:!1,children:S.jsx(ei.span,{className:"shimmer-text col-start-1 row-start-1",initial:{y:"80%",opacity:0},animate:{y:0,opacity:1,transition:{duration:.24,ease:[.4,0,.2,1]}},exit:{y:"-80%",opacity:0,transition:{duration:.16,ease:[.4,0,.2,1]}},children:I0[n]},I0[n])})]}),e?S.jsx("span",{className:"text-xs tabular-nums text-content-subtle","data-cy":"thinking-elapsed",children:Dne(s)}):null,i?S.jsx("span",{className:"text-xs text-content-subtle",children:i}):null]})};var Hne=Object.defineProperty,zne=(t,e)=>Hne(t,"name",{value:e,configurable:!0});function hb(t,[e,n]){return Math.min(n,Math.max(e,t))}zne(hb,"clamp");var Bne=Object.defineProperty,Une=(t,e)=>Bne(t,"name",{value:e,configurable:!0});function TL(t){const e=g.useRef({value:t,previous:t});return g.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}Une(TL,"usePrevious");var Wne=Object.defineProperty,kt=(t,e)=>Wne(t,"name",{value:e,configurable:!0}),AL=["PageUp","PageDown"],IL=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],RL={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gh="Slider",[B2,Zne,qne]=rb(gh),[pb,$re]=Di(gh,[qne]),[Gne,vh]=pb(gh),Kne=g.forwardRef(kt(function(e,n){const{name:r,min:s=0,max:i=100,step:o=1,orientation:l="horizontal",disabled:u=!1,minStepsBetweenThumbs:d=0,defaultValue:f=[s],value:p,onValueChange:m=kt(()=>{},"onValueChange"),onValueCommit:v=kt(()=>{},"onValueCommit"),inverted:w=!1,form:_,...x}=e,b=g.useRef(new Set),k=g.useRef(0),C=g.useRef(!1),A=l==="horizontal"?Yne:Xne,[M,R]=g.useState(null),I=qt(n,R),[L=[],N]=Da({prop:p,defaultProp:f,onChange:kt(Y=>{var ee;(ee=[...b.current][k.current])==null||ee.focus({preventScroll:!0,focusVisible:C.current}),C.current=!1,m(Y)},"onChange")}),j=g.useRef(L),V=g.useRef(L);g.useEffect(()=>{const Y=_?M==null?void 0:M.ownerDocument.getElementById(_):M==null?void 0:M.closest("form");if(Y instanceof HTMLFormElement){const z=kt(()=>N(V.current),"reset");return Y.addEventListener("reset",z),()=>Y.removeEventListener("reset",z)}},[M,_,N]);function Q(Y){const z=FL(L,Y);W(Y,z)}kt(Q,"handleSlideStart");function q(Y){W(Y,k.current)}kt(q,"handleSlideMove");function G(){String(L)!==String(j.current)&&v(L)}kt(G,"handleSlideEnd");function W(Y,z,{commit:ee}={commit:!1}){const B=gb(o),D=vf(Math.round((Y-s)/o)*o+s,B),X=hb(D,[s,i]);N((ce=[])=>{const se=$L(ce,X,z);if(zL(se,d*o)){k.current=se.indexOf(X);const re=String(se)!==String(ce);return re&&ee&&v(se),re?se:ce}else return ce})}return kt(W,"updateValues"),S.jsx(Gne,{scope:e.__scopeSlider,name:r,disabled:u,min:s,max:i,valueIndexToChangeRef:k,thumbs:b.current,values:L,orientation:l,form:_,children:S.jsx(B2.Provider,{scope:e.__scopeSlider,children:S.jsx(B2.Slot,{scope:e.__scopeSlider,children:S.jsx(A,{"aria-disabled":u,"data-disabled":u?"":void 0,...x,ref:I,onPointerDown:Wt(x.onPointerDown,()=>{u||(j.current=L,C.current=!1)}),min:s,max:i,inverted:w,onSlideStart:u?void 0:Q,onSlideMove:u?void 0:q,onSlideEnd:u?void 0:G,onHomeKeyDown:()=>{u||(C.current=!0,W(s,0,{commit:!0}))},onEndKeyDown:()=>{u||(C.current=!0,W(i,L.length-1,{commit:!0}))},onStepKeyDown:({event:Y,direction:z})=>{if(!u){C.current=!0;const D=AL.includes(Y.key)||Y.shiftKey&&IL.includes(Y.key)?10:1,X=k.current,ce=L[X],se=BL(ce,{min:s,step:o,direction:z,multiplier:D});W(se,X,{commit:!0})}}})})})})},"Slider")),[ML,OL]=pb(gh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Yne=g.forwardRef(kt(function(e,n){const{min:r,max:s,dir:i,inverted:o,onSlideStart:l,onSlideMove:u,onSlideEnd:d,onStepKeyDown:f,...p}=e,[m,v]=g.useState(null),w=qt(n,v),_=g.useRef(void 0),x=ab(i),b=x==="ltr",k=b&&!o||!b&&o;function C(T){const A=_.current||m.getBoundingClientRect(),M=[0,A.width],I=ag(M,k?[r,s]:[s,r]);return _.current=A,I(T-A.left)}return kt(C,"getValueFromPointer"),S.jsx(ML,{scope:e.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:S.jsx(LL,{dir:x,"data-orientation":"horizontal",...p,ref:w,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const A=C(T.clientX);l==null||l(A)},onSlideMove:T=>{const A=C(T.clientX);u==null||u(A)},onSlideEnd:()=>{_.current=void 0,d==null||d()},onStepKeyDown:T=>{const M=RL[k?"from-left":"from-right"].includes(T.key);f==null||f({event:T,direction:M?-1:1})}})})},"SliderHorizontal")),Xne=g.forwardRef(kt(function(e,n){const{min:r,max:s,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:u,onStepKeyDown:d,...f}=e,p=g.useRef(null),m=qt(n,p),v=g.useRef(void 0),w=!i;function _(x){const b=v.current||p.current.getBoundingClientRect(),k=[0,b.height],T=ag(k,w?[s,r]:[r,s]);return v.current=b,T(x-b.top)}return kt(_,"getValueFromPointer"),S.jsx(ML,{scope:e.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:S.jsx(LL,{"data-orientation":"vertical",...f,ref:m,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const b=_(x.clientY);o==null||o(b)},onSlideMove:x=>{const b=_(x.clientY);l==null||l(b)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:x=>{const k=RL[w?"from-bottom":"from-top"].includes(x.key);d==null||d({event:x,direction:k?-1:1})}})})},"SliderVertical")),LL=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,onSlideStart:s,onSlideMove:i,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:u,onStepKeyDown:d,...f}=e,p=vh(gh,r);return S.jsx(xn.span,{...f,ref:n,onKeyDown:Wt(e.onKeyDown,m=>{m.key==="Home"?(l(m),m.preventDefault()):m.key==="End"?(u(m),m.preventDefault()):AL.concat(IL).includes(m.key)&&(d(m),m.preventDefault())}),onPointerDown:Wt(e.onPointerDown,m=>{const v=m.target;v.setPointerCapture(m.pointerId),m.preventDefault(),p.thumbs.has(v)?v.focus({preventScroll:!0,focusVisible:!1}):s(m)}),onPointerMove:Wt(e.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&i(m)}),onPointerUp:Wt(e.onPointerUp,m=>{const v=m.target;v.hasPointerCapture(m.pointerId)&&(v.releasePointerCapture(m.pointerId),o(m))})})},"SliderImpl")),Qne="SliderTrack",Jne=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,...s}=e,i=vh(Qne,r);return S.jsx(xn.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...s,ref:n})},"SliderTrack")),jC="SliderRange",ere=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,...s}=e,i=vh(jC,r),o=OL(jC,r),l=g.useRef(null),u=qt(n,l),d=i.values.length,f=i.values.map(v=>mb(v,i.min,i.max)),p=d>1?Math.min(...f):0,m=100-Math.max(...f);return S.jsx(xn.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...s,ref:u,style:{...e.style,[o.startEdge]:p+"%",[o.endEdge]:m+"%"}})},"SliderRange")),tre="SliderThumb",[nre,DL]=pb(tre),rre="SliderThumbProvider";function NL(t){const{__scopeSlider:e,name:n,children:r,internal_do_not_use_render:s}=t,i=vh(rre,e),o=Zne(e),[l,u]=g.useState(null),d=g.useMemo(()=>l?o().findIndex(x=>x.ref.current===l):-1,[o,l]),f=cx(l),p=l?!!i.form||!!l.closest("form"):!0,m=i.values[d],v=n??(i.name?i.name+(i.values.length>1?"[]":""):void 0),w=m===void 0?0:mb(m,i.min,i.max);g.useEffect(()=>{if(l)return i.thumbs.add(l),()=>{i.thumbs.delete(l)}},[l,i.thumbs]);const _={value:m,name:v,form:i.form,isFormControl:p,index:d,thumb:l,onThumbChange:u,percent:w,size:f};return S.jsx(nre,{scope:e,..._,children:UL(s)?s(_):r})}kt(NL,"SliderThumbProvider");var Ry="SliderThumbTrigger",sre=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,...s}=e,i=vh(Ry,r),o=OL(Ry,r),{index:l,value:u,percent:d,size:f,onThumbChange:p}=DL(Ry,r),m=qt(n,p),v=jL(l,i.values.length),w=f==null?void 0:f[o.size],_=w?VL(w,d,o.direction):0;return S.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[o.startEdge]:`calc(${d}% + ${_}px)`},children:S.jsx(B2.ItemSlot,{scope:r,children:S.jsx(xn.span,{role:"slider","aria-label":e["aria-label"]||v,"aria-valuemin":i.min,"aria-valuenow":u,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:m,style:u===void 0?{display:"none"}:e.style,onFocus:Wt(e.onFocus,()=>{i.valueIndexToChangeRef.current=l})})})})},"SliderThumbTrigger")),ire=g.forwardRef(kt(function(e,n){const{__scopeSlider:r,name:s,...i}=e;return S.jsx(NL,{__scopeSlider:r,name:s,internal_do_not_use_render:({index:o,isFormControl:l})=>S.jsxs(S.Fragment,{children:[S.jsx(sre,{...i,ref:n,__scopeSlider:r}),l?S.jsx(are,{__scopeSlider:r},o):null]})})},"SliderThumb")),ore="SliderBubbleInput",are=g.forwardRef(kt(function({__scopeSlider:e,...n},r){const{value:s,name:i,form:o}=DL(ore,e),l=g.useRef(null),u=qt(l,r),d=TL(s);return g.useEffect(()=>{const f=l.current;if(!f)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"value").set;if(d!==s&&v){const w=new Event("input",{bubbles:!0});v.call(f,s),f.dispatchEvent(w)}},[d,s]),S.jsx(xn.input,{style:{display:"none"},name:i,form:o,...n,ref:u,defaultValue:s})},"SliderBubbleInput"));function $L(t=[],e,n){const r=[...t];return r[n]=e,r.sort((s,i)=>s-i)}kt($L,"getNextSortedValues");function mb(t,e,n){const i=100/(n-e)*(t-e);return hb(i,[0,100])}kt(mb,"convertValueToPercentage");function jL(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}kt(jL,"getLabel");function FL(t,e){if(t.length===1)return 0;const n=t.map(s=>Math.abs(s-e)),r=Math.min(...n);return n.indexOf(r)}kt(FL,"getClosestValueIndex");function VL(t,e,n){const r=t/2,i=ag([0,50],[0,r]);return(r-i(e)*n)*n}kt(VL,"getThumbInBoundsOffset");function HL(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}kt(HL,"getStepsBetweenValues");function zL(t,e){if(e>0){const n=HL(t);return Math.min(...n)>=e}return!0}kt(zL,"hasMinStepsBetweenValues");function ag(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}kt(ag,"linearScale");function gb(t){if(!Number.isFinite(t))return 0;const e=t.toString();if(e.includes("e")){const[r,s]=e.split("e"),i=r.split(".")[1]||"",o=Number(s);return Math.max(0,i.length-o)}const n=e.split(".")[1];return n?n.length:0}kt(gb,"getDecimalCount");function vf(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}kt(vf,"roundValue");function BL(t,{min:e,step:n,direction:r,multiplier:s}){const i=gb(n),o=(t-e)/n,l=Math.round(o),u=vf(l*n+e,i)===vf(t,i);let d;return u?d=l+s*r:r>0?d=Math.ceil(o):d=Math.floor(o),vf(d*n+e,i)}kt(BL,"getNextStepValue");function UL(t){return typeof t=="function"}kt(UL,"isFunction");const U2=g.forwardRef(({className:t,...e},n)=>S.jsxs(Kne,{ref:n,className:mn("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",t),...e,children:[S.jsx(Jne,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-input",children:S.jsx(ere,{className:"absolute h-full bg-primary"})}),S.jsx(ire,{className:mn("block h-3.5 w-3.5 rounded-full border border-border bg-foreground shadow-sm","transition-transform hover:scale-110 active:scale-95","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6B97FF]","disabled:pointer-events-none")})]}));U2.displayName="Slider";const lre=[{name:"surface-1",utility:"bg-surface-1",className:"bg-surface-1"},{name:"surface-2",utility:"bg-surface-2",className:"bg-surface-2"},{name:"surface-3",utility:"bg-surface-3",className:"bg-surface-3"},{name:"surface-4",utility:"bg-surface-4",className:"bg-surface-4"},{name:"surface-5",utility:"bg-surface-5",className:"bg-surface-5"},{name:"surface-6",utility:"bg-surface-6",className:"bg-surface-6"}],cre=[{name:"primary",utility:"bg-primary",className:"bg-primary"},{name:"selected",utility:"bg-selected",className:"bg-selected"},{name:"accent",utility:"bg-accent",className:"bg-accent"},{name:"success",utility:"bg-accent-success",className:"bg-accent-success"},{name:"warning",utility:"bg-accent-warning",className:"bg-accent-warning"},{name:"error",utility:"bg-accent-error",className:"bg-accent-error"}],ure=[{name:"gap-1",className:"w-1"},{name:"gap-2",className:"w-2"},{name:"gap-3",className:"w-3"},{name:"gap-4",className:"w-4"},{name:"gap-6",className:"w-6"},{name:"gap-8",className:"w-8"}],t0=[{name:"Accordion",path:"components/Accordion.tsx",status:"showcased",note:"Reusable primitive shown with local item composition."},{name:"AgentVariantsPanel",path:"components/AgentVariantsPanel.tsx",status:"feature-only",note:"Requires live variant session state and editor atoms."},{name:"AuthProgressScreen",path:"components/AuthProgressScreen.tsx",status:"feature-only",note:"Auth flow surface; represented through progress treatment."},{name:"AuthScreenView",path:"components/AuthScreenView.tsx",status:"feature-only",note:"Auth flow surface that depends on sign-in actions."},{name:"Button",path:"components/Button.tsx",status:"showcased",note:"Reusable tooltip-wrapped button shown in multiple states."},{name:"CommentCarouselLayer",path:"components/CommentCarouselLayer.tsx",status:"feature-only",note:"Preview overlay layer tied to iframe geometry."},{name:"CommentMarker",path:"components/CommentMarker.tsx",status:"feature-only",note:"Preview overlay marker tied to comment positions."},{name:"CommentMarkerLayer",path:"components/CommentMarkerLayer.tsx",status:"feature-only",note:"Preview overlay layer tied to comment collections."},{name:"CommentPopover",path:"components/CommentPopover.tsx",status:"feature-only",note:"Comment workflow popover tied to editor state."},{name:"CommentReferenceChip",path:"components/CommentReferenceChip.tsx",status:"feature-only",note:"Comment workflow chip tied to selected references."},{name:"CommentReferencePicker",path:"components/CommentReferencePicker.tsx",status:"feature-only",note:"Comment workflow picker tied to preview elements."},{name:"ElementInspector",path:"components/ElementInspector.tsx",status:"feature-only",note:"Primary editor surface with many app-level dependencies."},{name:"GitHome",path:"components/GitHome.tsx",status:"feature-only",note:"Git dashboard tied to repository state."},{name:"IframePreview",path:"components/IframePreview.tsx",status:"unsuitable",note:"Needs live iframe target and cross-window integration."},{name:"PreviewFrame",path:"components/PreviewFrame.tsx",status:"unsuitable",note:"Requires proxied app URL and iframe lifecycle."},{name:"PreviewSurface",path:"components/PreviewSurface.tsx",status:"unsuitable",note:"Requires preview iframe and overlay orchestration."},{name:"ProfileAvatar",path:"components/ProfileAvatar.tsx",status:"feature-only",note:"Account chrome tied to user identity data."},{name:"Progress",path:"components/Progress.tsx",status:"showcased",note:"Reusable inline loading/status primitive."},{name:"SecondaryVariantIframe",path:"components/SecondaryVariantIframe.tsx",status:"unsuitable",note:"Requires variant preview iframe lifecycle."},{name:"SparkleLoader",path:"components/SparkleLoader.tsx",status:"showcased",note:"Reusable loading animation shown in feedback states."},{name:"SplitButton",path:"components/SplitButton.tsx",status:"showcased",note:"Reusable compound action button shown with dropdown."},{name:"StatusSurface",path:"components/StatusSurface.tsx",status:"showcased",note:"Unified full-surface primitive: LoadingSurface / EmptyState / ErrorState."},{name:"SupportTicketModal",path:"components/SupportTicketModal.tsx",status:"feature-only",note:"Support workflow modal tied to form submission."},{name:"ThinkingIndicator",path:"components/ThinkingIndicator.tsx",status:"showcased",note:"Reusable thinking/loading indicator shown in feedback states."},{name:"Tooltip",path:"components/Tooltip.tsx",status:"showcased",note:"Reusable tooltip API shown with hover target."},{name:"VariantDragGhost",path:"components/VariantDragGhost.tsx",status:"feature-only",note:"Drag visual tied to variant split interactions."},{name:"VariantSplitDropZones",path:"components/VariantSplitDropZones.tsx",status:"feature-only",note:"Drop-zone visual tied to variant split interactions."},{name:"ui/accordion",path:"components/ui/accordion.tsx",status:"showcased",note:"Radix accordion primitive backing the local Accordion showcase."},{name:"ui/slider",path:"components/ui/slider.tsx",status:"showcased",note:"Radix slider primitive shown in enabled and disabled states."},{name:"ui/tooltip",path:"components/ui/tooltip.tsx",status:"showcased",note:"Radix tooltip primitive shown with forced-open preview."}],dre=()=>{window.location.hash=""},Yi=({title:t,eyebrow:e,description:n,children:r})=>S.jsxs("section",{className:"border-border bg-card shadow-surface-3 rounded-2xl border p-5",children:[S.jsxs("div",{className:"mb-5 max-w-2xl",children:[S.jsx("p",{className:"text-primary text-xs font-semibold tracking-[0.18em] uppercase",children:e}),S.jsx("h2",{className:"text-foreground mt-2 text-xl font-semibold",children:t}),S.jsx("p",{className:"text-muted-foreground mt-2 text-sm leading-6",children:n})]}),r]}),FC=({swatches:t})=>S.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:t.map(e=>S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-3",children:[S.jsx("div",{className:`h-16 rounded-lg ${e.className}`}),S.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3",children:[S.jsx("span",{className:"text-foreground text-sm font-medium",children:e.name}),S.jsx("code",{className:"bg-muted text-muted-foreground rounded px-2 py-1 text-xs",children:e.utility})]})]},e.name))}),fre=t=>t==="showcased"?"border-accent-success/40 bg-accent-success/10 text-accent-success":t==="cataloged"?"border-primary/40 bg-primary/10 text-primary":t==="generated"?"border-accent/40 bg-accent/10 text-accent":t==="unsuitable"?"border-accent-warning/40 bg-accent-warning/10 text-accent-warning":"border-border bg-surface-4 text-content-muted",hre=()=>{const t=t0.filter(n=>n.status==="showcased").length,e=t0.filter(n=>n.status==="cataloged").length;return S.jsx("main",{className:"bg-main font-main text-content h-screen overflow-y-auto",children:S.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-6 px-6 py-6 lg:px-8",children:[S.jsxs("header",{className:"border-border bg-surface-2 shadow-surface-4 rounded-3xl border p-6",children:[S.jsxs("button",{type:"button",onClick:dre,className:"text-content-subtle hover:text-content mb-6 inline-flex items-center gap-2 text-sm transition-colors",children:[S.jsx(QK,{className:"h-4 w-4",weight:"bold"}),"Back to editor"]}),S.jsxs("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between",children:[S.jsxs("div",{className:"max-w-3xl",children:[S.jsx("p",{className:"text-primary text-xs font-semibold tracking-[0.22em] uppercase",children:"Local component gallery"}),S.jsx("h1",{className:"text-foreground mt-3 text-4xl font-semibold tracking-tight",children:"Rivet design system"}),S.jsx("p",{className:"text-muted-foreground mt-3 text-base leading-7",children:"A Storybook-like route for checking the current UI primitives, tokens, and interaction states inside the Vite app."})]}),S.jsx("div",{className:"border-border bg-surface-3 rounded-2xl border p-4",children:S.jsxs("div",{className:"text-content-muted flex items-center gap-3 text-sm",children:[S.jsx(TR,{className:"text-primary h-5 w-5",weight:"bold"}),"Open with ",S.jsx("code",{className:"text-content",children:"#/design-system"})]})})]})]}),S.jsx(Yi,{eyebrow:"Controls",title:"Button, split button, and tooltip",description:"Rivet's shared Button exposes variants and sizes backed by Fluid Functionalism, alongside the split button and tooltip controls.",children:S.jsxs("div",{className:"grid gap-4 lg:grid-cols-[1fr_1fr]",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-3 text-sm font-medium",children:"Rivet Button"}),S.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[S.jsx(mo,{title:"Primary action",shortcut:"D",variant:"primary",children:"Design action"}),S.jsx(mo,{title:"Secondary action",variant:"secondary",children:"Secondary"}),S.jsx(mo,{title:"Disabled action",disabled:!0,variant:"tertiary",children:"Disabled"}),S.jsx(KR,{primaryLabel:"Ship",primaryIcon:oy,primaryAction:()=>{},dropdownItems:[{label:"Create PR",onClick:()=>{}},{label:"Copy branch",onClick:()=>{}}]})]})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-3 text-sm font-medium",children:"Tooltip states"}),S.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[S.jsx(Ul,{label:"Rivet tooltip API",side:"bottom",children:S.jsx("button",{className:"border-border bg-surface-4 text-content rounded-lg border px-4 py-2 text-sm",children:"Hover target"})}),S.jsx(px,{content:"Forced open preview",forceOpen:!0,side:"right",children:S.jsx("button",{className:"bg-selected text-content rounded-lg px-4 py-2 text-sm",children:"UI tooltip"})})]})]})]})}),S.jsx(Yi,{eyebrow:"Tokens",title:"Surface ladder",description:"Surface tokens move from the base app background toward raised panels without leaving the dark Rivet palette.",children:S.jsx(FC,{swatches:lre})}),S.jsx(Yi,{eyebrow:"Tokens",title:"Color roles",description:"Named roles should communicate purpose: brand, selection, neutral accent, and outcome colors.",children:S.jsx(FC,{swatches:cre})}),S.jsx(Yi,{eyebrow:"Type",title:"Typography",description:"Satoshi remains the default UI voice with clear hierarchy and muted support text.",children:S.jsxs("div",{className:"grid gap-4 lg:grid-cols-3",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-primary text-xs tracking-[0.18em] uppercase",children:"Display"}),S.jsx("p",{className:"text-foreground mt-2 text-3xl font-semibold tracking-tight",children:"Visual edits, quickly"})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground text-sm font-semibold",children:"Panel heading"}),S.jsx("p",{className:"text-muted-foreground mt-2 text-sm leading-6",children:"Body copy uses compact line height and muted contrast for dense inspector panels."})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs font-medium tracking-[0.16em] uppercase",children:"Micro label"}),S.jsx("code",{className:"bg-muted text-muted-foreground mt-3 block rounded-lg px-3 py-2 text-xs",children:"font-main text-content"})]})]})}),S.jsx(Yi,{eyebrow:"Layout",title:"Spacing rhythm",description:"A compact spacing scale keeps editor chrome dense while preserving scannable groupings.",children:S.jsx("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:S.jsx("div",{className:"flex flex-col gap-3",children:ure.map(n=>S.jsxs("div",{className:"flex items-center gap-4",children:[S.jsx("code",{className:"text-muted-foreground w-16 text-xs",children:n.name}),S.jsx("div",{className:`${n.className} bg-primary h-4 rounded`}),S.jsx("div",{className:"bg-border h-px flex-1"})]},n.name))})})}),S.jsx(Yi,{eyebrow:"Primitives",title:"Accordion and slider",description:"Representative Radix primitives styled through the local component layer.",children:S.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[S.jsxs(A0,{defaultValue:["foundations"],className:"border-border bg-surface-2 rounded-xl border p-2",children:[S.jsx(A0.Item,{value:"foundations",title:"Foundations",description:"Tokens, surfaces, type, and spacing.",className:"first-item",icon:S.jsx(oy,{className:"text-primary h-4 w-4"}),children:S.jsx("p",{children:"Use these pieces before adding one-off visual rules."})}),S.jsx(A0.Item,{value:"components",title:"Components",description:"Buttons, tooltips, accordions, sliders.",children:S.jsx("p",{children:"Keep states visible in this route as the system evolves."})})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-5",children:[S.jsx("p",{className:"text-foreground mb-5 text-sm font-medium",children:"Slider states"}),S.jsxs("div",{className:"space-y-6",children:[S.jsx(U2,{defaultValue:[64],max:100,step:1}),S.jsx(U2,{defaultValue:[36],max:100,step:1,disabled:!0})]})]})]})}),S.jsx(Yi,{eyebrow:"Feedback",title:"Motion and loading",description:"Loading states use existing CSS animation utilities and avoid per-frame React work where possible.",children:S.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-4 text-sm font-medium",children:"Progress"}),S.jsx(One,{message:"Applying visual change..."})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-4 text-sm font-medium",children:"Sparkle strip"}),S.jsx(Dx,{className:"text-primary text-xl"})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-foreground mb-4 text-sm font-medium",children:"Shimmer text"}),S.jsx("span",{className:"shimmer-text text-sm font-medium",children:"Generating variants"})]}),S.jsx("div",{className:"border-border bg-surface-2 rounded-xl border p-4 sm:col-span-3",children:S.jsx(Vne,{hint:"Reading selected elements"})})]})}),S.jsx(Yi,{eyebrow:"Feedback",title:"Status surfaces",description:"The unified full-surface system: one StatusSurface primitive with LoadingSurface / EmptyState / ErrorState wrappers. Every full-page loading, empty, and error state routes through these so they share layout, copy tone, and a single status_surface_shown impression event. Inline loaders (Sparkle, ThinkingIndicator, above) stay inline and are deliberately not part of this system.",children:S.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[S.jsx("div",{className:"border-border relative h-56 overflow-hidden rounded-xl border",children:S.jsx(E2,{fill:"surface",loader:"coalesce",trackGlobalLoaderCount:!1})}),S.jsx("div",{className:"border-border relative h-56 overflow-hidden rounded-xl border",children:S.jsx(vM,{icon:S.jsx(oy,{size:32}),title:"Nothing to preview yet",description:"Pick a direction from the panel."})}),S.jsx("div",{className:"border-border relative h-56 overflow-hidden rounded-xl border",children:S.jsx($x,{fill:"surface",size:"sm",title:"Preview isn't connected",description:"Rivet lost connection to your project.",actions:[{label:"Reload",onClick:()=>{}}]})})]})}),S.jsxs(Yi,{eyebrow:"Inventory",title:"Component coverage",description:"Every current component file is accounted for here. Reusable primitives are rendered above; app surfaces that need live editor, git, auth, iframe, or generated state are cataloged instead of mounted unsafely.",children:[S.jsxs("div",{className:"mb-4 grid gap-3 sm:grid-cols-3",children:[S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs tracking-[0.16em] uppercase",children:"Total components"}),S.jsx("p",{className:"text-foreground mt-2 text-2xl font-semibold",children:t0.length})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs tracking-[0.16em] uppercase",children:"Showcased"}),S.jsx("p",{className:"text-accent-success mt-2 text-2xl font-semibold",children:t})]}),S.jsxs("div",{className:"border-border bg-surface-2 rounded-xl border p-4",children:[S.jsx("p",{className:"text-content-subtle text-xs tracking-[0.16em] uppercase",children:"Cataloged"}),S.jsx("p",{className:"text-primary mt-2 text-2xl font-semibold",children:e})]})]}),S.jsxs("div",{className:"border-border overflow-hidden rounded-xl border",children:[S.jsxs("div",{className:"border-border bg-surface-3 text-content-subtle grid grid-cols-[minmax(140px,1fr)_minmax(110px,auto)_minmax(220px,2fr)] border-b px-4 py-3 text-xs font-semibold tracking-[0.14em] uppercase",children:[S.jsx("span",{children:"Component"}),S.jsx("span",{children:"Status"}),S.jsx("span",{children:"Coverage note"})]}),S.jsx("div",{className:"divide-border bg-surface-2 divide-y",children:t0.map(n=>S.jsxs("div",{className:"grid grid-cols-[minmax(140px,1fr)_minmax(110px,auto)_minmax(220px,2fr)] gap-3 px-4 py-3 text-sm",children:[S.jsxs("div",{children:[S.jsx("p",{className:"text-foreground font-medium",children:n.name}),S.jsx("code",{className:"text-muted-foreground text-xs",children:n.path})]}),S.jsx("div",{children:S.jsx("span",{className:`inline-flex rounded-full border px-2 py-1 text-xs font-medium ${fre(n.status)}`,children:n.status})}),S.jsx("p",{className:"text-muted-foreground",children:n.note})]},n.path))})]})]})]})})},pre=t=>(t.startsWith("#/")?t.slice(2):t.slice(1)).split("?")[0]==="design-system"?"design-system":"editor",W2=274,Am=395,My=Math.min(Am,Math.round((W2+Am)/2*1.1)),VC="rivet:panelWidth:v2",mre=t=>{if(!(t instanceof HTMLElement))return!1;const e=t.tagName.toLowerCase();return t.isContentEditable||e==="input"||e==="textarea"||e==="select"},gre=({projectPath:t})=>{const e=it(BR)>0,[n,r]=D5(HR),s=PU(),[i,o]=g.useState(()=>{if(typeof window>"u")return My;const T=Number(window.localStorage.getItem(VC));return Number.isFinite(T)&&T>=W2&&T<=Am?T:My}),[l,u]=g.useState(!1),[d,f]=g.useState(Cee),p=n?i:0,[m,v]=g.useState(n);g.useEffect(()=>{if(!n){v(!1);return}f(T=>kee({position:T,boundsLeftPx:i}))},[n,i]),g.useEffect(()=>{window.localStorage.setItem(VC,String(i))},[i]),g.useEffect(()=>{if(!n)return;const T=A=>{A.key==="Escape"&&(mre(A.target)||(A.preventDefault(),r(!1)))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n,r]);const w=g.useCallback(T=>{T.preventDefault(),T.stopPropagation();const A=T.clientX,M=i;u(!0);const R=L=>{const N=Math.min(Am,Math.max(W2,M+(L.clientX-A)));o(N)},I=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",I),window.removeEventListener("pointercancel",I),u(!1)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",I),window.addEventListener("pointercancel",I)},[i]),_=g.useCallback(()=>o(My),[]),x=Fee(),b=it(Qm);zee({enabled:!b});const k=x.isProcessing?"Completing authentication...":null,C=dt(Lx);return g.useEffect(()=>{C(t??null)},[t,C]),S.jsxs(ei.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[k!==null?S.jsx("div",{className:"absolute inset-0 z-50",children:S.jsx(fee,{message:k})}):null,S.jsx("div",{className:"relative flex min-w-0 flex-1 flex-col",children:S.jsx(VQ,{})}),S.jsx(S.Fragment,{children:e?null:S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"relative order-first h-full flex-shrink-0",style:{width:m?i:0},children:S.jsxs(ei.div,{className:"absolute inset-y-0 left-0 z-30",initial:!1,animate:{x:n?0:-i},transition:s?{duration:0}:{duration:.2,ease:[.22,1,.36,1]},onAnimationComplete:()=>{n&&v(!0)},style:{width:i,willChange:"transform"},children:[S.jsx(JX,{onClose:()=>r(!1)}),S.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panel",onPointerDown:w,onDoubleClick:_,className:"group/resize absolute inset-y-0 right-0 z-20 flex w-3 cursor-col-resize touch-none justify-end",children:S.jsx("span",{className:`h-full transition-all duration-150 ${l?"bg-content-muted w-0.5":"bg-divider group-hover/resize:bg-content-muted w-px group-hover/resize:w-0.5"}`})})]})}),l&&S.jsx("div",{className:"fixed inset-0 z-[100] cursor-col-resize"}),S.jsx(Aee,{isVisible:!0,isPanelOpen:n,isReducedMotion:!!s,position:d,dragBoundsLeftPx:p,onPositionChange:f,onToggle:()=>r(T=>!T)})]})}),S.jsx(rW,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},Z2="rivet_connect_deep_link",vre=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),e=t.get("connect"),n=e??window.sessionStorage.getItem(Z2);if(n!=="pinterest"&&n!=="arena")return null;if(window.sessionStorage.setItem(Z2,n),e){t.delete("connect");const r=t.toString();window.history.replaceState(null,document.title,window.location.pathname+(r?`?${r}`:"")+window.location.hash)}return n},yre=vre(),_re=()=>{const[t,e]=g.useState(window.location.hash),[n]=g.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(wm)==="1"),[r,s]=g.useState(!1),[i,o]=g.useState(yre);g.useEffect(()=>{n&&window.sessionStorage.removeItem(wm)},[n]);const{config:l,refetchConfig:u,loading:d,error:f}=$ee(),p=dt(Qm),{startLogin:m,isStartingLogin:v,loginError:w}=cM(),[_,x]=g.useState(!1);g.useEffect(()=>{l!=null&&l.userId?(Ee.identify(l.userId,{...l.email?{email:l.email}:{}}),l.email&&Ee.alias(l.email,l.userId)):l!=null&&l.email&&Ee.identify(l.email,{email:l.email})},[l==null?void 0:l.userId,l==null?void 0:l.email]),g.useEffect(()=>{l&&Ee.register({source:"visual_editor",surface:"visual_editor"})},[l]);const b=l!=null&&l.agentModeAvailable!==!0,k=pre(t),C=g.useCallback(async()=>{x(!0),p(!0);try{await u()}finally{p(!1),x(!1)}},[u,p]);if(g.useEffect(()=>{const R=()=>{const I=window.location.hash;e(I)};return window.addEventListener("hashchange",R),()=>window.removeEventListener("hashchange",R)},[]),k==="design-system")return S.jsx(hre,{});if(!d&&l===null&&!_){const R=f||"Could not load Rivet configuration.";return S.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:S.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[S.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),S.jsx("p",{className:"text-content-dim mt-2 text-xs",children:R}),S.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{C()},children:"Retry"})]})})}if(b)return S.jsx(uee,{isSigningIn:v,onStartSignIn:()=>{m()},errorMessage:w,displayMode:"full"});const A=(l==null?void 0:l.agentModeAvailable)===!0&&i!==null,M=(l==null?void 0:l.agentModeAvailable)===!0&&n&&!r&&!A;return S.jsxs(S.Fragment,{children:[S.jsx(gre,{projectPath:l==null?void 0:l.projectPath}),S.jsx(S2,{context:"onboarding",isOpen:M,onClose:()=>s(!0)}),S.jsx(S2,{context:"menu",isOpen:A,highlightProvider:i,onClose:()=>{window.sessionStorage.removeItem(Z2),o(null)}})]})};Zj();const wre=g.lazy(()=>XC(()=>import("./LibraryApp-DXPBLgDE.js"),[])),xre=window.location.pathname.startsWith("/rivet/library"),bre="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",Sre=new QD,Ere={session_recording:{maskAllInputs:!0,maskTextSelector:"[data-rivet-private]"}},kre=()=>S.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:S.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});Qj.createRoot(document.getElementById("root")).render(S.jsx(we.StrictMode,{children:S.jsx(Fj,{apiKey:bre,options:{api_host:"https://rivet-proxy.onrender.com/ingest",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",...Ere,mask_all_text:!1,mask_all_element_attributes:!1,loaded:t=>{t.register({source:"visual_editor",surface:"visual_editor",telemetry_version:2,rivet_version:"0.17.2",env:"production"})}},children:S.jsx(Uj,{fallback:S.jsx(kre,{}),children:S.jsx(CD,{client:Sre,children:S.jsx(QW,{defaultShape:"rounded",children:S.jsx(Ine,{defaultLibrary:"lucide",children:xre?S.jsx(g.Suspense,{fallback:S.jsx("div",{className:"bg-background h-screen"}),children:S.jsx(wre,{})}):S.jsx(_re,{})})})})})})}));export{Sx as A,mo as B,Mx as C,_x as D,Ex as E,xt as F,hee as G,yne as H,Tre as I,Ire as J,M0 as K,Rre as L,Nte as M,QX as N,rW as O,Rx as P,ZD as Q,Ax as R,nh as S,Ix as T,TX as U,Pne as X,JD as a,nN as b,g as c,rN as d,oN as e,sN as f,KD as g,yf as h,$r as i,aN as j,lN as k,iN as l,s3 as m,nr as n,Qe as o,Zl as p,DR as q,n3 as r,Zv as s,S as t,JC as u,h2 as v,dne as w,wx as x,xx as y,bx as z};
|
package/src/ui/dist/index.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
9
9
|
<title>Rivet - The visual editor for design</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/main-
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/main-
|
|
10
|
+
<script type="module" crossorigin src="/assets/main-CQ8l2PxN.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/main-BUZjlAHd.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|