(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,213043,e=>{"use strict";var t=e.i(659350),r=e.i(663456),n=e.i(136562),s=e.i(6146),a=e.i(670168),l=e.i(199630),i=e.i(948235),o=e.i(624621);let c=["w-3/5","w-4/5"],d=["w-3/4","w-1/2","w-5/6","w-2/3","w-3/5","w-4/5"];function m(e){let n,s,l=(0,r.c)(3),{width:i}=e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(a.l,{className:"h-3.5 w-full"}),l[0]=n):n=l[0],l[1]!==i?(s=(0,t.jsx)("div",{className:"flex h-9 items-center rounded-lg px-3",children:(0,t.jsx)("div",{className:i,children:n})}),l[1]=i,l[2]=s):s=l[2],s}function u(){let e,s,i,m,u,p,g,v,b,j,y,w,N,_=(0,r.c)(16),S=(0,o.f)(x);if((0,l.f)()&&S){let e,r,s;return _[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.f)("hidden md:flex h-full w-13.5 shrink-0 flex-col p-px","bg-background border-r border-border"),_[0]=e):e=_[0],_[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,t.jsx)(a.l,{className:"size-5"})}),_[1]=r):r=_[1],_[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("aside",{className:e,children:(0,t.jsx)("div",{className:"flex h-full w-full flex-col gap-2 p-2",children:(0,t.jsxs)("div",{className:"flex w-full flex-col items-center gap-1",children:[r,(0,t.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,t.jsx)(a.l,{className:"size-5"})})]})})}),_[2]=s):s=_[2],s}return _[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.f)("hidden md:flex h-full w-65 shrink-0 flex-col p-px","bg-background border-r border-border"),_[3]=e):e=_[3],_[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(a.l,{className:"h-4 w-12"}),_[4]=s):s=_[4],_[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)("div",{className:"flex h-9 w-full items-center justify-between gap-2 px-1",children:[s,(0,t.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,t.jsx)(a.l,{className:"size-5"})})]}),_[5]=i):i=_[5],_[6]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsxs)("div",{className:"flex h-8 w-full shrink-0 items-center gap-3 rounded-md border border-border px-3",children:[(0,t.jsx)(a.l,{className:"size-4 rounded-sm"}),(0,t.jsx)(a.l,{className:"h-3.5 w-16"})]}),_[6]=m):m=_[6],_[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsxs)("div",{className:"flex h-8 w-full shrink-0 items-center gap-3 rounded-md border border-border pl-3 pr-1",children:[(0,t.jsx)(a.l,{className:"size-4 rounded-sm"}),(0,t.jsx)(a.l,{className:"h-3.5 w-24"})]}),_[7]=u):u=_[7],_[8]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("div",{"aria-hidden":"true",className:"shrink-0 -mx-2 py-4",children:(0,t.jsx)("div",{className:"h-px bg-border"})}),_[8]=p):p=_[8],_[9]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between pr-1",children:[(0,t.jsx)(a.l,{className:"ml-3 h-3 w-14"}),(0,t.jsx)(a.l,{className:"h-3 w-10"})]}),_[9]=g):g=_[9],_[10]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:"flex items-center px-3 pb-1 pt-2",children:(0,t.jsx)(a.l,{className:"h-3 w-12"})}),_[10]=v):v=_[10],_[11]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:c.map(h)}),_[11]=b):b=_[11],_[12]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)("div",{className:"flex items-center px-3 pb-1 pt-4",children:(0,t.jsx)(a.l,{className:"h-3 w-16"})}),_[12]=j):j=_[12],_[13]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-hidden",children:[v,b,j,(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:d.map(f)})]}),_[13]=y):y=_[13],_[14]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-border"}),_[14]=w):w=_[14],_[15]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)("aside",{className:e,children:(0,t.jsxs)("div",{className:"flex h-full w-full flex-col gap-2 p-2",children:[i,m,u,p,g,y,(0,t.jsxs)("div",{className:"relative -mx-2 shrink-0 px-2 pb-2 pt-2",children:[w,(0,t.jsxs)("div",{className:"flex h-10 w-full items-center gap-2 rounded-md px-2",children:[(0,t.jsx)(a.l,{className:"size-6"}),(0,t.jsx)(a.l,{className:"h-3.5 w-24"})]})]})]})}),_[15]=N):N=_[15],N}function f(e){return(0,t.jsx)(m,{width:e},e)}function h(e){return(0,t.jsx)(m,{width:e},e)}function x(e){return e.isRoomManagerCollapsed}function p(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border pl-2 pr-1",children:[(0,t.jsx)(a.l,{className:"size-6 rounded-full"}),(0,t.jsx)(a.l,{className:"h-3.5 w-24"}),(0,t.jsx)(a.l,{className:"size-4 rounded-sm"})]}),n[0]=e):e=n[0],e}function g(){let e,s,l,i,o,c,d,m,u=(0,r.c)(8);return u[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.f)("shrink-0 flex gap-2 px-2 md:pl-0","max-md:items-center md:items-start","border-b border-border pb-2"),u[0]=e):e=u[0],u[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1 md:hidden",children:[(0,t.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center",children:(0,t.jsx)(a.l,{className:"size-5"})}),(0,t.jsx)(a.l,{className:"h-4 w-28"})]}),u[1]=s):s=u[1],u[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("div",{className:"shrink-0 self-start pl-3",children:(0,t.jsx)(a.l,{className:"h-9 w-18 rounded-md"})}),u[2]=l):l=u[2],u[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)("div",{className:"hidden min-w-0 items-start gap-2 p-px md:flex md:flex-1",children:[l,(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[(0,t.jsx)(p,{}),(0,t.jsx)(p,{})]})]}),u[3]=i):i=u[3],u[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 md:hidden",children:[(0,t.jsx)(p,{}),(0,t.jsx)(a.l,{className:"h-9 w-9 rounded-md"})]}),u[4]=o):o=u[4],u[5]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(a.l,{className:"hidden h-9 w-28 rounded-md md:block"}),u[5]=c):c=u[5],u[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,t.jsx)(a.l,{className:"size-5"})}),u[6]=d):d=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsxs)("div",{className:e,children:[s,i,o,(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[c,d,(0,t.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,t.jsx)(a.l,{className:"size-5"})})]})]}),u[7]=m):m=u[7],m}let v=["w-28","w-36","w-24","w-32"];function b(e){let s,l,i,o,c,d=(0,r.c)(7),{titleWidth:m}=e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,n.f)("flex h-28 w-64 flex-col justify-between md:h-32 md:w-52 lg:w-64","rounded-lg border border-border bg-card p-4"),d[0]=s):s=d[0],d[1]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(a.l,{className:"h-4 w-full"}),d[1]=l):l=d[1],d[2]!==m?(i=(0,t.jsx)("div",{className:m,children:l}),d[2]=m,d[3]=i):i=d[3],d[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxs)("div",{className:"flex justify-end",children:[(0,t.jsx)(a.l,{className:"size-6 rounded-full ring-2 ring-card -me-2"}),(0,t.jsx)(a.l,{className:"size-6 rounded-full ring-2 ring-card -me-2"}),(0,t.jsx)(a.l,{className:"size-6 rounded-full ring-2 ring-card"})]}),d[4]=o):o=d[4],d[5]!==i?(c=(0,t.jsxs)("div",{className:s,children:[i,o]}),d[5]=i,d[6]=c):c=d[6],c}function j(){let e,s,a,l=(0,r.c)(3);return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.f)("relative flex w-full shrink-0 items-center justify-center","min-h-0 flex-1","flex-col overflow-hidden py-4 md:py-6"),l[0]=e):e=l[0],l[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("div",{className:"hidden grid-cols-2 gap-4 md:grid",children:v.map(w)}),l[1]=s):s=l[1],l[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)("div",{className:e,children:[s,(0,t.jsx)("div",{className:"grid w-full grid-cols-2 gap-2 px-3 md:hidden",children:v.map(y)})]}),l[2]=a):a=l[2],a}function y(e){return(0,t.jsx)(a.l,{className:"min-h-20 rounded-xl"},e)}function w(e){return(0,t.jsx)(b,{titleWidth:e},e)}function N(){let e,s,a=(0,r.c)(2);return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.f)("relative flex w-full shrink-0 items-center justify-start","max-w-4xl mx-auto overflow-hidden","pt-2 md:pt-3"),a[0]=e):e=a[0],a[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("div",{className:e,children:[(0,t.jsx)("div",{className:"hidden w-full gap-4 px-3 md:flex",children:Array.from({length:6}).map(S)}),(0,t.jsx)("div",{className:(0,n.f)("md:hidden grid w-full","grid-flow-col grid-rows-2 auto-cols-[10.5rem]","gap-2 overflow-hidden px-3"),children:Array.from({length:6}).map(_)})]}),a[1]=s):s=a[1],s}function _(e,r){return(0,t.jsx)(a.l,{className:"h-16 rounded-xl"},`prompt-preset-m-${r}`)}function S(e,r){return(0,t.jsx)(a.l,{className:"h-16 w-52 shrink-0 rounded-lg"},`prompt-preset-${r}`)}function k(){let e,n,s,l,o,c,d=(0,r.c)(6);return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex h-9 items-center px-2",children:(0,t.jsx)(a.l,{className:"h-3.5 w-28"})}),d[0]=e):e=d[0],d[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)(a.l,{className:"size-9 rounded-full"}),(0,t.jsx)(a.l,{className:"size-9 rounded-full"}),(0,t.jsx)(a.l,{className:"size-9 rounded-full"}),(0,t.jsx)(a.l,{className:"size-9 rounded-full"})]}),d[1]=n):n=d[1],d[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsxs)("div",{className:"hidden flex-col gap-1 md:flex",children:[e,(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[n,(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,t.jsx)(a.l,{className:"size-9 rounded-full"}),(0,t.jsx)(a.l,{className:"size-9 rounded-full"})]})]})]}),d[2]=s):s=d[2],d[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(a.l,{className:"size-9 shrink-0 rounded-full"}),d[3]=l):l=d[3],d[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:"flex h-9 min-w-0 flex-1 items-center px-2",children:(0,t.jsx)(a.l,{className:"h-3.5 w-24"})}),d[4]=o):o=d[4],d[5]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("div",{className:"absolute bottom-3 left-0 right-0 z-10 px-1 md:bottom-6 md:px-4",children:(0,t.jsxs)("div",{className:"mx-auto w-full max-w-4xl",children:[(0,t.jsxs)("div",{className:"rounded-3xl border border-border bg-popover px-3 py-1.5",children:[s,(0,t.jsxs)("div",{className:"flex items-center gap-1.5 md:hidden",children:[l,o,(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)(a.l,{className:"size-9 rounded-full"}),(0,t.jsx)(a.l,{className:"size-9 rounded-full"})]})]})]}),(0,t.jsx)(i.f,{})]})}),d[5]=c):c=d[5],c}e.s(["ModelPresetsSkeleton",0,j,"PlaygroundSkeleton",0,function(){let e,a,l,i,o,c,d=(0,r.c)(8),m=(0,s.B)();return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.f)("flex flex-col md:flex-row","w-full text-muted-foreground","overflow-hidden","fixed inset-x-0 bottom-0 top-[calc(var(--playground-nav-offset,var(--navbar-height))+var(--navbar-top,0px))]","bg-background"),d[0]=e):e=d[0],d[1]!==m?(a=!m&&(0,t.jsx)(u,{}),d[1]=m,d[2]=a):a=d[2],d[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(g,{}),d[3]=l):l=d[3],d[4]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden pr-0 md:pr-6",children:(0,t.jsx)(j,{})}),d[4]=i):i=d[4],d[5]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col bg-card pt-2",children:[(0,t.jsxs)("div",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden",children:[l,(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[i,(0,t.jsx)("div",{className:"shrink-0 mb-(--composer-clearance,8rem)",children:(0,t.jsx)(N,{})})]})]}),(0,t.jsx)(k,{})]}),d[5]=o):o=d[5],d[6]!==a?(c=(0,t.jsxs)("div",{"aria-busy":"true","data-workspace-surface-shell":"",className:e,children:[a,o]}),d[6]=a,d[7]=c):c=d[7],c}])},57539,e=>{"use strict";var t=e.i(659350),r=e.i(663456),n=e.i(657288),s=e.i(510433),a=e.i(136562),l=e.i(139697),i=e.i(751155),o=e.i(361694),c=e.i(236614),d=e.i(231171),m=e.i(16043);function u(){return window.addEventListener("dragover",f),window.addEventListener("drop",f),()=>{window.removeEventListener("dragover",f),window.removeEventListener("drop",f)}}function f(e){e.dataTransfer?.types.includes("Files")&&e.preventDefault()}e.i(707060);var h=e.i(288265),x=e.i(693946),p=e.i(624621),g=e.i(556427),v=e.i(213043),b=e.i(829104),j=e.i(205059),y=e.i(673897),w=e.i(561124),N=e.i(250855),_=e.i(535072),S=e.i(22422),k=e.i(648292),C=e.i(73867),z=e.i(988199),I=e.i(977921);e.i(818009);var T=e.i(982432),M=e.i(510164),E=e.i(326282),A=e.i(368386),R=e.i(647204),P=e.i(973811),D=e.i(708638),F=e.i(235045);let V=e=>{let n,s,a,l,o,c,d=(0,r.c)(16),{attachments:m}=e,u=(0,h.f)();d[0]!==m.limit||d[1]!==m.list.length||d[2]!==u?(n=m.list.length>=m.limit?u("Maximum {limit} attachments added. Actual limit varies based on model and provider.",{limit:m.limit}):u("Limit: {limit} attachments per message. Actual limit varies based on model and provider.",{limit:m.limit}),d[0]=m.limit,d[1]=m.list.length,d[2]=u,d[3]=n):n=d[3];let f=n,x=m.list.length>=m.limit;return d[4]!==m?(s=async()=>{await m.handleFiles((0,M.z)())},d[4]=m,d[5]=s):s=d[5],d[6]!==u?(a=u("Add attachment"),d[6]=u,d[7]=a):a=d[7],d[8]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(D.f,{className:"size-5"}),d[8]=l):l=d[8],d[9]!==x||d[10]!==s||d[11]!==a?(o=(0,t.jsx)("span",{className:"inline-flex",children:(0,t.jsx)(F.f,{isIconOnly:!0,disabled:x,onClick:s,"aria-label":a,children:l})}),d[9]=x,d[10]=s,d[11]=a,d[12]=o):o=d[12],d[13]!==o||d[14]!==f?(c=(0,t.jsx)(i.Tooltip,{width:"sm",content:f,children:o}),d[13]=o,d[14]=f,d[15]=c):c=d[15],c};var O=e.i(623102),L=e.i(903121),B=e.i(8213);function q(e){let{prompt:t,attachments:r,lastSubmission:n,setPrompt:s,setCommandMode:a}=e,l=t.trim();(""===l||l===n.current?.prompt)&&0===r.list.length&&n.current&&(s(n.current.prompt),r.set(n.current.attachments),a&&a(n.current.commandMode))}var W=e.i(338749),$=e.i(895183);let U=e=>{let n,s,i,o,c,d=(0,r.c)(16),{mode:m,currentMode:u,icon:f,label:h,onSelect:x,disabled:p}=e,g=u===m,v=g&&"bg-primary hover:bg-primary/90 text-primary-foreground border-transparent";return d[0]!==v?(n=(0,a.f)(v),d[0]=v,d[1]=n):n=d[1],d[2]!==m||d[3]!==x?(s=()=>x(m),d[2]=m,d[3]=x,d[4]=s):s=d[4],d[5]!==f?(i=(0,t.jsx)(f,{className:"size-4"}),d[5]=f,d[6]=i):i=d[6],d[7]!==h?(o=(0,t.jsx)("span",{children:h}),d[7]=h,d[8]=o):o=d[8],d[9]!==p||d[10]!==g||d[11]!==n||d[12]!==s||d[13]!==i||d[14]!==o?(c=(0,t.jsxs)(l.Button,{shape:"pill",type:"button",size:"sm",variant:"outline",className:n,"aria-pressed":g,onClick:s,disabled:p,children:[i,o]}),d[9]=p,d[10]=g,d[11]=n,d[12]=s,d[13]=i,d[14]=o,d[15]=c):c=d[15],c},H=e=>{let n,s,a,l,i,o=(0,r.c)(17),{mode:c,onSelect:d,disabled:m}=e,u=(0,h.f)();return o[0]!==u?(n=u("Generate"),o[0]=u,o[1]=n):n=o[1],o[2]!==m||o[3]!==c||o[4]!==d||o[5]!==n?(s=(0,t.jsx)(U,{mode:"generate",currentMode:c,icon:$.f,label:n,onSelect:d,disabled:m}),o[2]=m,o[3]=c,o[4]=d,o[5]=n,o[6]=s):s=o[6],o[7]!==u?(a=u("Brainstorm"),o[7]=u,o[8]=a):a=o[8],o[9]!==m||o[10]!==c||o[11]!==d||o[12]!==a?(l=(0,t.jsx)(U,{mode:"chat",currentMode:c,icon:W.f,label:a,onSelect:d,disabled:m}),o[9]=m,o[10]=c,o[11]=d,o[12]=a,o[13]=l):l=o[13],o[14]!==s||o[15]!==l?(i=(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[s,l]}),o[14]=s,o[15]=l,o[16]=i):i=o[16],i};var G=e.i(439994);let K=e=>{let n,s,a,l=(0,r.c)(12),{prompt:i,disabled:o,isLoading:c,onSend:d,onStop:m,mode:u}=e,f=void 0!==c&&c,x=(0,h.f)();l[0]!==i?(n=i.trim(),l[0]=i,l[1]=n):n=l[1];let p=n.length>0;return l[2]!==x||l[3]!==u?(s="generate"===u?x("Generate new version"):void 0,l[2]=x,l[3]=u,l[4]=s):s=l[4],l[5]!==o||l[6]!==f||l[7]!==d||l[8]!==m||l[9]!==p||l[10]!==s?(a=(0,t.jsx)(G.f,{isGenerating:o,canSend:p,isLoading:f,onSend:d,onStop:m,specialModeLabel:s}),l[5]=o,l[6]=f,l[7]=d,l[8]=m,l[9]=p,l[10]=s,l[11]=a):a=l[11],a},J=e=>e.activeArtifactId,Z=e=>e.currentRoomId,Q=(0,P.l)([J,e=>e.artifacts],(e,t)=>e?t[e]?.type:void 0),X=(0,P.l)([J,Z,e=>e.artifacts,e=>e.rooms],(...e)=>{let[t,r,n,s]=e;if(!t||!r)return null;let a=n[t];return a?.activeCharacterId?s[r]?.characters[a.activeCharacterId]??null:null}),Y=(0,P.l)([Z,e=>e.rooms],(e,t)=>!!e&&(t[e]?.isProcessing??!1)),ee=(0,P.l)([J,e=>e.artifactViewerState,e=>e.artifactVersions],(e,t,r)=>{if(!e)return null;let n=t[e]?.activeVersionId;return n?r[n]?.generationStatus??null:null}),et=()=>{let e,n,s,a,l,i,o,c,d,u,f,x,g,v=(0,r.c)(54),b=(0,h.f)(),j=(0,m.useRef)(null),y=(0,m.useRef)(null),[w,N]=(0,m.useState)(""),[_,k]=(0,m.useState)("generate"),C=(0,m.useRef)(null),z=(0,E.E)(),{isDragging:I,isValid:P}=(0,A.f)(y),D=(0,p.f)(J),F=(0,p.f)(Q),W=(0,p.f)(Z),$=(0,p.f)(X),U=(0,p.f)(Y),G="generating"===(0,p.f)(ee),et=z.loadingKeys.size>0,er=U||G;v[0]===Symbol.for("react.memo_cache_sentinel")?(e=e=>{k(e),setTimeout(()=>j.current?.focus(),1)},v[0]=e):e=v[0];let en=e;v[1]!==D||v[2]!==$||v[3]!==F||v[4]!==z||v[5]!==W||v[6]!==b||v[7]!==et||v[8]!==er||v[9]!==_||v[10]!==w?(n=async()=>{if(!w.trim()&&0===z.list.length||!D||!W||er||et)return;if(!$)return void(0,T.c)({title:b("No model selected"),description:b("Please select a model to use for generation."),variant:"destructive"});let e={prompt:w,attachments:z.list};if(C.current=e,N(""),z.reset(),"chat"===_)S.z.sendConversationPromptToArtifact({payload:{roomId:W,artifactId:D,content:e.prompt,attachments:e.attachments}});else{if("app"!==F){(0,T.c)({title:b("Cannot Generate"),description:b("Generation is only supported for app artifacts with a defined archetype."),variant:"destructive"}),q({prompt:w,attachments:z,lastSubmission:C,setPrompt:N});return}let t=await S.z.sendGenerationPromptToArtifact({payload:{roomId:W,artifactId:D,prompt:e.prompt,attachments:e.attachments}});(0,R.V)(t)&&q({prompt:w,attachments:z,lastSubmission:C,setPrompt:N})}C.current=null},v[1]=D,v[2]=$,v[3]=F,v[4]=z,v[5]=W,v[6]=b,v[7]=et,v[8]=er,v[9]=_,v[10]=w,v[11]=n):n=v[11];let es=n;v[12]!==D||v[13]!==W||v[14]!==G?(s=()=>{if(G){let e=D&&p.f.getState().artifactViewerState[D]?.activeVersionId;e&&W&&D&&S.z.stopArtifactVersionGeneration({payload:{roomId:W,artifactId:D,versionId:e}})}else S.z.stopGeneration()},v[12]=D,v[13]=W,v[14]=G,v[15]=s):s=v[15];let ea=s;v[16]!==b||v[17]!==_?(a="chat"===_?b("Chat, brainstorm, or discuss this artifact..."):b("Describe the changes to generate a new version..."),v[16]=b,v[17]=_,v[18]=a):a=v[18];let el=a;return v[19]!==z?(l=(0,t.jsx)(O.f,{attachments:z}),v[19]=z,v[20]=l):l=v[20],v[21]!==z||v[22]!==I||v[23]!==P?(i=I?(0,t.jsx)(L.f,{isValid:P,onDrop:async e=>{await z.handleFiles((0,M.Q)(e))}}):null,v[21]=z,v[22]=I,v[23]=P,v[24]=i):i=v[24],v[25]!==er||v[26]!==_?(o=(0,t.jsx)("div",{className:"flex items-center gap-2 min-w-0",children:(0,t.jsx)(H,{mode:_,onSelect:en,disabled:er})}),v[25]=er,v[26]=_,v[27]=o):o=v[27],v[28]!==z||v[29]!==es||v[30]!==er||v[31]!==el||v[32]!==w?(c=(0,t.jsx)(B.f,{ref:j,placeholder:el,prompt:w,setPrompt:N,attachments:z,onSend:es,disabled:er}),v[28]=z,v[29]=es,v[30]=er,v[31]=el,v[32]=w,v[33]=c):c=v[33],v[34]!==z?(d=(0,t.jsx)("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:(0,t.jsx)(V,{attachments:z})}),v[34]=z,v[35]=d):d=v[35],v[36]!==es||v[37]!==ea||v[38]!==et||v[39]!==er||v[40]!==_||v[41]!==w?(u=(0,t.jsx)("div",{className:"flex",children:(0,t.jsx)(K,{prompt:w,disabled:er,onSend:es,onStop:ea,mode:_,isLoading:et})}),v[36]=es,v[37]=ea,v[38]=et,v[39]=er,v[40]=_,v[41]=w,v[42]=u):u=v[42],v[43]!==d||v[44]!==u?(f=(0,t.jsxs)("div",{className:"flex gap-1",children:[d,u]}),v[43]=d,v[44]=u,v[45]=f):f=v[45],v[46]!==f||v[47]!==o||v[48]!==c?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[o,c,f]}),v[46]=f,v[47]=o,v[48]=c,v[49]=x):x=v[49],v[50]!==x||v[51]!==l||v[52]!==i?(g=(0,t.jsxs)("div",{ref:y,className:"rounded-lg overflow-hidden border border-border w-full bg-card p-2 isolate contain-layout",children:[l,i,x]}),v[50]=x,v[51]=l,v[52]=i,v[53]=g):g=v[53],g};var er=e.i(895783),en=e.i(729987),es=e.i(216294),ea=e.i(196991);function el(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center p-8",children:(0,t.jsx)(ea.T,{children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground max-w-md",children:[(0,t.jsx)("p",{className:"text-lg font-medium mb-2",children:"Start the conversation"}),(0,t.jsx)("p",{className:"text-sm",children:"Use the chat composer below to discuss ideas, ask questions, or brainstorm about this artifact."})]})})}),n[0]=e):e=n[0],e}function ei(e){return(0,t.jsx)("div",{className:"max-w-3xl w-full",children:(0,t.jsx)(es.f,{messageId:e})},e)}let eo=(0,m.memo)(function(e){let n,s,l,i,o,c=(0,r.c)(9),{artifactId:d}=e,u=(0,m.useRef)(null),f=(0,m.useRef)(null);c[0]!==d?(n=e=>(0,w.p)(e,d),c[0]=d,c[1]=n):n=c[1];let h=(0,p.f)((0,er.f)(n));if(c[2]===Symbol.for("react.memo_cache_sentinel")?(s={scrollContainerRef:u,contentRef:f,initialStick:!0},c[2]=s):s=c[2],(0,en.f)(s),0===h.length){let e;return c[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(el,{}),c[3]=e):e=c[3],e}return c[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.f)("flex-1 min-h-0 w-full overflow-y-auto relative contain-layout contain-style"),c[4]=l):l=c[4],c[5]!==h?(i=h.map(ei),c[5]=h,c[6]=i):i=c[6],c[7]!==i?(o=(0,t.jsx)("div",{ref:u,className:l,children:(0,t.jsx)("div",{ref:f,children:(0,t.jsx)("div",{className:"flex flex-col items-center w-full gap-6 my-4 sm:px-0 duration-200 animate-in fade-in",children:i})})}),c[7]=i,c[8]=o):o=c[8],o},(e,t)=>e.artifactId===t.artifactId),ec=(0,m.memo)(function(e){let n,s,a,l=(0,r.c)(5),{artifactId:i}=e;return l[0]!==i?(n=(0,t.jsx)(eo,{artifactId:i}),l[0]=i,l[1]=n):n=l[1],l[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("div",{className:"max-w-4xl mx-auto w-full",children:(0,t.jsx)(et,{})}),l[2]=s):s=l[2],l[3]!==n?(a=(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[n,s]}),l[3]=n,l[4]=a):a=l[4],a},(e,t)=>e.artifactId===t.artifactId);var ed=e.i(797521),em=e.i(153746),eu=e.i(233452),ef=e.i(733442),eh=e.i(911189),ex=e.i(873151);let ep=e=>{let n,s,i,o,c,d,m,u,f,h,x,g,v,b,j,y,w,N,_,k,C=(0,r.c)(50),{versionId:z}=e,I=(0,p.f)(eg);C[0]!==z?(n=e=>e.artifactVersions[z]?.createdAt,C[0]=z,C[1]=n):n=C[1];let T=(0,p.f)(n);C[2]!==z?(s=e=>e.artifactVersions[z]?.generationStatus,C[2]=z,C[3]=s):s=C[3];let M=(0,p.f)(s);C[4]!==z?(i=e=>e.artifactVersions[z]?.error,C[4]=z,C[5]=i):i=C[5];let E=(0,p.f)(i);C[6]!==z?(o=e=>e.artifactVersions[z]?.versionNumber,C[6]=z,C[7]=o):o=C[7];let A=(0,p.f)(o);C[8]!==I?(c=e=>I?e.artifactViewerState[I]?.activeVersionId:null,C[8]=I,C[9]=c):c=C[9];let R=z===(0,p.f)(c);C[10]!==z?(d=e=>e.artifactVersions[z]?.characterName,C[10]=z,C[11]=d):d=C[11];let P=(0,p.f)(d);C[12]!==z?(m=e=>e.artifactVersions[z]?.prompt,C[12]=z,C[13]=m):m=C[13];let D=(0,p.f)(m),F=E?"failed":M??"idle",V=(0,eh.f)(T);C[14]!==I||C[15]!==z?(u=()=>{I&&S.z.setActiveVersionId({payload:{artifactId:I,versionId:z}})},C[14]=I,C[15]=z,C[16]=u):u=C[16];let O=u,L=R&&"bg-accent/40";C[17]!==L?(f=(0,a.f)("grid h-auto w-full max-w-full items-start justify-stretch p-2","text-left whitespace-normal",L),C[17]=L,C[18]=f):f=C[18],C[19]!==F?(h=(0,a.f)("inline-flex items-center justify-center h-2 w-2 shrink-0 border-border",(0,ef.I)({status:F})),C[19]=F,C[20]=h):h=C[20];let B=ef.s[F];return C[21]!==h||C[22]!==B?(x=(0,t.jsx)("span",{className:h,title:B,"aria-hidden":"true"}),C[21]=h,C[22]=B,C[23]=x):x=C[23],C[24]!==A?(g=(0,t.jsx)("span",{className:"text-sm font-medium text-foreground shrink-0",children:(0,t.jsxs)(ea.T,{children:["v",(0,t.jsx)(em.d,{children:A})]})}),C[24]=A,C[25]=g):g=C[25],C[26]!==P?(v=P&&(0,t.jsx)(eu.Badge,{size:"sm",variant:"muted",className:"max-w-48",children:(0,t.jsx)("span",{className:"truncate",children:P})}),C[26]=P,C[27]=v):v=C[27],C[28]!==x||C[29]!==g||C[30]!==v?(b=(0,t.jsxs)("span",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[x,g,v]}),C[28]=x,C[29]=g,C[30]=v,C[31]=b):b=C[31],C[32]!==T||C[33]!==V||C[34]!==F?(j=(0,t.jsx)("span",{className:"flex items-center gap-2 shrink-0",children:"generating"===F&&T?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,t.jsx)(ex.f,{start:T})}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:V})}),C[32]=T,C[33]=V,C[34]=F,C[35]=j):j=C[35],C[36]!==b||C[37]!==j?(y=(0,t.jsxs)("span",{className:"flex items-start justify-between gap-2 min-w-0 shrink-0",children:[b,j]}),C[36]=b,C[37]=j,C[38]=y):y=C[38],C[39]!==D?(w=D||(0,t.jsx)(ea.T,{children:"Initial version"}),C[39]=D,C[40]=w):w=C[40],C[41]!==w?(N=(0,t.jsx)("span",{className:"block text-xs text-muted-foreground truncate ph-no-capture","data-dd-privacy":"hidden",children:w}),C[41]=w,C[42]=N):N=C[42],C[43]!==y||C[44]!==N?(_=(0,t.jsxs)("span",{className:"min-w-0 flex flex-col gap-1",children:[y,N]}),C[43]=y,C[44]=N,C[45]=_):_=C[45],C[46]!==O||C[47]!==f||C[48]!==_?(k=(0,t.jsx)("div",{className:"w-full max-w-full overflow-hidden",children:(0,t.jsx)(l.Button,{variant:"ghost",weight:"regular",onClick:O,className:f,children:_})}),C[46]=O,C[47]=f,C[48]=_,C[49]=k):k=C[49],k};function eg(e){return e.activeArtifactId}let ev=(0,P.l)([e=>e.activeArtifactId,e=>e.artifactVersions],(e,t)=>e?Object.values(t).filter(t=>t?.artifactId===e).sort((e,t)=>{let r=e?.createdAt?new Date(e.createdAt).getTime():0;return(t?.createdAt?new Date(t.createdAt).getTime():0)-r}).map(e=>e.id):[]),eb=(0,m.memo)(()=>{let e,n,s,a,l,i=(0,r.c)(13),o=(0,ed.f)(),c=(0,p.f)((0,er.f)(ev));if(!(0,p.f)(ej))return null;if(0===c.length){let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center p-4 text-center text-xs text-muted-foreground",children:(0,t.jsx)(ea.T,{children:"No versions have been created yet."})}),i[0]=e):e=i[0],e}return i[1]!==o||i[2]!==c.length?(e=o.number(c.length,{preset:"integer"}),i[1]=o,i[2]=c.length,i[3]=e):e=i[3],i[4]!==e?(n=(0,t.jsx)("div",{className:"p-2",children:(0,t.jsx)("h4",{className:"text-xs font-semibold text-muted-foreground px-2",children:(0,t.jsxs)(ea.T,{children:["VERSIONS (",(0,t.jsx)(em.d,{children:e}),")"]})})}),i[4]=e,i[5]=n):n=i[5],i[6]!==c?(s=c.map(ey),i[6]=c,i[7]=s):s=i[7],i[8]!==s?(a=(0,t.jsx)("div",{className:"px-2 flex flex-col gap-1 overflow-y-auto",children:s}),i[8]=s,i[9]=a):a=i[9],i[10]!==n||i[11]!==a?(l=(0,t.jsxs)("div",{className:"flex flex-1 flex-col min-h-0",children:[n,a]}),i[10]=n,i[11]=a,i[12]=l):l=i[12],l},()=>!0);function ej(e){return e.activeArtifactId}function ey(e){return(0,t.jsx)(ep,{versionId:e},e)}var ew=e.i(795647),eN=e.i(279496),e_=e.i(579841),eS=e.i(134611),ek=e.i(942960),eC=e.i(195759),ez=e.i(536397),eI=e.i(624112),eT=e.i(761821),eM=e.i(888887),eE=e.i(562443),eA=e.i(39583);function eR(e){let n,s,a,i,o,c,d,m,u=(0,r.c)(19),{character:f,name:x,onRemove:p}=e,g=(0,h.f)();return u[0]!==f?(n=(0,t.jsx)(eE.f,{character:f,className:"size-5 shrink-0"}),u[0]=f,u[1]=n):n=u[1],u[2]!==x?(s=(0,t.jsx)("span",{className:"truncate",children:x}),u[2]=x,u[3]=s):s=u[3],u[4]!==n||u[5]!==s?(a=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[n,s]}),u[4]=n,u[5]=s,u[6]=a):a=u[6],u[7]!==p?(i=e=>{e.stopPropagation(),e.preventDefault(),p()},u[7]=p,u[8]=i):i=u[8],u[9]!==g||u[10]!==x?(o=g("Remove {name}",{name:x}),u[9]=g,u[10]=x,u[11]=o):o=u[11],u[12]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(eN.f,{className:"size-4"}),u[12]=c):c=u[12],u[13]!==i||u[14]!==o?(d=(0,t.jsx)("span",{className:"flex shrink-0 opacity-0 group-hover:opacity-100",children:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",className:"hover:bg-destructive/20 hover:text-destructive",onClick:i,onKeyDown:eP,"aria-label":o,children:c})}),u[13]=i,u[14]=o,u[15]=d):d=u[15],u[16]!==a||u[17]!==d?(m=(0,t.jsxs)("div",{className:"group flex w-full items-center justify-between gap-2",children:[a,d]}),u[16]=a,u[17]=d,u[18]=m):m=u[18],m}function eP(e){("Enter"===e.key||" "===e.key)&&e.stopPropagation()}function eD(e){let n,s,i,o,c,d,u,f,h,x,p,g,v,b,j,y=(0,r.c)(38),{triggerLabel:w,triggerAvatar:N,items:_,activeId:S,onSelect:k,onRemove:C,onAddNew:z,className:I}=e,[T,M]=(0,m.useState)(!1),E=(0,m.useRef)(null);y[0]!==I?(n=(0,a.f)("relative inline-block",I),y[0]=I,y[1]=n):n=y[1],y[2]!==N?(s=N?(0,t.jsx)(eE.f,{character:N,className:"size-5 shrink-0"}):null,y[2]=N,y[3]=s):s=y[3],y[4]!==w?(i=w??(0,t.jsx)(ea.T,{children:"Select a model"}),y[4]=w,y[5]=i):i=y[5],y[6]!==i?(o=(0,t.jsx)("span",{className:"truncate",children:i}),y[6]=i,y[7]=o):o=y[7],y[8]!==s||y[9]!==o?(c=(0,t.jsx)(eI.J,{render:(0,t.jsx)(l.Button,{variant:"outline",size:"sm",className:"min-w-0 max-w-50 md:max-w-none",children:(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-2 truncate",children:[s,o]})})}),y[8]=s,y[9]=o,y[10]=c):c=y[10];let A=S??void 0;return y[11]!==S||y[12]!==_||y[13]!==C||y[14]!==k?(d=_.length>0?(0,t.jsx)(ez.W,{className:"p-0",children:_.map(e=>(0,t.jsx)(ez.J,{value:e.id,"data-active":e.id===S,"aria-current":e.id===S?"true":void 0,className:"px-3 data-[active=true]:bg-accent data-[active=true]:text-accent-foreground",onSelect:()=>{k(e.id),M(!1)},children:(0,t.jsx)(eR,{character:e.character,name:e.label,onRemove:()=>{C(e.id)}})},e.id))}):null,y[11]=S,y[12]=_,y[13]=C,y[14]=k,y[15]=d):d=y[15],y[16]!==_.length?(u=_.length>0?(0,t.jsx)(ez.a,{className:"my-1"}):null,y[16]=_.length,y[17]=u):u=y[17],y[18]!==z?(f=()=>{z(),M(!1)},y[18]=z,y[19]=f):f=y[19],y[20]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(ew.f,{className:"size-4"}),x=(0,t.jsx)(ea.T,{children:"Add Model"}),y[20]=h,y[21]=x):(h=y[20],x=y[21]),y[22]!==f?(p=(0,t.jsx)(ez.W,{className:"p-0",children:(0,t.jsxs)(ez.J,{value:"add-new-model",layout:"slots",className:"px-3",onSelect:f,children:[h,x]})}),y[22]=f,y[23]=p):p=y[23],y[24]!==p||y[25]!==d||y[26]!==u?(g=(0,t.jsxs)(ez.X,{className:"max-h-none",children:[d,u,p]}),y[24]=p,y[25]=d,y[26]=u,y[27]=g):g=y[27],y[28]!==g||y[29]!==A?(v=(0,t.jsx)(eI.T,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,className:"w-55 max-h-96 min-w-32 overflow-auto p-1",initialFocus:E,children:(0,t.jsx)(ez.s,{ref:E,tabIndex:-1,defaultValue:A,className:"bg-transparent",onKeyDown:eF,children:g})}),y[28]=g,y[29]=A,y[30]=v):v=y[30],y[31]!==T||y[32]!==v||y[33]!==c?(b=(0,t.jsxs)(eI.V,{open:T,onOpenChange:M,children:[c,v]}),y[31]=T,y[32]=v,y[33]=c,y[34]=b):b=y[34],y[35]!==n||y[36]!==b?(j=(0,t.jsx)("div",{className:n,children:b}),y[35]=n,y[36]=b,y[37]=j):j=y[37],j}function eF(e){" "===e.key&&e.target===e.currentTarget&&(e.preventDefault(),e.currentTarget.querySelector('[cmdk-item][aria-selected="true"]')?.click())}function eV(){let e,n,s,a,l,i,o,c,d,u,f,g,v,b,j,y=(0,r.c)(45),N=(0,h.f)(),k=(0,_.x)(),{getEndpointDisplayName:C,getModelInfoByVariantSlug:z}=(0,eT.S)(),[I,T]=(0,m.useState)(!1),M=(0,p.f)(w.z),E=(0,p.f)(x.M);y[0]!==M?(e=e=>M?e.artifacts[M]:null,y[0]=M,y[1]=e):e=y[1];let A=(0,p.f)(e);y[2]!==E?(n=e=>(E?e.rooms[E]?.characters:{})??{},y[2]=E,y[3]=n):n=y[3];let R=(0,p.f)(n);A?.characterIds,y[4]!==A?.characterIds||y[5]!==R?(s=A?.characterIds?.map(e=>R[e]).filter(eB)??[],y[4]=A?.characterIds,y[5]=R,y[6]=s):s=y[6];let P=s;if(y[7]!==P||y[8]!==C){let e;y[10]!==C?(e=e=>{let t=e.model||e.modelInfo&&(0,eS.i)(e.modelInfo),r=t?(0,ek.f)(t):void 0,n=t?(0,eC.z)(t):void 0,s=e.name||e.presetName||C({slug:r,variant:n,providerName:e.provider});return{id:e.id,character:e,name:s}},y[10]=C,y[11]=e):e=y[11],a=P.map(e),y[7]=P,y[8]=C,y[9]=a}else a=y[9];let D=a,F=A?.activeCharacterId??null;if(y[12]!==F||y[13]!==D){let e;y[15]!==F?(e=e=>e.id===F,y[15]=F,y[16]=e):e=y[16],l=D.find(e),y[12]=F,y[13]=D,y[14]=l}else l=y[14];let V=l;y[17]!==M?(i=e=>{M&&S.z.setActiveCharacterForArtifact({payload:{artifactId:M,characterId:e}})},y[17]=M,y[18]=i):i=y[18];let O=i;y[19]!==M||y[20]!==z||y[21]!==E?(o=async e=>{if(T(!1),!E||!M)return;let t=(0,eS.i)(e),r=z(t),n=await S.z.addCharacters({payload:{roomId:E,characters:[{model:t,modelInfo:r,samplingParameters:{},artifactId:M}]}}),s=n?.characterIds?.[0];s&&S.z.setActiveCharacterForArtifact({payload:{artifactId:M,characterId:s}})},y[19]=M,y[20]=z,y[21]=E,y[22]=o):o=y[22];let L=o;y[23]!==M||y[24]!==N?(c=e=>{!M||window.confirm(N("Are you sure you want to remove this model from the artifact?"))&&S.z.removeCharacterFromArtifact({payload:{artifactId:M,characterId:e}})},y[23]=M,y[24]=N,y[25]=c):c=y[25];let B=c;if(!E||!M)return null;let q=V?.name??null,W=V?.character??null;return y[26]!==D?(d=D.map(eL),y[26]=D,y[27]=d):d=y[27],y[28]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{T(!0)},y[28]=u):u=y[28],y[29]!==F||y[30]!==O||y[31]!==B||y[32]!==d||y[33]!==q||y[34]!==W?(f=(0,t.jsx)(eD,{className:"align-top",triggerLabel:q,triggerAvatar:W,items:d,activeId:F,onSelect:O,onRemove:B,onAddNew:u}),y[29]=F,y[30]=O,y[31]=B,y[32]=d,y[33]=q,y[34]=W,y[35]=f):f=y[35],y[36]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{T(!1)},y[36]=g):g=y[36],y[37]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{}),y[37]=v):v=y[37],y[38]!==L||y[39]!==I||y[40]!==k?(b=(0,t.jsx)(eM.ModelSelect,{isDialog:k,isMobileSideDrawer:!0,isForceOpen:I,onBlur:g,filter:eO,onDone:L,showGuardrailsWarning:!0,hideUnavailableByDefault:!0,children:v}),y[38]=L,y[39]=I,y[40]=k,y[41]=b):b=y[41],y[42]!==f||y[43]!==b?(j=(0,t.jsxs)(t.Fragment,{children:[f,b]}),y[42]=f,y[43]=b,y[44]=j):j=y[44],j}function eO(e){return!(0,eA.f)(e)&&(0,e_.a)(e.output_modalities)}function eL(e){return{id:e.id,label:e.name,character:e.character}}function eB(e){return!!e}function eq(e){let n,s,i,o,c,d,u,f,x,p,g,v,b=(0,r.c)(25),{artifactId:j}=e,y=(0,h.f)(),[w,N]=(0,m.useState)(!1);return b[0]!==y?(n=y("Close workspace"),b[0]=y,b[1]=n):n=b[1],b[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(C.f,{className:"size-4"}),b[2]=s):s=b[2],b[3]!==n?(i=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",onClick:e$,"aria-label":n,children:s}),b[3]=n,b[4]=i):i=b[4],b[5]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:"flex-1 min-w-0 flex justify-center",children:(0,t.jsx)(eV,{})}),b[5]=o):o=b[5],b[6]===Symbol.for("react.memo_cache_sentinel")?(c=()=>N(eW),b[6]=c):c=b[6],b[7]!==y||b[8]!==w?(d=y(w?"Show Chat":"Show Version History"),b[7]=y,b[8]=w,b[9]=d):d=b[9],b[10]!==w?(u=w?(0,t.jsx)(z.f,{className:"size-5"}):(0,t.jsx)(I.f,{className:"size-5"}),b[10]=w,b[11]=u):u=b[11],b[12]!==d||b[13]!==u?(f=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",onClick:c,title:d,children:u}),b[12]=d,b[13]=u,b[14]=f):f=b[14],b[15]!==i||b[16]!==f?(x=(0,t.jsxs)("div",{className:"flex items-center gap-1.5 p-2 pl-0 m-px shrink-0 bg-background",children:[i,o,f]}),b[15]=i,b[16]=f,b[17]=x):x=b[17],b[18]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.f)("flex-1 min-h-0 overflow-hidden","bg-muted border border-border border-b-0","md:rounded-tl-2xl"),b[18]=p):p=b[18],b[19]!==j||b[20]!==w?(g=(0,t.jsx)("div",{className:p,children:(0,t.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:w?(0,t.jsx)(eb,{}):(0,t.jsx)(ec,{artifactId:j})})}),b[19]=j,b[20]=w,b[21]=g):g=b[21],b[22]!==g||b[23]!==x?(v=(0,t.jsxs)(t.Fragment,{children:[x,g]}),b[22]=g,b[23]=x,b[24]=v):v=b[24],v}function eW(e){return!e}function e$(){return S.z.closeArtifactView()}var eU=e.i(549692),eH=e.i(559802),eG=e.i(709687),eK=e.i(236911),eJ=e.i(882844),eZ=e.i(447680),eQ=e.i(635157);let eX=eQ.z.object({type:eQ.z.literal("runtime-error"),error:eQ.z.string()}),eY=eQ.z.object({type:eQ.z.literal("storage-get-item"),key:eQ.z.string(),requestId:eQ.z.number()}),e0=eQ.z.object({type:eQ.z.literal("storage-set-item"),key:eQ.z.string(),value:eQ.z.string()}),e1=eQ.z.object({type:eQ.z.literal("storage-remove-item"),key:eQ.z.string()}),e2=eQ.z.object({type:eQ.z.literal("storage-clear")}),e3=eQ.z.union([eX,eY,e0,e1,e2]),e4=new Set(["null"]),e5={kind:"idle"};function e6(e){let n,s,a,l,i,o,c=(0,r.c)(16),{title:d,subtitle:m,hint:u,showShimmer:f}=e,h=void 0===f||f,x=!!h||void 0;return c[0]!==d?(n=(0,t.jsx)("div",{className:"text-lg font-medium tracking-tight text-foreground md:text-xl",children:d}),c[0]=d,c[1]=n):n=c[1],c[2]!==m?(s=m?(0,t.jsx)("p",{className:"text-sm text-muted-foreground md:text-base",children:m}):null,c[2]=m,c[3]=s):s=c[3],c[4]!==h?(a=h?(0,t.jsx)("div",{className:"h-2 w-2/3 max-w-md overflow-hidden rounded-full bg-muted md:max-w-lg",children:(0,t.jsx)("div",{className:"h-full w-1/3 animate-preview-shimmer motion-reduce:animate-none bg-primary"})}):null,c[4]=h,c[5]=a):a=c[5],c[6]!==u?(l=u?(0,t.jsx)("p",{className:"text-muted-foreground/80 text-sm",children:u}):null,c[6]=u,c[7]=l):l=c[7],c[8]!==n||c[9]!==s||c[10]!==a||c[11]!==l?(i=(0,t.jsxs)("div",{className:"flex max-w-2xl flex-col items-center gap-3 px-4 text-center md:gap-4 md:px-8",children:[n,s,a,l]}),c[8]=n,c[9]=s,c[10]=a,c[11]=l,c[12]=i):i=c[12],c[13]!==x||c[14]!==i?(o=(0,t.jsx)("div",{className:"h-full w-full flex items-center justify-center",role:"status","aria-live":"polite","aria-busy":x,children:i}),c[13]=x,c[14]=i,c[15]=o):o=c[15],o}var e7=e.i(512157);function e8(e){let n,s,a,i,o,c,d,m,u=(0,r.c)(14),{artifactId:f,versionId:h,error:x}=e;u[0]!==f||u[1]!==h?(n=()=>{S.z.fixArtifactVersionError({payload:{artifactId:f,versionId:h}})},u[0]=f,u[1]=h,u[2]=n):n=u[2];let p=n;return u[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-destructive/10 text-destructive",children:(0,t.jsx)(e7.f,{className:"h-5 w-5"})}),u[3]=s):s=u[3],u[4]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)(ea.T,{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Preview Error"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check the error below and try the automatic fix."})]}),u[4]=a):a=u[4],u[5]!==x?(i=(0,t.jsx)("pre",{className:"mt-3 max-h-60 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:x}),u[5]=x,u[6]=i):i=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)($.f,{className:"h-4 w-4"}),c=(0,t.jsx)(ea.T,{children:"Try to Fix"}),u[7]=o,u[8]=c):(o=u[7],c=u[8]),u[9]!==p?(d=(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsxs)(l.Button,{variant:"default",size:"sm",onClick:p,children:[o,c]})}),u[9]=p,u[10]=d):d=u[10],u[11]!==i||u[12]!==d?(m=(0,t.jsx)("div",{className:"h-full w-full flex items-center justify-center p-6",children:(0,t.jsx)("div",{className:"max-w-2xl w-full px-4",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[s,(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[a,i,d]})]})})}),u[11]=i,u[12]=d,u[13]=m):m=u[13],m}let e9=(0,P.l)([w.x,w.j],(e,t)=>t?e[t]:void 0);function te(){let e,n,s,l,i,o,c=(0,r.c)(66),d=(0,h.f)(),u=(0,p.f)(w.I),f=(0,p.f)(e9),x=(0,m.useRef)(null),[g,v]=(0,m.useState)(e5),b="ready"===g.kind?g.result:null,j=u?.id??null,y=f?.id??null,N=b?.key;c[0]!==j||c[1]!==y||c[2]!==N?(e={iframeRef:x,artifactId:j,versionId:y,dependencyKey:N},c[0]=j,c[1]=y,c[2]=N,c[3]=e):e=c[3],function(e){let t,n,s=(0,r.c)(9),{iframeRef:a,artifactId:l,versionId:i,dependencyKey:o}=e;s[0]!==l||s[1]!==a||s[2]!==i?(t=()=>{let e=async function(e){var t,r;let n=a.current;if(!n||e.source!==n.contentWindow||!e4.has(e.origin))return;let s=(0,eJ.C)(e3,e.data);if((0,R.V)(s))return;let o=s.data;if(!l)return;let c=e=>{n.contentWindow?.postMessage({...e,type:"storage-response"},"*")},d=o.type;switch(d){case"storage-get-item":{let e=await (0,R.$)(()=>eZ.f.getArtifactData(l,o.key));if((0,R.V)(e)){if((t=e.error)instanceof DOMException&&"AbortError"===t.name)return void c({requestId:o.requestId,value:null});c({requestId:o.requestId,error:e.error instanceof Error?e.error.message:String(e.error??"Unknown error")});return}c({requestId:o.requestId,value:e.data});return}case"storage-set-item":return void await (0,R.$)(()=>eZ.f.setArtifactData(l,o.key,o.value));case"storage-remove-item":return void await (0,R.$)(()=>eZ.f.removeArtifactData(l,o.key));case"storage-clear":return void await (0,R.$)(()=>eZ.f.clearArtifactData(l));case"runtime-error":{if(!i)return;let e=function(e){let t=p.f.getState(),r=t.artifactVersions[e];if(!r)return[];let n=[];for(let e of Object.keys(r.fileContents)){let r=t.artifactFiles[e];r?.filename&&n.push(r.filename)}return n}(i),t=function(e,t){if(!e||0===t.length)return!1;let r=e.toLowerCase(),n=new Set;for(let e of t){let t=e.toLowerCase();n.add(t);let r=t.lastIndexOf("/");-1!==r&&r+12&&r.includes(e))return!0;return!1}(o.error,e);if(!("string"==typeof(r=o.error)&&r.includes("SyntaxError"))&&!t)return;S.z.reportArtifactVersionError({payload:{artifactId:l,versionId:i,error:o.error??""}});return}default:(0,eK.f)(d)}},t=function(t){(0,R.$)(()=>e(t))};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},s[0]=l,s[1]=a,s[2]=i,s[3]=t):t=s[3],s[4]!==l||s[5]!==o||s[6]!==a||s[7]!==i?(n=[a,l,i,o],s[4]=l,s[5]=o,s[6]=a,s[7]=i,s[8]=n):n=s[8],(0,m.useEffect)(t,n)}(e),c[4]!==u||c[5]!==d||c[6]!==f?(n=()=>{let e=!1;return(async()=>{if(!f||!u||"app"!==u.type||void 0!==f.generationStatus&&"success"!==f.generationStatus||f.error)return void v(e5);let t=f.id;if(await new Promise(tt),e)return;v({kind:"bundling",versionId:t});let r=p.f.getState(),n=eG.f.getState().artifactContent,s=(0,w.t)(r,{versionId:t});if(0===s.length)return void v({kind:"empty",versionId:t});let a=[];for(let e of s){var l,i;let s=r.artifactVersions[t]?.fileContents[e.id];if(!s)return void v({kind:"empty",versionId:t});let o=(l=n[s],i=r.artifactFileContents[s]?.content,"string"==typeof l?l:"string"==typeof i?i:"");a.push({path:e.filename,content:o})}let o=await (0,eH.f)(a);if(!e){if((0,R.V)(o)){let e=(0,eU.n)({location:"VersionPreview:createPreview",rawError:o.error}).message??d("An unknown error occurred during preview generation.");S.z.reportArtifactVersionError({payload:{artifactId:u.id,versionId:t,error:e}}),v({kind:"failed",versionId:t});return}v({kind:"ready",versionId:t,result:o.data})}})(),()=>{e=!0}},c[4]=u,c[5]=d,c[6]=f,c[7]=n):n=c[7];let _=f?.id;if(c[8]!==u||c[9]!==d||c[10]!==_||c[11]!==f?(s=[_,u,f,d],c[8]=u,c[9]=d,c[10]=_,c[11]=f,c[12]=s):s=c[12],(0,m.useEffect)(n,s),!u||"app"!==u.type){let e,r,n;return c[13]!==d?(e=d("Preview unavailable"),c[13]=d,c[14]=e):e=c[14],c[15]!==d?(r=d("No app artifact selected"),c[15]=d,c[16]=r):r=c[16],c[17]!==e||c[18]!==r?(n=(0,t.jsx)(e6,{title:e,subtitle:r,showShimmer:!1}),c[17]=e,c[18]=r,c[19]=n):n=c[19],n}if(!f){let e,r,n;return c[20]!==d?(e=d("Preview unavailable"),c[20]=d,c[21]=e):e=c[21],c[22]!==d?(r=d("No version is currently selected"),c[22]=d,c[23]=r):r=c[23],c[24]!==e||c[25]!==r?(n=(0,t.jsx)(e6,{title:e,subtitle:r,showShimmer:!1}),c[24]=e,c[25]=r,c[26]=n):n=c[26],n}if("generating"===f.generationStatus){let e,r,n,s;return c[27]!==d?(e=d("Generating version"),c[27]=d,c[28]=e):e=c[28],c[29]!==d?(r=d("Applying your instructions"),c[29]=d,c[30]=r):r=c[30],c[31]!==d?(n=d("The preview will appear here once it is ready."),c[31]=d,c[32]=n):n=c[32],c[33]!==e||c[34]!==r||c[35]!==n?(s=(0,t.jsx)(e6,{title:e,subtitle:r,hint:n}),c[33]=e,c[34]=r,c[35]=n,c[36]=s):s=c[36],s}if(f.error){let e;return c[37]!==u.id||c[38]!==f.error||c[39]!==f.id?(e=(0,t.jsx)(e8,{artifactId:u.id,versionId:f.id,error:f.error}),c[37]=u.id,c[38]=f.error,c[39]=f.id,c[40]=e):e=c[40],e}if("failed"===f.generationStatus){let e;return c[41]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-sm text-destructive",children:(0,t.jsx)(ea.T,{children:"An error occurred during generation."})}),c[41]=e):e=c[41],e}let k=function(e,t){if("idle"===e.kind)return"empty";if(e.versionId!==t)return"bundling";switch(e.kind){case"bundling":return"bundling";case"ready":return"ready";case"empty":case"failed":return"empty";default:return e}}(g,f.id);if("bundling"===k){let e,r,n,s;return c[42]!==d?(e=d("Preparing preview"),c[42]=d,c[43]=e):e=c[43],c[44]!==d?(r=d("Bundling files for the sandbox"),c[44]=d,c[45]=r):r=c[45],c[46]!==d?(n=d("This usually takes a few seconds."),c[46]=d,c[47]=n):n=c[47],c[48]!==e||c[49]!==r||c[50]!==n?(s=(0,t.jsx)(e6,{title:e,subtitle:r,hint:n}),c[48]=e,c[49]=r,c[50]=n,c[51]=s):s=c[51],s}if("ready"===k&&b){let e,r,n;c[52]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.f)("relative h-full w-full","flex flex-col"),c[52]=e):e=c[52];let s=b.key;return c[53]!==d?(r=d("Artifact Preview"),c[53]=d,c[54]=r):r=c[54],c[55]!==b.key||c[56]!==b.srcDoc||c[57]!==r?(n=(0,t.jsx)("div",{className:e,children:(0,t.jsx)("div",{className:"relative flex-1 min-h-0",children:(0,t.jsx)("iframe",{ref:x,title:r,className:"h-full w-full border-0",srcDoc:b.srcDoc,sandbox:"allow-scripts allow-modals allow-forms allow-pointer-lock allow-popups",loading:"lazy"},s)})}),c[55]=b.key,c[56]=b.srcDoc,c[57]=r,c[58]=n):n=c[58],n}return c[59]!==d?(l=d("No files to preview"),c[59]=d,c[60]=l):l=c[60],c[61]!==d?(i=d("This version does not contain any previewable files"),c[61]=d,c[62]=i):i=c[62],c[63]!==l||c[64]!==i?(o=(0,t.jsx)(e6,{title:l,subtitle:i,showShimmer:!1}),c[63]=l,c[64]=i,c[65]=o):o=c[65],o}function tt(e){requestAnimationFrame(()=>e())}var tr=e.i(540191);function tn(e){let t=eG.f.subscribe(e),r=p.f.subscribe(e);return()=>{t(),r()}}var ts=e.i(913743),ta=e.i(961160),tl=e.i(508701),ti=e.i(952384);let to="folder:";function tc(e){let n,s,a=(0,r.c)(3),{children:l}=e,i=(0,m.useRef)(null),o=(0,m.useRef)(null);return a[0]===Symbol.for("react.memo_cache_sentinel")?(n={scrollContainerRef:i,contentRef:o},a[0]=n):n=a[0],(0,en.f)(n),a[1]!==l?(s=(0,t.jsx)("div",{ref:i,className:"h-full overflow-auto bg-background",children:(0,t.jsx)("div",{className:"h-full",ref:o,children:l})}),a[1]=l,a[2]=s):s=a[2],s}function td(e){let n,s,a,l=(0,r.c)(13),{activeFileId:i,files:o,content:c}=e,{resolvedTheme:d}=(0,ta.i)();l[0]!==i||l[1]!==o?(n=i?o.find(e=>e.id===i):void 0,l[0]=i,l[1]=o,l[2]=n):n=l[2];let m=n;if(!m){let e;return l[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:(0,t.jsx)(ea.T,{children:"Select a file from the sidebar to view its content."})}),l[3]=e):e=l[3],e}if("string"!=typeof c){let e;return l[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:(0,t.jsx)(ea.T,{children:"No content available for this file in the selected version."})}),l[4]=e):e=l[4],e}l[5]!==m.type?(s=function(e){switch(e){case"typescript":return"typescript";case"html":return"html";case"css":return"css";case"json":return"json";case"markdown":return"markdown";case"javascript":case"jsx":return"javascript";default:return"text"}}(m.type),l[5]=m.type,l[6]=s):s=l[6];let u=s,f=c;if("html"===u)if(l[7]!==f){let e=f.toLowerCase().indexOf("");e>0&&(f=f.substring(e)),l[7]=f,l[8]=f}else f=l[8];let h="dark"===d?"github-dark":"github-light";return l[9]!==f||l[10]!==u||l[11]!==h?(a=(0,t.jsx)(tc,{children:(0,t.jsx)(ts.f,{roundedCorners:!1,border:!1,code:f,lang:u,theme:h})}),l[9]=f,l[10]=u,l[11]=h,l[12]=a):a=l[12],a}function tm(e){return!e.startsWith(to)}function tu(e){let n,s,a,i,o,c,d,u,f,x,g,v,b,j,y,N,k,C=(0,r.c)(76),{activeVersionId:z}=e,I=(0,h.f)(),T=(0,_.x)(),[M,E]=(0,m.useState)(!1),A=(0,p.f)(w.z);C[0]!==z?(n=e=>(0,w.n)(e,{versionId:z}),C[0]=z,C[1]=n):n=C[1];let R=(0,p.f)(n),P=(0,p.f)(w.F),D=(0,p.f)(th),F=(0,p.f)(tf);C[2]!==A?(s=e=>e.artifactViewerState[A??""]?.expandedFolders??{},C[2]=A,C[3]=s):s=C[3];let V=(0,p.f)(s);C[4]!==V?(a=V?Object.keys(V):[],C[4]=V,C[5]=a):a=C[5];let O=a;C[6]!==z||C[7]!==F||C[8]!==D||C[9]!==R?(i=function({files:e,activeVersionId:t,allVersions:r,allFileContents:n}){let s=[],a=new Set,l=e=>{let t=e.split("/").filter(Boolean),r=[];for(let e=0;e1?`${to}${r.slice(0,-1).join("/")}`:null,i=w.m.resultFunc(c,n,t.id);s.push({id:t.id,label:r.at(-1)??t.filename,parentId:a,status:"idle"===i?void 0:i})}return s}({files:R,activeVersionId:z,allVersions:D,allFileContents:F}),C[6]=z,C[7]=F,C[8]=D,C[9]=R,C[10]=i):i=C[10];let L=i;C[11]!==A||C[12]!==R?(o={artifactId:A,files:R},C[11]=A,C[12]=R,C[13]=o):o=C[13];let{onSelectionChange:B,onToggle:q,onRename:W,onDelete:$}=function(e){let t,n,s,a,l,i=(0,r.c)(15),{artifactId:o,files:c}=e,d=(0,h.f)();i[0]!==o?(t=e=>{if(!o)return;let t=e[0]??null,r=!!t?.startsWith(to);S.z.setActiveFileId({payload:{artifactId:o,fileId:r?null:t}})},i[0]=o,i[1]=t):t=i[1];let m=t;i[2]!==o?(n=e=>{if(!o||!e.id.startsWith(to))return;let t={...p.f.getState().artifactViewerState[o]?.expandedFolders??{}};e.expanded?t[e.id]=!0:delete t[e.id],S.z.setExpandedFolders({payload:{artifactId:o,expandedFolders:t}})},i[2]=o,i[3]=n):n=i[3];let u=n;i[4]!==o||i[5]!==c?(s=e=>{var t;let r,{id:n,nextLabel:s}=e;if(!o||n.startsWith(to))return;let a=c.find(e=>e.id===n);if(!a)return;let l=(0,ti.y)(s);if(!(0,ti.A)(l))return;let i=l.includes("/")?l:(t=a.filename,(r=(0,ti.y)(t).split("/").filter(Boolean)).length<=1?l:(r[r.length-1]=l,r.join("/")));S.z.renameArtifactFile({payload:{artifactId:o,fileId:a.id,newName:(0,ti.y)(i)}})},i[4]=o,i[5]=c,i[6]=s):s=i[6];let f=s;i[7]!==o||i[8]!==d?(a=e=>{let{ids:t}=e;if(!o)return;let r=t.filter(tm);if(0!==r.length&&globalThis.confirm(1===r.length?d("Delete this file? This action cannot be undone."):d("Delete {count} files? This action cannot be undone.",{count:r.length})))for(let e of r)S.z.deleteArtifactFile({payload:{artifactId:o,fileId:e}})},i[7]=o,i[8]=d,i[9]=a):a=i[9];let x=a;return i[10]!==x||i[11]!==f||i[12]!==m||i[13]!==u?(l={onSelectionChange:m,onToggle:u,onRename:f,onDelete:x},i[10]=x,i[11]=f,i[12]=m,i[13]=u,i[14]=l):l=i[14],l}(o),U=((y=(0,r.c)(6))[0]!==P||y[1]!==z?(b=()=>{if(!z||!P)return null;let e=p.f.getState(),t=(0,w.O)(e,{versionId:z}),r=t?.fileContents[P];if(!r)return null;let n=eG.f.getState().artifactContent[r];return"string"==typeof n?n:(0,w.S)(e,{versionId:z,fileId:P})},y[0]=P,y[1]=z,y[2]=b):b=y[2],N=b,y[3]!==P||y[4]!==z?(j=()=>z&&P?(0,w.S)(p.f.getState(),{versionId:z,fileId:P}):null,y[3]=P,y[4]=z,y[5]=j):j=y[5],k=j,(0,m.useSyncExternalStore)(tn,N,k));C[14]!==P||C[15]!==R?(c=function(e,t){if(!t)return"";let r=e.find(e=>e.id===t);return r?(0,ti.y)(r.filename).split("/").filter(Boolean).at(-1)??r.filename:""}(R,P),C[14]=P,C[15]=R,C[16]=c):c=C[16];let H=c;if(C[17]!==H){let e;e=H&&H.length>0?H:"file",d=(0,tl.f)(e),C[17]=H,C[18]=d}else d=C[18];let G=d;if(!T){let e,r,n,s,a,i,o,c,d,m,u,f;C[19]!==H||C[20]!==I?(e=H?I("Current file: {name}",{name:H}):I("Select a file"),C[19]=H,C[20]=I,C[21]=e):e=C[21],C[22]!==G?(r=(0,t.jsx)("span",{className:"shrink-0","aria-hidden":!0,children:G}),C[22]=G,C[23]=r):r=C[23],C[24]!==H?(n=H||(0,t.jsx)(ea.T,{children:"Select a file"}),C[24]=H,C[25]=n):n=C[25],C[26]!==n?(s=(0,t.jsx)("span",{className:"truncate",children:n}),C[26]=n,C[27]=s):s=C[27],C[28]!==s||C[29]!==r?(a=(0,t.jsxs)("span",{className:"flex items-center gap-2 min-w-0",children:[r,s]}),C[28]=s,C[29]=r,C[30]=a):a=C[30],C[31]!==a||C[32]!==e?(i=(0,t.jsx)(eI.J,{render:(0,t.jsx)(l.Button,{align:"start",size:"sm",variant:"outline",className:"min-w-0 max-w-[85vw]","aria-label":e,children:a})}),C[31]=a,C[32]=e,C[33]=i):i=C[33],C[34]!==P?(o=P?[P]:[],C[34]=P,C[35]=o):o=C[35],C[36]!==B?(c=e=>{let{selectedIds:t}=e;B(t),E(!1)},C[36]=B,C[37]=c):c=C[37],C[38]!==O||C[39]!==$||C[40]!==W||C[41]!==q||C[42]!==o||C[43]!==c||C[44]!==L?(d=(0,t.jsx)(eI.T,{align:"start",side:"bottom",sideOffset:6,collisionPadding:8,className:"w-[85vw] max-w-sm max-h-[70vh] overflow-auto p-1",children:(0,t.jsx)(tr.f,{items:L,defaultSelectedIds:o,defaultExpandedIds:O,onSelectionChange:c,onToggle:q,onRename:W,onDelete:$})}),C[38]=O,C[39]=$,C[40]=W,C[41]=q,C[42]=o,C[43]=c,C[44]=L,C[45]=d):d=C[45],C[46]!==M||C[47]!==i||C[48]!==d?(m=(0,t.jsx)("div",{className:"flex items-center justify-between gap-2 p-2 pt-0 border-b border-border",children:(0,t.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:(0,t.jsxs)(eI.V,{open:M,onOpenChange:E,children:[i,d]})})}),C[46]=M,C[47]=i,C[48]=d,C[49]=m):m=C[49];let h="string"==typeof U?U:null;return C[50]!==P||C[51]!==R||C[52]!==h?(u=(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(td,{activeFileId:P,files:R,content:h})}),C[50]=P,C[51]=R,C[52]=h,C[53]=u):u=C[53],C[54]!==m||C[55]!==u?(f=(0,t.jsxs)("div",{className:"flex h-full w-full flex-col bg-background",children:[m,u]}),C[54]=m,C[55]=u,C[56]=f):f=C[56],f}C[57]!==P?(u=P?[P]:[],C[57]=P,C[58]=u):u=C[58],C[59]!==B?(f=e=>{let{selectedIds:t}=e;B(t)},C[59]=B,C[60]=f):f=C[60],C[61]!==O||C[62]!==$||C[63]!==W||C[64]!==q||C[65]!==u||C[66]!==f||C[67]!==L?(x=(0,t.jsx)("aside",{className:"w-64 shrink-0 border-r border-border bg-background overflow-auto",children:(0,t.jsx)(tr.f,{items:L,defaultSelectedIds:u,defaultExpandedIds:O,onSelectionChange:f,onToggle:q,onRename:W,onDelete:$})}),C[61]=O,C[62]=$,C[63]=W,C[64]=q,C[65]=u,C[66]=f,C[67]=L,C[68]=x):x=C[68];let K="string"==typeof U?U:null;return C[69]!==P||C[70]!==R||C[71]!==K?(g=(0,t.jsx)("main",{className:"grow min-w-0",children:(0,t.jsx)(td,{activeFileId:P,files:R,content:K})}),C[69]=P,C[70]=R,C[71]=K,C[72]=g):g=C[72],C[73]!==x||C[74]!==g?(v=(0,t.jsxs)("div",{className:"flex h-full w-full bg-background",children:[x,g]}),C[73]=x,C[74]=g,C[75]=v):v=C[75],v}function tf(e){return e.artifactFileContents}function th(e){return e.artifactVersions}let tx=(0,m.memo)(function(){let e,n=(0,r.c)(3),s=(0,p.f)(w.L),a=(0,p.f)(w.j)??null;if("editor"===s){let e;return n[0]!==a?(e=(0,t.jsx)(tu,{activeVersionId:a}),n[0]=a,n[1]=e):e=n[1],e}return n[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(te,{}),n[2]=e):e=n[2],e});var tp=e.i(39835);let tg=m.forwardRef(function({title:e,titleId:t,...r},n){return m.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?m.createElement("title",{id:t},e):null,m.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25"}))});var tv=e.i(139659),tb=e.i(522396),tj=e.i(199168);function ty(){let e,n,s,a,l,i,o,c,d,m=(0,r.c)(19),u=(0,tj.o)(),f=(0,p.f)(w.z),h=(0,p.f)(w.L);m[0]!==f?(e=e=>{f&&S.z.setActiveArtifactView({payload:{artifactId:f,view:e}})},m[0]=f,m[1]=e):e=m[1];let x=e;return m[2]!==u?(n=u("Artifact view"),m[2]=u,m[3]=n):n=m[3],m[4]!==x?(s=()=>x("editor"),m[4]=x,m[5]=s):s=m[5],m[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(ea.T,{children:"Output"}),m[6]=a):a=m[6],m[7]!==s?(l=(0,t.jsx)(tb.Y,{value:"editor",onClick:s,children:a}),m[7]=s,m[8]=l):l=m[8],m[9]!==x?(i=()=>x("preview"),m[9]=x,m[10]=i):i=m[10],m[11]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(ea.T,{children:"Preview"}),m[11]=o):o=m[11],m[12]!==i?(c=(0,t.jsx)(tb.Y,{value:"preview",onClick:i,children:o}),m[12]=i,m[13]=c):c=m[13],m[14]!==h||m[15]!==n||m[16]!==l||m[17]!==c?(d=(0,t.jsxs)(tb.c,{"aria-label":n,value:h,children:[l,c]}),m[14]=h,m[15]=n,m[16]=l,m[17]=c,m[18]=d):d=m[18],d}function tw(e){let n,s,i,o,c,d,m,u,f,x,p,g,v,b=(0,r.c)(35),{name:j,versionNumber:y,isFullscreen:w,onToggleFullscreen:N,showViewSwitcher:_,artifactId:k,activeVersionId:C}=e,z=void 0!==w&&w,I=void 0===_||_,T=(0,h.f)();b[0]!==C||b[1]!==k?(n=()=>{k&&C&&S.z.downloadArtifactVersion({payload:{artifactId:k,versionId:C}})},b[0]=C,b[1]=k,b[2]=n):n=b[2];let M=n;b[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.f)("flex p-2 m-px items-center justify-between shrink-0","bg-background"),b[3]=s):s=b[3],b[4]!==j?(i=(0,t.jsx)("span",{className:"font-semibold text-base truncate",title:j,children:j}),b[4]=j,b[5]=i):i=b[5],b[6]!==T||b[7]!==y?(o=null!==y&&(0,t.jsx)("span",{className:"text-xs font-mono px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground shrink-0",title:T("Version {number}",{number:y}),children:(0,t.jsxs)(ea.T,{children:["v.",(0,t.jsx)(em.d,{children:y})]})}),b[6]=T,b[7]=y,b[8]=o):o=b[8],b[9]!==i||b[10]!==o?(c=(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[i,o]}),b[9]=i,b[10]=o,b[11]=c):c=b[11],b[12]!==I?(d=I&&(0,t.jsx)(ty,{}),b[12]=I,b[13]=d):d=b[13],b[14]!==T?(m=T("Download as .zip"),b[14]=T,b[15]=m):m=b[15],b[16]!==T?(u=T("Download as .zip"),b[16]=T,b[17]=u):u=b[17];let E=!C;return b[18]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(tp.f,{className:"size-4"}),b[18]=f):f=b[18],b[19]!==M||b[20]!==u||b[21]!==E||b[22]!==m?(x=(0,t.jsx)(l.Button,{size:"icon",variant:"ghost",tone:"subdued",onClick:M,title:m,"aria-label":u,disabled:E,children:f}),b[19]=M,b[20]=u,b[21]=E,b[22]=m,b[23]=x):x=b[23],b[24]!==T||b[25]!==z||b[26]!==N?(p=N&&(0,t.jsx)(l.Button,{size:"icon",variant:"ghost",tone:"subdued",onClick:N,title:T(z?"Exit full screen":"Full screen"),"aria-label":T(z?"Exit full screen":"Full screen"),children:z?(0,t.jsx)(tg,{className:"size-4"}):(0,t.jsx)(tv.f,{className:"size-4"})}),b[24]=T,b[25]=z,b[26]=N,b[27]=p):p=b[27],b[28]!==x||b[29]!==p||b[30]!==d?(g=(0,t.jsxs)("div",{className:"flex items-center gap-1 ml-4",children:[d,x,p]}),b[28]=x,b[29]=p,b[30]=d,b[31]=g):g=b[31],b[32]!==g||b[33]!==c?(v=(0,t.jsxs)("div",{className:s,children:[c,g]}),b[32]=g,b[33]=c,b[34]=v):v=b[34],v}let tN=(0,m.memo)(({artifact:e,activeVersionNumber:r,activeVersionId:n,isPreviewFullscreen:s,onToggleFullscreen:l})=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"shrink-0 bg-background",children:(0,t.jsx)(tw,{name:e.name,versionNumber:r,isFullscreen:s,onToggleFullscreen:()=>{l(),s||Promise.resolve().then(()=>{S.z.setActiveArtifactView({payload:{artifactId:e.id,view:"preview"}})})},artifactId:e.id,activeVersionId:n})}),(0,t.jsx)("div",{className:(0,a.f)("flex-1 min-h-0 overflow-hidden","bg-muted border border-border border-b-0","relative",s&&"pointer-events-none select-none will-change-transform"),children:(0,t.jsx)("div",{className:"absolute inset-0 flex flex-col",children:(0,t.jsx)("div",{className:(0,a.f)("h-full min-h-0 bg-muted"),children:(0,t.jsx)(tx,{})})})})]}));var t_=e.i(199630),tS=e.i(18728);function tk(e){let n,s,i,o,c,d,u,f,x,p,g,v,b,j,y,w=(0,r.c)(24),{onExit:N}=e,_=(0,h.f)(),S=(0,t_.f)()?document.querySelector("#portal-container")??document.body:null,[k,C]=(0,m.useState)(!1);if(w[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{let e=requestAnimationFrame(()=>C(!0));return()=>{cancelAnimationFrame(e)}},s=[],w[0]=n,w[1]=s):(n=w[0],s=w[1]),(0,m.useEffect)(n,s),w[2]!==N?(i=()=>{let e=e=>{"Escape"===e.key&&N()};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},o=[N],w[2]=N,w[3]=i,w[4]=o):(i=w[3],o=w[4]),(0,m.useEffect)(i,o),!S)return null;let z=k?"opacity-100":"opacity-0";return w[5]!==z?(c=(0,a.f)("fixed inset-0 z-modal bg-background flex flex-col","transition-opacity duration-150",z),w[5]=z,w[6]=c):c=w[6],w[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("div",{className:"flex-1"}),w[7]=d):d=w[7],w[8]!==N?(u=e=>{e.stopPropagation(),N()},w[8]=N,w[9]=u):u=w[9],w[10]!==_?(f=_("Exit Preview"),w[10]=_,w[11]=f):f=w[11],w[12]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)(eN.f,{className:"h-4 w-4"}),p=(0,t.jsx)(ea.T,{children:"Exit Preview"}),w[12]=x,w[13]=p):(x=w[12],p=w[13]),w[14]!==u||w[15]!==f?(g=(0,t.jsxs)(l.Button,{variant:"ghost",size:"xs",onClick:u,"aria-label":f,children:[x,p]}),w[14]=u,w[15]=f,w[16]=g):g=w[16],w[17]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:"flex-1"}),w[17]=v):v=w[17],w[18]!==g?(b=(0,t.jsxs)("div",{className:"flex items-center justify-center border-b border-border px-4 shrink-0",children:[d,g,v]}),w[18]=g,w[19]=b):b=w[19],w[20]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)("div",{className:"relative flex-1 min-h-0",children:(0,t.jsx)(te,{})}),w[20]=j):j=w[20],w[21]!==b||w[22]!==c?(y=(0,t.jsxs)("div",{className:c,children:[b,j]}),w[21]=b,w[22]=c,w[23]=y):y=w[23],(0,tS.createPortal)(y,S)}let tC=e=>{let n,s,l,i,o=(0,r.c)(10),{onMouseDown:c,currentValue:d,minValue:m,maxValue:u}=e,f=(0,h.f)();return o[0]!==f?(n=f("Resize panel"),o[0]=f,o[1]=n):n=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.f)("group relative w-1.5 h-full cursor-col-resize shrink-0","flex items-center justify-center","focus-visible:outline-hidden focus-visible:border-focus-border focus-visible:shadow-focus"),l=(0,t.jsx)("div",{className:(0,a.f)("w-px h-full bg-border transition-[width,background-color] duration-200","group-hover:w-0.5 group-hover:bg-primary","group-focus-visible:w-0.5 group-focus-visible:bg-primary")}),o[2]=s,o[3]=l):(s=o[2],l=o[3]),o[4]!==d||o[5]!==u||o[6]!==m||o[7]!==c||o[8]!==n?(i=(0,t.jsx)("div",{onMouseDown:c,role:"separator","aria-orientation":"vertical","aria-valuenow":d,"aria-valuemin":m,"aria-valuemax":u,tabIndex:0,"aria-label":n,className:s,children:l}),o[4]=d,o[5]=u,o[6]=m,o[7]=c,o[8]=n,o[9]=i):i=o[9],i};function tz(e){let n,s,a,l,i,o,c,d,u,f,h=(0,r.c)(29),{artifact:x,activeVersionId:p,activeVersionNumber:g}=e,[v,b]=(0,m.useState)(!1),j=(0,m.useRef)(null),y=(0,k.f)(j),w=void 0!==y&&y>0?y-320:1e3;h[0]!==w?(n={containerRef:j,side:"left",initialWidth:700,minWidth:320,maxWidth:w},h[0]=w,h[1]=n):n=h[1];let{handleMouseDown:N,panelWidth:_}=(({containerRef:e,side:t,initialWidth:r,minWidth:n=0,maxWidth:s=1/0})=>{let[a,l]=(0,m.useState)(r),i=(0,m.useRef)(!1);(0,m.useEffect)(()=>{l(e=>{let t=Math.max(n,Math.min(e,s));return t!==e?t:e})},[n,s]);let o=(0,m.useCallback)(r=>{if(!i.current||!e.current)return;let a=e.current.getBoundingClientRect();l(Math.max(n,Math.min("right"===t?a.right-r.clientX:r.clientX-a.left,s)))},[e,n,s,t]),c=(0,m.useCallback)(()=>{i.current=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect=""},[o]);return{panelWidth:a,handleMouseDown:(0,m.useCallback)(e=>{e.preventDefault(),i.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",o),window.addEventListener("mouseup",c)},[o,c])}})(n);h[2]!==p||h[3]!==v?(s=v&&(0,t.jsx)(tk,{activeVersionId:p,onExit:()=>b(!1)}),h[2]=p,h[3]=v,h[4]=s):s=h[4];let S=`${_}px`;return h[5]!==S?(a={"--panel-width":S},h[5]=S,h[6]=a):a=h[6],h[7]!==x.id?(l=(0,t.jsx)(eq,{artifactId:x.id}),h[7]=x.id,h[8]=l):l=h[8],h[9]!==a||h[10]!==l?(i=(0,t.jsx)("div",{"data-allow-inline-style":!0,style:a,className:"h-full flex w-(--panel-width) flex-col shrink-0",children:l}),h[9]=a,h[10]=l,h[11]=i):i=h[11],h[12]!==N||h[13]!==w||h[14]!==_?(o=(0,t.jsx)(tC,{onMouseDown:N,currentValue:_,minValue:320,maxValue:w}),h[12]=N,h[13]=w,h[14]=_,h[15]=o):o=h[15],h[16]===Symbol.for("react.memo_cache_sentinel")?(c=()=>b(tI),h[16]=c):c=h[16],h[17]!==p||h[18]!==g||h[19]!==x||h[20]!==v?(d=(0,t.jsx)("div",{className:"h-full flex flex-col flex-1 min-w-0 overflow-hidden",children:(0,t.jsx)(tN,{artifact:x,activeVersionNumber:g,activeVersionId:p,isPreviewFullscreen:v,onToggleFullscreen:c})}),h[17]=p,h[18]=g,h[19]=x,h[20]=v,h[21]=d):d=h[21],h[22]!==i||h[23]!==o||h[24]!==d?(u=(0,t.jsxs)("aside",{ref:j,className:"flex flex-row w-full h-full min-h-0",children:[i,o,d]}),h[22]=i,h[23]=o,h[24]=d,h[25]=u):u=h[25],h[26]!==u||h[27]!==s?(f=(0,t.jsxs)(t.Fragment,{children:[s,u]}),h[26]=u,h[27]=s,h[28]=f):f=h[28],f}function tI(e){return!e}var tT=e.i(387086);let tM=["chat","history","editor","preview"],tE={chat:(0,tT.b)("Chat"),history:(0,tT.b)("History"),editor:(0,tT.b)("Output"),preview:(0,tT.b)("Preview")};function tA(e){return"editor"===e||"preview"===e}let tR={editor:"editor",preview:"preview"},tP=(0,m.memo)(function(e){let n,s=(0,r.c)(4),{view:a,artifactId:l}=e;if("chat"===a){let e;return s[0]!==l?(e=(0,t.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:(0,t.jsx)(ec,{artifactId:l})}),s[0]=l,s[1]=e):e=s[1],e}if("history"===a){let e;return s[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:(0,t.jsx)(eb,{})}),s[2]=e):e=s[2],e}return s[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:(0,t.jsx)(tx,{})}),s[3]=n):n=s[3],n});function tD(e){let n,s,a,l=(0,r.c)(9),{activeView:i,onChange:o}=e,c=(0,tj.o)(),d=(0,tj.M)();return l[0]!==c?(n=c("Workspace view"),l[0]=c,l[1]=n):n=l[1],l[2]!==d||l[3]!==o?(s=tM.map(e=>(0,t.jsx)(tb.Y,{value:e,onClick:()=>{o(e)},children:d(tE[e])},e)),l[2]=d,l[3]=o,l[4]=s):s=l[4],l[5]!==i||l[6]!==n||l[7]!==s?(a=(0,t.jsx)(tb.c,{"aria-label":n,size:"sm",value:i,children:s}),l[5]=i,l[6]=n,l[7]=s,l[8]=a):a=l[8],a}function tF(e){let n,s,i,o,c,d,u,f,x,p,g,v,b,j,y,w,N,_,k,z,I,T,M,E,A=(0,r.c)(59),{artifact:R,activeVersionId:P}=e,D=(0,h.f)(),[F,V]=(0,m.useState)("chat"),[O,L]=(0,m.useState)(!1);A[0]!==R.id?(n=()=>{L(e=>{let t=!e;return t&&Promise.resolve().then(()=>{S.z.setActiveArtifactView({payload:{artifactId:R.id,view:"preview"}})}),t})},A[0]=R.id,A[1]=n):n=A[1];let B=n;A[2]!==R.id?(s=e=>{if(V(e),tA(e)){let t=tA(e)?tR[e]:null;null!==t&&S.z.setActiveArtifactView({payload:{artifactId:R.id,view:t}})}},A[2]=R.id,A[3]=s):s=A[3];let q=s;A[4]!==P||A[5]!==R.id?(i=()=>{P&&S.z.downloadArtifactVersion({payload:{artifactId:R.id,versionId:P}})},A[4]=P,A[5]=R.id,A[6]=i):i=A[6];let W=i;A[7]!==P||A[8]!==O?(o=O&&(0,t.jsx)(tk,{activeVersionId:P,onExit:()=>L(!1)}),A[7]=P,A[8]=O,A[9]=o):o=A[9],A[10]!==D?(c=D("Close workspace"),A[10]=D,A[11]=c):c=A[11],A[12]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(C.f,{className:"size-4"}),A[12]=d):d=A[12],A[13]!==c?(u=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:tV,"aria-label":c,className:"-ml-1",children:d}),A[13]=c,A[14]=u):u=A[14],A[15]!==R.name?(f=(0,t.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:(0,t.jsx)("span",{className:"font-semibold text-base truncate",title:R.name,children:R.name})}),A[15]=R.name,A[16]=f):f=A[16],A[17]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)("div",{className:"shrink-0 min-w-0 max-w-[60vw]",children:(0,t.jsx)(eV,{})}),A[17]=x):x=A[17],A[18]!==u||A[19]!==f?(p=(0,t.jsxs)("div",{className:"shrink-0 flex items-center gap-2 p-2 bg-background",children:[u,f,x]}),A[18]=u,A[19]=f,A[20]=p):p=A[20],A[21]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.f)("flex-1 min-h-0 overflow-hidden flex flex-col","bg-muted border border-border","md:rounded-tl-2xl"),A[21]=g):g=A[21],A[22]!==q||A[23]!==F?(v=(0,t.jsx)("div",{className:"flex items-center min-w-0",children:(0,t.jsx)(tD,{activeView:F,onChange:q})}),A[22]=q,A[23]=F,A[24]=v):v=A[24],A[25]!==D?(b=D("Download as .zip"),A[25]=D,A[26]=b):b=A[26];let $=!P;return A[27]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(tp.f,{className:"size-4"}),A[27]=j):j=A[27],A[28]!==W||A[29]!==b||A[30]!==$?(y=(0,t.jsx)(l.Button,{size:"icon",variant:"ghost",tone:"subdued",onClick:W,title:b,disabled:$,children:j}),A[28]=W,A[29]=b,A[30]=$,A[31]=y):y=A[31],A[32]!==D||A[33]!==O?(w=D(O?"Exit full screen":"Full screen"),A[32]=D,A[33]=O,A[34]=w):w=A[34],A[35]!==O?(N=O?(0,t.jsx)(tg,{className:"size-4"}):(0,t.jsx)(tv.f,{className:"size-4"}),A[35]=O,A[36]=N):N=A[36],A[37]!==B||A[38]!==w||A[39]!==N?(_=(0,t.jsx)(l.Button,{size:"icon",variant:"ghost",tone:"subdued",onClick:B,title:w,children:N}),A[37]=B,A[38]=w,A[39]=N,A[40]=_):_=A[40],A[41]!==y||A[42]!==_?(k=(0,t.jsxs)("div",{className:"flex items-center",children:[y,_]}),A[41]=y,A[42]=_,A[43]=k):k=A[43],A[44]!==v||A[45]!==k?(z=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-1.5 p-2 shrink-0 bg-background",children:[v,k]}),A[44]=v,A[45]=k,A[46]=z):z=A[46],A[47]!==R.id||A[48]!==F?(I=(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)(tP,{view:F,artifactId:R.id})}),A[47]=R.id,A[48]=F,A[49]=I):I=A[49],A[50]!==z||A[51]!==I?(T=(0,t.jsxs)("div",{className:g,children:[z,I]}),A[50]=z,A[51]=I,A[52]=T):T=A[52],A[53]!==p||A[54]!==T?(M=(0,t.jsxs)("aside",{className:"flex flex-col w-full h-full min-h-0",children:[p,T]}),A[53]=p,A[54]=T,A[55]=M):M=A[55],A[56]!==M||A[57]!==o?(E=(0,t.jsxs)(t.Fragment,{children:[o,M]}),A[56]=M,A[57]=o,A[58]=E):E=A[58],E}function tV(){S.z.closeArtifactView()}let tO=(0,m.memo)(function(){let e,n,s,a,l,i=(0,r.c)(14),o=(0,p.f)(w.I),c=(0,p.f)(w.j);i[0]!==c?(e=e=>(0,w.Q)(e,{versionId:c}),i[0]=c,i[1]=e):e=i[1];let d=(0,p.f)(e);i[2]!==c||i[3]!==o?(n=()=>{o&&!c&&o.headVersionId&&S.z.setActiveVersionId({payload:{artifactId:o.id,versionId:o.headVersionId}})},s=[o,c],i[2]=c,i[3]=o,i[4]=n,i[5]=s):(n=i[4],s=i[5]),(0,m.useEffect)(n,s);let u=(0,_.x)();if(!o)return null;let f=c??null,h=d??null;i[6]!==o||i[7]!==f||i[8]!==h?(a={artifact:o,activeVersionId:f,activeVersionNumber:h},i[6]=o,i[7]=f,i[8]=h,i[9]=a):a=i[9];let x=a;if(!u){let e;return i[10]!==x?(e=(0,t.jsx)(tF,{...x}),i[10]=x,i[11]=e):e=i[11],e}return i[12]!==x?(l=(0,t.jsx)(tz,{...x}),i[12]=x,i[13]=l):l=i[13],l},()=>!0);var tL=e.i(367765),tB=e.i(732571),tq=e.i(875910),tW=e.i(129067),t$=e.i(73668),tU=e.i(656921),tH=e.i(618115),tG=e.i(22022),tK=e.i(622817),tJ=e.i(733064),tZ=e.i(376885),tQ=e.i(545012),tX=e.i(128564),tY=e.i(264635),t0=e.i(744475);let t1=[];function t2(){let e,t,n,s,a=(0,r.c)(12),l=(0,tW.R)("oriCode"),i=(0,tQ.j)(),{isLoaded:o,isSignedIn:c,orgId:d,userId:u}=(0,tZ.f)(),f=l&&!0===c;a[0]!==f?(e={isEnabled:f},a[0]=f,a[1]=e):e=a[1];let{activeWorkspaceId:h,didFetchFail:x}=(0,tX.Z)(e),p=l?h??null:null;a[2]!==p?(t=(0,t0.b)(p),a[2]=p,a[3]=t):t=a[3];let{data:g,status:v,isPlaceholderData:b}=(0,tH.f)(t),j=function(e){let t,n,s=(0,r.c)(4),[a,l]=(0,m.useState)(null);return 8e3!==s[0]||s[1]!==e?(t=()=>{let t=setTimeout(()=>l(e),8e3);return()=>clearTimeout(t)},n=[8e3,e],s[0]=8e3,s[1]=e,s[2]=t,s[3]=n):(t=s[2],n=s[3]),(0,m.useEffect)(t,n),a===e}(`${u??""}|${d??""}|${h??""}`)||i&&o&&(!l||!1===c||x||"pending"!==v&&!b);e:{let e;if(!g||!h){n=t1;break e}if(a[4]!==h||a[5]!==g.interns){let t;a[7]!==h?(t=e=>e.workspaceId===h&&e.status===tY.L.Running,a[7]=h,a[8]=t):t=a[8],e=g.interns.filter(t).map(t3),a[4]=h,a[5]=g.interns,a[6]=e}else e=a[6];n=e}let y=n;return a[9]!==j||a[10]!==y?(s={modelInfos:y,isSettled:j},a[9]=j,a[10]=y,a[11]=s):s=a[11],s}function t3(e){return(0,tK.o)(e)}var t4=e.i(463444),t5=e.i(586837),t6=e.i(351764),t7=e.i(700050),t8=e.i(138814),t9=e.i(962852),re=e.i(934227),rt=e.i(642446),rr=e.i(978581),rn=e.i(80676),rs=e.i(894868),ra=e.i(827517),rl=e.i(780397);let ri=m.forwardRef(function({title:e,titleId:t,...r},n){return m.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?m.createElement("title",{id:t},e):null,m.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.636 5.636a9 9 0 1 0 12.728 0M12 3v9"}))});var ro=e.i(623304),rc=e.i(219643),rd=e.i(368966),rm=e.i(834336),ru=e.i(431399);function rf(e){let n,s,a,l,i=(0,r.c)(33),{character:o,isModelMandatoryReasoning:c,isReasoningEnabled:d}=e,m=(0,tj.o)();if(i[0]!==o.id||i[1]!==o.modelInfo?.endpoint?.model.reasoning_config||i[2]!==o.reasoning||i[3]!==m||i[4]!==c||i[5]!==d){let e,r,a,l,u,f,h,x=(0,rc.w)(o.modelInfo?.endpoint?.model.reasoning_config??null),p=(0,ru.I)(x),g=(0,rc.$)(o.reasoning?.effort??rm.s,x)??p[0],v=(0,ru.n)({isReasoningEnabled:d,maxTokens:o.reasoning?.maxTokens,effort:g,levelList:p});i[8]!==o.id?(e=e=>{S.z.updateCharacter({payload:{roomId:(0,rl.f)(),characterId:o.id,partialCharacter:{reasoning:e}}})},i[8]=o.id,i[9]=e):e=i[9];let b=e;i[10]!==o.reasoning||i[11]!==c||i[12]!==b?(r=()=>{c||b({...o.reasoning,enabled:!1})},i[10]=o.reasoning,i[11]=c,i[12]=b,i[13]=r):r=i[13];let j=r;i[14]!==o.reasoning||i[15]!==b?(a=e=>{let{maxTokens:t,...r}=o.reasoning??{};b({...r,enabled:!0,effort:e})},i[14]=o.reasoning,i[15]=b,i[16]=a):a=i[16];let y=a;i[17]!==m?(l=m("Reasoning effort"),i[17]=m,i[18]=l):l=i[18];let w=function(e){switch(e.kind){case"off":return"off";case"budget":return"";case"effort":return e.effort;default:return e}}(v);i[19]!==m?(u=m("Off"),i[19]=m,i[20]=u):u=i[20],i[21]!==c||i[22]!==u?(f=(0,t.jsx)(tb.Y,{value:"off",disabled:c,children:u}),i[21]=c,i[22]=u,i[23]=f):f=i[23],i[24]!==m?(h=e=>(0,t.jsx)(tb.Y,{value:e,"aria-label":rh(e,m),children:function(e,t){switch(e){case rd.E.Max:return t("Max");case rd.E.XHigh:return t("XHigh");case rd.E.High:return t("High");case rd.E.Medium:return t("Med");case rd.E.Low:return t("Low");case rd.E.Minimal:return t("Min");case rd.E.None:return t("None");default:return e}}(e,m)},e),i[24]=m,i[25]=h):h=i[25],n=(0,t.jsxs)(tb.c,{size:"sm","aria-label":l,value:w,onValueChange:e=>{if("off"===e)return void j();let t=p.find(t=>t===e);void 0!==t&&y(t)},children:[f,p.map(h)]}),s="budget"===v.kind?(0,t.jsx)("span",{className:"px-1 text-overline text-muted-foreground",children:function(e,t){switch(e.kind){case"off":return t("Off");case"budget":return t("{maxTokens, number} token budget",{maxTokens:e.maxTokens});case"effort":return rh(e.effort,t);default:return e}}(v,m)}):null,i[0]=o.id,i[1]=o.modelInfo?.endpoint?.model.reasoning_config,i[2]=o.reasoning,i[3]=m,i[4]=c,i[5]=d,i[6]=n,i[7]=s}else n=i[6],s=i[7];return i[26]!==m||i[27]!==c?(a=c?(0,t.jsx)("span",{className:"px-1 text-overline text-muted-foreground",children:m("Reasoning is mandatory for this model")}):null,i[26]=m,i[27]=c,i[28]=a):a=i[28],i[29]!==n||i[30]!==s||i[31]!==a?(l=(0,t.jsxs)(t.Fragment,{children:[n,s,a]}),i[29]=n,i[30]=s,i[31]=a,i[32]=l):l=i[32],l}function rh(e,t){switch(e){case rd.E.Max:return t("Max");case rd.E.XHigh:return t("Extra high");case rd.E.High:return t("High");case rd.E.Medium:return t("Medium");case rd.E.Low:return t("Low");case rd.E.Minimal:return t("Minimal");case rd.E.None:return t("None");default:return e}}function rx(e){let n,s,a,l,i,o,c,d,u,f,x,p,g,v,b,j,y,w=(0,r.c)(54),{character:N,onOpenAdvanced:_,children:k}=e,C=(0,h.f)(),[z,I]=(0,m.useState)(!1);w[0]!==N?(n=(0,tK.n)(N),w[0]=N,w[1]=n):n=w[1];let T=n,M=N.modelInfo?.endpoint?.supports_reasoning??!1;w[2]!==N.modelInfo?(s=!!N.modelInfo?.endpoint&&(0,rr.f)(N.modelInfo.endpoint),w[2]=N.modelInfo,w[3]=s):s=w[3];let E=s,A=!!E||(N.reasoning?.enabled??!1);w[4]!==k?(a=(0,t.jsx)(eI.J,{render:k}),w[4]=k,w[5]=a):a=w[5],w[6]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(ri,{className:"size-4"}),w[6]=l):l=w[6],w[7]!==C?(i=C("Enable"),w[7]=C,w[8]=i):i=w[8];let R=!N.isDisabled;return w[9]!==N.id||w[10]!==N.isDisabled?(o=()=>{S.z.updateCharacter({payload:{roomId:(0,rl.f)(),characterId:N.id,partialCharacter:{isDisabled:!N.isDisabled}}})},w[9]=N.id,w[10]=N.isDisabled,w[11]=o):o=w[11],w[12]!==i||w[13]!==R||w[14]!==o?(c=(0,t.jsx)(rg,{icon:l,label:i,checked:R,onToggle:o}),w[12]=i,w[13]=R,w[14]=o,w[15]=c):c=w[15],w[16]!==N.id||w[17]!==N.reasoning||w[18]!==C||w[19]!==T||w[20]!==E||w[21]!==A||w[22]!==M?(d=T?null:(0,t.jsx)(rg,{icon:(0,t.jsx)(W.f,{className:"size-4"}),label:C("Reasoning"),checked:A,disabled:!M||E,onToggle:()=>{S.z.updateCharacter({payload:{roomId:(0,rl.f)(),characterId:N.id,partialCharacter:{reasoning:{...N.reasoning,enabled:!A}}}})}}),w[16]=N.id,w[17]=N.reasoning,w[18]=C,w[19]=T,w[20]=E,w[21]=A,w[22]=M,w[23]=d):d=w[23],w[24]!==N||w[25]!==T||w[26]!==E||w[27]!==A||w[28]!==M?(u=!T&&M?(0,t.jsx)("div",{className:"flex flex-col gap-1.5 px-1 pb-1",children:(0,t.jsx)(rf,{character:N,isModelMandatoryReasoning:E,isReasoningEnabled:A})}):null,w[24]=N,w[25]=T,w[26]=E,w[27]=A,w[28]=M,w[29]=u):u=w[29],w[30]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(rp,{}),w[30]=f):f=w[30],w[31]!==N.id||w[32]!==C||w[33]!==T?(x=T?null:(0,t.jsx)(rv,{icon:(0,t.jsx)(t9.f,{className:"size-4"}),label:C("Duplicate"),onClick:()=>{S.z.duplicateCharacter({payload:{roomId:(0,rl.f)(),sourceCharacterId:N.id}}),I(!1)}}),w[31]=N.id,w[32]=C,w[33]=T,w[34]=x):x=w[34],w[35]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(t8.f,{className:"size-4"}),w[35]=p):p=w[35],w[36]!==C||w[37]!==T?(g=C(T?"Intern settings":"Advanced settings"),w[36]=C,w[37]=T,w[38]=g):g=w[38],w[39]!==_?(v=()=>{I(!1),_()},w[39]=_,w[40]=v):v=w[40],w[41]!==g||w[42]!==v?(b=(0,t.jsx)(rv,{icon:p,label:g,onClick:v}),w[41]=g,w[42]=v,w[43]=b):b=w[43],w[44]!==u||w[45]!==x||w[46]!==b||w[47]!==c||w[48]!==d?(j=(0,t.jsxs)(eI.T,{side:"bottom",align:"end",sideOffset:6,positionerClassName:"z-popover",collisionPadding:8,className:"w-auto min-w-60 rounded-xl p-1.5 shadow-lg",children:[c,d,u,f,x,b]}),w[44]=u,w[45]=x,w[46]=b,w[47]=c,w[48]=d,w[49]=j):j=w[49],w[50]!==z||w[51]!==j||w[52]!==a?(y=(0,t.jsxs)(eI.V,{open:z,onOpenChange:I,children:[a,j]}),w[50]=z,w[51]=j,w[52]=a,w[53]=y):y=w[53],y}function rp(){let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{"aria-hidden":"true",className:"mx-1 my-1 h-px bg-border"}),n[0]=e):e=n[0],e}function rg(e){let n,s,l,i,o,c,d=(0,r.c)(20),{icon:m,label:u,checked:f,disabled:x,onToggle:p}=e,g=(0,h.f)(),v=x?"opacity-50":"transition-colors hover:bg-accent";return d[0]!==v?(n=(0,a.f)("flex items-center justify-between gap-2 rounded-lg px-2 py-1.5 text-sm",v),d[0]=v,d[1]=n):n=d[1],d[2]!==m||d[3]!==u?(s=(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[m,u]}),d[2]=m,d[3]=u,d[4]=s):s=d[4],d[5]!==g||d[6]!==u?(l=g("Toggle {label}",{label:u}),d[5]=g,d[6]=u,d[7]=l):l=d[7],d[8]!==x||d[9]!==p?(i=e=>{e.stopPropagation(),x||p()},d[8]=x,d[9]=p,d[10]=i):i=d[10],d[11]!==f||d[12]!==x||d[13]!==l||d[14]!==i?(o=(0,t.jsx)(ro.Z,{checked:f,disabled:x,"aria-label":l,onClick:i}),d[11]=f,d[12]=x,d[13]=l,d[14]=i,d[15]=o):o=d[15],d[16]!==n||d[17]!==s||d[18]!==o?(c=(0,t.jsxs)("div",{className:n,children:[s,o]}),d[16]=n,d[17]=s,d[18]=o,d[19]=c):c=d[19],c}function rv(e){let n,s,l,i=(0,r.c)(7),{icon:o,label:c,onClick:d}=e;return i[0]!==d?(n=e=>{e.stopPropagation(),d()},i[0]=d,i[1]=n):n=i[1],i[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.f)("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm","transition-colors hover:bg-accent"),i[2]=s):s=i[2],i[3]!==o||i[4]!==c||i[5]!==n?(l=(0,t.jsxs)("button",{type:"button",onClick:n,className:s,children:[o,c]}),i[3]=o,i[4]=c,i[5]=n,i[6]=l):l=i[6],l}function rb(e,t){return"--"!==t?t:e?.modelInfo?.short_name??e?.modelInfo?.name??e?.name??t}let rj="transition-transform duration-quick ease-smooth-out motion-reduce:transition-none pointer-fine:hover:scale-110 active:scale-95";function ry(e){let n,s,l,i=(0,r.c)(5),{className:o}=e;return i[0]!==o?(n=(0,a.f)("block text-negative",o),i[0]=o,i[1]=n):n=i[1],i[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("line",{x1:"1.5",y1:"8.5",x2:"8.5",y2:"1.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),i[2]=s):s=i[2],i[3]!==n?(l=(0,t.jsx)("svg",{viewBox:"0 0 10 10",className:n,"aria-hidden":"true",children:s}),i[3]=n,i[4]=l):l=i[4],l}function rw({characterId:e,className:r,tooltip:n,onOpenChange:s}){let l=(0,h.f)(),o=(0,m.useMemo)(t4.F,[]),c=(0,p.f)(t=>o(t,e)),d=(0,ra.f)(c),u=(0,ra.X)(e=>d?e.colorsBySlug[d]??null:null),f=(0,ra.X)(e=>e.setColor),[x,g]=(0,m.useState)(!1);if(!d)return null;let v=(0,ra.N)(u),b=e=>{f(d,e),g(!1)},j=(0,t.jsx)("button",{type:"button","aria-label":l("Choose model color"),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:(0,a.f)("flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden","rounded-full border border-border/60 transition-colors hover:border-border",v?v.pillBg:"bg-background",r),children:v?null:(0,t.jsx)(ry,{className:"h-full w-full"})}),y=(0,t.jsx)(eI.J,{render:j});return(0,t.jsxs)(eI.V,{open:x,onOpenChange:e=>{g(e),s?.(e)},children:[n?(0,t.jsx)(i.Tooltip,{side:"bottom",delay:0,content:n,children:y}):y,(0,t.jsxs)(eI.T,{side:"bottom",align:"start",sideOffset:8,className:(0,a.f)("w-auto rounded-full p-1.5","flex items-center gap-1.5"),children:[(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":null===u,"aria-label":l("No color"),onClick:()=>b(null),className:(0,a.f)("flex h-6 w-6 items-center justify-center overflow-hidden rounded-full","border border-border/40 bg-background",rj,null===u&&"ring-2 ring-foreground/40 ring-offset-1 ring-offset-popover"),children:(0,t.jsx)(ry,{className:"h-4 w-4"})}),ra.$.map(e=>{let r=u===e.key;return(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":r,"aria-label":l("{color} background",{color:e.key}),onClick:()=>b(e.key),className:(0,a.f)("h-6 w-6 rounded-full border border-border/40",rj,e.swatchBg,r&&"ring-2 ring-foreground/40 ring-offset-1 ring-offset-popover")},e.key)})]})]})}var rN=e.i(855155),r_=e.i(481437),rS=e.i(912147),rk=e.i(181870),rC=e.i(475615),rz=e.i(344322),rI=e.i(743500),rT=e.i(9285),rM=e.i(411252);function rE(e){let r=(0,m.useMemo)(()=>e.title?.toString(),[e.title]),n=(0,m.useMemo)(()=>{if("boolean"==typeof e.open)return e.open?[r]:[]},[e.open,r]),s=(0,m.useCallback)(t=>{if(!e.onOpenChange)return;let n=Array.isArray(t)?t.includes(r):t===r;e.onOpenChange(n)},[e.onOpenChange,r]);return(0,t.jsx)(rM.Accordion,{collapsible:!0,defaultValue:e.defaultOpen?[r]:void 0,value:n,onValueChange:s,className:(0,a.f)(e.className),children:(0,t.jsxs)(rM.AccordionItem,{value:r,className:"border-none",children:[(0,t.jsx)(rM.AccordionTrigger,{className:(0,a.f)("text-sm hover:underline focus-visible:shadow-none focus-visible:underline",e.centered&&"justify-center",e.triggerClassName),onClick:e.onClick,children:e.title}),(0,t.jsx)(rM.AccordionContent,{className:"text-sm",children:e.children})]})})}var rA=e.i(554395),rR=e.i(989794);let rP=/[^\n\x20-\x7F]/,rD=/^$/;class rF{#e=0;#t=0;#r=0;#n;constructor(e){this.#n=e}update(e){let t=e.length;if(0===t)return;let r=0;if(t>=64){let n=rP.exec(e);if(null===n){let r=rV(e);this.#e+=t-r,this.#t+=r;return}r=n.index;let s=rV(e.slice(0,r));this.#e+=r-s,this.#t+=s,rD.test("")}for(let s=r;s=32&&t<=127){this.#e++;continue}if((n=t)<32||n>=128&&n<=591||n>=880&&n<=1023||n>=1024&&n<=1327){this.#t++;continue}this.#r++}}clone(){let e=new rF(this.#n);return e.#e=this.#e,e.#t=this.#t,e.#r=this.#r,e}finalize(){return Math.ceil(this.#e/this.#n)+Math.ceil(this.#t/2)+this.#r}}function rV(e){let t=0,r=e.indexOf("\n");for(;-1!==r;)t++,r=e.indexOf("\n",r+1);return t}var rO=e.i(393182),rL=e.i(72916),rB=e.i(393272),rq=e.i(983335),rW=e.i(960421),r$=e.i(919035),rU=e.i(651681);let rH={name:"ghost",size:24,node:[["path",{d:"M15 10v1",key:"oj8wfp"}],["path",{d:"M7.528 20.472a1.6 1.6 0 012.277 0l1.057 1.056a1.6 1.6 0 002.276 0l1.057-1.056a1.6 1.6 0 012.277 0l1.114 1.114a1.4 1.4 0 002.414-1V10a8 8 0 00-16 0v10.586a1.4 1.4 0 002.414 1z",key:"13lou3"}],["path",{d:"M9 10v1",key:"1e14fa"}]]};rH.node;let rG=(0,rU.f)(rH);var rK=e.i(63135),rJ=e.i(502704),rZ=e.i(284274),rQ=e.i(361220),rX=e.i(295654),rY=e.i(115247),r0=e.i(632521),r1=e.i(799963),r2=e.i(354896);let r3=e=>{let n,s,i,o,c,d,u,f,x,p,g,v,b,j,y,w,N,_,S,k,C=(0,r.c)(59),{label:z,presets:I,selectedId:T,disabled:M,onSelect:E,compact:A}=e,R=void 0!==A&&A,P=(0,h.f)(),[D,F]=(0,m.useState)(!1),V=(0,m.useId)();C[0]!==I||C[1]!==T?(n=I.find(e=>e.id===T)||null,C[0]=I,C[1]=T,C[2]=n):n=C[2];let O=n,L=R?"gap-1.5":"gap-1";C[3]!==L?(s=(0,a.f)("flex w-full flex-col",L),C[3]=L,C[4]=s):s=C[4];let B=R?"medium":void 0;C[5]!==z||C[6]!==B?(i=(0,t.jsx)(rC.f,{weight:B,leading:"snug",children:z}),C[5]=z,C[6]=B,C[7]=i):i=C[7];let q=!O&&"text-muted-foreground";C[8]!==q?(o=(0,a.f)("relative w-full pr-7",q),C[8]=q,C[9]=o):o=C[9],C[10]!==P||C[11]!==z||C[12]!==O?(c=O?O.name:P("Select {label}...",{label:z}),C[10]=P,C[11]=z,C[12]=O,C[13]=c):c=C[13],C[14]!==c?(d=(0,t.jsx)("span",{className:"line-clamp-1 w-full truncate text-start",children:c}),C[14]=c,C[15]=d):d=C[15],C[16]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(r2.f,{className:"absolute right-1 size-4 opacity-50"}),C[16]=u):u=C[16],C[17]!==M||C[18]!==V||C[19]!==D||C[20]!==d||C[21]!==o?(f=(0,t.jsx)(eI.J,{render:(0,t.jsxs)(l.Button,{align:"start",variant:"outline",size:"sm",density:"compact",role:"combobox","aria-expanded":D,"aria-controls":V,disabled:M,className:o,children:[d,u]})}),C[17]=M,C[18]=V,C[19]=D,C[20]=d,C[21]=o,C[22]=f):f=C[22],C[23]!==P||C[24]!==z?(x=P("Search {label}...",{label:z}),C[23]=P,C[24]=z,C[25]=x):x=C[25],C[26]!==x?(p=(0,t.jsx)(ez.H,{placeholder:x}),C[26]=x,C[27]=p):p=C[27],C[28]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)(ez.e,{children:(0,t.jsx)(ea.T,{children:"No preset found."})}),C[28]=g):g=C[28];let W=!T;if(C[29]!==E?(v=()=>{E(null),F(!1)},C[29]=E,C[30]=v):v=C[30],C[31]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(ea.T,{children:"None"}),C[31]=b):b=C[31],C[32]!==W||C[33]!==v?(j=(0,t.jsx)(r1.X,{isSelected:W,onSelect:v,children:b},"none"),C[32]=W,C[33]=v,C[34]=j):j=C[34],C[35]!==E||C[36]!==I||C[37]!==T){let e;C[39]!==E||C[40]!==T?(e=e=>(0,t.jsx)(r1.X,{value:e.name,isSelected:T===e.id,onSelect:()=>{E(e),F(!1)},children:e.name},e.id),C[39]=E,C[40]=T,C[41]=e):e=C[41],y=I.map(e),C[35]=E,C[36]=I,C[37]=T,C[38]=y}else y=C[38];return C[42]!==j||C[43]!==y?(w=(0,t.jsxs)(ez.W,{children:[j,y]}),C[42]=j,C[43]=y,C[44]=w):w=C[44],C[45]!==V||C[46]!==w?(N=(0,t.jsxs)(ez.X,{id:V,children:[g,w]}),C[45]=V,C[46]=w,C[47]=N):N=C[47],C[48]!==p||C[49]!==N?(_=(0,t.jsx)(eI.T,{positionerClassName:"z-popover",collisionPadding:8,className:"w-[calc(100dvw-5rem)] max-w-108 rounded-lg p-0",align:"start",children:(0,t.jsxs)(ez.s,{children:[p,N]})}),C[48]=p,C[49]=N,C[50]=_):_=C[50],C[51]!==D||C[52]!==f||C[53]!==_?(S=(0,t.jsxs)(eI.V,{open:D,onOpenChange:F,children:[f,_]}),C[51]=D,C[52]=f,C[53]=_,C[54]=S):S=C[54],C[55]!==S||C[56]!==s||C[57]!==i?(k=(0,t.jsxs)("div",{className:s,children:[i,S]}),C[55]=S,C[56]=s,C[57]=i,C[58]=k):k=C[58],k};var r4=e.i(449964),r5=e.i(326e3),r6=e.i(138257),r7=e.i(339814);function r8(e){let n,s,a,l,i,o,c,d,m,u=(0,r.c)(34),{label:f,value:x,options:p,onChange:g,className:v,shouldSort:b}=e,j=void 0===b||b,y=(0,h.f)(),w=(0,r6.useLocale)();if(u[0]!==v||u[1]!==y||u[2]!==f||u[3]!==w||u[4]!==g||u[5]!==p||u[6]!==j||u[7]!==x){let e,r,d=function(e,{options:t,shouldSort:r}){return Object.keys(t).map(e=>({label:e,value:t[e]})).filter(e=>void 0!==e.value).toSorted((t,n)=>r?(0,r7.o)(t.label,n.label,{locale:e}):0)}(w,{options:p,shouldSort:j});s=r5.Select,i=x,o=e=>{let t=d.find(t=>t.value===e);t&&g(t.value)},u[15]!==y||u[16]!==f?(e=y("Select {label}",{label:f}),u[15]=y,u[16]=f,u[17]=e):e=u[17],u[18]!==e?(r=(0,t.jsx)(r5.SelectValue,{placeholder:e}),u[18]=e,u[19]=r):r=u[19],u[20]!==v||u[21]!==f||u[22]!==r?(c=(0,t.jsx)(r5.SelectTrigger,{"aria-label":f,className:v,children:r}),u[20]=v,u[21]=f,u[22]=r,u[23]=c):c=u[23],n=r5.SelectContent,a="end",l=d.map(r9),u[0]=v,u[1]=y,u[2]=f,u[3]=w,u[4]=g,u[5]=p,u[6]=j,u[7]=x,u[8]=n,u[9]=s,u[10]=a,u[11]=l,u[12]=i,u[13]=o,u[14]=c}else n=u[8],s=u[9],a=u[10],l=u[11],i=u[12],o=u[13],c=u[14];return u[24]!==n||u[25]!==a||u[26]!==l?(d=(0,t.jsx)(n,{align:a,children:l}),u[24]=n,u[25]=a,u[26]=l,u[27]=d):d=u[27],u[28]!==s||u[29]!==i||u[30]!==o||u[31]!==c||u[32]!==d?(m=(0,t.jsxs)(s,{value:i,onValueChange:o,children:[c,d]}),u[28]=s,u[29]=i,u[30]=o,u[31]=c,u[32]=d,u[33]=m):m=u[33],m}function r9(e){return(0,t.jsx)(r5.SelectItem,{value:e.value,children:e.label},e.value)}function ne(e){let n,s,l,i,o,c,d=(0,r.c)(13),{character:m}=e,u=(0,h.f)();d[0]!==m.plugins?(n=m.plugins?.find(nr)?.pdf?.engine,d[0]=m.plugins,d[1]=n):n=d[1];let f=n;return d[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.f)("flex w-full flex-col","gap-1.5"),d[2]=s):s=d[2],d[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(rC.f,{weight:"medium",leading:"snug",htmlFor:"file-parser-engine",children:(0,t.jsx)(ea.T,{children:"File Parser Engine"})}),d[3]=l):l=d[3],d[4]!==u?(i=u("Engine"),d[4]=u,d[5]=i):i=d[5],d[6]!==m.id||d[7]!==m.plugins?(o=e=>{if(!e)return void S.z.togglePluginForCharacter({payload:{roomId:(0,rl.f)(),characterId:m.id,pluginId:rL.f.FileParser,forceState:!1}});let t=m.plugins?.filter(nt)||[];S.z.updateCharacter({payload:{roomId:(0,rl.f)(),characterId:m.id,partialCharacter:{plugins:[...t,{id:rL.f.FileParser,pdf:{engine:e}}]}}})},d[6]=m.id,d[7]=m.plugins,d[8]=o):o=d[8],d[9]!==f||d[10]!==i||d[11]!==o?(c=(0,t.jsxs)("div",{className:s,children:[l,(0,t.jsx)(r8,{label:i,value:f,options:r4.f,className:"h-8 w-full text-sm text-foreground",onChange:o})]}),d[9]=f,d[10]=i,d[11]=o,d[12]=c):c=d[12],c}function nt(e){return e.id!==rL.f.FileParser}function nr(e){return e.id===rL.f.FileParser}var nn=e.i(967605);function ns(e){let n,s,l,i,o,c,d,m,u,f=(0,r.c)(21),{character:g,withName:v,className:b}=e,j=void 0!==v&&v,y=(0,h.f)(),w=(0,p.f)(x.M),{isSignedIn:N}=(0,tZ.f)(),_=!0===N;f[0]!==_?(n={isEnabled:_},f[0]=_,f[1]=n):n=f[1];let{activeWorkspaceId:k}=(0,tX.Z)(n),C=(0,tK.J)(g.model)??(0,tK.J)(g.modelInfo?.slug),z=k??null,{data:I}=(0,tH.f)((0,t0.X)(z,C)),T=I?.intern,M=T?.status===tY.L.Running?T.runtimeMetadata.running_model??null:null,E=z&&C?(0,tK.W)({workspaceId:z,internId:C}):null;f[2]!==b?(s=(0,a.f)("flex w-full flex-col","gap-3 [&_*]:shadow-none",b),f[2]=b,f[3]=s):s=f[3],f[4]!==g||f[5]!==y||f[6]!==w||f[7]!==j?(l=j&&(0,t.jsxs)("div",{className:(0,a.f)("flex items-center","gap-3 pr-7"),children:[(0,t.jsx)(eE.f,{character:g,className:"size-9 shrink-0"}),(0,t.jsx)(rk.f,{name:"Intern nickname",className:"w-full flex-1 border-0",value:g.name??"",type:"text",placeholder:g.modelInfo?.name??y("Nickname"),onChange:e=>S.z.updateCharacter({payload:{roomId:w,characterId:g.id,partialCharacter:{name:e.target.value}}})}),(0,t.jsx)(ro.Z,{checked:!g.isDisabled,"aria-label":y("Listening"),onCheckedChange:e=>S.z.updateCharacter({payload:{roomId:w,characterId:g.id,partialCharacter:{isDisabled:!e}}})})]}),f[4]=g,f[5]=y,f[6]=w,f[7]=j,f[8]=l):l=f[8],f[9]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.f)("flex w-full flex-col","gap-1.5"),f[9]=i):i=f[9],f[10]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(rC.f,{weight:"medium",leading:"snug",children:(0,t.jsx)(ea.T,{children:"Model"})}),f[10]=o):o=f[10];let A=M??"—";return f[11]!==A?(c=(0,t.jsxs)("div",{className:i,children:[o,(0,t.jsx)("p",{className:"text-sm text-foreground",children:A})]}),f[11]=A,f[12]=c):c=f[12],f[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(ea.T,{children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"The model, system prompt, sampling, and tools are the intern's own. The room only sends it your messages."})}),f[13]=d):d=f[13],f[14]!==E?(m=E?(0,t.jsx)(nn.Link,{href:E,className:"text-sm font-medium text-accent-foreground underline-offset-4 hover:underline",children:(0,t.jsx)(ea.T,{children:"Edit persona in the interns hub"})}):null,f[14]=E,f[15]=m):m=f[15],f[16]!==m||f[17]!==s||f[18]!==l||f[19]!==c?(u=(0,t.jsxs)("div",{className:s,children:[l,c,d,m]}),f[16]=m,f[17]=s,f[18]=l,f[19]=c,f[20]=u):u=f[20],u}function na(e){let n,s=(0,r.c)(4);if((0,tK.n)(e.character)){let r;return s[0]!==e?(r=(0,t.jsx)(ns,{...e}),s[0]=e,s[1]=r):r=s[1],r}return s[2]!==e?(n=(0,t.jsx)(nl,{...e}),s[2]=e,s[3]=n):n=s[3],n}function nl({character:e,withName:r=!1,className:n}){let s=(0,ed.f)(),o=(0,h.f)(),c=(0,r$.f)(),d=(0,p.f)(x.M),{contextEntityId:u}=(0,t$.useEntity)(),f=(0,t6.q)(),{data:g,isLoading:v}=(0,tH.f)((0,t6.P)(u,f)),b=null===u||(0,t6.v)(f)||v,j=g?.presetsWithVersions||[],[y,w]=(0,m.useState)(!1),[N,_]=(0,m.useState)(null),[k,C]=(0,m.useState)(!1),z=(0,p.f)(t=>Object.values((0,t4.T)(t)).some(t=>t.id!==e.id&&!(0,tK.n)(t)));(0,m.useEffect)(()=>{C(!1)},[e.id]);let I=t=>{C(!1),S.z.updateCharacter({payload:{roomId:d,characterId:e.id,partialCharacter:t}})},M=(0,m.useMemo)(()=>e.presetSlug?j.find(t=>t.slug===e.presetSlug)??null:null,[e.presetSlug,j]),E=(0,m.useMemo)(()=>M?.designated_version_id&&M?.preset_versions&&M.preset_versions.find(e=>e.id===M.designated_version_id)||null,[M]),A=(0,m.useMemo)(()=>{let e=E?.system_prompt;return!!e&&e.trim().length>0},[E]),R=(0,m.useMemo)(()=>(0,rY.f)(e.modelInfo),[e.modelInfo]),P=(0,r0.f)(e),D=e.includeDefaultSystemPrompt??!0;(0,m.useEffect)(()=>{A&&D&&I({includeDefaultSystemPrompt:!1})},[A,D]);let F=(0,m.useMemo)(()=>R||(D?(0,rX.A)(e.modelInfo):e.description??""),[R,D,e.modelInfo,e.description]),V=(0,m.useMemo)(()=>{let e;return(e=new rF(4)).update(F),e.finalize()},[F]),O=e.modelInfo?.endpoint?.supports_reasoning??!1,L=!!e.modelInfo?.endpoint&&(0,rr.f)(e.modelInfo.endpoint),B=!!L||(e.reasoning?.enabled??!1),q=(0,rc.w)(e.modelInfo?.endpoint?.model.reasoning_config??null),W=null===q?rW.n:Object.fromEntries(Object.entries(rW.n).filter(([,e])=>q.includes(e))),$=(0,rc.$)(e.reasoning?.effort??rm.s,q)??Object.values(W)[0]??rm.s,U=(0,t.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,t.jsxs)(rC.f,{weight:"medium",leading:"snug",className:(0,a.f)("flex items-center","gap-2"),children:[(0,t.jsx)(rK.f,{className:(0,a.f)("size-4","transition-colors",B&&"text-primary")}),(0,t.jsx)(ea.T,{children:"Enable Reasoning"})]}),(0,t.jsx)(ro.Z,{id:`toggle-reasoning-${e.id}`,disabled:L,checked:B,onCheckedChange:t=>{let r={...e.reasoning};r.enabled=t,t||delete r.effort,I({reasoning:r})}})]}),H=(0,m.useMemo)(()=>A?null:(0,t.jsxs)(tb.c,{"aria-label":o("System prompt source"),className:"w-full",value:D?"default":"custom",children:[(0,t.jsx)(tb.Y,{value:"default",disabled:!!R,onClick:()=>I({includeDefaultSystemPrompt:!0}),children:(0,t.jsx)(ea.T,{children:"Default"})}),(0,t.jsx)(tb.Y,{value:"custom",disabled:!!R,onClick:()=>I({includeDefaultSystemPrompt:!1}),children:(0,t.jsx)(ea.T,{children:"Custom"})})]}),[o,D,R,A,I]);return(0,t.jsxs)("div",{className:(0,a.f)("flex w-full flex-col","gap-3 [&_*]:shadow-none",n),children:[r&&(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(eE.f,{character:e,className:"size-9 shrink-0"}),(0,t.jsx)(rk.f,{name:"Model Name",className:"w-full flex-1 border-0",value:e.name,type:"text",placeholder:o("Name"),onChange:e=>I({name:e.target.value})}),(0,t.jsx)(ro.Z,{checked:!e.isDisabled,onCheckedChange:t=>S.z.updateCharacter({payload:{roomId:d,characterId:e.id,partialCharacter:{isDisabled:!t}}})})]}),(0,t.jsxs)("div",{className:(0,a.f)("flex w-full flex-col","gap-1.5"),children:[(0,t.jsx)(rC.f,{weight:"medium",leading:"snug",children:(0,t.jsx)(ea.T,{children:"Model"})}),(0,t.jsx)(eM.ModelSelect,{isMobileSideDrawer:!0,compactWidth:!0,className:"h-8 text-sm",contentClassName:"w-[calc(100dvw-5rem)] max-w-108",selected:e.modelInfo,filter:e=>!(0,eA.f)(e)&&(0,e_.L)(e.output_modalities),onDone:t=>I({model:(0,eS.i)(t),modelInfo:t,provider:void 0,switchyardAlgorithm:t.permaslug===rO.f.Switchyard?e.switchyardAlgorithm:void 0})})]}),e.modelInfo?.permaslug===rO.f.Switchyard&&(0,t.jsxs)("div",{className:(0,a.f)("flex w-full flex-col","gap-1.5"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(rC.f,{weight:"medium",leading:"snug",children:(0,t.jsx)(ea.T,{children:"Switchyard algorithm"})}),e.switchyardAlgorithm&&(0,t.jsx)(l.Button,{size:"sm",variant:"ghost",onClick:()=>I({switchyardAlgorithm:void 0,plugins:e.plugins?.filter(e=>e.id!==rL.f.SwitchyardRouter)}),children:(0,t.jsx)(ea.T,{children:"Use server default"})})]}),(0,t.jsx)(r8,{label:o("Algorithm"),value:e.switchyardAlgorithm,options:rB.S,shouldSort:!1,className:(0,a.f)("bg-background h-8 w-full","text-sm"),onChange:e=>I({switchyardAlgorithm:e})},e.switchyardAlgorithm??"unset"),(0,t.jsx)("span",{className:"text-muted-foreground text-xs",children:(0,t.jsx)(ea.T,{children:"Unset uses the server default, Stage."})})]}),(0,t.jsx)(r3,{label:o("Preset"),presets:j,selectedId:M?.id||null,disabled:b,onSelect:e=>{e?(_(e),w(!0)):I({presetSlug:void 0,presetName:void 0,isRoutingPreset:void 0})},compact:!0}),e.isRoutingPreset?(0,t.jsx)("span",{className:"text-muted-foreground text-body",children:(0,t.jsx)(ea.T,{children:"This preset picks the model and provider for each message."})}):(0,t.jsxs)("div",{className:(0,a.f)("flex w-full flex-col","gap-1.5"),children:[(0,t.jsx)(rC.f,{weight:"medium",leading:"snug",children:(0,t.jsx)(ea.T,{children:"Provider"})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(r_.v,{className:"h-8 flex-1 text-sm",contentClassName:"w-[calc(100dvw-5rem)] max-w-80",permaslug:e.modelInfo?.permaslug||rX.I,variant:e.modelInfo?.endpoint?.variant,selected:e.provider||null,showGuardrailsWarning:!0,onDone:e=>I({provider:(0,rq.h)(e)})}),(0,t.jsx)(rQ.f,{className:"h-8 text-sm",contentClassName:"w-[calc(100dvw-5rem)] max-w-40",selected:e.providerSort||null,disabled:!!e.provider,onDone:e=>I({providerSort:e})})]})]}),(0,t.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,t.jsx)(i.Tooltip,{content:(0,t.jsx)(ea.T,{children:(0,t.jsxs)("span",{children:["Only route to endpoints that never retain your prompts or completions."," ",(0,t.jsx)(rS.f,{href:"/docs/guides/features/zdr",target:"_blank",rel:"noopener noreferrer",children:"Learn more about Zero Data Retention"})]})}),children:(0,t.jsxs)(rC.f,{weight:"medium",leading:"snug",className:(0,a.f)("flex items-center","gap-2"),children:[(0,t.jsx)(rG,{className:(0,a.f)("size-4","transition-colors",e.zdr&&"text-primary")}),(0,t.jsx)(ea.T,{children:"Require Zero Data Retention"})]})}),(0,t.jsx)(ro.Z,{id:`toggle-zdr-${e.id}`,checked:e.zdr??!1,onCheckedChange:e=>I({zdr:e})})]}),(0,t.jsx)(rT.f,{className:"my-2"}),(0,t.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,t.jsxs)(rC.f,{weight:"medium",leading:"snug",className:(0,a.f)("flex items-center","gap-2"),children:[(0,t.jsx)(rJ.f,{className:(0,a.f)("size-4","transition-colors",(e.isStreaming??!0)&&"text-primary")}),(0,t.jsx)(ea.T,{children:"Enable Streaming"})]}),(0,t.jsx)(ro.Z,{id:`toggle-streaming-${e.id}`,checked:e.isStreaming??!0,onCheckedChange:e=>I({isStreaming:e})})]}),!P&&(0,t.jsx)(ne,{character:e}),O&&(0,t.jsxs)("div",{className:(0,a.f)("flex flex-col","gap-3"),children:[L?(0,t.jsx)(i.Tooltip,{content:o("Reasoning is mandatory for this model"),children:(0,t.jsx)("span",{className:"inline-block w-full",children:U})}):U,O&&B&&(0,t.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,t.jsxs)(rC.f,{weight:"medium",leading:"snug",className:(0,a.f)("flex items-center","gap-2"),children:[(0,t.jsx)(rK.f,{className:(0,a.f)("size-4","transition-colors",B&&"text-primary")}),(0,t.jsx)(ea.T,{children:"Reasoning Effort"})]}),(0,t.jsx)(rI.f,{shouldSort:!1,label:o("Effort"),value:$,options:W,className:"w-40",onChange:t=>{e.reasoning?.maxTokens&&delete e.reasoning.maxTokens,I({reasoning:{...e.reasoning,effort:t}})}})]})]}),(0,t.jsx)(rT.f,{className:"my-2"}),(0,t.jsxs)("div",{className:"flex w-full flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(rC.f,{weight:"medium",leading:"snug",children:(0,t.jsx)(ea.T,{children:"System Prompt"})}),M&&A&&(0,t.jsx)(eu.Badge,{className:"border-primary/20 bg-primary/10 text-primary",children:(0,t.jsx)(ea.T,{children:"Preset Active"})})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground -mt-1",children:A?(0,t.jsx)(ea.T,{children:"The preset provides a system prompt. Custom text will be appended to it."}):(0,t.jsx)(ea.T,{children:"Use OpenRouter's default system prompt or choose custom."})}),R?(0,t.jsx)(i.Tooltip,{content:o("This model requires a specific system prompt."),children:H}):H,(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)(rA.o,{id:`description-${e.id}`,"data-dd-privacy":"hidden",className:(0,a.f)("resize-none py-2.5 leading-relaxed ph-no-capture",(!!R||D)&&"cursor-default bg-muted/40 text-muted-foreground"),rows:4,readOnly:!!R||D,value:A&&D&&!e.description?"":F,onChange:e=>{R||D||I({description:e.target.value})},placeholder:o("e.g. You are a world-class pirate captain.")})}),(0,t.jsx)("span",{className:"text-muted-foreground self-end text-xs",children:(0,t.jsxs)(ea.T,{children:["~",(0,t.jsx)(em.d,{children:s.number(V,{preset:"integer"})})," tokens"]})})]}),(0,t.jsx)(rE,{title:o("Sampling Parameters"),children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 px-2",children:[(0,t.jsx)(rZ.f,{floatingPoint:0,step:1,min:0,max:e.modelInfo?.context_length||rX.Q,name:(0,rR.f)(c,rN.Y.name),tooltips:rN.Y.description,id:`max-tokens-${e.id}`,value:e.maxTokens??0,onDone:e=>I({maxTokens:e})}),rN.e.map(r=>{let n=e.samplingParameters;return(0,t.jsx)(rZ.f,{id:`${r.name}-${e.id}`,step:"float"===r.metadata.type?.01:1,min:r.min??0,max:r.max??100,name:r.displayName,tooltips:r.description,value:"number"==typeof n[r.name]?n[r.name]:r.metadata.defaultValue||0,onDone:e=>I({samplingParameters:{...n,[r.name]:e}})},`${r.name}-${e.id}`)})]})}),(0,t.jsxs)("div",{className:"flex flex-col justify-end gap-2 md:flex-row",children:[(0,t.jsx)(l.Button,{size:"sm",className:"md:w-min",variant:"outline",disabled:k||!z,onClick:()=>{S.z.applyToAllCharacters({payload:{roomId:d,sourceCharacter:e}}),C(!0),(0,T.c)({title:o("Settings applied to all models")})},children:(0,t.jsx)(ea.T,{children:"Apply to All"})}),(0,t.jsx)(l.Button,{size:"sm",className:"md:w-min",variant:"outline",onClick:()=>{C(!1),S.z.resetCharacter({payload:{roomId:d,characterId:e.id}})},children:(0,t.jsx)(ea.T,{children:"Reset"})}),(0,t.jsx)(l.Button,{size:"sm",variant:"destructive",className:"md:w-min",onClick:()=>{S.z.removeCharacter({payload:{roomId:d,characterId:e.id}})},children:(0,t.jsx)(ea.T,{children:"Remove"})})]}),(0,t.jsx)(rz.N,{open:y,onOpenChange:w,children:(0,t.jsxs)(rz.d,{className:"flex flex-col gap-4",children:[(0,t.jsx)(rz.s,{children:(0,t.jsxs)(ea.T,{children:[(0,t.jsxs)(rz.F,{children:['Apply Preset "',(0,t.jsx)(em.d,{children:N?.name}),'"']}),(0,t.jsx)(rz.C,{children:"How would you like to apply this preset?"}),(0,t.jsxs)(rz.C,{children:[(0,t.jsx)("strong",{children:"Merge:"})," Uses both the preset config and this form's custom settings. The form settings take precedence."]}),(0,t.jsxs)(rz.C,{children:[(0,t.jsx)("strong",{children:"Reset and Apply:"})," Clears all custom settings then applies the selected preset."]})]})}),(0,t.jsx)(rz.c,{className:"gap-2 sm:justify-end",children:(0,t.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[(0,t.jsx)(l.Button,{variant:"outline",size:"sm",onClick:()=>{N&&(I({presetSlug:N.slug,presetName:N.name,isRoutingPreset:(0,t5.f)(N)}),w(!1),_(null))},children:(0,t.jsx)(ea.T,{children:"Merge with Current Config"})}),(0,t.jsx)(l.Button,{size:"sm",onClick:()=>{N&&(S.z.resetCharacter({payload:{roomId:d,characterId:e.id}}),I({presetSlug:N.slug,presetName:N.name,isRoutingPreset:(0,t5.f)(N),description:"",includeDefaultSystemPrompt:!1}),w(!1),_(null))},children:(0,t.jsx)(ea.T,{children:"Reset and Apply"})})]})})]})})]})}let ni=m.forwardRef(function({title:e,titleId:t,...r},n){return m.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M12 .75a8.25 8.25 0 0 0-4.135 15.39c.686.398 1.115 1.008 1.134 1.623a.75.75 0 0 0 .577.706c.352.083.71.148 1.074.195.323.041.6-.218.6-.544v-4.661a6.714 6.714 0 0 1-.937-.171.75.75 0 1 1 .374-1.453 5.261 5.261 0 0 0 2.626 0 .75.75 0 1 1 .374 1.452 6.712 6.712 0 0 1-.937.172v4.66c0 .327.277.586.6.545.364-.047.722-.112 1.074-.195a.75.75 0 0 0 .577-.706c.02-.615.448-1.225 1.134-1.623A8.25 8.25 0 0 0 12 .75Z"}),m.createElement("path",{fillRule:"evenodd",d:"M9.013 19.9a.75.75 0 0 1 .877-.597 11.319 11.319 0 0 0 4.22 0 .75.75 0 1 1 .28 1.473 12.819 12.819 0 0 1-4.78 0 .75.75 0 0 1-.597-.876ZM9.754 22.344a.75.75 0 0 1 .824-.668 13.682 13.682 0 0 0 2.844 0 .75.75 0 1 1 .156 1.492 15.156 15.156 0 0 1-3.156 0 .75.75 0 0 1-.668-.824Z",clipRule:"evenodd"}))});function no(e){let n,s,i,o,c,d,u,f,h,x,p,g=(0,r.c)(33),{character:v,isModelMandatoryReasoning:b,isReasoningEnabled:j,disabled:y}=e,w=(0,tj.o)(),[N,_]=(0,m.useState)(!1);g[0]!==v.id?(n=e=>{S.z.updateCharacter({payload:{roomId:(0,rl.f)(),characterId:v.id,partialCharacter:{reasoning:e}}})},g[0]=v.id,g[1]=n):n=g[1];let k=n;g[2]!==v.reasoning||g[3]!==b||g[4]!==j||g[5]!==k?(s=()=>{b||k({...v.reasoning,enabled:!j})},g[2]=v.reasoning,g[3]=b,g[4]=j,g[5]=k,g[6]=s):s=g[6];let C=s,z=N&&!y;return g[7]===Symbol.for("react.memo_cache_sentinel")?(i=(e,t)=>{("trigger-press"!==t.reason||e)&&_(e)},g[7]=i):i=g[7],g[8]!==w||g[9]!==j?(o=w(j?"Disable reasoning":"Enable reasoning"),g[8]=w,g[9]=j,g[10]=o):o=g[10],g[11]!==C?(c=e=>{e.stopPropagation(),C()},g[11]=C,g[12]=c):c=g[12],g[13]!==j?(d=(0,a.f)("border",j?(0,a.f)("border-warning/30 bg-warning-bg text-warning","hover:bg-warning-bg hover:border-warning/60"):(0,a.f)("border-transparent","hover:bg-muted hover:border-border"),"aria-disabled:cursor-not-allowed"),g[13]=j,g[14]=d):d=g[14],g[15]!==b||g[16]!==o||g[17]!==c||g[18]!==d?(u=(0,t.jsx)(l.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":o,"aria-disabled":b,onClick:c,className:d}),g[15]=b,g[16]=o,g[17]=c,g[18]=d,g[19]=u):u=g[19],g[20]!==j?(f=j?(0,t.jsx)(ni,{className:"size-4"}):(0,t.jsx)(W.f,{className:"size-4"}),g[20]=j,g[21]=f):f=g[21],g[22]!==u||g[23]!==f?(h=(0,t.jsx)(eI.J,{openOnHover:!0,delay:0,closeDelay:150,render:u,children:f}),g[22]=u,g[23]=f,g[24]=h):h=g[24],g[25]!==v||g[26]!==b||g[27]!==j?(x=(0,t.jsx)(eI.T,{side:"bottom",align:"start",sideOffset:6,className:"flex w-auto flex-col gap-1.5 p-1.5",children:(0,t.jsx)(rf,{character:v,isModelMandatoryReasoning:b,isReasoningEnabled:j})}),g[25]=v,g[26]=b,g[27]=j,g[28]=x):x=g[28],g[29]!==h||g[30]!==x||g[31]!==z?(p=(0,t.jsxs)(eI.V,{open:z,onOpenChange:i,children:[h,x]}),g[29]=h,g[30]=x,g[31]=z,g[32]=p):p=g[32],p}function nc(e){let n,s,l=(0,r.c)(13),{character:i,className:o}=e,{getModelInfoByVariantSlug:c}=(0,eT.S)(),d=i.model;l[0]!==i.modelInfo?.author||l[1]!==c||l[2]!==d?(n=i.modelInfo?.author??(d?c(d)?.author??null:null),l[0]=i.modelInfo?.author,l[1]=c,l[2]=d,l[3]=n):n=l[3];let m=n;if(m){let e,r,n=(0,tK.n)(i)?i.modelInfo?.author_icon_uri:void 0;return l[4]!==o?(e=(0,a.f)("size-5 shrink-0",o),l[4]=o,l[5]=e):e=l[5],l[6]!==m||l[7]!==n||l[8]!==e?(r=(0,t.jsx)(rs.f,{frame:!0,author:m,iconUri:n,className:e}),l[6]=m,l[7]=n,l[8]=e,l[9]=r):r=l[9],r}return l[10]!==i||l[11]!==o?(s=(0,t.jsx)(eE.f,{character:i,className:o}),l[10]=i,l[11]=o,l[12]=s):s=l[12],s}let nd=(0,m.memo)(({characterId:e,className:r=""})=>{let n=(0,h.f)(),{getEndpointDisplayName:s}=(0,eT.S)(),o=(0,m.useMemo)(t4.F,[]),c=(0,p.f)(t=>o(t,e)),[d,u]=(0,m.useState)(!1),[f,x]=(0,m.useState)(!1),g=(0,m.useMemo)(()=>{let e=c?.model||c?.modelInfo&&(0,eS.i)(c.modelInfo),t=s({slug:e?(0,ek.f)(e):void 0,variant:e?(0,eC.z)(e):void 0,providerName:c?.provider});return c?.name||c?.presetName||rb(c,t)},[c,s]),v=(0,ra.l)((0,ra.f)(c));if(!c)return null;let b=c.modelInfo?.endpoint?.supports_reasoning??!1,j=!!c.modelInfo?.endpoint&&(0,rr.f)(c.modelInfo.endpoint),y=!!j||(c.reasoning?.enabled??!1),w=(0,ra.N)(v),N=(0,tK.n)(c),_=n(N?"Intern settings":"Advanced settings"),k=c.isDisabled?"ghost-muted":"ghost",C=(0,a.f)("rounded-lg border","transition-[color,background-color,border-color,opacity] duration-150 ease-in-out","flex h-9 items-center justify-between gap-1",c?.isDisabled?"border-dashed border-transparent opacity-50":(0,a.f)("border-border text-foreground",w?w.pillBg:"bg-card")),z=(0,t.jsxs)("div",{className:"relative flex h-full w-full min-w-0 select-none items-center gap-2 pl-2",children:[(0,t.jsx)(nc,{character:c}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)("span",{className:"block truncate text-sm font-medium",children:g})})]});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eI.V,{children:[(0,t.jsx)(eI.J,{nativeButton:!1,openOnHover:!0,delay:150,closeDelay:200,render:(0,t.jsx)("div",{className:(0,a.f)("relative w-fit max-w-full",r)}),children:(0,t.jsxs)("div",{className:C,children:[z,(0,t.jsxs)("div",{className:"flex shrink-0 items-center pr-1",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)(rx,{character:c,onOpenAdvanced:()=>u(!0),children:(0,t.jsx)(l.Button,{type:"button",variant:"ghost",size:"icon-xs","aria-label":n("Model settings"),className:"size-6.5 min-w-6.5 md:hidden",children:(0,t.jsx)(t8.f,{className:"size-4"})})}),(0,t.jsx)(l.Button,{variant:k,size:"icon-xs","aria-label":n("Remove model"),className:"size-6.5 min-w-6.5 hover:bg-negative-bg hover:text-negative",onClick:t=>{t.stopPropagation(),S.z.removeCharacter({payload:{roomId:(0,rl.f)(),characterId:e}})},children:(0,t.jsx)(eN.f,{className:"size-4"})})]})]})}),(0,t.jsxs)(eI.T,{side:"bottom",align:"end",sideOffset:6,className:"flex w-auto items-center gap-1 p-1.5",children:[(0,t.jsx)(rw,{characterId:e,tooltip:n("Color label"),onOpenChange:x}),b&&(0,t.jsx)(no,{character:c,isModelMandatoryReasoning:j,isReasoningEnabled:y,disabled:f}),(0,t.jsx)(i.Tooltip,{side:"bottom",delay:0,disabled:f,content:n(c.isDisabled?"Show model":"Hide model"),children:(0,t.jsx)(l.Button,{type:"button",variant:"ghost",tone:c.isDisabled?"subdued":void 0,size:"icon-sm","aria-label":n(c.isDisabled?"Show model":"Hide model"),onClick:t=>{t.stopPropagation(),S.z.updateCharacter({payload:{roomId:(0,rl.f)(),characterId:e,partialCharacter:{isDisabled:!c.isDisabled}}})},className:(0,a.f)("border border-transparent hover:bg-muted hover:border-border",c.isDisabled&&"opacity-70"),children:c.isDisabled?(0,t.jsx)(rt.f,{className:"size-4"}):(0,t.jsx)(re.f,{className:"size-4"})})},c.isDisabled?"hidden":"shown"),N?null:(0,t.jsx)(i.Tooltip,{side:"bottom",delay:0,disabled:f,content:n("Duplicate"),children:(0,t.jsx)(l.Button,{type:"button",variant:"ghost",size:"icon-sm","aria-label":n("Duplicate model"),onClick:e=>{e.stopPropagation(),S.z.duplicateCharacter({payload:{roomId:(0,rl.f)(),sourceCharacterId:c.id}})},className:"border border-transparent hover:bg-muted hover:border-border",children:(0,t.jsx)(t9.f,{className:"size-4"})})}),(0,t.jsx)(i.Tooltip,{side:"bottom",delay:0,disabled:f,content:_,children:(0,t.jsx)(l.Button,{type:"button",variant:"ghost",tone:c.isDisabled?"subdued":void 0,size:"icon-sm","aria-label":_,onClick:e=>{e.stopPropagation(),u(!0)},className:(0,a.f)("border border-transparent hover:border-border",c.isDisabled?"hover:bg-muted":"hover:bg-card-hover"),children:(0,t.jsx)(t8.f,{className:"size-4"})})})]})]}),(0,t.jsx)(rn.N,{open:d,onOpenChange:u,children:(0,t.jsxs)(rn.d,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-2xl border-border/60 p-4 shadow-none",closeButtonClassName:"right-4 top-4",children:[(0,t.jsx)(rn.s,{children:(0,t.jsx)(rn.F,{children:_})}),(0,t.jsx)(na,{withName:!0,character:c})]})})]})},()=>!0);function nm(e){let n,s,l=(0,r.c)(5),{children:i,className:o}=e;return l[0]!==o?(n=(0,a.f)("duration-200 animate-in fade-in",o),l[0]=o,l[1]=n):n=l[1],l[2]!==i||l[3]!==n?(s=(0,t.jsx)("div",{className:n,children:i}),l[2]=i,l[3]=n,l[4]=s):s=l[4],s}let nu=(0,m.memo)(({sortedCharacterIds:e,isMd:r})=>0===e.length?null:r?(0,t.jsx)(t.Fragment,{children:e.map(e=>(0,t.jsx)(nm,{children:(0,t.jsx)(nd,{characterId:e,className:"w-fit shrink-0"})},e))}):(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsx)("div",{className:"flex -ml-2",children:e.map(e=>(0,t.jsx)("div",{className:"shrink-0 basis-auto pl-2",children:(0,t.jsx)(nm,{children:(0,t.jsx)(nd,{characterId:e,className:"w-fit shrink-0"})})},e))})}),(e,t)=>e.isMd===t.isMd&&e.sortedCharacterIds.length===t.sortedCharacterIds.length&&e.sortedCharacterIds.every((e,r)=>e===t.sortedCharacterIds[r]));var nf=e.i(359903),nh=e.i(971892),nx=e.i(261499),np=e.i(217411),ng=e.i(882968),nv=e.i(340966);function nb({sortedCharacterIds:e,onAddModelClick:r}){let n=(0,h.f)(),[s,i]=(0,m.useState)(!1),[o,c]=(0,m.useState)(null),d=(0,p.f)((0,er.f)(t4.T)),u=(0,nv.f)(),f=e.map(e=>d[e]).filter(e=>!!e),x=o?d[o]??null:null,g=null!==x,v=(0,m.useRef)(null);(0,m.useEffect)(()=>{x&&(v.current=x)},[x]);let b=x??v.current,j=f.length,y=n("{count, plural, one {# model selected} other {# models selected}}",{count:j}),w=f.slice(0,3);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eI.V,{open:s,onOpenChange:i,children:[(0,t.jsx)(eI.J,{render:(0,t.jsxs)(l.Button,{type:"button",variant:"outline",size:"sm",tone:"strong","aria-label":y,className:(0,a.f)("flex shrink-0 gap-2 rounded-lg px-2.5 py-0","border-border dark:border-slate-3 dark:bg-slate-2","hover:bg-accent hover:text-foreground active:bg-accent active:text-foreground","dark:hover:border-slate-5 dark:hover:bg-accent","data-[popup-open]:bg-accent dark:data-[popup-open]:border-slate-5"),children:[(0,t.jsx)("span",{className:"flex items-center",children:w.map(e=>(0,t.jsx)(ny,{character:e,className:"-me-1.5 last:me-0"},e.id))}),(0,t.jsx)("span",{children:j}),(0,t.jsx)(nf.f,{className:(0,a.f)("size-4 text-muted-foreground",nx.a,s&&"-scale-y-100")})]})}),(0,t.jsxs)(eI.T,{side:"bottom",align:"start",sideOffset:6,positionerClassName:"z-popover",collisionPadding:8,className:"w-72 rounded-xl p-1.5",children:[(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:f.map(e=>(0,t.jsx)(nw,{character:e,onOpenAdvanced:()=>{i(!1),c(e.id)}},e.id))}),(0,t.jsx)("div",{className:"mx-1 my-1 h-px bg-border","aria-hidden":"true"}),(0,t.jsxs)(l.Button,{type:"button",variant:"ghost",tone:"muted",onClick:()=>{i(!1),r()},className:"flex h-auto w-full px-2 py-1.5 leading-snug hover:bg-accent active:bg-accent active:text-foreground",children:[(0,t.jsx)(ew.f,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Add another model"})]})]})]}),(0,t.jsx)(np.j,{open:g,onOpenChange:e=>{e||c(null)},children:u?(0,t.jsxs)(np.U,{side:"right",container:u,showCloseButton:!1,overlayClassName:ng.u,className:ng.t,children:[(0,t.jsx)(np.L,{className:"sr-only",children:n("Model settings")}),b?(0,t.jsx)(nj,{character:b,onClose:()=>c(null)}):null]}):null})]})}function nj(e){let n,s,a,i,o,c,d,m,u,f=(0,r.c)(23),{character:x,onClose:p}=e,g=(0,h.f)(),{getEndpointDisplayName:v}=(0,eT.S)();f[0]!==x.model||f[1]!==x.modelInfo?(n=x.model||x.modelInfo&&(0,eS.i)(x.modelInfo),f[0]=x.model,f[1]=x.modelInfo,f[2]=n):n=f[2];let b=n;if(f[3]!==x||f[4]!==v||f[5]!==b){let e=v({slug:b?(0,ek.f)(b):void 0,variant:b?(0,eC.z)(b):void 0,providerName:x.provider});s=x.name||x.presetName||rb(x,e),f[3]=x,f[4]=v,f[5]=b,f[6]=s}else s=f[6];let j=s;return f[7]!==g?(a=g("Back to chat"),f[7]=g,f[8]=a):a=f[8],f[9]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(C.f,{className:"!size-5"}),f[9]=i):i=f[9],f[10]!==p||f[11]!==a?(o=(0,t.jsx)(l.Button,{type:"button",variant:"ghost",size:"icon",className:"shrink-0","aria-label":a,onClick:p,children:i}),f[10]=p,f[11]=a,f[12]=o):o=f[12],f[13]!==j?(c=(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:j}),f[13]=j,f[14]=c):c=f[14],f[15]!==o||f[16]!==c?(d=(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-2 py-2",children:[o,c]}),f[15]=o,f[16]=c,f[17]=d):d=f[17],f[18]!==x?(m=(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:(0,t.jsx)(na,{withName:!0,character:x})}),f[18]=x,f[19]=m):m=f[19],f[20]!==d||f[21]!==m?(u=(0,t.jsxs)(t.Fragment,{children:[d,m]}),f[20]=d,f[21]=m,f[22]=u):u=f[22],u}function ny(e){let n,s,l,i,o=(0,r.c)(19),{character:c,className:d}=e,{getModelInfoByVariantSlug:m}=(0,eT.S)(),u=c.model;o[0]!==c.modelInfo?.author||o[1]!==m||o[2]!==u?(n=c.modelInfo?.author??(u?m(u)?.author??null:null),o[0]=c.modelInfo?.author,o[1]=m,o[2]=u,o[3]=n):n=o[3];let f=n;if(!f){let e,r,n;return o[4]!==d?(e=(0,a.f)("flex size-5 shrink-0 items-center justify-center rounded-full","border border-background bg-accent text-2xs font-medium text-muted-foreground",d),o[4]=d,o[5]=e):e=o[5],o[6]!==c.name?.[0]?(r=c.name?.[0]?.toUpperCase()??"?",o[6]=c.name?.[0],o[7]=r):r=o[7],o[8]!==e||o[9]!==r?(n=(0,t.jsx)("span",{className:e,children:r}),o[8]=e,o[9]=r,o[10]=n):n=o[10],n}o[11]!==d?(s=(0,a.f)("flex size-5 shrink-0 items-center justify-center rounded-full","border-2 border-background bg-background","[&_svg]:!size-3.5",d),o[11]=d,o[12]=s):s=o[12];let h=(0,tK.n)(c)?c.modelInfo?.author_icon_uri:void 0;return o[13]!==f||o[14]!==h?(l=(0,t.jsx)(rs.f,{frame:!0,author:f,iconUri:h,className:"size-3.5"}),o[13]=f,o[14]=h,o[15]=l):l=o[15],o[16]!==s||o[17]!==l?(i=(0,t.jsx)("span",{className:s,children:l}),o[16]=s,o[17]=l,o[18]=i):i=o[18],i}function nw(e){let n,s,i,o,c,d,m,u,f,x,p,g,v,b,j,y=(0,r.c)(43),{character:w,onOpenAdvanced:N}=e,_=(0,h.f)(),{getEndpointDisplayName:k,getModelInfoByVariantSlug:C}=(0,eT.S)();y[0]!==w.model||y[1]!==w.modelInfo?(n=w.model||w.modelInfo&&(0,eS.i)(w.modelInfo),y[0]=w.model,y[1]=w.modelInfo,y[2]=n):n=y[2];let z=n;if(y[3]!==w||y[4]!==k||y[5]!==z){let e=k({slug:z?(0,ek.f)(z):void 0,variant:z?(0,eC.z)(z):void 0,providerName:w.provider});s=w.name||w.presetName||rb(w,e),y[3]=w,y[4]=k,y[5]=z,y[6]=s}else s=y[6];let I=s;y[7]!==w.model||y[8]!==w.modelInfo?.author||y[9]!==C?(i=w.modelInfo?.author??(w.model?C(w.model)?.author??null:null),y[7]=w.model,y[8]=w.modelInfo?.author,y[9]=C,y[10]=i):i=y[10];let T=i,M=w.isDisabled&&"opacity-50";return y[11]!==M?(o=(0,a.f)("group flex items-center gap-2 rounded-md px-2 py-1.5","transition-colors hover:bg-accent",M),y[11]=M,y[12]=o):o=y[12],y[13]!==_||y[14]!==I?(c=_("Settings for {name}",{name:I}),y[13]=_,y[14]=I,y[15]=c):c=y[15],y[16]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(nh.f,{className:"size-4"}),y[16]=d):d=y[16],y[17]!==c?(m=(0,t.jsx)(l.Button,{type:"button",variant:"ghost-muted",size:"icon-xs","aria-label":c,className:"shrink-0 hover:bg-accent active:bg-accent active:text-foreground",children:d}),y[17]=c,y[18]=m):m=y[18],y[19]!==w||y[20]!==N||y[21]!==m?(u=(0,t.jsx)(rx,{character:w,onOpenAdvanced:N,children:m}),y[19]=w,y[20]=N,y[21]=m,y[22]=u):u=y[22],y[23]!==w||y[24]!==T?(f=T?(0,t.jsx)(rs.f,{frame:!0,author:T,iconUri:(0,tK.n)(w)?w.modelInfo?.author_icon_uri:void 0,className:"size-5 shrink-0"}):(0,t.jsx)("span",{className:"size-5 shrink-0 rounded-full bg-accent"}),y[23]=w,y[24]=T,y[25]=f):f=y[25],y[26]!==I?(x=(0,t.jsx)("span",{className:"flex-1 truncate text-sm",children:I}),y[26]=I,y[27]=x):x=y[27],y[28]!==_||y[29]!==I?(p=_("Remove {name}",{name:I}),y[28]=_,y[29]=I,y[30]=p):p=y[30],y[31]!==w.id?(g=e=>{e.stopPropagation(),S.z.removeCharacter({payload:{roomId:(0,rl.f)(),characterId:w.id}})},y[31]=w.id,y[32]=g):g=y[32],y[33]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(eN.f,{className:"size-4"}),y[33]=v):v=y[33],y[34]!==p||y[35]!==g?(b=(0,t.jsx)(l.Button,{type:"button",variant:"ghost-muted",size:"icon-xs","aria-label":p,onClick:g,className:"shrink-0 hover:bg-negative-bg hover:text-negative-text active:bg-negative-bg active:text-negative-text",children:v}),y[34]=p,y[35]=g,y[36]=b):b=y[36],y[37]!==f||y[38]!==x||y[39]!==b||y[40]!==o||y[41]!==u?(j=(0,t.jsxs)("li",{className:o,children:[u,f,x,b]}),y[37]=f,y[38]=x,y[39]=b,y[40]=o,y[41]=u,y[42]=j):j=y[42],j}let nN=(0,m.memo)(()=>{let e,n,s,i,o,c,d,u,f,g,v,b,j,y,w,N,k,C,z,I,T,M,E,A,R,P,D,F,V,O,L=(0,r.c)(87),B=(0,h.f)(),[q,W]=(0,m.useState)(!1),[$,U]=(0,m.useState)(null),H=(0,p.f)(x.M),G=(0,_.x)(),K=(0,_.W)(),[J]=(0,tJ.f)(),{contextEntityId:Z}=(0,t$.useEntity)(),Q=(0,t6.q)();L[0]!==Z||L[1]!==Q?(e=(0,t6.P)(Z,Q),L[0]=Z,L[1]=Q,L[2]=e):e=L[2];let{data:X}=(0,tH.f)(e),Y=(0,tW.R)("chromeGeminiNano");L[3]!==Y?(n=(0,tG.w)(Y),L[3]=Y,L[4]=n):n=L[4];let ee=n,et=(0,p.f)((0,er.f)(t4.m)),en=(0,p.f)((0,er.f)(t4.T));if(L[5]!==en||L[6]!==et){let e;L[8]!==en?(e=e=>{let t=en[e]?.model;return t?[t]:[]},L[8]=en,L[9]=e):e=L[9],s=et.flatMap(e),L[5]=en,L[6]=et,L[7]=s}else s=L[7];let es=s,el=et.length>0;L[10]!==ee?(i=()=>{if(!ee)return;let e=!1;return(0,tL.P)(tG.Z).then(t=>{e||U(t)}).catch(()=>{e||U(null)}),()=>{e=!0}},L[10]=ee,L[11]=i):i=L[11];let ei=i;L[12]!==ei?(o=()=>ei(),c=[ei],L[12]=ei,L[13]=o,L[14]=c):(o=L[13],c=L[14]),(0,m.useEffect)(o,c),L[15]!==q||L[16]!==ei?(d=()=>{if(q)return ei()},u=[q,ei],L[15]=q,L[16]=ei,L[17]=d,L[18]=u):(d=L[17],u=L[18]),(0,m.useEffect)(d,u);let{modelInfos:eo}=t2();L[19]!==ee?(f=ee?[(0,tG.A)()]:[],L[19]=ee,L[20]=f):f=L[20],L[21]!==eo||L[22]!==f?(g=[...eo,...f],L[21]=eo,L[22]=f,L[23]=g):g=L[23];let ec=g,ed=eo.length>0;L[24]!==ee||L[25]!==ed?(v=function({hasInterns:e,hasLocalModel:t}){if(e)return t?`${tK.i} & local`:tK.i}({hasInterns:ed,hasLocalModel:ee}),L[24]=ee,L[25]=ed,L[26]=v):v=L[26];let em=v;L[27]!==ee||L[28]!==$?(b=ee&&"available"!==$?[tG.s]:[],L[27]=ee,L[28]=$,L[29]=b):b=L[29];let eu=b;e:{let e;if(!J||!X?.presetsWithVersions){j=null;break e}L[30]!==J||L[31]!==X.presetsWithVersions?(e=X.presetsWithVersions.find(e=>e.id===J)??null,L[30]=J,L[31]=X.presetsWithVersions,L[32]=e):e=L[32],j=e}let ef=j;L[33]!==en||L[34]!==H||L[35]!==X?.presetsWithVersions?(y=()=>{var e;let t,r=X?.presetsWithVersions;if(r)for(let n of(e=Object.values(en),t=new Map(r.map(e=>[e.slug,e])),e.flatMap(e=>{let r=e.presetSlug?t.get(e.presetSlug):void 0;if(!r)return[];let n=(0,t5.f)(r);return n===!!e.isRoutingPreset?[]:[{characterId:e.id,isRoutingPreset:n}]})))S.z.updateCharacter({payload:{roomId:H,characterId:n.characterId,partialCharacter:{isRoutingPreset:n.isRoutingPreset}}})},L[33]=en,L[34]=H,L[35]=X?.presetsWithVersions,L[36]=y):y=L[36],L[37]!==en||L[38]!==H||L[39]!==X?(w=[en,H,X],L[37]=en,L[38]=H,L[39]=X,L[40]=w):w=L[40],(0,m.useEffect)(y,w),L[41]===Symbol.for("react.memo_cache_sentinel")?(N=e=>{e?.preventDefault(),W(!0)},L[41]=N):N=L[41],(0,tU.f)(nk,N),L[42]===Symbol.for("react.memo_cache_sentinel")?(k=()=>W(!1),L[42]=k):k=L[42],L[43]!==eu||L[44]!==es?(C=[...eu,...es],L[43]=eu,L[44]=es,L[45]=C):C=L[45],L[46]!==H||L[47]!==ef?(z=async e=>{W(!1);let t=(0,eS.i)(e);S.z.addCharacters({payload:{roomId:H,characters:{model:t,modelInfo:e,samplingParameters:{},...ef&&!(0,tK.C)(t)&&{presetSlug:ef.slug,presetName:ef.name,isRoutingPreset:(0,t5.f)(ef)}}}}),(0,t7.K)({modelSlugs:[t],source:"manual"})},L[46]=H,L[47]=ef,L[48]=z):z=L[48];let eh=el?"icon-sm":"sm",ex=el?"shrink-0 md:w-auto md:px-2":"w-full gap-2 md:w-auto";L[49]===Symbol.for("react.memo_cache_sentinel")?(I=()=>W(!0),L[49]=I):I=L[49],L[50]!==B?(T=B("Add Model (⌘J)"),L[50]=B,L[51]=T):T=L[51],L[52]!==el?(M=el?(0,t.jsx)(ew.f,{className:"size-4"}):(0,t.jsx)("span",{children:(0,t.jsx)(ea.T,{children:"Add Model"})}),L[52]=el,L[53]=M):M=L[53],L[54]===Symbol.for("react.memo_cache_sentinel")?(E=(0,t.jsxs)("span",{className:"hidden items-center gap-0.5 text-xs md:flex",children:[(0,t.jsx)(tq.f,{variant:"action",children:"⌘"}),(0,t.jsx)(tq.f,{variant:"action",children:"J"})]}),L[54]=E):E=L[54],L[55]!==eh||L[56]!==ex||L[57]!==T||L[58]!==M?(A=(0,t.jsxs)(l.Button,{type:"button",variant:"outline",size:eh,className:ex,onClick:I,"aria-label":T,children:[M,E]}),L[55]=eh,L[56]=ex,L[57]=T,L[58]=M,L[59]=A):A=L[59],L[60]!==ec||L[61]!==em||L[62]!==q||L[63]!==C||L[64]!==z||L[65]!==A?(R=(0,t.jsx)(eM.ModelSelect,{isDialog:!1,isMobileSideDrawer:!0,isMultiSelect:!0,isForceOpen:q,onBlur:k,models:ec,modelsGroupName:em,disabledModelSlugs:C,filter:nC,showGuardrailsWarning:!0,hideUnavailableByDefault:!0,carryOverFilters:!0,onDone:z,children:A}),L[60]=ec,L[61]=em,L[62]=q,L[63]=C,L[64]=z,L[65]=A,L[66]=R):R=L[66];let ep=R,eg=!K&&et.length>0;if(G){let e;if(!el){let e,r;return L[67]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.f)("flex justify-start","p-px","pl-3"),L[67]=e):e=L[67],L[68]!==ep?(r=(0,t.jsx)("div",{className:e,children:ep}),L[68]=ep,L[69]=r):r=L[69],r}return L[70]!==ep||L[71]!==et?(e=(0,t.jsx)(n_,{sortedCharacterIds:et,addModelButton:ep}),L[70]=ep,L[71]=et,L[72]=e):e=L[72],e}L[73]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.f)("flex items-center gap-2"),L[73]=P):P=L[73],L[74]!==el||L[75]!==G||L[76]!==eg||L[77]!==et?(D=el&&(eg?(0,t.jsx)(nb,{sortedCharacterIds:et,onAddModelClick:()=>W(!0)}):(0,t.jsx)("div",{className:"flex overflow-hidden",children:(0,t.jsx)(nu,{sortedCharacterIds:et,isMd:!!G})})),L[74]=el,L[75]=G,L[76]=eg,L[77]=et,L[78]=D):D=L[78];let ev=eg&&"hidden";return L[79]!==ev?(F=(0,a.f)("flex items-center gap-2",ev),L[79]=ev,L[80]=F):F=L[80],L[81]!==ep||L[82]!==F?(V=(0,t.jsx)("div",{className:F,children:ep}),L[81]=ep,L[82]=F,L[83]=V):V=L[83],L[84]!==D||L[85]!==V?(O=(0,t.jsxs)("div",{className:P,children:[D,V]}),L[84]=D,L[85]=V,L[86]=O):O=L[86],O});function n_(e){let n,s,a,l,i=(0,r.c)(9),{sortedCharacterIds:o,addModelButton:c}=e;return i[0]!==c?(n=(0,t.jsx)("div",{className:"shrink-0 self-start pl-3",children:c}),i[0]=c,i[1]=n):n=i[1],i[2]!==o?(s=o.map(nS),i[2]=o,i[3]=s):s=i[3],i[4]!==s?(a=(0,t.jsx)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:s}),i[4]=s,i[5]=a):a=i[5],i[6]!==n||i[7]!==a?(l=(0,t.jsxs)("div",{className:"flex w-full items-start gap-2 p-px",children:[n,a]}),i[6]=n,i[7]=a,i[8]=l):l=i[8],l}function nS(e){return(0,t.jsx)(tB.f,{initialRender:!0,className:"min-w-0 max-w-full",children:(0,t.jsx)(nd,{characterId:e,className:"w-fit shrink-0"})},e)}function nk(e){return(e.metaKey||e.ctrlKey)&&!!e.key&&"j"===e.key.toLowerCase()}function nC(e){return!(0,eA.f)(e)&&(0,e_.L)(e.output_modalities)}var nz=e.i(120835),nI=e.i(702441),nT=e.i(301206),nM=e.i(149784),nE=e.i(206581),nA=e.i(612927);let nR="conversation-search-input";function nP(e){return!!e.key&&"f"===e.key.toLowerCase()&&(e.metaKey||e.ctrlKey)}function nD(e){let n,s,i,o,c,d,u,f,x,p,g,v,b,j,y,w,N,_,S,k,C,z,I,T,M,E,A,R,P=(0,r.c)(69),{onClose:D,onJumpToMatch:F,onClearHighlight:V,getSearchableMessages:O}=e,L=(0,r6.useLocale)(),B=(0,m.useRef)(null),[q,W]=(0,m.useState)("");P[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],P[0]=n):n=P[0];let[$,U]=(0,m.useState)(n),H=(0,h.f)(),[G,K]=(0,m.useState)(0),J=(0,nM.f)()?"⌘":"Ctrl";P[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,nT.f)(),P[1]=s):s=P[1];let Z=!s;P[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{(0,nT.f)()||B.current?.focus()},o=[],P[2]=i,P[3]=o):(i=P[2],o=P[3]),(0,m.useEffect)(i,o),P[4]!==V||P[5]!==F?(c=(e,t,r)=>{let n=e[t];n?F(n,r):V()},P[4]=V,P[5]=F,P[6]=c):c=P[6];let Q=c;P[7]!==O||P[8]!==L||P[9]!==Q?(d=e=>{var t;let r=e.target.value,n=(t=O(),t.flatMap(e=>(0,r7.P)(e.text,r.trim(),{locale:L}).map((t,r)=>({messageId:e.id,occurrence:r}))));W(r),U(n),K(0),Q(n,0,r)},P[7]=O,P[8]=L,P[9]=Q,P[10]=d):d=P[10];let X=d;P[11]!==G||P[12]!==$||P[13]!==q||P[14]!==Q?(u=e=>{var t;let r=0===(t=$.length)?0:(G+e+t)%t;K(r),Q($,r,q)},P[11]=G,P[12]=$,P[13]=q,P[14]=Q,P[15]=u):u=P[15];let Y=u;P[16]!==Y||P[17]!==D?(f=e=>{if(nP(e)){var t;if(""===(t=e.currentTarget).value||0===t.selectionStart&&t.selectionEnd===t.value.length)return;e.preventDefault(),e.currentTarget.select();return}if("Escape"===e.key){e.preventDefault(),D();return}"Enter"===e.key&&(e.preventDefault(),Y(e.shiftKey?-1:1))},P[16]=Y,P[17]=D,P[18]=f):f=P[18];let ee=f;if(P[19]===Symbol.for("react.memo_cache_sentinel")?(x=(0,a.f)("w-full","bg-popover"),P[19]=x):x=P[19],P[20]!==H?(p=H("Find in conversation"),P[20]=H,P[21]=p):p=P[21],P[22]!==H?(g=H("Find in conversation"),P[22]=H,P[23]=g):g=P[23],P[24]!==G||P[25]!==$.length||P[26]!==q){var et;v=""===q?"":0===(et=$.length)?"No results":`${G+1} / ${et}`,P[24]=G,P[25]=$.length,P[26]=q,P[27]=v}else v=P[27];P[28]!==v?(b=(0,t.jsx)("span",{"aria-live":"polite",className:"pointer-events-none pr-1.5 text-xs tabular-nums text-muted-foreground",children:v}),P[28]=v,P[29]=b):b=P[29],P[30]!==X||P[31]!==ee||P[32]!==q||P[33]!==p||P[34]!==g||P[35]!==b?(j=(0,t.jsx)(rk.f,{size:"sm",containerClassName:"min-w-0 flex-1 [&>span]:pointer-events-none",ref:B,"data-testid":nR,"aria-label":p,placeholder:g,value:q,onChange:X,onKeyDown:ee,className:"pr-16",trailingContent:b}),P[30]=X,P[31]=ee,P[32]=q,P[33]=p,P[34]=g,P[35]=b,P[36]=j):j=P[36],P[37]!==H?(y=H("Previous match"),P[37]=H,P[38]=y):y=P[38];let er=0===$.length;P[39]!==Y?(w=()=>Y(-1),P[39]=Y,P[40]=w):w=P[40],P[41]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)(nE.f,{className:"size-4"}),P[41]=N):N=P[41],P[42]!==y||P[43]!==er||P[44]!==w?(_=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm","aria-label":y,disabled:er,onClick:w,children:N}),P[42]=y,P[43]=er,P[44]=w,P[45]=_):_=P[45],P[46]!==H?(S=H("Next match"),P[46]=H,P[47]=S):S=P[47];let en=0===$.length;return P[48]!==Y?(k=()=>Y(1),P[48]=Y,P[49]=k):k=P[49],P[50]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)(r2.f,{className:"size-4"}),P[50]=C):C=P[50],P[51]!==S||P[52]!==en||P[53]!==k?(z=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm","aria-label":S,disabled:en,onClick:k,children:C}),P[51]=S,P[52]=en,P[53]=k,P[54]=z):z=P[54],P[55]!==H?(I=H("Close conversation search"),P[55]=H,P[56]=I):I=P[56],P[57]===Symbol.for("react.memo_cache_sentinel")?(T=(0,t.jsx)(nA.X,{className:"size-4"}),P[57]=T):T=P[57],P[58]!==D||P[59]!==I?(M=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm","aria-label":I,onClick:D,children:T}),P[58]=D,P[59]=I,P[60]=M):M=P[60],P[61]!==j||P[62]!==_||P[63]!==z||P[64]!==M?(E=(0,t.jsxs)("div",{className:"flex items-center gap-1 p-1.5",children:[j,_,z,M]}),P[61]=j,P[62]=_,P[63]=z,P[64]=M,P[65]=E):E=P[65],P[66]===Symbol.for("react.memo_cache_sentinel")?(A=Z&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rT.f,{}),(0,t.jsx)("p",{className:"px-3 py-1.5 text-xs leading-4 text-muted-foreground",children:(0,t.jsxs)(ea.T,{children:["Press"," ",(0,t.jsx)(tq.f,{children:(0,t.jsx)(em.d,{children:J})})," ",(0,t.jsx)(tq.f,{children:"F"})," when the field is empty or its text is selected to use browser search"]})})]}),P[66]=A):A=P[66],P[67]!==E?(R=(0,t.jsxs)(nI.N,{"data-testid":"conversation-search-panel",className:x,children:[E,A]}),P[67]=E,P[68]=R):R=P[68],R}let nF="model-presets",nV="hydration-failed",nO="message-list";var nL=e.i(558884),nB=e.i(735961);let nq=/^ {0,3}(`{3,}|~{3,})(.*)$/;function nW(){let e=p.f.getState(),t=(0,x.A)(e),r=nB.useItemStore.getState().items;return(0,N.b)(e).map(e=>{let n=t[e];return{id:e,text:n?function(e){if(!e.includes("```")&&!e.includes("~~~"))return e;let t=[],r=null;for(let n of e.split("\n")){let e=nq.exec(n);if(!e){t.push(n);continue}let s=e[1]??"",a=e[2]??"",l=s[0]??"";if(r){if(l===r.marker&&s.length>=r.length&&""===a.trim()){r=null;continue}t.push(n);continue}if("`"===l&&a.includes("`")){t.push(n);continue}r={marker:l,length:s.length}}return t.join("\n")}((0,nL.l)(n,r)):""}})}var n$=e.i(796531),nU=e.i(1423),nH=e.i(670168),nG=e.i(758767),nG=nG,nK=e.i(975436),nJ=e.i(121514),nJ=nJ,nZ=e.i(309421);function nQ(e){let n,s,i,o,c,d,m,u=(0,r.c)(18),{presentation:f,children:h}=e,x=(0,tj.o)(),p=(0,_.s)(),g=(0,nZ.F)(nX),v=(0,nv.f)();if("sidebar"===f!==(p&&!g))return null;if("sidebar"===f){let e;return u[0]!==h?(e=(0,t.jsx)("aside",{"data-testid":"jev-route-panel","data-dd-privacy":"hidden",className:"ph-no-capture flex w-80 xl:w-90 shrink-0 min-h-0 flex-col border-l border-border bg-background",children:h}),u[0]=h,u[1]=e):e=u[1],e}return u[2]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(l.Button,{variant:"ghost",size:"icon"}),u[2]=n):n=u[2],u[3]!==x?(s=x("Routing insights"),u[3]=x,u[4]=s):s=u[4],u[5]!==x?(i=x("Routing insights"),u[5]=x,u[6]=i):i=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(nJ.f,{className:"size-5"}),u[7]=o):o=u[7],u[8]!==s||u[9]!==i?(c=(0,t.jsx)(np.V,{render:n,"aria-label":s,title:i,children:o}),u[8]=s,u[9]=i,u[10]=c):c=u[10],u[11]!==h||u[12]!==v||u[13]!==x?(d=v&&(0,t.jsxs)(np.U,{side:"right",container:v,overlayClassName:ng.u,className:(0,a.f)(ng.t,"ph-no-capture [&>div:first-of-type]:pr-12"),"data-dd-privacy":"hidden","data-testid":"jev-route-panel",children:[(0,t.jsx)(np.L,{className:"sr-only",children:x("Routing insights")}),h]}),u[11]=h,u[12]=v,u[13]=x,u[14]=d):d=u[14],u[15]!==c||u[16]!==d?(m=(0,t.jsxs)(np.j,{children:[c,d]}),u[15]=c,u[16]=d,u[17]=m):m=u[17],m}function nX(e){return null!==e.target}var nY=e.i(336810),n0=e.i(511667),n1=e.i(808125),n2=e.i(667417),n3=e.i(917023),n4=e.i(68570),n5=e.i(257723),n6=e.i(99938),n7=e.i(288087);let n8={[n2.D.Text]:{icon:n6.f,className:"text-modality-text"},[n2.D.Image]:{icon:n5.f,className:"text-modality-image"},[n2.D.Audio]:{icon:n3.f,className:"text-modality-audio"},[n2.D.Video]:{icon:n7.f,className:"text-modality-video"},[n2.D.File]:{icon:n4.f,className:"text-modality-file"}},n9=[nY.F.Blue,nY.F.Mint,nY.F.YellowOrange,nY.F.Orchid,nY.F.MediumSlateBlue];function se(e){let n,s,l,o=(0,r.c)(10),{route:c}=e,d=(0,tj.o)(),m=(0,tj.M)();return o[0]!==d||o[1]!==m||o[2]!==c?(n=(void 0===c||void 0!==c.inputModalities)&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:d("Input modalities")}),void 0===c?(0,t.jsx)(nH.l,{"aria-hidden":"true",className:"h-5 w-24"}):(0,t.jsx)("ul",{className:"flex flex-wrap justify-end gap-1.5",children:c.inputModalities?.map(e=>{let{icon:r,className:n}=n8[e];return(0,t.jsx)("li",{children:(0,t.jsxs)(eu.Badge,{size:"sm",children:[(0,t.jsx)(r,{"aria-hidden":"true",className:(0,a.f)("size-3",n)}),m(n1.Z[e])]})},e)})})]}),o[0]=d,o[1]=m,o[2]=c,o[3]=n):n=o[3],o[4]!==d||o[5]!==c?(s=(void 0===c||void 0!==c.selectionProbabilities)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,t.jsx)(i.Tooltip,{content:d("Each model's chance in this turn's routing draw: the initial pick, or an escalation to a stronger model. Retries may use another model."),children:(0,t.jsxs)(i.TooltipNonInteractiveTrigger,{className:"flex w-fit items-center gap-1",children:[d("Selection share"),(0,t.jsx)(nK.f,{"aria-hidden":"true",className:"size-3"})]})})}),c?.selectionProbabilities===void 0?(0,t.jsxs)("div",{"aria-hidden":"true",className:"flex flex-col gap-2",children:[(0,t.jsx)(nH.l,{className:"h-2 w-full rounded-full"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-1",children:[(0,t.jsx)(nH.l,{className:"h-5 w-28 rounded-full"}),(0,t.jsx)(nH.l,{className:"h-5 w-24 rounded-full"})]})]}):(0,t.jsx)(st,{probabilities:c.selectionProbabilities})]}),o[4]=d,o[5]=c,o[6]=s):s=o[6],o[7]!==n||o[8]!==s?(l=(0,t.jsxs)(t.Fragment,{children:[n,s]}),o[7]=n,o[8]=s,o[9]=l):l=o[9],l}function st(e){let n,s,a,l,i,o,c=(0,r.c)(18),{probabilities:d}=e,m=(0,tj.o)(),u=(0,ed.f)(),{getModelInfoByVariantPermaslug:f,getModelInfoByVariantSlug:h}=(0,eT.S)();if(c[0]!==u||c[1]!==f||c[2]!==h||c[3]!==m||c[4]!==d){let e=d.toSorted(sl),t=e.slice(0,5),r=(0,n0.z)(t.map(sa),n9),s=e.slice(5).reduce(ss,0);n=[...t,...s>0?[{model:void 0,probability:s}]:[]].map(e=>{let{model:t,probability:n}=e,s=void 0===t?void 0:f(t)??h(t);return{model:t,label:void 0===t?m("Other"):s?.short_name??t,author:s?.author??t?.split("/")[0],probability:n,percent:n>0&&n<1e-4?m("<{percent}",{percent:u.ratio(1e-4,{preset:"fee"})??""}):u.ratio(n,{preset:"fee"}),color:void 0===t?"var(--chart-tokens-uncached)":r.get(t)}}),c[0]=u,c[1]=f,c[2]=h,c[3]=m,c[4]=d,c[5]=n}else n=c[5];let x=n;return c[6]!==x?(s=(0,t.jsx)("div",{"aria-hidden":"true",className:"flex h-2 overflow-hidden rounded-full bg-muted",children:x.map(sn)}),c[6]=x,c[7]=s):s=c[7],c[8]!==m?(a=m("Model selection shares"),c[8]=m,c[9]=a):a=c[9],c[10]!==x?(l=x.map(sr),c[10]=x,c[11]=l):l=c[11],c[12]!==a||c[13]!==l?(i=(0,t.jsx)("ul",{"aria-label":a,className:"grid grid-cols-2 gap-1",children:l}),c[12]=a,c[13]=l,c[14]=i):i=c[14],c[15]!==s||c[16]!==i?(o=(0,t.jsxs)(t.Fragment,{children:[s,i]}),c[15]=s,c[16]=i,c[17]=o):o=c[17],o}function sr(e){let{model:r,label:n,author:s,percent:a,color:l}=e;return(0,t.jsx)("li",{className:"min-w-0 max-w-full",children:(0,t.jsx)(i.Tooltip,{content:(0,t.jsx)("span",{className:"ph-no-capture","data-dd-privacy":"hidden",children:r??n}),children:(0,t.jsx)(i.TooltipNonInteractiveTrigger,{className:"block max-w-full rounded-full",children:(0,t.jsxs)(eu.Badge,{size:"sm",className:"h-5 max-w-full border-(--route-color)/20 bg-(--route-color)/12 px-1 leading-tight","data-allow-inline-style":!0,style:{"--route-color":l},children:[void 0!==s&&(0,t.jsx)(rs.f,{author:s,permaslug:r,bare:!0,className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:n}),(0,t.jsx)("span",{className:"shrink-0 tabular-nums",children:a})]})})})},r??"other")}function sn(e){let{model:r,probability:n,color:s}=e;return(0,t.jsx)("div",{className:"w-(--share-width) bg-(--share-color)","data-allow-inline-style":!0,style:{"--share-width":`${100*n}%`,"--share-color":s}},r??"other")}function ss(e,t){let{probability:r}=t;return e+r}function sa(e){let{model:t}=e;return t}function sl(e,t){return t.probability-e.probability}var si=e.i(769122),so=e.i(793585),sc=e.i(282823),sd=e.i(478300),sm=e.i(314522);let su=new Set(["image_url","input_audio","video_url","file"]),sf=eQ.z.object({type:eQ.z.literal("image").optional(),format:eQ.z.enum(["png","jpg","jpeg"]),data_base64:eQ.z.string().min(1).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,"data_base64 must be standard base64 with no data: prefix or whitespace")}).strict().openapi("DecisionsImageAsset",{description:"An image sent once and referenced by its key in the `assets` map. `data_base64` is the PNG or JPEG file in standard base64 with no `data:` prefix. The multipart `part` field of TypeSafe's API is not accepted."}),sh=eQ.z.record(eQ.z.string().refine(e=>e.trim().length>0,{message:"An asset reference cannot be empty or only whitespace"}),sf).openapi({description:"Images keyed by reference string, as in TypeSafe's API. Write a reference wherever the image belongs in `state`, `instructions`, or `criteria`; every asset must be referenced at least once, or the request fails with `400` naming the unused key. TypeSafe Jev endpoints receive `assets` as written and read a reference as a whole string value or inside longer text. Every other provider has each whole-string reference resolved to an `image_url` part before the request is sent, so it is accepted only where that provider reads `image_url` parts (top-level `state` items), and a reference inside longer text fails with `400`. `image_url` parts and `assets` can be mixed in one request."}),sx=sm.f.nullish(),sp=eQ.z.object({type:eQ.z.literal("noul"),instructions:sx,criteria:eQ.z.object({true:sx,false:sx}).optional()}).openapi("DecisionsNoulQuestion"),sg=eQ.z.object({type:eQ.z.literal("choice"),instructions:sx,criteria:eQ.z.record(eQ.z.string(),sm.f.nullable())}).openapi("DecisionsChoiceQuestion"),sv=eQ.z.object({type:eQ.z.literal("score"),instructions:sx,criteria:eQ.z.array(sm.f).min(1)}).openapi("DecisionsScoreQuestion"),sb=eQ.z.object({type:eQ.z.literal("box"),instructions:sm.f.openapi({description:"A description of the target to find, naming the image in `state` it is in; not a command, and no `criteria`."})}).openapi("DecisionsBoxQuestion",{description:"Finds one target in an image in `state` and answers with one bounding box (`top`, `bottom`, `left`, `right` as fractions of the image). Served by TypeSafe Jev endpoints only; every other provider rejects a box question with `400` before anything is sent upstream."}),sj=eQ.z.discriminatedUnion("type",[sp,sg,sv,sb]).openapi({description:"A Decisions question using a boolean, choice, ordered score, or image bounding-box evaluation.",discriminator:{propertyName:"type",mapping:{noul:"#/components/schemas/DecisionsNoulQuestion",choice:"#/components/schemas/DecisionsChoiceQuestion",score:"#/components/schemas/DecisionsScoreQuestion",box:"#/components/schemas/DecisionsBoxQuestion"}}});eQ.z.object({model:eQ.z.string(),state:sm.f.openapi({description:"The content to evaluate: a plain string, or a JSON object or array of related context."}),questions:eQ.z.record(eQ.z.string().min(1),sj).refine(e=>Object.keys(e).length>0,{message:"At least one question is required"}),assets:sh.optional(),provider:so.f.optional(),user:eQ.z.string().max(256).optional(),session_id:sc.p,trace:sd.f}).superRefine((e,t)=>{if(void 0!==e.assets)for(let r of function({state:e,questions:t,assets:r}){let n=new Set(Object.keys(r));for(let r of function*(e){let t=[...e];for(;t.length>0;){let e=t.pop();if("string"==typeof e){yield e;continue}if(Array.isArray(e)){for(let r of e)t.push(r);continue}if(!(!("object"==typeof e&&null!==e&&!Array.isArray(e))||"string"==typeof e.type&&su.has(e.type)&&Object.hasOwn(e,e.type)))for(let r of Object.values(e))t.push(r)}}([e,...Object.values(t).map(({type:e,...t})=>t)])){for(let e of n)r.includes(e)&&n.delete(e);if(0===n.size)break}return[...n]}({...e,assets:e.assets}))t.addIssue({code:"custom",path:["assets",r],message:`Asset "${r}" is not referenced in state, instructions, or criteria`})}).openapi("DecisionsRequest");let sy="cheaper_model_sufficient_",sw="higher_effort_gain_",sN={type:"choice",instructions:"Which task type is the user asking the assistant to perform? Classify by the task being requested, not by tools or boilerplate in the system context.",criteria:Object.fromEntries(si.G.map(e=>[e.tag,e.description]))};eQ.z.record(eQ.z.string().regex(/^[a-z][a-z0-9_]{0,63}$/),sj).refine(e=>Object.keys(e).every(e=>!e.startsWith(sy)&&!e.startsWith(sw)),"Candidate question IDs are reserved for runtime expansion").transform(e=>{var t;return{...e,...e.task?.type==="choice"?{task:{...t=e.task,criteria:{...sN.criteria,...Object.fromEntries(Object.entries(t.criteria).filter(([e])=>e in sN.criteria))}}}:{}}}).prefault({});var s_=e.i(988590);let sS=["0","1","2","3","4"],sk=eQ.z.object({type:eQ.z.literal("noul"),noul:eQ.z.number()}),sC=eQ.z.object({type:eQ.z.enum(["choice","score"]),confidence:eQ.z.number().optional(),probabilities:eQ.z.record(eQ.z.string(),eQ.z.number()).optional()}),sz=eQ.z.union([sk,sC]),sI=eQ.z.string().nullish().transform(e=>e??void 0),sT=eQ.z.object({model:eQ.z.string(),effort:sI,admitted:eQ.z.boolean().optional(),reason:eQ.z.string().optional(),estimated_cost:eQ.z.number().optional(),estimated_response_ms:eQ.z.number().optional()}),sM=eQ.z.object({model:eQ.z.string(),effort:sI,tier:eQ.z.string().optional()}),sE=eQ.z.array(eQ.z.object({model:eQ.z.string().min(1),probability:eQ.z.number().min(0).max(1)})).nonempty().refine(e=>new Set(e.map(({model:e})=>e)).size===e.length&&1e-6>=Math.abs(e.reduce((e,{probability:t})=>e+t,0)-1)),sA=eQ.z.looseObject({version:eQ.z.string().optional(),answers:eQ.z.record(eQ.z.string(),eQ.z.unknown()).optional(),input_tokens:eQ.z.number().optional(),output_tokens:eQ.z.number().optional(),floor:eQ.z.string().optional(),reason:eQ.z.string().optional(),reconsidered:eQ.z.boolean().optional(),incumbent_model:eQ.z.string().optional(),incumbent_effort:sI,advisor_model:eQ.z.string().optional(),estimated_stay_cost:eQ.z.number().optional(),estimated_switch_cost:eQ.z.number().optional(),estimated_input_tokens:eQ.z.number().optional(),estimated_output_tokens:eQ.z.number().optional(),evaluations:eQ.z.array(sT).optional().catch(void 0),candidates:eQ.z.array(sM).optional().catch(void 0),resolved_models:eQ.z.array(eQ.z.string()).optional(),pool_model_count:eQ.z.number().optional(),input_modalities:eQ.z.array(eQ.z.enum(n2.D)).nonempty().refine(e=>new Set(e).size===e.length).optional().catch(void 0),selection_probabilities:sE.optional().catch(void 0)}),sR=eQ.z.object({task_type:eQ.z.string().optional().catch(void 0)}),sP=(0,R.u)((0,eJ.C)(sA,{})),sD=Object.fromEntries(si.G.map(e=>[e.tag,e.displayName])),sF={task:sN,task_changed:{type:"noul",instructions:"Is there clear evidence that the remaining overall task has materially changed from the context entry identified by current.task_anchor_message_index? Compare the actual user goals using the recent user turns and conversation context. Routine tool steps, short follow-ups, and ambiguous continuations are not task changes. Missing current state or an unknown task anchor is not evidence of a change. A different task label alone is insufficient. This is an experimental evidence score, not a calibrated probability."},difficulty:{type:"score",instructions:"How difficult is the work required by the current request, considering relevant conversation history and unresolved requirements? Evaluate the reasoning needed now, including any broader constraints that affect this work. Neither a short tool step nor the surrounding agent harness determines difficulty on its own.",criteria:["Routine recall or copying","Simple transformation or familiar explanation","Several connected steps or constraints","Difficult reasoning, debugging or rigorous proof","Research-level reasoning or unusually complex integration"]},precision:{type:"score",instructions:"How exact must the answer be to satisfy the request?",criteria:["Open-ended brainstorming","Approximate answer is useful","Mostly correct details required","Strict requirements and few tolerable mistakes","Exact, verifiable result or rigorous proof required"]},big_model_gain:{type:"noul",instructions:"Would moving to a stronger model materially improve success on the current request, accounting for relevant history and unresolved requirements? Judge the model change separately from increasing reasoning effort on the current model. Consider repeated incorrect conclusions, failed approaches caused by misunderstanding the task or code, and evidence of stalled progress. Distinguish these from expected exploratory failures, provider or network errors, and waiting for external work; turn count or elapsed time alone is insufficient. For a fresh conversation with no current model, compare a frontier reasoning model with a capable inexpensive model. Treat this as an experimental quality judgment, not a calibrated probability."},higher_effort_gain:{type:"noul",instructions:"Compare keeping the current model and reasoning effort with using the specified higher reasoning effort on that same model. Would the higher-effort option materially improve the chance of correctly completing the current request, considering relevant history and unresolved requirements? Consider incorrect conclusions and failed approaches caused by misunderstanding the task. Provider errors, ordinary exploration, and elapsed time alone are not evidence that more reasoning will help. Do not judge switching models or estimate prices or cache reuse. This is an experimental quality judgment, not a calibrated probability."},cheaper_model_sufficient:{type:"noul",instructions:"Can the specified candidate model and reasoning effort meet the requirements to an acceptable standard? When keeping the current model and changing only effort, judge the current request in its conversation context, including broader requirements relevant to this work; lower effort can be sufficient during an unfinished task. When changing models, judge the remaining overall work. Completion language, passing tests, and elapsed time are not independent evidence of sufficiency. Preserve correctness, visual quality, and integration requirements. Answer positively only when the candidate is sufficient for the relevant work; answer negatively if it is insufficient or its capability is unknown. Candidate profiles are operator hypotheses, not proof. Do not estimate prices or cache reuse. This is an experimental quality judgment, not a calibrated probability."},visual_quality:{type:"noul",instructions:"Does success on the remaining overall task depend materially on exceptional visual design, composition, polish, or interactive presentation? Routine UI edits and mere frontend code do not imply this requirement. Preserve the overall goal through routine follow-ups. Judge the requested artifact, not model names or routing instructions."},codebase_integration:{type:"noul",instructions:"Does success on the remaining overall task require substantial understanding of an existing codebase, its architecture, contracts, or runtime behavior? Include cross-file analysis, root-cause investigation, and explaining observed behavior even when changes are forbidden, as well as implementing changes that preserve existing behavior. A simple file lookup, standalone snippet, or generic coding question is insufficient. Preserve this requirement through routine tool steps and follow-ups. Judge the actual task, not the surrounding agent harness."},output_length:{type:"score",instructions:"How long should the visible answer be to fulfill the request? Exclude private reasoning tokens.",criteria:["At most 128 tokens","About 512 tokens","About 1,024 tokens","About 2,048 tokens","About 4,096 tokens or more"]},latency_sensitive:{type:"noul",instructions:"Does the request explicitly prioritize a quick interactive response over deeper reasoning?"}};function sV(e){return{floor:e.floor,reason:e.reason,reconsidered:e.reconsidered,incumbentModel:e.incumbent_model,incumbentEffort:e.incumbent_effort,advisorModel:e.advisor_model,stayCost:e.estimated_stay_cost,switchCost:e.estimated_switch_cost,estimatedInputTokens:e.estimated_input_tokens,estimatedOutputTokens:e.estimated_output_tokens,poolModelCount:e.pool_model_count,evaluations:e.evaluations??[],candidates:e.candidates??[],resolvedModels:e.resolved_models??[],inputModalities:e.input_modalities,selectionProbabilities:e.selection_probabilities}}function sO(e){let t=e?.attempts,r=t?.length?t.findLast(e=>e.status>=200&&e.status<300):e?.endpoints.available.find(e=>e.selected);return{selectedModel:r?.model,provider:r?.provider,attempts:t?.length,generationTimeMs:e?.generation_time,isByok:e?.is_byok??!1}}function sL(e){return e.startsWith(sy)?{id:e,baseId:"cheaper_model_sufficient",candidateIndex:e.slice(sy.length)}:e.startsWith(sw)?{id:e,baseId:"higher_effort_gain",candidateIndex:e.slice(sw.length)}:{id:e,baseId:e,candidateIndex:void 0}}var sB=e.i(333131);function sq(e){return e.metadata?.requestedModel??e.metadata?.routerMetadata?.requested??e.metadata?.variantSlug}let sW={task:(0,tT.b)("Task"),task_changed:(0,tT.b)("Task change likelihood"),difficulty:(0,tT.b)("Difficulty"),precision:(0,tT.b)("Precision"),big_model_gain:(0,tT.b)("Larger model benefit"),visual_quality:(0,tT.b)("Visual quality"),codebase_integration:(0,tT.b)("Codebase integration"),output_length:(0,tT.b)("Response length"),latency_sensitive:(0,tT.b)("Speed preference")},s$=new Map([[rO.f.Auto,(0,tT.b)("Auto Router")],[rO.f.AutoCode,(0,tT.b)("Auto Code")],[rO.f.AutoBeta,(0,tT.b)("Auto Router (Beta)")],[rO.f.JevRouter,(0,tT.b)("Jev Router")]]),sU=["task","task_changed"],sH=["difficulty","precision","big_model_gain"],sG=["output_length","latency_sensitive","codebase_integration","visual_quality"];function sK(e){let n,s,a,l,i,o,c=(0,r.c)(21),{presentation:d}=e,m=void 0===d?"sidebar":d,u=(0,p.f)(t4.Q),f=(0,p.f)(x.A),h=(0,p.f)(x.U);if(c[0]!==u||c[1]!==f){let e;e=new Set(Object.values(f).flatMap(e=>{var t;return"assistant"===e.type&&sq(e)===rO.f.Auto&&(t=e.metadata?.routerMetadata,t?.pipeline?.some(e=>e.name===rL.f.JevRouter)===!0)?[e.characterId]:[]})),n=new Map(u.flatMap(({id:t,model:r})=>void 0!==r&&((0,sB.Q)(r)||r===rO.f.Auto&&e.has(t))?[[t,r]]:[])),c[0]=u,c[1]=f,c[2]=n}else n=c[2];let g=n;if(c[3]!==f||c[4]!==g||c[5]!==h){e:{for(let e=h.length-1;e>=0;e-=1){let t=h[e],r=void 0===t?void 0:f[t];if(r?.type==="assistant"&&g.has(r.characterId)&&sq(r)===g.get(r.characterId)){s=r;break e}}s=void 0}c[3]=f,c[4]=g,c[5]=h,c[6]=s}else s=c[6];let v=s;c[7]!==v?.isRetrying||c[8]!==v?.metadata?.routerMetadata?(a=v?.isRetrying?void 0:function(e){var t,r,n,s;let a,l,i=e?.pipeline??[],o=i.find(e=>e.name===rL.f.JevRouter);if(void 0!==o){let n;return t=e,r=o.data,n=(0,R.s)((0,eJ.C)(sA,r??{}),sP),{source:rL.f.JevRouter,version:n.version,jevTokens:void 0!==n.input_tokens&&void 0!==n.output_tokens?{input:n.input_tokens,output:n.output_tokens}:void 0,answers:Object.entries(n.answers??{}).flatMap(([e,t])=>{let r=(0,R.F)((0,eJ.C)(sz,t));if(void 0===r)return[];let n=sL(e);if("noul"===r.type)return[{...n,kind:"noul",value:r.noul}];let s=Object.entries(r.probabilities??{}).reduce((e,[t,r])=>void 0===e||r>e.value?{key:t,value:r}:e,void 0);if(void 0===s)return[];if("score"===r.type){var a,l,i;let t,o=function(e){if((0,s_.q)(e,sS))switch(e){case"0":return 0;case"1":return 1;case"2":return 2;case"3":return 3;case"4":return 4;default:return e}}(s.key);return void 0===o?[]:[{...n,kind:"score",level:o,levelLabel:(a=e,l=o,t=sF[sL(a).baseId],t?.type==="score"&&"string"==typeof(i=t.criteria[l])?i:void 0),confidence:r.confidence}]}return[{...n,kind:"choice",choice:s.key,choiceLabel:sD[s.key]??s.key,probability:s.value,confidence:r.confidence}]}),route:sV(n),call:sO(t)}}let c=i.find(e=>e.name===rL.f.Phaser);return void 0===c?void 0:(n=e,s=c.data,a=(0,R.F)((0,eJ.C)(sR,s??{})),l=a?.task_type,{source:rL.f.Phaser,version:void 0,jevTokens:void 0,answers:void 0===l?[]:[{id:"task",baseId:"task",candidateIndex:void 0,kind:"choice",choice:l,choiceLabel:sD[l]??l,probability:void 0,confidence:void 0}],route:sV(sP),call:sO(n)})}(v?.metadata?.routerMetadata),c[7]=v?.isRetrying,c[8]=v?.metadata?.routerMetadata,c[9]=a):a=c[9];let b=a;c[10]!==v||c[11]!==g?(l=(v&&g.get(v.characterId))??g.values().next().value,c[10]=v,c[11]=g,c[12]=l):l=c[12];let j=l;if(void 0===j)return null;let y=void 0!==v,w=void 0===b&&(v?.isGenerating===!0||v?.isRetrying===!0);return c[13]!==j||c[14]!==y||c[15]!==w||c[16]!==b?(i=(0,t.jsx)(sJ,{router:j,view:b,hasRouterResponse:y,isLoading:w}),c[13]=j,c[14]=y,c[15]=w,c[16]=b,c[17]=i):i=c[17],c[18]!==m||c[19]!==i?(o=(0,t.jsx)(nQ,{presentation:m,children:i}),c[18]=m,c[19]=i,c[20]=o):o=c[20],o}function sJ(e){let n,s,a,l,i,o,c,d,m,u,f,h,x,p=(0,r.c)(37),{router:g,view:v,hasRouterResponse:b,isLoading:j}=e,y=(0,tj.o)(),w=(0,tj.M)(),{getModelInfoByVariantSlug:N}=(0,eT.S)();if(p[0]!==N||p[1]!==w||p[2]!==g){s=N(g);let e=s$.get(g);a=void 0===e?s?.short_name??g:w(e),i="flex shrink-0 items-center justify-between gap-3 border-b border-border px-4 py-3",n=rs.f,l=s4(g,s),p[0]=N,p[1]=w,p[2]=g,p[3]=n,p[4]=s,p[5]=a,p[6]=l,p[7]=i}else n=p[3],s=p[4],a=p[5],l=p[6],i=p[7];let _=s?.author_icon_uri;p[8]!==n||p[9]!==g||p[10]!==l||p[11]!==_?(o=(0,t.jsx)(n,{author:l,permaslug:g,iconUri:_,frame:!0,className:"size-8"}),p[8]=n,p[9]=g,p[10]=l,p[11]=_,p[12]=o):o=p[12],p[13]!==a?(c=(0,t.jsx)("span",{className:"truncate text-base font-semibold text-foreground",children:a}),p[13]=a,p[14]=c):c=p[14];let S=j?"status":void 0;return p[15]!==y||p[16]!==j?(d=y(j?"Waiting for routing insights…":"Routing insights"),p[15]=y,p[16]=j,p[17]=d):d=p[17],p[18]!==S||p[19]!==d?(m=(0,t.jsx)("span",{role:S,className:"text-xs text-muted-foreground",children:d}),p[18]=S,p[19]=d,p[20]=m):m=p[20],p[21]!==c||p[22]!==m?(u=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[c,m]}),p[21]=c,p[22]=m,p[23]=u):u=p[23],p[24]!==i||p[25]!==o||p[26]!==u?(f=(0,t.jsxs)("div",{className:i,children:[o,u]}),p[24]=i,p[25]=o,p[26]=u,p[27]=f):f=p[27],p[28]!==y||p[29]!==b||p[30]!==j||p[31]!==a||p[32]!==v?(h=(0,t.jsx)("div",{className:"flex-1 overflow-y-auto overscroll-contain px-4 py-4 text-xs",children:void 0!==v||j?(0,t.jsx)(sZ,{view:v}):(0,t.jsx)("p",{className:"text-muted-foreground",children:y(b?"No route details are available for the latest {router} response.":"Send a message with {router} selected to see how your request is routed.",{router:a})})}),p[28]=y,p[29]=b,p[30]=j,p[31]=a,p[32]=v,p[33]=h):h=p[33],p[34]!==f||p[35]!==h?(x=(0,t.jsxs)(t.Fragment,{children:[f,h]}),p[34]=f,p[35]=h,p[36]=x):x=p[36],x}function sZ(e){let n,s,a,l,i,o,c,d,m,u,f,h,x,p,g,v,b,j,y,w=(0,r.c)(51),{view:N}=e,_=(0,tj.o)(),S=(0,ed.f)();w[0]!==S||w[1]!==N?(n=N?.call.generationTimeMs===void 0?void 0:S.duration(N.call.generationTimeMs,{preset:"latency"}),w[0]=S,w[1]=N,w[2]=n):n=w[2];let k=n,C=void 0===N;w[3]!==_?(s=_("Selected model"),w[3]=_,w[4]=s):s=w[4],w[5]!==s?(a=(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:s}),w[5]=s,w[6]=a):a=w[6],w[7]!==N?(l=void 0===N?(0,t.jsxs)("div",{"aria-hidden":"true",className:"flex items-center gap-2",children:[(0,t.jsx)(nH.l,{className:"size-8 shrink-0"}),(0,t.jsx)(nH.l,{className:"h-4 w-36"})]}):(0,t.jsx)(s3,{model:N.call.selectedModel}),w[7]=N,w[8]=l):l=w[8],w[9]!==_?(i=_("Provider"),w[9]=_,w[10]=i):i=w[10],w[11]!==N?(o=void 0===N?(0,t.jsx)(nH.l,{className:"h-4 w-16"}):N.call.provider,w[11]=N,w[12]=o):o=w[12],w[13]!==i||w[14]!==o?(c=(0,t.jsx)(s2,{label:i,value:o}),w[13]=i,w[14]=o,w[15]=c):c=w[15],w[16]!==_?(d=_("Generation time"),w[16]=_,w[17]=d):d=w[17],w[18]!==k||w[19]!==N?(m=void 0===N?(0,t.jsx)(nH.l,{className:"h-4 w-12"}):k,w[18]=k,w[19]=N,w[20]=m):m=w[20],w[21]!==m||w[22]!==d?(u=(0,t.jsx)(s2,{label:d,value:m}),w[21]=m,w[22]=d,w[23]=u):u=w[23],w[24]!==u||w[25]!==c?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border/50 pt-3",children:[c,u]}),w[24]=u,w[25]=c,w[26]=f):f=w[26],w[27]!==f||w[28]!==a||w[29]!==l?(h=(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3",children:[a,l,f]}),w[27]=f,w[28]=a,w[29]=l,w[30]=h):h=w[30],w[31]!==_?(x=_("Request analysis"),w[31]=_,w[32]=x):x=w[32],w[33]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(nG.f,{className:"size-4"}),w[33]=p):p=w[33];let z=N?.answers;w[34]!==z?(g=(0,t.jsx)(sQ,{answers:z,ids:sU}),w[34]=z,w[35]=g):g=w[35];let I=N?.route;return w[36]!==I?(v=(0,t.jsx)(se,{route:I}),w[36]=I,w[37]=v):v=w[37],w[38]!==_||w[39]!==N?.answers||w[40]!==N?.source?(b=N?.source!==rL.f.Phaser&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s1,{title:_("Complexity"),children:(0,t.jsx)(sQ,{answers:N?.answers,ids:sH})}),(0,t.jsx)(s1,{title:_("Response preferences"),children:(0,t.jsx)(sQ,{answers:N?.answers,ids:sG})}),(0,t.jsx)("p",{className:"text-xs leading-body text-muted-foreground",children:_("Most likely scores, using default criteria. The routing policy may use a different level.")})]}),w[38]=_,w[39]=N?.answers,w[40]=N?.source,w[41]=b):b=w[41],w[42]!==x||w[43]!==g||w[44]!==v||w[45]!==b?(j=(0,t.jsxs)(s0,{title:x,icon:p,children:[g,v,b]}),w[42]=x,w[43]=g,w[44]=v,w[45]=b,w[46]=j):j=w[46],w[47]!==h||w[48]!==C||w[49]!==j?(y=(0,t.jsxs)("div",{"aria-busy":C,className:"flex flex-col gap-5",children:[h,j]}),w[47]=h,w[48]=C,w[49]=j,w[50]=y):y=w[50],y}function sQ(e){let n,s,a,l,i=(0,r.c)(20),{answers:o,ids:c}=e,d=(0,tj.o)(),m=(0,tj.M)();if(void 0===o){let e,r;if(i[0]!==c||i[1]!==m){let r;i[3]!==m?(r=e=>(0,t.jsx)("li",{children:(0,t.jsx)(s2,{label:m(sW[e]??(0,tT.b)("Unknown")),value:(0,t.jsx)(nH.l,{"aria-hidden":"true",className:"h-4 w-24"})})},e),i[3]=m,i[4]=r):r=i[4],e=c.map(r),i[0]=c,i[1]=m,i[2]=e}else e=i[2];return i[5]!==e?(r=(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:e}),i[5]=e,i[6]=r):r=i[6],r}if(i[7]!==o||i[8]!==d||i[9]!==c){a=Symbol.for("react.early_return_sentinel");e:{var u;let e=(u=o,c.flatMap(e=>u.filter(t=>t.baseId===e&&void 0===t.candidateIndex)));if(0===e.length){let e,r;i[13]!==d?(e=d("Unavailable"),i[13]=d,i[14]=e):e=i[14],i[15]!==e?(r=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e}),i[15]=e,i[16]=r):r=i[16],a=r;break e}n="flex flex-col gap-2",s=e.map(sX)}i[7]=o,i[8]=d,i[9]=c,i[10]=n,i[11]=s,i[12]=a}else n=i[10],s=i[11],a=i[12];return a!==Symbol.for("react.early_return_sentinel")?a:(i[17]!==n||i[18]!==s?(l=(0,t.jsx)("ul",{className:n,children:s}),i[17]=n,i[18]=s,i[19]=l):l=i[19],l)}function sX(e){return(0,t.jsx)("li",{children:(0,t.jsx)(sY,{answer:e})},e.id)}function sY(e){var n;let s,a,l,o,c,d,m,u,f,h,x,p,g,v=(0,r.c)(34),{answer:b}=e,j=(0,tj.o)(),y=(0,ed.f)(),w=(n=b,l=(0,r.c)(8),o=(0,tj.o)(),c=(0,tj.M)(),d=sW[n.baseId],l[0]!==n.baseId||l[1]!==c||l[2]!==d?(s=void 0===d?n.baseId:c(d),l[0]=n.baseId,l[1]=c,l[2]=d,l[3]=s):s=l[3],m=s,l[4]!==n.candidateIndex||l[5]!==m||l[6]!==o?(a=void 0===n.candidateIndex?m:o("{label} (candidate {index})",{label:m,index:n.candidateIndex}),l[4]=n.candidateIndex,l[5]=m,l[6]=o,l[7]=a):a=l[7],a);if("choice"===b.kind){let e,r;return v[0]!==b.choiceLabel||v[1]!==b.probability||v[2]!==y||v[3]!==j?(e=void 0===b.probability?b.choiceLabel:j("{choice} ({probability})",{choice:b.choiceLabel,probability:y.ratio(b.probability,{preset:"native-fixed-0"})??""}),v[0]=b.choiceLabel,v[1]=b.probability,v[2]=y,v[3]=j,v[4]=e):e=v[4],v[5]!==w||v[6]!==e?(r=(0,t.jsx)(s2,{label:w,value:e}),v[5]=w,v[6]=e,v[7]=r):r=v[7],r}if("score"===b.kind&&"output_length"===b.baseId){let e;return v[8]!==b.levelLabel||v[9]!==w?(e=(0,t.jsx)(s2,{label:w,value:b.levelLabel}),v[8]=b.levelLabel,v[9]=w,v[10]=e):e=v[10],e}let N="score"===b.kind;v[11]!==b.level||v[12]!==b.value||v[13]!==y||v[14]!==j||v[15]!==N?(u=N?j("{level} of 5",{level:y.nativeNumber(b.level+1)??""}):y.ratio(b.value,{preset:"native-fixed-0"}),v[11]=b.level,v[12]=b.value,v[13]=y,v[14]=j,v[15]=N,v[16]=u):u=v[16];let _=u;v[17]!==w?(f=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:w}),v[17]=w,v[18]=f):f=v[18];let S=N?b.level+1:b.value,k=N?5:1;return v[19]!==w||v[20]!==S||v[21]!==k?(h=(0,t.jsx)(nU.f,{"aria-label":w,value:S,max:k,variant:"neutral",track:"muted",className:"h-1 w-12"}),v[19]=w,v[20]=S,v[21]=k,v[22]=h):h=v[22],v[23]!==b.levelLabel||v[24]!==j||v[25]!==N||v[26]!==_?(x=N?(0,t.jsx)("span",{className:"text-xs tabular-nums text-foreground",children:(0,t.jsx)(i.Tooltip,{content:(0,t.jsx)("span",{className:"ph-no-capture","data-dd-privacy":"hidden",children:b.levelLabel??j("Default criteria unavailable")}),children:(0,t.jsxs)(i.TooltipNonInteractiveTrigger,{className:"inline-flex min-w-14 items-center justify-end gap-1",children:[_,(0,t.jsx)(nK.f,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]})})}):(0,t.jsx)("span",{className:"min-w-14 text-right text-xs tabular-nums text-foreground",children:_}),v[23]=b.levelLabel,v[24]=j,v[25]=N,v[26]=_,v[27]=x):x=v[27],v[28]!==h||v[29]!==x?(p=(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[h,x]}),v[28]=h,v[29]=x,v[30]=p):p=v[30],v[31]!==f||v[32]!==p?(g=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[f,p]}),v[31]=f,v[32]=p,v[33]=g):g=v[33],g}function s0(e){let n,s,a=(0,r.c)(6),{title:l,icon:i,children:o}=e;return a[0]!==i||a[1]!==l?(n=(0,t.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[i,l]}),a[0]=i,a[1]=l,a[2]=n):n=a[2],a[3]!==o||a[4]!==n?(s=(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[n,o]}),a[3]=o,a[4]=n,a[5]=s):s=a[5],s}function s1(e){let n,s,a=(0,r.c)(5),{title:l,children:i}=e;return a[0]!==l?(n=(0,t.jsx)("h4",{className:"text-xs font-medium text-foreground",children:l}),a[0]=l,a[1]=n):n=a[1],a[2]!==i||a[3]!==n?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border/50 pt-3",children:[n,i]}),a[2]=i,a[3]=n,a[4]=s):s=a[4],s}function s2(e){let n,s,l,i,o,c=(0,r.c)(13),{label:d,value:m}=e,u=(0,tj.o)();c[0]!==d?(n=(0,t.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:d}),c[0]=d,c[1]=n):n=c[1];let f=null==m?"text-faint":"text-foreground";return c[2]!==f?(s=(0,a.f)("min-w-0 text-right text-xs tabular-nums wrap-anywhere",f),c[2]=f,c[3]=s):s=c[3],c[4]!==u||c[5]!==m?(l=m??u("Unknown"),c[4]=u,c[5]=m,c[6]=l):l=c[6],c[7]!==s||c[8]!==l?(i=(0,t.jsx)("div",{className:s,children:l}),c[7]=s,c[8]=l,c[9]=i):i=c[9],c[10]!==n||c[11]!==i?(o=(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[n,i]}),c[10]=n,c[11]=i,c[12]=o):o=c[12],o}function s3(e){let n,s,a,l,i,o=(0,r.c)(18),{model:c}=e,d=(0,tj.o)(),{getModelInfoByVariantPermaslug:m,getModelInfoByVariantSlug:u}=(0,eT.S)();if(void 0===c){let e,r;return o[0]!==d?(e=d("Unknown"),o[0]=d,o[1]=e):e=o[1],o[2]!==e?(r=(0,t.jsx)("span",{className:"text-faint",children:e}),o[2]=e,o[3]=r):r=o[3],r}o[4]!==m||o[5]!==u||o[6]!==c?(n=m(c)??u(c),s=s4(c,n),o[4]=m,o[5]=u,o[6]=c,o[7]=n,o[8]=s):(n=o[7],s=o[8]);let f=s;o[9]!==f||o[10]!==c?(a=(0,t.jsx)(rs.f,{frame:!0,author:f,permaslug:c,className:"size-8"}),o[9]=f,o[10]=c,o[11]=a):a=o[11];let h=n?.short_name??c;return o[12]!==h?(l=(0,t.jsx)("span",{className:"min-w-0 wrap-anywhere text-sm font-medium text-foreground",children:h}),o[12]=h,o[13]=l):l=o[13],o[14]!==c||o[15]!==a||o[16]!==l?(i=(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-left",title:c,children:[a,l]}),o[14]=c,o[15]=a,o[16]=l,o[17]=i):i=o[17],i}function s4(e,t){return t?.author??e.split("/")[0]??""}var s5=e.i(457661),s6=e.i(958924),s7=e.i(273884),s8=e.i(435799),s9=e.i(685457);function ae(){var e,n;let s,l,i,o,c,d,u,f,x,p,g,v=(0,r.c)(30),b=(0,h.f)(),j=(0,nZ.F)(ar),y=(0,nZ.F)(at),w=null!==j,N=(0,_.x)(),S=(0,nv.f)(),{shownTarget:k,openCount:C,release:z}=function(e,t){let n,s,a=(0,r.c)(4),[l,i]=(0,m.useState)(e),[o,c]=(0,m.useState)(0);null!==e&&e!==l&&(i(e),c(o+1)),a[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>i(null),a[0]=n):n=a[0];let d=n,u=e??(t?l:null);return a[1]!==o||a[2]!==u?(s={shownTarget:u,openCount:o,release:d},a[1]=o,a[2]=u,a[3]=s):s=a[3],s}(j,!(0,_.o)("(prefers-reduced-motion: reduce)"));e=w&&N,n=y,(i=(0,r.c)(4))[0]!==n||i[1]!==e?(s=()=>{if(!e)return;let t=e=>{"Escape"!==e.key||e.defaultPrevented||n()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},l=[e,n],i[0]=n,i[1]=e,i[2]=s,i[3]=l):(s=i[2],l=i[3]),(0,m.useEffect)(s,l),v[0]!==C||v[1]!==k?(o=k?(0,t.jsx)(an,{itemId:k.itemId,messageId:k.messageId},C):null,v[0]=C,v[1]=k,v[2]=o):o=v[2];let I=o,T=!w,M=!w,E=w?"w-100":"w-0 transition-[width] duration-0 delay-(--duration-quick) motion-reduce:delay-0";v[3]!==E?(c=(0,a.f)("hidden shrink-0 overflow-hidden border-l border-border bg-background md:block",E),v[3]=E,v[4]=c):c=v[4],v[5]!==w||v[6]!==z?(d=e=>{w||e.target!==e.currentTarget||z()},v[5]=w,v[6]=z,v[7]=d):d=v[7];let A=w?"duration-fast":"translate-x-full opacity-0 duration-quick";return v[8]!==A?(u=(0,a.f)("flex h-full w-100 flex-col","transition-[translate,opacity] ease-drawer motion-reduce:transition-none",A),v[8]=A,v[9]=u):u=v[9],v[10]!==I||v[11]!==d||v[12]!==u?(f=(0,t.jsx)("div",{onTransitionEnd:d,className:u,children:I}),v[10]=I,v[11]=d,v[12]=u,v[13]=f):f=v[13],v[14]!==T||v[15]!==M||v[16]!==c||v[17]!==f?(x=(0,t.jsx)("aside",{"data-testid":"playground-reasoning-panel","aria-hidden":T,inert:M,className:c,children:f}),v[14]=T,v[15]=M,v[16]=c,v[17]=f,v[18]=x):x=v[18],v[19]!==I||v[20]!==y||v[21]!==S||v[22]!==b||v[23]!==N||v[24]!==w||v[25]!==z?(p=N?null:(0,t.jsx)(np.j,{open:w,onOpenChange:e=>{e||y()},onOpenChangeComplete:e=>{e||z()},children:S?(0,t.jsxs)(np.U,{side:"right",container:S,showCloseButton:!1,overlayClassName:ng.u,className:ng.t,children:[(0,t.jsx)(np.L,{className:"sr-only",children:b("Reasoning")}),I]}):null}),v[19]=I,v[20]=y,v[21]=S,v[22]=b,v[23]=N,v[24]=w,v[25]=z,v[26]=p):p=v[26],v[27]!==p||v[28]!==x?(g=(0,t.jsxs)(t.Fragment,{children:[x,p]}),v[27]=p,v[28]=x,v[29]=g):g=v[29],g}function at(e){return e.close}function ar(e){return e.target}function an({itemId:e,messageId:r}){var n,s,a,i;let o=(0,h.f)(),c=(0,nZ.F)(e=>e.close),d=(0,m.useMemo)(N.x,[]),u=(0,p.f)(e=>d(e,r)),f=u?.type==="assistant"?u:void 0,x=f?.metadata?.reasoningDuration,g=f?.isGenerating??!1,v=(0,m.useMemo)(t4.F,[]),b=(0,p.f)(e=>f?.characterId?v(e,f.characterId):null),{getModelInfoByVariantSlug:j,getModelInfoByVariantPermaslug:y}=(0,eT.S)(),w=(0,m.useMemo)(()=>{let e=f?.metadata?.variantSlug??b?.model;return e?j(e)??y(e)??null:null},[f?.metadata?.variantSlug,b?.model,j,y]),_=(0,s7.Z)({routingPresetName:f?.metadata?.routingPresetName,routedModelName:(0,s7.f)({variantSlug:f?.metadata?.variantSlug,requestedModel:f?.metadata?.requestedModel,servedModelInfo:f?.metadata?.variantSlug?j(f.metadata.variantSlug)??y(f.metadata.variantSlug):null}),modelInfo:w,characterName:b?.name}),S=b?.name&&b.name!==_?b.name:null,k=(0,nB.useItemStore)(t=>(0,s5.j)(t,e)),C=(0,nB.useItemStore)(t=>(0,s5.N)(t,e)),z=!!x,I=g&&!z,T=(0,m.useRef)(null);(0,m.useEffect)(()=>{T.current?.scrollTo({top:0})},[e]);let M=(n=o,s=I,a=z,i=x??0,s?n("Thinking"):a?n("Reasoned · {duration}",{duration:(0,s8.f)(n,i)}):n("Reasoning"));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2 border-b border-border px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-baseline gap-1.5",children:[(0,t.jsx)("span",{className:"truncate text-sm font-semibold text-foreground",children:_??o("Reasoning")}),S?(0,t.jsx)(s6.f,{nickname:S}):null]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:M})]}),(0,t.jsx)(l.Button,{variant:"ghost",tone:"subdued",size:"icon-xs",onClick:c,"aria-label":o("Close reasoning panel"),className:"shrink-0",children:(0,t.jsx)(eN.f,{className:"h-4 w-4"})})]}),(0,t.jsx)(s9.f,{ref:T,content:k||C,isGenerating:I,className:"flex-1 overflow-y-auto px-4 py-4"})]})}var as=e.i(219328),aa=e.i(110572);let al={[aa.o.List]:(0,tT.b)("List"),[aa.o.Fanned]:(0,tT.b)("Side by side")},ai=[aa.o.List,aa.o.Fanned];function ao(){let e,n,s,a,l,i,o,c=(0,r.c)(16),d=(0,r$.f)(),m=(0,h.f)(),u=(0,aa.G)(ad),f=(0,aa.G)(ac);return c[0]!==f?(e=e=>{let t=function(e){switch(e){case aa.o.List:return aa.o.List;case aa.o.Fanned:return aa.o.Fanned;default:return null}}(e);t&&f(t)},c[0]=f,c[1]=e):e=c[1],c[2]!==m?(n=m("View mode"),c[2]=m,c[3]=n):n=c[3],c[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(r5.SelectValue,{}),c[4]=s):s=c[4],c[5]!==n?(a=(0,t.jsx)(r5.SelectTrigger,{"aria-label":n,className:"w-auto min-w-28 gap-2 font-medium",children:s}),c[5]=n,c[6]=a):a=c[6],c[7]!==d?(l=ai.map(e=>(0,t.jsx)(r5.SelectItem,{value:e,className:"whitespace-nowrap",children:d(al[e])},e)),c[7]=d,c[8]=l):l=c[8],c[9]!==l?(i=(0,t.jsx)(r5.SelectContent,{align:"end",className:"min-w-32",children:l}),c[9]=l,c[10]=i):i=c[10],c[11]!==u||c[12]!==e||c[13]!==a||c[14]!==i?(o=(0,t.jsxs)(r5.Select,{size:"compact",value:u,onValueChange:e,children:[a,i]}),c[11]=u,c[12]=e,c[13]=a,c[14]=i,c[15]=o):o=c[15],o}function ac(e){return e.setLayout}function ad(e){return e.layout}var am=e.i(205194);let au=(0,m.memo)(()=>{let e,t,n=(0,r.c)(6),s=(0,h.f)(),a=(0,am.f)();n[0]!==s||n[1]!==a?(e=async e=>{e?.preventDefault();let t=(0,rl.f)(),r=p.f.getState().rooms[t??""]?.characters,n=await S.z.createChatroom({payload:{title:s("Untitled Chat"),characters:r??{}}}),l=`?room=${n.id}`;a.push(l)},n[0]=s,n[1]=a,n[2]=e):e=n[2];let l=e;return(0,tU.f)(af,l),(0,tU.f)(ah,l),(0,tU.f)(ax,ap),(0,tU.f)(ag,av),n[3]!==s||n[4]!==a?(t=e=>{e?.preventDefault();let t=(0,rl.f)();t?S.z.duplicateRoom({payload:{sourceRoomId:t},dependencies:{router:a}}):(0,T.c)({title:s("Could not duplicate room"),description:s("No active chat to duplicate."),variant:"destructive"})},n[3]=s,n[4]=a,n[5]=t):t=n[5],(0,tU.f)(ab,t),(0,tU.f)(aj,ay),(0,tU.f)(aw,aN),null},()=>!0);function af(e){return!!e?.key&&"/"===e.key.toLowerCase()&&(e.metaKey||e.ctrlKey)}function ah(e){return!!e?.key&&"o"===e.key.toLowerCase()&&e.shiftKey&&(e.metaKey||e.ctrlKey)}function ax(e){return"Backspace"===e.key&&e.shiftKey&&(e.metaKey||e.ctrlKey)}function ap(e){e?.preventDefault();let t=(0,rl.f)();t&&S.z.clearAllMessages({payload:{roomId:t}})}function ag(e){return!!e?.key&&"x"===e.key.toLowerCase()&&e.shiftKey&&(e.metaKey||e.ctrlKey)}function av(e){e?.preventDefault();let t=(0,rl.f)();t&&S.z.clearCharacters({payload:{roomId:t}})}function ab(e){return!!e?.key&&"y"===e.key.toLowerCase()&&e.shiftKey&&(e.metaKey||e.ctrlKey)}function aj(e){return"ArrowUp"===e.key&&e.shiftKey&&(e.metaKey||e.ctrlKey)}function ay(e){e?.preventDefault();let t=(0,rl.f)();t&&S.z.setAllMessagesCollapsed({payload:{roomId:t,isCollapsed:!0}})}function aw(e){return"ArrowDown"===e.key&&e.shiftKey&&(e.metaKey||e.ctrlKey)}function aN(e){e?.preventDefault();let t=(0,rl.f)();t&&S.z.setAllMessagesCollapsed({payload:{roomId:t,isCollapsed:!1}})}var a_=e.i(307287),aS=e.i(497214),ak=e.i(227327);function aC(e){let t=e.modelInfo?.output_modalities??[];return(0,e_.W)(t)?rX.G.Video:t.includes(n2.j.Image)?rX.G.Image:rX.G.Text}function az(e){let n,s,l=(0,r.c)(6),{onClick:i,className:o,children:c}=e;return l[0]!==o?(n=(0,a.f)("flex flex-col rounded-xl p-3 text-left","bg-slate-3 dark:bg-slate-3","transition-colors","hover:bg-slate-4 dark:hover:bg-slate-4","active:bg-slate-5 dark:active:bg-slate-5",o),l[0]=o,l[1]=n):n=l[1],l[2]!==c||l[3]!==i||l[4]!==n?(s=(0,t.jsx)("button",{type:"button",onClick:i,className:n,children:c}),l[2]=c,l[3]=i,l[4]=n,l[5]=s):s=l[5],s}var aI=e.i(506050),aT=e.i(67089),aM=e.i(471316),aE=e.i(170993),aA=e.i(44299);async function aR({rooms:e,currentRoomId:t,storageInstanceId:r}){for(let n of Object.values(e).filter(e=>e.id!==t&&void 0===e.internId).sort((e,t)=>(0,aA.f)(t).getTime()-(0,aA.f)(e).getTime())){let e=await aP(n,r);if(e.length>0)return e}return[]}async function aP(e,t){let r=await aD(e,t),n=new Date;return Object.values(r).filter(e=>e&&(0,aE.f)(e)).map(e=>(0,aM.f)({...e,id:void 0,isDisabled:!1,zdr:void 0,createdAt:n,updatedAt:n}))}async function aD(e,t){if("success"===e.hydrationStatus)return e.characters;if(!t)return{};let r=await eZ.f.getRoomManifest(t,e.id);return eZ.f.getCharacters(t,r.characterIds)}function aF(e){return e.storageInstanceId}function aV(e){return e.currentRoomId}function aO(e){return e.rooms}function aL(e){return e.initializationStatus}let aB="Recently used";function aq(e){let n,s,a,l=(0,r.c)(9),{characters:o}=e,{setError:c}=(0,a_.useGlobalErrorToast)();l[0]!==c?(n=async e=>{if(!e.modelInfo)return;let t=await (0,R.$)(()=>S.z.addCharacters({payload:{roomId:(0,rl.f)(),characters:e}}));(0,R.V)(t)&&c((0,eU.n)({location:"AvatarGroup",rawError:t.error}))},l[0]=c,l[1]=n):n=l[1];let d=n;if(l[2]!==o||l[3]!==d){let e;l[5]!==d?(e=e=>(0,t.jsx)(i.Tooltip,{content:e?.modelInfo?.short_name,children:(0,t.jsx)("div",{onClick:t=>{t.stopPropagation(),d(e)},onKeyDown:t=>{"Enter"===t.key&&(t.stopPropagation(),d(e))},role:"button",tabIndex:0,className:"cursor-pointer rounded-full bg-background ring-2 ring-background -me-2 last:me-0",children:(0,t.jsx)(eE.f,{character:e})})},`avatar-${e.id}`),l[5]=d,l[6]=e):e=l[6],s=o.map(e),l[2]=o,l[3]=d,l[4]=s}else s=l[4];return l[7]!==s?(a=(0,t.jsx)("div",{className:"flex",children:s}),l[7]=s,l[8]=a):a=l[8],a}function aW(e,t){let n,s=(0,r.c)(4),{setError:a}=(0,a_.useGlobalErrorToast)();return s[0]!==t||s[1]!==a||s[2]!==e?(n=async()=>{(0,t7.g)({presetTitle:e,modelSlugs:(0,aS.k)(t.map(a$))});let r=await (0,R.$)(()=>S.z.replaceCharacters({payload:{roomId:(0,rl.f)(),characters:t}}));(0,R.V)(r)&&a((0,eU.n)({location:`PlaygroundModelPresets:${e}`,rawError:r.error}))},s[0]=t,s[1]=a,s[2]=e,s[3]=n):n=s[3],n}function a$(e){return e.model??null}function aU(e){return(0,eS.i)(e)}function aH(e){let n,s,a,l,i,o=(0,r.c)(13),{title:c,characters:d,onApply:m}=e;return o[0]!==m?(n=e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),m())},o[0]=m,o[1]=n):n=o[1],o[2]!==c?(s=(0,t.jsx)(nI.Y,{className:"flex flex-col p-4",children:(0,t.jsx)(nI.v,{className:"flex text-left",children:c})}),o[2]=c,o[3]=s):s=o[3],o[4]!==d?(a=(0,t.jsx)(nI.S,{className:"flex flex-col items-end p-4",children:(0,t.jsx)(aq,{characters:d})}),o[4]=d,o[5]=a):a=o[5],o[6]!==s||o[7]!==a?(l=(0,t.jsxs)(nI.N,{interactive:!0,className:"relative flex h-28 w-64 flex-col justify-between overflow-hidden md:h-32 md:w-52 lg:w-64 duration-200",children:[s,a]}),o[6]=s,o[7]=a,o[8]=l):l=o[8],o[9]!==m||o[10]!==n||o[11]!==l?(i=(0,t.jsx)("div",{role:"button",tabIndex:0,onClick:m,onKeyDown:n,children:l}),o[9]=m,o[10]=n,o[11]=l,o[12]=i):i=o[12],i}function aG(e){let n,s,a,l,i,o,c,d,m,u=(0,r.c)(24),{title:f,characters:h,onApply:x}=e;if(u[0]!==h||u[1]!==x||u[2]!==f){let e=(0,aS.k)(h.map(aJ));n=az,u[10]!==x?(i=()=>void x(),u[10]=x,u[11]=i):i=u[11],o="min-h-20 w-full justify-between gap-3",u[12]!==f?(c=(0,t.jsx)("span",{className:"text-sm font-medium leading-snug text-foreground",children:f}),u[12]=f,u[13]=c):c=u[13],s="flex items-center gap-2",a="true",l=e.map(aK),u[0]=h,u[1]=x,u[2]=f,u[3]=n,u[4]=s,u[5]=a,u[6]=l,u[7]=i,u[8]=o,u[9]=c}else n=u[3],s=u[4],a=u[5],l=u[6],i=u[7],o=u[8],c=u[9];return u[14]!==s||u[15]!==a||u[16]!==l?(d=(0,t.jsx)("span",{className:s,"aria-hidden":a,children:l}),u[14]=s,u[15]=a,u[16]=l,u[17]=d):d=u[17],u[18]!==n||u[19]!==i||u[20]!==o||u[21]!==c||u[22]!==d?(m=(0,t.jsxs)(n,{onClick:i,className:o,children:[c,d]}),u[18]=n,u[19]=i,u[20]=o,u[21]=c,u[22]=d,u[23]=m):m=u[23],m}function aK(e){let{id:r,model:n}=e;return(0,t.jsx)(rs.f,{frame:!0,author:n.author,iconUri:n.author_icon_uri,className:"size-4"},r)}function aJ(e){return e.modelInfo?{id:e.id,model:e.modelInfo}:null}function aZ(e){let n,s=(0,r.c)(3),{preset:a,View:l}=e,i=function(e){let t,n,s,a,l,i,o=(0,r.c)(19),c=(0,r$.f)(),{getModelInfoByVariantPermaslug:d,getModelInfoByVariantSlug:m}=(0,eT.S)();if(o[0]!==d||o[1]!==e.permaslugs){let r;o[3]!==d?(r=e=>d(e),o[3]=d,o[4]=r):r=o[4],t=(0,aS.k)(e.permaslugs.map(r)).map(aU),o[0]=d,o[1]=e.permaslugs,o[2]=t}else t=o[2];let u=t;o[5]!==m?(n=e=>{let t=m(e);if(!t)return null;let r=t.endpoint?{...t.endpoint,model:{...t.endpoint.model,default_stops:[...t.endpoint.model.default_stops]}}:null;return{...t,default_stops:[...t.default_stops],endpoint:r}},o[5]=m,o[6]=n):n=o[6];let f=n;o[7]!==f||o[8]!==u?(s=Object.values((0,ak.f)({getModelInfoByVariantSlug:f,variantSlugs:u})),o[7]=f,o[8]=u,o[9]=s):s=o[9];let h=s;o[10]!==e.title?(a=(0,tT.M)(e.title),o[10]=e.title,o[11]=a):a=o[11];let x=aW(a,h);return o[12]!==c||o[13]!==e.title?(l=c(e.title),o[12]=c,o[13]=e.title,o[14]=l):l=o[14],o[15]!==h||o[16]!==x||o[17]!==l?(i={title:l,characters:h,onApply:x},o[15]=h,o[16]=x,o[17]=l,o[18]=i):i=o[18],i}(a);return s[0]!==l||s[1]!==i?(n=(0,t.jsx)(l,{...i}),s[0]=l,s[1]=i,s[2]=n):n=s[2],n}function aQ(e){let n,s,a=(0,r.c)(7),{characters:l,View:i}=e,o=(0,h.f)(),c=aW(aB,l);return a[0]!==o?(n=o("Recently used"),a[0]=o,a[1]=n):n=a[1],a[2]!==i||a[3]!==l||a[4]!==c||a[5]!==n?(s=(0,t.jsx)(i,{title:n,characters:l,onApply:c}),a[2]=i,a[3]=l,a[4]=c,a[5]=n,a[6]=s):s=a[6],s}let aX=e=>({kind:"static",preset:e}),aY=(0,m.memo)(()=>{let e,n,s,l=(0,r.c)(11),i=(0,_.x)(),o=function(){let e,t,n=(0,r.c)(6),s=(0,p.f)(aL),a=(0,p.f)(aO),l=(0,p.f)(aV),i=(0,p.f)(aF),[o,c]=(0,m.useState)(null);return n[0]!==l||n[1]!==s||n[2]!==a||n[3]!==i?(e=()=>{if("idle"===s||"pending"===s)return void c(null);if("failed"===s)return void c([]);let e=!1;return(async()=>{let t=await (0,R.$)(()=>aR({rooms:a,currentRoomId:l,storageInstanceId:i}));if(!e){if((0,R.V)(t)){(0,aT.L)("recently-used-characters-load-failed",(0,aI.s)(t.error)),c([]);return}c(t.data)}})(),()=>{e=!0}},t=[s,a,l,i],n[0]=l,n[1]=s,n[2]=a,n[3]=i,n[4]=e,n[5]=t):(e=n[4],t=n[5]),(0,m.useEffect)(e,t),o}(),c=(0,p.f)(t4.Q),d=rX.Y[function(e){let[t,...r]=e.map(aC);return void 0===t?rX.G.Text:r.every(e=>e===t)?t:rX.G.Text}(c)];if(null===o){let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(v.ModelPresetsSkeleton,{}),l[0]=e):e=l[0],e}let u=i?aH:aG;if(l[1]!==u||l[2]!==d||l[3]!==o){let r;l[5]!==u?(r=e=>"static"===e.kind?(0,t.jsx)(aZ,{preset:e.preset,View:u},e.preset.title):(0,t.jsx)(aQ,{characters:e.characters,View:u},aB),l[5]=u,l[6]=r):r=l[6],e=(0===o.length?d.map(aX):[...d.slice(0,-1).map(aX),{kind:"recently-used",characters:o}]).map(r),l[1]=u,l[2]=d,l[3]=o,l[4]=e}else e=l[4];let f=e;return l[7]===Symbol.for("react.memo_cache_sentinel")?(n=(0,a.f)("relative flex w-full shrink-0 items-center justify-center","min-h-0 flex-1","flex-col overflow-hidden py-4 md:py-6"),l[7]=n):n=l[7],l[8]!==i||l[9]!==f?(s=(0,t.jsx)("div",{className:n,children:i?(0,t.jsx)(tB.f,{className:"w-auto",children:(0,t.jsx)("section",{className:"grid grid-cols-2 gap-4",children:f})}):(0,t.jsx)(tB.f,{className:"w-full",children:(0,t.jsx)("div",{className:"grid w-full grid-cols-2 gap-2 px-3",children:f})})}),l[8]=i,l[9]=f,l[10]=s):s=l[10],s},()=>!0);var a0=e.i(272719);function a1(){let e,t=(0,r.c)(5),{isSignedIn:n,entity:s}=(0,a0.f)((0,er.f)(a2)),a=(0,am.f)(),l=(0,eT.S)().getModelInfoByVariantSlug;return t[0]!==s?.default_text_model||t[1]!==l||t[2]!==n||t[3]!==a?(e=e=>{(0,t7.m)({presetTitle:(0,tT.M)(e.title)}),S.z.sendMessage({payload:{roomId:(0,rl.f)(),isSignedIn:!!n,content:e.prompt,attachments:[],defaultModelSlug:s?.default_text_model??null},dependencies:{router:a,getModelInfoByVariantSlug:l}})},t[0]=s?.default_text_model,t[1]=l,t[2]=n,t[3]=a,t[4]=e):e=t[4],e}function a2(e){return{isSignedIn:e.isSignedIn,entity:e.entity}}function a3(e){let n,s,i,o,c,d,m,u,f,h=(0,r.c)(24),{preset:x,className:p}=e,g=(0,r$.f)(),v=a1();return h[0]!==x||h[1]!==v?(n=()=>v(x),h[0]=x,h[1]=v,h[2]=n):n=h[2],h[3]!==p?(s=(0,a.f)("relative flex h-16 w-full max-w-screen-4xl flex-col items-start justify-center overflow-hidden hover:bg-card-hover",p),h[3]=p,h[4]=s):s=h[4],h[5]!==g||h[6]!==x.title?(i=g(x.title),h[5]=g,h[6]=x.title,h[7]=i):i=h[7],h[8]!==i?(o=(0,t.jsx)(nI.v,{className:"w-40 truncate text-left",children:i}),h[8]=i,h[9]=o):o=h[9],h[10]!==g||h[11]!==x.description?(c=g(x.description),h[10]=g,h[11]=x.description,h[12]=c):c=h[12],h[13]!==c?(d=(0,t.jsx)(nI.u,{className:"w-40 truncate text-left",children:c}),h[13]=c,h[14]=d):d=h[14],h[15]!==o||h[16]!==d?(m=(0,t.jsxs)(nI.O,{className:"p-4",children:[o,d]}),h[15]=o,h[16]=d,h[17]=m):m=h[17],h[18]!==s||h[19]!==m?(u=(0,t.jsx)(nI.N,{className:s,children:m}),h[18]=s,h[19]=m,h[20]=u):u=h[20],h[21]!==n||h[22]!==u?(f=(0,t.jsx)(l.Button,{type:"button",variant:"ghost",className:"h-auto p-0 w-auto shrink-0 rounded-lg text-left hover:bg-transparent",onClick:n,children:u}),h[21]=n,h[22]=u,h[23]=f):f=h[23],f}function a4(e){let n,s,a,l,i,o,c=(0,r.c)(17),{preset:d}=e,m=(0,r$.f)(),u=a1();return c[0]!==d||c[1]!==u?(n=()=>u(d),c[0]=d,c[1]=u,c[2]=n):n=c[2],c[3]!==m||c[4]!==d.title?(s=m(d.title),c[3]=m,c[4]=d.title,c[5]=s):s=c[5],c[6]!==s?(a=(0,t.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:s}),c[6]=s,c[7]=a):a=c[7],c[8]!==m||c[9]!==d.description?(l=m(d.description),c[8]=m,c[9]=d.description,c[10]=l):l=c[10],c[11]!==l?(i=(0,t.jsx)("span",{className:"line-clamp-2 text-xs text-muted-foreground",children:l}),c[11]=l,c[12]=i):i=c[12],c[13]!==n||c[14]!==a||c[15]!==i?(o=(0,t.jsxs)(az,{onClick:n,className:"gap-0.5",children:[a,i]}),c[13]=n,c[14]=a,c[15]=i,c[16]=o):o=c[16],o}function a5(){let e,n,s,l,i=(0,r.c)(16),o=(0,_.x)(),{scrollRef:c,maskClassName:d,updateScrollStatus:u}=function(){var e,t;let n,s,a,l,i,o=(0,r.c)(12),[c,d]=(0,m.useState)(null),[u,f]=(0,m.useState)(!1),[h,x]=(0,m.useState)(!0);o[0]!==c?(n=()=>{if(!c)return;let e=c.scrollLeft>0,t=c.scrollLeft+c.clientWidth{if(!c)return;p();let e=new ResizeObserver(()=>p());return e.observe(c),()=>e.disconnect()},a=[c,p],o[2]=c,o[3]=p,o[4]=s,o[5]=a):(s=o[4],a=o[5]),(0,m.useEffect)(s,a),o[6]!==h||o[7]!==u?(e=u,t=h,l=e&&t?"carousel-fade-both":t?"carousel-fade-right":e?"carousel-fade-left":"",o[6]=h,o[7]=u,o[8]=l):l=o[8],o[9]!==l||o[10]!==p?(i={scrollRef:d,maskClassName:l,updateScrollStatus:p},o[9]=l,o[10]=p,o[11]=i):i=o[11],i}();if(!o){let e,r,n,s;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.f)("grid grid-flow-col grid-rows-2 auto-cols-[10.5rem]","gap-2 overflow-x-auto px-3 scrollbar-hide"),r=rX.q.map(a7),i[0]=e,i[1]=r):(e=i[0],r=i[1]),i[2]!==c||i[3]!==u?(n=(0,t.jsx)("div",{ref:c,onScroll:u,className:e,children:r},"mobile-preset-grid"),i[2]=c,i[3]=u,i[4]=n):n=i[4],i[5]!==d||i[6]!==n?(s=(0,t.jsx)(tB.f,{className:"w-full",children:(0,t.jsx)("div",{className:d,children:n})}),i[5]=d,i[6]=n,i[7]=s):s=i[7],s}return i[8]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.f)("flex gap-4 overflow-x-auto scrollbar-hide","px-3"),i[8]=e):e=i[8],i[9]===Symbol.for("react.memo_cache_sentinel")?(n=rX.q.map(a6),i[9]=n):n=i[9],i[10]!==c||i[11]!==u?(s=(0,t.jsx)("div",{ref:c,className:e,onScroll:u,children:n},"desktop-preset-row"),i[10]=c,i[11]=u,i[12]=s):s=i[12],i[13]!==d||i[14]!==s?(l=(0,t.jsx)("div",{className:"w-full",children:(0,t.jsx)("div",{className:d,children:s})}),i[13]=d,i[14]=s,i[15]=l):l=i[15],l}function a6(e,r){return(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(a3,{preset:e,className:"bg-muted border-transparent"})},r)}function a7(e){return(0,t.jsx)(a4,{preset:e},e.title)}let a8=(0,m.memo)(()=>(0,t.jsx)("div",{className:(0,a.f)("relative flex w-full items-center justify-start shrink-0","max-w-4xl mx-auto overflow-hidden","pt-2 md:pt-3"),children:(0,t.jsx)(a5,{})}),()=>!0);var a9=e.i(76429),le=e.i(19773),lt=e.i(123215);let lr={models:le.d,preset:le.d,presetName:le.d,presetModel:le.d,presetRouting:le.Z,room:le.d},ln=(0,le.C)(lr);function ls(){let e,n,s,a,l,i=(0,r.c)(9),o=(0,p.f)(la),c=(0,lt.f)(),{isSignedIn:d}=(0,tZ.f)(),[u]=(0,le.i)(lr);return i[0]!==d?(e=()=>{!1===d&&(0,a9.e)()},n=[d],i[0]=d,i[1]=e,i[2]=n):(e=i[1],n=i[2]),(0,m.useEffect)(e,n),i[3]!==c||i[4]!==u||i[5]!==o?(s=()=>{if(o){let e=ln("/chat",u);c({forceRedirectUrl:e,signInForceRedirectUrl:e}),S.z.setShowSignUpModal({payload:{show:!1}})}},a=[o,c,u],i[3]=c,i[4]=u,i[5]=o,i[6]=s,i[7]=a):(s=i[6],a=i[7]),(0,m.useEffect)(s,a),i[8]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(t.Fragment,{}),i[8]=l):l=i[8],l}function la(e){return e.showSignUpModal}let ll=(0,m.memo)(()=>(0,t.jsx)(m.Suspense,{fallback:null,children:(0,t.jsx)(ls,{})}),()=>!0);var li=e.i(601608),lo=e.i(935084),lc=e.i(524268),ld=e.i(797913),lm=e.i(362942),lu=e.i(649301);function lf(){let e,n,s,a,l,i,o,c,d,u,f,g=(0,r.c)(24),v=(0,h.f)(),b=(0,am.f)(),[j,y]=(0,m.useState)(!1),w=(0,p.f)(x.M),N=(0,m.useRef)(w),_=(0,ld.N)(lh);g[0]!==w?(e=()=>{w!==N.current&&(N.current=w,y(!1))},n=[w],g[0]=w,g[1]=e,g[2]=n):(e=g[1],n=g[2]),(0,m.useEffect)(e,n),g[3]!==_||g[4]!==j?(s=()=>{j||_()},a=[j,_],g[3]=_,g[4]=j,g[5]=s,g[6]=a):(s=g[5],a=g[6]),(0,m.useEffect)(s,a),g[7]!==b?(l=async()=>{let e=await S.z.createChatroom({payload:{}});b.push(`?room=${e.id}`)},g[7]=b,g[8]=l):l=g[8];let k=l;return g[9]!==v?(i=v("Chats"),g[9]=v,g[10]=i):i=g[10],g[11]!==v?(o=v("Open chats"),g[11]=v,g[12]=o):o=g[12],g[13]!==v?(c=v("New chat"),g[13]=v,g[14]=c):c=g[14],g[15]!==k||g[16]!==c?(d={label:c,icon:lo.f,onClick:k},g[15]=k,g[16]=c,g[17]=d):d=g[17],g[18]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(lu.T,{children:(0,t.jsx)(lm.f,{})}),g[18]=u):u=g[18],g[19]!==j||g[20]!==i||g[21]!==o||g[22]!==d?(f=(0,t.jsx)(lc.f,{title:i,triggerAriaLabel:o,isOpen:j,onOpenChange:y,newAction:d,children:u}),g[19]=j,g[20]=i,g[21]=o,g[22]=d,g[23]=f):f=g[23],f}function lh(e){return e.exitSelectionMode}var lx=e.i(47354),lp=e.i(303125),lg=e.i(353209),lv=e.i(194215);let lb=m.forwardRef(function({title:e,titleId:t,...r},n){return m.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?m.createElement("title",{id:t},e):null,m.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.217 10.907a2.25 2.25 0 1 0 0 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186 9.566-5.314m-9.566 7.5 9.566 5.314m0 0a2.25 2.25 0 1 0 3.935 2.186 2.25 2.25 0 0 0-3.935-2.186Zm0-12.814a2.25 2.25 0 1 0 3.933-2.185 2.25 2.25 0 0 0-3.933 2.185Z"}))}),lj=m.forwardRef(function({title:e,titleId:t,...r},n){return m.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},r),e?m.createElement("title",{id:t},e):null,m.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M22 10.5h-6m-2.25-4.125a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0ZM4 19.235v-.11a6.375 6.375 0 0 1 12.75 0v.109A12.318 12.318 0 0 1 10.374 21c-2.331 0-4.512-.645-6.374-1.766Z"}))});var ly=e.i(609623),lw=e.i(857754),lN=e.i(192668),l_=e.i(168639);let lS=e=>{let n,s,l,i,o,c,d,m=(0,r.c)(12);return m[0]!==e?({ref:s,...n}=e,m[0]=e,m[1]=n,m[2]=s):(n=m[1],s=m[2]),m[3]!==n.className?(l=(0,a.f)("size-4",n.className),m[3]=n.className,m[4]=l):l=m[4],m[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(ea.T,{children:(0,t.jsx)("title",{children:"Markdown Icon"})}),o=(0,t.jsx)("rect",{width:"198",height:"118",x:"5",y:"5",ry:"10",strokeWidth:"10"}),c=(0,t.jsx)("path",{d:"M30 98V30h20l20 25 20-25h20v68H90V59L70 84 50 59v39zm125 0l-30-33h20V30h20v35h20z",stroke:"currentColor",fill:"currentColor"}),m[5]=i,m[6]=o,m[7]=c):(i=m[5],o=m[6],c=m[7]),m[8]!==n||m[9]!==s||m[10]!==l?(d=(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 208 128",fill:"none",stroke:"currentColor",ref:s,className:l,...n,children:[i,o,c]}),m[8]=n,m[9]=s,m[10]=l,m[11]=d):d=m[11],d};var lk=e.i(735729),lC=e.i(860658),lz=e.i(452142),lI=e.i(782059),lT=e.i(443143);let lM=(0,e.i(429332).default)(()=>e.A(899308).then(e=>e.CharacterImportModal),{loadableGenerated:{modules:[650172]}}),lE=e=>{let n,s,i,o,c,d,u,f=(0,r.c)(18),{className:x,disabled:p,onOpenModal:g}=e,v=void 0===x?"":x,b=(0,h.f)(),[j,y]=(0,m.useState)(!1);return f[0]!==b?(n=b("Import Character"),f[0]=b,f[1]=n):n=f[1],f[2]!==v?(s=(0,a.f)("w-full",v),f[2]=v,f[3]=s):s=f[3],f[4]!==g?(i=()=>{g?g():y(!0)},f[4]=g,f[5]=i):i=f[5],f[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(lI.f,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Import Character"})]}),f[6]=o):o=f[6],f[7]!==p||f[8]!==n||f[9]!==s||f[10]!==i?(c=(0,t.jsx)(l.Button,{variant:"ghost",size:"sm",align:"start",title:n,className:s,onClick:i,disabled:p,children:o}),f[7]=p,f[8]=n,f[9]=s,f[10]=i,f[11]=c):c=f[11],f[12]!==j||f[13]!==g?(d=!g&&(0,t.jsx)(lA,{isOpen:j,setIsOpen:y}),f[12]=j,f[13]=g,f[14]=d):d=f[14],f[15]!==c||f[16]!==d?(u=(0,t.jsxs)(t.Fragment,{children:[c,d]}),f[15]=c,f[16]=d,f[17]=u):u=f[17],u};function lA(e){let n,s=(0,r.c)(2);return(0,lT.f)(e.isOpen)?(s[0]!==e?(n=(0,t.jsx)(lM,{...e}),s[0]=e,s[1]=n):n=s[1],n):null}var lR=e.i(66237),lP=e.i(996116),lD=e.i(564353),lF=e.i(591397);function lV(){let e,n,s,a,l=(0,r.c)(10),i=(0,nB.useItemStore)(s5.h),o=(0,nB.useItemStore)(s5.S),c=(0,p.f)(lO)??void 0;l[0]!==c?(e=function(e){if(void 0!==e&&lR.f.test(e))return e.length>20?e.slice(-20):e}(c),l[0]=c,l[1]=e):e=l[1];let d=e,m=void 0===d?null:`${lP.G}${d}`,u=i?o??m:null;l[2]!==u?(n=(0,lD.C)(u),l[2]=u,l[3]=n):n=l[3];let{data:f,isLoading:h,error:x}=(0,tH.f)(n);if(!i||null===u)return null;l[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"whitespace-nowrap text-button font-medium text-foreground",children:"Session files"})}),l[4]=s):s=l[4];let g=null!==x;return l[5]!==u||l[6]!==f||l[7]!==h||l[8]!==g?(a=(0,t.jsx)("div",{className:"mt-1 border-t border-border/60 px-3 pb-1.5 pt-2",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[s,(0,t.jsx)(lL,{containerId:u,files:f,isLoading:h,hasError:g})]})}),l[5]=u,l[6]=f,l[7]=h,l[8]=g,l[9]=a):a=l[9],a}function lO(e){return e.currentRoomId}function lL(e){let n,s,a=(0,r.c)(10),{containerId:l,files:i,isLoading:o,hasError:c}=e;if(o){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading files…"})}),a[0]=e):e=a[0],e}if(c){let e;return a[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Couldn't load session files."})}),a[1]=e):e=a[1],e}if(!i||0===i.length){let e;return a[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"No files in this session yet."})}),a[2]=e):e=a[2],e}if(a[3]!==l||a[4]!==i){let e;a[6]!==l?(e=e=>({container_id:l,file_id:e.id,filename:e.path,bytes:e.bytes}),a[6]=l,a[7]=e):e=a[7],n=i.map(e),a[3]=l,a[4]=i,a[5]=n}else n=a[5];return a[8]!==n?(s=(0,t.jsx)(lF.f,{files:n,source:"session_panel"}),a[8]=n,a[9]=s):s=a[9],s}function lB(){let e,n,s,i,o,c,d,u,f,x,p,g,v,b,j,y,w,N=(0,r.c)(30),_=(0,h.f)(),k=(0,am.f)(),[C,z]=(0,m.useState)(!1),[I,M]=(0,m.useState)(!1);N[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{z(!1),M(!0)},N[0]=e):e=N[0];let E=e;N[1]!==_||N[2]!==k?(n=()=>{let e=(0,rl.f)();e?(S.z.duplicateRoom({payload:{sourceRoomId:e},dependencies:{router:k}}),z(!1)):(0,T.c)({title:_("Could not duplicate room"),description:_("No active chat to duplicate."),variant:"destructive"})},N[1]=_,N[2]=k,N[3]=n):n=N[3];let A=n;return N[4]!==_?(s=_("Room settings"),N[4]=_,N[5]=s):s=N[5],N[6]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(lg.f,{className:"size-5"}),N[6]=i):i=N[6],N[7]!==s?(o=(0,t.jsx)(eI.J,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon","aria-label":s,children:i})}),N[7]=s,N[8]=o):o=N[8],N[9]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.f)("w-min min-w-60 rounded-lg p-1.5"),N[9]=c):c=N[9],N[10]===Symbol.for("react.memo_cache_sentinel")?(d=()=>z(!1),N[10]=d):d=N[10],N[11]!==_?(u=_("Duplicate Chat"),N[11]=_,N[12]=u):u=N[12],N[13]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsxs)("span",{className:"flex w-full items-center justify-between",children:[(0,t.jsxs)(lH,{children:[(0,t.jsx)(t9.f,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Duplicate Room"})]}),(0,t.jsx)(lG,{shortcut:"Y"})]}),N[13]=f):f=N[13],N[14]!==A||N[15]!==u?(x=(0,t.jsx)(lU,{className:"h-auto w-full flex-col pt-0",buttonClassName:"w-full justify-between",onClose:d,onImportCharacter:E,children:(0,t.jsx)(l.Button,{variant:"ghost",size:"sm",title:u,className:"w-full",onClick:A,children:f})}),N[14]=A,N[15]=u,N[16]=x):x=N[16],N[17]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(lW,{}),g=(0,t.jsx)(l$,{}),v=(0,t.jsx)(lq,{}),b=(0,t.jsx)(lV,{}),N[17]=p,N[18]=g,N[19]=v,N[20]=b):(p=N[17],g=N[18],v=N[19],b=N[20]),N[21]!==x?(j=(0,t.jsxs)(eI.T,{side:"bottom",align:"end",positionerClassName:"z-popover",collisionPadding:8,className:c,children:[x,p,g,v,b]}),N[21]=x,N[22]=j):j=N[22],N[23]!==I?(y=(0,t.jsx)(lA,{isOpen:I,setIsOpen:M}),N[23]=I,N[24]=y):y=N[24],N[25]!==C||N[26]!==j||N[27]!==y||N[28]!==o?(w=(0,t.jsxs)(eI.V,{open:C,onOpenChange:z,children:[o,j,y]}),N[25]=C,N[26]=j,N[27]=y,N[28]=o,N[29]=w):w=N[29],w}function lq(){let e,n,s,l=(0,r.c)(8),i=(0,h.f)(),o=(0,r$.f)(),[c,d]=(0,lC.w)();return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"whitespace-nowrap text-button font-medium text-foreground",children:"Message color"})}),l[0]=e):e=l[0],l[1]!==c||l[2]!==i||l[3]!==o||l[4]!==d?(n=lC.q.map(e=>{let r=(e.value??void 0)===c;return(0,t.jsx)("button",{type:"button","aria-label":i("{label} bubble color",{label:o(e.label)}),"aria-pressed":r,title:o(e.label),className:(0,a.f)("size-3.5 rounded-full transition-shadow",e.swatchClass,r?"ring-2 ring-ring ring-offset-1 ring-offset-background":"hover:ring-1 hover:ring-border"),onClick:()=>d(e.value)},e.key)}),l[1]=c,l[2]=i,l[3]=o,l[4]=d,l[5]=n):n=l[5],l[6]!==n?(s=(0,t.jsx)("div",{className:"mt-1 border-t border-border/60 px-3 pb-1.5 pt-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[e,(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:n})]})}),l[6]=n,l[7]=s):s=l[7],s}function lW(){let e,n,s,a,l=(0,r.c)(10),i=(0,h.f)(),o=(0,l_.f)(),[c,d]=(0,lk.f)();return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"whitespace-nowrap text-button font-medium text-foreground",children:"Always expand messages"})}),l[0]=e):e=l[0],l[1]!==o||l[2]!==d?(n=e=>{d(e),o.capture("toggle_always_expand_messages",{enabled:e})},l[1]=o,l[2]=d,l[3]=n):n=l[3],l[4]!==i?(s=i("Always expand messages"),l[4]=i,l[5]=s):s=l[5],l[6]!==c||l[7]!==n||l[8]!==s?(a=(0,t.jsx)("div",{className:"mt-1 border-t border-border/60 px-3 pb-1.5 pt-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[e,(0,t.jsx)(ro.Z,{size:"sm",checked:c,onCheckedChange:n,"aria-label":s})]})}),l[6]=c,l[7]=n,l[8]=s,l[9]=a):a=l[9],a}function l$(){let e,n,s,a,l=(0,r.c)(10),i=(0,h.f)(),o=(0,l_.f)(),[c,d]=(0,lz.f)();return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ea.T,{children:(0,t.jsx)("span",{className:"whitespace-nowrap text-button font-medium text-foreground",children:"Show metrics inline"})}),l[0]=e):e=l[0],l[1]!==o||l[2]!==d?(n=e=>{d(e),o.capture("toggle_show_metrics_inline",{enabled:e})},l[1]=o,l[2]=d,l[3]=n):n=l[3],l[4]!==i?(s=i("Show metrics inline"),l[4]=i,l[5]=s):s=l[5],l[6]!==c||l[7]!==n||l[8]!==s?(a=(0,t.jsx)("div",{className:"px-3 pb-1.5 pt-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[e,(0,t.jsx)(ro.Z,{size:"sm",checked:c,onCheckedChange:n,"aria-label":s})]})}),l[6]=c,l[7]=n,l[8]=s,l[9]=a):a=l[9],a}let lU=e=>{let n,s,i,o,c,d,m,u,f,g,v,b,j,y,w,N,_,k,C,z,I,T,M,E,A,R,P,D,F,V,O,L,B,q,W,$=(0,r.c)(85),U=(0,h.f)(),{getEndpointDisplayName:H}=(0,eT.S)(),G=(0,p.f)(x.B),{copyToClipboard:K,isCopied:J}=(0,lN.f)();$[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,rl.f)(),$[0]=n):n=$[0];let Z=n;if($[1]!==G){let e=(0,aS.H)(Object.values(G??{}).map(lK)).filter(lJ).join(",");s=(0,lw.A)({models:e,room:void 0}).toString(),$[1]=G,$[2]=s}else s=$[2];let Q=s;$[3]!==K||$[4]!==e||$[5]!==Q?(i=async()=>{await K(Q),(0,t7.M)(),e.onClose?.()},$[3]=K,$[4]=e,$[5]=Q,$[6]=i):i=$[6];let X=i;$[7]!==e.className?(o=(0,a.f)("flex h-12 w-full overflow-auto pt-2","gap-0.5",e.className),$[7]=e.className,$[8]=o):o=$[8],$[9]!==U?(c=U("Export Chat"),$[9]=U,$[10]=c):c=$[10],$[11]!==e?(d=()=>{S.z.exportData({payload:{roomId:Z??""}}),e.onClose?.()},$[11]=e,$[12]=d):d=$[12],$[13]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsxs)(lH,{children:[(0,t.jsx)(tp.f,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Export"})]}),$[13]=m):m=$[13],$[14]!==e.buttonClassName||$[15]!==c||$[16]!==d?(u=(0,t.jsx)(l.Button,{variant:"ghost",size:"sm",title:c,className:e.buttonClassName,onClick:d,children:m}),$[14]=e.buttonClassName,$[15]=c,$[16]=d,$[17]=u):u=$[17],$[18]!==U?(f=U("Import Chat"),$[18]=U,$[19]=f):f=$[19],$[20]!==e?(g=()=>{S.z.importData({payload:{roomId:Z??""}}),e.onClose?.()},$[20]=e,$[21]=g):g=$[21],$[22]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsxs)(lH,{children:[(0,t.jsx)(lx.f,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Import"})]}),$[22]=v):v=$[22],$[23]!==e.buttonClassName||$[24]!==f||$[25]!==g?(b=(0,t.jsx)(l.Button,{variant:"ghost",size:"sm",title:f,className:e.buttonClassName,onClick:g,children:v}),$[23]=e.buttonClassName,$[24]=f,$[25]=g,$[26]=b):b=$[26],$[27]!==U?(j=U("Export Markdown"),$[27]=U,$[28]=j):j=$[28],$[29]!==H||$[30]!==U||$[31]!==e?(y=()=>{S.z.exportMarkdown({payload:{roomId:Z??""},dependencies:{getEndpointDisplayName:H,gt:U}}),e.onClose?.()},$[29]=H,$[30]=U,$[31]=e,$[32]=y):y=$[32],$[33]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsxs)(lH,{children:[(0,t.jsx)(lS,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Get Markdown"})]}),$[33]=w):w=$[33],$[34]!==e.buttonClassName||$[35]!==j||$[36]!==y?(N=(0,t.jsx)(l.Button,{variant:"ghost",size:"sm",title:j,className:e.buttonClassName,onClick:y,children:w}),$[34]=e.buttonClassName,$[35]=j,$[36]=y,$[37]=N):N=$[37],$[38]!==U?(_=U("Share Models"),$[38]=U,$[39]=_):_=$[39],$[40]===Symbol.for("react.memo_cache_sentinel")?(k=(0,t.jsx)(lb,{className:"size-4"}),C=(0,t.jsx)(lp.f,{className:"size-4"}),$[40]=k,$[41]=C):(k=$[40],C=$[41]),$[42]!==J?(z=(0,t.jsx)(ly.f,{active:J,from:k,to:C}),$[42]=J,$[43]=z):z=$[43],$[44]===Symbol.for("react.memo_cache_sentinel")?(I=(0,t.jsx)(ea.T,{children:"Share Models"}),$[44]=I):I=$[44],$[45]!==z?(T=(0,t.jsxs)(lH,{children:[z,I]}),$[45]=z,$[46]=T):T=$[46],$[47]!==X||$[48]!==e.buttonClassName||$[49]!==_||$[50]!==T?(M=(0,t.jsx)(l.Button,{variant:"ghost",size:"sm",title:_,className:e.buttonClassName,onClick:X,children:T}),$[47]=X,$[48]=e.buttonClassName,$[49]=_,$[50]=T,$[51]=M):M=$[51],$[52]!==e.buttonClassName||$[53]!==e.onImportCharacter?(E=(0,t.jsx)(lE,{className:e.buttonClassName,onOpenModal:e.onImportCharacter}),$[52]=e.buttonClassName,$[53]=e.onImportCharacter,$[54]=E):E=$[54];let Y=e.children;return $[55]!==U?(A=U("Clear Models"),$[55]=U,$[56]=A):A=$[56],$[57]!==e?(R=()=>{S.z.clearCharacters({payload:{roomId:Z??""}}),e.onClose?.()},$[57]=e,$[58]=R):R=$[58],$[59]===Symbol.for("react.memo_cache_sentinel")?(P=(0,t.jsxs)(lH,{children:[(0,t.jsx)(lj,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Clear Models"})]}),D=(0,t.jsx)(lG,{shortcut:"X"}),$[59]=P,$[60]=D):(P=$[59],D=$[60]),$[61]!==e.buttonClassName||$[62]!==A||$[63]!==R?(F=(0,t.jsxs)(l.Button,{variant:"ghost",size:"sm",title:A,className:e.buttonClassName,onClick:R,children:[P,D]}),$[61]=e.buttonClassName,$[62]=A,$[63]=R,$[64]=F):F=$[64],$[65]!==U?(V=U("Clear Chat"),$[65]=U,$[66]=V):V=$[66],$[67]!==e?(O=()=>{S.z.clearAllMessages({payload:{roomId:Z??""}}),e.onClose?.()},$[67]=e,$[68]=O):O=$[68],$[69]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsxs)(lH,{children:[(0,t.jsx)(lv.f,{className:"size-4"}),(0,t.jsx)(ea.T,{children:"Clear Chat"})]}),B=(0,t.jsx)(lG,{shortcut:"⌫"}),$[69]=L,$[70]=B):(L=$[69],B=$[70]),$[71]!==e.buttonClassName||$[72]!==V||$[73]!==O?(q=(0,t.jsxs)(l.Button,{variant:"ghost",size:"sm",title:V,className:e.buttonClassName,onClick:O,children:[L,B]}),$[71]=e.buttonClassName,$[72]=V,$[73]=O,$[74]=q):q=$[74],$[75]!==e.children||$[76]!==b||$[77]!==N||$[78]!==M||$[79]!==E||$[80]!==F||$[81]!==o||$[82]!==q||$[83]!==u?(W=(0,t.jsxs)("div",{className:o,children:[u,b,N,M,E,Y,F,q]}),$[75]=e.children,$[76]=b,$[77]=N,$[78]=M,$[79]=E,$[80]=F,$[81]=o,$[82]=q,$[83]=u,$[84]=W):W=$[84],W};function lH(e){let n,s=(0,r.c)(2),{children:a}=e;return s[0]!==a?(n=(0,t.jsx)("span",{className:"flex items-center gap-2",children:a}),s[0]=a,s[1]=n):n=s[1],n}function lG(e){let n,s,a,l=(0,r.c)(4),{shortcut:i}=e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(tq.f,{children:"⌘"}),s=(0,t.jsx)(tq.f,{children:"⇧"}),l[0]=n,l[1]=s):(n=l[0],s=l[1]),l[2]!==i?(a=(0,t.jsxs)("span",{className:"flex items-center gap-0.5",children:[n,s,(0,t.jsx)(tq.f,{children:i})]}),l[2]=i,l[3]=a):a=l[3],a}function lK(e){return e.modelInfo?(0,eS.i)(e.modelInfo):e.model}function lJ(e){return!!e}var lZ=e.i(758427),lQ=e.i(654678);let lX=()=>{let e,n,s,a,i,o,c,d=(0,r.c)(12),m=(0,am.f)(),u=(0,p.f)(x.s);d[0]!==m?(e=()=>m.refresh(),d[0]=m,d[1]=e):e=d[1];let f=e;return d[2]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(lQ.f,{className:"h-8 w-8 text-faint"}),d[2]=n):n=d[2],d[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ea.T,{children:(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("p",{className:"text-base font-medium text-foreground",children:"This chat could not be loaded"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"A refresh usually fixes this. If the problem persists, please contact support."})]})}),d[3]=s):s=d[3],d[4]!==u?(a=u&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex justify-between items-end",children:[(0,t.jsx)(ea.T,{children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Error details:"})}),(0,t.jsx)(lZ.f,{text:u})]}),(0,t.jsx)("div",{className:"relative w-full rounded-md border bg-background p-3 text-left text-xs text-muted-foreground max-h-96 overflow-y-auto",children:(0,t.jsx)("p",{className:"font-mono break-all",children:u})})]}),d[4]=u,d[5]=a):a=d[5],d[6]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(ea.T,{children:"Refresh Page"}),d[6]=i):i=d[6],d[7]!==f?(o=(0,t.jsx)(l.Button,{onClick:f,variant:"outline",size:"sm",children:i}),d[7]=f,d[8]=o):o=d[8],d[9]!==a||d[10]!==o?(c=(0,t.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4 text-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 max-w-sm",children:[n,s,a,o]})}),d[9]=a,d[10]=o,d[11]=c):c=d[11],c};var lY=e.i(412217),l0=e.i(136004);let l1="conversation-search-highlight";function l2(){"u">typeof CSS&&CSS.highlights&&CSS.highlights.delete(l1)}let l3=[lY.Y,"button",".katex"].join(", ");var l4=e.i(733205),l5=e.i(907781),l6=e.i(329343),l7=e.i(674896),l8=e.i(81),l9=e.i(376934),ie=e.i(578199);function it(e){return e.storageInstanceId}function ir(){let e,n=(0,r.c)(2),s=(()=>{let e,t,n,s,a=(0,r.c)(9),{entity:l}=(0,t$.useEntity)(),i=(0,l4.S)(ia);a[0]!==i?(e=()=>{i()},t=[i],a[0]=i,a[1]=e,a[2]=t):(e=a[1],t=a[2]),(0,m.useEffect)(e,t);let o=(0,l5.f)(),c=(0,p.f)(il);a[3]!==o||a[4]!==c?(n={expectedInstanceId:o,hydratedInstanceId:c},a[3]=o,a[4]=c,a[5]=n):n=a[5],(0,l6.f)(n);let d=l?.data?.default_text_model??rX.I;return a[6]!==d||a[7]!==o?(s={expectedInstanceId:o,defaultModelSlug:d},a[6]=d,a[7]=o,a[8]=s):s=a[8],s})();return n[0]!==s?(e=(0,t.jsx)(m.Suspense,{fallback:null,children:(0,t.jsx)(is,{...s})}),n[0]=s,n[1]=e):e=n[1],e}function is(e){let t,n,s,a=(0,r.c)(11),{expectedInstanceId:l,defaultModelSlug:i}=e,{getModelInfoByVariantSlug:o}=(0,eT.S)(),c=(0,tW.R)("chromeGeminiNano");a[0]!==c?(t=(0,tG.w)(c),a[0]=c,a[1]=t):t=a[1];let d=t,{modelInfos:u,isSettled:f}=t2();a[2]!==o||a[3]!==u||a[4]!==d?(n=e=>{if((0,tK.C)(e))return u.find(t=>t.slug===e)??null;if((0,tG.U)(e))return d?(0,tG.A)():null;let t=o(e);if(!t)return null;let r=t.endpoint?{...t.endpoint,model:{...t.endpoint.model,default_stops:[...t.endpoint.model.default_stops]}}:null;return{...t,default_stops:[...t.default_stops],endpoint:r}},a[2]=o,a[3]=u,a[4]=d,a[5]=n):n=a[5];let h=n;return a[6]!==i||a[7]!==l||a[8]!==f||a[9]!==h?(s={expectedInstanceId:l,getModelInfoByVariantSlug:h,defaultModelSlug:i,isInternRosterSettled:f},a[6]=i,a[7]=l,a[8]=f,a[9]=h,a[10]=s):s=a[10],(e=>{let t,n,s,a,l,i,o,c=(0,r.c)(24),{expectedInstanceId:d,getModelInfoByVariantSlug:u,defaultModelSlug:f,isInternRosterSettled:h}=e,x=(0,am.f)();c[0]===Symbol.for("react.memo_cache_sentinel")?(t={room:le.d,models:le.d,preset:le.d,presetName:le.d,presetModel:le.d,presetRouting:le.Z.withDefault(!1),tool:le.d},c[0]=t):t=c[0];let[g]=(0,le.i)(t),{room:v,models:b,preset:j,presetName:y,presetModel:w,presetRouting:N,tool:_}=g,k=(0,p.f)(it),C=null!==k&&k===d,z=(0,m.useRef)(null),I=(0,m.useRef)(null);c[1]!==C||c[2]!==v||c[3]!==x?(n=()=>{C&&function({roomIdFromUrl:e},{router:t}){let{currentRoomId:r,rooms:n}=p.f.getState();if(e!==r&&S.z.closeArtifactView(),!e)return S.z.setCurrentRoom({payload:{roomId:null}});if(!Object.hasOwn(n,e))return t.replace((0,l7.P)(window.location.pathname,l7.L.Chat));S.z.setCurrentRoom({payload:{roomId:e}}),S.z.setPendingCharacters({payload:{characters:null}});let{pendingMessageSource:s}=p.f.getState();"activity-replay"!==s&&S.z.setPendingMessage({payload:{message:null,source:null}})}({roomIdFromUrl:v},{router:x})},s=[v,C,x],c[1]=C,c[2]=v,c[3]=x,c[4]=n,c[5]=s):(n=c[4],s=c[5]),(0,m.useLayoutEffect)(n,s),c[6]!==f||c[7]!==u||c[8]!==k||c[9]!==h||c[10]!==C||c[11]!==b||c[12]!==j||c[13]!==w||c[14]!==y||c[15]!==N||c[16]!==v?(a=()=>{if(!C||v)return;let e={roomIdFromUrl:v,modelsFromUrl:b,presetFromUrl:j,presetNameFromUrl:y,presetModelFromUrl:w,presetRoutingFromUrl:N},t=JSON.stringify({urlParams:e,defaultModelSlug:!j||w||b?null:f,hydratedInstanceId:k});if(z.current===t)return;let{didResolveAllModels:r}=function(e,{getModelInfoByVariantSlug:t,defaultModelSlug:r,isInternRosterSettled:n}){if(!(e.modelsFromUrl||e.presetFromUrl||e.presetModelFromUrl)){let{pendingMessageSource:e}=p.f.getState();return"activity-replay"!==e&&(S.z.setPendingCharacters({payload:{characters:null}}),S.z.setPendingMessage({payload:{message:null,source:null}})),{didResolveAllModels:!0}}let s=[];e.presetModelFromUrl?s=[e.presetModelFromUrl]:e.modelsFromUrl?s=e.modelsFromUrl.split(","):e.presetFromUrl&&(s=[r]);let a=s.filter(e=>(0,tK.C)(e)&&null===t(e));if(a.length>0&&!n)return{didResolveAllModels:!1};let l=s.filter(e=>!a.includes(e)),i=(0,ak.f)({getModelInfoByVariantSlug:t,variantSlugs:l});e.presetFromUrl&&(i=Object.fromEntries(Object.entries(i).map(([t,r])=>[t,(0,tK.C)(r.model)?r:{...r,presetSlug:e.presetFromUrl??void 0,presetName:e.presetNameFromUrl?(0,l8.C)(e.presetNameFromUrl):void 0,isRoutingPreset:e.presetRoutingFromUrl||void 0}]))),(0,t7.v)({presetSlug:e.presetFromUrl??"",model:e.presetModelFromUrl??"",source:"url"});let o=Object.keys(i).length;return o>0&&S.z.setPendingCharacters({payload:{characters:i}}),{didResolveAllModels:o===l.length}}(e,{getModelInfoByVariantSlug:u,defaultModelSlug:f,isInternRosterSettled:h});z.current=r?t:null},l=[v,b,j,y,w,N,C,k,u,f,h],c[6]=f,c[7]=u,c[8]=k,c[9]=h,c[10]=C,c[11]=b,c[12]=j,c[13]=w,c[14]=y,c[15]=N,c[16]=v,c[17]=a,c[18]=l):(a=c[17],l=c[18]),(0,m.useEffect)(a,l),c[19]!==k||c[20]!==C||c[21]!==_?(i=()=>{if(!C)return;let e=JSON.stringify({toolFromUrl:_,hydratedInstanceId:k});if(I.current!==e){let t;I.current=e,null===(t=ie.T.find(e=>e.id===_)?.id??null)||(0,l9.p)(t,!0,{markAsUserPreference:!0})}},o=[_,C,k],c[19]=k,c[20]=C,c[21]=_,c[22]=i,c[23]=o):(i=c[22],o=c[23]),(0,m.useEffect)(i,o)})(s),null}function ia(e){return e.clearFilters}function il(e){return e.storageInstanceId}var ii=e.i(563456);function io(){let e,n,s,o,c,d,m,u,f,g,v,b,j,y,w,N=(0,r.c)(32),_=(0,h.f)(),S=(0,p.f)(x.e);N[0]!==_?(e=_("Zero Data Retention settings"),N[0]=_,N[1]=e):e=N[1],N[2]!==_?(n=_("Zero Data Retention"),N[2]=_,N[3]=n):n=N[3];let k=S&&"text-primary";N[4]!==k?(s=(0,a.f)("size-5 transition-colors",k),N[4]=k,N[5]=s):s=N[5],N[6]!==s?(o=(0,t.jsx)(rG,{className:s}),N[6]=s,N[7]=o):o=N[7],N[8]!==n||N[9]!==o?(c=(0,t.jsx)(i.Tooltip,{content:n,children:o}),N[8]=n,N[9]=o,N[10]=c):c=N[10],N[11]!==e||N[12]!==c?(d=(0,t.jsx)(eI.J,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon","aria-label":e,children:c})}),N[11]=e,N[12]=c,N[13]=d):d=N[13];let C=S&&"text-primary";return N[14]!==C?(m=(0,a.f)("size-4 transition-colors",C),N[14]=C,N[15]=m):m=N[15],N[16]!==m?(u=(0,t.jsx)(rG,{className:m}),N[16]=m,N[17]=u):u=N[17],N[18]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(ea.T,{children:"Require Zero Data Retention"}),N[18]=f):f=N[18],N[19]!==u?(g=(0,t.jsxs)(rC.f,{htmlFor:"toggle-zdr-all",variant:"field",className:"flex items-center gap-2 whitespace-nowrap",children:[u,f]}),N[19]=u,N[20]=g):g=N[20],N[21]!==S?(v=(0,t.jsx)(ro.Z,{id:"toggle-zdr-all",checked:S,onCheckedChange:ic}),N[21]=S,N[22]=v):v=N[22],N[23]!==g||N[24]!==v?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[g,v]}),N[23]=g,N[24]=v,N[25]=b):b=N[25],N[26]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(ea.T,{children:(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Only route to endpoints that never retain your prompts or completions. Applies to all models in this chat, including ones added later."," ",(0,t.jsx)(rS.f,{href:"/docs/guides/features/zdr",target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]})}),N[26]=j):j=N[26],N[27]!==b?(y=(0,t.jsx)(eI.T,{side:"bottom",align:"end",positionerClassName:"z-popover",collisionPadding:8,className:"w-80 rounded-lg p-3",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[b,j]})}),N[27]=b,N[28]=y):y=N[28],N[29]!==y||N[30]!==d?(w=(0,t.jsxs)(eI.V,{children:[d,y]}),N[29]=y,N[30]=d,N[31]=w):w=N[31],w}function ic(e){S.z.setRoomZdr({payload:{roomId:(0,rl.f)(),zdr:e}})}let id=()=>{let e,n,a=(0,r.c)(7),l=(0,p.f)(ih),i=(0,p.f)(ix),m=(0,ii.f)(),u=(0,j.f)(),f=(0,c.f)(s.J.Chatroom);if(u===b.u.Blocked){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(o.f,{surface:"chat",className:"fixed inset-x-0 bottom-0 top-[calc(var(--playground-nav-offset,var(--navbar-height))+var(--navbar-top,0px))]"}),a[0]=e):e=a[0],e}if(f===d.L.Blocked){let e;return a[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(y.WorkspaceCapabilityUnavailableState,{capability:s.J.Chatroom,className:"fixed inset-x-0 bottom-0 top-[calc(var(--playground-nav-offset,var(--navbar-height))+var(--navbar-top,0px))]"}),a[1]=e):e=a[1],e}if("failed"===i){let e;return a[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ir,{}),(0,t.jsx)(lX,{})]}),a[2]=e):e=a[2],e}if(null===l){let e;return a[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ir,{}),(0,t.jsx)(v.PlaygroundSkeleton,{})]}),a[3]=e):e=a[3],e}let h=u===b.u.Loading||f===d.L.Loading||!m;return a[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ir,{}),a[4]=e):e=a[4],a[5]!==h?(n=(0,t.jsxs)(t.Fragment,{children:[e,(0,t.jsx)(iu,{isNamespaceTransition:h})]}),a[5]=h,a[6]=n):n=a[6],n},im=e=>{let s,o,c,d,f,v,b,j,y,_,S,k,C,z,I,T,M,E,A,R,P,D,F,V,O,L,B,q,W,$,U,H,G,K,J,Z,Q,X,Y,ee,et,er,en,es,ea,el,ei=(0,r.c)(99),{isNamespaceTransition:eo}=e,ec=(0,h.f)();(el=(0,r.c)(1))[0]===Symbol.for("react.memo_cache_sentinel")?(ea=[],el[0]=ea):ea=el[0],(0,m.useEffect)(u,ea);let ed=(0,m.useRef)(null),em=(0,p.f)(N.z),eu=(0,p.f)(x.y),ef=(0,p.f)(x.M),eh=(0,p.f)(x.T),ex=(0,p.f)(ip),ep=(0,p.f)(w.z),eg=(0,m.useRef)(null),ev=(0,m.useRef)(null),eb=null!==ex;ei[0]!==ef||ei[1]!==em||ei[2]!==eu||ei[3]!==eb?(s=function(e){let{hasMessages:t,hydrationStatus:r,currentRoomId:n,isStoreReady:s}=e,a=!t;return"failed"===r?{mainContent:nV,shouldShowModelPresets:!1,shouldShowPromptPresets:a}:n&&t&&"success"===r?{mainContent:nO,shouldShowModelPresets:!1,shouldShowPromptPresets:!1}:t?{mainContent:"empty",shouldShowModelPresets:!1,shouldShowPromptPresets:!1}:{mainContent:nF,shouldShowModelPresets:s&&"success"===r||!n,shouldShowPromptPresets:a}}({hasMessages:em,hydrationStatus:eu,currentRoomId:ef,isStoreReady:eb}),ei[0]=ef,ei[1]=em,ei[2]=eu,ei[3]=eb,ei[4]=s):s=ei[4];let ej=s,ey=!eo&&null===ep&&ej.mainContent===nO;ei[5]!==ey?(o={isEnabled:ey,chatRegionRef:ev,messageListRef:ed},ei[5]=ey,ei[6]=o):o=ei[6];let ew=function(e){let t,n,s,a,l,i,o,c,d,u,f,h,x=(0,r.c)(27),{isEnabled:p,chatRegionRef:g,messageListRef:v}=e,b=(0,r6.useLocale)(),j=(0,m.useRef)(null),[y,w]=(0,m.useState)(!1),N=y&&p;x[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{j.current?.(),j.current=null},x[0]=t):t=x[0];let _=t;x[1]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{w(!1),_()},x[1]=n):n=x[1];let S=n;x[2]!==g?(s=()=>{var e;S(),g.current&&(e=g.current,(0,nT.f)()||requestAnimationFrame(()=>{e.querySelector('[data-testid="composer-input"]')?.focus()}))},x[2]=g,x[3]=s):s=x[3];let k=s;x[4]===Symbol.for("react.memo_cache_sentinel")?(a=()=>_,l=[_],x[4]=a,x[5]=l):(a=x[4],l=x[5]),(0,m.useEffect)(a,l),x[6]!==N?(i=()=>{N||S()},o=[N,S],x[6]=N,x[7]=i,x[8]=o):(i=x[7],o=x[8]),(0,m.useEffect)(i,o),x[9]!==g||x[10]!==b||x[11]!==v?(c=(e,t)=>{v.current?.scrollToMessage(e.messageId),j.current?.(),g.current&&(j.current=function(e,t,r,n){if(l2(),!("u">typeof CSS&&CSS.highlights&&"u">typeof Highlight))return()=>{};let s=!1,a=l0.d,l=()=>{if(s)return;let i=a<=0,o=t.querySelector(`[data-message-id="${CSS.escape(r.messageId)}"]`);o&&function(e,{element:t,match:r,query:n,isFinalAttempt:s}){var a;let l,i=function(e,{element:t,match:r,query:n,isFinalAttempt:s}){let a=[...t.querySelectorAll("[data-message-bubble]")].flatMap(e=>{let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:e=>e instanceof Element&&e.matches(l3)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),r=[],n=t.nextNode();for(;n;)n instanceof Text&&r.push(n),n=t.nextNode();return r}),l=function(e,{textNodes:t,query:r,occurrence:n,shouldSettleForClosest:s}){let a=t.map(e=>e.textContent??"").join(""),l=(0,r7.P)(a,r.trim(),{locale:e});return l[n]??(s?l.at(-1)??null:null)}(e,{textNodes:a,query:n,occurrence:r.occurrence,shouldSettleForClosest:s});return null===l?null:function(e,t,r){let n=0,s=null,a=0,l=null,i=0;for(let o of e){let e=n+(o.textContent??"").length;if(null===s&&t{s=!0,l2()}}(b,g.current,e,t))},x[9]=g,x[10]=b,x[11]=v,x[12]=c):c=x[12];let C=c;x[13]!==g||x[14]!==p?(d=e=>nP(e)&&p&&function(e,t){if(document.querySelector('[role="dialog"][data-open]'))return!1;let r=e instanceof Node?e:null;return!(r instanceof Element&&r.closest(`[data-testid="${nR}"]`))&&(!(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLElement&&r.isContentEditable)||(t?.contains(r)??!1))}(e.target,g.current),x[13]=g,x[14]=p,x[15]=d):d=x[15];let z=d;x[16]!==g||x[17]!==N?(u=()=>{if(N){var e;let t;return void(e=g.current,(t=e?.querySelector(`[data-testid="${nR}"]`))&&(t.focus(),t.select()))}(0,t7.P)({entryPoint:"keyboard"}),w(!0)},x[16]=g,x[17]=N,x[18]=u):u=x[18],(0,tU.f)(z,u),x[19]!==k||x[20]!==N?(f=()=>{N?k():((0,t7.P)({entryPoint:"header"}),w(!0))},x[19]=k,x[20]=N,x[21]=f):f=x[21];let I=f;return x[22]!==k||x[23]!==N||x[24]!==C||x[25]!==I?(h={isVisible:N,openFromHeader:I,close:k,jumpToMatch:C,clearHighlight:_},x[22]=k,x[23]=N,x[24]=C,x[25]=I,x[26]=h):h=x[26],h}(o);ei[7]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{let e=eg.current,t=ev.current;if(!e||!t)return;let r=()=>{let r=Number.parseFloat(getComputedStyle(e).bottom)||0;t.style.setProperty("--composer-clearance",`${e.offsetHeight+r+12}px`)};r();let n=new ResizeObserver(r);return n.observe(e),()=>n.disconnect()},ei[7]=c):c=ei[7],ei[8]!==ep?(d=[ep],ei[8]=ep,ei[9]=d):d=ei[9],(0,m.useEffect)(c,d),ei[10]!==eo?(f=!eo&&(0,t.jsx)(au,{}),ei[10]=eo,ei[11]=f):f=ei[11],ei[12]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.f)("flex flex-col md:flex-row","w-full text-muted-foreground","overflow-hidden","fixed inset-x-0 bottom-0 top-[calc(var(--playground-nav-offset,var(--navbar-height))+var(--navbar-top,0px))]","bg-background"),b=(0,t.jsx)(ll,{}),j=(0,t.jsx)(n$.f,{}),y=(0,t.jsx)(li.ResponsiveRoomManager,{}),ei[12]=v,ei[13]=b,ei[14]=j,ei[15]=y):(v=ei[12],b=ei[13],j=ei[14],y=ei[15]),ei[16]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.f)("relative flex flex-1 flex-col min-w-0 min-h-0 h-full pt-2","bg-card"),ei[16]=_):_=ei[16],ei[17]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.f)("flex flex-1 flex-col min-w-0 gap-2","min-h-0 h-full overflow-hidden"),k=(0,a.f)("shrink-0 flex gap-2 px-2 md:pl-0","max-md:items-center md:items-start","border-b border-border pb-2"),ei[17]=S,ei[18]=k):(S=ei[17],k=ei[18]),ei[19]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)(lf,{}),ei[19]=C):C=ei[19];let eN=!eh&&"italic text-faint";ei[20]!==eN?(z=(0,a.f)("ph-no-capture truncate text-sm font-medium text-foreground",eN),ei[20]=eN,ei[21]=z):z=ei[21],ei[22]!==eh||ei[23]!==ec?(I=eh||ec("Untitled"),ei[22]=eh,ei[23]=ec,ei[24]=I):I=ei[24],ei[25]!==z||ei[26]!==I?(T=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1 md:hidden",children:[C,(0,t.jsx)("span",{className:z,"data-dd-privacy":"hidden",children:I})]}),ei[25]=z,ei[26]=I,ei[27]=T):T=ei[27],ei[28]===Symbol.for("react.memo_cache_sentinel")?(M=(0,t.jsx)("div",{className:"flex min-w-0 flex-col gap-2 max-sm:shrink-0 md:flex-1",children:(0,t.jsx)(nN,{})}),ei[28]=M):M=ei[28],ei[29]===Symbol.for("react.memo_cache_sentinel")?(E=(0,t.jsx)("div",{className:"hidden md:flex items-center gap-1",children:(0,t.jsx)(ao,{})}),A=(0,t.jsx)(sK,{presentation:"drawer"}),R=(0,t.jsx)(io,{}),ei[29]=E,ei[30]=A,ei[31]=R):(E=ei[29],A=ei[30],R=ei[31]),ei[32]!==ew.isVisible||ei[33]!==ew.openFromHeader||ei[34]!==ey||ei[35]!==ec?(P=ey&&(0,t.jsx)(l.Button,{variant:"ghost",size:"icon","aria-label":ec("Find in conversation"),title:ec("Find in conversation"),"aria-expanded":ew.isVisible,onClick:ew.openFromHeader,children:(0,t.jsx)(n.f,{className:"size-5"})}),ei[32]=ew.isVisible,ei[33]=ew.openFromHeader,ei[34]=ey,ei[35]=ec,ei[36]=P):P=ei[36],ei[37]===Symbol.for("react.memo_cache_sentinel")?(D=(0,t.jsx)(lB,{}),ei[37]=D):D=ei[37],ei[38]!==P?(F=(0,t.jsxs)("div",{className:"shrink-0 flex items-center gap-1",children:[E,A,R,P,D]}),ei[38]=P,ei[39]=F):F=ei[39],ei[40]!==T||ei[41]!==F?(V=(0,t.jsxs)("div",{className:k,children:[T,M,F]}),ei[40]=T,ei[41]=F,ei[42]=V):V=ei[42],ei[43]!==ew.clearHighlight||ei[44]!==ew.close||ei[45]!==ew.isVisible||ei[46]!==ew.jumpToMatch||ei[47]!==ef?(O=ew.isVisible&&(0,t.jsx)("div",{className:"shrink-0 px-2 pb-2 md:pr-3",children:(0,t.jsx)(nD,{onClose:ew.close,onJumpToMatch:ew.jumpToMatch,onClearHighlight:ew.clearHighlight,getSearchableMessages:nW},ef??"no-room")}),ei[43]=ew.clearHighlight,ei[44]=ew.close,ei[45]=ew.isVisible,ei[46]=ew.jumpToMatch,ei[47]=ef,ei[48]=O):O=ei[48],ei[49]===Symbol.for("react.memo_cache_sentinel")?(L=(0,a.f)("flex flex-1 flex-col min-h-0 overflow-hidden"),ei[49]=L):L=ei[49],ei[50]!==ej.mainContent||ei[51]!==ej.shouldShowModelPresets?(B=ej.mainContent===nF&&(0,t.jsx)("div",{"data-testid":"playground-model-presets",className:"flex flex-1 flex-col min-h-0 overflow-hidden pr-0 md:pr-6",children:ej.shouldShowModelPresets?(0,t.jsx)(aY,{}):null}),ei[50]=ej.mainContent,ei[51]=ej.shouldShowModelPresets,ei[52]=B):B=ei[52],ei[53]!==ej.mainContent?(q=ej.mainContent===nV&&(0,t.jsx)("div",{"data-testid":"playground-hydration-failed",className:"flex flex-1 flex-col min-h-0 overflow-hidden pr-0 md:pr-6",children:(0,t.jsx)(lX,{})}),ei[53]=ej.mainContent,ei[54]=q):q=ei[54],ei[55]!==ej.mainContent?(W=ej.mainContent===nO&&(0,t.jsx)("div",{"data-testid":"playground-message-list","data-scroll-container":"true",className:(0,a.f)("flex flex-1 flex-col min-h-0 overflow-hidden"),children:(0,t.jsx)(as.f,{ref:ed})}),ei[55]=ej.mainContent,ei[56]=W):W=ei[56],ei[57]!==eb||ei[58]!==ej.shouldShowPromptPresets?($=ej.shouldShowPromptPresets&&(0,t.jsx)("div",{className:(0,a.f)("shrink-0","mb-(--composer-clearance,8rem)"),children:eb?(0,t.jsx)(a8,{}):null}),ei[57]=eb,ei[58]=ej.shouldShowPromptPresets,ei[59]=$):$=ei[59],ei[60]!==B||ei[61]!==q||ei[62]!==W||ei[63]!==$?(U=(0,t.jsxs)("div",{className:L,children:[B,q,W,$]}),ei[60]=B,ei[61]=q,ei[62]=W,ei[63]=$,ei[64]=U):U=ei[64],ei[65]!==ep?(H=ep&&(0,t.jsx)("div",{"data-testid":"playground-artifact-overlay",className:"absolute inset-0 z-10 bg-background",children:(0,t.jsx)(tO,{})}),ei[65]=ep,ei[66]=H):H=ei[66],ei[67]!==V||ei[68]!==O||ei[69]!==U||ei[70]!==H?(G=(0,t.jsxs)("div",{"data-testid":"playground-chat-pane","data-scroll-container":"true",className:S,children:[V,O,U,H]}),ei[67]=V,ei[68]=O,ei[69]=U,ei[70]=H,ei[71]=G):G=ei[71],ei[72]!==ep?(K=!ep&&(0,t.jsx)(nz.f,{}),ei[72]=ep,ei[73]=K):K=ei[73],ei[74]!==ep||ei[75]!==ej.mainContent?(J=!ep&&ej.mainContent===nO&&(0,t.jsx)("div",{"aria-hidden":"true",className:(0,a.f)("pointer-events-none absolute inset-x-0 bottom-0 z-above","h-(--composer-clearance,8rem)","bg-gradient-to-t from-background via-background/95 to-transparent")}),ei[74]=ep,ei[75]=ej.mainContent,ei[76]=J):J=ei[76],ei[77]!==ep?(Z=!ep&&(0,t.jsx)("div",{ref:eg,"data-testid":"playground-composer",className:(0,a.f)("absolute bottom-3 left-0 right-0 z-10 px-1 md:bottom-6 md:px-4","pointer-events-none [&>*]:pointer-events-auto"),children:(0,t.jsx)(g.f,{})}),ei[77]=ep,ei[78]=Z):Z=ei[78],ei[79]!==G||ei[80]!==K||ei[81]!==J||ei[82]!==Z?(Q=(0,t.jsxs)(nz.Q,{className:_,ref:ev,children:[G,K,J,Z]}),ei[79]=G,ei[80]=K,ei[81]=J,ei[82]=Z,ei[83]=Q):Q=ei[83],ei[84]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(ae,{}),Y=(0,t.jsx)(sK,{}),ei[84]=X,ei[85]=Y):(X=ei[84],Y=ei[85]),ei[86]!==Q?(ee=(0,t.jsxs)("div",{"data-testid":"playground-container","data-workspace-surface-shell":"",className:v,children:[b,j,y,Q,X,Y]}),ei[86]=Q,ei[87]=ee):ee=ei[87],ei[88]!==ee||ei[89]!==f?(et=(0,t.jsxs)(t.Fragment,{children:[f,ee]}),ei[88]=ee,ei[89]=f,ei[90]=et):et=ei[90];let e_=et;return ei[91]!==eo?(er=eo?{inert:!0}:{},ei[91]=eo,ei[92]=er):er=ei[92],ei[93]!==e_||ei[94]!==er?(en=(0,t.jsx)("div",{...er,children:e_}),ei[93]=e_,ei[94]=er,ei[95]=en):en=ei[95],ei[96]!==eo||ei[97]!==en?(es=(0,t.jsx)(i.TooltipProvider,{delay:500,closeDelay:100,timeout:400,children:(0,t.jsx)("div",{"aria-busy":eo,className:"relative min-h-0 w-full",children:en})}),ei[96]=eo,ei[97]=en,ei[98]=es):es=ei[98],es},iu=(0,m.memo)(e=>{let n,s=(0,r.c)(2),{isNamespaceTransition:a}=e;return s[0]!==a?(n=(0,t.jsx)(m.Suspense,{fallback:null,children:(0,t.jsx)(im,{isNamespaceTransition:a})}),s[0]=a,s[1]=n):n=s[1],n},(e,t)=>e.isNamespaceTransition===t.isNamespaceTransition);function ih(e){return e.storageInstanceId}function ix(e){return e.initializationStatus}function ip(e){return e.storageInstanceId}e.s(["Playground",0,()=>{let e,n=(0,r.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(m.Suspense,{fallback:null,children:(0,t.jsx)(id,{})}),n[0]=e):e=n[0],e}],57539)}]); //# sourceMappingURL=0fizah8hqjsa2.js.map