!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a099a4-b4bd-7173-be4b-823c82a3654e")}catch(e){}}();(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,354729,e=>{"use strict";var t=e.i(505962);e.i(122901);var r=e.i(270401);e.i(798823),e.i(429930),e.i(447680),e.i(22422),e.i(624621),e.i(735961);var n=e.i(612960);e.s(["DevSeedEffect",0,function(){let e,s,a=(0,t.c)(3),o=(0,n.useLocalizedRouter)();return a[0]!==o?(e=()=>{},s=[o],a[0]=o,a[1]=e,a[2]=s):(e=a[1],s=a[2]),(0,r.useEffect)(e,s),null}])},57539,e=>{"use strict";var t,r,n=e.i(222666),s=e.i(505962),a=e.i(152533),o=e.i(189511),l=e.i(452473),i=e.i(528164),c=e.i(648156),u=e.i(270401);function d(){return window.addEventListener("dragover",m),window.addEventListener("drop",m),()=>{window.removeEventListener("dragover",m),window.removeEventListener("drop",m)}}function m(e){e.dataTransfer?.types.includes("Files")&&e.preventDefault()}e.i(798823);var f=e.i(429930),h=e.i(693946),p=e.i(624621),g=e.i(556427),x=e.i(394333),v=e.i(980351),y=e.i(573503);let b=["w-3/5","w-4/5"],w=["w-3/4","w-1/2","w-5/6","w-2/3","w-3/5","w-4/5"];function S(e){let t,r,a=(0,s.c)(4),{width:o}=e;return a[0]!==o?(t=(0,l.cn)("h-3.5",o),a[0]=o,a[1]=t):t=a[1],a[2]!==t?(r=(0,n.jsx)("div",{className:"flex h-9 items-center rounded-lg px-3",children:(0,n.jsx)(x.Skeleton,{className:t})}),a[2]=t,a[3]=r):r=a[3],r}function j(){let e,t,r,a,o,i,c,u,d,m,f,h,g,y=(0,s.c)(16),S=(0,p.useChatroomStore)(N);if((0,v.useHydrated)()&&S){let e,t,r;return y[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("hidden md:flex h-full w-[54px] shrink-0 flex-col p-px","bg-background border-r border-border"),y[0]=e):e=y[0],y[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,n.jsx)(x.Skeleton,{className:"size-5"})}),y[1]=t):t=y[1],y[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("aside",{className:e,children:(0,n.jsx)("div",{className:"flex h-full w-full flex-col gap-2 p-2",children:(0,n.jsxs)("div",{className:"flex w-full flex-col items-center gap-1",children:[t,(0,n.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,n.jsx)(x.Skeleton,{className:"size-5"})})]})})}),y[2]=r):r=y[2],r}return y[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("hidden md:flex h-full w-[260px] shrink-0 flex-col p-px","bg-background border-r border-border"),y[3]=e):e=y[3],y[4]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(x.Skeleton,{className:"h-4 w-12"}),y[4]=t):t=y[4],y[5]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsxs)("div",{className:"flex h-9 w-full items-center justify-between gap-2 px-1",children:[t,(0,n.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,n.jsx)(x.Skeleton,{className:"size-5"})})]}),y[5]=r):r=y[5],y[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsxs)("div",{className:"flex h-8 w-full shrink-0 items-center gap-3 rounded-md border border-border px-3",children:[(0,n.jsx)(x.Skeleton,{className:"size-4 rounded-sm"}),(0,n.jsx)(x.Skeleton,{className:"h-3.5 w-16"})]}),y[6]=a):a=y[6],y[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.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,n.jsx)(x.Skeleton,{className:"size-4 rounded-sm"}),(0,n.jsx)(x.Skeleton,{className:"h-3.5 w-24"})]}),y[7]=o):o=y[7],y[8]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)("div",{"aria-hidden":"true",className:"shrink-0 -mx-2 py-4",children:(0,n.jsx)("div",{className:"h-px bg-border"})}),y[8]=i):i=y[8],y[9]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsxs)("div",{className:"flex h-7 shrink-0 items-center justify-between pr-1",children:[(0,n.jsx)(x.Skeleton,{className:"ml-3 h-3 w-14"}),(0,n.jsx)(x.Skeleton,{className:"h-3 w-10"})]}),y[9]=c):c=y[9],y[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,n.jsx)("div",{className:"flex items-center px-3 pb-1 pt-2",children:(0,n.jsx)(x.Skeleton,{className:"h-3 w-12"})}),y[10]=u):u=y[10],y[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,n.jsx)("div",{className:"flex flex-col gap-0.5",children:b.map(_)}),y[11]=d):d=y[11],y[12]===Symbol.for("react.memo_cache_sentinel")?(m=(0,n.jsx)("div",{className:"flex items-center px-3 pb-1 pt-4",children:(0,n.jsx)(x.Skeleton,{className:"h-3 w-16"})}),y[12]=m):m=y[12],y[13]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-hidden",children:[u,d,m,(0,n.jsx)("div",{className:"flex flex-col gap-0.5",children:w.map(C)})]}),y[13]=f):f=y[13],y[14]===Symbol.for("react.memo_cache_sentinel")?(h=(0,n.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-border"}),y[14]=h):h=y[14],y[15]===Symbol.for("react.memo_cache_sentinel")?(g=(0,n.jsx)("aside",{className:e,children:(0,n.jsxs)("div",{className:"flex h-full w-full flex-col gap-2 p-2",children:[r,a,o,i,c,f,(0,n.jsxs)("div",{className:"relative -mx-2 shrink-0 px-2 pb-2 pt-2",children:[h,(0,n.jsxs)("div",{className:"flex h-10 w-full items-center gap-2 rounded-md px-2",children:[(0,n.jsx)(x.Skeleton,{className:"size-6"}),(0,n.jsx)(x.Skeleton,{className:"h-3.5 w-24"})]})]})]})}),y[15]=g):g=y[15],g}function C(e){return(0,n.jsx)(S,{width:e},e)}function _(e){return(0,n.jsx)(S,{width:e},e)}function N(e){return e.isRoomManagerCollapsed}function k(){let e,t=(0,s.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsxs)("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border pl-2 pr-1",children:[(0,n.jsx)(x.Skeleton,{className:"size-6 rounded-full"}),(0,n.jsx)(x.Skeleton,{className:"h-3.5 w-24"}),(0,n.jsx)(x.Skeleton,{className:"size-4 rounded-sm"})]}),t[0]=e):e=t[0],e}function I(){let e,t,r,a,o,i,c,u,d=(0,s.c)(8);return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("shrink-0 flex gap-2 px-2 md:pl-0","max-md:items-center md:items-start","border-b border-border pb-2"),d[0]=e):e=d[0],d[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-1 md:hidden",children:[(0,n.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center",children:(0,n.jsx)(x.Skeleton,{className:"size-5"})}),(0,n.jsx)(x.Skeleton,{className:"h-4 w-28"})]}),d[1]=t):t=d[1],d[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("div",{className:"shrink-0 self-start pl-3",children:(0,n.jsx)(x.Skeleton,{className:"h-9 w-[4.5rem] rounded-md"})}),d[2]=r):r=d[2],d[3]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsxs)("div",{className:"hidden min-w-0 items-start gap-2 p-px md:flex md:flex-1",children:[r,(0,n.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-2",children:[(0,n.jsx)(k,{}),(0,n.jsx)(k,{})]})]}),d[3]=a):a=d[3],d[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 md:hidden",children:[(0,n.jsx)(k,{}),(0,n.jsx)(x.Skeleton,{className:"h-9 w-9 rounded-md"})]}),d[4]=o):o=d[4],d[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)(x.Skeleton,{className:"hidden h-9 w-28 rounded-md md:block"}),d[5]=i):i=d[5],d[6]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,n.jsx)(x.Skeleton,{className:"size-5"})}),d[6]=c):c=d[6],d[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,n.jsxs)("div",{className:e,children:[t,a,o,(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[i,c,(0,n.jsx)("div",{className:"flex size-9 items-center justify-center",children:(0,n.jsx)(x.Skeleton,{className:"size-5"})})]})]}),d[7]=u):u=d[7],u}let E=["w-28","w-36","w-24","w-32"];function A(e){let t,r,a,o,i,c=(0,s.c)(8),{titleWidth:u}=e;return c[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,l.cn)("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"),c[0]=t):t=c[0],c[1]!==u?(r=(0,l.cn)("h-4",u),c[1]=u,c[2]=r):r=c[2],c[3]!==r?(a=(0,n.jsx)(x.Skeleton,{className:r}),c[3]=r,c[4]=a):a=c[4],c[5]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsxs)("div",{className:"flex justify-end",children:[(0,n.jsx)(x.Skeleton,{className:"size-6 rounded-full ring-2 ring-card -me-2"}),(0,n.jsx)(x.Skeleton,{className:"size-6 rounded-full ring-2 ring-card -me-2"}),(0,n.jsx)(x.Skeleton,{className:"size-6 rounded-full ring-2 ring-card"})]}),c[5]=o):o=c[5],c[6]!==a?(i=(0,n.jsxs)("div",{className:t,children:[a,o]}),c[6]=a,c[7]=i):i=c[7],i}function F(){let e,t,r,a=(0,s.c)(3);return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("relative flex w-full shrink-0 items-center justify-center","min-h-0 flex-1","flex-col overflow-hidden py-4 md:py-6"),a[0]=e):e=a[0],a[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("div",{className:"hidden grid-cols-2 gap-4 md:grid",children:E.map($)}),a[1]=t):t=a[1],a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsxs)("div",{className:e,children:[t,(0,n.jsx)("div",{className:"grid w-full grid-cols-2 gap-2 px-3 md:hidden",children:E.map(M)})]}),a[2]=r):r=a[2],r}function M(e){return(0,n.jsx)(x.Skeleton,{className:"min-h-20 rounded-xl"},e)}function $(e){return(0,n.jsx)(A,{titleWidth:e},e)}function T(){let e,t,r=(0,s.c)(2);return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("relative flex w-full shrink-0 items-center justify-start","max-w-4xl mx-auto overflow-hidden","pt-2 md:pt-3"),r[0]=e):e=r[0],r[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsxs)("div",{className:e,children:[(0,n.jsx)("div",{className:"hidden w-full gap-4 px-3 md:flex",children:Array.from({length:6}).map(O)}),(0,n.jsx)("div",{className:(0,l.cn)("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(P)})]}),r[1]=t):t=r[1],t}function P(e,t){return(0,n.jsx)(x.Skeleton,{className:"h-16 rounded-xl"},`prompt-preset-m-${t}`)}function O(e,t){return(0,n.jsx)(x.Skeleton,{className:"h-16 w-52 shrink-0 rounded-lg"},`prompt-preset-${t}`)}function R(){let e,t,r,a,o,l,i=(0,s.c)(6);return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"flex h-9 items-center px-2",children:(0,n.jsx)(x.Skeleton,{className:"h-3.5 w-28"})}),i[0]=e):e=i[0],i[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"}),(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"}),(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"}),(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"})]}),i[1]=t):t=i[1],i[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsxs)("div",{className:"hidden flex-col gap-1 md:flex",children:[e,(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[t,(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"}),(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"})]})]})]}),i[2]=r):r=i[2],i[3]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)(x.Skeleton,{className:"size-9 shrink-0 rounded-full"}),i[3]=a):a=i[3],i[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)("div",{className:"flex h-9 min-w-0 flex-1 items-center px-2",children:(0,n.jsx)(x.Skeleton,{className:"h-3.5 w-24"})}),i[4]=o):o=i[4],i[5]===Symbol.for("react.memo_cache_sentinel")?(l=(0,n.jsx)("div",{className:"absolute bottom-3 left-0 right-0 z-10 px-1 md:bottom-6 md:px-4",children:(0,n.jsxs)("div",{className:"mx-auto w-full max-w-4xl",children:[(0,n.jsxs)("div",{className:"rounded-3xl border border-border bg-popover px-3 py-1.5",children:[r,(0,n.jsxs)("div",{className:"flex items-center gap-1.5 md:hidden",children:[a,o,(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"}),(0,n.jsx)(x.Skeleton,{className:"size-9 rounded-full"})]})]})]}),(0,n.jsx)(y.AiResponseDisclaimer,{})]})}),i[5]=l):l=i[5],l}function z(){let e,t,r,a,o,i=(0,s.c)(5);return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("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,56px)+var(--navbar-top,0px))]","bg-background"),t=(0,n.jsx)(j,{}),i[0]=e,i[1]=t):(e=i[0],t=i[1]),i[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)(I,{}),i[2]=r):r=i[2],i[3]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden pr-0 md:pr-6",children:(0,n.jsx)(F,{})}),i[3]=a):a=i[3],i[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsxs)("div",{"aria-busy":"true",className:e,children:[t,(0,n.jsxs)("div",{className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col bg-card pt-2",children:[(0,n.jsxs)("div",{className:"flex h-full min-h-0 min-w-0 flex-1 flex-col gap-2 overflow-hidden",children:[r,(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[a,(0,n.jsx)("div",{className:"shrink-0 mb-[var(--composer-clearance,8rem)]",children:(0,n.jsx)(T,{})})]})]}),(0,n.jsx)(R,{})]})]}),i[4]=o):o=i[4],o}var L=e.i(829104),D=e.i(160962),B=e.i(205059),V=e.i(985024),U=e.i(121850),G=e.i(673897),H=e.i(561124),q=e.i(250855),W=e.i(691038),K=e.i(22422),Y=e.i(807508),X=e.i(368862),Z=e.i(608050),J=e.i(946382);e.i(530023);var Q=e.i(612774),ee=e.i(399695),et=e.i(358058),er=e.i(570655),en=e.i(693697),es=e.i(321801),ea=e.i(531650),eo=e.i(235045);let el=e=>{let t,r,a,o,l=(0,s.c)(9),{attachments:i}=e,u=i.list.length>=i.limit?`Maximum ${i.limit} attachments added.`:`Limit: ${i.limit} attachments per message.`,d=`${u} Actual limit varies based on model and provider.`,m=i.list.length>=i.limit;return l[0]!==i?(t=async()=>{await i.handleFiles((0,ee.getFilesFromSelectDialog)())},l[0]=i,l[1]=t):t=l[1],l[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)(ea.PaperClipIcon,{className:"size-5"}),l[2]=r):r=l[2],l[3]!==m||l[4]!==t?(a=(0,n.jsx)("span",{className:"inline-flex",children:(0,n.jsx)(eo.ComposerFooterButton,{isIconOnly:!0,disabled:m,onClick:t,"aria-label":"Add attachment",children:r})}),l[3]=m,l[4]=t,l[5]=a):a=l[5],l[6]!==d||l[7]!==a?(o=(0,n.jsx)(c.Tooltip,{className:"w-44",content:d,children:a}),l[6]=d,l[7]=a,l[8]=o):o=l[8],o};var ei=e.i(623102),ec=e.i(903121),eu=e.i(8213);function ed(e){let{prompt:t,attachments:r,lastSubmission:n,setPrompt:s,setCommandMode:a}=e,o=t.trim();(""===o||o===n.current?.prompt)&&0===r.list.length&&n.current&&(s(n.current.prompt),r.set(n.current.attachments),a&&a(n.current.commandMode))}var em=e.i(133256),ef=e.i(733288),eh=((t={}).Chat="chat",t.Generate="generate",t);let ep=e=>{let t,r,a,o,c,u=(0,s.c)(16),{mode:d,currentMode:m,icon:f,label:h,onSelect:p,disabled:g}=e,x=m===d,v=x&&"bg-primary hover:bg-primary/90 text-primary-foreground border-transparent";return u[0]!==v?(t=(0,l.cn)("rounded-full",v),u[0]=v,u[1]=t):t=u[1],u[2]!==d||u[3]!==p?(r=()=>p(d),u[2]=d,u[3]=p,u[4]=r):r=u[4],u[5]!==f?(a=(0,n.jsx)(f,{className:"size-4"}),u[5]=f,u[6]=a):a=u[6],u[7]!==h?(o=(0,n.jsx)("span",{children:h}),u[7]=h,u[8]=o):o=u[8],u[9]!==g||u[10]!==x||u[11]!==t||u[12]!==r||u[13]!==a||u[14]!==o?(c=(0,n.jsxs)(i.Button,{type:"button",size:"sm",variant:"outline",className:t,"aria-pressed":x,onClick:r,disabled:g,children:[a,o]}),u[9]=g,u[10]=x,u[11]=t,u[12]=r,u[13]=a,u[14]=o,u[15]=c):c=u[15],c},eg=e=>{let t,r=(0,s.c)(4),{mode:a,onSelect:o,disabled:l}=e;return r[0]!==l||r[1]!==a||r[2]!==o?(t=(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(ep,{mode:eh.Generate,currentMode:a,icon:ef.SparklesIcon,label:"Generate",onSelect:o,disabled:l}),(0,n.jsx)(ep,{mode:eh.Chat,currentMode:a,icon:em.LightBulbIcon,label:"Brainstorm",onSelect:o,disabled:l})]}),r[0]=l,r[1]=a,r[2]=o,r[3]=t):t=r[3],t};var ex=e.i(743240),ev=e.i(53375);let ey=e=>{var t,r,a,o;let u,d,m,f,h,p,g=(0,s.c)(21),{prompt:x,disabled:v,isLoading:y,onSend:b,onStop:w,mode:S}=e;g[0]!==x?(u=x.trim(),g[0]=x,g[1]=u):u=g[1];let j=u.length>0;g[2]!==v||g[3]!==S?(t=v,r=S,d=t?"Stop":"generate"===r?"Generate new version":"Send message",g[2]=v,g[3]=S,g[4]=d):d=g[4];let C=d;g[5]!==v||g[6]!==S?(a=v,o=S,m=a?(0,n.jsx)(ev.StopIcon,{className:"size-4"}):"generate"===o?(0,n.jsx)(ef.SparklesIcon,{className:"size-4"}):(0,n.jsx)(ex.PaperAirplaneIcon,{className:"size-4"}),g[5]=v,g[6]=S,g[7]=m):m=g[7];let _=m,N=v?w:b,k=!v&&(!j||void 0!==y&&y),I=!v&&!j&&"opacity-40",E=v&&"bg-destructive hover:bg-destructive/90 text-destructive-foreground",A="generate"===S&&!v&&"bg-primary hover:bg-primary/90 text-primary-foreground";return g[8]!==I||g[9]!==E||g[10]!==A?(f=(0,l.cn)("transition-all",I,E,A),g[8]=I,g[9]=E,g[10]=A,g[11]=f):f=g[11],g[12]!==_||g[13]!==f||g[14]!==N||g[15]!==k||g[16]!==C?(h=(0,n.jsx)(i.Button,{size:"icon",onClick:N,disabled:k,"aria-label":C,className:f,children:_}),g[12]=_,g[13]=f,g[14]=N,g[15]=k,g[16]=C,g[17]=h):h=g[17],g[18]!==h||g[19]!==C?(p=(0,n.jsx)(c.Tooltip,{content:C,children:h}),g[18]=h,g[19]=C,g[20]=p):p=g[20],p},eb=e=>e.activeArtifactId,ew=e=>e.currentRoomId,eS=(0,es.createSelector)([eb,e=>e.artifacts],(e,t)=>e?t[e]?.type:void 0),ej=(0,es.createSelector)([eb,ew,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}),eC=(0,es.createSelector)([ew,e=>e.rooms],(e,t)=>!!e&&(t[e]?.isProcessing??!1)),e_=(0,es.createSelector)([eb,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}),eN=()=>{let e,t,r,a,o,l,i,c,d,m,h,g,x,v=(0,s.c)(51),y=(0,u.useRef)(null),b=(0,u.useRef)(null),[w,S]=(0,u.useState)(""),[j,C]=(0,u.useState)(eh.Generate),_=(0,u.useRef)(null),N=(0,et.useAttachments)(),{isDragging:k,isValid:I}=(0,er.useDragDrop)(b),E=(0,p.useChatroomStore)(eb),A=(0,p.useChatroomStore)(eS),F=(0,p.useChatroomStore)(ew),M=(0,p.useChatroomStore)(ej),$=(0,p.useChatroomStore)(eC),T=(0,p.useChatroomStore)(e_)===f.GenerationStatus.Generating,P=N.loadingKeys.size>0,O=$||T;v[0]===Symbol.for("react.memo_cache_sentinel")?(e=e=>{C(e),setTimeout(()=>y.current?.focus(),1)},v[0]=e):e=v[0];let R=e;v[1]!==E||v[2]!==M||v[3]!==A||v[4]!==N||v[5]!==F||v[6]!==P||v[7]!==O||v[8]!==j||v[9]!==w?(t=async()=>{if(!w.trim()&&0===N.list.length||!E||!F||O||P)return;if(!M)return void(0,Q.toast)({title:"No model selected",description:"Please select a model to use for generation.",variant:"destructive"});let e={prompt:w,attachments:N.list};if(_.current=e,S(""),N.reset(),j===eh.Chat)K.chatroomStoreActions.sendConversationPromptToArtifact({payload:{roomId:F,artifactId:E,content:e.prompt,attachments:e.attachments}});else{if(A!==f.ArtifactType.App){(0,Q.toast)({title:"Cannot Generate",description:"Generation is only supported for app artifacts with a defined archetype.",variant:"destructive"}),ed({prompt:w,attachments:N,lastSubmission:_,setPrompt:S});return}let t=await K.chatroomStoreActions.sendGenerationPromptToArtifact({payload:{roomId:F,artifactId:E,prompt:e.prompt,attachments:e.attachments}});(0,en.isErr)(t)&&ed({prompt:w,attachments:N,lastSubmission:_,setPrompt:S})}_.current=null},v[1]=E,v[2]=M,v[3]=A,v[4]=N,v[5]=F,v[6]=P,v[7]=O,v[8]=j,v[9]=w,v[10]=t):t=v[10];let z=t;v[11]!==E||v[12]!==F||v[13]!==T?(r=()=>{if(T){let e=E&&p.useChatroomStore.getState().artifactViewerState[E]?.activeVersionId;e&&F&&E&&K.chatroomStoreActions.stopArtifactVersionGeneration({payload:{roomId:F,artifactId:E,versionId:e}})}else K.chatroomStoreActions.stopGeneration()},v[11]=E,v[12]=F,v[13]=T,v[14]=r):r=v[14];let L=r,D=j===eh.Chat?"Chat, brainstorm, or discuss this artifact...":"Describe the changes to generate a new version...";return v[15]===Symbol.for("react.memo_cache_sentinel")?(a={isolation:"isolate",contain:"layout"},v[15]=a):a=v[15],v[16]!==N?(o=(0,n.jsx)(ei.ComposerAttachments,{attachments:N}),v[16]=N,v[17]=o):o=v[17],v[18]!==N||v[19]!==k||v[20]!==I?(l=k?(0,n.jsx)(ec.ComposerDropZone,{isValid:I,onDrop:async e=>{await N.handleFiles((0,ee.getFilesFromDragDrop)(e))}}):null,v[18]=N,v[19]=k,v[20]=I,v[21]=l):l=v[21],v[22]!==O||v[23]!==j?(i=(0,n.jsx)("div",{className:"flex items-center gap-2 min-w-0",children:(0,n.jsx)(eg,{mode:j,onSelect:R,disabled:O})}),v[22]=O,v[23]=j,v[24]=i):i=v[24],v[25]!==N||v[26]!==z||v[27]!==O||v[28]!==D||v[29]!==w?(c=(0,n.jsx)(eu.ComposerInput,{ref:y,placeholder:D,prompt:w,setPrompt:S,attachments:N,onSend:z,disabled:O}),v[25]=N,v[26]=z,v[27]=O,v[28]=D,v[29]=w,v[30]=c):c=v[30],v[31]!==N?(d=(0,n.jsx)("div",{className:"relative flex w-full min-w-0 items-center gap-1",children:(0,n.jsx)(el,{attachments:N})}),v[31]=N,v[32]=d):d=v[32],v[33]!==z||v[34]!==L||v[35]!==P||v[36]!==O||v[37]!==j||v[38]!==w?(m=(0,n.jsx)("div",{className:"flex",children:(0,n.jsx)(ey,{prompt:w,disabled:O,onSend:z,onStop:L,mode:j,isLoading:P})}),v[33]=z,v[34]=L,v[35]=P,v[36]=O,v[37]=j,v[38]=w,v[39]=m):m=v[39],v[40]!==d||v[41]!==m?(h=(0,n.jsxs)("div",{className:"flex gap-1",children:[d,m]}),v[40]=d,v[41]=m,v[42]=h):h=v[42],v[43]!==h||v[44]!==i||v[45]!==c?(g=(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[i,c,h]}),v[43]=h,v[44]=i,v[45]=c,v[46]=g):g=v[46],v[47]!==g||v[48]!==o||v[49]!==l?(x=(0,n.jsxs)("div",{ref:b,className:"rounded-lg overflow-hidden border border-border w-full bg-card p-2",style:a,children:[o,l,g]}),v[47]=g,v[48]=o,v[49]=l,v[50]=x):x=v[50],x};var ek=e.i(664514),eI=e.i(729987),eE=e.i(216294);function eA(){let e,t=(0,s.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center p-8",children:(0,n.jsxs)("div",{className:"text-center text-muted-foreground max-w-md",children:[(0,n.jsx)("p",{className:"text-lg font-medium mb-2",children:"Start the conversation"}),(0,n.jsx)("p",{className:"text-sm",children:"Use the chat composer below to discuss ideas, ask questions, or brainstorm about this artifact."})]})}),t[0]=e):e=t[0],e}function eF(e){return(0,n.jsx)("div",{className:"max-w-3xl w-full",children:(0,n.jsx)(eE.MessageListItem,{messageId:e})},e)}let eM=(0,u.memo)(function(e){let t,r,a,o,i,c,d=(0,s.c)(10),{artifactId:m}=e,f=(0,u.useRef)(null),h=(0,u.useRef)(null);d[0]!==m?(t=e=>(0,H.selectArtifactChatMessageIds)(e,m),d[0]=m,d[1]=t):t=d[1];let g=(0,p.useChatroomStore)((0,ek.useShallow)(t));if(d[2]===Symbol.for("react.memo_cache_sentinel")?(r={scrollContainerRef:f,contentRef:h,initialStick:!0},d[2]=r):r=d[2],(0,eI.useAutoScroll)(r),0===g.length){let e;return d[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(eA,{}),d[3]=e):e=d[3],e}return d[4]===Symbol.for("react.memo_cache_sentinel")?(a=(0,l.cn)("flex-1 min-h-0 w-full overflow-y-auto relative","overscroll-behavior-y-contain"),o={contain:"layout style"},d[4]=a,d[5]=o):(a=d[4],o=d[5]),d[6]!==g?(i=g.map(eF),d[6]=g,d[7]=i):i=d[7],d[8]!==i?(c=(0,n.jsx)("div",{ref:f,className:a,style:o,children:(0,n.jsx)("div",{ref:h,children:(0,n.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})})}),d[8]=i,d[9]=c):c=d[9],c},(e,t)=>e.artifactId===t.artifactId),e$=(0,u.memo)(function(e){let t,r,a,o=(0,s.c)(5),{artifactId:l}=e;return o[0]!==l?(t=(0,n.jsx)(eM,{artifactId:l}),o[0]=l,o[1]=t):t=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("div",{className:"max-w-4xl mx-auto w-full",children:(0,n.jsx)(eN,{})}),o[2]=r):r=o[2],o[3]!==t?(a=(0,n.jsxs)("div",{className:"flex flex-col h-full",children:[t,r]}),o[3]=t,o[4]=a):a=o[4],a},(e,t)=>e.artifactId===t.artifactId);var eT=e.i(733442),eP=e.i(911189),eO=e.i(873151);let eR=e=>{let t,r,a,o,i,c,u,d,m,h,g,x,v,y,b,w,S,j,C,_,N=(0,s.c)(52),{versionId:k}=e,I=(0,p.useChatroomStore)(ez);N[0]!==k?(t=e=>e.artifactVersions[k]?.createdAt,N[0]=k,N[1]=t):t=N[1];let E=(0,p.useChatroomStore)(t);N[2]!==k?(r=e=>e.artifactVersions[k]?.generationStatus,N[2]=k,N[3]=r):r=N[3];let A=(0,p.useChatroomStore)(r);N[4]!==k?(a=e=>e.artifactVersions[k]?.error,N[4]=k,N[5]=a):a=N[5];let F=(0,p.useChatroomStore)(a);N[6]!==k?(o=e=>e.artifactVersions[k]?.versionNumber,N[6]=k,N[7]=o):o=N[7];let M=(0,p.useChatroomStore)(o);N[8]!==I?(i=e=>I?e.artifactViewerState[I]?.activeVersionId:null,N[8]=I,N[9]=i):i=N[9];let $=k===(0,p.useChatroomStore)(i);N[10]!==k?(c=e=>e.artifactVersions[k]?.characterName,N[10]=k,N[11]=c):c=N[11];let T=(0,p.useChatroomStore)(c);N[12]!==k?(u=e=>e.artifactVersions[k]?.prompt,N[12]=k,N[13]=u):u=N[13];let P=(0,p.useChatroomStore)(u),O=F?f.GenerationStatus.Failed:A??f.GenerationStatus.Idle,R=(0,eP.useTimeAgo)(E);N[14]!==I||N[15]!==k?(d=()=>{I&&K.chatroomStoreActions.setActiveVersionId({payload:{artifactId:I,versionId:k}})},N[14]=I,N[15]=k,N[16]=d):d=N[16];let z=d;N[17]!==z?(m=e=>{("Enter"===e.key||" "===e.key)&&z()},N[17]=z,N[18]=m):m=N[18];let L=$&&"bg-accent/40";N[19]!==L?(h=(0,l.cn)("grid items-start p-2 rounded-md max-w-full","hover:bg-accent/50",L),N[19]=L,N[20]=h):h=N[20];let D=eT.generationStatusTheme[O],B=eT.generationStatusTheme[O];N[21]!==D.coreBg||N[22]!==B.ringBorder?(g=(0,l.cn)("inline-flex items-center justify-center h-2 w-2 rounded-full shrink-0",D.coreBg,B.ringBorder),N[21]=D.coreBg,N[22]=B.ringBorder,N[23]=g):g=N[23];let V=eT.generationStatusLabel[O];N[24]!==g||N[25]!==V?(x=(0,n.jsx)("span",{className:g,title:V,"aria-hidden":"true"}),N[24]=g,N[25]=V,N[26]=x):x=N[26],N[27]!==M?(v=(0,n.jsxs)("span",{className:"text-sm font-medium text-foreground shrink-0",children:["v",M]}),N[27]=M,N[28]=v):v=N[28],N[29]!==T?(y=T&&(0,n.jsx)("span",{className:"text-2xs text-muted-foreground border border-border rounded-sm px-1.5 py-0.5 truncate max-w-[12rem]",children:T}),N[29]=T,N[30]=y):y=N[30],N[31]!==x||N[32]!==v||N[33]!==y?(b=(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[x,v,y]}),N[31]=x,N[32]=v,N[33]=y,N[34]=b):b=N[34],N[35]!==E||N[36]!==R||N[37]!==O?(w=(0,n.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:O===f.GenerationStatus.Generating&&E?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,n.jsx)(eO.ElapsedTimer,{start:E})}):(0,n.jsx)("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:R})}),N[35]=E,N[36]=R,N[37]=O,N[38]=w):w=N[38],N[39]!==b||N[40]!==w?(S=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 min-w-0 shrink-0",children:[b,w]}),N[39]=b,N[40]=w,N[41]=S):S=N[41];let U=P||"Initial version";return N[42]!==U?(j=(0,n.jsx)("div",{className:"text-xs text-muted-foreground truncate ph-no-capture","data-dd-privacy":"hidden",children:U}),N[42]=U,N[43]=j):j=N[43],N[44]!==S||N[45]!==j?(C=(0,n.jsxs)("div",{className:"min-w-0 flex flex-col gap-1",children:[S,j]}),N[44]=S,N[45]=j,N[46]=C):C=N[46],N[47]!==z||N[48]!==h||N[49]!==C||N[50]!==m?(_=(0,n.jsx)("div",{className:"w-full max-w-full overflow-hidden",children:(0,n.jsx)("div",{role:"button",tabIndex:0,onClick:z,onKeyDown:m,className:h,children:C})}),N[47]=z,N[48]=h,N[49]=C,N[50]=m,N[51]=_):_=N[51],_};function ez(e){return e.activeArtifactId}let eL=(0,es.createSelector)([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):[]),eD=(0,u.memo)(()=>{let e,t,r,a,o=(0,s.c)(10),l=(0,p.useChatroomStore)((0,ek.useShallow)(eL));if(!(0,p.useChatroomStore)(eB))return null;if(0===l.length){let e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"flex flex-1 items-center justify-center p-4 text-center text-xs text-muted-foreground",children:"No versions have been created yet."}),o[0]=e):e=o[0],e}return o[1]!==l.length?(e=(0,n.jsx)("div",{className:"p-2",children:(0,n.jsxs)("h4",{className:"text-xs font-semibold text-muted-foreground px-2",children:["VERSIONS (",l.length,")"]})}),o[1]=l.length,o[2]=e):e=o[2],o[3]!==l?(t=l.map(eV),o[3]=l,o[4]=t):t=o[4],o[5]!==t?(r=(0,n.jsx)("div",{className:"px-2 flex flex-col gap-1 overflow-y-auto",children:t}),o[5]=t,o[6]=r):r=o[6],o[7]!==e||o[8]!==r?(a=(0,n.jsxs)("div",{className:"flex flex-1 flex-col min-h-0",children:[e,r]}),o[7]=e,o[8]=r,o[9]=a):a=o[9],a},()=>!0);function eB(e){return e.activeArtifactId}function eV(e){return(0,n.jsx)(eR,{versionId:e},e)}var eU=e.i(797738),eG=e.i(558200),eH=e.i(963),eq=e.i(778084),eW=e.i(834814),eK=e.i(784510),eY=e.i(706527),eX=e.i(461790),eZ=e.i(179273),eJ=e.i(888887),eQ=e.i(562443);function e0(e){let t,r,a,o,l,c,u,d=(0,s.c)(16),{character:m,name:f,onRemove:h}=e;d[0]!==m?(t=(0,n.jsx)(eQ.ChatroomCharacterAvatar,{character:m,className:"size-5 shrink-0"}),d[0]=m,d[1]=t):t=d[1],d[2]!==f?(r=(0,n.jsx)("span",{className:"truncate",children:f}),d[2]=f,d[3]=r):r=d[3],d[4]!==t||d[5]!==r?(a=(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[t,r]}),d[4]=t,d[5]=r,d[6]=a):a=d[6],d[7]!==h?(o=e=>{e.stopPropagation(),e.preventDefault(),h()},d[7]=h,d[8]=o):o=d[8];let p=`Remove ${f}`;return d[9]===Symbol.for("react.memo_cache_sentinel")?(l=(0,n.jsx)(eG.XMarkIcon,{className:"size-4"}),d[9]=l):l=d[9],d[10]!==o||d[11]!==p?(c=(0,n.jsx)(i.Button,{variant:"ghost",size:"icon-sm",className:"shrink-0 opacity-0 hover:bg-destructive/20 hover:text-destructive group-hover:opacity-100",onClick:o,"aria-label":p,children:l}),d[10]=o,d[11]=p,d[12]=c):c=d[12],d[13]!==a||d[14]!==c?(u=(0,n.jsxs)("div",{className:"group flex w-full items-center justify-between gap-2",children:[a,c]}),d[13]=a,d[14]=c,d[15]=u):u=d[15],u}function e1(e){let t,r,a,o,c,d,m,f,h,p,g,x,v,y=(0,s.c)(38),{triggerLabel:b,triggerAvatar:w,items:S,activeId:j,onSelect:C,onRemove:_,onAddNew:N,className:k}=e,[I,E]=(0,u.useState)(!1);y[0]!==k?(t=(0,l.cn)("relative inline-block",k),y[0]=k,y[1]=t):t=y[1],y[2]!==w?(r=w?(0,n.jsx)(eQ.ChatroomCharacterAvatar,{character:w,className:"size-5 shrink-0"}):null,y[2]=w,y[3]=r):r=y[3];let A=b??"Select a model";if(y[4]!==A?(a=(0,n.jsx)("span",{className:"truncate",children:A}),y[4]=A,y[5]=a):a=y[5],y[6]!==r||y[7]!==a?(o=(0,n.jsx)(eq.PopoverTrigger,{render:(0,n.jsx)(i.Button,{variant:"outline",size:"sm",className:"min-w-0 max-w-[200px] md:max-w-none overflow-hidden",children:(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2 truncate",children:[r,a]})})}),y[6]=r,y[7]=a,y[8]=o):o=y[8],y[9]!==j||y[10]!==S||y[11]!==_||y[12]!==C){let e;y[14]!==j||y[15]!==_||y[16]!==C?(e=e=>{let t=e.id===j,r=()=>{C(e.id),E(!1)};return(0,n.jsx)("div",{className:(0,l.cn)("relative flex w-full cursor-pointer select-none items-center rounded-xs px-3 py-1.5 text-sm outline-hidden hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",t&&"bg-accent text-accent-foreground"),role:"option","aria-selected":t,tabIndex:0,onClick:r,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),r())},children:(0,n.jsx)(e0,{character:e.character,name:e.label,onRemove:()=>{_(e.id)}})},e.id)},y[14]=j,y[15]=_,y[16]=C,y[17]=e):e=y[17],c=S.map(e),y[9]=j,y[10]=S,y[11]=_,y[12]=C,y[13]=c}else c=y[13];return y[18]!==S.length?(d=S.length>0?(0,n.jsx)(eW.Separator,{}):null,y[18]=S.length,y[19]=d):d=y[19],y[20]!==N?(m=()=>{N(),E(!1)},f=e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),N(),E(!1))},y[20]=N,y[21]=m,y[22]=f):(m=y[21],f=y[22]),y[23]===Symbol.for("react.memo_cache_sentinel")?(h=(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(eU.PlusIcon,{className:"size-4"}),(0,n.jsx)("span",{className:"text-sm",children:"Add Model"})]}),y[23]=h):h=y[23],y[24]!==m||y[25]!==f?(p=(0,n.jsx)(i.Button,{variant:"ghost",size:"md",className:"w-full justify-start",onClick:m,onKeyDown:f,children:h}),y[24]=m,y[25]=f,y[26]=p):p=y[26],y[27]!==p||y[28]!==c||y[29]!==d?(g=(0,n.jsx)(eq.PopoverContent,{side:"bottom",align:"start",sideOffset:4,collisionPadding:8,className:"w-[220px] max-h-96 min-w-[8rem] overflow-auto rounded-md p-1",children:(0,n.jsxs)("div",{role:"listbox",className:"flex flex-col gap-0.5",children:[c,d,p]})}),y[27]=p,y[28]=c,y[29]=d,y[30]=g):g=y[30],y[31]!==I||y[32]!==g||y[33]!==o?(x=(0,n.jsxs)(eq.Popover,{open:I,onOpenChange:E,children:[o,g]}),y[31]=I,y[32]=g,y[33]=o,y[34]=x):x=y[34],y[35]!==t||y[36]!==x?(v=(0,n.jsx)("div",{className:t,children:x}),y[35]=t,y[36]=x,y[37]=v):v=y[37],v}function e2(){let e,t,r,a,o,l,i,c,d,m,f,g,x,v,y,b=(0,s.c)(44),w=(0,W.useMediaMd)(),{getEndpointDisplayName:S,getModelInfoByVariantSlug:j}=(0,eK.useGlobal)(),[C,_]=(0,u.useState)(!1),N=(0,p.useChatroomStore)(H.selectActiveArtifactId),k=(0,p.useChatroomStore)(h.selectCurrentRoomId);b[0]!==N?(e=e=>N?e.artifacts[N]:null,b[0]=N,b[1]=e):e=b[1];let I=(0,p.useChatroomStore)(e);b[2]!==k?(t=e=>(k?e.rooms[k]?.characters:{})??{},b[2]=k,b[3]=t):t=b[3];let E=(0,p.useChatroomStore)(t);I?.characterIds,b[4]!==I?.characterIds||b[5]!==E?(r=I?.characterIds?.map(e=>E[e]).filter(e4)??[],b[4]=I?.characterIds,b[5]=E,b[6]=r):r=b[6];let A=r;if(b[7]!==A||b[8]!==S){let e;b[10]!==S?(e=e=>{let t=e.model||e.modelInfo&&(0,eY.getModelVariantSlug)(e.modelInfo),r=t?(0,eX.getStandardSlug)(t):void 0,n=t?(0,eZ.getStaticVariant)(t):void 0,s=e.name||e.presetName||S({slug:r,variant:n,providerName:e.provider});return{id:e.id,character:e,name:s}},b[10]=S,b[11]=e):e=b[11],a=A.map(e),b[7]=A,b[8]=S,b[9]=a}else a=b[9];let F=a,M=I?.activeCharacterId??null;if(b[12]!==M||b[13]!==F){let e;b[15]!==M?(e=e=>e.id===M,b[15]=M,b[16]=e):e=b[16],o=F.find(e),b[12]=M,b[13]=F,b[14]=o}else o=b[14];let $=o;b[17]!==N?(l=e=>{if(N){if("add-new-model"===e)return void _(!0);K.chatroomStoreActions.setActiveCharacterForArtifact({payload:{artifactId:N,characterId:e}})}},b[17]=N,b[18]=l):l=b[18];let T=l;b[19]!==N||b[20]!==j||b[21]!==k?(i=async e=>{if(_(!1),!k||!N)return;let t=(0,eY.getModelVariantSlug)(e),r=j(t),n=await K.chatroomStoreActions.addCharacters({payload:{roomId:k,characters:[{model:t,modelInfo:r,samplingParameters:{},artifactId:N}]}}),s=n?.characterIds?.[0];s&&K.chatroomStoreActions.setActiveCharacterForArtifact({payload:{artifactId:N,characterId:s}})},b[19]=N,b[20]=j,b[21]=k,b[22]=i):i=b[22];let P=i;b[23]!==N?(c=e=>{!N||window.confirm("Are you sure you want to remove this model from the artifact?")&&K.chatroomStoreActions.removeCharacterFromArtifact({payload:{artifactId:N,characterId:e}})},b[23]=N,b[24]=c):c=b[24];let O=c;if(!k||!N)return null;let R=$?.name??null,z=$?.character??null;return b[25]!==F?(d=F.map(e3),b[25]=F,b[26]=d):d=b[26],b[27]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{_(!0)},b[27]=m):m=b[27],b[28]!==M||b[29]!==T||b[30]!==O||b[31]!==d||b[32]!==R||b[33]!==z?(f=(0,n.jsx)(e1,{className:"align-top",triggerLabel:R,triggerAvatar:z,items:d,activeId:M,onSelect:T,onRemove:O,onAddNew:m}),b[28]=M,b[29]=T,b[30]=O,b[31]=d,b[32]=R,b[33]=z,b[34]=f):f=b[34],b[35]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{_(!1)},b[35]=g):g=b[35],b[36]===Symbol.for("react.memo_cache_sentinel")?(x=(0,n.jsx)("div",{}),b[36]=x):x=b[36],b[37]!==P||b[38]!==C||b[39]!==w?(v=(0,n.jsx)(eJ.ModelSelect,{isDialog:w,isMobileSideDrawer:!0,isForceOpen:C,onBlur:g,filter:e5,onDone:P,showGuardrailsWarning:!0,hideUnavailableByDefault:!0,children:x}),b[37]=P,b[38]=C,b[39]=w,b[40]=v):v=b[40],b[41]!==f||b[42]!==v?(y=(0,n.jsxs)(n.Fragment,{children:[f,v]}),b[41]=f,b[42]=v,b[43]=y):y=b[43],y}function e5(e){return(0,eH.isChattableModel)(e.output_modalities)}function e3(e){return{id:e.id,label:e.name,character:e.character}}function e4(e){return!!e}function e6(e){let t,r,a,o,c,d,m,f,h=(0,s.c)(15),{artifactId:p}=e,[g,x]=(0,u.useState)(!1);h[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(i.Button,{variant:"ghost",size:"icon",onClick:e7,"aria-label":"Close workspace",children:(0,n.jsx)(X.ArrowLeftIcon,{className:"size-4"})}),h[0]=t):t=h[0],h[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("div",{className:"flex-1 min-w-0 flex justify-center",children:(0,n.jsx)(e2,{})}),h[1]=r):r=h[1],h[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>x(e8),h[2]=a):a=h[2];let v=g?"Show Chat":"Show Version History";return h[3]!==g?(o=g?(0,n.jsx)(Z.ChatBubbleLeftRightIcon,{className:"size-5"}):(0,n.jsx)(J.ClockIcon,{className:"size-5"}),h[3]=g,h[4]=o):o=h[4],h[5]!==v||h[6]!==o?(c=(0,n.jsxs)("div",{className:"flex items-center gap-1.5 p-2 pl-0 m-px shrink-0 bg-background",children:[t,r,(0,n.jsx)(i.Button,{variant:"ghost",size:"icon",onClick:a,title:v,children:o})]}),h[5]=v,h[6]=o,h[7]=c):c=h[7],h[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,l.cn)("flex-1 min-h-0 overflow-hidden","bg-muted border border-border border-b-0","md:rounded-tl-2xl"),h[8]=d):d=h[8],h[9]!==p||h[10]!==g?(m=(0,n.jsx)("div",{className:d,children:(0,n.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:g?(0,n.jsx)(eD,{}):(0,n.jsx)(e$,{artifactId:p})})}),h[9]=p,h[10]=g,h[11]=m):m=h[11],h[12]!==c||h[13]!==m?(f=(0,n.jsxs)(n.Fragment,{children:[c,m]}),h[12]=c,h[13]=m,h[14]=f):f=h[14],f}function e8(e){return!e}function e7(){return K.chatroomStoreActions.closeArtifactView()}var e9=e.i(462904),te=e.i(559802),tt=e.i(709687),tr=e.i(336422),tn=e.i(204067),ts=e.i(447680),ta=e.i(2247);let to=new Set(["null"]);var tl=e.i(999974);function ti(e){let t,r,a,o,l,i,c,u=(0,s.c)(17),{title:d,subtitle:m,hint:f,showShimmer:h}=e,p=void 0===h||h,g=!!p||void 0;return u[0]!==d?(t=(0,n.jsx)("div",{className:"text-lg font-medium tracking-tight text-foreground md:text-xl",children:d}),u[0]=d,u[1]=t):t=u[1],u[2]!==m?(r=m?(0,n.jsx)("p",{className:"text-sm text-muted-foreground md:text-base",children:m}):null,u[2]=m,u[3]=r):r=u[3],u[4]!==p?(a=p?(0,n.jsx)("div",{className:"h-2 w-2/3 max-w-md overflow-hidden rounded-full bg-muted md:max-w-lg",children:(0,n.jsx)("div",{className:"h-full w-1/3 animate-[previewShimmer_1200ms_ease-in-out_infinite] motion-reduce:animate-none bg-primary"})}):null,u[4]=p,u[5]=a):a=u[5],u[6]!==f?(o=f?(0,n.jsx)("p",{className:"text-muted-foreground/80 text-sm",children:f}):null,u[6]=f,u[7]=o):o=u[7],u[8]===Symbol.for("react.memo_cache_sentinel")?(l=(0,n.jsx)(tl.default,{id:"d0cb2b6ec0de213f",children:"@keyframes previewShimmer{0%{transform:translate(-150%)}to{transform:translate(350%)}}"}),u[8]=l):l=u[8],u[9]!==t||u[10]!==r||u[11]!==a||u[12]!==o?(i=(0,n.jsxs)("div",{className:"flex max-w-2xl flex-col items-center gap-3 px-4 text-center md:gap-4 md:px-8",children:[t,r,a,o,l]}),u[9]=t,u[10]=r,u[11]=a,u[12]=o,u[13]=i):i=u[13],u[14]!==g||u[15]!==i?(c=(0,n.jsx)("div",{className:"h-full w-full flex items-center justify-center",role:"status","aria-live":"polite","aria-busy":g,children:i}),u[14]=g,u[15]=i,u[16]=c):c=u[16],c}var tc=e.i(527315);function tu(e){let t,r,a,o,l,c,u,d,m=(0,s.c)(14),{artifactId:f,versionId:h,error:p}=e;m[0]!==f||m[1]!==h?(t=()=>{K.chatroomStoreActions.fixArtifactVersionError({payload:{artifactId:f,versionId:h}})},m[0]=f,m[1]=h,m[2]=t):t=m[2];let g=t;return m[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-destructive/10 text-destructive",children:(0,n.jsx)(tc.ExclamationTriangleIcon,{className:"h-5 w-5"})}),m[3]=r):r=m[3],m[4]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Preview Error"}),o=(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check the error below and try the automatic fix."}),m[4]=a,m[5]=o):(a=m[4],o=m[5]),m[6]!==p?(l=(0,n.jsx)("pre",{className:"mt-3 max-h-60 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:p}),m[6]=p,m[7]=l):l=m[7],m[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)(ef.SparklesIcon,{className:"h-4 w-4"}),m[8]=c):c=m[8],m[9]!==g?(u=(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsxs)(i.Button,{variant:"default",size:"sm",onClick:g,children:[c,"Try to Fix"]})}),m[9]=g,m[10]=u):u=m[10],m[11]!==l||m[12]!==u?(d=(0,n.jsx)("div",{className:"h-full w-full flex items-center justify-center p-6",children:(0,n.jsx)("div",{className:"max-w-2xl w-full px-4",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[r,(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[a,o,l,u]})]})})}),m[11]=l,m[12]=u,m[13]=d):d=m[13],d}let td=(0,es.createSelector)([H.selectAllArtifactVersions,H.selectActiveArtifactVersionId],(e,t)=>t?e[t]:void 0);function tm(){let e,t,r,a,o=(0,s.c)(25),i=(0,p.useChatroomStore)(H.selectActiveArtifact),c=(0,p.useChatroomStore)(td),d=(0,u.useRef)(null),[m,h]=(0,u.useState)(null),[g,x]=(0,u.useState)(!1),v=i?.id??null,y=c?.id??null,b=m?.key;o[0]!==v||o[1]!==y||o[2]!==b?(e={iframeRef:d,artifactId:v,versionId:y,dependencyKey:b},o[0]=v,o[1]=y,o[2]=b,o[3]=e):e=o[3],function(e){let t,r,n=(0,s.c)(9),{iframeRef:a,artifactId:o,versionId:l,dependencyKey:i}=e;n[0]!==o||n[1]!==a||n[2]!==l?(t=()=>{let e=async function(e){var t,r;let n=a.current;if(!n||e.source!==n.contentWindow||!to.has(e.origin))return;let s=(0,tn.parseSchema)(ta.IncomingIframeMessageSchema,e.data);if((0,en.isErr)(s))return;let i=s.data;if(!o)return;let c=e=>{n.contentWindow?.postMessage({...e,type:ta.IframeEventType.StorageResponse},"*")},u=i.type;switch(u){case ta.IframeEventType.StorageGetItem:{let e=await (0,en.wrap)(()=>ts.persistence.getArtifactData(o,i.key));if((0,en.isErr)(e)){if((t=e.error)instanceof DOMException&&"AbortError"===t.name)return void c({requestId:i.requestId,value:null});c({requestId:i.requestId,error:e.error instanceof Error?e.error.message:String(e.error??"Unknown error")});return}c({requestId:i.requestId,value:e.data});return}case ta.IframeEventType.StorageSetItem:return void await (0,en.wrap)(()=>ts.persistence.setArtifactData(o,i.key,i.value));case ta.IframeEventType.StorageRemoveItem:return void await (0,en.wrap)(()=>ts.persistence.removeArtifactData(o,i.key));case ta.IframeEventType.StorageClear:return void await (0,en.wrap)(()=>ts.persistence.clearArtifactData(o));case ta.IframeEventType.RuntimeError:{if(!l)return;let e=function(e){let t=p.useChatroomStore.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}(l),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}(i.error,e);if(!("string"==typeof(r=i.error)&&r.includes("SyntaxError"))&&!t)return;K.chatroomStoreActions.reportArtifactVersionError({payload:{artifactId:o,versionId:l,error:i.error??""}});return}default:(0,tr.assertNever)(u)}},t=function(t){(0,en.wrap)(()=>e(t))};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},n[0]=o,n[1]=a,n[2]=l,n[3]=t):t=n[3],n[4]!==o||n[5]!==i||n[6]!==a||n[7]!==l?(r=[a,o,l,i],n[4]=o,n[5]=i,n[6]=a,n[7]=l,n[8]=r):r=n[8],(0,u.useEffect)(t,r)}(e),o[4]!==i||o[5]!==c?(t=()=>{(async()=>{if(!c||!i||i.type!==f.ArtifactType.App||!c||void 0!==c.generationStatus&&c.generationStatus!==f.GenerationStatus.Success||c.error){x(!1),h(null);return}await new Promise(tf),x(!0),h(null);let e=p.useChatroomStore.getState(),t=tt.useArtifactStore.getState().artifactContent,r=(0,H.selectFilesForPreview)(e,{versionId:c.id});if(0===r.length)return x(!1);let n=[];for(let o of r){var s,a;let r=e.artifactVersions[c.id]?.fileContents[o.id];if(!r)return void x(!1);let l=(s=t[r],a=e.artifactFileContents[r]?.content,"string"==typeof s?s:"string"==typeof a?a:"");n.push({path:o.filename,content:l})}let o=await (0,te.createPreview)(n);if((0,en.isErr)(o)){let e=(0,e9.makeErrorT)({location:"VersionPreview:createPreview",rawError:o.error}).message??"An unknown error occurred during preview generation.";i?.id&&c.id&&K.chatroomStoreActions.reportArtifactVersionError({payload:{artifactId:i.id,versionId:c.id,error:e}}),h(null);return}h(o.data),x(!1)})()},o[4]=i,o[5]=c,o[6]=t):t=o[6];let w=c?.id;if(o[7]!==i||o[8]!==w||o[9]!==c?(r=[w,i,c],o[7]=i,o[8]=w,o[9]=c,o[10]=r):r=o[10],(0,u.useEffect)(t,r),!i||i.type!==f.ArtifactType.App){let e;return o[11]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(ti,{title:"Preview unavailable",subtitle:"No app artifact selected",showShimmer:!1}),o[11]=e):e=o[11],e}if(!c){let e;return o[12]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(ti,{title:"Preview unavailable",subtitle:"No version is currently selected",showShimmer:!1}),o[12]=e):e=o[12],e}if(c.generationStatus===f.GenerationStatus.Generating){let e;return o[13]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(ti,{title:"Generating version",subtitle:"Applying your instructions",hint:"The preview will appear here once it is ready."}),o[13]=e):e=o[13],e}if(c.error){let e;return o[14]!==i.id||o[15]!==c.error||o[16]!==c.id?(e=(0,n.jsx)(tu,{artifactId:i.id,versionId:c.id,error:c.error}),o[14]=i.id,o[15]=c.error,o[16]=c.id,o[17]=e):e=o[17],e}if(c.generationStatus===f.GenerationStatus.Failed){let e;return o[18]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-sm text-destructive",children:"An error occurred during generation."}),o[18]=e):e=o[18],e}if(g){let e;return o[19]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(ti,{title:"Preparing preview",subtitle:"Bundling files for the sandbox",hint:"This usually takes a few seconds."}),o[19]=e):e=o[19],e}if(m){let e,t;return o[20]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.cn)("relative h-full w-full","flex flex-col"),o[20]=e):e=o[20],o[21]!==m.key||o[22]!==m.srcDoc?(t=(0,n.jsx)("div",{className:e,children:(0,n.jsx)("div",{className:"relative flex-1 min-h-0",children:(0,n.jsx)("iframe",{ref:d,title:"Artifact Preview",className:"h-full w-full border-0",srcDoc:m.srcDoc,sandbox:"allow-scripts allow-modals allow-forms allow-pointer-lock allow-popups",loading:"lazy"},m.key)})}),o[21]=m.key,o[22]=m.srcDoc,o[23]=t):t=o[23],t}return o[24]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)(ti,{title:"No files to preview",subtitle:"This version does not contain any previewable files",showShimmer:!1}),o[24]=a):a=o[24],a}function tf(e){requestAnimationFrame(()=>e())}var th=e.i(540191);function tp(e){let t=tt.useArtifactStore.subscribe(e),r=p.useChatroomStore.subscribe(e);return()=>{t(),r()}}var tg=e.i(933975),tx=e.i(128341),tv=e.i(508701),ty=e.i(952384);let tb="folder:";function tw(e){let t,r,a=(0,s.c)(3),{children:o}=e,l=(0,u.useRef)(null),i=(0,u.useRef)(null);return a[0]===Symbol.for("react.memo_cache_sentinel")?(t={scrollContainerRef:l,contentRef:i},a[0]=t):t=a[0],(0,eI.useAutoScroll)(t),a[1]!==o?(r=(0,n.jsx)("div",{ref:l,className:"h-full overflow-auto bg-background",children:(0,n.jsx)("div",{className:"h-full",ref:i,children:o})}),a[1]=o,a[2]=r):r=a[2],r}function tS(e){let t,r,a,o=(0,s.c)(13),{activeFileId:l,files:i,content:c}=e,{resolvedTheme:u}=(0,tx.useTheme)();o[0]!==l||o[1]!==i?(t=l?i.find(e=>e.id===l):void 0,o[0]=l,o[1]=i,o[2]=t):t=o[2];let d=t;if(!d){let e;return o[3]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:"Select a file from the sidebar to view its content."}),o[3]=e):e=o[3],e}if("string"!=typeof c){let e;return o[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"flex h-full w-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:"No content available for this file in the selected version."}),o[4]=e):e=o[4],e}o[5]!==d.type?(r=function(e){switch(e){case f.FileType.TypeScript:return"typescript";case f.FileType.HTML:return"html";case f.FileType.CSS:return"css";case f.FileType.JSON:return"json";case f.FileType.Markdown:return"markdown";case f.FileType.JavaScript:case f.FileType.JSX:return"javascript";default:return"text"}}(d.type),o[5]=d.type,o[6]=r):r=o[6];let m=r,h=c;if("html"===m)if(o[7]!==h){let e=h.toLowerCase().indexOf("");e>0&&(h=h.substring(e)),o[7]=h,o[8]=h}else h=o[8];let p="dark"===u?"github-dark":"github-light";return o[9]!==h||o[10]!==m||o[11]!==p?(a=(0,n.jsx)(tw,{children:(0,n.jsx)(tg.ShikiHighlighter,{roundedCorners:!1,border:!1,code:h,lang:m,theme:p})}),o[9]=h,o[10]=m,o[11]=p,o[12]=a):a=o[12],a}function tj(e){return!e.startsWith(tb)}function tC(e){let t,r,a,o,l,c,d,m,f,h,g,x,v,y,b,w,S,j=(0,s.c)(71),{activeVersionId:C}=e,_=(0,W.useMediaMd)(),[N,k]=(0,u.useState)(!1),I=(0,p.useChatroomStore)(H.selectActiveArtifactId);j[0]!==C?(t=e=>(0,H.selectFilesForVersion)(e,{versionId:C}),j[0]=C,j[1]=t):t=j[1];let E=(0,p.useChatroomStore)(t),A=(0,p.useChatroomStore)(H.selectActiveFileId),F=(0,p.useChatroomStore)(tN),M=(0,p.useChatroomStore)(t_);j[2]!==I?(r=e=>e.artifactViewerState[I??""]?.expandedFolders??{},j[2]=I,j[3]=r):r=j[3];let $=(0,p.useChatroomStore)(r);j[4]!==$?(a=$?Object.keys($):[],j[4]=$,j[5]=a):a=j[5];let T=a;j[6]!==C||j[7]!==M||j[8]!==F||j[9]!==E?(o=function({files:e,activeVersionId:t,allVersions:r,allFileContents:n}){let s=[],a=new Set,o=e=>{let t=e.split("/").filter(Boolean),r=[];for(let e=0;e1?`${tb}${r.slice(0,-1).join("/")}`:null,l=H.selectFileStatusForVersion.resultFunc(c,n,t.id);s.push({id:t.id,label:r.at(-1)??t.filename,parentId:a,status:"idle"===l?void 0:l})}return s}({files:E,activeVersionId:C,allVersions:F,allFileContents:M}),j[6]=C,j[7]=M,j[8]=F,j[9]=E,j[10]=o):o=j[10];let P=o;j[11]!==I||j[12]!==E?(l={artifactId:I,files:E},j[11]=I,j[12]=E,j[13]=l):l=j[13];let{onSelectionChange:O,onToggle:R,onRename:z,onDelete:L}=function(e){let t,r,n,a,o,l=(0,s.c)(14),{artifactId:i,files:c}=e;l[0]!==i?(t=e=>{if(!i)return;let t=e[0]??null,r=!!t?.startsWith(tb);K.chatroomStoreActions.setActiveFileId({payload:{artifactId:i,fileId:r?null:t}})},l[0]=i,l[1]=t):t=l[1];let u=t;l[2]!==i?(r=e=>{if(!i||!e.id.startsWith(tb))return;let t={...p.useChatroomStore.getState().artifactViewerState[i]?.expandedFolders??{}};e.expanded?t[e.id]=!0:delete t[e.id],K.chatroomStoreActions.setExpandedFolders({payload:{artifactId:i,expandedFolders:t}})},l[2]=i,l[3]=r):r=l[3];let d=r;l[4]!==i||l[5]!==c?(n=e=>{var t;let r,{id:n,nextLabel:s}=e;if(!i||n.startsWith(tb))return;let a=c.find(e=>e.id===n);if(!a)return;let o=(0,ty.normalizePath)(s);if(!(0,ty.isPathSafe)(o))return;let l=o.includes("/")?o:(t=a.filename,(r=(0,ty.normalizePath)(t).split("/").filter(Boolean)).length<=1?o:(r[r.length-1]=o,r.join("/")));K.chatroomStoreActions.renameArtifactFile({payload:{artifactId:i,fileId:a.id,newName:(0,ty.normalizePath)(l)}})},l[4]=i,l[5]=c,l[6]=n):n=l[6];let m=n;l[7]!==i?(a=e=>{let{ids:t}=e;if(!i)return;let r=t.filter(tj);if(0!==r.length&&globalThis.confirm(1===r.length?"Delete this file? This action cannot be undone.":`Delete ${r.length} files? This action cannot be undone.`))for(let e of r)K.chatroomStoreActions.deleteArtifactFile({payload:{artifactId:i,fileId:e}})},l[7]=i,l[8]=a):a=l[8];let f=a;return l[9]!==f||l[10]!==m||l[11]!==u||l[12]!==d?(o={onSelectionChange:u,onToggle:d,onRename:m,onDelete:f},l[9]=f,l[10]=m,l[11]=u,l[12]=d,l[13]=o):o=l[13],o}(l),D=((b=(0,s.c)(6))[0]!==A||b[1]!==C?(v=()=>{if(!C||!A)return null;let e=p.useChatroomStore.getState(),t=(0,H.selectVersionById)(e,{versionId:C}),r=t?.fileContents[A];if(!r)return null;let n=tt.useArtifactStore.getState().artifactContent[r];return"string"==typeof n?n:(0,H.selectArtifactFileContent)(e,{versionId:C,fileId:A})},b[0]=A,b[1]=C,b[2]=v):v=b[2],w=v,b[3]!==A||b[4]!==C?(y=()=>C&&A?(0,H.selectArtifactFileContent)(p.useChatroomStore.getState(),{versionId:C,fileId:A}):null,b[3]=A,b[4]=C,b[5]=y):y=b[5],S=y,(0,u.useSyncExternalStore)(tp,w,S));j[14]!==A||j[15]!==E?(c=function(e,t){if(!t)return"";let r=e.find(e=>e.id===t);return r?(0,ty.normalizePath)(r.filename).split("/").filter(Boolean).at(-1)??r.filename:""}(E,A),j[14]=A,j[15]=E,j[16]=c):c=j[16];let B=c;if(j[17]!==B){let e;e=B&&B.length>0?B:"file",d=(0,tv.getFileIconForLabel)(e),j[17]=B,j[18]=d}else d=j[18];let V=d;if(!_){let e,t,r,s,a,o,l,c,u,d,m=B?`Current file: ${B}`:"Select a file";j[19]!==V?(e=(0,n.jsx)("span",{className:"shrink-0","aria-hidden":!0,children:V}),j[19]=V,j[20]=e):e=j[20];let f=B||"Select a file";j[21]!==f?(t=(0,n.jsx)("span",{className:"truncate",children:f}),j[21]=f,j[22]=t):t=j[22],j[23]!==t||j[24]!==e?(r=(0,n.jsxs)("span",{className:"flex items-center gap-2 min-w-0",children:[e,t]}),j[23]=t,j[24]=e,j[25]=r):r=j[25],j[26]!==r||j[27]!==m?(s=(0,n.jsx)(eq.PopoverTrigger,{render:(0,n.jsx)(i.Button,{size:"sm",variant:"outline",className:"min-w-0 max-w-[85vw] truncate justify-start","aria-label":m,children:r})}),j[26]=r,j[27]=m,j[28]=s):s=j[28],j[29]!==A?(a=A?[A]:[],j[29]=A,j[30]=a):a=j[30],j[31]!==O?(o=e=>{let{selectedIds:t}=e;O(t),k(!1)},j[31]=O,j[32]=o):o=j[32],j[33]!==T||j[34]!==L||j[35]!==z||j[36]!==R||j[37]!==a||j[38]!==o||j[39]!==P?(l=(0,n.jsx)(eq.PopoverContent,{align:"start",side:"bottom",sideOffset:6,collisionPadding:8,className:"w-[85vw] max-w-sm max-h-[70vh] overflow-auto p-1",children:(0,n.jsx)(th.FileTree,{items:P,defaultSelectedIds:a,defaultExpandedIds:T,onSelectionChange:o,onToggle:R,onRename:z,onDelete:L})}),j[33]=T,j[34]=L,j[35]=z,j[36]=R,j[37]=a,j[38]=o,j[39]=P,j[40]=l):l=j[40],j[41]!==N||j[42]!==s||j[43]!==l?(c=(0,n.jsx)("div",{className:"flex items-center justify-between gap-2 p-2 pt-0 border-b border-border",children:(0,n.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:(0,n.jsxs)(eq.Popover,{open:N,onOpenChange:k,children:[s,l]})})}),j[41]=N,j[42]=s,j[43]=l,j[44]=c):c=j[44];let h="string"==typeof D?D:null;return j[45]!==A||j[46]!==E||j[47]!==h?(u=(0,n.jsx)("div",{className:"flex-1 min-h-0",children:(0,n.jsx)(tS,{activeFileId:A,files:E,content:h})}),j[45]=A,j[46]=E,j[47]=h,j[48]=u):u=j[48],j[49]!==c||j[50]!==u?(d=(0,n.jsxs)("div",{className:"flex h-full w-full flex-col bg-background",children:[c,u]}),j[49]=c,j[50]=u,j[51]=d):d=j[51],d}j[52]!==A?(m=A?[A]:[],j[52]=A,j[53]=m):m=j[53],j[54]!==O?(f=e=>{let{selectedIds:t}=e;O(t)},j[54]=O,j[55]=f):f=j[55],j[56]!==T||j[57]!==L||j[58]!==z||j[59]!==R||j[60]!==m||j[61]!==f||j[62]!==P?(h=(0,n.jsx)("aside",{className:"w-64 shrink-0 border-r border-border bg-background overflow-auto",children:(0,n.jsx)(th.FileTree,{items:P,defaultSelectedIds:m,defaultExpandedIds:T,onSelectionChange:f,onToggle:R,onRename:z,onDelete:L})}),j[56]=T,j[57]=L,j[58]=z,j[59]=R,j[60]=m,j[61]=f,j[62]=P,j[63]=h):h=j[63];let U="string"==typeof D?D:null;return j[64]!==A||j[65]!==E||j[66]!==U?(g=(0,n.jsx)("main",{className:"grow min-w-0",children:(0,n.jsx)(tS,{activeFileId:A,files:E,content:U})}),j[64]=A,j[65]=E,j[66]=U,j[67]=g):g=j[67],j[68]!==h||j[69]!==g?(x=(0,n.jsxs)("div",{className:"flex h-full w-full bg-background",children:[h,g]}),j[68]=h,j[69]=g,j[70]=x):x=j[70],x}function t_(e){return e.artifactFileContents}function tN(e){return e.artifactVersions}let tk=(0,u.memo)(function(){let e,t=(0,s.c)(3),r=(0,p.useChatroomStore)(H.selectActiveArtifactView),a=(0,p.useChatroomStore)(H.selectActiveArtifactVersionId)??null;if(r===f.ArtifactView.Editor){let e;return t[0]!==a?(e=(0,n.jsx)(tC,{activeVersionId:a}),t[0]=a,t[1]=e):e=t[1],e}return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(tm,{}),t[2]=e):e=t[2],e});var tI=e.i(649188);let tE=u.forwardRef(function({title:e,titleId:t,...r},n){return u.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?u.createElement("title",{id:t},e):null,u.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 tA=e.i(536652);function tF(){let e,t,r,a,o,c,u,d,m=(0,s.c)(19),h=(0,p.useChatroomStore)(H.selectActiveArtifactId),g=(0,p.useChatroomStore)(H.selectActiveArtifactView);m[0]!==h?(e=e=>{h&&K.chatroomStoreActions.setActiveArtifactView({payload:{artifactId:h,view:e}})},m[0]=h,m[1]=e):e=m[1];let x=e;m[2]!==x?(t=()=>x(f.ArtifactView.Editor),m[2]=x,m[3]=t):t=m[3];let v=g===f.ArtifactView.Editor?"bg-accent text-accent-foreground":"text-muted-foreground";m[4]!==v?(r=(0,l.cn)("text-sm",v),m[4]=v,m[5]=r):r=m[5],m[6]!==t||m[7]!==r?(a=(0,n.jsx)(i.Button,{size:"md",variant:"ghost",onClick:t,className:r,children:"Output"}),m[6]=t,m[7]=r,m[8]=a):a=m[8],m[9]!==x?(o=()=>x(f.ArtifactView.Preview),m[9]=x,m[10]=o):o=m[10];let y=g===f.ArtifactView.Preview?"bg-accent text-accent-foreground":"text-muted-foreground";return m[11]!==y?(c=(0,l.cn)("text-sm",y),m[11]=y,m[12]=c):c=m[12],m[13]!==o||m[14]!==c?(u=(0,n.jsx)(i.Button,{size:"md",variant:"ghost",onClick:o,className:c,children:"Preview"}),m[13]=o,m[14]=c,m[15]=u):u=m[15],m[16]!==a||m[17]!==u?(d=(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[a,u]}),m[16]=a,m[17]=u,m[18]=d):d=m[18],d}function tM(e){let t,r,a,o,c,u,d,m,f,h,p,g=(0,s.c)(27),{name:x,versionNumber:v,isFullscreen:y,onToggleFullscreen:b,showViewSwitcher:w,artifactId:S,activeVersionId:j}=e,C=void 0!==y&&y,_=void 0===w||w;g[0]!==j||g[1]!==S?(t=()=>{S&&j&&K.chatroomStoreActions.downloadArtifactVersion({payload:{artifactId:S,versionId:j}})},g[0]=j,g[1]=S,g[2]=t):t=g[2];let N=t;g[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,l.cn)("flex p-2 m-px items-center justify-between shrink-0","bg-background"),g[3]=r):r=g[3],g[4]!==x?(a=(0,n.jsx)("span",{className:"font-semibold text-base truncate",title:x,children:x}),g[4]=x,g[5]=a):a=g[5],g[6]!==v?(o=null!==v&&(0,n.jsxs)("span",{className:"text-xs font-mono px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground shrink-0",title:`Version ${v}`,children:["v.",v]}),g[6]=v,g[7]=o):o=g[7],g[8]!==a||g[9]!==o?(c=(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[a,o]}),g[8]=a,g[9]=o,g[10]=c):c=g[10],g[11]!==_?(u=_&&(0,n.jsx)(tF,{}),g[11]=_,g[12]=u):u=g[12];let k=!j;return g[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,n.jsx)(tI.ArrowDownTrayIcon,{className:"size-4"}),g[13]=d):d=g[13],g[14]!==N||g[15]!==k?(m=(0,n.jsx)(i.Button,{size:"icon",variant:"ghost",onClick:N,title:"Download as .zip","aria-label":"Download as .zip",disabled:k,className:"text-muted-foreground",children:d}),g[14]=N,g[15]=k,g[16]=m):m=g[16],g[17]!==C||g[18]!==b?(f=b&&(0,n.jsx)(i.Button,{size:"icon",variant:"ghost",onClick:b,title:C?"Exit full screen":"Full screen","aria-label":C?"Exit full screen":"Full screen",className:"text-muted-foreground",children:C?(0,n.jsx)(tE,{className:"size-4"}):(0,n.jsx)(tA.ArrowsPointingOutIcon,{className:"size-4"})}),g[17]=C,g[18]=b,g[19]=f):f=g[19],g[20]!==m||g[21]!==f||g[22]!==u?(h=(0,n.jsxs)("div",{className:"flex items-center gap-1 ml-4",children:[u,m,f]}),g[20]=m,g[21]=f,g[22]=u,g[23]=h):h=g[23],g[24]!==h||g[25]!==c?(p=(0,n.jsxs)("div",{className:r,children:[c,h]}),g[24]=h,g[25]=c,g[26]=p):p=g[26],p}let t$=(0,u.memo)(({artifact:e,activeVersionNumber:t,activeVersionId:r,isPreviewFullscreen:s,onToggleFullscreen:a})=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"shrink-0 bg-background",children:(0,n.jsx)(tM,{name:e.name,versionNumber:t,isFullscreen:s,onToggleFullscreen:()=>{a(),s||Promise.resolve().then(()=>{K.chatroomStoreActions.setActiveArtifactView({payload:{artifactId:e.id,view:f.ArtifactView.Preview}})})},artifactId:e.id,activeVersionId:r})}),(0,n.jsx)("div",{className:(0,l.cn)("flex-1 min-h-0 overflow-hidden","bg-muted border border-border border-b-0","relative",s&&"pointer-events-none select-none"),style:s?{willChange:"transform"}:void 0,children:(0,n.jsx)("div",{className:"absolute inset-0 flex flex-col",children:(0,n.jsx)("div",{className:(0,l.cn)("h-full min-h-0 bg-muted"),children:(0,n.jsx)(tk,{})})})})]}));var tT=e.i(214857);function tP(e){let t,r,a,o,c,d,m,f,h,p,g,x,y,b=(0,s.c)(20),{onExit:w}=e,S=(0,v.useHydrated)()?document.querySelector("#portal-container")??document.body:null,[j,C]=(0,u.useState)(!1);if(b[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{let e=requestAnimationFrame(()=>C(!0));return()=>{cancelAnimationFrame(e)}},r=[],b[0]=t,b[1]=r):(t=b[0],r=b[1]),(0,u.useEffect)(t,r),b[2]!==w?(a=()=>{let e=e=>{"Escape"===e.key&&w()};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},o=[w],b[2]=w,b[3]=a,b[4]=o):(a=b[3],o=b[4]),(0,u.useEffect)(a,o),!S)return null;let _=j?"opacity-100":"opacity-0";return b[5]!==_?(c=(0,l.cn)("fixed inset-0 z-modal bg-background flex flex-col","transition-opacity duration-150",_),b[5]=_,b[6]=c):c=b[6],b[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,n.jsx)("div",{className:"flex-1"}),b[7]=d):d=b[7],b[8]!==w?(m=e=>{e.stopPropagation(),w()},b[8]=w,b[9]=m):m=b[9],b[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(eG.XMarkIcon,{className:"h-4 w-4"}),b[10]=f):f=b[10],b[11]!==m?(h=(0,n.jsxs)(i.Button,{variant:"ghost",size:"xs",onClick:m,"aria-label":"Exit Preview",children:[f,"Exit Preview"]}),b[11]=m,b[12]=h):h=b[12],b[13]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)("div",{className:"flex-1"}),b[13]=p):p=b[13],b[14]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-center border-b border-border px-4 shrink-0",children:[d,h,p]}),b[14]=h,b[15]=g):g=b[15],b[16]===Symbol.for("react.memo_cache_sentinel")?(x=(0,n.jsx)("div",{className:"relative flex-1 min-h-0",children:(0,n.jsx)(tm,{})}),b[16]=x):x=b[16],b[17]!==g||b[18]!==c?(y=(0,n.jsxs)("div",{className:c,children:[g,x]}),b[17]=g,b[18]=c,b[19]=y):y=b[19],(0,tT.createPortal)(y,S)}let tO=e=>{let t,r,a,o=(0,s.c)(7),{onMouseDown:i,currentValue:c,minValue:u,maxValue:d}=e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,l.cn)("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"),r=(0,n.jsx)("div",{className:(0,l.cn)("w-px h-full bg-border transition-all duration-200","group-hover:w-0.5 group-hover:bg-primary","group-focus-visible:w-0.5 group-focus-visible:bg-primary")}),o[0]=t,o[1]=r):(t=o[0],r=o[1]),o[2]!==c||o[3]!==d||o[4]!==u||o[5]!==i?(a=(0,n.jsx)("div",{onMouseDown:i,role:"separator","aria-orientation":"vertical","aria-valuenow":c,"aria-valuemin":u,"aria-valuemax":d,tabIndex:0,"aria-label":"Resize panel",className:t,children:r}),o[2]=c,o[3]=d,o[4]=u,o[5]=i,o[6]=a):a=o[6],a};function tR(e){let t,r,a,o,l,i,c,d,m,f,h=(0,s.c)(29),{artifact:p,activeVersionId:g,activeVersionNumber:x}=e,[v,y]=(0,u.useState)(!1),b=(0,u.useRef)(null),w=(0,Y.useElementWidth)(b),S=void 0!==w&&w>0?w-320:1e3;h[0]!==S?(t={containerRef:b,side:"left",initialWidth:700,minWidth:320,maxWidth:S},h[0]=S,h[1]=t):t=h[1];let{handleMouseDown:j,panelWidth:C}=(({containerRef:e,side:t,initialWidth:r,minWidth:n=0,maxWidth:s=1/0})=>{let[a,o]=(0,u.useState)(r),l=(0,u.useRef)(!1);(0,u.useEffect)(()=>{o(e=>{let t=Math.max(n,Math.min(e,s));return t!==e?t:e})},[n,s]);let i=(0,u.useCallback)(r=>{if(!l.current||!e.current)return;let a=e.current.getBoundingClientRect();o(Math.max(n,Math.min("right"===t?a.right-r.clientX:r.clientX-a.left,s)))},[e,n,s,t]),c=(0,u.useCallback)(()=>{l.current=!1,window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect=""},[i]);return{panelWidth:a,handleMouseDown:(0,u.useCallback)(e=>{e.preventDefault(),l.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",i),window.addEventListener("mouseup",c)},[i,c])}})(t);h[2]!==g||h[3]!==v?(r=v&&(0,n.jsx)(tP,{activeVersionId:g,onExit:()=>y(!1)}),h[2]=g,h[3]=v,h[4]=r):r=h[4];let _=`${C}px`;return h[5]!==_?(a={width:_},h[5]=_,h[6]=a):a=h[6],h[7]!==p.id?(o=(0,n.jsx)(e6,{artifactId:p.id}),h[7]=p.id,h[8]=o):o=h[8],h[9]!==a||h[10]!==o?(l=(0,n.jsx)("div",{style:a,className:"h-full flex flex-col shrink-0",children:o}),h[9]=a,h[10]=o,h[11]=l):l=h[11],h[12]!==j||h[13]!==S||h[14]!==C?(i=(0,n.jsx)(tO,{onMouseDown:j,currentValue:C,minValue:320,maxValue:S}),h[12]=j,h[13]=S,h[14]=C,h[15]=i):i=h[15],h[16]===Symbol.for("react.memo_cache_sentinel")?(c=()=>y(tz),h[16]=c):c=h[16],h[17]!==g||h[18]!==x||h[19]!==p||h[20]!==v?(d=(0,n.jsx)("div",{className:"h-full flex flex-col flex-1 min-w-0 overflow-hidden",children:(0,n.jsx)(t$,{artifact:p,activeVersionNumber:x,activeVersionId:g,isPreviewFullscreen:v,onToggleFullscreen:c})}),h[17]=g,h[18]=x,h[19]=p,h[20]=v,h[21]=d):d=h[21],h[22]!==l||h[23]!==i||h[24]!==d?(m=(0,n.jsxs)("aside",{ref:b,className:"flex flex-row w-full h-full min-h-0",children:[l,i,d]}),h[22]=l,h[23]=i,h[24]=d,h[25]=m):m=h[25],h[26]!==m||h[27]!==r?(f=(0,n.jsxs)(n.Fragment,{children:[r,m]}),h[26]=m,h[27]=r,h[28]=f):f=h[28],f}function tz(e){return!e}var tL=((r={}).Chat="chat",r.History="history",r.Editor="editor",r.Preview="preview",r);let tD=["chat","history","editor","preview"],tB={chat:"Chat",history:"History",editor:"Output",preview:"Preview"};function tV(e){return"editor"===e||"preview"===e}let tU={editor:f.ArtifactView.Editor,preview:f.ArtifactView.Preview},tG=(0,u.memo)(function(e){let t,r=(0,s.c)(4),{view:a,artifactId:o}=e;if(a===tL.Chat){let e;return r[0]!==o?(e=(0,n.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:(0,n.jsx)(e$,{artifactId:o})}),r[0]=o,r[1]=e):e=r[1],e}if(a===tL.History){let e;return r[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:(0,n.jsx)(eD,{})}),r[2]=e):e=r[2],e}return r[3]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("div",{className:"h-full min-h-0 overflow-y-auto bg-muted",children:(0,n.jsx)(tk,{})}),r[3]=t):t=r[3],t});function tH(e){let t,r,a=(0,s.c)(5),{activeView:o,onChange:l}=e;return a[0]!==o||a[1]!==l?(t=tD.map(e=>(0,n.jsx)(i.Button,{size:"sm",className:"px-2 border border-transparent",variant:o===e?"outline":"ghost",onClick:()=>{l(e)},children:tB[e]},e)),a[0]=o,a[1]=l,a[2]=t):t=a[2],a[3]!==t?(r=(0,n.jsx)("div",{className:"flex items-center gap-1",children:t}),a[3]=t,a[4]=r):r=a[4],r}function tq(e){let t,r,a,o,c,d,m,h,p,g,x,v,y,b,w,S,j,C,_,N,k=(0,s.c)(48),{artifact:I,activeVersionId:E}=e,[A,F]=(0,u.useState)(tL.Chat),[M,$]=(0,u.useState)(!1);k[0]!==I.id?(t=()=>{$(e=>{let t=!e;return t&&Promise.resolve().then(()=>{K.chatroomStoreActions.setActiveArtifactView({payload:{artifactId:I.id,view:f.ArtifactView.Preview}})}),t})},k[0]=I.id,k[1]=t):t=k[1];let T=t;k[2]!==I.id?(r=e=>{if(F(e),tV(e)){let t=tV(e)?tU[e]:null;null!==t&&K.chatroomStoreActions.setActiveArtifactView({payload:{artifactId:I.id,view:t}})}},k[2]=I.id,k[3]=r):r=k[3];let P=r;k[4]!==E||k[5]!==I.id?(a=()=>{E&&K.chatroomStoreActions.downloadArtifactVersion({payload:{artifactId:I.id,versionId:E}})},k[4]=E,k[5]=I.id,k[6]=a):a=k[6];let O=a;k[7]!==E||k[8]!==M?(o=M&&(0,n.jsx)(tP,{activeVersionId:E,onExit:()=>$(!1)}),k[7]=E,k[8]=M,k[9]=o):o=k[9],k[10]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:tW,"aria-label":"Close workspace",className:"-ml-1",children:(0,n.jsx)(X.ArrowLeftIcon,{className:"size-4"})}),k[10]=c):c=k[10],k[11]!==I.name?(d=(0,n.jsx)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:(0,n.jsx)("span",{className:"font-semibold text-base truncate",title:I.name,children:I.name})}),k[11]=I.name,k[12]=d):d=k[12],k[13]===Symbol.for("react.memo_cache_sentinel")?(m=(0,n.jsx)("div",{className:"shrink-0 min-w-0 max-w-[60vw]",children:(0,n.jsx)(e2,{})}),k[13]=m):m=k[13],k[14]!==d?(h=(0,n.jsxs)("div",{className:"shrink-0 flex items-center gap-2 p-2 bg-background",children:[c,d,m]}),k[14]=d,k[15]=h):h=k[15],k[16]===Symbol.for("react.memo_cache_sentinel")?(p=(0,l.cn)("flex-1 min-h-0 overflow-hidden flex flex-col","bg-muted border border-border","md:rounded-tl-2xl"),k[16]=p):p=k[16],k[17]!==P||k[18]!==A?(g=(0,n.jsx)("div",{className:"flex items-center min-w-0",children:(0,n.jsx)(tH,{activeView:A,onChange:P})}),k[17]=P,k[18]=A,k[19]=g):g=k[19];let R=!E;k[20]===Symbol.for("react.memo_cache_sentinel")?(x=(0,n.jsx)(tI.ArrowDownTrayIcon,{className:"size-4"}),k[20]=x):x=k[20],k[21]!==O||k[22]!==R?(v=(0,n.jsx)(i.Button,{size:"icon",variant:"ghost",onClick:O,title:"Download as .zip",disabled:R,className:"text-muted-foreground",children:x}),k[21]=O,k[22]=R,k[23]=v):v=k[23];let z=M?"Exit full screen":"Full screen";return k[24]!==M?(y=M?(0,n.jsx)(tE,{className:"size-4"}):(0,n.jsx)(tA.ArrowsPointingOutIcon,{className:"size-4"}),k[24]=M,k[25]=y):y=k[25],k[26]!==T||k[27]!==z||k[28]!==y?(b=(0,n.jsx)(i.Button,{size:"icon",variant:"ghost",onClick:T,title:z,className:"text-muted-foreground",children:y}),k[26]=T,k[27]=z,k[28]=y,k[29]=b):b=k[29],k[30]!==v||k[31]!==b?(w=(0,n.jsxs)("div",{className:"flex items-center",children:[v,b]}),k[30]=v,k[31]=b,k[32]=w):w=k[32],k[33]!==g||k[34]!==w?(S=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-1.5 p-2 shrink-0 bg-background",children:[g,w]}),k[33]=g,k[34]=w,k[35]=S):S=k[35],k[36]!==I.id||k[37]!==A?(j=(0,n.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,n.jsx)(tG,{view:A,artifactId:I.id})}),k[36]=I.id,k[37]=A,k[38]=j):j=k[38],k[39]!==S||k[40]!==j?(C=(0,n.jsxs)("div",{className:p,children:[S,j]}),k[39]=S,k[40]=j,k[41]=C):C=k[41],k[42]!==C||k[43]!==h?(_=(0,n.jsxs)("aside",{className:"flex flex-col w-full h-full min-h-0",children:[h,C]}),k[42]=C,k[43]=h,k[44]=_):_=k[44],k[45]!==_||k[46]!==o?(N=(0,n.jsxs)(n.Fragment,{children:[o,_]}),k[45]=_,k[46]=o,k[47]=N):N=k[47],N}function tW(){K.chatroomStoreActions.closeArtifactView()}let tK=(0,u.memo)(function(){let e,t,r,a,o,l=(0,s.c)(14),i=(0,p.useChatroomStore)(H.selectActiveArtifact),c=(0,p.useChatroomStore)(H.selectActiveArtifactVersionId);l[0]!==c?(e=e=>(0,H.selectVersionNumberById)(e,{versionId:c}),l[0]=c,l[1]=e):e=l[1];let d=(0,p.useChatroomStore)(e);l[2]!==c||l[3]!==i?(t=()=>{i&&!c&&i.headVersionId&&K.chatroomStoreActions.setActiveVersionId({payload:{artifactId:i.id,versionId:i.headVersionId}})},r=[i,c],l[2]=c,l[3]=i,l[4]=t,l[5]=r):(t=l[4],r=l[5]),(0,u.useEffect)(t,r);let m=(0,W.useMediaMd)();if(!i)return null;let f=c??null,h=d??null;l[6]!==i||l[7]!==f||l[8]!==h?(a={artifact:i,activeVersionId:f,activeVersionNumber:h},l[6]=i,l[7]=f,l[8]=h,l[9]=a):a=l[9];let g=a;if(!m){let e;return l[10]!==g?(e=(0,n.jsx)(tq,{...g}),l[10]=g,l[11]=e):e=l[11],e}return l[12]!==g?(o=(0,n.jsx)(tR,{...g}),l[12]=g,l[13]=o):o=l[13],o},()=>!0);var tY=e.i(789280);e.i(742593);var tX=e.i(571236),tZ=e.i(507869),tJ=e.i(117738),tQ=e.i(19379),t0=e.i(79247),t1=e.i(977051),t2=e.i(22022),t5=e.i(622817),t3=e.i(733064),t4=e.i(850658);e.i(956425);var t6=e.i(290430),t8=e.i(744475),t7=e.i(480149),t9=e.i(48318);let re=[];function rt(){let e,t,r,n,a=(0,s.c)(12),o=(0,t1.useFeatureFlag)("oriCode"),l=(0,t1.useFeatureFlag)("oriChat"),i=o&&l,c=(0,t7.useIsFlagRecordingReady)(),{isLoaded:d,isSignedIn:m,orgId:f,userId:h}=(0,t4.useAuth)(),p=i&&!0===m;a[0]!==p?(e={isEnabled:p},a[0]=p,a[1]=e):e=a[1];let{activeWorkspaceId:g,didFetchFail:x}=(0,t9.useUserWorkspaces)(e),v=i?g??null:null;a[2]!==v?(t=(0,t8.internsListOptions)(v),a[2]=v,a[3]=t):t=a[3];let{data:y,status:b,isPlaceholderData:w}=(0,t0.useQuery)(t),S=function(e){let t,r,n=(0,s.c)(4),[a,o]=(0,u.useState)(null);return 8e3!==n[0]||n[1]!==e?(t=()=>{let t=setTimeout(()=>o(e),8e3);return()=>clearTimeout(t)},r=[8e3,e],n[0]=8e3,n[1]=e,n[2]=t,n[3]=r):(t=n[2],r=n[3]),(0,u.useEffect)(t,r),a===e}(`${h??""}|${f??""}|${g??""}`)||c&&d&&(!i||!1===m||x||"pending"!==b&&!w);e:{let e;if(!y||!g){r=re;break e}if(a[4]!==g||a[5]!==y.interns){let t;a[7]!==g?(t=e=>e.workspaceId===g&&e.status===t6.InternStatus.Running,a[7]=g,a[8]=t):t=a[8],e=y.interns.filter(t).map(rr),a[4]=g,a[5]=y.interns,a[6]=e}else e=a[6];r=e}let j=r;return a[9]!==S||a[10]!==j?(n={modelInfos:j,isSettled:S},a[9]=S,a[10]=j,a[11]=n):n=a[11],n}function rr(e){return(0,t5.getInternModelInfo)(e)}var rn=e.i(463444),rs=e.i(351764),ra=e.i(700050),ro=e.i(717607),rl=e.i(492565),ri=e.i(396501),rc=e.i(113511);let ru=u.forwardRef(function({title:e,titleId:t,...r},n){return u.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?u.createElement("title",{id:t},e):null,u.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"}),u.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"}))});var rd=e.i(442160),rm=e.i(389097),rf=e.i(557225),rh=e.i(827517),rp=e.i(780397);let rg=u.forwardRef(function({title:e,titleId:t,...r},n){return u.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?u.createElement("title",{id:t},e):null,u.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.636 5.636a9 9 0 1 0 12.728 0M12 3v9"}))});var rx=e.i(871068),rv=e.i(378599);function ry(e){let t,r,a,o,i,c,d,m,f,h,p,g,x,v,y,b=(0,s.c)(40),{character:w,onOpenAdvanced:S,children:j}=e,[C,_]=(0,u.useState)(!1);b[0]!==w?(t=(0,t5.isInternCharacter)(w),b[0]=w,b[1]=t):t=b[1];let N=t,k=w.modelInfo?.endpoint?.supports_reasoning??!1;b[2]!==w.modelInfo?(r=!!w.modelInfo?.endpoint&&(0,rd.isMandatoryReasoning)(w.modelInfo.endpoint),b[2]=w.modelInfo,b[3]=r):r=b[3];let I=r,E=!!I||(w.reasoning?.enabled??!1);b[4]!==j?(a=(0,n.jsx)(rx.PopoverTrigger,{render:j}),b[4]=j,b[5]=a):a=b[5],b[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,l.cn)("w-60 p-1.5","rounded-xl border border-border bg-popover text-popover-foreground shadow-lg"),b[6]=o):o=b[6],b[7]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)(rg,{className:"size-4"}),b[7]=i):i=b[7];let A=!w.isDisabled;b[8]!==w.id||b[9]!==w.isDisabled?(c=()=>{K.chatroomStoreActions.updateCharacter({payload:{roomId:(0,rp.getCurrentRoomId)(),characterId:w.id,partialCharacter:{isDisabled:!w.isDisabled}}})},b[8]=w.id,b[9]=w.isDisabled,b[10]=c):c=b[10],b[11]!==A||b[12]!==c?(d=(0,n.jsx)(rw,{icon:i,label:"Enable",checked:A,onToggle:c}),b[11]=A,b[12]=c,b[13]=d):d=b[13],b[14]!==w.id||b[15]!==w.reasoning||b[16]!==N||b[17]!==I||b[18]!==E||b[19]!==k?(m=N?null:(0,n.jsx)(rw,{icon:(0,n.jsx)(em.LightBulbIcon,{className:"size-4"}),label:"Reasoning",checked:E,disabled:!k||I,onToggle:()=>{K.chatroomStoreActions.updateCharacter({payload:{roomId:(0,rp.getCurrentRoomId)(),characterId:w.id,partialCharacter:{reasoning:{...w.reasoning,enabled:!E}}}})}}),b[14]=w.id,b[15]=w.reasoning,b[16]=N,b[17]=I,b[18]=E,b[19]=k,b[20]=m):m=b[20],b[21]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(rb,{}),b[21]=f):f=b[21],b[22]!==w.id||b[23]!==N?(h=N?null:(0,n.jsx)(rS,{icon:(0,n.jsx)(rl.DocumentDuplicateIcon,{className:"size-4"}),label:"Duplicate",onClick:()=>{K.chatroomStoreActions.duplicateCharacter({payload:{roomId:(0,rp.getCurrentRoomId)(),sourceCharacterId:w.id}}),_(!1)}}),b[22]=w.id,b[23]=N,b[24]=h):h=b[24],b[25]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)(ro.AdjustmentsHorizontalIcon,{className:"size-4"}),b[25]=p):p=b[25];let F=N?"Intern settings":"Advanced settings";return b[26]!==S?(g=()=>{_(!1),S()},b[26]=S,b[27]=g):g=b[27],b[28]!==F||b[29]!==g?(x=(0,n.jsx)(rS,{icon:p,label:F,onClick:g}),b[28]=F,b[29]=g,b[30]=x):x=b[30],b[31]!==h||b[32]!==x||b[33]!==d||b[34]!==m?(v=(0,n.jsxs)(rx.PopoverContent,{side:"bottom",align:"end",sideOffset:6,className:o,children:[d,m,f,h,x]}),b[31]=h,b[32]=x,b[33]=d,b[34]=m,b[35]=v):v=b[35],b[36]!==C||b[37]!==v||b[38]!==a?(y=(0,n.jsxs)(rx.Popover,{open:C,onOpenChange:_,children:[a,v]}),b[36]=C,b[37]=v,b[38]=a,b[39]=y):y=b[39],y}function rb(){let e,t=(0,s.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{"aria-hidden":"true",className:"mx-1 my-1 h-px bg-border"}),t[0]=e):e=t[0],e}function rw(e){let t,r,a,o,i,c=(0,s.c)(17),{icon:u,label:d,checked:m,disabled:f,onToggle:h}=e,p=f?"opacity-50":"transition-colors hover:bg-accent";c[0]!==p?(t=(0,l.cn)("flex items-center justify-between gap-2 rounded-lg px-2 py-1.5 text-sm",p),c[0]=p,c[1]=t):t=c[1],c[2]!==u||c[3]!==d?(r=(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[u,d]}),c[2]=u,c[3]=d,c[4]=r):r=c[4];let g=`Toggle ${d}`;return c[5]!==f||c[6]!==h?(a=e=>{e.stopPropagation(),f||h()},c[5]=f,c[6]=h,c[7]=a):a=c[7],c[8]!==m||c[9]!==f||c[10]!==g||c[11]!==a?(o=(0,n.jsx)(rv.Switch,{checked:m,disabled:f,"aria-label":g,onClick:a}),c[8]=m,c[9]=f,c[10]=g,c[11]=a,c[12]=o):o=c[12],c[13]!==t||c[14]!==r||c[15]!==o?(i=(0,n.jsxs)("div",{className:t,children:[r,o]}),c[13]=t,c[14]=r,c[15]=o,c[16]=i):i=c[16],i}function rS(e){let t,r,a,o=(0,s.c)(7),{icon:i,label:c,onClick:u}=e;return o[0]!==u?(t=e=>{e.stopPropagation(),u()},o[0]=u,o[1]=t):t=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,l.cn)("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm","transition-colors hover:bg-accent"),o[2]=r):r=o[2],o[3]!==i||o[4]!==c||o[5]!==t?(a=(0,n.jsxs)("button",{type:"button",onClick:t,className:r,children:[i,c]}),o[3]=i,o[4]=c,o[5]=t,o[6]=a):a=o[6],a}function rj(e,t){return"--"!==t?t:e?.modelInfo?.short_name??e?.modelInfo?.name??e?.name??t}function rC(e){let t,r,a,o=(0,s.c)(5),{className:i}=e;return o[0]!==i?(t=(0,l.cn)("block text-negative",i),o[0]=i,o[1]=t):t=o[1],o[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("line",{x1:"1.5",y1:"8.5",x2:"8.5",y2:"1.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),o[2]=r):r=o[2],o[3]!==t?(a=(0,n.jsx)("svg",{viewBox:"0 0 10 10",className:t,"aria-hidden":"true",children:r}),o[3]=t,o[4]=a):a=o[4],a}function r_({characterId:e,className:t,tooltip:r,onOpenChange:s}){let a=(0,u.useMemo)(rn.makeSelectCharacterById,[]),o=(0,p.useChatroomStore)(t=>a(t,e)),i=(0,rh.getModelColorKey)(o),d=(0,rh.useModelColorStore)(e=>i?e.colorsBySlug[i]??null:null),m=(0,rh.useModelColorStore)(e=>e.setColor),[f,h]=(0,u.useState)(!1);if(!i)return null;let g=(0,rh.getMessageColorOption)(d),x=e=>{m(i,e),h(!1)},v=(0,n.jsx)("button",{type:"button","aria-label":"Choose model color",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:(0,l.cn)("flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden","rounded-full border border-border/60 transition-colors hover:border-border",g?g.pillBg:"bg-background",t),children:g?null:(0,n.jsx)(rC,{className:"h-full w-full"})}),y=(0,n.jsx)(eq.PopoverTrigger,{render:v});return(0,n.jsxs)(eq.Popover,{open:f,onOpenChange:e=>{h(e),s?.(e)},children:[r?(0,n.jsx)(c.Tooltip,{side:"bottom",delay:0,content:r,children:y}):y,(0,n.jsxs)(eq.PopoverContent,{side:"bottom",align:"start",sideOffset:8,className:(0,l.cn)("w-auto rounded-full p-1.5","flex items-center gap-1.5"),children:[(0,n.jsx)("button",{type:"button",role:"radio","aria-checked":null===d,"aria-label":"No color",onClick:()=>x(null),className:(0,l.cn)("flex h-6 w-6 items-center justify-center overflow-hidden rounded-full","border border-border/40 bg-background transition-transform hover:scale-110 active:scale-95",null===d&&"ring-2 ring-foreground/40 ring-offset-1 ring-offset-popover"),children:(0,n.jsx)(rC,{className:"h-4 w-4"})}),rh.MESSAGE_COLOR_OPTIONS.map(e=>{let t=d===e.key;return(0,n.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":`${e.key} background`,onClick:()=>x(e.key),className:(0,l.cn)("h-6 w-6 rounded-full border border-border/40","transition-transform hover:scale-110 active:scale-95",e.swatchBg,t&&"ring-2 ring-foreground/40 ring-offset-1 ring-offset-popover")},e.key)})]})]})}var rN=e.i(469407),rk=e.i(810563),rI=e.i(558956),rE=e.i(863842),rA=e.i(632516),rF=e.i(617353);function rM(e){let t=(0,u.useMemo)(()=>e.title?.toString(),[e.title]),r=(0,u.useMemo)(()=>{if("boolean"==typeof e.open)return e.open?[t]:[]},[e.open,t]),s=(0,u.useCallback)(r=>{if(!e.onOpenChange)return;let n=Array.isArray(r)?r.includes(t):r===t;e.onOpenChange(n)},[e.onOpenChange,t]);return(0,n.jsx)(rF.Accordion,{collapsible:!0,defaultValue:e.defaultOpen?[t]:void 0,value:r,onValueChange:s,className:(0,l.cn)(e.className),children:(0,n.jsxs)(rF.AccordionItem,{value:t,className:"border-none",children:[(0,n.jsx)(rF.AccordionTrigger,{className:(0,l.cn)("py-4 text-sm hover:underline",e.centered&&"justify-center",e.triggerClassName),onClick:e.onClick,children:e.title}),(0,n.jsx)(rF.AccordionContent,{className:"text-sm",children:e.children})]})})}var r$=e.i(477020),rT=e.i(80125),rP=e.i(235750);let rO="zephyr",rR="deepseek-r1",rz="deepseek-v3.1",rL="qwen3";var rD=e.i(185473),rB=e.i(442427);function rV(e){let t,r,n=(0,rD.peek)(e)?.role==="assistant",s=(t=e.find(e=>"assistant"===e.role&&"name"in e&&"string"==typeof e.name)?.name,r={role:"assistant",content:""},t&&(r.name=t),r);return{messages:(0,rB.truthyValues)([...e,!n&&s]),assistantPrefill:s,isEndingWithAssistant:n}}var rU=e.i(586404),rG=e.i(366699),rH=e.i(562659);e.i(412665);var rq=e.i(769143);function rW(e){var t,r,n;let s=(0,rq.isToolCallsMessage)(e)?{normalized:!0,output:{role:"assistant",content:[!(r=(t=e).content)?null:"string"==typeof r?r:Array.isArray(r)?r.map(e=>{switch(e.type){case"text":return e.text;case"image_url":return"";case"file":return``;case"refusal":return e.refusal;case"input_audio":return"";case"input_video":case"video_url":return"