@lovelybunch/api 1.0.71-alpha.6 → 1.0.71-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/api/v1/resources/generate/route.js +6 -0
- package/dist/routes/api/v1/resources/generate-audio/route.js +6 -0
- package/dist/routes/api/v1/resources/generate-video/route.js +6 -0
- package/dist/routes/api/v1/resources/route.d.ts +4 -0
- package/dist/routes/api/v1/resources/route.js +5 -1
- package/package.json +4 -4
- package/static/assets/{AgentDetailPage-Bw8wHgla.js → AgentDetailPage-Opv1vviq.js} +1 -1
- package/static/assets/{AgentEditPage-CQ9Y3ez8.js → AgentEditPage-uLCBQAKt.js} +1 -1
- package/static/assets/{AgentsPage-DcgU1MPa.js → AgentsPage-CbwDfB0S.js} +1 -1
- package/static/assets/{AgentsSettingsPage-CgoXxqGL.js → AgentsSettingsPage-wqr9YnHr.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-BgqGOa4p.js → ApiKeysSettingsPage-16htmPFV.js} +1 -1
- package/static/assets/{ArchitectureEditPage-DrEnTloL.js → ArchitectureEditPage-Dvfb4b-o.js} +1 -1
- package/static/assets/{ArchitecturePage-Dpd6cyyT.js → ArchitecturePage-CzD1Oize.js} +1 -1
- package/static/assets/{AuthSettingsPage-wu1zFEx-.js → AuthSettingsPage-BP2zlNfC.js} +1 -1
- package/static/assets/{CallbackPage-DYzikcPp.js → CallbackPage-DEnicyfd.js} +1 -1
- package/static/assets/{CodePage-CtM-PEHU.js → CodePage-wBG-_Rs8.js} +1 -1
- package/static/assets/{CollapsibleSection-B23j-nZD.js → CollapsibleSection-DSatk0YZ.js} +1 -1
- package/static/assets/{DashboardPage-BoPCq6M9.js → DashboardPage-DmXHKAfY.js} +1 -1
- package/static/assets/{GitPage-DYicFQBx.js → GitPage-C-ZudM8s.js} +1 -1
- package/static/assets/{GitSettingsPage-B-1Nnid8.js → GitSettingsPage-DtvqZDAp.js} +1 -1
- package/static/assets/{IdentityPage-Cvj6SDPj.js → IdentityPage-WwVp_vBZ.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-CCfJKk2U.js → ImplementationStepsEditor-BKDdpUue.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-BgLXCF-u.js → IntegrationsSettingsPage-Vhh08Jjd.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-I9erHJXN.js → KnowledgeDetailPage-B8jlP-NF.js} +1 -1
- package/static/assets/{KnowledgeEditPage-BfaWotPl.js → KnowledgeEditPage-BppjRoZZ.js} +1 -1
- package/static/assets/{KnowledgePage-x9ShzjoT.js → KnowledgePage-CasWW1a1.js} +1 -1
- package/static/assets/{LoginPage-CZtwhbdN.js → LoginPage-DkguuNDQ.js} +1 -1
- package/static/assets/{McpSettingsPage-BHPjMqOX.js → McpSettingsPage-CZfBLxIj.js} +1 -1
- package/static/assets/{NewAgentPage-D-Pj_KgZ.js → NewAgentPage-BbANsmjr.js} +1 -1
- package/static/assets/{NewKnowledgePage-CoVnCUx6.js → NewKnowledgePage-BE18vt4E.js} +1 -1
- package/static/assets/{NewProposalPage-nCTq2mBC.js → NewProposalPage-BxKHijwN.js} +1 -1
- package/static/assets/{ProjectEditPage-d1cMZArt.js → ProjectEditPage-uwwvFm_Y.js} +1 -1
- package/static/assets/{ProjectPage-KwwOjk5b.js → ProjectPage-DJvT8Jwp.js} +1 -1
- package/static/assets/{PromptsSettingsPage-fSs6HBAk.js → PromptsSettingsPage-CWdSTKxS.js} +1 -1
- package/static/assets/{ProposalDetailPage-BnLOBPPT.js → ProposalDetailPage-CDyosWFj.js} +1 -1
- package/static/assets/{ProposalEditPage-bIYTFTmG.js → ProposalEditPage-D9b0X_vT.js} +1 -1
- package/static/assets/{ProposalsPage-D8W2d6g6.js → ProposalsPage-DdfAejqH.js} +1 -1
- package/static/assets/ResourcesPage-DCJ-ob0_.js +71 -0
- package/static/assets/{RulesSettingsPage-SWRxKVNH.js → RulesSettingsPage-CrIrk78x.js} +1 -1
- package/static/assets/{SchedulePage-DGxD8ZaL.js → SchedulePage-Dq53Q6fB.js} +1 -1
- package/static/assets/{TagInput-CYcNHzrk.js → TagInput-DtQl22K7.js} +1 -1
- package/static/assets/{TerminalPage-fabajZvk.js → TerminalPage-BcclpXIS.js} +1 -1
- package/static/assets/{TerminalSessionPage-DuJsKT9f.js → TerminalSessionPage-Tecaum7f.js} +1 -1
- package/static/assets/{UserPreferencesPage-DQMtobsK.js → UserPreferencesPage-B4jeTbEe.js} +1 -1
- package/static/assets/{UserSettingsPage-CFEb7pD0.js → UserSettingsPage-D_fTJGEB.js} +1 -1
- package/static/assets/{UtilitiesPage-qStPGLN_.js → UtilitiesPage-BVSfnezp.js} +1 -1
- package/static/assets/{alert-Baaj8mli.js → alert-DT5dIcQb.js} +1 -1
- package/static/assets/{arrow-down-CSpiROUo.js → arrow-down-D5JMw0I7.js} +1 -1
- package/static/assets/{arrow-left-CdJt7_wH.js → arrow-left-BbL7bi4b.js} +1 -1
- package/static/assets/{arrow-up-ugn3lusK.js → arrow-up-D5zdohVZ.js} +1 -1
- package/static/assets/{badge-fHjW-wEe.js → badge-CxMDR-vz.js} +1 -1
- package/static/assets/{browser-modal-D6BB5mxm.js → browser-modal-DZprh22G.js} +1 -1
- package/static/assets/{calendar-DXMWQL-h.js → calendar-DjIpzqju.js} +1 -1
- package/static/assets/{card-C9ekeZtD.js → card-Cq3qftln.js} +1 -1
- package/static/assets/{chevron-left-BkP_F3xd.js → chevron-left-8PdSXGp8.js} +1 -1
- package/static/assets/{circle-alert-DnIYekt3.js → circle-alert-CPeWHRYV.js} +1 -1
- package/static/assets/{circle-check-BO-qmBFl.js → circle-check-BsF5HxbR.js} +1 -1
- package/static/assets/{circle-check-big-BUVglreY.js → circle-check-big-DViAc1A0.js} +1 -1
- package/static/assets/{circle-play-84ZOWBDG.js → circle-play-C0yQlVR9.js} +1 -1
- package/static/assets/{circle-x-EQNlLpRR.js → circle-x-CT_9xyVN.js} +1 -1
- package/static/assets/{clipboard-Dv0iwZO9.js → clipboard-D-CHbLVc.js} +1 -1
- package/static/assets/{clock-BxO7xcX9.js → clock-D5nAa1In.js} +1 -1
- package/static/assets/{download-CpaVC4DU.js → download-Bl3cP1zr.js} +1 -1
- package/static/assets/{eye-BSR7OEmk.js → eye-DgdIekU1.js} +1 -1
- package/static/assets/{folder-git-2-9fWvFiHp.js → folder-git-2-BD7LL99o.js} +1 -1
- package/static/assets/{index-BAEEeZzi.js → index-CKcm92Kn.js} +3 -3
- package/static/assets/index-D9b0oysW.css +2 -0
- package/static/assets/{label-CRsu1MwQ.js → label-COUiN2Pd.js} +1 -1
- package/static/assets/{markdown-editor-Dop22vuJ.js → markdown-editor-Cln2Jo2-.js} +1 -1
- package/static/assets/{pause-C7KYrzQF.js → pause-CupPWZ26.js} +1 -1
- package/static/assets/{play-DhUf2mKM.js → play-sWUKmZEy.js} +1 -1
- package/static/assets/{plus-CemYz5Fm.js → plus-DM62ve-p.js} +1 -1
- package/static/assets/{radio-group-Dz2cO4IQ.js → radio-group-B6pYL4p4.js} +1 -1
- package/static/assets/{refresh-cw-BL3y7jJo.js → refresh-cw-ClU12bdt.js} +1 -1
- package/static/assets/{search-BvRo_rak.js → search-DHLiojAp.js} +1 -1
- package/static/assets/{switch-CDOrVL8G.js → switch-DC_em8xh.js} +1 -1
- package/static/assets/{tabs-CP_A6r0A.js → tabs-KzUqSzqd.js} +1 -1
- package/static/assets/{tag-BpNIhvRX.js → tag-cF4ktw0a.js} +1 -1
- package/static/assets/{terminal-preview-CbgoHEQH.js → terminal-preview-D-pmjUNP.js} +1 -1
- package/static/assets/{use-terminal-ZvK-kdxE.js → use-terminal-C1j4Pa5C.js} +1 -1
- package/static/assets/{zap-DOtH7YrV.js → zap-DGHMgsd8.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/ResourcesPage-Dq9DZFd7.js +0 -71
- package/static/assets/index-DdGUrKz8.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,b8 as E,aq as K,ak as T,j as a,al as N,b9 as U,ao as x,ap as w,ba as V,an as g,bb as z,at as H,as as $,f as I,bc as W}from"./index-
|
|
1
|
+
import{r as n,b8 as E,aq as K,ak as T,j as a,al as N,b9 as U,ao as x,ap as w,ba as V,an as g,bb as z,at as H,as as $,f as I,bc as W}from"./index-CKcm92Kn.js";var C="Radio",[X,k]=N(C),[Y,J]=X(C),_=n.forwardRef((r,t)=>{const{__scopeRadio:e,name:c,checked:o=!1,required:s,disabled:i,value:p="on",onCheck:f,form:R,...v}=r,[l,m]=n.useState(null),d=w(t,y=>m(y)),u=n.useRef(!1),b=l?R||!!l.closest("form"):!0;return a.jsxs(Y,{scope:e,checked:o,disabled:i,children:[a.jsx(x.button,{type:"button",role:"radio","aria-checked":o,"data-state":S(o),"data-disabled":i?"":void 0,disabled:i,value:p,...v,ref:d,onClick:g(r.onClick,y=>{o||f?.(),b&&(u.current=y.isPropagationStopped(),u.current||y.stopPropagation())})}),b&&a.jsx(P,{control:l,bubbles:!u.current,name:c,value:p,checked:o,required:s,disabled:i,form:R,style:{transform:"translateX(-100%)"}})]})});_.displayName=C;var j="RadioIndicator",G=n.forwardRef((r,t)=>{const{__scopeRadio:e,forceMount:c,...o}=r,s=J(j,e);return a.jsx(z,{present:c||s.checked,children:a.jsx(x.span,{"data-state":S(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});G.displayName=j;var Q="RadioBubbleInput",P=n.forwardRef(({__scopeRadio:r,control:t,checked:e,bubbles:c=!0,...o},s)=>{const i=n.useRef(null),p=w(i,s),f=H(e),R=$(t);return n.useEffect(()=>{const v=i.current;if(!v)return;const l=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(l,"checked").set;if(f!==e&&d){const u=new Event("click",{bubbles:c});d.call(v,e),v.dispatchEvent(u)}},[f,e,c]),a.jsx(x.input,{type:"radio","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:p,style:{...o.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});P.displayName=Q;function S(r){return r?"checked":"unchecked"}var Z=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],h="RadioGroup",[ee,ce]=N(h,[E,k]),A=E(),D=k(),[oe,re]=ee(h),M=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,name:c,defaultValue:o,value:s,required:i=!1,disabled:p=!1,orientation:f,dir:R,loop:v=!0,onValueChange:l,...m}=r,d=A(e),u=K(R),[b,y]=T({prop:s,defaultProp:o??null,onChange:l,caller:h});return a.jsx(oe,{scope:e,name:c,required:i,disabled:p,value:b,onValueChange:y,children:a.jsx(U,{asChild:!0,...d,orientation:f,dir:u,loop:v,children:a.jsx(x.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:u,...m,ref:t})})})});M.displayName=h;var O="RadioGroupItem",q=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,disabled:c,...o}=r,s=re(O,e),i=s.disabled||c,p=A(e),f=D(e),R=n.useRef(null),v=w(t,R),l=s.value===o.value,m=n.useRef(!1);return n.useEffect(()=>{const d=b=>{Z.includes(b.key)&&(m.current=!0)},u=()=>m.current=!1;return document.addEventListener("keydown",d),document.addEventListener("keyup",u),()=>{document.removeEventListener("keydown",d),document.removeEventListener("keyup",u)}},[]),a.jsx(V,{asChild:!0,...p,focusable:!i,active:l,children:a.jsx(_,{disabled:i,required:s.required,checked:l,...f,...o,name:s.name,ref:v,onCheck:()=>s.onValueChange(o.value),onKeyDown:g(d=>{d.key==="Enter"&&d.preventDefault()}),onFocus:g(o.onFocus,()=>{m.current&&R.current?.click()})})})});q.displayName=O;var ae="RadioGroupIndicator",F=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,...c}=r,o=D(e);return a.jsx(G,{...o,...c,ref:t})});F.displayName=ae;var L=M,B=q,te=F;const se=n.forwardRef(({className:r,...t},e)=>a.jsx(L,{className:I("grid gap-2",r),...t,ref:e}));se.displayName=L.displayName;const ne=n.forwardRef(({className:r,...t},e)=>a.jsx(B,{ref:e,className:I("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),...t,children:a.jsx(te,{className:"flex items-center justify-center",children:a.jsx(W,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ne.displayName=B.displayName;export{se as R,ne as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,f as i}from"./index-
|
|
1
|
+
import{r as c,j as e,f as i}from"./index-CKcm92Kn.js";const d=c.forwardRef(({className:s,onCheckedChange:r,onChange:t,...o},n)=>{const l=a=>{t?.(a),r?.(a.target.checked)};return e.jsxs("label",{className:i("relative inline-flex cursor-pointer",s),children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",onChange:l,ref:n,...o}),e.jsx("div",{className:"block bg-gray-300 w-9 h-5 rounded-full transition-colors duration-200 ease-in-out peer-checked:bg-blue-600"}),e.jsx("div",{className:"absolute left-0 top-0 bg-white w-4 h-4 rounded-full mt-0.5 ml-0.5 transition-transform duration-200 ease-in-out transform peer-checked:translate-x-4 shadow"})]})});d.displayName="Switch";export{d as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,aq as F,ak as $,j as c,al as k,be as D,ao as g,b8 as y,b9 as V,ba as G,an as m,bb as L,f as T}from"./index-
|
|
1
|
+
import{r as l,aq as F,ak as $,j as c,al as k,be as D,ao as g,b8 as y,b9 as V,ba as G,an as m,bb as L,f as T}from"./index-CKcm92Kn.js";var p="Tabs",[K,Q]=k(p,[y]),h=y(),[q,x]=K(p),N=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,onValueChange:r,defaultValue:d,orientation:n="horizontal",dir:u,activationMode:f="automatic",...v}=e,i=F(u),[s,b]=$({prop:o,onChange:r,defaultProp:d??"",caller:p});return c.jsx(q,{scope:t,baseId:D(),value:s,onValueChange:b,orientation:n,dir:i,activationMode:f,children:c.jsx(g.div,{dir:i,"data-orientation":n,...v,ref:a})})});N.displayName=p;var C="TabsList",I=l.forwardRef((e,a)=>{const{__scopeTabs:t,loop:o=!0,...r}=e,d=x(C,t),n=h(t);return c.jsx(V,{asChild:!0,...n,orientation:d.orientation,dir:d.dir,loop:o,children:c.jsx(g.div,{role:"tablist","aria-orientation":d.orientation,...r,ref:a})})});I.displayName=C;var R="TabsTrigger",j=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,disabled:r=!1,...d}=e,n=x(R,t),u=h(t),f=A(n.baseId,o),v=E(n.baseId,o),i=o===n.value;return c.jsx(G,{asChild:!0,...u,focusable:!r,active:i,children:c.jsx(g.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":v,"data-state":i?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:f,...d,ref:a,onMouseDown:m(e.onMouseDown,s=>{!r&&s.button===0&&s.ctrlKey===!1?n.onValueChange(o):s.preventDefault()}),onKeyDown:m(e.onKeyDown,s=>{[" ","Enter"].includes(s.key)&&n.onValueChange(o)}),onFocus:m(e.onFocus,()=>{const s=n.activationMode!=="manual";!i&&!r&&s&&n.onValueChange(o)})})})});j.displayName=R;var w="TabsContent",_=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,forceMount:r,children:d,...n}=e,u=x(w,t),f=A(u.baseId,o),v=E(u.baseId,o),i=o===u.value,s=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>s.current=!1);return()=>cancelAnimationFrame(b)},[]),c.jsx(L,{present:r||i,children:({present:b})=>c.jsx(g.div,{"data-state":i?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":f,hidden:!b,id:v,tabIndex:0,...n,ref:a,style:{...e.style,animationDuration:s.current?"0s":void 0},children:b&&d})})});_.displayName=w;function A(e,a){return`${e}-trigger-${a}`}function E(e,a){return`${e}-content-${a}`}var B=N,S=I,M=j,P=_;const U=B,z=l.forwardRef(({className:e,...a},t)=>c.jsx(S,{ref:t,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));z.displayName=S.displayName;const H=l.forwardRef(({className:e,...a},t)=>c.jsx(M,{ref:t,className:T("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...a}));H.displayName=M.displayName;const O=l.forwardRef(({className:e,...a},t)=>c.jsx(P,{ref:t,className:T("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));O.displayName=P.displayName;export{U as T,z as a,H as b,O as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as p,r as e,ab as S,j as u}from"./index-
|
|
1
|
+
import{c as p,r as e,ab as S,j as u}from"./index-CKcm92Kn.js";import{x as F,a as N}from"./xterm-DTxiCjtJ.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,ag as b,A as f}from"./index-
|
|
1
|
+
import{r as i,ag as b,A as f}from"./index-CKcm92Kn.js";function j(){const[y,u]=i.useState([]),[g,c]=i.useState(!1),[m,o]=i.useState(null),{refresh:p}=b(),d=i.useCallback(async(s,n,r)=>{try{c(!0),o(null);const e=await fetch(`${f}/api/v1/terminal/${s}/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableLogging:n||!1,startupCommand:r})});if(!e.ok){const a=await e.json();throw new Error(a.error||"Failed to create terminal session")}const t=await e.json();return await p(),t.sessionId}catch(e){const t=e instanceof Error?e.message:"Unknown error";return o(t),null}finally{c(!1)}},[p]),S=i.useCallback(async s=>{try{c(!0),o(null);let n;if(s.startsWith("session-")){const e=s.split("-");n=`${e[0]}-${e[1]}`}else{const e=s.split("-");n=`${e[0]}-${e[1]}`}const r=await fetch(`${f}/api/v1/terminal/${n}/destroy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s})});if(!r.ok){const e=await r.json();throw new Error(e.error||"Failed to destroy terminal session")}return u(e=>e.filter(t=>t.id!==s)),await p(),!0}catch(n){const r=n instanceof Error?n.message:"Unknown error";return o(r),!1}finally{c(!1)}},[p]),$=i.useCallback(async(s,n,r)=>{try{o(null);let e;if(s.startsWith("session-")){const a=s.split("-");e=`${a[0]}-${a[1]}`}else{const a=s.split("-");e=`${a[0]}-${a[1]}`}const t=await fetch(`${f}/api/v1/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,cols:n,rows:r})});if(!t.ok){const a=await t.json();throw new Error(a.error||"Failed to resize terminal session")}return!0}catch(e){const t=e instanceof Error?e.message:"Unknown error";return o(t),!1}},[]),k=i.useCallback(async(s,n,r)=>{try{c(!0),o(null);const e=new URLSearchParams;s&&e.set("proposalId",s),n&&(e.set("withPreview","true"),r&&Number.isFinite(r)&&e.set("lines",String(r)));const t=`${f}/api/v1/terminal/sessions${e.toString()?`?${e.toString()}`:""}`,a=await fetch(t);if(!a.ok){const l=await a.json();throw new Error(l.error||"Failed to fetch terminal sessions")}const w=await a.json();u(w.sessions)}catch(e){const t=e instanceof Error?e.message:"Unknown error";o(t)}finally{c(!1)}},[]),E=i.useCallback(async(s,n=8)=>{try{o(null);const r=new URLSearchParams;r.set("sessionId",s),r.set("withPreview","true"),r.set("lines",String(n)),r.set("colorize","true");const e=`${f}/api/v1/terminal/sessions?${r.toString()}`,t=await fetch(e);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.error||"Failed to fetch preview")}const a=await t.json(),w=Array.isArray(a?.sessions)&&a.sessions[0]?.preview?a.sessions[0].preview:[];return u(l=>l.map(h=>h.id===s?{...h,preview:w}:h)),w}catch(r){const e=r instanceof Error?r.message:"Unknown error";return o(e),[]}},[]);return{sessions:y,loading:g,error:m,createSession:d,destroySession:S,resizeSession:$,refreshSessions:k,fetchPreview:E}}export{j as u};
|
package/static/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">
|
|
10
10
|
<title>Coconut - Agentic Development Environment</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-CKcm92Kn.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D9b0oysW.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body class="font-inter">
|
|
15
15
|
<div id="root"></div>
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import{c as se,r as l,j as e,D as re,a as ie,b as oe,d as ce,n as z,S as Qe,B as I,ah as qe,aj as ke,H as Ie,A as J,a0 as de,v as V,w as W,x as O,y as $,z as L,ac as Me,ak as ea,al as sa,am as aa,an as xe,ao as be,ap as pe,aq as ta,ar as _s,as as na,at as la,f as ra,I as Ee,ai as Ss,X as Xe,C as Cs,g as je,au as We,av as ia,aw as oa,ax as ca,a5 as da,a6 as ua,s as ma,a7 as ha,aa as Le,e as Ze,T as es,ay as xa}from"./index-BAEEeZzi.js";import{C as Ke,b as ss,a as Ve,c as fa,d as pa}from"./card-C9ekeZtD.js";import{L as C}from"./label-CRsu1MwQ.js";import{B as Ne}from"./badge-fHjW-wEe.js";import{c as ga}from"./clipboard-B9ndUJKl.js";import{R as Ps}from"./registry-ANRa5WBi.js";import{D as Oe}from"./download-CpaVC4DU.js";import{C as ks}from"./chevron-left-BkP_F3xd.js";import{C as va}from"./calendar-DXMWQL-h.js";import{P as as}from"./plus-CemYz5Fm.js";import{S as ja}from"./search-BvRo_rak.js";/**
|
|
2
|
-
* @license lucide-react v0.542.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const wa=[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]],ts=se("file-audio",wa);/**
|
|
7
|
-
* @license lucide-react v0.542.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Na=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],$e=se("file-code",Na);/**
|
|
12
|
-
* @license lucide-react v0.542.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const ba=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],ns=se("file-image",ba);/**
|
|
17
|
-
* @license lucide-react v0.542.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const ya=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ls=se("file-json",ya);/**
|
|
22
|
-
* @license lucide-react v0.542.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const _a=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z",key:"1tzo1f"}]],rs=se("file-play",_a);/**
|
|
27
|
-
* @license lucide-react v0.542.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Sa=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],is=se("file-spreadsheet",Sa);/**
|
|
32
|
-
* @license lucide-react v0.542.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const Ca=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],os=se("file-type",Ca);/**
|
|
37
|
-
* @license lucide-react v0.542.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Pa=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],ka=se("hard-drive",Pa);/**
|
|
42
|
-
* @license lucide-react v0.542.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const Ma=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],fe=se("image",Ma);/**
|
|
47
|
-
* @license lucide-react v0.542.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const Ea=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],cs=se("maximize-2",Ea);/**
|
|
52
|
-
* @license lucide-react v0.542.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const Fa=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],le=se("music",Fa);/**
|
|
57
|
-
* @license lucide-react v0.542.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Ia=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],ds=se("presentation",Ia);/**
|
|
62
|
-
* @license lucide-react v0.542.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const Ga=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Ra=se("upload",Ga);/**
|
|
67
|
-
* @license lucide-react v0.542.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const Da=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Fe=se("video",Da);async function Ms(n){const c=n.startsWith("http")?n:`${Ps}${n}`,a=await fetch(c,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!a.ok)throw new Error(`Failed to fetch registry resource: ${a.status}`);return a.json()}async function Ta(){return Ms("/registry/resources/root.json")}async function us(n){return Ms(n)}function Pe(n){if(n)return n.startsWith("http")?n:`${Ps}${n}`}function Aa({open:n,onOpenChange:c,onSelectExample:a,onCustomizeInAssistant:d}){const[x,p]=l.useState([]),[m,v]=l.useState(!1),[j,E]=l.useState(null),[y,f]=l.useState(null),[g,w]=l.useState(null),[_,P]=l.useState(!1),[N,b]=l.useState(null);l.useEffect(()=>{n&&(v(!0),E(null),f(null),w(null),b(null),Ta().then(h=>{p(h.elements??[]),h.elements&&h.elements.length>0&&K(h.elements[0])}).catch(h=>{console.error("Failed to load registry resources",h),p([]),E("Failed to load examples from registry")}).finally(()=>v(!1)))},[n]);const K=async h=>{f(h.id),b(null),w(null),P(!0);try{const F=await us(h.endpoint);w(F)}catch(F){console.error("Failed to load resource detail",F),b("Unable to load details for this example")}finally{P(!1)}},k=()=>{g?.prompt&&(a(g.prompt),c(!1))},M=()=>{g?.prompt&&d&&(d(g.prompt),c(!1))},G=async h=>{if(y===h.id&&g?.prompt){a(g.prompt),c(!1);return}try{const F=await us(h.endpoint);F.prompt&&(a(F.prompt),c(!1))}catch(F){console.error("Failed to load resource detail",F)}};return e.jsx(re,{open:n,onOpenChange:c,children:e.jsxs(ie,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{className:"text-base sm:text-lg",children:"Example Prompts"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"h-[40%] min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:_?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):N?e.jsx("p",{className:"text-sm text-muted-foreground",children:N}):g?e.jsx("img",{src:Pe(g.imageUrl),alt:g.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example"})}),e.jsxs("div",{className:"flex-1 min-h-0 border-t flex flex-col",children:[m?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):j?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}):x.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(Qe,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:x.map(h=>e.jsxs("button",{onClick:()=>K(h),onDoubleClick:()=>G(h),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${y===h.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[h.thumbnailUrl&&e.jsx("img",{src:Pe(h.thumbnailUrl),alt:"",className:"w-12 h-12 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:h.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:h.description})]})]},h.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(I,{onClick:k,disabled:!g?.prompt||_,className:"w-full",children:[e.jsx(qe,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsxs("div",{className:"w-[35%] border-r flex flex-col",children:[m?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):j?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}):x.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(Qe,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:x.map(h=>e.jsxs("button",{onClick:()=>K(h),onDoubleClick:()=>G(h),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${y===h.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[h.thumbnailUrl&&e.jsx("img",{src:Pe(h.thumbnailUrl),alt:"",className:"w-16 h-16 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:h.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:h.description}),h.tags&&h.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[h.tags.slice(0,3).map(F=>e.jsx(Ne,{variant:"secondary",className:"text-[10px]",children:F},F)),h.tags.length>3&&e.jsxs(Ne,{variant:"outline",className:"text-[10px]",children:["+",h.tags.length-3]})]})]})]},h.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(I,{onClick:k,disabled:!g?.prompt||_,className:"w-full",children:[e.jsx(qe,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:_?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading details..."]}):N?e.jsx("p",{className:"text-sm text-muted-foreground",children:N}):g?e.jsx("img",{src:Pe(g.imageUrl),alt:g.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example to preview"})}),g&&e.jsxs("div",{className:"border-t p-4 bg-background flex-shrink-0 max-h-[30%] overflow-y-auto relative",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2 font-medium",children:"Full Prompt:"}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap pr-32",children:g.prompt}),d&&e.jsxs(I,{size:"sm",variant:"secondary",onClick:M,className:"absolute bottom-4 right-4",children:[e.jsx(ke,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})]})]})]})]})})}const Be={"nano-banana-pro":{id:"nano-banana-pro",label:"Nano Banana Pro",replicateId:"google/nano-banana-pro",features:{resolution:!0,outputQuality:!1,goFast:!1,safetyTolerance:!1,matchInputImage:!1},resolutionOptions:[{value:"1K",label:"1K"},{value:"2K",label:"2K"},{value:"4K",label:"4K"}],defaults:{resolution:"2K"}},"flux-2-dev":{id:"flux-2-dev",label:"FLUX.2 Dev",replicateId:"black-forest-labs/flux-2-dev",features:{resolution:!1,outputQuality:!0,goFast:!0,safetyTolerance:!1,matchInputImage:!0},defaults:{outputQuality:80,goFast:!0}},"flux-2-pro":{id:"flux-2-pro",label:"FLUX.2 Pro",replicateId:"black-forest-labs/flux-2-pro",features:{resolution:!0,outputQuality:!0,goFast:!1,safetyTolerance:!0,matchInputImage:!1},resolutionOptions:[{value:"0.5 MP",label:"0.5 MP"},{value:"1 MP",label:"1 MP"},{value:"2 MP",label:"2 MP"},{value:"4 MP",label:"4 MP"}],defaults:{resolution:"2 MP",outputQuality:80,safetyTolerance:2}}},ms=Object.values(Be).map(n=>({value:n.id,label:n.label})),hs=[{value:"1:1",label:"1:1"},{value:"2:3",label:"2:3"},{value:"3:2",label:"3:2"},{value:"3:4",label:"3:4"},{value:"4:3",label:"4:3"},{value:"4:5",label:"4:5"},{value:"5:4",label:"5:4"},{value:"9:16",label:"9:16"},{value:"16:9",label:"16:9"},{value:"21:9",label:"21:9"}],La={value:"match_input_image",label:"Match Input"},xs=[{value:"png",label:"PNG"},{value:"jpg",label:"JPG"},{value:"webp",label:"WebP"}],fs=[{value:"60",label:"60"},{value:"70",label:"70"},{value:"80",label:"80"},{value:"90",label:"90"},{value:"100",label:"100"}],ps=[{value:"1",label:"1 (Strict)"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6 (Relaxed)"}];function Ka({open:n,onOpenChange:c,onSave:a,onCustomizeInAssistant:d}){const[x,p]=l.useState(""),[m,v]=l.useState("nano-banana-pro"),[j,E]=l.useState("4:3"),[y,f]=l.useState("2K"),[g,w]=l.useState("png"),[_,P]=l.useState("80"),[N,b]=l.useState(!0),[K,k]=l.useState("2"),[M,G]=l.useState(null),[h,F]=l.useState(!1),[Y,U]=l.useState(!1),[B,T]=l.useState([]),[u,D]=l.useState([]),[H,o]=l.useState(!0),[Q,r]=l.useState(!1),{toast:S}=Ie(),A=Be[m],ee=A.features.matchInputImage?[La,...hs]:hs,ue=A.resolutionOptions||[];l.useEffect(()=>{const t=Be[m];t.defaults.resolution&&t.features.resolution&&f(t.defaults.resolution),t.defaults.outputQuality!==void 0&&P(String(t.defaults.outputQuality)),t.defaults.goFast!==void 0&&b(t.defaults.goFast),t.defaults.safetyTolerance!==void 0&&k(String(t.defaults.safetyTolerance)),E(X=>X==="match_input_image"&&!t.features.matchInputImage?"4:3":X)},[m]),l.useEffect(()=>{n&&me()},[n]);const me=async()=>{try{const X=await(await fetch(`${J}/api/v1/resources`)).json();if(X.success){const Z=(X.data||[]).filter(ae=>{const he=ae.type==="image/jpeg"||ae.name.toLowerCase().endsWith(".jpg")||ae.name.toLowerCase().endsWith(".jpeg"),Ae=ae.type==="image/png"||ae.name.toLowerCase().endsWith(".png");return(he||Ae)&&ae.thumbnailPath});T(Z)}}catch(t){console.error("Failed to fetch image resources:",t)}},ye=async()=>{if(!x.trim()){S({title:"Prompt required",description:"Please enter a prompt to generate an image",variant:"destructive"});return}F(!0),G(null);try{const t=H||u.length===0?[]:[...u],X=await fetch(`${J}/api/v1/resources/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:x,model:m,dimensions:j,resolution:A.features.resolution?y:void 0,output_format:g,output_quality:A.features.outputQuality?parseInt(_):void 0,go_fast:A.features.goFast?N:void 0,safety_tolerance:A.features.safetyTolerance?parseInt(K):void 0,image_input:t})}),Z=await X.json();if(!X.ok||!Z.success){const ae=Z.error?.message||"Failed to generate image",he=Z.error?.code==="MISSING_API_TOKEN";throw new Error(he?"Replicate API token not configured. Please add it in Settings → Integrations.":ae)}G(Z.data.imageUrl),S({title:"Image generated",description:"Your image has been generated successfully"})}catch(t){console.error("Generation error:",t),S({title:"Generation failed",description:t instanceof Error?t.message:"Failed to generate image. Please try again.",variant:"destructive"})}finally{F(!1)}},_e=async()=>{if(M){U(!0);try{await a(M),p(""),v("nano-banana-pro"),E("4:3"),f("2K"),w("png"),P("80"),b(!0),k("2"),G(null),o(!0),D([]),c(!1)}catch(t){S({title:"Save failed",description:t instanceof Error?t.message:"Failed to save image. Please try again.",variant:"destructive"})}finally{U(!1)}}},Re=()=>{!h&&!Y&&c(!1)},Se=()=>{o(!0),D([])},ve=t=>{H&&o(!1),u.includes(t)?(D(u.filter(X=>X!==t)),u.length===1&&o(!0)):u.length<3?D([...u,t]):S({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},De=t=>{p(t)},Te=t=>{d&&(r(!1),c(!1),d(`"${t}" Please customize this (and respond back just the updated markdown):`))};return e.jsxs(re,{open:n,onOpenChange:Re,children:[e.jsxs(ie,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{className:"text-base sm:text-lg",children:"Generate Image"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:h?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(z,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:M,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(fe,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(I,{size:"sm",onClick:()=>r(!0),className:"mt-2",children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-2 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:Se,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${H?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),B.map(t=>{const X=u.includes(t.id);return e.jsx("button",{onClick:()=>ve(t.id),className:`flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${X?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${J}/api/v1/resources/${t.id}/thumbnail`,alt:t.name,className:"w-full h-full object-cover"})},t.id)})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[45vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(de,{id:"prompt-mobile",placeholder:"Describe the image...",value:x,onChange:t=>p(t.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"model-mobile",className:"text-xs",children:"Model"}),e.jsxs(V,{value:m,onValueChange:t=>v(t),children:[e.jsx(W,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ms.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"outputFormat-mobile",className:"text-xs",children:"Format"}),e.jsxs(V,{value:g,onValueChange:w,children:[e.jsx(W,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:xs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.goFast&&e.jsx("div",{className:"space-y-1 flex flex-col justify-end",children:e.jsxs("div",{className:"flex items-center space-x-2 h-8",children:[e.jsx(Me,{id:"goFast-mobile",checked:N,onCheckedChange:t=>b(t===!0)}),e.jsx(C,{htmlFor:"goFast-mobile",className:"text-xs cursor-pointer",children:"Go Fast"})]})}),A.features.safetyTolerance&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"safetyTolerance-mobile",className:"text-xs",children:"Safety"}),e.jsxs(V,{value:K,onValueChange:k,children:[e.jsx(W,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ps.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[A.features.resolution&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"resolution-mobile",className:"text-xs",children:"Resolution"}),e.jsxs(V,{value:y,onValueChange:f,children:[e.jsx(W,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ue.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"aspectRatio-mobile",className:"text-xs",children:"Ratio"}),e.jsxs(V,{value:j,onValueChange:E,children:[e.jsx(W,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ee.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.outputQuality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"outputQuality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(V,{value:_,onValueChange:P,children:[e.jsx(W,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:fs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{onClick:ye,disabled:!x.trim()||h||Y,className:"flex-1 h-9",size:"sm",children:h?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:_e,disabled:!M||h||Y,variant:"outline",className:"flex-1 h-9",size:"sm",children:Y?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"prompt",children:"Prompt"}),e.jsx(de,{id:"prompt",placeholder:"Describe the image you want to generate...",value:x,onChange:t=>p(t.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"model",children:"Model"}),e.jsxs(V,{value:m,onValueChange:t=>v(t),children:[e.jsx(W,{id:"model",children:e.jsx(O,{})}),e.jsx($,{children:ms.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(V,{value:j,onValueChange:E,children:[e.jsx(W,{id:"aspectRatio",children:e.jsx(O,{})}),e.jsx($,{children:ee.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.resolution&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(V,{value:y,onValueChange:f,children:[e.jsx(W,{id:"resolution",children:e.jsx(O,{})}),e.jsx($,{children:ue.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputFormat",children:"Output Format"}),e.jsxs(V,{value:g,onValueChange:w,children:[e.jsx(W,{id:"outputFormat",children:e.jsx(O,{})}),e.jsx($,{children:xs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.outputQuality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputQuality",children:"Output Quality"}),e.jsxs(V,{value:_,onValueChange:P,children:[e.jsx(W,{id:"outputQuality",children:e.jsx(O,{})}),e.jsx($,{children:fs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.goFast&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Me,{id:"goFast",checked:N,onCheckedChange:t=>b(t===!0)}),e.jsx(C,{htmlFor:"goFast",className:"cursor-pointer",children:"Go Fast"})]}),A.features.safetyTolerance&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"safetyTolerance",children:"Safety Tolerance"}),e.jsxs(V,{value:K,onValueChange:k,children:[e.jsx(W,{id:"safetyTolerance",children:e.jsx(O,{})}),e.jsx($,{children:ps.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(I,{onClick:ye,disabled:!x.trim()||h||Y,className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:_e,disabled:!M||h||Y,variant:"outline",className:"w-full",children:Y?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:h?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(z,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating image..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:M,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(fe,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(I,{onClick:()=>r(!0),className:"mt-2",children:[e.jsx(ke,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-4 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:Se,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${H?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),B.map(t=>{const X=u.includes(t.id);return e.jsx("button",{onClick:()=>ve(t.id),className:`flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${X?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${J}/api/v1/resources/${t.id}/thumbnail`,alt:t.name,className:"w-full h-full object-cover"})},t.id)})]})})]})]})]}),e.jsx(Aa,{open:Q,onOpenChange:r,onSelectExample:De,onCustomizeInAssistant:d?Te:void 0})]})}var Es=["PageUp","PageDown"],Fs=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Is={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ge="Slider",[Ue,Va,Wa]=aa(ge),[Gs,vt]=sa(ge,[Wa]),[Oa,Ge]=Gs(ge),Rs=l.forwardRef((n,c)=>{const{name:a,min:d=0,max:x=100,step:p=1,orientation:m="horizontal",disabled:v=!1,minStepsBetweenThumbs:j=0,defaultValue:E=[d],value:y,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:w=!1,form:_,...P}=n,N=l.useRef(new Set),b=l.useRef(0),k=m==="horizontal"?$a:Ba,[M=[],G]=ea({prop:y,defaultProp:E,onChange:T=>{[...N.current][b.current]?.focus(),f(T)}}),h=l.useRef(M);function F(T){const u=Ja(M,T);B(T,u)}function Y(T){B(T,b.current)}function U(){const T=h.current[b.current];M[b.current]!==T&&g(M)}function B(T,u,{commit:D}={commit:!1}){const H=Za(p),o=et(Math.round((T-d)/p)*p+d,H),Q=_s(o,[d,x]);G((r=[])=>{const S=Ha(r,Q,u);if(Xa(S,j*p)){b.current=S.indexOf(Q);const A=String(S)!==String(r);return A&&D&&g(S),A?S:r}else return r})}return e.jsx(Oa,{scope:n.__scopeSlider,name:a,disabled:v,min:d,max:x,valueIndexToChangeRef:b,thumbs:N.current,values:M,orientation:m,form:_,children:e.jsx(Ue.Provider,{scope:n.__scopeSlider,children:e.jsx(Ue.Slot,{scope:n.__scopeSlider,children:e.jsx(k,{"aria-disabled":v,"data-disabled":v?"":void 0,...P,ref:c,onPointerDown:xe(P.onPointerDown,()=>{v||(h.current=M)}),min:d,max:x,inverted:w,onSlideStart:v?void 0:F,onSlideMove:v?void 0:Y,onSlideEnd:v?void 0:U,onHomeKeyDown:()=>!v&&B(d,0,{commit:!0}),onEndKeyDown:()=>!v&&B(x,M.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:u})=>{if(!v){const o=Es.includes(T.key)||T.shiftKey&&Fs.includes(T.key)?10:1,Q=b.current,r=M[Q],S=p*o*u;B(r+S,Q,{commit:!0})}}})})})})});Rs.displayName=ge;var[Ds,Ts]=Gs(ge,{startEdge:"left",endEdge:"right",size:"width",direction:1}),$a=l.forwardRef((n,c)=>{const{min:a,max:d,dir:x,inverted:p,onSlideStart:m,onSlideMove:v,onSlideEnd:j,onStepKeyDown:E,...y}=n,[f,g]=l.useState(null),w=pe(c,k=>g(k)),_=l.useRef(void 0),P=ta(x),N=P==="ltr",b=N&&!p||!N&&p;function K(k){const M=_.current||f.getBoundingClientRect(),G=[0,M.width],F=Ye(G,b?[a,d]:[d,a]);return _.current=M,F(k-M.left)}return e.jsx(Ds,{scope:n.__scopeSlider,startEdge:b?"left":"right",endEdge:b?"right":"left",direction:b?1:-1,size:"width",children:e.jsx(As,{dir:P,"data-orientation":"horizontal",...y,ref:w,style:{...y.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:k=>{const M=K(k.clientX);m?.(M)},onSlideMove:k=>{const M=K(k.clientX);v?.(M)},onSlideEnd:()=>{_.current=void 0,j?.()},onStepKeyDown:k=>{const G=Is[b?"from-left":"from-right"].includes(k.key);E?.({event:k,direction:G?-1:1})}})})}),Ba=l.forwardRef((n,c)=>{const{min:a,max:d,inverted:x,onSlideStart:p,onSlideMove:m,onSlideEnd:v,onStepKeyDown:j,...E}=n,y=l.useRef(null),f=pe(c,y),g=l.useRef(void 0),w=!x;function _(P){const N=g.current||y.current.getBoundingClientRect(),b=[0,N.height],k=Ye(b,w?[d,a]:[a,d]);return g.current=N,k(P-N.top)}return e.jsx(Ds,{scope:n.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:e.jsx(As,{"data-orientation":"vertical",...E,ref:f,style:{...E.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:P=>{const N=_(P.clientY);p?.(N)},onSlideMove:P=>{const N=_(P.clientY);m?.(N)},onSlideEnd:()=>{g.current=void 0,v?.()},onStepKeyDown:P=>{const b=Is[w?"from-bottom":"from-top"].includes(P.key);j?.({event:P,direction:b?-1:1})}})})}),As=l.forwardRef((n,c)=>{const{__scopeSlider:a,onSlideStart:d,onSlideMove:x,onSlideEnd:p,onHomeKeyDown:m,onEndKeyDown:v,onStepKeyDown:j,...E}=n,y=Ge(ge,a);return e.jsx(be.span,{...E,ref:c,onKeyDown:xe(n.onKeyDown,f=>{f.key==="Home"?(m(f),f.preventDefault()):f.key==="End"?(v(f),f.preventDefault()):Es.concat(Fs).includes(f.key)&&(j(f),f.preventDefault())}),onPointerDown:xe(n.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),y.thumbs.has(g)?g.focus():d(f)}),onPointerMove:xe(n.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&x(f)}),onPointerUp:xe(n.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),p(f))})})}),Ls="SliderTrack",Ks=l.forwardRef((n,c)=>{const{__scopeSlider:a,...d}=n,x=Ge(Ls,a);return e.jsx(be.span,{"data-disabled":x.disabled?"":void 0,"data-orientation":x.orientation,...d,ref:c})});Ks.displayName=Ls;var ze="SliderRange",Vs=l.forwardRef((n,c)=>{const{__scopeSlider:a,...d}=n,x=Ge(ze,a),p=Ts(ze,a),m=l.useRef(null),v=pe(c,m),j=x.values.length,E=x.values.map(g=>$s(g,x.min,x.max)),y=j>1?Math.min(...E):0,f=100-Math.max(...E);return e.jsx(be.span,{"data-orientation":x.orientation,"data-disabled":x.disabled?"":void 0,...d,ref:v,style:{...n.style,[p.startEdge]:y+"%",[p.endEdge]:f+"%"}})});Vs.displayName=ze;var He="SliderThumb",Ws=l.forwardRef((n,c)=>{const a=Va(n.__scopeSlider),[d,x]=l.useState(null),p=pe(c,v=>x(v)),m=l.useMemo(()=>d?a().findIndex(v=>v.ref.current===d):-1,[a,d]);return e.jsx(Ua,{...n,ref:p,index:m})}),Ua=l.forwardRef((n,c)=>{const{__scopeSlider:a,index:d,name:x,...p}=n,m=Ge(He,a),v=Ts(He,a),[j,E]=l.useState(null),y=pe(c,K=>E(K)),f=j?m.form||!!j.closest("form"):!0,g=na(j),w=m.values[d],_=w===void 0?0:$s(w,m.min,m.max),P=Ya(d,m.values.length),N=g?.[v.size],b=N?Qa(N,_,v.direction):0;return l.useEffect(()=>{if(j)return m.thumbs.add(j),()=>{m.thumbs.delete(j)}},[j,m.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[v.startEdge]:`calc(${_}% + ${b}px)`},children:[e.jsx(Ue.ItemSlot,{scope:n.__scopeSlider,children:e.jsx(be.span,{role:"slider","aria-label":n["aria-label"]||P,"aria-valuemin":m.min,"aria-valuenow":w,"aria-valuemax":m.max,"aria-orientation":m.orientation,"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,tabIndex:m.disabled?void 0:0,...p,ref:y,style:w===void 0?{display:"none"}:n.style,onFocus:xe(n.onFocus,()=>{m.valueIndexToChangeRef.current=d})})}),f&&e.jsx(Os,{name:x??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:w},d)]})});Ws.displayName=He;var za="RadioBubbleInput",Os=l.forwardRef(({__scopeSlider:n,value:c,...a},d)=>{const x=l.useRef(null),p=pe(x,d),m=la(c);return l.useEffect(()=>{const v=x.current;if(!v)return;const j=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(j,"value").set;if(m!==c&&y){const f=new Event("input",{bubbles:!0});y.call(v,c),v.dispatchEvent(f)}},[m,c]),e.jsx(be.input,{style:{display:"none"},...a,ref:p,defaultValue:c})});Os.displayName=za;function Ha(n=[],c,a){const d=[...n];return d[a]=c,d.sort((x,p)=>x-p)}function $s(n,c,a){const p=100/(a-c)*(n-c);return _s(p,[0,100])}function Ya(n,c){return c>2?`Value ${n+1} of ${c}`:c===2?["Minimum","Maximum"][n]:void 0}function Ja(n,c){if(n.length===1)return 0;const a=n.map(x=>Math.abs(x-c)),d=Math.min(...a);return a.indexOf(d)}function Qa(n,c,a){const d=n/2,p=Ye([0,50],[0,d]);return(d-p(c)*a)*a}function qa(n){return n.slice(0,-1).map((c,a)=>n[a+1]-c)}function Xa(n,c){if(c>0){const a=qa(n);return Math.min(...a)>=c}return!0}function Ye(n,c){return a=>{if(n[0]===n[1]||c[0]===c[1])return c[0];const d=(c[1]-c[0])/(n[1]-n[0]);return c[0]+d*(a-n[0])}}function Za(n){return(String(n).split(".")[1]||"").length}function et(n,c){const a=Math.pow(10,c);return Math.round(n*a)/a}var Bs=Rs,st=Ks,at=Vs,tt=Ws;const we=l.forwardRef(({className:n,...c},a)=>e.jsxs(Bs,{ref:a,className:ra("relative flex w-full touch-none select-none items-center",n),...c,children:[e.jsx(st,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(at,{className:"absolute h-full bg-primary"})}),e.jsx(tt,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));we.displayName=Bs.displayName;const gs=["English_Trustworth_Man","English_Aussie_Bloke","English_CalmWoman","English_UpsetGirl","English_Gentle-voiced_man","English_Whispering_girl","English_Diligent_Man","English_Graceful_Lady","English_ReservedYoungMan","English_PlayfulGirl","English_ManWithDeepVoice","English_MaturePartner","English_FriendlyPerson","English_MatureBoss","English_Debator","English_LovelyGirl","English_Steadymentor","English_Deep-VoicedGentleman","English_Wiselady","English_CaptivatingStoryteller","English_DecentYoungMan","English_SentimentalLady","English_ImposingManner","English_SadTeen","English_PassionateWarrior","English_WiseScholar","English_Soft-spokenGirl","English_SereneWoman","English_ConfidentWoman","English_PatientMan","English_Comedian","English_BossyLeader","English_Strong-WilledBoy","English_StressedLady","English_AssertiveQueen","English_AnimeCharacter","English_Jovialman","English_WhimsicalGirl","English_Kind-heartedGirl","Chinese (Mandarin)_Reliable_Executive","Chinese (Mandarin)_News_Anchor","Chinese (Mandarin)_Unrestrained_Young_Man","Chinese (Mandarin)_Mature_Woman","Arrogant_Miss","Robot_Armor","Chinese (Mandarin)_Kind-hearted_Antie","Chinese (Mandarin)_Refreshing_Young_Man","Chinese (Mandarin)_HK_Flight_Attendant","Chinese (Mandarin)_Humorous_Elder","Chinese (Mandarin)_Gentleman","Chinese (Mandarin)_Warm_Bestie","Chinese (Mandarin)_Stubborn_Friend","Chinese (Mandarin)_Sweet_Lady","Chinese (Mandarin)_Southern_Young_Man","Chinese (Mandarin)_Wise_Women","Chinese (Mandarin)_Gentle_Youth","Chinese (Mandarin)_Warm_Girl","Chinese (Mandarin)_Male_Announcer","Chinese (Mandarin)_Kind-hearted_Elder","Chinese (Mandarin)_Cute_Spirit","Chinese (Mandarin)_Radio_Host","Chinese (Mandarin)_Lyrical_Voice","Chinese (Mandarin)_Straightforward_Boy","Chinese (Mandarin)_Sincere_Adult","Chinese (Mandarin)_Gentle_Senior","Chinese (Mandarin)_Crisp_Girl","Chinese (Mandarin)_Pure-hearted_Boy","Chinese (Mandarin)_Soft_Girl","Chinese (Mandarin)_IntellectualGirl","Chinese (Mandarin)_Warm_HeartedGirl","Chinese (Mandarin)_Laid_BackGirl","Chinese (Mandarin)_ExplorativeGirl","Chinese (Mandarin)_Warm-HeartedAunt","Chinese (Mandarin)_BashfulGirl","Japanese_IntellectualSenior","Japanese_DecisivePrincess","Japanese_LoyalKnight","Japanese_DominantMan","Japanese_SeriousCommander","Japanese_ColdQueen","Japanese_DependableWoman","Japanese_GentleButler","Japanese_KindLady","Japanese_CalmLady","Japanese_OptimisticYouth","Japanese_GenerousIzakayaOwner","Japanese_SportyStudent","Japanese_InnocentBoy","Japanese_GracefulMaiden","Cantonese_ProfessionalHost(F)","Cantonese_GentleLady","Cantonese_ProfessionalHost(M)","Cantonese_PlayfulMan","Cantonese_CuteGirl","Cantonese_KindWoman","Korean_SweetGirl","Korean_CheerfulBoyfriend","Korean_EnchantingSister","Korean_ShyGirl","Korean_ReliableSister","Korean_StrictBoss","Korean_SassyGirl","Korean_ChildhoodFriendGirl","Korean_PlayboyCharmer","Korean_ElegantPrincess","Korean_BraveFemaleWarrior","Korean_BraveYouth","Korean_CalmLady","Korean_EnthusiasticTeen","Korean_SoothingLady","Korean_IntellectualSenior","Korean_LonelyWarrior","Korean_MatureLady","Korean_InnocentBoy","Korean_CharmingSister","Korean_AthleticStudent","Korean_BraveAdventurer","Korean_CalmGentleman","Korean_WiseElf","Korean_CheerfulCoolJunior","Korean_DecisiveQueen","Korean_ColdYoungMan","Korean_MysteriousGirl","Korean_QuirkyGirl","Korean_ConsiderateSenior","Korean_CheerfulLittleSister","Korean_DominantMan","Korean_AirheadedGirl","Korean_ReliableYouth","Korean_FriendlyBigSister","Korean_GentleBoss","Korean_ColdGirl","Korean_HaughtyLady","Korean_CharmingElderSister","Korean_IntellectualMan","Korean_CaringWoman","Korean_WiseTeacher","Korean_ConfidentBoss","Korean_AthleticGirl","Korean_PossessiveMan","Korean_GentleWoman","Korean_CockyGuy","Korean_ThoughtfulWoman","Korean_OptimisticYouth","Spanish_SereneWoman","Spanish_MaturePartner","Spanish_CaptivatingStoryteller","Spanish_Narrator","Spanish_WiseScholar","Spanish_Kind-heartedGirl","Spanish_DeterminedManager","Spanish_BossyLeader","Spanish_ReservedYoungMan","Spanish_ConfidentWoman","Spanish_ThoughtfulMan","Spanish_Strong-WilledBoy","Spanish_SophisticatedLady","Spanish_RationalMan","Spanish_AnimeCharacter","Spanish_Deep-tonedMan","Spanish_Fussyhostess","Spanish_SincereTeen","Spanish_FrankLady","Spanish_Comedian","Spanish_Debator","Spanish_ToughBoss","Spanish_Wiselady","Spanish_Steadymentor","Spanish_Jovialman","Spanish_SantaClaus","Spanish_Rudolph","Spanish_Intonategirl","Spanish_Arnold","Spanish_Ghost","Spanish_HumorousElder","Spanish_EnergeticBoy","Spanish_WhimsicalGirl","Spanish_StrictBoss","Spanish_ReliableMan","Spanish_SereneElder","Spanish_AngryMan","Spanish_AssertiveQueen","Spanish_CaringGirlfriend","Spanish_PowerfulSoldier","Spanish_PassionateWarrior","Spanish_ChattyGirl","Spanish_RomanticHusband","Spanish_CompellingGirl","Spanish_PowerfulVeteran","Spanish_SensibleManager","Spanish_ThoughtfulLady","Portuguese_SentimentalLady","Portuguese_BossyLeader","Portuguese_Wiselady","Portuguese_Strong-WilledBoy","Portuguese_Deep-VoicedGentleman","Portuguese_UpsetGirl","Portuguese_PassionateWarrior","Portuguese_AnimeCharacter","Portuguese_ConfidentWoman","Portuguese_AngryMan","Portuguese_CaptivatingStoryteller","Portuguese_Godfather","Portuguese_ReservedYoungMan","Portuguese_SmartYoungGirl","Portuguese_Kind-heartedGirl","Portuguese_Pompouslady","Portuguese_Grinch","Portuguese_Debator","Portuguese_SweetGirl","Portuguese_AttractiveGirl","Portuguese_ThoughtfulMan","Portuguese_PlayfulGirl","Portuguese_GorgeousLady","Portuguese_LovelyLady","Portuguese_SereneWoman","Portuguese_SadTeen","Portuguese_MaturePartner","Portuguese_Comedian","Portuguese_NaughtySchoolgirl","Portuguese_Narrator","Portuguese_ToughBoss","Portuguese_Fussyhostess","Portuguese_Dramatist","Portuguese_Steadymentor","Portuguese_Jovialman","Portuguese_CharmingQueen","Portuguese_SantaClaus","Portuguese_Rudolph","Portuguese_Arnold","Portuguese_CharmingSanta","Portuguese_CharmingLady","Portuguese_Ghost","Portuguese_HumorousElder","Portuguese_CalmLeader","Portuguese_GentleTeacher","Portuguese_EnergeticBoy","Portuguese_ReliableMan","Portuguese_SereneElder","Portuguese_GrimReaper","Portuguese_AssertiveQueen","Portuguese_WhimsicalGirl","Portuguese_StressedLady","Portuguese_FriendlyNeighbor","Portuguese_CaringGirlfriend","Portuguese_PowerfulSoldier","Portuguese_FascinatingBoy","Portuguese_RomanticHusband","Portuguese_StrictBoss","Portuguese_InspiringLady","Portuguese_PlayfulSpirit","Portuguese_ElegantGirl","Portuguese_CompellingGirl","Portuguese_PowerfulVeteran","Portuguese_SensibleManager","Portuguese_ThoughtfulLady","Portuguese_TheatricalActor","Portuguese_FragileBoy","Portuguese_ChattyGirl","Portuguese_Conscientiousinstructor","Portuguese_RationalMan","Portuguese_WiseScholar","Portuguese_FrankLady","Portuguese_DeterminedManager","French_Male_Speech_New","French_Female_News Anchor","French_CasualMan","French_MovieLeadFemale","French_FemaleAnchor","French_MaleNarrator","Indonesian_SweetGirl","Indonesian_ReservedYoungMan","Indonesian_CharmingGirl","Indonesian_CalmWoman","Indonesian_ConfidentWoman","Indonesian_CaringMan","Indonesian_BossyLeader","Indonesian_DeterminedBoy","Indonesian_GentleGirl","German_FriendlyMan","German_SweetLady","German_PlayfulMan","Russian_HandsomeChildhoodFriend","Russian_BrightHeroine","Russian_AmbitiousWoman","Russian_ReliableMan","Russian_CrazyQueen","Russian_PessimisticGirl","Russian_AttractiveGuy","Russian_Bad-temperedBoy","Italian_BraveHeroine","Italian_Narrator","Italian_WanderingSorcerer","Italian_DiligentLeader","Dutch_kindhearted_girl","Dutch_bossy_leader","Vietnamese_kindhearted_girl","Arabic_CalmWoman","Arabic_FriendlyGuy","Turkish_CalmWoman","Turkish_Trustworthyman","Ukrainian_CalmWoman"],vs=[{value:"auto",label:"Auto"},{value:"happy",label:"Happy"},{value:"sad",label:"Sad"},{value:"angry",label:"Angry"},{value:"fearful",label:"Fearful"},{value:"disgusted",label:"Disgusted"},{value:"surprised",label:"Surprised"},{value:"neutral",label:"Neutral"}],js=[{value:"English",label:"English"},{value:"Chinese",label:"Chinese"},{value:"Japanese",label:"Japanese"},{value:"Korean",label:"Korean"},{value:"Spanish",label:"Spanish"},{value:"Portuguese",label:"Portuguese"},{value:"French",label:"French"},{value:"Indonesian",label:"Indonesian"},{value:"German",label:"German"},{value:"Russian",label:"Russian"},{value:"Italian",label:"Italian"},{value:"Dutch",label:"Dutch"},{value:"Vietnamese",label:"Vietnamese"},{value:"Arabic",label:"Arabic"},{value:"Turkish",label:"Turkish"},{value:"Ukrainian",label:"Ukrainian"},{value:"Cantonese",label:"Cantonese"}],ws=[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"flac",label:"FLAC"}];function nt({open:n,onOpenChange:c,onSave:a}){const[d,x]=l.useState(""),[p,m]=l.useState("English_Trustworth_Man"),[v,j]=l.useState(!1),[E,y]=l.useState(""),[f,g]=l.useState(1),[w,_]=l.useState(0),[P,N]=l.useState("auto"),[b,K]=l.useState("English"),[k,M]=l.useState("mp3"),[G,h]=l.useState(null),[F,Y]=l.useState(!1),[U,B]=l.useState(!1),{toast:T}=Ie(),u=async()=>{if(!d.trim()){T({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}Y(!0),h(null);try{const o=v?E:p,Q=await fetch(`${J}/api/v1/resources/generate-audio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:d,voice_id:o,speed:f,pitch:w,emotion:P,language_boost:b,audio_format:k})}),r=await Q.json();if(!Q.ok||!r.success){const S=r.error?.message||"Failed to generate audio",A=r.error?.code==="MISSING_API_TOKEN";throw new Error(A?"Replicate API token not configured. Please add it in Settings → Integrations.":S)}h(r.data.audioUrl),T({title:"Audio generated",description:"Your audio has been generated successfully"})}catch(o){console.error("Generation error:",o),T({title:"Generation failed",description:o instanceof Error?o.message:"Failed to generate audio. Please try again.",variant:"destructive"})}finally{Y(!1)}},D=async()=>{if(G){B(!0);try{await a(G),x(""),m("English_Trustworth_Man"),j(!1),y(""),g(1),_(0),N("auto"),K("English"),M("mp3"),h(null),c(!1)}catch(o){T({title:"Save failed",description:o instanceof Error?o.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{B(!1)}}},H=()=>{!F&&!U&&c(!1)};return e.jsx(re,{open:n,onOpenChange:H,children:e.jsxs(ie,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{className:"text-base sm:text-lg",children:"Generate Audio"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:F?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(z,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):G?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(le,{className:"h-16 w-16 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-4 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:G,controls:!0,className:"w-full max-w-[90%]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(le,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[55vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"text-mobile",className:"text-xs",children:"Text"}),e.jsx(de,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:d,onChange:o=>x(o.target.value),rows:3,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Voice"}),e.jsxs(V,{value:v?"__custom__":p,onValueChange:o=>{o==="__custom__"?j(!0):(j(!1),m(o))},children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsxs($,{className:"max-h-60",children:[gs.map(o=>e.jsx(L,{value:o,className:"text-xs",children:o.replace(/_/g," ")},o)),e.jsx(L,{value:"__custom__",className:"text-xs font-medium",children:"Custom Voice ID..."})]})]}),v&&e.jsx(Ee,{placeholder:"Enter custom voice ID",value:E,onChange:o=>y(o.target.value),className:"h-8 text-xs mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs",children:["Speed: ",f.toFixed(1),"x"]}),e.jsx(we,{value:[f],onValueChange:([o])=>g(o),min:.5,max:2,step:.1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs",children:["Pitch: ",w>0?"+":"",w]}),e.jsx(we,{value:[w],onValueChange:([o])=>_(o),min:-12,max:12,step:1,className:"w-full"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Emotion"}),e.jsxs(V,{value:P,onValueChange:N,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:vs.map(o=>e.jsx(L,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Language"}),e.jsxs(V,{value:b,onValueChange:K,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:js.map(o=>e.jsx(L,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Format"}),e.jsxs(V,{value:k,onValueChange:M,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ws.map(o=>e.jsx(L,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{onClick:u,disabled:!d.trim()||F||U,className:"flex-1 h-9",size:"sm",children:F?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:D,disabled:!G||F||U,variant:"outline",className:"flex-1 h-9",size:"sm",children:U?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[30%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"text",children:"Text"}),e.jsx(de,{id:"text",placeholder:"Enter text to convert to speech...",value:d,onChange:o=>x(o.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Voice"}),e.jsxs(V,{value:v?"__custom__":p,onValueChange:o=>{o==="__custom__"?j(!0):(j(!1),m(o))},children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsxs($,{className:"max-h-80",children:[gs.map(o=>e.jsx(L,{value:o,children:o.replace(/_/g," ")},o)),e.jsx(L,{value:"__custom__",className:"font-medium",children:"Custom Voice ID..."})]})]}),v&&e.jsx(Ee,{placeholder:"Enter custom voice ID",value:E,onChange:o=>y(o.target.value),className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Speed: ",f.toFixed(1),"x"]}),e.jsx(we,{value:[f],onValueChange:([o])=>g(o),min:.5,max:2,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.5x"}),e.jsx("span",{children:"2x"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Pitch: ",w>0?"+":"",w]}),e.jsx(we,{value:[w],onValueChange:([o])=>_(o),min:-12,max:12,step:1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"-12"}),e.jsx("span",{children:"+12"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Emotion"}),e.jsxs(V,{value:P,onValueChange:N,children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsx($,{children:vs.map(o=>e.jsx(L,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Language Boost"}),e.jsxs(V,{value:b,onValueChange:K,children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsx($,{children:js.map(o=>e.jsx(L,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Audio Format"}),e.jsxs(V,{value:k,onValueChange:M,children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsx($,{children:ws.map(o=>e.jsx(L,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(I,{onClick:u,disabled:!d.trim()||F||U,className:"w-full",children:F?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:D,disabled:!G||F||U,variant:"outline",className:"w-full",children:U?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:F?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(z,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating audio..."})]}):G?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(le,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:G,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(le,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated audio will appear here"})]})})})]})]})})}const Ns=[{value:"5",label:"5 seconds"},{value:"8",label:"8 seconds"},{value:"10",label:"10 seconds"}],bs=[{value:"480p",label:"480p"},{value:"720p",label:"720p"},{value:"1080p",label:"1080p"}],ys=[{value:"16:9",label:"16:9 (Landscape)"},{value:"9:16",label:"9:16 (Portrait)"},{value:"1:1",label:"1:1 (Square)"}];function lt({open:n,onOpenChange:c,onSave:a}){const[d,x]=l.useState(""),[p,m]=l.useState("8"),[v,j]=l.useState("720p"),[E,y]=l.useState("16:9"),[f,g]=l.useState(!0),[w,_]=l.useState(null),[P,N]=l.useState(null),[b,K]=l.useState(null),[k,M]=l.useState(!1),[G,h]=l.useState(!1),[F,Y]=l.useState([]),{toast:U}=Ie();l.useEffect(()=>{n&&B()},[n]);const B=async()=>{try{const S=await(await fetch(`${J}/api/v1/resources`)).json();if(S.success){const A=(S.data||[]).filter(ee=>{const ue=ee.type==="image/jpeg"||ee.name.toLowerCase().endsWith(".jpg")||ee.name.toLowerCase().endsWith(".jpeg"),me=ee.type==="image/png"||ee.name.toLowerCase().endsWith(".png");return(ue||me)&&ee.thumbnailPath});Y(A)}}catch(r){console.error("Failed to fetch image resources:",r)}},T=r=>{r===P?N(null):r===w?(_(null),N(r)):w?N(r):_(r)},u=()=>{_(null),N(null)},D=async()=>{if(!d.trim()){U({title:"Prompt required",description:"Please enter a prompt to generate a video",variant:"destructive"});return}M(!0),K(null);try{const r=await fetch(`${J}/api/v1/resources/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d,image:w||void 0,last_frame:P||void 0,duration:parseInt(p),resolution:v,aspect_ratio:E,generate_audio:f})}),S=await r.json();if(!r.ok||!S.success){const A=S.error?.message||"Failed to generate video",ee=S.error?.code==="MISSING_API_TOKEN";throw new Error(ee?"Replicate API token not configured. Please add it in Settings → Integrations.":A)}K(S.data.videoUrl),U({title:"Video generated",description:"Your video has been generated successfully"})}catch(r){console.error("Generation error:",r),U({title:"Generation failed",description:r instanceof Error?r.message:"Failed to generate video. Please try again.",variant:"destructive"})}finally{M(!1)}},H=async()=>{if(b){h(!0);try{await a(b),x(""),m("8"),j("720p"),y("16:9"),g(!0),_(null),N(null),K(null),c(!1)}catch(r){U({title:"Save failed",description:r instanceof Error?r.message:"Failed to save video. Please try again.",variant:"destructive"})}finally{h(!1)}}},o=()=>{!k&&!G&&c(!1)},Q=r=>r===w?"start":r===P?"end":null;return e.jsx(re,{open:n,onOpenChange:o,children:e.jsxs(ie,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{className:"text-base sm:text-lg",children:"Generate Video"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(z,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):b?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:b,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(Fe,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsxs("div",{className:"border-t bg-background p-2 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 px-1",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:u,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${!w&&!P?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),F.map(r=>{const S=Q(r.id);return e.jsxs("button",{onClick:()=>T(r.id),className:`relative flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${S?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${J}/api/v1/resources/${r.id}/thumbnail`,alt:r.name,className:"w-full h-full object-cover"}),S&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-[10px] font-medium text-center py-0.5",children:S==="start"?"Start":"End"})]},r.id)})]})]}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[40vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(de,{id:"prompt-mobile",placeholder:"Describe the video you want to generate...",value:d,onChange:r=>x(r.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Duration"}),e.jsxs(V,{value:p,onValueChange:m,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:Ns.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Resolution"}),e.jsxs(V,{value:v,onValueChange:j,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:bs.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Ratio"}),e.jsxs(V,{value:E,onValueChange:y,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ys.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Me,{id:"generateAudio-mobile",checked:f,onCheckedChange:r=>g(r===!0)}),e.jsx(C,{htmlFor:"generateAudio-mobile",className:"text-xs cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{onClick:D,disabled:!d.trim()||k||G,className:"flex-1 h-9",size:"sm",children:k?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:H,disabled:!b||k||G,variant:"outline",className:"flex-1 h-9",size:"sm",children:G?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"prompt",children:"Prompt"}),e.jsx(de,{id:"prompt",placeholder:"Describe the video you want to generate...",value:d,onChange:r=>x(r.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"duration",children:"Duration"}),e.jsxs(V,{value:p,onValueChange:m,children:[e.jsx(W,{id:"duration",children:e.jsx(O,{})}),e.jsx($,{children:Ns.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(V,{value:v,onValueChange:j,children:[e.jsx(W,{id:"resolution",children:e.jsx(O,{})}),e.jsx($,{children:bs.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(V,{value:E,onValueChange:y,children:[e.jsx(W,{id:"aspectRatio",children:e.jsx(O,{})}),e.jsx($,{children:ys.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Me,{id:"generateAudio",checked:f,onCheckedChange:r=>g(r===!0)}),e.jsx(C,{htmlFor:"generateAudio",className:"cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(I,{onClick:D,disabled:!d.trim()||k||G,className:"w-full",children:k?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:H,disabled:!b||k||G,variant:"outline",className:"w-full",children:G?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(z,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating video..."})]}):b?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:b,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(Fe,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated video will appear here"})]})}),e.jsxs("div",{className:"border-t bg-background p-4 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:u,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${!w&&!P?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),F.map(r=>{const S=Q(r.id);return e.jsxs("button",{onClick:()=>T(r.id),className:`relative flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${S?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${J}/api/v1/resources/${r.id}/thumbnail`,alt:r.name,className:"w-full h-full object-cover"}),S&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-xs font-medium text-center py-1",children:S==="start"?"Start":"End"})]},r.id)})]})]})]})]})]})})}function rt({open:n,onOpenChange:c,resource:a,onCopyPath:d,onDownload:x,onNavigate:p,canNavigatePrev:m,canNavigateNext:v}){const[j,E]=l.useState(null),[y,f]=l.useState(!1),[g,w]=l.useState(!1);l.useEffect(()=>{w(!1)},[a?.id,n]);const _=a?`${J}/api/v1/resources/${a.id}`:"",P=a?.type.startsWith("image/")??!1,N=a?a.type==="image/svg+xml"||a.name.toLowerCase().endsWith(".svg"):!1,b=a?a.type==="application/pdf"||a.name.toLowerCase().endsWith(".pdf"):!1,K=a?.type.startsWith("video/")??!1,k=a?.type.startsWith("audio/")??!1,M=a?a.type.startsWith("text/")||a.type==="application/json"||a.type.includes("javascript")||a.type.includes("typescript")||a.type.includes("xml")||a.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,G=a?a.name.toLowerCase().endsWith(".md")||a.name.toLowerCase().endsWith(".markdown"):!1,h=a?a.type==="application/json"||a.name.toLowerCase().endsWith(".json"):!1,F=a?a.type==="text/html"||a.name.toLowerCase().endsWith(".html"):!1;if(l.useEffect(()=>{const u=D=>{if(n){if(D.key==="Escape"){g?w(!1):c(!1);return}if(!g){if(D.key==="ArrowLeft"&&m){D.preventDefault(),p("prev");return}D.key==="ArrowRight"&&v&&(D.preventDefault(),p("next"))}}};if(n)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[n,c,p,m,v,g]),l.useEffect(()=>{n&&a&&(M||G||h||F)?(f(!0),fetch(_).then(u=>{if(u.ok)return u.text();throw new Error("Failed to load file")}).then(u=>{E(u)}).catch(u=>{console.error("Failed to load text content:",u),E(null)}).finally(()=>{f(!1)})):E(null)},[n,a?.id,M,G,h,F,_]),!a)return null;const Y=u=>{if(u===0)return"0 B";const D=1024,H=["B","KB","MB","GB"],o=Math.floor(Math.log(u)/Math.log(D));return parseFloat((u/Math.pow(D,o)).toFixed(2))+" "+H[o]},U=u=>new Date(u).toLocaleString(),B=u=>u.startsWith("image/")?e.jsx(fe,{className:"h-6 w-6"}):u.startsWith("video/")?e.jsx(Fe,{className:"h-6 w-6"}):u.startsWith("audio/")?e.jsx(le,{className:"h-6 w-6"}):u.includes("text")||u.includes("document")||u.includes("code")?e.jsx(je,{className:"h-6 w-6"}):u.includes("json")||u.includes("javascript")||u.includes("typescript")?e.jsx($e,{className:"h-6 w-6"}):e.jsx(We,{className:"h-6 w-6"}),T=()=>{if(N)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:_,alt:a.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(I,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>w(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]});if(b)return e.jsx("iframe",{src:_,className:"w-full h-full min-h-[600px] rounded-lg border",title:a.name});if(K)return e.jsx("video",{src:_,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(k)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(le,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:_,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(G&&j!==null)return y?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(ia,{remarkPlugins:[ca],rehypePlugins:[oa],children:j})});if(F&&j!==null)return y?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:j,className:"w-full h-full min-h-[600px] rounded-lg border",title:a.name,sandbox:"allow-same-origin"});if(h&&j!==null){if(y)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let u=j;try{const D=JSON.parse(j);u=JSON.stringify(D,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:u})})})}return M&&j!==null?y?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:j})})}):P?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:_,alt:a.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(I,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>w(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[B(a.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(I,{variant:"outline",onClick:()=>x(a),children:[e.jsx(Oe,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return e.jsxs(e.Fragment,{children:[e.jsx(re,{open:n,onOpenChange:c,children:e.jsxs(ie,{className:"max-w-[90vw] w-[90vw] max-h-[90vh] h-[90vh] p-0 gap-0 flex flex-col [&>button]:hidden",children:[e.jsx(oe,{className:"px-6 pt-6 pb-4 border-b flex-shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[B(a.type),e.jsxs("div",{className:"flex-1 min-w-0 flex items-baseline gap-3",children:[e.jsx(ce,{className:"text-xl truncate",children:a.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:a.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>d(a),title:"Copy path to clipboard",children:e.jsx(Ss,{className:"h-4 w-4"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>x(a),title:"Download",children:e.jsx(Oe,{className:"h-4 w-4"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(!1),title:"Close",children:e.jsx(Xe,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 flex overflow-hidden",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden",children:[m&&e.jsx("button",{type:"button",onClick:()=>p("prev"),className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Previous resource",children:e.jsx(ks,{className:"h-5 w-5"})}),v&&e.jsx("button",{type:"button",onClick:()=>p("next"),className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Next resource",children:e.jsx(Cs,{className:"h-5 w-5"})}),T()]}),e.jsx("div",{className:"border-t p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:Y(a.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(va,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:U(a.uploadedAt)})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[a.metadata.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.metadata.description})]}),a.metadata.tags&&a.metadata.tags.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.metadata.tags.map(u=>e.jsx(Ne,{variant:"secondary",children:u},u))})]})]})]})})]})})]})}),g&&(P||N)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>w(!1),children:[e.jsx(I,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>w(!1),children:e.jsx(Xe,{className:"h-6 w-6"})}),e.jsx("img",{src:_,alt:a.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:u=>u.stopPropagation()})]})]})}function jt(){const[n,c]=l.useState([]),[a,d]=l.useState(!0),[x,p]=l.useState(!1),[m,v]=l.useState(""),[j,E]=l.useState(!1),[y,f]=l.useState([]),[g,w]=l.useState(""),[_,P]=l.useState(""),[N,b]=l.useState([]),[K,k]=l.useState(!1),[M,G]=l.useState(!1),[h,F]=l.useState(!1),[Y,U]=l.useState(null),[B,T]=l.useState(null),[u,D]=l.useState(null),[H,o]=l.useState(1),Q=12,r=l.useRef(null),{toast:S}=Ie();l.useEffect(()=>{A()},[]);const A=async()=>{try{d(!0);const i=await(await fetch(`${J}/api/v1/resources`)).json();i.success&&c(i.data||[])}catch(s){console.error("Failed to fetch resources:",s)}finally{d(!1)}},ee=s=>{s.length!==0&&b(Array.from(s))},ue=async()=>{if(N.length!==0){p(!0);try{for(const s of N){const i=new FormData;if(i.append("file",s),i.append("tags",y.join(", ")),i.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:i})).ok)throw new Error("Upload failed")}f([]),w(""),P(""),b([]),E(!1),await A(),S({title:"Upload successful",description:`${N.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),S({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{p(!1)}}},me=()=>{f([]),w(""),P(""),b([]),E(!1)},ye=s=>{if(s.key==="Enter"){s.preventDefault();const i=g.trim();i&&!y.includes(i)&&(f([...y,i]),w(""))}},_e=s=>{f(y.filter(i=>i!==s))},Re=s=>{b(N.filter((i,R)=>R!==s))},Se=async()=>{if(u)try{if((await fetch(`${J}/api/v1/resources/${u.id}`,{method:"DELETE"})).ok)await A(),S({title:"Resource deleted",description:`${u.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),S({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{D(null)}},ve=async s=>{try{const i=`.nut/resources/files/${s.path}`;await ga(i),S({title:"Path copied!",description:`Copied ${i} to clipboard`})}catch(i){console.error("Failed to copy path:",i),S({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},De=s=>{if(s===0)return"0 B";const i=1024,R=["B","KB","MB","GB"],q=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,q)).toFixed(2))+" "+R[q]},Te=(s,i)=>{const R=i.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||R.endsWith(".svg")?e.jsx(ns,{className:"h-4 w-4"}):e.jsx(fe,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(rs,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(ts,{className:"h-4 w-4"}):s==="application/pdf"||R.endsWith(".pdf")?e.jsx(je,{className:"h-4 w-4"}):R.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx($e,{className:"h-4 w-4"}):s==="application/json"||R.endsWith(".json")?e.jsx(ls,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||R.match(/\.(xls|xlsx|csv)$/)?e.jsx(is,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||R.match(/\.(ppt|pptx)$/)?e.jsx(ds,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(je,{className:"h-4 w-4"}):s.includes("font")||R.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(os,{className:"h-4 w-4"}):e.jsx(We,{className:"h-4 w-4"})},t=(s,i)=>{const R=i.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||R.endsWith(".svg")?e.jsx(ns,{className:"h-16 w-16"}):e.jsx(fe,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(rs,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(ts,{className:"h-16 w-16"}):s==="application/pdf"||R.endsWith(".pdf")?e.jsx(je,{className:"h-16 w-16"}):R.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx($e,{className:"h-16 w-16"}):s==="application/json"||R.endsWith(".json")?e.jsx(ls,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||R.match(/\.(xls|xlsx|csv)$/)?e.jsx(is,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||R.match(/\.(ppt|pptx)$/)?e.jsx(ds,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(je,{className:"h-16 w-16"}):s.includes("font")||R.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(os,{className:"h-16 w-16"}):e.jsx(We,{className:"h-16 w-16"})},X=s=>{const i=s.name.toLowerCase(),R=s.type.startsWith("image/");return s.type==="image/svg+xml"||i.endsWith(".svg")?e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/30 rounded-md border overflow-hidden p-2",children:e.jsx("img",{src:`${J}/api/v1/resources/${s.id}`,alt:s.name,className:"w-full h-full object-contain"})}):R&&s.thumbnailPath?e.jsx("img",{src:`${J}/api/v1/resources/${s.id}/thumbnail`,alt:s.name,className:"w-full h-32 object-cover rounded-md border",onError:te=>{te.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/50 rounded-md border",children:e.jsx("div",{className:"text-muted-foreground",children:t(s.type,s.name)})})},Z=n.filter(s=>{if(!m)return!0;const i=m.toLowerCase();return s.name.toLowerCase().includes(i)||s.metadata.description?.toLowerCase().includes(i)||s.metadata.tags?.some(R=>R.toLowerCase().includes(i))}),ae=Math.ceil(Z.length/Q),he=(H-1)*Q,Ae=Z.slice(he,he+Q);l.useEffect(()=>{o(1)},[m]);const Us=s=>{s.preventDefault(),s.stopPropagation()},zs=s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&ee(s.dataTransfer.files)},Hs=(s,i)=>{if(i.target.closest("button"))return;U(s);const q=Z.findIndex(te=>te.id===s.id);T(q>=0?q:null)},Je=s=>{window.open(`${J}/api/v1/resources/${s.id}?download=true`)},Ys=async s=>{p(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated image");const R=await i.blob(),q=`generated-image-${Date.now()}.png`,te=new FormData;if(te.append("file",R,q),te.append("tags",y.join(",")),te.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:te})).ok)throw new Error("Upload failed");await A(),S({title:"Image saved",description:"Generated image has been saved to resources"})}catch(i){throw console.error("Failed to save generated image:",i),S({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated image",variant:"destructive"}),i}finally{p(!1)}},Js=s=>{window.dispatchEvent(new CustomEvent("customize-prompt-in-assistant",{detail:{prompt:s}}))},Qs=async s=>{p(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated audio");const R=await i.blob();let q="mp3";const te=i.headers.get("content-type");te?.includes("wav")?q="wav":te?.includes("flac")?q="flac":s.includes(".wav")?q="wav":s.includes(".flac")&&(q="flac");const Ce=`generated-audio-${Date.now()}.${q}`,ne=new FormData;if(ne.append("file",R,Ce),ne.append("tags",y.join(",")),ne.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:ne})).ok)throw new Error("Upload failed");await A(),S({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(i){throw console.error("Failed to save generated audio:",i),S({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated audio",variant:"destructive"}),i}finally{p(!1)}},qs=async s=>{p(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated video");const R=await i.blob();let q="mp4";(i.headers.get("content-type")?.includes("webm")||s.includes(".webm"))&&(q="webm");const Ce=`generated-video-${Date.now()}.${q}`,ne=new FormData;if(ne.append("file",R,Ce),ne.append("tags",y.join(",")),ne.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:ne})).ok)throw new Error("Upload failed");await A(),S({title:"Video saved",description:"Generated video has been saved to resources"})}catch(i){throw console.error("Failed to save generated video:",i),S({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated video",variant:"destructive"}),i}finally{p(!1)}},Xs=s=>{if(B===null)return;const i=s==="next"?B+1:B-1;if(i<0||i>=Z.length)return;const R=Z[i];T(i),U(R)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Resources"}),e.jsx("p",{className:"text-muted-foreground",children:"Upload and generate media assets for your project"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(da,{children:[e.jsx(ua,{asChild:!0,children:e.jsxs(I,{variant:"outline",size:"sm",children:[e.jsx(ke,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Generate"}),e.jsx(ma,{className:"h-3 w-3 ml-1 opacity-50"})]})}),e.jsxs(ha,{align:"end",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:[e.jsxs(Le,{onClick:()=>k(!0),children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Image"]}),e.jsxs(Le,{onClick:()=>G(!0),children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Audio"]}),e.jsxs(Le,{onClick:()=>F(!0),children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Video"]})]})]}),e.jsxs(I,{size:"sm",onClick:()=>E(!j),children:[e.jsx(as,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Upload Resources"})]})]})]}),e.jsx(re,{open:j,onOpenChange:s=>!s&&me(),children:e.jsxs(ie,{className:"max-w-2xl",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Upload Resource"}),e.jsx(Ze,{children:"Add files to your project resources"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-muted-foreground/50 transition-colors",onDragOver:Us,onDrop:zs,onClick:()=>r.current?.click(),children:[e.jsx(Ra,{className:"mx-auto h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"mt-2 text-sm font-medium",children:"Drop files here or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Support for images, documents, and other files"})]}),e.jsx("input",{ref:r,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&ee(s.target.files)}),N.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Selected Files (",N.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:N.map((s,i)=>e.jsxs("div",{className:"flex items-center justify-between text-sm bg-muted/50 rounded px-3 py-2",children:[e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Re(i),className:"h-6 w-6 p-0 ml-2",children:e.jsx(es,{className:"h-3 w-3"})})]},i))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"tags",children:"Tags"}),e.jsx(Ee,{id:"tags",placeholder:"Type a tag and press Enter",value:g,onChange:s=>w(s.target.value),onKeyDown:ye}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:y.map(s=>e.jsxs(Ne,{variant:"secondary",className:"text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>_e(s),className:"ml-1 hover:text-destructive",children:"×"})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",placeholder:"Brief description of this resource...",value:_,onChange:s=>P(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(I,{variant:"outline",onClick:me,disabled:x,children:"Cancel"}),e.jsx(I,{onClick:ue,disabled:N.length===0||x,children:x?"Uploading...":`Upload ${N.length>0?`(${N.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(ja,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ee,{placeholder:"Search resources...",value:m,onChange:s=>v(s.target.value),className:"pl-8"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:a?Array.from({length:6}).map((s,i)=>e.jsxs(Ke,{className:"animate-pulse",children:[e.jsxs(ss,{children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]}),e.jsx(Ve,{children:e.jsx("div",{className:"h-20 bg-muted rounded"})})]},i)):Z.length>0?Ae.map(s=>e.jsxs(Ke,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:i=>Hs(s,i),children:[e.jsxs(ss,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[Te(s.type,s.name),e.jsx(fa,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(pa,{className:"text-xs",children:[De(s.size)," • ",new Date(s.uploadedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex justify-end space-x-1 mt-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),ve(s)},title:"Copy path to clipboard",children:e.jsx(Ss,{className:"h-3 w-3"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),Je(s)},children:e.jsx(Oe,{className:"h-3 w-3"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),D(s)},children:e.jsx(es,{className:"h-3 w-3"})})]})]}),e.jsxs(Ve,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:X(s)}),s.metadata.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:s.metadata.description}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(i=>e.jsx(Ne,{variant:"secondary",className:"text-xs",children:i},i))})]})]},s.id)):e.jsx("div",{className:"col-span-full",children:e.jsx(Ke,{children:e.jsxs(Ve,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xa,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No resources yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground text-center max-w-sm",children:"Upload files to get started. Resources can be referenced by LLMs and team members for enhanced context."}),e.jsxs(I,{className:"mt-4",onClick:()=>E(!0),children:[e.jsx(as,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),Z.length>Q&&e.jsxs("div",{className:"flex items-center justify-center gap-4 pt-4 pb-8",children:[e.jsxs(I,{variant:H===1?"outline":"default",size:"sm",onClick:()=>o(s=>Math.max(1,s-1)),disabled:H===1,children:[e.jsx(ks,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",H," of ",ae]}),e.jsxs(I,{variant:H===ae?"outline":"default",size:"sm",onClick:()=>o(s=>Math.min(ae,s+1)),disabled:H===ae,children:["Next",e.jsx(Cs,{className:"h-4 w-4 ml-1"})]})]}),x&&e.jsx("div",{className:"fixed bottom-4 right-4 bg-background border rounded-lg shadow-lg p-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),e.jsx("span",{className:"text-sm",children:"Uploading files..."})]})}),e.jsx(Ka,{open:K,onOpenChange:k,onSave:Ys,onCustomizeInAssistant:Js}),e.jsx(nt,{open:M,onOpenChange:G,onSave:Qs}),e.jsx(lt,{open:h,onOpenChange:F,onSave:qs}),e.jsx(rt,{open:!!Y,onOpenChange:s=>{s||U(null),s||T(null)},resource:Y,onCopyPath:ve,onDownload:Je,onNavigate:Xs,canNavigatePrev:B!==null&&B>0,canNavigateNext:B!==null&&B<Z.length-1}),e.jsx(re,{open:!!u,onOpenChange:s=>!s&&D(null),children:e.jsxs(ie,{className:"max-w-md",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Delete Resource"}),e.jsxs(Ze,{children:["Are you sure you want to delete ",e.jsx("strong",{children:u?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(I,{variant:"outline",onClick:()=>D(null),children:"Cancel"}),e.jsx(I,{variant:"destructive",onClick:Se,children:"Delete"})]})]})})]})}export{jt as default};
|